mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
several fixes for features.js and moved app actions to a feature...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
77b0759ac7
commit
dd8d5c32f6
@ -164,16 +164,25 @@ Feature.prototype.constructor = Feature
|
|||||||
var FeatureSet =
|
var FeatureSet =
|
||||||
module.FeatureSet = {
|
module.FeatureSet = {
|
||||||
buildFeatureList: function(obj, lst){
|
buildFeatureList: function(obj, lst){
|
||||||
|
lst = lst == null ? Object.keys(this) : lst
|
||||||
lst = lst.constructor !== Array ? [lst] : lst
|
lst = lst.constructor !== Array ? [lst] : lst
|
||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
// sort features via priority...
|
// sort features via priority keeping the order as close to
|
||||||
lst = lst.sort(function(a, b){
|
// manual as possible...
|
||||||
a = that[a] == null ? 0 : that[a].getPriority()
|
var l = lst.length
|
||||||
b = that[b] == null ? 0 : that[b].getPriority()
|
lst = lst
|
||||||
return b - a
|
// remove undefined features...
|
||||||
})
|
.filter(function(e){ return that[e] != null })
|
||||||
|
// build the sort table: [ <priority>, <rev-index>, <elem> ]
|
||||||
|
// NOTE: <rev-index> is element number from the tail...
|
||||||
|
.map(function(e, i){ return [ -that[e].getPriority(), i, e ] })
|
||||||
|
// do the sort...
|
||||||
|
// XXX for some reason JS compares lists as strings...
|
||||||
|
.sort(function(a, b){ return a[0] - b[0] || a[1] - b[1] })
|
||||||
|
// cleanup...
|
||||||
|
.map(function(e){ return e[2] })
|
||||||
|
|
||||||
// sort features via dependencies...
|
// sort features via dependencies...
|
||||||
var unapplicable = []
|
var unapplicable = []
|
||||||
|
|||||||
@ -212,15 +212,16 @@ $(function(){
|
|||||||
|
|
||||||
viewer.ImageGridFeatures.setup(a, [
|
viewer.ImageGridFeatures.setup(a, [
|
||||||
// features...
|
// features...
|
||||||
'ui-partial-ribbons',
|
|
||||||
'ui-ribbon-align-to-order',
|
'ui-ribbon-align-to-order',
|
||||||
'ui-single-image-view',
|
'ui-single-image-view',
|
||||||
'fs-loader',
|
'fs-loader',
|
||||||
|
'app-control',
|
||||||
|
|
||||||
// ui elements...
|
// ui elements...
|
||||||
'image-marks',
|
'image-marks',
|
||||||
'image-bookmarks',
|
'image-bookmarks',
|
||||||
|
|
||||||
|
'ui-partial-ribbons',
|
||||||
// chrome...
|
// chrome...
|
||||||
'ui-animation',
|
'ui-animation',
|
||||||
'ui-bounds-indicators',
|
'ui-bounds-indicators',
|
||||||
|
|||||||
@ -785,26 +785,6 @@ actions.Actions(Client, {
|
|||||||
setEmptyMsg: ['Set message to be displayed when nothing is loaded.',
|
setEmptyMsg: ['Set message to be displayed when nothing is loaded.',
|
||||||
function(msg, help){ this.ribbons.setEmptyMsg(msg, help) }],
|
function(msg, help){ this.ribbons.setEmptyMsg(msg, help) }],
|
||||||
|
|
||||||
// App stuff...
|
|
||||||
// XXX move this to a viewer window action set
|
|
||||||
// XXX revise these...
|
|
||||||
close: ['Cloase viewer',
|
|
||||||
function(){
|
|
||||||
// XXX should we do anything else here like auto-save???
|
|
||||||
window.close()
|
|
||||||
}],
|
|
||||||
toggleFullScreen: ['',
|
|
||||||
function(){
|
|
||||||
// XXX where should toggleFullscreenMode(..) be defined...
|
|
||||||
toggleFullscreenMode()
|
|
||||||
}],
|
|
||||||
showDevTools: ['',
|
|
||||||
function(){
|
|
||||||
if(window.showDevTools != null){
|
|
||||||
showDevTools()
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
|
|
||||||
|
|
||||||
// align modes...
|
// align modes...
|
||||||
// XXX these should also affect up/down navigation...
|
// XXX these should also affect up/down navigation...
|
||||||
@ -1050,7 +1030,6 @@ actions.Actions(Client, {
|
|||||||
function(target){ return updateImagePosition(this, target) }],
|
function(target){ return updateImagePosition(this, target) }],
|
||||||
shiftImageDown: [
|
shiftImageDown: [
|
||||||
function(target){ return updateImagePosition(this, target) }],
|
function(target){ return updateImagePosition(this, target) }],
|
||||||
|
|
||||||
shiftImageLeft: [
|
shiftImageLeft: [
|
||||||
function(target){
|
function(target){
|
||||||
this.ribbons.placeImage(target, -1)
|
this.ribbons.placeImage(target, -1)
|
||||||
@ -1077,6 +1056,7 @@ actions.Actions(Client, {
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
|
|
||||||
|
|
||||||
reverseImages: [ reloadAfter() ],
|
reverseImages: [ reloadAfter() ],
|
||||||
reverseRibbons: [ reloadAfter() ],
|
reverseRibbons: [ reloadAfter() ],
|
||||||
|
|
||||||
@ -1142,6 +1122,7 @@ var ImageGridFeatures =
|
|||||||
module.ImageGridFeatures = Object.create(features.FeatureSet)
|
module.ImageGridFeatures = Object.create(features.FeatureSet)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
// NOTE: this is split out to an action so as to enable ui elements to
|
// NOTE: this is split out to an action so as to enable ui elements to
|
||||||
@ -1262,7 +1243,6 @@ var PartialRibbonsActions = actions.Actions({
|
|||||||
// - go to top ribbon
|
// - go to top ribbon
|
||||||
// - shift image up
|
// - shift image up
|
||||||
// XXX The two should be completely independent.... (???)
|
// XXX The two should be completely independent.... (???)
|
||||||
// XXX need to test and tweak with actual images...
|
|
||||||
var PartialRibbons =
|
var PartialRibbons =
|
||||||
module.PartialRibbons = features.Feature(ImageGridFeatures, {
|
module.PartialRibbons = features.Feature(ImageGridFeatures, {
|
||||||
title: 'Partial Ribbons',
|
title: 'Partial Ribbons',
|
||||||
@ -1456,6 +1436,7 @@ module.AlignRibbonsToImageOrder = features.Feature(ImageGridFeatures, {
|
|||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'ui-ribbon-align-to-order',
|
tag: 'ui-ribbon-align-to-order',
|
||||||
|
exclusive: ['ui-ribbon-align'],
|
||||||
|
|
||||||
handlers: [
|
handlers: [
|
||||||
['focusImage.post', function(){ this.alignByOrder() }]
|
['focusImage.post', function(){ this.alignByOrder() }]
|
||||||
@ -1463,15 +1444,13 @@ module.AlignRibbonsToImageOrder = features.Feature(ImageGridFeatures, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
|
||||||
|
|
||||||
var AlignRibbonsToFirstImage =
|
var AlignRibbonsToFirstImage =
|
||||||
module.AlignRibbonsToFirstImage = features.Feature(ImageGridFeatures, {
|
module.AlignRibbonsToFirstImage = features.Feature(ImageGridFeatures, {
|
||||||
title: '',
|
title: '',
|
||||||
doc: '',
|
doc: '',
|
||||||
|
|
||||||
tag: 'ui-ribbon-align-to-first',
|
tag: 'ui-ribbon-align-to-first',
|
||||||
|
exclusive: ['ui-ribbon-align'],
|
||||||
|
|
||||||
handlers: [
|
handlers: [
|
||||||
['focusImage.post', function(){ this.alignByFirst() }],
|
['focusImage.post', function(){ this.alignByFirst() }],
|
||||||
@ -1819,7 +1798,6 @@ module.CurrentImageIndicator = features.Feature(ImageGridFeatures, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// XXX this depends on CurrentImageIndicator...
|
|
||||||
var CurrentImageIndicatorHideOnFastScreenNav =
|
var CurrentImageIndicatorHideOnFastScreenNav =
|
||||||
module.CurrentImageIndicatorHideOnFastScreenNav = features.Feature(ImageGridFeatures, {
|
module.CurrentImageIndicatorHideOnFastScreenNav = features.Feature(ImageGridFeatures, {
|
||||||
title: '',
|
title: '',
|
||||||
@ -1882,8 +1860,6 @@ module.CurrentImageIndicatorHideOnFastScreenNav = features.Feature(ImageGridFeat
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// XXX this depends on CurrentImageIndicator...
|
|
||||||
var CurrentImageIndicatorHideOnScreenNav =
|
var CurrentImageIndicatorHideOnScreenNav =
|
||||||
module.CurrentImageIndicatorHideOnScreenNav = features.Feature(ImageGridFeatures, {
|
module.CurrentImageIndicatorHideOnScreenNav = features.Feature(ImageGridFeatures, {
|
||||||
title: '',
|
title: '',
|
||||||
@ -2171,6 +2147,51 @@ module.ImageBookmarks = features.Feature(ImageGridFeatures, {
|
|||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
|
||||||
|
var AppControlActions = actions.Actions({
|
||||||
|
// XXX revise these...
|
||||||
|
close: ['Cloase viewer',
|
||||||
|
function(){
|
||||||
|
// XXX should we do anything else here like auto-save???
|
||||||
|
window.close()
|
||||||
|
}],
|
||||||
|
toggleFullScreen: ['',
|
||||||
|
function(){
|
||||||
|
// XXX where should toggleFullscreenMode(..) be defined...
|
||||||
|
toggleFullscreenMode()
|
||||||
|
}],
|
||||||
|
showDevTools: ['',
|
||||||
|
function(){
|
||||||
|
if(window.showDevTools != null){
|
||||||
|
showDevTools()
|
||||||
|
}
|
||||||
|
}],
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
// XXX this needs a better .isApplicable(..)
|
||||||
|
var AppControl =
|
||||||
|
module.AppControl = features.Feature(ImageGridFeatures, {
|
||||||
|
title: '',
|
||||||
|
doc: '',
|
||||||
|
|
||||||
|
tag: 'app-control',
|
||||||
|
|
||||||
|
actions: AppControlActions,
|
||||||
|
|
||||||
|
// XXX test if in:
|
||||||
|
// - chrome app
|
||||||
|
// - nw
|
||||||
|
// - mobile
|
||||||
|
isApplicable: function(){
|
||||||
|
return window.nodejs != null
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------
|
||||||
|
// XXX at this point this is a stub...
|
||||||
var FileSystemLoader =
|
var FileSystemLoader =
|
||||||
module.FileSystemLoader = features.Feature(ImageGridFeatures, {
|
module.FileSystemLoader = features.Feature(ImageGridFeatures, {
|
||||||
title: '',
|
title: '',
|
||||||
@ -2185,7 +2206,6 @@ module.FileSystemLoader = features.Feature(ImageGridFeatures, {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
return module })
|
return module })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user