mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
updated style...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
f93a44bd93
commit
a07a69c0f5
@ -41,7 +41,8 @@ var ui = require('features/ui')
|
|||||||
function makeTagTogglerAction(tag){
|
function makeTagTogglerAction(tag){
|
||||||
// get actual target gids...
|
// get actual target gids...
|
||||||
var _getTarget = function(target){
|
var _getTarget = function(target){
|
||||||
target = target || this.current
|
target = target
|
||||||
|
|| this.current
|
||||||
target = (target == 'all'
|
target = (target == 'all'
|
||||||
|| target == 'loaded'
|
|| target == 'loaded'
|
||||||
|| target in this.data.ribbons) ?
|
|| target in this.data.ribbons) ?
|
||||||
@ -53,8 +54,7 @@ function makeTagTogglerAction(tag){
|
|||||||
[]
|
[]
|
||||||
: target instanceof Array ?
|
: target instanceof Array ?
|
||||||
target
|
target
|
||||||
: [target]
|
: [target] }
|
||||||
}
|
|
||||||
|
|
||||||
// the toggler...
|
// the toggler...
|
||||||
var _tagToggler = toggler.Toggler('current',
|
var _tagToggler = toggler.Toggler('current',
|
||||||
@ -64,14 +64,10 @@ function makeTagTogglerAction(tag){
|
|||||||
if(action == null){
|
if(action == null){
|
||||||
var res = this.data.toggleTag(tag, target, '?')
|
var res = this.data.toggleTag(tag, target, '?')
|
||||||
return res.length == 1 ? res[0] : res
|
return res.length == 1 ? res[0] : res
|
||||||
|
|
||||||
} else if(action == 'on'){
|
} else if(action == 'on'){
|
||||||
this.tag(tag, target)
|
this.tag(tag, target)
|
||||||
|
|
||||||
} else if(action == 'off'){
|
} else if(action == 'off'){
|
||||||
this.untag(tag, target)
|
this.untag(tag, target) } },
|
||||||
}
|
|
||||||
},
|
|
||||||
['off', 'on'])
|
['off', 'on'])
|
||||||
|
|
||||||
// the action...
|
// the action...
|
||||||
@ -81,7 +77,8 @@ function makeTagTogglerAction(tag){
|
|||||||
this[target]
|
this[target]
|
||||||
: target
|
: target
|
||||||
// reverse gid list attr...
|
// reverse gid list attr...
|
||||||
if(typeof(target) == typeof('str') && target[0] == '!'){
|
if(typeof(target) == typeof('str')
|
||||||
|
&& target[0] == '!'){
|
||||||
var skip = new Set(this[target.slice(1)])
|
var skip = new Set(this[target.slice(1)])
|
||||||
target = this.data.order
|
target = this.data.order
|
||||||
.filter(function(gid){
|
.filter(function(gid){
|
||||||
@ -89,13 +86,19 @@ function makeTagTogglerAction(tag){
|
|||||||
|
|
||||||
// special case: no data...
|
// special case: no data...
|
||||||
if(this.data == null){
|
if(this.data == null){
|
||||||
return action == '??' ? ['off', 'on'] : 'off'
|
return action == '??' ?
|
||||||
|
['off', 'on']
|
||||||
|
: 'off'
|
||||||
|
|
||||||
// special case: multiple targets and toggle action...
|
// special case: multiple targets and toggle action...
|
||||||
// XXX do we need this???
|
// XXX do we need this???
|
||||||
} else if((target == 'all' || target == 'loaded' || target == 'ribbon'
|
} else if((target == 'all'
|
||||||
|
|| target == 'loaded'
|
||||||
|
|| target == 'ribbon'
|
||||||
|| target instanceof Array)
|
|| target instanceof Array)
|
||||||
&& (action == null || action == 'next' || action == 'prev'
|
&& (action == null
|
||||||
|
|| action == 'next'
|
||||||
|
|| action == 'prev'
|
||||||
|| action == '!')){
|
|| action == '!')){
|
||||||
var res = []
|
var res = []
|
||||||
var that = this
|
var that = this
|
||||||
@ -112,25 +115,22 @@ function makeTagTogglerAction(tag){
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
off.push(gid)
|
off.push(gid)
|
||||||
res.push('off')
|
res.push('off') } })
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
that.tag(tag, on)
|
that.tag(tag, on)
|
||||||
that.untag(tag, off)
|
that.untag(tag, off)
|
||||||
|
|
||||||
return res.length == 1 ? res[0] : res
|
return res.length == 1 ?
|
||||||
}
|
res[0]
|
||||||
|
: res }
|
||||||
|
|
||||||
// normal case...
|
// normal case...
|
||||||
return _tagToggler.call(this, target, action)
|
return _tagToggler.call(this, target, action) }
|
||||||
}
|
|
||||||
|
|
||||||
// cheating a bit...
|
// cheating a bit...
|
||||||
action.__proto__ = toggler.Toggler.prototype
|
action.__proto__ = toggler.Toggler.prototype
|
||||||
action.constructor = toggler.Toggler
|
action.constructor = toggler.Toggler
|
||||||
return action
|
return action }
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Build a tag toggler undo set of attrs...
|
// Build a tag toggler undo set of attrs...
|
||||||
@ -148,30 +148,29 @@ var undoTag = function(action){
|
|||||||
undoable: function(a){
|
undoable: function(a){
|
||||||
// handle ribbon-wide operations...
|
// handle ribbon-wide operations...
|
||||||
// NOTE: this is specific to .toggleMark(..)
|
// NOTE: this is specific to .toggleMark(..)
|
||||||
if(a.args[0] == 'ribbon' && action == 'toggleMark'){
|
if(a.args[0] == 'ribbon'
|
||||||
|
&& action == 'toggleMark'){
|
||||||
a.state = this.markedInRibbon()
|
a.state = this.markedInRibbon()
|
||||||
return true
|
return true }
|
||||||
}
|
|
||||||
// skip introspection...
|
// skip introspection...
|
||||||
return a.args.indexOf('?') < 0
|
return a.args.indexOf('?') < 0
|
||||||
&& a.args.indexOf('??') < 0
|
&& a.args.indexOf('??') < 0 },
|
||||||
},
|
|
||||||
undo: function(a){
|
undo: function(a){
|
||||||
// restore state...
|
// restore state...
|
||||||
if(a.state){
|
if(a.state){
|
||||||
this[action]('ribbon', 'off')
|
this[action]('ribbon', 'off')
|
||||||
this[action](a.state, 'on')
|
this[action](a.state, 'on')
|
||||||
|
|
||||||
// reverse state...
|
// reverse state...
|
||||||
} else {
|
} else {
|
||||||
this[action].apply(this,
|
this[action].apply(this,
|
||||||
// XXX is argument handling here too optimistic???
|
// XXX is argument handling here too optimistic???
|
||||||
a.args.map(function(e){
|
a.args
|
||||||
return e == 'on' ? 'off'
|
.map(function(e){
|
||||||
: e == 'off' ? 'on'
|
return e == 'on' ?
|
||||||
: e }))
|
'off'
|
||||||
}
|
: e == 'off' ?
|
||||||
},
|
'on'
|
||||||
|
: e })) } },
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
||||||
@ -197,26 +196,24 @@ var shiftMarked = function(direction){
|
|||||||
|
|
||||||
var getNext = function(direction){
|
var getNext = function(direction){
|
||||||
var next = that.data.getImage(direction)
|
var next = that.data.getImage(direction)
|
||||||
while(next != null && marked.indexOf(next) >= 0){
|
while(next != null
|
||||||
next = that.data.getImage(next, direction)
|
&& marked.indexOf(next) >= 0){
|
||||||
}
|
next = that.data.getImage(next, direction) }
|
||||||
return next
|
return next }
|
||||||
}
|
|
||||||
|
|
||||||
next = getNext(d)
|
next = getNext(d)
|
||||||
|| getNext(d == 'next' ? 'prev' : 'next')
|
|| getNext(d == 'next' ?
|
||||||
|
'prev'
|
||||||
|
: 'next')
|
||||||
|
|
||||||
next != null
|
next != null
|
||||||
&& this.data.focusImage(next)
|
&& this.data.focusImage(next) }
|
||||||
}
|
|
||||||
|
|
||||||
// shift the image...
|
// shift the image...
|
||||||
this.data['shiftImage'+ direction.capitalize()](marked)
|
this.data['shiftImage'+ direction.capitalize()](marked)
|
||||||
|
|
||||||
// obey the shiftImage protocol...
|
// obey the shiftImage protocol...
|
||||||
this.shiftImage.apply(this, marked)
|
this.shiftImage.apply(this, marked) } }
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Shift undo function constructor...
|
// Shift undo function constructor...
|
||||||
@ -225,8 +222,12 @@ var shiftMarked = function(direction){
|
|||||||
var undoShift = function(undo){
|
var undoShift = function(undo){
|
||||||
return function(a){
|
return function(a){
|
||||||
this[undo](this.data.getRibbon(
|
this[undo](this.data.getRibbon(
|
||||||
undo == 'shiftMarkedUp' ? 'next' : 'prev',
|
undo == 'shiftMarkedUp' ?
|
||||||
a.args.length == 0 ? a.current : a.args[0])) }}
|
'next'
|
||||||
|
: 'prev',
|
||||||
|
a.args.length == 0 ?
|
||||||
|
a.current
|
||||||
|
: a.args[0])) }}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -244,8 +245,9 @@ var ImageMarkActions = actions.Actions({
|
|||||||
get marked(){
|
get marked(){
|
||||||
return this.data == null ?
|
return this.data == null ?
|
||||||
[]
|
[]
|
||||||
: this.data.sortViaOrder(this.data.tagQuery('marked')) },
|
: this.data.sortViaOrder(
|
||||||
// XXX REVISE...
|
this.data.tagQuery('marked')) },
|
||||||
|
// NOTE: this will untag only the loaded images...
|
||||||
set marked(gids){
|
set marked(gids){
|
||||||
gids = gids instanceof Array ?
|
gids = gids instanceof Array ?
|
||||||
gids
|
gids
|
||||||
@ -257,12 +259,13 @@ var ImageMarkActions = actions.Actions({
|
|||||||
markedInRibbon: ['- Mark|Ribbon/',
|
markedInRibbon: ['- Mark|Ribbon/',
|
||||||
function(ribbon){
|
function(ribbon){
|
||||||
var ribbon = this.data.getRibbon(ribbon)
|
var ribbon = this.data.getRibbon(ribbon)
|
||||||
var images = this.data.makeSparseImages(this.data.getImages(ribbon))
|
var images = this.data.makeSparseImages(
|
||||||
|
this.data.getImages(ribbon))
|
||||||
|
|
||||||
return this.data.makeSparseImages(this.marked)
|
return this.data.makeSparseImages(this.marked)
|
||||||
// NOTE: this will also filter out undefined positions...
|
// NOTE: this will also filter out undefined positions...
|
||||||
.filter(function(img, i){ return images[i] != null })
|
.filter(function(img, i){
|
||||||
}],
|
return images[i] != null }) }],
|
||||||
|
|
||||||
prevMarked: ['Mark|Navigate/Previous marked image',
|
prevMarked: ['Mark|Navigate/Previous marked image',
|
||||||
{mode: function(target){
|
{mode: function(target){
|
||||||
@ -363,22 +366,22 @@ var ImageMarkEditActions = actions.Actions({
|
|||||||
while(i >= 0
|
while(i >= 0
|
||||||
// NOTE: we are avoiding mixing up a tag not set condition
|
// NOTE: we are avoiding mixing up a tag not set condition
|
||||||
// with image i not in ribbon...
|
// with image i not in ribbon...
|
||||||
&& (!ribbon[i] || !!marked[i] == state)){
|
&& (!ribbon[i]
|
||||||
|
|| !!marked[i] == state)){
|
||||||
ribbon[i]
|
ribbon[i]
|
||||||
&& block.splice(0, 0, ribbon[i])
|
&& block.splice(0, 0, ribbon[i])
|
||||||
i--
|
i-- }
|
||||||
}
|
|
||||||
|
|
||||||
// post block...
|
// post block...
|
||||||
var i = c+1
|
var i = c+1
|
||||||
while(i < ribbon.length
|
while(i < ribbon.length
|
||||||
// NOTE: we are avoiding mixing up a tag not set condition
|
// NOTE: we are avoiding mixing up a tag not set condition
|
||||||
// with image i not in ribbon...
|
// with image i not in ribbon...
|
||||||
&& (!ribbon[i] || !!marked[i] == state)){
|
&& (!ribbon[i]
|
||||||
|
|| !!marked[i] == state)){
|
||||||
ribbon[i]
|
ribbon[i]
|
||||||
&& block.push(ribbon[i])
|
&& block.push(ribbon[i])
|
||||||
i++
|
i++ }
|
||||||
}
|
|
||||||
|
|
||||||
// do the marking...
|
// do the marking...
|
||||||
return this.toggleMark(block, state ? 'off' : 'on')
|
return this.toggleMark(block, state ? 'off' : 'on')
|
||||||
@ -508,8 +511,9 @@ module.ImageMarksUI = core.ImageGridFeatures.Feature({
|
|||||||
.toggleImageMark(
|
.toggleImageMark(
|
||||||
gid,
|
gid,
|
||||||
'marked',
|
'marked',
|
||||||
this.data.hasTag(gid, 'marked') ? 'on' : 'off')
|
this.data.hasTag(gid, 'marked') ?
|
||||||
}],
|
'on'
|
||||||
|
: 'off') }],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -530,7 +534,7 @@ var ImageBookmarkActions = actions.Actions({
|
|||||||
return this.data == null ?
|
return this.data == null ?
|
||||||
[]
|
[]
|
||||||
: this.data.sortViaOrder(this.data.tagQuery('bookmark')) },
|
: this.data.sortViaOrder(this.data.tagQuery('bookmark')) },
|
||||||
// XXX REVISE...
|
// NOTE: this will untag only the loaded images...
|
||||||
set bookmarked(gids){
|
set bookmarked(gids){
|
||||||
gids = gids instanceof Array ?
|
gids = gids instanceof Array ?
|
||||||
gids
|
gids
|
||||||
@ -634,8 +638,9 @@ module.ImageBookmarksUI = core.ImageGridFeatures.Feature({
|
|||||||
.toggleImageMark(
|
.toggleImageMark(
|
||||||
gid,
|
gid,
|
||||||
'bookmark',
|
'bookmark',
|
||||||
this.data.hasTag(gid, 'bookmark') ? 'on' : 'off')
|
this.data.hasTag(gid, 'bookmark') ?
|
||||||
}],
|
'on'
|
||||||
|
: 'off') }],
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user