Browse Source

maybe support cross thread inlining

pull/40/head
James Campos 10 years ago
committed by czaks
parent
commit
3de119e417
  1. 58
      js/inline.js

58
js/inline.js

@ -1,22 +1,10 @@
;(function() {
$('.body a').click(inline)
$('head').append(
'<style>' +
'.inline {' +
' border: 1px dashed black;' +
' margin-left: 1em;' +
' padding: 1em;' +
'}' +
'</style>')
})()
function inline(e) {
var inline = function(e) {
e.preventDefault()
var postNum = parseInt(this.textContent.slice(2))
var cloneID = 'inline_' + postNum
var $clone = $('#' + cloneID)
var postNum = this.textContent.slice(2)
var $clone = $('#inline_' + postNum)
if ($clone.length)
return $clone.remove()
@ -25,10 +13,38 @@ function inline(e) {
? '.op .body'
: '#reply_' + postNum + ' .body'
$clone = $(selector).clone(true)
var link = {
postNum: postNum,
node: this
}
var $target = $(selector)
if ($target.length)
add(link, $target)
else
$.get(this.pathname, function(data) {
var $target = $(data).find(selector)
add(link, $target)
})
}
var add = function(link, $target) {
var $clone = $target.clone(true)
$clone.attr({
className: 'inline',
id: cloneID
"class": 'inline',
id: 'inline_' + link.postNum
})
$clone.insertAfter(this)
}
$clone.insertAfter(link.node)
}
$('head').append(
'<style>' +
'.inline {' +
' border: 1px dashed black;' +
' margin-left: 1em;' +
' padding: 1em;' +
'}' +
'</style>')
$('.body a').click(inline)
})()

Loading…
Cancel
Save