diff --git a/dist/angular-chosen.js b/dist/angular-chosen.js index f0037b7..7ae9807 100644 --- a/dist/angular-chosen.js +++ b/dist/angular-chosen.js @@ -1,6 +1,6 @@ /** * angular-chosen-localytics - Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way - * @version v1.4.2 + * @version v1.4.3 * @link http://github.com/leocaseiro/angular-chosen * @license MIT */ @@ -67,8 +67,12 @@ chosen = null; empty = false; initOrUpdate = function() { - var defaultText; + var defaultText, dropListDom; if (chosen) { + dropListDom = $(element.parent()).find("div.chosen-drop"); + if (dropListDom && dropListDom.length > 0 && dropListDom.css("left").indexOf("0") >= 0) { + return; + } return element.trigger('chosen:updated'); } else { $timeout(function() { diff --git a/dist/angular-chosen.min.js b/dist/angular-chosen.min.js index 036845a..d1262d0 100644 --- a/dist/angular-chosen.min.js +++ b/dist/angular-chosen.min.js @@ -1,7 +1,7 @@ /** * angular-chosen-localytics - Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way - * @version v1.4.2 + * @version v1.4.3 * @link http://github.com/leocaseiro/angular-chosen * @license MIT */ -(function(){var e=[].indexOf||function(e){for(var t=0,n=this.length;t=0)return o.$observe(r,function(e){var t;return t=String(l.attr(o.$attr[r])).slice(0,2),p[s(r)]="{{"===t?e:a.$eval(e),S()})}),b=function(){return l.addClass("loading").attr("disabled",!0).trigger("chosen:updated")},v=function(){return l.removeClass("loading"),angular.isDefined(o.disabled)?l.attr("disabled",o.disabled):l.attr("disabled",!1),l.trigger("chosen:updated")},d=null,c=!1,f=function(){var e;return d?l.trigger("chosen:updated"):(t(function(){d=l.chosen(p).data("chosen")}),angular.isObject(d)?e=d.default_text:void 0)},S=function(){return d&&c?l.attr("data-placeholder",d.results_none_found).attr("disabled",!0):l.removeAttr("data-placeholder"),l.trigger("chosen:updated")},u?(g=u.$render,u.$render=function(){return g(),f()},l.on("chosen:hiding_dropdown",function(){return a.$apply(function(){return u.$setTouched()})}),o.multiple&&(w=function(){return u.$viewValue},a.$watch(w,u.$render,!0))):f(),o.$observe("disabled",function(){return l.trigger("chosen:updated")}),o.ngOptions&&u)return h=o.ngOptions.match(r),y=h[7],a.$watchCollection(y,function(e,n){var r;return r=t(function(){return angular.isUndefined(e)?b():(c=i(e),v(),S())})}),a.$on("$destroy",function(e){if("undefined"!=typeof timer&&null!==timer)return t.cancel(timer)})}}}])}).call(this); \ No newline at end of file +(function(){var e=[].indexOf||function(e){for(var t=0,n=this.length;t=0)return o.$observe(r,function(e){var t;return t=String(l.attr(o.$attr[r])).slice(0,2),p[s(r)]="{{"===t?e:a.$eval(e),S()})}),b=function(){return l.addClass("loading").attr("disabled",!0).trigger("chosen:updated")},v=function(){return l.removeClass("loading"),angular.isDefined(o.disabled)?l.attr("disabled",o.disabled):l.attr("disabled",!1),l.trigger("chosen:updated")},d=null,c=!1,f=function(){var e,n;if(d){if(n=$(l.parent()).find("div.chosen-drop"),n&&n.length>0&&n.css("left").indexOf("0")>=0)return;return l.trigger("chosen:updated")}if(t(function(){d=l.chosen(p).data("chosen")}),angular.isObject(d))return e=d.default_text},S=function(){return d&&c?l.attr("data-placeholder",d.results_none_found).attr("disabled",!0):l.removeAttr("data-placeholder"),l.trigger("chosen:updated")},u?(g=u.$render,u.$render=function(){return g(),f()},l.on("chosen:hiding_dropdown",function(){return a.$apply(function(){return u.$setTouched()})}),o.multiple&&(w=function(){return u.$viewValue},a.$watch(w,u.$render,!0))):f(),o.$observe("disabled",function(){return l.trigger("chosen:updated")}),o.ngOptions&&u)return h=o.ngOptions.match(r),y=h[7],a.$watchCollection(y,function(e,n){var r;return r=t(function(){return angular.isUndefined(e)?b():(c=i(e),v(),S())})}),a.$on("$destroy",function(e){if("undefined"!=typeof timer&&null!==timer)return t.cancel(timer)})}}}])}).call(this); \ No newline at end of file diff --git a/example/index.coffee b/example/index.coffee deleted file mode 100644 index 98b3ad0..0000000 --- a/example/index.coffee +++ /dev/null @@ -1,42 +0,0 @@ -angular.module('chosenExampleApp', ['localytics.directives']) - -.config(['$parseProvider', ($parseProvider) -> - $parseProvider.unwrapPromises(true) -]) - -.controller('IndexCtrl', ['$scope', '$q', '$timeout', ($scope, $q, $timeout) -> - - simulateAjax = (result) -> - deferred = $q.defer() - fn = -> deferred.resolve(result) - $timeout fn, 3000 - deferred.promise - - simulateAjax(['grooo', 'wowowowow', 'lakakalakakl', 'yadayada', 'insight', 'delve', 'synergy']).then (result) -> - $scope.optionsFromQuery = result - - $scope.optionsFromQueryAsHash = do -> - result = - win: "Brilliant Escape" - fail: "Untimely Demise" - simulateAjax(result) - - $scope.$watch 'emptyCollection', (empty) -> - $scope.emptyOptions = simulateAjax(if empty then [] else ['look', 'i', 'have', 'data']) - - $scope.directiveOptions = - no_results_text: "SO SORRY" - - $scope.myPets = ['cat'] - $scope.pets = - cat: 'Cat' - dog: 'Dog' - hamster: 'Hamster' - - $timeout -> - $scope.$apply -> $scope.myPets.push('hamster') - , 1000 - - $scope.disabled = true - -]) diff --git a/example/index.html b/example/index.html index fd7b6a5..bc76dc7 100644 --- a/example/index.html +++ b/example/index.html @@ -132,6 +132,12 @@

#179 - inherit-select-class inside ng-if:

+

#59 - Don't scroll to top when selecting multiple items with ctrl

+
+ +
diff --git a/example/index.js b/example/index.js index d925007..7d49b7e 100644 --- a/example/index.js +++ b/example/index.js @@ -39,6 +39,68 @@ dog: 'Dog', hamster: 'Hamster' }; + $scope.state = ['California', 'Arizona']; + $scope.states = { + "AL": "Alabama", + "AK": "Alaska", + "AS": "American Samoa", + "AZ": "Arizona", + "AR": "Arkansas", + "CA": "California", + "CO": "Colorado", + "CT": "Connecticut", + "DE": "Delaware", + "DC": "District Of Columbia", + "FM": "Federated States Of Micronesia", + "FL": "Florida", + "GA": "Georgia", + "GU": "Guam", + "HI": "Hawaii", + "ID": "Idaho", + "IL": "Illinois", + "IN": "Indiana", + "IA": "Iowa", + "KS": "Kansas", + "KY": "Kentucky", + "LA": "Louisiana", + "ME": "Maine", + "MH": "Marshall Islands", + "MD": "Maryland", + "MA": "Massachusetts", + "MI": "Michigan", + "MN": "Minnesota", + "MS": "Mississippi", + "MO": "Missouri", + "MT": "Montana", + "NE": "Nebraska", + "NV": "Nevada", + "NH": "New Hampshire", + "NJ": "New Jersey", + "NM": "New Mexico", + "NY": "New York", + "NC": "North Carolina", + "ND": "North Dakota", + "MP": "Northern Mariana Islands", + "OH": "Ohio", + "OK": "Oklahoma", + "OR": "Oregon", + "PW": "Palau", + "PA": "Pennsylvania", + "PR": "Puerto Rico", + "RI": "Rhode Island", + "SC": "South Carolina", + "SD": "South Dakota", + "TN": "Tennessee", + "TX": "Texas", + "UT": "Utah", + "VT": "Vermont", + "VI": "Virgin Islands", + "VA": "Virginia", + "WA": "Washington", + "WV": "West Virginia", + "WI": "Wisconsin", + "WY": "Wyoming" + }; $timeout(function() { return $scope.$apply(function() { return $scope.myPets.push('hamster'); diff --git a/package.json b/package.json index 6e6ce22..150fcd8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "angular-chosen-localytics", "filename": "chosen.js", "main": "dist/angular-chosen.js", - "version": "1.4.2", + "version": "1.4.3", "description": "Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way", "homepage": "http://github.com/leocaseiro/angular-chosen", "repository": { @@ -40,7 +40,8 @@ "slobo", "lpsBetty", "nike-17", - "vstene" + "vstene", + "frnan" ], "dependencies": { "angular": "^1.5.7", diff --git a/src/chosen.coffee b/src/chosen.coffee index f8ee26a..02dc2ad 100644 --- a/src/chosen.coffee +++ b/src/chosen.coffee @@ -76,7 +76,11 @@ angular.module('localytics.directives').directive 'chosen', ['$timeout', ($timeo initOrUpdate = -> if chosen - element.trigger('chosen:updated') + # Fix #56 Don't scroll to top when selecting multiple items with ctrl + dropListDom = $(element.parent()).find("div.chosen-drop") #uses jQuery instead of Angular. + if dropListDom && dropListDom.length > 0 && dropListDom.css("left").indexOf("0") >= 0 + return + return element.trigger('chosen:updated') else $timeout -> chosen = element.chosen(options).data('chosen')