mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 22:45:46 +01:00
removed global admin object, CF rocket loader fix
added colorpicker module
This commit is contained in:
@@ -1,28 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*global define, socket, app, ajaxify, utils, Mousetrap, Hammer, RELATIVE_PATH*/
|
/*global define, socket, app, ajaxify, utils, Mousetrap, Hammer, RELATIVE_PATH*/
|
||||||
|
|
||||||
var admin = {};
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
admin.enableColorPicker = function(inputEl, callback) {
|
|
||||||
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function() {
|
|
||||||
var $this = $(this);
|
|
||||||
|
|
||||||
$this.ColorPicker({
|
|
||||||
color: $this.val() || '#000',
|
|
||||||
onChange: function(hsb, hex) {
|
|
||||||
$this.val('#' + hex);
|
|
||||||
if (typeof callback === 'function') {
|
|
||||||
callback(hsb, hex);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onShow: function(colpkr) {
|
|
||||||
$(colpkr).css('z-index', 1051);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
setupMenu();
|
setupMenu();
|
||||||
setupKeybindings();
|
setupKeybindings();
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH*/
|
/*global define, socket, app, bootbox, templates, ajaxify, RELATIVE_PATH*/
|
||||||
|
|
||||||
define('admin/manage/categories', ['uploader', 'admin/modules/iconSelect'], function(uploader, iconSelect) {
|
define('admin/manage/categories', [
|
||||||
|
'uploader',
|
||||||
|
'admin/modules/iconSelect',
|
||||||
|
'admin/modules/colorpicker'
|
||||||
|
], function(uploader, iconSelect, colorpicker) {
|
||||||
var Categories = {};
|
var Categories = {};
|
||||||
|
|
||||||
Categories.init = function() {
|
Categories.init = function() {
|
||||||
@@ -98,7 +102,7 @@ define('admin/manage/categories', ['uploader', 'admin/modules/iconSelect'], func
|
|||||||
var $inputEl = $(inputEl),
|
var $inputEl = $(inputEl),
|
||||||
previewEl = $inputEl.parents('[data-cid]').find('.preview-box');
|
previewEl = $inputEl.parents('[data-cid]').find('.preview-box');
|
||||||
|
|
||||||
admin.enableColorPicker($inputEl, function(hsb, hex) {
|
colorpicker.enable($inputEl, function(hsb, hex) {
|
||||||
if ($inputEl.attr('data-name') === 'bgColor') {
|
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||||
previewEl.css('background', '#' + hex);
|
previewEl.css('background', '#' + hex);
|
||||||
} else if ($inputEl.attr('data-name') === 'color') {
|
} else if ($inputEl.attr('data-name') === 'color') {
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*global define, templates, socket, ajaxify, app, admin, bootbox*/
|
/*global define, templates, socket, ajaxify, app, admin, bootbox*/
|
||||||
|
|
||||||
define('admin/manage/groups', ['admin/modules/iconSelect'], function(iconSelect) {
|
define('admin/manage/groups', [
|
||||||
|
'admin/modules/iconSelect',
|
||||||
|
'admin/modules/colorpicker'
|
||||||
|
], function(iconSelect, colorpicker) {
|
||||||
var Groups = {};
|
var Groups = {};
|
||||||
|
|
||||||
Groups.init = function() {
|
Groups.init = function() {
|
||||||
@@ -219,7 +222,7 @@ define('admin/manage/groups', ['admin/modules/iconSelect'], function(iconSelect)
|
|||||||
iconSelect.init(groupIcon);
|
iconSelect.init(groupIcon);
|
||||||
});
|
});
|
||||||
|
|
||||||
admin.enableColorPicker(changeGroupLabelColor, function(hsb, hex) {
|
colorpicker.enable(changeGroupLabelColor, function(hsb, hex) {
|
||||||
groupLabelPreview.css('background-color', '#' + hex);
|
groupLabelPreview.css('background-color', '#' + hex);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/*global define, socket, app, admin, utils, bootbox, RELATIVE_PATH*/
|
/*global define, socket, app, admin, utils, bootbox, RELATIVE_PATH*/
|
||||||
|
|
||||||
define('admin/manage/tags', ['forum/infinitescroll', 'admin/modules/selectable'], function(infinitescroll, selectable) {
|
define('admin/manage/tags', [
|
||||||
|
'forum/infinitescroll',
|
||||||
|
'admin/modules/selectable',
|
||||||
|
'admin/modules/colorpicker'
|
||||||
|
], function(infinitescroll, selectable, colorpicker) {
|
||||||
var Tags = {},
|
var Tags = {},
|
||||||
timeoutId = 0;
|
timeoutId = 0;
|
||||||
|
|
||||||
@@ -111,7 +115,7 @@ define('admin/manage/tags', ['forum/infinitescroll', 'admin/modules/selectable']
|
|||||||
var $inputEl = $(inputEl),
|
var $inputEl = $(inputEl),
|
||||||
previewEl = $inputEl.parents('.tag-row').find('.tag-item');
|
previewEl = $inputEl.parents('.tag-row').find('.tag-item');
|
||||||
|
|
||||||
admin.enableColorPicker($inputEl, function(hsb, hex) {
|
colorpicker.enable($inputEl, function(hsb, hex) {
|
||||||
if ($inputEl.attr('data-name') === 'bgColor') {
|
if ($inputEl.attr('data-name') === 'bgColor') {
|
||||||
previewEl.css('background-color', '#' + hex);
|
previewEl.css('background-color', '#' + hex);
|
||||||
} else if ($inputEl.attr('data-name') === 'color') {
|
} else if ($inputEl.attr('data-name') === 'color') {
|
||||||
|
|||||||
28
public/src/admin/modules/colorpicker.js
Normal file
28
public/src/admin/modules/colorpicker.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
/*globals define*/
|
||||||
|
|
||||||
|
define('admin/modules/colorpicker', function() {
|
||||||
|
var colorpicker = {};
|
||||||
|
|
||||||
|
colorpicker.enable = function(inputEl, callback) {
|
||||||
|
(inputEl instanceof jQuery ? inputEl : $(inputEl)).each(function() {
|
||||||
|
var $this = $(this);
|
||||||
|
|
||||||
|
$this.ColorPicker({
|
||||||
|
color: $this.val() || '#000',
|
||||||
|
onChange: function(hsb, hex) {
|
||||||
|
$this.val('#' + hex);
|
||||||
|
if (typeof callback === 'function') {
|
||||||
|
callback(hsb, hex);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onShow: function(colpkr) {
|
||||||
|
$(colpkr).css('z-index', 1051);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return colorpicker;
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user