f149b98cd3b6d27b177ae246882c9d1b69bc17da
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);
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

212)   
213)   $('#cats-chart').css('width',$(window).width()*0.9+'px');
214)   
215)   $.plot($('#cats-chart'),group.getCategoriesStats(),{
216)     'grid': {
217)         'hoverable': true
218)     }, 
219)     'legend': {
Benjamin Renard Preserve categories's color...

Benjamin Renard authored 10 years ago

220)         'show': false,
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

221)     },
222)     'series': { 
223)         'pie': {
224)             'show': true,
225)             'innerRadius': 0.5,
Benjamin Renard Improve chart

Benjamin Renard authored 10 years ago

226)             'radius': .8,
227)             'tilt': .5,
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

228)             'label': {
229)                 'show': true,
230)                 'formatter': function (label, series) {
Benjamin Renard Improve chart

Benjamin Renard authored 10 years ago

231) return '<div class="cats-chart-label">' + label + '<br/><span>' +   
232)                             Math.round(series.percent) + '% - '+series.data[0][1].toFixed(2)+'€</span></div>';
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

233)                 }
234)             }
235)         }
236)     }
237) });
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

238) }
239) 
240) on_categories_group_cat_click=function(e) {
241)   li=$(e.target);
242)   if (li.prop("tagName")!='LI') {
243)     return true;
244)   }
245)   cid=li.data('uuid');
246)   group=groups[$('#view-group-categories').data('group-uuid')];
247)   cat=group.categories[cid];
248)   li.html("<span class='cat-color' style='background-color: "+cat['color']+"'></span> "+
249)   "<input type='text' value=\""+cat.name+"\"/> "+
250)   "<button class='btn btn-default btn-xs cat_edit'><span class='glyphicon glyphicon-ok'></span></button>"+
251)   "<button class='btn btn-default btn-xs cat_delete'><span class='glyphicon glyphicon-trash'></span></button>");
252)   li.children('button.cat_edit').bind('click',{'li': li,'group': group,'cid': cid},on_categories_group_cat_edit_valid_btn_click);
253)   li.children('button.cat_delete').bind('click',{'li': li,'group': group,'cid': cid},on_categories_group_cat_delete_btn_click);
254) }
255) 
256) on_categories_group_cat_edit_valid_btn_click=function(e) {
257)   name=e.data.li.children('input:first').val();
258)   cat=e.data.group.categories[e.data.cid];
259)   e.data.group.updateCategory(e.data.cid,new Category(name,cat.color));
260)   groups.save();
261)   refresh_group_categories(e.data.group);
262) }
263) 
264) on_categories_group_cat_delete_btn_click=function(e) {
265)   e.data.group.deleteCategory(e.data.cid);
266)   groups.save();
267)   refresh_group_categories(e.data.group);
268) }
269) 
270) on_categories_go_back_group_btn_click=function(e) {
271)   view_group(groups[$('#view-group-categories').data('group-uuid')]);
272) }
273) 
274) on_categories_group_add_btn_click=function(e) {
275)   name=$('#add_category input')[0].value;
276)   
277)   if (jQuery.type(name)!='string' || name=='') {
278)     return;
279)   }
280)   group_uuid=$('#view-group-categories').data('group-uuid');
281)   group=groups[group_uuid];
282)   
283)   if (group.getCategoryByName(name,true)) {
284)     alert('Cette catégorie existe déjà');
285)   }
286)   else {
287)     group.addCategory(new Category(name));
288)     $('#add_category input')[0].value='';
289)     refresh_group_categories(group);
290)   }
291) }
292) 
293) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

294) /*****************************
295)  * Trash
296)  *****************************/
297) 
298) on_trash_group_btn_click=function(e) {
299)   group=groups[$('#view-group').data('uuid')];
300)   contributor_email=$('#view-group #contributor')[0].value;
301)   view_group_trash(group,contributor_email);
302) }
303) 
304) on_go_back_group_btn_click=function(e) {
305)   group=groups[$('#view-group-trash').data('uuid')];
306)   contributor_email=$('#view-group-trash').data('contributor-email');
307)   view_group(group,contributor_email);
308) }
309) 
310) view_group_trash=function(group,contributor_email) {
311)   $('#view-group-trash').data('uuid',group.uuid);
312)   $('#view-group-trash').data('contributor-email',contributor_email);
313)   var tbody=$('#view-group-trash #trash tbody');
314)   tbody.html('');
315)   contributions=group.deletedContributionsByContributorEmail(contributor_email);
316)   contributions.reverse();
317)   if (contributions.length==0) {
318)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
319)   }
320)   else {
321)     for (idx in contributions) {
322)       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>');
323)     }
324)   }
325)   
326)   $('#view-group-trash .contribution_restore_btn').bind('click',on_contribution_restore_btn_click);
327)  
328)   view_part('#view-group-trash');
329) }
330) 
331) on_contribution_restore_btn_click=function(e) {
332)   var group=groups[$('#view-group-trash').data('uuid')];
333)   contribution_uuid=$($(e.target).parents('tr')[0]).data('uuid');
334)   contribution=group.importContribution(group.deletedContributions[contribution_uuid]);
335)   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} );
336) }
337) 
338) on_confirm_contribution_restore=function(data) {
339)   data.group.restoreContribution(data.contribution_uuid);
340)   groups.save();
341)   view_group(data.group,data.contribution.contributor.email);
342) }
343) 
Benjamin Renard Manage group contributors t...

Benjamin Renard authored 10 years ago

344) on_trash_group_contributors_btn_click=function(e) {
345)   group=groups[$('#view-group').data('uuid')];
346)   view_group_trash_contributors(group);
347) }
348) 
349) on_go_back_group_trash_contributors_btn_click=function(e) {
350)   group=groups[$('#view-group-trash-contributors').data('uuid')];
351)   view_group(group);
352) }
353) 
354) view_group_trash_contributors=function(group) {
355)   $('#view-group-trash-contributors').data('uuid',group.uuid);
356)   var tbody=$('#view-group-trash-contributors #trash tbody');
357)   tbody.html('');
358)   contributors=group.getDeletedContributors();
359)   if (contributors.length==0) {
360)     tbody.append('<tr><td colspan=3>Aucun participant</td></tr>');
361)   }
362)   else {
363)     for (idx in contributors) {
364)       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>');
365)     }
366)   }
367) 
368)   $('#view-group-trash-contributors .contributor_restore_btn').bind('click',on_contributor_restore_btn_click);
369) 
370)   view_part('#view-group-trash-contributors');
371) }
372) 
373) on_contributor_restore_btn_click=function(e) {
374)   var group=groups[$('#view-group-trash-contributors').data('uuid')];
375)   contributor_email=$($(e.target).parents('tr')[0]).data('email');
376)   contributor=group.importContributor(group.deletedContributors[contributor_email]);
377)   myconfirm('Etes-vous sûre de vouloir restaurer '+contributor.name+' ?',on_confirm_contributor_restore,null,{'group':group,'contributor_email':contributor_email, 'contributor': contributor} );
378) }
379) 
380) on_confirm_contributor_restore=function(data) {
381)   data.group.restoreContributor(data.contributor_email);
382)   groups.save();
383)   view_group(data.group,data.contributor_email);
384) }
385) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

386) /******************************
387)  * Add/Edit/remove contributor
388)  ******************************/
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

395)   $('#add_contributor_modal').modal('show');
396) }
397) 
398) on_show_add_contributor_modal=function(e) {
399)   $('#add_contributor_modal #add_contributor_name').focus();
400) }
401) 
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

402) validateEmail=function(email) {
403)     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,}))$/;
404)     return re.test(email);
405) }
406) 
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

412)   if (name=='') {
413)     alert('Vous devez saisir un nom !');
414)     return;
415)   }
416)   var email=$('#add_contributor_email')[0].value;
417)   if (email=='') {
418)     alert('Vous devez saisir un email !');
419)     return;
420)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

423)     alert('Un contributor utilise déjà cet email !');
424)     return;
425)   }
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

426)   if (!validateEmail(email)) {
427)     alert('Email invalide !');
428)     return;
429)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

430)   if(edit_id=='-1') {
431)     group.addContributor(new Contributor(name,email));
432)   }
433)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

435)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

436)   set_contributors(group);
437)   $('#add_contributor_modal').modal('hide');
438)   groups.save();
Benjamin Renard Display contribution of con...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

440) }
441) 
442) on_close_add_contributor_modal=function () {
443)   $('#add_contributor_name')[0].value='';
444)   $('#add_contributor_email')[0].value='';
445) }
446) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

456)   $($('#add_contributor_modal h4')[0]).html('Editer un participant');
457)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Valider');
458)   $('#add_contributor_modal').modal('show');
459) }
460) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

465)   myconfirm(question,on_confirm_del_contributor,null,contributor);
466) }
467) 
468) on_confirm_del_contributor=function(contributor) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

471)   view_group(group);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

472)   groups.save();
473) }
474) 
475) /********************************
476)  * Add/edit/delete contribution
477)  ********************************/
478) on_show_add_contribution_modal=function(e) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

490)   $('#add_contribution_modal #add_contribution_title').typeahead({
491)     hint: true,
492)     highlight: true,
493)     minLength: 1
494)   },
495)   {
496)     name: 'titles',
497)     displayKey: 'value',
498)     source: group.findContributionByTitleMatches()
499)   });
500) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

501)   $('#add_contribution_modal #add_contribution_title').focus();
502) }
503) 
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

504) on_select_contribution_suggestion=function(event,choice,name) {
505)   if (jQuery.type(choice['category'])=='string') {
506)     $('#add_contribution_modal #add_contribution_category')[0].value=choice['category'];
507)   }
508) }
509) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

516)   $('#add_contribution_modal').modal('show');
517) }
518) 
519) on_valid_add_contribution_modal=function(e) {
520)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

524)   if (contributor==undefined) {
525)     alert('Participant inconu !');
526)     return;
527)   }
528)   var title=$('#add_contribution_title')[0].value;
529)   if (title=='') {
530)     $('#add_contribution_title')[0].focus();
531)     alert('Vous devez saisir un titre !');
532)     return;
533)   }
534)   var cost=$('#add_contribution_cost')[0].value;
535)   if (cost=='') {
536)     $('#add_contribution_cost')[0].focus();
537)     alert('Vous devez saisir un coût !');
538)     return;
539)   }
Benjamin Renard Add support of dot and comm...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

541)     $('#add_contribution_cost')[0].focus();
542)     alert('Coût incorrect !');
543)     return;
544)   }
545)   cost=parseFloat(cost.replace(',','.'));
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

546)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

549)   if (date!='') {
550)     if(!RegExp('^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9][0-9][0-9]$').test(date)) {
551)       $('#add_contribution_date')[0].focus();
552)       alert('Date incorrect !');
553)       return;
554)     }
555)     date=moment(date,'DD-MM-YYYY').toDate();
556)     if (jQuery.type(date)!='date') {
557)       alert('Date non-reconnu !');
558)       return;
559)     }
560)   }
561)   else {
562)     date=new Date();
563)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

564)   
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

568) 	return;
569)   }
570)   
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

573)   }
574)   else {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

579)   $('#add_contribution_modal').modal('hide');
580)   $('#add_contribution_modal form')[0].reset();
581)   groups.save();
582) }
583) 
584) on_close_add_contribution_modal=function () {
585)   $('#add_contribution_modal form')[0].reset();
586) }
587) 
588) on_contribution_delete_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

593) }
594) 
595) on_confirm_contribution_delete=function(data) {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

597)   groups.save();
598)   on_contributor_change();
599) }
600) 
601) on_contribution_edit_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

616)   $('#add_contribution_modal').modal('show');
617) }
618) 
619) 
620) 
621) /********************
622)  * Clear local data
623)  ********************/
624) clear_local_data=function() {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

625)   navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

630)   delete localStorage.groups;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

631)   location.reload();
632) }
633) 
634) /*********************
635)  * View balance
636)  *********************/
637) 
638) on_display_balance_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)   display_balance(group);
641) }
642) 
643) display_balance=function(group) {
644)   bal=group.balance();
645)   tbody=$($('#display_balance_modal tbody')[0]);
646)   tbody.html('');
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

647)   for (c in bal['balance']) {
648)     if(bal['balance'][c]['diff']<0) {
649)       diff='<td class="negative">'+bal['balance'][c]['diff'].toFixed(2)+' €</td>';
650)     }
651)     else {
652)       diff='<td><span class="glyphicon glyphicon-thumbs-up"></span></td>';
653)     }
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

655)   }
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

657)   $('#display_balance_modal').modal('show');
658) }
659) 
660) /*********************
661)  * Remove group
662)  *********************/
663) 
664) on_remove_group_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

671)     groups.save();
672)     location.reload();
673)   }
674)   else {
675)     alert('Erreur en supprimant le groupe '+group.name+' :(');
676)   }
677) }
678) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

679) /********************
680)  * Login
681)  ********************/
682) on_close_login_modal=function(e) {
683)   $('#login_modal form')[0].reset();
684) }
685) 
686) sync_server=false;
687) on_valid_login_modal=function(e) {
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

689)   email=$('#login_modal #login_email')[0].value;
690)   pass=$('#login_modal #login_pass')[0].value;
691)   server=$('#login_modal #login_server')[0].value;
692)   $('#login_modal').modal('hide');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

694)   sync_server.login(server,email,pass,
695)     function(data) {
696)       localStorage.user=JSON.stringify({
697)         'name': data.name,
698)         'email': email,
699)         'password': pass,
700)         'server': server,
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

704)       logged_menu();
705)     },
706)     function(data) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

708)       if (jQuery.type(data) != 'object' && data.loginerror) {
709)         alert(data.loginerror);
710)       }
711)       else {
712)         console.log(data);
713)         alert('Erreur durant la connexion au serveur');
714)       }
715)     }
716)   );
717) }
718) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

719) on_click_go_to_subscribe_btn=function() {
720)   $('#login_modal').modal('hide');
721)   $('#subscribe_modal').modal('show');
722) }
723) 
724) /********************
725)  * Subscribe
726)  ********************/
727) on_close_subscribe_modal=function(e) {
728)   $('#subscribe_modal form')[0].reset();
729) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

730) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

731) sync_server=false;
732) on_valid_subscribe_modal=function(e) {
733)   e.preventDefault();
734)   email=$('#subscribe_modal #subscribe_email')[0].value;
735)   name=$('#subscribe_modal #subscribe_name')[0].value;
736)   pass=$('#subscribe_modal #subscribe_pass')[0].value;
737)   server=$('#subscribe_modal #subscribe_server')[0].value;
738)   $('#subscribe_modal').modal('hide');
739)   pleaseWaitShow();
740)   sync_server.subscribe(server,email,name,pass,
741)     function(data) {
742)       localStorage.user=JSON.stringify({
743)         'name': data.name,
744)         'email': data.email,
745)         'password': data.password,
746)         'server': server,
747)       });
748)       pleaseWaitHide();
749)       logged_menu();
750)       alert('Bienvenu '+data.name+' !');
751)     },
752)     function(data) {
753)       pleaseWaitHide();
754)       if (jQuery.type(data) == 'object' && jQuery.type(data.subscribeerror)!='undefined') {
755)         alert(data.subscribeerror);
756)       }
757)       else {
758)         console.log(data);
759)         alert('Erreur durant la connexion au serveur');
760)       }
761)     }
762)   );
763) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

764) 
765) /********************
766)  * Sync
767)  ********************/
768) on_click_sync_btn=function(e) {
Benjamin Renard Hide navbar after sync btn...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

772)     onsuccess=function(data) {
773)       console.log(data);
774)       if (data.groups) {
775)         groups.import(data.groups);
776)         groups.save();
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

782)         alert('Groupes synchronisés');
783)       }
784)       else {
785)         onerror(data);
786)       }
787)     }
788)     onerror=function(data) {
789)       pleaseWaitHide();
790)       console.log(data);
791)       if (jQuery.type(data['loginerror'])!='undefined') {
792)         alert(data['loginerror']);
793)       }
794)       else if (jQuery.type(data['syncerror'])!='undefined') {
795)         alert(data['syncerror']);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

797)       else {
798)         alert('Erreur durant la synchronisation :(');
799)       }
800)     }
801)     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

802)   }
803)   else {
804)     alert("Vous devez vous connecter pour commencer");
805)     $('#login_modal').modal('show');
806)   }
807) }
808) 
809) /*
810)  * User menu
811)  */
812) user=false;
813) logged_menu=function() {
814)   user=JSON.parse(localStorage.user);
815)   $('#user-name').html(user.name);
816)   $('#user-menu li').remove();
817)   menu=$('#user-menu');
818)   menu.html("<li><a id='myaccount_btn'>Mon compte</a></li>"+
819)   "<li><a id='sync_btn'>Synchroniser</a></li>" +
820)   "<li class='divider'></li>" +
821)   "<li><a id='logoff_btn'>Déconnexion</a></li>");
822)   $('#myaccount_btn').bind('click',on_click_myaccount_btn);
823)   $('#sync_btn').bind('click',on_click_sync_btn);
824)   $('#logoff_btn').bind('click',on_click_logoff_btn);
825) }
826) 
827) logged_out_menu=function() {
Benjamin Renard Manage user global variable

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

829)   $('#user-name').html('Connexion');
830)   $('#user-menu li').remove();
831)   menu=$('#user-menu');
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

836) }
837) 
838) on_click_myaccount_btn=function() {
839)   $('#myaccount_modal #myaccount_email').html(user.email);
840)   $('#myaccount_modal #myaccount_name')[0].value=user.name;
Benjamin Renard Display server in myaccount...

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

842)   if (user.lastsync) {
843)     $('#myaccount_modal #myaccount_lastsync').html(moment(user.lastsync).format('DD/MM/YYYY HH:mm:ss'));
844)   }
845)   else {
846)     $('#myaccount_modal #myaccount_lastsync').html('Jamais synchronis&eacute;');
847)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

848)   $('#myaccount_modal').modal('show');
849) }
850) 
851) on_click_login_btn=function() {
852)   $('#login_modal').modal('show');
853) }
854) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

855) on_click_subscribe_btn=function() {
856)   $('#subscribe_modal').modal('show');
857) }
858) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

859) on_click_logoff_btn=function() {
860)   delete localStorage.user;
861)   logged_out_menu();
862) }
863) 
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

864) /*******************
865)  * pleaseWaitDialog
866)  *******************/
867) 
868) pleaseWaitShow=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

870) }
871) 
872) pleaseWaitHide=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

874) }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

875) 
876) /*********************
877)  * Activate
878)  *********************/
879) $( document ).ready( function() {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

880)   pleaseWaitShow();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

881)   if(typeof(Storage)!=="undefined"){
882)     groups=new GroupList();
883)     groups.loadFromLocalStorage();
884)     refresh_group_list();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

885)     if (jQuery.type(localStorage.user)!='undefined') {
886)       logged_menu();
887)     }
888)     else {
889)       logged_out_menu();
890)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

891)   }
892)   else {
893)     alert('Local storage not supported !');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

895)     return;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

896)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

898) 
Benjamin Renard Add link on App Name in Navbar

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

906) 
907)   $('#clear_local_data').bind('click',clear_local_data);
908) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

914)   $('#subscribe_modal').on('hidden.bs.modal',on_close_subscribe_modal);
915)   $('#subscribe_modal #subscribe_submit').bind('click',on_valid_subscribe_modal);
916)   $('#subscribe_modal form').bind('submit',on_valid_subscribe_modal);
917) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

918)   $('#view-group #contributor').bind('change',on_contributor_change);
919) 
920)   $('#add_contributor_btn').bind('click',on_click_add_contributor_btn);
921)   $('#add_contributor_submit').bind('click',on_valid_add_contributor_modal);
922)   $("#add_contributor_modal").on('shown.bs.modal',on_show_add_contributor_modal);
923)   $("#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

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

926) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

929)   $('#del_contributor_btn').bind('click',on_click_del_contributor_btn);
930) 
931)   $('#add_contribution_btn').bind('click',on_click_add_contribution_btn);
932)   $('#add_contribution_submit').bind('click',on_valid_add_contribution_modal);
933)   $("#add_contribution_modal").on('shown.bs.modal',on_show_add_contribution_modal);
934)   $("#add_contribution_modal").on('hidden.bs.modal',on_close_add_contribution_modal);
935)   $("#add_contribution_modal form").on('submit',on_valid_add_contribution_modal);
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

937) 
938)   $("#display_balance_btn").bind('click',on_display_balance_btn_click);
939) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

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

942) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

946)   
947)   $('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
948)   $("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
949)   
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

951)   pleaseWaitHide();