Commit e5073a5e authored by Benjamin Fischer's avatar Benjamin Fischer

GalleryView: added watch support

parent 718604cf
......@@ -86,8 +86,7 @@ define([
// only one path given -> create one item
self.items.push({
title: args.path.split("/").pop(),
src: vispa.dynamicURL("fs/getfile/?path=" + args.path +
"&_workspaceId=" + String(self.workspace.id)),
src: return this.applyDefaultQuery(this.dynamicURL("/fs/getfile?path="+args.path)),
type: args.path.split(".").pop().toLowerCase() == "pdf" ? "iframe" : "img"
});
} else if (args.paths) {
......@@ -95,8 +94,7 @@ define([
$.each(args.paths, function (index, path) {
self.items.push({
title: path.split("/").pop(),
src: vispa.dynamicURL("fs/getfile/?path=" + path +
"&_workspaceId=" + String(self.workspace.id)),
src: return this.applyDefaultQuery(this.dynamicURL("/fs/getfile?path="+path)),
type: path.split(".").pop().toLowerCase() == "pdf" ? "iframe" : "img"
});
});
......@@ -113,6 +111,18 @@ define([
}
// type
self.type = args.type || "img";
this.socket.on("watch", function(data) {
var watch = data.watch_id.split("_", 2);
if (watch[0] == "content") {
if (data.event == "modify") {
self.refresh(parseInt(watch[1]));
}
}
});
this.on("close", function() {
self.POST("/ajax/fs/unwatch", {});
});
},
render: function ($content) {
......@@ -143,7 +153,7 @@ define([
if ($node.length == 0) {
var $node = $("<" + type + ">")
$node.attr({
src: this.items[index].src,
src: this.items[index].src + "&watch_id=content_" + index,
index: index
});
$(".vispa-content", this._dialog.$el).append($node);
......@@ -156,6 +166,13 @@ define([
this.emit("select");
},
refresh: function (index) {
var type = this.items[index].type || this.type;
$(type + "[index=" + index + "]", this._dialog.$el).remove();
if (this.index == index);
this.select(this.index);
},
previous: function () {
if (this.index == 0) {
this.select(this.items.length - 1);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment