Socket
Socket
Sign inDemoInstall

checklist-model

Package Overview
Dependencies
1
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.8.0 to 0.9.0

docs/blocks/array-dynamic/ctrl.js

2

bower.json
{
"name": "checklist-model",
"version": "0.8.0",
"version": "0.9.0",
"description": "AngularJS directive for list of checkboxes",

@@ -5,0 +5,0 @@ "author": "https://github.com/vitalets",

@@ -53,10 +53,8 @@ /**

// getter / setter for original model
var getter = $parse(checklistModel);
var setter = getter.assign;
// getter for original model
var checklistModelGetter = $parse(checklistModel);
var checklistChange = $parse(attrs.checklistChange);
var checklistBeforeChange = $parse(attrs.checklistBeforeChange);
var ngModelGetter = $parse(attrs.ngModel);
// value added to list
var value = attrs.checklistValue ? $parse(attrs.checklistValue)(scope.$parent) : attrs.value;

@@ -82,10 +80,10 @@

return;
}
}
if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
scope[attrs.ngModel] = contains(getter(scope.$parent), value, comparator);
ngModelGetter.assign(scope, contains(checklistModelGetter(scope.$parent), getChecklistValue(), comparator));
return;
}
setValueInChecklistModel(value, newValue);
setValueInChecklistModel(getChecklistValue(), newValue);

@@ -97,9 +95,22 @@ if (checklistChange) {

// watches for value change of checklistValue (Credit to @blingerson)
scope.$watch(getChecklistValue, function(newValue, oldValue) {
if( newValue != oldValue && angular.isDefined(oldValue) && scope[attrs.ngModel] === true ) {
var current = checklistModelGetter(scope.$parent);
checklistModelGetter.assign(scope.$parent, remove(current, oldValue, comparator));
checklistModelGetter.assign(scope.$parent, add(current, newValue, comparator));
}
});
function getChecklistValue() {
return attrs.checklistValue ? $parse(attrs.checklistValue)(scope.$parent) : attrs.value;
}
function setValueInChecklistModel(value, checked) {
var current = getter(scope.$parent);
if (angular.isFunction(setter)) {
var current = checklistModelGetter(scope.$parent);
if (angular.isFunction(checklistModelGetter.assign)) {
if (checked === true) {
setter(scope.$parent, add(current, value, comparator));
checklistModelGetter.assign(scope.$parent, add(current, value, comparator));
} else {
setter(scope.$parent, remove(current, value, comparator));
checklistModelGetter.assign(scope.$parent, remove(current, value, comparator));
}

@@ -113,6 +124,6 @@ }

if (checklistBeforeChange && (checklistBeforeChange(scope) === false)) {
setValueInChecklistModel(value, scope[attrs.ngModel]);
setValueInChecklistModel(getChecklistValue(), ngModelGetter(scope));
return;
}
scope[attrs.ngModel] = contains(newArr, value, comparator);
ngModelGetter.assign(scope, contains(newArr, getChecklistValue(), comparator));
}

@@ -135,5 +146,2 @@

compile: function(tElement, tAttrs) {
if ((tElement[0].tagName !== 'INPUT' || tAttrs.type !== 'checkbox') && (tElement[0].tagName !== 'MD-CHECKBOX') && (!tAttrs.btnCheckbox)) {
throw 'checklist-model should be applied to `input[type="checkbox"]` or `md-checkbox`.';
}

@@ -140,0 +148,0 @@ if (!tAttrs.checklistValue && !tAttrs.value) {

@@ -5,3 +5,3 @@ {

"license": "MIT",
"version": "0.8.0",
"version": "0.9.0",
"homepage": "http://vitalets.github.io/checklist-model",

@@ -8,0 +8,0 @@ "author": {

![Bower](https://img.shields.io/bower/v/checklist-model.svg) [![NPM](https://img.shields.io/npm/v/checklist-model.svg)](https://www.npmjs.com/package/checklist-model) ![License](https://img.shields.io/npm/l/checklist-model.svg)
[![NPM](https://nodei.co/npm/checklist-model.png)](https://nodei.co/npm/checklist-model/)
# checklist-model

@@ -28,7 +30,9 @@ AngularJS directive for list of checkboxes

* If you're using `track by` you must specify the same thing for `checklist-value` too. See [#46](https://github.com/vitalets/checklist-model/issues/46).
* If you're also using `ngModel`, please keep in mind that the state of the checkbok is initialized with the value from `checklistModel`, not with the one from `ngModel`. Afterwards the two will be kept in sync, but initially, these two can be conflicting, so only `checklistModel` is used. See the entire discussion at [#104](https://github.com/vitalets/checklist-model/issues/104).
Please, try out
* live demo: http://vitalets.github.io/checklist-model
* Jsfiddle: http://jsfiddle.net/Ebv3p/2/
* Plunkr example (more advanced): http://plnkr.co/edit/pZLF0KesMDnIap0eCfSG?p=preview
* Live demo: http://vitalets.github.io/checklist-model
* JsFiddle basic example (use this to report any issue): http://jsfiddle.net/beradrian/fjoLy5sq/
* JSFiddle required example: http://jsfiddle.net/beradrian/7wt9q1ev/
* Plunkr example: http://plnkr.co/edit/pZLF0KesMDnIap0eCfSG?p=preview
* Plunkr example for [tree list](http://plnkr.co/edit/QPLk98pCljp8dFtptSYz?p=preview)

@@ -47,3 +51,3 @@

Please keep in mind to also create a Plunkr or JSFiddle example. This will greatly help us in assisting you and you can use one of the existing examples and fork it.
Please keep in mind to also add a Plunkr or JSFiddle example. This will greatly help us in assisting you and you can use one of the existing examples and fork it.

@@ -50,0 +54,0 @@ ## Development

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc