@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 9.48 kB
JavaScript
module.exports=function(t){function e(i){if(n[i])return n[i].exports;var o=n[i]={exports:{},id:i,loaded:!1};return t[i].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}({0:function(t,e,n){t.exports=n(963)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},955:function(t,e){t.exports=require("./format")},963:function(t,e,n){var i,o,r;!function(a,define){o=[n(955)],i=a,r="function"==typeof i?i.apply(e,o):i,!(void 0!==r&&(t.exports=r))}(function(){!function(t){var e=window.kendo,n=e.Class,i=e.ui.editor,o=e.ui.Editor.fn.options.formats,r=i.EditorUtils,a=i.Tool,s=i.ToolTemplate,l=i.FormatTool,u=i.Dom,f=i.RangeUtils,c=t.extend,d=i.EditorUtils.registerTool,p=i.EditorUtils.registerFormat,m="mousedown.kendoEditor",h="keydown.kendoEditor",g="k-marker",b=n.extend({init:function(t){this.format=t},numberOfSiblings:function(t){var e,n=0,i=0,o=0,r=t.parentNode;for(e=r.firstChild;e;e=e.nextSibling)e!=t&&(e.className==g?o++:3==e.nodeType?n++:i++);return o>1&&r.firstChild.className==g&&r.lastChild.className==g?0:i+n},findSuitable:function(t,e){var n,i;if(!e&&this.numberOfSiblings(t)>0)return null;for(n=t.parentNode,i=this.format[0].tags;!u.ofType(n,i);){if(this.numberOfSiblings(n)>0)return null;n=n.parentNode}return n},findFormat:function(t){var e,n,i,o,r,a=this.format,s=u.attrEquals;for(e=0,n=a.length;e<n;e++){if(i=t,o=a[e].tags,r=a[e].attr,i&&u.ofType(i,o)&&s(i,r))return i;for(;i;)if(i=u.parentOfType(i,o),i&&s(i,r))return i}return null},isFormatted:function(t){var e,n;for(e=0,n=t.length;e<n;e++)if(this.findFormat(t[e]))return!0;return!1}}),v=n.extend({init:function(t,e){this.finder=new b(t),this.attributes=c({},t[0].attr,e),this.tag=t[0].tags[0]},wrap:function(t){return u.wrap(t,u.create(t.ownerDocument,this.tag,this.attributes))},activate:function(t,e){this.finder.isFormatted(e)?(this.split(t),this.remove(e)):this.apply(e)},toggle:function(t){var e=this.immutables()?f.editableTextNodes:f.textNodes,n=e(t);n.length>0&&this.activate(t,n)},immutables:function(){return this.editor&&this.editor.options.immutables},apply:function(t){var e,n,i,o,r=[];if(t.length>1)for(e=0,n=t.length;e<n;e++)i=t[e],o=this.format(i,!0),r.push(o);else i=t[0],o=this.format(i,!1);this.consolidate(r)},format:function(t,e){var n=this.finder.findSuitable(t),i=this.attributes,o=i?i.style||{}:{};if(n)u.is(n,"font")&&(o.color&&n.removeAttribute("color"),o.fontName&&n.removeAttribute("face"),o.fontSize&&n.removeAttribute("size")),u.attr(n,i);else{for(;!u.isBlock(t.parentNode)&&1==t.parentNode.childNodes.length&&"true"!==t.parentNode.contentEditable&&e;)t=t.parentNode;n=this.wrap(t)}return n},remove:function(t){var e,n,i;for(e=0,n=t.length;e<n;e++)i=this.finder.findFormat(t[e]),i&&(this.attributes&&this.attributes.style?(u.unstyle(i,this.attributes.style),i.style.cssText||i.attributes["class"]||u.unwrap(i)):u.unwrap(i))},split:function(t){var e,n,i=f.textNodes(t),o=i.length;if(o>0)for(e=0;e<o;e++)n=this.finder.findFormat(i[e]),n&&f.split(t,n,!0)},consolidate:function(t){for(var e,n;t.length>1;)if(e=t.pop(),n=t[t.length-1],e.previousSibling&&e.previousSibling.className==g&&n.appendChild(e.previousSibling),e.tagName==n.tagName&&e.previousSibling==n&&e.style.cssText==n.style.cssText&&e.className===n.className){for(;e.firstChild;)n.appendChild(e.firstChild);u.remove(e)}}}),w=b.extend({init:function(t,e){this.format=t,this.greedyProperty=e,b.fn.init.call(this,t)},getInlineCssValue:function(e){var n,i,o,r,a,s,l,f,c,d,p,m,h=e.attributes,g=t.trim;if(h)for(n=0,i=h.length;n<i;n++)if(o=h[n],r=o.nodeName,a=o.nodeValue,o.specified&&"style"==r)for(s=g(a||e.style.cssText).split(";"),f=0,c=s.length;f<c;f++)if(l=s[f],l.length){if(d=l.split(":"),p=g(d[0].toLowerCase()),m=g(d[1]),p!=this.greedyProperty)continue;return p.indexOf("color")>=0?u.toHex(m):m}},getFormatInner:function(e){var n,i,o,r=t(u.isDataNode(e)?e.parentNode:e),a=r.parentsUntil("[contentEditable]").addBack().toArray().reverse();for(n=0,i=a.length;n<i;n++)if(o="className"==this.greedyProperty?a[n].className:this.getInlineCssValue(a[n]))return o;return"inherit"},getFormat:function(t){var e,n,i=this.getFormatInner(t[0]);for(e=1,n=t.length;e<n;e++)if(i!=this.getFormatInner(t[e]))return"";return i},isFormatted:function(t){return""!==this.getFormat(t)}}),y=v.extend({init:function(t,n,i){v.fn.init.call(this,t,n),this.values=n,this.finder=new w(t,i),i&&(this.greedyProperty=e.toCamelCase(i))},activate:function(t,e){var n=this.greedyProperty,i="apply";this.split(t),n&&"inherit"==this.values.style[n]&&(i="remove"),this[i](e)}}),x=l.extend({init:function(t){l.fn.init.call(this,c(t,{finder:new b(t.format),formatter:function(){return new v(t.format)}}))}}),k=a.extend({update:function(t,e){var n=t.data(this.type);n.close(),n.value(this.finder.getFormat(e))}}),F=k.extend({init:function(t){a.fn.init.call(this,t),this.type=e.support.browser.msie||e.support.touch?"kendoDropDownList":"kendoComboBox",this.format=[{tags:["span","font"]}],this.finder=new w(this.format,t.cssAttr)},command:function(t){var e=this.options,n=this.format,o={};return new i.FormatCommand(c(t,{formatter:function(){return o[e.domAttr]=t.value,new y(n,{style:o},e.cssAttr)}}))},initialize:function(t,n){var i,o,r,s=n.editor,l=this.options,u=l.name,f=[];l.defaultValue&&(f=[{text:s.options.messages[l.defaultValue[0].text],value:l.defaultValue[0].value}]),i=f.concat(l.items?l.items:s.options[u]||[]),t.attr({title:n.title}),t[this.type]({dataTextField:"text",dataValueField:"value",dataSource:i,change:function(){s._range=o,a.exec(s,u,this.value())},close:function(){setTimeout(function(){s._deleteSavedRange()},0)},highlightFirst:!1}),t.closest(".k-widget").removeClass("k-"+u).find("*").addBack().attr("unselectable","on"),r=t.data(this.type),r.value("inherit"),r.wrapper.on(m,".k-select,.k-input",function(){var t=s.getRange();o=s._containsRange(t)?t:o}).on(h,function(t){t.keyCode===e.keys.ENTER&&(s._deleteSavedRange(),t.preventDefault())})}}),T=a.extend({init:function(t){a.fn.init.call(this,t),this.format=[{tags:["span","font"]}],this.finder=new w(this.format,t.cssAttr)},options:{palette:"websafe"},update:function(){this._widget.close()},command:function(t){var e=this.options,n=this.format,o={};return new i.FormatCommand(c(t,{formatter:function(){return o[e.domAttr]=t.value,new y(n,{style:o},e.cssAttr)}}))},initialize:function(n,i){var o=this,s=i.editor,l=this.name,u=c({},T.fn.options,this.options),f=u.palette,d=u.columns;n=this._widget=new e.ui.ColorPicker(n,{toolIcon:"k-icon k-i-"+r.getToolCssClass(u.name),palette:f,columns:d,change:function(){var t=n.value();e.support.browser.msie&&o.storedRange&&o._inputFocused&&s.selectRange(o.storedRange),t&&a.exec(s,l,t),delete o.storedRange,delete o._inputFocused,s.focus()},open:function(e){var n=e.sender;o.storedRange=s.getRange(),n._popup.element.on(m,function(e){t(e.target).is("input.k-color-value")||e.preventDefault()}),n._popup.element.is("[unselectable='on']")||n._popup.element.attr({unselectable:"on"}).find("*:not(input)").attr("unselectable","on").end().find("input").on("focus",function(){o._inputFocused=!0})},close:function(t){t.sender._popup.element.off(m),e.support.browser.msie&&o.storedRange&&o._inputFocused&&s.selectRange(o.storedRange)},activate:function(t){t.preventDefault(),"rgba(255, 255, 255, 0)"!==t.sender._value.toCssRgba()&&n.trigger("change")}}),n.wrapper.attr({title:i.title,unselectable:"on"}).find("*:not(input)").attr("unselectable","on"),n.value("transparent")}});c(i,{InlineFormatFinder:b,InlineFormatter:v,DelayedExecutionTool:k,GreedyInlineFormatFinder:w,GreedyInlineFormatter:y,InlineFormatTool:x,FontTool:F,ColorTool:T}),p("bold",[{tags:["strong","b"]},{tags:["span"],attr:{style:{fontWeight:"bold"}}}]),d("bold",new x({key:"B",ctrl:!0,format:o.bold,template:new s({template:r.buttonTemplate,title:"Bold"})})),p("italic",[{tags:["em","i"]},{tags:["span"],attr:{style:{fontStyle:"italic"}}}]),d("italic",new x({key:"I",ctrl:!0,format:o.italic,template:new s({template:r.buttonTemplate,title:"Italic"})})),p("underline",[{tags:["span"],attr:{style:{textDecoration:"underline"}}},{tags:["u"]}]),d("underline",new x({key:"U",ctrl:!0,format:o.underline,template:new s({template:r.buttonTemplate,title:"Underline"})})),p("strikethrough",[{tags:["del","strike"]},{tags:["span"],attr:{style:{textDecoration:"line-through"}}}]),d("strikethrough",new x({format:o.strikethrough,template:new s({template:r.buttonTemplate,title:"Strikethrough"})})),p("superscript",[{tags:["sup"]}]),d("superscript",new x({format:o.superscript,template:new s({template:r.buttonTemplate,title:"Superscript"})})),p("subscript",[{tags:["sub"]}]),d("subscript",new x({format:o.subscript,template:new s({template:r.buttonTemplate,title:"Subscript"})})),d("foreColor",new T({cssAttr:"color",domAttr:"color",name:"foreColor",template:new s({template:r.colorPickerTemplate,title:"Color"})})),d("backColor",new T({cssAttr:"background-color",domAttr:"backgroundColor",name:"backColor",template:new s({template:r.colorPickerTemplate,title:"Background Color"})})),d("fontName",new F({cssAttr:"font-family",domAttr:"fontFamily",name:"fontName",defaultValue:[{text:"fontNameInherit",value:"inherit"}],template:new s({template:r.comboBoxTemplate,title:"Font Name"})})),d("fontSize",new F({cssAttr:"font-size",domAttr:"fontSize",name:"fontSize",defaultValue:[{text:"fontSizeInherit",value:"inherit"}],template:new s({template:r.comboBoxTemplate,title:"Font Size"})}))}(window.kendo.jQuery)},n(3))}});