mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-11 08:25:46 +01:00
icon mgmt for #2463
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"use strict";
|
||||
/*global define */
|
||||
/*global define, app, socket, ajaxify, RELATIVE_PATH, bootbox */
|
||||
|
||||
define('admin/manage/category', [
|
||||
'uploader',
|
||||
@@ -11,10 +11,8 @@ define('admin/manage/category', [
|
||||
Category.init = function() {
|
||||
var modified_categories = {};
|
||||
|
||||
function modified(el, cid) {
|
||||
if (!cid) {
|
||||
cid = $(el).parents('form').attr('data-cid');
|
||||
}
|
||||
function modified(el) {
|
||||
var cid = $(el).parents('form').attr('data-cid');
|
||||
|
||||
if (cid) {
|
||||
modified_categories[cid] = modified_categories[cid] || {};
|
||||
@@ -115,13 +113,18 @@ define('admin/manage/category', [
|
||||
|
||||
uploader.open(RELATIVE_PATH + '/admin/category/uploadpicture', { cid: cid }, 0, function(imageUrlOnServer) {
|
||||
inputEl.val(imageUrlOnServer);
|
||||
var previewBox = inputEl.siblings('.category-preview');
|
||||
var previewBox = inputEl.parent().siblings('.category-preview');
|
||||
previewBox.css('background', 'url(' + imageUrlOnServer + '?' + new Date().getTime() + ')')
|
||||
.css('background-size', 'cover');
|
||||
modified(inputEl[0], cid);
|
||||
modified(inputEl[0]);
|
||||
});
|
||||
});
|
||||
|
||||
// Icon selection
|
||||
$('.category-preview').on('click', function(ev) {
|
||||
iconSelect.init($(this).find('i'), modified);
|
||||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ define(function() {
|
||||
selected = 'fa-doesnt-exist';
|
||||
}
|
||||
if (selected) {
|
||||
$('#icons .fa-icons .fa.' + selected).parent().addClass('selected');
|
||||
$('#icons .fa-icons .fa.' + selected).addClass('selected');
|
||||
}
|
||||
|
||||
bootbox.confirm('<h2>Select an icon.</h2>' + $('#icons').html(), function(confirm) {
|
||||
@@ -29,6 +29,7 @@ define(function() {
|
||||
el.val(categoryIconClass);
|
||||
el.attr('value', categoryIconClass);
|
||||
|
||||
console.log(el);
|
||||
onModified(el);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<div class="row">
|
||||
<form role="form" class="category" data-cid="{category.cid}">
|
||||
<div class="col-md-9">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading"><i class="fa fa-folder"></i> Categories</div>
|
||||
@@ -15,7 +16,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form role="form" class="category" data-cid="{category.cid}">
|
||||
|
||||
<h3 data-edit-target="#cid-{category.cid}-name"><span>{category.name}</span> <small><i class="fa fa-edit"></i></small></h3>
|
||||
<input id="cid-{category.cid}-name" type="text" class="form-control hide" placeholder="Category Name" data-name="name" value="{category.name}" />
|
||||
<h4 data-edit-target="#cid-{category.cid}-description"><span>{category.description}</span> <small><i class="fa fa-edit"></i></small></h4>
|
||||
@@ -78,11 +79,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IMPORT admin/partials/categories/permissions.tpl -->
|
||||
</div>
|
||||
|
||||
<div class="col-md-3 options">
|
||||
@@ -99,10 +97,12 @@
|
||||
<i data-name="icon" value="{category.icon}" class="fa {category.icon} fa-2x"></i>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" data-cid="{category.cid}" data-name="image" data-value="{categories.image}" class="btn btn-default upload-button"><i class="fa fa-upload"></i> Upload Image</button>
|
||||
<!-- IF categories.image -->
|
||||
<small class="pointer delete-image"><i data-name="icon" value="fa-times" class="fa fa-times"></i></small>
|
||||
<!-- ENDIF categories.image -->
|
||||
<div class="btn-group-vertical">
|
||||
<button type="button" data-cid="{category.cid}" data-name="image" data-value="{category.image}" class="btn btn-default upload-button"><i class="fa fa-upload"></i> Upload Image</button>
|
||||
<!-- IF category.image -->
|
||||
<button class="btn btn-warning delete-image"><i data-name="icon" value="fa-times" class="fa fa-times"></i> Remove Image</button>
|
||||
<!-- ENDIF category.image -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -128,4 +128,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
Reference in New Issue
Block a user