You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
10 years ago
|
"use strict";
|
||
10 years ago
|
define('components', function() {
|
||
|
var components = {};
|
||
10 years ago
|
|
||
|
components.core = {
|
||
10 years ago
|
'post': function(name, value) {
|
||
10 years ago
|
return $('[data-' + name + '="' + value + '"]');
|
||
10 years ago
|
},
|
||
10 years ago
|
'post/content': function(pid) {
|
||
10 years ago
|
return components.core.post('pid', pid).find('[component="post/content"]');
|
||
10 years ago
|
},
|
||
|
'post/header': function(pid) {
|
||
10 years ago
|
return components.core.post('pid', pid).find('[component="post/header"]');
|
||
10 years ago
|
},
|
||
10 years ago
|
'post/anchor': function(index) {
|
||
10 years ago
|
return components.core.post('index', index).find('[component="post/anchor"]');
|
||
10 years ago
|
},
|
||
10 years ago
|
'post/vote-count': function(pid) {
|
||
10 years ago
|
return components.core.post('pid', pid).find('[component="post/vote-count"]');
|
||
10 years ago
|
},
|
||
10 years ago
|
'post/favourite-count': function(pid) {
|
||
10 years ago
|
return components.core.post('pid', pid).find('[component="post/favourite-count"]');
|
||
10 years ago
|
},
|
||
|
|
||
10 years ago
|
'user/postcount': function(uid) {
|
||
10 years ago
|
return $('[component="user/postcount"][data-uid="' + uid + '"]');
|
||
10 years ago
|
},
|
||
|
'user/reputation': function(uid) {
|
||
10 years ago
|
return $('[component="user/reputation"][data-uid="' + uid + '"]');
|
||
10 years ago
|
},
|
||
|
|
||
|
'category/topic': function(name, value) {
|
||
|
return $('[data-' + name + '="' + value + '"]');
|
||
10 years ago
|
}
|
||
|
};
|
||
|
|
||
|
components.get = function() {
|
||
|
var args = Array.prototype.slice.call(arguments, 1);
|
||
10 years ago
|
|
||
10 years ago
|
if (components.core[arguments[0]] && args.length) {
|
||
10 years ago
|
return components.core[arguments[0]].apply(this, args);
|
||
|
} else {
|
||
|
return $('[component="' + arguments[0] + '"]');
|
||
|
}
|
||
10 years ago
|
};
|
||
10 years ago
|
|
||
|
return components;
|
||
|
});
|