some tweaking and minor changes and fixes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-11-15 03:17:21 +03:00
parent 0a77873455
commit e3dd16a6ff
4 changed files with 49 additions and 25 deletions

View File

@ -237,6 +237,7 @@ button:hover {
/********************************************************** Ribbon ***/ /********************************************************** Ribbon ***/
/* XXX for some reason setting image size in vmin stops this from /* XXX for some reason setting image size in vmin stops this from
stretching in width... */ stretching in width... */
.shadow,
.ribbon { .ribbon {
position: relative; position: relative;
display: block; display: block;
@ -290,11 +291,13 @@ stretching in width... */
border: solid 5px red; border: solid 5px red;
} }
*/ */
/* NOTE: this is essentially a ribbon... */
.shadow { .shadow {
position: absolute; position: absolute;
overflow: visible; overflow: visible;
width: auto; width: auto;
height: auto; height: auto;
margin: 0px;
background: black; background: black;
-webkit-transition: all 0.1s ease-in; -webkit-transition: all 0.1s ease-in;
-moz-transition: all 0.1s ease-in; -moz-transition: all 0.1s ease-in;

View File

@ -361,6 +361,7 @@ button:hover {
/********************************************************** Ribbon ***/ /********************************************************** Ribbon ***/
/* XXX for some reason setting image size in vmin stops this from /* XXX for some reason setting image size in vmin stops this from
stretching in width... */ stretching in width... */
.shadow,
.ribbon { .ribbon {
position: relative; position: relative;
display: block; display: block;

View File

@ -66,6 +66,12 @@ module.RibbonsClassPrototype = {
getElemGID: function(elem){ getElemGID: function(elem){
return JSON.parse('"' + elem.attr('gid') + '"') return JSON.parse('"' + elem.attr('gid') + '"')
}, },
setElemGID: function(elem, gid){
return $(elem)
.attr('gid', JSON.stringify(gid)
// this removes the extra quots...
.replace(/^"(.*)"$/g, '$1'))
},
// DOM Constructors... // DOM Constructors...
// NOTE: these will return unattached objects... // NOTE: these will return unattached objects...
@ -78,34 +84,27 @@ module.RibbonsClassPrototype = {
// XXX NOTE: quots removal might render this incompatible with older data formats... // XXX NOTE: quots removal might render this incompatible with older data formats...
createRibbon: function(gids){ createRibbon: function(gids){
gids = gids.constructor !== Array ? [gids] : gids gids = gids.constructor !== Array ? [gids] : gids
var that = this
return $(gids.map(function(gid){ return $(gids.map(function(gid){
gid = gid != null ? gid+'' : gid gid = gid != null ? gid+'' : gid
return $('<div>') return that.setElemGID($('<div>')
.addClass('ribbon') .addClass('ribbon'), gid)[0]
.attr('gid', JSON.stringify(gid)
// this removes the extra quots...
.replace(/^"(.*)"$/g, '$1'))[0]
})) }))
}, },
// XXX NOTE: quots removal might render this incompatible with older data formats... // XXX NOTE: quots removal might render this incompatible with older data formats...
createImage: function(gids){ createImage: function(gids){
gids = gids.constructor !== Array ? [gids] : gids gids = gids.constructor !== Array ? [gids] : gids
var that = this
return $(gids.map(function(gid){ return $(gids.map(function(gid){
gid = gid != null ? gid+'' : gid gid = gid != null ? gid+'' : gid
return $('<div>') return that.setElemGID($('<div>')
.addClass('image') .addClass('image'), gid)[0]
.attr('gid', JSON.stringify(gid)
// this removes the extra quots...
.replace(/^"(.*)"$/g, '$1'))[0]
})) }))
}, },
createMark: function(cls, gid){ createMark: function(cls, gid){
gid = gid != null ? gid+'' : gid gid = gid != null ? gid+'' : gid
return $('<div class="mark">') return this.setElemGID($('<div class="mark">')
.addClass(cls) .addClass(cls), gid)
.attr('gid', JSON.stringify(gid)
// this removes the extra quots...
.replace(/^"(.*)"$/g, '$1'))
}, },
} }
@ -128,6 +127,7 @@ module.RibbonsPrototype = {
// Generic getters... // Generic getters...
getElemGID: RibbonsClassPrototype.getElemGID, getElemGID: RibbonsClassPrototype.getElemGID,
setElemGID: RibbonsClassPrototype.setElemGID,
// Helpers... // Helpers...
@ -435,7 +435,7 @@ module.RibbonsPrototype = {
// ...we need to scale it to the current scale... // ...we need to scale it to the current scale...
var shadow = setElementScale( var shadow = setElementScale(
$('<div>') $('<div>')
.addClass('shadow ribbon') .addClass('shadow')
.attr({ .attr({
gid: gid, gid: gid,
ticket: ticket, ticket: ticket,
@ -1051,7 +1051,6 @@ module.RibbonsPrototype = {
} }
var loaded = r.find('.image') var loaded = r.find('.image')
var unload = $()
// compensate for new/removed images... // compensate for new/removed images...
if(reference != null){ if(reference != null){
@ -1073,16 +1072,18 @@ module.RibbonsPrototype = {
} }
// remove all images that we do not need... // remove all images that we do not need...
var unloaded = $()
loaded = loaded loaded = loaded
.filter(function(i, img){ .filter(function(i, img){
if(gids.indexOf(that.getElemGID($(img))) >= 0){ if(gids.indexOf(that.getElemGID($(img))) >= 0){
return true return true
} }
unload.push(img) unloaded.push(img)
return false return false
}) })
// remove everything in one go... // remove everything in one go...
unload.remove() unloaded.detach()
unloaded = unloaded.toArray()
$(gids).each(function(i, gid){ $(gids).each(function(i, gid){
// support for sparse ribbons... // support for sparse ribbons...
@ -1090,9 +1091,16 @@ module.RibbonsPrototype = {
return return
} }
// get/create image... // get/create image...
// XXX this may affect other ribbons... // NOTE: as this will get a loaded image if it's loaded in
// a different ribbon this WILL affect that ribbon...
var img = that.getImage(gid) var img = that.getImage(gid)
img = img.length == 0 ? that.createImage(gid) : img if(img.length == 0){
img = unloaded.length > 0
// reuse an image we just detached...
? that.setElemGID(unloaded.pop(), gid)
// create a new image...
: that.createImage(gid)
}
// see of we are loaded in the right position... // see of we are loaded in the right position...
var g = loaded.length > i ? that.getElemGID(loaded.eq(i)) : null var g = loaded.length > i ? that.getElemGID(loaded.eq(i)) : null

View File

@ -126,7 +126,7 @@ actions.Actions({
// NOTE: the setters in the following use the appropriate actions // NOTE: the setters in the following use the appropriate actions
// so to avoid recursion do not use these in the specific // so to avoid recursion do not use these in the specific
// actions... // actions...
// Base ribbon... // Base ribbon...
get base(){ get base(){
return this.data == null ? null : this.data.base return this.data == null ? null : this.data.base
@ -520,6 +520,19 @@ var Viewer =
module.Viewer = module.Viewer =
actions.Actions(Client, { actions.Actions(Client, {
// Images...
/*
get images(){
return this.ribbons != null ? this.ribbons.images : null
},
// NOTE: if ribbons are null this will have no effect...
set images(value){
if(this.ribbons != null){
this.ribbons.images = value
}
},
*/
get screenwidth(){ get screenwidth(){
return this.ribbons != null ? this.ribbons.getScreenWidthImages() : null return this.ribbons != null ? this.ribbons.getScreenWidthImages() : null
}, },
@ -580,11 +593,10 @@ actions.Actions(Client, {
: viewer : viewer
if(this.ribbons == null){ if(this.ribbons == null){
this.ribbons = ribbons.Ribbons(viewer, data.images) this.ribbons = ribbons.Ribbons(viewer, this.images)
} else { } else {
this.ribbons.clear() this.ribbons.clear()
// XXX
this.ribbons.images = this.images this.ribbons.images = this.images
} }
@ -667,7 +679,7 @@ actions.Actions(Client, {
that.centerImage(t, 'after') that.centerImage(t, 'after')
} }
} }
//}, 0) //}, 10)
}], }],
// XXX these should also affect up/down navigation... // XXX these should also affect up/down navigation...
// ...navigate by proximity (closest to center) rather than by // ...navigate by proximity (closest to center) rather than by