mirror of
https://github.com/alextselegidis/easyappointments.git
synced 2024-11-29 11:23:10 +03:00
1 line
2.3 KiB
JavaScript
1 line
2.3 KiB
JavaScript
|
!function(i){"use strict";i.extend(!0,i.trumbowyg,{langs:{de:{history:{redo:"Wiederholen",undo:"Rückgängig"}},en:{history:{redo:"Redo",undo:"Undo"}},fr:{history:{redo:"Annuler",undo:"Rétablir"}}},plugins:{history:{init:function(o){o.o.plugins.history=i.extend(!0,{_stack:[],_index:-1,_focusEl:void 0},o.o.plugins.history||{});var t={title:o.lang.history.redo,ico:"redo",key:"Y",fn:function(){if(o.o.plugins.history._index<o.o.plugins.history._stack.length-1){o.o.plugins.history._index+=1;var i=o.o.plugins.history._index,t=o.o.plugins.history._stack[i];o.execCmd("html",t),o.o.plugins.history._stack[i]=o.$ed.html(),d(),e()}}},n={title:o.lang.history.undo,ico:"undo",key:"Z",fn:function(){if(o.o.plugins.history._index>0){o.o.plugins.history._index-=1;var i=o.o.plugins.history._index,t=o.o.plugins.history._stack[i];o.execCmd("html",t),o.o.plugins.history._stack[i]=o.$ed.html(),d(),e()}}},s=function(){var t,n,s=o.o.plugins.history._index,r=o.o.plugins.history._stack,d=r.slice(-1)[0]||"<p></p>",u=r[s],h=o.$ed.html(),c=o.doc.getSelection().focusNode,g="",a=o.o.plugins.history._focusEl;t=i("<div>"+d+"</div>").find("*").map(function(){return this.localName}),n=i("<div>"+h+"</div>").find("*").map(function(){return this.localName}),c&&(o.o.plugins.history._focusEl=c,g=c.outerHTML||c.textContent),h!==u&&(g.slice(-1).match(/\s/)||!l(t,n)||o.o.plugins.history._index<=0||c!==a?(o.o.plugins.history._index+=1,o.o.plugins.history._stack=r.slice(0,o.o.plugins.history._index),o.o.plugins.history._stack.push(h)):o.o.plugins.history._stack[s]=h,e())},e=function(){var i=o.o.plugins.history._index,t=o.o.plugins.history._stack.length,n=i>0,s=0!==t&&i!==t-1;r("historyUndo",n),r("historyRedo",s)},r=function(i,t){var n=o.$box.find(".trumbowyg-"+i+"-button");t?n.removeClass("trumbowyg-disable"):n.hasClass("trumbowyg-disable")||n.addClass("trumbowyg-disable")},l=function(i,o){if(i===o)return!0;if(null==i||null==o)return!1;if(i.length!==o.length)return!1;for(var t=0;t<i.length;t+=1)if(i[t]!==o[t])return!1;return!0},d=function(){var i=o.doc.getSelection().focusNode,t=o.doc.createRange();i.childNodes.length>0&&(t.setStartAfter(i.childNodes[i.childNodes.length-1]),t.setEndAfter(i.childNodes[i.childNodes.length-1]),o.doc.getSelection().removeAllRanges(),o.doc.getSelection().addRange(t))};o.$c.on("tbwinit tbwchange",s),o.addBtnDef("historyRedo",t),o.addBtnDef("historyUndo",n)}}}})}(jQuery);
|