[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/yuilib/3.17.2/editor-lists/ -> editor-lists-debug.js (source)

   1  /*
   2  YUI 3.17.2 (build 9c3c78e)
   3  Copyright 2014 Yahoo! Inc. All rights reserved.
   4  Licensed under the BSD License.
   5  http://yuilibrary.com/license/
   6  */
   7  
   8  YUI.add('editor-lists', function (Y, NAME) {
   9  
  10  
  11      /**
  12       * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support.
  13       * Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a>
  14       * and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
  15       * @class Plugin.EditorLists
  16       * @constructor
  17       * @extends Base
  18       * @module editor
  19       * @submodule editor-lists
  20       */
  21  
  22      var EditorLists = function() {
  23          EditorLists.superclass.constructor.apply(this, arguments);
  24      }, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
  25  
  26      Y.extend(EditorLists, Y.Base, {
  27          /**
  28          * Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
  29          * @private
  30          * @method _onNodeChange
  31          * @param {Event} e The Event facade passed from the host.
  32          */
  33          _onNodeChange: function(e) {
  34              var inst = this.get(HOST).getInstance(), li,
  35                  newList, sTab, par, moved = false, tag, focusEnd = false;
  36  
  37              if (e.changedType === 'tab') {
  38                  if (e.changedNode.test(LI + ', ' + LI + ' *')) {
  39                      Y.log('Overriding TAB to move lists around', 'info', 'editorLists');
  40                      e.changedEvent.halt();
  41                      e.preventDefault();
  42                      li = e.changedNode;
  43                      sTab = e.changedEvent.shiftKey;
  44                      par = li.ancestor(OL + ',' + UL);
  45                      tag = UL;
  46  
  47                      if (par.get('tagName').toLowerCase() === OL) {
  48                          tag = OL;
  49                      }
  50                      Y.log('ShiftKey: ' + sTab, 'info', 'editorLists');
  51  
  52                      if (!li.test(LI)) {
  53                          li = li.ancestor(LI);
  54                      }
  55                      if (sTab) {
  56                          if (li.ancestor(LI)) {
  57                              Y.log('Shifting list up one level', 'info', 'editorLists');
  58                              li.ancestor(LI).insert(li, 'after');
  59                              moved = true;
  60                              focusEnd = true;
  61                          }
  62                      } else {
  63                          //li.setStyle('border', '1px solid red');
  64                          if (li.previous(LI)) {
  65                              Y.log('Shifting list down one level', 'info', 'editorLists');
  66                              newList = inst.Node.create('<' + tag + '></' + tag + '>');
  67                              li.previous(LI).append(newList);
  68                              newList.append(li);
  69                              moved = true;
  70                          }
  71                      }
  72                  }
  73                  if (moved) {
  74                      if (!li.test(LI)) {
  75                          li = li.ancestor(LI);
  76                      }
  77                      li.all(EditorLists.REMOVE).remove();
  78                      if (Y.UA.ie) {
  79                          li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
  80                      }
  81                      //Selection here..
  82                      Y.log('Selecting the new node', 'info', 'editorLists');
  83                      (new inst.EditorSelection()).selectNode(li, true, focusEnd);
  84                  }
  85              }
  86          },
  87          initializer: function() {
  88              this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
  89          }
  90      }, {
  91          /**
  92          * The non element placeholder, used for positioning the cursor and filling empty items
  93          * @property NON
  94          * @static
  95          */
  96          NON: '<span class="yui-non">&nbsp;</span>',
  97          /**
  98          * The selector query to get all non elements
  99          * @property NONSEL
 100          * @static
 101          */
 102          NON_SEL: 'span.yui-non',
 103          /**
 104          * The items to removed from a list when a list item is moved, currently removes BR nodes
 105          * @property REMOVE
 106          * @static
 107          */
 108          REMOVE: 'br',
 109          /**
 110          * editorLists
 111          * @property NAME
 112          * @static
 113          */
 114          NAME: 'editorLists',
 115          /**
 116          * lists
 117          * @property NS
 118          * @static
 119          */
 120          NS: 'lists',
 121          ATTRS: {
 122              host: {
 123                  value: false
 124              }
 125          }
 126      });
 127  
 128      Y.namespace('Plugin');
 129  
 130      Y.Plugin.EditorLists = EditorLists;
 131  
 132  
 133  
 134  }, '3.17.2', {"requires": ["editor-base"]});


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1