UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

1 lines 16.4 kB
module.exports=function(e){function t(i){if(o[i])return o[i].exports;var n=o[i]={exports:{},id:i,loaded:!1};return e[i].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var o={};return t.m=e,t.c=o,t.p="",t(0)}({0:function(e,t,o){o(1019),e.exports=o(1019)},3:function(e,t){e.exports=function(){throw Error("define cannot be used indirect")}},964:function(e,t){e.exports=require("./range")},1019:function(e,t,o){var i,n,r;!function(s,define){n=[o(964)],i=s,r="function"==typeof i?i.apply(t,n):i,!(void 0!==r&&(e.exports=r))}(function(){!function(e,t){var o,i=window.kendo,n=i.ui,r=n.editor,s=n.Widget,l=e.extend,a=e.proxy,d=i.keys,p=".kendoEditor",u=r.EditorUtils,c=r.ToolTemplate,f=r.Tool,h=i._outerWidth,m=i._outerHeight,k="overflowAnchor",v=".k-tool-group:visible .k-tool:not(.k-state-disabled),.k-tool.k-overflow-anchor:visible,.k-tool-group:visible .k-colorpicker:not(input),.k-tool-group:visible .k-selectbox,.k-tool-group:visible .k-dropdown,.k-tool-group:visible .k-combobox .k-input",w={"k-i-sup-script":"superscript","k-i-sub-script":"subscript","k-i-align-left":"justifyLeft","k-i-align-center":"justifyCenter","k-i-align-right":"justifyRight","k-i-align-justify":"justifyFull","k-i-list-unordered":"insertUnorderedList","k-i-list-ordered":"insertOrderedList","k-i-list-roman-upper":"insertUpperRomanList","k-i-list-roman-lower":"insertLowerRomanList","k-i-import":"import","k-i-indent-increase":"indent","k-i-indent-decrease":"outdent","k-i-link-horizontal":"createLink","k-i-unlink-horizontal":"unlink","k-i-image":"insertImage","k-i-file-add":"insertFile","k-i-html":"viewHtml","k-i-foreground-color":"foreColor","k-i-paint":"backColor","k-i-table-insert":"createTable","k-i-table-column-insert-left":"addColumnLeft","k-i-table-column-insert-right":"addColumnRight","k-i-table-row-insert-above":"addRowAbove","k-i-table-row-insert-below":"addRowBelow","k-i-table-row-delete":"deleteRow","k-i-table-column-delete":"deleteColumn","k-i-table-properties":"tableWizard","k-i-table-wizard":"tableWizardInsert","k-i-table-position-left":"tableAlignLeft","k-i-table-position-center":"tableAlignCenter","k-i-table-position-right":"tableAlignRight","k-i-clear-css":"cleanFormatting","k-i-cells-merge-horizontally":"mergeCellsHorizontally","k-i-cells-merge-vertically":"mergeCellsVertically","k-i-cell-split-horizontally":"splitCellHorizontally","k-i-cell-split-vertically":"splitCellVertically","k-i-copy-format":"copyFormat","k-i-apply-format":"applyFormat"},b=f.extend({initialize:function(t,o){var i=o.editor.toolbar;t.attr("aria-controls",o.editor.element.attr("id")).on("click",e.proxy(function(){this.overflowPopup.toggle()},i))},options:{name:k},command:e.noop,update:e.noop,destroy:e.noop});u.registerTool(k,new b({key:"",ctrl:!0,template:new c({template:u.overflowAnchorTemplate})})),o=s.extend({init:function(e,t){var o=this;t=l({},t,{name:"EditorToolbar"}),s.fn.init.call(o,e,t),t.popup&&o._initPopup(),t.resizable&&t.resizable.toolbar&&(o._resizeHandler=i.onResize(function(){o.resize(!0)}),o.element.addClass("k-toolbar-resizable"))},events:["execute"],groups:{basic:["bold","italic","underline","strikethrough"],scripts:["subscript","superscript"],alignment:["justifyLeft","justifyCenter","justifyRight","justifyFull"],links:["insertImage","insertFile","createLink","unlink"],lists:["insertUnorderedList","insertOrderedList","insertUpperRomanList","insertLowerRomanList","indent","outdent"],tablesInsert:["createTable"],tablesAddDelete:["addColumnLeft","addColumnRight","addRowAbove","addRowBelow","deleteRow","deleteColumn"],tablesMerge:["mergeCellsHorizontally","mergeCellsVertically","splitCellHorizontally","splitCellVertically"],tablesPosition:["tableAlignLeft","tableAlignCenter","tableAlignRight"],advanced:["viewHtml","cleanFormatting","print","pdf","exportAs","import"],fonts:["fontName","fontSize"],colors:["foreColor","backColor"],formatPainter:["copyFormat","applyFormat"]},overflowFlaseTools:["formatting","fontName","fontSize","foreColor","backColor","insertHtml"],_initPopup:function(){var t=this;this.window=e(this.element).wrap("<div class='editorToolbarWindow' />").parent().prepend("<span class='k-editortoolbar-dragHandle'><span class='k-icon k-i-handler-drag'></span></span>").kendoWindow({title:!1,resizable:!1,draggable:{dragHandle:".k-editortoolbar-dragHandle"},animation:{open:{effects:"fade:in"},close:{effects:"fade:out"}},minHeight:42,visible:!1,autoFocus:!1,actions:[],dragend:function(){this._moved=!0}}).on("mousedown",function(o){e(o.target).is(".k-icon")||(t.preventPopupHide=!0)}).on("focusout",function(){t.options.editor.element.focusout()}).data("kendoWindow")},_toggleOverflowStyles:function(e,t){e.find("> li").toggleClass("k-item",t).find(".k-tool:not(.k-state-disabled), .k-overflow-button").toggleClass("k-overflow-button",t)},_initOverflowPopup:function(t){var o=this,n="<ul class='k-editor-overflow-popup k-overflow-container k-list-container'></ul>";o.overflowPopup=e(n).appendTo("body").kendoPopup({anchor:t,origin:i.support.isRtl(o.element)?"bottom left":"bottom right",position:i.support.isRtl(o.element)?"top left":"top right",copyAnchorStyles:!1,open:function(e){this.element.is(":empty")&&e.preventDefault(),o._toggleOverflowStyles(this.element,!0),t.attr("aria-expanded",!0)},close:function(){t.attr("aria-expanded",!1)},activate:a(o.focusOverflowPopup,o)}).data("kendoPopup")},items:function(){var e,t,o=this.options.resizable&&this.options.resizable.toolbar;return t=this.element.children().find("> *, select"),o&&(e=this.overflowPopup,t=t.add(e.element.children().find("> *"))),t},focused:function(){var t=i._activeElement(),o=this.window,n=this.overflowPopup;return o&&e(t).closest(o.wrapper).length||n&&n.visible()},toolById:function(e){var t,o=this.tools;for(t in o)if(t.toLowerCase()==e)return o[t]},toolGroupFor:function(t){var o,i=this.groups;if(this.isCustomTool(t))return"custom";for(o in i)if(e.inArray(t,i[o])>=0)return o},bindTo:function(t){var o=this,i=o.window;o._editor&&o._editor.unbind("select",a(o.resize,o)),o._editor=t,o.options.resizable&&o.options.resizable.toolbar&&t.options.tools.push(k),o.tools=o.expandTools(t.options.tools),o.render(),o.element.find(".k-combobox .k-input").keydown(function(t){var o=e(this).closest(".k-combobox").data("kendoComboBox"),i=t.keyCode;i==d.RIGHT||i==d.LEFT?o.close():i==d.DOWN&&(o.dropDown.isOpened()||(t.stopImmediatePropagation(),o.open()))}),o._attachEvents(),o.items().each(function(){var i,n=o._toolName(this),r="moreVertical"!==n?o.tools[n]:o.tools.overflowAnchor,s=r&&r.options,l=t.options.messages,a=s&&s.tooltip||l[n],d=e(this);r&&r.initialize&&("fontSize"!=n&&"fontName"!=n||(i=l[n+"Inherit"],d.find("input").val(i).end().find("span.k-input").text(i).end()),r.initialize(d,{title:o._appendShortcutSequence(a,r),editor:o._editor}),d.closest(".k-widget",o.element).addClass("k-editor-widget"),d.closest(".k-colorpicker",o.element).next(".k-colorpicker").addClass("k-editor-widget"))}),t.bind("select",a(o.resize,o)),o.update(),i&&i.wrapper.css({top:"",left:"",width:""})},show:function(){var e,t,o,n=this,r=n.window,s=n.options.editor,l=i.support.browser;r&&(e=r.wrapper,t=s.element,e.is(":visible")&&n.window.options.visible||(e[0].style.width||e.width(this._getWindowWidth()),r._moved||(o=t.offset(),e.css({top:Math.max(0,parseInt(o.top,10)-m(e)-parseInt(n.window.element.css("padding-bottom"),10)),left:Math.max(0,parseInt(o.left,10))})),(l.msie||l.edge)&&n._overlaps(t)?setTimeout(function(){r.open()},0):r.open()))},_getWindowWidth:function(){var e=this,t=e.window.wrapper,o=e.options.editor.element;return h(o)-parseInt(t.css("border-left-width"),10)-parseInt(t.css("border-right-width"),10)},_overlaps:function(e){var t=this.window.wrapper,o=t.offset(),i=o.left,n=o.top,r=e.offset(),s=r.left,l=r.top;return!(s+e.width()<i||s>i+t.width()||l+e.height()<n||l>n+t.height())},hide:function(){this.window&&this.window.close()},focus:function(){var e="tabIndex",t=this.element,o=this._editor.element.attr(e);t.attr(e,o||0).focus().find(v).first().focus(),o||0===o||t.removeAttr(e)},focusOverflowPopup:function(){var e="tabIndex",t=this.overflowPopup.element,o=this._editor.element.attr(e);t.closest(".k-animation-container").addClass("k-overflow-wrapper"),t.attr(e,o||0).find(v).first().focus(),o||0===o||t.removeAttr(e)},_appendShortcutSequence:function(e,t){if(!t.key)return e;var o=e+" (";return t.ctrl&&(o+="Ctrl + "),t.shift&&(o+="Shift + "),t.alt&&(o+="Alt + "),o+=t.key+")"},_nativeTools:["insertLineBreak","insertParagraph","redo","undo","autoLink"],tools:{},isCustomTool:function(e){return!(e in i.ui.Editor.defaultTools)},expandTools:function(t){var o,n,s,a,d=this._nativeTools,p=i.deepExtend({},i.ui.Editor.defaultTools),u={};for(n=0;n<t.length;n++)o=t[n],a=o.name,e.isPlainObject(o)?a&&p[a]?(u[a]=l({},p[a]),l(u[a].options,o)):(s=l({cssClass:"k-i-gear",type:"button",title:""},o),s.name||(s.name="custom"),s.cssClass="k-"+s.name,s.template||"button"!=s.type||(s.template=r.EditorUtils.buttonTemplate,s.title=s.title||s.tooltip),u[a]={options:s}):p[o]&&(u[o]=p[o]);for(n=0;n<d.length;n++)u[d[n]]||(u[d[n]]=p[d[n]]);return u},render:function(){function t(t){var o="";return t.getHtml?o=t.getHtml():(e.isFunction(t)||(t=i.template(t)),o=t(r)),i.trim(o)}function o(){c.children().length&&(y&&(c.data("position",g),g++),c.appendTo(w))}function n(t){t!==k?(c=e("<li class='k-tool-group' role='presentation' />"),c.data("overflow",e.inArray(t,_)===-1)):c=e("<li class='k-overflow-tools' />")}var r,s,l,d,p,u,c,f,h=this,m=h.tools,v=h._editor.element,w=h.element.empty(),b=h._editor.options.tools,g=0,y=h.options.resizable&&h.options.resizable.toolbar,_=this.overflowFlaseTools;for(w.empty(),b.length&&(d=b[0].name||b[0]),n(d,_),f=0;f<b.length;f++)d=b[f].name||b[f],r=m[d]&&m[d].options,!r&&e.isPlainObject(d)&&(r=d),s=r&&r.template,"break"==d&&(o(),e("<li class='k-row-break' />").appendTo(h.element),n(d,_)),s&&(u=h.toolGroupFor(d),p==u&&d!=k||(o(),n(d,_),p=u),d==k&&(s.options.title=h.options.messages.overflowAnchor),s=t(s),l=e(s).appendTo(c),"custom"==u&&(o(),n(d,_)),r.exec&&l.hasClass("k-tool")&&l.click(a(r.exec,v[0])));o(),e(h.element).children(":has(> .k-tool)").not(".k-overflow-tools").addClass("k-button-group"),h.updateGroups(),y&&h._initOverflowPopup(h.element.find(".k-overflow-anchor")),h.angular("compile",function(){return{elements:h.element}})},updateGroups:function(){e(this.element).children().not(".k-overflow-tools").each(function(){e(this).children().removeClass("k-group-start k-group-end").first().addClass("k-group-start").end().last().addClass("k-group-end").end()})},decorateFrom:function(t){this.items().filter(".k-decorated").each(function(){var o=e(this).data("kendoSelectBox");o&&o.decorate(t)})},destroy:function(){s.fn.destroy.call(this);var e,t=this.tools;for(e in t)t[e].destroy&&t[e].destroy();this.window&&this.window.destroy(),this._resizeHandler&&i.unbindResize(this._resizeHandler),this.overflowPopup&&this.overflowPopup.destroy()},_attachEvents:function(){var t=this,o=t.overflowPopup?t.overflowPopup.element:e([]);t.attachToolsEvents(t.element.add(o))},attachToolsEvents:function(t){var o=this,n="[role=button].k-tool",r=n+":not(.k-state-disabled), [role=button].k-i-import:not(.k-state-disabled)",s=n+".k-state-disabled",l=".k-dropdown",a=".k-colorpicker",u=[n,l,a].join(",");t.off(p).on("mouseenter"+p,r,function(){e(this).addClass("k-state-hover")}).on("mouseleave"+p,r,function(){e(this).removeClass("k-state-hover")}).on("mousedown"+p,u,function(e){e.preventDefault()}).on("keydown"+p,v,function(t){function n(e,t,o){var i=t.find(v),n=i.index(a)+e;return o&&(n=Math.max(0,Math.min(i.length-1,n))),i[n]}var r,s,l,a=this,p=o.options.resizable&&o.options.resizable.toolbar,u=i.support.isRtl(o.element)?-1:1,c=t.keyCode;c==d.RIGHT||c==d.LEFT?s=e(a).is(".k-dropdown")?e(a):n(c==d.RIGHT?1*u:-1*u,o.element,!0):!p||c!=d.UP&&c!=d.DOWN?c==d.HOME?(s=o.element.find(v)[0],t.preventDefault()):c==d.END?(r=o.element.find(v).filter(function(){return"hidden"!==e(this).css("visibility")}),s=r[r.length-1],t.preventDefault()):c==d.ESC?(o.overflowPopup&&o.overflowPopup.visible()&&o.overflowPopup.close(),s=o._editor):c!=d.TAB||t.ctrlKey||t.altKey||(l=p&&e(a.parentElement).hasClass("k-overflow-tool-group")?o.overflowPopup.element:o.element,t.shiftKey?s=n(-1,l):(s=n(1,l),s&&"hidden"!==e(s).closest(".k-overflow-tools").css("visibility")||(s=o._editor))):s=n(c==d.DOWN?1:-1,o.overflowPopup.element,!0),s&&(t.preventDefault(),s.focus()),c!==d.ENTER&&c!==d.SPACEBAR||!e(a).is("button")&&!e(a).is("a")||e(a).attr("href")||o._executeToolCommand(a,t)}).on("click"+p,r,function(e){o._executeToolCommand(this,e)}).on("click"+p,s,function(e){e.preventDefault()})},_executeToolCommand:function(t,o){var i=this,n=e(t);o.preventDefault(),o.stopPropagation(),n.removeClass("k-state-hover"),n.is("[data-popup]")||i._editor.exec(i._toolName(t))},_toolName:function(t){var o,n,r;if(t)return o=t.className,/k-tool\b/i.test(o)&&(o=t.firstChild.className),n=e.grep(o.split(" "),function(e){return!/^k-(widget|tool|tool-icon|icon|state-hover|header|combobox|dropdown|selectbox|colorpicker)$/i.test(e)}),n[0]?(r=n[0],w[r]&&(r=w[r]),r.indexOf("k-i-")>=0?i.toCamelCase(r.substring(r.indexOf("k-i-")+4)):r.substring(r.lastIndexOf("-")+1)):"custom"},refreshTools:function(){var t=this,o=t._editor,i=o.getRange(),n=r.RangeUtils.textNodes(i),s=o.options.immutables,l=t._immutablesContext(i);n=r.Dom.filterBy(n,r.Dom.htmlIndentSpace,!0),n.length||(n=[i.startContainer]),t.items().each(function(){var o,i=t.tools[t._toolName(this)];i&&(o=e(this),i.update&&i.update(o,n),s&&t._updateImmutablesState(i,o,l))}),this.update()},_immutablesContext:function(e){if(this._editor.options.immutables)return e.collapsed?r.Immutables.immutablesContext(e):0===r.RangeUtils.editableTextNodes(e).length},_updateImmutablesState:function(o,i,n){var s,l,a,d,p,u=o.name,c=i,f=o.options.trackImmutables;if(f===t&&(f=e.inArray(u,r.Immutables.toolsToBeUpdated)>-1),f){if(s=n?"none":"",!i.is(".k-tool")){l=i.data();for(a in l)if(a.match(/^kendo[A-Z][a-zA-Z]*/)){d=l[a],c=d.wrapper;break}}c.css("display",s),p=c.closest("li"),0===p.children(":visible").length&&p.css("display",s)}},update:function(){this.updateGroups()},_resize:function(e){var t=e.width,o=this.options.resizable&&this.options.resizable.toolbar,i=this.overflowPopup,n=this.options.editor.element,r=this.window;this.refreshTools(),o&&(r&&(r.wrapper.width(this._getWindowWidth()),r._moved||r.wrapper.css({left:Math.max(0,parseInt(n.offset().left,10))})),i.visible()&&i.close(!0),this._refreshWidths(),this._shrink(t),this._stretch(t),this._toggleOverflowStyles(this.element,!1),this._toggleOverflowStyles(this.overflowPopup.element,!0),this.element.children("li.k-overflow-tools").css("visibility",i.element.is(":empty")?"hidden":"visible"))},_refreshWidths:function(){this.element.children("li").each(function(t,o){var i=e(o);i.data("outerWidth",h(i,!0))})},_shrink:function(e){var t,o,i;if(e<this._groupsWidth())for(o=this._visibleGroups().filter(":not(.k-overflow-tools)"),i=o.length-1;i>=0&&(t=o.eq(i),!(e>this._groupsWidth()));i--)this._hideGroup(t)},_stretch:function(e){var t,o,i;if(e>this._groupsWidth())for(o=this._hiddenGroups(),i=0;i<o.length&&(t=o.eq(i),!(e<this._groupsWidth())&&this._showGroup(t,e));i++);},_hiddenGroups:function(){var t=this.overflowPopup,o=this.element.children("li.k-tool-group").filter(":hidden");return o=o.add(t.element.children("li")),o.sort(function(t,o){return e(t).data("position")>e(o).data("position")?1:-1}),o},_visibleGroups:function(){return this.element.children("li.k-tool-group, li.k-overflow-tools").filter(":visible")},_groupsWidth:function(){var t=0;return this._visibleGroups().each(function(){t+=e(this).data("outerWidth")}),Math.ceil(t)},_hideGroup:function(e){if(e.data("overflow")){var t=this.overflowPopup;e.detach().prependTo(t.element).addClass("k-overflow-tool-group")}else e.addClass("k-hidden")},_showGroup:function(t,o){var i,n,r;return!!t.hasClass("k-state-disabled")||(t.hasClass("k-overflow-tool-group")?r=t.data("outerWidth"):(t.removeClass("k-hidden"),r=h(t,!0),t.addClass("k-hidden")),!!(t.length&&o>this._groupsWidth()+r)&&(t.hasClass("k-overflow-tool-group")?(i=t.data("position"),0===i?t.detach().prependTo(this.element):(n=this.element.children().filter(function(t,o){return e(o).data("position")===i-1}),t.detach().insertAfter(n)),t.removeClass("k-overflow-tool-group")):t.removeClass("k-hidden"),!0))}}),e.extend(r,{Toolbar:o})}(window.kendo.jQuery)},o(3))}});