Gallery improvements: now loops and image count fixed.

This commit is contained in:
Zixaphir 2014-07-17 23:42:18 -07:00
parent 1ffb8da5b7
commit 5c41014b1a
3 changed files with 45 additions and 49 deletions

View File

@ -10509,7 +10509,7 @@
nodes.current.parentElement.scrollTop = 0;
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
d.body.style.overflow = 'hidden';
return nodes.total.textContent = --i;
return nodes.total.textContent = i;
},
generateThumb: function(file) {
var post, thumb, thumbImg, title;
@ -10564,7 +10564,7 @@
return cb();
},
open: function(e) {
var el, elType, err, file, name, nodes, post, rect, top, _base, _ref;
var el, elType, file, name, nodes, post, rect, top, _base, _ref;
if (e) {
e.preventDefault();
}
@ -10595,25 +10595,21 @@
nodes.current = file;
nodes.frame.scrollTop = 0;
nodes.next.focus();
if (Conf['Scroll to Post'] && (post = (_ref = (post = g.posts[file.dataset.post])) != null ? _ref.nodes.root : void 0)) {
Header.scrollTo(post);
}
$.on(file, 'error', function() {
return Gallery.cb.error(file, thumb);
});
rect = this.getBoundingClientRect();
top = rect.top;
if (top > 0) {
top += rect.height - doc.clientHeight;
}
if (top > 0) {
nodes.thumbs.scrollTop += top;
}
try {
if (Conf['Scroll to Post'] && (post = (_ref = (post = g.posts[file.dataset.post])) != null ? _ref.nodes.root : void 0)) {
Header.scrollTo(post);
if (top < 0) {
return;
}
} catch (_error) {
err = _error;
console.log(err);
}
return $.on(file, 'error', function() {
return Gallery.cb.error(file, thumb);
});
return nodes.thumbs.scrollTop += top;
},
image: function(e) {
e.preventDefault();
@ -10667,10 +10663,10 @@
});
},
prev: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id - 1]);
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id - 1] || Gallery.images[Gallery.images.length - 1]);
},
next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1]);
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]);
},
toggle: function() {
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();

View File

@ -9028,7 +9028,7 @@
},
handleUrl: function() {
var url, xhr;
url = prompt("Insert an url:");
url = prompt("Enter a URL:");
if (url === null) {
return;
}
@ -10540,7 +10540,7 @@
nodes.current.parentElement.scrollTop = 0;
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
d.body.style.overflow = 'hidden';
return nodes.total.textContent = --i;
return nodes.total.textContent = i;
},
generateThumb: function(file) {
var post, thumb, thumbImg, title;
@ -10595,7 +10595,7 @@
return cb();
},
open: function(e) {
var el, elType, err, file, name, nodes, post, rect, top, _base, _ref;
var el, elType, file, name, nodes, post, rect, top, _base, _ref;
if (e) {
e.preventDefault();
}
@ -10626,25 +10626,21 @@
nodes.current = file;
nodes.frame.scrollTop = 0;
nodes.next.focus();
if (Conf['Scroll to Post'] && (post = (_ref = (post = g.posts[file.dataset.post])) != null ? _ref.nodes.root : void 0)) {
Header.scrollTo(post);
}
$.on(file, 'error', function() {
return Gallery.cb.error(file, thumb);
});
rect = this.getBoundingClientRect();
top = rect.top;
if (top > 0) {
top += rect.height - doc.clientHeight;
}
if (top > 0) {
nodes.thumbs.scrollTop += top;
}
try {
if (Conf['Scroll to Post'] && (post = (_ref = (post = g.posts[file.dataset.post])) != null ? _ref.nodes.root : void 0)) {
Header.scrollTo(post);
if (top < 0) {
return;
}
} catch (_error) {
err = _error;
console.log(err);
}
return $.on(file, 'error', function() {
return Gallery.cb.error(file, thumb);
});
return nodes.thumbs.scrollTop += top;
},
image: function(e) {
e.preventDefault();
@ -10698,10 +10694,10 @@
});
},
prev: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id - 1]);
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id - 1] || Gallery.images[Gallery.images.length - 1]);
},
next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1]);
return Gallery.cb.open.call(Gallery.images[+Gallery.nodes.current.dataset.id + 1] || Gallery.images[0]);
},
toggle: function() {
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();

View File

@ -96,7 +96,7 @@ Gallery =
Gallery.images[0]
d.body.style.overflow = 'hidden'
nodes.total.textContent = --i
nodes.total.textContent = i
generateThumb: (file) ->
post = Get.postFromNode file
@ -166,24 +166,22 @@ Gallery =
nodes.current = file
nodes.frame.scrollTop = 0
nodes.next.focus()
# Scroll to post
if Conf['Scroll to Post'] and post = (post = g.posts[file.dataset.post])?.nodes.root
Header.scrollTo post
$.on file, 'error', ->
Gallery.cb.error file, thumb
# Scroll
rect = @getBoundingClientRect()
{top} = rect
if top > 0
top += rect.height - doc.clientHeight
return if top < 0
nodes.thumbs.scrollTop += top if top > 0
# Scroll to post
try
if Conf['Scroll to Post'] and post = (post = g.posts[file.dataset.post])?.nodes.root
Header.scrollTo post
catch err
console.log err
$.on file, 'error', ->
Gallery.cb.error file, thumb
nodes.thumbs.scrollTop += top
image: (e) ->
e.preventDefault()
@ -219,8 +217,14 @@ Gallery =
if postObj.filedeleted
post.kill true
prev: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id - 1]
next: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id + 1]
prev: ->
Gallery.cb.open.call(
Gallery.images[+Gallery.nodes.current.dataset.id - 1] or Gallery.images[Gallery.images.length - 1]
)
next: ->
Gallery.cb.open.call(
Gallery.images[+Gallery.nodes.current.dataset.id + 1] or Gallery.images[0]
)
toggle: -> (if Gallery.nodes then Gallery.cb.close else Gallery.build)()
blank: (e) -> Gallery.cb.close() if e.target is @