!function(a,b){"use strict";var c=b(a),d=b(document),e=b("#wpadminbar"),f=b("#wpfooter");b(function(){function g(){var a=c.width();T={windowHeight:c.height(),windowWidth:a,adminBarHeight:a>600?e.outerHeight():0,toolsHeight:t.outerHeight()||0,menuBarHeight:A.outerHeight()||0,visualTopHeight:u.outerHeight()||0,textTopHeight:w.outerHeight()||0,bottomHeight:z.outerHeight()||0,statusBarHeight:B.outerHeight()||0,sideSortablesHeight:C.height()||0},T.menuBarHeight<3&&(T.menuBarHeight=0)}function h(b){var c,d,e,f,g,h=jQuery.ui.keyCode,i=b.keyCode,j=document.createRange(),k=x[0].selectionStart,l=x[0].selectionEnd,m=y[0].firstChild,n=10;if(!k||!l||k===l){try{j.setStart(m,k),j.setEnd(m,l+1)}catch(o){}c=j.getBoundingClientRect(),c.height&&(d=c.top-n,e=d+c.height+n,f=T.adminBarHeight+T.toolsHeight+T.textTopHeight,g=T.windowHeight-T.bottomHeight,f>d&&(i===h.UP||i===h.LEFT||i===h.BACKSPACE)?a.scrollTo(a.pageXOffset,d+a.pageYOffset-f):e>g&&a.scrollTo(a.pageXOffset,e+a.pageYOffset-g))}}function i(){if(!(p&&!p.isHidden()||!p&&"tinymce"===R)){var a,b=x.height();y.width(x.width()-22),y.text(x.val()+" "),a=y.height(),Q>a&&(a=Q),a!==b&&(x.height(a),j())}}function j(b){if(!F||!F.settings.visible){var e,h,j,k,l,m,n,o,q,r=c.scrollTop(),G=b&&b.type,H="scroll"!==G,N=p&&!p.isHidden(),R=Q,U=E.offset().top,V=1,W=s.width();(H||!T.windowHeight)&&g(),N||"resize"!==G||i(),N?(e=u,h=v,n=T.visualTopHeight):(e=w,h=x,n=T.textTopHeight),m=e.parent().offset().top,o=h.offset().top,q=h.outerHeight(),l=N?Q+n:Q+20,l=q>l+5,l?((!I||H)&&r>=m-T.toolsHeight-T.adminBarHeight&&r<=m-T.toolsHeight-T.adminBarHeight+q-R?(I=!0,t.css({position:"fixed",top:T.adminBarHeight,width:W}),N&&A.length&&A.css({position:"fixed",top:T.adminBarHeight+T.toolsHeight,width:W-2*V-(N?0:e.outerWidth()-e.width())}),e.css({position:"fixed",top:T.adminBarHeight+T.toolsHeight+T.menuBarHeight,width:W-2*V-(N?0:e.outerWidth()-e.width())})):(I||H)&&(r<=m-T.toolsHeight-T.adminBarHeight?(I=!1,t.css({position:"absolute",top:0,width:W}),N&&A.length&&A.css({position:"absolute",top:0,width:W-2*V}),e.css({position:"absolute",top:T.menuBarHeight,width:W-2*V-(N?0:e.outerWidth()-e.width())})):r>=m-T.toolsHeight-T.adminBarHeight+q-R&&(I=!1,t.css({position:"absolute",top:q-R,width:W}),N&&A.length&&A.css({position:"absolute",top:q-R,width:W-2*V}),e.css({position:"absolute",top:q-R+T.menuBarHeight,width:W-2*V-(N?0:e.outerWidth()-e.width())}))),(!J||H&&S)&&r+T.windowHeight<=o+q+T.bottomHeight+T.statusBarHeight+V?b&&b.deltaHeight>0&&b.deltaHeight<100?a.scrollBy(0,b.deltaHeight):S&&(J=!0,B.css({position:"fixed",bottom:T.bottomHeight,visibility:"",width:W-2*V}),z.css({position:"fixed",bottom:0,width:W})):(!S&&J||(J||H)&&r+T.windowHeight>o+q+T.bottomHeight+T.statusBarHeight-V)&&(J=!1,B.add(z).attr("style",""),S||B.css("visibility","hidden"))):H&&(t.css({position:"absolute",top:0,width:W}),N&&A.length&&A.css({position:"absolute",top:0,width:W-2*V}),e.css({position:"absolute",top:T.menuBarHeight,width:W-2*V-(N?0:e.outerWidth()-e.width())}),B.add(z).attr("style","")),D.width()<300&&T.windowWidth>600&&d.height()>C.height()+U+120&&T.windowHeightT.windowHeight||K||L?U>=r+O?(C.attr("style",""),K=L=!1):r>M?K?(K=!1,j=C.offset().top-T.adminBarHeight,k=f.offset().top,kr&&(L?(L=!1,j=C.offset().top-P,k=f.offset().top,k=r+O&&(K=!0,C.css({position:"fixed",top:O,bottom:""}))):(r>=U-O?C.css({position:"fixed",top:O}):C.attr("style",""),K=L=!1),M=r):(C.attr("style",""),K=L=!1),H&&(s.css({paddingTop:T.toolsHeight}),N?v.css({paddingTop:T.visualTopHeight+T.menuBarHeight}):(x.css({marginTop:T.textTopHeight}),y.width(W-20-2*V)))}}function k(){i(),j()}function l(a){for(var b=1;6>b;b++)setTimeout(a,500*b)}function m(){clearTimeout(q),q=setTimeout(j,100)}function n(){a.pageYOffset&&a.pageYOffset>N&&a.scrollTo(a.pageXOffset,0),r.addClass("wp-editor-expand"),c.on("scroll.editor-expand resize.editor-expand",function(a){j(a.type),m()}),d.on("wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand",j).on("postbox-toggled.editor-expand",function(){!K&&!L&&a.pageYOffset>O&&(L=!0,a.scrollBy(0,-1),j(),a.scrollBy(0,1)),j()}).on("wp-window-resized.editor-expand",function(){p&&!p.isHidden()?p.execCommand("wpAutoResize"):i()}),x.on("focus.editor-expand input.editor-expand propertychange.editor-expand",i),x.on("keyup.editor-expand",h),G(),F&&F.pubsub.subscribe("hidden",k),p&&(p.settings.wp_autoresize_on=!0,p.execCommand("wpAutoResizeOn"),p.isHidden()||p.execCommand("wpAutoResize")),(!p||p.isHidden())&&i(),j(),d.trigger("editor-expand-on")}function o(){var e=a.getUserSetting("ed_size");a.pageYOffset&&a.pageYOffset>N&&a.scrollTo(a.pageXOffset,0),r.removeClass("wp-editor-expand"),c.off(".editor-expand"),d.off(".editor-expand"),x.off(".editor-expand"),H(),F&&F.pubsub.unsubscribe("hidden",k),b.each([u,w,t,A,z,B,s,v,x,C],function(a,b){b&&b.attr("style","")}),I=J=K=L=!1,p&&(p.settings.wp_autoresize_on=!1,p.execCommand("wpAutoResizeOff"),p.isHidden()||(x.hide(),e&&p.theme.resizeTo(null,e))),e&&x.height(e),d.trigger("editor-expand-off")}var p,q,r=b("#postdivrich"),s=b("#wp-content-wrap"),t=b("#wp-content-editor-tools"),u=b(),v=b(),w=b("#ed_toolbar"),x=b("#content"),y=b('
'),z=b("#post-status-info"),A=b(),B=b(),C=b("#side-sortables"),D=b("#postbox-container-1"),E=b("#post-body"),F=a.wp.editor&&a.wp.editor.fullscreen,G=function(){},H=function(){},I=!1,J=!1,K=!1,L=!1,M=0,N=130,O=56,P=20,Q=300,R=a.getUserSetting("editor"),S=!!parseInt(a.getUserSetting("hidetb"),10),T={windowHeight:0,windowWidth:0,adminBarHeight:0,toolsHeight:0,menuBarHeight:0,visualTopHeight:0,textTopHeight:0,bottomHeight:0,statusBarHeight:0,sideSortablesHeight:0};y.insertAfter(x),y.css({"font-family":x.css("font-family"),"font-size":x.css("font-size"),"line-height":x.css("line-height"),"white-space":"pre-wrap","word-wrap":"break-word"}),d.on("tinymce-editor-init.editor-expand",function(d,e){function f(){var a,b,c,d=e.selection.getNode();if(e.plugins.wpview&&(b=e.plugins.wpview.getView(d)))c=b.getBoundingClientRect();else{a=e.selection.getRng();try{c=a.getClientRects()[0]}catch(f){}c||(c=d.getBoundingClientRect())}return c.height?c:!1}function g(a){var b=a.keyCode;47>=b&&b!==q.SPACEBAR&&b!==q.ENTER&&b!==q.DELETE&&b!==q.BACKSPACE&&b!==q.UP&&b!==q.LEFT&&b!==q.DOWN&&b!==q.UP||b>=91&&93>=b||b>=112&&123>=b||144===b||145===b||h(b)}function h(b){var c,d,g,h,i=f(),j=50;i&&(c=i.top+e.iframeElement.getBoundingClientRect().top,d=c+i.height,c-=j,d+=j,g=T.adminBarHeight+T.toolsHeight+T.menuBarHeight+T.visualTopHeight,h=T.windowHeight-(S?T.bottomHeight+T.statusBarHeight:0),h-gc&&(b===q.UP||b===q.LEFT||b===q.BACKSPACE)?a.scrollTo(a.pageXOffset,c+a.pageYOffset-g):d>h&&a.scrollTo(a.pageXOffset,d+a.pageYOffset-h)))}function k(a){a.state||j()}function m(){c.on("scroll.mce-float-panels",t),setTimeout(function(){e.execCommand("wpAutoResize"),j()},300)}function n(){c.off("scroll.mce-float-panels"),setTimeout(function(){var b=s.offset().top;a.pageYOffset>b&&a.scrollTo(a.pageXOffset,b-T.adminBarHeight),i(),j()},100),j()}function o(){S=!S}var q=a.tinymce.util.VK,t=_.debounce(function(){!b(".mce-floatpanel:hover").length&&a.tinymce.ui.FloatPanel.hideAll(),b(".mce-tooltip").hide()},1e3,!0);"content"===e.id&&(p=e,e.settings.autoresize_min_height=Q,u=s.find(".mce-toolbar-grp"),v=s.find(".mce-edit-area"),B=s.find(".mce-statusbar"),A=s.find(".mce-menubar"),G=function(){e.on("keyup",g),e.on("show",m),e.on("hide",n),e.on("wp-toolbar-toggle",o),e.on("setcontent wp-autoresize wp-toolbar-toggle",j),e.on("undo redo",h),e.on("FullscreenStateChanged",k),c.off("scroll.mce-float-panels").on("scroll.mce-float-panels",t)},H=function(){e.off("keyup",g),e.off("show",m),e.off("hide",n),e.off("wp-toolbar-toggle",o),e.off("setcontent wp-autoresize wp-toolbar-toggle",j),e.off("undo redo",h),e.off("FullscreenStateChanged",k),c.off("scroll.mce-float-panels")},r.hasClass("wp-editor-expand")&&(G(),l(j)))}),r.hasClass("wp-editor-expand")&&(n(),s.hasClass("html-active")&&l(function(){j(),i()})),b("#adv-settings .editor-expand").show(),b("#editor-expand-toggle").on("change.editor-expand",function(){b(this).prop("checked")?(n(),a.setUserSetting("editor_expand","on")):(o(),a.setUserSetting("editor_expand","off"))}),a.editorExpand={on:n,off:o}}),b(function(){function g(){R||(R=!0,d.trigger("dfw-activate"),K.on("keydown.focus-shortcut",u))}function h(){R&&(k(),R=!1,d.trigger("dfw-deactivate"),K.off("keydown.focus-shortcut"))}function i(){return R}function j(){!S&&R&&(S=!0,K.on("keydown.focus",n),J.add(K).on("blur.focus",p),n(),a.setUserSetting("post_dfw","on"),d.trigger("dfw-on"))}function k(){S&&(S=!1,J.add(K).off(".focus"),o(),I.off(".focus"),a.setUserSetting("post_dfw","off"),d.trigger("dfw-off"))}function l(){S?k():j()}function m(){return S}function n(b){var d=b&&b.keyCode;return 27===d||87===d&&b.altKey&&b.shiftKey?void o(b):void(b&&(b.metaKey||b.ctrlKey&&!b.altKey||b.altKey&&b.shiftKey||d&&(47>=d&&8!==d&&13!==d&&32!==d&&46!==d||d>=91&&93>=d||d>=112&&135>=d||d>=144&&150>=d||d>=224))||(v||(v=!0,clearTimeout(E),E=setTimeout(function(){L.show()},600),I.css("z-index",9998),L.on("mouseenter.focus",function(){y=I.offset(),y.right=y.left+I.outerWidth(),y.bottom=y.top+I.outerHeight(),c.on("scroll.focus",function(){var b=a.pageYOffset;C&&B&&C!==b&&(By.bottom+V)&&o(),C=b})}).on("mouseleave.focus",function(){z=A=null,T=U=0,c.off("scroll.focus")}).on("mousemove.focus",function(a){var b=a.pageX,c=a.pageY;if(z&&A&&(b!==z||c!==A))if(A>=c&&c=A&&c>y.bottom||z>=b&&b=z&&b>y.right){if(T+=Math.abs(z-b),U+=Math.abs(A-c),(c<=y.top-V||c>=y.bottom+V||b<=y.left-V||b>=y.right+V)&&(T>10||U>10))return o(),z=A=null,void(T=U=0)}else T=U=0;z=b,A=c}).on("touchstart.focus",function(a){a.preventDefault(),o()}),I.off("mouseenter.focus"),D&&(clearTimeout(D),D=null),G.addClass("focus-on").removeClass("focus-off")),q(),s()))}function o(a){v&&(v=!1,clearTimeout(E),E=setTimeout(function(){L.hide()},200),I.css("z-index",""),L.off("mouseenter.focus mouseleave.focus mousemove.focus touchstart.focus"),"undefined"==typeof a&&I.on("mouseenter.focus",function(){(b.contains(I.get(0),document.activeElement)||F)&&n()}),D=setTimeout(function(){D=null,I.off("mouseenter.focus")},1e3),G.addClass("focus-off").removeClass("focus-on")),r(),t()}function p(){setTimeout(function(){function a(a){return b.contains(a.get(0),document.activeElement)}var c=document.activeElement.compareDocumentPosition(I.get(0));2!==c&&4!==c||!(a(O)||a(H)||a(f))||o()},0)}function q(){!w&&v&&(w=!0,e.on("mouseenter.focus",function(){e.addClass("focus-off")}).on("mouseleave.focus",function(){e.removeClass("focus-off")}))}function r(){w&&(w=!1,e.off(".focus"))}function s(){x||!v||M.find(":focus").length||(x=!0,M.stop().fadeTo("fast",.3).on("mouseenter.focus",t).off("mouseleave.focus"),N.on("focus.focus",t).off("blur.focus"))}function t(){x&&(x=!1,M.stop().fadeTo("fast",1).on("mouseleave.focus",s).off("mouseenter.focus"),N.on("blur.focus",s).off("focus.focus"))}function u(a){a.altKey&&a.shiftKey&&87===a.keyCode&&l()}var v,w,x,y,z,A,B,C,D,E,F,G=b(document.body),H=b("#wpcontent"),I=b("#post-body-content"),J=b("#title"),K=b("#content"),L=b(document.createElement("DIV")),M=b("#edit-slug-box"),N=M.find("a").add(M.find("button")).add(M.find("input")),O=b("#adminmenuwrap"),P=b(),Q=b(),R="on"===a.getUserSetting("editor_expand","on"),S=R?"on"===a.getUserSetting("post_dfw"):!1,T=0,U=0,V=20;G.append(L),L.css({display:"none",position:"fixed",top:e.height(),right:0,bottom:0,left:0,"z-index":9997}),I.css({position:"relative"}),c.on("mousemove.focus",function(a){B=a.pageY}),b("#postdivrich").hasClass("wp-editor-expand")&&K.on("keydown.focus-shortcut",u),d.on("tinymce-editor-setup.focus",function(a,b){b.addButton("dfw",{active:S,classes:"wp-dfw btn widget",disabled:!R,onclick:l,onPostRender:function(){var a=this;d.on("dfw-activate.focus",function(){a.disabled(!1)}).on("dfw-deactivate.focus",function(){a.disabled(!0)}).on("dfw-on.focus",function(){a.active(!0)}).on("dfw-off.focus",function(){a.active(!1)})},tooltip:"Distraction Free Writing",shortcut:"Alt+Shift+W"}),b.addCommand("wpToggleDFW",l),b.addShortcut("alt+shift+w","","wpToggleDFW")}),d.on("tinymce-editor-init.focus",function(a,c){function e(){F=!0}function f(){F=!1}var g,h;"content"===c.id&&(P=b(c.getWin()),Q=b(c.getContentAreaContainer()).find("iframe"),g=function(){c.on("keydown",n),c.on("blur",p),c.on("focus",e),c.on("blur",f)},h=function(){c.off("keydown",n),c.off("blur",p),c.off("focus",e),c.off("blur",f)},S&&g(),d.on("dfw-on.focus",g).on("dfw-off.focus",h),c.on("click",function(a){a.target===c.getDoc().documentElement&&c.focus()}))}),d.on("quicktags-init",function(a,c){var d;c.settings.buttons&&-1!==(","+c.settings.buttons+",").indexOf(",dfw,")&&(d=b("#"+c.name+"_dfw"),b(document).on("dfw-activate",function(){d.prop("disabled",!1)}).on("dfw-deactivate",function(){d.prop("disabled",!0)}).on("dfw-on",function(){d.addClass("active")}).on("dfw-off",function(){d.removeClass("active")}))}),d.on("editor-expand-on.focus",g).on("editor-expand-off.focus",h),S&&(K.on("keydown.focus",n),J.add(K).on("blur.focus",p)),a.wp=a.wp||{},a.wp.editor=a.wp.editor||{},a.wp.editor.dfw={activate:g,deactivate:h,isActive:i,on:j,off:k,toggle:l,isOn:m}})}(window,window.jQuery);