8941aab2c6601f5955a151f557bc5a32d64649f4
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,
226)             'radius': 1,
227)             'label': {
228)                 'show': true,
229)                 'radius': 3/4,
230)                 'background': {
231)                     'opacity': 0.5,
232)                     'color': '#000000',
233)                 },
234)                 'formatter': function (label, series) {
235) return '<div class="cats-chart-label">' + label + '<br/>' +   
236)                             Math.round(series.percent) + '%</div>';
237)                 }
238)             }
239)         }
240)     }
241) });
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

390) /******************************
391)  * Add/Edit/remove contributor
392)  ******************************/
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

399)   $('#add_contributor_modal').modal('show');
400) }
401) 
402) on_show_add_contributor_modal=function(e) {
403)   $('#add_contributor_modal #add_contributor_name').focus();
404) }
405) 
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

427)     alert('Un contributor utilise déjà cet email !');
428)     return;
429)   }
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

430)   if (!validateEmail(email)) {
431)     alert('Email invalide !');
432)     return;
433)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

434)   if(edit_id=='-1') {
435)     group.addContributor(new Contributor(name,email));
436)   }
437)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

439)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

440)   set_contributors(group);
441)   $('#add_contributor_modal').modal('hide');
442)   groups.save();
Benjamin Renard Display contribution of con...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

444) }
445) 
446) on_close_add_contributor_modal=function () {
447)   $('#add_contributor_name')[0].value='';
448)   $('#add_contributor_email')[0].value='';
449) }
450) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

460)   $($('#add_contributor_modal h4')[0]).html('Editer un participant');
461)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Valider');
462)   $('#add_contributor_modal').modal('show');
463) }
464) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

469)   myconfirm(question,on_confirm_del_contributor,null,contributor);
470) }
471) 
472) on_confirm_del_contributor=function(contributor) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

475)   view_group(group);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

476)   groups.save();
477) }
478) 
479) /********************************
480)  * Add/edit/delete contribution
481)  ********************************/
482) on_show_add_contribution_modal=function(e) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

505)   $('#add_contribution_modal #add_contribution_title').focus();
506) }
507) 
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

520)   $('#add_contribution_modal').modal('show');
521) }
522) 
523) on_valid_add_contribution_modal=function(e) {
524)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

545)     $('#add_contribution_cost')[0].focus();
546)     alert('Coût incorrect !');
547)     return;
548)   }
549)   cost=parseFloat(cost.replace(',','.'));
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

550)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

568)   
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

572) 	return;
573)   }
574)   
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

577)   }
578)   else {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

597) }
598) 
599) on_confirm_contribution_delete=function(data) {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

601)   groups.save();
602)   on_contributor_change();
603) }
604) 
605) on_contribution_edit_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

620)   $('#add_contribution_modal').modal('show');
621) }
622) 
623) 
624) 
625) /********************
626)  * Clear local data
627)  ********************/
628) clear_local_data=function() {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

629)   navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

634)   delete localStorage.groups;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

635)   location.reload();
636) }
637) 
638) /*********************
639)  * View balance
640)  *********************/
641) 
642) on_display_balance_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

644)   display_balance(group);
645) }
646) 
647) display_balance=function(group) {
648)   bal=group.balance();
649)   tbody=$($('#display_balance_modal tbody')[0]);
650)   tbody.html('');
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

659)   }
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

661)   $('#display_balance_modal').modal('show');
662) }
663) 
664) /*********************
665)  * Remove group
666)  *********************/
667) 
668) on_remove_group_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

693)   email=$('#login_modal #login_email')[0].value;
694)   pass=$('#login_modal #login_pass')[0].value;
695)   server=$('#login_modal #login_server')[0].value;
696)   $('#login_modal').modal('hide');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

698)   sync_server.login(server,email,pass,
699)     function(data) {
700)       localStorage.user=JSON.stringify({
701)         'name': data.name,
702)         'email': email,
703)         'password': pass,
704)         'server': server,
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

706)       });
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)       logged_menu();
709)     },
710)     function(data) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

734) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

768) 
769) /********************
770)  * Sync
771)  ********************/
772) on_click_sync_btn=function(e) {
Benjamin Renard Hide navbar after sync btn...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

776)     onsuccess=function(data) {
777)       console.log(data);
778)       if (data.groups) {
779)         groups.import(data.groups);
780)         groups.save();
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

801)       else {
802)         alert('Erreur durant la synchronisation :(');
803)       }
804)     }
805)     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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

833)   $('#user-name').html('Connexion');
834)   $('#user-menu li').remove();
835)   menu=$('#user-menu');
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

840) }
841) 
842) on_click_myaccount_btn=function() {
843)   $('#myaccount_modal #myaccount_email').html(user.email);
844)   $('#myaccount_modal #myaccount_name')[0].value=user.name;
Benjamin Renard Display server in myaccount...

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

852)   $('#myaccount_modal').modal('show');
853) }
854) 
855) on_click_login_btn=function() {
856)   $('#login_modal').modal('show');
857) }
858) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

859) on_click_subscribe_btn=function() {
860)   $('#subscribe_modal').modal('show');
861) }
862) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

863) on_click_logoff_btn=function() {
864)   delete localStorage.user;
865)   logged_out_menu();
866) }
867) 
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

868) /*******************
869)  * pleaseWaitDialog
870)  *******************/
871) 
872) pleaseWaitShow=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

874) }
875) 
876) pleaseWaitHide=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

878) }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

879) 
880) /*********************
881)  * Activate
882)  *********************/
883) $( document ).ready( function() {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

884)   pleaseWaitShow();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

885)   if(typeof(Storage)!=="undefined"){
886)     groups=new GroupList();
887)     groups.loadFromLocalStorage();
888)     refresh_group_list();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

889)     if (jQuery.type(localStorage.user)!='undefined') {
890)       logged_menu();
891)     }
892)     else {
893)       logged_out_menu();
894)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

895)   }
896)   else {
897)     alert('Local storage not supported !');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

899)     return;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

900)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

902) 
Benjamin Renard Add link on App Name in Navbar

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

910) 
911)   $('#clear_local_data').bind('click',clear_local_data);
912) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

918)   $('#subscribe_modal').on('hidden.bs.modal',on_close_subscribe_modal);
919)   $('#subscribe_modal #subscribe_submit').bind('click',on_valid_subscribe_modal);
920)   $('#subscribe_modal form').bind('submit',on_valid_subscribe_modal);
921) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

930) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

941) 
942)   $("#display_balance_btn").bind('click',on_display_balance_btn_click);
943) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

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

946) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

950)   
951)   $('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
952)   $("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
953)   
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

955)   pleaseWaitHide();