info: Improve appearance of rendered profile even more.
[org.fsf.memberdashboard.git] / assets / js / member-info.js
index e6e8b05b93df68231e68c9398328aff88da9f4ba..aaf093707c4171de73c463be616acfe4ef1f98d4 100644 (file)
@@ -21,7 +21,7 @@
 
 (function($) {
   function loadProfile(gid, success) {
-    $.get('/drupal/civicrm/profile/edit', {
+    $.get('/civicrm/profile/edit', {
       gid: gid,
       json: 1
     }, success);
           return _.isString(field.label) && _.isString(field.html);
         })
         .map(function (field) {
-          return $('<div></div>')
-            .append(field.label)
-            .append(field.html);
+          return $('<div class="crm-section"></div>')
+            .append($('<div class="form-item"></div>')
+                    .append($('<div class="label"></div>')
+                            .append(field.label))
+                    .append($('<div class="content"></div>')
+                            .append(field.html))
+                    .append($('<div class="clear"></div>')));
         })
         .value();
     }
 
+    // Support older versions of jQuery that don't parse the JSON by
+    // default.
+    profile = _.isString(profile) ? JSON.parse(profile): profile;
     var form = $('<form' + profile.attributes + '></form>');
 
     form.append(profile.requirednote)
       .append(profile.hidden)
       .append.apply(form, renderFields());
 
-    $('#crm-main-content-wrapper').append(form);
+    $('#info-loading').remove();
+    $('#info-form').append(form);
   }
 
   $(document).ready(function() {
-    loadProfile(memberDashboard.profile_id, renderProfile);
+    loadProfile(memberDashboard.profileId, renderProfile);
   });
 })(jQuery);