-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-expander.js
57 lines (46 loc) · 1.5 KB
/
media-expander.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(function ($) {
var processors = new Array();
var imageUploader = new ImageUploader("fc284497622fb0e57da75597b75c49bf");
function processPost(post_container) {
$(post_container).find(".body .post-text").each(function() {
var post = $(this);
var photos = $.map($(this).find("a[href]"), function(atag) {
url = $(atag).attr("href");
for (var i = processors.length - 1; i >= 0; i--) {
processors[i](url, function(newElement){
post.append(newElement);
});
};
});
});
}
var observer = new window.WebKitMutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
$(mutation.addedNodes).each(function() {
if ($(this).is(".post-container")) {
processPost($(this));
} else {
$(this).find(".post-container").each(function() {
processPost($(this));
});
}
});
});
});
var config = {
subtree: true,
childList: true,
characterData: false,
attributes: false
};
$("body").each(function() {
observer.observe(this, config);
});
processorSetup($,processors);
$(".post-container").each(function() {
processPost(this);
});
$(document).ready(function() {
imageUploader.setup();
});
})(jQuery);