From 16c6578bdb824964d91b7dc438b8927ccd8d4dca Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Tue, 31 Mar 2015 14:10:20 -0400 Subject: [PATCH] updated components to be a require.js module, not a global (:rage2:) --- public/src/client/categories.js | 2 +- public/src/client/category.js | 5 +++-- public/src/client/categoryTools.js | 2 +- public/src/client/footer.js | 2 +- public/src/client/recent.js | 2 +- public/src/client/topic.js | 7 ++++--- public/src/client/topic/events.js | 7 ++++--- public/src/client/topic/fork.js | 4 ++-- public/src/client/topic/postTools.js | 4 ++-- public/src/client/topic/posts.js | 7 ++++--- public/src/client/topic/threadTools.js | 4 ++-- public/src/client/unread.js | 2 +- public/src/{ => modules}/components.js | 9 +++++---- public/src/modules/navigator.js | 4 ++-- public/src/modules/topicSelect.js | 2 +- 15 files changed, 34 insertions(+), 29 deletions(-) rename public/src/{ => modules}/components.js (94%) diff --git a/public/src/client/categories.js b/public/src/client/categories.js index e3882ff831..b00db8b4bd 100644 --- a/public/src/client/categories.js +++ b/public/src/client/categories.js @@ -2,7 +2,7 @@ /* globals define, socket, app, templates, translator, ajaxify*/ -define('forum/categories', function() { +define('forum/categories', ['components'], function(components) { var categories = {}; $(window).on('action:ajaxify.start', function(ev, data) { diff --git a/public/src/client/category.js b/public/src/client/category.js index 1e6c0e94c4..8aa3b248d8 100644 --- a/public/src/client/category.js +++ b/public/src/client/category.js @@ -8,8 +8,9 @@ define('forum/category', [ 'share', 'navigator', 'forum/categoryTools', - 'sort' -], function(composer, pagination, infinitescroll, share, navigator, categoryTools, sort) { + 'sort', + 'components' +], function(composer, pagination, infinitescroll, share, navigator, categoryTools, sort, components) { var Category = {}; $(window).on('action:ajaxify.start', function(ev, data) { diff --git a/public/src/client/categoryTools.js b/public/src/client/categoryTools.js index e711bce436..749aca5dad 100644 --- a/public/src/client/categoryTools.js +++ b/public/src/client/categoryTools.js @@ -4,7 +4,7 @@ /* globals define, app, translator, socket, bootbox, ajaxify */ -define('forum/categoryTools', ['forum/topic/move', 'topicSelect'], function(move, topicSelect) { +define('forum/categoryTools', ['forum/topic/move', 'topicSelect', 'components'], function(move, topicSelect, components) { var CategoryTools = {}; diff --git a/public/src/client/footer.js b/public/src/client/footer.js index 4e7c2fa9ee..7a479308f0 100644 --- a/public/src/client/footer.js +++ b/public/src/client/footer.js @@ -1,7 +1,7 @@ "use strict"; /*globals define, app, translator, socket*/ -define('forum/footer', ['notifications', 'chat'], function(Notifications, Chat) { +define('forum/footer', ['notifications', 'chat', 'components'], function(Notifications, Chat, components) { Notifications.prepareDOM(); Chat.prepareDOM(); diff --git a/public/src/client/recent.js b/public/src/client/recent.js index 30d635ea0d..bb78a68080 100644 --- a/public/src/client/recent.js +++ b/public/src/client/recent.js @@ -2,7 +2,7 @@ /* globals define, app, socket, utils */ -define('forum/recent', ['forum/infinitescroll', 'composer'], function(infinitescroll, composer) { +define('forum/recent', ['forum/infinitescroll', 'composer', 'components'], function(infinitescroll, composer, components) { var Recent = {}; var newTopicCount = 0, diff --git a/public/src/client/topic.js b/public/src/client/topic.js index f28a9097c8..a42cb7ff50 100644 --- a/public/src/client/topic.js +++ b/public/src/client/topic.js @@ -1,7 +1,7 @@ 'use strict'; -/* globals define, app, components, templates, translator, socket, bootbox, config, ajaxify, RELATIVE_PATH, utils */ +/* globals define, app, templates, translator, socket, bootbox, config, ajaxify, RELATIVE_PATH, utils */ define('forum/topic', [ 'forum/pagination', @@ -12,8 +12,9 @@ define('forum/topic', [ 'forum/topic/browsing', 'forum/topic/posts', 'navigator', - 'sort' -], function(pagination, infinitescroll, threadTools, postTools, events, browsing, posts, navigator, sort) { + 'sort', + 'components' +], function(pagination, infinitescroll, threadTools, postTools, events, browsing, posts, navigator, sort, components) { var Topic = {}, currentUrl = ''; diff --git a/public/src/client/topic/events.js b/public/src/client/topic/events.js index 5a4fbbd48b..b38f752138 100644 --- a/public/src/client/topic/events.js +++ b/public/src/client/topic/events.js @@ -1,14 +1,15 @@ 'use strict'; -/* globals app, ajaxify, components, define, socket, translator, templates */ +/* globals app, ajaxify, define, socket, translator, templates */ define('forum/topic/events', [ 'forum/topic/browsing', 'forum/topic/postTools', 'forum/topic/threadTools', - 'forum/topic/posts' -], function(browsing, postTools, threadTools, posts) { + 'forum/topic/posts', + 'components' +], function(browsing, postTools, threadTools, posts, components) { var Events = {}; diff --git a/public/src/client/topic/fork.js b/public/src/client/topic/fork.js index 91ec8a2be9..63f2be0b63 100644 --- a/public/src/client/topic/fork.js +++ b/public/src/client/topic/fork.js @@ -1,8 +1,8 @@ 'use strict'; -/* globals define, app, ajaxify, components, translator, socket */ +/* globals define, app, ajaxify, translator, socket */ -define('forum/topic/fork', function() { +define('forum/topic/fork', ['components'], function(components) { var Fork = {}, forkModal, diff --git a/public/src/client/topic/postTools.js b/public/src/client/topic/postTools.js index 4e561b036c..446ee1f1c3 100644 --- a/public/src/client/topic/postTools.js +++ b/public/src/client/topic/postTools.js @@ -1,8 +1,8 @@ 'use strict'; -/* globals define, app, ajaxify, bootbox, components, socket, templates, translator, utils */ +/* globals define, app, ajaxify, bootbox, socket, templates, translator, utils */ -define('forum/topic/postTools', ['composer', 'share', 'navigator'], function(composer, share, navigator) { +define('forum/topic/postTools', ['composer', 'share', 'navigator', 'components'], function(composer, share, navigator, components) { var PostTools = {}, topicName; diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 070a97fa5b..1d7dcbe0df 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -1,13 +1,14 @@ 'use strict'; -/* globals config, app, ajaxify, components, define, socket, utils */ +/* globals config, app, ajaxify, define, socket, utils */ define('forum/topic/posts', [ 'forum/pagination', 'forum/infinitescroll', 'forum/topic/postTools', - 'navigator' -], function(pagination, infinitescroll, postTools, navigator) { + 'navigator', + 'components' +], function(pagination, infinitescroll, postTools, navigator, components) { var Posts = {}; diff --git a/public/src/client/topic/threadTools.js b/public/src/client/topic/threadTools.js index fe8bc1fcfb..d3504a7875 100644 --- a/public/src/client/topic/threadTools.js +++ b/public/src/client/topic/threadTools.js @@ -1,8 +1,8 @@ 'use strict'; -/* globals define, app, components, translator, ajaxify, socket, bootbox */ +/* globals define, app, translator, ajaxify, socket, bootbox */ -define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], function(fork, move) { +define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move', 'components'], function(fork, move, components) { var ThreadTools = {}; diff --git a/public/src/client/unread.js b/public/src/client/unread.js index c8c1c96de9..fa97312c27 100644 --- a/public/src/client/unread.js +++ b/public/src/client/unread.js @@ -2,7 +2,7 @@ /* globals define, app, socket */ -define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll'], function(recent, topicSelect, infinitescroll) { +define('forum/unread', ['forum/recent', 'topicSelect', 'forum/infinitescroll', 'components'], function(recent, topicSelect, infinitescroll, components) { var Unread = {}; $(window).on('action:ajaxify.start', function(ev, data) { diff --git a/public/src/components.js b/public/src/modules/components.js similarity index 94% rename from public/src/components.js rename to public/src/modules/components.js index bef3c95117..85f8b04526 100644 --- a/public/src/components.js +++ b/public/src/modules/components.js @@ -1,8 +1,7 @@ "use strict"; +define('components', function() { + var components = {}; -var components = components || {}; - -(function() { components.core = { 'post': function(name, value) { return $('[data-' + name + '="' + value + '"]'); @@ -44,4 +43,6 @@ var components = components || {}; return $('[component="' + arguments[0] + '"]'); } }; -}()); \ No newline at end of file + + return components; +}); \ No newline at end of file diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.js index f4f4d74a59..263c905d33 100644 --- a/public/src/modules/navigator.js +++ b/public/src/modules/navigator.js @@ -1,10 +1,10 @@ 'use strict'; -/* globals app, components, define, ajaxify, utils, translator, config */ +/* globals app, define, ajaxify, utils, translator, config */ -define('navigator', ['forum/pagination'], function(pagination) { +define('navigator', ['forum/pagination', 'components'], function(pagination, components) { var navigator = {}; var index = 1; diff --git a/public/src/modules/topicSelect.js b/public/src/modules/topicSelect.js index 3e3ae58d46..83519cb2c5 100644 --- a/public/src/modules/topicSelect.js +++ b/public/src/modules/topicSelect.js @@ -2,7 +2,7 @@ /* globals define*/ -define('topicSelect', function() { +define('topicSelect', ['components'], function(components) { var TopicSelect = {}; var lastSelected;