/* 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").attr('value', 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 = '
'; jQuery('#groupLayout').empty().append(html); } Drupal.ckeditorToolbarAllRender = function() { var toolbarUsed = jQuery('#edit-toolbar').val(); var toolbarAll = Drupal.settings.cke_toolbar_buttons_all; var htmlArray = new Array(); var html = ''; for (var i in toolbarAll) { if (new RegExp("\'[\s]*" + toolbarAll[i].name + "[\s]*\'").test(toolbarUsed) == false) { if (toolbarAll[i].name == false) continue; if (typeof htmlArray[toolbarAll[i].row] == 'undefined') htmlArray[toolbarAll[i].row] = ''; htmlArray[toolbarAll[i].row] += '
  • ' + toolbarAll[i].title + '
  • '; } } if (typeof htmlArray[5] == 'undefined') htmlArray[5] = ''; htmlArray[5] += '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • ' + toolbarAll['__group'].title + '
  • '; if (typeof htmlArray[6] == 'undefined') htmlArray[6] = ''; htmlArray[6] += '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • ' + toolbarAll['__spacer'].title + '
  • '; if (typeof htmlArray[7] == 'undefined') htmlArray[7] = ''; for (var j in htmlArray){ html += '
    '; } jQuery('#allButtons').empty().append(html); } Drupal.ckeditorToolbaInit(); });