mirror of
https://github.com/Karaka-Management/jsOMS.git
synced 2026-01-11 09:58:39 +00:00
Restructure components/elements
This commit is contained in:
parent
970bc410b8
commit
95253f94b3
16
UI/Component/Autocomplete.js
Normal file
16
UI/Component/Autocomplete.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Form manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
/** @namespace jsOMS.UI */
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
|
|
@ -12,7 +12,7 @@
|
|||
"use strict";
|
||||
|
||||
/** @namespace jsOMS.UI */
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI');
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager = function (app)
|
||||
jsOMS.UI.Component.Form = function (app)
|
||||
{
|
||||
this.app = app;
|
||||
this.forms = {};
|
||||
|
|
@ -35,7 +35,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.get = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.get = function (id)
|
||||
{
|
||||
return this.forms[id];
|
||||
};
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.isIgnored = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.isIgnored = function (id)
|
||||
{
|
||||
return this.ignore.indexOf(id) !== -1;
|
||||
};
|
||||
|
|
@ -61,7 +61,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.unbind = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.unbind = function (id)
|
||||
{
|
||||
|
||||
};
|
||||
|
|
@ -74,7 +74,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.bind = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.bind = function (id)
|
||||
{
|
||||
if (typeof id !== 'undefined' && typeof this.ignore[id] === 'undefined') {
|
||||
this.bindForm(id);
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.bindForm = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.bindForm = function (id)
|
||||
{
|
||||
if (typeof id === 'undefined' || !id) {
|
||||
this.app.logger.info('A form doesn\'t have an ID.');
|
||||
|
|
@ -130,7 +130,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.unbindForm = function (id)
|
||||
jsOMS.UI.Component.Form.prototype.unbindForm = function (id)
|
||||
{
|
||||
// todo: do i need the findex? can't i just use id?
|
||||
let findex = 0;
|
||||
|
|
@ -155,7 +155,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.submit = function (form)
|
||||
jsOMS.UI.Component.Form.prototype.submit = function (form)
|
||||
{
|
||||
/* Handle injects */
|
||||
const self = this,
|
||||
|
|
@ -195,7 +195,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.submitForm = function (form)
|
||||
jsOMS.UI.Component.Form.prototype.submitForm = function (form)
|
||||
{
|
||||
if (!form.isValid()) {
|
||||
this.app.logger.debug('Form "' + form.getId() + '" has invalid values.');
|
||||
|
|
@ -252,7 +252,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.FormManager.prototype.count = function ()
|
||||
jsOMS.UI.Component.Form.prototype.count = function ()
|
||||
{
|
||||
return this.forms.length;
|
||||
};
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
{
|
||||
"use strict";
|
||||
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI');
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TabManager = function (responseManager)
|
||||
jsOMS.UI.Component.Tab = function (responseManager)
|
||||
{
|
||||
this.responseManager = responseManager;
|
||||
};
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TabManager.prototype.bind = function (id)
|
||||
jsOMS.UI.Component.Tab.prototype.bind = function (id)
|
||||
{
|
||||
if (typeof id !== 'undefined') {
|
||||
const e = document.getElementById(id);
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TabManager.prototype.bindElement = function (e)
|
||||
jsOMS.UI.Component.Tab.prototype.bindElement = function (e)
|
||||
{
|
||||
const nodes = e.querySelectorAll('.tab-links a');
|
||||
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
{
|
||||
"use strict";
|
||||
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI');
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TableManager = function (responseManager)
|
||||
jsOMS.UI.Component.Table = function (responseManager)
|
||||
{
|
||||
this.responseManager = responseManager;
|
||||
};
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TableManager.prototype.bind = function (id)
|
||||
jsOMS.UI.Component.Table.prototype.bind = function (id)
|
||||
{
|
||||
if (typeof id !== 'undefined') {
|
||||
const e = document.getElementById(id);
|
||||
|
|
@ -62,7 +62,7 @@
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.TableManager.prototype.bindElement = function (e)
|
||||
jsOMS.UI.Component.Table.prototype.bindElement = function (e)
|
||||
{
|
||||
const rows = e.querySelectorAll('[data-href]'),
|
||||
length = rows.length;
|
||||
16
UI/Component/TagInput.js
Normal file
16
UI/Component/TagInput.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Form manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
/** @namespace jsOMS.UI */
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
16
UI/Component/TagList.js
Normal file
16
UI/Component/TagList.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
/**
|
||||
* Form manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
/** @namespace jsOMS.UI */
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Component');
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
|
|
@ -1,172 +0,0 @@
|
|||
/**
|
||||
* Form manager class.
|
||||
*
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright 2013 Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0 * @since 1.0.0
|
||||
*/
|
||||
(function (jsOMS)
|
||||
{
|
||||
"use strict";
|
||||
|
||||
/** @namespace jsOMS.UI.Element.Element*/
|
||||
jsOMS.Autoloader.defineNamespace('jsOMS.UI.Element.Element');
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @constructor
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.Element.Input = function (actions)
|
||||
{
|
||||
this.actions = actions;
|
||||
};
|
||||
|
||||
/**
|
||||
* Unbind input element
|
||||
*
|
||||
* @param {Object} input Input element
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.Element.Input.prototype.unbind = function (input)
|
||||
{
|
||||
this.app.inputManager.getKeyboardManager().unbind(input);
|
||||
input.removeEventListener('change', changeBind, false);
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind input elment
|
||||
*
|
||||
* @param {Object} input Input elment
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.Element.Input.prototype.bind = function (input)
|
||||
{
|
||||
let self = this;
|
||||
|
||||
input.addEventListener('change', function changeBind(event)
|
||||
{
|
||||
/* Handle remote datalist/autocomplete input element */
|
||||
let listId, list;
|
||||
if (typeof (listId = this.getAttribute('list')) !== 'undefined' && (list = document.getElementById(listId)) && list.getAttribute('data-list-src') !== 'undefined') {
|
||||
self.addRemoteDatalistOptions(this, list);
|
||||
}
|
||||
|
||||
/* Handle html defined functions */
|
||||
let change;
|
||||
if (typeof (change = this.getAttribute('data-change-func')) !== 'undefined') {
|
||||
change(this);
|
||||
}
|
||||
|
||||
/* Handle pre-defined dynamic change events */
|
||||
let ref;
|
||||
if (typeof (ref = this.getAttribute('data-ref')) !== 'undefined') {
|
||||
let e = document.getElementById(ref);
|
||||
|
||||
if(!e) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (e.tagName) {
|
||||
case 'ul':
|
||||
break;
|
||||
case 'table':
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let dataButton;
|
||||
if (typeof (dataButton = input.getAttribute('data-button')) !== 'undefined') {
|
||||
this.app.inputManager.getKeyboardManager().bind(input, 13, function ()
|
||||
{
|
||||
const db = document.getElementById(dataButton);
|
||||
|
||||
if(db) {
|
||||
db.click();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add remote datalist options
|
||||
*
|
||||
* This only applies for datalists that have remote options
|
||||
*
|
||||
* @param {Object} input Input elment
|
||||
* @param {Object} datalist Datalist elment
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.Element.Input.prototype.addRemoteDatalistOptions = function (input, datalist)
|
||||
{
|
||||
this.clearDatalistOptions(datalist);
|
||||
|
||||
let request = new jsOMS.Message.Request();
|
||||
request.setData(input.value);
|
||||
request.setType(jsOMS.Message.Response.ResponseType.JSON);
|
||||
request.setUri(datalist.getAttribute('data-list-src'));
|
||||
request.setMethod(jsOMS.Message.Request.RequestMethod.POST);
|
||||
request.setRequestHeader('Content-Type', 'application/json');
|
||||
request.setSuccess(function (xhr)
|
||||
{
|
||||
try {
|
||||
let o = JSON.parse(xhr.response),
|
||||
response = new jsOMS.Message.Response(o),
|
||||
responseLength = response.count(),
|
||||
tempResponse = null,
|
||||
success = null;
|
||||
|
||||
for (let k = 0; k < responseLength; k++) {
|
||||
tempResponse = response.getByIndex(k);
|
||||
console.log(tempResponse);
|
||||
|
||||
let option = null,
|
||||
data = tempResponse.getData(),
|
||||
length = data.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
option = document.createElement('option');
|
||||
option.value = tempResponse.value;
|
||||
option.text = tempResponse.text;
|
||||
|
||||
datalist.appendChild(option);
|
||||
}
|
||||
}
|
||||
} catch (exception) {
|
||||
self.app.logger.error('Invalid JSON object: ' + xhr, 'FormManager');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
request.send();
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all datalist options from datalist
|
||||
*
|
||||
* @param {Object} datalist Datalist elment
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
jsOMS.UI.Element.Input.prototype.clearDatalistOptions = function (datalist)
|
||||
{
|
||||
let length = datalist.options.length;
|
||||
|
||||
for (let i = 0; i < length; i++) {
|
||||
datalist.remove(0);
|
||||
}
|
||||
};
|
||||
}(window.jsOMS = window.jsOMS || {}));
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
jsOMS.UI.UIManager = function (app)
|
||||
{
|
||||
this.app = app;
|
||||
this.formManager = new jsOMS.UI.FormManager(this.app);
|
||||
this.tabManager = new jsOMS.UI.TabManager(this.app.responseManager);
|
||||
this.tableManager = new jsOMS.UI.TableManager(this.app.responseManager);
|
||||
this.formManager = new jsOMS.UI.Component.Form(this.app);
|
||||
this.tabManager = new jsOMS.UI.Component.Tab(this.app.responseManager);
|
||||
this.tableManager = new jsOMS.UI.Component.Table(this.app.responseManager);
|
||||
this.actionManager = new jsOMS.UI.ActionManager(this.app);
|
||||
this.dragNDrop = new jsOMS.UI.DragNDrop(this.app);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user