mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-11-01 11:50:07 +00:00
addded browse item buttons + some tweaking...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
4f9d284376
commit
ecc79477bd
@ -161,7 +161,7 @@
|
|||||||
.browse-widget .list .button {
|
.browse-widget .list .button {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
float:right;
|
float:right;
|
||||||
opacity: 0.7;
|
opacity: 0.5;
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -187,6 +187,10 @@
|
|||||||
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
.browse-widget .list>div.strike-out .text {
|
||||||
|
text-decoration: line-through;
|
||||||
|
opacity: 0.3;
|
||||||
|
}
|
||||||
.browse-widget .list>div.highlighted {
|
.browse-widget .list>div.highlighted {
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,7 +206,8 @@ WalkPrototype.options = {
|
|||||||
traversable: true,
|
traversable: true,
|
||||||
flat: false,
|
flat: false,
|
||||||
|
|
||||||
actionButton: 'o',
|
//actionButton: '⋯',
|
||||||
|
actionButton: '⊙',
|
||||||
pushButton: false,
|
pushButton: false,
|
||||||
|
|
||||||
list: listDir,
|
list: listDir,
|
||||||
|
|||||||
@ -170,7 +170,7 @@ requirejs(['../keyboard', '../object', './browse'], function(k, o, br){
|
|||||||
b = browser.Browser($('.container.tree'), {
|
b = browser.Browser($('.container.tree'), {
|
||||||
path: '/dir_a/tree/dir_c/',
|
path: '/dir_a/tree/dir_c/',
|
||||||
|
|
||||||
actionButton: 'o',
|
actionButton: true,
|
||||||
|
|
||||||
list: function(path, make){
|
list: function(path, make){
|
||||||
var cur = TREE
|
var cur = TREE
|
||||||
@ -218,6 +218,34 @@ requirejs(['../keyboard', '../object', './browse'], function(k, o, br){
|
|||||||
traversable: false,
|
traversable: false,
|
||||||
flat: true,
|
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){
|
list: function(path, make){
|
||||||
return this.options.data
|
return this.options.data
|
||||||
.map(function(k){
|
.map(function(k){
|
||||||
|
|||||||
@ -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.
|
// more info.
|
||||||
pushButton: false,
|
pushButton: false,
|
||||||
|
|
||||||
|
// A set of custom buttons to add to each item.
|
||||||
|
//
|
||||||
|
// Format:
|
||||||
|
itemButtons: false,
|
||||||
|
|
||||||
// Handle keys that are not bound...
|
// Handle keys that are not bound...
|
||||||
// NOTE: to disable, set ot undefined.
|
// NOTE: to disable, set ot undefined.
|
||||||
logKeys: function(k){ window.DEBUG && console.log(k) },
|
logKeys: function(k){ window.DEBUG && console.log(k) },
|
||||||
@ -750,7 +772,7 @@ var BrowserPrototype = {
|
|||||||
res.append($('<div>')
|
res.append($('<div>')
|
||||||
.addClass('button')
|
.addClass('button')
|
||||||
.html(that.options.actionButton === true ?
|
.html(that.options.actionButton === true ?
|
||||||
'o'
|
'✓'
|
||||||
: that.options.actionButton)
|
: that.options.actionButton)
|
||||||
.click(function(evt){
|
.click(function(evt){
|
||||||
evt.stopPropagation()
|
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($('<div>')
|
||||||
|
.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
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1983,12 +2034,7 @@ object.makeConstructor('List',
|
|||||||
|
|
||||||
// This is a shorthand for: new List(<elem>, { data: <list> })
|
// This is a shorthand for: new List(<elem>, { data: <list> })
|
||||||
var makeList =
|
var makeList =
|
||||||
module.makeList = function(elem, list, path){
|
module.makeList = makeBrowserMaker(List)
|
||||||
return List(elem, {
|
|
||||||
data: list,
|
|
||||||
path: path,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -2197,9 +2243,7 @@ object.makeConstructor('PathList',
|
|||||||
PathListPrototype)
|
PathListPrototype)
|
||||||
|
|
||||||
var makePathList =
|
var makePathList =
|
||||||
module.makePathList = function(elem, list, path){
|
module.makePathList = makeBrowserMaker(PathList)
|
||||||
return PathList(elem, { data: list, path: path })
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -269,19 +269,26 @@ $(function(){
|
|||||||
a.load({
|
a.load({
|
||||||
viewer: $('.viewer'),
|
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...
|
// load some testing data...
|
||||||
// NOTE: we can (and do) load this in parts...
|
} else {
|
||||||
a
|
// NOTE: we can (and do) load this in parts...
|
||||||
.setEmptyMsg('Loading...')
|
a
|
||||||
.load({
|
.load({
|
||||||
data: data.Data(testing.mock_data),
|
data: data.Data(testing.mock_data),
|
||||||
images: testing.makeTestImages(),
|
images: testing.makeTestImages(),
|
||||||
})
|
})
|
||||||
// this is needed when loading legacy sources that do not have tags
|
// this is needed when loading legacy sources that do not have tags
|
||||||
// synced...
|
// synced...
|
||||||
// do not do for actual data...
|
// do not do for actual data...
|
||||||
//.syncTags()
|
//.syncTags()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
a.setEmptyMsg(
|
a.setEmptyMsg(
|
||||||
|
|||||||
@ -2864,7 +2864,8 @@ var makeActionLister = function(list, filter, pre_order){
|
|||||||
// XXX DEBUG
|
// XXX DEBUG
|
||||||
//window.LIST = o.client
|
//window.LIST = o.client
|
||||||
|
|
||||||
return this
|
//return this
|
||||||
|
return o.client
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3813,6 +3814,7 @@ var FileSystemLoaderUIActions = actions.Actions({
|
|||||||
&& parent.focus
|
&& parent.focus
|
||||||
&& parent.focus()
|
&& parent.focus()
|
||||||
})
|
})
|
||||||
|
return o.client
|
||||||
}],
|
}],
|
||||||
|
|
||||||
// NOTE: if no path is passed (null) these behave just like .browsePath(..)
|
// 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: ['',
|
pushURLToHistory: ['',
|
||||||
function(url, open, check){
|
function(url, open, check){
|
||||||
var l = this.config['url-history-length'] || -1
|
var l = this.config['url-history-length'] || -1
|
||||||
@ -4057,6 +4070,7 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
|
|||||||
|
|
||||||
tag: 'url-history-local-storage',
|
tag: 'url-history-local-storage',
|
||||||
depends: [
|
depends: [
|
||||||
|
'ui',
|
||||||
'url-history',
|
'url-history',
|
||||||
],
|
],
|
||||||
|
|
||||||
@ -4065,7 +4079,7 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
|
|||||||
// NOTE: loading is done by the .url_history prop...
|
// NOTE: loading is done by the .url_history prop...
|
||||||
handlers: [
|
handlers: [
|
||||||
// save...
|
// save...
|
||||||
['pushURLToHistory dropURLFromHistory',
|
['pushURLToHistory dropURLFromHistory setTopURLHistory',
|
||||||
function(){
|
function(){
|
||||||
this.saveURLHistory()
|
this.saveURLHistory()
|
||||||
}],
|
}],
|
||||||
@ -4086,26 +4100,79 @@ module.URLHistoryLocalStorage = ImageGridFeatures.Feature({
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
var URLHistoryUIActions = actions.Actions({
|
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...
|
// XXX BUG: when running from action menu this breaks...
|
||||||
// ...possibly connected with restoring after .preventClosing(..)
|
// ...possibly connected with restoring after .preventClosing(..)
|
||||||
// XXX need to highlight/select current...
|
|
||||||
// XXX need to check items...
|
// XXX need to check items...
|
||||||
// XXX add buttons:
|
// XXX use svg icons for buttons...
|
||||||
// - remove item... (×)
|
|
||||||
// - bring to top...
|
|
||||||
listURLHistory: ['File/History',
|
listURLHistory: ['File/History',
|
||||||
function(){
|
function(){
|
||||||
var that = this
|
var that = this
|
||||||
var parent = this.preventClosing ? this.preventClosing() : null
|
var parent = this.preventClosing ? this.preventClosing() : null
|
||||||
var cur = this.base_path
|
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,
|
var o = overlay.Overlay(this.ribbons.viewer,
|
||||||
browse.makeList(
|
browse.makeList(
|
||||||
null,
|
null,
|
||||||
Object.keys(this.url_history).reverse(),
|
Object.keys(this.url_history).reverse(),
|
||||||
// XXX for some reason this is not selected...
|
{
|
||||||
cur)
|
// 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){
|
.open(function(evt, path){
|
||||||
|
removeStriked('open')
|
||||||
|
|
||||||
o.close()
|
o.close()
|
||||||
|
|
||||||
// close the parent ui...
|
// close the parent ui...
|
||||||
@ -4115,17 +4182,20 @@ var URLHistoryUIActions = actions.Actions({
|
|||||||
|
|
||||||
that.openURLFromHistory(path)
|
that.openURLFromHistory(path)
|
||||||
}))
|
}))
|
||||||
.close(function(){
|
.close(function(){
|
||||||
parent
|
removeStriked('close')
|
||||||
&& parent.focus
|
|
||||||
&& parent.focus()
|
|
||||||
})
|
|
||||||
|
|
||||||
// XXX HACK: for some reason arg 3 in the constructor has
|
parent
|
||||||
// no effect...
|
&& parent.focus
|
||||||
|
&& parent.focus()
|
||||||
|
})
|
||||||
|
|
||||||
|
// select and highlight current path...
|
||||||
cur && o.client
|
cur && o.client
|
||||||
.select(cur)
|
.select(cur)
|
||||||
.addClass('highlighted')
|
.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,
|
return [action,
|
||||||
function(_, path){
|
function(_, path){
|
||||||
|
path = normalizePath(path)
|
||||||
if(path){
|
if(path){
|
||||||
this.pushURLToHistory(normalizePath(path), action)
|
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...
|
// fs writer...
|
||||||
|
|
||||||
@ -4586,6 +4688,7 @@ ImageGridFeatures.Feature('viewer-testing', [
|
|||||||
'fs-loader',
|
'fs-loader',
|
||||||
'ui-fs-loader',
|
'ui-fs-loader',
|
||||||
'fs-url-history',
|
'fs-url-history',
|
||||||
|
'ui-fs-url-history',
|
||||||
|
|
||||||
'fs-writer',
|
'fs-writer',
|
||||||
'ui-fs-writer',
|
'ui-fs-writer',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user