mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
refactored button controls...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
abc1fd64b5
commit
9ea06bffdb
@ -18,6 +18,8 @@ var toggler = require('lib/toggler')
|
|||||||
var core = require('features/core')
|
var core = require('features/core')
|
||||||
var base = require('features/base')
|
var base = require('features/base')
|
||||||
|
|
||||||
|
var widgets = require('features/ui-widgets')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
@ -247,54 +249,31 @@ module.AppControl = core.ImageGridFeatures.Feature({
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Fullscreen app control buttons...
|
// Fullscreen app control buttons...
|
||||||
var FullScreenControllsActions = actions.Actions({
|
var FullScreenControllsActions = actions.Actions({
|
||||||
|
config: {
|
||||||
|
'fullscreen-controls': {
|
||||||
|
'_': ['minimize',
|
||||||
|
'minimize -- Minimize'],
|
||||||
|
'↙': ['fullscreen allways-shown',
|
||||||
|
'toggleFullScreen -- Toggle fullscreen'],
|
||||||
|
'×': ['close',
|
||||||
|
'close -- Quit'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
toggleFullScreenControls: ['Interface/',
|
toggleFullScreenControls: ['Interface/',
|
||||||
toggler.Toggler(null,
|
toggler.Toggler(null,
|
||||||
function(){
|
function(){
|
||||||
return this.ribbons.viewer.find('.fullscreen-controls').length > 0 ? 'on' : 'off' },
|
return this.ribbons.viewer.find('.fullscreen-controls').length > 0 ? 'on' : 'off' },
|
||||||
['off', 'on'],
|
['off', 'on'],
|
||||||
function(state){
|
function(state){
|
||||||
// clear the controls....
|
|
||||||
this.ribbons.viewer.find('.fullscreen-controls').remove()
|
|
||||||
|
|
||||||
if(state == 'on'){
|
if(state == 'on'){
|
||||||
var that = this
|
var config = this.config['fullscreen-controls']
|
||||||
|
|
||||||
$('<div>')
|
config
|
||||||
.addClass('fullscreen-controls buttons')
|
&& widgets.makeButtonControls(this, 'fullscreen-controls', config)
|
||||||
// minimize....
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button minimize')
|
|
||||||
.html('_')
|
|
||||||
.attr('info', 'Minimize')
|
|
||||||
.click(function(){ that.minimize() }))
|
|
||||||
// fullscreen....
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button fullscreen allways-shown')
|
|
||||||
// square...
|
|
||||||
//.html('□')
|
|
||||||
// diagonal arrows...
|
|
||||||
.html('↙')
|
|
||||||
.attr('info', 'Toggle fullscreen')
|
|
||||||
.click(function(){ that.toggleFullScreen() }))
|
|
||||||
// close...
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button close')
|
|
||||||
.html('×')
|
|
||||||
.attr('info', 'Close')
|
|
||||||
.click(function(){ that.close() }))
|
|
||||||
|
|
||||||
.on('mouseover', function(){
|
} else {
|
||||||
var t = $(event.target)
|
this.ribbons.viewer.find('.fullscreen-controls').remove()
|
||||||
|
|
||||||
var info = t.attr('info') || t.parents('[info]').attr('info') || ''
|
|
||||||
|
|
||||||
that.showStatusBarInfo(info)
|
|
||||||
})
|
|
||||||
.on('mouseout', function(){
|
|
||||||
that.showStatusBarInfo()
|
|
||||||
})
|
|
||||||
|
|
||||||
.appendTo(this.ribbons.viewer)
|
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
})
|
})
|
||||||
@ -316,6 +295,7 @@ module.FullScreenControlls = core.ImageGridFeatures.Feature({
|
|||||||
['toggleFullScreen',
|
['toggleFullScreen',
|
||||||
function(){
|
function(){
|
||||||
this.toggleFullScreenControls('on')
|
this.toggleFullScreenControls('on')
|
||||||
|
|
||||||
var fullscreen = this.toggleFullScreen('?')
|
var fullscreen = this.toggleFullScreen('?')
|
||||||
var buttons = this.ribbons.viewer.find('.fullscreen-controls')
|
var buttons = this.ribbons.viewer.find('.fullscreen-controls')
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,65 @@ var browseWalk = require('lib/widget/browse-walk')
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
// Format:
|
||||||
|
// {
|
||||||
|
// <button-text>: [
|
||||||
|
// <class>, // optional
|
||||||
|
// <info>, // optional
|
||||||
|
// <code>,
|
||||||
|
// ],
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
var makeButtonControls =
|
||||||
|
module.makeButtonControls =
|
||||||
|
function(context, cls, data){
|
||||||
|
// remove old versions...
|
||||||
|
context.ribbons.viewer.find('.'+cls).remove()
|
||||||
|
|
||||||
|
// make container...
|
||||||
|
var controls = $('<div>')
|
||||||
|
.addClass('buttons '+ cls)
|
||||||
|
.on('mouseover', function(){
|
||||||
|
var t = $(event.target)
|
||||||
|
|
||||||
|
var info = t.attr('info') || t.parents('[info]').attr('info') || ''
|
||||||
|
|
||||||
|
context.showStatusBarInfo(info)
|
||||||
|
})
|
||||||
|
.on('mouseout', function(){
|
||||||
|
context.showStatusBarInfo()
|
||||||
|
})
|
||||||
|
|
||||||
|
// make buttons...
|
||||||
|
Object.keys(data).forEach(function(k){
|
||||||
|
var e = data[k].slice()
|
||||||
|
var code = e.pop()
|
||||||
|
|
||||||
|
code = typeof(code) == typeof('str') ?
|
||||||
|
keyboard.parseActionCall(code)
|
||||||
|
: code
|
||||||
|
|
||||||
|
var func = code instanceof Function ?
|
||||||
|
code
|
||||||
|
: function(){
|
||||||
|
context[code.action].apply(context, code.arguments) }
|
||||||
|
|
||||||
|
var cls = e[0] || code.action || ''
|
||||||
|
var doc = e[1] || code.doc || e[0] || ''
|
||||||
|
|
||||||
|
controls
|
||||||
|
.append($('<div>')
|
||||||
|
.addClass('button ' + cls)
|
||||||
|
.html(k)
|
||||||
|
.attr('info', doc)
|
||||||
|
.click(func))
|
||||||
|
})
|
||||||
|
|
||||||
|
controls
|
||||||
|
.appendTo(context.ribbons.viewer)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// XXX make the selector more accurate...
|
// XXX make the selector more accurate...
|
||||||
// ...at this point this will select the first elem with text which
|
// ...at this point this will select the first elem with text which
|
||||||
// can be a different elem...
|
// can be a different elem...
|
||||||
@ -1004,9 +1063,16 @@ module.ContextActionMenu = core.ImageGridFeatures.Feature({
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// XXX make this not applicable to production...
|
// XXX make this not applicable to production...
|
||||||
|
|
||||||
|
|
||||||
var WidgetTestActions = actions.Actions({
|
var WidgetTestActions = actions.Actions({
|
||||||
config: {
|
config: {
|
||||||
'main-controls': 'on',
|
'main-controls-state': 'on',
|
||||||
|
'main-controls': {
|
||||||
|
'☰': ['menu',
|
||||||
|
'browseActions -- Show action menu...'],
|
||||||
|
'C<sub/>': ['crop',
|
||||||
|
'browseActions: "Crop/" -- Show crop menu...'],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
testAction: ['- Test/',
|
testAction: ['- Test/',
|
||||||
@ -1159,8 +1225,6 @@ var WidgetTestActions = actions.Actions({
|
|||||||
setTimeout(step, 1000)
|
setTimeout(step, 1000)
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// XXX this essentially mirrors app's .toggleFullScreenControls(..)
|
|
||||||
// ...need to make a buttons generator...
|
|
||||||
// XXX move this out...
|
// XXX move this out...
|
||||||
// XXX also see handlers....
|
// XXX also see handlers....
|
||||||
toggleMainControls: ['Interface/',
|
toggleMainControls: ['Interface/',
|
||||||
@ -1169,54 +1233,14 @@ var WidgetTestActions = actions.Actions({
|
|||||||
return this.ribbons.viewer.find('.main-controls').length > 0 ? 'on' : 'off' },
|
return this.ribbons.viewer.find('.main-controls').length > 0 ? 'on' : 'off' },
|
||||||
['off', 'on'],
|
['off', 'on'],
|
||||||
function(state){
|
function(state){
|
||||||
// clear the controls....
|
|
||||||
this.ribbons.viewer.find('.main-controls').remove()
|
|
||||||
|
|
||||||
if(state == 'on'){
|
if(state == 'on'){
|
||||||
var that = this
|
var config = this.config['main-controls']
|
||||||
|
|
||||||
$('<div>')
|
config
|
||||||
.addClass('main-controls buttons')
|
&& makeButtonControls(this, 'main-controls', config)
|
||||||
// menu....
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button')
|
|
||||||
.html('☰')
|
|
||||||
.attr('info', 'Show action menu...')
|
|
||||||
// XXX show this in status bar... (???)
|
|
||||||
.click(function(){ that.browseActions() }))
|
|
||||||
/*
|
|
||||||
// XXX make the rest configurable... (???)
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button')
|
|
||||||
.html('O')
|
|
||||||
.click(function(){ }))
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button')
|
|
||||||
.html('H')
|
|
||||||
.click(function(){ }))
|
|
||||||
//*/
|
|
||||||
// crop menu/status....
|
|
||||||
.append($('<div>')
|
|
||||||
.addClass('button crop')
|
|
||||||
.html('C')
|
|
||||||
// crop status...
|
|
||||||
.append($('<sub/>')
|
|
||||||
.addClass('status'))
|
|
||||||
.attr('info', 'Show crop menu...')
|
|
||||||
.click(function(){ that.browseActions('Crop/') }))
|
|
||||||
|
|
||||||
.on('mouseover', function(){
|
} else {
|
||||||
var t = $(event.target)
|
this.ribbons.viewer.find('.main-controls').remove()
|
||||||
|
|
||||||
var info = t.attr('info') || t.parents('[info]').attr('info') || ''
|
|
||||||
|
|
||||||
that.showStatusBarInfo(info)
|
|
||||||
})
|
|
||||||
.on('mouseout', function(){
|
|
||||||
that.showStatusBarInfo()
|
|
||||||
})
|
|
||||||
|
|
||||||
.appendTo(this.ribbons.viewer)
|
|
||||||
}
|
}
|
||||||
})],
|
})],
|
||||||
|
|
||||||
@ -1430,11 +1454,11 @@ module.WidgetTest = core.ImageGridFeatures.Feature({
|
|||||||
// main controls stuff...
|
// main controls stuff...
|
||||||
['start',
|
['start',
|
||||||
function(){
|
function(){
|
||||||
this.toggleMainControls(this.config['main-controls'] || 'on') }],
|
this.toggleMainControls(this.config['main-controls-state'] || 'on') }],
|
||||||
['load reload',
|
['load reload',
|
||||||
function(){
|
function(){
|
||||||
// update crop button status...
|
// update crop button status...
|
||||||
$('.main-controls.buttons .crop.button .status')
|
$('.main-controls.buttons .crop.button sub')
|
||||||
.text(this.crop_stack ? this.crop_stack.length : '') }]
|
.text(this.crop_stack ? this.crop_stack.length : '') }]
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user