cleaned up the button controls...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-11-10 05:18:44 +03:00
parent 2c650da183
commit bd729aa46b
2 changed files with 32 additions and 34 deletions

View File

@ -261,21 +261,7 @@ var FullScreenControllsActions = actions.Actions({
},
toggleFullScreenControls: ['Interface/',
toggler.Toggler(null,
function(){
return this.ribbons.viewer.find('.fullscreen-controls').length > 0 ? 'on' : 'off' },
['off', 'on'],
function(state){
if(state == 'on'){
var config = this.config['fullscreen-controls']
config
&& widgets.makeButtonControls(this, 'fullscreen-controls', config)
} else {
this.ribbons.viewer.find('.fullscreen-controls').remove()
}
})],
widgets.makeButtonControlsToggler('fullscreen-controls')],
})
var FullScreenControlls =

View File

@ -42,12 +42,14 @@ var browseWalk = require('lib/widget/browse-walk')
var makeButtonControls =
module.makeButtonControls =
function(context, cls, data){
cls = cls instanceof Array ? cls : cls.split(/\s+/g)
// remove old versions...
context.ribbons.viewer.find('.'+cls).remove()
context.ribbons.viewer.find('.'+ cls.join('.')).remove()
// make container...
var controls = $('<div>')
.addClass('buttons '+ cls)
.addClass('buttons '+ cls.join('.'))
.on('mouseover', function(){
var t = $(event.target)
@ -90,6 +92,30 @@ function(context, cls, data){
.appendTo(context.ribbons.viewer)
}
var makeButtonControlsToggler =
module.makeButtonControlsToggler =
function(cls, cfg){
cls = cls instanceof Array ? cls : cls.split(/\s+/g)
cfg = cfg || cls[0]
return toggler.Toggler(null,
function(){
return this.ribbons.viewer.find('.'+ cls.join('.')).length > 0 ? 'on' : 'off' },
['off', 'on'],
function(state){
if(state == 'on'){
var config = this.config[cfg]
config
&& makeButtonControls(this, cls, config)
} else {
this.ribbons.viewer.find('.'+ cls.join('.')).remove()
}
})
}
// XXX make the selector more accurate...
// ...at this point this will select the first elem with text which
@ -1082,25 +1108,11 @@ var MainControlsActions = actions.Actions({
},
toggleMainControls: ['Interface/',
toggler.Toggler(null,
function(){
return this.ribbons.viewer.find('.main-controls').length > 0 ? 'on' : 'off' },
['off', 'on'],
function(state){
if(state == 'on'){
var config = this.config['main-controls']
config
&& makeButtonControls(this, 'main-controls', config)
} else {
this.ribbons.viewer.find('.main-controls').remove()
}
})],
makeButtonControlsToggler('main-controls')],
})
var BrowseActions =
module.BrowseActions = core.ImageGridFeatures.Feature({
var MainControls =
module.MainControls = core.ImageGridFeatures.Feature({
title: '',
doc: '',