]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/tinymce/plugins/wpview/plugin.min.js
WordPress 4.0
[autoinstalls/wordpress.git] / wp-includes / js / tinymce / plugins / wpview / plugin.min.js
index f11bf25fd3f3c4c163a3e59db91f6bff87f37652..d6e7866cbee9426c2432c0304ca15b902a0d8008 100644 (file)
@@ -1 +1 @@
-tinymce.PluginManager.add("wpview",function(a){function b(a){for(;a&&"BODY"!==a.nodeName;){if(c(a))return a;a=a.parentNode}}function c(a){return a&&/\bwpview-wrap\b/.test(a.className)}function d(){return a.dom.create("p",{"data-wpview-pad":1},tinymce.Env.ie&&tinymce.Env.ie<11?"":'<br data-mce-bogus="1" />')}function e(c){return c=b("string"==typeof c?a.dom.get(c):c),c?window.decodeURIComponent(a.dom.getAttrib(c,"data-wpview-text")||""):""}function f(c,d){return c=b("string"==typeof c?a.dom.get(c):c),c?(a.dom.setAttrib(c,"data-wpview-text",window.encodeURIComponent(d||"")),!0):!1}function g(a){a.stopPropagation()}function h(b){var c,d=a.dom;b!==l&&(i(),l=b,d.addClass(b,"selected"),c=d.create("div",{"class":"wpview-clipboard",contenteditable:"true"},e(b)),b.insertBefore(c,b.firstChild),d.bind(c,"beforedeactivate focusin focusout",g),d.bind(l,"beforedeactivate focusin focusout",g),a.getBody().focus(),a.selection.select(c,!0))}function i(){var b,c=a.dom;l&&(b=a.dom.select(".wpview-clipboard",l)[0],c.unbind(b),c.remove(b),c.unbind(l,"beforedeactivate focusin focusout click mouseup",g),c.removeClass(l,"selected")),l=null}function j(b,d){for(var e=a.getBody(),f="previous"===d?"previousSibling":"nextSibling";b&&b.parentNode!==e;){if(b[f])return!1;b=b.parentNode}return c(b[f])?(h(b[f]),!0):!1}function k(a){return a.replace(/(<div[^>]+wpview-wrap[^>]+>)[\s\S]+?data-wpview-end[^>]*><\/ins><\/div>/g,"$1</div>")}var l,m=tinymce.util.VK,n=tinymce.dom.TreeWalker,o=!1;if("undefined"!=typeof wp&&wp.mce)return a.on("BeforeAddUndo",function(a){a.lastLevel&&k(a.level.content)===k(a.lastLevel.content)&&a.preventDefault()}),a.on("BeforeSetContent",function(b){b.content&&(b.initial||wp.mce.views.unbind(a),b.content=wp.mce.views.toViews(b.content))}),a.on("SetContent",function(b){var e,f;wp.mce.views.render(),(b.load||!b.set)&&(e=a.getBody(),c(e.lastChild)&&(f=d(),e.appendChild(f),b.initial||a.selection.setCursorLocation(f,0)))}),a.on("click",function(b){var e,f,g,h,j,k=a.getBody(),l=a.getDoc(),m=l.documentElement.scrollTop||k.scrollTop||0;"HTML"!==b.target.nodeName||b.metaKey||b.ctrlKey||(g=k.firstChild,h=k.lastChild,e=b.clientX,f=b.clientY,c(g)&&(e<g.offsetLeft&&f<g.offsetHeight-m||f<g.offsetTop)?(j=d(),k.insertBefore(j,g)):c(h)&&(e>h.offsetLeft+h.offsetWidth||m+f-(h.offsetTop+h.offsetHeight)>0)&&(j=d(),k.appendChild(j)),j&&(i(),a.getBody().focus(),a.selection.setCursorLocation(j,0)))}),a.on("init",function(){var d=a.selection;a.on("BeforeSetContent",function(){var e,f,g=b(d.getNode());g&&(!g.nextSibling||c(g.nextSibling)?(f=a.getDoc().createTextNode(""),a.dom.insertAfter(f,g)):(e=new n(g.nextSibling,g.nextSibling),f=e.next()),d.select(f),d.collapse(!0))}),a.on("SetContent",function(a){if(a.context){var b=d.getNode();b.innerHTML&&(b.innerHTML=wp.mce.views.toViews(b.innerHTML))}}),a.dom.bind(a.getBody(),"mousedown mouseup click",function(c){var d,e=b(c.target);return e?(c.stopPropagation(),tinymce.Env.ie<=10&&i(),h(e),"click"!==c.type||c.metaKey||c.ctrlKey||(a.dom.hasClass(c.target,"edit")?wp.mce.views.edit(e):a.dom.hasClass(c.target,"remove")&&a.dom.remove(e)),!1):(d=tinymce.Env.ie&&tinymce.Env.ie<=8?"mouseup":"mousedown",void(c.type===d&&i()))})}),a.on("PreProcess",function(b){var c=a.dom;tinymce.each(c.select("p[data-wpview-pad]",b.node),function(a){c.isEmpty(a)?c.remove(a):c.setAttrib(a,"data-wpview-pad",null)}),tinymce.each(c.select("div[data-wpview-text]",b.node),function(a){"textContent"in a?a.textContent=" ":a.innerText=" "})}),a.on("PostProcess",function(a){a.content&&(a.content=a.content.replace(/<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g,function(a,b){return b?"<p>"+window.decodeURIComponent(b)+"</p>":""}))}),a.on("keydown",function(e){var f,g,j=e.keyCode,k=a.getBody();if(l){if(e.metaKey||e.ctrlKey||j>=112&&123>=j)return void((e.metaKey||e.ctrlKey)&&88===j&&(o=l));if(f=b(a.selection.getNode()),f!==l)return void i();j===m.LEFT||j===m.UP?(i(),c(f.previousSibling)?h(f.previousSibling):f.previousSibling?(a.selection.select(f.previousSibling,!0),a.selection.collapse()):(g=d(),k.insertBefore(g,k.firstChild),a.selection.setCursorLocation(k.firstChild,0))):j===m.RIGHT||j===m.DOWN?(i(),c(f.nextSibling)?h(f.nextSibling):f.nextSibling?a.selection.setCursorLocation(f.nextSibling,0):(g=d(),k.appendChild(g),a.selection.setCursorLocation(k.lastChild,0))):(j===m.DELETE||j===m.BACKSPACE)&&a.dom.remove(l),e.preventDefault()}}),a.on("keydown",function(b){var c,d,e=b.keyCode,f=a.dom,g=a.selection.getRng(),h=g.startContainer,i=a.getBody();if(h&&h!==i&&!b.metaKey&&!b.ctrlKey)if(e===m.UP||e===m.LEFT){if(e===m.LEFT&&(!g.collapsed||0!==g.startOffset))return;if(!(c=f.getParent(h,f.isBlock)))return;j(c,"previous")&&b.preventDefault()}else if(e===m.DOWN||e===m.RIGHT){if(!(c=f.getParent(h,f.isBlock)))return;if(e===m.RIGHT){if(d=g.endContainer,!g.collapsed||0===g.startOffset&&d.length||d.nextSibling||3===d.nodeType&&g.startOffset!==d.length)return;for(;d&&d!==c&&d!==i;){if(d.nextSibling)return;d=d.parentNode}}j(c,"next")&&b.preventDefault()}}),a.on("keyup",function(b){var e,f,g=b.keyCode,h=a.getBody();o&&(a.dom.remove(o),o=!1),(g===m.DELETE||g===m.BACKSPACE)&&(c(h.lastChild)&&(e=d(),h.appendChild(e),2===h.childNodes.length&&a.selection.setCursorLocation(e,0)),f=a.selection.getRng(),h.firstChild===f.startContainer&&f.collapsed===!0&&c(f.startContainer.nextSibling)&&0===f.startOffset&&a.dom.remove(f.startContainer))}),{getViewText:e,setViewText:f}});
\ No newline at end of file
+tinymce.PluginManager.add("wpview",function(a){function b(a){return c(a,"wpview-wrap")}function c(a,b){for(;a&&a.parentNode;){if(a.className&&-1!==(" "+a.className+" ").indexOf(" "+b+" "))return a;a=a.parentNode}return!1}function d(c){return(c=b(c))?window.decodeURIComponent(a.dom.getAttrib(c,"data-wpview-text")||""):""}function e(c,d){return c=b(c),c?(a.dom.setAttrib(c,"data-wpview-text",window.encodeURIComponent(d||"")),!0):!1}function f(a){a.stopPropagation()}function g(b,c){var d=b?"before":"after",e=b?0:1;k(),a.selection.setCursorLocation(a.dom.select(".wpview-selection-"+d,c)[0],e),a.nodeChanged()}function h(b,c,d){var e=a.dom,f=e.create("p");t.ie&&t.ie<11||(f.innerHTML='<br data-mce-bogus="1">'),c?b.parentNode.insertBefore(f,b):e.insertAfter(f,b),k(),c&&d===u.ENTER?g(c,b):a.selection.setCursorLocation(f,0),a.nodeChanged()}function i(b){a.undoManager.transact(function(){h(b),a.dom.remove(b)})}function j(b){var c,e=a.dom;b&&b!==n&&(a.getBody().focus(),k(),n=b,e.setAttrib(b,"data-mce-selected",1),c=e.create("div",{"class":"wpview-clipboard",contenteditable:"true"},d(b)),a.dom.select(".wpview-body",b)[0].appendChild(c),e.bind(c,"beforedeactivate focusin focusout",f),e.bind(n,"beforedeactivate focusin focusout",f),z?a.selection.select(c):a.selection.select(c,!0),a.nodeChanged(),a.fire("wpview-selected",b))}function k(){var b,c=a.dom;n&&(b=a.dom.select(".wpview-clipboard",n)[0],c.unbind(b),c.remove(b),c.unbind(n,"beforedeactivate focusin focusout click mouseup",f),c.setAttrib(n,"data-mce-selected",null)),n=null}function l(a){return a.replace(/<div[^>]+data-wpview-text=\"([^"]+)"[^>]*>[\s\S]+?wpview-selection-after[^>]+>(?:&nbsp;|\u00a0)*<\/p><\/div>/g,"$1")}function m(a){return 47>=a&&a!==u.SPACEBAR&&a!==u.ENTER&&a!==u.DELETE&&a!==u.BACKSPACE&&(37>a||a>40)||a>=224||a>=144&&150>=a||a>=91&&93>=a||a>=112&&135>=a}var n,o,p,q,r,s,t=tinymce.Env,u=tinymce.util.VK,v=tinymce.dom.TreeWalker,w=!1,x=!0,y=function(){return!1},z=/iPad|iPod|iPhone/.test(navigator.userAgent);return"undefined"!=typeof wp&&wp.mce?(a.on("BeforeAddUndo",function(a){a.lastLevel&&l(a.level.content)===l(a.lastLevel.content)&&a.preventDefault()}),a.on("BeforeSetContent",function(b){var c;b.content&&(n&&i(n),c=a.selection.getNode(),(!b.content.match(/^\s*(https?:\/\/[^\s"]+)\s*$/i)||"P"===c.nodeName&&c.parentNode===a.getBody()&&a.dom.isEmpty(c))&&(b.content=wp.mce.views.toViews(b.content)))}),a.on("SetContent",function(){wp.mce.views.render()}),a.on("click",function(c){var d,e=c.clientX,f=c.clientY,h=a.getBody(),i=h.getBoundingClientRect(),j=h.firstChild,k=j.getBoundingClientRect(),l=h.lastChild,m=l.getBoundingClientRect();f<k.top&&(d=b(j))?(g(!0,d),c.preventDefault()):f>m.bottom&&(d=b(l))?(g(!1,d),c.preventDefault()):tinymce.each(a.dom.select(".wpview-wrap"),function(a){var b=a.getBoundingClientRect();return f>=b.top&&f<=b.bottom?void(e<i.left?(g(!0,a),c.preventDefault()):e>i.right&&(g(!1,a),c.preventDefault())):void 0})}),a.on("init",function(){var c=!1,d=a.selection,e=window.MutationObserver||window.WebKitMutationObserver;a.on("BeforeSetContent",function(){var c,e,f=b(d.getNode());f&&(!f.nextSibling||b(f.nextSibling)?(e=a.getDoc().createTextNode(""),a.dom.insertAfter(e,f)):(c=new v(f.nextSibling,f.nextSibling),e=c.next()),d.select(e),d.collapse(!0))}),a.dom.bind(a.getDoc(),"touchmove",function(){c=!0}),a.on("mousedown mouseup click touchend",function(d){var e=b(d.target);if(x=!1,e){if(d.stopImmediatePropagation(),d.preventDefault(),!("touchend"!==d.type&&"mousedown"!==d.type||d.metaKey||d.ctrlKey)){if(a.dom.hasClass(d.target,"edit"))return wp.mce.views.edit(e),a.focus(),!1;if(a.dom.hasClass(d.target,"remove"))return i(e),!1}return"touchend"===d.type&&c?c=!1:j(e),!1}("touchend"===d.type||"mousedown"===d.type)&&k(),"touchend"===d.type&&c&&(c=!1)},!0),e&&new e(function(){a.fire("wp-body-class-change")}).observe(a.getBody(),{attributes:!0,attributeFilter:["class"]})}),a.on("PreProcess",function(b){tinymce.each(a.dom.select("div[data-wpview-text]",b.node),function(a){a.textContent=a.innerText=" "})}),a.on("PostProcess",function(a){a.content&&(a.content=a.content.replace(/<div [^>]*?data-wpview-text="([^"]*)"[^>]*>[\s\S]*?<\/div>/g,function(a,b){return b?"<p>"+window.decodeURIComponent(b)+"</p>":""}))}),a.on("keydown",function(c){var d,e,f,l,o,q,r,s=c.keyCode,t=a.dom,v=a.selection;if(n){if((c.metaKey||c.ctrlKey)&&s!==u.BACKSPACE&&86!==s||s>=112&&123>=s)return void((c.metaKey||c.ctrlKey)&&88===s&&(w=n));if(e=b(v.getNode()),e!==n)return void k();s===u.LEFT?(g(!0,e),c.preventDefault()):s===u.UP?(e.previousSibling?b(e.previousSibling)?g(!0,e.previousSibling):(k(),v.select(e.previousSibling,!0),v.collapse()):g(!0,e),c.preventDefault()):s===u.RIGHT?(g(!1,e),c.preventDefault()):s===u.DOWN?(e.nextSibling?b(e.nextSibling)?g(!1,e.nextSibling):(k(),v.setCursorLocation(e.nextSibling,0)):g(!1,e),c.preventDefault()):m(s)||(i(n),(s===u.ENTER||s===u.DELETE||s===u.BACKSPACE)&&c.preventDefault())}else{if(c.metaKey||c.ctrlKey||s>=112&&123>=s)return;if(d=v.getNode(),p=d,e=b(d),v.isCollapsed()||(o=v.getRng(),(e=b(o.endContainer))?(q=o.cloneRange(),v.select(e.previousSibling,!0),v.collapse(),r=v.getRng(),q.setEnd(r.endContainer,r.endOffset),v.setRng(q)):(e=b(o.startContainer))&&(q=o.cloneRange(),q.setStart(e.nextSibling,0),v.setRng(q))),!e)return void(c.keyCode===u.BACKSPACE&&(a.dom.isEmpty(d)?(e=b(d.previousSibling))&&(g(!1,e),a.dom.remove(d),c.preventDefault()):(o=v.getRng())&&0===o.startOffset&&0===o.endOffset&&(e=b(d.previousSibling))&&(g(!1,e),c.preventDefault())));if(!(f=t.hasClass(e,"wpview-selection-before"))&&!(l=t.hasClass(e,"wpview-selection-after")))return;if(m(s))return;l&&s===u.UP||f&&s===u.BACKSPACE?(e.previousSibling?b(e.previousSibling)?g(!1,e.previousSibling):t.isEmpty(e.previousSibling)&&s===u.BACKSPACE?t.remove(e.previousSibling):(v.select(e.previousSibling,!0),v.collapse()):g(!0,e),c.preventDefault()):!l||s!==u.DOWN&&s!==u.RIGHT?!f||s!==u.UP&&s!==u.LEFT?f&&s===u.DOWN?(e.nextSibling?b(e.nextSibling)?g(!0,e.nextSibling):v.setCursorLocation(e.nextSibling,0):g(!1,e),c.preventDefault()):l&&s===u.LEFT||f&&s===u.RIGHT?(j(e),c.preventDefault()):l&&s===u.BACKSPACE?(i(e),c.preventDefault()):l?h(e):f&&h(e,!0,s):(e.previousSibling&&(b(e.previousSibling)?g(s===u.UP,e.previousSibling):(v.select(e.previousSibling,!0),v.collapse())),c.preventDefault()):(e.nextSibling&&(b(e.nextSibling)?g(s===u.RIGHT,e.nextSibling):v.setCursorLocation(e.nextSibling,0)),c.preventDefault()),s===u.ENTER&&c.preventDefault()}}),a.on("keyup",function(){w&&(i(w),w=!1)}),a.on("focus",function(){var c;r=!0,a.dom.addClass(a.getBody(),"has-focus"),x&&(c=b(a.getBody().firstChild))&&g(!0,c),x=!1}),a.on("blur",function(){r=!1,a.dom.removeClass(a.getBody(),"has-focus")}),a.on("NodeChange",function(d){var e=a.dom,f=a.dom.select(".wpview-wrap"),h=d.element.className,i=b(d.element),j=p;if(p=!1,clearInterval(o),tinymce.each(f,function(a){a.className&&(a.className=a.className.replace(/ ?\bwpview-(?:selection-before|selection-after|cursor-hide)\b/g,""))}),r&&i)if("wpview-selection-before"!==h&&"wpview-selection-after"!==h||!a.selection.isCollapsed())c(d.element,"wpview-clipboard")||q||(k(),q++,g(!0,i));else{if(q=0,k(),j===i.previousSibling)return void g(!0,i);if(j===i.nextSibling)return void g(!1,i);e.addClass(i,h),o=setInterval(function(){e.hasClass(i,"wpview-cursor-hide")?e.removeClass(i,"wpview-cursor-hide"):e.addClass(i,"wpview-cursor-hide")},500)}}),a.on("BeforeExecCommand",function(){var c,d=a.selection.getNode();d&&("wpview-selection-before"===d.className||"wpview-selection-after"===d.className)&&(c=b(d))&&(h(c),s=c)}),a.on("ExecCommand",function(){var b,c;n&&(b=n,k(),j(b)),s&&(c=s.nextSibling,c&&"P"===c.nodeName&&a.dom.isEmpty(c)&&(a.dom.remove(c),g(!1,s)),s=!1)}),a.on("ResolveName",function(c){a.dom.hasClass(c.target,"wpview-wrap")?(c.name=a.dom.getAttrib(c.target,"data-wpview-type")||"wpview",c.stopPropagation()):b(c.target)&&(c.preventDefault(),c.stopPropagation())}),{getViewText:d,setViewText:e,getView:b}):{getViewText:y,setViewText:y,getView:y}});
\ No newline at end of file