!function(){tinymce.PluginManager.add("qt_gridstackshortcode",function(t,e){function a(t,e){return e=new RegExp(e+'="([^"]+)"',"g").exec(t),e?window.decodeURIComponent(e[1]):""}function o(t,o,n){var i=e+"/img/"+a(o,"gridstack")+".jpg";return gridstack=a(o,"gridstack"),posttype=a(o,"posttype"),quantity=a(o,"quantity"),taxonomy=a(o,"taxonomy"),archivelink=a(o,"archivelink"),term_ids=a(o,"term_ids"),'<img src="'+i+'" class="mceItem '+t+'" data-gridstack="'+gridstack+'" data-posttype="'+posttype+'" 			data-mce-resize="false" data-mce-placeholder="1" data-quantity="'+quantity+'"  data-taxonomy="'+taxonomy+'" data-term_ids="'+term_ids+'" data-archivelink="'+archivelink+'" />'}function n(t){return console.log(t),t.replace(/\[qt_gridstackshortcode ([^\]]*)\]/g,function(t,e,a){return o("wp-qt_gridstackshortcode",e,a)})}function i(t){return t.replace(/(?:<p(?: [^>]+)?>)*(<img [^>]+>)(?:<\/p>)*/g,function(t,e){var o=a(e,"data-gridstack"),n=a(e,"data-posttype"),i=a(e,"data-quantity"),r=a(e,"data-taxonomy"),s=a(e,"data-archivelink"),l=a(e,"data-term_ids"),c="["+d;return"undefined"!=typeof o&&o.length&&(c+=' gridstack="'+o+'"'),"undefined"!=typeof n&&n.length&&(c+=' posttype="'+n+'"'),"undefined"!=typeof i&&i.length&&(c+=' quantity="'+i+'"'),"undefined"!=typeof r&&r.length&&(c+=' taxonomy="'+r+'"'),"undefined"!=typeof s&&s.length&&(c+=' archivelink="'+s+'"'),"undefined"!=typeof l&&l.length&&(c+=' term_ids="'+l+'"'),c+="]"})}var d="qt_gridstackshortcode";t.addCommand("qt_gridstackshortcode_popup",function(e,a){var o="";a.gridstack&&(o=a.gridstack);var n="";a.quantity&&(n=a.quantity);var i="";a.posttype&&(i=a.posttype);var r="";a.taxonomy&&(r=a.taxonomy);var s="";a.archivelink&&(s=a.archivelink);var l="";a.term_ids&&(l=a.term_ids),t.windowManager.open({title:"Gridstack editor",body:[{type:"listbox",name:"gridstack",label:"Gridstack",value:o,values:[{text:"Carousel",value:"qt-carousel"},{text:"Diamonds",value:"qt-diamonds"},{text:"Owlcarousel",value:"qt-owlcarousel"},{text:"Owlcarousel-row",value:"qt-owlcarousel-row"},{text:"Skywheel",value:"qt-skywheel"},{text:"Slideshow",value:"qt-slideshow"}],tooltip:"Select the type of gridstack you want"},{type:"listbox",name:"posttype",label:"Post-type",value:i,values:qtposttypes,tooltip:"Select the post type to use"},{type:"listbox",name:"quantity",label:"Quantity",value:n,values:[{text:"1",value:"1"},{text:"2",value:"2"},{text:"3",value:"3"},{text:"4",value:"4"},{text:"6",value:"6"},{text:"8",value:"8"},{text:"12",value:"12"},{text:"16",value:"16"},{text:"18",value:"18"},{text:"20",value:"20"},{text:"24",value:"24"},{text:"30",value:"30"}],tooltip:"Keep low for performance."},{type:"textbox",name:"taxonomy",label:"Taxonomy",value:r,tooltip:"Leave blank for none, or use taxonomy slug, like categories. Attention: each post type has its own taxonomies!"},{type:"textbox",name:"term_ids",label:"Term IDs",value:l,tooltip:"Leave blank for none, or use comma separated numbers"},{type:"listbox",name:"archivelink",label:"Link to archive",value:s,values:[{text:"Hide",value:"0"},{text:"Show",value:"1"}],tooltip:"Display a link to the full archive. Not all the gridstacks supports this"}],onsubmit:function(e){var a="["+d;"undefined"!=typeof e.data.gridstack&&e.data.gridstack.length&&(a+=' gridstack="'+e.data.gridstack+'"'),"undefined"!=typeof e.data.posttype&&e.data.posttype.length&&(a+=' posttype="'+e.data.posttype+'"'),"undefined"!=typeof e.data.quantity&&e.data.quantity.length&&(a+=' quantity="'+e.data.quantity+'"'),"undefined"!=typeof e.data.taxonomy&&e.data.taxonomy.length&&(a+=' taxonomy="'+e.data.taxonomy+'"'),"undefined"!=typeof e.data.archivelink&&e.data.archivelink.length&&(a+=' archivelink="'+e.data.archivelink+'"'),"undefined"!=typeof e.data.term_ids&&e.data.term_ids.length&&(a+=' term_ids="'+e.data.term_ids+'"'),a+="]",t.insertContent(a)}})}),t.addButton("qt_gridstackshortcode",{icon:"qt_gridstackshortcode",tooltip:"Gridstack Editor",text:" QT Gridstack Easymode",onclick:function(){t.execCommand("qt_gridstackshortcode_popup","",{gridstack:"qt-carousel",posttype:"post",quantity:"4",taxonomy:"",term_ids:"",archivelink:"0"})}}),t.on("BeforeSetcontent",function(t){t.content=n(t.content)}),t.on("GetContent",function(t){t.content=i(t.content)}),t.on("DblClick",function(e){var a=e.target.className.indexOf("wp-qt_gridstackshortcode");if("IMG"==e.target.nodeName&&e.target.className.indexOf("wp-qt_gridstackshortcode")>-1){var o=e.target.attributes["data-gridstack"].value,n=e.target.attributes["data-posttype"].value,i=e.target.attributes["data-quantity"].value,d=e.target.attributes["data-taxonomy"].value,r=e.target.attributes["data-archivelink"].value,s=e.target.attributes["data-term_ids"].value;console.log(o+" "+n+" "+i+" "+d+" archivelink:"+r+" term_ids:"+s),t.execCommand("qt_gridstackshortcode_popup","",{gridstack:o,posttype:n,quantity:i,taxonomy:d,term_ids:s,archivelink:r})}})})}();