steal("jquery/controller",function(b){b.Controller("MP.Preloader",{myThis:null},{stages:{Navbar:!1,Language:!1,Iframe:!1,LeftBar:!1,DragDrop:!1},loaded:0,step:null,knob:null,init:function(){MP.Preloader.myThis=this;this.step=Math.round(100/Object.keys(this.stages).length*100)/100;this.knob=this.element.find("#motopress-knob");this.set()},reopen:function(){for(var a in this.stages)"Navbar"===a||"Language"===a?delete this.stages[a]:this.stages[a]=!1},show:function(){this.loaded=0;this.set();this.element.show()},
hide:function(){this.element.fadeOut("slow");MP.Flash.showMessage()},load:function(a){this.stages.hasOwnProperty(a)&&!this.stages[a]&&(this.stages[a]=!0,this.loaded+=this.step,this.set())},set:function(){this.knob.val(this.loaded).trigger("change")}})});
steal("jquery/controller",function(b){b.Controller("MP.Flash",{myThis:null,setFlash:function(a,c){var d=MP.Flash.myThis.create();"undefined"===typeof c&&(c="warning");var e="";switch(c){case "info":e="alert-info";break;case "success":e="alert-success";break;case "error":e="alert-error"}e.length&&d.addClass(e);a.length&&d.children("span").html(a)},showMessage:function(){MP.Flash.myThis.element.children(".alert").each(function(){var a=b(this);a.show().mpalert();var c=setTimeout(function(){a.mpalert("close");
clearTimeout(c)},1E4)})}},{alertEl:b("<div />",{"class":"alert fade in",style:"display: none;"}),closeEl:b("<div />",{"class":"motopress-close motopress-icon-remove","data-dismiss":"alert"}),messageEl:b("<span />"),create:function(){return this.alertEl.clone().append(this.closeEl.clone(),this.messageEl.clone()).appendTo(this.element)},init:function(){MP.Flash.myThis=this}})});
steal("jquery/class",function(b){b.Class("MP.Utils",{validationError:b("<div />",{"class":"motopress-validation-error"}),tbStyle:null,wpFrontEndEditorEvents:[],strtr:function(a,c,d){if("object"===typeof c){d="";for(var e=0;e<a.length;e++)d+="0";var b=0,b=-1,e="";for(fr in c)for(b=0;-1!=(b=a.indexOf(fr,b));)if(0!=parseInt(d.substr(b,fr.length)))b+=1;else{for(var g=0;g<c[fr].length;g++)e+="1";d=d.substr(0,b)+e+d.substr(b+fr.length,d.length-(b+fr.length));a=a.substr(0,b)+c[fr]+a.substr(b+fr.length,a.length-
(b+fr.length));b=b+c[fr].length+1;e=""}return a}for(e=0;e<c.length;e++)a=a.replace(new RegExp(c.charAt(e),"g"),d.charAt(e));return a},uniqid:function(a,c){"undefined"==typeof a&&(a="");var d,b=function(a,c){a=parseInt(a,10).toString(16);return c<a.length?a.slice(a.length-c):c>a.length?Array(1+(c-a.length)).join("0")+a:a};this.php_js||(this.php_js={});this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random()));this.php_js.uniqidSeed++;d=a+b(parseInt((new Date).getTime()/1E3,
10),8);d+=b(this.php_js.uniqidSeed,5);c&&(d+=(10*Math.random()).toFixed(8).toString());return d},version_compare:function(a,c,d){this.php_js=this.php_js||{};this.php_js.ENV=this.php_js.ENV||{};var b=0,f=0,g=0,h={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},b=function(a){a=(""+a).replace(/[_\-+]/g,".");a=a.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,".");return a.length?a.split("."):[-8]},k=function(a){return a?isNaN(a)?h[a]||-7:parseInt(a,10):0};a=b(a);c=b(c);f=Math.max(a.length,
c.length);for(b=0;b<f;b++)if(a[b]!=c[b])if(a[b]=k(a[b]),c[b]=k(c[b]),a[b]<c[b]){g=-1;break}else if(a[b]>c[b]){g=1;break}if(!d)return g;switch(d){case ">":case "gt":return 0<g;case ">=":case "ge":return 0<=g;case "<=":case "le":return 0>=g;case "==":case "=":case "eq":return 0===g;case "<>":case "!=":case "ne":return 0!==g;case "":case "<":case "lt":return 0>g;default:return null}},inObject:function(a,c){var d=!1,b;for(b in c)if(c[b].toLowerCase()==a.toLowerCase()){d=!0;break}return d},removeByValue:function(a,
c){return-1!==c.indexOf(a)?(c.splice(c.indexOf(a),1),!0):!1},doSortSelectByText:function(a){if(a.children("optgroup").length)a.children("optgroup").each(function(){var a=b.makeArray(b(this).children("option")).sort(function(a,c){return b(a).text()>b(c).text()?1:b(a).text()<b(c).text()?-1:0});b(this).empty().html(a)});else{var c=b.makeArray(a.children("option")).sort(function(a,c){return b(a).text()>b(c).text()?1:b(a).text()<b(c).text()?-1:0});a.empty().html(c)}},addParamToUrl:function(a,c,d){var b=
a.indexOf("?"),f=a.indexOf("#");b==a.length-1&&(a=a.substring(0,b),b=-1);return(0<f?a.substring(0,f):a)+(0<b?"&"+c+"="+d:"?"+c+"="+d)+(0<f?a.substring(f):"")},removeParamFromUrl:function(a,c){var d=a.match(new RegExp(c+"\\=([a-z0-9]+)","i"));d&&(d=d[0],0<=a.search("&"+d)?a=a.replace("&"+d,""):0<=a.search("\\?"+d+"&")?a=a.replace("?"+d+"&",""):0<=a.search("\\?"+d)&&(a=a.replace("?"+d,"")));return a},showValidationError:function(a,c){var d=c.next(".motopress-validation-error");d.length&&d.remove();
this.validationError.clone().text(a).insertAfter(c)},getScrollbarWidth:function(){var a=window.browserScrollbarWidth;if("undefined"===typeof a){var c=b('<div style="width: 50px; height: 50px; position: absolute; left: -100px; top: -100px; overflow: auto;"><div style="width: 1px; height: 100px;"></div></div>');b("body").append(c);a=c[0].offsetWidth-c[0].clientWidth;c.remove()}return a},getSpanClass:function(a){for(var c=new RegExp("^("+parent.CE.Iframe.myThis.gridObj.span["class"]+")\\d{1,2}$","i"),
d=null,b=0;b<a.length;b++)if(c.test(a[b])){d=a[b];break}return d},getSpanNumber:function(a){return parseInt(a.match(/\d{1,2}/i))},notClone:function(a,c){return null===c||a[0]!==c.draggable[0]&&a[0]!==c.helper[0]?!0:!1},calcSpanNumber:function(a,c){var d=(a.hasClass("motopress-row-edge")?a:a.find(".motopress-row-edge").first()).children('[class*="'+parent.CE.Iframe.myThis.gridObj.span["class"]+'"].motopress-clmn'),e=0;d.length&&d.each(function(){if(MP.Utils.notClone(b(this),c)){var a=MP.Utils.getSpanNumber(MP.Utils.getSpanClass(b(this).prop("class").split(" ")));
e+=a}});return e},getHandleClass:function(a){for(var c=/^ui-resizable-(n|e|s|w|se|sw)$/i,d=null,b=0;b<a.length;b++)if(c.test(a[b])){d=a[b];break}return d},setup:function(){var a=navigator.userAgent.toLowerCase();this.Browser={Version:(a.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],Chrome:/chrome/.test(a),Safari:/webkit/.test(a),Opera:/opera/.test(a),IE:/msie/.test(a)&&!/opera/.test(a),Mozilla:/mozilla/.test(a)&&!/(compatible|webkit)/.test(a)}},getEditorActiveMode:function(a){for(var c=/^(tmce|html)-active$/i,
b=null,e=0;e<a.length;e++)c.test(a[e])&&(b=a[e]);return b},addWindowFix:function(){"function"===typeof tb_show&&"function"===typeof tb_remove&&(this.tbStyle=b("<style />",{type:"text/css",text:"#TB_overlay {z-index: 1051;} #TB_window {z-index: 1052;}"}).appendTo("head"))},removeWindowFix:function(){null!==this.tbStyle&&this.tbStyle.remove()},base64_decode:function(a){var c,b,e,f,g,h=0,k=0;f="";var l=[];if(!a)return a;a+="";do c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)),
b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)),f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)),g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(a.charAt(h++)),e=c<<18|b<<12|f<<6|g,c=e>>16&255,b=e>>8&255,e&=255,64==f?l[k++]=String.fromCharCode(c):64==g?l[k++]=String.fromCharCode(c,b):l[k++]=String.fromCharCode(c,b,e);while(h<a.length);f=l.join("");return f=this.utf8_decode(f)},base64_encode:function(a){var c,
b,e,f,g=0,h=0,k="",k=[];if(!a)return a;a=this.utf8_encode(a+"");do c=a.charCodeAt(g++),b=a.charCodeAt(g++),e=a.charCodeAt(g++),f=c<<16|b<<8|e,c=f>>18&63,b=f>>12&63,e=f>>6&63,f&=63,k[h++]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(c)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(b)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(e)+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".charAt(f);while(g<
a.length);k=k.join("");a=a.length%3;return(a?k.slice(0,a-3):k)+"===".slice(a||3)},utf8_decode:function(a){var c=[],b=0,e=0,f=0,g=0,h=0;for(a+="";b<a.length;)f=a.charCodeAt(b),128>f?(c[e++]=String.fromCharCode(f),b++):191<f&&224>f?(g=a.charCodeAt(b+1),c[e++]=String.fromCharCode((f&31)<<6|g&63),b+=2):(g=a.charCodeAt(b+1),h=a.charCodeAt(b+2),c[e++]=String.fromCharCode((f&15)<<12|(g&63)<<6|h&63),b+=3);return c.join("")},utf8_encode:function(a){if(null===a||"undefined"===typeof a)return"";a+="";var c=
"",b,e,f=0;b=e=0;for(var f=a.length,g=0;g<f;g++){var h=a.charCodeAt(g),k=null;128>h?e++:k=127<h&&2048>h?String.fromCharCode(h>>6|192)+String.fromCharCode(h&63|128):String.fromCharCode(h>>12|224)+String.fromCharCode(h>>6&63|128)+String.fromCharCode(h&63|128);null!==k&&(e>b&&(c+=a.slice(b,e)),c+=k,b=e=g+1)}e>b&&(c+=a.slice(b,f));return c},nl2br:function(a,b){return(a+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+(b||"undefined"===typeof b?"<br />":"<br>")+"$2")},br2nl:function(a){return a.replace(/<br[^>]*>\s*\r*\n*/g,
"\n")},addWpFrontEndEditorFix:function(){var a=b("#post-preview").data("events");"undefined"!==typeof a&&a.hasOwnProperty("click")&&(a=a.click.slice(),b.each(a,function(a,d){-1!==d.handler.toString().indexOf("wp_fee_redirect")&&(MP.Utils.wpFrontEndEditorEvents.push(d),b("#post-preview").data("events").click.splice(b("#post-preview").data("events").click.indexOf(d),1))}))},removeWpFrontEndEditorFix:function(){this.wpFrontEndEditorEvents.length&&(b.merge(b("#post-preview").data("events").click,this.wpFrontEndEditorEvents),
this.wpFrontEndEditorEvents.length=0)}},{})});
steal("jquery/controller",function(b){b.Controller("CE.Iframe",{myThis:null,window:null,contents:null,tmpPostId:null,wpEditor:null,wpTextarea:null},{gridObj:null,grid:b("<div />",{id:"motopress-ce-grid","class":"mp-container"}),divDisablePlugin:b("<div />",{"class":"motopress-disable-plugin"}),isHeadwayTheme:null,body:null,init:function(a){CE.Iframe.myThis=this;CE.Iframe.window=this.element[0].contentWindow;CE.Iframe.wpTextarea=b("#wp-content-editor-container #content");a.addClass("motopress-tmp-iframe-width");
b.ajax({url:parent.motopress.ajaxUrl,type:"POST",dataType:"json",data:{action:"motopress_ce_get_library",nonce:parent.motopressCE.nonces.motopress_ce_get_library,postID:parent.motopressCE.postID},success:function(b){CE.Iframe.myThis.gridObj=b.grid;CE.Iframe.myThis.getTinyMCEContent();a.on("load",CE.Iframe.myThis.proxy("onLoad"))},error:function(a){console.log("error",a)}})},onLoad:function(){CE.Navbar.myThis.onIframeLoad(this.element);CE.Iframe.contents=this.element.contents();CE.Iframe.contents.find('link[href*="js_composer"]').remove();
MP.Utils.addWpFrontEndEditorFix();var a=CE.Iframe.contents.find("head")[0],c=b("<script />",{text:'var steal = { production: "mp/ce/iframeProd/production.js" + parent.motopress.pluginVersionParam };'})[0];this.appendScript(a,c);c=b("<script />",{src:MP.Settings.pluginRootUrl+"/"+MP.Settings.pluginName+"/steal/steal.production.js?mp/ce/iframeProd"})[0];this.appendScript(a,c);this.body=CE.Iframe.contents.find("body");this.body.find("#wp-motopress-tmp-editor-wrap").hide();a=this.body.find(".motopress-content-wrapper");
a.length||(this.body.append(this.divDisablePlugin),this.isHeadwayTheme?MP.Flash.setFlash(localStorage.getItem("CENeedHeadwayThemeGrid"),"error"):MP.Flash.setFlash(localStorage.getItem("CENeedContentOutput"),"error"));this.element.removeClass("motopress-tmp-iframe-width");c=a.width();this.body.addClass("motopress-body");a.find("script").remove();var d=a.parents(),e=d.length-3;a.siblings(":not(link, style, script)").remove();d.each(function(a){b(this).addClass("motopress-content-wrapper-default");b(this).siblings(":not(link, style, script)").remove();
return a<e});a.wrap('<div class="'+CE.Iframe.myThis.gridObj.span.fullclass+'" />').parent().wrap('<div class="'+CE.Iframe.myThis.gridObj.row["class"]+' motopress-row" />').parent().wrap('<div id="motopress-container" class="mp-container" />');var d=a.closest("#motopress-container>.motopress-row"),f=parseFloat(d.css("margin-left")),g=parseFloat(d.css("margin-right"));d.attr("data-margin-left",f);c=c-f-g;d.addClass("motopress-row-no-margin");a.find("."+CE.Iframe.myThis.gridObj.span.minclass+".motopress-clmn").addClass("motopress-clmn-min");
var h=a.closest("#motopress-container");400>c?(c=400,h.css("min-width",c),this.grid.css("min-width",c)):1170<c&&(c=1170);h.css("max-width",c);this.grid.css("max-width",c);a=b('<div class="motopress-scene-light"></div>');c=b('<div class="motopress-scene-dark"></div>');h.append(b('<div class="motopress-scene-color"></div>').append(a,c));var k=function(){h.addClass("mp-container-dark");CE.Iframe.myThis.body.addClass("mp-scene-dark")};"true"==sessionStorage.getItem("motopressSceneIsDark")&&k();a.on("click",
function(){h.removeClass("mp-container-dark");CE.Iframe.myThis.body.removeClass("mp-scene-dark");sessionStorage.setItem("motopressSceneIsDark","false")});c.on("click",function(){k();sessionStorage.setItem("motopressSceneIsDark","true")});this.unwrapGrid();this.body.prepend(this.grid);a=h.find(".motopress-more-handler");a.length||(a=jQuery("<section />",{"class":"motopress-more-handler motopress-more-handler-disabled"}),a.prependTo(h.find(".motopress-content-wrapper")));a.attr("title",localStorage.getItem("CEMoreHandlerTitle"));
c=a.closest(".motopress-content-wrapper>.motopress-row");c.length&&a.insertAfter(c);b("body").hide(0,function(){b("body").show()});b.ajax({url:motopress.ajaxUrl,data:{action:"motopress_ce_remove_temporary_post",nonce:motopressCE.nonces.motopress_ce_remove_temporary_post,post_id:CE.Iframe.tmpPostId,postID:motopressCE.postID},type:"POST",error:function(a){a=b.parseJSON(a.responseText);a.debug?console.log(a.message):(MP.Flash.setFlash(a.message,"error"),MP.Flash.showMessage())}})},unwrapGrid:function(){this.body.find('div[data-motopress-group="mp_grid"]').each(function(){var a=
b(this),c=a.attr("data-motopress-group"),d=a.attr("data-motopress-shortcode"),e=a.attr("data-motopress-parameters"),f=a.attr("data-motopress-styles"),a=a.children("div");a.attr("data-motopress-group",c);a.attr("data-motopress-shortcode",d);e.length&&a.attr("data-motopress-parameters",e);f.length&&a.attr("data-motopress-styles",f);a.unwrap()})},renderContent:function(a){"undefined"===typeof a&&(a="");a=a.replace(/(?:<p>)?\x3c!--more(.*?)?--\x3e(?:<\/p>)?/,'<section class="motopress-more-handler"></section>').replace(/(?:<p>)?\x3c!--more(.*?)?--\x3e(?:<\/p>)?/,
"");var c=b("#motopress-ce-btn").attr("data-post-id");b.ajax({url:motopress.ajaxUrl,type:"POST",dataType:"json",data:{action:"motopress_ce_render_content",nonce:motopressCE.nonces.motopress_ce_render_content,data:a,post_id:c,postID:motopressCE.postID},success:function(b){CE.Iframe.tmpPostId=b.post_id;var c=MP.Utils.addParamToUrl(b.src,"motopress-ce",1);CE.Iframe.window.location.replace(c);c=new RegExp("\\[/"+CE.Iframe.myThis.gridObj.row.shortcode+"\\]","ig");a.length&&!c.test(a)&&MP.Flash.setFlash(localStorage.getItem("CEDefaultWPEditor"),
"info");CE.Iframe.myThis.isHeadwayTheme=b.hasOwnProperty("headway_themes")&&!0===b.headway_themes;MP.Preloader.myThis.load(CE.Iframe.shortName)},error:function(a){console.log(a.responseText);a=b.parseJSON(a.responseText);console.log(a.message)}})},getTinyMCEContent:function(){if("undefined"!==typeof tinyMCE){var a=MP.Utils.getEditorActiveMode(b("#wp-content-wrap").prop("class").split(" "));CE.Iframe.wpEditor=tinyMCE.get("content");if("html-active"===a)if(switchEditors.switchto(b("#content-tmce")[0]),
"undefined"===typeof CE.Iframe.wpEditor||null===CE.Iframe.wpEditor)if("4"==tinyMCE.majorVersion)tinyMCE.on("AddEditor",function(a){if("content"===a.editor.id)a.editor.on("init",function(b){CE.Iframe.wpEditor=a.editor;CE.Iframe.myThis.renderContent(a.editor.getContent({format:"html"}))})});else tinyMCE.onAddEditor.add(function(a,b){"content"===b.editorId&&b.onInit.add(function(a){CE.Iframe.wpEditor=a;CE.Iframe.myThis.renderContent(a.getContent({format:"html"}))})});else this.renderContent(CE.Iframe.wpEditor.getContent({format:"html"}));
else this.renderContent(CE.Iframe.wpEditor.getContent({format:"html"}))}else a=CE.Iframe.wpTextarea.val().length?switchEditors._wp_Autop(CE.Iframe.wpTextarea.val()).replace(RegExp("\n","g"),""):"",this.renderContent(a)},appendScript:function(a,b){a.appendChild(b)},prependScript:function(a,b){a.insertBefore(b,a.firstChild)},wpLinkCloseCallback:function(a){b("#wp-link").on("wpdialogclose.motopress",function(c){b("#wp-link").off("wpdialogclose.motopress");a()})}})});
steal("jquery/controller",function(b){b.Controller("CE.Navbar",{myThis:null},{iframe:b("#motopress-content-editor-scene"),scrollWidth:15,postStatus:null,postType:null,postNameObj:null,postNameObjInput:null,wpPostNameForm:null,wpPostNameFormPrompt:null,wpPostName:null,tutorialsCounter:0,init:function(a){CE.Navbar.myThis=this;CE.Iframe.myThis=null;this.wpPostNameForm=b('form[name="post"] input[name="post_title"]');this.wpPostNameFormPrompt=b('form[name="post"] #title-prompt-text');this.postType=a.find(".motopress-page-name #motopress-post-type").text();
this.postNameObj=a.find(".motopress-page-name #motopress-title");this.postNameObjInput=a.find(".motopress-page-name").children("#motopress-input-edit-title");this.setupBtns();b('link[href*="js_composer"]').remove();this.showContentEditor();b("#motopress-ce-btn").on("click",function(){var a=sessionStorage.getItem("motopressPluginAutoSaved");a&&"true"===a||(MP.Preloader.myThis.reopen(),new MP.Preloader(b("#motopress-preload")),new CE.Iframe(b("#motopress-content-editor-scene")),CE.Navbar.myThis.showContentEditor())});
0===b("#motopress-content-editor-scene-wrapper").height()&&(a=b("#motopress-content-editor-scene-wrapper").parent().height()-53,0<a&&b("#motopress-content-editor-scene-wrapper").height(a),a=b("#motopress-content-editor").parent().height()-32,0<a&&b("#motopress-content-editor").height(a),b(window).resize(function(){var a=b("#motopress-content-editor-scene-wrapper").parent().height()-53;0<a&&b("#motopress-content-editor-scene-wrapper").height(a);a=b("#motopress-content-editor").parent().height()-32;
0<a&&b("#motopress-content-editor").height(a)}));MP.Preloader.myThis.load(CE.Navbar.shortName)},onIframeLoad:function(a){this.wpPostName=this.wpPostNameForm.val();0===this.wpPostName.length?(this.postNameObj.empty().append(b("<i />",{text:localStorage.getItem("CEEmptyPostTitle")})),this.postNameObjInput.val("")):(this.postNameObj.text(this.wpPostName),this.postNameObjInput.val(this.wpPostName));this.scrollWidth=MP.Utils.getScrollbarWidth();var c=this.scrollWidth+724+80;a.css("min-width",c);b(".motopress-content-editor-navbar.ce_navbar").css("min-width",
c)},setupBtns:function(){var a="";b("form#post input#save-post").length?(this.postStatus="draft",a=localStorage.getItem("CEPublishBtnText")):(this.postStatus="published",a=localStorage.getItem("CEUpdateBtnText"),b("#motopress-content-editor-save").hide());b("#motopress-content-editor-publish").text(a)},"#motopress-title click":function(a,b){this.postNameObj.hide();this.postNameObjInput.show().select()},"#motopress-input-edit-title blur":function(a,c){var d=a[0];""==d.value?(this.postNameObj.empty().append(b("<i />",
{text:localStorage.getItem("CEEmptyPostTitle")})),this.wpPostNameForm.val(d.value),this.wpPostNameFormPrompt.removeClass("screen-reader-text")):(this.postNameObj.text(d.value),this.wpPostNameForm.val(d.value),this.wpPostNameFormPrompt.addClass("screen-reader-text"));this.postNameObjInput.hide();this.postNameObj.show()},"#motopress-input-edit-title keypress":function(a,c){var d=a[0];"13"==c.keyCode&&(""==d.value?(this.postNameObj.empty().append(b("<i />",{text:localStorage.getItem("CEEmptyPostTitle")})),
this.wpPostNameForm.val(d.value),this.wpPostNameFormPrompt.removeClass("screen-reader-text")):(this.postNameObj.text(d.value),this.wpPostNameForm.val(d.value),this.wpPostNameFormPrompt.addClass("screen-reader-text")),this.postNameObjInput.hide(),this.postNameObj.show())},"#motopress-content-editor-tutorials click":function(a){var b=jQuery("#motopress-tutorials-modal");jQuery("body");b.mpmodal("toggle");0===this.tutorialsCounter&&jQuery.ajax({type:"post",dataType:"html",url:motopress.ajaxUrl,data:{action:"motopress_tutorials"},
success:function(a){0!=a&&"nothing"!=a?b.find(".modal-body").html(a):b.find(".modal-body").html("<h1>Error: can't load tutorials.<h1>")}});this.tutorialsCounter++},"#motopress-content-editor-publish click":function(a){CE.Save.save();if(a.hasClass("motopress-ajax-update")){a.prop("disabled",!0).text(localStorage.getItem("CEUpdating"));var c=jQuery("form#post").serializeArray(),d=this;jQuery.ajax({type:"post",data:c,success:function(b){a.prop("disabled",!1).text(localStorage.getItem("CEUpdateBtnText"));
b=jQuery("#post-preview").attr("href");MP.Flash.setFlash(parent.MP.Utils.strtr(localStorage.getItem("CEPostSaved"),{"%postType%":d.postType,"%link%":b,"%preview%":localStorage.getItem("CEPreviewBtnText")}),"success");MP.Flash.showMessage()},error:function(a){console.log(a)}})}else MP.Preloader.myThis.show(),this.setPluginAutoOpen(!0),b("form#post #publish").click()},"#motopress-content-editor-save click":function(a){CE.Save.save();if(a.hasClass("motopress-ajax-update")){a.prop("disabled",!0).text(localStorage.getItem("CESaving"));
var c=jQuery("form#post").serializeArray(),d=this;jQuery.ajax({type:"post",data:c,success:function(b){a.prop("disabled",!1).text(localStorage.getItem("CESaveBtnText"));b=jQuery("#post-preview").attr("href");MP.Flash.setFlash(parent.MP.Utils.strtr(localStorage.getItem("CEPostSaved"),{"%postType%":d.postType,"%link%":b,"%preview%":localStorage.getItem("CEPreviewBtnText")}),"success");MP.Flash.showMessage()},error:function(a){console.log(a)}})}else MP.Preloader.myThis.show(),this.setPluginAutoOpen(!0),
b("form#post #save-post").click()},"#motopress-content-editor-preview click":function(){CE.Save.save();b("form#post #post-preview").click()},"#motopress-content-editor-delete click":function(){CE.Iframe.window.CE.Tools.myThis.removeBlock();CE.Save.changeContent()},"#motopress-content-editor-close click":function(){CE.Save.save();this.hideContentEditor();b("#motopress-content-editor-scene").off("load");MP.Utils.removeWindowFix();MP.Utils.removeWpFrontEndEditorFix();this.hideObjectControlBtns()},hideContentEditor:function(){MP.Error.terminate()},
showContentEditor:function(){b("html").css({overflow:"hidden",paddingTop:0});b("#motopress-content-editor").siblings(':not("#'+MP.Preloader.myThis.element.attr("id")+', script, link")').each(function(){b(this).is(":hidden")||b(this).addClass("motopress-hide")});b("#wpwrap").height("100%").children("#wpcontent").children("#wpadminbar").prependTo("body");b("#motopress-content-editor").show()},showObjectControlBtns:function(){b(".motopress-object-control-btns").css("display","inline-block")},hideObjectControlBtns:function(){b(".motopress-object-control-btns").hide()},
setPluginAutoOpen:function(a){sessionStorage.setItem("motopressPluginAutoOpen",a)},getPluginAutoOpen:function(){sessionStorage.getItem("motopressPluginAutoOpen")}})});
steal("jquery/class",function(b){b.Class("CE.Save",{isContentChanged:!1,excerpt:"",isNeedSaveExcerpt:!1,compareString:"",getCompareString:function(){return(b("#title").val()||"")+"::"+(b("#content").val()||"")+"::"+(b("#excerpt").val()||"")},save:function(){this.isContentChanged=!1;this.convertAndInsert();this.isNeedSaveExcerpt=!1;this.excerpt="";this.compareString=this.getCompareString();$this=this;wp.autosave&&($this.compareString=this.getCompareString(),b(window).off("beforeunload.edit-post").on("beforeunload.edit-post",
function(){var a="undefined"!==typeof tinymce&&tinymce.get("content");if(a&&!a.isHidden()&&a.isDirty()||$this.compareString!==$this.getCompareString())return postL10n.saveAlert}))},convertAndInsert:function(){var a=CE.Iframe.contents.find("body .motopress-content-wrapper");a.length&&(a=this.getSources("",a),null!==parent.CE.Iframe.wpEditor?(parent.CE.Iframe.wpEditor.setContent(a,{format:"html"}),tinyMCE.triggerSave()):parent.CE.Iframe.wpTextarea.val(parent.switchEditors._wp_Nop(a)),parent.MP.Settings.saveExcerpt&&
this.isNeedSaveExcerpt&&(a=b("#postexcerpt #excerpt",parent.document),a.length&&a.val(parent.switchEditors._wp_Nop(this.excerpt))))},getSources:function(a,c,d){"undefined"===typeof d&&(d=1);var e=this,f=null,g=null,f=1===d?parent.CE.Iframe.myThis.gridObj.row.shortcode:parent.CE.Iframe.myThis.gridObj.row.inner;c.children(".motopress-row, .motopress-more-handler").each(function(){var c=b(this),k=b(this).hasClass("motopress-row-edge")?b(this):b(this).find(".motopress-row-edge").first();1===d&&c.hasClass("motopress-more-handler")?
c.hasClass("motopress-more-handler-disabled")||(e.isNeedSaveExcerpt=!0,e.excerpt=a,a+="\x3c!--more--\x3e"):(a+="<p>["+f+e.getAttributesConsideringDependency(c,"parameters")+e.getAttributes(c,"styles")+"]</p>",k.children('[class*="'+parent.CE.Iframe.myThis.gridObj.span["class"]+'"].motopress-clmn').each(function(){var c=b(this),f=MP.Utils.getSpanClass(c.prop("class").split(" ")),f=MP.Utils.getSpanNumber(f),h="",k="";c.hasClass("motopress-empty")&&(h=' classes="motopress-empty mp-hidden-phone"');c.hasClass("motopress-space")&&
(h=' classes="motopress-space"');var m=c.get(0).style.minHeight;if(m.length){var n=parseInt(m);isNaN(n)||n===CE.Iframe.window.CE.Resizer.myThis.minHeight||n===CE.Iframe.window.CE.Resizer.myThis.spaceMinHeight||(k=' style="min-height: '+m+';"')}parent.CE.Iframe.myThis.gridObj.span.type&&"multiple"===parent.CE.Iframe.myThis.gridObj.span.type?(g=1===d?parent.CE.Iframe.myThis.gridObj.span.shortcode[f-1]:parent.CE.Iframe.myThis.gridObj.span.inner[f-1],mpSpanAttr=""):(mpSpanAttr=" "+parent.CE.Iframe.myThis.gridObj.span.attr+
'="'+f+'"',g=1===d?parent.CE.Iframe.myThis.gridObj.span.shortcode:parent.CE.Iframe.myThis.gridObj.span.inner);a+="<p>["+g+mpSpanAttr+h+k+e.getAttributes(c,"parameters")+e.getAttributes(c,"styles")+"]</p>";a=c.children(".motopress-row").length?e.getSources(a,c,d+1):e.getShortcode(a,c.find(".motopress-block-content > [data-motopress-shortcode]"));a+="<p>[/"+g+"]</p>"}),a+="<p>[/"+f+"]</p>")});return a},getShortcode:function(a,b){b.children("div");if(b.length){var d="",e=b.attr("data-motopress-shortcode"),
f=b.attr("data-motopress-close-type"),g="undefined"===typeof b.attr("data-motopress-unwrap")?!1:!0,h="",k="";"enclosed"===f&&(f=(f=b.attr("data-motopress-content"))?f.replace(/\[\]/g,"["):"",d+=f,k="<p>[/"+e+"]</p>");g||(h="<p>["+e+this.getAttributes(b,"parameters")+this.getAttributes(b,"styles")+"]</p>",d=h+d+k);a+=d}return a},changeContent:function(){if(!this.isContentChanged){var a=parent.CE.Iframe.wpEditor;if(a){var b=a.getContent({format:"html"}),b=b+("MOTOPRESS_"+MP.Utils.uniqid());a.setContent(b,
{format:"html"});a.focus();this.isContentChanged=!0}}},getAttributes:function(a,c){var d=a.attr("data-motopress-"+c),e="";d&&(d=JSON.parse(d),b.each(d,function(a,b){"undefined"!==typeof b.value&&""!==b.value&&(e+=" "+a+'="'+b.value+'"')}));return e},getAttributesConsideringDependency:function(a,c){var d=a.attr("data-motopress-"+c),e="",f=a.attr("data-motopress-group"),g=a.attr("data-motopress-shortcode"),h=CE.Iframe.window.CE.LeftBar.myThis.library[f].objects[g].parameters;d&&(d=JSON.parse(d),b.each(d,
function(a,c){if(-1===b.inArray(g,["mp_row","mp_row_inner"])||"undefined"===typeof h[a].disabled||"true"!==h[a].disabled||-1===b.inArray(a,"bg_video_youtube bg_video_youtube_cover bg_video_webm bg_video_mp4 bg_video_ogg bg_video_cover parallax_image".split(" ")))a in h&&"undefined"!==typeof h[a].dependency&&d[h[a].dependency.parameter].value!==h[a].dependency.value&&("undefined"===typeof h[a].disabled||"false"===h[a].disabled)||"undefined"!==typeof c.value&&""!==c.value&&(e+=" "+a+'="'+c.value+'"')}));
return e}},{})});
steal("jquery/class",function(b){b.Class("MP.Settings",{siteUrl:null,debug:null,adminUrl:null,pluginRootUrl:null,pluginName:null,palettes:null,lang:null,langName:null,loadScriptsUrl:null,spellcheck:null,saveExcerpt:null,setup:function(){"undefined"===typeof CE&&this.removeWpPanels();this.getSiteUrl();this.getWpSettings()},removeWpPanels:function(){b("#footer, #adminmenuwrap, #adminmenuback, .update-nag").remove();b("#wpcontent").css("margin-left",0);b("#wpbody-content").css("padding-bottom",0);b("#wpfooter").remove()},
getSiteUrl:function(){var a=window.location.href,b=a.indexOf("/wp-admin/");this.siteUrl=a.substr(0,b)},getWpSettings:function(){var a=null,c=null;"undefined"!==typeof motopressLE?(a=motopressLE.nonces.motopress_ce_get_wp_settings,c=!1):(a=motopressCE.nonces.motopress_ce_get_wp_settings,c=motopressCE.postID);b.ajax({url:motopress.ajaxUrl,data:{action:"motopress_ce_get_wp_settings",nonce:a,postID:c},dataType:"json",type:"POST",success:function(a){MP.Settings.debug=a.debug;MP.Settings.adminUrl=a.admin_url;
MP.Settings.pluginRootUrl=a.plugin_root_url;MP.Settings.pluginName=a.plugin_name;MP.Settings.palettes=a.palettes;MP.Settings.licenseType=a.license_type;MP.Settings.lang=a.lang;MP.Settings.loadScriptsUrl=a.load_scripts_url;MP.Settings.spellcheck="1"==a.spellcheck;MP.Settings.saveExcerpt="1"===a.save_excerpt;if(MP.Utils.Browser.IE||MP.Utils.Browser.Opera)window.location=MP.Settings.adminUrl+"?page="+MP.Settings.pluginName;new MP.Language},error:function(){MP.Flash.setFlash(localStorage.getItem("wpSettingsError"),
"error");MP.Flash.showMessage()}})}},{})});
steal("jquery/class",function(b){b.Class("MP.Language",{init:function(){b.ajax({url:MP.Settings.pluginRootUrl+"/"+MP.Settings.pluginName+"/lang/"+MP.Settings.lang.mpce+motopress.pluginVersionParam,type:"GET",dataType:"json",data:"",success:function(a){localStorage.clear();b.each(a.lang,function(a,b){localStorage.setItem(a,b)});MP.Settings.langName=a.name;CE.init(b);MP.Preloader.myThis.load(MP.Language.shortName)},error:function(){MP.Flash.setFlash(localStorage.getItem("langJsonNotFound"),"error");
MP.Flash.showMessage()}})}})});
steal("jquery/controller",function(b){b.Controller("CE.CodeModal",{myThis:null,currentShortcode:null,currentTextareaTinymce:null,listensTo:["show","shown","hide"]},{iframeBody:null,content:null,editor:null,saveBtn:null,saveHandler:null,init:function(){CE.CodeModal.myThis=this;this.content=this.element.find("#motopresscodecontent");"undefined"!==typeof tinyMCE&&"undefined"!==typeof tinyMCE.get("motopresscodecontent")&&(this.editor=tinyMCE.get("motopresscodecontent"));this.saveBtn=this.element.find("#motopress-save-code-content");
var a=this.element.find("#wp-motopresscodecontent-editor-tools");0===a.height()&&a.height(33);this.element.mpmodal({backdrop:"static",show:!1});b(window).on("resize",this.proxy("resize"));MP.Utils.addWindowFix()},setSize:function(a){var b=this.element.find(".modal-footer"),d=this.element.width()-(parseFloat(b.css("padding-left"))+parseFloat(b.css("padding-right")));b.width(d);d=this.element.find(".modal-body");b=this.element.height()-this.element.find(".modal-header").outerHeight()-parseFloat(d.css("margin-top"))-
parseFloat(d.css("margin-bottom"))-b.outerHeight();d.height(b);a&&this.element.css({display:"block",visibility:"hidden"});b=this.element.find("#wp-motopresscodecontent-editor-container");d=this.element.find("#wp-motopresscodecontent-wrap").height()-this.element.find("#wp-motopresscodecontent-editor-tools").height()-parseFloat(b.css("border-top-width"))-parseFloat(b.css("border-bottom-width"));b.height(d);var e=d-parseFloat(b.css("border-top-width"))-parseFloat(b.css("border-bottom-width"))-this.element.find("#qt_motopresscodecontent_toolbar").outerHeight()-
parseFloat(this.content.css("padding-top"))-parseFloat(this.content.css("padding-bottom"));this.content.height(e);var e=this.element.find("#motopresscodecontent_ifr"),f=b.find(".mce-first, tr.mceFirst").first(),g=b.find(".mce-statusbar, tr.mceLast").last(),b=d-parseFloat(b.css("border-top-width"))-parseFloat(b.css("border-bottom-width"))-f.outerHeight()-g.outerHeight();e.height(b);a&&(this.element.css({display:"",visibility:""}),this.content.removeAttr("rows"))},resize:function(){this.element.data("modal").isShown&&
this.setSize(!1)},show:function(a,b){this.setSize(!0);this.switchVisual();if(null!==this.saveHandler&&"function"===typeof this.saveHandler)this.saveBtn.off("click").on("click",this.saveHandler);null===this.iframeBody&&(this.iframeBody=this.element.find("#motopresscodecontent_ifr").contents().find(".motopresscodecontent"),this.iframeBody.css("max-width","none"));CE.Iframe.window.CE.Dialog.myThis.element.dialog("isOpen")&&!a.data("modal").hasOwnProperty("closeDialog")&&CE.Iframe.window.CE.Dialog.myThis.element.dialog("close")},
shown:function(){null!==this.editor?this.editor.execCommand("mceFocus",!1):this.content.focus();b("body").hide(0,function(){b("body").show()})},hide:function(a,b){var d=CE.CodeModal.currentShortcode.parent("."+CE.Iframe.window.CE.DragDrop.myThis.blockContent.attr("class")).next("."+CE.Iframe.window.CE.DragDrop.myThis.helper.attr("class")).children("."+CE.Iframe.window.CE.DragDrop.myThis.dragHandle.attr("class"));d.prev().focus();this.content.val("");null!==this.editor&&this.editor.setContent("");
this.saveHandler=null;null!==CE.Iframe.wpEditor&&CE.Iframe.wpEditor.focus();a.data("modal").hasOwnProperty("closeDialog")&&delete a.data("modal").closeDialog;CE.Iframe.window.CE.Dialog.myThis.element.dialog("isOpen")||CE.Iframe.window.CE.Dialog.myThis.open(d);var e=setTimeout(function(){CE.CodeModal.currentShortcode=null;CE.CodeModal.currentTextareaTinymce=null;clearTimeout(e)},0)},switchVisual:function(){var a=MP.Utils.getEditorActiveMode(this.element.find("#wp-motopresscodecontent-wrap").prop("class").split(" "));
"undefined"!==typeof tinyMCE&&"html-active"===a&&(switchEditors.switchto(this.element.find("#motopresscodecontent-tmce")[0]),null===this.editor&&(this.editor=tinyMCE.get("motopresscodecontent")))}})});
