v1.18.x
parent
d8dfda4a54
commit
da8b1b605c
@ -0,0 +1,33 @@
|
||||
'use strict';
|
||||
|
||||
|
||||
define('categorySelector', function () {
|
||||
var categorySelector = {};
|
||||
var selectedCategory;
|
||||
var el;
|
||||
categorySelector.init = function (_el, callback) {
|
||||
callback = callback || function () {};
|
||||
el = _el;
|
||||
el.on('click', '[data-cid]', function () {
|
||||
var categoryEl = $(this);
|
||||
categorySelector.selectCategory(categoryEl.attr('data-cid'));
|
||||
callback(selectedCategory);
|
||||
});
|
||||
};
|
||||
|
||||
categorySelector.getSelectedCategory = function () {
|
||||
return selectedCategory;
|
||||
};
|
||||
|
||||
categorySelector.selectCategory = function (cid) {
|
||||
var categoryEl = el.find('[data-cid="' + cid + '"]');
|
||||
selectedCategory = {
|
||||
cid: cid,
|
||||
name: categoryEl.attr('data-name'),
|
||||
};
|
||||
el.find('[component="category-selector-selected"]').html(categoryEl.find('[component="category-markup"]').html());
|
||||
};
|
||||
|
||||
return categorySelector;
|
||||
});
|
||||
|
@ -1,10 +1,16 @@
|
||||
<form type="form">
|
||||
<div class="form-group">
|
||||
<label for="select-cid">[[admin/manage/categories:select-category]]</label>
|
||||
<select class="form-control" name="select-cid" id="select-cid">
|
||||
<!-- BEGIN categories -->
|
||||
<option value="{categories.cid}">{categories.text}</option>
|
||||
<!-- END categories -->
|
||||
</select>
|
||||
<div component="category-selector" class="btn-group">
|
||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
|
||||
<span component="category-selector-selected">[[topic:thread_tools.select_category]]</span> <span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu category-dropdown-menu" role="menu">
|
||||
<!-- BEGIN categories -->
|
||||
<li role="presentation" class="category" data-cid="{categories.cid}" data-name="{categories.name}">
|
||||
<a role="menu-item">{categories.level}<span component="category-markup"><!-- IF categories.icon --><span class="fa-stack"><i style="color: {categories.bgColor};" class="fa fa-circle fa-stack-2x"></i><i style="color: {categories.color};" class="fa fa-stack-1x fa-fw {categories.icon}"></i></span><!-- ENDIF categories.icon --> {categories.name}</span></a>
|
||||
</li>
|
||||
<!-- END categories -->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
Loading…
Reference in New Issue