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.
nodebb/public/src/modules/components.js

52 lines
1.6 KiB
JavaScript

10 years ago
"use strict";
define('components', function() {
var components = {};
10 years ago
components.core = {
'post': function(name, value) {
10 years ago
return $('[component="post"][data-' + name + '="' + value + '"]');
},
10 years ago
'post/content': function(pid) {
return components.core.post('pid', pid).find('[component="post/content"]');
},
'post/header': function(pid) {
return components.core.post('pid', pid).find('[component="post/header"]');
},
'post/anchor': function(index) {
return components.core.post('index', index).find('[component="post/anchor"]');
},
'post/vote-count': function(pid) {
return components.core.post('pid', pid).find('[component="post/vote-count"]');
},
'post/favourite-count': function(pid) {
return components.core.post('pid', pid).find('[component="post/favourite-count"]');
},
'user/postcount': function(uid) {
return $('[component="user/postcount"][data-uid="' + uid + '"]');
},
'user/reputation': function(uid) {
return $('[component="user/reputation"][data-uid="' + uid + '"]');
},
'category/topic': function(name, value) {
return $('[component="category/topic"][data-' + name + '="' + value + '"]');
},
'categories/category': function(name, value) {
return $('[component="categories/category"][data-' + name + '="' + value + '"]');
10 years ago
}
};
components.get = function() {
var args = Array.prototype.slice.call(arguments, 1);
if (components.core[arguments[0]] && args.length) {
return components.core[arguments[0]].apply(this, args);
} else {
return $('[component="' + arguments[0] + '"]');
}
10 years ago
};
return components;
});