From 9a44acd27b0f8fb63cd07af7e7232f6c2b29ecf5 Mon Sep 17 00:00:00 2001 From: cash Date: Wed, 21 Sep 2011 20:57:33 -0400 Subject: Fixes #3770 CSS only site menu that works in IE7 --- js/lib/ui.js | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index 46e418e8b..7abf7626f 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -22,13 +22,6 @@ elgg.ui.init = function () { if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } - - // fix for ie7 CSS issue on menu dropdown - // open the menu when you hover over it, close when you click off of it. - // @todo This should be possible with CSS. Anyone want to tame the beast, go for it. - if ($.browser.msie && $.browser.version <= 7) { - $('.elgg-menu-site > .elgg-more').live('mouseenter', elgg.ui.ie7MenuFixMouseEnter) - } } /** @@ -282,32 +275,6 @@ elgg.ui.initDatePicker = function() { }); } -/** - * IE 7 doesn't like our site menu system CSS, so open it with JS. - */ -elgg.ui.ie7MenuFixMouseEnter = function() { - $('.elgg-menu-site .elgg-menu-site-more').css('display', 'block'); - $('.elgg-menu-site .elgg-more > a') - .css('background-color', 'white') - .css('color', '#555') - - $body = $('body'); - if (!$body.data('hasIe7Clear')) { - $body.live('click', elgg.ui.ie7MenuClear); - $body.data('hasIe7Clear', true); - } - -} - -/** - * Close the menu when clicking on the body - */ -elgg.ui.ie7MenuClear = function() { - $('.elgg-menu-site .elgg-menu-site-more').css('display', 'none'); - $('.elgg-menu-site .elgg-more > a') - .css('background-color', 'transparent') - .css('color', 'white') -} 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 -- cgit v1.2.3 From fbfcfee331d768c20e86585c644628b1bf3f14b7 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 9 Oct 2011 17:38:09 -0400 Subject: Fixes #3673 added autofocus class --- js/lib/ui.js | 2 ++ views/default/core/account/login_box.php | 9 --------- views/default/forms/login.php | 6 +++++- views/default/forms/register.php | 7 +------ views/default/forms/user/requestnewpassword.php | 12 +++++------- 5 files changed, 13 insertions(+), 23 deletions(-) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index 7abf7626f..57378a4d6 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -19,6 +19,8 @@ elgg.ui.init = function () { $('.elgg-requires-confirmation').live('click', elgg.ui.requiresConfirmation); + $('.elgg-autofocus').focus(); + if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } diff --git a/views/default/core/account/login_box.php b/views/default/core/account/login_box.php index 274172bdb..8c586d425 100644 --- a/views/default/core/account/login_box.php +++ b/views/default/core/account/login_box.php @@ -15,12 +15,3 @@ $title = elgg_echo('login'); $body = elgg_view_form('login', array('action' => "{$login_url}action/login")); echo elgg_view_module('aside', $title, $body); - -?> - - - diff --git a/views/default/forms/login.php b/views/default/forms/login.php index 91e9cda42..956b3a87f 100644 --- a/views/default/forms/login.php +++ b/views/default/forms/login.php @@ -9,7 +9,11 @@
- 'username')); ?> + 'username', + 'class' => 'elgg-autofocus', + )); + ?>
diff --git a/views/default/forms/register.php b/views/default/forms/register.php index 6e18cd53d..411152205 100644 --- a/views/default/forms/register.php +++ b/views/default/forms/register.php @@ -23,6 +23,7 @@ if (elgg_is_sticky_form('register')) { echo elgg_view('input/text', array( 'name' => 'name', 'value' => $name, + 'class' => 'elgg-autofocus', )); ?>
@@ -75,9 +76,3 @@ echo elgg_view('input/hidden', array('name' => 'friend_guid', 'value' => $vars[' echo elgg_view('input/hidden', array('name' => 'invitecode', 'value' => $vars['invitecode'])); echo elgg_view('input/submit', array('name' => 'submit', 'value' => elgg_echo('register'))); echo ''; -?> - \ No newline at end of file diff --git a/views/default/forms/user/requestnewpassword.php b/views/default/forms/user/requestnewpassword.php index 22357e728..8a5a18734 100644 --- a/views/default/forms/user/requestnewpassword.php +++ b/views/default/forms/user/requestnewpassword.php @@ -12,15 +12,13 @@

- 'username')); ?> + 'username', + 'class' => 'elgg-autofocus', + )); + ?>
elgg_echo('request'))); ?>
- - \ No newline at end of file -- cgit v1.2.3 From 75f971f3f4dc2517cf4ec18fe29f12f3d3e8d30a Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Sun, 23 Oct 2011 11:23:58 -0700 Subject: Fixes #3914. Moved avatar cropping to ui.js. --- js/lib/ui.js | 37 ++++++++++++++++++++++++++++ views/default/css/elements/misc.php | 2 +- views/default/forms/avatar/crop.php | 49 +++---------------------------------- 3 files changed, 42 insertions(+), 46 deletions(-) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index 57378a4d6..8cee500d0 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -1,6 +1,7 @@ elgg.provide('elgg.ui'); elgg.ui.init = function () { + // add user hover menus elgg.ui.initHoverMenu(); //if the user clicks a system message, make it disappear @@ -24,6 +25,14 @@ elgg.ui.init = function () { if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } + + // avatar cropper + $('#user-avatar-cropper').imgAreaSelect({ + selectionOpacity: 0, + aspectRatio: '1:1', + onSelectEnd: elgg.ui.avatarSelectChange, + onSelectChange: elgg.ui.avatarPreview + }); } /** @@ -277,6 +286,34 @@ elgg.ui.initDatePicker = function() { }); } +// Avatar cropping + +// display a preview of the users cropped section +elgg.ui.avatarPreview = function(img, selection) { + // catch for the first click on the image + if (selection.width == 0 || selection.height == 0) { + return; + } + + var origWidth = $("#user-avatar-cropper").width(); + var origHeight = $("#user-avatar-cropper").height(); + var scaleX = 100 / selection.width; + var scaleY = 100 / selection.height; + $('#user-avatar-preview > img').css({ + width: Math.round(scaleX * origWidth) + 'px', + height: Math.round(scaleY * origHeight) + 'px', + marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', + marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' + }); +} + +// populate the form with the correct coordinates once a user has cropped their image +elgg.ui.avatarSelectChange = function(img, selection) { + $('input[name=x1]').val(selection.x1); + $('input[name=x2]').val(selection.x2); + $('input[name=y1]').val(selection.y1); + $('input[name=y2]').val(selection.y2); +} 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 diff --git a/views/default/css/elements/misc.php b/views/default/css/elements/misc.php index ebac2b91f..d9622d34a 100644 --- a/views/default/css/elements/misc.php +++ b/views/default/css/elements/misc.php @@ -18,7 +18,7 @@ #avatar-croppingtool { border-top: 1px solid #ccc; } -#user-avatar { +#user-avatar-cropper { float: left; } #user-avatar-preview { diff --git a/views/default/forms/avatar/crop.php b/views/default/forms/avatar/crop.php index 1f39ff73c..dd1640b1f 100644 --- a/views/default/forms/avatar/crop.php +++ b/views/default/forms/avatar/crop.php @@ -12,7 +12,10 @@ $master_image = $vars['entity']->getIconUrl('master'); ?>
- <?php echo elgg_echo('avatar'); ?> + <?php echo elgg_echo('avatar'); ?> +
+
+
elgg_echo('avatar:create'))); ?>
- - - -- cgit v1.2.3 From 1b179e3dd38c98959dd95ee42af14d1a32ab2481 Mon Sep 17 00:00:00 2001 From: Brett Profitt Date: Sun, 23 Oct 2011 11:49:27 -0700 Subject: Fixes #3914. Pulled avatar code out into its own library. --- engine/lib/elgglib.php | 1 + js/lib/avatar_cropper.js | 50 +++++++++++++++++++++++++++++++++++++ js/lib/ui.js | 37 --------------------------- views/default/forms/avatar/crop.php | 1 + 4 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 js/lib/avatar_cropper.js (limited to 'js/lib/ui.js') diff --git a/engine/lib/elgglib.php b/engine/lib/elgglib.php index 53a15ba7a..66268cc96 100644 --- a/engine/lib/elgglib.php +++ b/engine/lib/elgglib.php @@ -2046,6 +2046,7 @@ function elgg_init() { elgg_register_js('elgg.userpicker', 'js/lib/userpicker.js'); elgg_register_js('elgg.friendspicker', 'js/lib/friends_picker.js'); elgg_register_js('jquery.easing', 'vendors/jquery/jquery.easing.1.3.packed.js'); + elgg_register_js('elgg.avatar_cropper', 'js/lib/avatar_cropper.js'); elgg_register_js('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/scripts/jquery.imgareaselect.min.js'); elgg_register_css('jquery.imgareaselect', 'vendors/jquery/jquery.imgareaselect-0.9.8/css/imgareaselect-deprecated.css'); diff --git a/js/lib/avatar_cropper.js b/js/lib/avatar_cropper.js new file mode 100644 index 000000000..bfd76225b --- /dev/null +++ b/js/lib/avatar_cropper.js @@ -0,0 +1,50 @@ +/** + * Avatar cropping + */ + +elgg.provide('elgg.avatarCropper'); + +/** + * Register the avatar cropper. + */ +elgg.avatarCropper.init = function() { + $('#user-avatar-cropper').imgAreaSelect({ + selectionOpacity: 0, + aspectRatio: '1:1', + onSelectEnd: elgg.avatarCropper.selectChange, + onSelectChange: elgg.avatarCropper.preview + }); +} + +/** + * Handler for changing select area. + */ +elgg.avatarCropper.preview = function(img, selection) { + // catch for the first click on the image + if (selection.width == 0 || selection.height == 0) { + return; + } + + var origWidth = $("#user-avatar-cropper").width(); + var origHeight = $("#user-avatar-cropper").height(); + var scaleX = 100 / selection.width; + var scaleY = 100 / selection.height; + $('#user-avatar-preview > img').css({ + width: Math.round(scaleX * origWidth) + 'px', + height: Math.round(scaleY * origHeight) + 'px', + marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', + marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' + }); +} + +/** + * Handler for updating the form inputs after select ends + */ +elgg.avatarCropper.selectChange = function(img, selection) { + $('input[name=x1]').val(selection.x1); + $('input[name=x2]').val(selection.x2); + $('input[name=y1]').val(selection.y1); + $('input[name=y2]').val(selection.y2); +} + +elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init); \ No newline at end of file diff --git a/js/lib/ui.js b/js/lib/ui.js index 8cee500d0..166ca16bc 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -25,14 +25,6 @@ elgg.ui.init = function () { if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } - - // avatar cropper - $('#user-avatar-cropper').imgAreaSelect({ - selectionOpacity: 0, - aspectRatio: '1:1', - onSelectEnd: elgg.ui.avatarSelectChange, - onSelectChange: elgg.ui.avatarPreview - }); } /** @@ -286,34 +278,5 @@ elgg.ui.initDatePicker = function() { }); } -// Avatar cropping - -// display a preview of the users cropped section -elgg.ui.avatarPreview = function(img, selection) { - // catch for the first click on the image - if (selection.width == 0 || selection.height == 0) { - return; - } - - var origWidth = $("#user-avatar-cropper").width(); - var origHeight = $("#user-avatar-cropper").height(); - var scaleX = 100 / selection.width; - var scaleY = 100 / selection.height; - $('#user-avatar-preview > img').css({ - width: Math.round(scaleX * origWidth) + 'px', - height: Math.round(scaleY * origHeight) + 'px', - marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', - marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' - }); -} - -// populate the form with the correct coordinates once a user has cropped their image -elgg.ui.avatarSelectChange = function(img, selection) { - $('input[name=x1]').val(selection.x1); - $('input[name=x2]').val(selection.x2); - $('input[name=y1]').val(selection.y1); - $('input[name=y2]').val(selection.y2); -} - 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 diff --git a/views/default/forms/avatar/crop.php b/views/default/forms/avatar/crop.php index dd1640b1f..f622fd60f 100644 --- a/views/default/forms/avatar/crop.php +++ b/views/default/forms/avatar/crop.php @@ -6,6 +6,7 @@ */ elgg_load_js('jquery.imgareaselect'); +elgg_load_js('elgg.avatar_cropper'); elgg_load_css('jquery.imgareaselect'); $master_image = $vars['entity']->getIconUrl('master'); -- cgit v1.2.3 From feefadb125770c0a513735ba7b3d6bea78c77d3b Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Fri, 28 Oct 2011 07:46:36 -0400 Subject: Fixes #4012 when using a timestamp with input/date, return UTC time rather than local time --- js/lib/ui.js | 4 ++-- views/default/input/date.php | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index 166ca16bc..6cc1bc78a 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -267,8 +267,8 @@ elgg.ui.initDatePicker = function() { onSelect: function(dateText) { if ($(this).is('.elgg-input-timestamp')) { // convert to unix timestamp - var date = $.datepicker.parseDate('yy-mm-dd', dateText); - var timestamp = $.datepicker.formatDate('@', date); + var dateParts = dateText.split("-"); + var timestamp = Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]); timestamp = timestamp / 1000; var id = $(this).attr('id'); diff --git a/views/default/input/date.php b/views/default/input/date.php index 35a951a0b..ceeb2105c 100644 --- a/views/default/input/date.php +++ b/views/default/input/date.php @@ -44,6 +44,7 @@ if ($timestamp) { $vars['class'] = "{$vars['class']} elgg-input-timestamp"; $vars['id'] = $vars['name']; unset($vars['name']); + unset($vars['internalname']); } // convert timestamps to text for display -- cgit v1.2.3 From 5c0bd8a19a294f178ddd6607dd3f624ca34fa5b7 Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 1 Nov 2011 19:36:27 -0400 Subject: added semi-colons after function expressions --- .../coding_standards/javascript_coding_standards.txt | 11 +++++++++++ js/lib/avatar_cropper.js | 6 +++--- js/lib/configuration.js | 2 +- js/lib/elgglib.js | 8 ++++---- js/lib/hooks.js | 8 ++++---- js/lib/ui.js | 14 +++++++------- js/lib/ui.widgets.js | 12 ++++++------ js/lib/userpicker.js | 10 +++++----- mod/blog/views/default/js/blog/save_draft.php | 4 ++-- mod/bookmarks/views/default/bookmarks/js.php | 2 +- mod/developers/views/default/js/developers/developers.php | 4 ++-- mod/embed/views/default/js/embed/embed.php | 8 ++++---- mod/messageboard/views/default/messageboard/js.php | 6 +++--- mod/thewire/views/default/js/thewire.php | 6 +++--- mod/tinymce/views/default/js/tinymce.php | 4 ++-- .../views/default/uservalidationbyemail/js.php | 2 +- 16 files changed, 59 insertions(+), 48 deletions(-) (limited to 'js/lib/ui.js') diff --git a/documentation/coding_standards/javascript_coding_standards.txt b/documentation/coding_standards/javascript_coding_standards.txt index 7d3b842ec..9939e80ab 100644 --- a/documentation/coding_standards/javascript_coding_standards.txt +++ b/documentation/coding_standards/javascript_coding_standards.txt @@ -1,2 +1,13 @@ *** JAVASCRIPT CODING STANDARDS *** +* Same formatting standards as PHP. + +* All functions should be in the elgg namespace. + +* Function expressions should end with a semi-colon: + + elgg.ui.toggles = function(event) { + event.preventDefault(); + $(target).slideToggle('medium'); + }; + diff --git a/js/lib/avatar_cropper.js b/js/lib/avatar_cropper.js index df6ba7866..fc32a0832 100644 --- a/js/lib/avatar_cropper.js +++ b/js/lib/avatar_cropper.js @@ -32,7 +32,7 @@ elgg.avatarCropper.init = function() { var selection = ias.getSelection(); elgg.avatarCropper.preview($('#user-avatar-cropper'), selection); } -} +}; /** * Handler for changing select area. @@ -57,7 +57,7 @@ elgg.avatarCropper.preview = function(img, selection) { marginLeft: '-' + Math.round(scaleX * selection.x1) + 'px', marginTop: '-' + Math.round(scaleY * selection.y1) + 'px' }); -} +}; /** * Handler for updating the form inputs after select ends @@ -71,6 +71,6 @@ elgg.avatarCropper.selectChange = function(img, selection) { $('input[name=x2]').val(selection.x2); $('input[name=y1]').val(selection.y1); $('input[name=y2]').val(selection.y2); -} +}; elgg.register_hook_handler('init', 'system', elgg.avatarCropper.init); \ No newline at end of file diff --git a/js/lib/configuration.js b/js/lib/configuration.js index f724a2f01..6e221c957 100644 --- a/js/lib/configuration.js +++ b/js/lib/configuration.js @@ -7,4 +7,4 @@ elgg.provide('elgg.config'); */ elgg.get_site_url = function() { return elgg.config.wwwroot; -} \ No newline at end of file +}; \ No newline at end of file diff --git a/js/lib/elgglib.js b/js/lib/elgglib.js index 628adccfc..d963a62be 100644 --- a/js/lib/elgglib.js +++ b/js/lib/elgglib.js @@ -467,7 +467,7 @@ elgg.parse_url = function(url, component, expand) { } } return results; -} +}; /** * Returns an object with key/values of the parsed query string. @@ -540,7 +540,7 @@ elgg.push_to_object_array = function(object, parent, value) { } return false; -} +}; /** * Tests if object[parent] contains child @@ -554,7 +554,7 @@ elgg.is_in_object_array = function(object, parent, value) { elgg.assertTypeOf('string', parent); return typeof(object[parent]) != 'undefined' && object[parent].indexOf(value) >= 0; -} +}; /** * Triggers the init hook when the library is ready @@ -569,4 +569,4 @@ elgg.initWhenReady = function() { elgg.trigger_hook('init', 'system'); elgg.trigger_hook('ready', 'system'); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/js/lib/hooks.js b/js/lib/hooks.js index edfd28f24..7bac471f6 100644 --- a/js/lib/hooks.js +++ b/js/lib/hooks.js @@ -136,7 +136,7 @@ elgg.register_instant_hook = function(name, type) { elgg.assertTypeOf('string', type); return elgg.push_to_object_array(elgg.config.instant_hooks, name, type); -} +}; /** * Is this hook registered as an instant hook? @@ -146,7 +146,7 @@ elgg.register_instant_hook = function(name, type) { */ elgg.is_instant_hook = function(name, type) { return elgg.is_in_object_array(elgg.config.instant_hooks, name, type); -} +}; /** * Records that a hook has been triggered. @@ -156,7 +156,7 @@ elgg.is_instant_hook = function(name, type) { */ elgg.set_triggered_hook = function(name, type) { return elgg.push_to_object_array(elgg.config.triggered_hooks, name, type); -} +}; /** * Has this hook been triggered yet? @@ -166,7 +166,7 @@ elgg.set_triggered_hook = function(name, type) { */ elgg.is_triggered_hook = function(name, type) { return elgg.is_in_object_array(elgg.config.triggered_hooks, name, type); -} +}; elgg.register_instant_hook('init', 'system'); elgg.register_instant_hook('ready', 'system'); diff --git a/js/lib/ui.js b/js/lib/ui.js index 6cc1bc78a..16ef2dc96 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -25,7 +25,7 @@ elgg.ui.init = function () { if ($('.elgg-input-date').length) { elgg.ui.initDatePicker(); } -} +}; /** * Toggles an element based on clicking a separate element @@ -43,7 +43,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 @@ -105,7 +105,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 +143,7 @@ elgg.ui.popupClose = function(event) { $('body').die('click', elgg.ui.popClose); } -} +}; /** * Toggles a child menu when the parent is clicked @@ -155,7 +155,7 @@ elgg.ui.toggleMenu = function(event) { $(this).siblings().slideToggle('medium'); $(this).toggleClass('elgg-menu-closed elgg-menu-opened'); event.preventDefault(); -} +}; /** * Initialize the hover menu @@ -215,7 +215,7 @@ elgg.ui.initHoverMenu = function(parent) { $(".elgg-menu-hover").fadeOut(); } }); -} +}; /** * Calls a confirm() and prevents default if denied. @@ -276,7 +276,7 @@ elgg.ui.initDatePicker = function() { } } }); -} +}; 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 diff --git a/js/lib/ui.widgets.js b/js/lib/ui.widgets.js index fb256672a..6435d2147 100644 --- a/js/lib/ui.widgets.js +++ b/js/lib/ui.widgets.js @@ -65,7 +65,7 @@ elgg.ui.widgets.add = function(event) { } }); event.preventDefault(); -} +}; /** * Persist the widget's new position @@ -96,7 +96,7 @@ elgg.ui.widgets.move = function(event, ui) { // @hack fixes jquery-ui/opera bug where draggable elements jump ui.item.css('top', 0); ui.item.css('left', 0); -} +}; /** * Removes a widget from the layout @@ -134,7 +134,7 @@ elgg.ui.widgets.remove = function(event) { } }); event.preventDefault(); -} +}; /** * Toggle the collapse state of the widget @@ -146,7 +146,7 @@ elgg.ui.widgets.collapseToggle = function(event) { $(this).toggleClass('elgg-widget-collapsed'); $(this).parent().parent().find('.elgg-body').slideToggle('medium'); event.preventDefault(); -} +}; /** * Save a widget's settings @@ -178,7 +178,7 @@ elgg.ui.widgets.saveSettings = function(event) { } }); event.preventDefault(); -} +}; /** * Make all elements have the same min-height @@ -197,6 +197,6 @@ elgg.ui.widgets.equalHeight = function(selector) { } }) $(selector).css('min-height', maxHeight); -} +}; elgg.register_hook_handler('init', 'system', elgg.ui.widgets.init); diff --git a/js/lib/userpicker.js b/js/lib/userpicker.js index ae2add53f..8287ba91c 100644 --- a/js/lib/userpicker.js +++ b/js/lib/userpicker.js @@ -34,7 +34,7 @@ elgg.userpicker.init = function() { }); $('.elgg-userpicker-remove').live('click', elgg.userpicker.removeUser); -} +}; /** * Adds a user to the select user list @@ -59,7 +59,7 @@ elgg.userpicker.addUser = function(event, ui) { $(this).val(''); event.preventDefault(); -} +}; /** * Remove a user from the selected user list @@ -75,7 +75,7 @@ elgg.userpicker.removeUser = function(event) { item.remove(); event.preventDefault(); -} +}; /** * Render the list item for insertion into the selected user list @@ -96,7 +96,7 @@ elgg.userpicker.viewUser = function(info) { html += " Date: Tue, 1 Nov 2011 20:24:54 -0400 Subject: Fixes #4022 made JS lib a little more consistent --- js/lib/ui.js | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) (limited to 'js/lib/ui.js') diff --git a/js/lib/ui.js b/js/lib/ui.js index 16ef2dc96..c26cbe389 100644 --- a/js/lib/ui.js +++ b/js/lib/ui.js @@ -14,17 +14,13 @@ 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(); - } }; /** @@ -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(); @@ -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); } @@ -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 -- cgit v1.2.3