mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
added url pinning in url history...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f84f97ab59
commit
89e04829f9
@ -128,6 +128,24 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* browse pinned items... */
|
||||||
|
.browse-widget .list>div:not(.pinned) .pin-set {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.browse-widget .list>div.pinned .pin-unset {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
.browse-widget .list>div.pinned + :not(.pinned) {
|
||||||
|
border-top: solid 1px rgba(255, 255, 255, 0.3);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
.browse-widget .list .pinned-separator:first-child,
|
||||||
|
.browse-widget .list .pinned-separator:last-child {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Metadata viewer */
|
/* Metadata viewer */
|
||||||
.item-value-view .text:first-child,
|
.item-value-view .text:first-child,
|
||||||
.browse-widget.metadata-view .list>div .text:first-child {
|
.browse-widget.metadata-view .list>div .text:first-child {
|
||||||
|
|||||||
@ -74,19 +74,22 @@ var URLHistoryActions = actions.Actions({
|
|||||||
delete this.url_history[url]
|
delete this.url_history[url]
|
||||||
this.url_history[url] = data
|
this.url_history[url] = data
|
||||||
}],
|
}],
|
||||||
|
// NOTE: if clear is not true then this will update a history item
|
||||||
|
// rather than fully rewriting it...
|
||||||
pushURLToHistory: ['- History/',
|
pushURLToHistory: ['- History/',
|
||||||
function(url, open, check){
|
function(url, open, check, clear){
|
||||||
var l = this.config['url-history-length'] || -1
|
var l = this.config['url-history-length'] || -1
|
||||||
|
|
||||||
if(l == 0){
|
if(l == 0){
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
url = url || this.location.path
|
|
||||||
open = open || this.location.method
|
|
||||||
check = check || 'checkPath'
|
|
||||||
|
|
||||||
this.url_history = this.url_history || {}
|
this.url_history = this.url_history || {}
|
||||||
|
var item = !clear ? (this.url_history[url] || {}) : {}
|
||||||
|
|
||||||
|
url = url || this.location.path
|
||||||
|
open = item.open = open || this.location.method
|
||||||
|
check = item.check = check || 'checkPath'
|
||||||
|
|
||||||
// remove the old value...
|
// remove the old value...
|
||||||
if(url in this.url_history && this.config['url-history-push-up-on-open']){
|
if(url in this.url_history && this.config['url-history-push-up-on-open']){
|
||||||
@ -94,10 +97,11 @@ var URLHistoryActions = actions.Actions({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// push url to history...
|
// push url to history...
|
||||||
this.url_history[url] = {
|
this.url_history[url] = item
|
||||||
|
/*this.url_history[url] = {
|
||||||
open: open,
|
open: open,
|
||||||
check: check,
|
check: check,
|
||||||
}
|
}*/
|
||||||
|
|
||||||
// update history length...
|
// update history length...
|
||||||
if(l > 0){
|
if(l > 0){
|
||||||
@ -420,18 +424,44 @@ var URLHistoryUIActions = actions.Actions({
|
|||||||
to_remove = []
|
to_remove = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX
|
||||||
|
|
||||||
var o = browse.makeLister(null,
|
var o = browse.makeLister(null,
|
||||||
function(path, make){
|
function(path, make){
|
||||||
var l = Object.keys(that.url_history)
|
var l = 0
|
||||||
.reverse()
|
var history = Object.keys(that.url_history).reverse()
|
||||||
// NOTE: this might get a little slow for
|
|
||||||
// very large sets...
|
// pinned items...
|
||||||
.map(function(p){
|
history
|
||||||
|
.filter(function(p){
|
||||||
|
return that.url_history[p].pinned
|
||||||
|
})
|
||||||
|
.forEach(function(p){
|
||||||
|
// prevent from drawing again...
|
||||||
|
history.splice(history.indexOf(p), 1)
|
||||||
|
|
||||||
make(p, {disabled: !that.checkURLFromHistory(p) })
|
make(p, {disabled: !that.checkURLFromHistory(p) })
|
||||||
.addClass(p == cur ? 'highlighted selected': '')
|
.addClass(p == cur ? 'highlighted selected': '')
|
||||||
})
|
.addClass('pinned')
|
||||||
.length
|
|
||||||
|
|
||||||
|
l++
|
||||||
|
})
|
||||||
|
|
||||||
|
// separator...
|
||||||
|
make('---')
|
||||||
|
.addClass('pinned-separator')
|
||||||
|
|
||||||
|
// history...
|
||||||
|
history
|
||||||
|
// NOTE: this might get a little slow for
|
||||||
|
// very large sets...
|
||||||
|
.forEach(function(p){
|
||||||
|
make(p, {disabled: !that.checkURLFromHistory(p) })
|
||||||
|
.addClass(p == cur ? 'highlighted selected': '')
|
||||||
|
l++
|
||||||
|
})
|
||||||
|
|
||||||
|
// empty history...
|
||||||
if(l == 0){
|
if(l == 0){
|
||||||
make('No history...', null, true)
|
make('No history...', null, true)
|
||||||
.find('.button').remove()
|
.find('.button').remove()
|
||||||
@ -442,14 +472,59 @@ var URLHistoryUIActions = actions.Actions({
|
|||||||
// move to top...
|
// move to top...
|
||||||
['♦',
|
['♦',
|
||||||
function(p){
|
function(p){
|
||||||
var top = this.filter('*', false).first()
|
|
||||||
var cur = this.filter('"'+p+'"', false)
|
var cur = this.filter('"'+p+'"', false)
|
||||||
|
|
||||||
|
var top = cur.hasClass('pinned') ?
|
||||||
|
this.filter('*', false).first()
|
||||||
|
: this.filter('*', false)
|
||||||
|
.filter(':not(.pinned)').first()
|
||||||
|
|
||||||
if(!top.is(cur)){
|
if(!top.is(cur)){
|
||||||
top.before(cur)
|
top.before(cur)
|
||||||
that.setTopURLHistory(p)
|
that.setTopURLHistory(p)
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
// pin to top...
|
||||||
|
// XXX should this be standard functionality???
|
||||||
|
// XXX should this .setTopURLHistory(..)???
|
||||||
|
['<span class="pin-set">●</span>'
|
||||||
|
+'<span class="pin-unset">○</span>',
|
||||||
|
function(p){
|
||||||
|
var cur = this.filter('"'+p+'"', false)
|
||||||
|
var top_unpinned = this.filter('*', false)
|
||||||
|
.filter(':not(.pinned)').first()
|
||||||
|
var sep = this.dom.find('.list>.pinned-separator')
|
||||||
|
|
||||||
|
// change state...
|
||||||
|
// pinned...
|
||||||
|
if(cur.hasClass('pinned')){
|
||||||
|
cur.removeClass('pinned')
|
||||||
|
delete that.url_history[p].pinned
|
||||||
|
|
||||||
|
// not pinned...
|
||||||
|
} else {
|
||||||
|
cur.addClass('pinned')
|
||||||
|
that.url_history[p].pinned = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// place...
|
||||||
|
// special case: everything is pinned -- place last...
|
||||||
|
if(top_unpinned.length == 0){
|
||||||
|
this.filter('*', false).last()
|
||||||
|
.after(cur)
|
||||||
|
.after(sep)
|
||||||
|
|
||||||
|
// place after last pinned...
|
||||||
|
} else {
|
||||||
|
top_unpinned
|
||||||
|
.before(cur)
|
||||||
|
|
||||||
|
// place the separator...
|
||||||
|
cur.hasClass('pinned') ?
|
||||||
|
cur.after(sep)
|
||||||
|
: cur.before(sep)
|
||||||
|
}
|
||||||
|
}],
|
||||||
// mark for removal...
|
// mark for removal...
|
||||||
['×',
|
['×',
|
||||||
function(p){
|
function(p){
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user