diff --git a/ui (gen4)/features/_ui-render.js b/ui (gen4)/features/_ui-render.js index aefb0d96..c24c2328 100755 --- a/ui (gen4)/features/_ui-render.js +++ b/ui (gen4)/features/_ui-render.js @@ -15,12 +15,39 @@ var core = require('features/core') +/*********************************************************************/ + +var RibbonsClassPrototype = { +} + + +var RibbonsPrototype = { + getImage: function(){ + // XXX + }, + getImageByPosition: function(){ + // XXX + }, + getRibbon: function(){ + // XXX + }, +} + + +var Ribbons = +module.Ribbons = +object.makeConstructor('Ribbons', + RibbonsClassPrototype, + RibbonsPrototype) + + + /*********************************************************************/ var RenderActions = actions.Actions({ load: [ function(){ - // XXX + // XXX setup .ribbons }], reload: [ function(){ diff --git a/ui (gen4)/features/ui-legacy.js b/ui (gen4)/features/ui-legacy.js index 62a57bf3..29a9bae4 100755 --- a/ui (gen4)/features/ui-legacy.js +++ b/ui (gen4)/features/ui-legacy.js @@ -70,7 +70,7 @@ module.Clickable = core.ImageGridFeatures.Feature({ // this will prevent double clicks... x = null y = null - that.focusImage(that.ribbons.getElemGID($(this))) + that.focusImage(that.ribbons.elemGID($(this))) last = Date.now() } }) @@ -190,11 +190,11 @@ module.DirectControlHammer = core.ImageGridFeatures.Feature({ // silently focus central image... if(that.config['focus-central-image'] == 'silent'){ - that.data.current = that.ribbons.getElemGID(central) + that.data.current = that.ribbons.elemGID(central) // focus central image in a normal manner... } else if(that.config['focus-central-image']){ - that.focusImage(that.ribbons.getElemGID(central)) + that.focusImage(that.ribbons.elemGID(central)) } setTimeout(function(){ diff --git a/ui (gen4)/features/ui-partial-ribbons-2.js b/ui (gen4)/features/ui-partial-ribbons-2.js index f4a7a11a..106c689f 100755 --- a/ui (gen4)/features/ui-partial-ribbons-2.js +++ b/ui (gen4)/features/ui-partial-ribbons-2.js @@ -45,7 +45,7 @@ var PartialRibbonsActions = actions.Actions({ updateRibbon: ['- Interface/Update partial ribbon size', function(target, w, size, threshold, preload){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) // NOTE: data.getImage(..) can return null at start or end // of ribbon, thus we need to account for this... : (this.data.getImage(target) diff --git a/ui (gen4)/features/ui-partial-ribbons-precache.js b/ui (gen4)/features/ui-partial-ribbons-precache.js index a8a90dc8..c18cf280 100755 --- a/ui (gen4)/features/ui-partial-ribbons-precache.js +++ b/ui (gen4)/features/ui-partial-ribbons-precache.js @@ -109,7 +109,7 @@ var PreCacheActions = actions.Actions({ preCacheJumpTargets: ['- Interface/Pre-cache potential jump target images', function(target, sources, radius, size){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) // NOTE: data.getImage(..) can return null at start or end // of ribbon, thus we need to account for this... : (this.data.getImage(target) diff --git a/ui (gen4)/features/ui-partial-ribbons-vdom.js b/ui (gen4)/features/ui-partial-ribbons-vdom.js index 57e75ee3..99dbcc13 100755 --- a/ui (gen4)/features/ui-partial-ribbons-vdom.js +++ b/ui (gen4)/features/ui-partial-ribbons-vdom.js @@ -61,8 +61,7 @@ var Ribbons = { restoreTransitions: null, noTransitions: null, noTransitionsDeep: null, - getElemGID: null, - setElemGID: null, + elemGID: null, replaceGid: null, makeShadow: null, @@ -518,7 +517,7 @@ var PartialRibbonsActions = actions.Actions({ updateRibbon: ['- Interface/Update partial ribbon size', function(target, w, size, threshold){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) // NOTE: data.getImage(..) can return null at start or end // of ribbon, thus we need to account for this... : (this.data.getImage(target) diff --git a/ui (gen4)/features/ui-ribbons.js b/ui (gen4)/features/ui-ribbons.js index 4ff18d2f..8dd863c4 100755 --- a/ui (gen4)/features/ui-ribbons.js +++ b/ui (gen4)/features/ui-ribbons.js @@ -32,10 +32,10 @@ function updateImagePosition(actions, target){ target = target || actions.current target = target instanceof jQuery - ? actions.ribbons.getElemGID(target) + ? actions.ribbons.elemGID(target) : target - var source_ribbon = actions.ribbons.getElemGID(actions.ribbons.getRibbon(target)) + var source_ribbon = actions.ribbons.elemGID(actions.ribbons.getRibbon(target)) var source_order = actions.data.getImageOrder(target) return function(){ @@ -106,18 +106,6 @@ actions.Actions({ return this.ribbons ? this.ribbons.viewer : undefined }, - // NOTE: this expects that ribbons will maintain .parent.images... - // NOTE: when getting rid of ribbons need to also remove the .parent - // reference... - // XXX remove... - get ribbons(){ - return this.__ribbons }, - set ribbons(ribbons){ - this.__ribbons = ribbons - ribbons.parent = this - }, - - load: [ function(data){ return function(){ @@ -283,7 +271,7 @@ actions.Actions({ centerImage: ['- Interface/Center an image in ribbon horizontally', function(target, align, offset, scale){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) : target // align current ribbon... @@ -292,7 +280,7 @@ actions.Actions({ centerRibbon: ['- Interface/Center a ribbon vertically', function(target){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) : target // align current ribbon... @@ -323,7 +311,7 @@ actions.Actions({ t = t.eq(direction == 'before' ? 0 : 1) } - t = ribbons.getElemGID(t) + t = ribbons.elemGID(t) this.focusImage(t, r) } @@ -612,7 +600,7 @@ actions.Actions({ updateRibbon: ['- Interface/Update partial ribbon size', function(target, w, size, threshold){ target = target instanceof jQuery - ? this.ribbons.getElemGID(target) + ? this.ribbons.elemGID(target) // NOTE: data.getImage(..) can return null at start or end // of ribbon, thus we need to account for this... : (this.data.getImage(target) diff --git a/ui (gen4)/features/ui-virtual-dom.js b/ui (gen4)/features/ui-virtual-dom.js index 54b7d60d..180a5011 100755 --- a/ui (gen4)/features/ui-virtual-dom.js +++ b/ui (gen4)/features/ui-virtual-dom.js @@ -18,28 +18,6 @@ var core = require('features/core') /*********************************************************************/ - -/*/ XXX -var ViewerClassPrototype = { -} - - -var ViewerPrototype = { - sync: function(){ - }, -} - - -var Viewer = -module.Viewer = -object.makeConstructor('Viewer', - ViewerClassPrototype, - ViewerPrototype) -//*/ - - -//--------------------------------------------------------------------- -// // - take care of DOM construction and update... // - alignment is done via .centerRibbon(..) / .centerImage(..) // - preview updates (XXX) @@ -51,7 +29,7 @@ var VirtualDOMRibbonsClassPrototype = { var VirtualDOMRibbonsPrototype = { // XXX this is a circular ref -- I do not like it... - imagegrid: null, + parent: null, dom: null, vdom: null, @@ -77,23 +55,28 @@ var VirtualDOMRibbonsPrototype = { }, restoreTransitions: function(){ }, - getElemGID: function(){ + elemGID: function(){ }, getImage: function(){ }, + getImageByPosition: function(){ + }, + getRibbon: function(){ + }, getVisibleImageSize: function(){ }, focusImage: function(){ }, px2vmin: function(){ }, + // ... // constructors... makeView: function(state, initial){ state = state || {} var that = this - var ig = this.imagegrid + var ig = this.parent var target = state.target || ig.current @@ -133,7 +116,7 @@ var VirtualDOMRibbonsPrototype = { makeRibbon: function(gid, target, count, state, initial){ state = state || {} var that = this - var ig = this.imagegrid + var ig = this.parent var current = ig.current target = target || state.target || current var size = this.state.tile_size = state.tile_size @@ -201,13 +184,13 @@ var VirtualDOMRibbonsPrototype = { // XXX update image previews... // XXX update image proportions for rotated images... (???) makeImage: function(gid, size){ - var ig = this.imagegrid + var ig = this.parent //size = this.state.tile_size = size size = size || this.state.tile_size || this.getVisibleImageSize('max') - var data = this.imagegrid.data - var images = this.imagegrid.images || {} + var data = this.parent.data + var images = this.parent.images || {} var current = data.current == gid ? '.current' : '' // resolve group preview cover... @@ -253,7 +236,7 @@ var VirtualDOMRibbonsPrototype = { makeImageMarks: function(gid){ var that = this var marks = [] - var tags = this.imagegrid.data.getTags(gid) + var tags = this.parent.data.getTags(gid) // XXX STUB: make this extensible... tags.indexOf('bookmark') >= 0 @@ -312,7 +295,7 @@ var VirtualDOMRibbonsPrototype = { this.sync() } else { - return this.imagegrid.scale + return this.parent.scale } }, @@ -349,7 +332,7 @@ var VirtualDOMRibbonsPrototype = { if(this.vdom == null){ var n = this.vdom = this.makeView(state, true) var v = vdom.create(n) - this.imagegrid.dom.append(v) + this.parent.dom.append(v) this.dom = v // patch state... @@ -375,8 +358,8 @@ var VirtualDOMRibbonsPrototype = { .sync() }, - __init__: function(imagegrid){ - this.imagegrid = imagegrid + __init__: function(parent){ + this.parent = parent || this.parent }, } @@ -388,9 +371,7 @@ object.makeConstructor('VirtualDOMRibbons', - - -/*********************************************************************/ +//--------------------------------------------------------------------- var VirtualDomActions = actions.Actions({ @@ -398,10 +379,8 @@ var VirtualDomActions = actions.Actions({ return this.__dom }, set dom(value){ this.__dom = value}, - get virtualdom(){ - return (this.__virtual_dom = this.__virtual_dom || VirtualDOMRibbons(this)) }, - + // XXX setup .ribbons... load: [ function(data){ return function(){ @@ -411,9 +390,10 @@ var VirtualDomActions = actions.Actions({ if(this.dom == null){ this.dom = viewer + this.ribbons = new VirtualDOMRibbons() } else { - this.virtualdom.clear() + this.ribbons.clear() } this.reload() @@ -421,13 +401,13 @@ var VirtualDomActions = actions.Actions({ }], reload: ['Interface/Reload viewer', function(){ - this.virtualdom.reset() + this.ribbons.reset() this.focusImage() }], // XXX this ignores it's args... refresh: ['Interface/Refresh images without reloading', function(gids, scale){ - this.virtualdom.sync() + this.ribbons.sync() this.focusImage() }], @@ -436,7 +416,7 @@ var VirtualDomActions = actions.Actions({ updateRibbon: ['- Interface/Update partial ribbon size', function(target, w, size, threshold){ target = target instanceof jQuery - ? this.virtualdom.getElemGID(target) + ? this.ribbons.elemGID(target) // NOTE: data.getImage(..) can return null at start or end // of ribbon, thus we need to account for this... : (this.data.getImage(target) @@ -452,7 +432,7 @@ var VirtualDomActions = actions.Actions({ // XXX for some reason this does not set the .current class // on the right image... - this.virtualdom.sync(target, size) + this.ribbons.sync(target, size) // XXX HACK: this fixes a bug in virtual-dom where .current // is not synced correctly... @@ -460,7 +440,7 @@ var VirtualDomActions = actions.Actions({ // manually, dom gets diffed and no change is detected // then the object gets recycled and the .current class // ends up on a different element... - this.virtualdom.focusImage(target) + this.ribbons.focusImage(target) this.centerViewer(target) }], @@ -481,14 +461,14 @@ module.VirtualDom = core.ImageGridFeatures.Feature({ handlers: [ ['clear', - function(){ this.virtualdom.clear() }], + function(){ this.ribbons.clear() }], ['fitImage toggleSingleImage', - function(){ delete this.virtualdom.state.tile_size }], + function(){ delete this.ribbons.state.tile_size }], // XXX account for fast navigation... ['focusImage.pre', function(target){ - var img = this.virtualdom.getImage(target) + var img = this.ribbons.getImage(target) // in-place update... if(img.length > 0){ @@ -497,7 +477,7 @@ module.VirtualDom = core.ImageGridFeatures.Feature({ if(!this.__partial_ribbon_update){ this.__partial_ribbon_update = setTimeout((function(){ delete this.__partial_ribbon_update - this.virtualdom.preventTransitions() + this.ribbons.preventTransitions() this .updateRibbon(this.current) @@ -506,7 +486,7 @@ module.VirtualDom = core.ImageGridFeatures.Feature({ // thus missing the base call... .alignRibbons(null, null, true) - this.virtualdom.restoreTransitions() + this.ribbons.restoreTransitions() }).bind(this), 150) } @@ -526,7 +506,7 @@ module.VirtualDom = core.ImageGridFeatures.Feature({ 'toggleMark', 'toggleBookmark', //], function(){ this.updateRibbon() }], - ], function(){ this.virtualdom.sync() }], + ], function(){ this.ribbons.sync() }], ], }) diff --git a/ui (gen4)/features/ui-widgets.js b/ui (gen4)/features/ui-widgets.js index 3af79913..c27a34c8 100755 --- a/ui (gen4)/features/ui-widgets.js +++ b/ui (gen4)/features/ui-widgets.js @@ -1396,7 +1396,7 @@ module.ContextActionMenu = core.ImageGridFeatures.Feature({ event.preventDefault() event.stopPropagation() - var g = gid || that.ribbons.getElemGID(img) + var g = gid || that.ribbons.elemGID(img) that .focusImage(g) @@ -1867,7 +1867,7 @@ var WidgetTestActions = actions.Actions({ if(cur && next && cur.birthtime.getMonth() != next.birthtime.getMonth()){ this.ribbons.getImageMarks(gid).filter('.partition').remove() this.ribbons.getImage(gid) - .after(this.ribbons.setElemGID($('