1 elgg.provide(
'elgg.ui');
3 elgg.ui.init =
function () {
6 $(
'.elgg-page').attr(
"onclick",
"return true");
9 elgg.ui.initHoverMenu();
12 $(
'.elgg-system-messages li').live(
'click',
function() {
13 $(
this).stop().fadeOut(
'fast');
16 $(
'.elgg-system-messages li').animate({opacity: 0.9}, 6000);
17 $(
'.elgg-system-messages li.elgg-state-success').fadeOut(
'slow');
19 $(
'[rel=toggle]').live(
'click',
elgg.ui.toggles);
21 $(
'[rel=popup]').live(
'click',
elgg.ui.popupOpen);
23 $(
'.elgg-menu-page .elgg-menu-parent').live(
'click',
elgg.ui.toggleMenu);
25 $(
'*[data-confirm], .elgg-requires-confirmation').live(
'click',
elgg.ui.requiresConfirmation);
26 if ($(
'.elgg-requires-confirmation').length > 0) {
27 elgg.deprecated_notice(
'Use of .elgg-requires-confirmation is deprecated by data-confirm',
'1.10');
30 $(
'.elgg-autofocus').focus();
31 if ($(
'.elgg-autofocus').length > 0) {
32 elgg.deprecated_notice(
'Use of .elgg-autofocus is deprecated by html5 autofocus', 1.9);
35 elgg.ui.initAccessInputs();
38 var elementId =
elgg.getSelectorFromUrlFragment(
document.URL);
39 $(elementId).addClass(
'elgg-state-highlight');
55 elgg.ui.toggles =
function(event) {
56 event.preventDefault();
58 target = $this.data().toggleSelector;
63 target = $this.attr(
'href');
66 $this.toggleClass(
'elgg-state-active');
68 $(target).each(
function(
index, elem) {
70 if ($elem.data().toggleSlide !=
false) {
71 $elem.slideToggle(
'medium');
96 elgg.ui.popupOpen =
function(event) {
97 event.preventDefault();
98 event.stopPropagation();
100 var target =
elgg.getSelectorFromUrlFragment($(
this).toggleClass(
'elgg-state-active').attr(
'href'));
105 targetSelector: target,
117 options =
elgg.trigger_hook(
'getOptions',
'ui.popup', params, options);
125 if ($target.is(
':visible')) {
127 $(
'body').die(
'click',
elgg.ui.popupClose);
131 $target.appendTo(
'body')
136 .die(
'click',
elgg.ui.popupClose)
137 .live(
'click',
elgg.ui.popupClose);
143 elgg.ui.popupClose =
function(event) {
144 $eventTarget = $(
event.target);
145 var inTarget =
false;
146 var $popups = $(
'[rel=popup]');
149 $popups.each(
function(
i, e) {
150 var target =
elgg.getSelectorFromUrlFragment($(e).attr(
'href')) +
':visible';
153 if (!$target.is(
':visible')) {
158 if ($eventTarget.closest(target).length > 0) {
165 $popups.each(
function(
i, e) {
167 var
$target = $(
elgg.getSelectorFromUrlFragment($e.attr(
'href')) +
':visible');
168 if ($target.length > 0) {
170 $e.removeClass(
'elgg-state-active');
174 $(
'body').die(
'click',
elgg.ui.popClose);
184 elgg.ui.toggleMenu =
function(event) {
185 $(
this).siblings().slideToggle(
'medium');
186 $(
this).toggleClass(
'elgg-menu-closed elgg-menu-opened');
187 event.preventDefault();
196 elgg.ui.initHoverMenu =
function(parent) {
203 function loadMenu(mac) {
204 var $all_placeholders = $(
".elgg-menu-hover[rel='" + mac +
"']");
207 var $ul = $all_placeholders.filter(
'[data-elgg-menu-data]');
213 elgg.get(
'ajax/view/navigation/menu/user_hover/contents', {
214 data: $ul.data(
'elggMenuData'),
218 $all_placeholders.removeClass(
'elgg-ajax-loader')
219 .html($(data).children());
230 $(parent).find(
".elgg-avatar").live(
'mouseover',
function() {
231 $(
this).children(
".elgg-icon-hover-menu").show();
233 .live(
'mouseout',
function() {
234 $(
this).children(
".elgg-icon-hover-menu").hide();
239 $(
".elgg-avatar > .elgg-icon-hover-menu").live(
'click',
function(e) {
240 var $placeholder = $(
this).parent().find(
".elgg-menu-hover.elgg-ajax-loader");
242 if ($placeholder.length) {
243 loadMenu($placeholder.attr(
"rel"));
247 var $hovermenu = $(
this).data(
'hovermenu') || null;
250 $hovermenu = $(
this).parent().find(
".elgg-menu-hover");
251 $(
this).data(
'hovermenu', $hovermenu);
255 if ($hovermenu.css(
'display') ==
"block") {
256 $hovermenu.fadeOut();
258 $avatar = $(
this).closest(
".elgg-avatar");
261 var offset = $avatar.offset();
262 var
top = $avatar.height() + offset.top +
'px';
263 var
left = $avatar.width() - 15 + offset.left +
'px';
265 $hovermenu.appendTo(
'body')
266 .css(
'position',
'absolute')
273 $(
".elgg-menu-hover:visible").not($hovermenu).fadeOut();
278 if ($(event.target).parents(
".elgg-avatar").length === 0) {
279 $(
".elgg-menu-hover").fadeOut();
290 elgg.ui.requiresConfirmation =
function(e) {
291 var confirmText = $(
this).data(
'confirm') ||
elgg.echo(
'question:areyousure');
292 if (!confirm(confirmText)) {
307 elgg.ui.loginHandler =
function(hook,
type, params, options) {
308 if (params.target.attr(
'id') ==
'login-dropdown-box') {
309 options.my =
'right top';
310 options.at =
'right bottom';
328 elgg.ui.initDatePicker =
function() {
329 function loadDatePicker() {
332 dateFormat:
'yy-mm-dd',
333 onSelect:
function(dateText) {
334 if ($(
this).is(
'.elgg-input-timestamp')) {
336 var dateParts = dateText.split(
"-");
337 var timestamp = Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]);
338 timestamp = timestamp / 1000;
340 var
id = $(
this).attr(
'id');
341 $(
'input[name="' +
id +
'"]').val(timestamp);
351 if (!$(
'.elgg-input-date').length) {
355 if (
elgg.get_language() ==
'en') {
360 url:
elgg.config.wwwroot +
'vendors/jquery/i18n/jquery.ui.datepicker-'+
elgg.get_language() +
'.js',
364 error: loadDatePicker
376 elgg.ui.registerTogglableMenuItems =
function(menuItemNameA, menuItemNameB) {
378 $(
'.elgg-menu-item-' + menuItemNameA +
' a').live(
'click',
function() {
379 var
$menu = $(
this).closest(
'.elgg-menu');
382 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
385 elgg.action($(
this).attr(
'href'), {
387 if (json.system_messages.error.length) {
389 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
394 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
403 $(
'.elgg-menu-item-' + menuItemNameB +
' a').live(
'click',
function() {
404 var
$menu = $(
this).closest(
'.elgg-menu');
407 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
410 elgg.action($(
this).attr(
'href'), {
412 if (json.system_messages.error.length) {
414 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
419 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
428 elgg.ui.toggleMenuItems =
function(
$menu, nameOfItemToShow, nameOfItemToHide) {
429 $menu.find(
'.elgg-menu-item-' + nameOfItemToShow).removeClass(
'hidden').find(
'a').focus();
430 $menu.find(
'.elgg-menu-item-' + nameOfItemToHide).addClass(
'hidden');
442 elgg.ui.initAccessInputs =
function () {
443 $(
'.elgg-input-access').each(
function () {
444 function updateMembersonlyNote() {
445 var val = $select.val();
446 if (val != acl && val !== 0) {
448 $note.css(
'visibility',
'visible');
450 $note.css(
'visibility',
'hidden');
453 var $select = $(
this),
454 acl = $select.data(
'group-acl'),
455 $note = $(
'.elgg-input-access-membersonly', this.parentNode),
456 commentCount = $select.data(
'comment-count'),
457 originalValue = $select.data(
'original-value');
459 updateMembersonlyNote();
460 $select.change(updateMembersonlyNote);
464 $select.change(
function(e) {
465 if ($(
this).val() != originalValue) {
466 if (!confirm(
elgg.echo(
'access:comments:change', [commentCount]))) {
467 $(
this).val(originalValue);
475 elgg.register_hook_handler(
'init',
'system',
elgg.ui.init);
476 elgg.register_hook_handler(
'init',
'system',
elgg.ui.initDatePicker);
477 elgg.register_hook_handler(
'getOptions',
'ui.popup',
elgg.ui.loginHandler);
478 elgg.ui.registerTogglableMenuItems(
'add-friend',
'remove-friend');
elgg message elgg state success
elgg message elgg state error
GNU GENERAL PUBLIC LICENSE June Free Software Franklin Fifth MA USA Everyone is permitted to copy and distribute verbatim copies of this license document
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
if(!$site) if(!($site instanceof ElggSite)) $site url