From 6fc95015784a023393203632f6c26f0d04750e9d Mon Sep 17 00:00:00 2001 From: Lukas Hinsch Date: Tue, 5 Jan 2016 10:44:26 +0100 Subject: [PATCH] Add option to add/override scope properties backing the table useful for: - additional methods to be called from within cell templates - further customizing default behavior --- dist/mindsmash-angular-uxtable.js | 25 ++++++++++++++----------- dist/mindsmash-angular-uxtable.min.js | 4 ++-- dist/mindsmash-angular-uxtable.tpls.js | 2 +- src/mindsmash-angular-uxtable.js | 23 ++++++++++++----------- 4 files changed, 29 insertions(+), 25 deletions(-) diff --git a/dist/mindsmash-angular-uxtable.js b/dist/mindsmash-angular-uxtable.js index 35ddbfd..3abf5d9 100644 --- a/dist/mindsmash-angular-uxtable.js +++ b/dist/mindsmash-angular-uxtable.js @@ -347,7 +347,10 @@ keyboard: true, selection: true, selectionKey: 'id', - rowAction: angular.noop // function(row, idx, api, $event)... + rowAction: angular.noop, // function(row, idx, api, $event)... + mobileViewSize: undefined, // media size to display mobile view (xs,sm,...), multiple values as comma-separated list + mobileViewTemplate: undefined, // replacement template for mobile view (instead of table), + scope: {} // additions/overrides to the scope backing the table (additional action methods etc.) }, pagination: { ngClass: 'ux-table-pagination', @@ -464,16 +467,6 @@ }, controller: ['$scope', function($scope) { this.api = $scope.api(); - - (function(viewConf) { - console.log(viewConf); - if (!!viewConf.mobileViewTemplate && !!viewConf.mobileViewSize) { - $scope.mobile = screenSize.is(viewConf.mobileViewSize); - screenSize.on(viewConf.mobileViewSize, function (mobile) { - $scope.mobile = mobile; - }); - } - }(this.api.getConfig().view)); }], link: function($scope, elem, attrs, ctrl) { var api = ctrl.api; @@ -555,6 +548,16 @@ // initialize updateConf(null, api.getConfig()); updateData(null, api.getData()); + + var viewConf = $scope.conf.view; + if (!!viewConf.mobileViewTemplate && !!viewConf.mobileViewSize) { + $scope.mobile = screenSize.is(viewConf.mobileViewSize); + screenSize.on(viewConf.mobileViewSize, function (mobile) { + $scope.mobile = mobile; + }); + } + + angular.extend($scope, api.getConfig().view.scope); } }; }]) diff --git a/dist/mindsmash-angular-uxtable.min.js b/dist/mindsmash-angular-uxtable.min.js index 823cf3a..f57de0a 100644 --- a/dist/mindsmash-angular-uxtable.min.js +++ b/dist/mindsmash-angular-uxtable.min.js @@ -1,7 +1,7 @@ /*! * mindsmash-angular-uxtable v0.3.1 * https://github.com/mindsmash/mindsmash-angular-uxtable - * Copyright (c) 2015 mindsmash GmbH + * Copyright (c) 2016 mindsmash GmbH * License: MIT */ -!function(a){"use strict";function b(b,d,e){this.get=function(f,g){a.isUndefined(g)&&(g={});var h=a.merge({},e,g);return new c(b,d,f,h)}}function c(b,c,d,e){var f=this;f.getConfig=function(){return j},f.getData=function(){return n};for(var g="uxTable."+d,h=function(){var a=sessionStorage[g];return a?JSON.parse(sessionStorage[g]):{}},i=function(){sessionStorage[g]=JSON.stringify({page:j.page,pageSize:j.pageSize,orderBy:j.orderBy,columns:j.columns,filters:j.filters})},j=a.extend(a.extend({source:a.noop,columns:[],selection:[],active:null,filters:{}},e),h()),k=function(a){if(!a||0===a.indexOf(e.i18n.prefix))return a;var b=a.replace(/ /g,"");return e.i18n.prefix+b.toLowerCase()},l=0;l=0&&a!==j.page&&(j.page=a,d=!0),null!==c&&c>0&&c!==j.pageSize&&(j.pageSize=c,d=!0),d&&(b.$emit("uxTable.configChanged",j),i(),f.load())},f.getVisibility=function(a){for(var b=0;ba&&j.page>0?(f.prevPage(),j.active=j.pageSize-1):a>=j.pageSize&&j.page=0&&ad&&c!==!1?j.selection.push(b):d>=0&&c!==!0&&j.selection.splice(d,1)},f.setPageSelection=function(a){for(var b=0;b{{ conf.pageSize }} ',closeOnBlur:!0,closeOnSelect:!1,closeOnDeselect:!1,options:[10,25,50,100]},toggle:{ngClass:"ux-table-toggle",template:' ',closeOnBlur:!0,closeOnSelect:!1,closeOnDeselect:!1},counter:{ngClass:"ux-table-counter",template:''},selectionCounter:{ngClass:"ux-table-selection-counter",template:' (clear)'},facets:{ngClass:"ux-table-facets",maxFacetCount:5,minFacetSize:3,options:{}},requestConverter:function(b,c){for(var d=b.orderBy,e={_page:b.page,_pageSize:b.pageSize,_orderBy:d&&d.key?d.key+(d.asc?",asc":",desc"):null},f={},g=0;g0&&(d.meta.orderBy={key:b.sort[0].property,asc:b.sort[0].ascending}),d}};this.setConfig=function(a){return c=a,this},this.$get=["$rootScope","$timeout",function(a,d){return new b(a,d,c)}]}).directive("uxTableView",["$rootScope","hotkeys","ElementClickListener","screenSize",function(a,b,c,d){return{replace:!0,restrict:"AE",templateUrl:"_uxTableView.html",scope:{api:"&"},controller:["$scope",function(a){this.api=a.api(),function(b){console.log(b),b.mobileViewTemplate&&b.mobileViewSize&&(a.mobile=d.is(b.mobileViewSize),d.on(b.mobileViewSize,function(b){a.mobile=b}))}(this.api.getConfig().view)}],link:function(d,e,f,g){var h=g.api;d.conf={},d.sortBy=h.setSorting,d.rowClick=function(a,b,c){h.toggleActive(b)};var i=function(a,b){d.conf=b},j=function(a,b){d.data=b};b.bindTo(d).add({combo:"shift+left",callback:h.firstPage}).add({combo:"left",callback:h.prevPage}).add({combo:"right",callback:h.nextPage}).add({combo:"shift+right",callback:h.lastPage}).add({combo:"space",callback:function(a){null!==d.conf.active&&(a.preventDefault(),h.toggleSelection(d.data[d.conf.active][d.conf.view.selectionKey]))}}).add({combo:"return",callback:function(a){if(null!==d.conf.active){a.preventDefault();var b=d.conf.active,c=d.data[b];d.conf.view.rowAction(c,b,h,a),d.conf.active=null}}}).add({combo:"up",callback:function(a){null!==d.conf.active&&(a.preventDefault(),h.prevActive())}}).add({combo:"down",callback:function(a){null!==d.conf.active&&(a.preventDefault(),h.nextActive())}}).add({combo:"esc",callback:function(a){null!==d.conf.active&&(a.preventDefault(),h.clearActive())}}),a.$on("uxTable.configChanged",i),a.$on("uxTable.dataChanged",j),c.register("uxTable.view",e,h.clearActive,!0),i(null,h.getConfig()),j(null,h.getData())}}}]).directive("uxTablePagination",["$rootScope","$timeout",function(a,b){return{replace:!0,restrict:"AE",templateUrl:"_uxTablePagination.html",scope:{api:"&"},controller:["$scope",function(a){var b=a.api();a.conf={},a.current={page:0},a.hasPrevious=function(b){return b=b?b:a.current.page,b>1},a.hasNext=function(b){return b=b?b:a.current.page,b=1&&c<=a.conf.pageCount&&b.setPage(c-1)}}],link:function(b,c,d){var e=b.api(),f=function(a,c){for(var d=[],e=a;c>=e;e++)d.push({number:e,active:b.current.page==e});return d},g=function(a){var c=1,d=a.pageCount;return d-c>a.pagination.maxSize-1&&(c=b.current.page-Math.floor((a.pagination.maxSize-1)/2)>0?b.current.page-Math.floor((a.pagination.maxSize-1)/2):1,d=c+(a.pagination.maxSize-1),d>a.pageCount&&(d=a.pageCount,c=d-(a.pagination.maxSize-1))),f(c,d)},h=function(a,c){b.conf=c,b.current.page=c.page+1,b.pages=g(c)};a.$on("uxTable.configChanged",h),h(null,e.getConfig())}}}]).directive("uxTablePaginationSize",["$rootScope","$compile","$filter",function(b,c,d){return{replace:!0,restrict:"AE",templateUrl:"_uxTablePaginationSize.html",scope:{api:"&"},link:{pre:function(e,f,g){var h=e.api();e.conf={},e.confLocal={ngModel:null,options:[],extraSettings:{dynamicTitle:!1,displayProp:"label",idProp:"id",externalIdProp:"id",enableSearch:!1,selectionLimit:1,showCheckAll:!1,showUncheckAll:!1,groupByTextProvider:a.noop,scrollable:!0,scrollableHeight:"auto",smartButtonMaxItems:1,smartButtonTextConverter:a.noop},events:{onItemSelect:function(a){h.setPagination(0,a.id)}}};var i=function(b,g){for(var h=[],i=0;i"+k+""),a.isString(k)&&e.confLocal.template!==k&&(f.find("button.dropdown-toggle").html(c(k)(e)),e.confLocal.template=k)};b.$on("uxTable.configChanged",i),i(null,h.getConfig())}}}}]).directive("uxTableToggle",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableToggle.html",scope:{api:"&"},link:{pre:function(d,e,f){var g=d.api();d.conf={},d.confLocal={ngModel:[],options:[],extraSettings:{dynamicTitle:!1,displayProp:"name",idProp:"key",externalIdProp:"key",enableSearch:!1,selectionLimit:0,showCheckAll:!1,showUncheckAll:!1,groupByTextProvider:a.noop,scrollable:!0,scrollableHeight:"auto",smartButtonMaxItems:0,smartButtonTextConverter:a.noop},events:{onItemSelect:function(a){g.setVisibility(a.key,!0)},onItemDeselect:function(a){0===d.confLocal.ngModel.length?d.confLocal.ngModel.push(a):g.setVisibility(a.key,!1)}}};var h=function(b,f){for(var g=[],h=[],i=0;i"+k+""),a.isString(k)&&d.confLocal.template!==k&&(e.find("button.dropdown-toggle").html(c(k)(d)),d.confLocal.template=k)};b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}}]).directive("uxTableCounter",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableCounter.html",scope:{api:"&"},link:function(d,e,f){var g=d.api();d.conf={},d.confLocal={};var h=function(b,f){d.conf=f;var g=f.counter.template;0!==g.indexOf("<")&&(g=""+g+""),a.isString(g)&&d.confLocal.template!==g&&(e.html(c(g)(d)),d.confLocal.template=g)};b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}]).directive("uxTableSelectionCounter",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableSelectionCounter.html",scope:{api:"&"},link:function(d,e,f){var g=d.api();d.conf={},d.confLocal={};var h=function(b,f){d.conf=f;var g=f.selectionCounter.template;0!==g.indexOf("<")&&(g=""+g+""),a.isString(g)&&d.confLocal.template!==g&&(e.html(c(g)(d)),d.confLocal.template=g)};d.clear=function(){g.clearSelection()},b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}]).directive("uxTableFacets",["$rootScope",function(a){return{replace:!0,restrict:"AE",templateUrl:"_uxTableFacets.html",scope:{api:"&"},link:function(b,c,d){var e=b.api();b.conf={};var f=function(a,c){b.conf=c};b.getFilter=function(a){return b.conf.filters[a]},b.setFilter=function(a,b){e.setFilter(a,b)},b.toggleFacet=function(a,b){e.toggleFacet(a,b)},a.$on("uxTable.configChanged",f),f(null,e.getConfig())}}}]).directive("uxTableCell",["$compile",function(b){return{scope:!1,require:"^uxTableView",link:function(c,d,e){var f=c.column.template;a.isString(f)&&d.html(b(f)(c))}}}]).directive("uxTableSelection",["$timeout",function(a){return{replace:!0,require:"^uxTableView",scope:{data:"=",selection:"=",selectionKey:"="},link:function(b,c,d,e){var f=e.api,g=function(a,d){if(a!==d){for(var e=0,f=0;f'),a.put("_uxTableFacets.html",'
  • ×
  • {{ term.count }}{{ term.term }}
'),a.put("_uxTablePagination.html",''),a.put("_uxTablePaginationSize.html",'
'),a.put("_uxTableSelectionCounter.html",'
'),a.put("_uxTableToggle.html",'
'),a.put("_uxTableView.html",'
{{ row[column.key] }}
')}]); \ No newline at end of file +!function(a){"use strict";function b(b,d,e){this.get=function(f,g){a.isUndefined(g)&&(g={});var h=a.merge({},e,g);return new c(b,d,f,h)}}function c(b,c,d,e){var f=this;f.getConfig=function(){return j},f.getData=function(){return n};for(var g="uxTable."+d,h=function(){var a=sessionStorage[g];return a?JSON.parse(sessionStorage[g]):{}},i=function(){sessionStorage[g]=JSON.stringify({page:j.page,pageSize:j.pageSize,orderBy:j.orderBy,columns:j.columns,filters:j.filters})},j=a.extend(a.extend({source:a.noop,columns:[],selection:[],active:null,filters:{}},e),h()),k=function(a){if(!a||0===a.indexOf(e.i18n.prefix))return a;var b=a.replace(/ /g,"");return e.i18n.prefix+b.toLowerCase()},l=0;l=0&&a!==j.page&&(j.page=a,d=!0),null!==c&&c>0&&c!==j.pageSize&&(j.pageSize=c,d=!0),d&&(b.$emit("uxTable.configChanged",j),i(),f.load())},f.getVisibility=function(a){for(var b=0;ba&&j.page>0?(f.prevPage(),j.active=j.pageSize-1):a>=j.pageSize&&j.page=0&&ad&&c!==!1?j.selection.push(b):d>=0&&c!==!0&&j.selection.splice(d,1)},f.setPageSelection=function(a){for(var b=0;b{{ conf.pageSize }} ',closeOnBlur:!0,closeOnSelect:!1,closeOnDeselect:!1,options:[10,25,50,100]},toggle:{ngClass:"ux-table-toggle",template:' ',closeOnBlur:!0,closeOnSelect:!1,closeOnDeselect:!1},counter:{ngClass:"ux-table-counter",template:''},selectionCounter:{ngClass:"ux-table-selection-counter",template:' (clear)'},facets:{ngClass:"ux-table-facets",maxFacetCount:5,minFacetSize:3,options:{}},requestConverter:function(b,c){for(var d=b.orderBy,e={_page:b.page,_pageSize:b.pageSize,_orderBy:d&&d.key?d.key+(d.asc?",asc":",desc"):null},f={},g=0;g0&&(d.meta.orderBy={key:b.sort[0].property,asc:b.sort[0].ascending}),d}};this.setConfig=function(a){return c=a,this},this.$get=["$rootScope","$timeout",function(a,d){return new b(a,d,c)}]}).directive("uxTableView",["$rootScope","hotkeys","ElementClickListener","screenSize",function(b,c,d,e){return{replace:!0,restrict:"AE",templateUrl:"_uxTableView.html",scope:{api:"&"},controller:["$scope",function(a){this.api=a.api()}],link:function(f,g,h,i){var j=i.api;f.conf={},f.sortBy=j.setSorting,f.rowClick=function(a,b,c){j.toggleActive(b)};var k=function(a,b){f.conf=b},l=function(a,b){f.data=b};c.bindTo(f).add({combo:"shift+left",callback:j.firstPage}).add({combo:"left",callback:j.prevPage}).add({combo:"right",callback:j.nextPage}).add({combo:"shift+right",callback:j.lastPage}).add({combo:"space",callback:function(a){null!==f.conf.active&&(a.preventDefault(),j.toggleSelection(f.data[f.conf.active][f.conf.view.selectionKey]))}}).add({combo:"return",callback:function(a){if(null!==f.conf.active){a.preventDefault();var b=f.conf.active,c=f.data[b];f.conf.view.rowAction(c,b,j,a),f.conf.active=null}}}).add({combo:"up",callback:function(a){null!==f.conf.active&&(a.preventDefault(),j.prevActive())}}).add({combo:"down",callback:function(a){null!==f.conf.active&&(a.preventDefault(),j.nextActive())}}).add({combo:"esc",callback:function(a){null!==f.conf.active&&(a.preventDefault(),j.clearActive())}}),b.$on("uxTable.configChanged",k),b.$on("uxTable.dataChanged",l),d.register("uxTable.view",g,j.clearActive,!0),k(null,j.getConfig()),l(null,j.getData());var m=f.conf.view;m.mobileViewTemplate&&m.mobileViewSize&&(f.mobile=e.is(m.mobileViewSize),e.on(m.mobileViewSize,function(a){f.mobile=a})),a.extend(f,j.getConfig().view.scope)}}}]).directive("uxTablePagination",["$rootScope","$timeout",function(a,b){return{replace:!0,restrict:"AE",templateUrl:"_uxTablePagination.html",scope:{api:"&"},controller:["$scope",function(a){var b=a.api();a.conf={},a.current={page:0},a.hasPrevious=function(b){return b=b?b:a.current.page,b>1},a.hasNext=function(b){return b=b?b:a.current.page,b=1&&c<=a.conf.pageCount&&b.setPage(c-1)}}],link:function(b,c,d){var e=b.api(),f=function(a,c){for(var d=[],e=a;c>=e;e++)d.push({number:e,active:b.current.page==e});return d},g=function(a){var c=1,d=a.pageCount;return d-c>a.pagination.maxSize-1&&(c=b.current.page-Math.floor((a.pagination.maxSize-1)/2)>0?b.current.page-Math.floor((a.pagination.maxSize-1)/2):1,d=c+(a.pagination.maxSize-1),d>a.pageCount&&(d=a.pageCount,c=d-(a.pagination.maxSize-1))),f(c,d)},h=function(a,c){b.conf=c,b.current.page=c.page+1,b.pages=g(c)};a.$on("uxTable.configChanged",h),h(null,e.getConfig())}}}]).directive("uxTablePaginationSize",["$rootScope","$compile","$filter",function(b,c,d){return{replace:!0,restrict:"AE",templateUrl:"_uxTablePaginationSize.html",scope:{api:"&"},link:{pre:function(e,f,g){var h=e.api();e.conf={},e.confLocal={ngModel:null,options:[],extraSettings:{dynamicTitle:!1,displayProp:"label",idProp:"id",externalIdProp:"id",enableSearch:!1,selectionLimit:1,showCheckAll:!1,showUncheckAll:!1,groupByTextProvider:a.noop,scrollable:!0,scrollableHeight:"auto",smartButtonMaxItems:1,smartButtonTextConverter:a.noop},events:{onItemSelect:function(a){h.setPagination(0,a.id)}}};var i=function(b,g){for(var h=[],i=0;i"+k+""),a.isString(k)&&e.confLocal.template!==k&&(f.find("button.dropdown-toggle").html(c(k)(e)),e.confLocal.template=k)};b.$on("uxTable.configChanged",i),i(null,h.getConfig())}}}}]).directive("uxTableToggle",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableToggle.html",scope:{api:"&"},link:{pre:function(d,e,f){var g=d.api();d.conf={},d.confLocal={ngModel:[],options:[],extraSettings:{dynamicTitle:!1,displayProp:"name",idProp:"key",externalIdProp:"key",enableSearch:!1,selectionLimit:0,showCheckAll:!1,showUncheckAll:!1,groupByTextProvider:a.noop,scrollable:!0,scrollableHeight:"auto",smartButtonMaxItems:0,smartButtonTextConverter:a.noop},events:{onItemSelect:function(a){g.setVisibility(a.key,!0)},onItemDeselect:function(a){0===d.confLocal.ngModel.length?d.confLocal.ngModel.push(a):g.setVisibility(a.key,!1)}}};var h=function(b,f){for(var g=[],h=[],i=0;i"+k+""),a.isString(k)&&d.confLocal.template!==k&&(e.find("button.dropdown-toggle").html(c(k)(d)),d.confLocal.template=k)};b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}}]).directive("uxTableCounter",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableCounter.html",scope:{api:"&"},link:function(d,e,f){var g=d.api();d.conf={},d.confLocal={};var h=function(b,f){d.conf=f;var g=f.counter.template;0!==g.indexOf("<")&&(g=""+g+""),a.isString(g)&&d.confLocal.template!==g&&(e.html(c(g)(d)),d.confLocal.template=g)};b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}]).directive("uxTableSelectionCounter",["$rootScope","$compile",function(b,c){return{replace:!0,restrict:"AE",templateUrl:"_uxTableSelectionCounter.html",scope:{api:"&"},link:function(d,e,f){var g=d.api();d.conf={},d.confLocal={};var h=function(b,f){d.conf=f;var g=f.selectionCounter.template;0!==g.indexOf("<")&&(g=""+g+""),a.isString(g)&&d.confLocal.template!==g&&(e.html(c(g)(d)),d.confLocal.template=g)};d.clear=function(){g.clearSelection()},b.$on("uxTable.configChanged",h),h(null,g.getConfig())}}}]).directive("uxTableFacets",["$rootScope",function(a){return{replace:!0,restrict:"AE",templateUrl:"_uxTableFacets.html",scope:{api:"&"},link:function(b,c,d){var e=b.api();b.conf={};var f=function(a,c){b.conf=c};b.getFilter=function(a){return b.conf.filters[a]},b.setFilter=function(a,b){e.setFilter(a,b)},b.toggleFacet=function(a,b){e.toggleFacet(a,b)},a.$on("uxTable.configChanged",f),f(null,e.getConfig())}}}]).directive("uxTableCell",["$compile",function(b){return{scope:!1,require:"^uxTableView",link:function(c,d,e){var f=c.column.template;a.isString(f)&&d.html(b(f)(c))}}}]).directive("uxTableSelection",["$timeout",function(a){return{replace:!0,require:"^uxTableView",scope:{data:"=",selection:"=",selectionKey:"="},link:function(b,c,d,e){var f=e.api,g=function(a,d){if(a!==d){for(var e=0,f=0;f'),a.put("_uxTableFacets.html",'
  • ×
  • {{ term.count }}{{ term.term }}
'),a.put("_uxTablePagination.html",''),a.put("_uxTablePaginationSize.html",'
'),a.put("_uxTableSelectionCounter.html",'
'),a.put("_uxTableToggle.html",'
'),a.put("_uxTableView.html",'
{{ row[column.key] }}
')}]); \ No newline at end of file diff --git a/dist/mindsmash-angular-uxtable.tpls.js b/dist/mindsmash-angular-uxtable.tpls.js index 48cecd8..f9aba33 100644 --- a/dist/mindsmash-angular-uxtable.tpls.js +++ b/dist/mindsmash-angular-uxtable.tpls.js @@ -32,7 +32,7 @@ angular.module('mindsmash.uxTable').run(['$templateCache', function($templateCac $templateCache.put('_uxTableView.html', - "
{{ row[column.key] }}
" + "
{{ row[column.key] }}
" ); }]); diff --git a/src/mindsmash-angular-uxtable.js b/src/mindsmash-angular-uxtable.js index a836c53..dc63e1e 100644 --- a/src/mindsmash-angular-uxtable.js +++ b/src/mindsmash-angular-uxtable.js @@ -349,7 +349,8 @@ selectionKey: 'id', rowAction: angular.noop, // function(row, idx, api, $event)... mobileViewSize: undefined, // media size to display mobile view (xs,sm,...), multiple values as comma-separated list - mobileViewTemplate: undefined // replacement template for mobile view (instead of table) + mobileViewTemplate: undefined, // replacement template for mobile view (instead of table), + scope: {} // additions/overrides to the scope backing the table (additional action methods etc.) }, pagination: { ngClass: 'ux-table-pagination', @@ -466,16 +467,6 @@ }, controller: function($scope) { this.api = $scope.api(); - - (function(viewConf) { - console.log(viewConf); - if (!!viewConf.mobileViewTemplate && !!viewConf.mobileViewSize) { - $scope.mobile = screenSize.is(viewConf.mobileViewSize); - screenSize.on(viewConf.mobileViewSize, function (mobile) { - $scope.mobile = mobile; - }); - } - }(this.api.getConfig().view)); }, link: function($scope, elem, attrs, ctrl) { var api = ctrl.api; @@ -557,6 +548,16 @@ // initialize updateConf(null, api.getConfig()); updateData(null, api.getData()); + + var viewConf = $scope.conf.view; + if (!!viewConf.mobileViewTemplate && !!viewConf.mobileViewSize) { + $scope.mobile = screenSize.is(viewConf.mobileViewSize); + screenSize.on(viewConf.mobileViewSize, function (mobile) { + $scope.mobile = mobile; + }); + } + + angular.extend($scope, api.getConfig().view.scope); } }; })