imgGif, start imgExpand rewrite
This commit is contained in:
parent
38b71787af
commit
a849b3b1a4
100
4chan_x.js
100
4chan_x.js
@ -59,7 +59,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, NAMESPACE, anonymize, autoWatch, callback, config, d, delform, el, expand, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, imgPreloading, keybinds, localize, log, nav, navtopr, nodeInserted, option, options, pathname, qr, quickReport, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, sauce, scroll, temp, threadHiding, titlePost, tzOffset, ui, updateFavicon, updateTitle, updater, watcher, _config, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _ref3, _ref4;
|
var $, $$, NAMESPACE, anonymize, autoWatch, callback, config, d, el, expandComment, expandThread, g, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageTypeChange, imgExpansion, imgGif, imgPreloading, keybinds, localize, log, nav, navtopr, nodeInserted, options, pathname, qr, quickReport, recaptcha, recaptchaListener, recaptchaReload, redirect, replyHiding, sauce, scroll, temp, threadHiding, titlePost, tzOffset, ui, updateFavicon, updateTitle, updater, watcher, _config, _i, _j, _len, _len2, _ref, _ref2, _ref3;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
if (typeof console != "undefined" && console !== null) {
|
if (typeof console != "undefined" && console !== null) {
|
||||||
log = console.log;
|
log = console.log;
|
||||||
@ -1671,6 +1671,57 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
imgGif = {
|
||||||
|
init: function() {
|
||||||
|
return g.callbacks.push(function(root) {
|
||||||
|
var src, thumb, thumbs, _i, _len, _results;
|
||||||
|
thumbs = $$('img[md5]', root);
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||||
|
thumb = thumbs[_i];
|
||||||
|
src = thumb.parentNode.href;
|
||||||
|
_results.push(/gif$/.test(src) ? thumb.src = src : void 0);
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
imgExpansion = {
|
||||||
|
init: function() {
|
||||||
|
var delform, expand, imageType, option, _i, _len, _ref;
|
||||||
|
g.callbacks.push(imgExpansion.cb.node);
|
||||||
|
expand = $.el('div', {
|
||||||
|
innerHTML: "<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit screen</option></select> <label>Expand Images<input type=checkbox id=imageExpand></label>"
|
||||||
|
});
|
||||||
|
imageType = $.getValue('imageType', 'full');
|
||||||
|
_ref = $$('option', expand);
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
option = _ref[_i];
|
||||||
|
if (option.textContent === imageType) {
|
||||||
|
option.selected = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$.bind($('select', expand), 'change', $.cb.value);
|
||||||
|
$.bind($('select', expand), 'change', imageTypeChange);
|
||||||
|
$.bind($('input', expand), 'click', imageExpandClick);
|
||||||
|
delform = $('form[name=delform]');
|
||||||
|
return $.prepend(delform, expand);
|
||||||
|
},
|
||||||
|
cb: {
|
||||||
|
node: function(root) {
|
||||||
|
var thumb, thumbs, _i, _len, _results;
|
||||||
|
thumbs = $$('img[md5]', root);
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||||
|
thumb = thumbs[_i];
|
||||||
|
$.bind(thumb.parentNode, 'click', imageClick);
|
||||||
|
_results.push(g.expand ? imageToggle(thumb.parentNode) : void 0);
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
imageClick = function(e) {
|
imageClick = function(e) {
|
||||||
if (e.shiftKey || e.altKey || e.ctrlKey) {
|
if (e.shiftKey || e.altKey || e.ctrlKey) {
|
||||||
return;
|
return;
|
||||||
@ -2080,47 +2131,10 @@
|
|||||||
$.bind(recaptcha, 'keydown', recaptchaListener);
|
$.bind(recaptcha, 'keydown', recaptchaListener);
|
||||||
$.bind($('form[name=post]'), 'submit', qr.cb.submit);
|
$.bind($('form[name=post]'), 'submit', qr.cb.submit);
|
||||||
if ($.config('Image Expansion')) {
|
if ($.config('Image Expansion')) {
|
||||||
delform = $('form[name=delform]');
|
imgExpansion.init();
|
||||||
expand = $.el('div', {
|
|
||||||
innerHTML: "<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit screen</option></select> <label>Expand Images<input type=checkbox id=imageExpand></label>"
|
|
||||||
});
|
|
||||||
imageType = $.getValue('imageType', 'full');
|
|
||||||
_ref3 = $$("option", expand);
|
|
||||||
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
|
|
||||||
option = _ref3[_j];
|
|
||||||
if (option.textContent === imageType) {
|
|
||||||
option.selected = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$.bind($('select', expand), 'change', $.cb.value);
|
|
||||||
$.bind($('select', expand), 'change', imageTypeChange);
|
|
||||||
$.bind($('input', expand), 'click', imageExpandClick);
|
|
||||||
$.before(delform.firstChild, expand);
|
|
||||||
g.callbacks.push(function(root) {
|
|
||||||
var thumb, thumbs, _i, _len, _results;
|
|
||||||
thumbs = $$('img[md5]', root);
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
|
||||||
thumb = thumbs[_i];
|
|
||||||
$.bind(thumb.parentNode, 'click', imageClick);
|
|
||||||
_results.push(g.expand ? imageToggle(thumb.parentNode) : void 0);
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if ($.config('Image Auto-Gif')) {
|
if ($.config('Image Auto-Gif')) {
|
||||||
g.callbacks.push(function(root) {
|
imgGif.init();
|
||||||
var src, thumb, thumbs, _i, _len, _results;
|
|
||||||
thumbs = $$('img[md5]', root);
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
|
||||||
thumb = thumbs[_i];
|
|
||||||
src = thumb.parentNode.href;
|
|
||||||
_results.push(/gif$/.test(src) ? thumb.src = src : void 0);
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if ($.config('Localize Time')) {
|
if ($.config('Localize Time')) {
|
||||||
localize.init();
|
localize.init();
|
||||||
@ -2188,9 +2202,9 @@
|
|||||||
expandComment.init();
|
expandComment.init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ref4 = g.callbacks;
|
_ref3 = g.callbacks;
|
||||||
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
|
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
|
||||||
callback = _ref4[_k];
|
callback = _ref3[_j];
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
$.bind(d.body, 'DOMNodeInserted', nodeInserted);
|
$.bind(d.body, 'DOMNodeInserted', nodeInserted);
|
||||||
|
|||||||
@ -1303,6 +1303,42 @@ imgPreloading =
|
|||||||
parent = thumb.parentNode
|
parent = thumb.parentNode
|
||||||
el = $.el 'img', src: parent.href
|
el = $.el 'img', src: parent.href
|
||||||
|
|
||||||
|
imgGif =
|
||||||
|
init: ->
|
||||||
|
g.callbacks.push (root) ->
|
||||||
|
thumbs = $$ 'img[md5]', root
|
||||||
|
for thumb in thumbs
|
||||||
|
src = thumb.parentNode.href
|
||||||
|
if /gif$/.test src
|
||||||
|
thumb.src = src
|
||||||
|
|
||||||
|
imgExpansion =
|
||||||
|
init: ->
|
||||||
|
g.callbacks.push imgExpansion.cb.node
|
||||||
|
|
||||||
|
expand = $.el 'div',
|
||||||
|
innerHTML:
|
||||||
|
"<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit screen</option></select>
|
||||||
|
<label>Expand Images<input type=checkbox id=imageExpand></label>"
|
||||||
|
imageType = $.getValue 'imageType', 'full'
|
||||||
|
for option in $$ 'option', expand
|
||||||
|
if option.textContent is imageType
|
||||||
|
option.selected = true
|
||||||
|
break
|
||||||
|
$.bind $('select', expand), 'change', $.cb.value
|
||||||
|
$.bind $('select', expand), 'change', imageTypeChange
|
||||||
|
$.bind $('input', expand), 'click', imageExpandClick
|
||||||
|
|
||||||
|
delform = $ 'form[name=delform]'
|
||||||
|
$.prepend delform, expand
|
||||||
|
|
||||||
|
cb:
|
||||||
|
node: (root) ->
|
||||||
|
thumbs = $$ 'img[md5]', root
|
||||||
|
for thumb in thumbs
|
||||||
|
$.bind thumb.parentNode, 'click', imageClick
|
||||||
|
if g.expand then imageToggle thumb.parentNode
|
||||||
|
|
||||||
# TODO rewrite these **************************************************************************
|
# TODO rewrite these **************************************************************************
|
||||||
|
|
||||||
imageClick = (e) ->
|
imageClick = (e) ->
|
||||||
@ -1637,34 +1673,10 @@ $.bind $('form[name=post]'), 'submit', qr.cb.submit
|
|||||||
|
|
||||||
#major features
|
#major features
|
||||||
if $.config 'Image Expansion'
|
if $.config 'Image Expansion'
|
||||||
delform = $ 'form[name=delform]'
|
imgExpansion.init()
|
||||||
expand = $.el 'div',
|
|
||||||
innerHTML:
|
|
||||||
"<select id=imageType name=imageType><option>full</option><option>fit width</option><option>fit screen</option></select>
|
|
||||||
<label>Expand Images<input type=checkbox id=imageExpand></label>"
|
|
||||||
imageType = $.getValue 'imageType', 'full'
|
|
||||||
for option in $$("option", expand)
|
|
||||||
if option.textContent is imageType
|
|
||||||
option.selected = true
|
|
||||||
break
|
|
||||||
$.bind $('select', expand), 'change', $.cb.value
|
|
||||||
$.bind $('select', expand), 'change', imageTypeChange
|
|
||||||
$.bind $('input', expand), 'click', imageExpandClick
|
|
||||||
$.before delform.firstChild, expand
|
|
||||||
|
|
||||||
g.callbacks.push (root) ->
|
|
||||||
thumbs = $$ 'img[md5]', root
|
|
||||||
for thumb in thumbs
|
|
||||||
$.bind thumb.parentNode, 'click', imageClick
|
|
||||||
if g.expand then imageToggle thumb.parentNode
|
|
||||||
|
|
||||||
if $.config 'Image Auto-Gif'
|
if $.config 'Image Auto-Gif'
|
||||||
g.callbacks.push (root) ->
|
imgGif.init()
|
||||||
thumbs = $$ 'img[md5]', root
|
|
||||||
for thumb in thumbs
|
|
||||||
src = thumb.parentNode.href
|
|
||||||
if /gif$/.test src
|
|
||||||
thumb.src = src
|
|
||||||
|
|
||||||
if $.config 'Localize Time'
|
if $.config 'Localize Time'
|
||||||
localize.init()
|
localize.init()
|
||||||
@ -1699,10 +1711,13 @@ if g.REPLY
|
|||||||
|
|
||||||
if $.config 'Image Preloading'
|
if $.config 'Image Preloading'
|
||||||
imgPreloading.init()
|
imgPreloading.init()
|
||||||
|
|
||||||
if $.config('Quick Reply') and $.config 'Persistent QR'
|
if $.config('Quick Reply') and $.config 'Persistent QR'
|
||||||
qr.persist()
|
qr.persist()
|
||||||
|
|
||||||
if $.config 'Post in Title'
|
if $.config 'Post in Title'
|
||||||
titlePost.init()
|
titlePost.init()
|
||||||
|
|
||||||
if $.config 'Unread Count'
|
if $.config 'Unread Count'
|
||||||
g.replies = []
|
g.replies = []
|
||||||
d.title = '(0) ' + d.title
|
d.title = '(0) ' + d.title
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user