Elgg  Version 2.3
Functions
admin.js File Reference

Go to the source code of this file.

Functions

 define (function(require){var $=require('jquery');var ui=require('jquery-ui');var elgg=require('elgg');var spinner=require('elgg/spinner');var Ajax=require('elgg/Ajax');var ajax=new Ajax();function init(){$('.elgg-system-messages li').stop(true);$(document).off('click', '.elgg-system-messages li');$(document).on('click', '.elgg-system-messages li', function(e){if(!$(e.target).is('a')){$(this).stop().slideUp('medium');}});initPluginReordering();$(".elgg-state-editable").editable(editProfileField,{type: 'text', onblur: 'submit', width: '300px', height: 'none', style: 'display:inline;'});$('#elgg-profile-fields').sortable({items: 'li', handle: 'span.elgg-state-draggable', stop:moveProfileField});$('a.elgg-admin-notice').click(deleteNotice);$(document).on('click', 'input:checkbox.elgg-state-disabled, label.elgg-state-disabled > input:checkbox', function(){return false;});$('[name=simplecache_enabled]').click(simplecacheToggle);$(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);$(document).on('click', '.elgg-plugin-details-container > ul a', showPluginDetails);$(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);$(document).on('click', '.elgg-plugin-state-change', toggleSinglePlugin);$(document).on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);}function freezePlugins(){$('#elgg-plugin-list-cover').css('display', 'block');}function unfreezePlugins(){$('#elgg-plugin-list-cover').css('display', 'none');}function initPluginReordering(){$('#elgg-plugin-list > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-head', forcePlaceholderSize:true, placeholder: 'elgg-widget-placeholder', opacity:0.8, revert:500, stop:movePlugin});}function toggleSinglePlugin(e){freezePlugins();e.preventDefault();ajax.action(this.href).done(function(output, statusText, jqXHR){if(jqXHR.AjaxData.status==-1){location.reload();return;}ajax.path('admin_plugins_refresh').done(function(output){$('#elgg-plugin-list').html(output.list);$('.elgg-sidebar').html(output.sidebar);$(".elgg-admin-plugins-categories > li.elgg-state-selected > a").trigger('click');initPluginReordering();unfreezePlugins();});});}function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.echo('question:areyousure'))){return;}freezePlugins();var guids=[], state=$(this).data('desiredState'), find_state=state== 'active'? 'inactive': 'active';$('.elgg-plugin.elgg-state-'+find_state+ ':visible').each(function(){var guid=$(this).data('guid');if(guid){guids.push(guid);}});if(!guids.length){elgg.register_error(elgg.echo('admin:plugins:already:'+state));return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', elgg.security.addToken(this.href));$form.append('< input type="hidden"name="guids"value="' + guids.join(',') + '"/>');$form.appendTo("body").submit();}function movePlugin(e, ui){freezePlugins();var pluginGuid=ui.item.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){var priorityDep=new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));ui.item.siblings().andSelf().each(function(){if(priorityDep.test($(this).find('.elgg-dependency-requires').text())){updatePluginView($(this));}});unfreezePlugins();}});}function updatePluginView(pluginView){var pluginGuid=pluginView.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.get({url:elgg.config.wwwroot+"ajax/view/object/plugin/full", dataType:"html", cache:false, data:{guid:pluginGuid, display_reordering:true}, success:function(htmlData){if(htmlData.length > 0){pluginView.html(htmlData);}}});}function editProfileField(value, settings){var id=$(this).attr('id');id=id.replace('elgg-profile-field-', '');var data={id:id, label:value};elgg.action('profile/fields/edit', data);return value;}function moveProfileField(e, ui){var orderArr=$('#elgg-profile-fields').sortable('toArray');var orderStr=orderArr.join(',');elgg.action('profile/fields/reorder',{fieldorder:orderStr});}function deleteNotice(e){e.preventDefault();var $container=$(this).closest('p');elgg.action($(this).attr('href'),{success:function(json){$container.slideUp('medium');}});}function simplecacheToggle(){if(!$(this).hasClass('elgg-state-disabled')){var names=['simplecache_minify_js', 'simplecache_minify_css', 'cache_symlink_enabled'];for(var i=0;i< names.length;i++){var $input=$('input[type!=hidden][name="' + names[i] + '"]');if($input.length){$input.parent().toggleClass('elgg-state-disabled');}}}}function filterPluginCategory(e){e.preventDefault();$(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");$(".elgg-plugin").hide();$(".elgg-plugin-category-"+$(this).attr("rel")).show();$(this).closest('li').addClass("elgg-state-selected");}function showPluginDetails(){$(".elgg-plugin-details-container > ul > li").removeClass("elgg-state-selected");$(".elgg-plugin-details-container > div > div").hide();$(".elgg-plugin-details-container ."+$(this).attr("rel")).show();$(this).parent().addClass("elgg-state-selected");}function showPluginScreenshot(){$(this).parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");$(this).addClass("elgg-state-selected");$(".elgg-plugin-details-screenshots > div > img").hide();$(".elgg-plugin-details-screenshots > div > img[rel='"+$(this).attr("rel")+"']").show();}init();})
 Admin-area specific javascript functions. More...
 

Function Documentation

define ( function(require){var $=require('jquery');var ui=require('jquery-ui');var elgg=require('elgg');var spinner=require('elgg/spinner');var Ajax=require('elgg/Ajax');var ajax=new Ajax();function init(){$('.elgg-system-messages li').stop(true);$(document).off('click', '.elgg-system-messages li');$(document).on('click', '.elgg-system-messages li', function(e){if(!$(e.target).is('a')){$(this).stop().slideUp('medium');}});initPluginReordering();$(".elgg-state-editable").editable(editProfileField,{type: 'text', onblur: 'submit', width: '300px', height: 'none', style: 'display:inline;'});$('#elgg-profile-fields').sortable({items: 'li', handle: 'span.elgg-state-draggable', stop:moveProfileField});$('a.elgg-admin-notice').click(deleteNotice);$(document).on('click', 'input:checkbox.elgg-state-disabled, label.elgg-state-disabled > input:checkbox', function(){return false;});$('[name=simplecache_enabled]').click(simplecacheToggle);$(document).on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);$(document).on('click', '.elgg-plugin-details-container > ul a', showPluginDetails);$(document).on('click', '.elgg-plugins-toggle', toggleAllPlugins);$(document).on('click', '.elgg-plugin-state-change', toggleSinglePlugin);$(document).on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);}function freezePlugins(){$('#elgg-plugin-list-cover').css('display', 'block');}function unfreezePlugins(){$('#elgg-plugin-list-cover').css('display', 'none');}function initPluginReordering(){$('#elgg-plugin-list > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-head', forcePlaceholderSize:true, placeholder: 'elgg-widget-placeholder', opacity:0.8, revert:500, stop:movePlugin});}function toggleSinglePlugin(e){freezePlugins();e.preventDefault();ajax.action(this.href).done(function(output, statusText, jqXHR){if(jqXHR.AjaxData.status==-1){location.reload();return;}ajax.path('admin_plugins_refresh').done(function(output){$('#elgg-plugin-list').html(output.list);$('.elgg-sidebar').html(output.sidebar);$(".elgg-admin-plugins-categories > li.elgg-state-selected > a").trigger('click');initPluginReordering();unfreezePlugins();});});}function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.echo('question:areyousure'))){return;}freezePlugins();var guids=[], state=$(this).data('desiredState'), find_state=state== 'active'? 'inactive': 'active';$('.elgg-plugin.elgg-state-'+find_state+ ':visible').each(function(){var guid=$(this).data('guid');if(guid){guids.push(guid);}});if(!guids.length){elgg.register_error(elgg.echo('admin:plugins:already:'+state));return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', elgg.security.addToken(this.href));$form.append('< input type="hidden"name="guids"value="' + guids.join(',') + '"/>');$form.appendTo("body").submit();}function movePlugin(e, ui){freezePlugins();var pluginGuid=ui.item.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){var priorityDep=new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));ui.item.siblings().andSelf().each(function(){if(priorityDep.test($(this).find('.elgg-dependency-requires').text())){updatePluginView($(this));}});unfreezePlugins();}});}function updatePluginView(pluginView){var pluginGuid=pluginView.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.get({url:elgg.config.wwwroot+"ajax/view/object/plugin/full", dataType:"html", cache:false, data:{guid:pluginGuid, display_reordering:true}, success:function(htmlData){if(htmlData.length > 0){pluginView.html(htmlData);}}});}function editProfileField(value, settings){var id=$(this).attr('id');id=id.replace('elgg-profile-field-', '');var data={id:id, label:value};elgg.action('profile/fields/edit', data);return value;}function moveProfileField(e, ui){var orderArr=$('#elgg-profile-fields').sortable('toArray');var orderStr=orderArr.join(',');elgg.action('profile/fields/reorder',{fieldorder:orderStr});}function deleteNotice(e){e.preventDefault();var $container=$(this).closest('p');elgg.action($(this).attr('href'),{success:function(json){$container.slideUp('medium');}});}function simplecacheToggle(){if(!$(this).hasClass('elgg-state-disabled')){var names=['simplecache_minify_js', 'simplecache_minify_css', 'cache_symlink_enabled'];for(var i=0;i< names.length;i++){var $input=$('input[type!=hidden][name="' + names[i] + '"]');if($input.length){$input.parent().toggleClass('elgg-state-disabled');}}}}function filterPluginCategory(e){e.preventDefault();$(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");$(".elgg-plugin").hide();$(".elgg-plugin-category-"+$(this).attr("rel")).show();$(this).closest('li').addClass("elgg-state-selected");}function showPluginDetails(){$(".elgg-plugin-details-container > ul > li").removeClass("elgg-state-selected");$(".elgg-plugin-details-container > div > div").hide();$(".elgg-plugin-details-container ."+$(this).attr("rel")).show();$(this).parent().addClass("elgg-state-selected");}function showPluginScreenshot(){$(this).parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");$(this).addClass("elgg-state-selected");$(".elgg-plugin-details-screenshots > div > img").hide();$(".elgg-plugin-details-screenshots > div > img[rel='"+$(this).attr("rel")+"']").show();}init();}  )

Admin-area specific javascript functions.

Since
1.8
Parameters
function(require){var$=require('jquery');var ui=require('jquery-ui');var elgg=require('elgg');var spinner=require('elgg/spinner');var Ajax=require('elgg/Ajax');var ajax=new Ajax();function init(){$('.elgg-system-messages li').stop(true);.off('click', '.elgg-system-messages li');.on('click', '.elgg-system-messages li', function(e){if(!$(e.target).is('a')){.stop().slideUp('medium');}});initPluginReordering();$(".elgg-state-editable").editable(editProfileField,{type: 'text', onblur: 'submit', width: '300px', height: 'none', style: 'display:inline;'});$('elgg-profile-fields').sortable({items: 'li', handle: 'span.elgg-state-draggable', stop:moveProfileField});$('a.elgg-admin-notice').click(deleteNotice);.on('click', 'input:checkbox.elgg-state-disabled, label.elgg-state-disabled > input:checkbox', function(){return false;});$('[name=simplecache_enabled]').click(simplecacheToggle);.on('click', '.elgg-admin-plugins-categories a', filterPluginCategory);.on('click', '.elgg-plugin-details-container > ul a', showPluginDetails);.on('click', '.elgg-plugins-toggle', toggleAllPlugins);.on('click', '.elgg-plugin-state-change', toggleSinglePlugin);.on('mouseenter', '.elgg-plugin-details-screenshots.elgg-plugin-screenshot', showPluginScreenshot);}function freezePlugins(){$('elgg-plugin-list-cover').css('display', 'block');}function unfreezePlugins(){$('elgg-plugin-list-cover').css('display', 'none');}function initPluginReordering(){$('elgg-plugin-list > ul').sortable({items: 'li:has(>.elgg-state-draggable)', handle: '.elgg-head', forcePlaceholderSize:true, placeholder: 'elgg-widget-placeholder', opacity:0.8, revert:500, stop:movePlugin});}function toggleSinglePlugin(e){freezePlugins();e.preventDefault();ajax.action(this.href).done(function(output, statusText, jqXHR){if(jqXHR.AjaxData.status==-1){location.reload();return;}ajax.path('admin_plugins_refresh').done(function(output){$('elgg-plugin-list').html(output.list);$('.elgg-sidebar').html(output.sidebar);$(".elgg-admin-plugins-categories > li.elgg-state-selected > a").trigger('click');initPluginReordering();unfreezePlugins();});});}function toggleAllPlugins(e){e.preventDefault();if(!confirm(elgg.echo('question:areyousure'))){return;}freezePlugins();var guids=[], state=.data('desiredState'), find_state=state== 'active'? 'inactive': 'active';$('.elgg-plugin.elgg-state-'+find_state+ ':visible').each(function(){var guid=.data('guid');if(guid){guids.push(guid);}});if(!guids.length){elgg.register_error(elgg.echo('admin:plugins:already:'+state));return;}spinner.start();var $form=$('< form method="post"/>');$form.prop('action', elgg.security.addToken(this.href));$form.append('< input type="hidden"name="guids"value="' + guids.join(',') + '"/>');$form.appendTo("body").submit();}function movePlugin(e, ui){freezePlugins();var pluginGuid=ui.item.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.action('admin/plugins/set_priority',{data:{plugin_guid:pluginGuid, priority:ui.item.index()+1}, success:function(){var priorityDep=new RegExp(elgg.echo('ElggPlugin:Dependencies:Priority'));ui.item.siblings().andSelf().each(function(){if(priorityDep.test(.find('.elgg-dependency-requires').text())){updatePluginView();}});unfreezePlugins();}});}function updatePluginView(pluginView){var pluginGuid=pluginView.attr('id');pluginGuid=pluginGuid.replace('elgg-object-', '');elgg.get({url:elgg.config.wwwroot+"ajax/view/object/plugin/full", dataType:"html", cache:false, data:{guid:pluginGuid, display_reordering:true}, success:function(htmlData){if(htmlData.length > 0){pluginView.html(htmlData);}}});}function editProfileField(value, settings){var id=.attr('id');id=id.replace('elgg-profile-field-', '');var data={id:id, label:value};elgg.action('profile/fields/edit', data);return value;}function moveProfileField(e, ui){var orderArr=$('elgg-profile-fields').sortable('toArray');var orderStr=orderArr.join(',');elgg.action('profile/fields/reorder',{fieldorder:orderStr});}function deleteNotice(e){e.preventDefault();var $container=.closest('p');elgg.action(.attr('href'),{success:function(json){$container.slideUp('medium');}});}function simplecacheToggle(){if(!.hasClass('elgg-state-disabled')){var names=['simplecache_minify_js', 'simplecache_minify_css', 'cache_symlink_enabled'];for(var i=0;i< names.length;i++){var $input=$('input[type!=hidden][name="' + names[i] + '"]');if($input.length){$input.parent().toggleClass('elgg-state-disabled');}}}}function filterPluginCategory(e){e.preventDefault();$(".elgg-admin-plugins-categories > li").removeClass("elgg-state-selected");$(".elgg-plugin").hide();$(".elgg-plugin-category-"+.attr("rel")).show();.closest('li').addClass("elgg-state-selected");}function showPluginDetails(){$(".elgg-plugin-details-container > ul > li").removeClass("elgg-state-selected");$(".elgg-plugin-details-container > div > div").hide();$(".elgg-plugin-details-container ."+.attr("rel")).show();.parent().addClass("elgg-state-selected");}function showPluginScreenshot(){.parent().find(".elgg-plugin-screenshot").removeClass("elgg-state-selected");.addClass("elgg-state-selected");$(".elgg-plugin-details-screenshots > div > img").hide();$(".elgg-plugin-details-screenshots > div > img[rel='"+.attr("rel")+"']").show();}init();} Active or deactivate all the visible plugins
{Event}e click event
Returns
void

Save the plugin order after a move event.

Parameters
{Object}e Event object.
{Object}ui jQueryUI object
Returns
void

Update the plugin view.

Parameters
{Object}pluginView Plugin view element to update
Returns
void

In-line editing for custom profile fields

Parameters
{String}value The new value
{Object}settings The settings used for editable
Returns
void

Save the plugin profile order after a move event.

Parameters
{Object}e Event object.
{Object}ui jQueryUI object
Returns
void

Fires the ajax action to delete the admin notice then hides the notice.

Returns
void

Toggles the display of the compression settings for simplecache

Returns
void

Filters the plugin list based on a selected category

Returns
void

Shows the details of the selected plugin

Returns
void

Handles mouseenters to show plugin screenshots

Returns
void