tupali_fork/librerias/summernote/summernote.min.js

4 lines
87 KiB
JavaScript
Raw Normal View History

2016-10-29 15:07:15 +00:00
/*! Summernote v0.8.1 | (c) 2013-2015 Alan Hong and other contributors | MIT license */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&module.exports?module.exports=a(require("jquery")):a(window.jQuery)}(function(a){"use strict";var b,c=function(){var b=function(a){return function(b){return a===b}},c=function(a,b){return a===b},d=function(a){return function(b,c){return b[a]===c[a]}},e=function(){return!0},f=function(){return!1},g=function(a){return function(){return!a.apply(a,arguments)}},h=function(a,b){return function(c){return a(c)&&b(c)}},i=function(a){return a},j=function(a,b){return function(){return a[b].apply(a,arguments)}},k=0,l=function(a){var b=++k+"";return a?a+b:b},m=function(b){var c=a(document);return{top:b.top+c.scrollTop(),left:b.left+c.scrollLeft(),width:b.right-b.left,height:b.bottom-b.top}},n=function(a){var b={};for(var c in a)a.hasOwnProperty(c)&&(b[a[c]]=c);return b},o=function(a,b){return b=b||"",b+a.split(".").map(function(a){return a.substring(0,1).toUpperCase()+a.substring(1)}).join("")};return{eq:b,eq2:c,peq2:d,ok:e,fail:f,self:i,not:g,and:h,invoke:j,uniqueId:l,rect2bnd:m,invertObject:n,namespaceToCamel:o}}(),d=function(){var b=function(a){return a[0]},d=function(a){return a[a.length-1]},e=function(a){return a.slice(0,a.length-1)},f=function(a){return a.slice(1)},g=function(a,b){for(var c=0,d=a.length;d>c;c++){var e=a[c];if(b(e))return e}},h=function(a,b){for(var c=0,d=a.length;d>c;c++)if(!b(a[c]))return!1;return!0},i=function(b,c){return a.inArray(c,b)},j=function(a,b){return-1!==i(a,b)},k=function(a,b){return b=b||c.self,a.reduce(function(a,c){return a+b(c)},0)},l=function(a){for(var b=[],c=-1,d=a.length;++c<d;)b[c]=a[c];return b},m=function(a){return!a||!a.length},n=function(a,c){if(!a.length)return[];var e=f(a);return e.reduce(function(a,b){var e=d(a);return c(d(e),b)?e[e.length]=b:a[a.length]=[b],a},[[b(a)]])},o=function(a){for(var b=[],c=0,d=a.length;d>c;c++)a[c]&&b.push(a[c]);return b},p=function(a){for(var b=[],c=0,d=a.length;d>c;c++)j(b,a[c])||b.push(a[c]);return b},q=function(a,b){var c=i(a,b);return-1===c?null:a[c+1]},r=function(a,b){var c=i(a,b);return-1===c?null:a[c-1]};return{head:b,last:d,initial:e,tail:f,prev:r,next:q,find:g,contains:j,all:h,sum:k,from:l,isEmpty:m,clusterBy:n,compact:o,unique:p}}(),e="function"==typeof define&&define.amd,f=function(b){var c="Comic Sans MS"===b?"Courier New":"Comic Sans MS",d=a("<div>").css({position:"absolute",left:"-9999px",top:"-9999px",fontSize:"200px"}).text("mmmmmmmmmwwwwwww").appendTo(document.body),e=d.css("fontFamily",c).width(),f=d.css("fontFamily",b+","+c).width();return d.remove(),e!==f},g=navigator.userAgent,h=/MSIE|Trident/i.test(g);if(h){var i=/MSIE (\d+[.]\d+)/.exec(g);i&&(b=parseFloat(i[1])),i=/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/.exec(g),i&&(b=parseFloat(i[1]))}var j=/Edge\/\d+/.test(g),k=!!window.CodeMirror;if(!k&&e&&require)if(require.hasOwnProperty("resolve"))try{require.resolve("codemirror"),k=!0}catch(l){k=!1}else require.hasOwnProperty("specified")&&(k=require.specified("codemirror"));var m={isMac:navigator.appVersion.indexOf("Mac")>-1,isMSIE:h,isEdge:j,isFF:!j&&/firefox/i.test(g),isPhantom:/PhantomJS/i.test(g),isWebkit:!j&&/webkit/i.test(g),isChrome:!j&&/chrome/i.test(g),isSafari:!j&&/safari/i.test(g),browserVersion:b,jqueryVersion:parseFloat(a.fn.jquery),isSupportAmd:e,hasCodeMirror:k,isFontInstalled:f,isW3CRangeSupport:!!document.createRange},n=String.fromCharCode(160),o="\ufeff",p=function(){var b=function(b){return b&&a(b).hasClass("note-editable")},e=function(b){return b&&a(b).hasClass("note-control-sizing")},f=function(a){return a=a.toUpperCase(),function(b){return b&&b.nodeName.toUpperCase()===a}},g=function(a){return a&&3===a.nodeType},h=function(a){return a&&1===a.nodeType},i=function(a){return a&&/^BR|^IMG|^HR|^IFRAME|^BUTTON/.test(a.nodeName.toUpperCase())},j=function(a){return b(a)?!1:a&&/^DIV|^P|^LI|^H[1-7]/.test(a.nodeName.toUpperCase())},k=function(a){return a&&/^H[1-7]/.test(a.nodeName.toUpperCase())},l=f("PRE"),q=f("LI"),r=function(a){return j(a)&&!q(a)},s=f("TABLE"),t=function(a){return!(y(a)||u(a)||v(a)||j(a)||s(a)||x(a))},u=function(a){
return a.each(f,function(a,b){p.appendChildNodes(e,b.childNodes),p.remove(b)}),d.head(c)})}return j},this.current=function(b){var c=a(p.isElement(b.sc)?b.sc:b.sc.parentNode),d=this.fromNode(c);try{d=a.extend(d,{"font-bold":document.queryCommandState("bold")?"bold":"normal","font-italic":document.queryCommandState("italic")?"italic":"normal","font-underline":document.queryCommandState("underline")?"underline":"normal","font-subscript":document.queryCommandState("subscript")?"subscript":"normal","font-superscript":document.queryCommandState("superscript")?"superscript":"normal","font-strikethrough":document.queryCommandState("strikethrough")?"strikethrough":"normal"})}catch(e){}if(b.isOnList()){var f=["circle","disc","disc-leading-zero","square"],g=a.inArray(d["list-style-type"],f)>-1;d["list-style"]=g?"unordered":"ordered"}else d["list-style"]="none";var h=p.ancestor(b.sc,p.isPara);if(h&&h.style["line-height"])d["line-height"]=h.style.lineHeight;else{var i=parseInt(d["line-height"],10)/parseInt(d["font-size"],10);d["line-height"]=i.toFixed(1)}return d.anchor=b.isOnAnchor()&&p.ancestor(b.sc,p.isAnchor),d.ancestors=p.listAncestor(b.sc,p.isEditable),d.range=b,d}},Q=function(){var b=this;this.insertOrderedList=function(a){this.toggleList("OL",a)},this.insertUnorderedList=function(a){this.toggleList("UL",a)},this.indent=function(b){var e=this,f=M.create(b).wrapBodyInlineWithPara(),g=f.nodes(p.isPara,{includeAncestor:!0}),h=d.clusterBy(g,c.peq2("parentNode"));a.each(h,function(b,c){var f=d.head(c);p.isLi(f)?e.wrapList(c,f.parentNode.nodeName):a.each(c,function(b,c){a(c).css("marginLeft",function(a,b){return(parseInt(b,10)||0)+25})})}),f.select()},this.outdent=function(b){var e=this,f=M.create(b).wrapBodyInlineWithPara(),g=f.nodes(p.isPara,{includeAncestor:!0}),h=d.clusterBy(g,c.peq2("parentNode"));a.each(h,function(b,c){var f=d.head(c);p.isLi(f)?e.releaseList([c]):a.each(c,function(b,c){a(c).css("marginLeft",function(a,b){return b=parseInt(b,10)||0,b>25?b-25:""})})}),f.select()},this.toggleList=function(e,f){var g=M.create(f).wrapBodyInlineWithPara(),h=g.nodes(p.isPara,{includeAncestor:!0}),i=g.paraBookmark(h),j=d.clusterBy(h,c.peq2("parentNode"));if(d.find(h,p.isPurePara)){var k=[];a.each(j,function(a,c){k=k.concat(b.wrapList(c,e))}),h=k}else{var l=g.nodes(p.isList,{includeAncestor:!0}).filter(function(b){return!a.nodeName(b,e)});l.length?a.each(l,function(a,b){p.replace(b,e)}):h=this.releaseList(j,!0)}M.createFromParaBookmark(i,h).select()},this.wrapList=function(a,b){var c=d.head(a),e=d.last(a),f=p.isList(c.previousSibling)&&c.previousSibling,g=p.isList(e.nextSibling)&&e.nextSibling,h=f||p.insertAfter(p.create(b||"UL"),e);return a=a.map(function(a){return p.isPurePara(a)?p.replace(a,"LI"):a}),p.appendChildNodes(h,a),g&&(p.appendChildNodes(h,d.from(g.childNodes)),p.remove(g)),a},this.releaseList=function(b,c){var e=[];return a.each(b,function(b,f){var g=d.head(f),h=d.last(f),i=c?p.lastAncestor(g,p.isList):g.parentNode,j=i.childNodes.length>1?p.splitTree(i,{node:h.parentNode,offset:p.position(h)+1},{isSkipPaddingBlankHTML:!0}):null,k=p.splitTree(i,{node:g.parentNode,offset:p.position(g)},{isSkipPaddingBlankHTML:!0});f=c?p.listDescendant(k,p.isLi):d.from(k.childNodes).filter(p.isLi),(c||!p.isList(i.parentNode))&&(f=f.map(function(a){return p.replace(a,"P")})),a.each(d.from(f).reverse(),function(a,b){p.insertAfter(b,i)});var l=d.compact([i,k,j]);a.each(l,function(b,c){var d=[c].concat(p.listDescendant(c,p.isList));a.each(d.reverse(),function(a,b){p.nodeLength(b)||p.remove(b,!0)})}),e=e.concat(f)}),e}},R=function(){var b=new Q;this.insertTab=function(a,b){var c=p.createText(new Array(b+1).join(p.NBSP_CHAR));a=a.deleteContents(),a.insertNode(c,!0),a=M.create(c,b),a.select()},this.insertParagraph=function(c){var d=M.create(c);d=d.deleteContents(),d=d.wrapBodyInlineWithPara();var e,f=p.ancestor(d.sc,p.isPara);if(f){if(p.isEmpty(f)&&p.isLi(f))return void b.toggleList(f.parentNode.nodeName);if(p.isEmpty(f)&&p.isPara(f)&&p.isBlockquote(f.parentNode))p.insertAfter(f,f.parentNode),e=f;else{e=p.splitTree(f,d.getStartPoint());var g=p.list
}).render()})},this.addImagePopoverButtons=function(){b.memo("button.imageSize100",function(){return f.button({contents:'<span class="note-fontsize-10">100%</span>',tooltip:i.image.resizeFull,click:b.createInvokeHandler("editor.resize","1")}).render()}),b.memo("button.imageSize50",function(){return f.button({contents:'<span class="note-fontsize-10">50%</span>',tooltip:i.image.resizeHalf,click:b.createInvokeHandler("editor.resize","0.5")}).render()}),b.memo("button.imageSize25",function(){return f.button({contents:'<span class="note-fontsize-10">25%</span>',tooltip:i.image.resizeQuarter,click:b.createInvokeHandler("editor.resize","0.25")}).render()}),b.memo("button.floatLeft",function(){return f.button({contents:f.icon(h.icons.alignLeft),tooltip:i.image.floatLeft,click:b.createInvokeHandler("editor.floatMe","left")}).render()}),b.memo("button.floatRight",function(){return f.button({contents:f.icon(h.icons.alignRight),tooltip:i.image.floatRight,click:b.createInvokeHandler("editor.floatMe","right")}).render()}),b.memo("button.floatNone",function(){return f.button({contents:f.icon(h.icons.alignJustify),tooltip:i.image.floatNone,click:b.createInvokeHandler("editor.floatMe","none")}).render()}),b.memo("button.removeMedia",function(){return f.button({contents:f.icon(h.icons.trash),tooltip:i.image.remove,click:b.createInvokeHandler("editor.removeMedia")}).render()})},this.addLinkPopoverButtons=function(){b.memo("button.linkDialogShow",function(){return f.button({contents:f.icon(h.icons.link),tooltip:i.link.edit,click:b.createInvokeHandler("linkDialog.show")}).render()}),b.memo("button.unlink",function(){return f.button({contents:f.icon(h.icons.unlink),tooltip:i.link.unlink,click:b.createInvokeHandler("editor.unlink")}).render()})},this.build=function(a,c){for(var d=0,e=c.length;e>d;d++){for(var g=c[d],h=g[0],i=g[1],j=f.buttonGroup({className:"note-"+h}).render(),k=0,l=i.length;l>k;k++){var m=b.memo("button."+i[k]);m&&j.append("function"==typeof m?m(b):m)}j.appendTo(a)}},this.updateCurrentStyle=function(){var c=b.invoke("editor.currentStyle");if(this.updateBtnStates({".note-btn-bold":function(){return"bold"===c["font-bold"]},".note-btn-italic":function(){return"italic"===c["font-italic"]},".note-btn-underline":function(){return"underline"===c["font-underline"]},".note-btn-subscript":function(){return"subscript"===c["font-subscript"]},".note-btn-superscript":function(){return"superscript"===c["font-superscript"]},".note-btn-strikethrough":function(){return"strikethrough"===c["font-strikethrough"]}}),c["font-family"]){var f=c["font-family"].split(",").map(function(a){return a.replace(/[\'\"]/g,"").replace(/\s+$/,"").replace(/^\s+/,"")}),h=d.find(f,e.isFontInstalled);g.find(".dropdown-fontname li a").each(function(){var b=a(this).data("value")+""==h+"";this.className=b?"checked":""}),g.find(".note-current-fontname").text(h)}if(c["font-size"]){var i=c["font-size"];g.find(".dropdown-fontsize li a").each(function(){var b=a(this).data("value")+""==i+"";this.className=b?"checked":""}),g.find(".note-current-fontsize").text(i)}if(c["line-height"]){var j=c["line-height"];g.find(".dropdown-line-height li a").each(function(){var b=a(this).data("value")+""==j+"";this.className=b?"checked":""})}},this.updateBtnStates=function(b){a.each(b,function(a,b){f.toggleBtnActive(g.find(a),b())})},this.tableMoveHandler=function(b){var c,d=18,e=a(b.target.parentNode),f=e.next(),g=e.find(".note-dimension-picker-mousecatcher"),i=e.find(".note-dimension-picker-highlighted"),j=e.find(".note-dimension-picker-unhighlighted");if(void 0===b.offsetX){var k=a(b.target).offset();c={x:b.pageX-k.left,y:b.pageY-k.top}}else c={x:b.offsetX,y:b.offsetY};var l={c:Math.ceil(c.x/d)||1,r:Math.ceil(c.y/d)||1};i.css({width:l.c+"em",height:l.r+"em"}),g.data("value",l.c+"x"+l.r),3<l.c&&l.c<h.insertTableMaxSize.col&&j.css({width:l.c+1+"em"}),3<l.r&&l.r<h.insertTableMaxSize.row&&j.css({height:l.r+1+"em"}),f.html(l.c+" x "+l.r)}},ea=function(b){var c=a.summernote.ui,d=b.layoutInfo.note,e=b.layoutInfo.toolbar,f=b.options;this.shouldInitialize=function(){return!f.airMode},this.initial