25094987011a26629d61bd60ffc8da1a6d362929
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

1) refresh_group_list=function() {
2)   grouplist=$('#group-choice')[0];
3)   $('a.group-choice').each(function(idx,a) {
4)     $(a).parent().remove();
5)   });
6) 
7)   if (groups.count()==0) {
8)     $(grouplist).prepend('<li><a class="group-choice">Aucune groupe</a></li>');
9)   }
10)   else { 
11)     groups.each(function(idx,group) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

12)       $(grouplist).prepend('<li><a class="group-choice" data-uuid="'+group.uuid+'">'+group.name+'</a></li>');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

13)     });
14) 
15)     $('a.group-choice').each(function(idx,a) {
16)       $(a).bind('click',on_group_choice_click);
17)     });
18)   }
19) }
20) 
21) 
22) /****************
23)  * Add group
24)  ****************/
Benjamin Renard Hide navbar-groupe-collapse...

Benjamin Renard authored 10 years ago

25) 
26) on_click_add_group_btn=function(e) {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

27)   navbar_collapse_hide();
Benjamin Renard Hide navbar-groupe-collapse...

Benjamin Renard authored 10 years ago

28)   $('#add_group_modal').modal('show');
29) }
30) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

31) on_show_add_group_modal=function(e) {
32)   $('#add_group_modal #add_group_name').focus();
33) }
34) 
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

35) on_valid_add_group_modal=function (e) {
36)   e.preventDefault();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

37)   var name=$('#add_group_name')[0].value;
38)   if (name=='') {
39)     alert('Vous devez saisir un nom !');
40)     return;
41)   }
42)   if (groups[name]!==undefined) {
43)     alert('Ce groupe exite déjà !');
44)     return;
45)   }
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

46)   var uuid=groups.newGroup(name);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

47)   refresh_group_list();
48)   $('#add_group_modal').modal('hide');
49)   groups.save();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

50)   view_group(groups[uuid]);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

51) }
52) 
53) on_close_add_group_modal=function () {
Benjamin Renard Fix error on add_group_moda...

Benjamin Renard authored 10 years ago

54)   $('#add_group_modal form')[0].reset();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

55) }
56) 
57) /****************
58)  * Nav bars
59)  ****************/
60) on_group_choice_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

61)   view_group(groups[$(e.target).data('uuid')]);
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

62)   navbar_collapse_hide();
63) }
64) 
65) navbar_collapse_hide=function() {
66)   if ($('#navbar-groupe-collapse').hasClass('in')) {
67)     $('#navbar-groupe-collapse').collapse('hide');
68)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

69) }
70) 
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

71) /****************
72)  * Parts
73)  ****************/
74) 
75) view_part=function(part) {
76)   $('.part').each(function(idx,div) {
77)     $(div).css('display','none');
78)   });
79)   $(part).css('display','block');
80) }
81) 
82) view_home=function() {
Benjamin Renard Hide navbar on view_home

Benjamin Renard authored 10 years ago

83)   navbar_collapse_hide();
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

84)   if (user) {
85)     $('#view-home #title').html('Bonjour '+user.name);
86)   }
87)   else {
88)     $('#view-home #title').html('Bonjour');
89)   }
90)   if (groups.count()>0) {
91)     tbody=$('#view-home #mybalances tbody');
92)     tbody.html('');
93)     balances=groups.balances();
94)     var sum=0;
95)     for (g in balances) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

96)       if (jQuery.type(balances[g]['balance'][user.email])!='undefined') {
97)         if (balances[g]['balance'][user.email]['diff']<0) {
98)           sum+=balances[g]['balance'][user.email]['diff'];
99)           diff='<td class="negative">'+balances[g]['balance'][user.email]['diff'].toFixed(2)+'</td>';
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

100)         }
101)         else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

102)           value=balances[g]['balance'][user.email]['total']-balances[g]['min'];
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

103)           sum+=value;
104)           diff='<td class="positive">+'+value.toFixed(2)+' €</td>';
105)         }
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

106)         menu='<div class="btn-group" data-grp="'+g+'"><button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="glyphicon glyphicon-cog"></span></button><ul class="dropdown-menu"><li><a class="home_grp_cat_btn"><span class="glyphicon glyphicon-th-list"></span> Catégories</a></li></ul></div>';
107)         tbody.html(tbody.html()+'<tr><td><a class="group-link" data-uuid="'+g+'">'+balances[g].name+'</a></td>'+diff+'<td>'+menu+'</td></tr>');
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

108)       }
109)     }
Benjamin Renard Make group name as link in...

Benjamin Renard authored 10 years ago

110)     $('#view-home #mybalances a.group-link').bind('click',function(e) {
Benjamin Renard Fixed link to group in Home...

Benjamin Renard authored 10 years ago

111)       g=$(e.target).data('uuid');
Benjamin Renard Make group name as link in...

Benjamin Renard authored 10 years ago

112)       if (jQuery.type(groups[g])!='undefined') {
113)         view_group(groups[g]);
114)       }
115)     });
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

116)     $('a.home_grp_cat_btn').each(function(idx,a) {
117)       $(a).bind('click',on_home_grp_cat_btn_click);
118)     });
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

119)     if (sum<0) {
120)       $('#view-home #mybalances #total-value').html('<span class="negative">'+sum.toFixed(2)+' €</span>');
121)     }
122)     else {
123)       $('#view-home #mybalances #total-value').html('<span class="positive">'+(sum==0?'':'+')+sum.toFixed(2)+' €</span>');
124)     }
Benjamin Renard Fixed table display on home...

Benjamin Renard authored 10 years ago

125)     $('#view-home #mybalances').css('display','table');
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

126)   }
127)   else {
128)     $('#view-home #mybalances').css('display','none');
129)   }
130)   view_part('#view-home');
131) }
132) 
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

133) on_home_grp_cat_btn_click=function(e) {
134)   grp_id=$(e.target).parents('div.btn-group').data('grp');
135)   grp=groups[grp_id];
136)   ul=$('#grp_cat_modal ul');
137)   html="";
Benjamin Renard Improve category selection

Benjamin Renard authored 10 years ago

138)   for(cid in grp.getSortedCategories()) {
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

139)     html+="<li><span class='cat-color' style='background-color: "+grp.categories[cid]['color']+"'></span> "+grp.categories[cid]['name']+"</li>";
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

140)   }
141)   ul.html(html);
142)   $('#grp_cat_modal').modal('show');
143) }
144) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

145) /****************
146)  * View group
147)  ****************/
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

148) view_group=function(group,contributor_email) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

149)   $('#view-group').data('uuid',group.uuid);
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

150)   $('#view-group .group-title:first').html(group.name);
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

151)   set_contributors(group,contributor_email);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

152)   on_contributor_change();
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

153)   view_part('#view-group');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

154) }
155) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

156) set_contributors=function(group,contributor_email) {
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

157)   $('#view-group #contributor option').remove();
158)   if(group.contributors.length==0) {
159)     $('#view-group #contributor').append('<option>Aucun participant</option>');
160)   }
161)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

162)     for (email in group.contributors) {
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

163)       if (email == contributor_email) {
164)         sel=' selected';
165)       }
166)       else {
167)         sel='';
168)       }
169)       $('#view-group #contributor').append('<option value="'+email+'"'+sel+'>'+group.contributors[email].name+'</option>');
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

170)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

171)   }
172) }
173) 
174) on_contributor_change=function(e) {
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

175) 	if ($('#group-navbar-collapse-1').hasClass('in')) {
176) 		$('#group-navbar-collapse-1').collapse('hide');
177) 	}
178) 	$('#view-group #group-username').html($('#view-group #contributor option:selected').text());
179) 	show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

180) }
181) 
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

182) show_contributions=function(group,contributor_email) {
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

183)   var tbody=$($('#view-group #contributions tbody')[0]);
184)   tbody.html('');
185)   total=$($('#view-group #total-value')[0]);
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

186)   contributions=group.contributionsByContributorEmail(contributor_email);
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

187)   contributions.reverse();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

188)   if (contributions.length==0) {
189)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
190)     total.html('0,00 €');
191)   }
192)   else {
193)     sum=0;
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

194)     for (idx in contributions) {
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

195)       var cat='';
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

196)       if (contributions[idx].category && jQuery.type(group.categories[contributions[idx].category])) {
197) 		cat='<br/><span class="category"><span class="cat-color" style="background-color: '+group.categories[contributions[idx].category]['color']+'"></span> '+group.categories[contributions[idx].category]['name']+"</span>";
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

198) 	  }
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

199)       col_actions='<td><div class="btn-group" data-uuid="'+contributions[idx].uuid+'"><button type="button" class="btn btn-default btn-sm contribution_edit_btn"><span class="glyphicon glyphicon-edit"></span></button><button type="button" class="btn btn-default btn-sm contribution_delete_btn"><span class="glyphicon glyphicon-trash"></span></button></div></td>';
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

200)       tbody.append('<tr><td>'+contributions[idx].getTitle()+cat+'</td><td>'+contributions[idx].cost.toFixed(2)+' €<br/><span class="date">'+moment(contributions[idx].date).format('DD/MM/YYYY')+'</span></td>'+col_actions+'</tr>');
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

201)       sum+=contributions[idx].cost;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

202)     }
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

203)     total.html(sum.toFixed(2)+' €');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

204)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

205)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

206)   $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
207)   $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
208) }
209) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

210) /*****************************
211)  * Trash
212)  *****************************/
213) 
214) on_trash_group_btn_click=function(e) {
215)   group=groups[$('#view-group').data('uuid')];
216)   contributor_email=$('#view-group #contributor')[0].value;
217)   view_group_trash(group,contributor_email);
218) }
219) 
220) on_go_back_group_btn_click=function(e) {
221)   group=groups[$('#view-group-trash').data('uuid')];
222)   contributor_email=$('#view-group-trash').data('contributor-email');
223)   view_group(group,contributor_email);
224) }
225) 
226) view_group_trash=function(group,contributor_email) {
227)   $('#view-group-trash').data('uuid',group.uuid);
228)   $('#view-group-trash').data('contributor-email',contributor_email);
229)   var tbody=$('#view-group-trash #trash tbody');
230)   tbody.html('');
231)   contributions=group.deletedContributionsByContributorEmail(contributor_email);
232)   contributions.reverse();
233)   if (contributions.length==0) {
234)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
235)   }
236)   else {
237)     for (idx in contributions) {
238)       tbody.append('<tr data-uuid="'+contributions[idx].uuid+'"><td>'+contributions[idx].getTitle()+'</td><td>'+contributions[idx].cost.toFixed(2)+' €<br/><span class="date">'+moment(contributions[idx].date).format('DD/MM/YYYY')+'</span></td><td><button type="button" class="btn btn-default contribution_restore_btn"><span class="glyphicon glyphicon-share"></span></button></td></tr>');
239)     }
240)   }
241)   
242)   $('#view-group-trash .contribution_restore_btn').bind('click',on_contribution_restore_btn_click);
243)  
244)   view_part('#view-group-trash');
245) }
246) 
247) on_contribution_restore_btn_click=function(e) {
248)   var group=groups[$('#view-group-trash').data('uuid')];
249)   contribution_uuid=$($(e.target).parents('tr')[0]).data('uuid');
250)   contribution=group.importContribution(group.deletedContributions[contribution_uuid]);
251)   myconfirm('Etes-vous sûre de vouloir restaurer la participation '+contribution.getTitle()+' de '+contribution.contributor.name+' ?',on_confirm_contribution_restore,null,{'group':group,'contribution_uuid':contribution_uuid, 'contribution': contribution} );
252) }
253) 
254) on_confirm_contribution_restore=function(data) {
255)   data.group.restoreContribution(data.contribution_uuid);
256)   groups.save();
257)   view_group(data.group,data.contribution.contributor.email);
258) }
259) 
Benjamin Renard Manage group contributors t...

Benjamin Renard authored 10 years ago

260) on_trash_group_contributors_btn_click=function(e) {
261)   group=groups[$('#view-group').data('uuid')];
262)   view_group_trash_contributors(group);
263) }
264) 
265) on_go_back_group_trash_contributors_btn_click=function(e) {
266)   group=groups[$('#view-group-trash-contributors').data('uuid')];
267)   view_group(group);
268) }
269) 
270) view_group_trash_contributors=function(group) {
271)   $('#view-group-trash-contributors').data('uuid',group.uuid);
272)   var tbody=$('#view-group-trash-contributors #trash tbody');
273)   tbody.html('');
274)   contributors=group.getDeletedContributors();
275)   if (contributors.length==0) {
276)     tbody.append('<tr><td colspan=3>Aucun participant</td></tr>');
277)   }
278)   else {
279)     for (idx in contributors) {
280)       tbody.append('<tr data-email="'+contributors[idx].email+'"><td>'+contributors[idx].name+'</td><td><button type="button" class="btn btn-default contributor_restore_btn"><span class="glyphicon glyphicon-share"></span></button></td></tr>');
281)     }
282)   }
283) 
284)   $('#view-group-trash-contributors .contributor_restore_btn').bind('click',on_contributor_restore_btn_click);
285) 
286)   view_part('#view-group-trash-contributors');
287) }
288) 
289) on_contributor_restore_btn_click=function(e) {
290)   var group=groups[$('#view-group-trash-contributors').data('uuid')];
291)   contributor_email=$($(e.target).parents('tr')[0]).data('email');
292)   contributor=group.importContributor(group.deletedContributors[contributor_email]);
293)   myconfirm('Etes-vous sûre de vouloir restaurer '+contributor.name+' ?',on_confirm_contributor_restore,null,{'group':group,'contributor_email':contributor_email, 'contributor': contributor} );
294) }
295) 
296) on_confirm_contributor_restore=function(data) {
297)   data.group.restoreContributor(data.contributor_email);
298)   groups.save();
299)   view_group(data.group,data.contributor_email);
300) }
301) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

302) /******************************
303)  * Add/Edit/remove contributor
304)  ******************************/
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

305) on_click_add_contributor_btn=function() {
Benjamin Renard Fixed add contributor

Benjamin Renard authored 10 years ago

306)   $('#add_contributor_modal').data('group-uuid',$('#view-group').data('uuid'))
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

307)   $($('#add_contributor_modal h4')[0]).html('Ajouter un participant');
308)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Ajouter');
309)   $('#view-group #edit_id')[0].value='-1';
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

310)   $('#add_contributor_modal #add_contributor_email').attr('disabled',false);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

311)   $('#add_contributor_modal').modal('show');
312) }
313) 
314) on_show_add_contributor_modal=function(e) {
315)   $('#add_contributor_modal #add_contributor_name').focus();
316) }
317) 
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

318) validateEmail=function(email) {
319)     var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
320)     return re.test(email);
321) }
322) 
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

323) on_valid_add_contributor_modal=function(e) {
324)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

325)   var group=groups[$('#add_contributor_modal').data('group-uuid')];
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

326)   var name=$('#add_contributor_name')[0].value;
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

327)   edit_id=$('#view-group #edit_id')[0].value;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

328)   if (name=='') {
329)     alert('Vous devez saisir un nom !');
330)     return;
331)   }
332)   var email=$('#add_contributor_email')[0].value;
333)   if (email=='') {
334)     alert('Vous devez saisir un email !');
335)     return;
336)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

337)   duplicate=group.contributorByEmail(email)
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

338)   if (duplicate!=undefined && edit=='-1') {
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

339)     alert('Un contributor utilise déjà cet email !');
340)     return;
341)   }
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

342)   if (!validateEmail(email)) {
343)     alert('Email invalide !');
344)     return;
345)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

346)   if(edit_id=='-1') {
347)     group.addContributor(new Contributor(name,email));
348)   }
349)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

350)     group.replaceContributor(email,new Contributor(name,email));
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

351)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

352)   set_contributors(group);
353)   $('#add_contributor_modal').modal('hide');
354)   groups.save();
Benjamin Renard Display contribution of con...

Benjamin Renard authored 10 years ago

355)   view_group(group,email);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

356) }
357) 
358) on_close_add_contributor_modal=function () {
359)   $('#add_contributor_name')[0].value='';
360)   $('#add_contributor_email')[0].value='';
361) }
362) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

363) on_edit_contributor_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

364)   var group=groups[$('#view-group').data('uuid')];
365)   $('#add_contributor_modal').data('group-uuid',group.uuid);
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

366)   contributor_email=$('#view-group #contributor')[0].value;
367)   contributor=group.contributorByEmail(contributor_email);
368)   $('#view-group #edit_id')[0].value=contributor_email;
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

369)   $('#add_contributor_modal #add_contributor_name')[0].value=contributor.name;
370)   $('#add_contributor_modal #add_contributor_email')[0].value=contributor.email;
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

371)   $('#add_contributor_modal #add_contributor_email').attr('disabled',true);
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

372)   $($('#add_contributor_modal h4')[0]).html('Editer un participant');
373)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Valider');
374)   $('#add_contributor_modal').modal('show');
375) }
376) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

377) on_click_del_contributor_btn=function() {
Benjamin Renard Fix contributor deletion

Benjamin Renard authored 10 years ago

378)   var group=groups[$('#view-group').data('uuid')];
379)   contributor=group.contributorByEmail($('#view-group #contributor')[0].value);
380)   question='Voulez-vous vraiment supprimer '+contributor.name+' ?';
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

381)   myconfirm(question,on_confirm_del_contributor,null,contributor);
382) }
383) 
384) on_confirm_del_contributor=function(contributor) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

385)   var group=groups[$('#view-group').data('uuid')];
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

386)   group.removeContributor(contributor);
Benjamin Renard Display group home after de...

Benjamin Renard authored 10 years ago

387)   view_group(group);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

388)   groups.save();
389) }
390) 
391) /********************************
392)  * Add/edit/delete contribution
393)  ********************************/
394) on_show_add_contribution_modal=function(e) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

395)   $('#add_contribution_modal #add_contribution_contributor_email').html($('#view-group #contributor').html());
396)   $('#add_contribution_modal #add_contribution_contributor_email')[0].value=$('#view-group #contributor')[0].value;
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

397)   gid=$('#add_contribution_modal').data('group-uuid');
398)   group=groups[gid];
Benjamin Renard Improve category selection

Benjamin Renard authored 10 years ago

399)   current_cat=$('#add_contribution_modal #add_contribution_category')[0].value;
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

400)   cats="<option value=''>Non définie</option>";
Benjamin Renard Improve category selection

Benjamin Renard authored 10 years ago

401)   for (u in group.getSortedCategories()) {
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

402) 	cats+="<option value='"+u+"'>"+group.categories[u]['name']+"</option>";
403)   }
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

404)   $('#add_contribution_modal #add_contribution_category').html(cats);
Benjamin Renard Improve category selection

Benjamin Renard authored 10 years ago

405)   $('#add_contribution_modal #add_contribution_category')[0].value=current_cat;
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

406)   $('#add_contribution_modal #add_contribution_title').typeahead({
407)     hint: true,
408)     highlight: true,
409)     minLength: 1
410)   },
411)   {
412)     name: 'titles',
413)     displayKey: 'value',
414)     source: group.findContributionByTitleMatches()
415)   });
416) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

417)   $('#add_contribution_modal #add_contribution_title').focus();
418) }
419) 
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

420) on_select_contribution_suggestion=function(event,choice,name) {
421)   if (jQuery.type(choice['category'])=='string') {
422)     $('#add_contribution_modal #add_contribution_category')[0].value=choice['category'];
423)   }
424) }
425) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

426) on_click_add_contribution_btn=function() {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

427)   $('#add_contribution_modal').data('group-uuid',$('#view-group').data('uuid'));
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

428)   $('#add_contribution_modal #edit_uuid')[0].value='-1';
bn8 Add pickadate date picker

bn8 authored 10 years ago

429)   $('#add_contribution_date')[0].value=moment().format('DD/MM/YYYY');
Benjamin Renard Customize add_contribution_...

Benjamin Renard authored 10 years ago

430)   $($('#add_contribution_modal h4')[0]).html('Ajouter une contribution');
431)   $($('#add_contribution_modal #add_contribution_submit')[0]).html('Ajouter');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

432)   $('#add_contribution_modal').modal('show');
433) }
434) 
435) on_valid_add_contribution_modal=function(e) {
436)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

437)   var group=groups[$('#add_contribution_modal').data('group-uuid')];
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

438)   var contributor_email=$('#add_contribution_contributor_email')[0].value;
439)   var contributor=group.contributorByEmail(contributor_email);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

440)   if (contributor==undefined) {
441)     alert('Participant inconu !');
442)     return;
443)   }
444)   var title=$('#add_contribution_title')[0].value;
445)   if (title=='') {
446)     $('#add_contribution_title')[0].focus();
447)     alert('Vous devez saisir un titre !');
448)     return;
449)   }
450)   var cost=$('#add_contribution_cost')[0].value;
451)   if (cost=='') {
452)     $('#add_contribution_cost')[0].focus();
453)     alert('Vous devez saisir un coût !');
454)     return;
455)   }
Benjamin Renard Add support of dot and comm...

Benjamin Renard authored 10 years ago

456)   else if(!RegExp('^[0-9]*((,|\.)[0-9]{1,2})*$').test(cost)) {
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

457)     $('#add_contribution_cost')[0].focus();
458)     alert('Coût incorrect !');
459)     return;
460)   }
461)   cost=parseFloat(cost.replace(',','.'));
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

462)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

463)   var date=$('#add_contribution_date')[0].value;
bn8 Add pickadate date picker

bn8 authored 10 years ago

464)   date.replace(/ /g,'');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

465)   if (date!='') {
466)     if(!RegExp('^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9][0-9][0-9]$').test(date)) {
467)       $('#add_contribution_date')[0].focus();
468)       alert('Date incorrect !');
469)       return;
470)     }
471)     date=moment(date,'DD-MM-YYYY').toDate();
472)     if (jQuery.type(date)!='date') {
473)       alert('Date non-reconnu !');
474)       return;
475)     }
476)   }
477)   else {
478)     date=new Date();
479)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

480)   
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

481)   var cat=$('#add_contribution_category')[0].value;
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

482)   if (cat != '' && !jQuery.type(group.categories[cat])) {
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

483) 	alert('Category incorrect');
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

484) 	return;
485)   }
486)   
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

487)   if($('#add_contribution_modal #edit_uuid')[0].value=='-1') {
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

488)     group.addContribution(new Contribution(contributor,cost,title,date,cat));
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

489)   }
490)   else {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

491)     contribution_uuid=$('#add_contribution_modal #edit_uuid')[0].value;
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

492)     group.updateContribution(contribution_uuid,new Contribution(contributor,cost,title,date,cat));
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

493)   }
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

494)   show_contributions(group,contributor_email);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

495)   $('#add_contribution_modal').modal('hide');
496)   $('#add_contribution_modal form')[0].reset();
497)   groups.save();
498) }
499) 
500) on_close_add_contribution_modal=function () {
501)   $('#add_contribution_modal form')[0].reset();
502) }
503) 
504) on_contribution_delete_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

505)   var group=groups[$('#view-group').data('uuid')];
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

506)   contribution_uuid=$($(e.target).parents('div')[0]).data('uuid');
507)   contribution=group.contributions[contribution_uuid];
508)   myconfirm('Etes-vous sûre de vouloir supprimer la participation '+contribution.getTitle()+' de '+contribution.contributor.name+' ?',on_confirm_contribution_delete,null,{'group':group,'contribution_uuid':contribution_uuid, 'contribution': contribution} );
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

509) }
510) 
511) on_confirm_contribution_delete=function(data) {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

512)   data.group.deleteContribution(data.contribution_uuid);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

513)   groups.save();
514)   on_contributor_change();
515) }
516) 
517) on_contribution_edit_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

518)   var group=groups[$('#view-group').data('uuid')];
519)   $('#add_contribution_modal').data('group-uuid',$('#view-group').data('uuid'));
Benjamin Renard Customize add_contribution_...

Benjamin Renard authored 10 years ago

520)   $($('#add_contribution_modal h4')[0]).html('Editer une contribution');
521)   $($('#add_contribution_modal #add_contribution_submit')[0]).html('Valider');
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

522)   contribution_uuid=$($(e.target).parents('div')[0]).data('uuid');
523)   contribution=group.contributions[contribution_uuid];
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

524)   $('#add_contribution_modal #add_contribution_contributor_email')[0].value=contribution.contributor.email;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

525)   $('#add_contribution_modal #add_contribution_title')[0].value=contribution.getTitle();
526)   $('#add_contribution_modal #add_contribution_cost')[0].value=contribution.cost;
527)   $('#add_contribution_modal #add_contribution_date')[0].value=moment(contribution.date).format('DD/MM/YYYY');
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

528)   if (contribution.category) {
529) 	$('#add_contribution_modal #add_contribution_category')[0].value=contribution.category;
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

530)   }
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

531)   $('#add_contribution_modal #edit_uuid')[0].value=contribution_uuid;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

532)   $('#add_contribution_modal').modal('show');
533) }
534) 
535) 
536) 
537) /********************
538)  * Clear local data
539)  ********************/
540) clear_local_data=function() {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

541)   navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

542)   myconfirm('Etes-vous sûre de vouloir supprimer les données locales ?',on_confirm_clear_local_data);
543) }
544) 
545) on_confirm_clear_local_data=function(data) {
Benjamin Renard Just remove groups from loc...

Benjamin Renard authored 10 years ago

546)   delete localStorage.groups;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

547)   location.reload();
548) }
549) 
550) /*********************
551)  * View balance
552)  *********************/
553) 
554) on_display_balance_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

555)   group=groups[$('#view-group').data('uuid')];
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

556)   display_balance(group);
557) }
558) 
559) display_balance=function(group) {
560)   bal=group.balance();
561)   tbody=$($('#display_balance_modal tbody')[0]);
562)   tbody.html('');
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

563)   for (c in bal['balance']) {
564)     if(bal['balance'][c]['diff']<0) {
565)       diff='<td class="negative">'+bal['balance'][c]['diff'].toFixed(2)+' €</td>';
566)     }
567)     else {
568)       diff='<td><span class="glyphicon glyphicon-thumbs-up"></span></td>';
569)     }
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

570)     tbody.append('<tr><td>'+bal['balance'][c]['name']+'</td><td>'+bal['balance'][c]['total'].toFixed(2)+' €</td>'+diff+'</tr>');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

571)   }
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

572)   $('#display_balance_modal #total-value').html(bal.sum.toFixed(2)+' €');
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

573)   $('#display_balance_modal').modal('show');
574) }
575) 
576) /*********************
577)  * Remove group
578)  *********************/
579) 
580) on_remove_group_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

581)   group=groups[$('#view-group').data('uuid')];
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

582)   myconfirm('Etes-vous sûre de vouloir supprimer le group '+group.name+' ?',on_confirm_remove_group,null,group);
583) }
584) 
585) on_confirm_remove_group=function(group) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

586)   if(groups.removeGroup(group.uuid)) {
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

587)     groups.save();
588)     location.reload();
589)   }
590)   else {
591)     alert('Erreur en supprimant le groupe '+group.name+' :(');
592)   }
593) }
594) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

595) /********************
596)  * Login
597)  ********************/
598) on_close_login_modal=function(e) {
599)   $('#login_modal form')[0].reset();
600) }
601) 
602) sync_server=false;
603) on_valid_login_modal=function(e) {
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

604)   e.preventDefault();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

605)   email=$('#login_modal #login_email')[0].value;
606)   pass=$('#login_modal #login_pass')[0].value;
607)   server=$('#login_modal #login_server')[0].value;
608)   $('#login_modal').modal('hide');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

609)   pleaseWaitShow();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

610)   sync_server.login(server,email,pass,
611)     function(data) {
612)       localStorage.user=JSON.stringify({
613)         'name': data.name,
614)         'email': email,
615)         'password': pass,
616)         'server': server,
bn8 Add lastsync information to...

bn8 authored 10 years ago

617)         'lastsync': null
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

618)       });
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

619)       pleaseWaitHide();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

620)       logged_menu();
621)     },
622)     function(data) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

623)       pleaseWaitHide();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

624)       if (jQuery.type(data) != 'object' && data.loginerror) {
625)         alert(data.loginerror);
626)       }
627)       else {
628)         console.log(data);
629)         alert('Erreur durant la connexion au serveur');
630)       }
631)     }
632)   );
633) }
634) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

635) on_click_go_to_subscribe_btn=function() {
636)   $('#login_modal').modal('hide');
637)   $('#subscribe_modal').modal('show');
638) }
639) 
640) /********************
641)  * Subscribe
642)  ********************/
643) on_close_subscribe_modal=function(e) {
644)   $('#subscribe_modal form')[0].reset();
645) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

646) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

647) sync_server=false;
648) on_valid_subscribe_modal=function(e) {
649)   e.preventDefault();
650)   email=$('#subscribe_modal #subscribe_email')[0].value;
651)   name=$('#subscribe_modal #subscribe_name')[0].value;
652)   pass=$('#subscribe_modal #subscribe_pass')[0].value;
653)   server=$('#subscribe_modal #subscribe_server')[0].value;
654)   $('#subscribe_modal').modal('hide');
655)   pleaseWaitShow();
656)   sync_server.subscribe(server,email,name,pass,
657)     function(data) {
658)       localStorage.user=JSON.stringify({
659)         'name': data.name,
660)         'email': data.email,
661)         'password': data.password,
662)         'server': server,
663)       });
664)       pleaseWaitHide();
665)       logged_menu();
666)       alert('Bienvenu '+data.name+' !');
667)     },
668)     function(data) {
669)       pleaseWaitHide();
670)       if (jQuery.type(data) == 'object' && jQuery.type(data.subscribeerror)!='undefined') {
671)         alert(data.subscribeerror);
672)       }
673)       else {
674)         console.log(data);
675)         alert('Erreur durant la connexion au serveur');
676)       }
677)     }
678)   );
679) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

680) 
681) /********************
682)  * Sync
683)  ********************/
684) on_click_sync_btn=function(e) {
Benjamin Renard Hide navbar after sync btn...

Benjamin Renard authored 10 years ago

685)   navbar_collapse_hide();
Benjamin Renard Manage user global variable

Benjamin Renard authored 10 years ago

686)   if (user) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

687)     pleaseWaitShow();
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

688)     onsuccess=function(data) {
689)       console.log(data);
690)       if (data.groups) {
691)         groups.import(data.groups);
692)         groups.save();
bn8 Add lastsync information to...

bn8 authored 10 years ago

693)         user.lastsync=new Date().getTime();
694)         localStorage.user=JSON.stringify(user);
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

695)         refresh_group_list();
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

696)         pleaseWaitHide();
Benjamin Renard Display home after successf...

Benjamin Renard authored 10 years ago

697)         view_home();
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

698)         alert('Groupes synchronisés');
699)       }
700)       else {
701)         onerror(data);
702)       }
703)     }
704)     onerror=function(data) {
705)       pleaseWaitHide();
706)       console.log(data);
707)       if (jQuery.type(data['loginerror'])!='undefined') {
708)         alert(data['loginerror']);
709)       }
710)       else if (jQuery.type(data['syncerror'])!='undefined') {
711)         alert(data['syncerror']);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

712)       }
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

713)       else {
714)         alert('Erreur durant la synchronisation :(');
715)       }
716)     }
717)     sync_server.sync(user.server, user.email, user.password, groups.export(),onsuccess,onerror);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

718)   }
719)   else {
720)     alert("Vous devez vous connecter pour commencer");
721)     $('#login_modal').modal('show');
722)   }
723) }
724) 
725) /*
726)  * User menu
727)  */
728) user=false;
729) logged_menu=function() {
730)   user=JSON.parse(localStorage.user);
731)   $('#user-name').html(user.name);
732)   $('#user-menu li').remove();
733)   menu=$('#user-menu');
734)   menu.html("<li><a id='myaccount_btn'>Mon compte</a></li>"+
735)   "<li><a id='sync_btn'>Synchroniser</a></li>" +
736)   "<li class='divider'></li>" +
737)   "<li><a id='logoff_btn'>Déconnexion</a></li>");
738)   $('#myaccount_btn').bind('click',on_click_myaccount_btn);
739)   $('#sync_btn').bind('click',on_click_sync_btn);
740)   $('#logoff_btn').bind('click',on_click_logoff_btn);
741) }
742) 
743) logged_out_menu=function() {
Benjamin Renard Manage user global variable

Benjamin Renard authored 10 years ago

744)   user=false;
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

745)   $('#user-name').html('Connexion');
746)   $('#user-menu li').remove();
747)   menu=$('#user-menu');
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

748)   menu.html("<li><a id='login_btn'>Connexion</a></li>"+
749) 	"<li><a id='subscribe_btn'>Inscription</a></li>");
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

750)   $('#login_btn').bind('click',on_click_login_btn);
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

751)   $('#subscribe_btn').bind('click',on_click_subscribe_btn);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

752) }
753) 
754) on_click_myaccount_btn=function() {
755)   $('#myaccount_modal #myaccount_email').html(user.email);
756)   $('#myaccount_modal #myaccount_name')[0].value=user.name;
Benjamin Renard Display server in myaccount...

Benjamin Renard authored 10 years ago

757)   $('#myaccount_modal #myaccount_server').html(user.server);
bn8 Add lastsync information to...

bn8 authored 10 years ago

758)   if (user.lastsync) {
759)     $('#myaccount_modal #myaccount_lastsync').html(moment(user.lastsync).format('DD/MM/YYYY HH:mm:ss'));
760)   }
761)   else {
762)     $('#myaccount_modal #myaccount_lastsync').html('Jamais synchronis&eacute;');
763)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

764)   $('#myaccount_modal').modal('show');
765) }
766) 
767) on_click_login_btn=function() {
768)   $('#login_modal').modal('show');
769) }
770) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

771) on_click_subscribe_btn=function() {
772)   $('#subscribe_modal').modal('show');
773) }
774) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

775) on_click_logoff_btn=function() {
776)   delete localStorage.user;
777)   logged_out_menu();
778) }
779) 
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

780) /*******************
781)  * pleaseWaitDialog
782)  *******************/
783) 
784) pleaseWaitShow=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

785)   $('#please_wait_modal').modal('show');
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

786) }
787) 
788) pleaseWaitHide=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

789)   $('#please_wait_modal').modal('hide');
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

790) }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

791) 
792) /*********************
793)  * Activate
794)  *********************/
795) $( document ).ready( function() {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

796)   pleaseWaitShow();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

797)   if(typeof(Storage)!=="undefined"){
798)     groups=new GroupList();
799)     groups.loadFromLocalStorage();
800)     refresh_group_list();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

801)     if (jQuery.type(localStorage.user)!='undefined') {
802)       logged_menu();
803)     }
804)     else {
805)       logged_out_menu();
806)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

807)   }
808)   else {
809)     alert('Local storage not supported !');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

810)     pleaseWaitHide();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

811)     return;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

812)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

813)   sync_server=new SyncServer();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

814) 
Benjamin Renard Add link on App Name in Navbar

Benjamin Renard authored 10 years ago

815)   $('#app-name').bind('click',view_home);
816) 
Benjamin Renard Hide navbar-groupe-collapse...

Benjamin Renard authored 10 years ago

817)   $('#add_group_btn').bind('click',on_click_add_group_btn);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

818)   $('#add_group_submit').bind('click',on_valid_add_group_modal);
819)   $("#add_group_modal").on('shown.bs.modal',on_show_add_group_modal);
820)   $("#add_group_modal").on('hidden.bs.modal',on_close_add_group_modal);
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

821)   $("#add_group_modal form").bind('submit',on_valid_add_group_modal);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

822) 
823)   $('#clear_local_data').bind('click',clear_local_data);
824) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

825)   $('#login_modal').on('hidden.bs.modal',on_close_login_modal);
826)   $('#login_modal #login_submit').bind('click',on_valid_login_modal);
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

827)   $('#login_modal #go_to_subscribe_btn').bind('click',on_click_go_to_subscribe_btn);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

828)   $('#login_modal form').bind('submit',on_valid_login_modal);
829) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

830)   $('#subscribe_modal').on('hidden.bs.modal',on_close_subscribe_modal);
831)   $('#subscribe_modal #subscribe_submit').bind('click',on_valid_subscribe_modal);
832)   $('#subscribe_modal form').bind('submit',on_valid_subscribe_modal);
833) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

834)   $('#view-group #contributor').bind('change',on_contributor_change);
835) 
836)   $('#add_contributor_btn').bind('click',on_click_add_contributor_btn);
837)   $('#add_contributor_submit').bind('click',on_valid_add_contributor_modal);
838)   $("#add_contributor_modal").on('shown.bs.modal',on_show_add_contributor_modal);
839)   $("#add_contributor_modal").on('hidden.bs.modal',on_close_add_contributor_modal);
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

840)   $("#add_contributor_modal form").bind('submit',on_valid_add_contributor_modal);
bn8 Add pickadate date picker

bn8 authored 10 years ago

841)   $("#add_contribution_date").pickadate({'format': 'dd/mm/yyyy','firstDay': 1});
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

842) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

843)   $('#edit_contributor_btn').bind('click',on_edit_contributor_btn_click);
Benjamin Renard Manage group contributors t...

Benjamin Renard authored 10 years ago

844)   $('#trash_contributor_btn').bind('click',on_trash_group_contributors_btn_click);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

845)   $('#del_contributor_btn').bind('click',on_click_del_contributor_btn);
846) 
847)   $('#add_contribution_btn').bind('click',on_click_add_contribution_btn);
848)   $('#add_contribution_submit').bind('click',on_valid_add_contribution_modal);
849)   $("#add_contribution_modal").on('shown.bs.modal',on_show_add_contribution_modal);
850)   $("#add_contribution_modal").on('hidden.bs.modal',on_close_add_contribution_modal);
851)   $("#add_contribution_modal form").on('submit',on_valid_add_contribution_modal);
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

852)   $('#add_contribution_modal #add_contribution_title').on('typeahead:selected', on_select_contribution_suggestion);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

853) 
854)   $("#display_balance_btn").bind('click',on_display_balance_btn_click);
855) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

856)   $("#view-group-trash #go-back-group").bind('click',on_go_back_group_btn_click);
Benjamin Renard Manage group contributors t...

Benjamin Renard authored 10 years ago

857)   $("#view-group-trash-contributors #go-back-group").bind('click',on_go_back_group_trash_contributors_btn_click);
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

858) 
859)   $('#trash_group_btn').bind('click',on_trash_group_btn_click);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

860)   $('#remove_group_btn').bind('click',on_remove_group_btn_click);
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

861)   view_home();
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

862)   pleaseWaitHide();