diff --git a/ui (gen4)/css/widget/browse.css b/ui (gen4)/css/widget/browse.css
index c723a759..db20e5e1 100755
--- a/ui (gen4)/css/widget/browse.css
+++ b/ui (gen4)/css/widget/browse.css
@@ -161,7 +161,7 @@
.browse-widget .list .button {
display: inline-block;
float:right;
- opacity: 0.7;
+ opacity: 0.5;
padding-left: 10px;
padding-right: 10px;
box-sizing: border-box;
@@ -187,6 +187,10 @@
overflow: hidden;
}
+.browse-widget .list>div.strike-out .text {
+ text-decoration: line-through;
+ opacity: 0.3;
+}
.browse-widget .list>div.highlighted {
font-style: italic;
}
diff --git a/ui (gen4)/lib/widget/browse-walk.js b/ui (gen4)/lib/widget/browse-walk.js
index a94bb1cb..f8424676 100755
--- a/ui (gen4)/lib/widget/browse-walk.js
+++ b/ui (gen4)/lib/widget/browse-walk.js
@@ -206,7 +206,8 @@ WalkPrototype.options = {
traversable: true,
flat: false,
- actionButton: 'o',
+ //actionButton: '⋯',
+ actionButton: '⊙',
pushButton: false,
list: listDir,
diff --git a/ui (gen4)/lib/widget/browse.html b/ui (gen4)/lib/widget/browse.html
index 5bd82928..c8b814a6 100755
--- a/ui (gen4)/lib/widget/browse.html
+++ b/ui (gen4)/lib/widget/browse.html
@@ -170,7 +170,7 @@ requirejs(['../keyboard', '../object', './browse'], function(k, o, br){
b = browser.Browser($('.container.tree'), {
path: '/dir_a/tree/dir_c/',
- actionButton: 'o',
+ actionButton: true,
list: function(path, make){
var cur = TREE
@@ -218,6 +218,34 @@ requirejs(['../keyboard', '../object', './browse'], function(k, o, br){
traversable: false,
flat: true,
+ itemButtons: [
+ ['⤒',
+ function(p){
+ this.filter().first()
+ .before(this.filter(p))
+ }],
+ ['▵',
+ function(p){
+ var c = this.filter(p)
+ var p = c.prev()
+ if(p.length > 0){
+ p.before(c)
+ }
+ }],
+ ['▿',
+ function(p){
+ var c = this.filter(p)
+ var p = c.next()
+ if(p.length > 0){
+ p.after(c)
+ }
+ }],
+ ['×',
+ function(p){
+ this.filter(p).remove()
+ }],
+ ],
+
list: function(path, make){
return this.options.data
.map(function(k){
diff --git a/ui (gen4)/lib/widget/browse.js b/ui (gen4)/lib/widget/browse.js
index 48f4f8ca..01b17fe3 100755
--- a/ui (gen4)/lib/widget/browse.js
+++ b/ui (gen4)/lib/widget/browse.js
@@ -35,6 +35,23 @@ var quoteWS = function(str){
}
+function makeBrowserMaker(constructor){
+ return function(elem, list, rest){
+ if(typeof(rest) == typeof('str')){
+ return constructor(elem, { data: list, path: rest })
+
+ } else {
+ var opts = {}
+ for(var k in rest){
+ opts[k] = rest[k]
+ }
+ opts.data = list
+ return constructor(elem, opts)
+ }
+ }
+}
+
+
/*********************************************************************/
@@ -230,6 +247,11 @@ var BrowserPrototype = {
// more info.
pushButton: false,
+ // A set of custom buttons to add to each item.
+ //
+ // Format:
+ itemButtons: false,
+
// Handle keys that are not bound...
// NOTE: to disable, set ot undefined.
logKeys: function(k){ window.DEBUG && console.log(k) },
@@ -750,7 +772,7 @@ var BrowserPrototype = {
res.append($('
')
.addClass('button')
.html(that.options.actionButton === true ?
- 'o'
+ '✓'
: that.options.actionButton)
.click(function(evt){
evt.stopPropagation()
@@ -771,6 +793,35 @@ var BrowserPrototype = {
}))
}
+ // custom buttons...
+ that.options.itemButtons
+ && that.options.itemButtons.slice()
+ // make the order consistent for the user -- first
+ // in list, first in item (from left), and should
+ // be added last...
+ .reverse()
+ .forEach(function(e){
+ var html = e[0]
+ var func = e[1]
+
+ res.append($('
')
+ .addClass('button')
+ .html(html)
+ .click(function(evt){
+ // prevent clicks from triggering the item action...
+ evt.stopPropagation()
+
+ // action name...
+ if(typeof(func) == typeof('str')){
+ that[func](p)
+
+ // handler...
+ } else {
+ func.call(that, p)
+ }
+ }))
+ })
+
return res
}
@@ -1983,12 +2034,7 @@ object.makeConstructor('List',
// This is a shorthand for: new List(, { data: })
var makeList =
-module.makeList = function(elem, list, path){
- return List(elem, {
- data: list,
- path: path,
- })
-}
+module.makeList = makeBrowserMaker(List)
@@ -2197,9 +2243,7 @@ object.makeConstructor('PathList',
PathListPrototype)
var makePathList =
-module.makePathList = function(elem, list, path){
- return PathList(elem, { data: list, path: path })
-}
+module.makePathList = makeBrowserMaker(PathList)
diff --git a/ui (gen4)/ui.js b/ui (gen4)/ui.js
index 33e6b077..91a5734c 100755
--- a/ui (gen4)/ui.js
+++ b/ui (gen4)/ui.js
@@ -269,19 +269,26 @@ $(function(){
a.load({
viewer: $('.viewer'),
})
+ .setEmptyMsg('Loading...')
+
+
+ // load last url in history...
+ if(a.url_history && Object.keys(a.url_history).length > 0){
+ a.openURLFromHistory(0)
// load some testing data...
- // NOTE: we can (and do) load this in parts...
- a
- .setEmptyMsg('Loading...')
- .load({
- data: data.Data(testing.mock_data),
- images: testing.makeTestImages(),
- })
- // this is needed when loading legacy sources that do not have tags
- // synced...
- // do not do for actual data...
- //.syncTags()
+ } else {
+ // NOTE: we can (and do) load this in parts...
+ a
+ .load({
+ data: data.Data(testing.mock_data),
+ images: testing.makeTestImages(),
+ })
+ // this is needed when loading legacy sources that do not have tags
+ // synced...
+ // do not do for actual data...
+ //.syncTags()
+ }
a.setEmptyMsg(
diff --git a/ui (gen4)/viewer.js b/ui (gen4)/viewer.js
index dbd070df..38e3877d 100755
--- a/ui (gen4)/viewer.js
+++ b/ui (gen4)/viewer.js
@@ -2864,7 +2864,8 @@ var makeActionLister = function(list, filter, pre_order){
// XXX DEBUG
//window.LIST = o.client
- return this
+ //return this
+ return o.client
}
}
@@ -3813,6 +3814,7 @@ var FileSystemLoaderUIActions = actions.Actions({
&& parent.focus
&& parent.focus()
})
+ return o.client
}],
// NOTE: if no path is passed (null) these behave just like .browsePath(..)
@@ -3886,6 +3888,17 @@ var URLHistoryActions = actions.Actions({
}
}],
+ setTopURLHistory: ['',
+ function(url){
+ var data = this.url_history[url]
+
+ if(data == null){
+ return
+ }
+
+ delete this.url_history[url]
+ this.url_history[url] = data
+ }],
pushURLToHistory: ['',
function(url, open, check){
var l = this.config['url-history-length'] || -1
@@ -4057,6 +4070,7 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
tag: 'url-history-local-storage',
depends: [
+ 'ui',
'url-history',
],
@@ -4065,7 +4079,7 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
// NOTE: loading is done by the .url_history prop...
handlers: [
// save...
- ['pushURLToHistory dropURLFromHistory',
+ ['pushURLToHistory dropURLFromHistory setTopURLHistory',
function(){
this.saveURLHistory()
}],
@@ -4086,26 +4100,79 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
//---------------------------------------------------------------------
var URLHistoryUIActions = actions.Actions({
+ config: {
+ // Indicate when to remove striked items from url history list
+ //
+ // Supported values:
+ // - true | undefined - always remove
+ // - flase - never remove
+ // - [ 'open', 'close' ] - explicitly select event
+ 'url-history-list-clear': ['open', 'close'],
+ },
// XXX BUG: when running from action menu this breaks...
// ...possibly connected with restoring after .preventClosing(..)
- // XXX need to highlight/select current...
// XXX need to check items...
- // XXX add buttons:
- // - remove item... (×)
- // - bring to top...
+ // XXX use svg icons for buttons...
listURLHistory: ['File/History',
function(){
var that = this
var parent = this.preventClosing ? this.preventClosing() : null
var cur = this.base_path
+ var to_remove = []
+
+ // remove stirked out elements...
+ var removeStriked = function(evt){
+ var rem = that.config['url-history-list-clear']
+ if(rem == false || rem != null && rem.indexOf(evt) < 0){
+ return
+ }
+ to_remove.forEach(function(e){
+ that.dropURLFromHistory(e)
+ })
+ to_remove = []
+ }
+
var o = overlay.Overlay(this.ribbons.viewer,
browse.makeList(
null,
- Object.keys(this.url_history).reverse(),
- // XXX for some reason this is not selected...
- cur)
+ Object.keys(this.url_history).reverse(),
+ {
+ // add item buttons...
+ itemButtons: [
+ // move to top...
+ ['♦',
+ function(p){
+ var top = this.filter().first()
+ var cur = this.filter(p)
+
+ if(!top.is(cur)){
+ top.before(cur)
+ that.setTopURLHistory(p)
+ }
+ }],
+ // mark for removal...
+ ['×',
+ function(p){
+ var e = this.filter(p)
+ .toggleClass('strike-out')
+
+ if(e.hasClass('strike-out')){
+ to_remove.indexOf(p) < 0
+ && to_remove.push(p)
+
+ } else {
+ var i = to_remove.indexOf(p)
+ if(i >= 0){
+ to_remove.splice(i, 1)
+ }
+ }
+ }],
+ ],
+ })
.open(function(evt, path){
+ removeStriked('open')
+
o.close()
// close the parent ui...
@@ -4115,17 +4182,20 @@ var URLHistoryUIActions = actions.Actions({
that.openURLFromHistory(path)
}))
- .close(function(){
- parent
- && parent.focus
- && parent.focus()
- })
+ .close(function(){
+ removeStriked('close')
- // XXX HACK: for some reason arg 3 in the constructor has
- // no effect...
+ parent
+ && parent.focus
+ && parent.focus()
+ })
+
+ // select and highlight current path...
cur && o.client
.select(cur)
.addClass('highlighted')
+
+ return o.client
}],
})
@@ -4147,12 +4217,16 @@ module.URLHistoryUI = ImageGridFeatures.Feature({
//---------------------------------------------------------------------
-var pushToHistory = function(action){
+var pushToHistory = function(action, to_top){
return [action,
function(_, path){
+ path = normalizePath(path)
if(path){
this.pushURLToHistory(normalizePath(path), action)
}
+ if(to_top){
+ this.setTopURLHistory(path)
+ }
}]
}
@@ -4178,6 +4252,34 @@ module.FileSystemLoaderURLHistory = ImageGridFeatures.Feature({
+//---------------------------------------------------------------------
+
+// Opening the url via .browsePath(..) if url is in history will move
+// it to top of list...
+var FileSystemURLHistoryUI =
+module.FileSystemLoaderURLHistoryUI = ImageGridFeatures.Feature({
+ title: '',
+ doc: '',
+
+ tag: 'ui-fs-url-history',
+ depends: [
+ 'ui-fs-loader',
+ 'fs-url-history',
+ ],
+
+ handlers: [
+ ['browsePath',
+ function(res){
+ var that = this
+ res.open(function(_, path){
+ that.setTopURLHistory(path)
+ })
+ }],
+ ],
+})
+
+
+
//---------------------------------------------------------------------
// fs writer...
@@ -4586,6 +4688,7 @@ ImageGridFeatures.Feature('viewer-testing', [
'fs-loader',
'ui-fs-loader',
'fs-url-history',
+ 'ui-fs-url-history',
'fs-writer',
'ui-fs-writer',