Seditio Source
Root |
./othercms/b2evolution_7.2.3/rsc/ext/tiny_mce/plugins/image/plugin.min.js
tinymce.PluginManager.add("image",function(b){function v(e,n,t){return function i(e,a){return a=a||[],tinymce.each(e,function(e){var t={text:e.text||e.title};e.menu?t.menu=i(e.menu):(t.value=e.value,n(t)),a.push(t)}),a}(e,t||[])}function e(t){return function(){var e=b.settings.image_list;"string"==typeof e?tinymce.util.XHR.send({url:e,success:function(e){t(tinymce.util.JSON.parse(e))}}):"function"==typeof e?e(t):t(e)}}function t(e){var r,a,t,o,l,s,i,n={},c=b.dom,g=!1!==b.settings.image_dimensions;function m(){var e,t,i,a;e=r.find("#width")[0],t=r.find("#height")[0],e&&t&&(i=e.value(),a=t.value(),r.find("#constrain")[0].checked()&&o&&l&&i&&a&&(o!=i?(a=Math.round(i/o*a),isNaN(a)||t.value(a)):(i=Math.round(a/l*i),isNaN(i)||e.value(i))),o=i,l=a)}function d(){var t,i;f(),m(),(n=tinymce.extend(n,r.toJSON())).alt||(n.alt=""),n.title||(n.title=""),""===n.width&&(n.width=null),""===n.height&&(n.height=null),n.style||(n.style=null),n={src:n.src,alt:n.alt,title:n.title,width:n.width,height:n.height,style:n.style,caption:n.caption,class:n.class},b.undoManager.transact(function(){if(n.src){if(""===n.title&&(n.title=null),a?c.setAttribs(a,n):(n.id="__mcenew",b.focus(),b.selection.setContent(c.createHTML("img",n)),a=c.get("__mcenew"),c.setAttrib(a,"id",null)),b.editorUpload.uploadImagesAuto(),!1===n.caption&&c.is(a.parentNode,"figure.image")&&(t=a.parentNode,c.insertAfter(a,t),c.remove(t)),!0!==n.caption)!function(e){function t(){e.onload=e.onerror=null,b.selection&&(b.selection.select(e),b.nodeChanged())}e.onload=function(){n.width||n.height||!g||c.setAttribs(e,{width:e.clientWidth,height:e.clientHeight}),t()},e.onerror=t}(a);else if(!c.is(a.parentNode,"figure.image")){a=(i=a).cloneNode(!0),(t=c.create("figure",{class:"image"})).appendChild(a),t.appendChild(c.create("figcaption",{contentEditable:!0},"Caption")),t.contentEditable=!1;var e=c.getParent(i,function(e){return b.schema.getTextBlockElements()[e.nodeName]});e?c.split(e,i,t):c.replace(t,i),b.selection.select(t)}}else a&&(c.remove(a),b.focus(),b.nodeChanged())})}function u(e){return e=e&&e.replace(/px$/,"")}a=b.selection.getNode(),(t=c.getParent(a,"figure.image"))&&(a=c.select("img",t)[0]),a&&("IMG"!=a.nodeName||a.getAttribute("data-mce-object")||a.getAttribute("data-mce-placeholder"))&&(a=null),a&&(o=c.getAttrib(a,"width"),l=c.getAttrib(a,"height"),n={src:c.getAttrib(a,"src"),alt:c.getAttrib(a,"alt"),title:c.getAttrib(a,"title"),class:c.getAttrib(a,"class"),width:o,height:l,caption:!!t}),e&&(s={type:"listbox",label:"Image list",values:v(e,function(e){e.value=b.convertURL(e.value||e.url,"src")},[{text:"None",value:""}]),value:n.src&&b.convertURL(n.src,"src"),onselect:function(e){var t=r.find("#alt");(!t.value()||e.lastControl&&t.value()==e.lastControl.text())&&t.value(e.control.text()),r.find("#src").value(e.control.value()).fire("change")},onPostRender:function(){s=this}}),b.settings.image_class_list&&(i={name:"class",type:"listbox",label:"Class",values:v(b.settings.image_class_list,function(e){e.value&&(e.textStyle=function(){return b.formatter.getCssText({inline:"img",classes:[e.value]})})})});var h=[{name:"src",type:"filepicker",filetype:"image",label:"Source",autofocus:!0,onchange:function(e){var t,i,a,n=e.meta||{};s&&s.value(b.convertURL(this.value(),"src")),tinymce.each(n,function(e,t){r.find("#"+t).value(e)}),n.width||n.height||(t=b.convertURL(this.value(),"src"),i=b.settings.image_prepend_url,a=new RegExp("^(?:[a-z]+:)?//","i"),i&&!a.test(t)&&t.substring(0,i.length)!==i&&(t=i+t),this.value(t),function(e,i){var a=document.createElement("img");function t(e,t){a.parentNode&&a.parentNode.removeChild(a),i({width:e,height:t})}a.onload=function(){t(Math.max(a.width,a.clientWidth),Math.max(a.height,a.clientHeight))},a.onerror=function(){t()};var n=a.style;n.visibility="hidden",n.position="fixed",n.bottom=n.left=0,n.width=n.height="auto",document.body.appendChild(a),a.src=e}(b.documentBaseURI.toAbsolute(this.value()),function(e){e.width&&e.height&&g&&(o=e.width,l=e.height,r.find("#width").value(o),r.find("#height").value(l))}))}},s];function p(e){if(e.margin){var t=e.margin.split(" ");switch(t.length){case 1:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[0],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[0];break;case 2:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[0],e["margin-left"]=e["margin-left"]||t[1];break;case 3:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[1];break;case 4:e["margin-top"]=e["margin-top"]||t[0],e["margin-right"]=e["margin-right"]||t[1],e["margin-bottom"]=e["margin-bottom"]||t[2],e["margin-left"]=e["margin-left"]||t[3]}delete e.margin}return e}function f(){function e(e){return 0<e.length&&/^[0-9]+$/.test(e)&&(e+="px"),e}if(b.settings.image_advtab){var t=r.toJSON(),i=c.parseStyle(t.style);i=p(i),t.vspace&&(i["margin-top"]=i["margin-bottom"]=e(t.vspace)),t.hspace&&(i["margin-left"]=i["margin-right"]=e(t.hspace)),t.border&&(i["border-width"]=e(t.border)),r.find("#style").value(c.serializeStyle(c.parseStyle(c.serializeStyle(i))))}}!1!==b.settings.image_description&&h.push({name:"alt",type:"textbox",label:"Image description"}),b.settings.image_title&&h.push({name:"title",type:"textbox",label:"Image Title"}),g&&h.push({type:"container",label:"Dimensions",layout:"flex",direction:"row",align:"center",spacing:5,items:[{name:"width",type:"textbox",maxLength:5,size:3,onchange:m,ariaLabel:"Width"},{type:"label",text:"x"},{name:"height",type:"textbox",maxLength:5,size:3,onchange:m,ariaLabel:"Height"},{name:"constrain",type:"checkbox",checked:!0,text:"Constrain proportions"}]}),h.push(i),b.settings.image_caption&&tinymce.Env.ceFalse&&h.push({name:"caption",type:"checkbox",label:"Caption"}),r=b.settings.image_advtab?(a&&(a.style.marginLeft&&a.style.marginRight&&a.style.marginLeft===a.style.marginRight&&(n.hspace=u(a.style.marginLeft)),a.style.marginTop&&a.style.marginBottom&&a.style.marginTop===a.style.marginBottom&&(n.vspace=u(a.style.marginTop)),a.style.borderWidth&&(n.border=u(a.style.borderWidth)),n.style=b.dom.serializeStyle(b.dom.parseStyle(b.dom.getAttrib(a,"style")))),b.windowManager.open({title:"Insert/edit image",data:n,bodyType:"tabpanel",body:[{title:"General",type:"form",items:h},{title:"Advanced",type:"form",pack:"start",items:[{label:"Style",name:"style",type:"textbox",onchange:function(){if(b.settings.image_advtab){var e=r.toJSON(),t=c.parseStyle(e.style);r.find("#vspace").value(""),r.find("#hspace").value(""),((t=p(t))["margin-top"]&&t["margin-bottom"]||t["margin-right"]&&t["margin-left"])&&(t["margin-top"]===t["margin-bottom"]?r.find("#vspace").value(u(t["margin-top"])):r.find("#vspace").value(""),t["margin-right"]===t["margin-left"]?r.find("#hspace").value(u(t["margin-right"])):r.find("#hspace").value("")),t["border-width"]&&r.find("#border").value(u(t["border-width"])),r.find("#style").value(c.serializeStyle(c.parseStyle(c.serializeStyle(t))))}}},{type:"form",layout:"grid",packV:"start",columns:2,padding:0,alignH:["left","right"],defaults:{type:"textbox",maxWidth:50,onchange:f},items:[{label:"Vertical space",name:"vspace"},{label:"Horizontal space",name:"hspace"},{label:"Border",name:"border"}]}]}],onSubmit:d})):b.windowManager.open({title:"Insert/edit image",data:n,body:h,onSubmit:d})}b.on("preInit",function(){function e(r){return function(e){var t,i,a=e.length;function n(e){e.attr("contenteditable",r?"true":null)}for(;a--;)t=e[a],void 0,(i=t.attr("class"))&&/\bimage\b/.test(i)&&(t.attr("contenteditable",r?"false":null),tinymce.each(t.getAll("figcaption"),n))}}b.parser.addNodeFilter("figure",e(!0)),b.serializer.addNodeFilter("figure",e(!1))}),b.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:e(t),onPostRender:function(){var a=this,n=b.plugins.b2evo_shorttags;n?b.on("NodeChange",function(e){var t=b.selection.getNode(),i=n.selected();i?a.disabled(!0):a.disabled(!1),a.active(!i&&b.dom.is(t,"img:not([data-mce-object],[data-mce-placeholder]),figure.image"))}):this.stateSelector="img:not([data-mce-object],[data-mce-placeholder]),figure.image"}}),b.addMenuItem("image",{icon:"image",text:"Insert/edit image",onclick:e(t),context:"insert",prependToContext:!0}),b.addCommand("mceImage",e(t))});