diff --git a/Leanote/Leanote-Info.plist b/Leanote/Leanote-Info.plist index 4e3b939..36db71c 100755 --- a/Leanote/Leanote-Info.plist +++ b/Leanote/Leanote-Info.plist @@ -38,7 +38,7 @@ CFBundleVersion - 95C + 961 LSRequiresIPhoneOS NSAppTransportSecurity diff --git a/Leanote/Settings.bundle/Root.plist b/Leanote/Settings.bundle/Root.plist index 7374e82..7971ffc 100755 --- a/Leanote/Settings.bundle/Root.plist +++ b/Leanote/Settings.bundle/Root.plist @@ -18,7 +18,7 @@ AutocorrectionType No DefaultValue - 1.0 (95C) + 1.0 (961) IsSecure Key diff --git a/Leanote/editor/EditorAssets/ZSSRichTextEditor.js b/Leanote/editor/EditorAssets/ZSSRichTextEditor.js index 2909096..7de10f8 100755 --- a/Leanote/editor/EditorAssets/ZSSRichTextEditor.js +++ b/Leanote/editor/EditorAssets/ZSSRichTextEditor.js @@ -82,9 +82,9 @@ ZSSEditor.init = function(callbacker, logger) { // Change a few CSS values if the device is an iPad ZSSEditor.isiPad = (navigator.userAgent.match(/iPad/i) != null); if (ZSSEditor.isiPad) { - $(document.body).addClass('ipad_body'); - $('#zss_field_title').addClass('ipad_field_title'); - $('#zss_field_content').addClass('ipad_field_content'); + $(document.body).addClass('ipad-body'); + // $('#zss_field_title').addClass('ipad_field_title'); + // $('#zss_field_content').addClass('ipad_field_content'); } document.execCommand('insertBrOnReturn', false, false); diff --git a/Leanote/editor/EditorAssets/all.js b/Leanote/editor/EditorAssets/all.js index 37d7283..d48e673 100755 --- a/Leanote/editor/EditorAssets/all.js +++ b/Leanote/editor/EditorAssets/all.js @@ -7,8 +7,8 @@ window.wp=window.wp||{},function(){wp.shortcode={next:function(t,e,n){var s,r,o= !function(e){function t(){var e=s();e!==r&&(r=e,l.trigger("orientationchange"))}function n(t,n,a,o){var i=a.type;a.type=n,e.event.dispatch.call(t,a,o),a.type=i}e.attrFn=e.attrFn||{};var a=navigator.userAgent.toLowerCase(),o=a.indexOf("chrome")>-1&&(a.indexOf("windows")>-1||a.indexOf("macintosh")>-1||a.indexOf("linux")>-1)&&a.indexOf("mobile")<0&&a.indexOf("nexus")<0,i={tap_pixel_range:5,swipe_h_threshold:50,swipe_v_threshold:50,taphold_threshold:750,doubletap_int:500,touch_capable:"ontouchstart"in document.documentElement&&!o,orientation_support:"orientation"in window&&"onorientationchange"in window,startevent:"ontouchstart"in document.documentElement&&!o?"touchstart":"mousedown",endevent:"ontouchstart"in document.documentElement&&!o?"touchend":"mouseup",moveevent:"ontouchstart"in document.documentElement&&!o?"touchmove":"mousemove",tapevent:"ontouchstart"in document.documentElement&&!o?"tap":"click",scrollevent:"ontouchstart"in document.documentElement&&!o?"touchmove":"scroll",hold_timer:null,tap_timer:null};e.isTouchCapable=function(){return i.touch_capable},e.getStartEvent=function(){return i.startevent},e.getEndEvent=function(){return i.endevent},e.getMoveEvent=function(){return i.moveevent},e.getTapEvent=function(){return i.tapevent},e.getScrollEvent=function(){return i.scrollevent},e.each(["tapstart","tapend","tap","singletap","doubletap","taphold","swipe","swipeup","swiperight","swipedown","swipeleft","swipeend","scrollstart","scrollend","orientationchange"],function(t,n){e.fn[n]=function(e){return e?this.on(n,e):this.trigger(n)},e.attrFn[n]=!0}),e.event.special.tapstart={setup:function(){var t=this,a=e(t);a.on(i.startevent,function(e){if(a.data("callee",arguments.callee),e.which&&1!==e.which)return!1;var o=e.originalEvent,c={position:{x:i.touch_capable?o.touches[0].screenX:e.screenX,y:i.touch_capable?o.touches[0].screenY:e.screenY},offset:{x:i.touch_capable?o.touches[0].pageX-o.touches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?o.touches[0].pageY-o.touches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target};return n(t,"tapstart",e,c),!0})},remove:function(){e(this).off(i.startevent,e(this).data.callee)}},e.event.special.tapmove={setup:function(){var t=this,a=e(t);a.on(i.moveevent,function(e){a.data("callee",arguments.callee);var o=e.originalEvent,c={position:{x:i.touch_capable?o.touches[0].screenX:e.screenX,y:i.touch_capable?o.touches[0].screenY:e.screenY},offset:{x:i.touch_capable?o.touches[0].pageX-o.touches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?o.touches[0].pageY-o.touches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target};return n(t,"tapmove",e,c),!0})},remove:function(){e(this).off(i.moveevent,e(this).data.callee)}},e.event.special.tapend={setup:function(){var t=this,a=e(t);a.on(i.endevent,function(e){a.data("callee",arguments.callee);var o=e.originalEvent,c={position:{x:i.touch_capable?o.changedTouches[0].screenX:e.screenX,y:i.touch_capable?o.changedTouches[0].screenY:e.screenY},offset:{x:i.touch_capable?o.changedTouches[0].pageX-o.changedTouches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?o.changedTouches[0].pageY-o.changedTouches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target};return n(t,"tapend",e,c),!0})},remove:function(){e(this).off(i.endevent,e(this).data.callee)}},e.event.special.taphold={setup:function(){var t,a=this,o=e(a),c={x:0,y:0};o.on(i.startevent,function(e){if(e.which&&1!==e.which)return!1;o.data("tapheld",!1),t=e.target;var s=e.originalEvent,r=(new Date).getTime(),u={x:i.touch_capable?s.touches[0].screenX:e.screenX,y:i.touch_capable?s.touches[0].screenY:e.screenY},h={x:i.touch_capable?s.touches[0].pageX-s.touches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?s.touches[0].pageY-s.touches[0].target.offsetTop:e.offsetY};return c.x=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageX:e.pageX,c.y=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageY:e.pageY,i.hold_timer=window.setTimeout(function(){var l=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageX:e.pageX,p=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageY:e.pageY;if(e.target==t&&c.x==l&&c.y==p){o.data("tapheld",!0);var g=(new Date).getTime(),f={x:i.touch_capable?s.touches[0].screenX:e.screenX,y:i.touch_capable?s.touches[0].screenY:e.screenY},d={x:i.touch_capable?s.touches[0].pageX-s.touches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?s.touches[0].pageY-s.touches[0].target.offsetTop:e.offsetY};duration=g-r;var v={startTime:r,endTime:g,startPosition:u,startOffset:h,endPosition:f,endOffset:d,duration:duration,target:e.target};o.data("callee1",arguments.callee),n(a,"taphold",e,v)}},i.taphold_threshold),!0}).on(i.endevent,function(){o.data("callee2",arguments.callee),o.data("tapheld",!1),window.clearTimeout(i.hold_timer)})},remove:function(){e(this).off(i.startevent,e(this).data.callee1).off(i.endevent,e(this).data.callee2)}},e.event.special.doubletap={setup:function(){var t,a,o,c,s=this,r=e(s);r.on(i.startevent,function(e){return e.which&&1!==e.which?!1:r.data("lastTouch")?void 0:(r.data("doubletapped",!1),t=e.target,r.data("callee1",arguments.callee),c=e.originalEvent,o={position:{x:i.touch_capable?c.touches[0].screenX:e.screenX,y:i.touch_capable?c.touches[0].screenY:e.screenY},offset:{x:i.touch_capable?c.touches[0].pageX-c.touches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?c.touches[0].pageY-c.touches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target},!0)}).on(i.endevent,function(e){var c=(new Date).getTime(),u=r.data("lastTouch")||c+1,h=c-u;if(window.clearTimeout(a),r.data("callee2",arguments.callee),h0&&e.target==t&&h>100){r.data("doubletapped",!0),window.clearTimeout(i.tap_timer);var l={position:{x:i.touch_capable?e.originalEvent.changedTouches[0].screenX:e.screenX,y:i.touch_capable?e.originalEvent.changedTouches[0].screenY:e.screenY},offset:{x:i.touch_capable?e.originalEvent.changedTouches[0].pageX-e.originalEvent.changedTouches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?e.originalEvent.changedTouches[0].pageY-e.originalEvent.changedTouches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target},p={firstTap:o,secondTap:l,interval:l.time-o.time};n(s,"doubletap",e,p)}else r.data("lastTouch",c),a=window.setTimeout(function(){window.clearTimeout(a)},i.doubletap_int,[e]);r.data("lastTouch",c)})},remove:function(){e(this).off(i.startevent,e(this).data.callee1).off(i.endevent,e(this).data.callee2)}},e.event.special.singletap={setup:function(){var t=this,a=e(t),o=null,c=null,s={x:0,y:0};a.on(i.startevent,function(e){return e.which&&1!==e.which?!1:(c=(new Date).getTime(),o=e.target,a.data("callee1",arguments.callee),s.x=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageX:e.pageX,s.y=e.originalEvent.targetTouches?e.originalEvent.targetTouches[0].pageY:e.pageY,!0)}).on(i.endevent,function(e){a.data("callee2",arguments.callee),e.target==o&&(end_pos_x=e.originalEvent.changedTouches?e.originalEvent.changedTouches[0].pageX:e.pageX,end_pos_y=e.originalEvent.changedTouches?e.originalEvent.changedTouches[0].pageY:e.pageY,i.tap_timer=window.setTimeout(function(){if(!a.data("doubletapped")&&!a.data("tapheld")&&s.x==end_pos_x&&s.y==end_pos_y){var o=e.originalEvent,r={position:{x:i.touch_capable?o.changedTouches[0].screenX:e.screenX,y:i.touch_capable?o.changedTouches[0].screenY:e.screenY},offset:{x:i.touch_capable?o.changedTouches[0].pageX-o.changedTouches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?o.changedTouches[0].pageY-o.changedTouches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target};r.time-c=-i.tap_pixel_range&&diff_x<=i.tap_pixel_range&&diff_y>=-i.tap_pixel_range&&diff_y<=i.tap_pixel_range)){var l=e.originalEvent,p={position:{x:i.touch_capable?l.changedTouches[0].screenX:e.screenX,y:i.touch_capable?l.changedTouches[0].screenY:e.screenY},offset:{x:i.touch_capable?l.changedTouches[0].pageX-l.changedTouches[0].target.offsetLeft:e.offsetX,y:i.touch_capable?l.changedTouches[0].pageY-l.changedTouches[0].target.offsetTop:e.offsetY},time:(new Date).getTime(),target:e.target};n(a,"tap",e,p)}})},remove:function(){e(this).off(i.startevent,e(this).data.callee1).off(i.endevent,e(this).data.callee2)}},e.event.special.swipe={setup:function(){function t(t){s=e(t.target),s.data("callee1",arguments.callee),h.x=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageX:t.pageX,h.y=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageY:t.pageY,l.x=h.x,l.y=h.y,r=!0;var n=t.originalEvent;o={position:{x:i.touch_capable?n.touches[0].screenX:t.screenX,y:i.touch_capable?n.touches[0].screenY:t.screenY},offset:{x:i.touch_capable?n.touches[0].pageX-n.touches[0].target.offsetLeft:t.offsetX,y:i.touch_capable?n.touches[0].pageY-n.touches[0].target.offsetTop:t.offsetY},time:(new Date).getTime(),target:t.target};for(var a=new Date;new Date-a<100;);}function n(t){s=e(t.target),s.data("callee2",arguments.callee),l.x=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageX:t.pageX,l.y=t.originalEvent.targetTouches?t.originalEvent.targetTouches[0].pageY:t.pageY,window.clearTimeout(i.hold_timer);var n,a=s.data("xthreshold"),c=s.data("ythreshold"),p="undefined"!=typeof a&&a!==!1&&parseInt(a)?parseInt(a):i.swipe_h_threshold,g="undefined"!=typeof c&&c!==!1&&parseInt(c)?parseInt(c):i.swipe_v_threshold;if(h.y>l.y&&h.y-l.y>g&&(n="swipeup"),h.xp&&(n="swiperight"),h.yg&&(n="swipedown"),h.x>l.x&&h.x-l.x>p&&(n="swipeleft"),void 0!=n&&r){h.x=0,h.y=0,l.x=0,l.y=0,r=!1;var f=t.originalEvent;endEvnt={position:{x:i.touch_capable?f.touches[0].screenX:t.screenX,y:i.touch_capable?f.touches[0].screenY:t.screenY},offset:{x:i.touch_capable?f.touches[0].pageX-f.touches[0].target.offsetLeft:t.offsetX,y:i.touch_capable?f.touches[0].pageY-f.touches[0].target.offsetTop:t.offsetY},time:(new Date).getTime(),target:t.target};var d=Math.abs(o.position.x-endEvnt.position.x),v=Math.abs(o.position.y-endEvnt.position.y),m={startEvnt:o,endEvnt:endEvnt,direction:n.replace("swipe",""),xAmount:d,yAmount:v,duration:endEvnt.time-o.time};u=!0,s.trigger("swipe",m).trigger(n,m)}}function a(t){s=e(t.target);var n="";if(s.data("callee3",arguments.callee),u){var a=s.data("xthreshold"),c=s.data("ythreshold"),h="undefined"!=typeof a&&a!==!1&&parseInt(a)?parseInt(a):i.swipe_h_threshold,l="undefined"!=typeof c&&c!==!1&&parseInt(c)?parseInt(c):i.swipe_v_threshold,p=t.originalEvent;endEvnt={position:{x:i.touch_capable?p.changedTouches[0].screenX:t.screenX,y:i.touch_capable?p.changedTouches[0].screenY:t.screenY},offset:{x:i.touch_capable?p.changedTouches[0].pageX-p.changedTouches[0].target.offsetLeft:t.offsetX,y:i.touch_capable?p.changedTouches[0].pageY-p.changedTouches[0].target.offsetTop:t.offsetY},time:(new Date).getTime(),target:t.target},o.position.y>endEvnt.position.y&&o.position.y-endEvnt.position.y>l&&(n="swipeup"),o.position.xh&&(n="swiperight"),o.position.yl&&(n="swipedown"),o.position.x>endEvnt.position.x&&o.position.x-endEvnt.position.x>h&&(n="swipeleft");var g=Math.abs(o.position.x-endEvnt.position.x),f=Math.abs(o.position.y-endEvnt.position.y),d={startEvnt:o,endEvnt:endEvnt,direction:n.replace("swipe",""),xAmount:g,yAmount:f,duration:endEvnt.time-o.time};s.trigger("swipeend",d)}r=!1,u=!1}var o,c=this,s=e(c),r=!1,u=!1,h={x:0,y:0},l={x:0,y:0};s.on(i.startevent,t),s.on(i.moveevent,n),s.on(i.endevent,a)},remove:function(){e(this).off(i.startevent,e(this).data.callee1).off(i.moveevent,e(this).data.callee2).off(i.endevent,e(this).data.callee3)}},e.event.special.scrollstart={setup:function(){function t(e,t){a=t,n(c,a?"scrollstart":"scrollend",e)}var a,o,c=this,s=e(c);s.on(i.scrollevent,function(e){s.data("callee",arguments.callee),a||t(e,!0),clearTimeout(o),o=setTimeout(function(){t(e,!1)},50)})},remove:function(){e(this).off(i.scrollevent,e(this).data.callee)}};var c,s,r,u,h,l=e(window),p={0:!0,180:!0};if(i.orientation_support){var g=window.innerWidth||e(window).width(),f=window.innerHeight||e(window).height(),d=50;u=g>f&&g-f>d,h=p[window.orientation],(u&&h||!u&&!h)&&(p={"-90":!0,90:!0})}e.event.special.orientationchange=c={setup:function(){return i.orientation_support?!1:(r=s(),l.on("throttledresize",t),!0)},teardown:function(){return i.orientation_support?!1:(l.off("throttledresize",t),!0)},add:function(e){var t=e.handler;e.handler=function(e){return e.orientation=s(),t.apply(this,arguments)}}},e.event.special.orientationchange.orientation=s=function(){var e=!0,t=document.documentElement;return e=i.orientation_support?p[window.orientation]:t&&t.clientWidth/t.clientHeight<1.1,e?"portrait":"landscape"},e.event.special.throttledresize={setup:function(){e(this).on("resize",_)},teardown:function(){e(this).off("resize",_)}};var v,m,w,T=250,_=function(){m=(new Date).getTime(),w=m-x,w>=T?(x=m,e(this).trigger("throttledresize")):(v&&window.clearTimeout(v),v=window.setTimeout(t,T-w))},x=0;e.each({scrollend:"scrollstart",swipeup:"swipe",swiperight:"swipe",swipedown:"swipe",swipeleft:"swipe",swipeend:"swipe"},function(t,n){e.event.special[t]={setup:function(){e(this).on(n,e.noop)}}})}(jQuery); function WPHybridCallbacker(){}WPHybridCallbacker.prototype.callback=function(e,r){var t=e+":";r&&(t+=r),isUsingiOS?this.callbackThroughIFrame(t):console.log(t)},WPHybridCallbacker.prototype.callbackThroughIFrame=function(e){var r=document.createElement("IFRAME");r.setAttribute("src",e),r.style.cssText="border: 0px transparent;",document.documentElement.appendChild(r),r.parentNode.removeChild(r),r=null}; function WPHybridLogger(r,a){this.callbacker=r,this.parameterSeparator=a}WPHybridLogger.prototype.log=function(r){this.callbacker.callback("callback-log","msg="+r)},WPHybridLogger.prototype.logError=function(r,a,l){var o=["msg="+r,"url="+a,"line="+l],c=o.join(this.parameterSeparator);this.callbacker.callback("callback-log-error",c)}; -function callObjc(e){var t=document.createElement("IFRAME");t.setAttribute("src",e),t.style.cssText="border: 0px transparent;",document.documentElement.appendChild(t),t.parentNode.removeChild(t),t=null}function removeFomat(){try{for(var e=window.getSelection(),t=e.getRangeAt(0).cloneRange(),i=t.commonAncestorContainer;;){var n=i.nodeName.toLowerCase();if("p"==n||"div"==n||"hr"==n||"table"==n||"img"==n||"a"==n||"span"==n||"font"==n||"body"==n||0===n.indexOf("h")||"blockquote"==n)break;i=i.parentNode}if("img"===n)return;var o=$(i);if("body"!=n&&"html"!=n){if("div"==n&&"zss_field_content"==i.className)return;var r=n;-1!=n.indexOf("h")||"blockquote"==n?r="p":"a"===n&&(r="span");var a,d="LEACLR-"+(new Date).getTime(),l="~*Z+&",s='',c=$(s).get(0);o.find("img").length>0?(t.insertNode(c),a=o.html()):(c.innerHTML=l,t.insertNode(c),a=o.text(),a=a.replace(l,s)),o.replaceWith("<"+r+">"+a+"");var t=document.createRange(),S=window.getSelection();t.setStart($("#"+d).get(0),0),t.collapse(!0),S.removeAllRanges(),S.addRange(t),$("#"+d).remove()}console.log("format ok")}catch(u){console.error(u)}}function ZSSField(e,t){this.wrappedObject=e,this.callbacker=t,this.isComposing=!1,this.multiline=!1,this.bodyPlaceholderColor="#000000",this.wrappedDomNode().hasAttribute("nostyle")&&(this.hasNoStyle=!0),this.useVisualFormatting="true"===this.wrappedObject.data("wpUseVisualFormatting"),this.bindListeners()}var log=function(e){console.log(e),callObjc("callback-log:msg="+e)},LEAMD={},isUsingiOS=!0,defaultCallbackSeparator="~";const NodeName={BLOCKQUOTE:"BLOCKQUOTE",PARAGRAPH:"P"};var ZSSEditor={};ZSSEditor.caretArguments=["yOffset=0","height=0"],ZSSEditor.caretInfo={y:0,height:0},ZSSEditor.isiPad,ZSSEditor.currentSelection,ZSSEditor.currentEditingImage,ZSSEditor.currentEditingVideo,ZSSEditor.currentEditingLink,ZSSEditor.focusedField=null,ZSSEditor.enabledItems={},ZSSEditor.editableFields={},ZSSEditor.lastTappedNode=null,ZSSEditor.defaultParagraphSeparator="p",ZSSEditor.init=function(e,t){ZSSEditor.callbacker=e,ZSSEditor.logger=t,rangy.init(),ZSSEditor.isiPad=null!=navigator.userAgent.match(/iPad/i),ZSSEditor.isiPad&&($(document.body).addClass("ipad_body"),$("#zss_field_title").addClass("ipad_field_title"),$("#zss_field_content").addClass("ipad_field_content")),document.execCommand("insertBrOnReturn",!1,!1),document.execCommand("defaultParagraphSeparator",!1,this.defaultParagraphSeparator),document.execCommand("styleWithCSS",!1,!1);var i=$("div.field").each(function(){var e=new ZSSField($(this),ZSSEditor.callbacker),t=e.getNodeId();ZSSEditor.editableFields[t]=e,ZSSEditor.callback("callback-new-field","id="+t)});document.addEventListener("selectionchange",function(e){if(ZSSEditor.currentEditingLink=null,i.is(":focus")){ZSSEditor.selectionChangedCallback(),ZSSEditor.sendEnabledStyles(e);var t=$(e.target);t.hasClass("zs_active")||$("img").removeClass("zs_active")}},!1),$("[contenteditable]").on("paste",function(e){e.preventDefault();var t=(e.originalEvent||e).clipboardData.getData("text/plain");document.execCommand("insertText",!1,t)}),this.domLoadedCallback()},ZSSEditor.callback=function(e,t){this.callbacker.callback(e,t)},ZSSEditor.domLoadedCallback=function(){this.callback("callback-dom-loaded")},ZSSEditor.selectionChangedCallback=function(){var e=this.getJoinedFocusedFieldIdAndCaretArguments();this.callback("callback-selection-changed",e),this.callback("callback-input",e)},ZSSEditor.stylesCallback=function(e){var t="";e.length>0&&(t=e.join(defaultCallbackSeparator)),this.callback("callback-selection-style",t)},ZSSEditor.log=function(e){this.logger.log(e)},ZSSEditor.logMainElementSizes=function(){e="Window [w:"+$(window).width()+"|h:"+$(window).height()+"]",this.log(e);var e=encodeURIComponent("Viewport [w:"+window.innerWidth+"|h:"+window.innerHeight+"]");this.log(e),e=encodeURIComponent("Body [w:"+$(document.body).width()+"|h:"+$(document.body).height()+"]"),this.log(e),e=encodeURIComponent("HTML [w:"+$("html").width()+"|h:"+$("html").height()+"]"),this.log(e),e=encodeURIComponent("Document [w:"+$(document).width()+"|h:"+$(document).height()+"]"),this.log(e)},ZSSEditor.refreshVisibleViewportSize=function(){$(document.body).css("min-height",window.innerHeight+"px"),$("#zss_field_content").css("min-height",window.innerHeight-$("#zss_field_content").position().top+"px")},ZSSEditor.focusFirstEditableField=function(){$("div[contenteditable=true]:first").focus()},ZSSEditor.getField=function(e){var t=this.editableFields[e];return t},ZSSEditor.getFocusedField=function(){for(var e=$(this.closerParentNodeWithName("div")),t=e.attr("id");e&&(!t||null==this.editableFields[t]);)e=this.closerParentNodeStartingAtNode("div",e),e&&(t=e.attr("id"));var i=this.editableFields[t];return i?i:this.editableFields.zss_field_content},ZSSEditor.backupRange=function(){var e=window.getSelection(),t=e.getRangeAt(0);ZSSEditor.currentSelection={startContainer:t.startContainer,startOffset:t.startOffset,endContainer:t.endContainer,endOffset:t.endOffset}},ZSSEditor.restoreRange=function(){if(this.currentSelection){var e=window.getSelection();e.removeAllRanges();var t=document.createRange();t.setStart(this.currentSelection.startContainer,this.currentSelection.startOffset),t.setEnd(this.currentSelection.endContainer,this.currentSelection.endOffset),e.addRange(t)}},ZSSEditor.getSelectedText=function(){var e=window.getSelection();return e.toString()},ZSSEditor.getCaretArguments=function(){var e=this.getYCaretInfo();return null==e?null:(this.caretArguments[0]="yOffset="+e.y,this.caretArguments[1]="height="+e.height,this.caretArguments)},ZSSEditor.getJoinedFocusedFieldIdAndCaretArguments=function(){var e,t=ZSSEditor.getJoinedCaretArguments(),i=ZSSEditor.getFocusedField();e=i?i.getNodeId():"zss_field_content";var n="id="+e;return t=n+defaultCallbackSeparator+t},ZSSEditor.getJoinedCaretArguments=function(){var e=(this.getCaretArguments(),this.caretArguments.join(defaultCallbackSeparator));return e},ZSSEditor.getCaretYPosition=function(){var e=window.getSelection(),t=e.getRangeAt(0),i=document.createElement("span");i.appendChild(document.createTextNode("​")),t.insertNode(i);var n=i.offsetTop,o=i.parentNode;return o.removeChild(i),o.normalize(),n},ZSSEditor.getYCaretInfo=function(){var e=window.getSelection(),t=0==e.rangeCount;if(t)return null;var i=0,n=0,o=e.getRangeAt(0),r=0==o.getClientRects().length;if(r){var a=ZSSEditor.closerParentNode(),d=(ZSSEditor.closerParentNodeWithName("div"),$(a).css("font-size")),l=Math.floor(1.5*parseInt(d.replace("px","")));i=this.getCaretYPosition(),n=l}else if(o.getClientRects){var s=o.getClientRects();if(s.length>0){var c=document.body.getClientRects()[0].top<0;c&&(i=document.body.scrollTop),i+=s[0].top,n=s[0].height}}return this.caretInfo.y=i,this.caretInfo.height=n,this.caretInfo},ZSSEditor.defaultParagraphSeparatorTag=function(){return"<"+this.defaultParagraphSeparator+">"},ZSSEditor.setBold=function(){document.execCommand("bold",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setItalic=function(){document.execCommand("italic",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setSubscript=function(){document.execCommand("subscript",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setSuperscript=function(){document.execCommand("superscript",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setStrikeThrough=function(){var e="strikeThrough",t=ZSSEditor.isCommandEnabled(e);document.execCommand(e,!1,null);var i=t&&ZSSEditor.isCommandEnabled(e);if(i){for(var n=["del"],o=window.getSelection(),r=o.getRangeAt(0).cloneRange(),a=r.commonAncestorContainer,d=!1;a&&!d;)d=a&&a.nodeType==document.ELEMENT_NODE&&n.indexOf(a.nodeName.toLowerCase())>-1,d||(a=a.parentElement);if(a){var l=($(a).replaceWith(a.innerHTML),window.getSelection(),o.getRangeAt(0).cloneRange());l.setEnd(l.startContainer,l.startOffset+1),o.removeAllRanges(),o.addRange(l)}}ZSSEditor.sendEnabledStyles()},ZSSEditor.setUnderline=function(){document.execCommand("underline",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setBlockquote=function(){var e=rangy.saveSelection(),t=document.getSelection(),i=t.getRangeAt(0).cloneRange(),n=!1,o=this.getAncestorElementForSettingBlockquote(i);if(o){n=!0;var r=this.getChildNodesIntersectingRange(o,i);r&&r.length&&this.toggleBlockquoteForSpecificChildNodes(o,r)}rangy.restoreSelection(e),n&&ZSSEditor.sendEnabledStyles()},ZSSEditor.removeFormating=function(){var e=window.getSelection().toString();e?document.execCommand("removeFormat",!1,null):removeFomat(),ZSSEditor.sendEnabledStyles()},ZSSEditor.setHorizontalRule=function(){document.execCommand("insertHorizontalRule",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setHeading=function(e){var t=e,i=document.queryCommandValue("formatBlock");i.length>0&&i.toLowerCase()==t?document.execCommand("formatBlock",!1,this.defaultParagraphSeparatorTag()):document.execCommand("formatBlock",!1,"<"+t+">"),ZSSEditor.sendEnabledStyles()},ZSSEditor.setParagraph=function(){var e="p",t=document.queryCommandValue("formatBlock");t.length>0&&t.toLowerCase()==e?document.execCommand("formatBlock",!1,this.defaultParagraphSeparatorTag()):document.execCommand("formatBlock",!1,"<"+e+">"),ZSSEditor.sendEnabledStyles()},ZSSEditor.undo=function(){document.execCommand("undo"),ZSSEditor.sendEnabledStyles()},ZSSEditor.redo=function(){document.execCommand("redo"),ZSSEditor.sendEnabledStyles()},ZSSEditor.setOrderedList=function(){document.execCommand("insertOrderedList",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setUnorderedList=function(){document.execCommand("insertUnorderedList",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setJustifyCenter=function(){document.execCommand("justifyCenter",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setJustifyFull=function(){document.execCommand("justifyFull",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setJustifyLeft=function(){document.execCommand("justifyLeft",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setJustifyRight=function(){document.execCommand("justifyRight",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setIndent=function(){document.execCommand("indent",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setOutdent=function(){document.execCommand("outdent",!1,null),ZSSEditor.sendEnabledStyles()},ZSSEditor.setTextColor=function(e){ZSSEditor.restoreRange(),document.execCommand("styleWithCSS",null,!0),document.execCommand("foreColor",!1,e),document.execCommand("styleWithCSS",null,!1),ZSSEditor.sendEnabledStyles()},ZSSEditor.setBackgroundColor=function(e){ZSSEditor.restoreRange(),document.execCommand("styleWithCSS",null,!0),document.execCommand("hiliteColor",!1,e),document.execCommand("styleWithCSS",null,!1),ZSSEditor.sendEnabledStyles()},ZSSEditor.insertLink=function(e,t){ZSSEditor.restoreRange();var i=document.getSelection();if(i.rangeCount){var n=document.createElement("a");n.setAttribute("href",e);var o=i.getRangeAt(0).cloneRange();o.surroundContents(n),n.innerHTML=t,i.removeAllRanges(),i.addRange(o)}ZSSEditor.sendEnabledStyles()},ZSSEditor.updateLink=function(e,t){ZSSEditor.restoreRange();var i=ZSSEditor.lastTappedNode;i&&(i.setAttribute("href",e),i.innerHTML=t),ZSSEditor.sendEnabledStyles()},ZSSEditor.unlink=function(){var e=ZSSEditor.closerParentNodeWithName("a");e&&this.unwrapNode(e),ZSSEditor.sendEnabledStyles()},ZSSEditor.unwrapNode=function(e){var t=rangy.saveSelection();$(e).contents().unwrap(),rangy.restoreSelection(t)},ZSSEditor.wrapNode=function(e){var t=rangy.saveSelection();$(e).contents().wrap("

"),rangy.restoreSelection(t)},ZSSEditor.quickLink=function(){var e=document.getSelection(),t="",i=new String(e),n=new RegExp("^(.+)(@)(.+)$","gi");-1==i.search(n)?(checkhttplink=new RegExp("^http://","gi"),-1==i.search(checkhttplink)?(checkanchorlink=new RegExp("^#","gi"),t=-1==i.search(checkanchorlink)?"http://"+e:e):t=e):(checkmaillink=new RegExp("^mailto:","gi"),t=-1==i.search(checkmaillink)?"mailto:"+e:e);var o=''+e+"";ZSSEditor.insertHTML(o)},ZSSEditor.toggleBlockquoteForSpecificChildNodes=function(e,t){if(t&&t.length>0)if(e.nodeName==NodeName.BLOCKQUOTE)for(var i=0;i';try{this.insertHTML(o)}catch(r){console.error(r)}}},ZSSEditor.insertLocalImage=function(e,t){var i=" ",n=this.getImageProgressIdentifier(e),o=this.getImageContainerIdentifier(e),r='',a="",d='',l='',s=r+d+l+a;s=i+s+i,this.insertHTML(s),this.sendEnabledStyles()},ZSSEditor.getImageNodeWithIdentifier=function(e){return $('img[data-wpid="'+e+'"]')},ZSSEditor.getImageProgressIdentifier=function(e){return"progress_"+e},ZSSEditor.getImageProgressNodeWithIdentifier=function(e){return $("#"+this.getImageProgressIdentifier(e))},ZSSEditor.getImageContainerIdentifier=function(e){return"img_container_"+e},ZSSEditor.getImageContainerNodeWithIdentifier=function(e){return $("#"+this.getImageContainerIdentifier(e))},ZSSEditor.isMediaContainerNode=function(e){return void 0===e.id?!1:0==e.id.search("img_container_")||0==e.id.search("video_container_")},ZSSEditor.extractMediaIdentifier=function(e){return 0==e.id.search("img_container_")?e.id.replace("img_container_",""):0==e.id.search("video_container_")?e.id.replace("video_container_",""):""},ZSSEditor.replaceLocalImageWithRemoteImage=function(e,t){var i=this.getImageNodeWithIdentifier(e);if(0==i.length)return void this.markImageUploadDone(e);var n=new Image;n.onload=function(){i.attr("src",n.src),ZSSEditor.markImageUploadDone(e)},n.onerror=function(){i.attr("src",n.src),ZSSEditor.markImageUploadDone(e)},n.src=t},ZSSEditor.setProgressOnImage=function(e,t){var i=this.getImageNodeWithIdentifier(e);if(0!=i.length){1>t&&i.addClass("uploading");var n=this.getImageProgressNodeWithIdentifier(e);0!=n.length&&n.attr("value",t)}},ZSSEditor.markImageUploadDone=function(e){var t=this.getImageNodeWithIdentifier(e);if(t.length>0){t.removeAttr("data-wpid"),t.removeClass("uploading"),t.removeAttr("class"),t.parent().attr("id")==this.getImageContainerIdentifier(e)&&(t.parent().attr("id",""),t.parent().replaceWith(t));var i='';t.wrap(i)}var n=ZSSEditor.getJoinedFocusedFieldIdAndCaretArguments();ZSSEditor.callback("callback-input",n);var o=this;setTimeout(function(){o.sendImageReplacedCallback(e)},500)},ZSSEditor.sendImageReplacedCallback=function(e){var t=["id="+encodeURIComponent(e)],i=t.join(defaultCallbackSeparator);this.callback("callback-image-replaced",i)},ZSSEditor.markImageUploadFailed=function(e,t){var i=this.getImageNodeWithIdentifier(e);if(0!=i.length){var n="";i[0].width>480&&i[0].height>240?n="largeFail":(i[0].width<100||i[0].height<100)&&(n="smallFail"),i.addClass("failed");var o=this.getImageContainerNodeWithIdentifier(e);0!=o.length&&(o.attr("data-failed",t),i.removeClass("uploading"),o.addClass("failed"),o.addClass(n));var r=this.getImageProgressNodeWithIdentifier(e);0!=r.length&&r.addClass("failed")}},ZSSEditor.unmarkImageUploadFailed=function(e){var t=this.getImageNodeWithIdentifier(e);0!=t.length&&t.removeClass("failed");var i=this.getImageContainerNodeWithIdentifier(e);0!=i.length&&(i.removeAttr("data-failed"),i.removeClass("failed"));var n=this.getImageProgressNodeWithIdentifier(e);0!=n.length&&n.removeClass("failed")},ZSSEditor.removeImage=function(e){var t=this.getImageNodeWithIdentifier(e);0!=t.length&&t.remove();var i=this.getImageContainerNodeWithIdentifier(e);0!=i.length&&(i.attr("id",""),i.remove())},ZSSEditor.sendMediaRemovedCallback=function(e){var t=["id="+encodeURIComponent(e)],i=t.join(defaultCallbackSeparator);this.callback("callback-media-removed",i)},ZSSEditor.insertVideo=function(e,t,i){var n='";this.insertHTML(n),this.sendEnabledStyles()},ZSSEditor.insertInProgressVideoWithIDUsingPosterImage=function(e,t){var i=" ",n=this.getVideoProgressIdentifier(e),o=this.getVideoContainerIdentifier(e),r='',a="",d='',l='',s=i+r+d+l+a+i;this.insertHTML(s),this.sendEnabledStyles()},ZSSEditor.getVideoNodeWithIdentifier=function(e){return $('video[data-wpid="'+e+'"]')},ZSSEditor.getVideoProgressIdentifier=function(e){return"progress_"+e},ZSSEditor.getVideoProgressNodeWithIdentifier=function(e){return $("#"+this.getVideoProgressIdentifier(e))},ZSSEditor.getVideoContainerIdentifier=function(e){return"video_container_"+e},ZSSEditor.getVideoContainerNodeWithIdentifier=function(e){return $("#"+this.getVideoContainerIdentifier(e))},ZSSEditor.replaceLocalVideoWithRemoteVideo=function(e,t,i,n){var o=this.getVideoNodeWithIdentifier(e);if(0==o.length)return void this.markVideoUploadDone(e);o.attr("src",t),o.attr("controls",""),""!=n&&o.attr("data-wpvideopress",n),o.attr("poster",i);var r=this;o.on("webkitbeginfullscreen",function(){r.sendVideoFullScreenStarted()}),o.on("webkitendfullscreen",function(){r.sendVideoFullScreenEnded()}),o.on("error",function(){o.load()}),this.markVideoUploadDone(e)},ZSSEditor.setProgressOnVideo=function(e,t){var i=this.getVideoNodeWithIdentifier(e);if(0!=i.length){1>t&&i.addClass("uploading");var n=this.getVideoProgressNodeWithIdentifier(e);0!=n.length&&n.attr("value",t)}},ZSSEditor.markVideoUploadDone=function(e){var t=this.getVideoNodeWithIdentifier(e);t.length>0&&(t.removeAttr("data-wpid"),t.removeClass("uploading"),t.removeAttr("class"),t.parent().attr("id")==this.getVideoContainerIdentifier(e)&&(t.parent().attr("id",""),t.parent().replaceWith(t)));var i=ZSSEditor.getJoinedFocusedFieldIdAndCaretArguments();ZSSEditor.callback("callback-input",i);var n=this;setTimeout(function(){n.sendVideoReplacedCallback(e)},500)},ZSSEditor.sendVideoReplacedCallback=function(e){var t=["id="+encodeURIComponent(e)],i=t.join(defaultCallbackSeparator);this.callback("callback-video-replaced",i)},ZSSEditor.sendVideoFullScreenStarted=function(){this.callback("callback-video-fullscreen-started","empty")},ZSSEditor.sendVideoFullScreenEnded=function(){this.callback("callback-video-fullscreen-ended","empty")},ZSSEditor.sendVideoPressInfoRequest=function(e){var t=["id="+encodeURIComponent(e)],i=t.join(defaultCallbackSeparator);this.callback("callback-videopress-info-request",i)},ZSSEditor.markVideoUploadFailed=function(e,t){var i=this.getVideoNodeWithIdentifier(e);if(0!=i.length){var n="";i[0].width>480&&i[0].height>240?n="largeFail":(i[0].width<100||i[0].height<100)&&(n="smallFail"),i.addClass("failed");var o=this.getVideoContainerNodeWithIdentifier(e);0!=o.length&&(o.attr("data-failed",t),i.removeClass("uploading"),o.addClass("failed"),o.addClass(n));var r=this.getVideoProgressNodeWithIdentifier(e);0!=r.length&&r.addClass("failed")}},ZSSEditor.unmarkVideoUploadFailed=function(e){var t=this.getVideoNodeWithIdentifier(e);0!=t.length&&t.removeClass("failed");var i=this.getVideoContainerNodeWithIdentifier(e);0!=i.length&&(i.removeAttr("data-failed"),i.removeClass("failed"));var n=this.getVideoProgressNodeWithIdentifier(e);0!=n.length&&n.removeClass("failed")},ZSSEditor.removeVideo=function(e){var t=this.getVideoNodeWithIdentifier(e);0!=t.length&&t.remove();var i=this.getVideoContainerNodeWithIdentifier(e);0!=i.length&&(i.attr("id",""),i.remove())},ZSSEditor.replaceVideoPressVideosForShortcode=function(e){var t=/]*data-wpvideopress="([\s\S]+?)"[^>]*>*<\/video>/g,i=e.replace(t,ZSSEditor.removeVideoVisualFormattingCallback);return i},ZSSEditor.removeVideoVisualFormattingCallback=function(e,t){return"[wpvideo "+t+"]"},ZSSEditor.applyVideoFormattingCallback=function(e){if(0==e.attrs.numeric.length)return e.content;var t=e.attrs.numeric[0],i='"wpposter.svg"',n='";return n},ZSSEditor.setVideoPressLinks=function(e,t,i){var n=$('video[data-wpvideopress="'+e+'"]');if(0!=n.length){n.attr("src",t),n.attr("controls",""),0==i.length?n.attr("poster","wpposter.svg"):n.attr("poster",i);var o=this;n.on("webkitbeginfullscreen",function(){o.sendVideoFullScreenStarted()}),n.on("webkitendfullscreen",function(){o.sendVideoFullScreenEnded()}),n.load()}},ZSSEditor.pauseAllVideos=function(){$("video").each(function(){this.pause()})},ZSSEditor.updateCurrentImageMeta=function(e){if(ZSSEditor.currentEditingImage){var t=JSON.parse(e),i=ZSSEditor.createImageFromMeta(t),n=ZSSEditor.findImageCaptionNode(ZSSEditor.currentEditingImage);n.insertAdjacentHTML("afterend",i),n.remove(),ZSSEditor.currentEditingImage=null}},ZSSEditor.applyImageSelectionFormatting=function(e){var t=ZSSEditor.findImageCaptionNode(e),i="";(e.width<100||e.height<100)&&(i=" small");var n='Edit',o=''+n+"";t.insertAdjacentHTML("beforebegin",o);var r=t.previousSibling;r.appendChild(t)},ZSSEditor.removeImageSelectionFormatting=function(e){var t=ZSSEditor.findImageCaptionNode(e);if(t.parentNode&&-1!=t.parentNode.className.indexOf("edit-container")){var i=t.parentNode,n=i.parentNode;n.insertBefore(t,i),i.remove()}},ZSSEditor.removeImageSelectionFormattingFromHTML=function(e){var t=document.createElement("div"),i=$(t).html(e),n=i.find("span.edit-container img");if(0==n.length)return e;for(var o=0;o")+1),i):i},ZSSEditor.applyCaptionFormatting=function(e){var t=e.attrs.named,i='"},ZSSEditor.removeCaptionFormatting=function(e){var t=/