Fixed page-manager, now uses pageManager.refresh() to link pages (edit/remove/..) + trouble with 'remove' (first time only ok) + added post variables to pageManager.refresh() too

This commit is contained in:
xdrm-brackets 2017-01-08 19:14:22 +01:00
parent a51304086f
commit 33fb700e2a
30 changed files with 743 additions and 155 deletions

View File

@ -9,8 +9,6 @@
class group_membersChoice{
public static function render($params){
var_dump('membersChoice');
debug();
/* [1] On vérifie le type de groupe (user/machine)
=========================================================*/
/* (1) On vérifie les paramètres */

View File

@ -1,11 +1,20 @@
// Regular
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/r.ttf');
src: url('/css/font/Open Sans/R.ttf');
font-weight: normal;
font-style: normal;
}
// Semi Bold
@font-face{
font-family: 'Open Sans sb';
src: url('/css/font/Open Sans/SB.ttf');
font-weight: normal;
font-style: normal;
}
// Bold
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/b.ttf');
@ -13,7 +22,7 @@
font-style: normal;
}
// Italic
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/i.ttf');
@ -21,7 +30,7 @@
font-style: italic;
}
// Bold Italic
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/bi.ttf');
@ -29,18 +38,18 @@
font-style: italic;
}
// Light
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/L.ttf');
font-weight: lighter;
font-weight: 100;
font-style: normal;
}
// Light italic
@font-face{
font-family: 'Open Sans';
src: url('/css/font/Open Sans/Li.ttf');
font-weight: lighter;
font-weight: 100;
font-style: italic;
}

Binary file not shown.

View File

@ -1,38 +1,37 @@
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/r.ttf");
src: url("/css/font/Open Sans/R.ttf");
font-weight: normal;
font-style: normal;
}
font-style: normal; }
@font-face {
font-family: 'Open Sans sb';
src: url("/css/font/Open Sans/SB.ttf");
font-weight: normal;
font-style: normal; }
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/b.ttf");
font-weight: bold;
font-style: normal;
}
font-style: normal; }
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/i.ttf");
font-weight: normal;
font-style: italic;
}
font-style: italic; }
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/bi.ttf");
font-weight: bold;
font-style: italic;
}
font-style: italic; }
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/L.ttf");
font-weight: lighter;
font-style: normal;
}
font-weight: 100;
font-style: normal; }
@font-face {
font-family: 'Open Sans';
src: url("/css/font/Open Sans/Li.ttf");
font-weight: lighter;
font-style: italic;
}
font-weight: 100;
font-style: italic; }
/*# sourceMappingURL=fonts.css.map */

View File

@ -1,129 +1,374 @@
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
/** 1. Set default font family to sans-serif. 2. Prevent iOS and IE text size adjust after device orientation change, without disabling user zoom. */
html { font-family: sans-serif; /* 1 */ -ms-text-size-adjust: 100%; /* 2 */ -webkit-text-size-adjust: 100%; /* 2 */ }
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS and IE text size adjust after device orientation change,
* without disabling user zoom.
*/
html {
font-family: sans-serif;
/* 1 */
-ms-text-size-adjust: 100%;
/* 2 */
-webkit-text-size-adjust: 100%;
/* 2 */ }
/** Remove default margin. */
body { margin: 0; font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial'; }
/**
* Remove default margin.
*/
body {
margin: 0;
font-size: 16px;
font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial';
font-weight: normal; }
/* HTML5 display definitions ========================================================================== */
/** Correct `block` display not defined for any HTML5 element in IE 8/9. Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox. Correct `block` display not defined for `main` in IE 11. */
article, aside, details, figcaption, figure, footer, header, main, menu, nav, section, summary { display: block; }
/* HTML5 display definitions
========================================================================== */
/**
* Correct `block` display not defined for any HTML5 element in IE 8/9.
* Correct `block` display not defined for `details` or `summary` in IE 10/11
* and Firefox.
* Correct `block` display not defined for `main` in IE 11.
*/
article,
aside,
details,
figcaption,
figure,
footer,
header,
main,
menu,
nav,
section,
summary {
display: block; }
/** 1. Correct `inline-block` display not defined in IE 8/9. 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. */
audio, canvas, progress, video { display: inline-block; /* 1 */ vertical-align: baseline; /* 2 */ }
/**
* 1. Correct `inline-block` display not defined in IE 8/9.
* 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
*/
audio,
canvas,
progress,
video {
display: inline-block;
/* 1 */
vertical-align: baseline;
/* 2 */ }
/** Prevent modern browsers from displaying `audio` without controls. Remove excess height in iOS 5 devices. */
audio:not([controls]) { display: none; height: 0; }
/**
* Prevent modern browsers from displaying `audio` without controls.
* Remove excess height in iOS 5 devices.
*/
audio:not([controls]) {
display: none;
height: 0; }
/** Address `[hidden]` styling not present in IE 8/9/10. Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22. */
[hidden], template { display: none; }
/**
* Address `[hidden]` styling not present in IE 8/9/10.
* Hide the `template` element in IE 8/9/10/11, Safari, and Firefox < 22.
*/
[hidden],
template {
display: none; }
/* Links ========================================================================== */
/** Remove the gray background color from active links in IE 10. */
a { background-color: transparent; }
/* Links
========================================================================== */
/**
* Remove the gray background color from active links in IE 10.
*/
a {
background-color: transparent; }
/** Improve readability of focused elements when they are also in an active/hover state. */
a:active, a:hover { outline: 0; }
/**
* Improve readability of focused elements when they are also in an
* active/hover state.
*/
a:active,
a:hover {
outline: 0; }
/* Text-level semantics ========================================================================== */
/** Address inconsistent styling of `abbr[title]`. 1. Correct styling in Firefox 39 and Opera 12. 2. Correct missing styling in Chrome, Edge, IE, Opera, and Safari. */
abbr[title] { border-bottom: none; /* 1 */ text-decoration: underline; /* 2 */ text-decoration: underline dotted; /* 2 */ }
/* Text-level semantics
========================================================================== */
/**
* Address inconsistent styling of `abbr[title]`.
* 1. Correct styling in Firefox 39 and Opera 12.
* 2. Correct missing styling in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
border-bottom: none;
/* 1 */
text-decoration: underline;
/* 2 */
text-decoration: underline dotted;
/* 2 */ }
/** Address inconsistent styling of b and strong. 1. Correct duplicate application of `bolder` in Safari 6.0.2. 2. Correct style set to `bold` in Edge 12+, Safari 6.2+, and Chrome 18+. */
b, strong { font-weight: inherit; /* 1 */ }
/**
* Address inconsistent styling of b and strong.
* 1. Correct duplicate application of `bolder` in Safari 6.0.2.
* 2. Correct style set to `bold` in Edge 12+, Safari 6.2+, and Chrome 18+.
*/
b,
strong {
font-weight: inherit;
/* 1 */ }
b, strong { font-weight: bolder; /* 2 */ }
b,
strong {
font-weight: bolder;
/* 2 */ }
/** Address styling not present in Safari and Chrome. */
dfn { font-style: italic; }
/**
* Address styling not present in Safari and Chrome.
*/
dfn {
font-style: italic; }
/** Address variable `h1` font-size and margin within `section` and `article` contexts in Firefox 4+, Safari, and Chrome. */
h1 { font-size: 2em; margin: 0.67em 0; }
/**
* Address variable `h1` font-size and margin within `section` and `article`
* contexts in Firefox 4+, Safari, and Chrome.
*/
h1 {
font-size: 2em;
margin: 0.67em 0; }
/** Address styling not present in IE 8/9. */
mark { background-color: #ff0; color: #000; }
/**
* Address styling not present in IE 8/9.
*/
mark {
background-color: #ff0;
color: #000; }
/** Address inconsistent and variable font size in all browsers. */
small { font-size: 80%; }
/**
* Address inconsistent and variable font size in all browsers.
*/
small {
font-size: 80%; }
/** Prevent `sub` and `sup` affecting `line-height` in all browsers. */
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
/**
* Prevent `sub` and `sup` affecting `line-height` in all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline; }
sup { top: -0.5em; }
sup {
top: -0.5em; }
sub { bottom: -0.25em; }
sub {
bottom: -0.25em; }
/* Embedded content ========================================================================== */
/** Remove border when inside `a` element in IE 8/9/10. */
img { border: 0; }
/* Embedded content
========================================================================== */
/**
* Remove border when inside `a` element in IE 8/9/10.
*/
img {
border: 0; }
/** Correct overflow not hidden in IE 9/10/11. */
svg:not(:root) { overflow: hidden; }
/**
* Correct overflow not hidden in IE 9/10/11.
*/
svg:not(:root) {
overflow: hidden; }
/* Grouping content ========================================================================== */
/** Address margin not present in IE 8/9 and Safari. */
figure { margin: 1em 40px; }
/* Grouping content
========================================================================== */
/**
* Address margin not present in IE 8/9 and Safari.
*/
figure {
margin: 1em 40px; }
/** Address inconsistent styling of `hr`. 1. Correct `box-sizing` set to `border-box` in Firefox. 2. Correct `overflow` set to `hidden` in IE 8/9/10/11 and Edge 12. */
hr { box-sizing: content-box; /* 1 */ height: 0; /* 1 */ overflow: visible; /* 2 */ }
/**
* Address inconsistent styling of `hr`.
* 1. Correct `box-sizing` set to `border-box` in Firefox.
* 2. Correct `overflow` set to `hidden` in IE 8/9/10/11 and Edge 12.
*/
hr {
box-sizing: content-box;
/* 1 */
height: 0;
/* 1 */
overflow: visible;
/* 2 */ }
/** Contain overflow in all browsers. */
pre { overflow: auto; }
/**
* Contain overflow in all browsers.
*/
pre {
overflow: auto; }
/** 1. Correct inheritance and scaling of font-size for preformatted text. 2. Address odd `em`-unit font size rendering in all browsers. */
code, kbd, pre, samp { font-family: monospace, monospace; /* 1 */ font-size: 1em; /* 2 */ }
/**
* 1. Correct inheritance and scaling of font-size for preformatted text.
* 2. Address odd `em`-unit font size rendering in all browsers.
*/
code,
kbd,
pre,
samp {
font-family: monospace, monospace;
/* 1 */
font-size: 1em;
/* 2 */ }
/* Forms ========================================================================== */
/** Known limitation: by default, Chrome and Safari on OS X allow very limited styling of `select`, unless a `border` property is set. */
/** 1. Correct font properties not being inherited. 2. Address margins set differently in Firefox 4+, Safari, and Chrome. */
button, input, optgroup, select, textarea { font: inherit; /* 1 */ margin: 0; /* 2 */ }
/* Forms
========================================================================== */
/**
* Known limitation: by default, Chrome and Safari on OS X allow very limited
* styling of `select`, unless a `border` property is set.
*/
/**
* 1. Correct font properties not being inherited.
* 2. Address margins set differently in Firefox 4+, Safari, and Chrome.
*/
button,
input,
optgroup,
select,
textarea {
font: inherit;
/* 1 */
margin: 0;
/* 2 */ }
/** Address `overflow` set to `hidden` in IE 8/9/10/11. */
button { overflow: visible; }
/**
* Address `overflow` set to `hidden` in IE 8/9/10/11.
*/
button {
overflow: visible; }
/** Address inconsistent `text-transform` inheritance for `button` and `select`. All other form control elements do not inherit `text-transform` values. Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. Correct `select` style inheritance in Firefox. */
button, select { text-transform: none; }
/**
* Address inconsistent `text-transform` inheritance for `button` and `select`.
* All other form control elements do not inherit `text-transform` values.
* Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
* Correct `select` style inheritance in Firefox.
*/
button,
select {
text-transform: none; }
/** 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` and `video` controls. 2. Correct inability to style clickable `input` types in iOS. 3. Improve usability and consistency of cursor style between image-type `input` and others. */
button, html input[type="button"], input[type="reset"], input[type="submit"] { -webkit-appearance: button; /* 2 */ cursor: pointer; /* 3 */ }
/**
* 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
* and `video` controls.
* 2. Correct inability to style clickable `input` types in iOS.
* 3. Improve usability and consistency of cursor style between image-type
* `input` and others.
*/
button,
html input[type="button"],
input[type="reset"],
input[type="submit"] {
-webkit-appearance: button;
/* 2 */
cursor: pointer;
/* 3 */ }
/** Re-set default cursor for disabled elements. */
button[disabled], html input[disabled] { cursor: default; }
/**
* Re-set default cursor for disabled elements.
*/
button[disabled],
html input[disabled] {
cursor: default; }
/** Remove inner padding and border in Firefox 4+. */
button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; }
/**
* Remove inner padding and border in Firefox 4+.
*/
button::-moz-focus-inner,
input::-moz-focus-inner {
border: 0;
padding: 0; }
/** Address Firefox 4+ setting `line-height` on `input` using `!important` in the UA stylesheet. */
input { line-height: normal; }
/**
* Address Firefox 4+ setting `line-height` on `input` using `!important` in
* the UA stylesheet.
*/
input {
line-height: normal; }
/** It's recommended that you don't attempt to style these elements. Firefox's implementation doesn't respect box-sizing, padding, or width. 1. Address box sizing set to `content-box` in IE 8/9/10. 2. Remove excess padding in IE 8/9/10. */
input[type="checkbox"], input[type="radio"] { box-sizing: border-box; /* 1 */ padding: 0; /* 2 */ }
/**
* It's recommended that you don't attempt to style these elements.
* Firefox's implementation doesn't respect box-sizing, padding, or width.
*
* 1. Address box sizing set to `content-box` in IE 8/9/10.
* 2. Remove excess padding in IE 8/9/10.
*/
input[type="checkbox"],
input[type="radio"] {
box-sizing: border-box;
/* 1 */
padding: 0;
/* 2 */ }
/** Fix the cursor style for Chrome's increment/decrement buttons. For certain `font-size` values of the `input`, it causes the cursor style of the decrement button to change from `default` to `text`. */
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { height: auto; }
/**
* Fix the cursor style for Chrome's increment/decrement buttons. For certain
* `font-size` values of the `input`, it causes the cursor style of the
* decrement button to change from `default` to `text`.
*/
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
height: auto; }
/** Address `appearance` set to `searchfield` in Safari and Chrome. */
input[type="search"] { -webkit-appearance: textfield; }
/**
* Address `appearance` set to `searchfield` in Safari and Chrome.
*/
input[type="search"] {
-webkit-appearance: textfield; }
/** Remove inner padding and search cancel button in Safari and Chrome on OS X. Safari (but not Chrome) clips the cancel button when the search input has padding (and `textfield` appearance). */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
/**
* Remove inner padding and search cancel button in Safari and Chrome on OS X.
* Safari (but not Chrome) clips the cancel button when the search input has
* padding (and `textfield` appearance).
*/
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-decoration {
-webkit-appearance: none; }
/** Define consistent border, margin, and padding. */
fieldset { border: 1px solid #c0c0c0; margin: 0 2px; padding: 0.35em 0.625em 0.75em; }
/**
* Define consistent border, margin, and padding.
*/
fieldset {
border: 1px solid #c0c0c0;
margin: 0 2px;
padding: 0.35em 0.625em 0.75em; }
/** 1. Correct `color` not being inherited in IE 8/9/10/11. 2. Remove padding so people aren't caught out if they zero out fieldsets. */
legend { border: 0; /* 1 */ padding: 0; /* 2 */ }
/**
* 1. Correct `color` not being inherited in IE 8/9/10/11.
* 2. Remove padding so people aren't caught out if they zero out fieldsets.
*/
legend {
border: 0;
/* 1 */
padding: 0;
/* 2 */ }
/** Remove default vertical scrollbar in IE 8/9/10/11. */
textarea { overflow: auto; }
/**
* Remove default vertical scrollbar in IE 8/9/10/11.
*/
textarea {
overflow: auto; }
/** Don't inherit the `font-weight` (applied by a rule above). NOTE: the default cannot safely be changed in Chrome and Safari on OS X. */
optgroup { font-weight: bold; }
/**
* Don't inherit the `font-weight` (applied by a rule above).
* NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
*/
optgroup {
font-weight: bold; }
/* Tables ========================================================================== */
/** Remove most spacing between table cells. */
table { border-collapse: collapse; border-spacing: 0; }
/* Tables
========================================================================== */
/**
* Remove most spacing between table cells.
*/
table {
border-collapse: collapse;
border-spacing: 0; }
td, th { padding: 0; }
td,
th {
padding: 0; }
/*# sourceMappingURL=reset.css.map */

View File

@ -18,8 +18,9 @@ html {
body {
margin: 0;
// font-size: 12px;
font-size: 16px;
font-family: 'Open Sans', 'Ubuntu', 'Verdana', 'Arial';
font-weight: normal;
}
/* HTML5 display definitions

View File

@ -10,7 +10,7 @@ DOM = {
/* [0] Instanciation
===========================================*/
var pageManager = new pageManagerClass();
pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] );
var api = new APIClass('/api/');
@ -157,6 +157,8 @@ function navMenu(section, persistence){
navSubMenu(target);
}, false);
DOM.HEADER.remClass('loading');
};
/* (x) Si première ou changement de page, on charge la nouvelle */
@ -167,10 +169,16 @@ function navMenu(section, persistence){
}
}navMenu(pageManager.page);
}
// init page-manager
pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] );
// launch pageManager
navMenu(pageManager.page);
@ -180,10 +188,23 @@ function navMenu(section, persistence){
// set default refresher
pageManager.refresher = function(){
/* (1) Loads page */
navSubMenu( this.vars[0] );
/* (2) Set listener for sub-menu nav */
document.querySelector('#CONTAINER > .sub-menu-side').addEventListener('click', function(e){
var target = e.target;
while( target != document.body && !target.getData('sublink') )
target = target.parentNode;
if( target.getData('sublink') )
navSubMenu(target);
}, false);
};

View File

@ -0,0 +1,285 @@
/* CONSTRUCTEUR D'UN DEFLATER DE formulaire
*
* @container<Element> Formulaire ou autre élément contenant les champs
* @tags<Array> Tableau contenant les éléments à prendre en compte
* @attr<Array> Tableau contenant les attributs à prendre pour le nom (par ordre de priorité)
*
*/
function FormDeflater(container, tags, attr){
/* [0] Vérification des INPUT
=========================================================*/
var correctParams = container instanceof Element;
correctParams = correctParams && tags instanceof Array;
correctParams = correctParams && attr instanceof Array;
/* [1] On formatte les données
=========================================================*/
// On met les tags en minuscule
for( var i = 0 ; i < tags.length ; i++ )
tags[i] = tags[i].toLowerCase();
// On met les attributs en minuscule
for( var i = 0 ; i < attr.length ; i++ )
attr[i] = attr[i].toLowerCase();
/* [2] On enregistre les attributs
=========================================================*/
this.container = container;
this.tags = tags;
this.attr = attr;
}
FormDeflater.prototype = {
container: this.container, // Contiendra le 'formulaire' (<form> ou autre)
tags: this.tags, // Contiendra les balises HTML à ne pas prendre en compte
attr: this.attr // Contiendra la liste des attributs à prendre pour nom (par ordre de priorité)
};
/* RETOURNE UN OBJET CONTENANT LES DONNÉES DU FORMULAIRE
*
* @return form<Object> Objet correspondant aux données du formulaire
*
*/
FormDeflater.prototype.deflate = function(){
/* [1] On récupère tous les enfants
=========================================================*/
var children = this.getChildren( this.container );
/* [2] On filtre les éléments qui ont pas le bon tag
=========================================================*/
children = this.filterElements( children );
/* [3] On essaie de trouver les attributs primants (non vides et en premier dans la liste @this.attr)
=========================================================*/
/* (0) On initialise l'objet de retour */
var object = {};
/* (1) Pour chacun des éléments */
for( var c = 0 ; c < children.length ; c++ ){
/* (2) Pour chacun des attributs par ordre de priorité */
for( var a = 0 ; a < this.attr.length ; a++ ){
// On récupère l'attribut
var attr = children[c].getAttribute(this.attr[a]);
/* (3) Si l'attribut est défini (pas null ni vide) */
if( attr !== null && attr.length > 0 ){
/* (4) Si on a pas déja un champ de même nom */
if( object.hasOwnProperty(attr) ){
var existing = object[attr];
// {1} Si l'existant est un tableau, on ajoute notre valeur //
if( existing instanceof Array )
object[attr].push( { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked } );
// {2} Sinon, si c'est une valeur seule, on crée un tableau //
else
object[attr] = [ object[attr], { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked } ];
/* (5) Si c'est le premier champ avec ce nom, on le crée */
}else
object[attr] = { target: children[c], attr: this.attr[a], value: children[c].value, checked: children[c].checked };
// On en a fini pour cet élément
break;
}
}
}
/* [4] On met en forme les données
=========================================================*/
object = this.cleanOutput(object);
return object;
};
/* RETOURNE SI UN ELEMENT EST UN BOUTON DE TYPE RADIO/CHECKBOX OU NON
*
* @element<Element> Element en question
*
* @return result<Boolean> Renvoie si TRUE or FALSE il en est un
*
*/
FormDeflater.prototype.checkable = function(element){
if( element.tagName != 'INPUT' )
return false;
if( ['radio', 'checkbox'].indexOf( element.getAttribute('type').toLowerCase() ) == -1 )
return false;
return true;
};
/* NETTOIE LES DONNÉES EN SORTIE POUR QU'ELLES SOIENT UTILISABLES ET OPTIMISÉES
*
* @input<Object> Données "brutes"
*
* @return output<Object> Données sans les valeurs inutiles et explicitées
*
*/
FormDeflater.prototype.cleanOutput = function(input){
var output = {};
/* [1] On parcourt toutes les valeurs récupérées
=========================================================*/
for( var key in input ){
/* [2] Si c'est un tableau
=========================================================*/
if( input[key] instanceof Array ){
// VRAI si tous les éléments sont radio/checkbox
var areCheckable = true;
// Contiendra les indices des valeurs ou 'checked=TRUE'
var checkedIndexes = [];
/* (1) On vérifie si tous les champs sont checkables */
for( var i in input[key])
// si pas checkable, on arrête de vérifier
if( !this.checkable(input[key][i].target) ){
areCheckable = false;
break;
// Sinon si checkable et checked=TRUE, on incrémente @nbChecked
}else if( input[key][i].checked === true )
checkedIndexes.push(i);
/* (2) Si c'est que des radio ou des checkbox avec une seule valeur à TRUE */
if( areCheckable )
if( checkedIndexes.length == 1 )
output[key] = input[key][checkedIndexes[0]].value;
/* (3) Si c'est que des radio ou des checkbox avec plusieurs valeurs à TRUE */
else{
output[key] = [];
for( var i in checkedIndexes )
output[key].push( input[key][checkedIndexes[i]].value );
}
/* (4) Si c'est pas que des radio ou des checkbox, on met les valeurs */
else{
output[key] = [];
for( var i in input[key] )
output[key].push( input[key][i].value );
}
/* [3] S'il n'y a qu'une donnée (pas un tableau)
=========================================================*/
}else{
/* (1) Si de type 'radio' ou 'checkbox', on met la valeur de 'checked' */
if( this.checkable(input[key].target) )
output[key] = input[key].checked ? input[key].value : null;
/* (2) Sinon, on met la valeur de 'value' */
else
output[key] = input[key].value;
}
}
return output;
};
/* RETOURNE LA LISTE DE TOUS LES ÉLÉMENTS QUEL QUE SOIT LE NIVEAU HIÉRARCHIQUE
*
* @parent<Element> Parent duquel on veut les enfants
*
* @return children<Array> Tableau contenant tous les enfants
*
*/
FormDeflater.prototype.getChildren = function(parent){
// Si le parent n'est pas un élément, on retourne aucun enfant
if( !(parent instanceof Element) ) return [];
/* [1] Initialisation des variables
=========================================================*/
// Contient la liste des enfants directs
var children = [].slice.call(parent.children);
// Contiendra la liste des enfants directs et indirects
var allChildren = children;
/* [2] On parcourt tous les enfants
=========================================================*/
for( var i = 0 ; i < children.length ; i++ ){
// On relance la fonction récursivement sur tous les enfants
allChildren = allChildren.concat( [].slice.call(this.getChildren(children[i])) );
}
/* [3] On retourne le résultat
=========================================================*/
return allChildren;
};
/* FILTRE LES éléments en fonction de @this.tags et @this.attr
*
* @elements<Array> Le tableau contenant les éléments à trier
*
* @return filtered<Array> Retourne le tableau des éléments filtrés
*
*/
FormDeflater.prototype.filterElements = function(elements){
// Contiendra les éléments correspondants aux critères
var filtered = [];
/* [1] On parcourt tous les éléments
=========================================================*/
for( var i = 0 ; i < elements.length ; i++ )
// Si l'élément a le bon tag, on le garde
if( this.tags.indexOf( elements[i].tagName.toLowerCase() ) > -1 )
filtered.push(elements[i]);
/* [2] On retourne les éléments filtržés
=========================================================*/
return filtered;
};
/************/
/* USE CASE */
/************/
/* (1) Instanciation */
/*HIDDEN*/// var instance = new FormDeflater(
/*HIDDEN*/// document.getElementById('myform'),
/*HIDDEN*/// ['input', 'select'], // éléments à prendre en compte (tagName)
/*HIDDEN*/// ['id', 'name', 'data-elementname'] // Attributs par ordre de priorité
/*HIDDEN*/// );
/*HIDDEN*///
/* (2) On récupère l'objet */
/*HIDDEN*///
/*HIDDEN*/// var object = instance.deflate();
/*HIDDEN*///

View File

@ -208,7 +208,6 @@ pageManagerClass.prototype = {
pas la page ou si la page de l'URL ne correspond à aucune page de la liste)
========================================================================== */
setPage: function(pName, pPath, pContainer, pPageList, pRoot){
// liste de pages si c'est un tableau
var pageList = ( typeof pPageList == 'object' && pPageList instanceof Array ) ? pPageList : null; // si this.pagelist n'est pas overwrite il vaut null
@ -235,10 +234,18 @@ pageManagerClass.prototype = {
// Si on veut just `refresh` la page
if( pName === true ){
// formulaire POST
var fd = new FormData();
for( var i = 0 ; i < this.vars.length ; i++ )
fd.append(this.vars[i], null);
this.updateURL(); // can be useful for content or dep
this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){
this.container.innerHTML = e;
this.loadDependencies();
this.refresher.apply(this);
this.updateURL(); // if updated in refresher
}.bind(this), 'POST', fd);
return this;

View File

@ -208,7 +208,6 @@ pageManagerClass.prototype = {
pas la page ou si la page de l'URL ne correspond à aucune page de la liste)
========================================================================== */
setPage: function(pName, pPath, pContainer, pPageList, pRoot){
// liste de pages si c'est un tableau
var pageList = ( typeof pPageList == 'object' && pPageList instanceof Array ) ? pPageList : null; // si this.pagelist n'est pas overwrite il vaut null
@ -235,10 +234,18 @@ pageManagerClass.prototype = {
// Si on veut just `refresh` la page
if( pName === true ){
// formulaire POST
var fd = new FormData();
for( var i = 0 ; i < this.vars.length ; i++ )
fd.append(this.vars[i], null);
this.updateURL(); // could be useful for content or dep
this.ajax(this.root+this.path+'/'+this.page+'.php', function(e){
this.container.innerHTML = e;
this.loadDependencies();
this.refresher.apply(this);
this.updateURL(); // if updated in refresher
}.bind(this), 'POST', fd);
return this;

View File

@ -10,7 +10,7 @@ DOM = {
/* [0] Instanciation
===========================================*/
var pageManager = new pageManagerClass();
pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] );
var api = new APIClass('/api/');
@ -157,6 +157,8 @@ function navMenu(section, persistence){
navSubMenu(target);
}, false);
DOM.HEADER.remClass('loading');
};
/* (x) Si première ou changement de page, on charge la nouvelle */
@ -167,10 +169,16 @@ function navMenu(section, persistence){
}
}navMenu(pageManager.page);
}
// init page-manager
pageManager.setPage(null, '/view', DOM.CONTAINER, ['history', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings'] );
// launch pageManager
navMenu(pageManager.page);
@ -180,10 +188,23 @@ function navMenu(section, persistence){
// set default refresher
pageManager.refresher = function(){
/* (1) Loads page */
navSubMenu( this.vars[0] );
/* (2) Set listener for sub-menu nav */
document.querySelector('#CONTAINER > .sub-menu-side').addEventListener('click', function(e){
var target = e.target;
while( target != document.body && !target.getData('sublink') )
target = target.parentNode;
if( target.getData('sublink') )
navSubMenu(target);
}, false);
};

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

View File

@ -108,9 +108,8 @@ if( section.view.element != null ){
for( i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('cluster');
navSubMenu('edit');
document.location = '';
pageManager.vars = [ 'edit', e.target.getData('cluster') ];
pageManager.refresh();
}, false);
}
@ -119,9 +118,8 @@ if( section.view.element != null ){
for( i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('cluster');
navSubMenu('remove');
document.location = '';
pageManager.vars = [ 'remove', e.target.getData('cluster') ];
pageManager.refresh();
}, false);
}
@ -149,7 +147,6 @@ if( section.view.element != null ){
if( response.ModuleError != 0 )
return false;
// {4} Si tout s'est bien passé //
e.target.parentNode.parentNode.removeChild( e.target.parentNode );
});
@ -161,11 +158,10 @@ if( section.view.element != null ){
/* (7) On gere la "modification" des membres d'un groupe */
for( i = 0 ; i < section.view.group.add.length ; i++ ){
section.view.group.add[i].addEventListener('click', function(e){
section.view.group.add[i].addEventListener('mouseup', function(e){
pageManager.vars[1] = e.target.getData('cluster');
navSubMenu('members');
document.location = '';
pageManager.refresh();
}, false);
@ -766,8 +762,8 @@ if( section.members.element != null && section.members.chooser.element != null )
/* (2) Redirection */
pageManager.vars[1] = data;
console.log(pageManager.vars);
pageManager.refresh();
document.location = '';
}, false);

View File

@ -94,9 +94,8 @@ if( section.view.element != null ){
for( var i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('machine');
navSubMenu('edit');
document.location = '';
pageManager.vars = [ 'edit', e.target.getData('machine') ];
pageManager.refresh();
}, false);
}
@ -105,9 +104,8 @@ if( section.view.element != null ){
for( var i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('machine');
navSubMenu('remove');
document.location = '';
pageManager.vars = [ 'remove', e.target.getData('machine') ];
pageManager.refresh();
}, false);
}

View File

View File

View File

@ -102,9 +102,8 @@ if( section.view.element != null ){
for( var i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('user');
navSubMenu('edit');
document.location = '';
pageManager.vars = [ 'edit', e.target.getData('user') ];
pageManager.refresh();
}, false);
}
@ -113,9 +112,8 @@ if( section.view.element != null ){
for( var i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('user');
navSubMenu('remove');
document.location = '';
pageManager.vars = [ 'remove', e.target.getData('user') ];
pageManager.refresh();
}, false);
}
@ -318,8 +316,11 @@ if( section.remove.element != null ){
// Gestion automatique au chargement de la page si ID_MACHINE dans url "/users/remove/:id_user:"
if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ){
console.log('init id', pageManager.vars);
// On récupère la user d'uid donné dans l'URL
api.send({path:'userDefault/getById', id_user:pageManager.vars[1]}, function(response){
console.warn('user to remove', response);
// Si aucune erreur et un résultat
if( response.ModuleError == 0 ){
found_remove = [ response.user ]; // On récupère le résultat

View File

View File

View File

@ -12,7 +12,7 @@
<!-- Dépendences CSS -->
<link type='text/css' rel='stylesheet' href='/css/min/reset.css' /> <!-- Reset du css natif des browsers -->
<link type='text/css' rel='stylesheet' href='/css/min/font.css' /> <!-- Positionnement global des pages -->
<link type='text/css' rel='stylesheet' href='/css/min/fonts.css' /> <!-- Positionnement global des pages -->
<link type='text/css' rel='stylesheet' href='/css/min/layout.css' /> <!-- Positionnement global des pages -->
<link type='text/css' rel='stylesheet' href='/css/min/header.css' /> <!-- Gestion du header -->
<link type='text/css' rel='stylesheet' href='/css/min/menu-side.css' /> <!-- Gestion du menu -->