/* Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ jQuery(document).ready(function() { function Tools(event, ui) { //outer loop for rows var tools = "[\n"; rows = jQuery("#groupLayout div.sortableListDiv").length; jQuery.each(jQuery("#groupLayout div.sortableListDiv"), function(rowIndex, rowValue) { if (jQuery("li",rowValue).length > 0) { tools = tools + " ["; } //inner loop for toolbar buttons jQuery.each(jQuery("li",rowValue), function(buttonIndex, buttonValue) { if (jQuery(buttonValue).hasClass('spacer')) { tools = tools + ",'-'"; } else if (jQuery(buttonValue).hasClass('group')) { tools = tools + "],\n ["; } else { tools = tools + ",'" + jQuery(buttonValue).attr('id') + "'" ; } }); if (jQuery("li" ,rowValue).length > 0) { if (rowIndex < (rows -1)) { tools = tools + "],\n '/',\n"; } else { tools = tools + "]\n"; } } }); tools = tools + "]"; tools = tools.replace(/\[,/g, '['); tools = tools.replace(/\[],/g, ''); jQuery("#edit-toolbar").val(tools); } Drupal.ckeditorToolbaInit = function() { Drupal.ckeditorToolbarUsedRender(); Drupal.ckeditorToolbarAllRender(); var firefox = navigator.userAgent.toLowerCase().match(/firefox\/[0-9]\./); jQuery(".sortableList").sortable({ connectWith: ".sortableList", items: "div.sortableListDiv", sort: function(event, ui) { if (firefox){ ui.helper.css({'top' : ui.position.top - 35 + 'px'}); } }, stop: function(event, ui) { Tools(event, ui); } }).disableSelection(); jQuery(".sortableRow").sortable({ connectWith: ".sortableRow", items: "li.sortableItem", sort: function(event, ui) { if (firefox){ ui.helper.css({'top' : ui.position.top - 35 + 'px'}); } }, stop: function(event, ui) { Tools(event, ui); } }).disableSelection(); jQuery("li.sortableItem").mouseover(function(){ jQuery(".sortableList").sortable("disable"); }); jQuery("li.sortableItem").mouseout(function(){ jQuery(".sortableList").sortable("enable"); }); } Drupal.ckeditorToolbarReload = function() { jQuery(".sortableList").sortable('destroy'); jQuery(".sortableRow").sortable('destroy'); jQuery("li.sortableItem").unbind(); Drupal.ckeditorToolbaInit(); } Drupal.ckeditorToolbarUsedRender = function() { var toolbar = jQuery('#edit-toolbar').val(); toolbar = eval(toolbar); var html = '