diff --git editors/ckeditor.inc editors/ckeditor.inc
index 90bb277..ded6dd4 100644
--- editors/ckeditor.inc
+++ editors/ckeditor.inc
@@ -250,9 +250,6 @@ function wysiwyg_ckeditor_settings($editor, $config, $theme) {
$settings['extraPlugins'] = implode(',', array_unique($extra_plugins));
}
- // For now, all buttons are placed into one row.
- $settings['toolbar'] = array($settings['toolbar']);
-
return $settings;
}
diff --git wysiwyg.admin.css wysiwyg.admin.css
index 7b4a295..420d83f 100644
--- wysiwyg.admin.css
+++ wysiwyg.admin.css
@@ -1,5 +1,3 @@
-/* $Id$ */
-
#toolbar-rows {
margin: 1em 0;
}
@@ -45,7 +43,7 @@
#wysiwyg-toolbar-designer .add {
display: inline-block;
background: transparent url(images/add.png) no-repeat;
- width: 16px;
+ text-indent: 18px;
height: 16px;
text-decoration: none;
outline: none;
diff --git wysiwyg.admin.inc wysiwyg.admin.inc
index 83e6744..f3dacf2 100644
--- wysiwyg.admin.inc
+++ wysiwyg.admin.inc
@@ -189,18 +189,18 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'#attributes' => array('class' => array('wysiwyg-button', 'wysiwyg-button-' . $button['plugin'] . '-' . $button['button'])),
);
}
- $form['toolbar_designer']['toolbar'] = array(
+ $form['toolbar_designer']['stage'] = array(
'#type' => 'item',
'#title' => t('Toolbar'),
);
- $form['toolbar_designer']['toolbar']['toolbar'] = array(
+ $form['toolbar_designer']['stage']['rows'] = array(
'#markup' => '
',
);
- $form['toolbar_designer']['toolbar']['actions'] = array(
+ $form['toolbar_designer']['stage']['actions'] = array(
'#type' => 'container',
'#id' => 'toolbar-actions',
);
- $form['toolbar_designer']['toolbar']['actions']['add-row'] = array(
+ $form['toolbar_designer']['stage']['actions']['add-row'] = array(
'#type' => 'link',
'#title' => t('Add new row'),
'#href' => '#',
@@ -208,7 +208,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
'class' => array('add', 'add-toolbar-row'),
),
);
- $form['toolbar_designer']['toolbar']['templates'] = array(
+ $form['toolbar_designer']['stage']['templates'] = array(
'#markup' => '
@@ -219,6 +219,10 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
',
);
+ $form['toolbar_designer']['change_notification'] = array(
+ '#markup' => '
*' . t('Changes made to this toolbar will not be saved until the form is submitted.') . '
',
+ );
+
$form['toolbar_designer']['#attached']['js'][] = array(
'data' => array('wysiwyg_toolbar' => $toolbar_support),
'type' => 'setting',
@@ -227,7 +231,7 @@ function wysiwyg_profile_form($form, &$form_state, $profile) {
$form['toolbar_designer']['#attached']['library'][] = array('system', 'ui.sortable');
$form['toolbar_designer']['#attached']['js'][] = $module_path . '/wysiwyg.admin.js';
$form['toolbar_designer']['#attached']['css'][] = $module_path . '/wysiwyg.admin.css';
- $form['toolbar_designer']['_toolbar'] = array(
+ $form['toolbar_designer']['toolbar'] = array(
'#type' => 'hidden',
'#attributes' => array('id' => 'edit-toolbar'),
);
@@ -398,8 +402,8 @@ function wysiwyg_profile_form_submit($form, &$form_state) {
$values['extensions'] = array();
}
- // Restore toolbar array
- $raw_toolbar = explode("\n", trim($values['toolbar']));
+ // Restore toolbar array.
+ $raw_toolbar = explode("\n", trim(preg_replace('/\r/','', $values['toolbar'])));
$values['toolbar'] = array();
foreach ($raw_toolbar as $raw_row) {
$row = array();
diff --git wysiwyg.admin.js wysiwyg.admin.js
index 6b153d1..56340f3 100644
--- wysiwyg.admin.js
+++ wysiwyg.admin.js
@@ -1,4 +1,3 @@
-// $Id$
(function ($, undefined) {
Drupal.behaviors.wysiwygToolbarDesigner = {
@@ -6,9 +5,9 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
var settings = settings.wysiwyg_toolbar;
var workspace = $('#wysiwyg-toolbar-designer');
var designArea = $('#toolbar-rows');
- var changeNotification = $('#wysiwyg-toolbar-designer div.warning');
+ var changeNotification = $('#wysiwyg-toolbar-designer div.toolbar-changed-warning');
var availableButtons = $('#toolbar-available-buttons');
- var separator = $('.wysiwyg-button-default-Separator',availableButtons);
+ var separator = $('.wysiwyg-button-default-separator', availableButtons);
var createRow = function(noGroup) {
var row = $('.toolbar-row-template',workspace).clone().removeClass('toolbar-row-template');
@@ -27,6 +26,7 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
var group = createGroup();
row.append(group);
row.sortable('refresh');
+ changeNotification.fadeIn();
return false;
});
}
@@ -52,22 +52,19 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
addClasses: false,
stop: function(event,ui) {
changeNotification.fadeIn();
+ },
+ beforeStop: function(event, ui) {
+ // ui.item is the clone of an available button dragged to this group.
+ ui.item.removeClass('template-button').addClass('toolbar-button');
+ },
+ receive: function(event, ui) {
+ // ui.sender is posibly the available button which was cloned and
+ // and dragged to this group. Separators can be used multiple times.
+ if (ui.sender.hasClass('template-button') && !ui.sender.hasClass('wysiwyg-button-default-separator')) {
+ ui.sender.hide();
+ }
}
- });
-
- group.droppable({
- accept: '.template-button',
- drop: function(event,ui) {
- var button = ui.draggable.clone();
- button.removeClass('template-button').addClass('toolbar-button');
-
- // Disable this button in template area.
- ui.draggable.hide();
- separator.show();
- $(this).append(button).sortable('refresh');
- changeNotification.fadeIn();
- }
});
return group;
}
@@ -124,6 +121,7 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
$('.wysiwyg-button',availableButtons).addClass('template-button').draggable({
handle: '.handler',
helper: 'clone',
+ connectToSortable: '.toolbar-group',
revert: 'invalid',
addClasses: false
});
@@ -143,7 +141,7 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
var buttons = $('.toolbar-button', item);
if (item.hasClass('toolbar-button')) {
- buttons.add(item);
+ buttons = buttons.add(item);
}
// Remove each button and enable in template.
@@ -177,21 +175,25 @@ Drupal.behaviors.wysiwygToolbarDesigner = {
$('#wysiwyg-profile-form').submit(function() {
// Prepare toolbar data to submit.
- var toolbar = "";
+ var toolbar = [];
designArea.find('.toolbar-row').each(function(key,rowDom){
- var row = "";
+ var row = [];
$('.toolbar-group',rowDom).each(function(key,groupDom){
- var group = "";
+ var group = [];
$('.wysiwyg-button',groupDom).each(function(key,button){
var cls = /wysiwyg-button-([^-]+)-([^\s]+)/.exec($(button).attr('class'));
- group += cls[1] + "." + cls[2] + ",";
+ group.push(cls[1] + "." + cls[2]);
})
- row += group + "|";
+ if (group.length > 0) {
+ row.push(group.join(','));
+ }
});
- toolbar += row + "\n";
+ if (row.length > 0) {
+ toolbar.push(row.join('|'));
+ }
});
// Assign to hidden field.
- $('#edit-toolbar').val(toolbar);
+ $('#edit-toolbar').val(toolbar.join('\n'));
});
reset();
diff --git wysiwyg.module wysiwyg.module
index 75318b0..aefa7ca 100644
--- wysiwyg.module
+++ wysiwyg.module
@@ -465,7 +465,7 @@ function wysiwyg_add_plugin_settings($profile) {
if ($plugin === $proxy) {
continue;
}
- $profile_plugins_native[$plugin] = $plugins[$plugin];
+ $profile_plugins_native[$plugin] = $plugins[$editor['name']][$plugin];
}
}
}