diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b797a274..e56944521 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ Sometimes the changelog has notes (not comprehensive) acknowledging people's wor The links to individual versions below are to copies of the script with the update URL removed. If you want automatic updates, install the script from the links on the [main page](https://github.com/ccd0/4chan-x). +## v1.11.0 + +**v1.11.0.0** *(2015-06-14)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.0.0/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.11.0.0/builds/4chan-X-noupdate.crx "Chromium version")] +- Based on v1.10.14.2. +- Gallery now preloads the next image in sequence. +- `Stretch to Fit` option added to gallery. +- Various bug fixes. +- Drop workarounds for old versions of Chromium (< v34). + ### v1.10.14 **v1.10.14.2** *(2015-06-11)* - [[Firefox](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.2/builds/4chan-X-noupdate.user.js "Firefox version")] [[Chromium](https://raw.githubusercontent.com/ccd0/4chan-x/1.10.14.2/builds/4chan-X-noupdate.crx "Chromium version")] diff --git a/builds/4chan-X-beta.crx b/builds/4chan-X-beta.crx index 240eb8bf7..bcdb34611 100644 Binary files a/builds/4chan-X-beta.crx and b/builds/4chan-X-beta.crx differ diff --git a/builds/4chan-X-beta.meta.js b/builds/4chan-X-beta.meta.js index c8e29f53c..344e3f860 100644 --- a/builds/4chan-X-beta.meta.js +++ b/builds/4chan-X-beta.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X beta -// @version 1.10.14.2 +// @version 1.11.0.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X-beta.user.js b/builds/4chan-X-beta.user.js index 6e1b37cd4..ff1d01568 100644 --- a/builds/4chan-X-beta.user.js +++ b/builds/4chan-X-beta.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X beta -// @version 1.10.14.2 +// @version 1.11.0.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -267,6 +267,7 @@ 'Hide Thumbnails': [false], 'Fit Width': [true], 'Fit Height': [true], + 'Stretch to Fit': [false], 'Scroll to Post': [true], 'Slide Delay': [6.0] }, @@ -396,7 +397,7 @@ doc = d.documentElement; g = { - VERSION: '1.10.14.2', + VERSION: '1.11.0.0', NAMESPACE: '4chan X.', boards: {} }; @@ -2365,26 +2366,7 @@ Polyfill = { init: function() { - this.notificationPermission(); - this.toBlob(); - return this.visibility(); - }, - notificationPermission: function() { - if (!window.Notification || 'permission' in Notification || !window.webkitNotifications) { - return; - } - return Object.defineProperty(Notification, 'permission', { - get: function() { - switch (webkitNotifications.checkPermission()) { - case 0: - return 'granted'; - case 1: - return 'default'; - case 2: - return 'denied'; - } - } - }); + return this.toBlob(); }, toBlob: function() { var base1; @@ -2400,26 +2382,6 @@ type: 'image/png' })); }); - }, - visibility: function() { - if ('visibilityState' in d) { - return; - } - Object.defineProperties(HTMLDocument.prototype, { - visibilityState: { - get: function() { - return this.webkitVisibilityState; - } - }, - hidden: { - get: function() { - return this.webkitHidden; - } - } - }); - return $.on(d, 'webkitvisibilitychange', function() { - return $.event('visibilitychange'); - }); } }; @@ -7369,7 +7331,7 @@ event = node.nodeName === 'SELECT' ? 'change' : 'input'; $.on(nodes[name], event, save); } - if (Conf['Remember QR Size']) { + if ((typeof chrome === "undefined" || chrome === null) && Conf['Remember QR Size']) { $.get('QR Size', '', function(item) { return nodes.com.style.cssText = item['QR Size']; }); @@ -9359,29 +9321,43 @@ Gallery.images.push(thumb); return $.add(Gallery.nodes.thumbs, thumb); }, + load: function(thumb, errorCB) { + var elType, ext, file; + ext = thumb.href.match(/\w*$/); + elType = { + 'webm': 'video', + 'pdf': 'iframe' + }[ext] || 'img'; + file = $.el(elType, { + title: thumb.title + }); + $.extend(file.dataset, thumb.dataset); + $.on(file, 'error', errorCB); + file.src = thumb.href; + return file; + }, open: function(thumb) { - var el, elType, file, name, newID, nodes, oldID, post, slideshow; + var el, file, newID, nodes, oldID, post, ref; nodes = Gallery.nodes; - name = nodes.name; oldID = +nodes.current.dataset.id; newID = +thumb.dataset.id; - slideshow = Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0)); - if (el = $('.gal-highlight', nodes.thumbs)) { + if (el = Gallery.images[oldID]) { $.rmClass(el, 'gal-highlight'); } $.addClass(thumb, 'gal-highlight'); - elType = /\.webm$/.test(thumb.href) ? 'video' : /\.pdf$/.test(thumb.href) ? 'iframe' : 'img'; - $[elType === 'iframe' ? 'addClass' : 'rmClass'](doc, 'gal-pdf'); - file = $.el(elType, { - title: name.download = name.textContent = thumb.title - }); - $.extend(file.dataset, thumb.dataset); - $.on(file, 'error', Gallery.error); - file.src = name.href = thumb.href; + nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + if (((ref = Gallery.cache) != null ? ref.dataset.id : void 0) === '' + newID) { + file = Gallery.cache; + $.off(file, 'error', Gallery.cacheError); + $.on(file, 'error', Gallery.error); + } else { + file = Gallery.load(thumb, Gallery.error); + } $.off(nodes.current, 'error', Gallery.error); ImageCommon.pause(nodes.current); $.replace(nodes.current, file); - if (elType === 'video') { + nodes.current = file; + if (file.nodeName === 'VIDEO') { file.loop = true; Volume.setup(file); if (Conf['Autoplay']) { @@ -9391,11 +9367,14 @@ ImageCommon.addControls(file); } } + doc.classList.toggle('gal-pdf', file.nodeName === 'IFRAME'); + Gallery.cb.setHeight(); nodes.count.textContent = +thumb.dataset.id + 1; - nodes.current = file; + nodes.name.download = nodes.name.textContent = thumb.title; + nodes.name.href = thumb.href; nodes.frame.scrollTop = 0; nodes.next.focus(); - if (slideshow) { + if (Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0))) { Gallery.setupTimer(); } else { Gallery.cb.stop(); @@ -9403,7 +9382,7 @@ if (Conf['Scroll to Post'] && (post = g.posts[file.dataset.post])) { Header.scrollTo(post.nodes.root); } - return nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + return Gallery.cache = Gallery.load(Gallery.images[(newID + 1) % Gallery.images.length], Gallery.cacheError); }, error: function() { var ref; @@ -9425,6 +9404,9 @@ }; })(this)); }, + cacheError: function() { + return delete Gallery.cache; + }, cleanupTimer: function() { var current; clearTimeout(Gallery.timeoutID); @@ -9586,6 +9568,11 @@ setFitness: function() { return (this.checked ? $.addClass : $.rmClass)(doc, "gal-" + (this.name.toLowerCase().replace(/\s+/g, '-'))); }, + setHeight: function() { + var current, dim, frame, height, ref, ref1, ref2, width; + ref = Gallery.nodes, current = ref.current, frame = ref.frame; + return current.style.minHeight = Conf['Stretch to Fit'] && (dim = (ref1 = g.posts[current.dataset.post]) != null ? ref1.file.dimensions : void 0) ? ((ref2 = dim.split('x'), width = ref2[0], height = ref2[1], ref2), Math.min(doc.clientHeight - 25, height / width * frame.clientWidth) + 'px') : null; + }, setDelay: function() { return Gallery.delay = +this.value; } @@ -9610,11 +9597,14 @@ var input, label; label = UI.checkbox(name, name); input = label.firstElementChild; - if (name === 'Fit Width' || name === 'Fit Height' || name === 'Hide Thumbnails') { + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height') { $.on(input, 'change', Gallery.cb.setFitness); } $.event('change', null, input); $.on(input, 'change', $.cb.checked); + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height' || name === 'Stretch to Fit') { + $.on(input, 'change', Gallery.cb.setHeight); + } return { el: label }; @@ -9623,7 +9613,7 @@ var delayInput, delayLabel, item, subEntries; subEntries = (function() { var k, len1, ref, results; - ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Scroll to Post']; + ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit', 'Scroll to Post']; results = []; for (k = 0, len1 = ref.length; k < len1; k++) { item = ref[k]; @@ -10798,6 +10788,9 @@ }, wheel: function(e) { var el, volume; + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { + return; + } if (!(el = $('video:not([data-md5])', this))) { return; } @@ -15769,6 +15762,9 @@ div = $.el('div', { innerHTML: ": " + E(description) + "" }); + if ((typeof chrome !== "undefined" && chrome !== null) && key === 'Remember QR Size') { + div.hidden = true; + } input = $('input', div); $.on(input, 'change', function() { this.parentNode.parentNode.dataset.checked = this.checked; @@ -19074,13 +19070,6 @@ "}\n" + ".gal-fit-height .gal-image img,\n" + ".gal-fit-height .gal-image video {\n" + -" /*\n" + -" Chrome doesn't support viewpoint units in calc()\n" + -" http://bugs.chromium.org/168840\n" + -" \"It looks like the original author of viewport units in WebKit is not coming back to fix this stuff.\"\n" + -" Well, fuck.\n" + -" */\n" + -" max-height: 95vh;\n" + " max-height: calc(100vh - 25px);\n" + "}\n" + ".gal-image iframe {\n" + diff --git a/builds/4chan-X-noupdate.crx b/builds/4chan-X-noupdate.crx index a2577befc..2599a61f0 100644 Binary files a/builds/4chan-X-noupdate.crx and b/builds/4chan-X-noupdate.crx differ diff --git a/builds/4chan-X-noupdate.user.js b/builds/4chan-X-noupdate.user.js index 904633d40..4c9519bab 100644 --- a/builds/4chan-X-noupdate.user.js +++ b/builds/4chan-X-noupdate.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.10.14.2 +// @version 1.11.0.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -266,6 +266,7 @@ 'Hide Thumbnails': [false], 'Fit Width': [true], 'Fit Height': [true], + 'Stretch to Fit': [false], 'Scroll to Post': [true], 'Slide Delay': [6.0] }, @@ -395,7 +396,7 @@ doc = d.documentElement; g = { - VERSION: '1.10.14.2', + VERSION: '1.11.0.0', NAMESPACE: '4chan X.', boards: {} }; @@ -2364,26 +2365,7 @@ Polyfill = { init: function() { - this.notificationPermission(); - this.toBlob(); - return this.visibility(); - }, - notificationPermission: function() { - if (!window.Notification || 'permission' in Notification || !window.webkitNotifications) { - return; - } - return Object.defineProperty(Notification, 'permission', { - get: function() { - switch (webkitNotifications.checkPermission()) { - case 0: - return 'granted'; - case 1: - return 'default'; - case 2: - return 'denied'; - } - } - }); + return this.toBlob(); }, toBlob: function() { var base1; @@ -2399,26 +2381,6 @@ type: 'image/png' })); }); - }, - visibility: function() { - if ('visibilityState' in d) { - return; - } - Object.defineProperties(HTMLDocument.prototype, { - visibilityState: { - get: function() { - return this.webkitVisibilityState; - } - }, - hidden: { - get: function() { - return this.webkitHidden; - } - } - }); - return $.on(d, 'webkitvisibilitychange', function() { - return $.event('visibilitychange'); - }); } }; @@ -7368,7 +7330,7 @@ event = node.nodeName === 'SELECT' ? 'change' : 'input'; $.on(nodes[name], event, save); } - if (Conf['Remember QR Size']) { + if ((typeof chrome === "undefined" || chrome === null) && Conf['Remember QR Size']) { $.get('QR Size', '', function(item) { return nodes.com.style.cssText = item['QR Size']; }); @@ -9358,29 +9320,43 @@ Gallery.images.push(thumb); return $.add(Gallery.nodes.thumbs, thumb); }, + load: function(thumb, errorCB) { + var elType, ext, file; + ext = thumb.href.match(/\w*$/); + elType = { + 'webm': 'video', + 'pdf': 'iframe' + }[ext] || 'img'; + file = $.el(elType, { + title: thumb.title + }); + $.extend(file.dataset, thumb.dataset); + $.on(file, 'error', errorCB); + file.src = thumb.href; + return file; + }, open: function(thumb) { - var el, elType, file, name, newID, nodes, oldID, post, slideshow; + var el, file, newID, nodes, oldID, post, ref; nodes = Gallery.nodes; - name = nodes.name; oldID = +nodes.current.dataset.id; newID = +thumb.dataset.id; - slideshow = Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0)); - if (el = $('.gal-highlight', nodes.thumbs)) { + if (el = Gallery.images[oldID]) { $.rmClass(el, 'gal-highlight'); } $.addClass(thumb, 'gal-highlight'); - elType = /\.webm$/.test(thumb.href) ? 'video' : /\.pdf$/.test(thumb.href) ? 'iframe' : 'img'; - $[elType === 'iframe' ? 'addClass' : 'rmClass'](doc, 'gal-pdf'); - file = $.el(elType, { - title: name.download = name.textContent = thumb.title - }); - $.extend(file.dataset, thumb.dataset); - $.on(file, 'error', Gallery.error); - file.src = name.href = thumb.href; + nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + if (((ref = Gallery.cache) != null ? ref.dataset.id : void 0) === '' + newID) { + file = Gallery.cache; + $.off(file, 'error', Gallery.cacheError); + $.on(file, 'error', Gallery.error); + } else { + file = Gallery.load(thumb, Gallery.error); + } $.off(nodes.current, 'error', Gallery.error); ImageCommon.pause(nodes.current); $.replace(nodes.current, file); - if (elType === 'video') { + nodes.current = file; + if (file.nodeName === 'VIDEO') { file.loop = true; Volume.setup(file); if (Conf['Autoplay']) { @@ -9390,11 +9366,14 @@ ImageCommon.addControls(file); } } + doc.classList.toggle('gal-pdf', file.nodeName === 'IFRAME'); + Gallery.cb.setHeight(); nodes.count.textContent = +thumb.dataset.id + 1; - nodes.current = file; + nodes.name.download = nodes.name.textContent = thumb.title; + nodes.name.href = thumb.href; nodes.frame.scrollTop = 0; nodes.next.focus(); - if (slideshow) { + if (Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0))) { Gallery.setupTimer(); } else { Gallery.cb.stop(); @@ -9402,7 +9381,7 @@ if (Conf['Scroll to Post'] && (post = g.posts[file.dataset.post])) { Header.scrollTo(post.nodes.root); } - return nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + return Gallery.cache = Gallery.load(Gallery.images[(newID + 1) % Gallery.images.length], Gallery.cacheError); }, error: function() { var ref; @@ -9424,6 +9403,9 @@ }; })(this)); }, + cacheError: function() { + return delete Gallery.cache; + }, cleanupTimer: function() { var current; clearTimeout(Gallery.timeoutID); @@ -9585,6 +9567,11 @@ setFitness: function() { return (this.checked ? $.addClass : $.rmClass)(doc, "gal-" + (this.name.toLowerCase().replace(/\s+/g, '-'))); }, + setHeight: function() { + var current, dim, frame, height, ref, ref1, ref2, width; + ref = Gallery.nodes, current = ref.current, frame = ref.frame; + return current.style.minHeight = Conf['Stretch to Fit'] && (dim = (ref1 = g.posts[current.dataset.post]) != null ? ref1.file.dimensions : void 0) ? ((ref2 = dim.split('x'), width = ref2[0], height = ref2[1], ref2), Math.min(doc.clientHeight - 25, height / width * frame.clientWidth) + 'px') : null; + }, setDelay: function() { return Gallery.delay = +this.value; } @@ -9609,11 +9596,14 @@ var input, label; label = UI.checkbox(name, name); input = label.firstElementChild; - if (name === 'Fit Width' || name === 'Fit Height' || name === 'Hide Thumbnails') { + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height') { $.on(input, 'change', Gallery.cb.setFitness); } $.event('change', null, input); $.on(input, 'change', $.cb.checked); + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height' || name === 'Stretch to Fit') { + $.on(input, 'change', Gallery.cb.setHeight); + } return { el: label }; @@ -9622,7 +9612,7 @@ var delayInput, delayLabel, item, subEntries; subEntries = (function() { var k, len1, ref, results; - ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Scroll to Post']; + ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit', 'Scroll to Post']; results = []; for (k = 0, len1 = ref.length; k < len1; k++) { item = ref[k]; @@ -10797,6 +10787,9 @@ }, wheel: function(e) { var el, volume; + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { + return; + } if (!(el = $('video:not([data-md5])', this))) { return; } @@ -15768,6 +15761,9 @@ div = $.el('div', { innerHTML: ": " + E(description) + "" }); + if ((typeof chrome !== "undefined" && chrome !== null) && key === 'Remember QR Size') { + div.hidden = true; + } input = $('input', div); $.on(input, 'change', function() { this.parentNode.parentNode.dataset.checked = this.checked; @@ -19073,13 +19069,6 @@ "}\n" + ".gal-fit-height .gal-image img,\n" + ".gal-fit-height .gal-image video {\n" + -" /*\n" + -" Chrome doesn't support viewpoint units in calc()\n" + -" http://bugs.chromium.org/168840\n" + -" \"It looks like the original author of viewport units in WebKit is not coming back to fix this stuff.\"\n" + -" Well, fuck.\n" + -" */\n" + -" max-height: 95vh;\n" + " max-height: calc(100vh - 25px);\n" + "}\n" + ".gal-image iframe {\n" + diff --git a/builds/4chan-X.crx b/builds/4chan-X.crx index bf8664b3b..21ae5c0d8 100644 Binary files a/builds/4chan-X.crx and b/builds/4chan-X.crx differ diff --git a/builds/4chan-X.meta.js b/builds/4chan-X.meta.js index 23fde4657..ef171b2ac 100644 --- a/builds/4chan-X.meta.js +++ b/builds/4chan-X.meta.js @@ -1,6 +1,6 @@ // ==UserScript== // @name 4chan X -// @version 1.10.14.2 +// @version 1.11.0.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index eea3b72b7..500a483d2 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -1,7 +1,7 @@ // Generated by CoffeeScript // ==UserScript== // @name 4chan X -// @version 1.10.14.2 +// @version 1.11.0.0 // @minGMVer 1.14 // @minFFVer 26 // @namespace 4chan-X @@ -267,6 +267,7 @@ 'Hide Thumbnails': [false], 'Fit Width': [true], 'Fit Height': [true], + 'Stretch to Fit': [false], 'Scroll to Post': [true], 'Slide Delay': [6.0] }, @@ -396,7 +397,7 @@ doc = d.documentElement; g = { - VERSION: '1.10.14.2', + VERSION: '1.11.0.0', NAMESPACE: '4chan X.', boards: {} }; @@ -2365,26 +2366,7 @@ Polyfill = { init: function() { - this.notificationPermission(); - this.toBlob(); - return this.visibility(); - }, - notificationPermission: function() { - if (!window.Notification || 'permission' in Notification || !window.webkitNotifications) { - return; - } - return Object.defineProperty(Notification, 'permission', { - get: function() { - switch (webkitNotifications.checkPermission()) { - case 0: - return 'granted'; - case 1: - return 'default'; - case 2: - return 'denied'; - } - } - }); + return this.toBlob(); }, toBlob: function() { var base1; @@ -2400,26 +2382,6 @@ type: 'image/png' })); }); - }, - visibility: function() { - if ('visibilityState' in d) { - return; - } - Object.defineProperties(HTMLDocument.prototype, { - visibilityState: { - get: function() { - return this.webkitVisibilityState; - } - }, - hidden: { - get: function() { - return this.webkitHidden; - } - } - }); - return $.on(d, 'webkitvisibilitychange', function() { - return $.event('visibilitychange'); - }); } }; @@ -7369,7 +7331,7 @@ event = node.nodeName === 'SELECT' ? 'change' : 'input'; $.on(nodes[name], event, save); } - if (Conf['Remember QR Size']) { + if ((typeof chrome === "undefined" || chrome === null) && Conf['Remember QR Size']) { $.get('QR Size', '', function(item) { return nodes.com.style.cssText = item['QR Size']; }); @@ -9359,29 +9321,43 @@ Gallery.images.push(thumb); return $.add(Gallery.nodes.thumbs, thumb); }, + load: function(thumb, errorCB) { + var elType, ext, file; + ext = thumb.href.match(/\w*$/); + elType = { + 'webm': 'video', + 'pdf': 'iframe' + }[ext] || 'img'; + file = $.el(elType, { + title: thumb.title + }); + $.extend(file.dataset, thumb.dataset); + $.on(file, 'error', errorCB); + file.src = thumb.href; + return file; + }, open: function(thumb) { - var el, elType, file, name, newID, nodes, oldID, post, slideshow; + var el, file, newID, nodes, oldID, post, ref; nodes = Gallery.nodes; - name = nodes.name; oldID = +nodes.current.dataset.id; newID = +thumb.dataset.id; - slideshow = Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0)); - if (el = $('.gal-highlight', nodes.thumbs)) { + if (el = Gallery.images[oldID]) { $.rmClass(el, 'gal-highlight'); } $.addClass(thumb, 'gal-highlight'); - elType = /\.webm$/.test(thumb.href) ? 'video' : /\.pdf$/.test(thumb.href) ? 'iframe' : 'img'; - $[elType === 'iframe' ? 'addClass' : 'rmClass'](doc, 'gal-pdf'); - file = $.el(elType, { - title: name.download = name.textContent = thumb.title - }); - $.extend(file.dataset, thumb.dataset); - $.on(file, 'error', Gallery.error); - file.src = name.href = thumb.href; + nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + if (((ref = Gallery.cache) != null ? ref.dataset.id : void 0) === '' + newID) { + file = Gallery.cache; + $.off(file, 'error', Gallery.cacheError); + $.on(file, 'error', Gallery.error); + } else { + file = Gallery.load(thumb, Gallery.error); + } $.off(nodes.current, 'error', Gallery.error); ImageCommon.pause(nodes.current); $.replace(nodes.current, file); - if (elType === 'video') { + nodes.current = file; + if (file.nodeName === 'VIDEO') { file.loop = true; Volume.setup(file); if (Conf['Autoplay']) { @@ -9391,11 +9367,14 @@ ImageCommon.addControls(file); } } + doc.classList.toggle('gal-pdf', file.nodeName === 'IFRAME'); + Gallery.cb.setHeight(); nodes.count.textContent = +thumb.dataset.id + 1; - nodes.current = file; + nodes.name.download = nodes.name.textContent = thumb.title; + nodes.name.href = thumb.href; nodes.frame.scrollTop = 0; nodes.next.focus(); - if (slideshow) { + if (Gallery.slideshow && (newID > oldID || (oldID === Gallery.images.length - 1 && newID === 0))) { Gallery.setupTimer(); } else { Gallery.cb.stop(); @@ -9403,7 +9382,7 @@ if (Conf['Scroll to Post'] && (post = g.posts[file.dataset.post])) { Header.scrollTo(post.nodes.root); } - return nodes.thumbs.scrollTop = thumb.offsetTop + thumb.offsetHeight / 2 - nodes.thumbs.clientHeight / 2; + return Gallery.cache = Gallery.load(Gallery.images[(newID + 1) % Gallery.images.length], Gallery.cacheError); }, error: function() { var ref; @@ -9425,6 +9404,9 @@ }; })(this)); }, + cacheError: function() { + return delete Gallery.cache; + }, cleanupTimer: function() { var current; clearTimeout(Gallery.timeoutID); @@ -9586,6 +9568,11 @@ setFitness: function() { return (this.checked ? $.addClass : $.rmClass)(doc, "gal-" + (this.name.toLowerCase().replace(/\s+/g, '-'))); }, + setHeight: function() { + var current, dim, frame, height, ref, ref1, ref2, width; + ref = Gallery.nodes, current = ref.current, frame = ref.frame; + return current.style.minHeight = Conf['Stretch to Fit'] && (dim = (ref1 = g.posts[current.dataset.post]) != null ? ref1.file.dimensions : void 0) ? ((ref2 = dim.split('x'), width = ref2[0], height = ref2[1], ref2), Math.min(doc.clientHeight - 25, height / width * frame.clientWidth) + 'px') : null; + }, setDelay: function() { return Gallery.delay = +this.value; } @@ -9610,11 +9597,14 @@ var input, label; label = UI.checkbox(name, name); input = label.firstElementChild; - if (name === 'Fit Width' || name === 'Fit Height' || name === 'Hide Thumbnails') { + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height') { $.on(input, 'change', Gallery.cb.setFitness); } $.event('change', null, input); $.on(input, 'change', $.cb.checked); + if (name === 'Hide Thumbnails' || name === 'Fit Width' || name === 'Fit Height' || name === 'Stretch to Fit') { + $.on(input, 'change', Gallery.cb.setHeight); + } return { el: label }; @@ -9623,7 +9613,7 @@ var delayInput, delayLabel, item, subEntries; subEntries = (function() { var k, len1, ref, results; - ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Scroll to Post']; + ref = ['Hide Thumbnails', 'Fit Width', 'Fit Height', 'Stretch to Fit', 'Scroll to Post']; results = []; for (k = 0, len1 = ref.length; k < len1; k++) { item = ref[k]; @@ -10798,6 +10788,9 @@ }, wheel: function(e) { var el, volume; + if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) { + return; + } if (!(el = $('video:not([data-md5])', this))) { return; } @@ -15769,6 +15762,9 @@ div = $.el('div', { innerHTML: ": " + E(description) + "" }); + if ((typeof chrome !== "undefined" && chrome !== null) && key === 'Remember QR Size') { + div.hidden = true; + } input = $('input', div); $.on(input, 'change', function() { this.parentNode.parentNode.dataset.checked = this.checked; @@ -19074,13 +19070,6 @@ "}\n" + ".gal-fit-height .gal-image img,\n" + ".gal-fit-height .gal-image video {\n" + -" /*\n" + -" Chrome doesn't support viewpoint units in calc()\n" + -" http://bugs.chromium.org/168840\n" + -" \"It looks like the original author of viewport units in WebKit is not coming back to fix this stuff.\"\n" + -" Well, fuck.\n" + -" */\n" + -" max-height: 95vh;\n" + " max-height: calc(100vh - 25px);\n" + "}\n" + ".gal-image iframe {\n" + diff --git a/builds/4chan-X.zip b/builds/4chan-X.zip index 636478f5f..d3b9837ec 100644 Binary files a/builds/4chan-X.zip and b/builds/4chan-X.zip differ diff --git a/builds/updates-beta.xml b/builds/updates-beta.xml index e4f03564e..78c8c6f3a 100644 --- a/builds/updates-beta.xml +++ b/builds/updates-beta.xml @@ -1,7 +1,7 @@ - + diff --git a/builds/updates.xml b/builds/updates.xml index cbf72fcff..424963579 100644 --- a/builds/updates.xml +++ b/builds/updates.xml @@ -1,7 +1,7 @@ - + diff --git a/package.json b/package.json index f15bb668a..7acbc69d4 100755 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "description": "Cross-browser userscript for maximum lurking on 4chan.", "meta": { "name": "4chan X", - "version": "1.10.14.2", - "date": "2015-06-12T03:09:08.773Z", + "version": "1.11.0.0", + "date": "2015-06-14T08:23:24.605Z", "repo": "https://github.com/ccd0/4chan-x/", "page": "https://github.com/ccd0/4chan-x", "downloads": "https://ccd0.github.io/4chan-x/builds/",