This commit is contained in:
James Campos 2011-07-10 21:02:13 -07:00
parent b33e25ac76
commit bdd2a0375f
2 changed files with 149 additions and 158 deletions

View File

@ -1080,19 +1080,19 @@
input = _ref2[_i]; input = _ref2[_i];
$.bind(input, 'click', $.cb.checked); $.bind(input, 'click', $.cb.checked);
} }
$.bind($('input[type=button]', dialog), 'click', options.cb.clearHidden); $.bind($('input[type=button]', dialog), 'click', options.clearHidden);
_ref3 = $$('#floaty a', dialog); _ref3 = $$('#floaty a', dialog);
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
link = _ref3[_j]; link = _ref3[_j];
$.bind(link, 'click', options.tab); $.bind(link, 'click', options.tab);
} }
$.bind($('textarea[name=flavors]', dialog), 'change', $.cb.value); $.bind($('textarea[name=flavors]', dialog), 'change', $.cb.value);
$.bind($('input[name=time]', dialog), 'keyup', options.cb.time); $.bind($('input[name=time]', dialog), 'keyup', options.time);
_ref4 = $$('#keybinds input', dialog); _ref4 = $$('#keybinds input', dialog);
for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) { for (_k = 0, _len3 = _ref4.length; _k < _len3; _k++) {
input = _ref4[_k]; input = _ref4[_k];
input.value = $.getValue("key/" + input.name, config.hotkeys[input.name]); input.value = $.getValue("key/" + input.name, config.hotkeys[input.name]);
$.bind(input, 'keydown', options.cb.keybind); $.bind(input, 'keydown', options.keybind);
} }
/* /*
Two parent divs are necessary to center on all browsers. Two parent divs are necessary to center on all browsers.
@ -1105,7 +1105,7 @@
}); });
$.append(overlay, dialog); $.append(overlay, dialog);
$.append(d.body, overlay); $.append(d.body, overlay);
options.cb.time.call($('input[name=time]', dialog)); options.time.call($('input[name=time]', dialog));
$.bind(overlay, 'click', function() { $.bind(overlay, 'click', function() {
return $.rm(overlay); return $.rm(overlay);
}); });
@ -1123,38 +1123,36 @@
} }
return _results; return _results;
}, },
cb: { clearHidden: function(e) {
clearHidden: function(e) { $.deleteValue("hiddenReplies/" + g.BOARD + "/");
$.deleteValue("hiddenReplies/" + g.BOARD + "/"); $.deleteValue("hiddenThreads/" + g.BOARD + "/");
$.deleteValue("hiddenThreads/" + g.BOARD + "/"); this.value = "hidden: 0";
this.value = "hidden: 0"; return g.hiddenReplies = {};
return g.hiddenReplies = {}; },
}, keybind: function(e) {
keybind: function(e) { var key;
var key; e.preventDefault();
e.preventDefault(); e.stopPropagation();
e.stopPropagation(); key = keybinds.cb.keyCode(e, true);
key = keybinds.cb.keyCode(e, true); if (key != null) {
if (key != null) { if (key) {
if (key) { if (e.altKey) {
if (e.altKey) { key = 'alt+' + key;
key = 'alt+' + key; }
} if (e.ctrlKey) {
if (e.ctrlKey) { key = 'ctrl+' + key;
key = 'ctrl+' + key;
}
} }
this.value = key;
$.setValue("key/" + this.name, key);
return keybinds[this.name] = key;
} }
}, this.value = key;
time: function(e) { $.setValue("key/" + this.name, key);
$.setValue('time', this.value); return keybinds[this.name] = key;
Time.foo();
Time.date = new Date();
return $('#timePreview').textContent = Time.funk(Time);
} }
},
time: function(e) {
$.setValue('time', this.value);
Time.foo();
Time.date = new Date();
return $('#timePreview').textContent = Time.funk(Time);
} }
}; };
cooldown = { cooldown = {
@ -2301,37 +2299,35 @@
init: function() { init: function() {
unread.replies = []; unread.replies = [];
d.title = '(0) ' + d.title; d.title = '(0) ' + d.title;
$.bind(window, 'scroll', unread.cb.scroll); $.bind(window, 'scroll', unread.scroll);
return g.callbacks.push(unread.cb.node); return g.callbacks.push(unread.node);
}, },
cb: { node: function(root) {
node: function(root) { if (root.className) {
if (root.className) { return;
return; }
unread.replies.push(root);
unread.updateTitle();
return Favicon.update();
},
scroll: function(e) {
var bottom, height, i, reply, _len, _ref;
height = d.body.clientHeight;
_ref = unread.replies;
for (i = 0, _len = _ref.length; i < _len; i++) {
reply = _ref[i];
bottom = reply.getBoundingClientRect().bottom;
if (bottom > height) {
break;
} }
unread.replies.push(root); }
unread.updateTitle(); if (i === 0) {
return;
}
unread.replies = unread.replies.slice(i);
unread.updateTitle();
if (unread.replies.length === 0) {
return Favicon.update(); return Favicon.update();
},
scroll: function(e) {
var bottom, height, i, reply, _len, _ref;
height = d.body.clientHeight;
_ref = unread.replies;
for (i = 0, _len = _ref.length; i < _len; i++) {
reply = _ref[i];
bottom = reply.getBoundingClientRect().bottom;
if (bottom > height) {
break;
}
}
if (i === 0) {
return;
}
unread.replies = unread.replies.slice(i);
unread.updateTitle();
if (unread.replies.length === 0) {
return Favicon.update();
}
} }
}, },
updateTitle: function() { updateTitle: function() {
@ -2457,26 +2453,24 @@
}); });
$.hide(img); $.hide(img);
$.append(d.body, img); $.append(d.body, img);
return g.callbacks.push(imageHover.cb.node); return g.callbacks.push(imageHover.node);
}, },
cb: { node: function(root) {
node: function(root) { var thumb;
var thumb; if (!(thumb = $('img[md5]', root))) {
if (!(thumb = $('img[md5]', root))) { return;
return;
}
$.bind(thumb, 'mouseover', imageHover.cb.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend);
},
mouseover: function(e) {
var el;
el = $('#iHover');
el.src = null;
el.src = this.parentNode.href;
ui.el = el;
return $.show(el);
} }
$.bind(thumb, 'mouseover', imageHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend);
},
mouseover: function(e) {
var el;
el = $('#iHover');
el.src = null;
el.src = this.parentNode.href;
ui.el = el;
return $.show(el);
} }
}; };
imgPreloading = { imgPreloading = {
@ -2505,23 +2499,23 @@
}; };
imgExpand = { imgExpand = {
init: function() { init: function() {
g.callbacks.push(imgExpand.cb.node); g.callbacks.push(imgExpand.node);
imgExpand.dialog(); imgExpand.dialog();
$.bind(window, 'resize', imgExpand.resize); $.bind(window, 'resize', imgExpand.resize);
return imgExpand.resize(); return imgExpand.resize();
}, },
node: function(root) {
var a, thumb;
if (!(thumb = $('img[md5]', root))) {
return;
}
a = thumb.parentNode;
$.bind(a, 'click', imgExpand.cb.toggle);
if (imgExpand.on && root.className !== 'inline') {
return imgExpand.toggle(a);
}
},
cb: { cb: {
node: function(root) {
var a, thumb;
if (!(thumb = $('img[md5]', root))) {
return;
}
a = thumb.parentNode;
$.bind(a, 'click', imgExpand.cb.toggle);
if (imgExpand.on && root.className !== 'inline') {
return imgExpand.toggle(a);
}
},
toggle: function(e) { toggle: function(e) {
if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) { if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) {
return; return;

View File

@ -860,13 +860,13 @@ options =
for input in $$ 'input[type=checkbox]', dialog for input in $$ 'input[type=checkbox]', dialog
$.bind input, 'click', $.cb.checked $.bind input, 'click', $.cb.checked
$.bind $('input[type=button]', dialog), 'click', options.cb.clearHidden $.bind $('input[type=button]', dialog), 'click', options.clearHidden
$.bind link, 'click', options.tab for link in $$ '#floaty a', dialog $.bind link, 'click', options.tab for link in $$ '#floaty a', dialog
$.bind $('textarea[name=flavors]', dialog), 'change', $.cb.value $.bind $('textarea[name=flavors]', dialog), 'change', $.cb.value
$.bind $('input[name=time]', dialog), 'keyup', options.cb.time $.bind $('input[name=time]', dialog), 'keyup', options.time
for input in $$ '#keybinds input', dialog for input in $$ '#keybinds input', dialog
input.value = $.getValue "key/#{input.name}", config.hotkeys[input.name] input.value = $.getValue "key/#{input.name}", config.hotkeys[input.name]
$.bind input, 'keydown', options.cb.keybind $.bind input, 'keydown', options.keybind
### ###
Two parent divs are necessary to center on all browsers. Two parent divs are necessary to center on all browsers.
@ -878,7 +878,7 @@ options =
$.append overlay, dialog $.append overlay, dialog
$.append d.body, overlay $.append d.body, overlay
options.cb.time.call $('input[name=time]', dialog) options.time.call $('input[name=time]', dialog)
$.bind overlay, 'click', -> $.rm overlay $.bind overlay, 'click', -> $.rm overlay
$.bind dialog.firstElementChild, 'click', (e) -> e.stopPropagation() $.bind dialog.firstElementChild, 'click', (e) -> e.stopPropagation()
@ -890,31 +890,30 @@ options =
else else
$.hide div $.hide div
cb: clearHidden: (e) ->
clearHidden: (e) -> #'hidden' might be misleading; it's the number of IDs we're *looking* for,
#'hidden' might be misleading; it's the number of IDs we're *looking* for, # not the number of posts actually hidden on the page.
# not the number of posts actually hidden on the page. $.deleteValue "hiddenReplies/#{g.BOARD}/"
$.deleteValue "hiddenReplies/#{g.BOARD}/" $.deleteValue "hiddenThreads/#{g.BOARD}/"
$.deleteValue "hiddenThreads/#{g.BOARD}/" @value = "hidden: 0"
@value = "hidden: 0" g.hiddenReplies = {}
g.hiddenReplies = {} keybind: (e) ->
keybind: (e) -> e.preventDefault()
e.preventDefault() e.stopPropagation()
e.stopPropagation() key = keybinds.cb.keyCode e, true
key = keybinds.cb.keyCode e, true
if key? if key?
if key if key
key = 'alt+' + key if e.altKey key = 'alt+' + key if e.altKey
key = 'ctrl+' + key if e.ctrlKey key = 'ctrl+' + key if e.ctrlKey
@value = key @value = key
$.setValue "key/#{@name}", key $.setValue "key/#{@name}", key
keybinds[@name] = key keybinds[@name] = key
time: (e) -> time: (e) ->
$.setValue 'time', @value $.setValue 'time', @value
Time.foo() Time.foo()
Time.date = new Date() Time.date = new Date()
$('#timePreview').textContent = Time.funk Time $('#timePreview').textContent = Time.funk Time
cooldown = cooldown =
init: -> init: ->
@ -1766,29 +1765,28 @@ unread =
init: -> init: ->
unread.replies = [] unread.replies = []
d.title = '(0) ' + d.title d.title = '(0) ' + d.title
$.bind window, 'scroll', unread.cb.scroll $.bind window, 'scroll', unread.scroll
g.callbacks.push unread.cb.node g.callbacks.push unread.node
cb: node: (root) ->
node: (root) -> return if root.className
return if root.className unread.replies.push root
unread.replies.push root unread.updateTitle()
unread.updateTitle() Favicon.update()
scroll: (e) ->
height = d.body.clientHeight
for reply, i in unread.replies
{bottom} = reply.getBoundingClientRect()
if bottom > height #post is not completely read
break
return if i is 0
unread.replies = unread.replies[i..]
unread.updateTitle()
if unread.replies.length is 0
Favicon.update() Favicon.update()
scroll: (e) ->
height = d.body.clientHeight
for reply, i in unread.replies
{bottom} = reply.getBoundingClientRect()
if bottom > height #post is not completely read
break
return if i is 0
unread.replies = unread.replies[i..]
unread.updateTitle()
if unread.replies.length is 0
Favicon.update()
updateTitle: -> updateTitle: ->
d.title = d.title.replace /\d+/, unread.replies.length d.title = d.title.replace /\d+/, unread.replies.length
@ -1860,19 +1858,18 @@ imageHover =
img = $.el 'img', id: 'iHover' img = $.el 'img', id: 'iHover'
$.hide img $.hide img
$.append d.body, img $.append d.body, img
g.callbacks.push imageHover.cb.node g.callbacks.push imageHover.node
cb: node: (root) ->
node: (root) -> return unless thumb = $ 'img[md5]', root
return unless thumb = $ 'img[md5]', root $.bind thumb, 'mouseover', imageHover.mouseover
$.bind thumb, 'mouseover', imageHover.cb.mouseover $.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mousemove', ui.hover $.bind thumb, 'mouseout', ui.hoverend
$.bind thumb, 'mouseout', ui.hoverend mouseover: (e) ->
mouseover: (e) -> el = $ '#iHover'
el = $ '#iHover' el.src = null
el.src = null el.src = @parentNode.href
el.src = @parentNode.href ui.el = el
ui.el = el $.show el
$.show el
imgPreloading = imgPreloading =
init: -> init: ->
@ -1891,17 +1888,17 @@ imgGif =
imgExpand = imgExpand =
init: -> init: ->
g.callbacks.push imgExpand.cb.node g.callbacks.push imgExpand.node
imgExpand.dialog() imgExpand.dialog()
$.bind window, 'resize', imgExpand.resize $.bind window, 'resize', imgExpand.resize
imgExpand.resize() imgExpand.resize()
node: (root) ->
return unless thumb = $ 'img[md5]', root
a = thumb.parentNode
$.bind a, 'click', imgExpand.cb.toggle
if imgExpand.on and root.className isnt 'inline' then imgExpand.toggle a
cb: cb:
node: (root) ->
return unless thumb = $ 'img[md5]', root
a = thumb.parentNode
$.bind a, 'click', imgExpand.cb.toggle
if imgExpand.on and root.className isnt 'inline' then imgExpand.toggle a
toggle: (e) -> toggle: (e) ->
return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0
e.preventDefault() e.preventDefault()