[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ckeditor/includes/jqueryUI/ -> sort.js (source)

   1  /*
   2  Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
   3  For licensing, see LICENSE.html or http://ckeditor.com/license
   4  */
   5  jQuery(document).ready(function() {
   6      function Tools(event, ui) {
   7          //outer loop for rows
   8          var tools = "[\n";
   9          rows = jQuery("#groupLayout div.sortableListDiv").length;
  10          jQuery.each(jQuery("#groupLayout div.sortableListDiv"), function(rowIndex, rowValue) {
  11              if (jQuery("li",rowValue).length > 0) {
  12                  tools = tools + "    [";
  13              }
  14              //inner loop for toolbar buttons
  15              jQuery.each(jQuery("li",rowValue), function(buttonIndex, buttonValue) {
  16                  if (jQuery(buttonValue).hasClass('spacer')) {
  17                      tools = tools + ",'-'";
  18                  }
  19                  else if (jQuery(buttonValue).hasClass('group')) {
  20                      tools = tools + "],\n    [";
  21                  }
  22                  else {
  23                      tools = tools + ",'" + jQuery(buttonValue).attr('id') + "'" ;
  24                  }
  25              });
  26  
  27              if (jQuery("li" ,rowValue).length > 0) {
  28                  if (rowIndex < (rows -1)) {
  29                      tools = tools + "],\n    '/',\n";
  30                  }
  31                  else {
  32                      tools = tools + "]\n";
  33                  }
  34              }
  35          });
  36          tools = tools + "]";
  37          tools = tools.replace(/\[,/g, '[');
  38          tools = tools.replace(/\[],/g, '');
  39          jQuery("#edit-toolbar").attr('value', tools);
  40      }
  41  
  42      Drupal.ckeditorToolbaInit = function() {
  43          Drupal.ckeditorToolbarUsedRender();
  44          Drupal.ckeditorToolbarAllRender();
  45  
  46          var firefox = navigator.userAgent.toLowerCase().match(/firefox\/[0-9]\./);
  47          jQuery(".sortableList").sortable({
  48              connectWith: ".sortableList",
  49              items: "div.sortableListDiv",
  50              sort: function(event, ui) {
  51                  if (firefox){
  52                      ui.helper.css({'top' : ui.position.top - 35 + 'px'});
  53                  }
  54              },
  55              stop: function(event, ui) {
  56                  Tools(event, ui);
  57              }
  58          }).disableSelection();
  59  
  60          jQuery(".sortableRow").sortable({
  61              connectWith: ".sortableRow",
  62              items: "li.sortableItem",
  63              sort: function(event, ui) {
  64                  if (firefox){
  65                      ui.helper.css({'top' : ui.position.top - 35 + 'px'});
  66                  }
  67              },
  68              stop: function(event, ui) {
  69                  Tools(event, ui);
  70              }
  71          }).disableSelection();
  72  
  73          jQuery("li.sortableItem").mouseover(function(){
  74              jQuery(".sortableList").sortable("disable");
  75          });
  76          jQuery("li.sortableItem").mouseout(function(){
  77              jQuery(".sortableList").sortable("enable");
  78          });
  79      }
  80  
  81      Drupal.ckeditorToolbarReload = function() {
  82          jQuery(".sortableList").sortable('destroy');
  83          jQuery(".sortableRow").sortable('destroy');
  84          jQuery("li.sortableItem").unbind();
  85          Drupal.ckeditorToolbaInit();
  86      }
  87  
  88      Drupal.ckeditorToolbarUsedRender = function() {
  89          var toolbar = jQuery('#edit-toolbar').val();
  90          toolbar = eval(toolbar);
  91          var html = '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">';
  92          var group = false;
  93  
  94          for (var row in toolbar) {
  95              if (typeof toolbar[row] == 'string' && toolbar[row] == '/') {
  96                  group = false;
  97                  html += '</ul></span></div><div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">';
  98              }
  99              else {
 100                  if (group == false){
 101                      group = true;
 102                  }
 103                  else {
 104                      html += '<li class="sortableItem group"><img src="' + Drupal.settings.cke_toolbar_buttons_all['__group']['icon'] + '" alt="group" title="group" /></li>';
 105                  }
 106                  for (var button in toolbar[row]) {
 107                      if (toolbar[row][button] == '-') {
 108                          html += '<li class="sortableItem spacer"><img src="' + Drupal.settings.cke_toolbar_buttons_all['__spacer']['icon'] + '" alt="spacer" title="spacer" /></li>';
 109                      }
 110                      else if (Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]) {
 111                          html += '<li class="sortableItem" id="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['name'] + '"><img src="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['icon'] + '" alt="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['title'] + '" title="' + Drupal.settings.cke_toolbar_buttons_all[toolbar[row][button]]['title'] + '" /></li>';
 112                      }
 113                  }
 114              }
 115          }
 116          html += '</ul></span></div>';
 117          jQuery('#groupLayout').empty().append(html);
 118      }
 119  
 120      Drupal.ckeditorToolbarAllRender = function() {
 121          var toolbarUsed = jQuery('#edit-toolbar').val();
 122          var toolbarAll = Drupal.settings.cke_toolbar_buttons_all;
 123  
 124          var htmlArray = new Array();
 125          var html = '';
 126  
 127          for (var i in toolbarAll) {
 128              if (new RegExp("\'[\s]*" + toolbarAll[i].name + "[\s]*\'").test(toolbarUsed) == false) {
 129                  if (toolbarAll[i].name == false) continue;
 130                  if (typeof htmlArray[toolbarAll[i].row] == 'undefined') htmlArray[toolbarAll[i].row] = '';
 131                  htmlArray[toolbarAll[i].row] += '<li class="sortableItem" id="' + toolbarAll[i].name + '"><img src="' + toolbarAll[i].icon + '" alt="' + toolbarAll[i].title + '" title="' + toolbarAll[i].title + '" /></li>';
 132              }
 133          }
 134  
 135          if (typeof htmlArray[5] == 'undefined') htmlArray[5] = '';
 136          htmlArray[5] += '<li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li><li class="sortableItem group"><img src="' + toolbarAll['__group'].icon + '" alt="' + toolbarAll['__group'].title + '" title="' + toolbarAll['__group'].title + '" /></li>';
 137  
 138          if (typeof htmlArray[6] == 'undefined') htmlArray[6] = '';
 139          htmlArray[6] += '<li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li><li class="sortableItem spacer"><img src="' + toolbarAll['__spacer'].icon + '" alt="' + toolbarAll['__spacer'].title + '" title="' + toolbarAll['__spacer'].title + '" /></li>';
 140  
 141          if (typeof htmlArray[7] == 'undefined') htmlArray[7] = '';
 142  
 143          for (var j in htmlArray){
 144              html += '<div class="sortableListDiv"><span class="sortableListSpan"><ul class="sortableRow">' + htmlArray[j] + '</ul></span></div>';
 145          }
 146          jQuery('#allButtons').empty().append(html);
 147      }
 148  
 149      Drupal.ckeditorToolbaInit();
 150  });


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7