]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui3/build/editor/editor-lists.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui3 / build / editor / editor-lists.js
1 /*
2  Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3  Code licensed under the BSD License:
4  http://developer.yahoo.com/yui/license.html
5  version: 3.3.0
6  build: 3167
7  */
8 YUI.add('editor-lists',function(Y){var EditorLists=function(){EditorLists.superclass.constructor.apply(this,arguments);},LI='li',OL='ol',UL='ul',HOST='host';Y.extend(EditorLists,Y.Base,{_onNodeChange:function(e){var inst=this.get(HOST).getInstance(),sel,li,newLi,newList,sTab,par,moved=false,tag,focusEnd=false;if(Y.UA.ie&&e.changedType==='enter'){if(e.changedNode.test(LI+', '+LI+' *')){e.changedEvent.halt();e.preventDefault();li=e.changedNode;newLi=inst.Node.create('<'+LI+'>'+EditorLists.NON+'</'+LI+'>');if(!li.test(LI)){li=li.ancestor(LI);}
9 li.insert(newLi,'after');sel=new inst.Selection();sel.selectNode(newLi.get('firstChild'),true,false);}}
10 if(e.changedType==='tab'){if(e.changedNode.test(LI+', '+LI+' *')){e.changedEvent.halt();e.preventDefault();li=e.changedNode;sTab=e.changedEvent.shiftKey;par=li.ancestor(OL+','+UL);tag=UL;if(par.get('tagName').toLowerCase()===OL){tag=OL;}
11 if(!li.test(LI)){li=li.ancestor(LI);}
12 if(sTab){if(li.ancestor(LI)){li.ancestor(LI).insert(li,'after');moved=true;focusEnd=true;}}else{if(li.previous(LI)){newList=inst.Node.create('<'+tag+'></'+tag+'>');li.previous(LI).append(newList);newList.append(li);moved=true;}}}
13 if(moved){if(!li.test(LI)){li=li.ancestor(LI);}
14 li.all(EditorLists.REMOVE).remove();if(Y.UA.ie){li=li.append(EditorLists.NON).one(EditorLists.NON_SEL);}
15 (new inst.Selection()).selectNode(li,true,focusEnd);}}},initializer:function(){this.get(HOST).on('nodeChange',Y.bind(this._onNodeChange,this));}},{NON:'<span class="yui-non">&nbsp;</span>',NON_SEL:'span.yui-non',REMOVE:'br',NAME:'editorLists',NS:'lists',ATTRS:{host:{value:false}}});Y.namespace('Plugin');Y.Plugin.EditorLists=EditorLists;Y.mix(Y.Plugin.ExecCommand.COMMANDS,{insertunorderedlist:function(cmd){var inst=this.get('host').getInstance(),out;this.get('host')._execCommand(cmd,'');},insertorderedlist:function(cmd){var inst=this.get('host').getInstance(),out;this.get('host')._execCommand(cmd,'');}});},'3.3.0',{requires:['editor-base'],skinnable:false});