diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..04ba039
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+# EditorConfig helps developers define and maintain consistent
+# coding styles between different editors and IDEs
+# editorconfig.org
+
+root = true
+
+[*]
+
+# Change these settings to your own preference
+indent_style = space
+indent_size = 2
+
+# We recommend you to keep these unchanged
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+
+[*.md]
+trim_trailing_whitespace = false
diff --git a/.jshintrc b/.jshintrc
index 701d222..15b0538 100644
--- a/.jshintrc
+++ b/.jshintrc
@@ -20,11 +20,10 @@
"noarg" : true,
"noempty" : true,
"nonew" : true,
- "quotmark" : "double",
"regexp" : true,
"smarttabs": true,
"strict" : true,
"trailing" : true,
"undef" : true,
"unused" : "vars"
-}
\ No newline at end of file
+}
diff --git a/Gruntfile.js b/Gruntfile.js
new file mode 100644
index 0000000..7aec975
--- /dev/null
+++ b/Gruntfile.js
@@ -0,0 +1,70 @@
+'use_strict';
+
+module.exports = function(grunt) {
+ grunt.initConfig({
+ pkg: grunt.file.readJSON('package.json'),
+ bump: {
+ options: {
+ files: ['package.json', 'bower.json'],
+ commit: false,
+ push: false,
+ commitMessage: 'Release v%VERSION%',
+ commitFiles: ['package.json', 'bower.json']
+ }
+ },
+ cssmin: {
+ style: {
+ files: {
+ 'dist/ez-checkbox.min.css': ['dist/ez-checkbox.css']
+ }
+ }
+ },
+ jshint: {
+ options: {
+ jshintrc: '.jshintrc'
+ },
+ src: {
+ files: {
+ src: ['src/**/*.js', 'test/**/*.js']
+ },
+ }
+ },
+ less: {
+ dist: {
+ files: {
+ 'dist/ez-checkbox.css': 'src/*.less'
+ }
+ }
+ },
+ uglify: {
+ options: {
+ mangle: true,
+ compile: true,
+ compress: true
+ },
+ dist: {
+ files: {
+ 'dist/ez-checkbox.min.js': ['src/**/*.js']
+ }
+ }
+ },
+ watch: {
+ all: {
+ files: ['Gruntfile.js', 'src/*.js'],
+ tasks: ['default'],
+ options: {
+ livereload: 1676,
+ }
+ }
+ }
+ });
+
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-contrib-uglify');
+ grunt.loadNpmTasks('grunt-contrib-watch');
+ grunt.loadNpmTasks('grunt-contrib-less');
+ grunt.loadNpmTasks('grunt-contrib-cssmin');
+ grunt.loadNpmTasks('grunt-bump');
+
+ grunt.registerTask('default', ['jshint', 'less', 'uglify', 'cssmin']);
+};
diff --git a/LICENSE b/LICENSE
index d6f187c..d713e44 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2014 Sebastian Hammerl, Getslash GmbH
+Copyright (c) 2014 Sebastian Hammerl, Getslash GmbH, Joris de Wit
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
\ No newline at end of file
+SOFTWARE.
diff --git a/README.md b/README.md
index 442c8e1..b038047 100644
--- a/README.md
+++ b/README.md
@@ -1,79 +1,38 @@
-angular-bootstrap-checkbox
-==========================
+ez-checkbox
+===========
-A checkbox for AngularJS styled to fit the Twitter Bootstrap standard design
+A better checkbox for AngularJS.
-Screenshot:
-
-
-
-### Description:
-
-The standard checkboxes which use the input HTML element just don't look good in combination with Bootstrap.
-
-Surprisingly, I could not find any nice looking, simple checkbox, so I built one. It is based on a button and Glyphicons which behaves like a normal checkbox.
-
-The angular-bootstrap-checkbox is compatible to the use of the original AngularJS input[checkbox], with one minor change: while the original implementation allows an "uninitialized" or other then defined state of the model this one forces "false" or "ng-false-value" (not checked) when not set to "true" or "ng-true-value".
-
-### Installation via Bower:
-
-```
-$ bower install angular-bootstrap-checkbox --save
-```
-
-### Usage:
-
-Add "ui.checkbox" to your modules list. Then you can use it like AngularJS input[checkbox]:
-
-```
-
-```
-
-Additionally you can set the size:
+##Features
+- Inverse selection (show check on falsy value)
+- Non boolean true/false values
+- Easily transclude a clickable label
+##Installation
+- run `bower install ez-checkbox`
+- add `ez.checkbox` to your applications list of modules
+- add sources to your html
+```html
+
+
```
- (Normal size, corresponds to 'btn-xs')
- (Large, corresponds to 'btn-sm')
- (Larger, corresponds to Button default size)
- (Largest, corresponds to 'btn-lg')
-```
-
-
-And also style the checkboxes like Bootstrap buttons:
-
-```
- (Looks like primary button)
- (Looks like success button)
- (Looks like info button)
- (Looks like warning button)
- (Looks like danger button)
-```
+##Requirements
+Font Awesome.
-
+##Demo
+See Live Demo
-See index.html and app.js for examples and how it works.
-
-### Testing:
-
-Start web server e.g. via Python:
-```
-$ python -m SimpleHTTPServer 8000
-```
-
-Start Karma E2E tests (has to be installed globally before):
-```
-$ karma start
+##Usage
+```html
+This is cool
```
-### License
+##Options
+Add the following attributes to customize behaviour
-Copyright (c) 2014 Sebastian Hammerl, Getslash GmbH
+- `invert="true"` - Show check on false value instead of true
+- `true-value="this-is-cool"` - Will display check in checkbox if ng-model value === 'this-is-cool'
-Licensed under the MIT License
\ No newline at end of file
+##Acknowledgements
+Thanks to angular-bootstrap-checkbox.
diff --git a/angular-bootstrap-checkbox.js b/angular-bootstrap-checkbox.js
deleted file mode 100644
index 0849d6d..0000000
--- a/angular-bootstrap-checkbox.js
+++ /dev/null
@@ -1,76 +0,0 @@
-"use strict";
-
-angular.module("ui.checkbox", []).directive("checkbox", function() {
- return {
- scope: {},
- require: "ngModel",
- restrict: "E",
- replace: "true",
- template: "",
- link: function(scope, elem, attrs, modelCtrl) {
- scope.size = "default";
- // Default Button Styling
- scope.stylebtn = {};
- // Default Checkmark Styling
- scope.styleicon = {"width": "10px", "left": "-1px"};
- // If size is undefined, Checkbox has normal size (Bootstrap 'xs')
- if(attrs.large !== undefined) {
- scope.size = "large";
- scope.stylebtn = {"padding-top": "2px", "padding-bottom": "2px", "height": "30px"};
- scope.styleicon = {"width": "8px", "left": "-5px", "font-size": "17px"};
- }
- if(attrs.larger !== undefined) {
- scope.size = "larger";
- scope.stylebtn = {"padding-top": "2px", "padding-bottom": "2px", "height": "34px"};
- scope.styleicon = {"width": "8px", "left": "-8px", "font-size": "22px"};
- }
- if(attrs.largest !== undefined) {
- scope.size = "largest";
- scope.stylebtn = {"padding-top": "2px", "padding-bottom": "2px", "height": "45px"};
- scope.styleicon = {"width": "11px", "left": "-11px", "font-size": "30px"};
- }
-
- var trueValue = true;
- var falseValue = false;
-
- // If defined set true value
- if(attrs.ngTrueValue !== undefined) {
- trueValue = attrs.ngTrueValue;
- }
- // If defined set false value
- if(attrs.ngFalseValue !== undefined) {
- falseValue = attrs.ngFalseValue;
- }
-
- // Check if name attribute is set and if so add it to the DOM element
- if(scope.name !== undefined) {
- elem.name = scope.name;
- }
-
- // Update element when model changes
- scope.$watch(function() {
- if(modelCtrl.$modelValue === trueValue || modelCtrl.$modelValue === true) {
- modelCtrl.$setViewValue(trueValue);
- } else {
- modelCtrl.$setViewValue(falseValue);
- }
- return modelCtrl.$modelValue;
- }, function(newVal, oldVal) {
- scope.checked = modelCtrl.$modelValue === trueValue;
- }, true);
-
- // On click swap value and trigger onChange function
- elem.bind("click", function() {
- scope.$apply(function() {
- if(modelCtrl.$modelValue === falseValue) {
- modelCtrl.$setViewValue(trueValue);
- } else {
- modelCtrl.$setViewValue(falseValue);
- }
- });
- });
- }
- };
-});
\ No newline at end of file
diff --git a/app.js b/app.js
deleted file mode 100644
index 2b89069..0000000
--- a/app.js
+++ /dev/null
@@ -1,14 +0,0 @@
-"use strict";
-
-angular.module("angular-bootstrap-checkbox-test", ["ui.checkbox"]).controller("index", function($scope) {
- $scope.checkboxModel = [
- false, false, false,false, false, false, false, false, true, false, true
- ];
-
- $scope.changes = 0;
- $scope.onChange = function() {
- $scope.changes++;
- };
-
- $scope.isDisabled = false;
-});
\ No newline at end of file
diff --git a/bower.json b/bower.json
index e8bf99d..5bde218 100644
--- a/bower.json
+++ b/bower.json
@@ -1,19 +1,12 @@
{
- "name": "angular-bootstrap-checkbox",
- "version": "0.3.1",
- "authors": [
- "Sebastian Hammerl, Getslash GmbH"
- ],
- "description": "A checkbox for AngularJS styled to fit the Twitter Bootstrap standard design",
- "main": "angular-bootstrap-checkbox.js",
+ "name": "ez-checkbox",
+ "version": "0.0.0",
+ "description": "A checkbox for AngularJS",
"keywords": [
"angular",
"angularjs",
"directive",
- "ui",
- "bootstrap",
"form",
- "input",
"checkbox"
],
"license": "MIT",
@@ -24,9 +17,6 @@
],
"dependencies": {
"angular": ">= 1.2.0",
- "bootstrap": ">= 3.0.0"
- },
- "devDependencies": {
- "angular-scenario": ">= 1.2.0"
+ "font-awesome": ">= 4.0.0"
}
}
diff --git a/checkbox.png b/checkbox.png
deleted file mode 100644
index ca3ca48..0000000
Binary files a/checkbox.png and /dev/null differ
diff --git a/dist/ez-checkbox.css b/dist/ez-checkbox.css
new file mode 100644
index 0000000..083eb7e
--- /dev/null
+++ b/dist/ez-checkbox.css
@@ -0,0 +1,12 @@
+.ez-checkbox {
+ position: relative;
+ margin-right: 5px;
+ color: #333;
+ cursor: pointer;
+}
+.ez-checkbox:hover {
+ text-decoration: none;
+}
+.ez-checkbox i {
+ cursor: pointer;
+}
diff --git a/dist/ez-checkbox.min.css b/dist/ez-checkbox.min.css
new file mode 100644
index 0000000..017769a
--- /dev/null
+++ b/dist/ez-checkbox.min.css
@@ -0,0 +1 @@
+.ez-checkbox,.ez-checkbox i{cursor:pointer}.ez-checkbox{position:relative;margin-right:5px;color:#333}.ez-checkbox:hover{text-decoration:none}
\ No newline at end of file
diff --git a/dist/ez-checkbox.min.js b/dist/ez-checkbox.min.js
new file mode 100644
index 0000000..0ad9db5
--- /dev/null
+++ b/dist/ez-checkbox.min.js
@@ -0,0 +1 @@
+"use strict";angular.module("ez.checkbox",[]).directive("ezCheckbox",[function(){return{require:"ngModel",restrict:"EA",replace:"true",transclude:!0,template:'',scope:{},link:function(a,b,c,d){var e=!0,f=!1;c.hasOwnProperty("trueValue")&&(e=c.trueValue),c.hasOwnProperty("invert")&&(f=e,e=!1),d.$render=function(){a.checked=d.$modelValue===e?!0:!1},a.toggle=function(){d.$setViewValue(d.$modelValue===f?e:f),d.$render()}}}}]);
\ No newline at end of file
diff --git a/index.html b/index.html
index c1fc638..f41d1ca 100644
--- a/index.html
+++ b/index.html
@@ -1,369 +1,137 @@
-
-
-
-
-
-
-
-
-
-
- |
- Example
- |
- |
-
- Value
- |
- |
-
- Code
- |
- |
-
+
+
-
- |
- Minimal example
- |
-
-
- |
-
-
- |
-
-
-
- |
-
+
-<checkbox
- ng-model="checkboxModel[0]"
-></checkbox>
-
- |
-
-
-
- |
- Example with custom name attribute
- |
-
-
- |
-
-
- |
-
-
-
- |
-
+
+
-<checkbox
- ng-model="checkboxModel[1]"
- name="custom-name"
-></checkbox>
+
+
+
+
+
- |
- Example with custom false value
- |
-
-
- |
-
-
- |
-
-
-
-
- |
-
-
-<checkbox
- ng-model="checkboxModel[3]"
- ng-false-value="The Untruth"
-></checkbox>
-
- |
+ Example |
+ Checkbox |
+ Value |
+ External Control |
+ Code |
|
- Example with custom true and false value
+ Minimal example
|
-
+
+ Checkbox Label
+
|
-
+
|
- |
-
+ |
-<checkbox
- ng-model="checkboxModel[4]"
- ng-true-value="The Truth"
- ng-false-value="The Untruth"
-></checkbox>
+<ez-checkbox
+ ng-model="form.example1"
+></ez-checkbox>
|
|
- Example with change listener when clicked
+ Example with inverted truth and custom name attribute
|
-
+
|
-
-
- Clicks:
+
|
-
+
Set to true
-
+
Set to false
|
-
+ |
-<checkbox
- ng-model="checkboxModel[5]"
- ng-change="onChange()"
-></checkbox>
+<ez-checkbox
+ ng-model="form.example2" invert="true"
+ name="example2"
+></ez-checkbox>
|
|
- Example disabled checkbox
+ Example with custom true value
|
-
+
|
-
+
|
-
+
Set to true
-
+
Set to false
+
+
+ Set to "The Real True"
-
- Enable
-
-
- Disable
-
- |
-
-
-<checkbox
- ng-model="checkboxModel[6]"
- ng-disabled="isDisabled === true"
-></checkbox>
-
|
-
-
-
|
- Different Sizes (normal, large, larger, largest)
- |
-
-
-
-
-
-
-
-
-
-
- |
-
+<ez-checkbox
+ ng-model="form.example3"
+ true-value="The Real True"
+></ez-checkbox>
-<checkbox
- ng-model="checkboxModel[7]"
-></checkbox>
-<checkbox large
- ng-model="checkboxModel[7]"
-></checkbox>
-<checkbox larger
- ng-model="checkboxModel[7]"
-></checkbox>
-<checkbox largest
- ng-model="checkboxModel[7]"
-></checkbox>
-
- |
-
-
-
- |
- Different Styles (normal, primary, success, info, warning, danger)
- |
- |
-
- default:
-
- primary:
-
- success:
-
- info:
-
- warning:
-
- danger:
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-<checkbox
- ng-model="checkboxModel[9]"
-></checkbox>
-<checkbox class="btn-primary"
- ng-model="checkboxModel[9]"
-></checkbox>
-<checkbox class="btn-success"
- ng-model="checkboxModel[9]"
-></checkbox>
-<checkbox class="btn-info"
- ng-model="checkboxModel[9]"
-></checkbox>
-<checkbox class="btn-warning"
- ng-model="checkboxModel[9]"
-></checkbox>
-<checkbox class="btn-danger"
- ng-model="checkboxModel[9]"
-></checkbox>
|
-
-
- app.js:
-
-angular.module("angular-bootstrap-checkbox-test", ["ui.checkbox"])
-.controller("index", function($scope) {
- $scope.checkboxModel = [
- false, false, false,false, false, false, false, false, true, false, true
- ];
-
- $scope.changes = 0;
- $scope.onChange = function() {
- $scope.changes++;
- };
-
- $scope.isDisabled = false;
-});
-
- |
-
-
\ No newline at end of file
+ |