text: prettypress=new function(){this.status=0,this.hooked_tinymce="no",this.hooked_text="no",this.markdown_active="no",this.publish_menu_active="no",this.initial_editor_width=jQuery("#wp-content-wrap").width(),this.toggle=function(){var a=jQuery("[name=auto_draft]").val();if("1"===a)return this.prelaunchsave(),!1;if(0===this.status)if(1===this.findpageurl()){jQuery("#content-markdown").show(),jQuery("#wp-content-wrap").addClass("prettypress_entry_field"),jQuery("#titlewrap").addClass("prettypress_title"),jQuery("#prettypress_wrapper").fadeIn(500),jQuery("#prettypress_iframe").load(function(){prettypress.frameload()});var b=jQuery("#prettypress_iframe").attr("src");if(this.src!=b){var c=this.src;jQuery("#prettypress_iframe").attr("src",c)}this.status=1,prettypress.resize()}else this.error("Couldn't find any page to draw original theme from. You may need to press 'save' if you have just created this post.",5e3);else jQuery("#content-markdown").hide(),jQuery("#prettypress_wrapper").fadeOut(500),jQuery("#wp-content-wrap").removeClass("prettypress_entry_field"),jQuery("#wp-content-wrap").css("width",prettypress.initial_editor_width+"px"),jQuery("#titlewrap").removeClass("prettypress_title"),jQuery("#titlewrap").css("width",prettypress.initial_editor_width+"px"),"yes"===prettypress.markdown_active&&prettypress.togglemarkdown(),this.status=0},this.prelaunchsave=function(){var a=this.getactivetitle();if(a){jQuery("form#post").append('<input type="hidden" name="prettypress_active" value="1" />');var b=this.getactivecontent();return"undefined"!=typeof tinymce&&null!=tinymce.activeEditor?tinymce.activeEditor.setContent(b):jQuery("textarea#content").val(b),jQuery("#save-post").click(),!0}return this.error("Sorry, you need to enter a post title before PrettyPress can provide a live preview.",5e3),!0},this.publish=function(){var a=this.getactivecontent();"undefined"!=typeof tinymce&&null!=tinymce.activeEditor?tinymce.activeEditor.setContent(a):jQuery("textarea#content").val(a),jQuery("#publish").click()},this.resize=function(){var a=jQuery("#prettypress_wrapper").css("padding-top").replace(/[A-Za-z$-]/g,"");a=2*parseInt(a);var b=jQuery("#prettypress_wrapper").css("height").replace(/[A-Za-z$-]/g,"");b=parseInt(b)-a;var c=b-230;b+=a,jQuery("#prettypress_iframe").css("width",jQuery("#prettypress_preview_container").css("width")),jQuery("#prettypress_iframe").css("height",b+"px"),jQuery("#content_ifr").css("height",c+"px")},this.findpageurl=function(){var a=jQuery("#prettypress_post_permalink").val();return a?(this.src=a,1):(this.src="",0)},this.error=function(a,b){b||(b=0);var c=this.generateUid("error");jQuery("#prettypress_warnings").append('<div id="'+c+'" class="prettypress_warning_box"><p><strong>PrettyPress error: </strong>'+a+"</p><p><small>Click this message to hide it</small></p></div>"),0!=b&&window.setTimeout(function(){jQuery("#"+c).fadeOut(1e3,function(){jQuery(this).remove()})},b)},this.generateUid=function(a){function b(){return(65536*(1+Math.random())|0).toString(16).substring(1)}var c=a||"-";return b()+b()+c+b()+c+b()+c+b()+c+b()+b()+b()},this.frameload=function(){var a=jQuery("#prettypress_iframe");jQuery("[title]",a.contents()).each(function(){var a=jQuery(this).attr("title");"<span data-rel="===a&&jQuery(this).removeAttr("title")}),jQuery("#wpadminbar",a.contents()).hide(),jQuery("html",a.contents()).css("margin-top","0!important");var b=jQuery("[data-rel=title]",a.contents()).html();b?this.current_content_title=b:this.error("Couldn't find a title on preview page. You need to add data-rel='title' to the element holding it.",5e3);var c=jQuery("[data-rel=content]",a.contents()).html();b?this.current_content=c:this.error("Couldn't find the content on preview page. You need to add data-rel='content' to the element holding it.",5e3),this.updatepreviewcontent("content")},this.updatepreviewcontent=function(a){var b=jQuery("#prettypress_iframe");if(1===prettypress.status)if("title"===a){var c=this.getactivetitle();c!=this.current_content_title&&(jQuery("[data-rel=title]",b.contents()).html(c),this.current_content_title=c)}else if("content"===a){var d=this.getactivecontent();d!=this.current_content&&(jQuery("[data-rel=content]",b.contents()).html(d),this.current_content=d)}},this.getactivetitle=function(){return jQuery("#title").val()},this.getactivecontent=function(){if("yes"===prettypress.markdown_active){var a=prettypress.getmarkdownvalue();return marked(a)}return"none"===jQuery("textarea#content").css("display")?tinymce.activeEditor.getContent():jQuery("textarea#content").val()},this.hooktinymce=function(){tinymce.activeEditor.onKeyUp.add(function(){prettypress.updatepreviewcontent("content")}),tinymce.activeEditor.onChange.add(function(){prettypress.updatepreviewcontent("content")})},this.bootuphooks=function(){prettypress.tinymceexists()&&null!=tinymce.activeEditor&&(prettypress.hooktinymce(),prettypress.hooked_tinymce="yes"),jQuery("textarea#content").keyup(function(){prettypress.updatepreviewcontent("content")}),prettypress.hooked_text="yes",jQuery("textarea#prettypress_markdown").keyup(function(){prettypress.updatepreviewcontent("content")})},this.recursivehooks=function(){return prettypress.tinymceexists()?"yes"===prettypress.hooked_tinymce&&"yes"===prettypress.hooked_text?(clearInterval(prettypress.recursinghnd),!1):void("no"===prettypress.hooked_tinymce&&null!=tinymce.activeEditor&&(prettypress.hooktinymce(),prettypress.hooked_tinymce="yes")):(clearInterval(prettypress.recursinghnd),!1)},this.tinymceexists=function(){return"undefined"==typeof tinymce?!1:!0},this.togglemarkdown=function(){if("yes"===prettypress.markdown_active){var a=prettypress.getactivecontent();prettypress.tinymceexists()&&null!=tinymce.activeEditor&&tinymce.activeEditor.setContent(a),jQuery("textarea#content").val(a),jQuery("#prettypress_markdown_editor_wrapper").hide(),jQuery("#wp-content-editor-container").show(),jQuery("#content-resize-handle").show(),jQuery("#insert-media-button").show(),prettypress.markdown_active="no"}else{var a=prettypress.getactivecontent(),b=toMarkdown(a);jQuery("#prettypress_markdown").val(b),jQuery("#wp-content-editor-container").hide(),jQuery("#content-resize-handle").hide(),jQuery("#insert-media-button").hide(),jQuery("#prettypress_markdown_editor_wrapper").show(),prettypress.markdown_active="yes"}},this.getmarkdownvalue=function(){return"yes"===prettypress.markdown_active?jQuery("#prettypress_markdown").val():void 0},this.publishmenutoggle=function(){"no"===prettypress.publish_menu_active?(jQuery("#prettypress_publish_menu").show(),prettypress.publish_menu_active="yes"):(jQuery("#prettypress_publish_menu").hide(),prettypress.publish_menu_active="no")}};