Add Main.callbackNodes.
This commit is contained in:
parent
a43aea527e
commit
8fc1f86689
@ -728,26 +728,46 @@
|
|||||||
return $.ready(Main.initFeaturesReady);
|
return $.ready(Main.initFeaturesReady);
|
||||||
},
|
},
|
||||||
initFeaturesReady: function() {
|
initFeaturesReady: function() {
|
||||||
var board, child, thread, _i, _j, _len, _len1, _ref, _ref1;
|
var child, posts, thread, threads, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
if (!$.id('navtopr')) {
|
if (!$.id('navtopr')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
board = $('.board');
|
threads = [];
|
||||||
_ref = board.children;
|
posts = [];
|
||||||
|
_ref = $('.board').children;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
child = _ref[_i];
|
child = _ref[_i];
|
||||||
if (child.className === 'thread') {
|
if (child.className !== 'thread') {
|
||||||
thread = new Thread(child, g.BOARD);
|
continue;
|
||||||
_ref1 = thread.root.children;
|
}
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
thread = new Thread(child, g.BOARD);
|
||||||
child = _ref1[_j];
|
threads.push(thread);
|
||||||
if ($.hasClass(child, 'postContainer')) {
|
_ref1 = thread.root.children;
|
||||||
new Post(child, thread, g.BOARD);
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
}
|
child = _ref1[_j];
|
||||||
|
if (!$.hasClass(child, 'postContainer')) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
posts.push(new Post(child, thread, g.BOARD));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Main.callbackNodes(Thread, threads, true);
|
||||||
|
return Main.callbackNodes(Post, posts, true);
|
||||||
|
},
|
||||||
|
callbackNodes: function(klass, nodes, notify) {
|
||||||
|
var callback, i, len, _i, _j, _len, _ref;
|
||||||
|
len = nodes.length;
|
||||||
|
_ref = klass.prototype.callbacks;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
callback = _ref[_i];
|
||||||
|
try {
|
||||||
|
for (i = _j = 0; 0 <= len ? _j < len : _j > len; i = 0 <= len ? ++_j : --_j) {
|
||||||
|
callback.cb.call(nodes[i]);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $.log(g);
|
|
||||||
},
|
},
|
||||||
settings: function() {
|
settings: function() {
|
||||||
return alert('Here be settings');
|
return alert('Here be settings');
|
||||||
|
|||||||
@ -566,14 +566,31 @@ Main =
|
|||||||
$.ready Main.initFeaturesReady
|
$.ready Main.initFeaturesReady
|
||||||
initFeaturesReady: ->
|
initFeaturesReady: ->
|
||||||
return unless $.id 'navtopr'
|
return unless $.id 'navtopr'
|
||||||
board = $ '.board'
|
|
||||||
for child in board.children
|
threads = []
|
||||||
if child.className is 'thread'
|
posts = []
|
||||||
thread = new Thread child, g.BOARD
|
|
||||||
for child in thread.root.children
|
for child in $('.board').children
|
||||||
if $.hasClass child, 'postContainer'
|
continue unless child.className is 'thread'
|
||||||
new Post child, thread, g.BOARD
|
thread = new Thread child, g.BOARD
|
||||||
$.log g
|
threads.push thread
|
||||||
|
for child in thread.root.children
|
||||||
|
continue unless $.hasClass child, 'postContainer'
|
||||||
|
posts.push new Post child, thread, g.BOARD
|
||||||
|
|
||||||
|
Main.callbackNodes Thread, threads, true
|
||||||
|
Main.callbackNodes Post, posts, true
|
||||||
|
|
||||||
|
callbackNodes: (klass, nodes, notify) ->
|
||||||
|
# get the nodes' length only once
|
||||||
|
len = nodes.length
|
||||||
|
for callback in klass::callbacks
|
||||||
|
try
|
||||||
|
for i in [0...len]
|
||||||
|
callback.cb.call nodes[i]
|
||||||
|
catch err
|
||||||
|
# handle error if notify
|
||||||
|
return
|
||||||
|
|
||||||
settings: ->
|
settings: ->
|
||||||
alert 'Here be settings'
|
alert 'Here be settings'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user