refactoring: removed NAV_* form base.js as thy were not used but added complexity...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-07-03 20:44:24 +04:00
parent dacfdf6192
commit d6812c1bb8

View File

@ -20,17 +20,6 @@
* *
**********************************************************************/ **********************************************************************/
// NOTE: NAV_ALL might not be practical...
var NAV_ALL = '*'
var NAV_VISIBLE = ':visible'
var NAV_MARKED = '.marked:visible'
var NAV_DEFAULT = NAV_ALL
var NAV_RIBBON_ALL = ''
var NAV_RIBBON_VISIBLE = ':visible'
var NAV_RIBBON_DEFAULT = NAV_RIBBON_ALL
//var NAV_RIBBON_DEFAULT = NAV_RIBBON_VISIBLE
// can be: // can be:
// - animate // - animate
// - css // - css
@ -213,13 +202,12 @@ function getScreenWidthInImages(size){
// NOTE: this might return an empty target if the ribbon is empty... // NOTE: this might return an empty target if the ribbon is empty...
// NOTE: this only "sees" the loaded images, for a full check use // NOTE: this only "sees" the loaded images, for a full check use
// getGIDBefore(...) that will check the full data... // getGIDBefore(...) that will check the full data...
function getImageBefore(image, ribbon, mode){ function getImageBefore(image, ribbon){
mode = mode == null ? NAV_DEFAULT : mode
image = image == null ? getImage() : $(image) image = image == null ? getImage() : $(image)
if(ribbon == null){ if(ribbon == null){
ribbon = getRibbon(image) ribbon = getRibbon(image)
} }
var images = $(ribbon).find('.image').filter(mode) var images = $(ribbon).find('.image')
var order = getImageOrder(image) var order = getImageOrder(image)
var prev = [] var prev = []
@ -235,7 +223,7 @@ function getImageBefore(image, ribbon, mode){
function shiftTo(image, ribbon){ function shiftTo(image, ribbon){
var target = getImageBefore(image, ribbon, NAV_ALL) var target = getImageBefore(image, ribbon)
var cur_ribbon = getRibbon(image) var cur_ribbon = getRibbon(image)
// insert before the first image if nothing is before the target... // insert before the first image if nothing is before the target...
@ -623,7 +611,7 @@ function centerRibbon(ribbon, image, mode){
// we are at the start of a ribbon -- nothing before... // we are at the start of a ribbon -- nothing before...
} else { } else {
// get first image in ribbon... // get first image in ribbon...
target = ribbon.find('.image').filter(NAV_DEFAULT).first() target = ribbon.find('.image').first()
var dl = getRelativeVisualPosition(target, image).left/scale var dl = getRelativeVisualPosition(target, image).left/scale
l = { l = {
left: l + dl + (w/2) + offset left: l + dl + (w/2) + offset
@ -646,7 +634,6 @@ function centerRibbon(ribbon, image, mode){
// a shorthand... // a shorthand...
function centerRibbons(mode, no_skip_current){ function centerRibbons(mode, no_skip_current){
return $('.ribbon') return $('.ribbon')
.filter('*' + NAV_RIBBON_DEFAULT)
.each(function(){ .each(function(){
if(no_skip_current == true && $(this).find('.current.image').length > 0){ if(no_skip_current == true && $(this).find('.current.image').length > 0){
return return
@ -665,7 +652,7 @@ function centerRibbons(mode, no_skip_current){
function clickHandler(evt){ function clickHandler(evt){
var img = $(evt.target).closest('.image') var img = $(evt.target).closest('.image')
if(img.filter(NAV_VISIBLE).length > 0){ if(img.length > 0){
centerView(focusImage(img)) centerView(focusImage(img))
centerRibbons() centerRibbons()
@ -689,10 +676,9 @@ function dblClickHandler(evt){
*/ */
// basic navigation actions... // basic navigation actions...
function nextImage(n, mode){ function nextImage(n){
mode = mode == null ? NAV_DEFAULT : mode
n = n == null ? 1 : n n = n == null ? 1 : n
var target = getImage().nextAll('.image' + mode) var target = getImage().nextAll('.image')
if(target.length < n){ if(target.length < n){
target = target.last() target = target.last()
target = target.length == 0 ? getImage() : target target = target.length == 0 ? getImage() : target
@ -705,10 +691,9 @@ function nextImage(n, mode){
} }
return centerView(focusImage(target)) return centerView(focusImage(target))
} }
function prevImage(n, mode){ function prevImage(n){
mode = mode == null ? NAV_DEFAULT : mode
n = n == null ? 1 : n n = n == null ? 1 : n
var target = getImage().prevAll('.image' + mode) var target = getImage().prevAll('.image')
if(target.length < n){ if(target.length < n){
target = target.last() target = target.last()
target = target.length == 0 ? getImage() : target target = target.length == 0 ? getImage() : target
@ -723,46 +708,43 @@ function prevImage(n, mode){
} }
function nextScreenImages(mode){ function nextScreenImages(){
return nextImage(Math.round(getScreenWidthInImages()), mode) return nextImage(Math.round(getScreenWidthInImages()))
} }
function prevScreenImages(mode){ function prevScreenImages(){
return prevImage(Math.round(getScreenWidthInImages()), mode) return prevImage(Math.round(getScreenWidthInImages()))
} }
// XXX revise... // XXX revise...
function firstImage(mode){ function firstImage(){
$('.viewer').trigger('requestedFirstImage', [getRibbon()]) $('.viewer').trigger('requestedFirstImage', [getRibbon()])
mode = mode == null ? NAV_DEFAULT : mode if(getImage().prevAll('.image').length == 0){
if(getImage().prevAll('.image' + mode).length == 0){
flashIndicator('start') flashIndicator('start')
} }
return centerView( return centerView(
focusImage( focusImage(
getRibbon().find('.image').filter(mode).first())) getRibbon().find('.image').first()))
} }
// XXX revise... // XXX revise...
function lastImage(mode){ function lastImage(){
$('.viewer').trigger('requestedLastImage', [getRibbon()]) $('.viewer').trigger('requestedLastImage', [getRibbon()])
mode = mode == null ? NAV_DEFAULT : mode if(getImage().nextAll('.image').length == 0){
if(getImage().nextAll('.image' + mode).length == 0){
flashIndicator('end') flashIndicator('end')
} }
return centerView( return centerView(
focusImage( focusImage(
getRibbon().find('.image').filter(mode).last())) getRibbon().find('.image').last()))
} }
// NOTE: if moving is 'next' these will chose the image after the current's order. // NOTE: if moving is 'next' these will chose the image after the current's order.
// NOTE: if an image with the same order is found, moving argument has no effect. // NOTE: if an image with the same order is found, moving argument has no effect.
function prevRibbon(mode){ function prevRibbon(){
mode = mode == null ? NAV_DEFAULT : mode
var cur = getImage() var cur = getImage()
var target_ribbon = getRibbon(cur).prevAll('.ribbon' + NAV_RIBBON_DEFAULT).first() var target_ribbon = getRibbon(cur).prevAll('.ribbon').first()
var target = getImageBefore(cur, target_ribbon) var target = getImageBefore(cur, target_ribbon)
// no ribbon above... // no ribbon above...
@ -772,19 +754,18 @@ function prevRibbon(mode){
} else { } else {
// first image... // first image...
if(target.length == 0){ if(target.length == 0){
target = target_ribbon.find('.image' + mode).first() target = target_ribbon.find('.image').first()
} else { } else {
var next = target.nextAll('.image' + mode).first() var next = target.nextAll('.image').first()
target = next.length > 0 ? next : target target = next.length > 0 ? next : target
} }
} }
return centerView(focusImage(target)) return centerView(focusImage(target))
} }
function nextRibbon(mode){ function nextRibbon(){
mode = mode == null ? NAV_DEFAULT : mode
var cur = getImage() var cur = getImage()
var target_ribbon = getRibbon(cur).nextAll('.ribbon' + NAV_RIBBON_DEFAULT).first() var target_ribbon = getRibbon(cur).nextAll('.ribbon').first()
var target = getImageBefore(cur, target_ribbon) var target = getImageBefore(cur, target_ribbon)
// no ribbon below... // no ribbon below...
@ -794,7 +775,7 @@ function nextRibbon(mode){
} else { } else {
// first image... // first image...
if(target.length == 0){ if(target.length == 0){
target = target_ribbon.find('.image' + mode).first() target = target_ribbon.find('.image').first()
} }
} }
@ -1061,17 +1042,16 @@ function zoomOut(){
// NOTE: for shiftImageRight/shiftImageLeft see data.js, as they depend // NOTE: for shiftImageRight/shiftImageLeft see data.js, as they depend
// on data ordering... // on data ordering...
function shiftImageTo(image, direction, moving, force_create_ribbon, mode){ function shiftImageTo(image, direction, moving, force_create_ribbon){
if(image == null){ if(image == null){
image = getImage() image = getImage()
} }
mode = mode == null ? NAV_DEFAULT : mode
// account move for direction... // account move for direction...
// XXX get the value from some place more logical than the argument... // XXX get the value from some place more logical than the argument...
var a = moving == 'prev' ? 'prevAll' : 'nextAll' var a = moving == 'prev' ? 'prevAll' : 'nextAll'
var b = moving == 'prev' ? 'nextAll' : 'prevAll' var b = moving == 'prev' ? 'nextAll' : 'prevAll'
var target = image[a]('.image' + mode).first() var target = image[a]('.image').first()
target = target.length == 0 ? image[b]().first() : target target = target.length == 0 ? image[b]().first() : target