Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angularjs-color-picker

Package Overview
Dependencies
Maintainers
2
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angularjs-color-picker - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

2

bower.json
{
"name": "angular-color-picker",
"description": "Color Picker Directive For AngularJS",
"version": "2.2.0",
"version": "2.3.0",
"homepage": "https://github.com/ruhley/angular-color-picker",

@@ -6,0 +6,0 @@ "repository": {

# Changelog
## v2.3.0
#### Breaking Changes
* None
#### New Features
* New `round` option to show a round color picker
#### Bug Fixes
* None
## v2.2.0

@@ -4,0 +15,0 @@

/*!
* angularjs-color-picker v2.2.0
* angularjs-color-picker v2.3.0
* https://github.com/ruhley/angular-color-picker/

@@ -7,3 +7,3 @@ *

*
* 2016-07-26 09:55:18
* 2016-07-29 09:30:27
*

@@ -243,3 +243,3 @@ */

this.$scope.$watchGroup(['AngularColorPickerController.options.disabled', 'AngularColorPickerController.options.swatchBootstrap', 'AngularColorPickerController.options.swatchOnly', 'AngularColorPickerController.options.swatch', 'AngularColorPickerController.options.pos', 'AngularColorPickerController.options.inline', 'AngularColorPickerController.options.placeholder'], this.reInit.bind(this));
this.$scope.$watchGroup(['AngularColorPickerController.options.disabled', 'AngularColorPickerController.options.swatchBootstrap', 'AngularColorPickerController.options.swatchOnly', 'AngularColorPickerController.options.swatch', 'AngularColorPickerController.options.pos', 'AngularColorPickerController.options.inline', 'AngularColorPickerController.options.placeholder', 'AngularColorPickerController.options.round'], this.reInit.bind(this));

@@ -424,2 +424,3 @@ // api

alpha: true,
round: false,
case: 'upper',

@@ -452,2 +453,6 @@ format: 'hsl',

this.visible = this.options.inline;
if (this.options.round) {
this.options.hue = false;
}
}

@@ -585,5 +590,7 @@ }, {

el.css({
'top': bounding.height * _this7.lightnessPos / 100 + 'px'
});
if (!_this7.options.round) {
el.css({
'top': bounding.height * _this7.lightnessPos / 100 + 'px'
});
}
});

@@ -601,5 +608,12 @@ }

el.css({
'left': bounding.width * _this8.saturationPos / 100 + 'px'
});
if (_this8.options.round) {
el.css({
left: bounding.width * _this8.xPos / 100 + 'px',
top: bounding.height * _this8.yPos / 100 + 'px'
});
} else {
el.css({
'left': bounding.width * _this8.saturationPos / 100 + 'px'
});
}
});

@@ -752,15 +766,31 @@ }

this.saturation = (event.pageX - offset.left) / el.prop('offsetWidth') * 100;
this.lightness = (1 - (event.pageY - offset.top) / el.prop('offsetHeight')) * 100;
if (this.options.round) {
var dx = (event.pageX - offset.left) * 2.0 / el.prop('offsetWidth') - 1.0;
var dy = -((event.pageY - offset.top) * 2.0 / el.prop('offsetHeight')) + 1.0;
if (this.saturation > 100) {
this.saturation = 100;
} else if (this.saturation < 0) {
this.saturation = 0;
}
var tmpSaturation = Math.sqrt(dx * dx + dy * dy);
var tmpHue = Math.atan2(dy, dx);
if (this.lightness > 100) {
this.saturation = 100 * tmpSaturation;
var degHue = tmpHue * 57.29577951308233; // rad to deg
if (degHue < 0.0) {
degHue += 360.0;
}
this.hue = degHue;
this.lightness = 100;
} else if (this.lightness < 0) {
this.lightness = 0;
} else {
this.saturation = (event.pageX - offset.left) / el.prop('offsetWidth') * 100;
this.lightness = (1 - (event.pageY - offset.top) / el.prop('offsetHeight')) * 100;
if (this.saturation > 100) {
this.saturation = 100;
} else if (this.saturation < 0) {
this.saturation = 0;
}
if (this.lightness > 100) {
this.lightness = 100;
} else if (this.lightness < 0) {
this.lightness = 0;
}
}

@@ -772,8 +802,32 @@ }

if (this.saturation !== undefined) {
this.saturationPos = this.saturation / 100 * 100;
if (this.options.round) {
var angle = this.hue * 0.01745329251994; // deg to rad
var px = Math.cos(angle) * this.saturation;
var py = -Math.sin(angle) * this.saturation;
if (this.saturationPos < 0) {
this.saturationPos = 0;
} else if (this.saturationPos > 100) {
this.saturationPos = 100;
this.xPos = (px + 100.0) * 0.5;
this.yPos = (py + 100.0) * 0.5;
// because we are using percentages this can be half of 100%
var center = 50;
// distance of pointer from the center of the circle
var distance = Math.pow(center - this.xPos, 2) + Math.pow(center - this.yPos, 2);
// distance of edge of circle from the center of the circle
var radius = Math.pow(center, 2);
// if not inside the circle
if (distance > radius) {
var rads = Math.atan2(this.yPos - center, this.xPos - center);
this.xPos = Math.cos(rads) * center + center;
this.yPos = Math.sin(rads) * center + center;
}
} else {
this.saturationPos = this.saturation / 100 * 100;
if (this.saturationPos < 0) {
this.saturationPos = 0;
} else if (this.saturationPos > 100) {
this.saturationPos = 100;
}
}

@@ -925,4 +979,5 @@

function template($templateCache) {
$templateCache.put('template/color-picker/directive.html', '<div class="color-picker-wrapper" ng-class="{' + '\'color-picker-disabled\': AngularColorPickerController.options.disabled,' + '\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,' + '}">' + ' <div class="color-picker-input-wrapper" ng-class="{\'input-group\': AngularColorPickerController.options.swatchBootstrap && AngularColorPickerController.options.swatch}">' + ' <span ng-if="AngularColorPickerController.options.swatchPos === \'left\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span>' + ' <input class="color-picker-input form-control" type="text" ng-model="AngularColorPickerController.ngModel" ng-readonly="AngularColorPickerController.options.swatchOnly" ng-disabled="AngularColorPickerController.options.disabled" ng-blur="AngularColorPickerController.onBlur($event)" ng-change="AngularColorPickerController.onChange($event)" size="7" ng-focus="AngularColorPickerController.api.open($event)" ng-class="{\'color-picker-input-swatch\': AngularColorPickerController.options.swatch && !AngularColorPickerController.options.swatchOnly && AngularColorPickerController.options.swatchPos === \'left\'}" placeholder="{{AngularColorPickerController.options.placeholder}}">' + ' <span ng-if="AngularColorPickerController.options.swatchPos === \'right\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span>' + ' </div>' + ' <div class="color-picker-panel" ng-show="AngularColorPickerController.visible" ng-class="{' + ' \'color-picker-panel-top color-picker-panel-right\': AngularColorPickerController.options.pos === \'top right\',' + ' \'color-picker-panel-top color-picker-panel-left\': AngularColorPickerController.options.pos === \'top left\',' + ' \'color-picker-panel-bottom color-picker-panel-right\': AngularColorPickerController.options.pos === \'bottom right\',' + ' \'color-picker-panel-bottom color-picker-panel-left\': AngularColorPickerController.options.pos === \'bottom left\',' + ' \'color-picker-show-hue\': AngularColorPickerController.options.hue,' + ' \'color-picker-show-alpha\': AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\',' + ' \'color-picker-show-inline\': AngularColorPickerController.options.inline,' + ' }">' + ' <div class="color-picker-grid-wrapper">' + ' <div class="color-picker-row">' + ' <div class="color-picker-grid color-picker-sprite">' + ' <div class="color-picker-grid-inner"></div>' + ' <div class="color-picker-picker">' + ' <div></div>' + ' </div>' + ' </div>' + ' <div class="color-picker-hue color-picker-sprite" ng-show="AngularColorPickerController.options.hue">' + ' <div class="color-picker-slider"></div>' + ' </div>' + ' <div class="color-picker-opacity color-picker-sprite" ng-show="AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\'">' + ' <div class="color-picker-slider"></div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="color-picker-actions">' + ' <button ' + ' class="color-picker-action color-picker-action-clear"' + ' ng-class="AngularColorPickerController.options.clear.class"' + ' ng-show="AngularColorPickerController.options.clear.show"' + ' ng-click="AngularColorPickerController.api.clear($event)"' + ' >' + ' {{AngularColorPickerController.options.clear.label}}' + ' </button><!--' + ' --><button ' + ' class="color-picker-action color-picker-action-reset"' + ' ng-class="AngularColorPickerController.options.reset.class"' + ' ng-show="AngularColorPickerController.options.reset.show"' + ' ng-click="AngularColorPickerController.api.reset($event)"' + ' >' + ' {{AngularColorPickerController.options.reset.label}}' + ' </button><!--' + ' --><button' + ' class="color-picker-action color-picker-action-close"' + ' ng-class="AngularColorPickerController.options.close.class"' + ' ng-show="AngularColorPickerController.options.close.show"' + ' ng-click="AngularColorPickerController.api.close($event)"' + ' >' + ' {{AngularColorPickerController.options.close.label}}' + ' </button>' + ' </div>' + ' </div>' + '</div>');
$templateCache.put('template/color-picker/directive.html', '<div class="color-picker-wrapper" ng-class="{' + '\'color-picker-disabled\': AngularColorPickerController.options.disabled,' + '\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,' + '}">' + ' <div class="color-picker-input-wrapper" ng-class="{\'input-group\': AngularColorPickerController.options.swatchBootstrap && AngularColorPickerController.options.swatch}">' + ' <span ng-if="AngularColorPickerController.options.swatchPos === \'left\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span>' + ' <input class="color-picker-input form-control" type="text" ng-model="AngularColorPickerController.ngModel" ng-readonly="AngularColorPickerController.options.swatchOnly" ng-disabled="AngularColorPickerController.options.disabled" ng-blur="AngularColorPickerController.onBlur($event)" ng-change="AngularColorPickerController.onChange($event)" size="7" ng-focus="AngularColorPickerController.api.open($event)" ng-class="{\'color-picker-input-swatch\': AngularColorPickerController.options.swatch && !AngularColorPickerController.options.swatchOnly && AngularColorPickerController.options.swatchPos === \'left\'}" placeholder="{{AngularColorPickerController.options.placeholder}}">' + ' <span ng-if="AngularColorPickerController.options.swatchPos === \'right\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span>' + ' </div>' + ' <div class="color-picker-panel" ng-show="AngularColorPickerController.visible" ng-class="{' + ' \'color-picker-panel-top color-picker-panel-right\': AngularColorPickerController.options.pos === \'top right\',' + ' \'color-picker-panel-top color-picker-panel-left\': AngularColorPickerController.options.pos === \'top left\',' + ' \'color-picker-panel-bottom color-picker-panel-right\': AngularColorPickerController.options.pos === \'bottom right\',' + ' \'color-picker-panel-bottom color-picker-panel-left\': AngularColorPickerController.options.pos === \'bottom left\',' + ' \'color-picker-panel-round\': AngularColorPickerController.options.round,' + ' \'color-picker-show-hue\': AngularColorPickerController.options.hue,' + ' \'color-picker-show-alpha\': AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\',' + ' \'color-picker-show-inline\': AngularColorPickerController.options.inline,' + ' }">' + ' <div class="color-picker-grid-wrapper">' + ' <div class="color-picker-row">' + ' <div class="color-picker-grid color-picker-sprite">' + ' <div class="color-picker-grid-inner"></div>' + ' <div class="color-picker-picker">' + ' <div></div>' + ' </div>' + ' </div>' + ' <div class="color-picker-hue color-picker-sprite" ng-show="AngularColorPickerController.options.hue">' + ' <div class="color-picker-slider"></div>' + ' </div>' + ' <div class="color-picker-opacity color-picker-sprite" ng-show="AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\'">' + ' <div class="color-picker-slider"></div>' + ' </div>' + ' </div>' + ' </div>' + ' <div class="color-picker-actions">' + ' <button ' + ' class="color-picker-action color-picker-action-clear"' + ' ng-class="AngularColorPickerController.options.clear.class"' + ' ng-show="AngularColorPickerController.options.clear.show"' + ' ng-click="AngularColorPickerController.api.clear($event)"' + ' >' + ' {{AngularColorPickerController.options.clear.label}}' + ' </button><!--' + ' --><button ' + ' class="color-picker-action color-picker-action-reset"' + ' ng-class="AngularColorPickerController.options.reset.class"' + ' ng-show="AngularColorPickerController.options.reset.show"' + ' ng-click="AngularColorPickerController.api.reset($event)"' + ' >' + ' {{AngularColorPickerController.options.reset.label}}' + ' </button><!--' + ' --><button' + ' class="color-picker-action color-picker-action-close"' + ' ng-class="AngularColorPickerController.options.close.class"' + ' ng-show="AngularColorPickerController.options.close.show"' + ' ng-click="AngularColorPickerController.api.close($event)"' + ' >' + ' {{AngularColorPickerController.options.close.label}}' + ' </button>' + ' </div>' + ' </div>' + '</div>');
}
template.$inject = ['$templateCache'];

@@ -929,0 +984,0 @@

/*!
* angularjs-color-picker v2.2.0
* angularjs-color-picker v2.3.0
* https://github.com/ruhley/angular-color-picker/

@@ -7,5 +7,5 @@ *

*
* 2016-07-26 09:55:18
* 2016-07-29 09:30:27
*
*/
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):o.AngularjsColorPicker=t()}(this,function(){"use strict";function o(){return{restrict:"E",require:["^ngModel"],scope:{ngModel:"=",options:"=?",api:"=?",eventApi:"=?"},bindToController:!0,templateUrl:"template/color-picker/directive.html",controller:s,controllerAs:"AngularColorPickerController",link:function(o,t,e,i){o.control=i,o.init()}}}function t(o){o.put("template/color-picker/directive.html",'<div class="color-picker-wrapper" ng-class="{\'color-picker-disabled\': AngularColorPickerController.options.disabled,\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,}"> <div class="color-picker-input-wrapper" ng-class="{\'input-group\': AngularColorPickerController.options.swatchBootstrap && AngularColorPickerController.options.swatch}"> <span ng-if="AngularColorPickerController.options.swatchPos === \'left\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span> <input class="color-picker-input form-control" type="text" ng-model="AngularColorPickerController.ngModel" ng-readonly="AngularColorPickerController.options.swatchOnly" ng-disabled="AngularColorPickerController.options.disabled" ng-blur="AngularColorPickerController.onBlur($event)" ng-change="AngularColorPickerController.onChange($event)" size="7" ng-focus="AngularColorPickerController.api.open($event)" ng-class="{\'color-picker-input-swatch\': AngularColorPickerController.options.swatch && !AngularColorPickerController.options.swatchOnly && AngularColorPickerController.options.swatchPos === \'left\'}" placeholder="{{AngularColorPickerController.options.placeholder}}"> <span ng-if="AngularColorPickerController.options.swatchPos === \'right\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span> </div> <div class="color-picker-panel" ng-show="AngularColorPickerController.visible" ng-class="{ \'color-picker-panel-top color-picker-panel-right\': AngularColorPickerController.options.pos === \'top right\', \'color-picker-panel-top color-picker-panel-left\': AngularColorPickerController.options.pos === \'top left\', \'color-picker-panel-bottom color-picker-panel-right\': AngularColorPickerController.options.pos === \'bottom right\', \'color-picker-panel-bottom color-picker-panel-left\': AngularColorPickerController.options.pos === \'bottom left\', \'color-picker-show-hue\': AngularColorPickerController.options.hue, \'color-picker-show-alpha\': AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\', \'color-picker-show-inline\': AngularColorPickerController.options.inline, }"> <div class="color-picker-grid-wrapper"> <div class="color-picker-row"> <div class="color-picker-grid color-picker-sprite"> <div class="color-picker-grid-inner"></div> <div class="color-picker-picker"> <div></div> </div> </div> <div class="color-picker-hue color-picker-sprite" ng-show="AngularColorPickerController.options.hue"> <div class="color-picker-slider"></div> </div> <div class="color-picker-opacity color-picker-sprite" ng-show="AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\'"> <div class="color-picker-slider"></div> </div> </div> </div> <div class="color-picker-actions"> <button class="color-picker-action color-picker-action-clear" ng-class="AngularColorPickerController.options.clear.class" ng-show="AngularColorPickerController.options.clear.show" ng-click="AngularColorPickerController.api.clear($event)" > {{AngularColorPickerController.options.clear.label}} </button><!-- --><button class="color-picker-action color-picker-action-reset" ng-class="AngularColorPickerController.options.reset.class" ng-show="AngularColorPickerController.options.reset.show" ng-click="AngularColorPickerController.api.reset($event)" > {{AngularColorPickerController.options.reset.label}} </button><!-- --><button class="color-picker-action color-picker-action-close" ng-class="AngularColorPickerController.options.close.class" ng-show="AngularColorPickerController.options.close.show" ng-click="AngularColorPickerController.api.close($event)" > {{AngularColorPickerController.options.close.label}} </button> </div> </div></div>')}var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o},i=function(o,t){if(!(o instanceof t))throw new TypeError("Cannot call a class as a function")},n=function(){function o(o,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(o,i.key,i)}}return function(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}}(),s=function(){function o(t,e,n,s){i(this,o),this.$scope=t,this.$element=e,this.$document=n,this.$timeout=s,this.$scope.init=this.init.bind(this),this.hue=0,this.saturation=void 0,this.lightness=void 0,this.opacity=void 0}return n(o,[{key:"watchNgModel",value:function(o,t){var e=this;if(!this.colorMouse)if(void 0===o||void 0===t||this.hasOwnProperty("initialNgModel")||(this.initialNgModel=o),this.hasOwnProperty("initialNgModel")&&(o===this.initialNgModel?"function"==typeof this.$scope.control[0].$setPristine&&this.$scope.control[0].$setPristine():"function"==typeof this.$scope.control[0].$setDirty&&this.$scope.control[0].$setDirty()),void 0!==o&&null!==o&&o.length>4){var i=tinycolor(o);if(i.isValid()){var n=i.toHsv();this.updateModel=!1,this.hue=n.h,this.saturation=100*n.s,this.lightness=100*n.v,this.options.alpha&&(this.opacity=100*n.a),this.$timeout(function(){e.updateModel=!0}),this.isValid=!0}else this.isValid=!1;this.$scope.control[0].$setValidity(this.$element.attr("name"),this.isValid)}else null!==o&&""!==o||(this.hue=0,this.saturation=void 0,this.lightness=void 0,this.opacity=void 0),this.swatchColor=""}},{key:"watchSwatchPos",value:function(o){var t=this;void 0!==o&&(this.initConfig(),this.$timeout(function(){t.updateSwatchBackground()}))}},{key:"setupApi",value:function(){var o=this;this.api||(this.api={}),this.api.open=function(t){return!!o.visible||(o.visible=!0,o.hueMouse=!1,o.opacityMouse=!1,o.colorMouse=!1,o.hueUpdate(),o.saturationUpdate(),o.lightnessUpdate(),o.opacityUpdate(),void o.eventApiDispatch("onOpen",[t]))},this.api.close=function(t){o.options.inline||!o.visible&&null===o.$element[0].querySelector(".color-picker-panel").offsetParent||(o.visible=!1,o.$scope.$applyAsync(),o.eventApiDispatch("onClose",[t]))},this.api.clear=function(t){""!==o.ngModel&&(o.ngModel="",o.eventApiDispatch("onClear",[t]))},this.api.reset=function(t){o.ngModel!==o.initialNgModel&&(o.ngModel=o.initialNgModel,o.eventApiDispatch("onReset",[t]))},this.api.getElement=function(){return o.$element}}},{key:"reInit",value:function(o){void 0!==o&&this.initConfig()}},{key:"reInitAndUpdate",value:function(o){void 0!==o&&(this.initConfig(),this.update())}},{key:"init",value:function(){var o=this;this.chrome=Boolean(window.chrome);var t=window.navigator.userAgent.match(/Android\s([0-9\.]*)/i);this.android_version=t&&t.length>1?parseFloat(t[1]):NaN,this.updateModel=!0,this.$scope.$watch("AngularColorPickerController.ngModel",this.watchNgModel.bind(this)),this.$scope.$watch("AngularColorPickerController.options.swatchPos",this.watchSwatchPos.bind(this)),this.$scope.$watchGroup(["AngularColorPickerController.options.format","AngularColorPickerController.options.alpha","AngularColorPickerController.options.case"],this.reInitAndUpdate.bind(this)),this.$scope.$watchGroup(["AngularColorPickerController.options.disabled","AngularColorPickerController.options.swatchBootstrap","AngularColorPickerController.options.swatchOnly","AngularColorPickerController.options.swatch","AngularColorPickerController.options.pos","AngularColorPickerController.options.inline","AngularColorPickerController.options.placeholder"],this.reInit.bind(this)),this.$scope.$watch("AngularColorPickerController.api",this.setupApi.bind(this)),this.$scope.$watch("AngularColorPickerController.swatchColor",this.updateSwatchBackground.bind(this)),this.$scope.$watch("AngularColorPickerController.hue",this.hueUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.saturation",this.saturationUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.lightness",this.lightnessUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.opacity",this.opacityUpdate.bind(this)),this.$scope.$on("$destroy",function(){o.$document.off("mousedown",o.onMouseDown),o.$document.off("mouseup",o.onMouseUp),o.$document.off("mousemove",o.onMouseMove),o.$document.off("touchstart",o.onMouseDown),o.$document.off("touchend",o.onMouseUp),o.$document.off("touchmove",o.onMouseMove),o.eventApiDispatch("onDestroy")}),this.initConfig(),this.$document.on("mousedown",this.onMouseDown.bind(this)),this.$document.on("mouseup",this.onMouseUp.bind(this)),this.$document.on("mousemove",this.onMouseMove.bind(this)),this.$document.on("touchstart",this.onMouseDown.bind(this)),this.$document.on("touchend",this.onMouseUp.bind(this)),this.$document.on("touchmove",this.onMouseMove.bind(this)),this.find(".color-picker-grid").on("click",this.onColorClick.bind(this)),this.find(".color-picker-grid").on("touchend",this.onColorClick.bind(this)),this.find(".color-picker-hue").on("click",this.onHueClick.bind(this)),this.find(".color-picker-hue").on("touchend",this.onHueClick.bind(this)),this.find(".color-picker-opacity").on("click",this.onOpacityClick.bind(this)),this.find(".color-picker-opacity").on("touchend",this.onOpacityClick.bind(this))}},{key:"onMouseDown",value:function(o){!this.options.disabled&&this.find(o.target).length>0&&(o.target.classList.contains("color-picker-grid-inner")||o.target.classList.contains("color-picker-picker")||o.target.parentNode.classList.contains("color-picker-picker")?(this.colorDown(o),this.$scope.$apply()):o.target.classList.contains("color-picker-hue")||o.target.parentNode.classList.contains("color-picker-hue")?(this.hueDown(o),this.$scope.$apply()):(o.target.classList.contains("color-picker-opacity")||o.target.parentNode.classList.contains("color-picker-opacity"))&&(this.opacityDown(o),this.$scope.$apply()))}},{key:"onMouseUp",value:function(o){this.colorMouse||this.hueMouse||this.opacityMouse||0!==this.find(o.target).length?this.colorMouse?(this.colorUp(o),this.$scope.$apply(),this.onChange(o)):this.hueMouse?(this.hueUp(o),this.$scope.$apply(),this.onChange(o)):this.opacityMouse&&(this.opacityUp(o),this.$scope.$apply(),this.onChange(o)):(this.setupApi(),this.api.close(o),this.$scope.$apply())}},{key:"onMouseMove",value:function(o){this.colorMouse?(this.colorChange(o),this.$scope.$apply()):this.hueMouse?(this.hueChange(o),this.$scope.$apply()):this.opacityMouse&&(this.opacityChange(o),this.$scope.$apply())}},{key:"onColorClick",value:function(o){this.options.disabled||(this.colorChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onHueClick",value:function(o){this.options.disabled||(this.hueChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onOpacityClick",value:function(o){this.options.disabled||(this.opacityChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onChange",value:function(o){this.hasOwnProperty("onChangeValue")||(this.onChangeValue=this.ngModel),this.ngModel!==this.onChangeValue&&(this.onChangeValue=this.ngModel,this.eventApiDispatch("onChange",[o]))}},{key:"onBlur",value:function(o){this.ngModel!==this.onChangeValue&&(this.updateModel=!0,this.update()),this.eventApiDispatch("onBlur",[o])}},{key:"initConfig",value:function(){this.options=this.merge(this.options,{disabled:!1,hue:!0,alpha:!0,case:"upper",format:"hsl",pos:"bottom left",swatch:!0,swatchOnly:!1,swatchPos:"left",swatchBootstrap:!0,inline:!1,placeholder:"",close:{show:!1,label:"Close",class:""},clear:{show:!1,label:"Clear",class:""},reset:{show:!1,label:"Reset",class:""}}),this.visible=this.options.inline}},{key:"merge",value:function(o,t){var i,n={};for(i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);if("object"===("undefined"==typeof o?"undefined":e(o)))for(i in o)o.hasOwnProperty(i)&&("object"===e(o[i])?n[i]=this.merge(o[i],n[i]):n[i]=o[i]);return n}},{key:"focus",value:function(){this.find(".color-picker-input")[0].focus()}},{key:"update",value:function(){if(void 0===this.hue||void 0===this.saturation||void 0===this.lightness)return!1;var o,t=tinycolor({h:this.hue,s:this.saturation/100,v:this.lightness/100});switch(this.options.alpha&&t.setAlpha(this.opacity/100),this.swatchColor=t.toHslString(),this.options.format){case"rgb":o=t.toRgbString();break;case"hex":o=t.toHexString(),o="lower"===this.options.case?o.toLowerCase():o.toUpperCase();break;case"hex8":o=t.toHex8String(),o="lower"===this.options.case?o.toLowerCase():o.toUpperCase();break;case"hsv":o=t.toHsvString();break;default:o=t.toHslString()}this.updateModel&&(this.ngModel=o)}},{key:"updateSwatchBackground",value:function(){var o=angular.element(this.$element[0].querySelector(".color-picker-swatch"));o.css({"background-color":this.swatchColor})}},{key:"huePosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-hue"),e=angular.element(o.$element[0].querySelector(".color-picker-hue .color-picker-slider")),i=t.getBoundingClientRect();e.css({top:i.height*o.huePos/100+"px"})})}},{key:"opacityPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-opacity"),e=angular.element(o.$element[0].querySelector(".color-picker-opacity .color-picker-slider")),i=t.getBoundingClientRect();e.css({top:i.height*o.opacityPos/100+"px"})})}},{key:"lightnessPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-grid"),e=angular.element(o.$element[0].querySelector(".color-picker-grid .color-picker-picker")),i=t.getBoundingClientRect();e.css({top:i.height*o.lightnessPos/100+"px"})})}},{key:"saturationPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-grid"),e=angular.element(o.$element[0].querySelector(".color-picker-grid .color-picker-picker")),i=t.getBoundingClientRect();e.css({left:i.width*o.saturationPos/100+"px"})})}},{key:"gridUpdate",value:function(){var o=angular.element(this.$element[0].querySelector(".color-picker-grid"));o.css({"background-color":this.grid})}},{key:"hueDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.hueMouse=!0}},{key:"hueUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.hueMouse=!1}},{key:"hueChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-hue");this.hue=360*(1-(o.pageY-this.offset(t).top)/t.prop("offsetHeight")),this.hue>360?this.hue=360:this.hue<0&&(this.hue=0)}},{key:"hueUpdate",value:function(){void 0!==this.hue&&(this.huePos=100*(1-this.hue/360),this.grid=tinycolor({h:this.hue,s:100,v:1}).toHslString(),this.huePos<0?this.huePos=0:this.huePos>100&&(this.huePos=100),this.huePosUpdate(),this.gridUpdate(),this.update())}},{key:"opacityDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.opacityMouse=!0}},{key:"opacityUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.opacityMouse=!1}},{key:"opacityChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-opacity");this.opacity=100*(1-(o.pageY-this.offset(t).top)/t.prop("offsetHeight")),this.opacity>100?this.opacity=100:this.opacity<0&&(this.opacity=0)}},{key:"opacityUpdate",value:function(){void 0!==this.opacity&&(this.opacityPos=100*(1-this.opacity/100),this.opacityPos<0?this.opacityPos=0:this.opacityPos>100&&(this.opacityPos=100),this.opacityPosUpdate(),this.update())}},{key:"colorDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.colorMouse=!0}},{key:"colorUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.colorMouse=!1}},{key:"colorChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-grid-inner"),e=this.offset(t);this.saturation=(o.pageX-e.left)/t.prop("offsetWidth")*100,this.lightness=100*(1-(o.pageY-e.top)/t.prop("offsetHeight")),this.saturation>100?this.saturation=100:this.saturation<0&&(this.saturation=0),this.lightness>100?this.lightness=100:this.lightness<0&&(this.lightness=0)}},{key:"saturationUpdate",value:function(o){void 0!==this.saturation&&(this.saturationPos=this.saturation/100*100,this.saturationPos<0?this.saturationPos=0:this.saturationPos>100&&(this.saturationPos=100),this.saturationPosUpdate(),this.update())}},{key:"lightnessUpdate",value:function(){void 0!==this.lightness&&(this.lightnessPos=100*(1-this.lightness/100),this.lightnessPos<0?this.lightnessPos=0:this.lightnessPos>100&&(this.lightnessPos=100),this.lightnessPosUpdate(),this.update())}},{key:"eventApiDispatch",value:function(o,t){this.eventApi&&"function"==typeof this.eventApi[o]&&(t||(t=[]),t.unshift(this.ngModel),t.unshift(this.api),this.eventApi[o].apply(this,t))}},{key:"find",value:function(o){var t,e=this.wrapper?this.wrapper[0]:this.$element[0],i=[];if(!o)return i;if("string"==typeof o){if(1!==(t=e.nodeType)&&9!==t)return[];i=e.querySelectorAll(o)}else e.contains(o)&&i.push(o);return angular.element(i)}},{key:"offset",value:function(o){var t,e,i,n,s=o[0];if(s)return s.getClientRects().length?(i=s.getBoundingClientRect(),i.width||i.height?(n=s.ownerDocument,e=null!==n&&n===n.window?n:9===n.nodeType&&n.defaultView,t=n.documentElement,this.chrome&&this.android_version<6&&screen.width<=768?{top:i.top-t.clientTop,left:i.left-t.clientLeft}:{top:i.top+e.pageYOffset-t.clientTop,left:i.left+e.pageXOffset-t.clientLeft}):i):{top:0,left:0}}}]),o}();s.$inject=["$scope","$element","$document","$timeout"],t.$inject=["$templateCache"];var r=angular.module("color.picker",[]).directive("colorPicker",o).run(t);return r});
!function(o,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):o.AngularjsColorPicker=t()}(this,function(){"use strict";function o(){return{restrict:"E",require:["^ngModel"],scope:{ngModel:"=",options:"=?",api:"=?",eventApi:"=?"},bindToController:!0,templateUrl:"template/color-picker/directive.html",controller:n,controllerAs:"AngularColorPickerController",link:function(o,t,e,i){o.control=i,o.init()}}}function t(o){o.put("template/color-picker/directive.html",'<div class="color-picker-wrapper" ng-class="{\'color-picker-disabled\': AngularColorPickerController.options.disabled,\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,}"> <div class="color-picker-input-wrapper" ng-class="{\'input-group\': AngularColorPickerController.options.swatchBootstrap && AngularColorPickerController.options.swatch}"> <span ng-if="AngularColorPickerController.options.swatchPos === \'left\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span> <input class="color-picker-input form-control" type="text" ng-model="AngularColorPickerController.ngModel" ng-readonly="AngularColorPickerController.options.swatchOnly" ng-disabled="AngularColorPickerController.options.disabled" ng-blur="AngularColorPickerController.onBlur($event)" ng-change="AngularColorPickerController.onChange($event)" size="7" ng-focus="AngularColorPickerController.api.open($event)" ng-class="{\'color-picker-input-swatch\': AngularColorPickerController.options.swatch && !AngularColorPickerController.options.swatchOnly && AngularColorPickerController.options.swatchPos === \'left\'}" placeholder="{{AngularColorPickerController.options.placeholder}}"> <span ng-if="AngularColorPickerController.options.swatchPos === \'right\'" class="color-picker-swatch" ng-click="AngularColorPickerController.focus()" ng-show="AngularColorPickerController.options.swatch" ng-class="{\'color-picker-swatch-left\': AngularColorPickerController.options.swatchPos !== \'right\', \'color-picker-swatch-right\': AngularColorPickerController.options.swatchPos === \'right\', \'input-group-addon\': AngularColorPickerController.options.swatchBootstrap}"></span> </div> <div class="color-picker-panel" ng-show="AngularColorPickerController.visible" ng-class="{ \'color-picker-panel-top color-picker-panel-right\': AngularColorPickerController.options.pos === \'top right\', \'color-picker-panel-top color-picker-panel-left\': AngularColorPickerController.options.pos === \'top left\', \'color-picker-panel-bottom color-picker-panel-right\': AngularColorPickerController.options.pos === \'bottom right\', \'color-picker-panel-bottom color-picker-panel-left\': AngularColorPickerController.options.pos === \'bottom left\', \'color-picker-panel-round\': AngularColorPickerController.options.round, \'color-picker-show-hue\': AngularColorPickerController.options.hue, \'color-picker-show-alpha\': AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\', \'color-picker-show-inline\': AngularColorPickerController.options.inline, }"> <div class="color-picker-grid-wrapper"> <div class="color-picker-row"> <div class="color-picker-grid color-picker-sprite"> <div class="color-picker-grid-inner"></div> <div class="color-picker-picker"> <div></div> </div> </div> <div class="color-picker-hue color-picker-sprite" ng-show="AngularColorPickerController.options.hue"> <div class="color-picker-slider"></div> </div> <div class="color-picker-opacity color-picker-sprite" ng-show="AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\'"> <div class="color-picker-slider"></div> </div> </div> </div> <div class="color-picker-actions"> <button class="color-picker-action color-picker-action-clear" ng-class="AngularColorPickerController.options.clear.class" ng-show="AngularColorPickerController.options.clear.show" ng-click="AngularColorPickerController.api.clear($event)" > {{AngularColorPickerController.options.clear.label}} </button><!-- --><button class="color-picker-action color-picker-action-reset" ng-class="AngularColorPickerController.options.reset.class" ng-show="AngularColorPickerController.options.reset.show" ng-click="AngularColorPickerController.api.reset($event)" > {{AngularColorPickerController.options.reset.label}} </button><!-- --><button class="color-picker-action color-picker-action-close" ng-class="AngularColorPickerController.options.close.class" ng-show="AngularColorPickerController.options.close.show" ng-click="AngularColorPickerController.api.close($event)" > {{AngularColorPickerController.options.close.label}} </button> </div> </div></div>')}var e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o},i=function(o,t){if(!(o instanceof t))throw new TypeError("Cannot call a class as a function")},s=function(){function o(o,t){for(var e=0;e<t.length;e++){var i=t[e];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(o,i.key,i)}}return function(t,e,i){return e&&o(t.prototype,e),i&&o(t,i),t}}(),n=function(){function o(t,e,s,n){i(this,o),this.$scope=t,this.$element=e,this.$document=s,this.$timeout=n,this.$scope.init=this.init.bind(this),this.hue=0,this.saturation=void 0,this.lightness=void 0,this.opacity=void 0}return s(o,[{key:"watchNgModel",value:function(o,t){var e=this;if(!this.colorMouse)if(void 0===o||void 0===t||this.hasOwnProperty("initialNgModel")||(this.initialNgModel=o),this.hasOwnProperty("initialNgModel")&&(o===this.initialNgModel?"function"==typeof this.$scope.control[0].$setPristine&&this.$scope.control[0].$setPristine():"function"==typeof this.$scope.control[0].$setDirty&&this.$scope.control[0].$setDirty()),void 0!==o&&null!==o&&o.length>4){var i=tinycolor(o);if(i.isValid()){var s=i.toHsv();this.updateModel=!1,this.hue=s.h,this.saturation=100*s.s,this.lightness=100*s.v,this.options.alpha&&(this.opacity=100*s.a),this.$timeout(function(){e.updateModel=!0}),this.isValid=!0}else this.isValid=!1;this.$scope.control[0].$setValidity(this.$element.attr("name"),this.isValid)}else null!==o&&""!==o||(this.hue=0,this.saturation=void 0,this.lightness=void 0,this.opacity=void 0),this.swatchColor=""}},{key:"watchSwatchPos",value:function(o){var t=this;void 0!==o&&(this.initConfig(),this.$timeout(function(){t.updateSwatchBackground()}))}},{key:"setupApi",value:function(){var o=this;this.api||(this.api={}),this.api.open=function(t){return!!o.visible||(o.visible=!0,o.hueMouse=!1,o.opacityMouse=!1,o.colorMouse=!1,o.hueUpdate(),o.saturationUpdate(),o.lightnessUpdate(),o.opacityUpdate(),void o.eventApiDispatch("onOpen",[t]))},this.api.close=function(t){o.options.inline||!o.visible&&null===o.$element[0].querySelector(".color-picker-panel").offsetParent||(o.visible=!1,o.$scope.$applyAsync(),o.eventApiDispatch("onClose",[t]))},this.api.clear=function(t){""!==o.ngModel&&(o.ngModel="",o.eventApiDispatch("onClear",[t]))},this.api.reset=function(t){o.ngModel!==o.initialNgModel&&(o.ngModel=o.initialNgModel,o.eventApiDispatch("onReset",[t]))},this.api.getElement=function(){return o.$element}}},{key:"reInit",value:function(o){void 0!==o&&this.initConfig()}},{key:"reInitAndUpdate",value:function(o){void 0!==o&&(this.initConfig(),this.update())}},{key:"init",value:function(){var o=this;this.chrome=Boolean(window.chrome);var t=window.navigator.userAgent.match(/Android\s([0-9\.]*)/i);this.android_version=t&&t.length>1?parseFloat(t[1]):NaN,this.updateModel=!0,this.$scope.$watch("AngularColorPickerController.ngModel",this.watchNgModel.bind(this)),this.$scope.$watch("AngularColorPickerController.options.swatchPos",this.watchSwatchPos.bind(this)),this.$scope.$watchGroup(["AngularColorPickerController.options.format","AngularColorPickerController.options.alpha","AngularColorPickerController.options.case"],this.reInitAndUpdate.bind(this)),this.$scope.$watchGroup(["AngularColorPickerController.options.disabled","AngularColorPickerController.options.swatchBootstrap","AngularColorPickerController.options.swatchOnly","AngularColorPickerController.options.swatch","AngularColorPickerController.options.pos","AngularColorPickerController.options.inline","AngularColorPickerController.options.placeholder","AngularColorPickerController.options.round"],this.reInit.bind(this)),this.$scope.$watch("AngularColorPickerController.api",this.setupApi.bind(this)),this.$scope.$watch("AngularColorPickerController.swatchColor",this.updateSwatchBackground.bind(this)),this.$scope.$watch("AngularColorPickerController.hue",this.hueUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.saturation",this.saturationUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.lightness",this.lightnessUpdate.bind(this)),this.$scope.$watch("AngularColorPickerController.opacity",this.opacityUpdate.bind(this)),this.$scope.$on("$destroy",function(){o.$document.off("mousedown",o.onMouseDown),o.$document.off("mouseup",o.onMouseUp),o.$document.off("mousemove",o.onMouseMove),o.$document.off("touchstart",o.onMouseDown),o.$document.off("touchend",o.onMouseUp),o.$document.off("touchmove",o.onMouseMove),o.eventApiDispatch("onDestroy")}),this.initConfig(),this.$document.on("mousedown",this.onMouseDown.bind(this)),this.$document.on("mouseup",this.onMouseUp.bind(this)),this.$document.on("mousemove",this.onMouseMove.bind(this)),this.$document.on("touchstart",this.onMouseDown.bind(this)),this.$document.on("touchend",this.onMouseUp.bind(this)),this.$document.on("touchmove",this.onMouseMove.bind(this)),this.find(".color-picker-grid").on("click",this.onColorClick.bind(this)),this.find(".color-picker-grid").on("touchend",this.onColorClick.bind(this)),this.find(".color-picker-hue").on("click",this.onHueClick.bind(this)),this.find(".color-picker-hue").on("touchend",this.onHueClick.bind(this)),this.find(".color-picker-opacity").on("click",this.onOpacityClick.bind(this)),this.find(".color-picker-opacity").on("touchend",this.onOpacityClick.bind(this))}},{key:"onMouseDown",value:function(o){!this.options.disabled&&this.find(o.target).length>0&&(o.target.classList.contains("color-picker-grid-inner")||o.target.classList.contains("color-picker-picker")||o.target.parentNode.classList.contains("color-picker-picker")?(this.colorDown(o),this.$scope.$apply()):o.target.classList.contains("color-picker-hue")||o.target.parentNode.classList.contains("color-picker-hue")?(this.hueDown(o),this.$scope.$apply()):(o.target.classList.contains("color-picker-opacity")||o.target.parentNode.classList.contains("color-picker-opacity"))&&(this.opacityDown(o),this.$scope.$apply()))}},{key:"onMouseUp",value:function(o){this.colorMouse||this.hueMouse||this.opacityMouse||0!==this.find(o.target).length?this.colorMouse?(this.colorUp(o),this.$scope.$apply(),this.onChange(o)):this.hueMouse?(this.hueUp(o),this.$scope.$apply(),this.onChange(o)):this.opacityMouse&&(this.opacityUp(o),this.$scope.$apply(),this.onChange(o)):(this.setupApi(),this.api.close(o),this.$scope.$apply())}},{key:"onMouseMove",value:function(o){this.colorMouse?(this.colorChange(o),this.$scope.$apply()):this.hueMouse?(this.hueChange(o),this.$scope.$apply()):this.opacityMouse&&(this.opacityChange(o),this.$scope.$apply())}},{key:"onColorClick",value:function(o){this.options.disabled||(this.colorChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onHueClick",value:function(o){this.options.disabled||(this.hueChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onOpacityClick",value:function(o){this.options.disabled||(this.opacityChange(o),this.$scope.$apply(),this.onChange(o))}},{key:"onChange",value:function(o){this.hasOwnProperty("onChangeValue")||(this.onChangeValue=this.ngModel),this.ngModel!==this.onChangeValue&&(this.onChangeValue=this.ngModel,this.eventApiDispatch("onChange",[o]))}},{key:"onBlur",value:function(o){this.ngModel!==this.onChangeValue&&(this.updateModel=!0,this.update()),this.eventApiDispatch("onBlur",[o])}},{key:"initConfig",value:function(){this.options=this.merge(this.options,{disabled:!1,hue:!0,alpha:!0,round:!1,case:"upper",format:"hsl",pos:"bottom left",swatch:!0,swatchOnly:!1,swatchPos:"left",swatchBootstrap:!0,inline:!1,placeholder:"",close:{show:!1,label:"Close",class:""},clear:{show:!1,label:"Clear",class:""},reset:{show:!1,label:"Reset",class:""}}),this.visible=this.options.inline,this.options.round&&(this.options.hue=!1)}},{key:"merge",value:function(o,t){var i,s={};for(i in t)t.hasOwnProperty(i)&&(s[i]=t[i]);if("object"===("undefined"==typeof o?"undefined":e(o)))for(i in o)o.hasOwnProperty(i)&&("object"===e(o[i])?s[i]=this.merge(o[i],s[i]):s[i]=o[i]);return s}},{key:"focus",value:function(){this.find(".color-picker-input")[0].focus()}},{key:"update",value:function(){if(void 0===this.hue||void 0===this.saturation||void 0===this.lightness)return!1;var o,t=tinycolor({h:this.hue,s:this.saturation/100,v:this.lightness/100});switch(this.options.alpha&&t.setAlpha(this.opacity/100),this.swatchColor=t.toHslString(),this.options.format){case"rgb":o=t.toRgbString();break;case"hex":o=t.toHexString(),o="lower"===this.options.case?o.toLowerCase():o.toUpperCase();break;case"hex8":o=t.toHex8String(),o="lower"===this.options.case?o.toLowerCase():o.toUpperCase();break;case"hsv":o=t.toHsvString();break;default:o=t.toHslString()}this.updateModel&&(this.ngModel=o)}},{key:"updateSwatchBackground",value:function(){var o=angular.element(this.$element[0].querySelector(".color-picker-swatch"));o.css({"background-color":this.swatchColor})}},{key:"huePosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-hue"),e=angular.element(o.$element[0].querySelector(".color-picker-hue .color-picker-slider")),i=t.getBoundingClientRect();e.css({top:i.height*o.huePos/100+"px"})})}},{key:"opacityPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-opacity"),e=angular.element(o.$element[0].querySelector(".color-picker-opacity .color-picker-slider")),i=t.getBoundingClientRect();e.css({top:i.height*o.opacityPos/100+"px"})})}},{key:"lightnessPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-grid"),e=angular.element(o.$element[0].querySelector(".color-picker-grid .color-picker-picker")),i=t.getBoundingClientRect();o.options.round||e.css({top:i.height*o.lightnessPos/100+"px"})})}},{key:"saturationPosUpdate",value:function(){var o=this;this.$timeout(function(){var t=o.$element[0].querySelector(".color-picker-grid"),e=angular.element(o.$element[0].querySelector(".color-picker-grid .color-picker-picker")),i=t.getBoundingClientRect();o.options.round?e.css({left:i.width*o.xPos/100+"px",top:i.height*o.yPos/100+"px"}):e.css({left:i.width*o.saturationPos/100+"px"})})}},{key:"gridUpdate",value:function(){var o=angular.element(this.$element[0].querySelector(".color-picker-grid"));o.css({"background-color":this.grid})}},{key:"hueDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.hueMouse=!0}},{key:"hueUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.hueMouse=!1}},{key:"hueChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-hue");this.hue=360*(1-(o.pageY-this.offset(t).top)/t.prop("offsetHeight")),this.hue>360?this.hue=360:this.hue<0&&(this.hue=0)}},{key:"hueUpdate",value:function(){void 0!==this.hue&&(this.huePos=100*(1-this.hue/360),this.grid=tinycolor({h:this.hue,s:100,v:1}).toHslString(),this.huePos<0?this.huePos=0:this.huePos>100&&(this.huePos=100),this.huePosUpdate(),this.gridUpdate(),this.update())}},{key:"opacityDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.opacityMouse=!0}},{key:"opacityUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.opacityMouse=!1}},{key:"opacityChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-opacity");this.opacity=100*(1-(o.pageY-this.offset(t).top)/t.prop("offsetHeight")),this.opacity>100?this.opacity=100:this.opacity<0&&(this.opacity=0)}},{key:"opacityUpdate",value:function(){void 0!==this.opacity&&(this.opacityPos=100*(1-this.opacity/100),this.opacityPos<0?this.opacityPos=0:this.opacityPos>100&&(this.opacityPos=100),this.opacityPosUpdate(),this.update())}},{key:"colorDown",value:function(o){o.stopPropagation(),o.preventDefault(),this.colorMouse=!0}},{key:"colorUp",value:function(o){o.stopPropagation(),o.preventDefault(),this.colorMouse=!1}},{key:"colorChange",value:function(o){o.stopPropagation(),o.preventDefault();var t=this.find(".color-picker-grid-inner"),e=this.offset(t);if(this.options.round){var i=2*(o.pageX-e.left)/t.prop("offsetWidth")-1,s=-(2*(o.pageY-e.top)/t.prop("offsetHeight"))+1,n=Math.sqrt(i*i+s*s),r=Math.atan2(s,i);this.saturation=100*n;var l=57.29577951308233*r;l<0&&(l+=360),this.hue=l,this.lightness=100}else this.saturation=(o.pageX-e.left)/t.prop("offsetWidth")*100,this.lightness=100*(1-(o.pageY-e.top)/t.prop("offsetHeight")),this.saturation>100?this.saturation=100:this.saturation<0&&(this.saturation=0),this.lightness>100?this.lightness=100:this.lightness<0&&(this.lightness=0)}},{key:"saturationUpdate",value:function(o){if(void 0!==this.saturation){if(this.options.round){var t=.01745329251994*this.hue,e=Math.cos(t)*this.saturation,i=-Math.sin(t)*this.saturation;this.xPos=.5*(e+100),this.yPos=.5*(i+100);var s=50,n=Math.pow(s-this.xPos,2)+Math.pow(s-this.yPos,2),r=Math.pow(s,2);if(n>r){var l=Math.atan2(this.yPos-s,this.xPos-s);this.xPos=Math.cos(l)*s+s,this.yPos=Math.sin(l)*s+s}}else this.saturationPos=this.saturation/100*100,this.saturationPos<0?this.saturationPos=0:this.saturationPos>100&&(this.saturationPos=100);this.saturationPosUpdate(),this.update()}}},{key:"lightnessUpdate",value:function(){void 0!==this.lightness&&(this.lightnessPos=100*(1-this.lightness/100),this.lightnessPos<0?this.lightnessPos=0:this.lightnessPos>100&&(this.lightnessPos=100),this.lightnessPosUpdate(),this.update())}},{key:"eventApiDispatch",value:function(o,t){this.eventApi&&"function"==typeof this.eventApi[o]&&(t||(t=[]),t.unshift(this.ngModel),t.unshift(this.api),this.eventApi[o].apply(this,t))}},{key:"find",value:function(o){var t,e=this.wrapper?this.wrapper[0]:this.$element[0],i=[];if(!o)return i;if("string"==typeof o){if(1!==(t=e.nodeType)&&9!==t)return[];i=e.querySelectorAll(o)}else e.contains(o)&&i.push(o);return angular.element(i)}},{key:"offset",value:function(o){var t,e,i,s,n=o[0];if(n)return n.getClientRects().length?(i=n.getBoundingClientRect(),i.width||i.height?(s=n.ownerDocument,e=null!==s&&s===s.window?s:9===s.nodeType&&s.defaultView,t=s.documentElement,this.chrome&&this.android_version<6&&screen.width<=768?{top:i.top-t.clientTop,left:i.left-t.clientLeft}:{top:i.top+e.pageYOffset-t.clientTop,left:i.left+e.pageXOffset-t.clientLeft}):i):{top:0,left:0}}}]),o}();n.$inject=["$scope","$element","$document","$timeout"],t.$inject=["$templateCache"];var r=angular.module("color.picker",[]).directive("colorPicker",o).run(t);return r});
{
"name": "angularjs-color-picker",
"description": "Color Picker Directive For AngularJS",
"version": "2.2.0",
"version": "2.3.0",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "dist/angularjs-color-picker.min.js",

@@ -75,2 +75,3 @@ # Angular Color Picker

disabled: [false, true],
round: [false, true],
format: ['hsl', 'hsv', 'rgb', 'hex', 'hex8'],

@@ -77,0 +78,0 @@ hue: [true, false],

@@ -194,3 +194,4 @@ export default class AngularColorPickerController {

'AngularColorPickerController.options.inline',
'AngularColorPickerController.options.placeholder'
'AngularColorPickerController.options.placeholder',
'AngularColorPickerController.options.round',
],

@@ -369,2 +370,3 @@ this.reInit.bind(this)

alpha: true,
round: false,
case: 'upper',

@@ -397,2 +399,6 @@ format: 'hsl',

this.visible = this.options.inline;
if (this.options.round) {
this.options.hue = false;
}
}

@@ -520,5 +526,7 @@

el.css({
'top': (bounding.height * this.lightnessPos / 100) + 'px',
});
if (!this.options.round) {
el.css({
'top': (bounding.height * this.lightnessPos / 100) + 'px',
});
}
});

@@ -533,5 +541,13 @@ }

el.css({
'left': (bounding.width * this.saturationPos / 100) + 'px',
});
if (this.options.round) {
el.css({
left: (bounding.width * this.xPos / 100) + 'px',
top: (bounding.height * this.yPos / 100) + 'px',
});
}
else {
el.css({
'left': (bounding.width * this.saturationPos / 100) + 'px',
});
}
});

@@ -669,15 +685,31 @@ }

this.saturation = ((event.pageX - offset.left) / el.prop('offsetWidth')) * 100;
this.lightness = (1 - ((event.pageY - offset.top) / el.prop('offsetHeight'))) * 100;
if (this.options.round) {
var dx = ((event.pageX - offset.left) * 2.0 / el.prop('offsetWidth')) - 1.0;
var dy = -((event.pageY - offset.top) * 2.0 / el.prop('offsetHeight')) + 1.0;
if (this.saturation > 100) {
this.saturation = 100;
} else if (this.saturation < 0) {
this.saturation = 0;
}
var tmpSaturation = Math.sqrt(dx * dx + dy * dy);
var tmpHue = Math.atan2(dy, dx);
if (this.lightness > 100) {
this.lightness = 100;
} else if (this.lightness < 0) {
this.lightness = 0;
this.saturation = 100 * tmpSaturation;
var degHue = tmpHue * 57.29577951308233; // rad to deg
if (degHue < 0.0) {
degHue += 360.0;
}
this.hue = degHue;
this.lightness = 100;
} else {
this.saturation = ((event.pageX - offset.left) / el.prop('offsetWidth')) * 100;
this.lightness = (1 - ((event.pageY - offset.top) / el.prop('offsetHeight'))) * 100;
if (this.saturation > 100) {
this.saturation = 100;
} else if (this.saturation < 0) {
this.saturation = 0;
}
if (this.lightness > 100) {
this.lightness = 100;
} else if (this.lightness < 0) {
this.lightness = 0;
}
}

@@ -688,8 +720,32 @@ }

if (this.saturation !== undefined) {
this.saturationPos = (this.saturation / 100) * 100;
if (this.options.round) {
var angle = this.hue * 0.01745329251994; // deg to rad
var px = Math.cos(angle) * this.saturation;
var py = -Math.sin(angle) * this.saturation;
if (this.saturationPos < 0) {
this.saturationPos = 0;
} else if (this.saturationPos > 100) {
this.saturationPos = 100;
this.xPos = (px + 100.0) * 0.5;
this.yPos = (py + 100.0) * 0.5;
// because we are using percentages this can be half of 100%
var center = 50;
// distance of pointer from the center of the circle
var distance = Math.pow(center - this.xPos, 2) + Math.pow(center - this.yPos, 2);
// distance of edge of circle from the center of the circle
var radius = Math.pow(center, 2);
// if not inside the circle
if (distance > radius) {
var rads = Math.atan2(this.yPos - center, this.xPos - center);
this.xPos = Math.cos(rads) * center + center;
this.yPos = Math.sin(rads) * center + center;
}
} else {
this.saturationPos = (this.saturation / 100) * 100;
if (this.saturationPos < 0) {
this.saturationPos = 0;
} else if (this.saturationPos > 100) {
this.saturationPos = 100;
}
}

@@ -696,0 +752,0 @@

export default function template($templateCache) {
$templateCache.put('template/color-picker/directive.html',
'<div class="color-picker-wrapper" ng-class="{' +
'\'color-picker-disabled\': AngularColorPickerController.options.disabled,' +
'\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,' +
'\'color-picker-disabled\': AngularColorPickerController.options.disabled,' +
'\'color-picker-swatch-only\': AngularColorPickerController.options.swatchOnly,' +
'}">' +

@@ -17,2 +17,3 @@ ' <div class="color-picker-input-wrapper" ng-class="{\'input-group\': AngularColorPickerController.options.swatchBootstrap && AngularColorPickerController.options.swatch}">' +

' \'color-picker-panel-bottom color-picker-panel-left\': AngularColorPickerController.options.pos === \'bottom left\',' +
' \'color-picker-panel-round\': AngularColorPickerController.options.round,' +
' \'color-picker-show-hue\': AngularColorPickerController.options.hue,' +

@@ -68,2 +69,3 @@ ' \'color-picker-show-alpha\': AngularColorPickerController.options.alpha && AngularColorPickerController.options.format !== \'hex\',' +

}
template.$inject = ['$templateCache'];

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

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc