editor-lists-debug.js revision aa2ac226ad6e45232f8416eecc99d2165ce74d03
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @module editor
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @submodule editor-lists
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Handles list manipulation inside the Editor. Adds keyboard manipulation and execCommand support. Adds overrides for the <a href="Plugin.ExecCommand.html#method_COMMANDS.insertorderedlist">insertorderedlist</a> and <a href="Plugin.ExecCommand.html#method_COMMANDS.insertunorderedlist">insertunorderedlist</a> execCommands.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @class Plugin.EditorLists
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @constructor
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @extends Base
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith var EditorLists = function() {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith EditorLists.superclass.constructor.apply(this, arguments);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith }, LI = 'li', OL = 'ol', UL = 'ul', HOST = 'host';
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Listener for host's nodeChange event and captures the tabkey interaction only when inside a list node.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @method _onNodeChange
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @param {Event} e The Event facade passed from the host.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith var inst = this.get(HOST).getInstance(), sel, li,
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith newLi, newList, sTab, par, moved = false, tag, focusEnd = false;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if (e.changedNode.test(LI + ', ' + LI + ' *')) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('Overriding the Enter Key', 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith newLi = inst.Node.create('<' + LI + '>' + EditorLists.NON + '</' + LI + '>');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith sel.selectNode(newLi.get('firstChild'), true, false);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if (e.changedNode.test(LI + ', ' + LI + ' *')) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('Overriding TAB to move lists around', 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith if (par.get('tagName').toLowerCase() === OL) {
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('ShiftKey: ' + sTab, 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('Shifting list up one level', 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith //li.setStyle('border', '1px solid red');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('Shifting list down one level', 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith newList = inst.Node.create('<' + tag + '></' + tag + '>');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith li = li.append(EditorLists.NON).one(EditorLists.NON_SEL);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith //Selection here..
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith Y.log('Selecting the new node', 'info', 'editorLists');
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith (new inst.Selection()).selectNode(li, true, focusEnd);
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith this.get(HOST).on('nodeChange', Y.bind(this._onNodeChange, this));
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * The non element placeholder, used for positioning the cursor and filling empty items
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @property REMOVE
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * The selector query to get all non elements
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @property NONSEL
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * The items to removed from a list when a list item is moved, currently removes BR nodes
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @property REMOVE
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * editorLists
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @property NAME
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @property NS
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Override for the insertunorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @for ExecCommand
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @method COMMANDS.insertunorderedlist
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @param {String} cmd The command executed: insertunorderedlist
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @return {Node} Node instance of the item touched by this command.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith var inst = this.get('host').getInstance(), out;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * Override for the insertorderedlist method from the <a href="Plugin.EditorLists.html">EditorLists</a> plugin.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @for ExecCommand
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @method COMMANDS.insertorderedlist
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @param {String} cmd The command executed: insertorderedlist
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith * @return {Node} Node instance of the item touched by this command.
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith var inst = this.get('host').getInstance(), out;
c1bef59b02d89a84c23d29663cc4e6d46148ebd2David Goldsmith}, '@VERSION@' ,{skinnable:false, requires:['editor-base']});