From d5088fae685dd2de6c0c5dcd2c46f72fec1f4ac6 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Mon, 28 Nov 2016 02:25:39 +0300 Subject: [PATCH] added url pin toggler... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/history.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js index b46ec697..ad4b9acb 100755 --- a/ui (gen4)/features/history.js +++ b/ui (gen4)/features/history.js @@ -9,6 +9,7 @@ var actions = require('lib/actions') var features = require('lib/features') +var toggler = require('lib/toggler') var core = require('features/core') var widgets = require('features/ui-widgets') @@ -151,6 +152,26 @@ var URLHistoryActions = actions.Actions({ return null } }], + toggleURLPinned: ['History/', + toggler.Toggler( + function(){ return this.location.path }, + function(url, action){ + var e = this.url_history[url] + + // get state... + if(action == null){ + return e && e.pinned ? 'on' : 'off' + + // change state -> 'on'... + } else if(action == 'on'){ + e.pinned = true + + // change state -> 'off'... + } else if(action == 'off'){ + delete e.pinned + } + }, + ['off', 'on'])], openURLFromHistory: ['- History/', function(url, open){ this.url_history = this.url_history || {} @@ -401,6 +422,13 @@ var URLHistoryUIActions = actions.Actions({ // - [ 'open', 'close' ] - explicitly select event 'url-history-list-clear': ['open', 'close'], }, + // XXX pinned items are sorted differently on load and on pin -- i.e. + // a newly pinned item is added to the end of the pin list while + // when loaded it will show up in it's correct relative order + // in the list... + // ...not sure if this is the right way to go but: + // - not sure that pinning should re-order items + // - not sure if keeping pin order separately is a good idee... // XXX make availabilyty checking live (now on open dialog)... // XXX need to check items... // XXX use svg icons for buttons... @@ -487,6 +515,7 @@ var URLHistoryUIActions = actions.Actions({ // pin to top... // XXX should this be standard functionality??? // XXX should this .setTopURLHistory(..)??? + // XXX should we get pinned state via .toggleURLPinned(url, '?') here??? ['' +'', function(p){ @@ -499,12 +528,14 @@ var URLHistoryUIActions = actions.Actions({ // pinned... if(cur.hasClass('pinned')){ cur.removeClass('pinned') - delete that.url_history[p].pinned + //delete that.url_history[p].pinned + that.toggleURLPinned(p, 'off') // not pinned... } else { cur.addClass('pinned') - that.url_history[p].pinned = true + //that.url_history[p].pinned = true + that.toggleURLPinned(p, 'on') } // place...