2a50bbbd20bd987af2b06c95a5a058d2f2a7aac6
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 Replace categories modal by...

Benjamin Renard authored 10 years ago

106)         tbody.html(tbody.html()+'<tr><td><a class="group-link" data-uuid="'+g+'">'+balances[g].name+'</a></td>'+diff+'</tr>');
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

125)   }
126)   else {
127)     $('#view-home #mybalances').css('display','none');
128)   }
129)   view_part('#view-home');
130) }
131) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

132) /****************
133)  * View group
134)  ****************/
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

141) }
142) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

144)   $('#view-group #contributor option').remove();
145)   if(group.contributors.length==0) {
146)     $('#view-group #contributor').append('<option>Aucun participant</option>');
147)   }
148)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

150)       if (email == contributor_email) {
151)         sel=' selected';
152)       }
153)       else {
154)         sel='';
155)       }
156)       $('#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

157)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

158)   }
159) }
160) 
161) on_contributor_change=function(e) {
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

162) 	if ($('#group-navbar-collapse-1').hasClass('in')) {
163) 		$('#group-navbar-collapse-1').collapse('hide');
164) 	}
165) 	$('#view-group #group-username').html($('#view-group #contributor option:selected').text());
166) 	show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

167) }
168) 
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

175)   if (contributions.length==0) {
176)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
177)     total.html('0,00 €');
178)   }
179)   else {
180)     sum=0;
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

183)       if (contributions[idx].category && jQuery.type(group.categories[contributions[idx].category])) {
184) 		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

185) 	  }
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

186)       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

187)       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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

191)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

192)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

193)   $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
194)   $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
195) }
196) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

197) on_categories_group_btn_click=function(e) {
198)   group=groups[$('#view-group').data('uuid')];
199)   $('#view-group-categories').data('group-uuid',$('#view-group').data('uuid'));
200)   refresh_group_categories(group);
201)   view_part('#view-group-categories');
202) }
203) 
204) refresh_group_categories=function(group) {
205)   ul=$('#view-group-categories ul');
206)   html="";
207)   for(cid in group.getSortedCategories()) {
208)     html+="<li data-uuid='"+cid+"'><span class='cat-color' style='background-color: "+group.categories[cid]['color']+"'></span> "+group.categories[cid]['name']+"</li>";
209)   }
210)   ul.html(html);
211)   $('#view-group-categories ul li').bind('click',on_categories_group_cat_click);
212) }
213) 
214) on_categories_group_cat_click=function(e) {
215)   li=$(e.target);
216)   if (li.prop("tagName")!='LI') {
217)     return true;
218)   }
219)   cid=li.data('uuid');
220)   group=groups[$('#view-group-categories').data('group-uuid')];
221)   cat=group.categories[cid];
222)   li.html("<span class='cat-color' style='background-color: "+cat['color']+"'></span> "+
223)   "<input type='text' value=\""+cat.name+"\"/> "+
224)   "<button class='btn btn-default btn-xs cat_edit'><span class='glyphicon glyphicon-ok'></span></button>"+
225)   "<button class='btn btn-default btn-xs cat_delete'><span class='glyphicon glyphicon-trash'></span></button>");
226)   li.children('button.cat_edit').bind('click',{'li': li,'group': group,'cid': cid},on_categories_group_cat_edit_valid_btn_click);
227)   li.children('button.cat_delete').bind('click',{'li': li,'group': group,'cid': cid},on_categories_group_cat_delete_btn_click);
228) }
229) 
230) on_categories_group_cat_edit_valid_btn_click=function(e) {
231)   name=e.data.li.children('input:first').val();
232)   cat=e.data.group.categories[e.data.cid];
233)   e.data.group.updateCategory(e.data.cid,new Category(name,cat.color));
234)   groups.save();
235)   refresh_group_categories(e.data.group);
236) }
237) 
238) on_categories_group_cat_delete_btn_click=function(e) {
239)   e.data.group.deleteCategory(e.data.cid);
240)   groups.save();
241)   refresh_group_categories(e.data.group);
242) }
243) 
244) on_categories_go_back_group_btn_click=function(e) {
245)   view_group(groups[$('#view-group-categories').data('group-uuid')]);
246) }
247) 
248) on_categories_group_add_btn_click=function(e) {
249)   name=$('#add_category input')[0].value;
250)   
251)   if (jQuery.type(name)!='string' || name=='') {
252)     return;
253)   }
254)   group_uuid=$('#view-group-categories').data('group-uuid');
255)   group=groups[group_uuid];
256)   
257)   if (group.getCategoryByName(name,true)) {
258)     alert('Cette catégorie existe déjà');
259)   }
260)   else {
261)     group.addCategory(new Category(name));
262)     $('#add_category input')[0].value='';
263)     refresh_group_categories(group);
264)   }
265) }
266) 
267) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

268) /*****************************
269)  * Trash
270)  *****************************/
271) 
272) on_trash_group_btn_click=function(e) {
273)   group=groups[$('#view-group').data('uuid')];
274)   contributor_email=$('#view-group #contributor')[0].value;
275)   view_group_trash(group,contributor_email);
276) }
277) 
278) on_go_back_group_btn_click=function(e) {
279)   group=groups[$('#view-group-trash').data('uuid')];
280)   contributor_email=$('#view-group-trash').data('contributor-email');
281)   view_group(group,contributor_email);
282) }
283) 
284) view_group_trash=function(group,contributor_email) {
285)   $('#view-group-trash').data('uuid',group.uuid);
286)   $('#view-group-trash').data('contributor-email',contributor_email);
287)   var tbody=$('#view-group-trash #trash tbody');
288)   tbody.html('');
289)   contributions=group.deletedContributionsByContributorEmail(contributor_email);
290)   contributions.reverse();
291)   if (contributions.length==0) {
292)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
293)   }
294)   else {
295)     for (idx in contributions) {
296)       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>');
297)     }
298)   }
299)   
300)   $('#view-group-trash .contribution_restore_btn').bind('click',on_contribution_restore_btn_click);
301)  
302)   view_part('#view-group-trash');
303) }
304) 
305) on_contribution_restore_btn_click=function(e) {
306)   var group=groups[$('#view-group-trash').data('uuid')];
307)   contribution_uuid=$($(e.target).parents('tr')[0]).data('uuid');
308)   contribution=group.importContribution(group.deletedContributions[contribution_uuid]);
309)   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} );
310) }
311) 
312) on_confirm_contribution_restore=function(data) {
313)   data.group.restoreContribution(data.contribution_uuid);
314)   groups.save();
315)   view_group(data.group,data.contribution.contributor.email);
316) }
317) 
Benjamin Renard Manage group contributors t...

Benjamin Renard authored 10 years ago

318) on_trash_group_contributors_btn_click=function(e) {
319)   group=groups[$('#view-group').data('uuid')];
320)   view_group_trash_contributors(group);
321) }
322) 
323) on_go_back_group_trash_contributors_btn_click=function(e) {
324)   group=groups[$('#view-group-trash-contributors').data('uuid')];
325)   view_group(group);
326) }
327) 
328) view_group_trash_contributors=function(group) {
329)   $('#view-group-trash-contributors').data('uuid',group.uuid);
330)   var tbody=$('#view-group-trash-contributors #trash tbody');
331)   tbody.html('');
332)   contributors=group.getDeletedContributors();
333)   if (contributors.length==0) {
334)     tbody.append('<tr><td colspan=3>Aucun participant</td></tr>');
335)   }
336)   else {
337)     for (idx in contributors) {
338)       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>');
339)     }
340)   }
341) 
342)   $('#view-group-trash-contributors .contributor_restore_btn').bind('click',on_contributor_restore_btn_click);
343) 
344)   view_part('#view-group-trash-contributors');
345) }
346) 
347) on_contributor_restore_btn_click=function(e) {
348)   var group=groups[$('#view-group-trash-contributors').data('uuid')];
349)   contributor_email=$($(e.target).parents('tr')[0]).data('email');
350)   contributor=group.importContributor(group.deletedContributors[contributor_email]);
351)   myconfirm('Etes-vous sûre de vouloir restaurer '+contributor.name+' ?',on_confirm_contributor_restore,null,{'group':group,'contributor_email':contributor_email, 'contributor': contributor} );
352) }
353) 
354) on_confirm_contributor_restore=function(data) {
355)   data.group.restoreContributor(data.contributor_email);
356)   groups.save();
357)   view_group(data.group,data.contributor_email);
358) }
359) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

360) /******************************
361)  * Add/Edit/remove contributor
362)  ******************************/
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

369)   $('#add_contributor_modal').modal('show');
370) }
371) 
372) on_show_add_contributor_modal=function(e) {
373)   $('#add_contributor_modal #add_contributor_name').focus();
374) }
375) 
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

376) validateEmail=function(email) {
377)     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,}))$/;
378)     return re.test(email);
379) }
380) 
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

386)   if (name=='') {
387)     alert('Vous devez saisir un nom !');
388)     return;
389)   }
390)   var email=$('#add_contributor_email')[0].value;
391)   if (email=='') {
392)     alert('Vous devez saisir un email !');
393)     return;
394)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

397)     alert('Un contributor utilise déjà cet email !');
398)     return;
399)   }
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

400)   if (!validateEmail(email)) {
401)     alert('Email invalide !');
402)     return;
403)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

404)   if(edit_id=='-1') {
405)     group.addContributor(new Contributor(name,email));
406)   }
407)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

409)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

410)   set_contributors(group);
411)   $('#add_contributor_modal').modal('hide');
412)   groups.save();
Benjamin Renard Display contribution of con...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

414) }
415) 
416) on_close_add_contributor_modal=function () {
417)   $('#add_contributor_name')[0].value='';
418)   $('#add_contributor_email')[0].value='';
419) }
420) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

430)   $($('#add_contributor_modal h4')[0]).html('Editer un participant');
431)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Valider');
432)   $('#add_contributor_modal').modal('show');
433) }
434) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

439)   myconfirm(question,on_confirm_del_contributor,null,contributor);
440) }
441) 
442) on_confirm_del_contributor=function(contributor) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

445)   view_group(group);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

446)   groups.save();
447) }
448) 
449) /********************************
450)  * Add/edit/delete contribution
451)  ********************************/
452) on_show_add_contribution_modal=function(e) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

453)   $('#add_contribution_modal #add_contribution_contributor_email').html($('#view-group #contributor').html());
454)   $('#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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

464)   $('#add_contribution_modal #add_contribution_title').typeahead({
465)     hint: true,
466)     highlight: true,
467)     minLength: 1
468)   },
469)   {
470)     name: 'titles',
471)     displayKey: 'value',
472)     source: group.findContributionByTitleMatches()
473)   });
474) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

475)   $('#add_contribution_modal #add_contribution_title').focus();
476) }
477) 
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

478) on_select_contribution_suggestion=function(event,choice,name) {
479)   if (jQuery.type(choice['category'])=='string') {
480)     $('#add_contribution_modal #add_contribution_category')[0].value=choice['category'];
481)   }
482) }
483) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

490)   $('#add_contribution_modal').modal('show');
491) }
492) 
493) on_valid_add_contribution_modal=function(e) {
494)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

498)   if (contributor==undefined) {
499)     alert('Participant inconu !');
500)     return;
501)   }
502)   var title=$('#add_contribution_title')[0].value;
503)   if (title=='') {
504)     $('#add_contribution_title')[0].focus();
505)     alert('Vous devez saisir un titre !');
506)     return;
507)   }
508)   var cost=$('#add_contribution_cost')[0].value;
509)   if (cost=='') {
510)     $('#add_contribution_cost')[0].focus();
511)     alert('Vous devez saisir un coût !');
512)     return;
513)   }
Benjamin Renard Add support of dot and comm...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

515)     $('#add_contribution_cost')[0].focus();
516)     alert('Coût incorrect !');
517)     return;
518)   }
519)   cost=parseFloat(cost.replace(',','.'));
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

520)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

523)   if (date!='') {
524)     if(!RegExp('^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9][0-9][0-9]$').test(date)) {
525)       $('#add_contribution_date')[0].focus();
526)       alert('Date incorrect !');
527)       return;
528)     }
529)     date=moment(date,'DD-MM-YYYY').toDate();
530)     if (jQuery.type(date)!='date') {
531)       alert('Date non-reconnu !');
532)       return;
533)     }
534)   }
535)   else {
536)     date=new Date();
537)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

538)   
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

542) 	return;
543)   }
544)   
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

547)   }
548)   else {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

553)   $('#add_contribution_modal').modal('hide');
554)   $('#add_contribution_modal form')[0].reset();
555)   groups.save();
556) }
557) 
558) on_close_add_contribution_modal=function () {
559)   $('#add_contribution_modal form')[0].reset();
560) }
561) 
562) on_contribution_delete_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

564)   contribution_uuid=$($(e.target).parents('div')[0]).data('uuid');
565)   contribution=group.contributions[contribution_uuid];
566)   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

567) }
568) 
569) on_confirm_contribution_delete=function(data) {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

571)   groups.save();
572)   on_contributor_change();
573) }
574) 
575) on_contribution_edit_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

583)   $('#add_contribution_modal #add_contribution_title')[0].value=contribution.getTitle();
584)   $('#add_contribution_modal #add_contribution_cost')[0].value=contribution.cost;
585)   $('#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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

590)   $('#add_contribution_modal').modal('show');
591) }
592) 
593) 
594) 
595) /********************
596)  * Clear local data
597)  ********************/
598) clear_local_data=function() {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

599)   navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

604)   delete localStorage.groups;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

605)   location.reload();
606) }
607) 
608) /*********************
609)  * View balance
610)  *********************/
611) 
612) on_display_balance_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

614)   display_balance(group);
615) }
616) 
617) display_balance=function(group) {
618)   bal=group.balance();
619)   tbody=$($('#display_balance_modal tbody')[0]);
620)   tbody.html('');
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

621)   for (c in bal['balance']) {
622)     if(bal['balance'][c]['diff']<0) {
623)       diff='<td class="negative">'+bal['balance'][c]['diff'].toFixed(2)+' €</td>';
624)     }
625)     else {
626)       diff='<td><span class="glyphicon glyphicon-thumbs-up"></span></td>';
627)     }
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

628)     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

629)   }
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

631)   $('#display_balance_modal').modal('show');
632) }
633) 
634) /*********************
635)  * Remove group
636)  *********************/
637) 
638) on_remove_group_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

645)     groups.save();
646)     location.reload();
647)   }
648)   else {
649)     alert('Erreur en supprimant le groupe '+group.name+' :(');
650)   }
651) }
652) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

653) /********************
654)  * Login
655)  ********************/
656) on_close_login_modal=function(e) {
657)   $('#login_modal form')[0].reset();
658) }
659) 
660) sync_server=false;
661) on_valid_login_modal=function(e) {
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

663)   email=$('#login_modal #login_email')[0].value;
664)   pass=$('#login_modal #login_pass')[0].value;
665)   server=$('#login_modal #login_server')[0].value;
666)   $('#login_modal').modal('hide');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

668)   sync_server.login(server,email,pass,
669)     function(data) {
670)       localStorage.user=JSON.stringify({
671)         'name': data.name,
672)         'email': email,
673)         'password': pass,
674)         'server': server,
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

678)       logged_menu();
679)     },
680)     function(data) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

682)       if (jQuery.type(data) != 'object' && data.loginerror) {
683)         alert(data.loginerror);
684)       }
685)       else {
686)         console.log(data);
687)         alert('Erreur durant la connexion au serveur');
688)       }
689)     }
690)   );
691) }
692) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

693) on_click_go_to_subscribe_btn=function() {
694)   $('#login_modal').modal('hide');
695)   $('#subscribe_modal').modal('show');
696) }
697) 
698) /********************
699)  * Subscribe
700)  ********************/
701) on_close_subscribe_modal=function(e) {
702)   $('#subscribe_modal form')[0].reset();
703) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

704) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

705) sync_server=false;
706) on_valid_subscribe_modal=function(e) {
707)   e.preventDefault();
708)   email=$('#subscribe_modal #subscribe_email')[0].value;
709)   name=$('#subscribe_modal #subscribe_name')[0].value;
710)   pass=$('#subscribe_modal #subscribe_pass')[0].value;
711)   server=$('#subscribe_modal #subscribe_server')[0].value;
712)   $('#subscribe_modal').modal('hide');
713)   pleaseWaitShow();
714)   sync_server.subscribe(server,email,name,pass,
715)     function(data) {
716)       localStorage.user=JSON.stringify({
717)         'name': data.name,
718)         'email': data.email,
719)         'password': data.password,
720)         'server': server,
721)       });
722)       pleaseWaitHide();
723)       logged_menu();
724)       alert('Bienvenu '+data.name+' !');
725)     },
726)     function(data) {
727)       pleaseWaitHide();
728)       if (jQuery.type(data) == 'object' && jQuery.type(data.subscribeerror)!='undefined') {
729)         alert(data.subscribeerror);
730)       }
731)       else {
732)         console.log(data);
733)         alert('Erreur durant la connexion au serveur');
734)       }
735)     }
736)   );
737) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

738) 
739) /********************
740)  * Sync
741)  ********************/
742) on_click_sync_btn=function(e) {
Benjamin Renard Hide navbar after sync btn...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

746)     onsuccess=function(data) {
747)       console.log(data);
748)       if (data.groups) {
749)         groups.import(data.groups);
750)         groups.save();
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

756)         alert('Groupes synchronisés');
757)       }
758)       else {
759)         onerror(data);
760)       }
761)     }
762)     onerror=function(data) {
763)       pleaseWaitHide();
764)       console.log(data);
765)       if (jQuery.type(data['loginerror'])!='undefined') {
766)         alert(data['loginerror']);
767)       }
768)       else if (jQuery.type(data['syncerror'])!='undefined') {
769)         alert(data['syncerror']);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

771)       else {
772)         alert('Erreur durant la synchronisation :(');
773)       }
774)     }
775)     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

776)   }
777)   else {
778)     alert("Vous devez vous connecter pour commencer");
779)     $('#login_modal').modal('show');
780)   }
781) }
782) 
783) /*
784)  * User menu
785)  */
786) user=false;
787) logged_menu=function() {
788)   user=JSON.parse(localStorage.user);
789)   $('#user-name').html(user.name);
790)   $('#user-menu li').remove();
791)   menu=$('#user-menu');
792)   menu.html("<li><a id='myaccount_btn'>Mon compte</a></li>"+
793)   "<li><a id='sync_btn'>Synchroniser</a></li>" +
794)   "<li class='divider'></li>" +
795)   "<li><a id='logoff_btn'>Déconnexion</a></li>");
796)   $('#myaccount_btn').bind('click',on_click_myaccount_btn);
797)   $('#sync_btn').bind('click',on_click_sync_btn);
798)   $('#logoff_btn').bind('click',on_click_logoff_btn);
799) }
800) 
801) logged_out_menu=function() {
Benjamin Renard Manage user global variable

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

803)   $('#user-name').html('Connexion');
804)   $('#user-menu li').remove();
805)   menu=$('#user-menu');
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

810) }
811) 
812) on_click_myaccount_btn=function() {
813)   $('#myaccount_modal #myaccount_email').html(user.email);
814)   $('#myaccount_modal #myaccount_name')[0].value=user.name;
Benjamin Renard Display server in myaccount...

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

816)   if (user.lastsync) {
817)     $('#myaccount_modal #myaccount_lastsync').html(moment(user.lastsync).format('DD/MM/YYYY HH:mm:ss'));
818)   }
819)   else {
820)     $('#myaccount_modal #myaccount_lastsync').html('Jamais synchronis&eacute;');
821)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

822)   $('#myaccount_modal').modal('show');
823) }
824) 
825) on_click_login_btn=function() {
826)   $('#login_modal').modal('show');
827) }
828) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

829) on_click_subscribe_btn=function() {
830)   $('#subscribe_modal').modal('show');
831) }
832) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

833) on_click_logoff_btn=function() {
834)   delete localStorage.user;
835)   logged_out_menu();
836) }
837) 
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

838) /*******************
839)  * pleaseWaitDialog
840)  *******************/
841) 
842) pleaseWaitShow=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

844) }
845) 
846) pleaseWaitHide=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

848) }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

849) 
850) /*********************
851)  * Activate
852)  *********************/
853) $( document ).ready( function() {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

854)   pleaseWaitShow();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

855)   if(typeof(Storage)!=="undefined"){
856)     groups=new GroupList();
857)     groups.loadFromLocalStorage();
858)     refresh_group_list();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

859)     if (jQuery.type(localStorage.user)!='undefined') {
860)       logged_menu();
861)     }
862)     else {
863)       logged_out_menu();
864)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

865)   }
866)   else {
867)     alert('Local storage not supported !');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

869)     return;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

870)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

872) 
Benjamin Renard Add link on App Name in Navbar

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

876)   $('#add_group_submit').bind('click',on_valid_add_group_modal);
877)   $("#add_group_modal").on('shown.bs.modal',on_show_add_group_modal);
878)   $("#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

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

Benjamin Renard authored 10 years ago

880) 
881)   $('#clear_local_data').bind('click',clear_local_data);
882) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

885)   $('#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

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

Benjamin Renard authored 10 years ago

888)   $('#subscribe_modal').on('hidden.bs.modal',on_close_subscribe_modal);
889)   $('#subscribe_modal #subscribe_submit').bind('click',on_valid_subscribe_modal);
890)   $('#subscribe_modal form').bind('submit',on_valid_subscribe_modal);
891) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

892)   $('#view-group #contributor').bind('change',on_contributor_change);
893) 
894)   $('#add_contributor_btn').bind('click',on_click_add_contributor_btn);
895)   $('#add_contributor_submit').bind('click',on_valid_add_contributor_modal);
896)   $("#add_contributor_modal").on('shown.bs.modal',on_show_add_contributor_modal);
897)   $("#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

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

900) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

903)   $('#del_contributor_btn').bind('click',on_click_del_contributor_btn);
904) 
905)   $('#add_contribution_btn').bind('click',on_click_add_contribution_btn);
906)   $('#add_contribution_submit').bind('click',on_valid_add_contribution_modal);
907)   $("#add_contribution_modal").on('shown.bs.modal',on_show_add_contribution_modal);
908)   $("#add_contribution_modal").on('hidden.bs.modal',on_close_add_contribution_modal);
909)   $("#add_contribution_modal form").on('submit',on_valid_add_contribution_modal);
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

911) 
912)   $("#display_balance_btn").bind('click',on_display_balance_btn_click);
913) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

914)   $("#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

915)   $("#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

916) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

917)   $('#categories_group_btn').bind('click',on_categories_group_btn_click);
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

919)   $('#remove_group_btn').bind('click',on_remove_group_btn_click);
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

920)   
921)   $('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
922)   $("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
923)   
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

925)   pleaseWaitHide();