diff --git a/wysiwyg.admin.inc b/wysiwyg.admin.inc index bc3e5ec..eba038b --- a/wysiwyg.admin.inc +++ b/wysiwyg.admin.inc @@ -112,6 +112,9 @@ function wysiwyg_profile_form($form, &$form_state, $profile) { '#collapsible' => FALSE, '#tree' => TRUE, '#theme' => 'wysiwyg_admin_button_table', + '#attached' => array( + 'js' => array(drupal_get_path('module', 'wysiwyg') . '/wysiwyg.admin.js'), + ), ); $plugins = wysiwyg_get_plugins($profile->editor); @@ -297,9 +300,23 @@ function theme_wysiwyg_admin_button_table($variables) { $rows[] = $row; } - $output = theme('table', array('rows' => $rows, 'attributes' => array('width' => '100%'))); + $output = array( + 'table' => array( + '#theme' => 'table', + '#rows' => $rows, + '#attributes' => array( + 'class' => array('wysiwyg-button-table'), + 'width' => '100%' + ) + ), + 'actions' => array( + '#prefix' => l(t('Select All'), '', array('attributes' => array('id' => 'wysiwyg-select-all', 'class' => 'wysiwyg-select'), 'fragment' => 'all')), + '#markup' => ' | ', + '#suffix' => l(t('Select None'), '', array('attributes' => array('id' => 'wysiwyg-select-none', 'class' => 'wysiwyg-select'), 'fragment' => 'none')) + ) + ); - return $output; + return render($output); } /** diff --git a/wysiwyg.admin.js b/wysiwyg.admin.js new file mode 100644 index 0000000..7d68585 --- /dev/null +++ b/wysiwyg.admin.js @@ -0,0 +1,28 @@ +(function ($) { + + /** + * Toggle button table checkbox state. + */ + function wysiwygToggleButtons(state) { + $('.wysiwyg-button-table input:checkbox').attr('checked', state); + } + + /** + * WYSIWYG admin behaviors. + */ + Drupal.behaviors.wysiwygAdmin = { + attach: function(context) { + $('.wysiwyg-select', context).click(function(e) { + e.preventDefault(); + + var state = ($(this).attr('id') == 'wysiwyg-select-all') ? true : false; + wysiwygToggleButtons(state); + }); + }, + + detach: function () { + wysiwygToggleButtons(false); + } + } + +})(jQuery);