diff options
Diffstat (limited to 'js/lib/ui.js')
-rw-r--r-- | js/lib/ui.js | 59 |
1 files changed, 29 insertions, 30 deletions
diff --git a/js/lib/ui.js b/js/lib/ui.js index 6cc1bc78a..c26cbe389 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -14,18 +14,14 @@ elgg.ui.init = function () { $('[rel=toggle]').live('click', elgg.ui.toggles); - $('[rel=popup]').live('click', elgg.ui.popsUp); + $('[rel=popup]').live('click', elgg.ui.popupOpen); $('.elgg-menu-page .elgg-menu-parent').live('click', elgg.ui.toggleMenu); $('.elgg-requires-confirmation').live('click', elgg.ui.requiresConfirmation); $('.elgg-autofocus').focus(); - - if ($('.elgg-input-date').length) { - elgg.ui.initDatePicker(); - } -} +}; /** * Toggles an element based on clicking a separate element @@ -43,7 +39,7 @@ elgg.ui.toggles = function(event) { var target = $(this).toggleClass('elgg-state-active').attr('href'); $(target).slideToggle('medium'); -} +}; /** * Pops up an element based on clicking a separate element @@ -63,7 +59,7 @@ elgg.ui.toggles = function(event) { * @param {Object} event * @return void */ -elgg.ui.popsUp = function(event) { +elgg.ui.popupOpen = function(event) { event.preventDefault(); event.stopPropagation(); @@ -105,7 +101,7 @@ elgg.ui.popsUp = function(event) { $('body') .die('click', elgg.ui.popupClose) .live('click', elgg.ui.popupClose); -} +}; /** * Catches clicks that aren't in a popup and closes all popups. @@ -143,7 +139,7 @@ elgg.ui.popupClose = function(event) { $('body').die('click', elgg.ui.popClose); } -} +}; /** * Toggles a child menu when the parent is clicked @@ -155,7 +151,7 @@ elgg.ui.toggleMenu = function(event) { $(this).siblings().slideToggle('medium'); $(this).toggleClass('elgg-menu-closed elgg-menu-opened'); event.preventDefault(); -} +}; /** * Initialize the hover menu @@ -183,7 +179,7 @@ elgg.ui.initHoverMenu = function(parent) { var $hovermenu = $(this).data('hovermenu') || null; if (!$hovermenu) { - var $hovermenu = $(this).parent().find(".elgg-menu-hover"); + $hovermenu = $(this).parent().find(".elgg-menu-hover"); $(this).data('hovermenu', $hovermenu); } @@ -215,7 +211,7 @@ elgg.ui.initHoverMenu = function(parent) { $(".elgg-menu-hover").fadeOut(); } }); -} +}; /** * Calls a confirm() and prevents default if denied. @@ -240,7 +236,7 @@ elgg.ui.requiresConfirmation = function(e) { * * @return {Object} */ -elgg.ui.LoginHandler = function(hook, type, params, options) { +elgg.ui.loginHandler = function(hook, type, params, options) { if (params.target.attr('id') == 'login-dropdown-box') { options.my = 'right top'; options.at = 'right bottom'; @@ -261,22 +257,25 @@ elgg.ui.LoginHandler = function(hook, type, params, options) { * @return void */ elgg.ui.initDatePicker = function() { - $('.elgg-input-date').datepicker({ - // ISO-8601 - dateFormat: 'yy-mm-dd', - onSelect: function(dateText) { - if ($(this).is('.elgg-input-timestamp')) { - // convert to unix timestamp - var dateParts = dateText.split("-"); - var timestamp = Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]); - timestamp = timestamp / 1000; - - var id = $(this).attr('id'); - $('input[name="' + id + '"]').val(timestamp); + if ($('.elgg-input-date').length) { + $('.elgg-input-date').datepicker({ + // ISO-8601 + dateFormat: 'yy-mm-dd', + onSelect: function(dateText) { + if ($(this).is('.elgg-input-timestamp')) { + // convert to unix timestamp + var dateParts = dateText.split("-"); + var timestamp = Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]); + timestamp = timestamp / 1000; + + var id = $(this).attr('id'); + $('input[name="' + id + '"]').val(timestamp); + } } - } - }); -} + }); + } +}; elgg.register_hook_handler('init', 'system', elgg.ui.init); -elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.LoginHandler);
\ No newline at end of file +elgg.register_hook_handler('init', 'system', elgg.ui.initDatePicker); +elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.loginHandler);
\ No newline at end of file |