From ea28c2c55c689be25a2212dfbdffd840c88921aa Mon Sep 17 00:00:00 2001 From: brettp Date: Mon, 7 Feb 2011 05:10:11 +0000 Subject: Pulled elgg-icon and elgg-icon-* into the admin css. Pulled out profile field JS into elgg.admin obj. Fixed editing profile field names. git-svn-id: http://code.elgg.org/elgg/trunk@8061 36083f99-b078-4883-b0ff-0f9b5a30f544 --- views/default/js/admin.php | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'views/default/js') diff --git a/views/default/js/admin.php b/views/default/js/admin.php index 46e82c71b..ca690c876 100644 --- a/views/default/js/admin.php +++ b/views/default/js/admin.php @@ -13,6 +13,7 @@ elgg.admin.init = function () { elgg_slide_toggle($(this), '.plugin_details', '.manifest_file'); }); + // plugin screenshot modal $('.elgg-plugin-screenshot a').click(elgg.admin.displayPluginScreenshot); // draggable plugin reordering @@ -25,6 +26,22 @@ elgg.admin.init = function () { revert: 500, stop: elgg.admin.movePlugin }); + + // in-line editing for custom profile fields. + $(".elgg-state-editable").editable(elgg.admin.editProfileField, { + type: 'text', + onblur: 'submit', + width: '300px', + height: 'none', + style: 'display:inline;' + }); + + // draggable profile field reordering. + $('#sortable_profile_fields').sortable({ + items: 'li', + handle: 'span.elgg-state-draggable', + stop: elgg.admin.moveProfileField + }); } /** @@ -90,4 +107,40 @@ elgg.admin.displayPluginScreenshot = function(e) { lb.css('top', top_pos).css('left', left_pos).show(); }; +/** + * In-line editing for custom profile fields + * + * @param string value The new value + * @param {Object} settings The settings used for editable + * @return void + */ +elgg.admin.editProfileField = function(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; +} + +/** + * Save the plugin profile order after a move event. + * + * @param {Object} e Event object. + * @param {Object} ui jQueryUI object + * @return void + */ +elgg.admin.moveProfileField = function(e, ui) { + var orderArr = $('#sortable_profile_fields').sortable('toArray'); + var orderStr = orderArr.join(','); + + elgg.action('profile/fields/reorder', { + fieldorder: orderStr + }); +} + elgg.register_event_handler('init', 'system', elgg.admin.init); \ No newline at end of file -- cgit v1.2.3