diff --git a/dist/angular-dropdowns.js b/dist/angular-dropdowns.js index e9649e0..72e8702 100644 --- a/dist/angular-dropdowns.js +++ b/dist/angular-dropdowns.js @@ -133,7 +133,7 @@ angular.module('ngDropdowns', []).directive('dropdownSelect', [ var index; index = _dropdowns.indexOf(ddEl); if (index > -1) { - _dropdowns.splice(index, -1); + _dropdowns.splice(index, 1); } }; service.toggleActive = function(ddEl) { diff --git a/dist/angular-dropdowns.min.js b/dist/angular-dropdowns.min.js index b9768f1..f817f68 100644 --- a/dist/angular-dropdowns.min.js +++ b/dist/angular-dropdowns.min.js @@ -1 +1 @@ -angular.module("ngDropdowns",[]).directive("dropdownSelect",["DropdownService",function(a){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(b,c,d){b.labelField=null!=d.dropdownItemLabel?d.dropdownItemLabel:"text",a.register(c),this.select=function(a){a!==b.dropdownModel&&angular.copy(a,b.dropdownModel),b.dropdownOnchange({selected:a})},c.bind("click",function(b){b.stopPropagation(),a.toggleActive(c)}),b.$on("$destroy",function(){a.unregister(c)})}],template:"
\n {{dropdownModel[labelField]}}\n \n
"}}]).directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(a,b,c,d){a.selectItem=function(){a.dropdownSelectItem.href||d.select(a.dropdownSelectItem)}},template:"
  • \n \n {{dropdownSelectItem[dropdownItemLabel]}}\n \n
  • "}}]).directive("dropdownMenu",["$parse","$compile","DropdownService",function(a,b,c){var d;return d="",{restrict:"A",replace:!1,scope:{dropdownMenu:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(a,e,f){var g,h,i;a.labelField=null!=f.dropdownItemLabel?f.dropdownItemLabel:"text",g=angular.element(d),g.data("$dropdownMenuController",this),i=b(g)(a),h=angular.element("
    "),e.replaceWith(h),h.append(e),h.append(i),c.register(i),this.select=function(b){b!==a.dropdownModel&&angular.copy(b,a.dropdownModel),a.dropdownOnchange({selected:b})},e.bind("click",function(a){a.stopPropagation(),c.toggleActive(i)}),a.$on("$destroy",function(){c.unregister(i)})}]}}]).directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(a,b,c,d){a.selectItem=function(){a.dropdownMenuItem.href||d.select(a.dropdownMenuItem)}},template:"
  • \n \n {{dropdownMenuItem[dropdownItemLabel]}}\n \n
  • "}}]).factory("DropdownService",["$document",function(a){var b,c,d;return c={},d=[],b=a.find("body"),b.bind("click",function(){return angular.forEach(d,function(a){a.removeClass("active")})}),c.register=function(a){d.push(a)},c.unregister=function(a){var b;b=d.indexOf(a),b>-1&&d.splice(b,-1)},c.toggleActive=function(a){angular.forEach(d,function(b){b!==a&&b.removeClass("active")}),a.toggleClass("active")},c}]); \ No newline at end of file +angular.module("ngDropdowns",[]).directive("dropdownSelect",["DropdownService",function(a){return{restrict:"A",replace:!0,scope:{dropdownSelect:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(b,c,d){b.labelField=null!=d.dropdownItemLabel?d.dropdownItemLabel:"text",a.register(c),this.select=function(a){a!==b.dropdownModel&&angular.copy(a,b.dropdownModel),b.dropdownOnchange({selected:a})},c.bind("click",function(b){b.stopPropagation(),a.toggleActive(c)}),b.$on("$destroy",function(){a.unregister(c)})}],template:"
    \n {{dropdownModel[labelField]}}\n \n
    "}}]).directive("dropdownSelectItem",[function(){return{require:"^dropdownSelect",replace:!0,scope:{dropdownItemLabel:"=",dropdownSelectItem:"="},link:function(a,b,c,d){a.selectItem=function(){a.dropdownSelectItem.href||d.select(a.dropdownSelectItem)}},template:"
  • \n \n {{dropdownSelectItem[dropdownItemLabel]}}\n \n
  • "}}]).directive("dropdownMenu",["$parse","$compile","DropdownService",function(a,b,c){var d;return d="",{restrict:"A",replace:!1,scope:{dropdownMenu:"=",dropdownModel:"=",dropdownOnchange:"&"},controller:["$scope","$element","$attrs",function(a,e,f){var g,h,i;a.labelField=null!=f.dropdownItemLabel?f.dropdownItemLabel:"text",g=angular.element(d),g.data("$dropdownMenuController",this),i=b(g)(a),h=angular.element("
    "),e.replaceWith(h),h.append(e),h.append(i),c.register(i),this.select=function(b){b!==a.dropdownModel&&angular.copy(b,a.dropdownModel),a.dropdownOnchange({selected:b})},e.bind("click",function(a){a.stopPropagation(),c.toggleActive(i)}),a.$on("$destroy",function(){c.unregister(i)})}]}}]).directive("dropdownMenuItem",[function(){return{require:"^dropdownMenu",replace:!0,scope:{dropdownMenuItem:"=",dropdownItemLabel:"="},link:function(a,b,c,d){a.selectItem=function(){a.dropdownMenuItem.href||d.select(a.dropdownMenuItem)}},template:"
  • \n \n {{dropdownMenuItem[dropdownItemLabel]}}\n \n
  • "}}]).factory("DropdownService",["$document",function(a){var b,c,d;return c={},d=[],b=a.find("body"),b.bind("click",function(){return angular.forEach(d,function(a){a.removeClass("active")})}),c.register=function(a){d.push(a)},c.unregister=function(a){var b;b=d.indexOf(a),b>-1&&d.splice(b,1)},c.toggleActive=function(a){angular.forEach(d,function(b){b!==a&&b.removeClass("active")}),a.toggleClass("active")},c}]); \ No newline at end of file diff --git a/scripts/dropdowns.js b/scripts/dropdowns.js index e9649e0..72e8702 100644 --- a/scripts/dropdowns.js +++ b/scripts/dropdowns.js @@ -133,7 +133,7 @@ angular.module('ngDropdowns', []).directive('dropdownSelect', [ var index; index = _dropdowns.indexOf(ddEl); if (index > -1) { - _dropdowns.splice(index, -1); + _dropdowns.splice(index, 1); } }; service.toggleActive = function(ddEl) { diff --git a/src/dropdowns.coffee b/src/dropdowns.coffee index de96d32..5747f30 100644 --- a/src/dropdowns.coffee +++ b/src/dropdowns.coffee @@ -185,7 +185,7 @@ angular.module('ngDropdowns', []) service.unregister = (ddEl) -> index = _dropdowns.indexOf(ddEl) - _dropdowns.splice(index, -1) if index > -1 + _dropdowns.splice(index, 1) if index > -1 return service.toggleActive = (ddEl) ->