summernote-rails 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,2 @@
1
- !function(a){"use strict";var b=navigator.appVersion.indexOf("Mac")>-1,c=navigator.userAgent.indexOf("MSIE")>-1,d=function(){var a=function(a){return function(b){return a===b}},b=function(a,b){return a===b},c=function(){return!1},d=function(a){return function(){return!a.apply(a,arguments)}},e=function(a){return a};return{eq:a,eq2:b,fail:c,not:d,self:e}}(),e=function(){var a=function(a){return a[0]},b=function(a){return a[a.length-1]},c=function(a){return a.slice(0,a.length-1)},e=function(a){return a.slice(1)},f=function(a,b){return b=b||d.self,a.reduce(function(a,c){return a+b(c)},0)},g=function(a){for(var b=[],c=-1,d=a.length;++c<d;)b[c]=a[c];return b},h=function(c,d){if(0===c.length)return[];var f=e(c);return f.reduce(function(a,c){var e=b(a);return d(b(e),c)?e[e.length]=c:a[a.length]=[c],a},[[a(c)]])},i=function(a){for(var b=[],c=0,d=a.length;d>c;c++)a[c]&&b.push(a[c]);return b};return{head:a,last:b,initial:c,tail:e,sum:f,from:g,compact:i,clusterBy:h}}(),f=function(){var b=function(a){return function(b){return b&&b.nodeName===a}},c=function(a){return a&&/^P|^LI|^H[1-7]/.test(a.nodeName)},f=function(a){return a&&/^UL|^OL/.test(a.nodeName)},g=function(b){return b&&a(b).hasClass("note-editable")},h=function(b){return b&&a(b).hasClass("note-control-sizing")},i=function(a,b){for(;a;){if(b(a))return a;a=a.parentNode}return null},j=function(a,b){b=b||d.fail;var c=[];return i(a,function(a){return c.push(a),b(a)}),c},k=function(b,c){for(var d=j(b),e=c;e;e=e.parentNode)if(a.inArray(e,d)>-1)return e;return null},l=function(a,b){var c=[],d=!1,e=!1,f=function(g){if(g){if(g===a&&(d=!0),d&&!e&&c.push(g),g===b)return e=!0,void 0;for(var h=0,i=g.childNodes.length;i>h;h++)f(g.childNodes[h])}};return f(k(a,b)),c},m=function(a,b){b=b||d.fail;for(var c=[];a&&(c.push(a),!b(a));)a=a.previousSibling;return c},n=function(a,b){b=b||d.fail;for(var c=[];a&&(c.push(a),!b(a));)a=a.nextSibling;return c},o=function(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a},p=function(b,c){return a.each(c,function(a,c){b.appendChild(c)}),b},q=b("#text"),r=function(a){return q(a)?a.nodeValue.length:a.childNodes.length},s=function(a){for(var b=0;a=a.previousSibling;)b+=1;return b},t=function(b,c){var f=e.initial(j(c,d.eq(b)));return a.map(f,s).reverse()},u=function(a,b){for(var c=a,d=0,e=b.length;e>d;d++)c=c.childNodes[b[d]];return c},v=function(a,b){if(0===b)return a;if(b>=r(a))return a.nextSibling;if(q(a))return a.splitText(b);var c=a.childNodes[b];return a=o(a.cloneNode(!1),a),p(a,n(c))},w=function(a,b,c){var e=j(b,d.eq(a));return 1===e.length?v(b,c):e.reduce(function(a,d){var e=d.cloneNode(!1);return o(e,d),a===b&&(a=v(a,c)),p(e,n(a)),e})};return{isText:q,isPara:c,isList:f,isEditable:g,isControlSizing:h,isAnchor:b("A"),isDiv:b("DIV"),isSpan:b("SPAN"),isB:b("B"),isU:b("U"),isS:b("S"),isI:b("I"),isImg:b("IMG"),ancestor:i,listAncestor:j,listNext:n,listPrev:m,commonAncestor:k,listBetween:l,insertAfter:o,position:s,makeOffsetPath:t,fromOffsetPath:u,split:w}}(),g=!!document.createRange,h=function(a,b){var c,d,g=a.parentElement(),h=document.body.createTextRange(),i=e.from(g.childNodes);for(c=0;c<i.length;c++)if(!f.isText(i[c])){if(h.moveToElementText(i[c]),h.compareEndPoints("StartToStart",a)>=0)break;d=i[c]}if(0!=c&&f.isText(i[c-1])){var j=document.body.createTextRange(),k=null;j.moveToElementText(d||g),j.collapse(!d),k=d?d.nextSibling:g.firstChild;var l=a.duplicate();l.setEndPoint("StartToStart",j);for(var m=l.text.replace(/[\r\n]/g,"").length;m>k.nodeValue.length&&k.nextSibling;)m-=k.nodeValue.length,k=k.nextSibling;k.nodeValue,b&&k.nextSibling&&f.isText(k.nextSibling)&&m==k.nodeValue.length&&(m-=k.nodeValue.length,k=k.nextSibling),g=k,c=m}return{cont:g,offset:c}},i=function(a){var b=function(a,c){var g,h;if(f.isText(a)){var i=f.listPrev(a,d.not(f.isText)),j=e.last(i).previousSibling;g=j||a.parentNode,c+=e.sum(e.tail(i),f.length),h=!j}else{if(g=a.childNodes[c]||a,f.isText(g))return b(g,c);c=0,h=!1}return{cont:g,collapseToStart:h,offset:c}},c=document.body.createTextRange(),g=b(a.cont,a.offset);return c.moveToElementText(g.cont),c.collapse(g.collapseToStart),c.moveStart("character",g.offset),c},j=function(b,c,j,k){if(0===arguments.length)if(g){var l=document.getSelection().getRangeAt(0);b=l.startContainer,c=l.startOffset,j=l.endContainer,k=l.endOffset}else{var m=document.selection.createRange(),n=m.duplicate();n.collapse(!1);var o=m;o.collapse(!0);var p=h(o,!0),q=h(n,!1);b=p.cont,c=p.offset,j=q.cont,k=q.offset}this.sc=b,this.so=c,this.ec=j,this.eo=k;var r=function(){if(g){var a=document.createRange();return a.setStart(b,c),a.setEnd(j,k),a}var d=i({cont:b,offset:c});return d.setEndPoint("EndToEnd",i({cont:j,offset:k})),d};this.select=function(){var a=r();if(g){var b=document.getSelection();b.rangeCount>0&&b.removeAllRanges(),b.addRange(a)}else a.select()},this.listPara=function(){var c=f.listBetween(b,j),g=e.compact(a.map(c,function(a){return f.ancestor(a,f.isPara)}));return a.map(e.clusterBy(g,d.eq2),e.head)},this.isOnList=function(){var a=f.ancestor(b,f.isList),c=f.ancestor(j,f.isList);return a&&a===c},this.isOnAnchor=function(){var a=f.ancestor(b,f.isAnchor),c=f.ancestor(j,f.isAnchor);return a&&a===c},this.isCollapsed=function(){return b===j&&c===k},this.insertNode=function(a){var b=r();g?b.insertNode(a):b.pasteHTML(a.outerHTML)},this.toString=function(){var a=r();return g?a.toString():a.text},this.bookmark=function(a){return{s:{path:f.makeOffsetPath(a,b),offset:c},e:{path:f.makeOffsetPath(a,j),offset:k}}}},k=function(a,b){return new j(f.fromOffsetPath(a,b.s.path),b.s.offset,f.fromOffsetPath(a,b.e.path),b.e.offset)},l=function(){this.stylePara=function(b,c){var d=b.listPara();a.each(d,function(b,d){a.each(c,function(a,b){d.style[a]=b})})},this.current=function(b,c){var d=a(f.isText(b.sc)?b.sc.parentNode:b.sc),e=d.css(["font-size","text-align","list-style-type","line-height"])||{};if(e["font-size"]=parseInt(e["font-size"]),e["font-bold"]=document.queryCommandState("bold")?"bold":"normal",e["font-italic"]=document.queryCommandState("italic")?"italic":"normal",e["font-underline"]=document.queryCommandState("underline")?"underline":"normal",b.isOnList()){var g=["circle","disc","disc-leading-zero","square"],h=a.inArray(e["list-style-type"],g)>-1;e["list-style"]=h?"unordered":"ordered"}else e["list-style"]="none";var i=f.ancestor(b.sc,f.isPara);if(i&&i.style["line-height"])e["line-height"]=i.style.lineHeight;else{var j=parseInt(e["line-height"])/parseInt(e["font-size"]);e["line-height"]=j.toFixed(1)}return e.image=f.isImg(c)&&c,e.anchor=b.isOnAnchor()&&f.ancestor(b.sc,f.isAnchor),e.aAncestor=f.listAncestor(b.sc,f.isEditable),e}},m=function(){var a=[],b=[],c=function(a){var b=a[0],c=new j;return{contents:a.html(),bookmark:c.bookmark(b),scrollTop:a.scrollTop()}},d=function(a,b){a.html(b.contents).scrollTop(b.scrollTop),k(a[0],b.bookmark).select()};this.undo=function(e){var f=c(e);0!==a.length&&(d(e,a.pop()),b.push(f))},this.redo=function(e){var f=c(e);0!==b.length&&(d(e,b.pop()),a.push(f))},this.recordUndo=function(d){b=[],a.push(c(d))}},n=function(){var b=new l;this.currentStyle=function(a){return document.getSelection&&0==document.getSelection().rangeCount?null:b.current(new j,a)},this.undo=function(a){a.data("NoteHistory").undo(a)},this.redo=function(a){a.data("NoteHistory").redo(a)};for(var d=this.recordUndo=function(a){a.data("NoteHistory").recordUndo(a)},e=["bold","italic","underline","strikethrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList","indent","outdent","formatBlock","removeFormat","backColor","foreColor","insertImage","insertHorizontalRule"],g=0,h=e.length;h>g;g++)this[e[g]]=function(a){return function(b,c){d(b),document.execCommand(a,!1,c)}}(e[g]);this.formatBlock=function(a,b){b=c?"<"+b+">":b,document.execCommand("FormatBlock",!1,b)},this.fontSize=function(a,b){d(a),document.execCommand("fontSize",!1,3);var c=a.find("font[size=3]");c.removeAttr("size").css("font-size",b+"px")},this.lineHeight=function(a,c){d(a),b.stylePara(new j,{lineHeight:c})},this.unlink=function(a){var b=new j;if(b.isOnAnchor()){d(a);var c=f.ancestor(b.sc,f.isAnchor);b=new j(c,0,c,1),b.select(),document.execCommand("unlink")}},this.setLinkDialog=function(b,e){var g=new j;if(g.isOnAnchor()){var h=f.ancestor(g.sc,f.isAnchor);g=new j(h,0,h,1)}e({range:g,text:g.toString(),url:g.isOnAnchor()?f.ancestor(g.sc,f.isAnchor).href:""},function(e){g.select(),d(b);var f=-1!==e.toLowerCase().indexOf("://"),h=f?e:"http://"+e;if(c&&g.isCollapsed()){g.insertNode(a('<A id="linkAnchor">'+e+"</A>")[0]);var i=a("#linkAnchor").removeAttr("id").attr("href",h);g=new j(i[0],0,i[0],1),g.select()}else document.execCommand("createlink",!1,h)})},this.color=function(a,b){var c=JSON.parse(b);d(a),document.execCommand("foreColor",!1,c.foreColor),document.execCommand("backColor",!1,c.backColor)},this.insertTable=function(b,e){d(b);for(var f,g=e.split("x"),h=g[0],i=g[1],k=[],l=c?"&nbsp;":"<br/>",m=0;h>m;m++)k.push("<td>"+l+"</td>");f=k.join("");for(var n,o=[],p=0;i>p;p++)o.push("<tr>"+f+"</tr>");n=o.join("");var q='<table class="table table-bordered">'+n+"</table>";(new j).insertNode(a(q)[0])},this.float=function(a,b,c){d(a),c.style.cssFloat=b},this.resize=function(a,b,c){d(a),c.style.width=a.width()*b+"px",c.style.height=""},this.resizeTo=function(a,b){b.style.width=a.x+"px",b.style.height=a.y+"px"}},o=function(){this.update=function(b,c){var d=function(b,c){b.find(".dropdown-menu li a").each(function(){var b=a(this).attr("data-value")==c;this.className=b?"checked":""})},e=b.find(".note-fontsize");e.find(".note-current-fontsize").html(c["font-size"]),d(e,parseFloat(c["font-size"]));var f=b.find(".note-height");d(f,parseFloat(c["line-height"]));var g=function(a,c){var d=b.find(a);d[c()?"addClass":"removeClass"]("active")};g('button[data-event="bold"]',function(){return"bold"===c["font-bold"]}),g('button[data-event="italic"]',function(){return"italic"===c["font-italic"]}),g('button[data-event="underline"]',function(){return"underline"===c["font-underline"]}),g('button[data-event="justifyLeft"]',function(){return"left"===c["text-align"]||"start"===c["text-align"]}),g('button[data-event="justifyCenter"]',function(){return"center"===c["text-align"]}),g('button[data-event="justifyRight"]',function(){return"right"===c["text-align"]}),g('button[data-event="justifyFull"]',function(){return"justify"===c["text-align"]}),g('button[data-event="insertUnorderedList"]',function(){return"unordered"===c["list-style"]}),g('button[data-event="insertOrderedList"]',function(){return"ordered"===c["list-style"]})},this.updateRecentColor=function(b,c,d){var e=a(b).closest(".note-color"),f=e.find(".note-recent-color"),g=JSON.parse(f.attr("data-value"));g[c]=d,f.attr("data-value",JSON.stringify(g));var h="backColor"===c?"background-color":"color";f.find("i").css(h,d)}},p=function(){this.update=function(b,c){var d=b.find(".note-link-popover"),e=b.find(".note-image-popover");if(c.anchor){var f=d.find("a");f.attr("href",c.anchor.href).html(c.anchor.href);var g=c.anchor.getBoundingClientRect();d.css({display:"block",left:g.left,top:a(document).scrollTop()+g.bottom})}else d.hide();if(c.image){var g=c.image.getBoundingClientRect();e.css({display:"block",left:g.left,top:a(document).scrollTop()+g.bottom})}else e.hide()},this.hide=function(a){a.children().hide()}},q=function(){this.update=function(b,c){var d=b.find(".note-control-selection");if(c.image){var e=c.image.getBoundingClientRect();d.css({display:"block",left:e.left+"px",top:a(document).scrollTop()+e.top+"px",width:e.width+"px",height:e.height+"px"}).data("target",c.image);var f=e.width+"x"+e.height;d.find(".note-control-selection-info").text(f)}else d.hide()},this.hide=function(a){a.children().hide()}},r=function(){this.showImageDialog=function(b,c,d){var e=b.find(".note-image-dialog"),f=b.find(".note-dropzone"),g=b.find(".note-image-input");e.on("shown.bs.modal",function(){f.on("dragenter dragover dragleave",!1),f.on("drop",function(a){c(a),e.modal("hide")}),g.on("change",function(){d(this.files),a(this).val(""),e.modal("hide")})}).on("hidden.bs.modal",function(){f.off("dragenter dragover dragleave drop"),g.off("change")}).modal("show")},this.showLinkDialog=function(a,b,c){var d=a.find(".note-link-dialog"),e=d.find(".note-link-text"),f=d.find(".note-link-url"),g=d.find(".note-link-btn");d.on("shown.bs.modal",function(){e.html(b.text),f.val(b.url).keyup(function(){f.val()?g.removeClass("disabled").attr("disabled",!1):g.addClass("disabled").attr("disabled",!0),b.text||e.html(f.val())}).trigger("focus"),g.click(function(a){d.modal("hide"),c(f.val()),a.preventDefault()})}).on("hidden.bs.modal",function(){f.off("keyup"),d.off("shown.bs.modal hidden.bs.modal"),g.off("click")}).modal("show")},this.showHelpDialog=function(a){a.find(".note-help-dialog").modal("show")}},s=function(){var c=new n,d=new o,e=new p,g=new q,h=new r,i={BACKSPACE:8,TAB:9,ENTER:13,SPACE:32,NUM0:48,NUM1:49,NUM6:54,NUM7:55,NUM8:56,B:66,E:69,I:73,J:74,K:75,L:76,R:82,S:83,U:85,Y:89,Z:90,SLASH:191,LEFTBRACKET:219,BACKSLACH:220,RIGHTBRACKET:221},j=function(b){var c=a(b).closest(".note-editor");return{editor:function(){return c},toolbar:function(){return c.find(".note-toolbar")},editable:function(){return c.find(".note-editable")},statusbar:function(){return c.find(".note-statusbar")},popover:function(){return c.find(".note-popover")},handle:function(){return c.find(".note-handle")},dialog:function(){return c.find(".note-dialog")}}},k=function(a){var d=b?a.metaKey:a.ctrlKey,e=a.shiftKey,f=a.keyCode,g=d||e||f===i.TAB,k=g?j(a.target):null;if(d&&(e&&f===i.Z||f===i.Y))c.redo(k.editable());else if(d&&f===i.Z)c.undo(k.editable());else if(d&&f===i.B)c.bold(k.editable());else if(d&&f===i.I)c.italic(k.editable());else if(d&&f===i.U)c.underline(k.editable());else if(d&&e&&f===i.S)c.strikethrough(k.editable());else if(d&&f===i.BACKSLACH)c.removeFormat(k.editable());else if(d&&f===i.K)c.setLinkDialog(k.editable(),function(a,b){h.showLinkDialog(k.dialog(),a,b)});else if(d&&f===i.SLASH)h.showHelpDialog(k.dialog());else if(d&&e&&f===i.L)c.justifyLeft(k.editable());else if(d&&e&&f===i.E)c.justifyCenter(k.editable());else if(d&&e&&f===i.R)c.justifyRight(k.editable());else if(d&&e&&f===i.J)c.justifyFull(k.editable());else if(d&&e&&f===i.NUM7)c.insertUnorderedList(k.editable());else if(d&&e&&f===i.NUM8)c.insertOrderedList(k.editable());else if(d&&f===i.LEFTBRACKET)c.outdent(k.editable());else if(d&&f===i.RIGHTBRACKET)c.indent(k.editable());else if(d&&f===i.NUM0)c.formatBlock(k.editable(),"P");else if(d&&i.NUM1<=f&&f<=i.NUM6){var l="H"+String.fromCharCode(f);c.formatBlock(k.editable(),l)}else{if(!d||f!==i.ENTER)return(f===i.BACKSPACE||f===i.ENTER||f===i.SPACE)&&c.recordUndo(j(a.target).editable()),void 0;c.insertHorizontalRule(k.editable())}a.preventDefault()},l=function(b,d){b.trigger("focus"),a.each(d,function(a,d){var e=new FileReader;e.onload=function(a){c.insertImage(b,a.target.result)},e.readAsDataURL(d)})},m=function(a){var b=a.originalEvent.dataTransfer;if(b&&b.files){var c=j(a.currentTarget||a.target);l(c.editable(),b.files)}a.stopPropagation(),a.preventDefault()},s=function(a){f.isImg(a.target)&&a.preventDefault()},t=function(a){var b=j(a.currentTarget||a.target),f=c.currentStyle(a.target);f&&(d.update(b.toolbar(),f),e.update(b.popover(),f),g.update(b.handle(),f))},u=function(a){var b=j(a.currentTarget||a.target);e.hide(b.popover()),g.hide(b.handle())},v=function(b){if(f.isControlSizing(b.target)){var d,h=j(b.target),i=h.handle(),k=h.popover(),l=h.editable(),m=h.editor(),n=i.find(".note-control-selection").data("target"),o=a(n).offset(),p=a(document).scrollTop();m.on("mousemove",function(a){d={x:a.clientX-o.left,y:a.clientY-(o.top-p)},c.resizeTo(d,n),g.update(i,{image:n}),e.update(k,{image:n})}).on("mouseup",function(){m.off("mousemove").off("mouseup")}),c.recordUndo(l),b.stopPropagation(),b.preventDefault()}},w=function(b){var c=a(b.target).closest("[data-event]");c.length>0&&b.preventDefault()},x=function(b){var e=a(b.target).closest("[data-event]");if(e.length>0){var f,g=e.attr("data-event"),i=e.attr("data-value"),k=j(b.target),n=k.dialog(),o=k.editable();if(-1!==a.inArray(g,["resize","float"])){var p=k.handle(),q=p.find(".note-control-selection");f=q.data("target")}c[g]&&(o.trigger("focus"),c[g](o,i,f)),-1!==a.inArray(g,["backColor","foreColor"])?d.updateRecentColor(e[0],g,i):"showLinkDialog"===g?c.setLinkDialog(o,function(a,b){h.showLinkDialog(n,a,b)}):"showImageDialog"===g?h.showImageDialog(n,m,function(a){l(o,a)}):"showHelpDialog"===g&&h.showHelpDialog(n),t(b)}},y=24,z=function(b){var c=a(document),d=j(b.target).editable(),e=d.offset().top-c.scrollTop(),f=function(a){d.height(a.clientY-(e+y))},g=function(){c.unbind("mousemove",f).unbind("mouseup",g)};c.mousemove(f).mouseup(g),b.stopPropagation(),b.preventDefault()},A=18,B=function(b){var c,d=a(b.target.parentNode),e=d.next(),f=d.find(".note-dimension-picker-mousecatcher"),g=d.find(".note-dimension-picker-highlighted"),h=d.find(".note-dimension-picker-unhighlighted");if(void 0===b.offsetX){var i=a(b.target).offset();c={x:b.pageX-i.left,y:b.pageY-i.top}}else c={x:b.offsetX,y:b.offsetY};var j={c:Math.ceil(c.x/A)||1,r:Math.ceil(c.y/A)||1};g.css({width:j.c+"em",height:j.r+"em"}),f.attr("data-value",j.c+"x"+j.r),3<j.c&&j.c<10&&h.css({width:j.c+1+"em"}),3<j.r&&j.r<10&&h.css({height:j.r+1+"em"}),e.html(j.c+" x "+j.r)};this.attach=function(a,b){a.editable.on("keydown",k),a.editable.on("mousedown",s),a.editable.on("keyup mouseup",t),a.editable.on("scroll",u),a.editable.on("dragenter dragover dragleave",!1),a.editable.on("drop",m),a.handle.on("mousedown",v),a.toolbar.on("click",x),a.popover.on("click",x),a.toolbar.on("mousedown",w),a.popover.on("mousedown",w),a.statusbar.on("mousedown",z);var c=a.toolbar,d=c.find(".note-dimension-picker-mousecatcher");d.on("mousemove",B),b.onenter&&a.editable.keypress(function(a){a.keyCode===i.ENTER&&b.onenter(a)}),b.onfocus&&a.editable.focus(b.onfocus),b.onblur&&a.editable.blur(b.onblur),b.onkeyup&&a.editable.blur(b.onkeyup),b.onkeydown&&a.editable.blur(b.onkeydown)},this.dettach=function(a){a.editable.off(),a.toolbar.off(),a.handle.off(),a.popover.off()}},t=function(){var c={picture:'<button type="button" class="btn btn-default btn-sm btn-small" title="Picture" data-event="showImageDialog" tabindex="-1"><i class="icon-picture"></i></button>',link:'<button type="button" class="btn btn-default btn-sm btn-small" title="Link" data-event="showLinkDialog" data-shortcut="Ctrl+K" data-mac-shortcut="⌘+K" tabindex="-1"><i class="icon-link"></i></button>',table:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Table" data-toggle="dropdown" tabindex="-1"><i class="icon-table"></i> <span class="caret"></span></button><ul class="dropdown-menu"><div class="note-dimension-picker"><div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div><div class="note-dimension-picker-highlighted"></div><div class="note-dimension-picker-unhighlighted"></div></div><div class="note-dimension-display"> 1 x 1 </div></ul>',style:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Style" data-toggle="dropdown" tabindex="-1"><i class="icon-magic"></i> <span class="caret"></span></button><ul class="dropdown-menu"><li><a data-event="formatBlock" data-value="p">Normal</a></li><li><a data-event="formatBlock" data-value="blockquote"><blockquote>Quote</blockquote></a></li><li><a data-event="formatBlock" data-value="pre">Code</a></li><li><a data-event="formatBlock" data-value="h1"><h1>Header 1</h1></a></li><li><a data-event="formatBlock" data-value="h2"><h2>Header 2</h2></a></li><li><a data-event="formatBlock" data-value="h3"><h3>Header 3</h3></a></li><li><a data-event="formatBlock" data-value="h4"><h4>Header 4</h4></a></li><li><a data-event="formatBlock" data-value="h5"><h5>Header 5</h5></a></li><li><a data-event="formatBlock" data-value="h6"><h6>Header 6</h6></a></li></ul>',fontsize:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Font Size" tabindex="-1"><span class="note-current-fontsize">11</span> <b class="caret"></b></button><ul class="dropdown-menu"><li><a data-event="fontSize" data-value="8"><i class="icon-ok"></i> 8</a></li><li><a data-event="fontSize" data-value="9"><i class="icon-ok"></i> 9</a></li><li><a data-event="fontSize" data-value="10"><i class="icon-ok"></i> 10</a></li><li><a data-event="fontSize" data-value="11"><i class="icon-ok"></i> 11</a></li><li><a data-event="fontSize" data-value="12"><i class="icon-ok"></i> 12</a></li><li><a data-event="fontSize" data-value="14"><i class="icon-ok"></i> 14</a></li><li><a data-event="fontSize" data-value="18"><i class="icon-ok"></i> 18</a></li><li><a data-event="fontSize" data-value="24"><i class="icon-ok"></i> 24</a></li><li><a data-event="fontSize" data-value="36"><i class="icon-ok"></i> 36</a></li></ul>',color:'<button type="button" class="btn btn-default btn-sm btn-small note-recent-color" title="Recent Color" data-event="color" data-value=\'{"foreColor":"black","backColor":"yellow"}\' tabindex="-1"><i class="icon-font" style="color:black;background-color:yellow;"></i></button><button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="More Color" data-toggle="dropdown" tabindex="-1"><span class="caret"></span></button><ul class="dropdown-menu"><li><div class="btn-group"><div class="note-palette-title">BackColor</div><div class="note-color-palette" data-target-event="backColor"></div></div><div class="btn-group"><div class="note-palette-title">FontColor</div><div class="note-color-palette" data-target-event="foreColor"></div></div></li></ul>',bold:'<button type="button" class="btn btn-default btn-sm btn-small" title="Bold" data-shortcut="Ctrl+B" data-mac-shortcut="⌘+B" data-event="bold" tabindex="-1"><i class="icon-bold"></i></button>',italic:'<button type="button" class="btn btn-default btn-sm btn-small" title="Italic" data-shortcut="Ctrl+I" data-mac-shortcut="⌘+I" data-event="italic" tabindex="-1"><i class="icon-italic"></i></button>',underline:'<button type="button" class="btn btn-default btn-sm btn-small" title="Underline" data-shortcut="Ctrl+U" data-mac-shortcut="⌘+U" data-event="underline" tabindex="-1"><i class="icon-underline"></i></button>',clear:'<button type="button" class="btn btn-default btn-sm btn-small" title="Remove Font Style" data-shortcut="Ctrl+\\" data-mac-shortcut="⌘+\\" data-event="removeFormat" tabindex="-1"><i class="icon-eraser"></i></button>',ul:'<button type="button" class="btn btn-default btn-sm btn-small" title="Unordered list" data-shortcut="Ctrl+Shift+8" data-mac-shortcut="⌘+⇧+7" data-event="insertUnorderedList" tabindex="-1"><i class="icon-list-ul"></i></button>',ol:'<button type="button" class="btn btn-default btn-sm btn-small" title="Ordered list" data-shortcut="Ctrl+Shift+7" data-mac-shortcut="⌘+⇧+8" data-event="insertOrderedList" tabindex="-1"><i class="icon-list-ol"></i></button>',paragraph:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Paragraph" data-toggle="dropdown" tabindex="-1"><i class="icon-align-left"></i> <span class="caret"></span></button><ul class="dropdown-menu"><li><div class="note-align btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Align left" data-shortcut="Ctrl+Shift+L" data-mac-shortcut="⌘+⇧+L" data-event="justifyLeft" tabindex="-1"><i class="icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Align center" data-shortcut="Ctrl+Shift+E" data-mac-shortcut="⌘+⇧+E" data-event="justifyCenter" tabindex="-1"><i class="icon-align-center"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Align right" data-shortcut="Ctrl+Shift+R" data-mac-shortcut="⌘+⇧+R" data-event="justifyRight" tabindex="-1"><i class="icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Justify full" data-shortcut="Ctrl+Shift+J" data-mac-shortcut="⌘+⇧+J" data-event="justifyFull" tabindex="-1"><i class="icon-align-justify"></i></button></div></li><li><div class="note-list btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Outdent" data-shortcut="Ctrl+[" data-mac-shortcut="⌘+[" data-event="outdent" tabindex="-1"><i class="icon-indent-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Indent" data-shortcut="Ctrl+]" data-mac-shortcut="⌘+]" data-event="indent" tabindex="-1"><i class="icon-indent-right"></i></button></li></ul>',height:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Line Height" tabindex="-1"><i class="icon-text-height"></i>&nbsp; <b class="caret"></b></button><ul class="dropdown-menu"><li><a data-event="lineHeight" data-value="1.0"><i class="icon-ok"></i> 1.0</a></li><li><a data-event="lineHeight" data-value="1.2"><i class="icon-ok"></i> 1.2</a></li><li><a data-event="lineHeight" data-value="1.4"><i class="icon-ok"></i> 1.4</a></li><li><a data-event="lineHeight" data-value="1.5"><i class="icon-ok"></i> 1.5</a></li><li><a data-event="lineHeight" data-value="1.6"><i class="icon-ok"></i> 1.6</a></li><li><a data-event="lineHeight" data-value="1.8"><i class="icon-ok"></i> 1.8</a></li><li><a data-event="lineHeight" data-value="2.0"><i class="icon-ok"></i> 2.0</a></li><li><a data-event="lineHeight" data-value="3.0"><i class="icon-ok"></i> 3.0</a></li></ul>',help:'<button type="button" class="btn btn-default btn-sm btn-small" title="Help" data-shortcut="Ctrl+/" data-mac-shortcut="⌘+/" data-event="showHelpDialog" tabindex="-1"><i class="icon-question"></i></button>'},d='<div class="note-popover"><div class="note-link-popover popover fade bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-link-content"><a href="http://www.google.com" target="_blank">www.google.com</a>&nbsp;&nbsp;<div class="note-insert btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Edit" data-event="showLinkDialog" tabindex="-1"><i class="icon-edit"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Unlink" data-event="unlink" tabindex="-1"><i class="icon-unlink"></i></button></div></div></div><div class="note-image-popover popover fade bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-image-content"><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Full" data-event="resize" data-value="1" tabindex="-1"><i class="icon-resize-full"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Half" data-event="resize" data-value="0.5" tabindex="-1">½</button><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Thrid" data-event="resize" data-value="0.33" tabindex="-1">⅓</button><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Quarter" data-event="resize" data-value="0.25" tabindex="-1">¼</button></div><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Float Left" data-event="float" data-value="left" tabindex="-1"><i class="icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Float Right" data-event="float" data-value="right" tabindex="-1"><i class="icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Float None" data-event="float" data-value="none" tabindex="-1"><i class="icon-reorder"></i></button></div></div></div></div>',e='<div class="note-handle"><div class="note-control-selection"><div class="note-control-selection-bg"></div><div class="note-control-holder note-control-nw"></div><div class="note-control-holder note-control-ne"></div><div class="note-control-holder note-control-sw"></div><div class="note-control-sizing note-control-se"></div><div class="note-control-selection-info"></div></div></div>',f='<table class="note-shortcut"><thead><tr><th></th><th>Text formatting</th></tr></thead><tbody><tr><td>⌘ + B</td><td>Toggle Bold</td></tr><tr><td>⌘ + I</td><td>Toggle Italic</td></tr><tr><td>⌘ + U</td><td>Toggle Underline</td></tr><tr><td>⌘ + ⇧ + S</td><td>Toggle Strike</td></tr><tr><td>⌘ + \\</td><td>Remove Font Style</td></tr></tr></tbody></table>',g='<table class="note-shortcut"><thead><tr><th></th><th>Action</th></tr></thead><tbody><tr><td>⌘ + Z</td><td>Undo</td></tr><tr><td>⌘ + ⇧ + Z</td><td>Redo</td></tr><tr><td>⌘ + ]</td><td>Indent</td></tr><tr><td>⌘ + [</td><td>Outdent</td></tr><tr><td>⌘ + K</td><td>Insert Link</td></tr><tr><td>⌘ + ENTER</td><td>Insert Horizontal Rule</td></tr></tbody></table>',h='<table class="note-shortcut"><thead><tr><th></th><th>Paragraph formatting</th></tr></thead><tbody><tr><td>⌘ + ⇧ + L</td><td>Align Left</td></tr><tr><td>⌘ + ⇧ + E</td><td>Align Center</td></tr><tr><td>⌘ + ⇧ + R</td><td>Align Right</td></tr><tr><td>⌘ + ⇧ + J</td><td>Justify Full</td></tr><tr><td>⌘ + ⇧ + NUM7</td><td>Ordered List</td></tr><tr><td>⌘ + ⇧ + NUM8</td><td>Unordered List</td></tr></tbody></table>',i='<table class="note-shortcut"><thead><tr><th></th><th>Document Style</th></tr></thead><tbody><tr><td>⌘ + NUM0</td><td>Normal Text</td></tr><tr><td>⌘ + NUM1</td><td>Heading 1</td></tr><tr><td>⌘ + NUM2</td><td>Heading 2</td></tr><tr><td>⌘ + NUM3</td><td>Heading 3</td></tr><tr><td>⌘ + NUM4</td><td>Heading 4</td></tr><tr><td>⌘ + NUM5</td><td>Heading 5</td></tr><tr><td>⌘ + NUM6</td><td>Heading 6</td></tr></tbody></table>',j='<table class="note-shortcut-layout"><tbody><tr><td>'+g+"</td><td>"+f+"</td></tr>"+"<tr><td>"+i+"</td><td>"+h+"</td></tr>"+"</tbody>"+"</table>",k='<div class="note-dialog"><div class="note-image-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true" tabindex="-1">×</button><h4>Insert Image</h4></div><div class="modal-body"><div class="row-fluid"><div class="note-dropzone span12">Drag an image here</div><div>or if you prefer...</div><input class="note-image-input" type="file" class="note-link-url" type="text" /></div></div></div></div></div><div class="note-link-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true" tabindex="-1">×</button><h4>Edit Link</h4></div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>Text to display</label><span class="note-link-text form-control input-xlarge uneditable-input" /></div><div class="form-group"><label>To what URL should this link go?</label><input class="note-link-url form-control span12" type="text" /></div></div></div><div class="modal-footer"><a href="#" class="btn disabled note-link-btn" disabled="disabled">Link</a></div></div></div></div><div class="note-help-dialog modal fade" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><div class="modal-background"><a class="modal-close pull-right" data-dismiss="modal" aria-hidden="true" tabindex="-1">Close</a><div class="title">Keyboard shortcuts</div>'+j+'<p class="text-center"><a href="//hackerwins.github.io/summernote/" target="_blank">Summernote v0.3</a> · <a href="//github.com/HackerWins/summernote" target="_blank">Project</a> · <a href="//github.com/HackerWins/summernote/issues" target="_blank">Issues</a></p>'+"</div>"+"</div>"+"</div>"+"</div>"+"</div>",l=function(c,d){c.find("button").each(function(c,d){var e=a(d),f=e.attr(b?"data-mac-shortcut":"data-shortcut");f&&e.attr("title",function(a,b){return b+" ("+f+")"})}).tooltip({container:"body",placement:d||"top"})},n=[["#000000","#424242","#636363","#9C9C94","#CEC6CE","#EFEFEF","#EFF7F7","#FFFFFF"],["#FF0000","#FF9C00","#FFFF00","#00FF00","#00FFFF","#0000FF","#9C00FF","#FF00FF"],["#F7C6CE","#FFE7CE","#FFEFC6","#D6EFD6","#CEDEE7","#CEE7F7","#D6D6E7","#E7D6DE"],["#E79C9C","#FFC69C","#FFE79C","#B5D6A5","#A5C6CE","#9CC6EF","#B5A5D6","#D6A5BD"],["#E76363","#F7AD6B","#FFD663","#94BD7B","#73A5AD","#6BADDE","#8C7BC6","#C67BA5"],["#CE0000","#E79439","#EFC631","#6BA54A","#4A7B8C","#3984C6","#634AA5","#A54A7B"],["#9C0000","#B56308","#BD9400","#397B21","#104A5A","#085294","#311873","#731842"],["#630000","#7B3900","#846300","#295218","#083139","#003163","#21104A","#4A1031"]],o=function(b){b.find(".note-color-palette").each(function(){for(var b=a(this),c=b.attr("data-target-event"),d="",e=0,f=n.length;f>e;e++){for(var g=n[e],h="<div>",i=0,j=g.length;j>i;i++){var k=g[i],l=['<button type="button" class="note-color-btn" style="background-color:',k,';" data-event="',c,'" data-value="',k,'" title="',k,'" data-toggle="button" tabindex="-1"></button>'].join("");
2
- h+=l}h+="</div>",d+=h}b.html(d)})};this.createLayout=function(b,f,g,h){if(!b.next().hasClass("note-editor")){var i=a('<div class="note-editor"></div>');f>0&&a('<div class="note-statusbar"><div class="note-resizebar"><div class="note-icon-bar"></div><div class="note-icon-bar"></div><div class="note-icon-bar"></div></div></div>').prependTo(i);var j=a('<div class="note-editable" contentEditable="true"></div>').prependTo(i);g&&j.attr("tabIndex",g),f&&j.height(f),j.html(b.html()),j.data("NoteHistory",new m);for(var n="",p=0,q=h.length;q>p;p++){var r=h[p];n+='<div class="note-'+r[0]+' btn-group">';for(var s=0,t=r[1].length;t>s;s++)n+=c[r[1][s]];n+="</div>"}n='<div class="note-toolbar btn-toolbar">'+n+"</div>";var u=a(n).prependTo(i);o(u),l(u,"bottom");var v=a(d).prependTo(i);l(v),a(e).prependTo(i),a(k).prependTo(i),i.insertAfter(b),b.hide()}};var p=this.layoutInfoFromHolder=function(a){var b=a.next();if(b.hasClass("note-editor"))return{editor:b,toolbar:b.find(".note-toolbar"),editable:b.find(".note-editable"),statusbar:b.find(".note-statusbar"),popover:b.find(".note-popover"),handle:b.find(".note-handle"),dialog:b.find(".note-dialog")}};this.removeLayout=function(a){var b=p(a);b&&(a.html(b.editable.html()),b.editor.remove(),a.show())}},u=new t,v=new s;a.fn.extend({summernote:function(b){if(b=a.extend({toolbar:[["style",["style"]],["font",["bold","italic","underline","clear"]],["fontsize",["fontsize"]],["color",["color"]],["para",["ul","ol","paragraph"]],["height",["height"]],["table",["table"]],["insert",["link","picture"]],["help",["help"]]]},b),this.each(function(c,d){var e=a(d);u.createLayout(e,b.height,b.tabIndex,b.toolbar);var f=u.layoutInfoFromHolder(e);v.attach(f,b)}),this.first()&&b.focus){var c=u.layoutInfoFromHolder(this.first());c.editable.focus()}this.length>0&&b.oninit&&b.oninit()},code:function(b){return void 0===b?this.map(function(b,c){var d=u.layoutInfoFromHolder(a(c)),e=!(!d||!d.editable);return e?d.editable.html():a(c).html()}):(this.each(function(c,d){var e=u.layoutInfoFromHolder(a(d));e&&e.editable&&e.editable.html(b)}),void 0)},destroy:function(){this.each(function(b,c){var d=a(c),e=u.layoutInfoFromHolder(d);e&&e.editable&&(v.dettach(e),u.removeLayout(d))})},summernoteInner:function(){return{dom:f,list:e,func:d,Range:j}}})}(jQuery),"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){"use strict";var c,d,e=this.length>>>0,f=!1;for(1<arguments.length&&(d=b,f=!0),c=0;e>c;++c)this.hasOwnProperty(c)&&(f?d=a(d,this[c],c,this):(d=this[c],f=!0));if(!f)throw new TypeError("Reduce of empty array with no initial value");return d});
1
+ !function(a){"use strict";var b={bMac:navigator.appVersion.indexOf("Mac")>-1,bMSIE:navigator.userAgent.indexOf("MSIE")>-1,bFF:navigator.userAgent.indexOf("Firefox")>-1},c=function(){var a=function(a){return function(b){return a===b}},b=function(a,b){return a===b},c=function(){return!1},d=function(a){return function(){return!a.apply(a,arguments)}},e=function(a){return a};return{eq:a,eq2:b,fail:c,not:d,self:e}}(),d=function(){var a=function(a){return a[0]},b=function(a){return a[a.length-1]},d=function(a){return a.slice(0,a.length-1)},e=function(a){return a.slice(1)},f=function(a,b){return b=b||c.self,a.reduce(function(a,c){return a+b(c)},0)},g=function(a){for(var b=[],c=-1,d=a.length;++c<d;)b[c]=a[c];return b},h=function(c,d){if(0===c.length)return[];var f=e(c);return f.reduce(function(a,c){var e=b(a);return d(b(e),c)?e[e.length]=c:a[a.length]=[c],a},[[a(c)]])},i=function(a){for(var b=[],c=0,d=a.length;d>c;c++)a[c]&&b.push(a[c]);return b};return{head:a,last:b,initial:d,tail:e,sum:f,from:g,compact:i,clusterBy:h}}(),e=function(){var b=function(b){return a.Deferred(function(a){var c=new FileReader;c.onload=function(b){a.resolve(b.target.result)},c.onerror=function(){a.reject(this)},c.readAsDataURL(b)}).promise()},c=function(b){return a.Deferred(function(a){function c(){e(),a.resolve(f)}function d(){e(),a.reject(f)}function e(){f.onload=null,f.onerror=null,f.onabort=null}var f=new Image;f.onload=c,f.onerror=d,f.onabort=d,f.src=b}).promise()};return{readFile:b,loadImage:c}}(),f=function(){var b=function(a){return function(b){return b&&b.nodeName===a}},e=function(a){return a&&/^P|^LI|^H[1-7]/.test(a.nodeName)},g=function(a){return a&&/^UL|^OL/.test(a.nodeName)},h=function(b){return b&&a(b).hasClass("note-editable")},i=function(b){return b&&a(b).hasClass("note-control-sizing")},j=function(a,b){for(;a;){if(b(a))return a;a=a.parentNode}return null},k=function(a,b){b=b||c.fail;var d=[];return j(a,function(a){return d.push(a),b(a)}),d},l=function(b,c){for(var d=k(b),e=c;e;e=e.parentNode)if(a.inArray(e,d)>-1)return e;return null},m=function(a,b){var c=[],d=!1,e=!1,f=function(g){if(g){if(g===a&&(d=!0),d&&!e&&c.push(g),g===b)return e=!0,void 0;for(var h=0,i=g.childNodes.length;i>h;h++)f(g.childNodes[h])}};return f(l(a,b)),c},n=function(a,b){b=b||c.fail;for(var d=[];a&&(d.push(a),!b(a));)a=a.previousSibling;return d},o=function(a,b){b=b||c.fail;for(var d=[];a&&(d.push(a),!b(a));)a=a.nextSibling;return d},p=function(a,b){var c=b.nextSibling,d=b.parentNode;return c?d.insertBefore(a,c):d.appendChild(a),a},q=function(b,c){return a.each(c,function(a,c){b.appendChild(c)}),b},r=b("#text"),s=function(a){return r(a)?a.nodeValue.length:a.childNodes.length},t=function(a){for(var b=0;a=a.previousSibling;)b+=1;return b},u=function(b,e){var f=d.initial(k(e,c.eq(b)));return a.map(f,t).reverse()},v=function(a,b){for(var c=a,d=0,e=b.length;e>d;d++)c=c.childNodes[b[d]];return c},w=function(a,b){if(0===b)return a;if(b>=s(a))return a.nextSibling;if(r(a))return a.splitText(b);var c=a.childNodes[b];return a=p(a.cloneNode(!1),a),q(a,o(c))},x=function(a,b,d){var e=k(b,c.eq(a));return 1===e.length?w(b,d):e.reduce(function(a,c){var e=c.cloneNode(!1);return p(e,c),a===b&&(a=w(a,d)),q(e,o(a)),e})},y=function(a,b){if(a&&a.parentNode){if(a.removeNode)return a.removeNode(b);var c=a.parentNode;if(!b){for(var d=[],e=0,f=a.childNodes.length;f>e;e++)d.push(a.childNodes[e]);for(var e=0,f=d.length;f>e;e++)c.insertBefore(d[e],a)}c.removeChild(a)}},z=function(b){return a("<div/>").html(b).text()},A=function(a){return f.isTextarea(a[0])?z(a.val()):a.html()};return{isText:r,isPara:e,isList:g,isEditable:h,isControlSizing:i,isAnchor:b("A"),isDiv:b("DIV"),isSpan:b("SPAN"),isB:b("B"),isU:b("U"),isS:b("S"),isI:b("I"),isImg:b("IMG"),isTextarea:b("TEXTAREA"),ancestor:j,listAncestor:k,listNext:o,listPrev:n,commonAncestor:l,listBetween:m,insertAfter:p,position:t,makeOffsetPath:u,fromOffsetPath:v,split:x,remove:y,html:A}}(),g=function(){var b=!!document.createRange,e=function(a,b){var c,e,g=a.parentElement(),h=document.body.createTextRange(),i=d.from(g.childNodes);for(c=0;c<i.length;c++)if(!f.isText(i[c])){if(h.moveToElementText(i[c]),h.compareEndPoints("StartToStart",a)>=0)break;e=i[c]}if(0!==c&&f.isText(i[c-1])){var j=document.body.createTextRange(),k=null;j.moveToElementText(e||g),j.collapse(!e),k=e?e.nextSibling:g.firstChild;var l=a.duplicate();l.setEndPoint("StartToStart",j);for(var m=l.text.replace(/[\r\n]/g,"").length;m>k.nodeValue.length&&k.nextSibling;)m-=k.nodeValue.length,k=k.nextSibling;{k.nodeValue}b&&k.nextSibling&&f.isText(k.nextSibling)&&m==k.nodeValue.length&&(m-=k.nodeValue.length,k=k.nextSibling),g=k,c=m}return{cont:g,offset:c}},g=function(a){var b=function(a,e){var g,h;if(f.isText(a)){var i=f.listPrev(a,c.not(f.isText)),j=d.last(i).previousSibling;g=j||a.parentNode,e+=d.sum(d.tail(i),f.length),h=!j}else{if(g=a.childNodes[e]||a,f.isText(g))return b(g,e);e=0,h=!1}return{cont:g,collapseToStart:h,offset:e}},e=document.body.createTextRange(),g=b(a.cont,a.offset);return e.moveToElementText(g.cont),e.collapse(g.collapseToStart),e.moveStart("character",g.offset),e},h=function(e,h,i,j){this.sc=e,this.so=h,this.ec=i,this.eo=j;var k=function(){if(b){var a=document.createRange();return a.setStart(e,h),a.setEnd(i,j),a}var c=g({cont:e,offset:h});return c.setEndPoint("EndToEnd",g({cont:i,offset:j})),c};this.select=function(){var a=k();if(b){var c=document.getSelection();c.rangeCount>0&&c.removeAllRanges(),c.addRange(a)}else a.select()},this.listPara=function(){var b=f.listBetween(e,i),g=d.compact(a.map(b,function(a){return f.ancestor(a,f.isPara)}));return a.map(d.clusterBy(g,c.eq2),d.head)};var l=function(a){return function(){var b=f.ancestor(e,a);return b&&b===f.ancestor(i,a)}};this.isOnEditable=l(f.isEditable),this.isOnList=l(f.isList),this.isOnAnchor=l(f.isAnchor),this.isCollapsed=function(){return e===i&&h===j},this.insertNode=function(a){var c=k();b?c.insertNode(a):c.pasteHTML(a.outerHTML)},this.toString=function(){var a=k();return b?a.toString():a.text},this.bookmark=function(a){return{s:{path:f.makeOffsetPath(a,e),offset:h},e:{path:f.makeOffsetPath(a,i),offset:j}}}};return{create:function(a,c,d,f){if(0===arguments.length)if(b){var g=document.getSelection();if(0===g.rangeCount)return null;var i=g.getRangeAt(0);a=i.startContainer,c=i.startOffset,d=i.endContainer,f=i.endOffset}else{var j=document.selection.createRange(),k=j.duplicate();k.collapse(!1);var l=j;l.collapse(!0);var m=e(l,!0),n=e(k,!1);a=m.cont,c=m.offset,d=n.cont,f=n.offset}else 2===arguments.length&&(d=a,f=c);return new h(a,c,d,f)},createFromBookmark:function(a,b){var c=f.fromOffsetPath(a,b.s.path),d=b.s.offset,e=f.fromOffsetPath(a,b.e.path),g=b.e.offset;return new h(c,d,e,g)}}}(),h=function(){this.stylePara=function(b,c){var d=b.listPara();a.each(d,function(b,d){a.each(c,function(a,b){d.style[a]=b})})},this.current=function(b,c){var d=a(f.isText(b.sc)?b.sc.parentNode:b.sc),e=d.css(["font-size","text-align","list-style-type","line-height"])||{};if(e["font-size"]=parseInt(e["font-size"]),e["font-bold"]=document.queryCommandState("bold")?"bold":"normal",e["font-italic"]=document.queryCommandState("italic")?"italic":"normal",e["font-underline"]=document.queryCommandState("underline")?"underline":"normal",b.isOnList()){var g=["circle","disc","disc-leading-zero","square"],h=a.inArray(e["list-style-type"],g)>-1;e["list-style"]=h?"unordered":"ordered"}else e["list-style"]="none";var i=f.ancestor(b.sc,f.isPara);if(i&&i.style["line-height"])e["line-height"]=i.style.lineHeight;else{var j=parseInt(e["line-height"])/parseInt(e["font-size"]);e["line-height"]=j.toFixed(1)}return e.image=f.isImg(c)&&c,e.anchor=b.isOnAnchor()&&f.ancestor(b.sc,f.isAnchor),e.aAncestor=f.listAncestor(b.sc,f.isEditable),e}},i=function(){var a=[],b=[],c=function(a){var b=a[0],c=g.create();return{contents:a.html(),bookmark:c.bookmark(b),scrollTop:a.scrollTop()}},d=function(a,b){a.html(b.contents).scrollTop(b.scrollTop),g.createFromBookmark(a[0],b.bookmark).select()};this.undo=function(e){var f=c(e);0!==a.length&&(d(e,a.pop()),b.push(f))},this.redo=function(e){var f=c(e);0!==b.length&&(d(e,b.pop()),a.push(f))},this.recordUndo=function(d){b=[],a.push(c(d))}},j=function(){this.saveRange=function(a){a.data("range",g.create())},this.restoreRange=function(a){var b=a.data("range");b&&b.select()};var c=new h;this.currentStyle=function(a){var b=g.create();return b.isOnEditable()&&c.current(b,a)},this.tab=function(b){d(b);var c=g.create(),e=new Array(b.data("tabsize")+1).join("&nbsp;");c.insertNode(a('<span id="noteTab">'+e+"</span>")[0]);var h=a("#noteTab").removeAttr("id");c=g.create(h[0],1),c.select(),f.remove(h[0])},this.undo=function(a){a.data("NoteHistory").undo(a)},this.redo=function(a){a.data("NoteHistory").redo(a)};for(var d=this.recordUndo=function(a){a.data("NoteHistory").recordUndo(a)},i=["bold","italic","underline","strikethrough","justifyLeft","justifyCenter","justifyRight","justifyFull","insertOrderedList","insertUnorderedList","indent","outdent","formatBlock","removeFormat","backColor","foreColor","insertHorizontalRule"],j=0,k=i.length;k>j;j++)this[i[j]]=function(a){return function(b,c){d(b),document.execCommand(a,!1,c)}}(i[j]);this.insertImage=function(b,c){e.loadImage(c).done(function(e){d(b);var f=a("<img>").attr("src",c);f.css("width",Math.min(b.width(),e.width)),g.create().insertNode(f[0])}).fail(function(){var a=b.data("callbacks");a.onImageUploadError&&a.onImageUploadError()})},this.formatBlock=function(a,c){d(a),c=b.bMSIE?"<"+c+">":c,document.execCommand("FormatBlock",!1,c)},this.fontSize=function(a,c){d(a),document.execCommand("fontSize",!1,3),b.bFF?a.find("font[size=3]").removeAttr("size").css("font-size",c+"px"):a.find("span").filter(function(){return"medium"==this.style.fontSize}).css("font-size",c+"px")},this.lineHeight=function(a,b){d(a),c.stylePara(g.create(),{lineHeight:b})},this.unlink=function(a){var b=g.create();if(b.isOnAnchor()){d(a);var c=f.ancestor(b.sc,f.isAnchor);b=g.create(c,0,c,1),b.select(),document.execCommand("unlink")}},this.setLinkDialog=function(c,e){var h=g.create();if(h.isOnAnchor()){var i=f.ancestor(h.sc,f.isAnchor);h=g.create(i,0,i,1)}e({range:h,text:h.toString(),url:h.isOnAnchor()?f.ancestor(h.sc,f.isAnchor).href:""},function(e){h.select(),d(c);var f=-1!==e.toLowerCase().indexOf("://"),i=f?e:"http://"+e;if(b.bMSIE&&h.isCollapsed()){h.insertNode(a('<A id="linkAnchor">'+e+"</A>")[0]);var j=a("#linkAnchor").removeAttr("id").attr("href",i);h=g.create(j[0],0,j[0],1),h.select()}else document.execCommand("createlink",!1,i)})},this.color=function(a,b){var c=JSON.parse(b),e=c.foreColor,f=c.backColor;d(a),e&&document.execCommand("foreColor",!1,e),f&&document.execCommand("backColor",!1,f)},this.insertTable=function(c,e){d(c);for(var f,h=e.split("x"),i=h[0],j=h[1],k=[],l=b.bMSIE?"&nbsp;":"<br/>",m=0;i>m;m++)k.push("<td>"+l+"</td>");f=k.join("");for(var n,o=[],p=0;j>p;p++)o.push("<tr>"+f+"</tr>");n=o.join("");var q='<table class="table table-bordered">'+n+"</table>";g.create().insertNode(a(q)[0])},this.floatMe=function(a,b,c){d(a),c.style.cssFloat=b},this.resize=function(a,b,c){d(a),c.style.width=a.width()*b+"px",c.style.height=""},this.resizeTo=function(a,b){var c=a.y/a.x,d=b.data("ratio");b.css({width:d>c?a.x:a.y/d,height:d>c?a.x*d:a.y})}},k=function(){this.update=function(b,c){var d=function(b,c){b.find(".dropdown-menu li a").each(function(){var b=a(this).attr("data-value")==c;this.className=b?"checked":""})},e=b.find(".note-fontsize");e.find(".note-current-fontsize").html(c["font-size"]),d(e,parseFloat(c["font-size"]));var f=b.find(".note-height");d(f,parseFloat(c["line-height"]));var g=function(a,c){var d=b.find(a);d[c()?"addClass":"removeClass"]("active")};g('button[data-event="bold"]',function(){return"bold"===c["font-bold"]}),g('button[data-event="italic"]',function(){return"italic"===c["font-italic"]}),g('button[data-event="underline"]',function(){return"underline"===c["font-underline"]}),g('button[data-event="justifyLeft"]',function(){return"left"===c["text-align"]||"start"===c["text-align"]}),g('button[data-event="justifyCenter"]',function(){return"center"===c["text-align"]}),g('button[data-event="justifyRight"]',function(){return"right"===c["text-align"]}),g('button[data-event="justifyFull"]',function(){return"justify"===c["text-align"]}),g('button[data-event="insertUnorderedList"]',function(){return"unordered"===c["list-style"]}),g('button[data-event="insertOrderedList"]',function(){return"ordered"===c["list-style"]})},this.updateRecentColor=function(b,c,d){var e=a(b).closest(".note-color"),f=e.find(".note-recent-color"),g=JSON.parse(f.attr("data-value"));g[c]=d,f.attr("data-value",JSON.stringify(g));var h="backColor"===c?"background-color":"color";f.find("i").css(h,d)},this.updateFullscreen=function(a,b){var c=a.find('button[data-event="fullscreen"]');c[b?"addClass":"removeClass"]("active")},this.updateCodeview=function(a,b){var c=a.find('button[data-event="codeview"]');c[b?"addClass":"removeClass"]("active")},this.enable=function(a){a.find("button").not('button[data-event="codeview"]').removeClass("disabled")},this.disable=function(a){a.find("button").not('button[data-event="codeview"]').addClass("disabled")}},l=function(){var b=function(b,c){var d=a(c),e=d.position(),f=d.height();b.css({display:"block",left:e.left,top:e.top+f})};this.update=function(a,c){var d=a.find(".note-link-popover"),e=a.find(".note-image-popover");if(c.anchor){var f=d.find("a");f.attr("href",c.anchor.href).html(c.anchor.href),b(d,c.anchor)}else d.hide();c.image?b(e,c.image):e.hide()},this.hide=function(a){a.children().hide()}},m=function(){this.update=function(b,c){var d=b.find(".note-control-selection");if(c.image){var e=a(c.image),f=e.position(),g={w:e.width(),h:e.height()};d.css({display:"block",left:f.left,top:f.top,width:g.w,height:g.h}).data("target",c.image);var h=g.w+"x"+g.h;d.find(".note-control-selection-info").text(h)}else d.hide()},this.hide=function(a){a.children().hide()}},n=function(){this.showImageDialog=function(b,c,d,e){var f=b.find(".note-image-dialog"),g=b.find(".note-dropzone"),h=b.find(".note-image-input"),i=b.find(".note-image-url"),j=b.find(".note-image-btn");f.on("shown.bs.modal",function(){g.on("dragenter dragover dragleave",!1),g.on("drop",function(a){c(a),f.modal("hide")}),h.on("change",function(){d(this.files),a(this).val(""),f.modal("hide")}),i.val("").keyup(function(){i.val()?j.removeClass("disabled").attr("disabled",!1):j.addClass("disabled").attr("disabled",!0)}).trigger("focus"),j.click(function(a){f.modal("hide"),e(i.val()),a.preventDefault()})}).on("hidden.bs.modal",function(){g.off("dragenter dragover dragleave drop"),h.off("change"),f.off("shown.bs.modal hidden.bs.modal"),i.off("keyup"),j.off("click")}).modal("show")},this.showLinkDialog=function(a,b,c){var d=a.find(".note-link-dialog"),e=d.find(".note-link-text"),f=d.find(".note-link-url"),g=d.find(".note-link-btn");d.on("shown.bs.modal",function(){e.html(b.text),f.val(b.url).keyup(function(){f.val()?g.removeClass("disabled").attr("disabled",!1):g.addClass("disabled").attr("disabled",!0),b.text||e.html(f.val())}).trigger("focus"),g.click(function(a){d.modal("hide"),c(f.val()),a.preventDefault()})}).on("hidden.bs.modal",function(){f.off("keyup"),g.off("click"),d.off("shown.bs.modal hidden.bs.modal")}).modal("show")},this.showHelpDialog=function(a){a.find(".note-help-dialog").modal("show")}},o=function(){var c=new j,d=new k,g=new l,h=new m,i=new n,o={BACKSPACE:8,TAB:9,ENTER:13,SPACE:32,NUM0:48,NUM1:49,NUM6:54,NUM7:55,NUM8:56,B:66,E:69,I:73,J:74,K:75,L:76,R:82,S:83,U:85,Y:89,Z:90,SLASH:191,LEFTBRACKET:219,BACKSLACH:220,RIGHTBRACKET:221},p=function(b){var c=a(b).closest(".note-editor");return{editor:function(){return c},toolbar:function(){return c.find(".note-toolbar")},editable:function(){return c.find(".note-editable")},codable:function(){return c.find(".note-codable")},statusbar:function(){return c.find(".note-statusbar")},popover:function(){return c.find(".note-popover")},handle:function(){return c.find(".note-handle")},dialog:function(){return c.find(".note-dialog")}}},q=function(a){var d=b.bMac?a.metaKey:a.ctrlKey,e=a.shiftKey,f=a.keyCode,g=d||e||f===o.TAB,h=g?p(a.target):null;if(f===o.TAB&&h.editable().data("tabsize"))c.tab(h.editable());else if(d&&(e&&f===o.Z||f===o.Y))c.redo(h.editable());else if(d&&f===o.Z)c.undo(h.editable());else if(d&&f===o.B)c.bold(h.editable());else if(d&&f===o.I)c.italic(h.editable());else if(d&&f===o.U)c.underline(h.editable());else if(d&&e&&f===o.S)c.strikethrough(h.editable());else if(d&&f===o.BACKSLACH)c.removeFormat(h.editable());else if(d&&f===o.K)h.editable(),c.setLinkDialog(h.editable(),function(a,b){i.showLinkDialog(h.dialog(),a,b)});else if(d&&f===o.SLASH)i.showHelpDialog(h.dialog());else if(d&&e&&f===o.L)c.justifyLeft(h.editable());else if(d&&e&&f===o.E)c.justifyCenter(h.editable());else if(d&&e&&f===o.R)c.justifyRight(h.editable());else if(d&&e&&f===o.J)c.justifyFull(h.editable());else if(d&&e&&f===o.NUM7)c.insertUnorderedList(h.editable());else if(d&&e&&f===o.NUM8)c.insertOrderedList(h.editable());else if(d&&f===o.LEFTBRACKET)c.outdent(h.editable());else if(d&&f===o.RIGHTBRACKET)c.indent(h.editable());else if(d&&f===o.NUM0)c.formatBlock(h.editable(),"P");else if(d&&o.NUM1<=f&&f<=o.NUM6){var j="H"+String.fromCharCode(f);c.formatBlock(h.editable(),j)}else{if(!d||f!==o.ENTER)return(f===o.BACKSPACE||f===o.ENTER||f===o.SPACE)&&c.recordUndo(p(a.target).editable()),void 0;c.insertHorizontalRule(h.editable())}a.preventDefault()},r=function(b,d){var f=b.data("callbacks");c.restoreRange(b),f.onImageUpload?f.onImageUpload(d,c,b):a.each(d,function(a,d){e.readFile(d).done(function(a){c.insertImage(b,a)}).fail(function(){f.onImageUploadError&&f.onImageUploadError()})})},s=function(a){var b=a.originalEvent.dataTransfer;if(b&&b.files){var c=p(a.currentTarget||a.target);r(c.editable(),b.files)}a.stopPropagation(),a.preventDefault()},t=function(a){f.isImg(a.target)&&a.preventDefault()},u=function(a){var b=p(a.currentTarget||a.target),e=c.currentStyle(a.target);e&&(d.update(b.toolbar(),e),g.update(b.popover(),e),h.update(b.handle(),e))},v=function(a){var b=p(a.currentTarget||a.target);g.hide(b.popover()),h.hide(b.handle())},w=function(b){if(f.isControlSizing(b.target)){var d,e=p(b.target),i=e.handle(),j=e.popover(),k=e.editable(),l=e.editor(),m=i.find(".note-control-selection").data("target"),n=a(m),o=n.offset(),q=a(document).scrollTop();l.on("mousemove",function(a){d={x:a.clientX-o.left,y:a.clientY-(o.top-q)},c.resizeTo(d,n),h.update(i,{image:m}),g.update(j,{image:m})}).on("mouseup",function(){l.off("mousemove").off("mouseup")}),n.data("ratio")||n.data("ratio",n.height()/n.width()),c.recordUndo(k),b.stopPropagation(),b.preventDefault()}},x=function(b){var c=a(b.target).closest("[data-event]");c.length>0&&b.preventDefault()},y=function(b){var e=a(b.target).closest("[data-event]");if(e.length>0){var f,g=e.attr("data-event"),h=e.attr("data-value"),j=p(b.target),k=j.dialog(),l=j.editable(),m=j.codable();if(-1!==a.inArray(g,["resize","floatMe"])){var n=j.handle(),o=n.find(".note-control-selection");f=o.data("target")}if(c[g]&&(l.trigger("focus"),c[g](l,h,f)),-1!==a.inArray(g,["backColor","foreColor"]))d.updateRecentColor(e[0],g,h);else if("showLinkDialog"===g)l.focus(),c.setLinkDialog(l,function(a,b){i.showLinkDialog(k,a,b)});else if("showImageDialog"===g)l.focus(),i.showImageDialog(k,s,function(a){r(l,a)},function(a){c.restoreRange(l),c.insertImage(l,a)});else if("showHelpDialog"===g)i.showHelpDialog(k);else if("fullscreen"===g){var q=j.editor();q.toggleClass("fullscreen");var t=j.toolbar(),v=function(){var b=a(window).height()-t.outerHeight();l.css("height",b)},w=q.hasClass("fullscreen");w?(l.data("orgHeight",l.css("height")),a(window).resize(v).trigger("resize")):(l.css("height",l.data("orgHeight")),a(window).off("resize")),d.updateFullscreen(t,w)}else if("codeview"===g){var q=j.editor(),t=j.toolbar();q.toggleClass("codeview");var x=q.hasClass("codeview");x?(m.val(l.html()),m.height(l.height()),d.disable(t),m.focus()):(l.html(m.val()),l.height(m.height()),d.enable(t),l.focus()),d.updateCodeview(j.toolbar(),x)}u(b)}},z=24,A=function(b){var c=a(document),d=p(b.target),e=d.editable(),f=(d.codable(),e.offset().top-c.scrollTop()),g=function(a){e.height(a.clientY-(f+z))},h=function(){c.unbind("mousemove",g).unbind("mouseup",h)};c.mousemove(g).mouseup(h),b.stopPropagation(),b.preventDefault()},B=18,C=function(b){var c,d=a(b.target.parentNode),e=d.next(),f=d.find(".note-dimension-picker-mousecatcher"),g=d.find(".note-dimension-picker-highlighted"),h=d.find(".note-dimension-picker-unhighlighted");if(void 0===b.offsetX){var i=a(b.target).offset();c={x:b.pageX-i.left,y:b.pageY-i.top}}else c={x:b.offsetX,y:b.offsetY};var j={c:Math.ceil(c.x/B)||1,r:Math.ceil(c.y/B)||1};g.css({width:j.c+"em",height:j.r+"em"}),f.attr("data-value",j.c+"x"+j.r),3<j.c&&j.c<10&&h.css({width:j.c+1+"em"}),3<j.r&&j.r<10&&h.css({height:j.r+1+"em"}),e.html(j.c+" x "+j.r)};this.attach=function(a,b){a.editable.on("keydown",q),a.editable.on("mousedown",t),a.editable.on("keyup mouseup",u),a.editable.on("scroll",v),a.editable.on("dragenter dragover dragleave",!1),a.editable.on("drop",s),a.handle.on("mousedown",w),a.toolbar.on("click",y),a.popover.on("click",y),a.toolbar.on("mousedown",x),a.popover.on("mousedown",x),a.statusbar.on("mousedown",A);var d=a.toolbar,e=d.find(".note-dimension-picker-mousecatcher");e.on("mousemove",C),a.editable.on("blur",function(){c.saveRange(a.editable)}),b.onenter&&a.editable.keypress(function(a){a.keyCode===o.ENTER&&b.onenter(a)}),b.onfocus&&a.editable.focus(b.onfocus),b.onblur&&a.editable.blur(b.onblur),b.onkeyup&&a.editable.keyup(b.onkeyup),b.onkeydown&&a.editable.keydown(b.onkeydown),a.editable.data("callbacks",{onChange:b.onChange,onAutoSave:b.onAutoSave,onPasteBefore:b.onPasteBefore,onPasteAfter:b.onPasteAfter,onImageUpload:b.onImageUpload,onImageUploadError:b.onImageUpload,onFileUpload:b.onFileUpload,onFileUploadError:b.onFileUpload})},this.dettach=function(a){a.editable.off(),a.toolbar.off(),a.handle.off(),a.popover.off()}},p=function(){var c={picture:'<button type="button" class="btn btn-default btn-sm btn-small" title="Picture" data-event="showImageDialog" tabindex="-1"><i class="fa fa-picture-o icon-picture"></i></button>',link:'<button type="button" class="btn btn-default btn-sm btn-small" title="Link" data-event="showLinkDialog" data-shortcut="Ctrl+K" data-mac-shortcut="⌘+K" tabindex="-1"><i class="fa fa-link icon-link"></i></button>',table:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Table" data-toggle="dropdown" tabindex="-1"><i class="fa fa-table icon-table"></i> <span class="caret"></span></button><ul class="dropdown-menu"><div class="note-dimension-picker"><div class="note-dimension-picker-mousecatcher" data-event="insertTable" data-value="1x1"></div><div class="note-dimension-picker-highlighted"></div><div class="note-dimension-picker-unhighlighted"></div></div><div class="note-dimension-display"> 1 x 1 </div></ul>',style:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Style" data-toggle="dropdown" tabindex="-1"><i class="fa fa-magic icon-magic"></i> <span class="caret"></span></button><ul class="dropdown-menu"><li><a data-event="formatBlock" data-value="p">Normal</a></li><li><a data-event="formatBlock" data-value="blockquote"><blockquote>Quote</blockquote></a></li><li><a data-event="formatBlock" data-value="pre">Code</a></li><li><a data-event="formatBlock" data-value="h1"><h1>Header 1</h1></a></li><li><a data-event="formatBlock" data-value="h2"><h2>Header 2</h2></a></li><li><a data-event="formatBlock" data-value="h3"><h3>Header 3</h3></a></li><li><a data-event="formatBlock" data-value="h4"><h4>Header 4</h4></a></li><li><a data-event="formatBlock" data-value="h5"><h5>Header 5</h5></a></li><li><a data-event="formatBlock" data-value="h6"><h6>Header 6</h6></a></li></ul>',fontsize:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Font Size" tabindex="-1"><span class="note-current-fontsize">11</span> <b class="caret"></b></button><ul class="dropdown-menu"><li><a data-event="fontSize" data-value="8"><i class="fa fa-check icon-ok"></i> 8</a></li><li><a data-event="fontSize" data-value="9"><i class="fa fa-check icon-ok"></i> 9</a></li><li><a data-event="fontSize" data-value="10"><i class="fa fa-check icon-ok"></i> 10</a></li><li><a data-event="fontSize" data-value="11"><i class="fa fa-check icon-ok"></i> 11</a></li><li><a data-event="fontSize" data-value="12"><i class="fa fa-check icon-ok"></i> 12</a></li><li><a data-event="fontSize" data-value="14"><i class="fa fa-check icon-ok"></i> 14</a></li><li><a data-event="fontSize" data-value="18"><i class="fa fa-check icon-ok"></i> 18</a></li><li><a data-event="fontSize" data-value="24"><i class="fa fa-check icon-ok"></i> 24</a></li><li><a data-event="fontSize" data-value="36"><i class="fa fa-check icon-ok"></i> 36</a></li></ul>',color:'<button type="button" class="btn btn-default btn-sm btn-small note-recent-color" title="Recent Color" data-event="color" data-value=\'{"backColor":"yellow"}\' tabindex="-1"><i class="fa fa-font icon-font" style="color:black;background-color:yellow;"></i></button><button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="More Color" data-toggle="dropdown" tabindex="-1"><span class="caret"></span></button><ul class="dropdown-menu"><li><div class="btn-group"><div class="note-palette-title">BackColor</div><div class="note-color-reset" data-event="backColor" data-value="inherit" title="Transparent">Set transparent</div><div class="note-color-palette" data-target-event="backColor"></div></div><div class="btn-group"><div class="note-palette-title">FontColor</div><div class="note-color-reset" data-event="foreColor" data-value="inherit" title="Reset">Reset to default</div><div class="note-color-palette" data-target-event="foreColor"></div></div></li></ul>',bold:'<button type="button" class="btn btn-default btn-sm btn-small" title="Bold" data-shortcut="Ctrl+B" data-mac-shortcut="⌘+B" data-event="bold" tabindex="-1"><i class="fa fa-bold icon-bold"></i></button>',italic:'<button type="button" class="btn btn-default btn-sm btn-small" title="Italic" data-shortcut="Ctrl+I" data-mac-shortcut="⌘+I" data-event="italic" tabindex="-1"><i class="fa fa-italic icon-italic"></i></button>',underline:'<button type="button" class="btn btn-default btn-sm btn-small" title="Underline" data-shortcut="Ctrl+U" data-mac-shortcut="⌘+U" data-event="underline" tabindex="-1"><i class="fa fa-underline icon-underline"></i></button>',clear:'<button type="button" class="btn btn-default btn-sm btn-small" title="Remove Font Style" data-shortcut="Ctrl+\\" data-mac-shortcut="⌘+\\" data-event="removeFormat" tabindex="-1"><i class="fa fa-eraser icon-eraser"></i></button>',ul:'<button type="button" class="btn btn-default btn-sm btn-small" title="Unordered list" data-shortcut="Ctrl+Shift+8" data-mac-shortcut="⌘+⇧+7" data-event="insertUnorderedList" tabindex="-1"><i class="fa fa-list-ul icon-list-ul"></i></button>',ol:'<button type="button" class="btn btn-default btn-sm btn-small" title="Ordered list" data-shortcut="Ctrl+Shift+7" data-mac-shortcut="⌘+⇧+8" data-event="insertOrderedList" tabindex="-1"><i class="fa fa-list-ol icon-list-ol"></i></button>',paragraph:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" title="Paragraph" data-toggle="dropdown" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i> <span class="caret"></span></button><ul class="dropdown-menu"><li><div class="note-align btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Align left" data-shortcut="Ctrl+Shift+L" data-mac-shortcut="⌘+⇧+L" data-event="justifyLeft" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Align center" data-shortcut="Ctrl+Shift+E" data-mac-shortcut="⌘+⇧+E" data-event="justifyCenter" tabindex="-1"><i class="fa fa-align-center icon-align-center"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Align right" data-shortcut="Ctrl+Shift+R" data-mac-shortcut="⌘+⇧+R" data-event="justifyRight" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Justify full" data-shortcut="Ctrl+Shift+J" data-mac-shortcut="⌘+⇧+J" data-event="justifyFull" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button></div></li><li><div class="note-list btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Outdent" data-shortcut="Ctrl+[" data-mac-shortcut="⌘+[" data-event="outdent" tabindex="-1"><i class="fa fa-outdent icon-indent-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Indent" data-shortcut="Ctrl+]" data-mac-shortcut="⌘+]" data-event="indent" tabindex="-1"><i class="fa fa-indent icon-indent-right"></i></button></li></ul>',height:'<button type="button" class="btn btn-default btn-sm btn-small dropdown-toggle" data-toggle="dropdown" title="Line Height" tabindex="-1"><i class="fa fa-text-height icon-text-height"></i>&nbsp; <b class="caret"></b></button><ul class="dropdown-menu"><li><a data-event="lineHeight" data-value="1.0"><i class="fa fa-check icon-ok"></i> 1.0</a></li><li><a data-event="lineHeight" data-value="1.2"><i class="fa fa-check icon-ok"></i> 1.2</a></li><li><a data-event="lineHeight" data-value="1.4"><i class="fa fa-check icon-ok"></i> 1.4</a></li><li><a data-event="lineHeight" data-value="1.5"><i class="fa fa-check icon-ok"></i> 1.5</a></li><li><a data-event="lineHeight" data-value="1.6"><i class="fa fa-check icon-ok"></i> 1.6</a></li><li><a data-event="lineHeight" data-value="1.8"><i class="fa fa-check icon-ok"></i> 1.8</a></li><li><a data-event="lineHeight" data-value="2.0"><i class="fa fa-check icon-ok"></i> 2.0</a></li><li><a data-event="lineHeight" data-value="3.0"><i class="fa fa-check icon-ok"></i> 3.0</a></li></ul>',help:'<button type="button" class="btn btn-default btn-sm btn-small" title="Help" data-shortcut="Ctrl+/" data-mac-shortcut="⌘+/" data-event="showHelpDialog" tabindex="-1"><i class="fa fa-question icon-question"></i></button>',fullscreen:'<button type="button" class="btn btn-default btn-sm btn-small" title="Full Screen" data-event="fullscreen" tabindex="-1"><i class="fa fa-arrows-alt icon-fullscreen"></i></button>',codeview:'<button type="button" class="btn btn-default btn-sm btn-small" title="Code View" data-event="codeview" tabindex="-1"><i class="fa fa-code icon-code"></i></button>'},d='<div class="note-popover"><div class="note-link-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-link-content"><a href="http://www.google.com" target="_blank">www.google.com</a>&nbsp;&nbsp;<div class="note-insert btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Edit" data-event="showLinkDialog" tabindex="-1"><i class="fa fa-edit icon-edit"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Unlink" data-event="unlink" tabindex="-1"><i class="fa fa-unlink icon-unlink"></i></button></div></div></div><div class="note-image-popover popover bottom in" style="display: none;"><div class="arrow"></div><div class="popover-content note-image-content"><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Full" data-event="resize" data-value="1" tabindex="-1"><span class="note-fontsize-10">100%</span> </button><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Half" data-event="resize" data-value="0.5" tabindex="-1"><span class="note-fontsize-10">50%</span> </button><button type="button" class="btn btn-default btn-sm btn-small" title="Resize Quarter" data-event="resize" data-value="0.25" tabindex="-1"><span class="note-fontsize-10">25%</span> </button></div><div class="btn-group"><button type="button" class="btn btn-default btn-sm btn-small" title="Float Left" data-event="floatMe" data-value="left" tabindex="-1"><i class="fa fa-align-left icon-align-left"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Float Right" data-event="floatMe" data-value="right" tabindex="-1"><i class="fa fa-align-right icon-align-right"></i></button><button type="button" class="btn btn-default btn-sm btn-small" title="Float None" data-event="floatMe" data-value="none" tabindex="-1"><i class="fa fa-align-justify icon-align-justify"></i></button></div></div></div></div>',e='<div class="note-handle"><div class="note-control-selection"><div class="note-control-selection-bg"></div><div class="note-control-holder note-control-nw"></div><div class="note-control-holder note-control-ne"></div><div class="note-control-holder note-control-sw"></div><div class="note-control-sizing note-control-se"></div><div class="note-control-selection-info"></div></div></div>',g='<table class="note-shortcut"><thead><tr><th></th><th>Text formatting</th></tr></thead><tbody><tr><td>⌘ + B</td><td>Toggle Bold</td></tr><tr><td>⌘ + I</td><td>Toggle Italic</td></tr><tr><td>⌘ + U</td><td>Toggle Underline</td></tr><tr><td>⌘ + ⇧ + S</td><td>Toggle Strike</td></tr><tr><td>⌘ + \\</td><td>Remove Font Style</td></tr></tr></tbody></table>',h='<table class="note-shortcut"><thead><tr><th></th><th>Action</th></tr></thead><tbody><tr><td>⌘ + Z</td><td>Undo</td></tr><tr><td>⌘ + ⇧ + Z</td><td>Redo</td></tr><tr><td>⌘ + ]</td><td>Indent</td></tr><tr><td>⌘ + [</td><td>Outdent</td></tr><tr><td>⌘ + K</td><td>Insert Link</td></tr><tr><td>⌘ + ENTER</td><td>Insert Horizontal Rule</td></tr></tbody></table>',j='<table class="note-shortcut"><thead><tr><th></th><th>Paragraph formatting</th></tr></thead><tbody><tr><td>⌘ + ⇧ + L</td><td>Align Left</td></tr><tr><td>⌘ + ⇧ + E</td><td>Align Center</td></tr><tr><td>⌘ + ⇧ + R</td><td>Align Right</td></tr><tr><td>⌘ + ⇧ + J</td><td>Justify Full</td></tr><tr><td>⌘ + ⇧ + NUM7</td><td>Ordered List</td></tr><tr><td>⌘ + ⇧ + NUM8</td><td>Unordered List</td></tr></tbody></table>',k='<table class="note-shortcut"><thead><tr><th></th><th>Document Style</th></tr></thead><tbody><tr><td>⌘ + NUM0</td><td>Normal Text</td></tr><tr><td>⌘ + NUM1</td><td>Heading 1</td></tr><tr><td>⌘ + NUM2</td><td>Heading 2</td></tr><tr><td>⌘ + NUM3</td><td>Heading 3</td></tr><tr><td>⌘ + NUM4</td><td>Heading 4</td></tr><tr><td>⌘ + NUM5</td><td>Heading 5</td></tr><tr><td>⌘ + NUM6</td><td>Heading 6</td></tr></tbody></table>',l='<table class="note-shortcut-layout"><tbody><tr><td>'+h+"</td><td>"+g+"</td></tr><tr><td>"+k+"</td><td>"+j+"</td></tr></tbody></table>";
2
+ b.bMac||(l=l.replace(/⌘/g,"Ctrl").replace(/⇧/g,"Shift"));{var m='<div class="note-dialog"><div class="note-image-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">×</button><h4>Insert Image</h4></div><div class="modal-body"><div class="row-fluid"><div class="note-dropzone span12">Drag an image here</div><h5>Select from files</h5><input class="note-image-input" type="file" name="files" accept="image/*" capture="camera" /><h5>Image URL</h5><input class="note-image-url form-control span12" type="text" /></div></div><div class="modal-footer"><button href="#" class="btn btn-primary note-image-btn disabled" disabled="disabled">Insert</button></div></div></div></div><div class="note-link-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><button type="button" class="close" aria-hidden="true" tabindex="-1">×</button><h4>Edit Link</h4></div><div class="modal-body"><div class="row-fluid"><div class="form-group"><label>Text to display</label><span class="note-link-text form-control input-xlarge uneditable-input" /></div><div class="form-group"><label>To what URL should this link go?</label><input class="note-link-url form-control span12" type="text" /></div></div></div><div class="modal-footer"><button href="#" class="btn btn-primary note-link-btn disabled" disabled="disabled">Link</button></div></div></div></div><div class="note-help-dialog modal" aria-hidden="false"><div class="modal-dialog"><div class="modal-content"><div class="modal-body"><div class="modal-background"><a class="modal-close pull-right" aria-hidden="true" tabindex="-1">Close</a><div class="title">Keyboard shortcuts</div>'+l+'<p class="text-center"><a href="//hackerwins.github.io/summernote/" target="_blank">Summernote v0.4</a> · <a href="//github.com/HackerWins/summernote" target="_blank">Project</a> · <a href="//github.com/HackerWins/summernote/issues" target="_blank">Issues</a></p></div></div></div></div></div>',n=function(c,d){c.find("button").each(function(c,d){var e=a(d),f=e.attr(b.bMac?"data-mac-shortcut":"data-shortcut");f&&e.attr("title",function(a,b){return b+" ("+f+")"})}).tooltip({container:"body",placement:d||"top"})},o=[["#000000","#424242","#636363","#9C9C94","#CEC6CE","#EFEFEF","#F7F7F7","#FFFFFF"],["#FF0000","#FF9C00","#FFFF00","#00FF00","#00FFFF","#0000FF","#9C00FF","#FF00FF"],["#F7C6CE","#FFE7CE","#FFEFC6","#D6EFD6","#CEDEE7","#CEE7F7","#D6D6E7","#E7D6DE"],["#E79C9C","#FFC69C","#FFE79C","#B5D6A5","#A5C6CE","#9CC6EF","#B5A5D6","#D6A5BD"],["#E76363","#F7AD6B","#FFD663","#94BD7B","#73A5AD","#6BADDE","#8C7BC6","#C67BA5"],["#CE0000","#E79439","#EFC631","#6BA54A","#4A7B8C","#3984C6","#634AA5","#A54A7B"],["#9C0000","#B56308","#BD9400","#397B21","#104A5A","#085294","#311873","#731842"],["#630000","#7B3900","#846300","#295218","#083139","#003163","#21104A","#4A1031"]],p=function(b){b.find(".note-color-palette").each(function(){for(var b=a(this),c=b.attr("data-target-event"),d="",e=0,f=o.length;f>e;e++){for(var g=o[e],h="<div>",i=0,j=g.length;j>i;i++){var k=g[i],l=['<button type="button" class="note-color-btn" style="background-color:',k,';" data-event="',c,'" data-value="',k,'" title="',k,'" data-toggle="button" tabindex="-1"></button>'].join("");h+=l}h+="</div>",d+=h}b.html(d)})},q=(this.createLayout=function(b,g,h,j){if(!b.next().hasClass("note-editor")){var k=a('<div class="note-editor"></div>');if(g>0){a('<div class="note-statusbar"><div class="note-resizebar"><div class="note-icon-bar"></div><div class="note-icon-bar"></div><div class="note-icon-bar"></div></div></div>').prependTo(k)}var l=a('<div class="note-editable" contentEditable="true"></div>').prependTo(k);g&&l.height(g),h&&l.data("tabsize",h),l.html(f.html(b)),l.data("NoteHistory",new i);{a('<textarea class="note-codable"></textarea>').prependTo(k)}setTimeout(function(){document.execCommand("styleWithCSS",0,!0)});for(var o="",q=0,r=j.length;r>q;q++){var s=j[q];o+='<div class="note-'+s[0]+' btn-group">';for(var t=0,u=s[1].length;u>t;t++)o+=c[s[1][t]];o+="</div>"}o='<div class="note-toolbar btn-toolbar">'+o+"</div>";var v=a(o).prependTo(k);p(v),n(v,"bottom");var w=a(d).prependTo(k);n(w),a(e).prependTo(k);var x=a(m).prependTo(k);x.find("button.close, a.modal-close").click(function(){a(this).closest(".modal").modal("hide")}),k.insertAfter(b),b.hide()}},this.layoutInfoFromHolder=function(a){var b=a.next();if(b.hasClass("note-editor"))return{editor:b,toolbar:b.find(".note-toolbar"),editable:b.find(".note-editable"),codable:b.find(".note-codable"),statusbar:b.find(".note-statusbar"),popover:b.find(".note-popover"),handle:b.find(".note-handle"),dialog:b.find(".note-dialog")}});this.removeLayout=function(a){var b=q(a);b&&(a.html(b.editable.html()),b.editor.remove(),a.show())}}},q=new p,r=new o;a.fn.extend({summernote:function(b){if(b=a.extend({toolbar:[["style",["style"]],["font",["bold","italic","underline","clear"]],["fontsize",["fontsize"]],["color",["color"]],["para",["ul","ol","paragraph"]],["height",["height"]],["table",["table"]],["insert",["link","picture"]],["view",["fullscreen","codeview"]],["help",["help"]]]},b),this.each(function(c,d){var e=a(d);q.createLayout(e,b.height,b.tabsize,b.toolbar);var f=q.layoutInfoFromHolder(e);r.attach(f,b)}),this.first()&&b.focus){var c=q.layoutInfoFromHolder(this.first());c.editable.focus()}this.length>0&&b.oninit&&b.oninit()},code:function(b){if(void 0===b){var c=this.first();if(0===c.length)return;var d=q.layoutInfoFromHolder(c);if(d&&d.editable){var e=d.editor.hasClass("codeview");return e?d.codable.val():d.editable.html()}return c.html()}this.each(function(c,d){var e=q.layoutInfoFromHolder(a(d));e&&e.editable&&e.editable.html(b)})},destroy:function(){this.each(function(b,c){var d=a(c),e=q.layoutInfoFromHolder(d);e&&e.editable&&(r.dettach(e),q.removeLayout(d))})},summernoteInner:function(){return{dom:f,list:d,func:c,range:g}}})}(window.jQuery),"function"!=typeof Array.prototype.reduce&&(Array.prototype.reduce=function(a,b){"use strict";var c,d,e=this.length>>>0,f=!1;for(1<arguments.length&&(d=b,f=!0),c=0;e>c;++c)this.hasOwnProperty(c)&&(f?d=a(d,this[c],c,this):(d=this[c],f=!0));if(!f)throw new TypeError("Reduce of empty array with no initial value");return d});