angular-chosen-localytics
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "angular-chosen-localytics", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -1,1 +0,1 @@ | ||
console.warn('the file ./chosen.js is deprecated, you must include ./dist/angular-chosen.js or ./dist/angular-chosen.min.js instead'); | ||
console.warn('the file ./chosen.js is deprecated, you must include ./dist/angular-chosen.js or ./dist/angular-chosen.min.js instead'); |
/** | ||
* angular-chosen-localytics - Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way | ||
* @version v1.2.0 | ||
* @version v1.2.1 | ||
* @link http://github.com/leocaseiro/angular-chosen | ||
@@ -15,3 +15,3 @@ * @license MIT | ||
var CHOSEN_OPTION_WHITELIST, NG_OPTIONS_REGEXP, isEmpty, snakeCase; | ||
NG_OPTIONS_REGEXP = /^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/; | ||
NG_OPTIONS_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/; | ||
CHOSEN_OPTION_WHITELIST = ['noResultsText', 'allowSingleDeselect', 'disableSearchThreshold', 'disableSearch', 'enableSplitWordSearch', 'inheritSelectClasses', 'maxSelectedOptions', 'placeholderTextMultiple', 'placeholderTextSingle', 'searchContains', 'singleBackstrokeDelete', 'displayDisabledOptions', 'displaySelectedOptions', 'width']; | ||
@@ -41,4 +41,5 @@ snakeCase = function(input) { | ||
link: function(scope, element, attr, ngModel) { | ||
var chosen, defaultText, disableWithMessage, empty, initOrUpdate, match, options, origRender, removeEmptyMessage, startLoading, stopLoading, valuesExpr, viewWatch; | ||
var chosen, empty, initOrUpdate, match, options, origRender, startLoading, stopLoading, updateMessage, valuesExpr, viewWatch; | ||
scope.disabledValuesHistory = scope.disabledValuesHistory ? scope.disabledValuesHistory : []; | ||
element = $(element); | ||
element.addClass('localytics-chosen'); | ||
@@ -48,48 +49,41 @@ options = scope.$eval(attr.chosen) || {}; | ||
if (indexOf.call(CHOSEN_OPTION_WHITELIST, key) >= 0) { | ||
return options[snakeCase(key)] = String(element.attr(attr.$attr[key])).slice(0, 2) === '{{' ? value : scope.$eval(value); | ||
return attr.$observe(key, function(value) { | ||
options[snakeCase(key)] = String(element.attr(attr.$attr[key])).slice(0, 2) === '{{' ? value : scope.$eval(value); | ||
return updateMessage(); | ||
}); | ||
} | ||
}); | ||
startLoading = function() { | ||
var disabledValueOfElement, elementAlreadyExists; | ||
disabledValueOfElement = {}; | ||
elementAlreadyExists = false; | ||
angular.forEach(scope.disabledValuesHistory, function(data) { | ||
if (data.hasOwnProperty(element.context.id)) { | ||
data[element.context.id] = element.context.disabled; | ||
elementAlreadyExists = true; | ||
} | ||
}); | ||
if (!elementAlreadyExists) { | ||
disabledValueOfElement[element.context.id] = element.context.disabled; | ||
scope.disabledValuesHistory.push(disabledValueOfElement); | ||
} | ||
return element.addClass('loading').attr('disabled', true).trigger('chosen:updated'); | ||
}; | ||
stopLoading = function() { | ||
var disabledValue; | ||
disabledValue = false; | ||
angular.forEach(scope.disabledValuesHistory, function(data) { | ||
disabledValue = data.hasOwnProperty(element.context.id) ? data[element.context.id] : disabledValue; | ||
}); | ||
return element.removeClass('loading').attr('disabled', disabledValue).trigger('chosen:updated'); | ||
element.removeClass('loading'); | ||
if (angular.isDefined(attr.disabled)) { | ||
element.attr('disabled', attr.disabled); | ||
} else { | ||
element.attr('disabled', false); | ||
} | ||
return element.trigger('chosen:updated'); | ||
}; | ||
chosen = null; | ||
defaultText = null; | ||
empty = false; | ||
initOrUpdate = function() { | ||
var defaultText; | ||
if (chosen) { | ||
return element.trigger('chosen:updated'); | ||
} else { | ||
chosen = element.chosen(options); | ||
return defaultText = chosen.default_text; | ||
chosen = element.chosen(options).data('chosen'); | ||
if (angular.isObject(chosen)) { | ||
return defaultText = chosen.default_text; | ||
} | ||
} | ||
}; | ||
removeEmptyMessage = function() { | ||
empty = false; | ||
return element.attr('data-placeholder', defaultText).trigger('chosen:updated'); | ||
updateMessage = function() { | ||
if (empty) { | ||
element.attr('data-placeholder', chosen.results_none_found).attr('disabled', true); | ||
} else { | ||
element.removeAttr('data-placeholder'); | ||
} | ||
return element.trigger('chosen:updated'); | ||
}; | ||
disableWithMessage = function() { | ||
empty = true; | ||
return element.attr('data-placeholder', chosen.results_none_found).attr('disabled', true).trigger('chosen:updated'); | ||
}; | ||
if (ngModel) { | ||
@@ -122,9 +116,5 @@ origRender = ngModel.$render; | ||
} else { | ||
if (empty) { | ||
removeEmptyMessage(); | ||
} | ||
empty = isEmpty(newVal); | ||
stopLoading(); | ||
if (isEmpty(newVal) && !attr.allowEmptyResultsList) { | ||
return disableWithMessage(); | ||
} | ||
return updateMessage(); | ||
} | ||
@@ -131,0 +121,0 @@ }); |
/** | ||
* angular-chosen-localytics - Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way | ||
* @version v1.2.0 | ||
* @version v1.2.1 | ||
* @link http://github.com/leocaseiro/angular-chosen | ||
* @license MIT | ||
*/ | ||
(function(){var e=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};angular.module("localytics.directives",[]),angular.module("localytics.directives").directive("chosen",["$timeout",function(t){var r,n,i,a;return n=/^\s*(.*?)(?:\s+as\s+(.*?))?(?:\s+group\s+by\s+(.*))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+(.*?)(?:\s+track\s+by\s+(.*?))?$/,r=["noResultsText","allowSingleDeselect","disableSearchThreshold","disableSearch","enableSplitWordSearch","inheritSelectClasses","maxSelectedOptions","placeholderTextMultiple","placeholderTextSingle","searchContains","singleBackstrokeDelete","displayDisabledOptions","displaySelectedOptions","width"],a=function(e){return e.replace(/[A-Z]/g,function(e){return"_"+e.toLowerCase()})},i=function(e){var t;if(angular.isArray(e))return 0===e.length;if(angular.isObject(e))for(t in e)if(e.hasOwnProperty(t))return!1;return!0},{restrict:"A",require:"?ngModel",priority:1,link:function(s,l,o,d){var u,c,h,f,g,p,y,b,v,$,w,x,m;return s.disabledValuesHistory=s.disabledValuesHistory?s.disabledValuesHistory:[],l.addClass("localytics-chosen"),y=s.$eval(o.chosen)||{},angular.forEach(o,function(t,n){return e.call(r,n)>=0?y[a(n)]="{{"===String(l.attr(o.$attr[n])).slice(0,2)?t:s.$eval(t):void 0}),$=function(){var e,t;return e={},t=!1,angular.forEach(s.disabledValuesHistory,function(e){e.hasOwnProperty(l.context.id)&&(e[l.context.id]=l.context.disabled,t=!0)}),t||(e[l.context.id]=l.context.disabled,s.disabledValuesHistory.push(e)),l.addClass("loading").attr("disabled",!0).trigger("chosen:updated")},w=function(){var e;return e=!1,angular.forEach(s.disabledValuesHistory,function(t){e=t.hasOwnProperty(l.context.id)?t[l.context.id]:e}),l.removeClass("loading").attr("disabled",e).trigger("chosen:updated")},u=null,c=null,f=!1,g=function(){return u?l.trigger("chosen:updated"):(u=l.chosen(y),c=u.default_text)},v=function(){return f=!1,l.attr("data-placeholder",c).trigger("chosen:updated")},h=function(){return f=!0,l.attr("data-placeholder",u.results_none_found).attr("disabled",!0).trigger("chosen:updated")},d?(b=d.$render,d.$render=function(){return b(),g()},o.multiple&&(m=function(){return d.$viewValue},s.$watch(m,d.$render,!0))):g(),o.$observe("disabled",function(){return l.trigger("chosen:updated")}),o.ngOptions&&d?(p=o.ngOptions.match(n),x=p[7],s.$watchCollection(x,function(e,r){var n;return n=t(function(){return angular.isUndefined(e)?$():(f&&v(),w(),i(e)&&!o.allowEmptyResultsList?h():void 0)})}),s.$on("$destroy",function(e){return"undefined"!=typeof timer&&null!==timer?t.cancel(timer):void 0})):void 0}}}])}).call(this); | ||
(function(){var e=[].indexOf||function(e){for(var t=0,r=this.length;r>t;t++)if(t in this&&this[t]===e)return t;return-1};angular.module("localytics.directives",[]),angular.module("localytics.directives").directive("chosen",["$timeout",function(t){var r,n,i,a;return n=/^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?(?:\s+group\s+by\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w]*)|(?:\(\s*([\$\w][\$\w]*)\s*,\s*([\$\w][\$\w]*)\s*\)))\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?$/,r=["noResultsText","allowSingleDeselect","disableSearchThreshold","disableSearch","enableSplitWordSearch","inheritSelectClasses","maxSelectedOptions","placeholderTextMultiple","placeholderTextSingle","searchContains","singleBackstrokeDelete","displayDisabledOptions","displaySelectedOptions","width"],a=function(e){return e.replace(/[A-Z]/g,function(e){return"_"+e.toLowerCase()})},i=function(e){var t;if(angular.isArray(e))return 0===e.length;if(angular.isObject(e))for(t in e)if(e.hasOwnProperty(t))return!1;return!0},{restrict:"A",require:"?ngModel",priority:1,link:function(s,l,o,d){var u,c,f,h,g,p,v,b,y,S,w;return s.disabledValuesHistory=s.disabledValuesHistory?s.disabledValuesHistory:[],l=$(l),l.addClass("localytics-chosen"),g=s.$eval(o.chosen)||{},angular.forEach(o,function(t,n){return e.call(r,n)>=0?o.$observe(n,function(e){return g[a(n)]="{{"===String(l.attr(o.$attr[n])).slice(0,2)?e:s.$eval(e),y()}):void 0}),v=function(){return l.addClass("loading").attr("disabled",!0).trigger("chosen:updated")},b=function(){return l.removeClass("loading"),angular.isDefined(o.disabled)?l.attr("disabled",o.disabled):l.attr("disabled",!1),l.trigger("chosen:updated")},u=null,c=!1,f=function(){var e;return u?l.trigger("chosen:updated"):(u=l.chosen(g).data("chosen"),angular.isObject(u)?e=u.default_text:void 0)},y=function(){return c?l.attr("data-placeholder",u.results_none_found).attr("disabled",!0):l.removeAttr("data-placeholder"),l.trigger("chosen:updated")},d?(p=d.$render,d.$render=function(){return p(),f()},o.multiple&&(w=function(){return d.$viewValue},s.$watch(w,d.$render,!0))):f(),o.$observe("disabled",function(){return l.trigger("chosen:updated")}),o.ngOptions&&d?(h=o.ngOptions.match(n),S=h[7],s.$watchCollection(S,function(e,r){var n;return n=t(function(){return angular.isUndefined(e)?v():(c=i(e),b(),y())})}),s.$on("$destroy",function(e){return"undefined"!=typeof timer&&null!==timer?t.cancel(timer):void 0})):void 0}}}])}).call(this); |
{ | ||
"name": "angular-chosen-localytics", | ||
"filename": "dist/angular-chosen.min.js", | ||
"version": "1.2.0", | ||
"filename": "chosen.js", | ||
"version": "1.2.1", | ||
"description": "Angular Chosen directive is an AngularJS Directive that brings the Chosen jQuery in a Angular way", | ||
@@ -39,7 +39,9 @@ "homepage": "http://github.com/leocaseiro/angular-chosen", | ||
"Odi55555", | ||
"slobo" | ||
"slobo", | ||
"nike-17", | ||
"vstene" | ||
], | ||
"dependencies": { | ||
"jquery": "^2.0.3", | ||
"chosen": "^1.1.0", | ||
"chosen-npm": "^1.4.2", | ||
"angular": "^1.2.0" | ||
@@ -46,0 +48,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
Angular Chosen Localytics [![Bower](https://img.shields.io/bower/v/angular-chosen-localytics.svg)](https://github.com/leocaseiro/angular-chosen) | ||
Angular Chosen Localytics [![bower](https://img.shields.io/badge/bower-v1.2.0-brightgreen.svg)](https://github.com/leocaseiro/angular-chosen) [![npm](https://img.shields.io/badge/npm-v1.2.0-brightgreen.svg)](https://www.npmjs.com/package/angular-chosen-localytics) | ||
============== | ||
@@ -12,10 +12,24 @@ | ||
# Examples Demo Page | ||
[/example/index.html](http://htmlpreview.github.io/?https://github.com/leocaseiro/angular-chosen/blob/master/example/index.html) | ||
# [Full Documentation with Examples](http://leocaseiro.github.io/angular-chosen/) | ||
## Installation | ||
## Installation (npm or bower) | ||
Via bower | ||
$ bower install angular-chosen-localytics --save | ||
Via npm | ||
$ npm install angular-chosen-localytics --save | ||
Or download zip file | ||
[Download v1.2.0](https://github.com/leocaseiro/angular-chosen/archive/1.2.0.zip) | ||
## Yeoman or Bower install | ||
@@ -22,0 +36,0 @@ If you use Yeoman or Bower install, you need to rename the `chosen.jquery.js` or the `chosen.proto.js` to `chosen.js`. Otherwise Chosen won't be included in your `index.html`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138
90228
1757
+ Addedchosen-npm@^1.4.2
+ Addedchosen-npm@1.4.2(transitive)
- Removedchosen@^1.1.0