fix not working startup of gallery, as mediaContent has to be an array without gaps from non-media content

This commit is contained in:
Ralf Becker 2015-01-22 09:01:58 +00:00
parent f27d39aeeb
commit fcda7613f1

View File

@ -83,6 +83,7 @@ function expose (widget)
* *
* @param {et2_nextmatch} nm * @param {et2_nextmatch} nm
* @param {Object[]} images * @param {Object[]} images
* @param {number} start_at
* @returns {undefined} * @returns {undefined}
*/ */
var read_from_nextmatch = function(nm, images, start_at) var read_from_nextmatch = function(nm, images, start_at)
@ -106,10 +107,10 @@ function expose (widget)
if(data && data.data && data.data.mime && mime_regex.test(data.data.mime)) if(data && data.data && data.data.mime && mime_regex.test(data.data.mime))
{ {
var media = this.getMedia(data.data); var media = this.getMedia(data.data);
images[i] = jQuery.extend({}, data.data, media[0]); images.push(jQuery.extend({}, data.data, media[0]));
}
} }
} }
};
/** /**
* Set a particular index/image in the gallery instead of just appending * Set a particular index/image in the gallery instead of just appending
@ -148,7 +149,7 @@ function expose (widget)
// //
// list // list
gallery.list[index] = gallery.list[new_index]; gallery.list[index] = gallery.list[new_index];
gallery.list.splice(new_index,1) gallery.list.splice(new_index,1);
// indicators & slides // indicators & slides
var dom_nodes = ['indicators','slides']; var dom_nodes = ['indicators','slides'];
@ -316,21 +317,21 @@ function expose (widget)
// current index and slide as arguments: // current index and slide as arguments:
onslide: function(index, slide) { onslide: function(index, slide) {
// Call our onslide method, and include gallery as an attribute // Call our onslide method, and include gallery as an attribute
self.expose_onslide.apply(self, [this, index,slide]) self.expose_onslide.apply(self, [this, index,slide]);
}, },
// Callback function executed after the slide change transition. // Callback function executed after the slide change transition.
// Is called with the gallery instance as "this" object and the // Is called with the gallery instance as "this" object and the
// current index and slide as arguments: // current index and slide as arguments:
onslideend: function(index, slide) { onslideend: function(index, slide) {
// Call our onslide method, and include gallery as an attribute // Call our onslide method, and include gallery as an attribute
self.expose_onslideend.apply(self, [this, index,slide]) self.expose_onslideend.apply(self, [this, index,slide]);
}, },
//// Callback function executed on slide content load. //// Callback function executed on slide content load.
// Is called with the gallery instance as "this" object and the // Is called with the gallery instance as "this" object and the
// slide index and slide element as arguments: // slide index and slide element as arguments:
onslidecomplete: function(index, slide) { onslidecomplete: function(index, slide) {
// Call our onslide method, and include gallery as an attribute // Call our onslide method, and include gallery as an attribute
self.expose_onslidecomplete.apply(self, [this, index,slide]) self.expose_onslidecomplete.apply(self, [this, index,slide]);
}, },
//// Callback function executed when the Gallery is about to be closed. //// Callback function executed when the Gallery is about to be closed.
// Is called with the gallery instance as "this" object: // Is called with the gallery instance as "this" object:
@ -387,10 +388,18 @@ function expose (widget)
{ {
// Get the row that was clicked, find its index in the list // Get the row that was clicked, find its index in the list
var current_entry = nm.controller.getRowByNode(event.target); var current_entry = nm.controller.getRowByNode(event.target);
current_index = current_entry.idx || 0;
// But before it goes, we'll pull everything we can // But before it goes, we'll pull everything we can
read_from_nextmatch.call(this, nm, mediaContent); read_from_nextmatch.call(this, nm, mediaContent);
// find current_entry in array and set it's array-index
for(var i; i < mediaContent.length; i++)
{
if ('filemanager::'+mediaContent[i].path == current_entry.uid)
{
current_index = i;
break;
}
}
// This will trigger nm to refresh and get just the ones we can handle // This will trigger nm to refresh and get just the ones we can handle
// but it might take a while, so do it later - make sure our current // but it might take a while, so do it later - make sure our current
@ -403,7 +412,7 @@ function expose (widget)
{ {
mediaContent = this.getMedia(_value); mediaContent = this.getMedia(_value);
} }
this.expose_options.index = Math.min(current_index, mediaContent.length-1); this.expose_options.index = current_index;
gallery = blueimp.Gallery(mediaContent, this.expose_options); gallery = blueimp.Gallery(mediaContent, this.expose_options);
}, },
expose_onopen: function (event){}, expose_onopen: function (event){},