compleated bookmark indicators, more refactoring...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-12-14 06:29:22 +04:00
parent 2bd9c98011
commit 7f681d264a
5 changed files with 57 additions and 21 deletions

View File

@ -648,7 +648,7 @@ var KEYBOARD_CONFIG = {
// XXX should this toggle or set mark to on? // XXX should this toggle or set mark to on?
default: doc('Mark current image and advance', default: doc('Mark current image and advance',
function(){ function(){
toggleImageMark('on') toggleMark('on')
directionImage() directionImage()
// XXX do we need this??? // XXX do we need this???
//if(getImage().filter(':visible').length == 0){ //if(getImage().filter(':visible').length == 0){
@ -659,7 +659,7 @@ var KEYBOARD_CONFIG = {
// same as default but in reverse direction... // same as default but in reverse direction...
shift: doc('Mark current image and return', shift: doc('Mark current image and return',
function(){ function(){
toggleImageMark('on') toggleMark('on')
directionImage(true) directionImage(true)
// XXX do we need this??? // XXX do we need this???
//if(getImage().filter(':visible').length == 0){ //if(getImage().filter(':visible').length == 0){
@ -669,13 +669,13 @@ var KEYBOARD_CONFIG = {
}), }),
ctrl: doc('Show mark dialog', function(){ markImagesDialog() }), ctrl: doc('Show mark dialog', function(){ markImagesDialog() }),
}, },
Ins: doc('Toggle mark on current image', function(){ toggleImageMark() }), Ins: doc('Toggle mark on current image', function(){ toggleMark() }),
'invert-marks': doc('Invert image marks', 'invert-marks': doc('Invert image marks',
function(){ invertImageMarks() }), function(){ invertImageMarks() }),
A: { A: {
// XXX does not yet work with DATA (???) // XXX does not yet work with DATA (???)
//shift: doc('Toggle marks in current contagious block', //shift: doc('Toggle marks in current contagious block',
// function(){ toggleImageMarkBlock() }), // function(){ toggleMarkBlock() }),
ctrl: doc('Mark current ribbon', ctrl: doc('Mark current ribbon',
function(){ function(){
@ -699,7 +699,7 @@ var KEYBOARD_CONFIG = {
}, },
U: { U: {
default: doc('Unmark current image', default: doc('Unmark current image',
function(){ toggleImageMark('off') }), function(){ toggleMark('off') }),
ctrl: doc('Unmark current ribbon', ctrl: doc('Unmark current ribbon',
function(){ removeImageMarks('ribbon') }), function(){ removeImageMarks('ribbon') }),
shift: doc('Unamrk all', shift: doc('Unamrk all',

View File

@ -1039,13 +1039,18 @@ button:hover {
.context-mode-indicators .current-image-marked { .context-mode-indicators .current-image-marked {
color: blue; color: blue;
} }
.context-mode-indicators .current-image-bookmarked {
color: yellow;
}
.global-mode-indicators .marked-only-visible .shown, .global-mode-indicators .marked-only-visible .shown,
.global-mode-indicators .marks-visible .shown, .global-mode-indicators .marks-visible .shown,
.context-mode-indicators .current-image-bookmarked .shown,
.context-mode-indicators .current-image-marked .shown { .context-mode-indicators .current-image-marked .shown {
display: none; display: none;
} }
.global-mode-indicators .marked-only-visible:after, .global-mode-indicators .marked-only-visible:after,
.global-mode-indicators .marks-visible:after, .global-mode-indicators .marks-visible:after,
.context-mode-indicators .current-image-bookmarked:after,
.context-mode-indicators .current-image-marked:after { .context-mode-indicators .current-image-marked:after {
display: inline-block; display: inline-block;
width: 6px; width: 6px;
@ -1063,6 +1068,11 @@ button:hover {
.context-mode-indicators .current-image-marked:after { .context-mode-indicators .current-image-marked:after {
color: blue; color: blue;
} }
.context-mode-indicators .current-image-bookmarked:after {
color: yellow;
background-color: yellow;
border: solid 2px yellow;
}
.marks-visible.viewer .global-mode-indicators .marks-visible { .marks-visible.viewer .global-mode-indicators .marks-visible {
display: inline-block; display: inline-block;
} }
@ -1076,10 +1086,11 @@ button:hover {
background-color: transparent; background-color: transparent;
} }
/* image mark in single image mode... */ /* image mark in single image mode... */
.context-mode-indicators .current-image-bookmarked,
.context-mode-indicators .current-image-marked { .context-mode-indicators .current-image-marked {
display: none; display: none;
color: blue;
} }
.single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-bookmarked.shown,
.single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-marked.shown { .single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-marked.shown {
display: inline-block; display: inline-block;
} }

View File

@ -1068,13 +1068,18 @@ button:hover {
.context-mode-indicators .current-image-marked { .context-mode-indicators .current-image-marked {
color: blue; color: blue;
} }
.context-mode-indicators .current-image-bookmarked {
color: yellow;
}
.global-mode-indicators .marked-only-visible .shown, .global-mode-indicators .marked-only-visible .shown,
.global-mode-indicators .marks-visible .shown, .global-mode-indicators .marks-visible .shown,
.context-mode-indicators .current-image-bookmarked .shown,
.context-mode-indicators .current-image-marked .shown { .context-mode-indicators .current-image-marked .shown {
display: none; display: none;
} }
.global-mode-indicators .marked-only-visible:after, .global-mode-indicators .marked-only-visible:after,
.global-mode-indicators .marks-visible:after, .global-mode-indicators .marks-visible:after,
.context-mode-indicators .current-image-bookmarked:after,
.context-mode-indicators .current-image-marked:after { .context-mode-indicators .current-image-marked:after {
display: inline-block; display: inline-block;
width: 6px; width: 6px;
@ -1093,6 +1098,11 @@ button:hover {
.context-mode-indicators .current-image-marked:after { .context-mode-indicators .current-image-marked:after {
color: blue; color: blue;
} }
.context-mode-indicators .current-image-bookmarked:after {
color: yellow;
background-color: yellow;
border: solid 2px yellow;
}
.marks-visible.viewer .global-mode-indicators .marks-visible { .marks-visible.viewer .global-mode-indicators .marks-visible {
display: inline-block; display: inline-block;
} }
@ -1106,10 +1116,11 @@ button:hover {
background-color: transparent; background-color: transparent;
} }
/* image mark in single image mode... */ /* image mark in single image mode... */
.context-mode-indicators .current-image-bookmarked,
.context-mode-indicators .current-image-marked { .context-mode-indicators .current-image-marked {
display: none; display: none;
color: blue;
} }
.single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-bookmarked.shown,
.single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-marked.shown { .single-image-mode.marks-visible.viewer .context-mode-indicators .current-image-marked.shown {
display: inline-block; display: inline-block;
} }

View File

@ -204,7 +204,7 @@ var toggleMarkesView = createCSSClassToggler(
*/ */
var toggleImageMark = makeMarkToggler('marked', 'selected', 'togglingMark') var toggleMark = makeMarkToggler('marked', 'selected', 'togglingMark')
// mode can be: // mode can be:
@ -217,7 +217,7 @@ function removeImageMarks(mode){
var res = ribbon var res = ribbon
.find('.marked') .find('.marked')
.each(function(){ .each(function(){
toggleImageMark(this, 'off') toggleMark(this, 'off')
}) })
$('.viewer').trigger('removeingRibbonMarks', [ribbon]) $('.viewer').trigger('removeingRibbonMarks', [ribbon])
@ -225,7 +225,7 @@ function removeImageMarks(mode){
} else if(mode == 'all'){ } else if(mode == 'all'){
var res = $('.marked') var res = $('.marked')
.each(function(){ .each(function(){
toggleImageMark(this, 'off') toggleMark(this, 'off')
}) })
$('.viewer').trigger('removeingAllMarks') $('.viewer').trigger('removeingAllMarks')
} }
@ -240,7 +240,7 @@ function markAll(mode){
var res = ribbon var res = ribbon
.find('.image:not(.marked)') .find('.image:not(.marked)')
.each(function(){ .each(function(){
toggleImageMark(this, 'on') toggleMark(this, 'on')
}) })
$('.viewer').trigger('markingRibbon', [ribbon]) $('.viewer').trigger('markingRibbon', [ribbon])
@ -248,7 +248,7 @@ function markAll(mode){
} else if(mode == 'all'){ } else if(mode == 'all'){
var res = $('.image:not(.marked)') var res = $('.image:not(.marked)')
.each(function(){ .each(function(){
toggleImageMark(this, 'on') toggleMark(this, 'on')
}) })
$('.viewer').trigger('markingAll') $('.viewer').trigger('markingAll')
} }
@ -262,7 +262,7 @@ function invertImageMarks(){
var res = ribbon var res = ribbon
.find('.image') .find('.image')
.each(function(){ .each(function(){
toggleImageMark(this, 'next') toggleMark(this, 'next')
}) })
$('.viewer').trigger('invertingMarks', [ribbon]) $('.viewer').trigger('invertingMarks', [ribbon])
return res return res
@ -273,16 +273,16 @@ function invertImageMarks(){
// images... // images...
// XXX need to make this dynamic data compatible... // XXX need to make this dynamic data compatible...
// XXX this will mark the block ONLY IF it is loaded!!! // XXX this will mark the block ONLY IF it is loaded!!!
function toggleImageMarkBlock(image){ function toggleMarkBlock(image){
if(image == null){ if(image == null){
image = getImage() image = getImage()
} }
var found = [false, false] var found = [false, false]
// we need to invert this... // we need to invert this...
var state = toggleImageMark() var state = toggleMark()
var _convert = function(i){ var _convert = function(i){
return function(){ return function(){
if(toggleImageMark(this, '?') == state){ if(toggleMark(this, '?') == state){
// we found the end... // we found the end...
// NOTE: this will not be set if we reached the end of // NOTE: this will not be set if we reached the end of
// the ribbon or the end of the loaded images... // the ribbon or the end of the loaded images...
@ -290,7 +290,7 @@ function toggleImageMarkBlock(image){
// stop the iteration... // stop the iteration...
return false return false
} }
toggleImageMark(this, state) toggleMark(this, state)
} }
} }
image.nextAll('.image').each(_convert(1)) image.nextAll('.image').each(_convert(1))
@ -387,7 +387,7 @@ function markImagesDialog(){
var alg = 'Mark images:' var alg = 'Mark images:'
var cur = toggleImageMark('?') == 'on' ? 'Unmark' : 'Mark' var cur = toggleMark('?') == 'on' ? 'Unmark' : 'Mark'
cfg = {} cfg = {}
cfg[alg] = [ cfg[alg] = [
@ -411,11 +411,11 @@ function markImagesDialog(){
// NOTE: these must be in order of least-specific last... // NOTE: these must be in order of least-specific last...
if(/current image/.test(res)){ if(/current image/.test(res)){
toggleImageMark() toggleMark()
var msg = (cur + ' image').toLowerCase() var msg = (cur + ' image').toLowerCase()
} else if(/current block/.test(res)){ } else if(/current block/.test(res)){
toggleImageMarkBlock() toggleMarkBlock()
var msg = 'toggled block marks' var msg = 'toggled block marks'
} else if(/Invert/.test(res)){ } else if(/Invert/.test(res)){

View File

@ -32,11 +32,17 @@ function setupIndicators(){
.css('cursor', 'hand') .css('cursor', 'hand')
.click(function(){ toggleMarkedOnlyView() }) .click(function(){ toggleMarkedOnlyView() })
showContextIndicator(
'current-image-bookmarked',
'Image is bookmarked (ctrl-B)')
.css('cursor', 'hand')
.click(function(){ toggleBookmark() })
showContextIndicator( showContextIndicator(
'current-image-marked', 'current-image-marked',
'Image is marked (Ins)') 'Image is marked (Ins)')
.css('cursor', 'hand') .css('cursor', 'hand')
.click(function(){ toggleImageMark() }) .click(function(){ toggleMark() })
} }
@ -50,6 +56,13 @@ function updateContextIndicators(image){
} else { } else {
indicator.removeClass('shown') indicator.removeClass('shown')
} }
indicator = $('.context-mode-indicators .current-image-bookmarked')
if(image.hasClass('bookmarked')){
indicator.addClass('shown')
} else {
indicator.removeClass('shown')
}
} }
@ -360,6 +373,7 @@ function setupDataBindings(viewer){
.on([ .on([
'focusingImage', 'focusingImage',
'togglingMark', 'togglingMark',
'togglingBookmark',
'removeingAllMarks', 'removeingAllMarks',
'removeingRibbonMarks', 'removeingRibbonMarks',
'markingAll', 'markingAll',