diff --git a/.gitignore b/.gitignore index bc6411d5..4a5dbf7f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .DS_Store .idea -node_modules -bower_components +/node_modules +/bower_components +dev.html diff --git a/bower.json b/bower.json index 84f0b1ad..7762fef0 100644 --- a/bower.json +++ b/bower.json @@ -1,9 +1,9 @@ { "name": "ngHandsontable", - "version": "0.7.0-beta1", + "version": "0.7.0-beta2", "dependencies": { "angular": "~1.4", - "handsontable": "~0.17.0" + "handsontable": "~0.18.0" }, "homepage": "https://github.com/handsontable/ngHandsontable", "authors": [ diff --git a/demo/build/app.js b/demo/build/app.js index ea56de2f..93445f49 100644 --- a/demo/build/app.js +++ b/demo/build/app.js @@ -38,7 +38,7 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ } config.$inject = ['$sceDelegateProvider', '$httpProvider', '$stateProvider', '$compileProvider', '$urlRouterProvider', 'demoMapProvider']; - app.constant('version', 'v0.7.0-beta1'); + app.constant('version', 'v0.7.0-beta2'); app.config(config); angular.element(document).ready(function() { @@ -318,6 +318,18 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ description: 'Enable copy/paste in context menu' } }, + 'pagination': { + 'rows-pagination': { + url: getUrl('fohohenabo/1'), + title: 'Paginate rows', + description: 'Paginate rows' + }, + 'columns-pagination': { + url: getUrl('qudufogafu/1'), + title: 'Paginate columns', + description: 'Paginate columns' + }, + }, 'other': { 'access-to-instance': { url: getUrl('fovoxu/4'), @@ -333,7 +345,7 @@ require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof requ url: getUrl('locome/2'), title: 'Custom renderer', description: 'Custom renderer' - } + }, } }; }()); diff --git a/demo/js/demos.js b/demo/js/demos.js index 7069a393..508610d9 100644 --- a/demo/js/demos.js +++ b/demo/js/demos.js @@ -77,6 +77,18 @@ description: 'Enable copy/paste in context menu' } }, + 'pagination': { + 'rows-pagination': { + url: getUrl('fohohenabo/1'), + title: 'Paginate rows', + description: 'Paginate rows' + }, + 'columns-pagination': { + url: getUrl('qudufogafu/1'), + title: 'Paginate columns', + description: 'Paginate columns' + }, + }, 'other': { 'access-to-instance': { url: getUrl('fovoxu/4'), @@ -92,7 +104,7 @@ url: getUrl('locome/2'), title: 'Custom renderer', description: 'Custom renderer' - } + }, } }; }()); diff --git a/dist/ngHandsontable.js b/dist/ngHandsontable.js index b8dac022..d20e8617 100644 --- a/dist/ngHandsontable.js +++ b/dist/ngHandsontable.js @@ -1,11 +1,11 @@ /** - * ngHandsontable 0.7.0-beta1 + * ngHandsontable 0.7.0-beta2 * * Copyright 2012-2015 Marcin Warpechowski * Copyright 2015 Handsoncode sp. z o.o. * Licensed under the MIT license. * https://github.com/handsontable/ngHandsontable - * Date: Thu Aug 27 2015 15:02:29 GMT+0200 (CEST) + * Date: Fri Sep 11 2015 09:12:32 GMT+0200 (CEST) */ if (document.all && !document.addEventListener) { // IE 8 and lower @@ -20,8 +20,13 @@ angular.module('ngHandsontable', [ 'ngHandsontable.directives' ]); + +Handsontable.hooks.add('afterContextMenuShow', function() { + Handsontable.eventManager.isHotTableEnv = false; +}); + (function() { - function autoCompleteFactory() { + function autoCompleteFactory($parse) { return { parseAutoComplete: function(column, dataSet, propertyOnly) { column.source = function(query, process) { @@ -40,18 +45,21 @@ angular.module('ngHandsontable', [ if (angular.isArray(options.object)) { source = options.object; } else { - var - objKeys = options.object.split('.'), - paramObject = data; - - while (objKeys.length > 0) { - var key = objKeys.shift(); - paramObject = paramObject[key]; - } - - if (propertyOnly) { - for (var i = 0, length = paramObject.length; i < length; i++) { - source.push(paramObject[i][options.property]); + // Using $parse to evaluate the expression against the row object + // allows us to support filters like the ngRepeat directive does. + var paramObject = $parse(options.object)(data); + + if (angular.isArray(paramObject)) { + if (propertyOnly) { + for (var i = 0, length = paramObject.length; i < length; i++) { + var item = paramObject[i][options.property]; + + if (item !== null && item !== undefined) { + source.push(item); + } + } + } else { + source = paramObject; } } else { source = paramObject; @@ -62,7 +70,7 @@ angular.module('ngHandsontable', [ } }; } - autoCompleteFactory.$inject = []; + autoCompleteFactory.$inject = ['$parse']; angular.module('ngHandsontable.services').factory('autoCompleteFactory', autoCompleteFactory); }()); @@ -170,7 +178,7 @@ angular.module('ngHandsontable', [ htOptions, i, length; settings = settings || {}; - angular.extend(scopeOptions, scope.settings); + angular.extend(scopeOptions, scope.settings || {}); htOptions = this.getAvailableSettings(); for (i = 0, length = htOptions.length; i < length; i++) { @@ -195,14 +203,14 @@ angular.module('ngHandsontable', [ htHooks, i, length, attribute; settings = settings || {}; - angular.extend(scopeOptions, scope.settings); + angular.extend(scopeOptions, scope.settings || {}); htHooks = this.getAvailableHooks(); for (i = 0, length = htHooks.length; i < length; i++) { attribute = 'on' + ucFirst(htHooks[i]); - if (typeof scopeOptions[attribute] !== 'undefined') { - settings[htHooks[i]] = scopeOptions[attribute]; + if (typeof scopeOptions[htHooks[i]] === 'function' || typeof scopeOptions[attribute] === 'function') { + settings[htHooks[i]] = scopeOptions[htHooks[i]] || scopeOptions[attribute]; } } @@ -375,7 +383,7 @@ angular.module('ngHandsontable', [ $scope.column = {}; } var optionList = {}; - var match = options.match(/^\s*(.+)\s+in\s+(.*)\s*$/); + var match = options.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)\s*$/); if (match) { optionList.property = match[1]; @@ -401,12 +409,12 @@ angular.module('ngHandsontable', [ }; }); - return function (scope, element, attributes, controllerInstance) { + return function (scope, element, attrs, controllerInstance) { var column = {}; // Turn all attributes without value as `true` by default - angular.forEach(Object.keys(attributes), function(key) { - if (key.charAt(0) !== '$' && attributes[key] === '') { + angular.forEach(Object.keys(attrs), function(key) { + if (key.charAt(0) !== '$' && attrs[key] === '') { column[key] = true; } }); @@ -479,6 +487,13 @@ angular.module('ngHandsontable', [ if (!scope.htSettings) { scope.htSettings = {}; } + // Turn all attributes without value as `true` by default + angular.forEach(Object.keys(attrs), function(key) { + if (key.charAt(0) !== '$' && attrs[key] === '') { + scope.htSettings[key] = true; + } + }); + settingFactory.mergeSettingsFromScope(scope.htSettings, scope); settingFactory.mergeHooksFromScope(scope.htSettings, scope); scope.htSettings.data = scope.datarows; @@ -493,7 +508,7 @@ angular.module('ngHandsontable', [ } if (typeof scope.htSettings.columns[i].optionList === 'string') { var optionList = {}; - var match = scope.htSettings.columns[i].optionList.match(/^\s*(.+)\s+in\s+(.*)\s*$/); + var match = scope.htSettings.columns[i].optionList.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)\s*$/); if (match) { optionList.property = match[1]; @@ -506,8 +521,6 @@ angular.module('ngHandsontable', [ autoCompleteFactory.parseAutoComplete(scope.htSettings.columns[i], scope.datarows, true); } } - scope.hotInstance = settingFactory.initializeHandsontable(element, scope.htSettings); - var origAfterChange = scope.htSettings.afterChange; scope.htSettings.afterChange = function() { @@ -518,20 +531,26 @@ angular.module('ngHandsontable', [ scope.$apply(); } }; + scope.hotInstance = settingFactory.initializeHandsontable(element, scope.htSettings); - // TODO: Add watch properties descriptor + needs perf test watch equality vs toJson + // TODO: Add watch properties descriptor + needs perf test. Watch full equality vs toJson angular.forEach(bindingsKeys, function(key) { - scope.$watch(key, function(newValue) { - if (newValue === void 0) { + scope.$watch(key, function(newValue, oldValue) { + if (newValue === void 0 || newValue === oldValue) { return; } if (key === 'datarows') { - settingFactory.renderHandsontable(scope.hotInstance); + // If reference to data rows is not changed then only re-render table + if (scope.hotInstance.getSettings().data === newValue) { + settingFactory.renderHandsontable(scope.hotInstance); + } else { + scope.hotInstance.loadData(newValue); + } } else { scope.htSettings[key] = newValue; settingFactory.updateHandsontableSettings(scope.hotInstance, scope.htSettings); } - }, ['datarows', 'columns', 'colWidths', 'rowHeaders'].indexOf(key) >= 0); + }, ['datarows', 'columns', 'rowHeights', 'colWidths', 'rowHeaders', 'colHeaders'].indexOf(key) >= 0); }); /** diff --git a/dist/ngHandsontable.min.js b/dist/ngHandsontable.min.js index 3717eafe..a452c70f 100644 --- a/dist/ngHandsontable.min.js +++ b/dist/ngHandsontable.min.js @@ -1,11 +1,11 @@ /** - * ngHandsontable 0.7.0-beta1 + * ngHandsontable 0.7.0-beta2 * * Copyright 2012-2015 Marcin Warpechowski * Copyright 2015 Handsoncode sp. z o.o. * Licensed under the MIT license. * https://github.com/handsontable/ngHandsontable - * Date: Thu Aug 27 2015 15:02:29 GMT+0200 (CEST) + * Date: Fri Sep 11 2015 09:12:32 GMT+0200 (CEST) */ -document.all&&!document.addEventListener&&(document.createElement("hot-table"),document.createElement("hot-column"),document.createElement("hot-autocomplete")),angular.module("ngHandsontable.services",[]),angular.module("ngHandsontable.directives",[]),angular.module("ngHandsontable",["ngHandsontable.services","ngHandsontable.directives"]),function(){function a(){return{parseAutoComplete:function(a,b,c){a.source=function(d,e){var f=this.instance.getSelected()[0],g=[],h=b[f];if(h){var i=a.optionList;if(i.object){if(angular.isArray(i.object))g=i.object;else{for(var j=i.object.split("."),k=h;j.length>0;){var l=j.shift();k=k[l]}if(c)for(var m=0,n=k.length;n>m;m++)g.push(k[m][i.property]);else g=k}e(g)}}}}}}a.$inject=[],angular.module("ngHandsontable.services").factory("autoCompleteFactory",a)}(),function(){function a(){var a={};return{getInstance:function(b){return a[b]},registerInstance:function(b,c){a[b]=c},removeInstance:function(b){a[b]=void 0}}}a.$inject=[],angular.module("ngHandsontable.services").factory("hotRegisterer",a)}(),function(){function a(a){return a.replace(/[A-Z]/g,function(a){return"-"+a.charAt(0).toLowerCase()})}function b(a){return a.substr(0,1).toUpperCase()+a.substr(1,a.length-1)}function c(c){return{containerClassName:"handsontable-container",initializeHandsontable:function(a,b){var d,e=document.createElement("div");return e.className=this.containerClassName,a[0].appendChild(e),d=new Handsontable(e,b),b.hotId&&c.registerInstance(b.hotId,d),d},updateHandsontableSettings:function(a,b){a&&a.updateSettings(b)},renderHandsontable:function(a){a&&a.render()},mergeSettingsFromScope:function(a,b){var c,d,e,f=angular.extend({},b);for(a=a||{},angular.extend(f,b.settings),c=this.getAvailableSettings(),d=0,e=c.length;e>d;d++)"undefined"!=typeof f[c[d]]&&(a[c[d]]=f[c[d]]);return a},mergeHooksFromScope:function(a,c){var d,e,f,g,h=angular.extend({},c);for(a=a||{},angular.extend(h,c.settings),d=this.getAvailableHooks(),e=0,f=d.length;f>e;e++)g="on"+b(d[e]),"undefined"!=typeof h[g]&&(a[d[e]]=h[g]);return a},trimScopeDefinitionAccordingToAttrs:function(a,b){for(var c in a)a.hasOwnProperty(c)&&void 0===b[c]&&void 0===b[a[c].substr(1,a[c].length)]&&delete a[c];return a},getTableScopeDefinition:function(){var a={};return this.applyAvailableSettingsScopeDef(a),this.applyAvailableHooksScopeDef(a),a.datarows="=",a.dataschema="=",a.observeDomVisibility="=",a.settings="=",a},getColumnScopeDefinition:function(){var a={};return this.applyAvailableSettingsScopeDef(a),a.data="@",a},applyAvailableSettingsScopeDef:function(a){var b,c,d;for(b=this.getAvailableSettings(),c=0,d=b.length;d>c;c++)a[b[c]]="=";return a},applyAvailableHooksScopeDef:function(a){var c,d,e;for(c=this.getAvailableHooks(),d=0,e=c.length;e>d;d++)a[c[d]]="=on"+b(c[d]);return a},getAvailableSettings:function(b){var c=Object.keys(Handsontable.DefaultSettings.prototype);return-1===c.indexOf("contextMenuCopyPaste")&&c.push("contextMenuCopyPaste"),b&&(c=c.map(a)),c},getAvailableHooks:function(b){var c=Handsontable.hooks.getRegistered();return b&&(c=c.map(function(b){return"on-"+a(b)})),c}}}c.$inject=["hotRegisterer"],angular.module("ngHandsontable.services").factory("settingFactory",c)}(),function(){function a(){return{restrict:"EA",scope:!0,require:"^hotColumn",link:function(a,b,c,d){var e=c.datarows;d.setColumnOptionList(e)}}}a.$inject=[],angular.module("ngHandsontable.directives").directive("hotAutocomplete",a)}(),function(){function a(a){return{restrict:"EA",require:"^hotTable",scope:{},controller:["$scope",function(a){this.setColumnOptionList=function(b){a.column||(a.column={});var c={},d=b.match(/^\s*(.+)\s+in\s+(.*)\s*$/);d?(c.property=d[1],c.object=d[2]):c.object=b.split(","),a.column.optionList=c}}],compile:function(b,c){var d=this;return this.scope=a.trimScopeDefinitionAccordingToAttrs(a.getColumnScopeDefinition(),c),angular.forEach(Object.keys(this.scope),function(a){d.$$isolateBindings[a]={attrName:a,collection:!1,mode:"data"===a?"@":"=",optional:!1}}),function(b,c,d,e){var f={};angular.forEach(Object.keys(d),function(a){"$"!==a.charAt(0)&&""===d[a]&&(f[a]=!0)}),a.mergeSettingsFromScope(f,b),b.column||(b.column={}),angular.extend(b.column,f),e.setColumnSetting(b.column),b.$on("$destroy",function(){e.removeColumnSetting(b.column)})}}}}a.$inject=["settingFactory"],angular.module("ngHandsontable.directives").directive("hotColumn",a)}(),function(){function a(a,b,c){return{restrict:"EA",scope:{},priority:-400,controller:["$scope",function(b){this.setColumnSetting=function(c){b.htSettings||(b.htSettings={}),b.htSettings.columns||(b.htSettings.columns=[]),b.htSettings.columns.push(c),a.updateHandsontableSettings(b.hotInstance,b.htSettings)},this.removeColumnSetting=function(c){b.htSettings.columns.indexOf(c)>-1&&(b.htSettings.columns.splice(b.htSettings.columns.indexOf(c),1),a.updateHandsontableSettings(b.hotInstance,b.htSettings))}}],compile:function(d,e){var f,g=this;return this.scope=a.trimScopeDefinitionAccordingToAttrs(a.getTableScopeDefinition(),e),f=Object.keys(this.scope),angular.forEach(f,function(a){var b=g.scope[a].charAt(0);g.$$isolateBindings[a]={attrName:g.scope[a].length>1?g.scope[a].substr(1,g.scope[a].length):a,collection:!1,mode:b,optional:!1}}),function(d,e,g){if(d.htSettings||(d.htSettings={}),a.mergeSettingsFromScope(d.htSettings,d),a.mergeHooksFromScope(d.htSettings,d),d.htSettings.data=d.datarows,d.htSettings.dataSchema=d.dataschema,d.htSettings.hotId=g.hotId,d.htSettings.observeDOMVisibility=d.observeDomVisibility,d.htSettings.columns)for(var h=0,i=d.htSettings.columns.length;i>h;h++)if("autocomplete"===d.htSettings.columns[h].type){if("string"==typeof d.htSettings.columns[h].optionList){var j={},k=d.htSettings.columns[h].optionList.match(/^\s*(.+)\s+in\s+(.*)\s*$/);k?(j.property=k[1],j.object=k[2]):j.object=j,d.htSettings.columns[h].optionList=j}b.parseAutoComplete(d.htSettings.columns[h],d.datarows,!0)}d.hotInstance=a.initializeHandsontable(e,d.htSettings);var l=d.htSettings.afterChange;d.htSettings.afterChange=function(){l&&l.apply(this,arguments),c.$$phase||d.$apply()},angular.forEach(f,function(b){d.$watch(b,function(c){void 0!==c&&("datarows"===b?a.renderHandsontable(d.hotInstance):(d.htSettings[b]=c,a.updateHandsontableSettings(d.hotInstance,d.htSettings)))},["datarows","columns","colWidths","rowHeaders"].indexOf(b)>=0)}),d.$watchCollection("datarows",function(b,c){c&&c.length===d.htSettings.minSpareRows&&b.length!==d.htSettings.minSpareRows&&(d.htSettings.data=d.datarows,a.updateHandsontableSettings(d.hotInstance,d.htSettings))})}}}}a.$inject=["settingFactory","autoCompleteFactory","$rootScope"],angular.module("ngHandsontable.directives").directive("hotTable",a)}(); \ No newline at end of file +document.all&&!document.addEventListener&&(document.createElement("hot-table"),document.createElement("hot-column"),document.createElement("hot-autocomplete")),angular.module("ngHandsontable.services",[]),angular.module("ngHandsontable.directives",[]),angular.module("ngHandsontable",["ngHandsontable.services","ngHandsontable.directives"]),Handsontable.hooks.add("afterContextMenuShow",function(){Handsontable.eventManager.isHotTableEnv=!1}),function(){function a(a){return{parseAutoComplete:function(b,c,d){b.source=function(e,f){var g=this.instance.getSelected()[0],h=[],i=c[g];if(i){var j=b.optionList;if(j.object){if(angular.isArray(j.object))h=j.object;else{var k=a(j.object)(i);if(angular.isArray(k))if(d)for(var l=0,m=k.length;m>l;l++){var n=k[l][j.property];null!==n&&void 0!==n&&h.push(n)}else h=k;else h=k}f(h)}}}}}}a.$inject=["$parse"],angular.module("ngHandsontable.services").factory("autoCompleteFactory",a)}(),function(){function a(){var a={};return{getInstance:function(b){return a[b]},registerInstance:function(b,c){a[b]=c},removeInstance:function(b){a[b]=void 0}}}a.$inject=[],angular.module("ngHandsontable.services").factory("hotRegisterer",a)}(),function(){function a(a){return a.replace(/[A-Z]/g,function(a){return"-"+a.charAt(0).toLowerCase()})}function b(a){return a.substr(0,1).toUpperCase()+a.substr(1,a.length-1)}function c(c){return{containerClassName:"handsontable-container",initializeHandsontable:function(a,b){var d,e=document.createElement("div");return e.className=this.containerClassName,a[0].appendChild(e),d=new Handsontable(e,b),b.hotId&&c.registerInstance(b.hotId,d),d},updateHandsontableSettings:function(a,b){a&&a.updateSettings(b)},renderHandsontable:function(a){a&&a.render()},mergeSettingsFromScope:function(a,b){var c,d,e,f=angular.extend({},b);for(a=a||{},angular.extend(f,b.settings||{}),c=this.getAvailableSettings(),d=0,e=c.length;e>d;d++)"undefined"!=typeof f[c[d]]&&(a[c[d]]=f[c[d]]);return a},mergeHooksFromScope:function(a,c){var d,e,f,g,h=angular.extend({},c);for(a=a||{},angular.extend(h,c.settings||{}),d=this.getAvailableHooks(),e=0,f=d.length;f>e;e++)g="on"+b(d[e]),("function"==typeof h[d[e]]||"function"==typeof h[g])&&(a[d[e]]=h[d[e]]||h[g]);return a},trimScopeDefinitionAccordingToAttrs:function(a,b){for(var c in a)a.hasOwnProperty(c)&&void 0===b[c]&&void 0===b[a[c].substr(1,a[c].length)]&&delete a[c];return a},getTableScopeDefinition:function(){var a={};return this.applyAvailableSettingsScopeDef(a),this.applyAvailableHooksScopeDef(a),a.datarows="=",a.dataschema="=",a.observeDomVisibility="=",a.settings="=",a},getColumnScopeDefinition:function(){var a={};return this.applyAvailableSettingsScopeDef(a),a.data="@",a},applyAvailableSettingsScopeDef:function(a){var b,c,d;for(b=this.getAvailableSettings(),c=0,d=b.length;d>c;c++)a[b[c]]="=";return a},applyAvailableHooksScopeDef:function(a){var c,d,e;for(c=this.getAvailableHooks(),d=0,e=c.length;e>d;d++)a[c[d]]="=on"+b(c[d]);return a},getAvailableSettings:function(b){var c=Object.keys(Handsontable.DefaultSettings.prototype);return-1===c.indexOf("contextMenuCopyPaste")&&c.push("contextMenuCopyPaste"),b&&(c=c.map(a)),c},getAvailableHooks:function(b){var c=Handsontable.hooks.getRegistered();return b&&(c=c.map(function(b){return"on-"+a(b)})),c}}}c.$inject=["hotRegisterer"],angular.module("ngHandsontable.services").factory("settingFactory",c)}(),function(){function a(){return{restrict:"EA",scope:!0,require:"^hotColumn",link:function(a,b,c,d){var e=c.datarows;d.setColumnOptionList(e)}}}a.$inject=[],angular.module("ngHandsontable.directives").directive("hotAutocomplete",a)}(),function(){function a(a){return{restrict:"EA",require:"^hotTable",scope:{},controller:["$scope",function(a){this.setColumnOptionList=function(b){a.column||(a.column={});var c={},d=b.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)\s*$/);d?(c.property=d[1],c.object=d[2]):c.object=b.split(","),a.column.optionList=c}}],compile:function(b,c){var d=this;return this.scope=a.trimScopeDefinitionAccordingToAttrs(a.getColumnScopeDefinition(),c),angular.forEach(Object.keys(this.scope),function(a){d.$$isolateBindings[a]={attrName:a,collection:!1,mode:"data"===a?"@":"=",optional:!1}}),function(b,c,d,e){var f={};angular.forEach(Object.keys(d),function(a){"$"!==a.charAt(0)&&""===d[a]&&(f[a]=!0)}),a.mergeSettingsFromScope(f,b),b.column||(b.column={}),angular.extend(b.column,f),e.setColumnSetting(b.column),b.$on("$destroy",function(){e.removeColumnSetting(b.column)})}}}}a.$inject=["settingFactory"],angular.module("ngHandsontable.directives").directive("hotColumn",a)}(),function(){function a(a,b,c){return{restrict:"EA",scope:{},priority:-400,controller:["$scope",function(b){this.setColumnSetting=function(c){b.htSettings||(b.htSettings={}),b.htSettings.columns||(b.htSettings.columns=[]),b.htSettings.columns.push(c),a.updateHandsontableSettings(b.hotInstance,b.htSettings)},this.removeColumnSetting=function(c){b.htSettings.columns.indexOf(c)>-1&&(b.htSettings.columns.splice(b.htSettings.columns.indexOf(c),1),a.updateHandsontableSettings(b.hotInstance,b.htSettings))}}],compile:function(d,e){var f,g=this;return this.scope=a.trimScopeDefinitionAccordingToAttrs(a.getTableScopeDefinition(),e),f=Object.keys(this.scope),angular.forEach(f,function(a){var b=g.scope[a].charAt(0);g.$$isolateBindings[a]={attrName:g.scope[a].length>1?g.scope[a].substr(1,g.scope[a].length):a,collection:!1,mode:b,optional:!1}}),function(d,e,g){if(d.htSettings||(d.htSettings={}),angular.forEach(Object.keys(g),function(a){"$"!==a.charAt(0)&&""===g[a]&&(d.htSettings[a]=!0)}),a.mergeSettingsFromScope(d.htSettings,d),a.mergeHooksFromScope(d.htSettings,d),d.htSettings.data=d.datarows,d.htSettings.dataSchema=d.dataschema,d.htSettings.hotId=g.hotId,d.htSettings.observeDOMVisibility=d.observeDomVisibility,d.htSettings.columns)for(var h=0,i=d.htSettings.columns.length;i>h;h++)if("autocomplete"===d.htSettings.columns[h].type){if("string"==typeof d.htSettings.columns[h].optionList){var j={},k=d.htSettings.columns[h].optionList.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)\s*$/);k?(j.property=k[1],j.object=k[2]):j.object=j,d.htSettings.columns[h].optionList=j}b.parseAutoComplete(d.htSettings.columns[h],d.datarows,!0)}var l=d.htSettings.afterChange;d.htSettings.afterChange=function(){l&&l.apply(this,arguments),c.$$phase||d.$apply()},d.hotInstance=a.initializeHandsontable(e,d.htSettings),angular.forEach(f,function(b){d.$watch(b,function(c,e){void 0!==c&&c!==e&&("datarows"===b?d.hotInstance.getSettings().data===c?a.renderHandsontable(d.hotInstance):d.hotInstance.loadData(c):(d.htSettings[b]=c,a.updateHandsontableSettings(d.hotInstance,d.htSettings)))},["datarows","columns","rowHeights","colWidths","rowHeaders","colHeaders"].indexOf(b)>=0)}),d.$watchCollection("datarows",function(b,c){c&&c.length===d.htSettings.minSpareRows&&b.length!==d.htSettings.minSpareRows&&(d.htSettings.data=d.datarows,a.updateHandsontableSettings(d.hotInstance,d.htSettings))})}}}}a.$inject=["settingFactory","autoCompleteFactory","$rootScope"],angular.module("ngHandsontable.directives").directive("hotTable",a)}(); \ No newline at end of file diff --git a/index.html b/index.html index a3132d51..544ccd83 100644 --- a/index.html +++ b/index.html @@ -136,14 +136,14 @@

Code