You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
8 lines
5.7 KiB
8 lines
5.7 KiB
/*
|
|
YUI 3.17.2 (build 9c3c78e)
|
|
Copyright 2014 Yahoo! Inc. All rights reserved.
|
|
Licensed under the BSD License.
|
|
http://yuilibrary.com/license/
|
|
*/
|
|
|
|
YUI.add("content-editable",function(e,t){var n=e.Lang,r=e.Node,i="contentready",s="ready",o="p",u="blur",a="container",f="contentEditable",l="",c="focus",h="host",p="innerHTML",d="key",v="parentNode",m="paste",g="Text",y="use",b=function(){b.superclass.constructor.apply(this,arguments)};e.extend(b,e.Plugin.Base,{_rendered:null,_instance:null,initializer:function(){var e=this.get(h);e&&(e.frame=this),this._eventHandles=[],this.publish(s,{emitFacade:!0,defaultFn:this._defReadyFn})},destructor:function(){(new e.EventHandle(this._eventHandles)).detach(),this._container.removeAttribute(f)},_onDomEvent:function(e){var t;e.frameX=e.frameY=0,(e.pageX>0||e.pageY>0)&&e.type.substring(0,3)!==d&&(t=this._container.getXY(),e.frameX=t[0],e.frameY=t[1]),e.frameTarget=e.target,e.frameCurrentTarget=e.currentTarget,e.frameEvent=e,this.fire("dom:"+e.type,e)},_DOMPaste:function(e){var t=this.getInstance(),n=l,r=t.config.win;e._event.originalTarget&&(n=e._event.originalTarget),e._event.clipboardData&&(n=e._event.clipboardData.getData(g)),r.clipboardData&&(n=r.clipboardData.getData(g),n===l&&(r.clipboardData.setData(g,n)||(n=null))),e.frameTarget=e.target,e.frameCurrentTarget=e.currentTarget,e.frameEvent=e,n?e.clipboardData={data:n,getData:function(){return n}}:e.clipboardData=null,this.fire("dom:paste",e)},_defReadyFn:function(){var t=this.getInstance(),n=this.get(a);e.each(b.DOM_EVENTS,function(r,i){var s=e.bind(this._onDomEvent,this),o=e.UA.ie&&b.THROTTLE_TIME>0?e.throttle(s,b.THROTTLE_TIME):s;t.Node.DOM_EVENTS[i]||(t.Node.DOM_EVENTS[i]=1),r===1&&i!==c&&i!==u&&i!==m&&(i.substring(0,3)===d?this._eventHandles.push(n.on(i,o,n)):this._eventHandles.push(n.on(i,s,n)))},this),t.Node.DOM_EVENTS.paste=1,this._eventHandles.push(n.on(m,e.bind(this._DOMPaste,this),n),n.on(c,e.bind(this._onDomEvent,this),n),n.on(u,e.bind(this._onDomEvent,this),n)),t.__use=t.use,t.use=e.bind(this.use,this)},_onContentReady:function(t){if(!this._ready){this._ready=!0;var n=this.getInstance(),o=e.clone(this.get(y));this.fire(i),t&&(n.config.doc=r.getDOMNode(t.target)),o.push(e.bind(function(){n.EditorSelection&&(n.EditorSelection.DEFAULT_BLOCK_TAG=this.get("defaultblock"),n.EditorSelection.ROOT=this.get(a)),this.fire(s)},this)),n.use.apply(n,o)}},_getDefaultBlock:function(){return this._getHostValue("defaultblock")},_getDir:function(){return this._getHostValue("dir")},_getExtraCSS:function(){return this._getHostValue("extracss")},_getHTML:function(){var e,t;return this._ready&&(t=this.get(a),e=t.get(p)),e},_getHostValue:function(e){var t=this.get(h);if(t)return t.get(e)},_setHTML:function(t){if(this._ready){var n=this.get(a);n.set(p,t)}else this.once(i,e.bind(this._setHTML,this,t));return t},_setLinkedCSS:function(t){if(this._ready){var n=this.getInstance();n.Get.css(t)}else this.once(i,e.bind(this._setLinkedCSS,this,t));return t},_setDir:function(t){var n;return this._ready?(n=this.get(a),n.setAttribute("dir",t)):this.once(i,e.bind(this._setDir,this,t)),t},_setExtraCSS:function(t){if(this._ready){if(t){var n=this.getInstance(),s=n.one("head");this._extraCSSNode&&this._extraCSSNode.remove(),this._extraCSSNode=r.create("<style>"+t+"</style>"),s.append(this._extraCSSNode)}}else this.once(i,e.bind(this._setExtraCSS,this,t));return t},_setLang:function(t){var n;return this._ready?(n=this.get(a),n.setAttribute("lang",t)):this.once(i,e.bind(this._setLang,this,t)),t},_instanceLoaded:function(t){this._instance=t,this._onContentReady();var n=this._instance.config.doc;if(!e.UA.ie)try{n.execCommand("styleWithCSS",!1,!1),n.execCommand("insertbronreturn",!1,!1)}catch(r){}},_validateLinkedCSS:function(e){return n.isString(e)||n.isArray(e)},use:function(){var t=this.getInstance(),r=e.Array(arguments),i=!1;return n.isFunction(r[r.length-1])&&(i=r.pop()),i&&r.push(function(){i.apply(t,arguments)}),t.__use.apply(t,r)},delegate:function(e,t,n,r){var i=this.getInstance();return i?(r||(r=n,n=this.get(a)),i.delegate(e,t,n,r)):!1},getInstance:function(){return this._instance},render:function(t){var n,i,s;return this._rendered?this:(t&&this.set(a,t),container=this.get(a),container||(container=r.create(b.HTML),e.one("body").prepend(container),this.set(a,container)),this._rendered=!0,this._container.setAttribute(f,!0),n=e.clone(this.get(y)),s=e.bind(function(){i=YUI(),i.host=this.get(h),i.use("node-base",e.bind(this._instanceLoaded,this))},this),n.push(s),e.use.apply(e,n),this)},focus:function(){return this._container.focus(),this},show:function(){return this._container.show(),this.focus(),this},hide:function(){return this._container.hide(),this}},{THROTTLE_TIME:100,DOM_EVENTS:{click:1,dblclick:1,focusin:1,focusout:1,keydown:1,keypress:1,keyup:1,mousedown:1,mouseup:1,paste:1},HTML:"<div></div>",NAME:"contentEditable",NS:f,ATTRS:{dir:{lazyAdd:!1,validator:n.isString,setter:"_setDir",valueFn:"_getDir"},container:{setter:function(t){return this._container=e.one(t),this._container}},content:{getter:"_getHTML",lazyAdd:!1,setter:"_setHTML",validator:n.isString,value:"<br>"},defaultblock:{validator:n.isString,value:o,valueFn:"_getDefaultBlock"},extracss:{lazyAdd:!1,setter:"_setExtraCSS",validator:n.isString,valueFn:"_getExtraCSS"},id:{writeOnce:!0,getter:function(t){return t||(t="inlineedit-"+e.guid()),t}},lang:{validator:n.isString,setter:"_setLang",lazyAdd:!1,value:"en-US"},linkedcss:{setter:"_setLinkedCSS",validator:"_validateLinkedCSS"},node:{readOnly:!0,value:null,getter:function(){return this._container}},use:{validator:n.isArray,writeOnce:!0,value:["node-base","editor-selection","stylesheet"]}}}),e.namespace("Plugin"),e.Plugin.ContentEditable=b},"3.17.2",{requires:["node-base","editor-selection","stylesheet","plugin"]});
|
|
|