fixed a couple of minor bugs + added .options.elementShorthand to browse.js + some tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2016-05-23 01:17:18 +03:00
parent 55ca190585
commit 5603acbd3b
6 changed files with 167 additions and 154 deletions

View File

@ -594,7 +594,7 @@ var FileSystemLoaderUIActions = actions.Actions({
} }
// indicate that we are working... // indicate that we are working...
var spinner = make($('<center><div class="loader"/></center>')) var spinner = make('...')
// XXX we do not need to actually read anything.... // XXX we do not need to actually read anything....
//file.loadIndex(path, that.config['index-dir'], this.logger) //file.loadIndex(path, that.config['index-dir'], this.logger)
@ -868,7 +868,7 @@ var FileSystemSaveHistoryUIActions = actions.Actions({
} }
// indicate that we are working... // indicate that we are working...
var spinner = make($('<center><div class="loader"/></center>')) var spinner = make('...')
that.loadSaveHistoryList() that.loadSaveHistoryList()
.catch(function(err){ .catch(function(err){

View File

@ -564,7 +564,7 @@ module.MetadataFSUI = core.ImageGridFeatures.Feature({
// add a loading indicator... // add a loading indicator...
// NOTE: this will get overwritten when calling .updateMetadata() // NOTE: this will get overwritten when calling .updateMetadata()
data.push('---') data.push('---')
data.push($('<center><div class="loader"/></center>')) data.push('...')
client.update() client.update()
reader.then(function(data){ reader.then(function(data){

View File

@ -107,7 +107,7 @@ var SharpActions = actions.Actions({
sizes = (this.config['preview-normalized'] ? sizes = (this.config['preview-normalized'] ?
sizes sizes
.map(function(s){ .map(function(s){
return cfg_sizes.filter(function(c){ return c > s }).pop() || s }) return cfg_sizes.filter(function(c){ return c >= s }).pop() || s })
: sizes) : sizes)
.unique() .unique()

View File

@ -17,8 +17,7 @@ var core = require('features/core')
/*********************************************************************/ /*********************************************************************/
// helper... //
// Change image proportions depending on scale... // Change image proportions depending on scale...
// //
// A) Small image -- min(screenwidth, screenheight) > threshold // A) Small image -- min(screenwidth, screenheight) > threshold
@ -75,8 +74,37 @@ var core = require('features/core')
// //
// NOTE: this in part does the same job as .ribbons.correctImageProportionsForRotation(..) // NOTE: this in part does the same job as .ribbons.correctImageProportionsForRotation(..)
// //
// XXX should this be an action???
function updateImageProportions(){ var SingleImageActions = actions.Actions({
config: {
// View scale...
//
// NOTE: these will get overwritten if/when the user changes the scale...
'single-image-scale': null,
'ribbon-scale': null,
// Set scale 'units' for different viewes...
//
// NOTE: the units are actually properties used to get/set the values.
'single-image-scale-unit': 'screenfit',
'ribbon-scale-unit': 'screenwidth',
// The threshold from which the image block starts to tend to
// screen proportions...
// - Above this the block is square.
// - At 1 the block is the same proportions as the screen.
// - between this and 1 the block is proportionally between a
// square and screen proportions.
//
// NOTE: setting this to null or to -1 will disable the feature...
'single-image-proportions-threshold': 2,
// XXX HACK...
'-single-image-redraw-on-focus': true,
},
updateImageProportions: ['- Interface/',
function(){
var that = this var that = this
var threshold = this.config['single-image-proportions-threshold'] var threshold = this.config['single-image-proportions-threshold']
@ -189,40 +217,9 @@ function updateImageProportions(){
.restoreTransitions(true) .restoreTransitions(true)
}) })
} }
} }],
//---------------------------------------------------------------------
var SingleImageActions = actions.Actions({
config: {
// View scale...
//
// NOTE: these will get overwritten if/when the user changes the scale...
'single-image-scale': null,
'ribbon-scale': null,
// Set scale 'units' for different viewes...
//
// NOTE: the units are actually properties used to get/set the values.
'single-image-scale-unit': 'screenfit',
'ribbon-scale-unit': 'screenwidth',
// The threshold from which the image block starts to tend to
// screen proportions...
// - Above this the block is square.
// - At 1 the block is the same proportions as the screen.
// - between this and 1 the block is proportionally between a
// square and screen proportions.
//
// NOTE: setting this to null or to -1 will disable the feature...
'single-image-proportions-threshold': 2,
// XXX HACK...
'-single-image-redraw-on-focus': true,
},
toggleSingleImage: ['Interface/Toggle single image view', toggleSingleImage: ['Interface/Toggle single image view',
toggler.CSSClassToggler( toggler.CSSClassToggler(
function(){ return this.ribbons.viewer }, function(){ return this.ribbons.viewer },
@ -278,7 +275,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
// singe image mode -- set image proportions... // singe image mode -- set image proportions...
if(this.toggleSingleImage('?') == 'on'){ if(this.toggleSingleImage('?') == 'on'){
updateImageProportions.call(this) this.updateImageProportions()
this.config['single-image-scale'] = this.config['single-image-scale'] =
this[this.config['single-image-scale-unit']] this[this.config['single-image-scale-unit']]
@ -292,7 +289,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
['resizeRibbon', ['resizeRibbon',
function(){ function(){
if(this.toggleSingleImage('?') == 'on'){ if(this.toggleSingleImage('?') == 'on'){
updateImageProportions.call(this) this.updateImageProportions()
} }
}], }],
// NOTE: this is not part of the actual action above because we // NOTE: this is not part of the actual action above because we
@ -319,7 +316,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
|| this[this.config['single-image-scale-unit']] || this[this.config['single-image-scale-unit']]
} }
updateImageProportions.call(this) this.updateImageProportions()
// ribbon mode -- restore original image size... // ribbon mode -- restore original image size...
} else { } else {

View File

@ -300,14 +300,32 @@ var BrowserPrototype = {
'close', 'close',
], ],
// Shorthand elements...
// Separator element...
// Element text as passed to make(..) to generate a separator
// element rather than a list element...
// //
// NOTE: if null text checking is disabled... // Format:
elementSeparatorText: null, // {
// <key>: {
// class: <element-class-str>,
// html: <element-html-str>,
// },
// ...
// }
//
// If make(..) gets passed <key> it will construct and element
// via <element-html-str> with an optional <element-class-str>
//
// NOTE: .class is optional...
// NOTE: set this to null to disable shorthands...
elementShorthand: {
'---': {
'class': 'separator',
'html': '<hr>'
},
'...': {
'class': 'separator',
'html': '<center><div class="loader"/></center>',
},
},
// Separator class... // Separator class...
// //
@ -315,11 +333,6 @@ var BrowserPrototype = {
// be treated as a separator and not as a list element. // be treated as a separator and not as a list element.
// NOTE: to disable class checking set this to null // NOTE: to disable class checking set this to null
elementSeparatorClass: 'separator', elementSeparatorClass: 'separator',
// Separator HTML code...
//
// NOTE: if this is null, then '<hr>' is used.
elementSeparatorHTML: '<hr>',
}, },
// XXX TEST: this should prevent event propagation... // XXX TEST: this should prevent event propagation...
@ -873,15 +886,17 @@ var BrowserPrototype = {
buttons = buttons buttons = buttons
|| (that.options.itemButtons && that.options.itemButtons.slice()) || (that.options.itemButtons && that.options.itemButtons.slice())
// special case separator... // special case: shorthand...
if(p && (p == that.options.elementSeparatorText if(p && (p in (that.options.elementShorthand || {})
|| (p.hasClass || (p.hasClass
&& that.options.elementSeparatorClass && p in that.options.elementShorthand
&& p.hasClass(that.options.elementSeparatorClass)))){ && that.options.elementShorthand[p].class
&& p.hasClass(that.options.elementShorthand[p].class)))){
var res = p var res = p
var shorthand = that.options.elementShorthand[p]
if(typeof(res) == typeof('str')){ if(typeof(res) == typeof('str')){
res = $(that.options.elementSeparatorHTML || '<hr>') res = $(shorthand.html)
.addClass(that.options.elementSeparatorClass || '') .addClass(shorthand.class || '')
} }
res.appendTo(l) res.appendTo(l)
return res return res
@ -911,7 +926,7 @@ var BrowserPrototype = {
// XXX is this the correct way to do this??? // XXX is this the correct way to do this???
var txt = p.text() var txt = p.text()
// XXX disable search??? // XXX disable search???
console.warn('jQuery objects as browse list elements not yet fully supported.') //console.warn('jQuery objects as browse list elements not yet fully supported.')
// str and other stuff... // str and other stuff...
} else { } else {
@ -2224,8 +2239,6 @@ ListerPrototype.options = {
skipDisabledItems: false, skipDisabledItems: false,
// NOTE: to disable this set it to false or null // NOTE: to disable this set it to false or null
disableItemPattern: '^- ', disableItemPattern: '^- ',
elementSeparatorText: '---',
} }
// XXX should we inherit or copy options??? // XXX should we inherit or copy options???
// ...inheriting might pose problems with deleting values reverting // ...inheriting might pose problems with deleting values reverting
@ -2287,8 +2300,6 @@ ListPrototype.options = {
// NOTE: to disable this set it to false or null // NOTE: to disable this set it to false or null
disableItemPattern: '^- ', disableItemPattern: '^- ',
elementSeparatorText: '---',
list: function(path, make){ list: function(path, make){
var that = this var that = this
var data = this.options.data var data = this.options.data

View File

@ -2238,8 +2238,10 @@ var RibbonsPrototype = {
} else if((o == 0 || o == 180) && image_p != viewer_p){ } else if((o == 0 || o == 180) && image_p != viewer_p){
image.css({ image.css({
width: h, //width: h,
height: w, //height: w,
width: '',
height: '',
margin: '', margin: '',
}) })
@ -2248,7 +2250,10 @@ var RibbonsPrototype = {
// square image... // square image...
} else { } else {
image.css({ image.css({
'margin': '', width: '',
height: '',
margin: '',
}) })
} }
}) })