Copying layout for phone/matrice to facebook/matrice
This commit is contained in:
parent
bef99c46f8
commit
be7fb63f9c
|
@ -99,53 +99,38 @@ inputFacebookMatrice.prototype.storageToFields = function(){
|
|||
|
||||
/* (2) On construit le HTML de la matrice */
|
||||
// Contiendra le HTML
|
||||
var matrice_html = ["<table class='line'>"];
|
||||
var matrice_html = ["<div class='line matrice'>"];
|
||||
var conA, conB, L, Ll, C, Cl;
|
||||
|
||||
// {1} Pour chaque ligne //
|
||||
for( var A = 0 ; A < contacts.length ; A++ ){
|
||||
var conA = contactData[A];
|
||||
|
||||
|
||||
matrice_html.push('<tr>');
|
||||
|
||||
if( A > 0 ){ // Noms sur la première ligne (abscisses)
|
||||
matrice_html.push('<td style="text-align: right;">');
|
||||
matrice_html.push(conA.username);
|
||||
matrice_html.push('</td>');
|
||||
}else // Sinon,
|
||||
matrice_html.push('<td></td>');
|
||||
for( L = 0, Ll = contacts.length ; L < Ll ; L++ ){
|
||||
conA = contactData[L];
|
||||
|
||||
// {2} Pour chaque case //
|
||||
for( var B = 0 ; B < contacts.length ; B++ ){ if( B < contacts.length-1 ){
|
||||
var conB = contactData[B];
|
||||
for( C = L+1, Cl = contacts.length ; C < Cl ; C++ ){
|
||||
conB = contactData[C];
|
||||
|
||||
// {3} Première colonne -> Intitulé des ordonnées //
|
||||
if( A == 0 ){
|
||||
matrice_html.push('<td>');
|
||||
matrice_html.push('<span style="writing-mode: vertical-lr; text-align: right;">');
|
||||
matrice_html.push(conB.username);
|
||||
matrice_html.push('</span>');
|
||||
// {3} Insertion //
|
||||
matrice_html.push( "<input type='checkbox' data-name='"+conA.uid+"' value='"+conB.uid+"' id='f_matrice_"+conA.uid+"_"+conB.uid+"'" );
|
||||
|
||||
// {4} Valeurs des relations (boutons) //
|
||||
}else if( B < A ){
|
||||
matrice_html.push("<td>");
|
||||
matrice_html.push("<input type='checkbox' name='matrice_"+conA.uid+"_"+conB.uid+"' data-name='"+conA.uid+"' value='"+conB.uid+"' id='f_matrice_"+conA.uid+"_"+conB.uid+"'");
|
||||
// Si la relation existe, on active le bouton
|
||||
if( matriceData[A] != null && matriceData[A].indexOf(B) > -1 )
|
||||
matrice_html.push(" checked");
|
||||
matrice_html.push(" >");
|
||||
matrice_html.push("<label for='f_matrice_"+conA.uid+"_"+conB.uid+"'></label>");
|
||||
// Si lien actif, on le restitue
|
||||
if( matriceData.hasOwnProperty(conA.uid) && matriceData[conA.uid].indexOf(conB.uid) > -1 )
|
||||
matrice_html.push( "checked='checked'");
|
||||
|
||||
// {5} Cases vides (moitié supérieure droite) //
|
||||
}else
|
||||
matrice_html.push("<td class='hidden'>");
|
||||
matrice_html.push( ">" );
|
||||
|
||||
matrice_html.push('</td>');
|
||||
}}
|
||||
matrice_html.push( "<label class='matrice-content' for='f_matrice_"+conA.uid+"_"+conB.uid+"'>")
|
||||
matrice_html.push( "Est-ce que <span>" );
|
||||
matrice_html.push( !isNaN(conA.existing) ? lsi.get('f_friends', conA.existing).name : conA.username );
|
||||
matrice_html.push( '</span> et <span>' );
|
||||
matrice_html.push( !isNaN(conB.existing) ? lsi.get('f_friends', conB.existing).name : conB.username );
|
||||
matrice_html.push( '</span> se connaissent ?' );
|
||||
matrice_html.push( "</label>" );
|
||||
|
||||
matrice_html.push('</tr>');
|
||||
}
|
||||
matrice_html.push('</table>');
|
||||
|
||||
}
|
||||
matrice_html.push( '</div>' );
|
||||
|
||||
|
||||
/* (3) On affiche la matrice */
|
||||
|
|
|
@ -111,7 +111,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
|
|||
conB = contactData[C];
|
||||
|
||||
// {3} Insertion //
|
||||
matrice_html.push( "<input type='checkbox' data-name='"+conA.uid+"' value='"+conB.uid+"' id='f_matrice_"+conA.uid+"_"+conB.uid+"'" );
|
||||
matrice_html.push( "<input type='checkbox' data-name='"+conA.uid+"' value='"+conB.uid+"' id='p_matrice_"+conA.uid+"_"+conB.uid+"'" );
|
||||
|
||||
// Si lien actif, on le restitue
|
||||
if( matriceData.hasOwnProperty(conA.uid) && matriceData[conA.uid].indexOf(conB.uid) > -1 )
|
||||
|
@ -119,7 +119,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
|
|||
|
||||
matrice_html.push( ">" );
|
||||
|
||||
matrice_html.push( "<label class='matrice-content' for='f_matrice_"+conA.uid+"_"+conB.uid+"'>")
|
||||
matrice_html.push( "<label class='matrice-content' for='p_matrice_"+conA.uid+"_"+conB.uid+"'>")
|
||||
matrice_html.push( "Est-ce que <span>" );
|
||||
matrice_html.push( !isNaN(conA.existing) ? lsi.get('p_friends', conA.existing).name : conA.username );
|
||||
matrice_html.push( '</span> et <span>' );
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
function inputFacebookMatrice(a){this.container=a}inputFacebookMatrice.prototype={container:this.container};
|
||||
inputFacebookMatrice.prototype.fieldsToStorage=function(){console.group("[facebook.matrice] fields to storage");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("f_matrice",0,d);console.groupEnd()};
|
||||
inputFacebookMatrice.prototype.storageToFields=function(){console.group("[facebook.matrice] storage to fields");var a=lsi["export"]("f_fiches"),d=lsi.get("f_matrice",0),b=lsi["export"]("f_contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a=["<table class='line'>"];for(c=0;c<e.length;c++){var g=b[c];a.push("<tr>");0<c?(a.push('<td style="text-align: right;">'),a.push(g.username),a.push("</td>")):a.push("<td></td>");for(var f=0;f<e.length;f++)if(f<e.length-1){var h=b[f];
|
||||
0==c?(a.push("<td>"),a.push('<span style="writing-mode: vertical-lr; text-align: right;">'),a.push(h.username),a.push("</span>")):f<c?(a.push("<td>"),a.push("<input type='checkbox' name='matrice_"+g.uid+"_"+h.uid+"' data-name='"+g.uid+"' value='"+h.uid+"' id='f_matrice_"+g.uid+"_"+h.uid+"'"),null!=d[c]&&-1<d[c].indexOf(f)&&a.push(" checked"),a.push(" >"),a.push("<label for='f_matrice_"+g.uid+"_"+h.uid+"'></label>")):a.push("<td class='hidden'>");a.push("</td>")}a.push("</tr>")}a.push("</table>");
|
||||
this.container.innerHTML=a.join("");console.groupEnd()};inputFacebookMatrice.prototype.attach=function(){console.group("[facebook.matrice] attaching events");lsi.createDataset("f_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd()};
|
||||
inputFacebookMatrice.prototype.fieldsToStorage=function(){console.group("[facebook.matrice] fields to storage");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var f in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][f]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("f_matrice",0,d);console.groupEnd()};
|
||||
inputFacebookMatrice.prototype.storageToFields=function(){console.group("[facebook.matrice] storage to fields");var a=lsi["export"]("f_fiches"),d=lsi.get("f_matrice",0),b=lsi["export"]("f_contacts"),f=[],c;for(c in a)-1==f.indexOf(a[c].contact)&&f.push(a[c].contact);var a=["<div class='line matrice'>"],e,g,k,h,l;g=0;for(k=f.length;g<k;g++)for(c=b[g],h=g+1,l=f.length;h<l;h++)e=b[h],a.push("<input type='checkbox' data-name='"+c.uid+"' value='"+e.uid+"' id='f_matrice_"+c.uid+"_"+e.uid+"'"),d.hasOwnProperty(c.uid)&&
|
||||
-1<d[c.uid].indexOf(e.uid)&&a.push("checked='checked'"),a.push(">"),a.push("<label class='matrice-content' for='f_matrice_"+c.uid+"_"+e.uid+"'>"),a.push("Est-ce que <span>"),a.push(isNaN(c.existing)?c.username:lsi.get("f_friends",c.existing).name),a.push("</span> et <span>"),a.push(isNaN(e.existing)?e.username:lsi.get("f_friends",e.existing).name),a.push("</span> se connaissent ?"),a.push("</label>");a.push("</div>");this.container.innerHTML=a.join("");console.groupEnd()};
|
||||
inputFacebookMatrice.prototype.attach=function(){console.group("[facebook.matrice] attaching events");lsi.createDataset("f_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd()};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var inputPhoneMatrice=function(a){this.container=a};inputPhoneMatrice.prototype={container:this.container};
|
||||
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.group("[phone.matrice] fields to storage");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var c={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==c[b]&&(c[b]=[]),c[b].push(parseInt(a[b])));lsi.set("p_matrice",0,c);console.groupEnd()};
|
||||
inputPhoneMatrice.prototype.storageToFields=function(){console.group("[phone.matrice] storage to fields");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);var a=["<div class='line matrice'>"],f,g,k,h,l;g=0;for(k=e.length;g<k;g++)for(d=b[g],h=g+1,l=e.length;h<l;h++)f=b[h],a.push("<input type='checkbox' data-name='"+d.uid+"' value='"+f.uid+"' id='f_matrice_"+d.uid+"_"+f.uid+"'"),c.hasOwnProperty(d.uid)&&
|
||||
-1<c[d.uid].indexOf(f.uid)&&a.push("checked='checked'"),a.push(">"),a.push("<label class='matrice-content' for='f_matrice_"+d.uid+"_"+f.uid+"'>"),a.push("Est-ce que <span>"),a.push(isNaN(d.existing)?d.username:lsi.get("p_friends",d.existing).name),a.push("</span> et <span>"),a.push(isNaN(f.existing)?f.username:lsi.get("p_friends",f.existing).name),a.push("</span> se connaissent ?"),a.push("</label>");a.push("</div>");this.container.innerHTML=a.join("");console.groupEnd()};
|
||||
inputPhoneMatrice.prototype.storageToFields=function(){console.group("[phone.matrice] storage to fields");var a=lsi["export"]("p_fiches"),c=lsi.get("p_matrice",0),b=lsi["export"]("p_contacts"),e=[],d;for(d in a)-1==e.indexOf(a[d].contact)&&e.push(a[d].contact);var a=["<div class='line matrice'>"],f,g,k,h,l;g=0;for(k=e.length;g<k;g++)for(d=b[g],h=g+1,l=e.length;h<l;h++)f=b[h],a.push("<input type='checkbox' data-name='"+d.uid+"' value='"+f.uid+"' id='p_matrice_"+d.uid+"_"+f.uid+"'"),c.hasOwnProperty(d.uid)&&
|
||||
-1<c[d.uid].indexOf(f.uid)&&a.push("checked='checked'"),a.push(">"),a.push("<label class='matrice-content' for='p_matrice_"+d.uid+"_"+f.uid+"'>"),a.push("Est-ce que <span>"),a.push(isNaN(d.existing)?d.username:lsi.get("p_friends",d.existing).name),a.push("</span> et <span>"),a.push(isNaN(f.existing)?f.username:lsi.get("p_friends",f.existing).name),a.push("</span> se connaissent ?"),a.push("</label>");a.push("</div>");this.container.innerHTML=a.join("");console.groupEnd()};
|
||||
inputPhoneMatrice.prototype.attach=function(){console.group("[phone.matrice] attaching events");lsi.createDataset("p_matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(c){a.fieldsToStorage();setTimeout(function(){a.storageToFields()},500)},!1);console.groupEnd()};
|
||||
inputPhoneMatrice.prototype.parseGrid=function(){var a=$$(".matrice-panel input[data-name][value]"),c;for(c in a)if(a[c]instanceof Element){var b=a[c].getData("name"),e=a[c].value;this.sGrid[b]instanceof Array||(this.sGrid[b]=[]);this.sGrid[b][e]=a[c]}};
|
||||
|
|
Loading…
Reference in New Issue