aboutsummaryrefslogtreecommitdiff
path: root/views/default/js
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-07 02:15:11 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-07 02:15:11 +0000
commitcb5ecaff25b858117a57ede78f353661a520c9d4 (patch)
tree205600b0f86ad858086250402bf5ca2a44b9367e /views/default/js
parent31ad8156b107894e238f4f53ec174aa8a4c30aa4 (diff)
downloadelgg-cb5ecaff25b858117a57ede78f353661a520c9d4.tar.gz
elgg-cb5ecaff25b858117a57ede78f353661a520c9d4.tar.bz2
Added drag and drop reordering of plugins. Started pulling out admin area's js into elgg.admin JS object.
git-svn-id: http://code.elgg.org/elgg/trunk@8056 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/js')
-rw-r--r--views/default/js/admin.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/views/default/js/admin.php b/views/default/js/admin.php
new file mode 100644
index 000000000..46e82c71b
--- /dev/null
+++ b/views/default/js/admin.php
@@ -0,0 +1,93 @@
+<?php
+/**
+ * Admin-area specific javascript functions.
+ *
+ * @since 1.8
+ */
+?>
+elgg.provide('elgg.admin');
+
+elgg.admin.init = function () {
+ // display manifest info
+ $('a.manifest_details.link').click(function() {
+ elgg_slide_toggle($(this), '.plugin_details', '.manifest_file');
+ });
+
+ $('.elgg-plugin-screenshot a').click(elgg.admin.displayPluginScreenshot);
+
+ // draggable plugin reordering
+ $('#elgg-plugin-list').sortable({
+ items: 'div.elgg-state-draggable',
+ handle: 'h3.elgg-head',
+ forcePlaceholderSize: true,
+ placeholder: 'elgg-widget-placeholder',
+ opacity: 0.8,
+ revert: 500,
+ stop: elgg.admin.movePlugin
+ });
+}
+
+/**
+ * Save the plugin order after a move event.
+ *
+ * @param {Object} e Event object.
+ * @param {Object} ui jQueryUI object
+ * @return void
+ */
+elgg.admin.movePlugin = function(e, ui) {
+ // get guid from id like elgg-plugin-<guid>
+ var pluginGuid = ui.item.closest('.plugin_details').attr('id');
+ pluginGuid = pluginGuid.replace('elgg-plugin-', '');
+
+ elgg.action('admin/plugins/set_priority', {
+ data: {
+ plugin_guid: pluginGuid,
+ // we start at priority 1
+ priority: ui.item.index() + 1
+ }
+ });
+};
+
+/**
+ * Display a plugin screenshot.
+ *
+ * @param {Object} e The event object.
+ * @return void
+ */
+elgg.admin.displayPluginScreenshot = function(e) {
+ e.preventDefault();
+ var lb = $('.elgg-plugin-screenshot-lightbox');
+
+ if (lb.length < 1) {
+ $('body').append('<div class="elgg-plugin-screenshot-lightbox"></div>');
+ lb = $('.elgg-plugin-screenshot-lightbox');
+
+ lb.click(function() {
+ lb.hide();
+ });
+
+ $(document).click(function(e) {
+ var target = $(e.target);
+ if (target.is('a') && target.hasClass('elgg-plugin-screenshot-lightbox')) {
+ lb.hide();
+ e.preventDefault();
+ }
+ });
+ }
+
+ var html = '<img class="pas" src="' + $(this).attr('href') + '">';
+ var desc = $(this).find('img').attr('alt');
+
+ if (desc) {
+ html = '<h2 class="pam">' + desc + '</h2>' + html;
+ }
+
+ lb.html(html);
+
+ top_pos = $(window).scrollTop() + 10 + 'px';
+ left_pos = $(window).scrollLeft() + 5 + 'px';
+
+ lb.css('top', top_pos).css('left', left_pos).show();
+};
+
+elgg.register_event_handler('init', 'system', elgg.admin.init); \ No newline at end of file