From a6628c42b8cca62dfd0f2af3b16308dd948f6114 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Wed, 8 Feb 2017 02:04:59 +0300 Subject: [PATCH] now it is possible to either force the buttons on by including placeholders in options.buttons or via specific options... sitll seems too complicated. Signed-off-by: Alex A. Naanou --- ui (gen4)/features/history.js | 3 ++- ui (gen4)/features/ui-widgets.js | 10 ++++++++ ui (gen4)/lib/widget/browse.js | 44 ++++++++++++++++++++++---------- 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js index 1d6eae57..53a752c7 100755 --- a/ui (gen4)/features/history.js +++ b/ui (gen4)/features/history.js @@ -734,11 +734,12 @@ var URLHistoryUIActions = actions.Actions({ to_remove: to_remove, - // XXX should the normal items have a "to top" button??? buttons: [ // open... ['', function(p){ dialog.browsePath(p) }], + // XXX should the normal items have a "to top" button??? + 'TO_TOP', 'PIN', 'REMOVE', ], diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index a234b9bf..e68ee58e 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1684,6 +1684,11 @@ 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... @@ -1721,6 +1726,11 @@ var WidgetTestActions = actions.Actions({ make.EditablePinnedList(letters, pins, { list_id: 'letters', //pins_sortable: false, + /*buttons: [ + 'PIN', + 'REMOVE', + ], + //*/ }) // NOTE: the dialog's .parent is not yet set at this point... diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js index 481f2800..10eda6bd 100755 --- a/ui (gen4)/lib/widget/browse.js +++ b/ui (gen4)/lib/widget/browse.js @@ -720,36 +720,52 @@ function(list, options){ } // up/down... - options.item_order_buttons - && (_buttons['UP'] = [options.shift_up_button || '⏶', + if(options.item_order_buttons + || buttons.indexOf('UP') >= 0){ + _buttons['UP'] = [ + options.shift_up_button || '⏶', function(p, e){ move(p, -1) - && e.prev().before(e) }]) - && (_buttons['DOWN'] = [options.shift_down_button || '⏷', + && e.prev().before(e) } + ] + } + if(options.item_order_buttons + || buttons.indexOf('DOWN') >= 0){ + _buttons['DOWN'] = [ + options.shift_down_button || '⏷', function(p, e){ move(p, 1) - && e.next().after(e) }]) + && e.next().after(e) } + ] + } // top... - options.to_top_button - && (_buttons['TO_TOP'] = [options.to_top_button === true ? + var i = buttons.indexOf('TO_TOP') + if(options.to_top_button || i >= 0){ + _buttons['TO_TOP'] = [ + (options.to_top_button === true || i >= 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... - options.to_bottom_button - && (_buttons['TO_BOTTOM'] = [options.to_bottom_button === true ? + var i = buttons.indexOf('TO_BOTTOM') + if(options.to_bottom_button || i >= 0){ + _buttons['TO_BOTTOM'] = [ + (options.to_bottom_button === true || i >= 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... @@ -769,8 +785,8 @@ function(list, options){ : buttons.splice(i, 1, _buttons[key]) }) // clear out the unused button placeholders... - buttons = buttons - .filter(function(b){ + buttons = options.buttons = + buttons.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...