Fix Gallery.node

This commit is contained in:
Zixaphir 2013-08-21 07:45:42 -07:00
parent fa44526c54
commit 943ec4d2f4
3 changed files with 38 additions and 35 deletions

View File

@ -8838,10 +8838,12 @@
node: function() {
var _ref;
if (!(Gallery.el && ((_ref = this.file) != null ? _ref.isImage : void 0))) {
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
Gallery.generateThumb($('.file', this.nodes.root));
if (Gallery.el) {
Gallery.generateThumb($('.file', this.nodes.root));
}
if (!Conf['Image Expansion']) {
return $.on(this.file.thumb.parentNode, 'click', Gallery.cb.image);
}
@ -8872,7 +8874,7 @@
$.add(d.body, dialog);
Gallery.thumbs.scrollTop = 0;
Gallery.current.parentElement.scrollTop = 0;
Gallery.cb.open.call(image ? $("[href=" + image.href + "]", Gallery.thumbs) : Gallery.images[0]);
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", Gallery.thumbs) : Gallery.images[0]);
return d.body.style.overflow = 'hidden';
},
generateThumb: function(file) {
@ -8938,20 +8940,19 @@
Gallery.frame.scrollTop = 0;
return Gallery.url.focus();
},
image: function(e) {
e.preventDefault();
e.stopPropagation();
return Gallery.build(this);
},
prev: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.current.dataset.id - 1]);
},
next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.current.dataset.id + 1]);
},
image: function() {
return Gallery.build(this);
},
toggle: function() {
if (Gallery.el) {
return Gallery.cb.close();
}
return Gallery.build();
return (Gallery.el ? Gallery.cb.close : Gallery.build)();
},
close: function() {
$.rm(Gallery.el);

View File

@ -8826,10 +8826,12 @@
node: function() {
var _ref;
if (!(Gallery.el && ((_ref = this.file) != null ? _ref.isImage : void 0))) {
if (!((_ref = this.file) != null ? _ref.isImage : void 0)) {
return;
}
Gallery.generateThumb($('.file', this.nodes.root));
if (Gallery.el) {
Gallery.generateThumb($('.file', this.nodes.root));
}
if (!Conf['Image Expansion']) {
return $.on(this.file.thumb.parentNode, 'click', Gallery.cb.image);
}
@ -8860,7 +8862,7 @@
$.add(d.body, dialog);
Gallery.thumbs.scrollTop = 0;
Gallery.current.parentElement.scrollTop = 0;
Gallery.cb.open.call(image ? $("[href=" + image.href + "]", Gallery.thumbs) : Gallery.images[0]);
Gallery.cb.open.call(image ? $("[href='" + (image.href.replace(/https?:/, '')) + "']", Gallery.thumbs) : Gallery.images[0]);
return d.body.style.overflow = 'hidden';
},
generateThumb: function(file) {
@ -8926,20 +8928,19 @@
Gallery.frame.scrollTop = 0;
return Gallery.url.focus();
},
image: function(e) {
e.preventDefault();
e.stopPropagation();
return Gallery.build(this);
},
prev: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.current.dataset.id - 1]);
},
next: function() {
return Gallery.cb.open.call(Gallery.images[+Gallery.current.dataset.id + 1]);
},
image: function() {
return Gallery.build(this);
},
toggle: function() {
if (Gallery.el) {
return Gallery.cb.close();
}
return Gallery.build();
return (Gallery.el ? Gallery.cb.close : Gallery.build)();
},
close: function() {
$.rm(Gallery.el);

View File

@ -18,8 +18,9 @@ Gallery =
cb: @node
node: ->
return unless Gallery.el and @file?.isImage
Gallery.generateThumb $ '.file', @nodes.root
return unless @file?.isImage
Gallery.generateThumb $ '.file', @nodes.root if Gallery.el
unless Conf['Image Expansion']
$.on @file.thumb.parentNode, 'click', Gallery.cb.image
@ -63,7 +64,7 @@ Gallery =
Gallery.current.parentElement.scrollTop = 0
Gallery.cb.open.call if image
$ "[href=#{image.href}]", Gallery.thumbs
$ "[href='#{image.href.replace /https?:/, ''}']", Gallery.thumbs
else
Gallery.images[0]
@ -88,6 +89,7 @@ Gallery =
cb:
keybinds: (e) ->
return unless key = Keybinds.keyCode e
cb = switch key
when 'Esc', Conf['Open Gallery']
Gallery.cb.close
@ -102,9 +104,8 @@ Gallery =
cb()
open: (e) ->
if e
e.preventDefault()
e.preventDefault() if e
$.rmClass el, 'gal-highlight' if el = $ '.gal-highlight', Gallery.thumbs
$.addClass @, 'gal-highlight'
@ -117,16 +118,16 @@ Gallery =
Gallery.current = img
Gallery.frame.scrollTop = 0
Gallery.url.focus()
prev: ->
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id - 1]
next: ->
Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id + 1]
image: ->
image: (e) ->
e.preventDefault()
e.stopPropagation()
Gallery.build @
toggle: ->
if Gallery.el
return Gallery.cb.close()
Gallery.build()
prev: -> Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id - 1]
next: -> Gallery.cb.open.call Gallery.images[+Gallery.current.dataset.id + 1]
toggle: -> (if Gallery.el then Gallery.cb.close else Gallery.build)()
close: ->
$.rm Gallery.el
delete Gallery.el