mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +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...'],
|
||||
['□',
|
||||
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...
|
||||
|
||||
@ -2682,6 +2711,7 @@ var BaseBrowserPrototype = {
|
||||
&& (item.focused = true) },
|
||||
default_item: function(){ return this.get(0) },
|
||||
options: {
|
||||
// XXX get this from options...
|
||||
skipDisabled: true,
|
||||
},
|
||||
getter: 'get' }),
|
||||
@ -3114,9 +3144,13 @@ var BrowserPrototype = {
|
||||
// // - number/string/list/object
|
||||
// // - 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(..)
|
||||
// ['html',
|
||||
// '<action>: <arg> .. -- comment'],
|
||||
// '<action>: <arg> .. -- comment',
|
||||
// <force>],
|
||||
//
|
||||
// ...
|
||||
// ]
|
||||
@ -3695,17 +3729,27 @@ var BrowserPrototype = {
|
||||
// buttons...
|
||||
// XXX migrate the default buttons functionality and button inheritance...
|
||||
var buttons = (item.buttons || options.itemButtons || [])
|
||||
// resolve buttons from library...
|
||||
.map(function(button){
|
||||
return button instanceof Array ?
|
||||
button
|
||||
: Items.buttons[button] || button })
|
||||
.slice()
|
||||
// NOTE: keep the order unsurprising...
|
||||
.reverse()
|
||||
var stopPropagation = function(evt){ evt.stopPropagation() }
|
||||
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')
|
||||
button.classList.add('button')
|
||||
button.innerHTML = html
|
||||
// XXX should buttons be active in disabled state???
|
||||
if(!item.disabled){
|
||||
|
||||
button.innerHTML = html instanceof Function ?
|
||||
html.call(that, item)
|
||||
: html
|
||||
|
||||
if(force || !item.disabled){
|
||||
button.setAttribute('tabindex', '0')
|
||||
// events to keep in buttons...
|
||||
;(options.buttonLocalEvents || options.localEvents || [])
|
||||
@ -3747,7 +3791,7 @@ var BrowserPrototype = {
|
||||
var k = keyboard.event2key(evt)
|
||||
if(k.includes('Enter')){
|
||||
event.stopPropagation()
|
||||
func.call(that, evt) } }) }
|
||||
func.call(that, evt, item) } }) }
|
||||
}
|
||||
elem.appendChild(button)
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user