added public/src/admin.js; moved enableColorPicker into admin.enableColorPicker

v1.18.x
psychobunny 11 years ago
parent e2312c8330
commit 29137299c2

@ -0,0 +1,19 @@
"use strict";
var admin = {};
(function() {
admin.enableColorPicker = function(inputEl, callback) {
inputEl.ColorPicker({
color: inputEl.val() || '#000',
onChange: function(hsb, hex) {
inputEl.val('#' + hex);
if (typeof callback === 'function') {
callback(hsb, hex);
}
}
});
};
}());

@ -139,21 +139,17 @@ define(['uploader'], function(uploader) {
}
function enableColorPicker(idx, inputEl) {
var $inputEl = $(inputEl),
var $inputEl = $(inputEl),
previewEl = $inputEl.parents('[data-cid]').find('.preview-box');
$inputEl.ColorPicker({
color: $inputEl.val() || '#000',
onChange: function(hsb, hex) {
$inputEl.val('#' + hex);
if ($inputEl.attr('data-name') === 'bgColor') {
previewEl.css('background', '#' + hex);
} else if ($inputEl.attr('data-name') === 'color') {
previewEl.css('color', '#' + hex);
}
modified($inputEl[0]);
admin.enableColorPicker($inputEl, function(hsb, hex) {
if ($inputEl.attr('data-name') === 'bgColor') {
previewEl.css('background', '#' + hex);
} else if ($inputEl.attr('data-name') === 'color') {
previewEl.css('color', '#' + hex);
}
modified($inputEl[0]);
});
}

Loading…
Cancel
Save