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 $(
'.elgg-requires-confirmation').live(
'click',
elgg.ui.requiresConfirmation);
27 $(
'.elgg-autofocus').focus();
28 if ($(
'.elgg-autofocus').length > 0) {
29 elgg.deprecated_notice(
'Use of .elgg-autofocus is deprecated by html5 autofocus', 1.9);
32 elgg.ui.initAccessInputs();
44 elgg.ui.toggles =
function(event) {
45 event.preventDefault();
48 var target = $(
this).toggleClass(
'elgg-state-active').attr(
'href');
50 $(target).slideToggle(
'medium');
71 elgg.ui.popupOpen =
function(event) {
72 event.preventDefault();
73 event.stopPropagation();
75 var target =
elgg.getSelectorFromUrlFragment($(
this).toggleClass(
'elgg-state-active').attr(
'href'));
80 targetSelector: target,
92 options =
elgg.trigger_hook(
'getOptions',
'ui.popup', params, options);
100 if ($target.is(
':visible')) {
102 $(
'body').die(
'click',
elgg.ui.popupClose);
106 $target.appendTo(
'body')
111 .die(
'click',
elgg.ui.popupClose)
112 .live(
'click',
elgg.ui.popupClose);
118 elgg.ui.popupClose =
function(event) {
119 $eventTarget = $(
event.target);
120 var inTarget =
false;
121 var $popups = $(
'[rel=popup]');
124 $popups.each(
function(
i, e) {
125 var target =
elgg.getSelectorFromUrlFragment($(e).attr(
'href')) +
':visible';
128 if (!$target.is(
':visible')) {
133 if ($eventTarget.closest(target).length > 0) {
140 $popups.each(
function(
i, e) {
142 var
$target = $(
elgg.getSelectorFromUrlFragment($e.attr(
'href')) +
':visible');
143 if ($target.length > 0) {
145 $e.removeClass(
'elgg-state-active');
149 $(
'body').die(
'click',
elgg.ui.popClose);
159 elgg.ui.toggleMenu =
function(event) {
160 $(
this).siblings().slideToggle(
'medium');
161 $(
this).toggleClass(
'elgg-menu-closed elgg-menu-opened');
162 event.preventDefault();
171 elgg.ui.initHoverMenu =
function(parent) {
177 $(parent).find(
".elgg-avatar").live(
'mouseover',
function() {
178 $(
this).children(
".elgg-icon-hover-menu").show();
180 .live(
'mouseout',
function() {
181 $(
this).children(
".elgg-icon-hover-menu").hide();
186 $(
".elgg-avatar > .elgg-icon-hover-menu").live(
'click',
function(e) {
188 var $hovermenu = $(
this).data(
'hovermenu') || null;
191 $hovermenu = $(
this).parent().find(
".elgg-menu-hover");
192 $(
this).data(
'hovermenu', $hovermenu);
196 if ($hovermenu.css(
'display') ==
"block") {
197 $hovermenu.fadeOut();
199 $avatar = $(
this).closest(
".elgg-avatar");
202 var offset = $avatar.offset();
203 var
top = $avatar.height() + offset.top +
'px';
204 var
left = $avatar.width() - 15 + offset.left +
'px';
206 $hovermenu.appendTo(
'body')
207 .css(
'position',
'absolute')
214 $(
".elgg-menu-hover:visible").not($hovermenu).fadeOut();
219 if ($(event.target).parents(
".elgg-avatar").length === 0) {
220 $(
".elgg-menu-hover").fadeOut();
231 elgg.ui.requiresConfirmation =
function(e) {
232 var confirmText = $(
this).data(
'confirm') ||
elgg.echo(
'question:areyousure');
233 if (!confirm(confirmText)) {
248 elgg.ui.loginHandler =
function(hook,
type, params, options) {
249 if (params.target.attr(
'id') ==
'login-dropdown-box') {
250 options.my =
'right top';
251 options.at =
'right bottom';
269 elgg.ui.initDatePicker =
function() {
270 var loadDatePicker =
function() {
273 dateFormat:
'yy-mm-dd',
274 onSelect:
function(dateText) {
275 if ($(
this).is(
'.elgg-input-timestamp')) {
277 var dateParts = dateText.split(
"-");
278 var timestamp = Date.UTC(dateParts[0], dateParts[1] - 1, dateParts[2]);
279 timestamp = timestamp / 1000;
281 var
id = $(
this).attr(
'id');
282 $(
'input[name="' +
id +
'"]').val(timestamp);
288 if ($(
'.elgg-input-date').length &&
elgg.get_language() ==
'en') {
290 }
else if ($(
'.elgg-input-date').length) {
292 url:
elgg.config.wwwroot +
'vendors/jquery/i18n/jquery.ui.datepicker-'+
elgg.get_language() +
'.js',
296 error: loadDatePicker
308 elgg.ui.registerTogglableMenuItems =
function(menuItemNameA, menuItemNameB) {
310 $(
'.elgg-menu-item-' + menuItemNameA +
' a').live(
'click',
function() {
311 var
$menu = $(
this).closest(
'.elgg-menu');
314 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
317 elgg.action($(
this).attr(
'href'), {
319 if (json.system_messages.error.length) {
321 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
326 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
335 $(
'.elgg-menu-item-' + menuItemNameB +
' a').live(
'click',
function() {
336 var
$menu = $(
this).closest(
'.elgg-menu');
339 elgg.ui.toggleMenuItems($menu, menuItemNameA, menuItemNameB);
342 elgg.action($(
this).attr(
'href'), {
344 if (json.system_messages.error.length) {
346 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
351 elgg.ui.toggleMenuItems($menu, menuItemNameB, menuItemNameA);
360 elgg.ui.toggleMenuItems =
function(
$menu, nameOfItemToShow, nameOfItemToHide) {
361 $menu.find(
'.elgg-menu-item-' + nameOfItemToShow).removeClass(
'hidden').find(
'a').focus();
362 $menu.find(
'.elgg-menu-item-' + nameOfItemToHide).addClass(
'hidden');
374 elgg.ui.initAccessInputs =
function () {
375 $(
'.elgg-input-access').each(
function () {
376 function updateMembersonlyNote() {
377 var val = $select.val();
378 if (val != acl && val !== 0) {
380 $note.css(
'visibility',
'visible');
382 $note.css(
'visibility',
'hidden');
385 var $select = $(
this),
386 acl = $select.data(
'group-acl'),
387 $note = $(
'.elgg-input-access-membersonly', this.parentNode);
389 updateMembersonlyNote();
390 $select.change(updateMembersonlyNote);
395 elgg.register_hook_handler(
'init',
'system',
elgg.ui.init);
396 elgg.register_hook_handler(
'init',
'system',
elgg.ui.initDatePicker);
397 elgg.register_hook_handler(
'getOptions',
'ui.popup',
elgg.ui.loginHandler);
398 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);}})
$CONFIG url
The full URL where Elgg is installed.