d872d5a56db8aac85b0c0da9cd8c66599e092373
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 Auto collaspse bottom nav bar

Benjamin Renard authored 10 years ago

71) bottom_navbar_collapse_hide=function() {
72)   if ($('#bottom-navbar-collapse-1').hasClass('in')) {
73)     $('#bottom-navbar-collapse-1').collapse('hide');
74)   }
75) }
76) 
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

77) /****************
78)  * Parts
79)  ****************/
80) 
81) view_part=function(part) {
82)   $('.part').each(function(idx,div) {
83)     $(div).css('display','none');
84)   });
85)   $(part).css('display','block');
86) }
87) 
88) view_home=function() {
Benjamin Renard Hide navbar on view_home

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

90)   if (user) {
91)     $('#view-home #title').html('Bonjour '+user.name);
92)   }
93)   else {
94)     $('#view-home #title').html('Bonjour');
95)   }
96)   if (groups.count()>0) {
97)     tbody=$('#view-home #mybalances tbody');
98)     tbody.html('');
99)     balances=groups.balances();
100)     var sum=0;
101)     for (g in balances) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

102)       if (jQuery.type(balances[g]['balance'][user.email])!='undefined') {
103)         if (balances[g]['balance'][user.email]['diff']<0) {
104)           sum+=balances[g]['balance'][user.email]['diff'];
105)           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

106)         }
107)         else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

109)           sum+=value;
110)           diff='<td class="positive">+'+value.toFixed(2)+' €</td>';
111)         }
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

113)       }
114)     }
Benjamin Renard Make group name as link in...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

117)       if (jQuery.type(groups[g])!='undefined') {
118)         view_group(groups[g]);
119)       }
120)     });
Benjamin Renard Add Categories management

Benjamin Renard authored 10 years ago

121)     $('a.home_grp_cat_btn').each(function(idx,a) {
122)       $(a).bind('click',on_home_grp_cat_btn_click);
123)     });
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

131)   }
132)   else {
133)     $('#view-home #mybalances').css('display','none');
134)   }
135)   view_part('#view-home');
136) }
137) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

138) /****************
139)  * View group
140)  ****************/
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

147) }
148) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

150)   $('#view-group #contributor option').remove();
151)   if(group.contributors.length==0) {
152)     $('#view-group #contributor').append('<option>Aucun participant</option>');
153)   }
154)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

156)       if (email == contributor_email) {
157)         sel=' selected';
158)       }
159)       else {
160)         sel='';
161)       }
162)       $('#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

163)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

164)   }
165) }
166) 
167) on_contributor_change=function(e) {
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

168) 	if ($('#group-navbar-collapse-1').hasClass('in')) {
169) 		$('#group-navbar-collapse-1').collapse('hide');
170) 	}
171) 	$('#view-group #group-username').html($('#view-group #contributor option:selected').text());
172) 	show_contributions(groups[$('#view-group').data('uuid')],$('#view-group #contributor')[0].value);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

173) }
174) 
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

181)   if (contributions.length==0) {
182)     tbody.append('<tr><td colspan=3>Aucune contributions</td></tr>');
183)     total.html('0,00 €');
184)   }
185)   else {
186)     sum=0;
Benjamin Renard Sort contribution by date o...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

191) 	  }
Benjamin Renard Upgrade to bootstrap 3

Benjamin Renard authored 10 years ago

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

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

197)   }
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

198)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

199)   $('.contribution_delete_btn').bind('click',on_contribution_delete_btn_click);
200)   $('.contribution_edit_btn').bind('click',on_contribution_edit_btn_click);
201) }
202) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

203) on_categories_group_btn_click=function(e) {
204)   group=groups[$('#view-group').data('uuid')];
205)   $('#view-group-categories').data('group-uuid',$('#view-group').data('uuid'));
206)   refresh_group_categories(group);
Benjamin Renard Auto collaspse bottom nav bar

Benjamin Renard authored 10 years ago

207)   bottom_navbar_collapse_hide();
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

208)   view_part('#view-group-categories');
209) }
210) 
211) refresh_group_categories=function(group) {
212)   ul=$('#view-group-categories ul');
213)   html="";
214)   for(cid in group.getSortedCategories()) {
215)     html+="<li data-uuid='"+cid+"'><span class='cat-color' style='background-color: "+group.categories[cid]['color']+"'></span> "+group.categories[cid]['name']+"</li>";
216)   }
217)   ul.html(html);
218)   $('#view-group-categories ul li').bind('click',on_categories_group_cat_click);
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

219)   
220)   $('#cats-chart').css('width',$(window).width()*0.9+'px');
221)   
222)   $.plot($('#cats-chart'),group.getCategoriesStats(),{
223)     'grid': {
224)         'hoverable': true
225)     }, 
226)     'legend': {
Benjamin Renard Preserve categories's color...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

228)     },
229)     'series': { 
230)         'pie': {
231)             'show': true,
232)             'innerRadius': 0.5,
Benjamin Renard Improve chart

Benjamin Renard authored 10 years ago

233)             'radius': .8,
234)             'tilt': .5,
Benjamin Renard Add categories chart

Benjamin Renard authored 10 years ago

235)             'label': {
236)                 'show': true,
237)                 'formatter': function (label, series) {
Benjamin Renard Improve chart

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

240)                 }
241)             }
242)         }
243)     }
244) });
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

301) /*****************************
302)  * Trash
303)  *****************************/
304) 
305) on_trash_group_btn_click=function(e) {
306)   group=groups[$('#view-group').data('uuid')];
307)   contributor_email=$('#view-group #contributor')[0].value;
Benjamin Renard Auto collaspse bottom nav bar

Benjamin Renard authored 10 years ago

308)   bottom_navbar_collapse_hide();
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

394) /******************************
395)  * Add/Edit/remove contributor
396)  ******************************/
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

403)   $('#add_contributor_modal').modal('show');
404) }
405) 
406) on_show_add_contributor_modal=function(e) {
407)   $('#add_contributor_modal #add_contributor_name').focus();
408) }
409) 
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

431)     alert('Un contributor utilise déjà cet email !');
432)     return;
433)   }
Benjamin Renard Add contributor's email val...

Benjamin Renard authored 10 years ago

434)   if (!validateEmail(email)) {
435)     alert('Email invalide !');
436)     return;
437)   }
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

438)   if(edit_id=='-1') {
439)     group.addContributor(new Contributor(name,email));
440)   }
441)   else {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

443)   }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

444)   set_contributors(group);
445)   $('#add_contributor_modal').modal('hide');
446)   groups.save();
Benjamin Renard Display contribution of con...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

448) }
449) 
450) on_close_add_contributor_modal=function () {
451)   $('#add_contributor_name')[0].value='';
452)   $('#add_contributor_email')[0].value='';
453) }
454) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

464)   $($('#add_contributor_modal h4')[0]).html('Editer un participant');
465)   $($('#add_contributor_modal #add_contributor_submit')[0]).html('Valider');
466)   $('#add_contributor_modal').modal('show');
467) }
468) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

473)   myconfirm(question,on_confirm_del_contributor,null,contributor);
474) }
475) 
476) on_confirm_del_contributor=function(contributor) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

479)   view_group(group);
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

480)   groups.save();
481) }
482) 
483) /********************************
484)  * Add/edit/delete contribution
485)  ********************************/
486) on_show_add_contribution_modal=function(e) {
Benjamin Renard Manage contributor by their...

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

497)   $('#add_contribution_modal #add_contribution_category')[0].value=current_cat;
Benjamin Renard Fixed autocomplete

Benjamin Renard authored 10 years ago

498)   $('#add_contribution_modal #add_contribution_title').typeahead('destroy');
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

499)   $('#add_contribution_modal #add_contribution_title').typeahead({
500)     hint: true,
501)     highlight: true,
502)     minLength: 1
503)   },
504)   {
505)     name: 'titles',
506)     displayKey: 'value',
507)     source: group.findContributionByTitleMatches()
508)   });
509) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

510)   $('#add_contribution_modal #add_contribution_title').focus();
511) }
512) 
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

513) on_select_contribution_suggestion=function(event,choice,name) {
514)   if (jQuery.type(choice['category'])=='string') {
Benjamin Renard Fixed autocomplete

Benjamin Renard authored 10 years ago

515)     $('#add_contribution_modal #add_contribution_category').val(choice['category']);
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

516)   }
517) }
518) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

525)   $('#add_contribution_modal').modal('show');
526) }
527) 
528) on_valid_add_contribution_modal=function(e) {
529)   e.preventDefault();
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

550)     $('#add_contribution_cost')[0].focus();
551)     alert('Coût incorrect !');
552)     return;
553)   }
554)   cost=parseFloat(cost.replace(',','.'));
Benjamin Renard Clean code

Benjamin Renard authored 10 years ago

555)   
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

573)   
Benjamin Renard Fix category management

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

577) 	return;
578)   }
579)   
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

582)   }
583)   else {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

588)   $('#add_contribution_modal').modal('hide');
589)   $('#add_contribution_modal form')[0].reset();
590)   groups.save();
591) }
592) 
593) on_close_add_contribution_modal=function () {
594)   $('#add_contribution_modal form')[0].reset();
595) }
596) 
597) on_contribution_delete_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

602) }
603) 
604) on_confirm_contribution_delete=function(data) {
Benjamin Renard Use UUID as Contribution id...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

606)   groups.save();
607)   on_contributor_change();
608) }
609) 
610) on_contribution_edit_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

625)   $('#add_contribution_modal').modal('show');
626) }
627) 
628) 
629) 
630) /********************
631)  * Clear local data
632)  ********************/
633) clear_local_data=function() {
Benjamin Renard Add function navbar_collaps...

Benjamin Renard authored 10 years ago

634)   navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

639)   delete localStorage.groups;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

640)   location.reload();
641) }
642) 
643) /*********************
644)  * View balance
645)  *********************/
646) 
647) on_display_balance_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

649)   display_balance(group);
650) }
651) 
652) display_balance=function(group) {
653)   bal=group.balance();
654)   tbody=$($('#display_balance_modal tbody')[0]);
655)   tbody.html('');
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

664)   }
Benjamin Renard Improve balance display

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

666)   $('#display_balance_modal').modal('show');
667) }
668) 
669) /*********************
670)  * Remove group
671)  *********************/
672) 
673) on_remove_group_btn_click=function(e) {
Benjamin Renard Add uuid to group and refer...

Benjamin Renard authored 10 years ago

674)   group=groups[$('#view-group').data('uuid')];
Benjamin Renard Auto collaspse bottom nav bar

Benjamin Renard authored 10 years ago

675)   bottom_navbar_collapse_hide();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

681)     groups.save();
682)     location.reload();
683)   }
684)   else {
685)     alert('Erreur en supprimant le groupe '+group.name+' :(');
686)   }
687) }
688) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

689) /********************
690)  * Login
691)  ********************/
692) on_close_login_modal=function(e) {
693)   $('#login_modal form')[0].reset();
694) }
695) 
696) sync_server=false;
697) on_valid_login_modal=function(e) {
Benjamin Renard Manage submit event in moda...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

699)   email=$('#login_modal #login_email')[0].value;
700)   pass=$('#login_modal #login_pass')[0].value;
701)   server=$('#login_modal #login_server')[0].value;
702)   $('#login_modal').modal('hide');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

704)   sync_server.login(server,email,pass,
705)     function(data) {
706)       localStorage.user=JSON.stringify({
707)         'name': data.name,
708)         'email': email,
709)         'password': pass,
710)         'server': server,
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

714)       logged_menu();
715)     },
716)     function(data) {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

718)       if (jQuery.type(data) != 'object' && data.loginerror) {
719)         alert(data.loginerror);
720)       }
721)       else {
722)         console.log(data);
723)         alert('Erreur durant la connexion au serveur');
724)       }
725)     }
726)   );
727) }
728) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

729) on_click_go_to_subscribe_btn=function() {
730)   $('#login_modal').modal('hide');
731)   $('#subscribe_modal').modal('show');
732) }
733) 
734) /********************
735)  * Subscribe
736)  ********************/
737) on_close_subscribe_modal=function(e) {
738)   $('#subscribe_modal form')[0].reset();
739) }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

740) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

774) 
775) /********************
776)  * Sync
777)  ********************/
778) on_click_sync_btn=function(e) {
Benjamin Renard Hide navbar after sync btn...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

782)     onsuccess=function(data) {
783)       console.log(data);
784)       if (data.groups) {
785)         groups.import(data.groups);
786)         groups.save();
bn8 Add lastsync information to...

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

792)         alert('Groupes synchronisés');
793)       }
794)       else {
795)         onerror(data);
796)       }
797)     }
798)     onerror=function(data) {
799)       pleaseWaitHide();
800)       console.log(data);
801)       if (jQuery.type(data['loginerror'])!='undefined') {
802)         alert(data['loginerror']);
803)       }
804)       else if (jQuery.type(data['syncerror'])!='undefined') {
805)         alert(data['syncerror']);
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

807)       else {
808)         alert('Erreur durant la synchronisation :(');
809)       }
810)     }
811)     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

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

839)   $('#user-name').html('Connexion');
840)   $('#user-menu li').remove();
841)   menu=$('#user-menu');
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

846) }
847) 
848) on_click_myaccount_btn=function() {
849)   $('#myaccount_modal #myaccount_email').html(user.email);
850)   $('#myaccount_modal #myaccount_name')[0].value=user.name;
Benjamin Renard Display server in myaccount...

Benjamin Renard authored 10 years ago

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

bn8 authored 10 years ago

852)   if (user.lastsync) {
853)     $('#myaccount_modal #myaccount_lastsync').html(moment(user.lastsync).format('DD/MM/YYYY HH:mm:ss'));
854)   }
855)   else {
856)     $('#myaccount_modal #myaccount_lastsync').html('Jamais synchronis&eacute;');
857)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

858)   $('#myaccount_modal').modal('show');
859) }
860) 
861) on_click_login_btn=function() {
862)   $('#login_modal').modal('show');
863) }
864) 
Benjamin Renard Add subscribe feature

Benjamin Renard authored 10 years ago

865) on_click_subscribe_btn=function() {
866)   $('#subscribe_modal').modal('show');
867) }
868) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

869) on_click_logoff_btn=function() {
870)   delete localStorage.user;
871)   logged_out_menu();
872) }
873) 
Benjamin Renard Add pleaseWaitDialog and fu...

Benjamin Renard authored 10 years ago

874) /*******************
875)  * pleaseWaitDialog
876)  *******************/
877) 
878) pleaseWaitShow=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

880) }
881) 
882) pleaseWaitHide=function() {
Benjamin Renard Fix please wait modal

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

884) }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

885) 
886) /*********************
887)  * Activate
888)  *********************/
889) $( document ).ready( function() {
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

890)   pleaseWaitShow();
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

891)   if(typeof(Storage)!=="undefined"){
892)     groups=new GroupList();
893)     groups.loadFromLocalStorage();
894)     refresh_group_list();
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

895)     if (jQuery.type(localStorage.user)!='undefined') {
896)       logged_menu();
897)     }
898)     else {
899)       logged_out_menu();
900)     }
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

901)   }
902)   else {
903)     alert('Local storage not supported !');
Benjamin Renard Use pleaseWaitDialog in som...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

905)     return;
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

906)   }
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

908) 
Benjamin Renard Add link on App Name in Navbar

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

916) 
917)   $('#clear_local_data').bind('click',clear_local_data);
918) 
Benjamin Renard Add login and sync support

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

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

Benjamin Renard authored 10 years ago

924)   $('#subscribe_modal').on('hidden.bs.modal',on_close_subscribe_modal);
925)   $('#subscribe_modal #subscribe_submit').bind('click',on_valid_subscribe_modal);
926)   $('#subscribe_modal form').bind('submit',on_valid_subscribe_modal);
927) 
Benjamin Renard Initial commit

Benjamin Renard authored 10 years ago

928)   $('#view-group #contributor').bind('change',on_contributor_change);
929) 
930)   $('#add_contributor_btn').bind('click',on_click_add_contributor_btn);
931)   $('#add_contributor_submit').bind('click',on_valid_add_contributor_modal);
932)   $("#add_contributor_modal").on('shown.bs.modal',on_show_add_contributor_modal);
933)   $("#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

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

bn8 authored 10 years ago

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

Benjamin Renard authored 10 years ago

936) 
Benjamin Renard Add edit contributor feature

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

939)   $('#del_contributor_btn').bind('click',on_click_del_contributor_btn);
940) 
941)   $('#add_contribution_btn').bind('click',on_click_add_contribution_btn);
942)   $('#add_contribution_submit').bind('click',on_valid_add_contribution_modal);
943)   $("#add_contribution_modal").on('shown.bs.modal',on_show_add_contribution_modal);
944)   $("#add_contribution_modal").on('hidden.bs.modal',on_close_add_contribution_modal);
945)   $("#add_contribution_modal form").on('submit',on_valid_add_contribution_modal);
Benjamin Renard Manage contribution suggest...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

947) 
948)   $("#display_balance_btn").bind('click',on_display_balance_btn_click);
949) 
Benjamin Renard Add possibility to view trash

Benjamin Renard authored 10 years ago

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

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

952) 
Benjamin Renard Replace categories modal by...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

956)   
957)   $('#view-group-categories span.input-group-addon').bind('click',on_categories_group_add_btn_click);
958)   $("#view-group-categories button.go-back-group").bind('click',on_categories_go_back_group_btn_click);
959)   
Benjamin Renard Manage multiple screen part...

Benjamin Renard authored 10 years ago

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

Benjamin Renard authored 10 years ago

961)   pleaseWaitHide();