3 * Copyright © 2014 Free Software Foundation, Inc.
5 * This file is a part of FSF Member Dashboard.
7 * FSF Member Dashboard is free software; you can copy, modify, and
8 * distribute it under the terms of the GNU Affero General Public
9 * License Version 3, 19 November 2007 and the CiviCRM Licensing
12 * FSF Member Dashboard is distributed in the hope that it will be
13 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with FSF Member Dashboard. If not, see
19 * <http://www.gnu.org/licenses/>.
23 function loadProfile(gid
, success
) {
24 $.get('/civicrm/profile/edit', {
30 function renderProfile(profile
) {
31 function renderFields() {
32 return _
.chain(profile
)
34 .filter(function(field
) {
35 return _
.isString(field
.label
) && _
.isString(field
.html
);
37 .map(function (field
) {
38 return $('<div class="crm-section"></div>')
39 .append($('<div class="form-item"></div>')
40 .append($('<div class="label"></div>')
42 .append($('<div class="content"></div>')
44 .append($('<div class="clear"></div>')));
49 // Support older versions of jQuery that don't parse the JSON by
51 profile
= _
.isString(profile
) ? JSON
.parse(profile
): profile
;
52 var form
= $('<form' + profile
.attributes
+ '></form>');
54 form
.append(profile
.requirednote
)
55 .append(profile
.hidden
)
56 .append
.apply(form
, renderFields());
58 $('#info-loading').remove();
59 $('#info-form').append(form
);
62 $(document
).ready(function() {
63 loadProfile(memberDashboard
.profileId
, renderProfile
);