From 943ec4d2f44f7c5d5dee9479e54805602c1541e1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Wed, 21 Aug 2013 07:45:42 -0700 Subject: [PATCH] Fix Gallery.node --- builds/appchan-x.user.js | 21 +++++++++++---------- builds/crx/script.js | 21 +++++++++++---------- src/Images/Gallery.coffee | 31 ++++++++++++++++--------------- 3 files changed, 38 insertions(+), 35 deletions(-) diff --git a/builds/appchan-x.user.js b/builds/appchan-x.user.js index ea17b2e79..c38f8afc4 100644 --- a/builds/appchan-x.user.js +++ b/builds/appchan-x.user.js @@ -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); diff --git a/builds/crx/script.js b/builds/crx/script.js index 5ac2c218c..9e85f0fc8 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -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); diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 1490b23e6..4e0a7c9c7 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -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