UNPKG

kendo-ui-core

Version:
3 lines (2 loc) 14.6 kB
!function(e){"function"==typeof define&&define.amd?define(["kendo.core.min"],e):e()}((function(){!function(e,t,n){"use strict";if(t&&t.injector){var a,i,r,o,l=t.module("kendo.directives",[]),u=t.injector(["ng"]),c=u.get("$parse"),s=u.get("$timeout"),d=u.get("$log"),f=(r={TreeList:"TreeListDataSource",TreeView:"HierarchicalDataSource",Scheduler:"SchedulerDataSource",PivotGrid:"PivotDataSource",PivotConfigurator:"PivotDataSource",PanelBar:"HierarchicalDataSource",Menu:"$PLAIN",ContextMenu:"$PLAIN"},o=function(e,t){return"$PLAIN"==t?e:kendo.data[t].create(e)},function(t,n,a,i){var l=r[a]||"DataSource",u=t.$eval(i),c=o(u,l);return t.$watch(i,(function(t){var a,i=(a=e(a=n),kendo.widgetInstance(a,kendo.ui)||kendo.widgetInstance(a,kendo.mobile.ui)||kendo.widgetInstance(a,kendo.dataviz.ui));if(i&&"function"==typeof i.setDataSource&&t!==u&&t!==i.dataSource){var r=o(t,l);i.setDataSource(r),u=t}})),c}),p={kDataSource:!0,kOptions:!0,kRebind:!0,kNgModel:!0,kNgDelay:!0},v={name:!0,title:!0,style:!0},m=/^(input|select|textarea)$/i;l.factory("directiveFactory",["$compile",function(t){var n,i=!1;a=t;return{create:function(t,a){return{restrict:"AC",require:["?ngModel","^?form"],scope:!1,controller:["$scope","$attrs","$element",function(e,t){this.template=L(A,t),t._cleanUp=L((function(){this.template=null,t._cleanUp=null}),this)}],link:function(r,o,l,u){var c=e(o),s=t.replace(/([A-Z])/g,"-$1");c.attr(s,c.attr("data-"+s)),c[0].removeAttribute("data-"+s),x(r,o,l,t,a,u)&&(n&&clearTimeout(n),n=setTimeout((function(){r.$emit("kendoRendered"),i||(i=!0,e("form").each((function(){var t=e(this).controller("form");t&&t.$setPristine()})))})))}}}}}]);var g={Editor:"textarea",NumericTextBox:"input",DatePicker:"input",DateTimePicker:"input",TimePicker:"input",AutoComplete:"input",ColorPicker:"input",MaskedTextBox:"input",MultiSelect:"input",Upload:"input",Validator:"form",Button:"button",ListView:"ul",ScrollView:"div",PanelBar:"ul",TreeView:"ul",Menu:"ul",ContextMenu:"ul",ActionSheet:"ul",Switch:"input"},h=[],$=[];t.forEach(["MobileScroller"],(function(e){$.push(e),e="kendo"+e,l.directive(e,(function(){return{restrict:"A",link:function(t,n,a){x(t,n,a,e,e)}}}))}));var k=kendo.htmlEncode,w=/{{/g,y=/}}/g;kendo.htmlEncode=function(e){return k(e).replace(w,"{&#8203;{").replace(y,"}&#8203;}")};var b=[];kendo.onWidgetRegistered((function(n){b=e.grep(b,(function(e){return!_.apply(null,e)})),function(e,n){function a(e,t){l.directive(e,["directiveFactory",function(n){return n.create(t,e)}])}var i=n?"Mobile":"",r=i+=e.fn.options.name,o="kendo"+i.charAt(0)+i.substr(1).toLowerCase(),u=(i="kendo"+i).replace(/([A-Z])/g,"-$1");if(-1==h.indexOf(i.replace("kendo",""))){var c=i===o?[i]:[i,o];t.forEach(c,(function(e){l.directive(e,(function(){return{restrict:"E",replace:!0,template:function(e,t){var n=g[r]||"div",a=t.kScopeField||t.scopeField;return"<"+n+" "+u+(a?'="'+a+'"':"")+">"+e.html()+"</"+n+">"}}}))}))}$.indexOf(i.replace("kendo",""))>-1||(a(i,i),o!=i&&a(o,i))}(n.widget,"Mobile"==n.prefix)})),_(["ui.Widget","mobile.ui.Widget"],"angular",(function(r,o){var l=this.self;if("init"==r)return!o&&i&&(o=i),i=null,void(o&&o.$angular&&(l.$angular_scope=o.$angular[0],l.$angular_init(l.element,o)));var u=l.$angular_scope;u&&function(e){var t=s;try{return s=function(e){return e()},e()}finally{s=t}}((function(){var i=o(),c=i.elements,s=i.data;if(c.length>0)switch(r){case"cleanup":t.forEach(c,(function(t){var n=e(t).data("$$kendoScope");n&&n!==u&&n.$$kendoScope&&function(t,n){t.$destroy(),n&&e(n).removeData("$scope").removeData("$$kendoScope").removeData("$isolateScope").removeData("$isolateScopeNoTemplate").removeClass("ng-scope")}(n,t)}));break;case"compile":var d=l.element.injector(),f=d?d.get("$compile"):a;t.forEach(c,(function(t,a){var r;if(i.scopeFrom)r=i.scopeFrom;else{var o=s&&s[a];o!==n?(r=e.extend(u.$new(),o)).$$kendoScope=!0:r=u}e(t).data("$$kendoScope",r),f(t)(r)})),E(u)}}))})),_("ui.Widget","$angular_getLogicValue",(function(){return this.self.value()})),_("ui.Widget","$angular_setLogicValue",(function(e){this.self.value(e)})),_("ui.Select","$angular_getLogicValue",(function(){var e=this.self.dataItem(),t=this.self.options.dataValueField;return e?this.self.options.valuePrimitive?t?e[t]:e:e.toJSON():null})),_("ui.Select","$angular_setLogicValue",(function(e){var t=this.self,a=t.options,i=a.dataValueField,r=a.text||"";e===n&&(e=""),i&&!a.valuePrimitive&&e&&(r=e[a.dataTextField]||"",e=e[i||a.dataTextField]),!1!==t.options.autoBind||t.listView.bound()||!r&&e&&a.valuePrimitive?t.value(e):t._preselect(e,r)})),_("ui.MultiSelect","$angular_getLogicValue",(function(){var t=this.self.dataItems().slice(0),n=this.self.options.dataValueField;return n&&this.self.options.valuePrimitive&&(t=e.map(t,(function(e){return e[n]}))),t})),_("ui.MultiSelect","$angular_setLogicValue",(function(t){null==t&&(t=[]);var n=this.self,a=n.options,i=a.dataValueField,r=t;i&&!a.valuePrimitive&&(t=e.map(t,(function(e){return e[i]}))),!1!==a.autoBind||a.valuePrimitive||n.listView.bound()?n.value(t):n._preselect(r,t)})),_("ui.Widget","$angular_init",(function(e,t){var n=this.self;if(t&&!Array.isArray(t))for(var a=n.$angular_scope,i=n.events.length;--i>=0;){var r=n.events[i],o=t[r];o&&"string"==typeof o&&(t[r]=n.$angular_makeEventHandler(r,a,o))}})),_("ui.Widget","$angular_makeEventHandler",(function(e,t,n){return n=c(n),function(e){E(t,(function(){n(t,{kendoEvent:e})}))}})),_(["ui.Grid","ui.ListView","ui.TreeView","ui.PanelBar"],"$angular_makeEventHandler",(function(e,n,a){return"change"!=e?this.next():(a=c(a),function(e){var i,r,o,l,u,c,s=e.sender,d=s.options,f={kendoEvent:e};t.isString(d.selectable)&&(i=-1!==d.selectable.indexOf("cell"),r=-1!==d.selectable.indexOf("multiple")),s._checkBoxSelection&&(r=!0),o=f.selected=this.select(),l=f.data=[],u=f.columns=[];for(var p=0;p<o.length;p++){var v=i?o[p].parentNode:o[p],m=s.dataItem(v);i?(t.element.inArray(m,l)<0&&l.push(m),c=t.element(o[p]).index(),t.element.inArray(c,u)<0&&u.push(c)):l.push(m)}r||(f.dataItem=f.data=l[0],f.angularDataItem=kendo.proxyModelSetters(f.dataItem),f.selected=o[0]),E(n,(function(){a(n,f)}))})})),_("ui.Grid","$angular_init",(function(a,i){if(this.next(),i.columns){var r=e.extend({},kendo.Template,i.templateSettings);t.forEach(i.columns,(function(e){!e.field||e.template||e.format||e.values||e.encoded!==n&&!e.encoded||(e.template="<span ng-bind='"+kendo.expr(e.field,"dataItem")+"'>#: "+kendo.expr(e.field,r.paramName)+"#</span>")}))}}));var S,T={TreeMap:["Template"],Grid:["AltRowTemplate","DetailTemplate","RowTemplate"],ListView:["EditTemplate","Template","AltTemplate"],Pager:["SelectTemplate","LinkTemplate"],PivotGrid:["ColumnHeaderTemplate","DataCellTemplate","RowHeaderTemplate"],Scheduler:["AllDayEventTemplate","DateHeaderTemplate","EventTemplate","MajorTimeHeaderTemplate","MinorTimeHeaderTemplate"],ScrollView:["Template"],PanelBar:["Template"],TreeView:["Template"],Validator:["ErrorTemplate"]};S={},t.forEach(T,(function(e,n){t.forEach(e,(function(e){S[e]||(S[e]=[]),S[e].push("?^^kendo"+n)}))})),t.forEach(S,(function(e,t){var n="k"+t,a=kendo.toHyphens(n);l.directive(n,(function(){return{restrict:"A",require:e,terminal:!0,compile:function(t,i){if(""===i[n]){t.removeAttr(a);var r=t[0].outerHTML;return function(t,i,o,l){for(var u;!u&&l.length;)u=l.shift();u?(u.template(n,r),i.remove()):d.warn(a+" without a matching parent widget found. It can be one of the following: "+e.join(", "))}}}}}))}))}function x(t,a,r,o,l,u){if(!(a instanceof jQuery))throw new Error("The Kendo UI directives require jQuery to be available before AngularJS. Please include jquery before angular in the document.");var f=r.kNgDelay,p=t.$eval(f),v=(u=u||[])[0],m=u[1],g=e(a)[o];if(!g)return window.console.error("Could not find: "+o),null;var h=V(t,a,r,o,g),$=h.options;if(h.unresolved.length){for(var k=[],w=0,y=h.unresolved.length;w<y;w++){var b=h.unresolved[w],S=e.Deferred((function(e){var a=t.$watch(b.path,(function(t){t!==n&&(a(),e.resolve())}))})).promise();k.push(S)}e.when.apply(null,k).then(A)}else{if(!f||p)return A();var x=t.$root||t,L=function(){var e=t.$watch(f,(function(t){t!==n&&(e(),a.removeAttr(r.$attr.kNgDelay),f=null,s(A))}))};/^\$(digest|apply)$/.test(x.$$phase)?L():t.$apply(L)}function A(){var u;r.kRebind&&(u=e(e(a)[0].cloneNode(!0))),$=V(t,a,r,o,g).options,a.is("select")&&function(t){if(t.length>0){var n=e(t[0]);!/\S/.test(n.text())&&/^\?/.test(n.val())&&n.remove();for(var a=0;a<t.length;a++)e(t[a]).off("$destroy")}}(a[0].options);var s=g.call(a,i=$).data(o);!function(e,t,n,a,i){if(n[i]){var r=c(n[i]).assign;if(!r)throw new Error(i+" attribute used but expression in it is not assignable: "+n[a]);r(t,e)}}(s,t,r,o,l),t.$emit("kendoWidgetCreated",s);var f=function(e,t){var n=e.$on("$destroy",(function(){n(),t&&(kendo.destroy(t.element),t=null)}));return n}(t,s);if(r.kRebind&&function(t,n,a,i,r,o,l){var u=n.$watch(r,(function(r,c){if(!t._muteRebind&&r!==c){u(),l._cleanUp&&l._cleanUp();var s=T[t.options.name];s&&s.forEach((function(t){var a=n.$eval(l["k"+t]);a&&i.append(e(a).attr(kendo.toHyphens("k"+t),""))}));var d=e(t.wrapper)[0],f=e(t.element)[0];"Upload"===t.options.name&&(a=e(f));var p=a.injector().get("$compile");t._destroy(),o&&o(),t=null,f&&(d&&d.parentNode.replaceChild(f,d),e(a).replaceWith(i)),p(i)(n)}}),!0);E(n)}(s,t,a,u,r.kRebind,f,r),r.kNgDisabled){var p=r.kNgDisabled,h=t.$eval(p);h&&s.enable(!h),function(e,t,n,a){if(kendo.ui.PanelBar&&e instanceof kendo.ui.PanelBar||kendo.ui.Menu&&e instanceof kendo.ui.Menu)return void d.warn("k-ng-disabled specified on a widget that does not have the enable() method: "+e.options.name);t.$watch(a,(function(t,n){t!=n&&e.enable(!t)}))}(s,t,0,p)}if(r.kNgReadonly){var k=r.kNgReadonly,w=t.$eval(k);w&&s.readonly(w),function(e,t,n,a){if("function"!=typeof e.readonly)return void d.warn("k-ng-readonly specified on a widget that does not have the readonly() method: "+e.options.name);t.$watch(a,(function(t,n){t!=n&&e.readonly(t)}))}(s,t,0,k)}return r.kNgModel&&P(s,t,r.kNgModel),v&&function(e,t,a,i,r){if(!e.value)return;var o,l=!1;o=D(a)?function(){return function(e){if(/checkbox|radio/i.test(e.attr("type")))return e.prop("checked");return e.val()}(a)}:function(){return e.value()};var u=function(){var a=i.$viewValue;a===n&&(a=i.$modelValue),a===n&&(a=null),l=!0,setTimeout((function(){if(l=!1,e){var n=t[e.element.attr("k-ng-model")];n&&(a=n),(!1!==e.options.autoBind||e.listView.bound()||a)&&e.value(a)}}),0)};i.$render=u,setTimeout((function(){i.$render!==u&&(i.$render=u,i.$render())})),D(a)&&a.on("change",(function(){l=!0}));var c=function(e){return function(){var n;l&&!a.is("select")||(e&&r&&(n=r.$pristine),i.$setViewValue(o()),e&&(i.$setPristine(),n&&r.$setPristine()),E(t))}};e.first("change",c(!1)),e.first("spin",c(!1)),kendo.ui.AutoComplete&&e instanceof kendo.ui.AutoComplete||e.first("dataBound",c(!0));var s=o();isNaN(i.$viewValue)||s==i.$viewValue||(i.$isEmpty(i.$viewValue)?null!=s&&""!==s&&s!=i.$viewValue&&i.$setViewValue(s):e.value(i.$viewValue));i.$setPristine()}(s,t,a,v,m),s&&function(t,n){if(!window.MutationObserver||!t.wrapper)return;var a=[].slice.call(e(n)[0].classList),i=new MutationObserver((function(n){r(),t&&(n.forEach((function(n){var i=e(t.wrapper)[0];switch(n.attributeName){case"class":var r=[].slice.call(n.target.classList);r.forEach((function(e){a.indexOf(e)<0&&(i.classList.add(e),kendo.ui.ComboBox&&t instanceof kendo.ui.ComboBox&&t.input[0].classList.add(e))})),a.forEach((function(e){r.indexOf(e)<0&&(i.classList.remove(e),kendo.ui.ComboBox&&t instanceof kendo.ui.ComboBox&&t.input[0].classList.remove(e))})),a=r;break;case"disabled":"function"!=typeof t.enable||t.element.attr("readonly")||t.enable(!e(n.target).attr("disabled"));break;case"readonly":"function"!=typeof t.readonly||t.element.attr("disabled")||t.readonly(!!e(n.target).attr("readonly"))}})),o())}));function r(){i.disconnect()}function o(){i.observe(e(n)[0],{attributes:!0})}o(),t.first("destroy",r)}(s,a),s}}function V(a,i,r,o,l){var u=o.replace(/^kendo/,""),c=[],s=r.kOptions||r.options,d=a.$eval(s);s&&d===n&&c.push({option:"options",path:s});var m=t.extend({},r.defaultOptions,d);function g(e,i){var r=t.copy(a.$eval(i));r===n?c.push({option:e,path:i}):m[e]=r}var h=l.widget.prototype.options,$=l.widget.prototype.events;e.each(r,(function(e,t){if("source"!==e&&"kDataSource"!==e&&"kScopeField"!==e&&"scopeField"!==e){var n="data"+e.charAt(0).toUpperCase()+e.slice(1);if(0===e.indexOf("on")){var a=e.replace(/^on./,(function(e){return e.charAt(2).toLowerCase()}));$.indexOf(a)>-1&&(m[a]=t)}if(h.hasOwnProperty(n))g(n,t);else if(h.hasOwnProperty(e)&&!v[e])g(e,t);else if(!p[e]){var i=e.match(/^k(On)?([A-Z].*)/);if(i){var r=i[2].charAt(0).toLowerCase()+i[2].slice(1);i[1]&&"kOnLabel"!=e?m[r]=t:("kOnLabel"==e&&(r="onLabel"),g(r,t))}}}}));var k=r.kDataSource||r.source;return k&&(m.dataSource=f(a,i,u,k)),m.$angular=[a],{options:m,unresolved:c}}function D(e){return m.test(e[0].tagName)}function P(t,a,i){if(kendo.ui.DateRangePicker&&t instanceof kendo.ui.DateRangePicker){var r,o=i.split(","),l=o[0].trim();return P(t._startDateInput,a,l),void(o[1]?(r=o[1].trim(),P(t._endDateInput,a,r),t.range({start:a[l],end:a[r]})):t.range({start:a[l],end:null}))}if("function"==typeof t.value){var u=e(t.element).parents("ng-form, form").first(),s=kendo.getter(u.attr("name"),!0)(a),f=c(i),p=f.assign,v=!1,m=kendo.ui.MultiSelect&&t instanceof kendo.ui.MultiSelect||kendo.ui.RangeSlider&&t instanceof kendo.ui.RangeSlider,g=function(e){return e&&m?e.length:0},h=g(f(a));t.$angular_setLogicValue(f(a));var $=function(e,a){e===n&&(e=null),v||e==a&&g(e)==h||(h=g(e),t.$angular_setLogicValue(e))};m?a.$watchCollection(i,$):a.$watch(i,$);var k=function(){v=!0,s&&s.$pristine&&s.$setDirty(),E(a,(function(){p(a,t.$angular_getLogicValue()),h=g(f(a))})),v=!1};t.first("change",k),t.first("spin",k)}else d.warn("k-ng-model specified on a widget that does not have the value() method: "+t.options.name)}function L(e,t){return function(n,a){return e.call(t,n,a)}}function A(e,t){this[e]=kendo.stringify(t)}function E(e,t){var n=e.$root||e,a=/^\$(digest|apply)$/.test(n.$$phase);t?a?t():n.$apply(t):a||n.$digest()}function _(e,n,a){if(Array.isArray(e))return t.forEach(e,(function(e){_(e,n,a)}));if("string"==typeof e){for(var i=e.split("."),r=kendo;r&&i.length>0;)r=r[i.shift()];if(!r)return b.push([e,n,a]),!1;e=r.prototype}var o=e[n];return e[n]=function(){var e=this,t=arguments;return a.apply({self:e,next:function(){return o.apply(e,arguments.length>0?arguments:t)}},t)},!0}}(window.kendo.jQuery,window.angular)})); //# sourceMappingURL=kendo.angular.min.js.map