Polished up inline rename in oxygen (todo: make this script shared/core?)
authorDan
Wed, 19 Nov 2008 11:37:45 -0500
changeset 744 fcaae08f41a2
parent 743 0acb5d0f8328
child 745 0a3866f74faa
Polished up inline rename in oxygen (todo: make this script shared/core?)
themes/oxygen/header.tpl
--- a/themes/oxygen/header.tpl	Wed Nov 19 11:37:10 2008 -0500
+++ b/themes/oxygen/header.tpl	Wed Nov 19 11:37:45 2008 -0500
@@ -89,6 +89,10 @@
         textbox.onkeyup = function(e) { if(!e) return; if(e.keyCode == 13) ajaxRenameInlineSave(); if(e.keyCode == 27) ajaxRenameInlineCancel(); };
         elem.parentNode.insertBefore(textbox, elem);
         document.onclick = ajaxRenameInlineCancel;
+        
+        load_component('l10n');
+        load_component('fadefilter');
+        load_component('messagebox');
       }
       function ajaxRenameInlineSave()
       {
@@ -102,8 +106,23 @@
         elem1.style.display = 'block';
         if(!value || value=='') return;
         ajaxPost(stdAjaxPrefix+'&_mode=rename', 'newtitle='+ajaxEscape(value), function() {
-          if(ajax.readyState == 4) {
-            alert(ajax.responseText);
+          if ( ajax.readyState == 4 )
+          {
+            var response = String(ajax.responseText);
+            if ( !check_json_response(response) )
+            {
+              handle_invalid_json(response);
+              return false;
+            }
+            response = parseJSON(response);
+            if ( response.success )
+            {
+              new MessageBox( MB_OK|MB_ICONINFORMATION, $lang.get('ajax_rename_success_title'), $lang.get('ajax_rename_success_body', { page_name_new: value }) );
+            }
+            else
+            {
+              alert(response.error);
+            }
           }
         });
       }