2014-01-06 01:46:22 +01:00
refresh _group _list = function ( ) {
grouplist = $ ( '#group-choice' ) [ 0 ] ;
$ ( 'a.group-choice' ) . each ( function ( idx , a ) {
$ ( a ) . parent ( ) . remove ( ) ;
} ) ;
if ( groups . count ( ) == 0 ) {
$ ( grouplist ) . prepend ( '<li><a class="group-choice">Aucune groupe</a></li>' ) ;
}
else {
groups . each ( function ( idx , group ) {
$ ( grouplist ) . prepend ( '<li><a class="group-choice">' + group . name + '</a></li>' ) ;
} ) ;
$ ( 'a.group-choice' ) . each ( function ( idx , a ) {
$ ( a ) . bind ( 'click' , on _group _choice _click ) ;
} ) ;
}
}
/ * * * * * * * * * * * * * * * *
* Add group
* * * * * * * * * * * * * * * * /
2014-01-06 17:10:33 +01:00
on _click _add _group _btn = function ( e ) {
2014-01-06 17:22:09 +01:00
navbar _collapse _hide ( ) ;
2014-01-06 17:10:33 +01:00
$ ( '#add_group_modal' ) . modal ( 'show' ) ;
}
2014-01-06 01:46:22 +01:00
on _show _add _group _modal = function ( e ) {
$ ( '#add_group_modal #add_group_name' ) . focus ( ) ;
}
on _valid _add _group _modal = function ( ) {
var name = $ ( '#add_group_name' ) [ 0 ] . value ;
if ( name == '' ) {
alert ( 'Vous devez saisir un nom !' ) ;
return ;
}
if ( groups [ name ] !== undefined ) {
alert ( 'Ce groupe exite déjà !' ) ;
return ;
}
groups [ name ] = new Group ( name ) ;
refresh _group _list ( ) ;
$ ( '#add_group_modal' ) . modal ( 'hide' ) ;
groups . save ( ) ;
view _group ( groups [ name ] ) ;
}
on _close _add _group _modal = function ( ) {
2014-01-06 02:11:09 +01:00
$ ( '#add_group_modal form' ) [ 0 ] . reset ( ) ;
2014-01-06 01:46:22 +01:00
}
/ * * * * * * * * * * * * * * * *
* Nav bars
* * * * * * * * * * * * * * * * /
on _group _choice _click = function ( e ) {
view _group ( groups [ $ ( e . target ) . html ( ) ] ) ;
2014-01-06 17:22:09 +01:00
navbar _collapse _hide ( ) ;
}
navbar _collapse _hide = function ( ) {
if ( $ ( '#navbar-groupe-collapse' ) . hasClass ( 'in' ) ) {
$ ( '#navbar-groupe-collapse' ) . collapse ( 'hide' ) ;
}
2014-01-06 01:46:22 +01:00
}
/ * * * * * * * * * * * * * * * *
* View group
* * * * * * * * * * * * * * * * /
view _group = function ( group ) {
2014-01-06 03:03:17 +01:00
$ ( '#view-group h1 span:first' ) . html ( group . name ) ;
$ ( '#view-group #group_name' ) [ 0 ] . value = group . name ;
2014-01-06 01:46:22 +01:00
set _contributors ( group ) ;
on _contributor _change ( ) ;
$ ( '#view-group' ) . css ( 'display' , 'block' ) ;
}
set _contributors = function ( group ) {
$ ( '#view-group #contributor option' ) . remove ( ) ;
if ( group . contributors . length == 0 ) {
$ ( '#view-group #contributor' ) . append ( '<option>Aucun participant</option>' ) ;
}
else {
$ ( group . contributors ) . each ( function ( idx , c ) {
$ ( '#view-group #contributor' ) . append ( '<option value="' + c . name + '">' + c . name + '</option>' ) ;
} ) ;
}
}
on _contributor _change = function ( e ) {
2014-01-06 03:03:17 +01:00
show _contributions ( groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] , $ ( '#view-group #contributor' ) [ 0 ] . value ) ;
2014-01-06 01:46:22 +01:00
}
show _contributions = function ( group , contributor _name ) {
var tbody = $ ( $ ( '#view-group #contributions tbody' ) [ 0 ] ) ;
tbody . html ( '' ) ;
total = $ ( $ ( '#view-group #total-value' ) [ 0 ] ) ;
contributions = group . contributionsByContributorName ( contributor _name ) ;
if ( contributions . length == 0 ) {
tbody . append ( '<tr><td colspan=3>Aucune contributions</td></tr>' ) ;
total . html ( '0,00 €' ) ;
}
else {
sum = 0 ;
for ( idx in contributions ) {
col _actions = '<td><div class="btn-group" data-id="' + contributions [ idx ] . id + '"><button type="button" class="btn btn-default contribution_edit_btn"><span class="glyphicon glyphicon-edit"></span></button><button type="button" class="btn btn-default contribution_delete_btn"><span class="glyphicon glyphicon-trash"></span></button></div></td>' ;
tbody . append ( '<tr><td>' + contributions [ idx ] . getTitle ( ) + '</td><td>' + contributions [ idx ] . cost + ' €</td>' + col _actions + '</tr>' ) ;
sum += contributions [ idx ] . cost ;
}
total . html ( sum + ' €' ) ;
}
2014-01-12 01:11:24 +01:00
2014-01-06 01:46:22 +01:00
$ ( '.contribution_delete_btn' ) . bind ( 'click' , on _contribution _delete _btn _click ) ;
$ ( '.contribution_edit_btn' ) . bind ( 'click' , on _contribution _edit _btn _click ) ;
}
2014-01-06 03:04:57 +01:00
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Add / Edit / remove contributor
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
2014-01-06 01:46:22 +01:00
on _click _add _contributor _btn = function ( ) {
2014-01-06 03:03:17 +01:00
$ ( '#add_contributor_modal #group_name' ) [ 0 ] . value = $ ( '#view-group #group_name' ) [ 0 ] . value ;
2014-01-06 03:04:57 +01:00
$ ( $ ( '#add_contributor_modal h4' ) [ 0 ] ) . html ( 'Ajouter un participant' ) ;
$ ( $ ( '#add_contributor_modal #add_contributor_submit' ) [ 0 ] ) . html ( 'Ajouter' ) ;
$ ( '#view-group #edit_id' ) [ 0 ] . value = '-1' ;
2014-01-06 01:46:22 +01:00
$ ( '#add_contributor_modal' ) . modal ( 'show' ) ;
}
on _show _add _contributor _modal = function ( e ) {
$ ( '#add_contributor_modal #add_contributor_name' ) . focus ( ) ;
}
on _valid _add _contributor _modal = function ( ) {
var group = groups [ $ ( '#add_contributor_modal #group_name' ) [ 0 ] . value ] ;
var name = $ ( '#add_contributor_name' ) [ 0 ] . value ;
2014-01-06 03:04:57 +01:00
edit _id = $ ( '#view-group #edit_id' ) [ 0 ] . value ;
2014-01-06 01:46:22 +01:00
if ( name == '' ) {
alert ( 'Vous devez saisir un nom !' ) ;
return ;
}
2014-01-06 03:04:57 +01:00
duplicate = group . contributorByName ( name ) ;
if ( duplicate != undefined && duplicate . id != edit _id ) {
2014-01-06 01:46:22 +01:00
alert ( 'Un contributor porte déjà ce nom !' ) ;
return ;
}
var email = $ ( '#add_contributor_email' ) [ 0 ] . value ;
if ( email == '' ) {
alert ( 'Vous devez saisir un email !' ) ;
return ;
}
2014-01-06 03:04:57 +01:00
duplicate = group . contributorByEmail ( email )
if ( duplicate != undefined && duplicate . id != edit _id ) {
2014-01-06 01:46:22 +01:00
alert ( 'Un contributor utilise déjà cet email !' ) ;
return ;
}
2014-01-06 03:04:57 +01:00
if ( edit _id == '-1' ) {
group . addContributor ( new Contributor ( name , email ) ) ;
}
else {
group . replaceContributor ( edit _id , new Contributor ( name , email ) ) ;
}
2014-01-06 01:46:22 +01:00
set _contributors ( group ) ;
$ ( '#add_contributor_modal' ) . modal ( 'hide' ) ;
$ ( '#add_contributor_name' ) [ 0 ] . value = '' ;
$ ( '#add_contributor_email' ) [ 0 ] . value = '' ;
groups . save ( ) ;
}
on _close _add _contributor _modal = function ( ) {
$ ( '#add_contributor_name' ) [ 0 ] . value = '' ;
$ ( '#add_contributor_email' ) [ 0 ] . value = '' ;
}
2014-01-06 03:04:57 +01:00
on _edit _contributor _btn _click = function ( e ) {
var group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
$ ( '#add_contributor_modal #group_name' ) [ 0 ] . value = group . name ;
contributor _name = $ ( '#view-group #contributor' ) [ 0 ] . value ;
contributor = group . contributorByName ( contributor _name ) ;
$ ( '#view-group #edit_id' ) [ 0 ] . value = contributor . id ;
$ ( '#add_contributor_modal #add_contributor_name' ) [ 0 ] . value = contributor . name ;
$ ( '#add_contributor_modal #add_contributor_email' ) [ 0 ] . value = contributor . email ;
$ ( $ ( '#add_contributor_modal h4' ) [ 0 ] ) . html ( 'Editer un participant' ) ;
$ ( $ ( '#add_contributor_modal #add_contributor_submit' ) [ 0 ] ) . html ( 'Valider' ) ;
$ ( '#add_contributor_modal' ) . modal ( 'show' ) ;
}
2014-01-06 01:46:22 +01:00
on _click _del _contributor _btn = function ( ) {
contributor = $ ( '#view-group #contributor' ) [ 0 ] . value ;
question = 'Voulez-vous vraiment supprimer ' + contributor + ' ?' ;
myconfirm ( question , on _confirm _del _contributor , null , contributor ) ;
}
on _confirm _del _contributor = function ( contributor ) {
2014-01-06 03:03:17 +01:00
var group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
2014-01-06 01:46:22 +01:00
group . removeContributor ( contributor ) ;
set _contributors ( group ) ;
groups . save ( ) ;
}
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Add / edit / delete contribution
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
on _show _add _contribution _modal = function ( e ) {
var cs = $ ( $ ( '#add_contribution_modal #add_contribution_contributor_name' ) [ 0 ] ) ;
cs . html ( '' ) ;
$ ( '#view-group #contributor option' ) . each ( function ( idx , option ) {
cs . append ( $ ( option ) . clone ( ) ) ;
} ) ;
cs [ 0 ] . value = $ ( '#view-group #contributor' ) [ 0 ] . value ;
$ ( '#add_contribution_modal #add_contribution_title' ) . focus ( ) ;
}
on _click _add _contribution _btn = function ( ) {
2014-01-06 03:03:17 +01:00
$ ( '#add_contribution_modal #group_name' ) [ 0 ] . value = $ ( '#view-group #group_name' ) [ 0 ] . value ;
2014-01-06 01:46:22 +01:00
$ ( '#add_contribution_modal #edit_id' ) [ 0 ] . value = '-1' ;
2014-01-06 03:06:04 +01:00
$ ( $ ( '#add_contribution_modal h4' ) [ 0 ] ) . html ( 'Ajouter une contribution' ) ;
$ ( $ ( '#add_contribution_modal #add_contribution_submit' ) [ 0 ] ) . html ( 'Ajouter' ) ;
2014-01-06 01:46:22 +01:00
$ ( '#add_contribution_modal' ) . modal ( 'show' ) ;
}
on _valid _add _contribution _modal = function ( e ) {
e . preventDefault ( ) ;
var group = groups [ $ ( '#add_contribution_modal #group_name' ) [ 0 ] . value ] ;
var contributor _name = $ ( '#add_contribution_contributor_name' ) [ 0 ] . value ;
var contributor = group . contributorByName ( contributor _name ) ;
if ( contributor == undefined ) {
alert ( 'Participant inconu !' ) ;
return ;
}
var title = $ ( '#add_contribution_title' ) [ 0 ] . value ;
if ( title == '' ) {
$ ( '#add_contribution_title' ) [ 0 ] . focus ( ) ;
alert ( 'Vous devez saisir un titre !' ) ;
return ;
}
var cost = $ ( '#add_contribution_cost' ) [ 0 ] . value ;
if ( cost == '' ) {
$ ( '#add_contribution_cost' ) [ 0 ] . focus ( ) ;
alert ( 'Vous devez saisir un coût !' ) ;
return ;
}
2014-01-06 02:11:43 +01:00
else if ( ! RegExp ( '^[0-9]*((,|\.)[0-9]{1,2})*$' ) . test ( cost ) ) {
2014-01-06 01:46:22 +01:00
$ ( '#add_contribution_cost' ) [ 0 ] . focus ( ) ;
alert ( 'Coût incorrect !' ) ;
return ;
}
cost = parseFloat ( cost . replace ( ',' , '.' ) ) ;
2014-01-12 01:11:24 +01:00
2014-01-06 01:46:22 +01:00
var date = $ ( '#add_contribution_date' ) [ 0 ] . value ;
if ( date != '' ) {
if ( ! RegExp ( '^[0-3][0-9]\/[0-1][0-9]\/[0-2][0-9][0-9][0-9]$' ) . test ( date ) ) {
$ ( '#add_contribution_date' ) [ 0 ] . focus ( ) ;
alert ( 'Date incorrect !' ) ;
return ;
}
date = moment ( date , 'DD-MM-YYYY' ) . toDate ( ) ;
if ( jQuery . type ( date ) != 'date' ) {
alert ( 'Date non-reconnu !' ) ;
return ;
}
}
else {
date = new Date ( ) ;
}
2014-01-12 01:11:24 +01:00
2014-01-06 01:46:22 +01:00
if ( $ ( '#add_contribution_modal #edit_id' ) [ 0 ] . value == '-1' ) {
group . addContribution ( new Contribution ( contributor , cost , title , date ) ) ;
}
else {
contribution _id = $ ( '#add_contribution_modal #edit_id' ) [ 0 ] . value ;
group . replaceContribution ( contribution _id , new Contribution ( contributor , cost , title , date ) ) ;
}
show _contributions ( group , contributor _name ) ;
$ ( '#add_contribution_modal' ) . modal ( 'hide' ) ;
$ ( '#add_contribution_modal form' ) [ 0 ] . reset ( ) ;
groups . save ( ) ;
}
on _close _add _contribution _modal = function ( ) {
$ ( '#add_contribution_modal form' ) [ 0 ] . reset ( ) ;
}
on _contribution _delete _btn _click = function ( e ) {
2014-01-06 03:03:17 +01:00
var group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
2014-01-06 01:46:22 +01:00
contribution _id = $ ( $ ( e . target ) . parents ( 'div' ) [ 0 ] ) . data ( 'id' ) ;
contribution = group . contributions [ contribution _id ] ;
myconfirm ( 'Etes-vous sûre de vouloir supprimer la participation ' + contribution . getTitle ( ) + ' de ' + contribution . contributor . name + ' ?' , on _confirm _contribution _delete , null , { 'group' : group , 'contribution_id' : contribution _id , 'contribution' : contribution } ) ;
}
on _confirm _contribution _delete = function ( data ) {
delete data . group . contributions [ data . contribution _id ] ;
groups . save ( ) ;
on _contributor _change ( ) ;
}
on _contribution _edit _btn _click = function ( e ) {
2014-01-06 03:03:17 +01:00
var group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
$ ( '#add_contribution_modal #group_name' ) [ 0 ] . value = $ ( '#view-group #group_name' ) [ 0 ] . value ;
2014-01-06 03:06:04 +01:00
$ ( $ ( '#add_contribution_modal h4' ) [ 0 ] ) . html ( 'Editer une contribution' ) ;
$ ( $ ( '#add_contribution_modal #add_contribution_submit' ) [ 0 ] ) . html ( 'Valider' ) ;
2014-01-06 01:46:22 +01:00
contribution _id = $ ( $ ( e . target ) . parents ( 'div' ) [ 0 ] ) . data ( 'id' ) ;
contribution = group . contributions [ contribution _id ] ;
$ ( '#add_contribution_modal #add_contribution_contributor_name' ) [ 0 ] . value = contribution . contributor . name ;
$ ( '#add_contribution_modal #add_contribution_title' ) [ 0 ] . value = contribution . getTitle ( ) ;
$ ( '#add_contribution_modal #add_contribution_cost' ) [ 0 ] . value = contribution . cost ;
$ ( '#add_contribution_modal #add_contribution_date' ) [ 0 ] . value = moment ( contribution . date ) . format ( 'DD/MM/YYYY' ) ;
$ ( '#add_contribution_modal #edit_id' ) [ 0 ] . value = contribution _id ;
$ ( '#add_contribution_modal' ) . modal ( 'show' ) ;
}
/ * * * * * * * * * * * * * * * * * * * *
* Clear local data
* * * * * * * * * * * * * * * * * * * * /
clear _local _data = function ( ) {
2014-01-06 17:22:09 +01:00
navbar _collapse _hide ( ) ;
2014-01-06 01:46:22 +01:00
myconfirm ( 'Etes-vous sûre de vouloir supprimer les données locales ?' , on _confirm _clear _local _data ) ;
}
on _confirm _clear _local _data = function ( data ) {
localStorage . clear ( ) ;
location . reload ( ) ;
}
/ * * * * * * * * * * * * * * * * * * * * *
* View balance
* * * * * * * * * * * * * * * * * * * * * /
on _display _balance _btn _click = function ( e ) {
2014-01-06 03:03:17 +01:00
group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
2014-01-06 01:46:22 +01:00
display _balance ( group ) ;
}
display _balance = function ( group ) {
bal = group . balance ( ) ;
tbody = $ ( $ ( '#display_balance_modal tbody' ) [ 0 ] ) ;
tbody . html ( '' ) ;
2014-01-12 20:07:01 +01:00
for ( c in bal [ 'balance' ] ) {
if ( bal [ 'balance' ] [ c ] [ 'diff' ] < 0 ) {
diff = '<td class="negative">' + bal [ 'balance' ] [ c ] [ 'diff' ] . toFixed ( 2 ) + ' €</td>' ;
}
else {
diff = '<td><span class="glyphicon glyphicon-thumbs-up"></span></td>' ;
}
tbody . append ( '<tr><td>' + c + '</td><td>' + bal [ 'balance' ] [ c ] [ 'total' ] + ' €</td>' + diff + '</tr>' ) ;
2014-01-06 01:46:22 +01:00
}
2014-01-12 20:07:01 +01:00
$ ( '#display_balance_modal #total-value' ) . html ( bal . sum . toFixed ( 2 ) + ' €' ) ;
2014-01-06 01:46:22 +01:00
$ ( '#display_balance_modal' ) . modal ( 'show' ) ;
}
/ * * * * * * * * * * * * * * * * * * * * *
* Remove group
* * * * * * * * * * * * * * * * * * * * * /
on _remove _group _btn _click = function ( e ) {
2014-01-06 03:03:17 +01:00
group = groups [ $ ( '#view-group #group_name' ) [ 0 ] . value ] ;
2014-01-06 01:46:22 +01:00
myconfirm ( 'Etes-vous sûre de vouloir supprimer le group ' + group . name + ' ?' , on _confirm _remove _group , null , group ) ;
}
on _confirm _remove _group = function ( group ) {
if ( groups . removeGroup ( group . name ) ) {
groups . save ( ) ;
location . reload ( ) ;
}
else {
alert ( 'Erreur en supprimant le groupe ' + group . name + ' :(' ) ;
}
}
2014-01-12 01:24:16 +01:00
/ * * * * * * * * * * * * * * * * * * * *
* Login
* * * * * * * * * * * * * * * * * * * * /
on _close _login _modal = function ( e ) {
$ ( '#login_modal form' ) [ 0 ] . reset ( ) ;
}
sync _server = false ;
on _valid _login _modal = function ( e ) {
email = $ ( '#login_modal #login_email' ) [ 0 ] . value ;
pass = $ ( '#login_modal #login_pass' ) [ 0 ] . value ;
server = $ ( '#login_modal #login_server' ) [ 0 ] . value ;
$ ( '#login_modal' ) . modal ( 'hide' ) ;
sync _server . login ( server , email , pass ,
function ( data ) {
localStorage . user = JSON . stringify ( {
'name' : data . name ,
'email' : email ,
'password' : pass ,
'server' : server ,
} ) ;
logged _menu ( ) ;
} ,
function ( data ) {
if ( jQuery . type ( data ) != 'object' && data . loginerror ) {
alert ( data . loginerror ) ;
}
else {
console . log ( data ) ;
alert ( 'Erreur durant la connexion au serveur' ) ;
}
}
) ;
}
/ * * * * * * * * * * * * * * * * * * * *
* Sync
* * * * * * * * * * * * * * * * * * * * /
on _click _sync _btn = function ( e ) {
2014-01-12 20:03:12 +01:00
if ( user ) {
2014-01-12 01:24:16 +01:00
sync _server . sync ( user . server , user . email , user . password , groups . export ( ) ,
function ( data ) {
console . log ( data ) ;
if ( data . groups ) {
groups . import ( data . groups ) ;
groups . save ( ) ;
refresh _group _list ( ) ;
alert ( 'Groupes synchronisés' ) ;
}
else {
console . log ( data ) ;
alert ( 'Erreur durant la synchronisation :(' ) ;
}
} ,
function ( data ) {
console . log ( data ) ;
alert ( 'Impossible de contacter le serveur :(' ) ;
}
) ;
}
else {
alert ( "Vous devez vous connecter pour commencer" ) ;
$ ( '#login_modal' ) . modal ( 'show' ) ;
}
}
/ *
* User menu
* /
user = false ;
logged _menu = function ( ) {
user = JSON . parse ( localStorage . user ) ;
$ ( '#user-name' ) . html ( user . name ) ;
$ ( '#user-menu li' ) . remove ( ) ;
menu = $ ( '#user-menu' ) ;
menu . html ( "<li><a id='myaccount_btn'>Mon compte</a></li>" +
"<li><a id='sync_btn'>Synchroniser</a></li>" +
"<li class='divider'></li>" +
"<li><a id='logoff_btn'>Déconnexion</a></li>" ) ;
$ ( '#myaccount_btn' ) . bind ( 'click' , on _click _myaccount _btn ) ;
$ ( '#sync_btn' ) . bind ( 'click' , on _click _sync _btn ) ;
$ ( '#logoff_btn' ) . bind ( 'click' , on _click _logoff _btn ) ;
}
logged _out _menu = function ( ) {
2014-01-12 20:03:12 +01:00
user = false ;
2014-01-12 01:24:16 +01:00
$ ( '#user-name' ) . html ( 'Connexion' ) ;
$ ( '#user-menu li' ) . remove ( ) ;
menu = $ ( '#user-menu' ) ;
menu . html ( "<li><a id='login_btn'>Connexion</a></li>" ) ;
$ ( '#login_btn' ) . bind ( 'click' , on _click _login _btn ) ;
}
on _click _myaccount _btn = function ( ) {
$ ( '#myaccount_modal #myaccount_email' ) . html ( user . email ) ;
$ ( '#myaccount_modal #myaccount_name' ) [ 0 ] . value = user . name ;
2014-01-12 20:05:08 +01:00
$ ( '#myaccount_modal #myaccount_server' ) . html ( user . server ) ;
2014-01-12 01:24:16 +01:00
$ ( '#myaccount_modal' ) . modal ( 'show' ) ;
}
on _click _login _btn = function ( ) {
$ ( '#login_modal' ) . modal ( 'show' ) ;
}
on _click _logoff _btn = function ( ) {
delete localStorage . user ;
logged _out _menu ( ) ;
}
2014-01-06 01:46:22 +01:00
/ * * * * * * * * * * * * * * * * * * * * *
* Activate
* * * * * * * * * * * * * * * * * * * * * /
$ ( document ) . ready ( function ( ) {
if ( typeof ( Storage ) !== "undefined" ) {
groups = new GroupList ( ) ;
groups . loadFromLocalStorage ( ) ;
refresh _group _list ( ) ;
2014-01-12 01:24:16 +01:00
if ( jQuery . type ( localStorage . user ) != 'undefined' ) {
logged _menu ( ) ;
}
else {
logged _out _menu ( ) ;
}
2014-01-06 01:46:22 +01:00
}
else {
alert ( 'Local storage not supported !' ) ;
2014-01-12 01:24:16 +01:00
return ;
2014-01-06 01:46:22 +01:00
}
2014-01-12 01:24:16 +01:00
sync _server = new SyncServer ( ) ;
2014-01-06 01:46:22 +01:00
2014-01-06 17:10:33 +01:00
$ ( '#add_group_btn' ) . bind ( 'click' , on _click _add _group _btn ) ;
2014-01-06 01:46:22 +01:00
$ ( '#add_group_submit' ) . bind ( 'click' , on _valid _add _group _modal ) ;
$ ( "#add_group_modal" ) . on ( 'shown.bs.modal' , on _show _add _group _modal ) ;
$ ( "#add_group_modal" ) . on ( 'hidden.bs.modal' , on _close _add _group _modal ) ;
$ ( "#add_group_modal form" ) . on ( 'submit' , on _valid _add _group _modal ) ;
$ ( '#clear_local_data' ) . bind ( 'click' , clear _local _data ) ;
2014-01-12 01:24:16 +01:00
$ ( '#login_modal' ) . on ( 'hidden.bs.modal' , on _close _login _modal ) ;
$ ( '#login_modal #login_submit' ) . bind ( 'click' , on _valid _login _modal ) ;
$ ( '#login_modal form' ) . bind ( 'submit' , on _valid _login _modal ) ;
2014-01-06 01:46:22 +01:00
$ ( '#view-group #contributor' ) . bind ( 'change' , on _contributor _change ) ;
$ ( '#add_contributor_btn' ) . bind ( 'click' , on _click _add _contributor _btn ) ;
$ ( '#add_contributor_submit' ) . bind ( 'click' , on _valid _add _contributor _modal ) ;
$ ( "#add_contributor_modal" ) . on ( 'shown.bs.modal' , on _show _add _contributor _modal ) ;
$ ( "#add_contributor_modal" ) . on ( 'hidden.bs.modal' , on _close _add _contributor _modal ) ;
$ ( "#add_contributor_modal form" ) . on ( 'submit' , on _valid _add _contributor _modal ) ;
2014-01-06 03:04:57 +01:00
$ ( '#edit_contributor_btn' ) . bind ( 'click' , on _edit _contributor _btn _click ) ;
2014-01-06 01:46:22 +01:00
$ ( '#del_contributor_btn' ) . bind ( 'click' , on _click _del _contributor _btn ) ;
$ ( '#add_contribution_btn' ) . bind ( 'click' , on _click _add _contribution _btn ) ;
$ ( '#add_contribution_submit' ) . bind ( 'click' , on _valid _add _contribution _modal ) ;
$ ( "#add_contribution_modal" ) . on ( 'shown.bs.modal' , on _show _add _contribution _modal ) ;
$ ( "#add_contribution_modal" ) . on ( 'hidden.bs.modal' , on _close _add _contribution _modal ) ;
$ ( "#add_contribution_modal form" ) . on ( 'submit' , on _valid _add _contribution _modal ) ;
$ ( "#display_balance_btn" ) . bind ( 'click' , on _display _balance _btn _click ) ;
$ ( '#remove_group_btn' ) . bind ( 'click' , on _remove _group _btn _click ) ;
} ) ;