Updating minified JavaScript files
authorwoltlab.com <woltlab@woltlab.com>
Thu, 12 Feb 2015 13:16:47 +0000 (14:16 +0100)
committerwoltlab.com <woltlab@woltlab.com>
Thu, 12 Feb 2015 13:16:47 +0000 (14:16 +0100)
wcfsetup/install/files/js/3rdParty/redactor/plugins/wcombined.min.js

index f8bead0f6de51399c85b762fc698ff80ec61bdb2..82d8ff974390f174db42eb49a4e3eb84841e1605 100644 (file)
@@ -15,4 +15,4 @@ if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wmonkeypatch=functio
 // wupload.js
 if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wupload=function(){return{_boundGlobalUploadEvents:false,_dropArea:{},_timer:null,_isDragging:false,_isFile:false,init:function(){var a=".redactor_"+this.$textarea.wcfIdentify();$(document).on("dragover"+a,$.proxy(this.wupload._dragOver,this));$(document).on("dragleave"+a,$.proxy(this.wupload._dragLeave,this));$(document).on("drop"+a,(function(b){b.preventDefault();this.wupload._revertDropArea(undefined,this.$textarea.wcfIdentify())}).bind(this));if(!this.wupload._boundGlobalUploadEvents){this.wupload._boundGlobalUploadEvents=true;$(document).on("dragend",function(b){b.preventDefault()})}WCF.System.Event.addListener("com.woltlab.wcf.attachment","autoInsert_"+this.$textarea.wcfIdentify(),$.proxy(this.wupload.insertPastedImageAttachment,this))},_dragOver:function(d){d=d.originalEvent;if(!d.dataTransfer||!d.dataTransfer.types){return}var e=false;for(var c in d.dataTransfer){if(/^moz/.test(c)){e=true;break}}this.wupload._isFile=false;if(e){if(d.dataTransfer.types[0]==="application/x-moz-file"){this.wupload._isFile=true}}else{for(var g=0;g<d.dataTransfer.types.length;g++){if(d.dataTransfer.types[g]==="Files"){this.wupload._isFile=true;break}}}if(!this.wupload._isFile){return}this.wupload._isFile=true;d.preventDefault();if(!this.wupload._isDragging){var b=this.$textarea.wcfIdentify();if(this.wupload._dropArea[b]===undefined){this.wupload._dropArea[b]=$('<div class="redactorDropArea">'+WCF.Language.get("wcf.attachment.dragAndDrop.dropHere")+"</div>").hide().appendTo(document.body);this.wupload._dropArea[b].on("dragover",$.proxy(this.wupload._hoverDropArea,this)).on("dragleave",$.proxy(this.wupload._revertDropArea,this)).on("drop",$.proxy(this.wupload._drop,this))}var a=(this.wutil.inWysiwygMode())?this.$editor.getDimensions("outer"):this.$textarea.getDimensions("outer");var f=(this.wutil.inWysiwygMode())?this.$editor.getOffsets("offset"):this.$textarea.getOffsets("offset");this.wupload._dropArea[b].css({height:a.height+"px",left:f.left+"px",lineHeight:a.height+"px",top:f.top+"px",width:a.width+"px"}).show();this.wupload._isDragging=true}d.preventDefault()},_hoverDropArea:function(a){this.wupload._dropArea[this.$textarea.wcfIdentify()].addClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropNow"))},_revertDropArea:function(c,a){if(!this.wupload._isFile){return}var b=a||this.$textarea.wcfIdentify();this.wupload._dropArea[b].removeClass("active").text(WCF.Language.get("wcf.attachment.dragAndDrop.dropHere"));if(a){this.wupload._dropArea[b].hide()}},_dragLeave:function(){if(!this.wupload._isDragging||!this.wupload._isFile){return}if(this.wupload._timer===null){this.wupload._timer=new WCF.PeriodicalExecuter((function(a){a.stop();if(!this.wupload._isDragging){this.wupload._dropArea[this.$textarea.wcfIdentify()].hide()}}).bind(this),100)}else{this.wupload._timer.resume()}this.wupload._isDragging=false},_drop:function(b){if(!this.wupload._isFile){return}b=b.originalEvent||b;if(b.dataTransfer&&b.dataTransfer.files.length){b.preventDefault();var a=this.$textarea.wcfIdentify();this.wupload._revertDropArea(undefined,a);for(var c=0;c<b.dataTransfer.files.length;c++){WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+a,{file:b.dataTransfer.files[c]})}}},pasteClipboardUploadMozilla:function(){this.$editor.find("img[data-mozilla-paste-image]").each($.proxy(function(d,g){var f=$(g);var a=f.prop("src").split(",");var e=a[0].split(";")[0].split(":")[1];var c=a[1];var b={blob:WCF.base64toBlob(c,e),uploadID:null};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","upload_"+this.$textarea.wcfIdentify(),b);f.replaceWith('<span class="redactor-pastedImageFromClipboard-'+b.uploadID+'" />')},this))},insertPastedImageAttachment:function(b){var a=this.$editor.find("span.redactor-pastedImageFromClipboard-"+b.uploadID);a.before(b.attachment);a.remove()}}};
 // wutil.js
-if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wutil=function(){var c="";var d=null;var a=false;var b=false;var e=null;return{_autosaveWorker:null,_range:null,init:function(){this.$textarea.parents("form").submit($.proxy(this.wutil.submit,this));if(this.wutil.getOption("woltlab.autosave").active){this.wutil.autosaveEnable();if(this.wutil.getOption("woltlab.autosave").saveOnInit||this.$textarea.data("saveOnInit")){this.wutil.setOption("woltlab.autosaveOnce",true)}else{this.wutil.autosaveRestore()}}this.wutil.setOption("autosave",false);var f=this.core.destroy;this.core.destroy=(function(){this.wutil.autosaveDisable();f.call(this)}).bind(this)},saveSelection:function(g){var f=getSelection();if(f.rangeCount){this.wutil._range=f.getRangeAt(0)}else{if(g){this.wutil._range=null}}},restoreSelection:function(){if(document.activeElement!==this.$editor[0]){this.$editor.focus()}if(this.wutil._range!==null){var f=window.getSelection();f.removeAllRanges();f.addRange(this.wutil._range);this.wutil._range=null}},clearSelection:function(){this.wutil._range=null},getSelection:function(){return this.wutil._range},insertAtCaret:function(g){if(this.opts.visual){console.debug("insertAtCaret() failed: Editor is in WYSIWYG-mode.");return false}this.$textarea.focus();var h=this.$textarea.getCaret();if(h==-1){console.debug("insertAtCaret() failed: Source is not input[type=text], input[type=password] or textarea.")}var f=this.$textarea.val();f=f.substr(0,h)+g+f.substr(h);this.$textarea.val(f);return true},insertDynamic:function(f,g){if(this.wutil.inWysiwygMode()){this.insert.html(f,false)}else{if(g===undefined||g===null){g=f}this.wutil.insertAtCaret(g)}},setOption:function(f,g){if(f.indexOf(".")!==-1){f=f.split(".",2);this.opts[f[0]][f[1]]=g}else{this.opts[f]=g}},getOption:function(f){if(f.indexOf(".")!==-1){f=f.split(".",2);if(this.opts[f[0]][f[1]]){return this.opts[f[0]][f[1]]}}else{if(this.opts[f]){return this.opts[f]}}return null},inPlainMode:function(){return !this.opts.visual},inWysiwygMode:function(){return(this.opts.visual)},replaceRangesWith:function(f){getSelection().removeAllRanges();getSelection().addRange(f)},getText:function(){if(this.wutil.inWysiwygMode()){this.code.startSync();var f=this.$textarea.val();this.$textarea.val($.trim(this.wbbcode.convertFromHtml(f)))}var g=$.trim(this.$textarea.val());g=g.replace(/\[\/quote\]\n/g,"[/quote]");return g},isEmptyEditor:function(){if(this.opts.visual){return this.utils.isEmpty(this.$editor.html())}return(!$.trim(this.$textarea.val()))},submit:function(){if(this.wutil.inWysiwygMode()){this.code.startSync();var f=$.trim(this.wbbcode.convertFromHtml(this.$textarea.val()));f=f.replace(/\[\/quote\]\n/g,"[/quote]");this.$textarea.val(f)}this.wutil.autosavePurge()},reset:function(){if(this.opts.visual){this.$editor.html("<p>"+this.opts.invisibleSpace+"</p>");this.wutil.saveSelection()}this.$textarea.val("");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","reset",{wysiwygContainerID:this.$textarea.wcfIdentify()})},autosaveEnable:function(f){if(!this.wutil.getOption("woltlab.autosave").active){this.wutil.setOption("woltlab.autosave",{active:true,key:f})}if(this.wutil._autosaveWorker===null){this.wutil.autosavePurgeOutdated();this.wutil._autosaveWorker=new WCF.PeriodicalExecuter((function(g){this.wutil.saveTextToStorage(false)}).bind(this),15*1000)}return true},saveTextToStorage:function(g){var f=this.wutil.getText();if(c==f&&!g){return}try{localStorage.setItem(this.wutil.getOption("woltlab.autosave").key,JSON.stringify({content:f,timestamp:Date.now()}));c=f;a=true;if(e===null){e=new WCF.PeriodicalExecuter((function(i){if(b===true){return}if(a===false){i.stop();e=null;return}this.wutil.autosaveShowNotice("saved");a=false}).bind(this),120*1000)}}catch(h){console.debug("[wutil.saveTextToStorage] Unable to access local storage: "+h.message)}},autosaveDisable:function(){if(!this.wutil.getOption("woltlab.autosave").active){return false}this.wutil._autosaveWorker.stop();this.wutil._autosaveWorker=null;this.wutil.setOption("woltlab.autosave",{active:false,key:""});return true},autosavePurge:function(){try{localStorage.removeItem(this.wutil.getOption("woltlab.autosave").key)}catch(f){console.debug("[wutil.autosavePurge] Unable to access local storage: "+f.message)}},autosaveRestore:function(){var f=this.wutil.getOption("woltlab.autosave");var g=null;try{g=localStorage.getItem(f.key)}catch(h){console.debug("[wutil.autosaveRestore] Unable to access local storage: "+h.message)}try{g=(g===null)?null:JSON.parse(g)}catch(h){g=null}if(g===null||!g.content){return false}if(f.lastEditTime&&(f.lastEditTime*1000)>g.timestamp){this.wutil.autosavePurge();return false}if(f.prompt){this.wutil.autosaveShowNotice("prompt",g);return false}if(this.wutil.inWysiwygMode()){this.wutil.setOption("woltlab.originalValue",g.content)}else{this.$textarea.val(g.content)}this.wutil.autosaveShowNotice("restored",{timestamp:g.timestamp});return true},autosaveShowNotice:function(j,l){if(d===null){d=$('<div class="redactorAutosaveNotice"><span class="redactorAutosaveMessage" /></div>');d.appendTo(this.$box);var h=(function(m){if(m!==null&&m.originalEvent.propertyName!=="opacity"){return}if(d.hasClass("open")&&m!==null){if(d.data("callbackOpen")){d.data("callbackOpen")()}}else{if(d.data("callbackClose")){d.data("callbackClose")()}d.removeData("callbackClose");d.removeData("callbackOpen");d.removeClass("redactorAutosaveNoticeIcons");d.empty();$('<span class="redactorAutosaveMessage" />').appendTo(d)}}).bind(this);d.on("transitionend webkitTransitionEnd",h)}var i="";switch(j){case"prompt":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(l.timestamp).toLocaleString()})+'"></span>').prependTo(d);var k=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.confirm")+'"></span>').appendTo(d);var f=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.discard")+'"></span>').appendTo(d);k.click((function(){this.wutil.replaceText(l.content);h(null);this.wutil.autosaveShowNotice("restored",l)}).bind(this));f.click((function(){this.wutil.autosavePurge();d.removeClass("open")}).bind(this));i=WCF.Language.get("wcf.message.autosave.prompt");d.addClass("redactorAutosaveNoticeIcons");var g="";g=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),(function(m){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),g);setTimeout(function(){d.removeClass("open")},3000)}).bind(this));break;case"restored":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(l.timestamp).toLocaleString()})+'"></span>').prependTo(d);var k=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.confirm")+'"></span>').appendTo(d);var f=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.revert")+'"></span>').appendTo(d);k.click(function(){d.removeClass("open")});f.click((function(){WCF.System.Confirmation.show(WCF.Language.get("wcf.message.autosave.restored.revert.confirmMessage"),(function(m){if(m==="confirm"){this.wutil.reset();this.wutil.autosavePurge();d.removeClass("open")}}).bind(this))}).bind(this));i=WCF.Language.get("wcf.message.autosave.restored");d.addClass("redactorAutosaveNoticeIcons");var g="";g=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),(function(m){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),g);setTimeout(function(){k.trigger("click")},3000)}).bind(this));break;case"saved":if(d.hasClass("open")){return}setTimeout(function(){d.removeClass("open")},2000);i=WCF.Language.get("wcf.message.autosave.saved");break}d.children("span.redactorAutosaveMessage").text(i);d.addClass("open");if(j!=="saved"){WCF.DOMNodeInsertedHandler.execute()}},autosavePurgeOutdated:function(){var j=0;var m=this.wutil.getOption("woltlab.autosave").prefix;var l=m+"_wcf_master";try{j=localStorage.getItem(l)}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}if(j===0){return}var f=Date.now()-(7*24*3600*1000);if(j===null||j<f){var i=new RegExp("^"+m+"_");for(var h in localStorage){if(h.match(i)&&h!==l){var g=localStorage.getItem(h);try{g=JSON.parse(g)}catch(k){g={timestamp:0}}if(g===null||!g.timestamp||g.timestamp<f){try{localStorage.removeItem(h)}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}}}}try{localStorage.setItem(l,Date.now())}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}}},autosavePause:function(){b=true},autosaveResume:function(){b=false},buttonReplace:function(i,g,j,l,k){var f=this.buttonGet(i);var h=this.buttonAddAfter(i,g,j,l,k);if(f.parent().hasClass("separator")){h.parent().addClass("separator")}f.parent().remove();return h},removeZeroWidthSpace:function(f){var g="";for(var j=0,i=f.length;j<i;j++){var h=f.charCodeAt(j).toString(16);if(h!="200b"){g+=f[j]}}return g},getSource:function(){return this.$textarea},getName:function(){return this.$textarea.wcfIdentify()},selectionEndOfEditor:function(){this.focus.setEnd();var f=this.$editor.children(":last")[0];if(f.tagName==="P"){if(f.innerHTML===""){f.remove();f=$(this.opts.emptyHtml).appendTo(this.$editor)[0]}if(f.lastChild.nodeType===Element.TEXT_NODE){this.caret.set(f.lastChild,f.lastChild.length,f.lastChild,f.lastChild.length)}else{this.caret.setEnd(f)}}else{this.wutil.setCaretAfter(f)}this.wutil.saveSelection()},adjustSelectionForBlockElement:function(){if(document.activeElement!==this.$editor[0]){this.wutil.restoreSelection()}if(getSelection().getRangeAt(0).collapsed){var h=getSelection().getRangeAt(0).startContainer;if(h.nodeType===Node.TEXT_NODE&&h.textContent==="\u200b"&&h.parentElement.tagName==="P"&&h.parentElement.parentElement===this.$editor[0]){return}else{var f=$(h).parentsUntil(this.$editor[0]).last();if(f[0]===document.body.parentElement){this.wutil.selectionEndOfEditor()}else{var g=$("<p><br></p>").insertAfter(f);this.caret.setEnd(g)}}}},isCaret:function(){this.selection.get();return this.range.collapsed},isEndOfElement:function(f){this.selection.get();if(!this.wutil.isCaret()){return false}if(this.range.endContainer.nodeType===Element.TEXT_NODE){if(this.range.endOffset<this.range.endContainer.length){return false}}if(!this.wutil.isNodeWithin(this.range.endContainer,f)){return false}var g=this.range.endContainer;while(g!==f){if(g.nextSibling){return false}g=g.parentNode}return true},isNodeWithin:function(h,g){var f=$(h);while(f[0]!==this.$editor[0]){if(f[0]===g){return true}f=f.parent()}return false},containsTag:function(g,f){switch(g.nodeType){case Element.ELEMENT_NODE:if(g.tagName===f){return true}case Element.DOCUMENT_FRAGMENT_NODE:for(var h=0;h<g.childNodes.length;h++){if(this.wutil.containsTag(g.childNodes[h],f)){return true}}return false;break;default:return false;break}},replaceText:function(h){var i=$(document);var f=i.scrollTop();var g=false;if(this.wutil.inWysiwygMode()){this.code.toggle();g=true}this.$textarea.val(h);if(g){this.code.toggle();i.scrollTop(f)}i.trigger("resize")},setCaretBefore:function(f){this.wutil._setCaret(f,true)},setCaretAfter:function(f){this.wutil._setCaret(f,false)},_setCaret:function(g,h){var f=$(this.opts.emptyHtml);f[(h?"insertBefore":"insertAfter")](g);this.caret.setEnd(f[0])},fixDOM:function(){var i=this.$editor[0].childNodes[0];var f=i;var g=null;while(f){i=f;f=i.nextSibling;if(i.nodeType===Element.ELEMENT_NODE){if(this.reIsBlock.test(i.tagName)){g=null}else{if(g===null){g=$("<p />").insertBefore(i)}g.append(i)}}else{if(i.nodeType===Element.TEXT_NODE){if(g===null){if(f){if(f.nodeType===Element.ELEMENT_NODE&&f.tagName==="P"&&f.innerHTML==="\u200B"){var h=f.nextSibling;this.$editor[0].removeChild(f);f=h}}g=$("<p />").insertBefore(i)}g.append(i)}}}}}};
+if(!RedactorPlugins){var RedactorPlugins={}}RedactorPlugins.wutil=function(){var c="";var d=null;var a=false;var b=false;var e=null;return{_autosaveWorker:null,_range:null,init:function(){this.$textarea.parents("form").submit($.proxy(this.wutil.submit,this));if(this.wutil.getOption("woltlab.autosave").active){this.wutil.autosaveEnable();if(this.wutil.getOption("woltlab.autosave").saveOnInit||this.$textarea.data("saveOnInit")){this.wutil.setOption("woltlab.autosaveOnce",true)}else{this.wutil.autosaveRestore()}}this.wutil.setOption("autosave",false);var f=this.core.destroy;this.core.destroy=(function(){this.wutil.autosaveDisable();f.call(this)}).bind(this)},saveSelection:function(g){var f=getSelection();if(f.rangeCount){this.wutil._range=f.getRangeAt(0)}else{if(g){this.wutil._range=null}}},restoreSelection:function(){if(document.activeElement!==this.$editor[0]){this.$editor.focus()}if(this.wutil._range!==null){var f=window.getSelection();f.removeAllRanges();f.addRange(this.wutil._range);this.wutil._range=null}},clearSelection:function(){this.wutil._range=null},getSelection:function(){return this.wutil._range},insertAtCaret:function(g){if(this.opts.visual){console.debug("insertAtCaret() failed: Editor is in WYSIWYG-mode.");return false}this.$textarea.focus();var h=this.$textarea.getCaret();if(h==-1){console.debug("insertAtCaret() failed: Source is not input[type=text], input[type=password] or textarea.")}var f=this.$textarea.val();f=f.substr(0,h)+g+f.substr(h);this.$textarea.val(f);return true},insertDynamic:function(f,g){if(this.wutil.inWysiwygMode()){this.insert.html(f,false)}else{if(g===undefined||g===null){g=f}this.wutil.insertAtCaret(g)}},setOption:function(f,g){if(f.indexOf(".")!==-1){f=f.split(".",2);this.opts[f[0]][f[1]]=g}else{this.opts[f]=g}},getOption:function(f){if(f.indexOf(".")!==-1){f=f.split(".",2);if(this.opts[f[0]][f[1]]){return this.opts[f[0]][f[1]]}}else{if(this.opts[f]){return this.opts[f]}}return null},inPlainMode:function(){return !this.opts.visual},inWysiwygMode:function(){return(this.opts.visual)},replaceRangesWith:function(f){getSelection().removeAllRanges();getSelection().addRange(f)},getText:function(){if(this.wutil.inWysiwygMode()){this.code.startSync();var f=this.$textarea.val();this.$textarea.val($.trim(this.wbbcode.convertFromHtml(f)))}var g=$.trim(this.$textarea.val());g=this.wutil._removeSuperfluousNewlines(g);return g},isEmptyEditor:function(){if(this.opts.visual){return this.utils.isEmpty(this.$editor.html())}return(!$.trim(this.$textarea.val()))},submit:function(){if(this.wutil.inWysiwygMode()){this.code.startSync();var f=$.trim(this.wbbcode.convertFromHtml(this.$textarea.val()));f=this.wutil._removeSuperfluousNewlines(f);this.$textarea.val(f)}this.wutil.autosavePurge()},_removeSuperfluousNewlines:function(g){g=g.replace(/(\[\/(?:align|code|quote)\])\n/g,"$1");var f={text:g};WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","wutil_removeSuperfluousNewlines",f);return f.text},reset:function(){if(this.opts.visual){this.$editor.html("<p>"+this.opts.invisibleSpace+"</p>");this.wutil.saveSelection()}this.$textarea.val("");WCF.System.Event.fireEvent("com.woltlab.wcf.redactor","reset",{wysiwygContainerID:this.$textarea.wcfIdentify()})},autosaveEnable:function(f){if(!this.wutil.getOption("woltlab.autosave").active){this.wutil.setOption("woltlab.autosave",{active:true,key:f})}if(this.wutil._autosaveWorker===null){this.wutil.autosavePurgeOutdated();this.wutil._autosaveWorker=new WCF.PeriodicalExecuter((function(g){this.wutil.saveTextToStorage(false)}).bind(this),15*1000)}return true},saveTextToStorage:function(g){var f=this.wutil.getText();if(c==f&&!g){return}try{localStorage.setItem(this.wutil.getOption("woltlab.autosave").key,JSON.stringify({content:f,timestamp:Date.now()}));c=f;a=true;if(e===null){e=new WCF.PeriodicalExecuter((function(i){if(b===true){return}if(a===false){i.stop();e=null;return}this.wutil.autosaveShowNotice("saved");a=false}).bind(this),120*1000)}}catch(h){console.debug("[wutil.saveTextToStorage] Unable to access local storage: "+h.message)}},autosaveDisable:function(){if(!this.wutil.getOption("woltlab.autosave").active){return false}this.wutil._autosaveWorker.stop();this.wutil._autosaveWorker=null;this.wutil.setOption("woltlab.autosave",{active:false,key:""});return true},autosavePurge:function(){try{localStorage.removeItem(this.wutil.getOption("woltlab.autosave").key)}catch(f){console.debug("[wutil.autosavePurge] Unable to access local storage: "+f.message)}},autosaveRestore:function(){var f=this.wutil.getOption("woltlab.autosave");var g=null;try{g=localStorage.getItem(f.key)}catch(h){console.debug("[wutil.autosaveRestore] Unable to access local storage: "+h.message)}try{g=(g===null)?null:JSON.parse(g)}catch(h){g=null}if(g===null||!g.content){return false}if(f.lastEditTime&&(f.lastEditTime*1000)>g.timestamp){this.wutil.autosavePurge();return false}if(f.prompt){this.wutil.autosaveShowNotice("prompt",g);return false}if(this.wutil.inWysiwygMode()){this.wutil.setOption("woltlab.originalValue",g.content)}else{this.$textarea.val(g.content)}this.wutil.autosaveShowNotice("restored",{timestamp:g.timestamp});return true},autosaveShowNotice:function(j,l){if(d===null){d=$('<div class="redactorAutosaveNotice"><span class="redactorAutosaveMessage" /></div>');d.appendTo(this.$box);var h=(function(m){if(m!==null&&m.originalEvent.propertyName!=="opacity"){return}if(d.hasClass("open")&&m!==null){if(d.data("callbackOpen")){d.data("callbackOpen")()}}else{if(d.data("callbackClose")){d.data("callbackClose")()}d.removeData("callbackClose");d.removeData("callbackOpen");d.removeClass("redactorAutosaveNoticeIcons");d.empty();$('<span class="redactorAutosaveMessage" />').appendTo(d)}}).bind(this);d.on("transitionend webkitTransitionEnd",h)}var i="";switch(j){case"prompt":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(l.timestamp).toLocaleString()})+'"></span>').prependTo(d);var k=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.confirm")+'"></span>').appendTo(d);var f=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.prompt.discard")+'"></span>').appendTo(d);k.click((function(){this.wutil.replaceText(l.content);h(null);this.wutil.autosaveShowNotice("restored",l)}).bind(this));f.click((function(){this.wutil.autosavePurge();d.removeClass("open")}).bind(this));i=WCF.Language.get("wcf.message.autosave.prompt");d.addClass("redactorAutosaveNoticeIcons");var g="";g=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),(function(m){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),g);setTimeout(function(){d.removeClass("open")},3000)}).bind(this));break;case"restored":$('<span class="icon icon16 fa-info blue jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.version",{date:new Date(l.timestamp).toLocaleString()})+'"></span>').prependTo(d);var k=$('<span class="icon icon16 fa-check green pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.confirm")+'"></span>').appendTo(d);var f=$('<span class="icon icon16 fa-times red pointer jsTooltip" title="'+WCF.Language.get("wcf.message.autosave.restored.revert")+'"></span>').appendTo(d);k.click(function(){d.removeClass("open")});f.click((function(){WCF.System.Confirmation.show(WCF.Language.get("wcf.message.autosave.restored.revert.confirmMessage"),(function(m){if(m==="confirm"){this.wutil.reset();this.wutil.autosavePurge();d.removeClass("open")}}).bind(this))}).bind(this));i=WCF.Language.get("wcf.message.autosave.restored");d.addClass("redactorAutosaveNoticeIcons");var g="";g=WCF.System.Event.addListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),(function(m){WCF.System.Event.removeListener("com.woltlab.wcf.redactor","keydown_"+this.$textarea.wcfIdentify(),g);setTimeout(function(){k.trigger("click")},3000)}).bind(this));break;case"saved":if(d.hasClass("open")){return}setTimeout(function(){d.removeClass("open")},2000);i=WCF.Language.get("wcf.message.autosave.saved");break}d.children("span.redactorAutosaveMessage").text(i);d.addClass("open");if(j!=="saved"){WCF.DOMNodeInsertedHandler.execute()}},autosavePurgeOutdated:function(){var j=0;var m=this.wutil.getOption("woltlab.autosave").prefix;var l=m+"_wcf_master";try{j=localStorage.getItem(l)}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}if(j===0){return}var f=Date.now()-(7*24*3600*1000);if(j===null||j<f){var i=new RegExp("^"+m+"_");for(var h in localStorage){if(h.match(i)&&h!==l){var g=localStorage.getItem(h);try{g=JSON.parse(g)}catch(k){g={timestamp:0}}if(g===null||!g.timestamp||g.timestamp<f){try{localStorage.removeItem(h)}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}}}}try{localStorage.setItem(l,Date.now())}catch(k){console.debug("[wutil.autosavePurgeOutdated] Unable to access local storage: "+k.message)}}},autosavePause:function(){b=true},autosaveResume:function(){b=false},buttonReplace:function(i,g,j,l,k){var f=this.buttonGet(i);var h=this.buttonAddAfter(i,g,j,l,k);if(f.parent().hasClass("separator")){h.parent().addClass("separator")}f.parent().remove();return h},removeZeroWidthSpace:function(f){var g="";for(var j=0,i=f.length;j<i;j++){var h=f.charCodeAt(j).toString(16);if(h!="200b"){g+=f[j]}}return g},getSource:function(){return this.$textarea},getName:function(){return this.$textarea.wcfIdentify()},selectionEndOfEditor:function(){this.focus.setEnd();var f=this.$editor.children(":last")[0];if(f.tagName==="P"){if(f.innerHTML===""){f.remove();f=$(this.opts.emptyHtml).appendTo(this.$editor)[0]}if(f.lastChild.nodeType===Element.TEXT_NODE){this.caret.set(f.lastChild,f.lastChild.length,f.lastChild,f.lastChild.length)}else{this.caret.setEnd(f)}}else{this.wutil.setCaretAfter(f)}this.wutil.saveSelection()},adjustSelectionForBlockElement:function(){if(document.activeElement!==this.$editor[0]){this.wutil.restoreSelection()}if(getSelection().getRangeAt(0).collapsed){var h=getSelection().getRangeAt(0).startContainer;if(h.nodeType===Node.TEXT_NODE&&h.textContent==="\u200b"&&h.parentElement.tagName==="P"&&h.parentElement.parentElement===this.$editor[0]){return}else{var f=$(h).parentsUntil(this.$editor[0]).last();if(f[0]===document.body.parentElement){this.wutil.selectionEndOfEditor()}else{var g=$("<p><br></p>").insertAfter(f);this.caret.setEnd(g)}}}},isCaret:function(){this.selection.get();return this.range.collapsed},isEndOfElement:function(f){this.selection.get();if(!this.wutil.isCaret()){return false}if(this.range.endContainer.nodeType===Element.TEXT_NODE){if(this.range.endOffset<this.range.endContainer.length){return false}}if(!this.wutil.isNodeWithin(this.range.endContainer,f)){return false}var g=this.range.endContainer;while(g!==f){if(g.nextSibling){return false}g=g.parentNode}return true},isNodeWithin:function(h,g){var f=$(h);while(f[0]!==this.$editor[0]){if(f[0]===g){return true}f=f.parent()}return false},containsTag:function(g,f){switch(g.nodeType){case Element.ELEMENT_NODE:if(g.tagName===f){return true}case Element.DOCUMENT_FRAGMENT_NODE:for(var h=0;h<g.childNodes.length;h++){if(this.wutil.containsTag(g.childNodes[h],f)){return true}}return false;break;default:return false;break}},replaceText:function(h){var i=$(document);var f=i.scrollTop();var g=false;if(this.wutil.inWysiwygMode()){this.code.toggle();g=true}this.$textarea.val(h);if(g){this.code.toggle();i.scrollTop(f)}i.trigger("resize")},setCaretBefore:function(f){this.wutil._setCaret(f,true)},setCaretAfter:function(f){this.wutil._setCaret(f,false)},_setCaret:function(g,h){var f=$(this.opts.emptyHtml);f[(h?"insertBefore":"insertAfter")](g);this.caret.setEnd(f[0])},fixDOM:function(){var i=this.$editor[0].childNodes[0];var f=i;var g=null;while(f){i=f;f=i.nextSibling;if(i.nodeType===Element.ELEMENT_NODE){if(this.reIsBlock.test(i.tagName)){g=null}else{if(g===null){g=$("<p />").insertBefore(i)}g.append(i)}}else{if(i.nodeType===Element.TEXT_NODE){if(g===null){if(f){if(f.nodeType===Element.ELEMENT_NODE&&f.tagName==="P"&&f.innerHTML==="\u200B"){var h=f.nextSibling;this.$editor[0].removeChild(f);f=h}}g=$("<p />").insertBefore(i)}g.append(i)}}}}}};