From c5c1bf6b9235db0362758c093ad3cc42c92a2dee Mon Sep 17 00:00:00 2001 From: James Seppi Date: Tue, 28 Oct 2014 11:33:36 -0500 Subject: [PATCH] just bind to click, other events weren't doing anything --- angular-dropdowns.js | 16 ++++++---------- bower.json | 2 +- dist/angular-dropdowns.js | 16 ++++++---------- dist/angular-dropdowns.min.js | 2 +- 4 files changed, 14 insertions(+), 22 deletions(-) diff --git a/angular-dropdowns.js b/angular-dropdowns.js index bc89224..1351990 100644 --- a/angular-dropdowns.js +++ b/angular-dropdowns.js @@ -54,8 +54,8 @@ dd.run(['$templateCache', function ($templateCache) { }]); -dd.directive('dropdownSelect', ['DropdownService', '$window', - function (DropdownService, $window) { +dd.directive('dropdownSelect', ['DropdownService', + function (DropdownService) { return { restrict: 'A', replace: true, @@ -79,9 +79,7 @@ dd.directive('dropdownSelect', ['DropdownService', '$window', }); }; - // Does not register touchstart events outside of directive scope - var $clickEvent = ('click'||'touchstart' in $window); - $element.bind($clickEvent, function (event) { + $element.bind('click', function (event) { event.stopPropagation(); DropdownService.toggleActive($element); }); @@ -119,8 +117,8 @@ dd.directive('dropdownSelectItem', [ } ]); -dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window', '$templateCache', - function ($parse, $compile, DropdownService, $window, $templateCache) { +dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templateCache', + function ($parse, $compile, DropdownService, $templateCache) { return { restrict: 'A', replace: false, @@ -133,8 +131,6 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window' controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { $scope.labelField = $attrs.dropdownItemLabel || 'text'; - // Does not register touchstart events outside of directive scope. - var $clickEvent = ('click'||'touchstart' in $window); var $template = angular.element($templateCache.get('ngDropdowns/templates/dropdownMenu.html')); // Attach this controller to the element's data $template.data('$dropdownMenuController', this); @@ -157,7 +153,7 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window' }); }; - $element.bind($clickEvent, function (event) { + $element.bind('click', function (event) { event.stopPropagation(); DropdownService.toggleActive(tpl); }); diff --git a/bower.json b/bower.json index f6f6afa..29cf8d3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-dropdowns", - "version": "0.4.0", + "version": "0.4.1", "homepage": "https://github.com/jseppi/angular-dropdowns", "authors": [ "James Seppi (http://github.com/jseppi)", diff --git a/dist/angular-dropdowns.js b/dist/angular-dropdowns.js index bc89224..1351990 100644 --- a/dist/angular-dropdowns.js +++ b/dist/angular-dropdowns.js @@ -54,8 +54,8 @@ dd.run(['$templateCache', function ($templateCache) { }]); -dd.directive('dropdownSelect', ['DropdownService', '$window', - function (DropdownService, $window) { +dd.directive('dropdownSelect', ['DropdownService', + function (DropdownService) { return { restrict: 'A', replace: true, @@ -79,9 +79,7 @@ dd.directive('dropdownSelect', ['DropdownService', '$window', }); }; - // Does not register touchstart events outside of directive scope - var $clickEvent = ('click'||'touchstart' in $window); - $element.bind($clickEvent, function (event) { + $element.bind('click', function (event) { event.stopPropagation(); DropdownService.toggleActive($element); }); @@ -119,8 +117,8 @@ dd.directive('dropdownSelectItem', [ } ]); -dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window', '$templateCache', - function ($parse, $compile, DropdownService, $window, $templateCache) { +dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$templateCache', + function ($parse, $compile, DropdownService, $templateCache) { return { restrict: 'A', replace: false, @@ -133,8 +131,6 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window' controller: ['$scope', '$element', '$attrs', function ($scope, $element, $attrs) { $scope.labelField = $attrs.dropdownItemLabel || 'text'; - // Does not register touchstart events outside of directive scope. - var $clickEvent = ('click'||'touchstart' in $window); var $template = angular.element($templateCache.get('ngDropdowns/templates/dropdownMenu.html')); // Attach this controller to the element's data $template.data('$dropdownMenuController', this); @@ -157,7 +153,7 @@ dd.directive('dropdownMenu', ['$parse', '$compile', 'DropdownService', '$window' }); }; - $element.bind($clickEvent, function (event) { + $element.bind('click', function (event) { event.stopPropagation(); DropdownService.toggleActive(tpl); }); diff --git a/dist/angular-dropdowns.min.js b/dist/angular-dropdowns.min.js index 2bdc149..45f2973 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]}}","","
  • "].join("")),e.put("ngDropdowns/templates/dropdownMenu.html",['"].join("")),e.put("ngDropdowns/templates/dropdownMenuItem.html",['
  • ','',"{{dropdownMenuItem[dropdownItemLabel]}}","","
  • "].join(""))}]),n.directive("dropdownSelect",["DropdownService","$window",function(e,n){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(n,t,d){n.labelField=d.dropdownItemLabel||"text",e.register(t),this.select=function(e){e!==n.dropdownModel&&o.copy(e,n.dropdownModel),n.dropdownOnchange({selected:e})};var r="click";t.bind(r,function(o){o.stopPropagation(),e.toggleActive(t)}),n.$on("$destroy",function(){e.unregister(t)})}],templateUrl:"ngDropdowns/templates/dropdownSelect.html"}}]),n.directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(e,o,n,t){e.selectItem=function(){e.dropdownSelectItem.href||t.select(e.dropdownSelectItem)}},templateUrl:"ngDropdowns/templates/dropdownSelectItem.html"}}]),n.directive("dropdownMenu",["$parse","$compile","DropdownService","$window","$templateCache",function(e,n,t,d,r){return{restrict:"A",replace:!1,scope:{dropdownMenu:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(e,d,l){e.labelField=l.dropdownItemLabel||"text";var i="click",p=o.element(r.get("ngDropdowns/templates/dropdownMenu.html"));p.data("$dropdownMenuController",this);var c=n(p)(e),s=o.element('
    ');d.replaceWith(s),s.append(d),s.append(c),t.register(c),this.select=function(n){n!==e.dropdownModel&&o.copy(n,e.dropdownModel),e.dropdownOnchange({selected:n})},d.bind(i,function(e){e.stopPropagation(),t.toggleActive(c)}),e.$on("$destroy",function(){t.unregister(c)})}]}}]),n.directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(e,o,n,t){e.selectItem=function(){e.dropdownMenuItem.href||t.select(e.dropdownMenuItem)}},templateUrl:"ngDropdowns/templates/dropdownMenuItem.html"}}]),n.factory("DropdownService",["$document",function(e){var n=e.find("body"),t={},d=[];return n.bind("click",function(){o.forEach(d,function(e){e.removeClass("active")})}),t.register=function(e){d.push(e)},t.unregister=function(e){var o;o=d.indexOf(e),o>-1&&d.splice(o,1)},t.toggleActive=function(e){o.forEach(d,function(o){o!==e&&o.removeClass("active")}),e.toggleClass("active")},t}])}(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]}}","","
  • "].join("")),e.put("ngDropdowns/templates/dropdownMenu.html",['"].join("")),e.put("ngDropdowns/templates/dropdownMenuItem.html",['
  • ','',"{{dropdownMenuItem[dropdownItemLabel]}}","","
  • "].join(""))}]),n.directive("dropdownSelect",["DropdownService",function(e){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(n,t,d){n.labelField=d.dropdownItemLabel||"text",e.register(t),this.select=function(e){e!==n.dropdownModel&&o.copy(e,n.dropdownModel),n.dropdownOnchange({selected:e})},t.bind("click",function(o){o.stopPropagation(),e.toggleActive(t)}),n.$on("$destroy",function(){e.unregister(t)})}],templateUrl:"ngDropdowns/templates/dropdownSelect.html"}}]),n.directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(e,o,n,t){e.selectItem=function(){e.dropdownSelectItem.href||t.select(e.dropdownSelectItem)}},templateUrl:"ngDropdowns/templates/dropdownSelectItem.html"}}]),n.directive("dropdownMenu",["$parse","$compile","DropdownService","$templateCache",function(e,n,t,d){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(d.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),t.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(),t.toggleActive(p)}),e.$on("$destroy",function(){t.unregister(p)})}]}}]),n.directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(e,o,n,t){e.selectItem=function(){e.dropdownMenuItem.href||t.select(e.dropdownMenuItem)}},templateUrl:"ngDropdowns/templates/dropdownMenuItem.html"}}]),n.factory("DropdownService",["$document",function(e){var n=e.find("body"),t={},d=[];return n.bind("click",function(){o.forEach(d,function(e){e.removeClass("active")})}),t.register=function(e){d.push(e)},t.unregister=function(e){var o;o=d.indexOf(e),o>-1&&d.splice(o,1)},t.toggleActive=function(e){o.forEach(d,function(o){o!==e&&o.removeClass("active")}),e.toggleClass("active")},t}])}(window,window.angular); \ No newline at end of file