Gallery improvements: now loops and image count fixed.
This commit is contained in:
parent
1ffb8da5b7
commit
5c41014b1a
@ -10509,7 +10509,7 @@
|
|||||||
nodes.current.parentElement.scrollTop = 0;
|
nodes.current.parentElement.scrollTop = 0;
|
||||||
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
|
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
|
||||||
d.body.style.overflow = 'hidden';
|
d.body.style.overflow = 'hidden';
|
||||||
return nodes.total.textContent = --i;
|
return nodes.total.textContent = i;
|
||||||
},
|
},
|
||||||
generateThumb: function(file) {
|
generateThumb: function(file) {
|
||||||
var post, thumb, thumbImg, title;
|
var post, thumb, thumbImg, title;
|
||||||
@ -10564,7 +10564,7 @@
|
|||||||
return cb();
|
return cb();
|
||||||
},
|
},
|
||||||
open: function(e) {
|
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) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@ -10595,25 +10595,21 @@
|
|||||||
nodes.current = file;
|
nodes.current = file;
|
||||||
nodes.frame.scrollTop = 0;
|
nodes.frame.scrollTop = 0;
|
||||||
nodes.next.focus();
|
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();
|
rect = this.getBoundingClientRect();
|
||||||
top = rect.top;
|
top = rect.top;
|
||||||
if (top > 0) {
|
if (top > 0) {
|
||||||
top += rect.height - doc.clientHeight;
|
top += rect.height - doc.clientHeight;
|
||||||
}
|
if (top < 0) {
|
||||||
if (top > 0) {
|
return;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
return $.on(file, 'error', function() {
|
return nodes.thumbs.scrollTop += top;
|
||||||
return Gallery.cb.error(file, thumb);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
image: function(e) {
|
image: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -10667,10 +10663,10 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
prev: function() {
|
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() {
|
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() {
|
toggle: function() {
|
||||||
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
|
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
|
||||||
|
|||||||
@ -9028,7 +9028,7 @@
|
|||||||
},
|
},
|
||||||
handleUrl: function() {
|
handleUrl: function() {
|
||||||
var url, xhr;
|
var url, xhr;
|
||||||
url = prompt("Insert an url:");
|
url = prompt("Enter a URL:");
|
||||||
if (url === null) {
|
if (url === null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -10540,7 +10540,7 @@
|
|||||||
nodes.current.parentElement.scrollTop = 0;
|
nodes.current.parentElement.scrollTop = 0;
|
||||||
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
|
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", nodes.thumbs) : Gallery.images[0]);
|
||||||
d.body.style.overflow = 'hidden';
|
d.body.style.overflow = 'hidden';
|
||||||
return nodes.total.textContent = --i;
|
return nodes.total.textContent = i;
|
||||||
},
|
},
|
||||||
generateThumb: function(file) {
|
generateThumb: function(file) {
|
||||||
var post, thumb, thumbImg, title;
|
var post, thumb, thumbImg, title;
|
||||||
@ -10595,7 +10595,7 @@
|
|||||||
return cb();
|
return cb();
|
||||||
},
|
},
|
||||||
open: function(e) {
|
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) {
|
if (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
@ -10626,25 +10626,21 @@
|
|||||||
nodes.current = file;
|
nodes.current = file;
|
||||||
nodes.frame.scrollTop = 0;
|
nodes.frame.scrollTop = 0;
|
||||||
nodes.next.focus();
|
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();
|
rect = this.getBoundingClientRect();
|
||||||
top = rect.top;
|
top = rect.top;
|
||||||
if (top > 0) {
|
if (top > 0) {
|
||||||
top += rect.height - doc.clientHeight;
|
top += rect.height - doc.clientHeight;
|
||||||
}
|
if (top < 0) {
|
||||||
if (top > 0) {
|
return;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
} catch (_error) {
|
|
||||||
err = _error;
|
|
||||||
console.log(err);
|
|
||||||
}
|
}
|
||||||
return $.on(file, 'error', function() {
|
return nodes.thumbs.scrollTop += top;
|
||||||
return Gallery.cb.error(file, thumb);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
image: function(e) {
|
image: function(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -10698,10 +10694,10 @@
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
prev: function() {
|
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() {
|
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() {
|
toggle: function() {
|
||||||
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
|
return (Gallery.nodes ? Gallery.cb.close : Gallery.build)();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ Gallery =
|
|||||||
Gallery.images[0]
|
Gallery.images[0]
|
||||||
|
|
||||||
d.body.style.overflow = 'hidden'
|
d.body.style.overflow = 'hidden'
|
||||||
nodes.total.textContent = --i
|
nodes.total.textContent = i
|
||||||
|
|
||||||
generateThumb: (file) ->
|
generateThumb: (file) ->
|
||||||
post = Get.postFromNode file
|
post = Get.postFromNode file
|
||||||
@ -166,24 +166,22 @@ Gallery =
|
|||||||
nodes.current = file
|
nodes.current = file
|
||||||
nodes.frame.scrollTop = 0
|
nodes.frame.scrollTop = 0
|
||||||
nodes.next.focus()
|
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
|
# Scroll
|
||||||
rect = @getBoundingClientRect()
|
rect = @getBoundingClientRect()
|
||||||
{top} = rect
|
{top} = rect
|
||||||
if top > 0
|
if top > 0
|
||||||
top += rect.height - doc.clientHeight
|
top += rect.height - doc.clientHeight
|
||||||
|
return if top < 0
|
||||||
|
|
||||||
nodes.thumbs.scrollTop += top if top > 0
|
nodes.thumbs.scrollTop += top
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
image: (e) ->
|
image: (e) ->
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@ -219,8 +217,14 @@ Gallery =
|
|||||||
if postObj.filedeleted
|
if postObj.filedeleted
|
||||||
post.kill true
|
post.kill true
|
||||||
|
|
||||||
prev: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id - 1]
|
prev: ->
|
||||||
next: -> Gallery.cb.open.call Gallery.images[+Gallery.nodes.current.dataset.id + 1]
|
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)()
|
toggle: -> (if Gallery.nodes then Gallery.cb.close else Gallery.build)()
|
||||||
blank: (e) -> Gallery.cb.close() if e.target is @
|
blank: (e) -> Gallery.cb.close() if e.target is @
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user