2016-04-27 12:32:54 +00:00
function inputPhoneMini ( a , b ) { this . container = a ; this . nav _container = b } inputPhoneMini . prototype = { container : this . container , nav _container : this . nav _container , selected : 0 , handler : null , defaultData : { firstname : "" , lastname : "" , username : "" , sexe : [ { status : ! 0 } , { status : ! 1 } ] , age : "" , job : "." , loc : [ { status : ! 0 } , { status : ! 1 } , { status : ! 1 } , { status : ! 1 } ] } } ;
2016-04-27 16:04:54 +00:00
inputPhoneMini . prototype . fieldsToStorage = function ( ) { console . log ( "MINI FICHE: FIELDS TO STORAGE" ) ; for ( var a = $$ ( "article.mini-relation-panel .mini-fiche-relation" ) , b = 0 ; b < a . length ; b ++ ) { var c = ( new FormDeflater ( a [ b ] , [ "input" , "select" ] , [ "data-name" ] ) ) . deflate ( ) ; console . log ( c ) ; var d = lsi . get ( "mini-fiches" , "form" + c . uid . value ) ; ! 1 === d && ( d . username = "inconnu" , d . firstname = "inconnu" , d . lastname = "inconnu" ) ; c = { uid : c . uid . value , firstname : d . firstname , lastname : d . lastname , username : d . username , sexe : c . sexe , age : c . age . value ,
job : c . job . value , loc : c . loc } ; lsi . set ( "mini-fiches" , "form" + c . uid , c ) } } ;
2016-04-27 12:32:54 +00:00
inputPhoneMini . prototype . add = function ( a ) { console . log ( "MINI FICHE: ADD" ) ; if ( null == a . uid ) return ! 1 ; a . firstname = null != a . firstname ? a . firstname : this . defaultData . firstname ; a . lastname = null != a . lastname ? a . lastname : this . defaultData . lastname ; a . username = null != a . username ? a . username : this . defaultData . username ; a . age = null != a . age ? a . age : this . defaultData . age ; a . sexe = null != a . sexe ? a . sexe : this . defaultData . sexe ; a . job = null != a . job ? a . job : this . defaultData . job ; a . loc = null != a . loc ? a . loc : this . defaultData . loc ; this . container . innerHTML +=
miniFicheBuilder . build ( { firstname : a . firstname , lastname : a . lastname , username : a . username , uid : a . uid , age : a . age , job : a . job } ) ; var b = $ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>span>select[data-name="job"]>option[value="' + a . job + '"]' ) ; null != b && b . setAttribute ( "selected" , "selected" ) ; for ( var c = $$ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>input[type="radio"][data-name="sexe"]' ) , b = 0 ; b < c . length && b < a . sexe . length ; b ++ ) a . sexe [ b ] . status ? c [ b ] . setAttribute ( "checked" ,
2016-04-27 16:04:54 +00:00
"checked" ) : c [ b ] . removeAttribute ( "checked" ) ; c = $$ ( 'article.mini-fiche-relation input[data-name="uid"][value="' + a . uid + '"] ~ h5>input[type="radio"][data-name="loc"]' ) ; for ( b = 0 ; b < c . length && b < a . loc . length ; b ++ ) a . loc [ b ] . status ? c [ b ] . setAttribute ( "checked" , "checked" ) : c [ b ] . removeAttribute ( "checked" ) } ;
2016-04-27 12:32:54 +00:00
inputPhoneMini . prototype . storageToFields = function ( ) { console . log ( "MINI FICHE: STORAGE TO FIELDS" ) ; var a = lsi . keys ( "mini-fiches" ) ; this . container . innerHTML = "" ; for ( var b = [ ] , c = 0 ; c < a . length ; c ++ ) { var d = lsi . get ( "mini-fiches" , a [ c ] ) ; this . add ( { uid : d . uid , firstname : d . firstname , lastname : d . lastname , username : d . username , age : d . age , sexe : d . sexe , job : d . job , loc : d . loc } ) ; b . push ( d . uid ) } this . updateNavBar ( b ) } ;
inputPhoneMini . prototype . sync = function ( ) { console . log ( "MINI FICHE: SYNC" ) ; for ( var a = lsi . keys ( "contacts" ) , b = 0 ; b < a . length ; b ++ ) { var c = lsi . get ( "contacts" , a [ b ] ) , d = lsi . get ( "mini-fiches" , a [ b ] ) ; null == d && ( d = this . defaultData ) ; d . uid = c . uid ; d . firstname = c . firstname ; d . lastname = c . lastname ; d . username = c . username ; lsi . set ( "mini-fiches" , a [ b ] , d ) } } ;
2016-04-27 10:25:42 +00:00
inputPhoneMini . prototype . nav = function ( a ) { if ( "undefined" == typeof a || isNaN ( a . innerHTML ) ) return ! 1 ; for ( var b = $$ ( "#nav-mini > span.active" ) , c = 0 ; c < b . length ; c ++ ) b [ c ] . remClass ( "active" ) ; a . addClass ( "active" ) ; this . selected = parseInt ( a . innerHTML ) - 1 ; a = $$ ( "article.mini-relation-panel .mini-fiche-relation.active" ) ; for ( c = 0 ; c < a . length ; c ++ ) a [ c ] . remClass ( "active" ) ; this . container . children [ this . selected ] . addClass ( "active" ) } ;
2016-04-27 16:04:54 +00:00
inputPhoneMini . prototype . updateNavBar = function ( a ) { this . nav _container . innerHTML = "" ; for ( var b = 0 ; b < a . length ; b ++ ) { var c = parseInt ( a [ b ] ) + 1 ; this . nav _container . innerHTML += "<span>" + c + "</span>" } this . check ( ) ; this . nav ( this . nav _container . children [ this . selected ] ) } ;
2016-04-27 16:32:44 +00:00
inputPhoneMini . prototype . check = function ( ) { for ( var a = lsi . keys ( "mini-fiches" ) , b = 0 ; b < a . length ; b ++ ) { var c = lsi . get ( "mini-fiches" , a [ b ] ) , d = ! 0 ; ( d = ( d = ( d = ( d = d && ! isNaN ( parseInt ( c . age ) ) ) && checkRadioValue ( c . sexe ) ) && "." != c . job ) && checkRadioValue ( c . loc ) ) ? this . nav _container . children [ c . uid ] . addClass ( "done" ) : this . nav _container . children [ c . uid ] . remClass ( "done" ) } } ;
2016-04-27 10:25:42 +00:00
inputPhoneMini . prototype . attach = function ( a ) { console . log ( "MINI FICHE: ATTACH" ) ; lsi . createDataset ( "mini-fiches" ) ; this . storageToFields ( ) ; this . handler = a ; var b = this , b = this ; this . nav _container . addEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( ) } , ! 1 ) } ;