admin: Fix color transformer
This commit is contained in:
parent
b4ec736948
commit
382417b9ff
@ -371,11 +371,14 @@ angular.module("FICApp")
|
|||||||
.filter("toColor", function() {
|
.filter("toColor", function() {
|
||||||
return function(num) {
|
return function(num) {
|
||||||
num >>>= 0;
|
num >>>= 0;
|
||||||
var b = num & 0xFF,
|
var b = (num & 0xFF).toString(16),
|
||||||
g = (num & 0xFF00) >>> 8,
|
g = ((num & 0xFF00) >>> 8).toString(16),
|
||||||
r = (num & 0xFF0000) >>> 16,
|
r = ((num & 0xFF0000) >>> 16).toString(16),
|
||||||
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
||||||
return "#" + r.toString(16) + g.toString(16) + b.toString(16);
|
if (r.length <= 1) r = "0" + r;
|
||||||
|
if (g.length <= 1) g = "0" + g;
|
||||||
|
if (b.length <= 1) b = "0" + b;
|
||||||
|
return "#" + r + g + b;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.filter("cksum", function() {
|
.filter("cksum", function() {
|
||||||
@ -413,11 +416,14 @@ angular.module("FICApp")
|
|||||||
link: function(scope, ele, attr, ctrl){
|
link: function(scope, ele, attr, ctrl){
|
||||||
ctrl.$formatters.unshift(function(num){
|
ctrl.$formatters.unshift(function(num){
|
||||||
num >>>= 0;
|
num >>>= 0;
|
||||||
var b = num & 0xFF,
|
var b = (num & 0xFF).toString(16),
|
||||||
g = (num & 0xFF00) >>> 8,
|
g = ((num & 0xFF00) >>> 8).toString(16),
|
||||||
r = (num & 0xFF0000) >>> 16,
|
r = ((num & 0xFF0000) >>> 16).toString(16),
|
||||||
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
a = ( (num & 0xFF000000) >>> 24 ) / 255 ;
|
||||||
return "#" + r.toString(16) + g.toString(16) + b.toString(16);
|
if (r.length <= 1) r = "0" + r;
|
||||||
|
if (g.length <= 1) g = "0" + g;
|
||||||
|
if (b.length <= 1) b = "0" + b;
|
||||||
|
return "#" + r + g + b;
|
||||||
});
|
});
|
||||||
ctrl.$parsers.unshift(function(viewValue){
|
ctrl.$parsers.unshift(function(viewValue){
|
||||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(viewValue);
|
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(viewValue);
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
<label for="{{ field }}" class="col-sm-2 col-form-label-sm">{{ field | capitalize }}</label>
|
<label for="{{ field }}" class="col-sm-2 col-form-label-sm">{{ field | capitalize }}</label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="team[field]" ng-if="field != 'color'">
|
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="team[field]" ng-if="field != 'color'">
|
||||||
<input type="color" class="form-control form-control-sm" id="{{ field }}{{ member.id }}" ng-model="team[field]" ng-if="field == 'color'" color>
|
<input type="color" class="form-control form-control-sm" id="{{ field }}" ng-model="team[field]" ng-if="field == 'color'" color>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" ng-if="team.id">
|
<div class="row" ng-if="team.id">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user