Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
drupal.org
better_formats
Commits
b51ceef4
Commit
b51ceef4
authored
Dec 24, 2008
by
dragonwize
Browse files
More fixes and enhancements to the JS helper for the content type form
parent
312a75cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
35 deletions
+47
-35
better_formats_node_type_form.js
better_formats_node_type_form.js
+47
-35
No files found.
better_formats_node_type_form.js
View file @
b51ceef4
...
...
@@ -9,47 +9,59 @@
* Also hides formats that are not available per the Allowed checkboxes.
*/
function
better_formats_toggle_formats
(
el
)
{
$
(
'
select.bf-default-formats option
'
).
each
(
function
()
{
function
better_formats_init
()
{
// set default settings check for use of global allowed formats
Drupal
.
settings
.
better_formats
=
{
"
num_checked
"
:
$
(
'
input.bf-allowed-formats:checked
'
).
length
};
// collapsing the input format setting after the weight columns have been hidden
$
(
'
.input-format-settings > legend > a
'
).
click
();
// add hide/show events for allowed formats
var
format_boxes
=
$
(
'
input.bf-allowed-formats
'
);
format_boxes
.
click
(
function
()
{
better_formats_toggle_formats
(
$
(
this
));
});
if
(
Drupal
.
settings
.
better_formats
.
num_checked
>
0
)
{
format_boxes
.
each
(
function
()
{
better_formats_toggle_formats
(
$
(
this
),
true
);
});
}
}
function
better_formats_toggle_formats
(
el
,
init
)
{
// hide all formats except site default when the first box is checked
if
(
Drupal
.
settings
.
better_formats
.
num_checked
===
0
)
{
$
(
'
select.bf-default-formats option[value != "0"][value != "
'
+
el
.
val
()
+
'
"]
'
).
removeAttr
(
'
selected
'
).
hide
();
}
$
(
'
select.bf-default-formats option[value = "
'
+
el
.
val
()
+
'
"]
'
).
each
(
function
()
{
var
option
=
$
(
this
);
if
(
option
.
val
()
==
el
.
val
())
{
if
(
el
.
attr
(
'
checked
'
))
{
// hide all formats except site default when the first box is checked
if
(
Drupal
.
settings
.
better_formats
.
num_checked
===
0
)
{
$
(
'
select.bf-default-formats option[value != "0"]
'
).
hide
();
}
Drupal
.
settings
.
better_formats
.
num_checked
+=
1
;
option
.
show
();
}
else
{
}
else
{
option
.
removeAttr
(
'
selected
'
).
hide
();
// keep num_checked from going below zero
if
(
Drupal
.
settings
.
better_formats
.
num_checked
>
0
)
{
Drupal
.
settings
.
better_formats
.
num_checked
-=
1
;
}
// show all globally allowed formats if no boxes are checked
if
(
Drupal
.
settings
.
better_formats
.
num_checked
===
0
)
{
// show global formats available to roles
// because no format allowed boxes are checked
$
(
'
select.bf-default-formats option
'
).
show
();
}
}
}
});
// do not modify count on intial run
if
(
!
init
)
{
if
(
el
.
attr
(
'
checked
'
))
{
Drupal
.
settings
.
better_formats
.
num_checked
+=
1
;
}
else
if
(
Drupal
.
settings
.
better_formats
.
num_checked
>
0
)
{
// keep num_checked from going below zero
Drupal
.
settings
.
better_formats
.
num_checked
-=
1
;
}
}
// show all globally allowed formats if no boxes are checked
if
(
Drupal
.
settings
.
better_formats
.
num_checked
===
0
)
{
// show global formats available to roles
// because no format allowed boxes are checked
$
(
'
select.bf-default-formats option
'
).
show
();
}
}
function
better_formats_show_global_formats
()
{
$
(
'
select.bf-default-formats option
'
).
show
();
}
$
(
document
).
ready
(
function
()
{
// set default settings check for use of global allowed formats
Drupal
.
settings
.
better_formats
=
{
"
num_checked
"
:
0
};
// collapsing the input format setting after the weight columns have been hidden
$
(
'
.input-format-settings > legend > a
'
).
click
();
// add hide/show events for allowed formats
$
(
'
input.bf-allowed-formats
'
).
click
(
function
()
{
better_formats_toggle_formats
(
$
(
this
));
}).
each
(
function
()
{
better_formats_toggle_formats
(
$
(
this
));
});
});
\ No newline at end of file
$
(
document
).
ready
(
better_formats_init
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment