diff --git a/public/src/app.js b/public/src/app.js index 5484d9de50..13ad87175d 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -565,6 +565,14 @@ app.cacheBuster = null; }); }; + app.loadJQueryUI = function(callback) { + if (typeof $().autocomplete === 'function') { + return callback(); + } + + $.getScript(RELATIVE_PATH + '/vendor/jquery/js/jquery-ui-1.10.4.custom.js', callback); + }; + app.showEmailConfirmWarning = function(err) { if (!config.requireEmailConfirmation || !app.user.uid) { return; diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js index e7ed54cbbe..c0e90dc818 100644 --- a/public/src/client/account/edit.js +++ b/public/src/client/account/edit.js @@ -17,10 +17,12 @@ define('forum/account/edit', ['forum/account/header', 'uploader', 'translator'], $('#submitBtn').on('click', updateProfile); - $('#inputBirthday').datepicker({ - changeMonth: true, - changeYear: true, - yearRange: '1900:+0' + app.loadJQueryUI(function() { + $('#inputBirthday').datepicker({ + changeMonth: true, + changeYear: true, + yearRange: '1900:+0' + }); }); currentEmail = $('#inputEmail').val(); diff --git a/public/src/modules/autocomplete.js b/public/src/modules/autocomplete.js index 8a6967a308..aa4f6a7e51 100644 --- a/public/src/modules/autocomplete.js +++ b/public/src/modules/autocomplete.js @@ -7,62 +7,66 @@ define('autocomplete', function() { var module = {}; module.user = function (input) { - return input.autocomplete({ - delay: 100, - source: function(request, response) { - socket.emit('user.search', {query: request.term}, function(err, result) { - if (err) { - return app.alertError(err.message); - } + app.loadJQueryUI(function() { + return input.autocomplete({ + delay: 100, + source: function(request, response) { + socket.emit('user.search', {query: request.term}, function(err, result) { + if (err) { + return app.alertError(err.message); + } - if (result && result.users) { - var names = result.users.map(function(user) { - return user && { - label: user.username, - value: user.username, - user: { - uid: user.uid, - name: user.username, - slug: user.userslug - } - }; - }); - response(names); - } - $('.ui-autocomplete a').attr('data-ajaxify', 'false'); - }); - } + if (result && result.users) { + var names = result.users.map(function(user) { + return user && { + label: user.username, + value: user.username, + user: { + uid: user.uid, + name: user.username, + slug: user.userslug + } + }; + }); + response(names); + } + $('.ui-autocomplete a').attr('data-ajaxify', 'false'); + }); + } + }); }); }; module.group = function(input) { - return input.autocomplete({ - delay: 100, - source: function(request, response) { - socket.emit('groups.search', { - query: request.term, - options: {} - }, function(err, results) { - if (err) { - return app.alertError(err.message); - } + app.loadJQueryUI(function() { + return input.autocomplete({ + delay: 100, + source: function(request, response) { + socket.emit('groups.search', { + query: request.term, + options: {} + }, function(err, results) { + if (err) { + return app.alertError(err.message); + } - if (results && results.length) { - var names = results.map(function(group) { - return group && { - label: group.name, - value: group.name, - group: { - name: group.name, - slug: group.slug - } - }; - }); - response(names); - } - $('.ui-autocomplete a').attr('data-ajaxify', 'false'); - }); - } + if (results && results.length) { + var names = results.map(function(group) { + return group && { + label: group.name, + value: group.name, + group: { + name: group.name, + slug: group.slug + } + }; + }); + response(names); + } + $('.ui-autocomplete a').attr('data-ajaxify', 'false'); + }); + } + }); }); }; diff --git a/public/src/modules/chat.js b/public/src/modules/chat.js index 9c1183d6a1..b27b932eec 100644 --- a/public/src/modules/chat.js +++ b/public/src/modules/chat.js @@ -179,28 +179,31 @@ define('chat', ['components', 'taskbar', 'string', 'sounds', 'forum/chats', 'tra chatModal.css('zIndex', 100); chatModal.appendTo($('body')); module.center(chatModal); - chatModal.draggable({ - start:function() { - module.bringModalToTop(chatModal); - }, - stop:function() { - chatModal.find('#chat-message-input').focus(); - }, - distance: 10, - handle: '.modal-header' - }); - chatModal.find('.modal-content').resizable({ - minHeight: 250, - minWidth: 400 - }); + app.loadJQueryUI(function() { + chatModal.find('.modal-content').resizable({ + minHeight: 250, + minWidth: 400 + }); - chatModal.find('.modal-content').on('resize', function(event, ui) { - if (ui.originalSize.height === ui.size.height) { - return; - } + chatModal.find('.modal-content').on('resize', function(event, ui) { + if (ui.originalSize.height === ui.size.height) { + return; + } - chatModal.find('#chat-content').css('height', module.calculateChatListHeight(chatModal)); + chatModal.find('#chat-content').css('height', module.calculateChatListHeight(chatModal)); + }); + + chatModal.draggable({ + start:function() { + module.bringModalToTop(chatModal); + }, + stop:function() { + chatModal.find('#chat-message-input').focus(); + }, + distance: 10, + handle: '.modal-header' + }); }); chatModal.find('#chat-with-name').html(username); diff --git a/public/src/modules/composer/tags.js b/public/src/modules/composer/tags.js index 0d0e16ab2b..acd5fb3203 100644 --- a/public/src/modules/composer/tags.js +++ b/public/src/modules/composer/tags.js @@ -34,26 +34,29 @@ define('composer/tags', function() { addTags(postData.tags, tagEl); var input = postContainer.find('.bootstrap-tagsinput input'); - input.autocomplete({ - delay: 100, - open: function() { - $(this).autocomplete('widget').css('z-index', 20000); - }, - source: function(request, response) { - socket.emit('topics.searchTags', {query: request.term, cid: postData.cid}, function(err, tags) { - if (err) { - return app.alertError(err.message); - } - if (tags) { - response(tags); - } - $('.ui-autocomplete a').attr('data-ajaxify', 'false'); - }); - }, - select: function(event, ui) { - // when autocomplete is selected from the dropdown simulate a enter key down to turn it into a tag - triggerEnter(input); - } + + app.loadJQueryUI(function() { + input.autocomplete({ + delay: 100, + open: function() { + $(this).autocomplete('widget').css('z-index', 20000); + }, + source: function(request, response) { + socket.emit('topics.searchTags', {query: request.term, cid: postData.cid}, function(err, tags) { + if (err) { + return app.alertError(err.message); + } + if (tags) { + response(tags); + } + $('.ui-autocomplete a').attr('data-ajaxify', 'false'); + }); + }, + select: function(event, ui) { + // when autocomplete is selected from the dropdown simulate a enter key down to turn it into a tag + triggerEnter(input); + } + }); }); input.attr('tabIndex', tagEl.attr('tabIndex')); diff --git a/src/meta/js.js b/src/meta/js.js index 8974999a65..20589dc707 100644 --- a/src/meta/js.js +++ b/src/meta/js.js @@ -22,7 +22,6 @@ module.exports = function(Meta) { scripts: { base: [ 'public/vendor/jquery/js/jquery.js', - 'public/vendor/jquery/js/jquery-ui-1.10.4.custom.js', 'public/vendor/jquery/sortable/Sortable.js', './node_modules/socket.io-client/socket.io.js', 'public/vendor/jquery/timeago/jquery.timeago.min.js', diff --git a/src/views/admin/header.tpl b/src/views/admin/header.tpl index d0460bb058..05cee84e76 100644 --- a/src/views/admin/header.tpl +++ b/src/views/admin/header.tpl @@ -51,6 +51,7 @@ +