AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
authorDan
Sun, 07 Oct 2007 16:56:14 -0400
changeset 171 1465f48faba0
parent 170 4c5c2b66a34d
child 172 1bc7e849a264
AJAX login box is now used in userprefs panel; Spry shake effect and general UX on auth fail is smoother now; added ajaxLoginNavTo() JS function
includes/clientside/static/ajax.js
includes/clientside/static/misc.js
plugins/SpecialUserPrefs.php
--- a/includes/clientside/static/ajax.js	Sun Oct 07 08:39:40 2007 -0400
+++ b/includes/clientside/static/ajax.js	Sun Oct 07 16:56:14 2007 -0400
@@ -822,6 +822,33 @@
   window.location = loc;
 }
 
+var navto_ns;
+var navto_pg;
+var navto_ul;
+
+function ajaxLoginNavTo(namespace, page_id, min_level)
+{
+  // IE <6 pseudo-compatibility
+  if ( KILL_SWITCH )
+    return true;
+  navto_pg = page_id;
+  navto_ns = namespace;
+  navto_ul = min_level;
+  if ( auth_level < min_level )
+  {
+    ajaxPromptAdminAuth(function(k) {
+      ENANO_SID = k;
+      auth_level = navto_ul;
+      var loc = makeUrlNS(navto_ns, navto_pg);
+      if ( (ENANO_SID + ' ').length > 1 )
+        window.location = loc;
+    }, min_level);
+    return false;
+  }
+  var loc = makeUrlNS(navto_ns, navto_pg);
+  window.location = loc;
+}
+
 function ajaxAdminUser(username)
 {
   // IE <6 pseudo-compatibility
--- a/includes/clientside/static/misc.js	Sun Oct 07 08:39:40 2007 -0400
+++ b/includes/clientside/static/misc.js	Sun Oct 07 16:56:14 2007 -0400
@@ -499,8 +499,8 @@
               ajax_auth_error_string = response.error;
               mb_current_obj.updateContent('');
               document.getElementById('messageBox').style.backgroundColor = '#C0C0C0';
-              new Spry.Effect.Shake('messageBox', {duration: 1500}).start();
-              new Spry.Effect.Shake('messageBoxButtons', {duration: 1500}).start();
+              var mb_parent = document.getElementById('messageBox').parentNode;
+              new Spry.Effect.Shake(mb_parent, {duration: 1500}).start();
               setTimeout("document.getElementById('messageBox').style.backgroundColor = '#FFF'; ajaxAuthLoginInnerSetup();", 2500);
             }
             else
--- a/plugins/SpecialUserPrefs.php	Sun Oct 07 08:39:40 2007 -0400
+++ b/plugins/SpecialUserPrefs.php	Sun Oct 07 16:56:14 2007 -0400
@@ -100,7 +100,7 @@
   global $db, $session, $paths, $template, $plugins; // Common objects
   global $userprefs_menu_links;
   
-  userprefs_menu_add('Profile/membership', 'Edit e-mail address and password', makeUrlNS('Special', 'Preferences/EmailPassword'));
+  userprefs_menu_add('Profile/membership', 'Edit e-mail address and password', makeUrlNS('Special', 'Preferences/EmailPassword') . '" onclick="ajaxLoginNavTo(\'Special\', \'Preferences/EmailPassword\', '.USER_LEVEL_CHPREF.'); return false;');
   userprefs_menu_add('Profile/membership', 'Edit signature', makeUrlNS('Special', 'Preferences/Signature'));
   userprefs_menu_add('Profile/membership', 'Edit public profile', makeUrlNS('Special', 'Preferences/Profile'));
   userprefs_menu_add('Private messages', 'Inbox', makeUrlNS('Special', 'PrivateMessages/Folder/Inbox'));
@@ -302,11 +302,14 @@
   {
     case 'Home':
       global $email;
-      $user_page = '<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '">user page</a> <sup>(<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '#do:comments">comments</a>)</sup>';
+      $userpage_id = $paths->nslist['User'] . sanitize_page_id($session->username);
+      $userpage_exists = ( isPage($userpage_id) ) ? '' : ' class="wikilink-nonexistent"';
+      $user_page = '<a href="' . makeUrlNS('User', sanitize_page_id($session->username)) . '"' . $userpage_exists . '>user page</a> <sup>(<a href="' . makeUrlNS('User', str_replace(' ', '_', $session->username)) . '#do:comments">comments</a>)</sup>';
       $site_admin = $email->encryptEmail(getConfig('contact_email'), '', '', 'administrator');
+      $make_one_now = '<a href="' . makeUrlNS('User', sanitize_page_id($session->username)) . '">make one now</a>';
       echo "<h3 style='margin-top: 0;'>$session->username, welcome to your control panel</h3>";
       echo "<p>Here you can make changes to your profile, view statistics on yourself on this site, and set your preferences.</p>
-            <p>If you have not already done so, you are encouraged to make a $user_page and tell the other members of this site a little about yourself.</p>
+            <p>Your $user_page is your free writing space. You can use it to tell the other members of this site a little bit about yourself. If you haven't already made a user page, why not $make_one_now?</p>
             <p>Use the menu at the top to navigate around. If you have any questions, you may contact the $site_admin.";
       break;
     case 'EmailPassword':