2019-10-05 15:49:10 -04:00
|
|
|
window.wp=window.wp||{},function(f,m){m.editor=m.editor||{},window.switchEditors=new function(){var s,d,n={};function e(){!s&&window.tinymce&&(s=window.tinymce,(d=s.$)(document).on("click",function(e){var t=d(e.target);t.hasClass("wp-switch-editor")&&r(t.attr("data-wp-editor-id"),t.hasClass("switch-tmce")?"tmce":"html")}))}function u(e){var t=d(".mce-toolbar-grp",e.getContainer())[0],n=t&&t.clientHeight;return n&&10<n&&n<200?parseInt(n,10):30}function r(e,t){e=e||"content",t=t||"toggle";var n,r,i=s.get(e),a=d("#wp-"+e+"-wrap"),o=d("#"+e),c=o[0];if("toggle"===t&&(t=i&&!i.isHidden()?"html":"tmce"),"tmce"===t||"tinymce"===t){if(i&&!i.isHidden())return!1;void 0!==window.QTags&&window.QTags.closeAllTags(e),n=parseInt(c.style.height,10)||0;(i?i.getParam("wp_keep_scroll_position"):window.tinyMCEPreInit.mceInit[e]&&window.tinyMCEPreInit.mceInit[e].wp_keep_scroll_position)&&function(e){if(!e||!e.length)return;var t=e[0],n=function(e,t){var n=t.cursorStart,r=t.cursorEnd,i=l(e,n);i&&(n=-1!==["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"].indexOf(i.tagType)?i.ltPos:i.gtPos);var a=l(e,r);a&&(r=a.gtPos);var o=g(e,n);o&&!o.showAsPlainText&&(n=o.urlAtStartOfContent?o.endIndex:o.startIndex);var c=g(e,r);c&&!c.showAsPlainText&&(r=c.urlAtEndOfContent?c.startIndex:c.endIndex);return{cursorStart:n,cursorEnd:r}}(t.value,{cursorStart:t.selectionStart,cursorEnd:t.selectionEnd}),r=n.cursorStart,i=n.cursorEnd,a=r!==i?"range":"single",o=null,c=b(d,"").attr("data-mce-type","bookmark");if("range"==a){var p=t.value.slice(r,i),s=c.clone().addClass("mce_SELRES_end");o=[p,s[0].outerHTML].join("")}t.value=[t.value.slice(0,r),c.clone().addClass("mce_SELRES_start")[0].outerHTML,o,t.value.slice(i)].join("")}(o),i?(i.show(),!s.Env.iOS&&n&&50<(n=n-u(i)+14)&&n<5e3&&i.theme.resizeTo(null,n),i.getParam("wp_keep_scroll_position")&&w(i)):s.init(window.tinyMCEPreInit.mceInit[e]),a.removeClass("html-active").addClass("tmce-active"),o.attr("aria-hidden",!0),window.setUserSetting("editor","tinymce")}else if("html"===t){if(i&&i.isHidden())return!1;if(i){s.Env.iOS||(n=(r=i.iframeElement)?parseInt(r.style.height,10):0)&&50<(n=n+u(i)-14)&&n<5e3&&(c.style.height=n+"px");var p=null;i.getParam("wp_keep_scroll_position")&&(p=function(e){var t=e.getWin().getSelection();if(!t||t.rangeCount<1)return;var n="SELRES_"+Math.random(),r=b(e.$,n),i=r.clone().addClass("mce_SELRES_start"),a=r.clone().addClass("mce_SELRES_end"),o=t.getRangeAt(0),c=o.startContainer,p=o.startOffset,s=o.cloneRange();0<e.$(c).parents(".mce-offscreen-selection").length?(c=e.$("[data-mce-selected]")[0],i.attr("data-mce-object-selection","true"),a.attr("data-mce-object-selection","true"),e.$(c).before(i[0]),e.$(c).after(a[0])):(s.collapse(!1),s.insertNode(a[0]),s.setStart(c,p),s.collapse(!0),s.insertNode(i[0]),o.setStartAfter(i[0]),o.setEndBefore(a[0]),t.removeAllRanges(),t.addRange(o));e.on("GetContent",x);var d=E(e.getContent());e.off("GetContent",x),i.remove(),a.remove();var l=new RegExp('<span[^>]*\\s*class="mce_SELRES_start"[^>]+>\\s*'+n+"[^<]*<\\/span>(\\s*)"),g=new RegExp('(\\s*)<span[^>]*\\s*class="mce_SELRES_end"[^>]+>\\s*'+n+"[^<]*<\\/span>"),u=d.match(l),w=d.match(g);if(!u)return null;var f=u.index,m=u[0].length,h=null;if(w){-1!==u[0].indexOf("data-mce-object-selection")&&(m-=u[1].length);var v=w.index;-1!==w[0].indexOf("data-mce-object-selection")&&(v-=w[1].length),h=v-m}return{start:f,end:h}}(i)),i.hide(),p&&function(e,t){if(!t)return;var n=e.getElement(),r=t.start,i=t.end||t.start;n.focus&&setTimeout(function(){n.setSelectionRange(r,i),n.blur&&n.blur(),n.focus()},100)}(i,p)}else o.css({display:"",visibility:""});a.removeClass("tmce-active").addClass("html-active"),o.attr("aria-hidden",!1),window.setUserSetting("editor","html")}}function l(e,t){var n=e.lastIndexOf("<",t-1);if(e.lastIndexOf(">",t)<n||">"===e.substr(t,1)){var r=e.substr(n),i=r.match(/<\s*(\/)?(\w+|\!-{2}.*-{2})/);if(!i)return null;var a=i[2];return{ltPos:n,gtPos:n+r.indexOf(">")+1,tagType:a,isClosingTag:!!i[1]}}return null}function g(e,t){for(var n=function(e){var t,
|