mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
tweaking buttons...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
74ad368a30
commit
584f8dee65
@ -260,6 +260,7 @@ requirejs([
|
|||||||
'buttonAction: item button focused -- example button action...'],
|
'buttonAction: item button focused -- example button action...'],
|
||||||
['□',
|
['□',
|
||||||
function(){ console.log('BUTTON:', ...arguments) }],
|
function(){ console.log('BUTTON:', ...arguments) }],
|
||||||
|
'ToggleDisabled',
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -160,6 +160,35 @@ Items.nest = function(item, list, options){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// Buttons...
|
||||||
|
var buttons = Items.buttons = {}
|
||||||
|
|
||||||
|
|
||||||
|
buttons.ToggleDisabled = [
|
||||||
|
function(item){
|
||||||
|
return item.disabled ?
|
||||||
|
'☐'
|
||||||
|
: '☑' },
|
||||||
|
'toggleDisabled: item',
|
||||||
|
true]
|
||||||
|
|
||||||
|
buttons.ToggleHidden = [
|
||||||
|
function(item){
|
||||||
|
return item.hidden ?
|
||||||
|
'☐'
|
||||||
|
: '☑' },
|
||||||
|
'toggleHidden: item']
|
||||||
|
|
||||||
|
buttons.ToggleSelected = [
|
||||||
|
function(item){
|
||||||
|
return item.selected ?
|
||||||
|
'☐'
|
||||||
|
: '☑' },
|
||||||
|
'toggleSelect: item']
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// wrappers...
|
// wrappers...
|
||||||
|
|
||||||
@ -2682,6 +2711,7 @@ var BaseBrowserPrototype = {
|
|||||||
&& (item.focused = true) },
|
&& (item.focused = true) },
|
||||||
default_item: function(){ return this.get(0) },
|
default_item: function(){ return this.get(0) },
|
||||||
options: {
|
options: {
|
||||||
|
// XXX get this from options...
|
||||||
skipDisabled: true,
|
skipDisabled: true,
|
||||||
},
|
},
|
||||||
getter: 'get' }),
|
getter: 'get' }),
|
||||||
@ -3114,9 +3144,13 @@ var BrowserPrototype = {
|
|||||||
// // - number/string/list/object
|
// // - number/string/list/object
|
||||||
// // - any values...
|
// // - any values...
|
||||||
// //
|
// //
|
||||||
|
// // <force> (optional, bool), of true the button will
|
||||||
|
// // be active while the item is disabled...
|
||||||
|
// //
|
||||||
// // NOTE: for more doc see keyboard.Keyboard.parseStringHandler(..)
|
// // NOTE: for more doc see keyboard.Keyboard.parseStringHandler(..)
|
||||||
// ['html',
|
// ['html',
|
||||||
// '<action>: <arg> .. -- comment'],
|
// '<action>: <arg> .. -- comment',
|
||||||
|
// <force>],
|
||||||
//
|
//
|
||||||
// ...
|
// ...
|
||||||
// ]
|
// ]
|
||||||
@ -3695,17 +3729,27 @@ var BrowserPrototype = {
|
|||||||
// buttons...
|
// buttons...
|
||||||
// XXX migrate the default buttons functionality and button inheritance...
|
// XXX migrate the default buttons functionality and button inheritance...
|
||||||
var buttons = (item.buttons || options.itemButtons || [])
|
var buttons = (item.buttons || options.itemButtons || [])
|
||||||
|
// resolve buttons from library...
|
||||||
|
.map(function(button){
|
||||||
|
return button instanceof Array ?
|
||||||
|
button
|
||||||
|
: Items.buttons[button] || button })
|
||||||
.slice()
|
.slice()
|
||||||
// NOTE: keep the order unsurprising...
|
// NOTE: keep the order unsurprising...
|
||||||
.reverse()
|
.reverse()
|
||||||
var stopPropagation = function(evt){ evt.stopPropagation() }
|
var stopPropagation = function(evt){ evt.stopPropagation() }
|
||||||
buttons
|
buttons
|
||||||
.forEach(function([html, handler]){
|
// XXX add option to use a shortcut key...
|
||||||
|
// XXX use keyword to inherit buttons...
|
||||||
|
.forEach(function([html, handler, force, keyword]){
|
||||||
var button = document.createElement('div')
|
var button = document.createElement('div')
|
||||||
button.classList.add('button')
|
button.classList.add('button')
|
||||||
button.innerHTML = html
|
|
||||||
// XXX should buttons be active in disabled state???
|
button.innerHTML = html instanceof Function ?
|
||||||
if(!item.disabled){
|
html.call(that, item)
|
||||||
|
: html
|
||||||
|
|
||||||
|
if(force || !item.disabled){
|
||||||
button.setAttribute('tabindex', '0')
|
button.setAttribute('tabindex', '0')
|
||||||
// events to keep in buttons...
|
// events to keep in buttons...
|
||||||
;(options.buttonLocalEvents || options.localEvents || [])
|
;(options.buttonLocalEvents || options.localEvents || [])
|
||||||
@ -3747,7 +3791,7 @@ var BrowserPrototype = {
|
|||||||
var k = keyboard.event2key(evt)
|
var k = keyboard.event2key(evt)
|
||||||
if(k.includes('Enter')){
|
if(k.includes('Enter')){
|
||||||
event.stopPropagation()
|
event.stopPropagation()
|
||||||
func.call(that, evt) } }) }
|
func.call(that, evt, item) } }) }
|
||||||
}
|
}
|
||||||
elem.appendChild(button)
|
elem.appendChild(button)
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user