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