diff --git a/UI/Component/Autocomplete.js b/UI/Component/Autocomplete.js new file mode 100644 index 0000000..36172a9 --- /dev/null +++ b/UI/Component/Autocomplete.js @@ -0,0 +1,16 @@ +/** + * Form manager class. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @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 || {})); \ No newline at end of file diff --git a/UI/FormManager.js b/UI/Component/Form.js similarity index 90% rename from UI/FormManager.js rename to UI/Component/Form.js index 6d336b7..61b4e36 100644 --- a/UI/FormManager.js +++ b/UI/Component/Form.js @@ -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 */ - 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 */ - 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 */ - 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 */ - 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 */ - 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 */ - 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 */ - 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 */ - 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 */ - 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 */ - jsOMS.UI.FormManager.prototype.count = function () + jsOMS.UI.Component.Form.prototype.count = function () { return this.forms.length; }; diff --git a/UI/Input.js b/UI/Component/Input.js similarity index 100% rename from UI/Input.js rename to UI/Component/Input.js diff --git a/UI/TabManager.js b/UI/Component/Tab.js similarity index 89% rename from UI/TabManager.js rename to UI/Component/Tab.js index 481a104..5500170 100644 --- a/UI/TabManager.js +++ b/UI/Component/Tab.js @@ -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 */ - 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 */ - 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 */ - jsOMS.UI.TabManager.prototype.bindElement = function (e) + jsOMS.UI.Component.Tab.prototype.bindElement = function (e) { const nodes = e.querySelectorAll('.tab-links a'); diff --git a/UI/TableManager.js b/UI/Component/Table.js similarity index 87% rename from UI/TableManager.js rename to UI/Component/Table.js index 3e26e18..a7320db 100644 --- a/UI/TableManager.js +++ b/UI/Component/Table.js @@ -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 */ - 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 */ - 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 */ - jsOMS.UI.TableManager.prototype.bindElement = function (e) + jsOMS.UI.Component.Table.prototype.bindElement = function (e) { const rows = e.querySelectorAll('[data-href]'), length = rows.length; diff --git a/UI/Component/TagInput.js b/UI/Component/TagInput.js new file mode 100644 index 0000000..36172a9 --- /dev/null +++ b/UI/Component/TagInput.js @@ -0,0 +1,16 @@ +/** + * Form manager class. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @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 || {})); \ No newline at end of file diff --git a/UI/Component/TagList.js b/UI/Component/TagList.js new file mode 100644 index 0000000..36172a9 --- /dev/null +++ b/UI/Component/TagList.js @@ -0,0 +1,16 @@ +/** + * Form manager class. + * + * @author OMS Development Team + * @author Dennis Eichhorn + * @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 || {})); \ No newline at end of file diff --git a/UI/Element/Input.js b/UI/Element/Input.js deleted file mode 100644 index 5596888..0000000 --- a/UI/Element/Input.js +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Form manager class. - * - * @author OMS Development Team - * @author Dennis Eichhorn - * @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 - */ - jsOMS.UI.Element.Input = function (actions) - { - this.actions = actions; - }; - - /** - * Unbind input element - * - * @param {Object} input Input element - * - * @since 1.0.0 - * @author Dennis Eichhorn - */ - 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 - */ - 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 - */ - 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 - */ - 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 || {})); diff --git a/UI/UIManager.js b/UI/UIManager.js index 0a58a1f..be92985 100644 --- a/UI/UIManager.js +++ b/UI/UIManager.js @@ -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); };