diff --git a/README.md b/README.md index 81928ea..0b7ae2e 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ An Angular directive that allow you to pick a color from a custom palette There's a bunch of color picker components out there, they are great at what they are doing, and this one does not aims to replace them. Unfortunately, allowing your end user to choose any color they want to, can lead sometimes to a UI-break. So how do you handle a case when you only want to allow to pick a color from a custom color palette? This component is the answer. -**Requirements:** AngularJS 1.3+ +**Requirements:** AngularJS 1.3+ **File Size:** 0.98 kb minified # Installation @@ -24,7 +24,7 @@ Download [https://github.com/softmonkeyjapan/angular-color-chooser/archive/v0.1. # Usage -1. Include both the `color-chooser.css` and `color-chooser.js` in your HTML. +1. Include both the `color-chooser.css` and `color-chooser.js` in your HTML. ```html @@ -37,7 +37,7 @@ Download [https://github.com/softmonkeyjapan/angular-color-chooser/archive/v0.1. angular.module('myApp', ['lk-color-chooser']) ``` -3. Configure the plugin (see below **configuration** section) +3. Configure the plugin (see below **configuration** section) 4. Create a scope to bind the value of the selected color @@ -54,19 +54,19 @@ Download [https://github.com/softmonkeyjapan/angular-color-chooser/archive/v0.1. 5. Add the directive to your HTML element ```html - + ``` 6. That's it, you're done! -# Configuration +# Configuration In order for the component to work, you'll need to provide a set of colors. There's 2 ways of doing this : ### Using configure(options) from Provider -You can define in a global way, the set of colors you want to use within your app. +You can define in a global way, the set of colors you want to use within your app. NOTE : This will be override if you pass the colors directly from a scope (see below). ```js @@ -78,11 +78,11 @@ angular.module('myApp', ['lk-color-chooser']) colors: ['#72C2FF', '#6798E6', '#CEA1E1', '#FFADED', '#FC809B', '#FFC787', '#FFF074', '#A6FC81', '#09E6AE', '#18C4C7'] }); }]) -``` +``` ### From a controller -In some case, you will want to use some colors, maybe different from the ones defined within the provider. In that case you can create a new scope from inside a controller : +In some case, you will want to use some colors, maybe different from the ones defined within the provider. In that case you can create a new scope from inside a controller : ```js angular @@ -95,7 +95,7 @@ angular and simply pass it to the directive : ```html - + ``` NOTE : Passing a scope to the directive's `colors` attribute will override the provider definition. @@ -103,7 +103,7 @@ NOTE : Passing a scope to the directive's `colors` attribute will override the p # Tests ```bash -npm install +npm install && npm install -g karma-cli bower install karma start test/karma.conf.js ``` diff --git a/dist/color-chooser.js b/dist/color-chooser.js index a3a7b7d..adfc80e 100644 --- a/dist/color-chooser.js +++ b/dist/color-chooser.js @@ -52,16 +52,16 @@ .directive('lkColorChooser', ['lkColorSettings', '$timeout', function (lkColorSettings, $timeout) { return { restrict: 'EA', - template: '', + template: '', replace: true, scope: { colors: '=?', - selected: '=' + selectedColor: '=' }, controller: ['$scope', '$timeout', function lkColorChooserCtrl ($scope, $timeout) { this.setSelectedColor = function (color) { $timeout(function() { - $scope.selected = color; + $scope.selectedColor = color; }); } }], diff --git a/dist/color-chooser.min.js b/dist/color-chooser.min.js index a8c3b1f..a628058 100644 --- a/dist/color-chooser.min.js +++ b/dist/color-chooser.min.js @@ -1 +1 @@ -"use strict";!function(){angular.module("lk-color-chooser",[]).provider("lkColorSettings",function(){this.colors=[],this.$get=function(){return{colors:this.colors}},this.configure=function(o){var l;for(l in o)this[l]=o[l]}}).directive("lkColorChooser",["lkColorSettings","$timeout",function(o){return{restrict:"EA",template:'',replace:!0,scope:{colors:"=?",selected:"="},controller:["$scope","$timeout",function(o,l){this.setSelectedColor=function(c){l(function(){o.selected=c})}}],link:function(l){l.colors||(l.colors=o.colors)}}}]).directive("lkColor",function(){return{restrict:"EA",require:"^lkColorChooser",template:'
  •  
  • ',replace:!0,scope:{color:"="},link:function(o,l,c,r){l.on("click",function(){r.setSelectedColor(o.color)})}}})}(); \ No newline at end of file +"use strict";!function(){angular.module("lk-color-chooser",[]).provider("lkColorSettings",function(){this.colors=[],this.$get=function(){return{colors:this.colors}},this.configure=function(o){var l;for(l in o)this[l]=o[l]}}).directive("lkColorChooser",["lkColorSettings","$timeout",function(o){return{restrict:"EA",template:'',replace:!0,scope:{colors:"=?",selectedColor:"="},controller:["$scope","$timeout",function(o,l){this.setSelectedColor=function(r){l(function(){o.selectedColor=r})}}],link:function(l){l.colors||(l.colors=o.colors)}}}]).directive("lkColor",function(){return{restrict:"EA",require:"^lkColorChooser",template:'
  •  
  • ',replace:!0,scope:{color:"="},link:function(o,l,r,c){l.on("click",function(){c.setSelectedColor(o.color)})}}})}(); \ No newline at end of file diff --git a/src/color-chooser.js b/src/color-chooser.js index a3a7b7d..adfc80e 100644 --- a/src/color-chooser.js +++ b/src/color-chooser.js @@ -52,16 +52,16 @@ .directive('lkColorChooser', ['lkColorSettings', '$timeout', function (lkColorSettings, $timeout) { return { restrict: 'EA', - template: '', + template: '', replace: true, scope: { colors: '=?', - selected: '=' + selectedColor: '=' }, controller: ['$scope', '$timeout', function lkColorChooserCtrl ($scope, $timeout) { this.setSelectedColor = function (color) { $timeout(function() { - $scope.selected = color; + $scope.selectedColor = color; }); } }],