mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
reworked button placement...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
a6628c42b8
commit
fd4b663c1e
@ -1684,11 +1684,6 @@ var WidgetTestActions = actions.Actions({
|
||||
make.EditableList(letters, {
|
||||
list_id: 'letters',
|
||||
sortable: 'y',
|
||||
|
||||
buttons: [
|
||||
'TO_TOP',
|
||||
'UP',
|
||||
],
|
||||
})
|
||||
|
||||
// NOTE: the dialog's .parent is not yet set at this point...
|
||||
@ -1726,11 +1721,10 @@ var WidgetTestActions = actions.Actions({
|
||||
make.EditablePinnedList(letters, pins, {
|
||||
list_id: 'letters',
|
||||
//pins_sortable: false,
|
||||
/*buttons: [
|
||||
'PIN',
|
||||
'REMOVE',
|
||||
buttons: [
|
||||
'UP',
|
||||
'TO_BOTTOM',
|
||||
],
|
||||
//*/
|
||||
})
|
||||
|
||||
// NOTE: the dialog's .parent is not yet set at this point...
|
||||
|
||||
@ -690,10 +690,32 @@ function(list, options){
|
||||
}
|
||||
|
||||
var buttons = options.buttons = (options.buttons || []).slice()
|
||||
var _buttons = {}
|
||||
|
||||
// manual sorting buttons...
|
||||
// options buttons...
|
||||
// NOTE: the order here is important...
|
||||
if(editable && !options.sort){
|
||||
// up/down...
|
||||
options.item_order_buttons
|
||||
&& buttons.indexOf('UP') < 0
|
||||
&& buttons.push('UP')
|
||||
options.item_order_buttons
|
||||
&& buttons.indexOf('DOWN') < 0
|
||||
&& buttons.push('DOWN')
|
||||
|
||||
// top/bottom...
|
||||
options.to_top_button
|
||||
&& buttons.indexOf('TO_TOP') < 0
|
||||
&& buttons.push('TO_TOP')
|
||||
options.to_bottom_button
|
||||
&& buttons.indexOf('TO_BOTTOM') < 0
|
||||
&& buttons.push('TO_BOTTOM')
|
||||
}
|
||||
// 'x' button...
|
||||
editable
|
||||
&& options.delete_button !== false
|
||||
&& buttons.indexOf('REMOVE') < 0
|
||||
&& buttons.push('REMOVE')
|
||||
|
||||
var move = function(p, offset){
|
||||
var l = dialog.__list[id]
|
||||
var i = l.indexOf(p)
|
||||
@ -718,75 +740,51 @@ function(list, options){
|
||||
// return the shift distance...
|
||||
return j - i
|
||||
}
|
||||
|
||||
// up/down...
|
||||
if(options.item_order_buttons
|
||||
|| buttons.indexOf('UP') >= 0){
|
||||
_buttons['UP'] = [
|
||||
options.shift_up_button || '⏶',
|
||||
var __buttons = {
|
||||
UP: [options.shift_up_button || '⏶',
|
||||
function(p, e){
|
||||
move(p, -1)
|
||||
&& e.prev().before(e) }
|
||||
]
|
||||
}
|
||||
if(options.item_order_buttons
|
||||
|| buttons.indexOf('DOWN') >= 0){
|
||||
_buttons['DOWN'] = [
|
||||
options.shift_down_button || '⏷',
|
||||
&& e.prev().before(e) }],
|
||||
DOWN: [options.shift_down_button || '⏷',
|
||||
function(p, e){
|
||||
move(p, 1)
|
||||
&& e.next().after(e) }
|
||||
]
|
||||
}
|
||||
|
||||
// top...
|
||||
var i = buttons.indexOf('TO_TOP')
|
||||
if(options.to_top_button || i >= 0){
|
||||
_buttons['TO_TOP'] = [
|
||||
(options.to_top_button === true || i >= 0) ?
|
||||
&& e.next().after(e) }],
|
||||
TO_TOP: [
|
||||
(options.to_top_button === true
|
||||
|| buttons.indexOf('TO_TOP') >= 0) ?
|
||||
'⤒'
|
||||
: options.to_top_button,
|
||||
function(p, e){
|
||||
var d = move(p, -dialog.__list[id].length)
|
||||
d && e.prevAll().eq(Math.abs(d+1)).before(e)
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
// bottom...
|
||||
var i = buttons.indexOf('TO_BOTTOM')
|
||||
if(options.to_bottom_button || i >= 0){
|
||||
_buttons['TO_BOTTOM'] = [
|
||||
(options.to_bottom_button === true || i >= 0) ?
|
||||
}],
|
||||
TO_BOTTOM: [
|
||||
(options.to_bottom_button === true
|
||||
|| buttons.indexOf('TO_BOTTOM') >= 0) ?
|
||||
'⤓'
|
||||
: options.to_bottom_button,
|
||||
function(p, e){
|
||||
var d = move(p, dialog.__list[id].length)
|
||||
d && e.nextAll().eq(Math.abs(d)).before(e)
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
// 'x' button if not disabled...
|
||||
editable
|
||||
&& options.delete_button !== false
|
||||
&& (_buttons['REMOVE'] = Buttons.markForRemoval(
|
||||
}],
|
||||
REMOVE: Buttons.markForRemoval(
|
||||
to_remove,
|
||||
options.delete_button !== true ?
|
||||
options.delete_button
|
||||
: undefined))
|
||||
: undefined)
|
||||
}
|
||||
|
||||
// add the buttons...
|
||||
Object.keys(_buttons).forEach(function(key){
|
||||
var i = buttons.indexOf(key)
|
||||
i < 0 ?
|
||||
buttons.push(_buttons[key])
|
||||
: buttons.splice(i, 1, _buttons[key])
|
||||
})
|
||||
// clear out the unused button placeholders...
|
||||
// replace the button placeholders...
|
||||
buttons = options.buttons =
|
||||
buttons.filter(function(b){
|
||||
buttons
|
||||
.map(function(button){
|
||||
return button in __buttons ?
|
||||
__buttons[button]
|
||||
: button[1] in __buttons ?
|
||||
[button[0], __buttons[button[1]][1]]
|
||||
: button.slice() })
|
||||
// clear out the unused button placeholders...
|
||||
.filter(function(b){
|
||||
return ['UP', 'DOWN', 'TO_TOP', 'TO_BOTTOM', 'REMOVE'].indexOf(b) < 0 })
|
||||
|
||||
// if we are sortable then we will need to also be grouped...
|
||||
@ -1037,6 +1035,8 @@ function(list, pins, options){
|
||||
length_limit: options.pins_length_limit || 10,
|
||||
|
||||
isItemHidden: null,
|
||||
|
||||
buttons: options.buttons.slice(),
|
||||
}
|
||||
pins_options.__proto__ = options
|
||||
var sortable = pins_options.sortable =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user