From 54cbbe2844d5bb9a3cac6ffab69d0e318e22b455 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Tue, 17 Mar 2015 12:47:40 -0400 Subject: [PATCH] components system --- public/src/client/topic/events.js | 2 +- public/src/components.js | 17 +++++++++++++++++ src/meta/js.js | 7 ++++--- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 public/src/components.js diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index c90dd149b5..25b872e649 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -96,7 +96,7 @@ define('forum/topic/events', [ } function onPostEdited(data) { - var editedPostEl = $('#content_' + data.pid), + var editedPostEl = components.get('post/content', data.pid), editedPostTitle = $('#topic_title_' + data.pid); if (editedPostTitle.length) { diff --git a/public/src/components.js b/public/src/components.js new file mode 100644 index 0000000000..2bd94b06f0 --- /dev/null +++ b/public/src/components.js @@ -0,0 +1,17 @@ +"use strict"; + +var components = components || {}; + +(function() { + components.core = { + 'post/content': function(pid) { + var el = $('[data-pid="' + pid + '"]').find('[component="post/content"]'); + return el.length ? el : $('[data-pid="' + pid + '"]').find('.post-content'); // deprecated after 0.7x + } + }; + + components.get = function() { + var args = Array.prototype.slice.call(arguments, 1); + return components.core[arguments[0]].apply(this, args); + }; +}()); \ No newline at end of file diff --git a/src/meta/js.js b/src/meta/js.js index 4373d21a1d..3d8ced839c 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -44,10 +44,11 @@ module.exports = function(Meta) { 'public/src/utils.js', 'public/src/app.js', 'public/src/ajaxify.js', - 'public/src/variables.js', - 'public/src/widgets.js', + 'public/src/components.js', + 'public/src/overrides.js', 'public/src/translator.js', - 'public/src/overrides.js' + 'public/src/variables.js', + 'public/src/widgets.js' ], rjs: [] }