Fix pretty-printing on Chrome.

This commit is contained in:
Mayhem 2013-11-02 16:46:56 +01:00
parent 6460d5e0c1
commit a223568937

View File

@ -6,8 +6,9 @@ Fourchan =
if board is 'g' if board is 'g'
$.globalEval """ $.globalEval """
window.addEventListener('prettyprint', function(e) { window.addEventListener('prettyprint', function(e) {
var pre = e.detail; window.dispatchEvent(new CustomEvent('prettyprint:cb', {
pre.innerHTML = prettyPrintOne(pre.innerHTML); detail: prettyPrintOne(e.detail)
}));
}, false); }, false);
""" """
Post.callbacks.push Post.callbacks.push
@ -32,9 +33,11 @@ Fourchan =
cb: @math cb: @math
code: -> code: ->
return if @isClone return if @isClone
for pre in $$ '.prettyprint:not(.prettyprinted)', @nodes.comment apply = (e) -> pre.innerHTML = e.detail
$.event 'prettyprint', pre, window $.on window, 'prettyprint:cb', apply
$.addClass pre, 'prettyprinted' for pre in $$ '.prettyprint', @nodes.comment
$.event 'prettyprint', pre.innerHTML, window
$.off window, 'prettyprint:cb', apply
return return
math: -> math: ->
return if @isClone or !$ '.math', @nodes.comment return if @isClone or !$ '.math', @nodes.comment