move image stuff together
This commit is contained in:
parent
3c12aee02d
commit
8e315e9415
250
4chan_x.js
250
4chan_x.js
@ -610,63 +610,6 @@
|
||||
return $.setValue("hiddenReply/" + g.BOARD + "/", g.hiddenReply);
|
||||
}
|
||||
};
|
||||
imageHover = {
|
||||
init: function() {
|
||||
var img;
|
||||
img = $.el('img', {
|
||||
id: 'iHover'
|
||||
});
|
||||
$.hide(img);
|
||||
d.body.appendChild(img);
|
||||
return g.callbacks.push(imageHover.cb.node);
|
||||
},
|
||||
offset: {
|
||||
x: 45,
|
||||
y: -120
|
||||
},
|
||||
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];
|
||||
_results.push($.bind(thumb, 'mouseover', imageHover.cb.mouseover));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
mouseover: function(e) {
|
||||
var clientX, clientY, img, target;
|
||||
target = e.target, clientX = e.clientX, clientY = e.clientY;
|
||||
img = $('#iHover');
|
||||
img.src = target.parentNode.href;
|
||||
$.show(img);
|
||||
imageHover.winHeight = d.body.clientHeight;
|
||||
imageHover.winWidth = d.body.clientWidth;
|
||||
$.bind(target, 'mousemove', imageHover.cb.mousemove);
|
||||
return $.bind(target, 'mouseout', imageHover.cb.mouseout);
|
||||
},
|
||||
mousemove: function(e) {
|
||||
var bot, clientX, clientY, img, imgHeight, top;
|
||||
clientX = e.clientX, clientY = e.clientY;
|
||||
img = $('#iHover');
|
||||
imgHeight = img.offsetHeight;
|
||||
top = clientY + imageHover.offset.y;
|
||||
bot = top + imgHeight;
|
||||
img.style.top = imageHover.winHeight < imgHeight || top < 0 ? '0px' : bot > imageHover.winHeight ? imageHover.winHeight - imgHeight + 'px' : top + 'px';
|
||||
return img.style.left = clientX + imageHover.offset.x;
|
||||
},
|
||||
mouseout: function(e) {
|
||||
var img, target;
|
||||
target = e.target;
|
||||
img = $('#iHover');
|
||||
$.hide(img);
|
||||
img.src = null;
|
||||
$.unbind(target, 'mousemove', imageHover.cb.mousemove);
|
||||
return $.unbind(target, 'mouseout', imageHover.cb.mouseout);
|
||||
}
|
||||
}
|
||||
};
|
||||
keybinds = {
|
||||
init: function() {
|
||||
$.bind(d, 'keydown', keybinds.cb.keydown);
|
||||
@ -1659,74 +1602,6 @@
|
||||
return d.title = "/" + g.BOARD + "/ - " + tc;
|
||||
}
|
||||
};
|
||||
imgPreloading = {
|
||||
init: function() {
|
||||
return g.callbacks.push(function(root) {
|
||||
var el, parent, thumb, thumbs, _i, _len, _results;
|
||||
thumbs = $$('img[md5]', root);
|
||||
_results = [];
|
||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||
thumb = thumbs[_i];
|
||||
parent = thumb.parentNode;
|
||||
_results.push(el = $.el('img', {
|
||||
src: parent.href
|
||||
}));
|
||||
}
|
||||
return _results;
|
||||
});
|
||||
}
|
||||
};
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
quickReport = {
|
||||
init: function() {
|
||||
return g.callbacks.push(quickReport.cb.node);
|
||||
@ -1894,6 +1769,131 @@
|
||||
return $('#recaptcha_challenge_field', dialog).value = target.value;
|
||||
}
|
||||
};
|
||||
imageHover = {
|
||||
init: function() {
|
||||
var img;
|
||||
img = $.el('img', {
|
||||
id: 'iHover'
|
||||
});
|
||||
$.hide(img);
|
||||
d.body.appendChild(img);
|
||||
return g.callbacks.push(imageHover.cb.node);
|
||||
},
|
||||
offset: {
|
||||
x: 45,
|
||||
y: -120
|
||||
},
|
||||
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];
|
||||
_results.push($.bind(thumb, 'mouseover', imageHover.cb.mouseover));
|
||||
}
|
||||
return _results;
|
||||
},
|
||||
mouseover: function(e) {
|
||||
var clientX, clientY, img, target;
|
||||
target = e.target, clientX = e.clientX, clientY = e.clientY;
|
||||
img = $('#iHover');
|
||||
img.src = target.parentNode.href;
|
||||
$.show(img);
|
||||
imageHover.winHeight = d.body.clientHeight;
|
||||
imageHover.winWidth = d.body.clientWidth;
|
||||
$.bind(target, 'mousemove', imageHover.cb.mousemove);
|
||||
return $.bind(target, 'mouseout', imageHover.cb.mouseout);
|
||||
},
|
||||
mousemove: function(e) {
|
||||
var bot, clientX, clientY, img, imgHeight, top;
|
||||
clientX = e.clientX, clientY = e.clientY;
|
||||
img = $('#iHover');
|
||||
imgHeight = img.offsetHeight;
|
||||
top = clientY + imageHover.offset.y;
|
||||
bot = top + imgHeight;
|
||||
img.style.top = imageHover.winHeight < imgHeight || top < 0 ? '0px' : bot > imageHover.winHeight ? imageHover.winHeight - imgHeight + 'px' : top + 'px';
|
||||
return img.style.left = clientX + imageHover.offset.x;
|
||||
},
|
||||
mouseout: function(e) {
|
||||
var img, target;
|
||||
target = e.target;
|
||||
img = $('#iHover');
|
||||
$.hide(img);
|
||||
img.src = null;
|
||||
$.unbind(target, 'mousemove', imageHover.cb.mousemove);
|
||||
return $.unbind(target, 'mouseout', imageHover.cb.mouseout);
|
||||
}
|
||||
}
|
||||
};
|
||||
imgPreloading = {
|
||||
init: function() {
|
||||
return g.callbacks.push(function(root) {
|
||||
var el, parent, thumb, thumbs, _i, _len, _results;
|
||||
thumbs = $$('img[md5]', root);
|
||||
_results = [];
|
||||
for (_i = 0, _len = thumbs.length; _i < _len; _i++) {
|
||||
thumb = thumbs[_i];
|
||||
parent = thumb.parentNode;
|
||||
_results.push(el = $.el('img', {
|
||||
src: parent.href
|
||||
}));
|
||||
}
|
||||
return _results;
|
||||
});
|
||||
}
|
||||
};
|
||||
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) {
|
||||
if (e.shiftKey || e.altKey || e.ctrlKey) {
|
||||
return;
|
||||
|
||||
180
script.coffee
180
script.coffee
@ -425,52 +425,6 @@ replyHiding =
|
||||
delete g.hiddenReply[id]
|
||||
$.setValue "hiddenReply/#{g.BOARD}/", g.hiddenReply
|
||||
|
||||
imageHover =
|
||||
init: ->
|
||||
img = $.el 'img', id: 'iHover'
|
||||
$.hide img
|
||||
d.body.appendChild img
|
||||
g.callbacks.push imageHover.cb.node
|
||||
offset:
|
||||
x: 45
|
||||
y: -120
|
||||
cb:
|
||||
node: (root) ->
|
||||
thumbs = $$ 'img[md5]', root
|
||||
for thumb in thumbs
|
||||
$.bind thumb, 'mouseover', imageHover.cb.mouseover
|
||||
mouseover: (e) ->
|
||||
{target, clientX, clientY} = e
|
||||
img = $ '#iHover'
|
||||
img.src = target.parentNode.href
|
||||
$.show img
|
||||
imageHover.winHeight = d.body.clientHeight
|
||||
imageHover.winWidth = d.body.clientWidth
|
||||
$.bind target, 'mousemove', imageHover.cb.mousemove
|
||||
$.bind target, 'mouseout', imageHover.cb.mouseout
|
||||
mousemove: (e) ->
|
||||
{clientX, clientY} = e
|
||||
img = $ '#iHover'
|
||||
imgHeight = img.offsetHeight
|
||||
|
||||
top = clientY + imageHover.offset.y
|
||||
bot = top + imgHeight
|
||||
img.style.top =
|
||||
if imageHover.winHeight < imgHeight or top < 0
|
||||
'0px'
|
||||
else if bot > imageHover.winHeight
|
||||
imageHover.winHeight - imgHeight + 'px'
|
||||
else
|
||||
top + 'px'
|
||||
img.style.left = clientX + imageHover.offset.x
|
||||
mouseout: (e) ->
|
||||
{target} = e
|
||||
img = $ '#iHover'
|
||||
$.hide img
|
||||
img.src = null
|
||||
$.unbind target, 'mousemove', imageHover.cb.mousemove
|
||||
$.unbind target, 'mouseout', imageHover.cb.mouseout
|
||||
|
||||
keybinds =
|
||||
init: ->
|
||||
$.bind d, 'keydown', keybinds.cb.keydown
|
||||
@ -1299,50 +1253,6 @@ titlePost =
|
||||
tc = $('span.filetitle').textContent or $('blockquote').textContent
|
||||
d.title = "/#{g.BOARD}/ - #{tc}"
|
||||
|
||||
imgPreloading =
|
||||
init: ->
|
||||
g.callbacks.push (root) ->
|
||||
thumbs = $$ 'img[md5]', root
|
||||
for thumb in thumbs
|
||||
parent = thumb.parentNode
|
||||
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
|
||||
|
||||
quickReport =
|
||||
init: ->
|
||||
g.callbacks.push quickReport.cb.node
|
||||
@ -1440,6 +1350,96 @@ nodeInserted = (e) ->
|
||||
$('#recaptcha_image img', dialog).src = "http://www.google.com/recaptcha/api/image?c=" + target.value
|
||||
$('#recaptcha_challenge_field', dialog).value = target.value
|
||||
|
||||
imageHover =
|
||||
init: ->
|
||||
img = $.el 'img', id: 'iHover'
|
||||
$.hide img
|
||||
d.body.appendChild img
|
||||
g.callbacks.push imageHover.cb.node
|
||||
offset:
|
||||
x: 45
|
||||
y: -120
|
||||
cb:
|
||||
node: (root) ->
|
||||
thumbs = $$ 'img[md5]', root
|
||||
for thumb in thumbs
|
||||
$.bind thumb, 'mouseover', imageHover.cb.mouseover
|
||||
mouseover: (e) ->
|
||||
{target, clientX, clientY} = e
|
||||
img = $ '#iHover'
|
||||
img.src = target.parentNode.href
|
||||
$.show img
|
||||
imageHover.winHeight = d.body.clientHeight
|
||||
imageHover.winWidth = d.body.clientWidth
|
||||
$.bind target, 'mousemove', imageHover.cb.mousemove
|
||||
$.bind target, 'mouseout', imageHover.cb.mouseout
|
||||
mousemove: (e) ->
|
||||
{clientX, clientY} = e
|
||||
img = $ '#iHover'
|
||||
imgHeight = img.offsetHeight
|
||||
|
||||
top = clientY + imageHover.offset.y
|
||||
bot = top + imgHeight
|
||||
img.style.top =
|
||||
if imageHover.winHeight < imgHeight or top < 0
|
||||
'0px'
|
||||
else if bot > imageHover.winHeight
|
||||
imageHover.winHeight - imgHeight + 'px'
|
||||
else
|
||||
top + 'px'
|
||||
img.style.left = clientX + imageHover.offset.x
|
||||
mouseout: (e) ->
|
||||
{target} = e
|
||||
img = $ '#iHover'
|
||||
$.hide img
|
||||
img.src = null
|
||||
$.unbind target, 'mousemove', imageHover.cb.mousemove
|
||||
$.unbind target, 'mouseout', imageHover.cb.mouseout
|
||||
|
||||
imgPreloading =
|
||||
init: ->
|
||||
g.callbacks.push (root) ->
|
||||
thumbs = $$ 'img[md5]', root
|
||||
for thumb in thumbs
|
||||
parent = thumb.parentNode
|
||||
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 **************************************************************************
|
||||
|
||||
imageClick = (e) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user