2016-05-03 13:39:16 +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 : { sexe : [ { status : ! 0 } , { status : ! 1 } ] , age : "" , job : "." , loc : [ { status : ! 0 } , { status : ! 1 } , { status : ! 1 } , { status : ! 1 } ] , timestamp : 0 , valid : ! 1 } } ;
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 ( ) , d = crc32 ( JSON . stringify ( c ) ) , e = lsi . get ( "mini-fiches" , c . uid . value ) ; if ( ! 1 !== e ) { if ( null != e . hash && e . hash == d ) break ; console . warn ( "> MINI UPDATE" ) ; c = { uid : c . uid . value , firstname : e . firstname , lastname : e . lastname , username : e . username , sexe : c . sexe , age : c . age . value ,
job : c . job . value , loc : c . loc , hash : d } ; c . valid = this . check ( c ) ; c . timestamp = Date . now ( ) ; lsi . set ( "mini-fiches" , c . uid , c ) } } } ;
inputPhoneMini . prototype . add = function ( a ) { console . log ( "MINI FICHE: ADD" ) ; if ( null == a || null == a . uid ) return ! 1 ; 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 ; var b = lsi . get ( "contacts" , a . uid ) ; if ( ! 1 === b ) return ! 1 ; this . container . innerHTML += miniFicheBuilder . build ( { firstname : b . firstname , lastname : b . lastname , username : 0 == b . username . length ? "" : "(" + b . username + ")" , uid : a . uid , age : a . age ,
job : a . job } ) ; 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" , "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" ) } ; inputPhoneMini . prototype . storageToFields = function ( ) { console . log ( "MINI FICHE: STORAGE TO FIELDS" ) ; var a = lsi [ "export" ] ( "mini-fiches" ) ; this . container . innerHTML = "" ; this . add ( a [ this . selected ] ) ; this . updateNavBar ( ) } ;
inputPhoneMini . prototype . sync = function ( ) { console . log ( "MINI FICHE: SYNC" ) ; var a = lsi [ "export" ] ( "contacts" ) , b ; for ( b in a ) { var c = lsi . get ( "mini-fiches" , b ) ; null == c && ( c = this . defaultData , c . valid = ! 1 ) ; c . uid = a [ b ] . uid ; lsi . set ( "mini-fiches" , b , c ) } } ; inputPhoneMini . prototype . nav = function ( a ) { if ( "undefined" == typeof a || isNaN ( a . innerHTML ) || "nav-mini" != a . parentNode . id ) 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 } ;
inputPhoneMini . prototype . updateNavBar = function ( ) { var a = lsi [ "export" ] ( "mini-fiches" ) , b = Object . keys ( a ) . length ; if ( this . nav _container . children . length != b ) { this . nav _container . innerHTML = "" ; for ( var c = 0 ; c < b ; c ++ ) this . nav _container . innerHTML += "<span></span>" } for ( var d in a ) b = this . nav _container . children [ a [ d ] . uid ] , b . innerHTML = a [ d ] . uid + 1 , ! 0 === a [ d ] . valid ? b . addClass ( "done" ) : b . remClass ( "done" ) ; this . nav ( this . nav _container . children [ this . selected ] ) } ;
2016-04-29 13:24:03 +00:00
inputPhoneMini . prototype . check = function ( a ) { return ! isNaN ( parseInt ( a . age ) ) && checkRadioValue ( a . sexe ) && "." != a . job && checkRadioValue ( a . loc ) ? ! 0 : ! 1 } ; inputPhoneMini . prototype . attach = function ( a ) { console . log ( "MINI FICHE: ATTACH" ) ; lsi . createDataset ( "mini-fiches" ) ; this . storageToFields ( ) ; this . handler = a ; var b = this ; this . nav _container . addEventListener ( "click" , function ( a ) { b . nav ( a . target ) ; b . handler ( a . target ) } , ! 1 ) } ;