checklist-model
Advanced tools
Comparing version 0.9.0 to 0.10.0
{ | ||
"name": "checklist-model", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "AngularJS directive for list of checkboxes", | ||
@@ -5,0 +5,0 @@ "author": "https://github.com/vitalets", |
@@ -8,2 +8,7 @@ /** | ||
/* commonjs package manager support (eg componentjs) */ | ||
if (typeof module !== "undefined" && typeof exports !== "undefined" && module.exports === exports){ | ||
module.exports = 'checklist-model'; | ||
} | ||
angular.module('checklist-model', []) | ||
@@ -30,3 +35,3 @@ .directive('checklistModel', ['$parse', '$compile', function($parse, $compile) { | ||
return arr; | ||
} | ||
} | ||
@@ -71,3 +76,3 @@ // remove | ||
}; | ||
} else { | ||
@@ -79,4 +84,4 @@ comparator = $parse(attrs.checklistComparator)(scope.$parent); | ||
// watch UI checked change | ||
scope.$watch(attrs.ngModel, function(newValue, oldValue) { | ||
if (newValue === oldValue) { | ||
var unbindModel = scope.$watch(attrs.ngModel, function(newValue, oldValue) { | ||
if (newValue === oldValue) { | ||
return; | ||
@@ -97,4 +102,4 @@ } | ||
// watches for value change of checklistValue (Credit to @blingerson) | ||
scope.$watch(getChecklistValue, function(newValue, oldValue) { | ||
// watches for value change of checklistValue | ||
var unbindCheckListValue = scope.$watch(getChecklistValue, function(newValue, oldValue) { | ||
if( newValue != oldValue && angular.isDefined(oldValue) && scope[attrs.ngModel] === true ) { | ||
@@ -105,8 +110,16 @@ var current = checklistModelGetter(scope.$parent); | ||
} | ||
}); | ||
}, true); | ||
var unbindDestroy = scope.$on('$destroy', destroy); | ||
function destroy() { | ||
unbindModel(); | ||
unbindCheckListValue(); | ||
unbindDestroy(); | ||
} | ||
function getChecklistValue() { | ||
return attrs.checklistValue ? $parse(attrs.checklistValue)(scope.$parent) : attrs.value; | ||
} | ||
function setValueInChecklistModel(value, checked) { | ||
@@ -121,3 +134,3 @@ var current = checklistModelGetter(scope.$parent); | ||
} | ||
} | ||
@@ -124,0 +137,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"homepage": "http://vitalets.github.io/checklist-model", | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -36,8 +36,12 @@ ![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) | ||
* JSFiddle required example: http://jsfiddle.net/beradrian/7wt9q1ev/ | ||
* Plunkr example: http://plnkr.co/edit/pZLF0KesMDnIap0eCfSG?p=preview | ||
* Plunkr example: http://plnkr.co/edit/0UrMwtiNQxJJbVWnYgSt?p=preview | ||
* Plunkr example for [tree list](http://plnkr.co/edit/QPLk98pCljp8dFtptSYz?p=preview) | ||
## Installation | ||
1. Download [latest release](https://github.com/vitalets/checklist-model/releases) or use bower `bower install checklist-model` or install from npm `npm install checklist-model` | ||
2. Add to app dependencies: | ||
1. Include the directive in your code | ||
1. Download [latest release](https://github.com/vitalets/checklist-model/releases) *or* | ||
2. Use bower `bower install checklist-model` *or* | ||
3. Install from npm `npm install checklist-model` | ||
2. If your JavaScript file is not generated from dependencies, then you must include it in your HTML `<script src='checklist-model.js'></script>` | ||
3. Add to app dependencies: | ||
````js | ||
@@ -68,3 +72,3 @@ var app = angular.module("app", ["checklist-model"]); | ||
### How to make a new release | ||
1. Change the version number in `bower.json` and `package.json` | ||
1. Change the version number in `bower.json` and `package.json` (if not already changed - check the version number against the latest release in Github) | ||
2. Create a new [release](https://github.com/vitalets/checklist-model/releases) in github with the same name for tag and title as the version number (e.g. `1.0.0`). Do not forget to include the changelog in the release description. | ||
@@ -71,0 +75,0 @@ 3. Run `npm publish` to publish the new version to npm |
90639
15934
1050
77