From 8ba892be870ffa4bf7859a259623d960e0883a5b Mon Sep 17 00:00:00 2001 From: BDomzalski Date: Thu, 9 Apr 2015 16:27:33 +0200 Subject: [PATCH 1/4] dropdownItemLabel promoted into scope variable For dropdownSelect and dropdownMenu the dropdownItemLabel is not taken from the isolate scope variable rether than attrs to make the $interpolation of the value possible. --- angular-dropdowns.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/angular-dropdowns.js b/angular-dropdowns.js index 69eee1e..de0ffa7 100644 --- a/angular-dropdowns.js +++ b/angular-dropdowns.js @@ -68,11 +68,12 @@ dd.directive('dropdownSelect', ['DropdownService', scope: { dropdownSelect: '=', dropdownModel: '=', + dropdownItemLabel: '@', dropdownOnchange: '&' }, controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { - $scope.labelField = $attrs.dropdownItemLabel || 'text'; + $scope.labelField = $scope.dropdownItemLabel || 'text'; DropdownService.register($element); @@ -131,11 +132,12 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templat scope: { dropdownMenu: '=', dropdownModel: '=', + dropdownItemLabel: '@', dropdownOnchange: '&' }, controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { - $scope.labelField = $attrs.dropdownItemLabel || 'text'; + $scope.labelField = $scope.dropdownItemLabel || 'text'; var $template = angular.element($templateCache.get('ngDropdowns/templates/dropdownMenu.html')); // Attach this controller to the element's data @@ -233,4 +235,4 @@ dd.factory('DropdownService', ['$document', return service; } ]); -})(window, window.angular); \ No newline at end of file +})(window, window.angular); From 6501d97b0156e7f077dd56657f2d5f69ca088c4d Mon Sep 17 00:00:00 2001 From: James Seppi Date: Thu, 9 Apr 2015 09:51:20 -0500 Subject: [PATCH 2/4] remove unused args --- angular-dropdowns.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/angular-dropdowns.js b/angular-dropdowns.js index de0ffa7..98e5815 100644 --- a/angular-dropdowns.js +++ b/angular-dropdowns.js @@ -72,7 +72,7 @@ dd.directive('dropdownSelect', ['DropdownService', dropdownOnchange: '&' }, - controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { + controller: ['$scope', '$element', function ($scope, $element) { $scope.labelField = $scope.dropdownItemLabel || 'text'; DropdownService.register($element); @@ -136,7 +136,7 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templat dropdownOnchange: '&' }, - controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { + controller: ['$scope', '$element', function ($scope, $element) { $scope.labelField = $scope.dropdownItemLabel || 'text'; var $template = angular.element($templateCache.get('ngDropdowns/templates/dropdownMenu.html')); From 738289e3e2298a106c94bf6b9e9272f3f516ba8a Mon Sep 17 00:00:00 2001 From: James Seppi Date: Thu, 9 Apr 2015 09:51:32 -0500 Subject: [PATCH 3/4] update dist --- dist/angular-dropdowns.js | 12 +++++++----- dist/angular-dropdowns.min.js | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/dist/angular-dropdowns.js b/dist/angular-dropdowns.js index 69eee1e..98e5815 100644 --- a/dist/angular-dropdowns.js +++ b/dist/angular-dropdowns.js @@ -68,11 +68,12 @@ dd.directive('dropdownSelect', ['DropdownService', scope: { dropdownSelect: '=', dropdownModel: '=', + dropdownItemLabel: '@', dropdownOnchange: '&' }, - controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { - $scope.labelField = $attrs.dropdownItemLabel || 'text'; + controller: ['$scope', '$element', function ($scope, $element) { + $scope.labelField = $scope.dropdownItemLabel || 'text'; DropdownService.register($element); @@ -131,11 +132,12 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templat scope: { dropdownMenu: '=', dropdownModel: '=', + dropdownItemLabel: '@', dropdownOnchange: '&' }, - controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { - $scope.labelField = $attrs.dropdownItemLabel || 'text'; + controller: ['$scope', '$element', function ($scope, $element) { + $scope.labelField = $scope.dropdownItemLabel || 'text'; var $template = angular.element($templateCache.get('ngDropdowns/templates/dropdownMenu.html')); // Attach this controller to the element's data @@ -233,4 +235,4 @@ dd.factory('DropdownService', ['$document', return service; } ]); -})(window, window.angular); \ No newline at end of file +})(window, window.angular); diff --git a/dist/angular-dropdowns.min.js b/dist/angular-dropdowns.min.js index ae0d823..53cc509 100644 --- a/dist/angular-dropdowns.min.js +++ b/dist/angular-dropdowns.min.js @@ -1,4 +1,4 @@ /** * @license MIT http://jseppi.mit-license.org/license.html */ -!function(e,o){"use strict";var n=o.module("ngDropdowns",[]);n.run(["$templateCache",function(e){e.put("ngDropdowns/templates/dropdownSelect.html",['
','{{dropdownModel[labelField]}}','","
"].join("")),e.put("ngDropdowns/templates/dropdownSelectItem.html",["
  • ",'',"{{dropdownSelectItem[dropdownItemLabel]}}","",'',"{{dropdownSelectItem[dropdownItemLabel]}}","","
  • "].join("")),e.put("ngDropdowns/templates/dropdownMenu.html",['"].join("")),e.put("ngDropdowns/templates/dropdownMenuItem.html",["
  • ",'',"{{dropdownMenuItem[dropdownItemLabel]}}","",'',"{{dropdownMenuItem[dropdownItemLabel]}}","","
  • "].join(""))}]),n.directive("dropdownSelect",["DropdownService",function(e){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(n,d,t){n.labelField=t.dropdownItemLabel||"text",e.register(d),this.select=function(e){e!==n.dropdownModel&&o.copy(e,n.dropdownModel),n.dropdownOnchange({selected:e})},d.bind("click",function(o){o.stopPropagation(),e.toggleActive(d)}),n.$on("$destroy",function(){e.unregister(d)})}],templateUrl:"ngDropdowns/templates/dropdownSelect.html"}}]),n.directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(e,o,n,d){e.selectItem=function(){e.dropdownSelectItem.href||d.select(e.dropdownSelectItem)}},templateUrl:"ngDropdowns/templates/dropdownSelectItem.html"}}]),n.directive("dropdownMenu",["$parse","$compile","DropdownService","$templateCache",function(e,n,d,t){return{restrict:"A",replace:!1,scope:{dropdownMenu:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(e,r,l){e.labelField=l.dropdownItemLabel||"text";var i=o.element(t.get("ngDropdowns/templates/dropdownMenu.html"));i.data("$dropdownMenuController",this);var p=n(i)(e),c=o.element('
    ');r.replaceWith(c),c.append(r),c.append(p),d.register(p),this.select=function(n){n!==e.dropdownModel&&o.copy(n,e.dropdownModel),e.dropdownOnchange({selected:n})},r.bind("click",function(e){e.stopPropagation(),d.toggleActive(p)}),e.$on("$destroy",function(){d.unregister(p)})}]}}]),n.directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(e,o,n,d){e.selectItem=function(){e.dropdownMenuItem.href||d.select(e.dropdownMenuItem)}},templateUrl:"ngDropdowns/templates/dropdownMenuItem.html"}}]),n.factory("DropdownService",["$document",function(e){var n=e.find("body"),d={},t=[];return n.bind("click",function(){o.forEach(t,function(e){e.removeClass("active")})}),d.register=function(e){t.push(e)},d.unregister=function(e){var o;o=t.indexOf(e),o>-1&&t.splice(o,1)},d.toggleActive=function(e){o.forEach(t,function(o){o!==e&&o.removeClass("active")}),e.toggleClass("active")},d}])}(window,window.angular); \ No newline at end of file +!function(e,o){"use strict";var n=o.module("ngDropdowns",[]);n.run(["$templateCache",function(e){e.put("ngDropdowns/templates/dropdownSelect.html",['
    ','{{dropdownModel[labelField]}}','","
    "].join("")),e.put("ngDropdowns/templates/dropdownSelectItem.html",["
  • ",'',"{{dropdownSelectItem[dropdownItemLabel]}}","",'',"{{dropdownSelectItem[dropdownItemLabel]}}","","
  • "].join("")),e.put("ngDropdowns/templates/dropdownMenu.html",['"].join("")),e.put("ngDropdowns/templates/dropdownMenuItem.html",["
  • ",'',"{{dropdownMenuItem[dropdownItemLabel]}}","",'',"{{dropdownMenuItem[dropdownItemLabel]}}","","
  • "].join(""))}]),n.directive("dropdownSelect",["DropdownService",function(e){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownItemLabel:"@",dropdownOnchange:"&"},controller:["$scope","$element",function(n,d){n.labelField=n.dropdownItemLabel||"text",e.register(d),this.select=function(e){e!==n.dropdownModel&&o.copy(e,n.dropdownModel),n.dropdownOnchange({selected:e})},d.bind("click",function(o){o.stopPropagation(),e.toggleActive(d)}),n.$on("$destroy",function(){e.unregister(d)})}],templateUrl:"ngDropdowns/templates/dropdownSelect.html"}}]),n.directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(e,o,n,d){e.selectItem=function(){e.dropdownSelectItem.href||d.select(e.dropdownSelectItem)}},templateUrl:"ngDropdowns/templates/dropdownSelectItem.html"}}]),n.directive("dropdownMenu",["$parse","$compile","DropdownService","$templateCache",function(e,n,d,t){return{restrict:"A",replace:!1,scope:{dropdownMenu:"=",dropdownModel:"=",dropdownItemLabel:"@",dropdownOnchange:"&"},controller:["$scope","$element",function(e,r){e.labelField=e.dropdownItemLabel||"text";var l=o.element(t.get("ngDropdowns/templates/dropdownMenu.html"));l.data("$dropdownMenuController",this);var p=n(l)(e),i=o.element('
    ');r.replaceWith(i),i.append(r),i.append(p),d.register(p),this.select=function(n){n!==e.dropdownModel&&o.copy(n,e.dropdownModel),e.dropdownOnchange({selected:n})},r.bind("click",function(e){e.stopPropagation(),d.toggleActive(p)}),e.$on("$destroy",function(){d.unregister(p)})}]}}]),n.directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(e,o,n,d){e.selectItem=function(){e.dropdownMenuItem.href||d.select(e.dropdownMenuItem)}},templateUrl:"ngDropdowns/templates/dropdownMenuItem.html"}}]),n.factory("DropdownService",["$document",function(e){var n=e.find("body"),d={},t=[];return n.bind("click",function(){o.forEach(t,function(e){e.removeClass("active")})}),d.register=function(e){t.push(e)},d.unregister=function(e){var o;o=t.indexOf(e),o>-1&&t.splice(o,1)},d.toggleActive=function(e){o.forEach(t,function(o){o!==e&&o.removeClass("active")}),e.toggleClass("active")},d}])}(window,window.angular); \ No newline at end of file From e82693df97315bed1a6292e3b1203d89156f65a7 Mon Sep 17 00:00:00 2001 From: James Seppi Date: Thu, 9 Apr 2015 09:54:38 -0500 Subject: [PATCH 4/4] bump version, add BDomzalski --- bower.json | 5 +++-- package.json | 12 ++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/bower.json b/bower.json index 3dca4a4..a7ba950 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-dropdowns", - "version": "1.0.0", + "version": "1.1.0", "homepage": "https://github.com/jseppi/angular-dropdowns", "authors": [ "James Seppi (http://github.com/jseppi)", @@ -11,7 +11,8 @@ "tlvince", "dinodsaurus", "elishacook", - "alexisbg" + "alexisbg", + "BDomzalski" ], "description": "AngularJS Dropdown Directives", "main": [ diff --git a/package.json b/package.json index 33a2af1..68b329f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-dropdowns", - "version": "1.0.0", + "version": "1.1.0", "author": { "name": "James Seppi", "email": "james.seppi@gmail.com", @@ -23,7 +23,8 @@ "tlvince", "dinodsaurus", "elishacook", - "alexisbg" + "alexisbg", + "BDomzalski" ], "repository": { "type": "git", @@ -37,11 +38,6 @@ "gulp-rename": "^1.2.0", "gulp-rimraf": "^0.1.0", "gulp-uglify": "^0.3.2", - "jshint-stylish": "^0.4.0", - "karma": "^0.12.22" - }, - "engines": { - "node": "0.10.x", - "npm": "1.4.x" + "jshint-stylish": "^0.4.0" } }