Modification de la documentation
This commit is contained in:
46
src/gsdom.js
46
src/gsdom.js
@@ -2,10 +2,14 @@ window.$_ = (() => {
|
||||
'use strict';
|
||||
/**
|
||||
* Création du constructeur
|
||||
*
|
||||
* @example
|
||||
* let element = $_("a.link", "div#main");
|
||||
*
|
||||
* @param {String} selector Sélecteur utilisé
|
||||
* @param {HTMLElement} scope Racine de la recherche
|
||||
*/
|
||||
let Constructor = function(selector, scope) {
|
||||
let Constructor = function (selector, scope) {
|
||||
if (!selector) {
|
||||
return;
|
||||
}
|
||||
@@ -22,7 +26,7 @@ window.$_ = (() => {
|
||||
* Application d'une fonction sur chacun des éléments
|
||||
* @param {Function} callback La fonction de rappel
|
||||
*/
|
||||
Constructor.prototype.each = function(callback) {
|
||||
Constructor.prototype.each = function (callback) {
|
||||
if (!callback || typeof callback !== 'function') {
|
||||
return;
|
||||
}
|
||||
@@ -36,7 +40,7 @@ window.$_ = (() => {
|
||||
* @param {String} className Le nom de la classe à ajouter
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.addClass = function(className) {
|
||||
Constructor.prototype.addClass = function (className) {
|
||||
this.each(item => {
|
||||
item.classList.add(className);
|
||||
});
|
||||
@@ -47,7 +51,7 @@ window.$_ = (() => {
|
||||
* @param {String} className Le nom de la classe à ajouter
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.removeClass = function(className) {
|
||||
Constructor.prototype.removeClass = function (className) {
|
||||
this.each(item => {
|
||||
item.classList.remove(className);
|
||||
});
|
||||
@@ -59,7 +63,7 @@ window.$_ = (() => {
|
||||
* @param {String} newClass Nom de la classe de remplacement
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.replaceClass = function(oldClass, newClass) {
|
||||
Constructor.prototype.replaceClass = function (oldClass, newClass) {
|
||||
this.each(item => {
|
||||
item.classList.replace(oldClass, newClass);
|
||||
});
|
||||
@@ -71,7 +75,7 @@ window.$_ = (() => {
|
||||
* @param {String} value Valeur de l'attribut
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.setAttr = function(attr, value) {
|
||||
Constructor.prototype.setAttr = function (attr, value) {
|
||||
this.each(item => {
|
||||
item.setAttribute(attr, value);
|
||||
});
|
||||
@@ -82,7 +86,7 @@ window.$_ = (() => {
|
||||
* @param {String} attr Nom de l'attribut à supprimer
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.delAttr = function(attr) {
|
||||
Constructor.prototype.delAttr = function (attr) {
|
||||
this.each(item => {
|
||||
item.removeAttribute(attr);
|
||||
});
|
||||
@@ -92,7 +96,7 @@ window.$_ = (() => {
|
||||
* Ajoute l'attribut hidden aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.setHidden = function() {
|
||||
Constructor.prototype.setHidden = function () {
|
||||
this.setAttr('hidden', '');
|
||||
return this;
|
||||
};
|
||||
@@ -100,7 +104,7 @@ window.$_ = (() => {
|
||||
* Ajoute l'attribut readonly aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.setReadOnly = function() {
|
||||
Constructor.prototype.setReadOnly = function () {
|
||||
this.setAttr('readonly', '');
|
||||
return this;
|
||||
};
|
||||
@@ -108,7 +112,7 @@ window.$_ = (() => {
|
||||
* Ajoute l'attribut disabled aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.setDisabled = function() {
|
||||
Constructor.prototype.setDisabled = function () {
|
||||
this.setAttr('disabled', '');
|
||||
return this;
|
||||
};
|
||||
@@ -116,7 +120,7 @@ window.$_ = (() => {
|
||||
* Supprime l'attribut hidden aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.delHidden = function() {
|
||||
Constructor.prototype.delHidden = function () {
|
||||
this.delAttr('hidden');
|
||||
return this;
|
||||
};
|
||||
@@ -124,7 +128,7 @@ window.$_ = (() => {
|
||||
* Supprime l'attribut readonly aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.delReadOnly = function() {
|
||||
Constructor.prototype.delReadOnly = function () {
|
||||
this.delAttr('readonly');
|
||||
return this;
|
||||
};
|
||||
@@ -132,7 +136,7 @@ window.$_ = (() => {
|
||||
* Supprime l'attribut disabled aux éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.delDisabled = function() {
|
||||
Constructor.prototype.delDisabled = function () {
|
||||
this.delAttr('disabled');
|
||||
return this;
|
||||
};
|
||||
@@ -140,7 +144,7 @@ window.$_ = (() => {
|
||||
* switche l'attribut hidden des éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.toggleHidden = function() {
|
||||
Constructor.prototype.toggleHidden = function () {
|
||||
this.each(item => {
|
||||
if (item.hasAttribute('hidden')) {
|
||||
item.removeAttribute('hidden');
|
||||
@@ -154,7 +158,7 @@ window.$_ = (() => {
|
||||
* switche l'attribut readonly des éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.toggleReadOnly = function() {
|
||||
Constructor.prototype.toggleReadOnly = function () {
|
||||
this.each(item => {
|
||||
if (item.hasAttribute('readonly')) {
|
||||
item.removeAttribute('readonly');
|
||||
@@ -168,7 +172,7 @@ window.$_ = (() => {
|
||||
* switche l'attribut disabled des éléments sélectionnés
|
||||
* @returns {this} Chainage
|
||||
*/
|
||||
Constructor.prototype.toggleDisabled = function() {
|
||||
Constructor.prototype.toggleDisabled = function () {
|
||||
this.each(item => {
|
||||
if (item.hasAttribute('disabled')) {
|
||||
item.removeAttribute('disabled');
|
||||
@@ -184,7 +188,7 @@ window.$_ = (() => {
|
||||
* @param {Function} callback Gestionnaire de l'événement
|
||||
* @param {Boolean} useCapture Propagation de l'événement
|
||||
*/
|
||||
Constructor.prototype.on = function(type, callback, useCapture) {
|
||||
Constructor.prototype.on = function (type, callback, useCapture) {
|
||||
this.each(item => {
|
||||
item.removeEventListener(type, callback, useCapture || false);
|
||||
item.addEventListener(type, (evt, el) => {
|
||||
@@ -198,7 +202,7 @@ window.$_ = (() => {
|
||||
* @param {Function} callback Gestionnaire de l'événement
|
||||
* @param {Boolean} useCapture Propagation de l'événement
|
||||
*/
|
||||
Constructor.prototype.onClick = function(callback, useCapture) {
|
||||
Constructor.prototype.onClick = function (callback, useCapture) {
|
||||
this.on('click', callback, useCapture || false);
|
||||
return this;
|
||||
};
|
||||
@@ -206,21 +210,21 @@ window.$_ = (() => {
|
||||
* Retourne si un élément a été trouvé
|
||||
* @returns {Boolean} l'élément du DOM trouvé
|
||||
*/
|
||||
Constructor.prototype.found = function() {
|
||||
Constructor.prototype.found = function () {
|
||||
return this.elems.length > 0;
|
||||
};
|
||||
/**
|
||||
* Retourne le premier élément trouvé
|
||||
* @returns {HTMLElement} l'élément du DOM trouvé
|
||||
*/
|
||||
Constructor.prototype.first = function() {
|
||||
Constructor.prototype.first = function () {
|
||||
return this.found() ? this.elems[0] : false;
|
||||
};
|
||||
/**
|
||||
* Retourne le dernier élément trouvé
|
||||
* @returns {HTMLElement} L'élément du DOM trouvé
|
||||
*/
|
||||
Constructor.prototype.last = function() {
|
||||
Constructor.prototype.last = function () {
|
||||
return this.found() ? this.elems[this.elems.length - 1] : false;
|
||||
};
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user