1 |
- function removeDomainFromUrl(e){"use strict";return e.replace(/^https?:\/\/[^\/]+/i,"")}function var_dump(e,t){"use strict";var i="";t||(t=0);var s,a="";for(s=0;t+1>s;s+=1)a+=" ";if("object"==typeof e){var n,r;for(n in e)e.hasOwnProperty(n)&&(r=e[n],"object"==typeof r?(i+=a+"'"+n+"' ...\n",i+=var_dump(r,t+1)):i+=a+"'"+n+"' => \""+r+'"\n')}else i="===>"+e+"<===("+typeof e+")";return i}var IMG_PARAM={URL:0,TITLE:1,ALT:2,WIDTH:3,HEIGHT:4},pluginPath='http://lib.amic.ru/js/' /*removeDomainFromUrl(CKEDITOR.plugins.get("slideshow").path)*/,BASE_PATH=removeDomainFromUrl(CKEDITOR.basePath),SCRIPT_JQUERY=pluginPath+"3rdParty/jquery.min.js",SCRIPT_ADDGAL=pluginPath+"3rdParty/ad-gallery/jquery.ad-gallery.min.js",CSS_ADDGAL=pluginPath+"3rdParty/ad-gallery/jquery.ad-gallery.css",SCRIPT_FANCYBOX=pluginPath+"3rdParty/fancybox2/jquery.fancybox.pack.js?v=2.1.5",CSS_FANCYBOX=pluginPath+"3rdParty/fancybox2/jquery.fancybox.css?v=2.1.5",listItem=function(e){"use strict";return e.type==CKEDITOR.NODE_ELEMENT&&e.is("li")},ULItem=function(e){"use strict";return e.type==CKEDITOR.NODE_ELEMENT&&e.is("ul")},iFrameItem=function(e){"use strict";return e.type==CKEDITOR.NODE_ELEMENT&&e.is("iframe")};Array.prototype.pushUnique=function(e){"use strict";var t;for(t=0;t<this.length;t+=1)if(this[t][0]==e[0])return-1;return this.push(e),this.length-1},Array.prototype.updateVal=function(e,t){"use strict";var i;for(i=0;i<this.length;i+=1)if(this[i][0]==e)return this[i]=[e,t],!0;return this[i]=[e,t],!1},Array.prototype.getVal=function(e){"use strict";var t;for(t=0;t<this.length;t+=1)if(this[t][0]==e)return this[t][1];return null},CKEDITOR.dialog.add("slideshowDialog",function(e){"use strict";function t(e,t,i,s,a){e=l(e);var n;return n=s?s.createElement("OPTION"):document.createElement("OPTION"),e&&n&&"option"==n.getName()?(CKEDITOR.env.ie?(isNaN(parseInt(a,10))?e.$.options.add(n.$):e.$.options.add(n.$,a),n.$.innerHTML=t.length>0?t:"",n.$.value=i):(null!==a&&a<e.getChildCount()?e.getChild(0>a?0:a).insertBeforeMe(n):e.append(n),n.setText(t.length>0?t:""),n.setValue(i)),n):!1}function i(e,t,i,s){if(e=l(e),0>t)return!1;var a=e.getChild(t);return a.setText(i),a.setValue(s),a}function s(e){for(e=l(e);e.getChild(0)&&e.getChild(0).remove(););}function a(e,s,a,o){e=l(e);var d=n(e);if(0>d)return!1;var c=d+s;if(c=0>c?0:c,c=c>=e.getChildCount()?e.getChildCount()-1:c,d==c)return!1;var h=/(^IMG_\d+)/,u=e.getChild(c),g=u.getText(),p=u.getValue();g=g.replace(h,"IMG_"+d),i(e,c,g,p),u=e.getChild(d),g=u.getText(),p=u.getValue(),u.remove(),g=g.replace(h,"IMG_"+c),u=t(e,g,p,a?a:null,c),r(e,c);var m=o.imagesList[d],f=o.imagesList[c];return o.imagesList[d]=f,o.imagesList[c]=m,u}function n(e){return e=l(e),e?e.$.selectedIndex:-1}function r(e,t){if(e=l(e),0>t)return null;var i=e.getChildren().count();return e.$.selectedIndex=t>=i?i-1:t,e}function l(e){return e&&e.domId&&e.getInputElement().$?e.getInputElement():e&&e.$?e:!1}function o(e){if(1!=e.openCloseStep){var t=e.getContentElement("slideshowinfoid","framepreviewid");t.isVisible()?v(e):g(e)}}function d(e){var t=e.getDialog();e=l(e);var i,s,a,n=0;for(i=0;i<e.getChildren().count();i+=1)if(s=e.getChild(i),s.$.selected){a=s,n=i;break}r(e,n),o(t)}function c(e){var t=e.getContentElement("slideshowinfoid","imglistitemsid");return n(t)}function h(e){var t=BASE_PATH+"plugins/slideshow/icons/placeholder.png";if(1==e.imagesList.length&&e.imagesList[0][IMG_PARAM.URL]==t){var i=e.getContentElement("slideshowinfoid","imglistitemsid");i=l(i);var s=0;e.imagesList.splice(s,1),i.getChild(s).remove()}}function u(e){h(e);var i=e.previewImage,s=i.$.src,a=i.$.width/i.$.height,n=50,l=50;a>1?l/=a:n*=a;var d,c=e.getContentElement("slideshowinfoid","imglistitemsid"),u=e.imagesList.pushUnique([s,"","",n.toFixed(0),l.toFixed(0)]);u>=0&&(d=t(c,"IMG_"+u+" : "+s.substring(s.lastIndexOf("/")+1),s,e.getParentEditor().document),r(c,u),o(e))}function g(e){var t=e.getContentElement("slideshowinfoid","imglistitemsid"),i=n(t),s=e.imagesList[i];t=e.getContentElement("slideshowinfoid","imgtitleid"),t=l(t),t.setValue(s[1]),t=e.getContentElement("slideshowinfoid","imgdescid"),t=l(t),t.setValue(s[2]),t=e.getContentElement("slideshowinfoid","imgpreviewid"),t=l(t);var a='<div style="text-align:center;"> <img src="'+s[0]+'" title="'+s[1]+'" alt="'+s[2]+'" style=" max-height: 200px; max-width: 350px;"> </div>';t.setHtml(a);var r=e.getContentElement("slideshowinfoid","framepreviewid"),o=e.getContentElement("slideshowinfoid","imgparamsid");r=l(r),r.hide(),o=l(o),o.show()}function p(e){var i=e.getContentElement("slideshowinfoid","imglistitemsid");i=l(i);var s,a=!1;for(s=i.getChildren().count()-1;s>=0;s--)i.getChild(s).$.selected&&(e.imagesList.splice(s,1),i.getChild(s).remove(),a=!0);if(a){if(0==e.imagesList.length){{var n=BASE_PATH+"plugins/slideshow/icons/placeholder.png";t(i,"IMG_0 : "+n.substring(n.lastIndexOf("/")+1),n,e.getParentEditor().document)}e.imagesList.pushUnique([n,P.imgTitle,P.imgDesc,"50","50"])}r(i,0),o(e)}}function m(e,t){var i=e.getContentElement("slideshowinfoid","imglistitemsid");i=l(i);var s=n(i);1!=i.getChildren().count()&&(-1!=t||0!=s)&&(1!=t||s!=i.getChildren().count()-1)&&(a(i,t,e.getParentEditor().document,e),w(e))}function f(e,t){e.imagesList[c(e)][IMG_PARAM.TITLE]=t,g(e)}function b(e,t){e.imagesList[c(e)][IMG_PARAM.ALT]=t,g(e)}function v(e){var t=e.getContentElement("slideshowinfoid","framepreviewid"),i=e.getContentElement("slideshowinfoid","imgparamsid");i=l(i),i.hide(),t=l(t),t.show(),w(e)}function y(e,t){e.open(),e.writeln(t),e.close()}function w(e){var t=436,i=300;if(1==e.params.getVal("showthumbid")?i-=120:1==e.params.getVal("showcontrolid")&&(i-=30),0!=e.imagesList.length){var s=e.getContentElement("slideshowinfoid","imglistitemsid"),a=n(s);0>a&&(a=0),s=e.getContentElement("slideshowinfoid","framepreviewid");var r="";r+="<head>",r+='<script src="'+SCRIPT_JQUERY+'" type="text/javascript"></script>',r+='<script type="text/javascript" src="'+SCRIPT_ADDGAL+'"></script>',r+='<link rel="stylesheet" type="text/css" href="'+CSS_ADDGAL+'" />',1==e.params.getVal("openOnClickId")&&(r+='<link rel="stylesheet" type="text/css" href="'+CSS_FANCYBOX+'" />',r+='<script type="text/javascript" src="'+SCRIPT_FANCYBOX+'"></script>',r+='<script type="text/javascript">',r+=k(e),r+="</script>"),r+='<script type="text/javascript">',r+=L(e,a,t,i),r+="</script>",r+="</head>",r+="<body>";var o=O(e);r+=o.getOuterHtml(),r+="</body>",r+="",s=l(s);var d=s.getFirst(iFrameItem);d&&d.remove();var c=null,h=t+60,u=i;1==e.params.getVal("showthumbid")?u+=120:1==e.params.getVal("showcontrolid")&&(u+=30);var g=CKEDITOR.dom.element.createFromHtml('<iframe style="width:'+h+"px;height:"+u+'px;background:azure; " class="cke_pasteframe" frameborder="10" allowTransparency="false" role="region" scrolling="no"></iframe>');g.setAttribute("name","totoFrame"),g.setAttribute("id","totoFrame"),g.on("load",function(){if(null==c){c=this.$;var e;c.contentDocument?e=c.contentDocument:c.contentWindow&&(e=c.contentWindow.document),e?y(e,r):alert("Cannot inject dynamic contents into iframe.")}}),s.append(g)}}function C(e,i){var s,a,n,l,d,c,h,u,g,p=i.$.getElementsByTagName("img"),m=e.getContentElement("slideshowinfoid","imglistitemsid");for(s=0;s<p.length;s+=1){a=p[s],n=a.src,l=a.width,0==l&&(l=a.naturalWidth),0==l?(l=50,d=50):(d=a.height,0==d&&(d=a.naturalHeight),0==d&&(l=50,d=50)),c=l/d,h=50,u=50,c>1?u/=c:h*=c,g=e.imagesList.pushUnique([n,a.title,a.alt,h,u]);var f;g>=0&&(f=t(m,"IMG_"+g+" : "+n.substring(n.lastIndexOf("/")+1),n,e.getParentEditor().document))}r(m,0),o(e)}function x(e){{var i=e.getContentElement("slideshowinfoid","imglistitemsid"),s=BASE_PATH+"plugins/slideshow/icons/placeholder.png";t(i,"IMG_0 : "+s.substring(s.lastIndexOf("/")+1),s,e.getParentEditor().document)}e.imagesList.pushUnique([s,P.imgTitle,P.imgDesc,"50","50"]),r(i,0),o(e)}function A(){var e=this.getDialog();if(e.newSlideShowMode)switch(e.slideshowDOM.setAttribute("data-"+this.id,this.getValue()),this.type){case"checkbox":break;case"text":break;case"select":}else switch(this.type){case"checkbox":this.setValue("true"==e.slideshowDOM.getAttribute("data-"+this.id));break;case"text":this.setValue(e.slideshowDOM.getAttribute("data-"+this.id));break;case"select":this.setValue(e.slideshowDOM.getAttribute("data-"+this.id))}}function I(){var e=this.getDialog();switch(e.params.updateVal(this.id,this.getValue()),this.type){case"checkbox":break;case"text":break;case"select":}o(e)}function E(e){e.previewImage&&(e.previewImage.removeListener("load",R),e.previewImage.removeListener("error",V),e.previewImage.removeListener("abort",V),e.previewImage.remove(),e.previewImage=null),e.imagesList=null,e.params=null,e.slideshowDOM=null;var t=e.getContentElement("slideshowinfoid","imglistitemsid");s(t),e.openCloseStep=!1}function D(e){for(var t="";t.length<e;)t+=Math.random().toString(36).substring(2);return t.substring(0,e)}function T(e,t){var i=t.getElementsByTag("ul");return null==i?null:1==i.count()?i.getItem(0):null}function L(e,t,i,s){var a=e.params.getVal("slideshowid"),n="ad-gallery_"+a,r="(function($) {",l="";r+="$(function() {",0==s&&(s=e.params.getVal("pictheightid")),0==i&&(i="false"),0==e.params.getVal("showtitleid")&&(l=", hooks: { displayDescription: function(image) {}}");var o="loader_image: '"+pluginPath+"3rdParty/ad-gallery/loader.gif', width:"+i+", height:"+s+", start_at_index: "+t+", animation_speed: "+e.params.getVal("animspeedid")+l+", update_window_hash: false, effect: '"+e.params.getVal("transitiontypeid")+"',",d=" slideshow: { enable: true, autostart: "+e.params.getVal("autostartid")+", start_label: '"+P.labelStart+"', stop_label: '"+P.labelStop+"', speed: "+1e3*e.params.getVal("speedid")+"}";return r+=" var galleries = $('#"+n+"').adGallery({"+o+d+"});",r+="});",r+="})(jQuery);"}function k(e){var t=e.params.getVal("slideshowid"),i="ad-gallery_"+t,s="(function($) {";return s+="$(function() {",s+='$("#'+i+'").on("click",".ad-image",function(){',s+='var imgObj =$(this).find("img");',s+='var isrc=imgObj.attr("src");',s+="var ititle=null;",s+="var idesc=null;",s+="var iname=isrc.split('/');",s+="iname=iname[iname.length-1];",s+='var imgdescid=$(this).find(".ad-image-description");',s+="if(imgdescid){",s+='ititle=$(this).find(".ad-description-title");',s+="if(ititle)ititle=ititle.text();",s+="if(ititle!='')ititle='<big>'+ititle+'</big>';",s+='idesc=$(this).find("span");',s+="if(idesc)idesc=idesc.text();",s+="if(idesc!=''){",s+="if(ititle!='')ititle=ititle+'<br>';",s+="idesc='<i>'+idesc+'</i>';",s+="}",s+="}",s+="$.fancybox.open({",s+="href:isrc,",s+="beforeLoad:function(){",s+="this.title=ititle+idesc;",s+="},",s+="});",s+="});",s+="});",s+="})(jQuery);"}function _(e,t){var i,s,a,n;for(i=0;i<e.imagesList.length;i+=1)s=t.append("li"),s.setAttribute("contenteditable","false"),a=s.append("a"),a.setAttribute("href",removeDomainFromUrl(e.imagesList[i][IMG_PARAM.URL])),a.setAttribute("contenteditable","false"),n=a.append("img"),n.setAttribute("src",removeDomainFromUrl(e.imagesList[i][IMG_PARAM.URL])),n.setAttribute("title",e.imagesList[i][IMG_PARAM.TITLE]),n.setAttribute("alt",e.imagesList[i][IMG_PARAM.ALT]),n.setAttribute("contenteditable","false"),n.setAttribute("width",e.imagesList[i][IMG_PARAM.WIDTH]),n.setAttribute("height",e.imagesList[i][IMG_PARAM.HEIGHT])}function O(t){var i=t.params.getVal("slideshowid"),s="ad-gallery_"+i,a="display: block;",n="display: block;";0==t.params.getVal("showthumbid")&&(a="display: none;"),0==t.params.getVal("showcontrolid")&&(n="visibility: hidden;");var r=e.document.createElement("div");r.setAttribute("id",i),r.setAttribute("class","slideshowPlugin"),r.setAttribute("contenteditable","false");var l=r.append("div");l.setAttribute("class","ad-gallery"),l.setAttribute("contenteditable","false"),l.setAttribute("id",s);var o=l.append("div");o.setAttribute("class","ad-image-wrapper"),o.setAttribute("contenteditable","false");var d=l.append("div");d.setAttribute("class","ad-controls"),d.setAttribute("contenteditable","false"),d.setAttribute("style",n);var c=l.append("div");c.setAttribute("class","ad-nav"),c.setAttribute("style",a),c.setAttribute("contenteditable","false");var h=c.append("div");h.setAttribute("class","ad-thumbs"),h.setAttribute("contenteditable","false");var u=h.append("ul");return u.setAttribute("class","ad-thumb-list"),u.setAttribute("contenteditable","false"),_(t,u),r}function S(t){var i={},s={};t.openCloseStep=!0,t.commitContent(t);var a,n=O(t);for(a=0;a<t.params.length;a+=1)n.data(t.params[a][0],t.params[a][1]);var r=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript",src:SCRIPT_JQUERY}});n.append(r);var l=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript",src:SCRIPT_ADDGAL}});if(n.append(l),1==t.params.getVal("openOnClickId")){var o=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript"}});o.setText("(function($) { $('head').append('<link rel=\"stylesheet\" href=\""+CSS_FANCYBOX+'" type="text/css" />\'); })(jQuery);'),n.append(o);var d=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript",src:SCRIPT_FANCYBOX}});n.append(d);var c=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript"}});c.setText(k(t)),n.append(c)}var h=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript"}});h.setText("(function($) { $('head').append('<link rel=\"stylesheet\" href=\""+CSS_ADDGAL+'" type="text/css" />\'); })(jQuery);'),n.append(h);var u=CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript"}});u.setText(L(t,0,0,0)),n.append(u),t.imagesList.length&&(i.backgroundImage='url("'+t.imagesList[0][IMG_PARAM.URL]+'")'),i.backgroundSize="50%",i.display="block";var g=e.createFakeElement(n,"cke_slideShow","slideShow",!1);return g.setAttributes(s),g.setStyles(i),t.fakeImage?(g.replace(t.fakeImage),e.getSelection().selectElement(g)):e.insertElement(g),E(t),t.hide(),!0}var P=e.lang.slideshow,R=function(){var e=this.previewImage;e.removeListener("load",R),e.removeListener("error",V),e.removeListener("abort",V),u(this)},V=function(){var e=this.previewImage;e.removeListener("load",R),e.removeListener("error",V),e.removeListener("abort",V)},M=function(e){return"cke_"+D(8)+"_"+e};return{title:P.dialogTitle,width:500,height:600,resizable:CKEDITOR.DIALOG_RESIZE_NONE,buttons:[CKEDITOR.dialog.okButton(e,{label:"OkCK",style:"display:none;"}),CKEDITOR.dialog.cancelButton,{id:"myokbtnid",type:"button",label:"OK",title:P.validModif,accessKey:"C",disabled:!1,onClick:function(){S(this.getDialog())}}],contents:[{id:"slideshowinfoid",label:"Basic Settings",align:"center",elements:[{type:"text",id:"id",style:"display:none;",onLoad:function(){this.getInputElement().setAttribute("readOnly",!0)}},{type:"text",id:"txturlid",style:"display:none;",label:P.imgList,onChange:function(){var e=this.getDialog(),t=this.getValue();if(t.length>0){var i=e.previewImage;i.on("load",R,e),i.on("error",V,e),i.on("abort",V,e),i.setAttribute("src",t)}}},{type:"button",id:"browse",hidden:"true",style:"display:inline-block;margin-top:0px;",filebrowser:{action:"Browse",target:"slideshowinfoid:txturlid",url:e.config.filebrowserImageBrowseUrl||e.config.filebrowserBrowseUrl},label:P.imgAdd},{type:"vbox",align:"center",children:[{type:"html",align:"center",id:"framepreviewtitleid",style:"font-family: Amaranth; color: #1E66EB; font-size: 20px; font-weight: bold;",html:P.previewMode},{type:"html",id:"framepreviewid",align:"center",style:"width:500px;height:320px",html:""},{type:"hbox",id:"imgparamsid",style:"display:none;width:500px;",height:"325px",children:[{type:"vbox",align:"center",width:"400px",children:[{type:"text",id:"imgtitleid",label:P.imgTitle,onChange:function(){f(this.getDialog(),this.getValue())},onBlur:function(){f(this.getDialog(),this.getValue())}},{type:"text",id:"imgdescid",label:P.imgDesc,onChange:function(){b(this.getDialog(),this.getValue())},onBlur:function(){b(this.getDialog(),this.getValue())}},{type:"html",id:"imgpreviewid",style:"width:400px;height:200px;",html:"<div>xx</div>"}]}]},{type:"hbox",align:"center",height:110,widths:["25%","50%"],children:[{type:"vbox",children:[{type:"checkbox",id:"autostartid",label:P.autoStart,"default":"checked",style:"margin-top:15px;",onChange:I,commit:I,setup:A},{type:"checkbox",id:"showtitleid",label:P.showTitle,"default":"checked",onChange:I,commit:I,setup:A},{type:"checkbox",id:"showcontrolid",label:P.showControls,"default":"checked",onChange:I,commit:I,setup:A},{type:"checkbox",id:"showthumbid",label:P.showThumbs,"default":"checked",onChange:I,commit:I,setup:A},{type:"checkbox",id:"openOnClickId",label:P.openOnClick,"default":"checked",onChange:I,commit:I,setup:A}]},{type:"select",id:"imglistitemsid",label:P.picturesList,multiple:!1,style:"height:125px;width:250px",items:[],onChange:function(){d(this)}},{type:"vbox",children:[{type:"button",id:"previewbtn",style:"margin-top:15px;margin-left:25px;",label:P.previewMode,onClick:function(){v(this.getDialog())}},{type:"button",id:"removeselectedbtn",style:"margin-left:25px;",label:P.imgDelete,onClick:function(){p(this.getDialog())}},{type:"button",id:"editselectedbtn",style:"margin-left:25px;",label:P.imgEdit,onClick:function(){g(this.getDialog())}},{type:"hbox",children:[{type:"button",id:"upselectedbtn",style:"width:32px; margin-left:25px;",label:P.arrowUp,onClick:function(){m(this.getDialog(),-1)}},{type:"button",id:"downselectedbtn",style:"width:32px;",label:P.arrowDown,onClick:function(){m(this.getDialog(),1)}}]}]}]},{type:"hbox",children:[{type:"text",id:"pictheightid",label:P.pictHeight,maxLength:3,style:"width:100px;","default":"300",onChange:function(){var e=/^\d+$/;0==e.test(this.getValue())&&this.setValue(300),this.getDialog().params.updateVal(this.id,this.getValue()),o(this.getDialog())},commit:I,setup:A},{type:"text",id:"speedid",label:P.displayTime,maxLength:3,style:"width:100px;","default":"5",onChange:function(){var e=/^\d+$/;0==e.test(this.getValue())&&this.setValue(5),this.getDialog().params.updateVal(this.id,this.getValue()),o(this.getDialog())},commit:I,setup:A},{type:"text",id:"animspeedid",label:P.transitionTime,style:"width:100px;",maxLength:4,"default":"500",onChange:function(){var e=/^\d+$/;0==e.test(this.getValue())&&this.setValue(500),this.getDialog().params.updateVal(this.id,this.getValue()),o(this.getDialog())},commit:I,setup:A},{type:"select",id:"transitiontypeid",label:P.transition,items:[[P.tr1,"none"],[P.tr2,"resize"],[P.tr3,"slide-vert"],[P.tr4,"slide-hori"],[P.tr5,"fade"]],"default":"resize",style:"width:100px;",commit:I,setup:A,onChange:I}]}]}]}],onLoad:function(){},onShow:function(){this.dialog=this,this.slideshowDOM=null,this.openCloseStep=!0,this.fakeImage=null;var t=null;this.imagesList=[],this.params=[],this.previewImage=e.document.createElement("img"),this.okRefresh=!0;var i=this.getSelectedElement();if(i&&i.data("cke-real-element-type")&&"slideShow"==i.data("cke-real-element-type")&&(this.fakeImage=i,t=e.restoreRealElement(i)),t){this.slideshowDOM=t;var s=T(this,t);if(null==s)return alert("BIG Problem slideShowContainer !!"),!1;var a=t.getAttribute("id");if(null==a)return alert("BIG Problem slideshowid !!"),!1;this.params.push(["slideshowid",a]),C(this,s);var n,r=t.$.dataset;for(n in r)this.params.push([n,r[n]]);this.setupContent(this,!0),this.newSlideShowMode=!1}else this.params.push(["slideshowid",M("slideShow")]),x(this),this.commitContent(this);this.openCloseStep=!1,v(this)},onOk:function(){return!1},onHide:function(){E(this)}}});
|