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

View File

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

View File

@ -107,7 +107,7 @@ var SharpActions = actions.Actions({
sizes = (this.config['preview-normalized'] ?
sizes
.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)
.unique()

View File

@ -17,8 +17,7 @@ var core = require('features/core')
/*********************************************************************/
// helper...
//
// Change image proportions depending on scale...
//
// 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(..)
//
// 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 threshold = this.config['single-image-proportions-threshold']
@ -189,40 +217,9 @@ function updateImageProportions(){
.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',
toggler.CSSClassToggler(
function(){ return this.ribbons.viewer },
@ -278,7 +275,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
// singe image mode -- set image proportions...
if(this.toggleSingleImage('?') == 'on'){
updateImageProportions.call(this)
this.updateImageProportions()
this.config['single-image-scale'] =
this[this.config['single-image-scale-unit']]
@ -292,7 +289,7 @@ module.SingleImageView = core.ImageGridFeatures.Feature({
['resizeRibbon',
function(){
if(this.toggleSingleImage('?') == 'on'){
updateImageProportions.call(this)
this.updateImageProportions()
}
}],
// 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']]
}
updateImageProportions.call(this)
this.updateImageProportions()
// ribbon mode -- restore original image size...
} else {

View File

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

View File

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