Change browser color picker to jscolor picker for cursor color

pull/1/head
ClemDee 6 years ago
parent 0636714829
commit f3bb56925b

@ -111,8 +111,14 @@
vertical-align: middle; vertical-align: middle;
margin-right: 5px; margin-right: 5px;
} }
input[type="color"] { .cp-settings-cursor-color-picker {
width: 100px; display: inline-block;
vertical-align: middle;
height: 25px;
width: 70px;
margin-right: 10px;
cursor: pointer;
border: 1px solid black;
} }
.cp-settings-language-selector { .cp-settings-language-selector {
button.btn { button.btn {

@ -15,6 +15,7 @@ define([
'/settings/make-backup.js', '/settings/make-backup.js',
'/common/common-feedback.js', '/common/common-feedback.js',
'/common/jscolor.js',
'/bower_components/file-saver/FileSaver.min.js', '/bower_components/file-saver/FileSaver.min.js',
'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css',
'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css',
@ -1191,13 +1192,13 @@ define([
var $inputBlock = $('<div>').appendTo($div); var $inputBlock = $('<div>').appendTo($div);
var $colorPicker = $("<div>", { class: "cp-settings-cursor-color-picker"});
var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved}); var $ok = $('<span>', {'class': 'fa fa-check', title: Messages.saved});
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}); var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'});
var $input = $('<input>', { // when jscolor picker value change
type: 'color', var onchange = function (colorL) {
}).on('change', function () { var val = "#" + colorL.toString();
var val = $input.val();
if (!/^#[0-9a-fA-F]{6}$/.test(val)) { return; } if (!/^#[0-9a-fA-F]{6}$/.test(val)) { return; }
$spinner.show(); $spinner.show();
$ok.hide(); $ok.hide();
@ -1205,15 +1206,27 @@ define([
$spinner.hide(); $spinner.hide();
$ok.show(); $ok.show();
}); });
}).appendTo($inputBlock); $colorPicker.css('bakcground-color', val);
};
$ok.hide().appendTo($inputBlock); // jscolor picker
$spinner.hide().appendTo($inputBlock); var jscolorL = new window.jscolor($colorPicker[0],{showOnClick: false, onFineChange: onchange, valueElement:undefined});
$colorPicker.click(function () {
jscolorL.show();
});
// set default color
common.getAttribute(['general', 'cursor', 'color'], function (e, val) { common.getAttribute(['general', 'cursor', 'color'], function (e, val) {
if (e) { return void console.error(e); } if (e) { return void console.error(e); }
$input.val(val || ''); val = val || "#000";
$colorPicker.css('bakcground-color', val);
jscolorL.fromString(val);
}); });
$colorPicker.appendTo($inputBlock);
$ok.hide().appendTo($inputBlock);
$spinner.hide().appendTo($inputBlock);
return $div; return $div;
}; };

Loading…
Cancel
Save