ui: simplify icon insertion in labels, using '^' as prefix
This commit is contained in:
parent
4651cc7c5d
commit
0c922f8184
5 changed files with 14 additions and 10 deletions
|
|
@ -9,7 +9,8 @@ var widgets = require('../widgets'),
|
|||
sidepanelCreateToggle = require('../sidepanel').createToggle,
|
||||
editObject = function(a,b){require('./edit-objects').editObject(a,b,true)},
|
||||
editSession = function(a,b){require('./edit-objects').editSession(a,b,true)},
|
||||
purgeStores = require('./purge')
|
||||
purgeStores = require('./purge'),
|
||||
{iconify} = require('../utils')
|
||||
|
||||
|
||||
var getObjectData = function(obj){
|
||||
|
|
@ -75,7 +76,7 @@ var updateDom = function(container,data, remote) {
|
|||
container.removeClass('has-tabs')
|
||||
}
|
||||
|
||||
$(`[data-tab="#${container.attr('id')}"]`).html(`<a><span>${data.label}</span></a>`)
|
||||
$(`[data-tab="#${container.attr('id')}"]`).html(`<a><span>${iconify(data.label)}</span></a>`)
|
||||
|
||||
if (!remote) editObject(newContainer,data)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
var widgets = require('./widgets'),
|
||||
widgetOptions = widgets.widgetOptions,
|
||||
createWidget = widgets.createWidget,
|
||||
icon = require('./utils').icon
|
||||
{iconify} = require('./utils')
|
||||
|
||||
var getIterator = function(id,type){
|
||||
var iterator = MISC.iterators[type]
|
||||
|
|
@ -53,17 +53,18 @@ module.exports.tabs = function(data,parent,main,parentLabel){
|
|||
hash = hashCode(label),
|
||||
id = 'tab_'+hash+'_'+getIterator('tab'+hash,'tab')
|
||||
|
||||
tabData.label = label
|
||||
tabData.label = iconify(label)
|
||||
|
||||
delete tabData.id
|
||||
|
||||
navtabs.append(`<li data-tab="#${id}"><a><span>${label}</span></a></li>`)
|
||||
navtabs.append(`<li data-tab="#${id}"><a><span>${tabData.label}</span></a></li>`)
|
||||
|
||||
var tabContent = $(`<div class="tab ${tabData.tabs&&tabData.tabs.length?'has-tabs':''}" id="${id}" data-index="${i}"></div>`)
|
||||
tabContent.data(tabData)
|
||||
|
||||
|
||||
if (tabData.tabs && tabData.tabs.length) {
|
||||
module.exports.tabs(tabData.tabs,tabContent,false,label)
|
||||
module.exports.tabs(tabData.tabs,tabContent,false,tabData.label)
|
||||
} else if (tabData.widgets && tabData.widgets.length) {
|
||||
module.exports.widgets(tabData.widgets,tabContent)
|
||||
}
|
||||
|
|
@ -160,9 +161,7 @@ module.exports.widgets = function(data,parent) {
|
|||
// Generate label, iconify if starting with "icon:"
|
||||
var label = widgetData.label == 'auto'?
|
||||
widgetData.id:
|
||||
typeof widgetData.label == 'string' && widgetData.label.indexOf('icon:')!=-1?
|
||||
icon(widgetData.label.split(':')[1].trim().replace('fa-','')):
|
||||
widgetData.label
|
||||
iconify(widgetData.label)
|
||||
|
||||
// create container
|
||||
var widgetContainer = $(`
|
||||
|
|
|
|||
|
|
@ -41,6 +41,9 @@ module.exports = {
|
|||
},
|
||||
icon: function(i) {
|
||||
return `<i class="fa fa-fw fa-${i}"></i>`
|
||||
},
|
||||
iconify:function(string){
|
||||
return String(string).replace(/\^[^\s]*/g,(x)=>{return module.exports.icon(x.substring(1))})
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue