mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-25 19:48:49 +02:00
poc form SDK (extends to form)
This commit is contained in:
56
js/DI/widget.js
Normal file
56
js/DI/widget.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Widgets handling.
|
||||
*
|
||||
* @returns {{handleElement: handleElement}}
|
||||
* @constructor
|
||||
*/
|
||||
const Widget = function(){
|
||||
|
||||
/**
|
||||
* initWidgets.
|
||||
*
|
||||
* @param oElement
|
||||
*/
|
||||
function initWidgets(oElement){
|
||||
|
||||
// get all widgets
|
||||
const aWidgetFields = oElement.querySelectorAll('[data-widget]');
|
||||
|
||||
// iterate throw widgets...
|
||||
aWidgetFields.forEach(function (widgetField) {
|
||||
|
||||
// initialize widget
|
||||
const sWidgetName = widgetField.dataset.widget;
|
||||
const oWidget = eval(`$(widgetField).${sWidgetName}()`);
|
||||
console.log('Init widget: ' + sWidgetName);
|
||||
console.log(oWidget);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* handleElement.
|
||||
*
|
||||
* @param element
|
||||
*/
|
||||
function handleElement(element){
|
||||
initWidgets(element);
|
||||
}
|
||||
|
||||
return {
|
||||
handleElement,
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user