mirror of
https://github.com/flynx/ImageGrid.git
synced 2026-01-07 10:51:09 +00:00
minor tweaks to .updateImage(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
13d1b8752c
commit
8875b75208
@ -22,7 +22,7 @@ require('nw.gui').Window.get().showDevTools()
|
|||||||
|
|
||||||
<!-- for viewer structure doc see: ribbons.js... -->
|
<!-- for viewer structure doc see: ribbons.js... -->
|
||||||
|
|
||||||
<div class="viewer gray">
|
<div class="viewer gray marks-visible">
|
||||||
|
|
||||||
<div class="ribbon-set"></div>
|
<div class="ribbon-set"></div>
|
||||||
|
|
||||||
|
|||||||
@ -481,23 +481,39 @@ module.RibbonsPrototype = {
|
|||||||
// .updateImage()
|
// .updateImage()
|
||||||
// -> image
|
// -> image
|
||||||
//
|
//
|
||||||
|
// Update specific image:
|
||||||
|
// .updateImage(gid)
|
||||||
|
// .updateImage(image)
|
||||||
|
// -> image
|
||||||
|
//
|
||||||
// Update all image:
|
// Update all image:
|
||||||
// .updateImage('*')
|
// .updateImage('*')
|
||||||
// -> image
|
// -> image
|
||||||
//
|
//
|
||||||
|
// NOTE: this can update collections of images by passing either a
|
||||||
|
// list of gids, images or a jQuery collection...
|
||||||
|
//
|
||||||
// If this is set to true image previews will be loaded synchronously...
|
// If this is set to true image previews will be loaded synchronously...
|
||||||
load_img_sync: false,
|
load_img_sync: false,
|
||||||
//
|
//
|
||||||
updateImage: function(image, gid, size, sync){
|
updateImage: function(image, gid, size, sync){
|
||||||
image = image == null ? this.getImage()
|
image = (image == '*' ? this.viewer.find('.image')
|
||||||
: image == '*' ? this.viewer.find('.image')
|
: image == null
|
||||||
: $(image)
|
|| typeof(image) == typeof('str') ? this.getImage(image)
|
||||||
|
: $(image))
|
||||||
|
var lst = image.toArray()
|
||||||
sync = sync == null ? this.load_img_sync : sync
|
sync = sync == null ? this.load_img_sync : sync
|
||||||
size = size == null ? this.getVisibleImageSize('max') : size
|
size = size == null ? this.getVisibleImageSize('max') : size
|
||||||
|
|
||||||
var that = this
|
var that = this
|
||||||
return image.each(function(){
|
return $(image.map(function(){
|
||||||
var image = $(this)
|
var image = this instanceof String
|
||||||
|
|| typeof(this) == typeof('str')
|
||||||
|
? that.getImage(this+'')
|
||||||
|
: $(this)
|
||||||
|
if(image.length == 0){
|
||||||
|
return
|
||||||
|
}
|
||||||
var old_gid = that.getElemGID(image)
|
var old_gid = that.getElemGID(image)
|
||||||
|
|
||||||
// same image -- update...
|
// same image -- update...
|
||||||
@ -523,7 +539,7 @@ module.RibbonsPrototype = {
|
|||||||
|
|
||||||
// if not images data defined drop out...
|
// if not images data defined drop out...
|
||||||
if(that.images == null){
|
if(that.images == null){
|
||||||
return
|
return image[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the image data...
|
// get the image data...
|
||||||
@ -564,7 +580,8 @@ module.RibbonsPrototype = {
|
|||||||
// update the preview if it's a new image or...
|
// update the preview if it's a new image or...
|
||||||
// XXX this should be pushed as far back as possible...
|
// XXX this should be pushed as far back as possible...
|
||||||
if(old_gid != gid
|
if(old_gid != gid
|
||||||
// the new preview (purl) is different to current...
|
// the new preview (p_url) is different to current...
|
||||||
|
// NOTE: this may not work correctly for relative urls...
|
||||||
|| image.css('background-image').indexOf(encodeURI(p_url)) < 0){
|
|| image.css('background-image').indexOf(encodeURI(p_url)) < 0){
|
||||||
// sync load...
|
// sync load...
|
||||||
if(sync){
|
if(sync){
|
||||||
@ -593,7 +610,9 @@ module.RibbonsPrototype = {
|
|||||||
|
|
||||||
// marks and other indicators...
|
// marks and other indicators...
|
||||||
that.updateImageIndicators(gid, image)
|
that.updateImageIndicators(gid, image)
|
||||||
})
|
|
||||||
|
return image[0]
|
||||||
|
}))
|
||||||
},
|
},
|
||||||
|
|
||||||
// update a set of images in a ribbon...
|
// update a set of images in a ribbon...
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
*
|
*
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
|
define(function(require){ var module = {}
|
||||||
|
console.log('>>> viewer')
|
||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
|
||||||
@ -14,3 +17,4 @@
|
|||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* vim:set ts=4 sw=4 : */
|
* vim:set ts=4 sw=4 : */
|
||||||
|
return module })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user