Docblock and general minor cleanup

This commit is contained in:
Dennis Eichhorn 2018-12-29 11:55:32 +01:00
parent 97a693fe4b
commit b83b957740
43 changed files with 641 additions and 517 deletions

View File

@ -28,8 +28,6 @@
*
* @return {int}
*
* @method
*
* @since 1.0.0
*/
getId ()

View File

@ -28,7 +28,7 @@
*
* @param {Object} account Account
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -42,7 +42,7 @@
*
* @param {int} id Account id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -64,8 +64,6 @@
*
* @return {null|Object}
*
* @method
*
* @since 1.0.0
*/
get (id)

View File

@ -29,8 +29,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
registerLoadedAssets ()
@ -48,14 +46,12 @@
/**
* Load asset.
*
* @param {string} path Asset path
* @param {string} filetype Filetype of the asset
* @param {string} path Asset path
* @param {string} filetype Filetype of the asset
* @param {requestCallback} [callback] Callback after load
*
* @return {string|boolean}
*
* @method
*
* @since 1.0.0
*/
load (path, filetype, callback)
@ -126,9 +122,7 @@
*
* @param {string} key Key of the asset
*
* @return
*
* @method
* @return {null|string}
*
* @since 1.0.0
*/
@ -150,8 +144,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
remove (key)

View File

@ -16,6 +16,8 @@
/**
* @constructor
*
* @param {string} uri Login uri
*
* @since 1.0.0
*/
constructor (uri)
@ -29,8 +31,6 @@
*
* @param {Object} account Account
*
* @method
*
* @since 1.0.0
*/
setAccount (account)
@ -43,8 +43,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getAccount ()
@ -55,7 +53,7 @@
/**
* Login account.
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -78,7 +76,7 @@
/**
* Logout account.
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -90,7 +88,7 @@
/**
* Handle login result.
*
* @method
* @return {void}
*
* @since 1.0.0
*/

View File

@ -3,7 +3,7 @@
*
* The autoloader is responsible for defining namespaces and dynamically loading javascript
* files that are not yet included. The intention is to provide a similar functionality as
* include, import etc. Contrary to it's name the autoloader is not able to truely autoload
* include, import etc. Contrary to it's name the autoloader is not able to truly autoload
* referenced classes.
*
* @copyright Dennis Eichhorn
@ -25,6 +25,8 @@
*
* @param {string} namespace Namespace
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.Autoloader.defineNamespace = function (namespace)
@ -51,6 +53,8 @@
/**
* Collect all loaded javascript files
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.Autoloader.initPreloaded = function ()
@ -74,6 +78,8 @@
*
* @param {string} file Script URI
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.Autoloader.addPreloaded = function (file)
@ -86,9 +92,11 @@
/**
* Include script
*
* @param {string} file Script URI
* @param {string} file Script URI
* @param {function} callback Callback after script loading
*
* @return {void}
*
* @since 1.0.0
*/
jsOMS.Autoloader.include = function (file, callback)

View File

@ -30,14 +30,12 @@
/**
* Set option.
*
* @param {int|string} key Option key
* @param {boolean|int|float|string|Array} value Option value
* @param {boolean} [overwrite] Overwrite value
* @param {int|string} key Option key
* @param {boolean|int|float|string|Array} value Option value
* @param {boolean} [overwrite] Overwrite value
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
set (key, value, overwrite = false)
@ -58,8 +56,6 @@
*
* @return {boolean|int|float|string|Array}
*
* @method
*
* @since 1.0.0
*/
get (key)
@ -78,8 +74,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
remove (key)

View File

@ -27,8 +27,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
static available()

View File

@ -33,9 +33,9 @@
* Adding the same event overwrites the existing one as "waiting"
*
* @param {string|int} group Group id
* @param {string|int} id Event id
* @param {string|int} id Event id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -55,8 +55,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
reset (group)
@ -75,8 +73,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
hasOutstanding (group)
@ -99,14 +95,12 @@
*
* Executes the callback specified for this group if all events are finished
*
* @param {string|int} group Group id
* @param {string|int} [id] Event id
* @param {Object} [data] Data for event
* @param {string|int} group Group id
* @param {string|int} [id] Event id
* @param {Object} [data] Data for event
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
trigger (group, id = '', data = null)
@ -135,14 +129,12 @@
*
* Executes the callback specified for this group if all events are finished
*
* @param {string|int} group Group id
* @param {string|int} [id] Event id
* @param {Object} [data] Data for event
* @param {string|int} group Group id
* @param {string|int} [id] Event id
* @param {Object} [data] Data for event
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
triggerSingleEvent (group, id = '', data = null)
@ -182,8 +174,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
detach (group)
@ -198,8 +188,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
detachCallback(group)
@ -220,8 +208,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
detachGroup(group)
@ -238,15 +224,13 @@
/**
* Attach callback to event group
*
* @param {string|int} group Group id
* @param {function} callback Callback or route for the event
* @param {boolean} [remove] Should be removed after execution
* @param {boolean} [reset] Reset after triggering
* @param {string|int} group Group id
* @param {function} callback Callback or route for the event
* @param {boolean} [remove] Should be removed after execution
* @param {boolean} [reset] Reset after triggering
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
attach (group, callback, remove = false, reset = false)
@ -265,8 +249,6 @@
*
* @return {int}
*
* @method
*
* @since 1.0.0
*/
count ()

View File

@ -33,13 +33,11 @@
* Get logging instance
*
* @param {boolean} [verbose] Verbose logging
* @param {boolean} [ui] Ui logging
* @param {boolean} [remote] Remote logging
* @param {boolean} [ui] Ui logging
* @param {boolean} [remote] Remote logging
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
static getInstance (verbose = true, ui = true, remote = false)
@ -54,14 +52,12 @@
/**
* Interpolate message
*
* @param {string} message Message structure
* @param {string} message Message structure
* @param {Object} [context] Context to put into message
* @param {string} [level] Log level
* @param {string} [level] Log level
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
interpolate (message, context, level)
@ -80,14 +76,12 @@
/**
* Create context
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
* @param {string} level Log level
* @param {string} level Log level
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
createContext (message, context, level)
@ -106,14 +100,12 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
* @param {string} level Log level
* @param {string} level Log level
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
write (message, context, level)
@ -136,14 +128,12 @@
/**
* Create local log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
* @param {string} level Log level
* @param {string} level Log level
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
writeVerbose (message, context, level)
@ -177,14 +167,12 @@
/**
* Create remote log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
* @param {string} level Log level
* @param {string} level Log level
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
writeRemote (message, context, level)
@ -204,13 +192,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
emergency (message, context = {})
@ -221,13 +207,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
alert (message, context = {})
@ -238,13 +222,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
critical (message, context = {})
@ -255,13 +237,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
error (message, context = {})
@ -272,13 +252,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
warning (message, context = {})
@ -289,13 +267,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
notice (message, context = {})
@ -306,13 +282,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
info (message, context = {})
@ -323,13 +297,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
debug (message, context = {})
@ -340,14 +312,12 @@
/**
* Create log message
*
* @param {string} level Log level
* @param {string} message Message to display
* @param {string} level Log level
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
log (level, message, context = {})
@ -358,13 +328,11 @@
/**
* Create log message
*
* @param {string} message Message to display
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
console (message, context = {})

View File

@ -9,6 +9,15 @@
(function (jsOMS) {
"use strict";
/**
* Evaluate math formula
*
* @param {string} equation Equation
*
* @return {null|float|int}
*
* @since 1.0.0
*/
jsOMS.mathEvaluate = function(equation)
{
const stack = [],
@ -41,11 +50,29 @@
return !isNaN(parseFloat(result)) && isFinite(result) ? result : null;
};
/**
* Parse value
*
* @param {string} value Value to parse
*
* @return {float|int}
*
* @since 1.0.0
*/
jsOMS.parseValue = function(value)
{
return typeof value === 'string' ? (value.indexOf('.') === -1 ? parseInt(value) : parseFloat(value)) : value;
}
/**
* Perform shunting yard
*
* @param {string} value Value to parse
*
* @return {Array}
*
* @since 1.0.0
*/
jsOMS.shuntingYard = function(equation)
{
const stack = [];

View File

@ -14,16 +14,39 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification.App');
jsOMS.Message.Notification.App.AppNotification = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor ()
{
this.status = 0;
};
/**
* Set notification status.
*
* @param {int} status Notification status
*
* @return {void}
*
* @since 1.0.0
*/
setStatus (status)
{
this.status = status;
};
/**
* Create notification
*
* @param {Object} msg Notification
*
* @return {void}
*
* @since 1.0.0
*/
send (msg)
{
const tpl = document.getElementById('app-message');

View File

@ -14,16 +14,37 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification.Browser');
jsOMS.Message.Notification.Browser.BrowserNotification = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor()
{
this.status = 0;
};
/**
* Set notification status.
*
* @param {int} status Notification status
*
* @return {void}
*
* @since 1.0.0
*/
setStatus (status)
{
this.status = status;
};
/**
* Ask for browser permission to create notifications
*
* @return {void}
*
* @since 1.0.0
*/
requestPermission ()
{
const self = this;
@ -40,8 +61,18 @@
}
};
/**
* Create notification
*
* @param {Object} msg Notification
*
* @return {void}
*
* @since 1.0.0
*/
send (msg)
{
// todo: implement
/** global: Notification */
let n = new Notification(/* ... */);
};

View File

@ -1,5 +1,5 @@
/**
* Browser notification.
* Notification manager.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
@ -14,12 +14,27 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
jsOMS.Message.Notification.NotificationManager = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor()
{
this.appNotifier = new jsOMS.Message.Notification.App.AppNotification();
this.browserNotifier = new jsOMS.Message.Notification.Browser.BrowserNotification();
};
/**
* Create notification.
*
* @param {Object} message Message object
* @param {int} type Notification type
*
* @return {void}
*
* @since 1.0.0
*/
send (message, type)
{
if (jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION === type) {
@ -29,11 +44,25 @@
}
};
/**
* Get the app notification manager.
*
* @return {Object}
*
* @since 1.0.0
*/
getAppNotifier ()
{
return this.appNotifier;
};
/**
* Get the browser notification manager.
*
* @return {Object}
*
* @since 1.0.0
*/
getBrowserNotifier ()
{
return this.browserNotifier;

View File

@ -13,6 +13,15 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
jsOMS.Message.Notification.NotificationMessage = class {
/**
* @constructor
*
* @param {string} status Message status
* @param {string} title Message title
* @param {string} message Message content
*
* @since 1.0.0
*/
constructor(status, title, message)
{
this.status = status;

View File

@ -17,6 +17,10 @@
/**
* @constructor
*
* @param {string} uri Request uri
* @param {string} method Request method/verb
* @param {string} type Request content type
*
* @since 1.0.0
*/
constructor (uri = null, method, type)
@ -44,8 +48,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
setContentTypeBasedOnType(type)
@ -67,8 +69,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
static getBrowser()
@ -99,8 +99,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
static getOS()
@ -124,7 +122,7 @@
*
* @param {string} method Method type
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -140,8 +138,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getMethod()
@ -156,7 +152,7 @@
*
* @param {string} type Method type
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -172,8 +168,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getResponseType()
@ -184,10 +178,10 @@
/**
* Set request header.
*
* @param {string} type Request type
* @param {string} type Request type
* @param {string} header Request header
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -201,8 +195,6 @@
*
* @return {Array}
*
* @method
*
* @since 1.0.0
*/
getRequestHeader()
@ -215,7 +207,7 @@
*
* @param {string} uri Request uri
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -229,8 +221,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getUri()
@ -241,10 +231,9 @@
/**
* Set success callback.
*
* @callback requestCallback
* @param {requestCallback} callback - Success callback
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -256,10 +245,10 @@
/**
* Set result callback.
*
* @param {int} status Http response status
* @param {int} status Http response status
* @param {function} callback Callback
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -273,7 +262,7 @@
*
* @param {Array} data Request data
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -287,8 +276,6 @@
*
* @return {Array}
*
* @method
*
* @since 1.0.0
*/
getData()
@ -303,7 +290,7 @@
*
* @param {string} type Method type
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -320,8 +307,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getType()
@ -334,8 +319,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
queryfy(obj)
@ -355,8 +338,6 @@
*
* @return {Array}
*
* @method
*
* @since 1.0.0
*/
send()

View File

@ -16,16 +16,39 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Response');
jsOMS.Message.Response.Response = class {
/**
* @constructor
*
* @param {mixed} data Response data
*
* @since 1.0.0
*/
constructor (data)
{
this.responses = data;
};
/**
* Get response by id.
*
* @param {string} id Response id
*
* @return {mixed}
*
* @since 1.0.0
*/
get (id)
{
return this.responses[id];
};
/**
* Count the amount of responses.
*
* @return {int}
*
* @since 1.0.0
*/
count ()
{
return this.responses.length;

View File

@ -35,7 +35,7 @@
* @param {requestCallback} message Callback for message
* @param {string} [request] Request id in order to only handle a specific request
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -58,7 +58,7 @@
* @param {Array|Object} data Date to use in callback
* @param {jsOMS.Message.Request.Request} [request] Request id for request specific execution
*
* @method
* @return {void}
*
* @since 1.0.0
*/

View File

@ -26,12 +26,10 @@
* Get module instance.
*
* @param {string} module Module name
* @param {Object} app Application reference
* @param {Object} app Application reference
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
static getInstance (module, app)

View File

@ -17,6 +17,8 @@
/**
* @constructor
*
* @param {Object} app Application
*
* @since 1.0.0
*/
constructor(app)
@ -32,8 +34,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
get (module)

View File

View File

View File

@ -1,5 +1,5 @@
/**
* Form manager class.
* Action manager class.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
@ -11,197 +11,187 @@
"use strict";
/** @namespace jsOMS.UI */
jsOMS.Autoloader.defineNamespace('jsOMS.UI');
jsOMS.Autoloader.defineNamespace('jsOMS.UI.ActionManager');
/**
* Constructor
*
* @param {Object} app Application
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager = function (app)
{
this.app = app;
this.actions = {};
};
jsOMS.UI.ActionManager = class {
/**
* @constructor
*
* @param {Object} app Application
*
* @since 1.0.0
*/
constructor(app)
{
this.app = app;
this.actions = {};
};
/**
* Bind element.
*
* @param {string} [id] Element id (optional)
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager.prototype.bind = function (id)
{
const uiElements = typeof id === 'undefined' ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]),
length = uiElements.length;
/**
* Bind element.
*
* @param {string} [id] Element id (optional)
*
* @return {void}
*
* @since 1.0.0
*/
bind(id)
{
const uiElements = typeof id === 'undefined' ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]),
length = uiElements.length;
for (let i = 0; i < length; ++i) {
if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) {
this.bindElement(uiElements[i]);
for (let i = 0; i < length; ++i) {
if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) {
this.bindElement(uiElements[i]);
}
}
}
};
};
/**
* Bind element.
*
* @param {Element} e Element to bind
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager.prototype.bindElement = function (e)
{
if (!jsOMS.isValidJson(e.getAttribute('data-action'))) {
jsOMS.Log.Logger.instance.error('Invalid json string: \'' + e.getAttribute('data-action') + '\'');
/**
* Bind element.
*
* @param {Element} e Element to bind
*
* @return {void}
*
* @since 1.0.0
*/
bindElement (e)
{
if (!jsOMS.isValidJson(e.getAttribute('data-action'))) {
jsOMS.Log.Logger.instance.error('Invalid json string: \'' + e.getAttribute('data-action') + '\'');
return;
}
// todo: validate json, if invalid log error
const listeners = JSON.parse(e.getAttribute('data-action')),
listenerLength = listeners.length,
self = this;
// For everey action an event is registered
for (let i = 0; i < listenerLength; ++i) {
let c = [e], hasSelector = false;
if (listeners[i].hasOwnProperty('selector')) {
c = document.querySelectorAll(listeners[i].selector);
hasSelector = true;
}
let childLength = c.length;
for (let j = 0; j < childLength; ++j) {
this.bindListener(c[j].id, listeners[i]);
}
// if it has selector then a listener for child events must be implemented since these can potentially changed without any knowledge
// todo: what if the selector parent is different from "e"? then this doesn't make sense! Maybe this isn't allowed to happen!
// todo: careful this could cause bugs if there is another component relying on a listener for this dom element. Maybe create actionManager domlistener?
// Maybe just use this listener for ALL action listeners and check if delete, then remove otherwise do current stuff.
// Problem is, the listener doesn't work for the node itself only for children and listening to ALL document nodes might be a bad idea?!?!?!
const observeConfig = { childList: false, attributes: true, subtree: false };
if (hasSelector) {
this.app.eventManager.attach(e.id + '-childList', function(data) {
const length = data.addedNodes.length;
for (let j = 0; j < length; ++j) {
self.bindListener(data.addedNodes[j].id, listeners[i], true);
// todo only make removable if action itself is defined as auto removable
}
});
observeConfig.childList = true;
observeConfig.subtree = true;
}
this.app.eventManager.attach(e.id + '-attributes', function(data) {});
this.app.uiManager.getDOMObserver().observe(e, observeConfig);
}
};
/**
* Bind listener for object
*
* @param {string} id Element to bind
* @param {object} listener Listener object
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager.prototype.bindListener = function(id, listener, removable = false)
{
const self = this,
actionLength = listener.action.length;
for (let j = 1; j < actionLength; ++j) {
if (typeof id === 'undefined' || typeof listener.key === 'undefined') {
jsOMS.Log.Logger.instance.error('Invalid element id/key: ' + id + '/' + listener.key);
return;
}
this.app.eventManager.attach(id + '-' + listener.key + '-' + listener.action[j - 1].key, function (data)
{
self.runAction(id, listener, listener.action[j], data);
}, removable, true);
}
// todo: the true here is a memory leak since it should be removed at some point?!
// todo: handle onload action right after registering everything. this will be used for onload api calls in order to get content such as lists or models. Maybe in the main application after registering a invoke('onload') should be called if the application wants to execute the onload elements
// todo: validate json, if invalid log error
const listeners = JSON.parse(e.getAttribute('data-action')),
listenerLength = listeners.length,
self = this;
// Register event for first action
document.getElementById(id).addEventListener(listener.listener, function (event)
// For everey action an event is registered
for (let i = 0; i < listenerLength; ++i) {
let c = [e], hasSelector = false;
if (listeners[i].hasOwnProperty('selector')) {
c = document.querySelectorAll(listeners[i].selector);
hasSelector = true;
}
let childLength = c.length;
for (let j = 0; j < childLength; ++j) {
this.bindListener(c[j].id, listeners[i]);
}
// if it has selector then a listener for child events must be implemented since these can potentially changed without any knowledge
// todo: what if the selector parent is different from "e"? then this doesn't make sense! Maybe this isn't allowed to happen!
// todo: careful this could cause bugs if there is another component relying on a listener for this dom element. Maybe create actionManager domlistener?
// Maybe just use this listener for ALL action listeners and check if delete, then remove otherwise do current stuff.
// Problem is, the listener doesn't work for the node itself only for children and listening to ALL document nodes might be a bad idea?!?!?!
const observeConfig = { childList: false, attributes: true, subtree: false };
if (hasSelector) {
this.app.eventManager.attach(e.id + '-childList', function(data) {
const length = data.addedNodes.length;
for (let j = 0; j < length; ++j) {
self.bindListener(data.addedNodes[j].id, listeners[i], true);
// todo only make removable if action itself is defined as auto removable
}
});
observeConfig.childList = true;
observeConfig.subtree = true;
}
this.app.eventManager.attach(e.id + '-attributes', function(data) {});
this.app.uiManager.getDOMObserver().observe(e, observeConfig);
}
};
/**
* Bind listener for object
*
* @param {string} id Element to bind
* @param {object} listener Listener object
*
* @return {void}
*
* @since 1.0.0
*/
bindListener (id, listener, removable = false)
{
if (listener.preventDefault) {
event.preventDefault();
const self = this,
actionLength = listener.action.length;
for (let j = 1; j < actionLength; ++j) {
if (typeof id === 'undefined' || typeof listener.key === 'undefined') {
jsOMS.Log.Logger.instance.error('Invalid element id/key: ' + id + '/' + listener.key);
return;
}
this.app.eventManager.attach(id + '-' + listener.key + '-' + listener.action[j - 1].key, function (data)
{
self.runAction(id, listener, listener.action[j], data);
}, removable, true);
}
// todo: the true here is a memory leak since it should be removed at some point?!
// todo: handle onload action right after registering everything. this will be used for onload api calls in order to get content such as lists or models. Maybe in the main application after registering a invoke('onload') should be called if the application wants to execute the onload elements
// Register event for first action
document.getElementById(id).addEventListener(listener.listener, function (event)
{
if (listener.preventDefault) {
event.preventDefault();
}
self.runAction(this.id, listener, listener.action[0], event);
});
};
/**
* Run event action.
*
* @param {string} id Element
* @param {Object} listener Listener
* @param {Object} action Action
* @param {Object} data Data for the next action
*
* @return {void}
*
* @since 1.0.0
*/
runAction (id, listener, action, data)
{
const self = this;
if (!this.actions.hasOwnProperty(action.type)) {
jsOMS.Log.Logger.instance.warning('Undefined action ' + action.type);
return;
}
self.runAction(this.id, listener, listener.action[0], event);
});
};
action.data = data;
/**
* Run event action.
*
* @param {string} id Element
* @param {Object} listener Listener
* @param {Object} action Action
* @param {Object} data Data for the next action
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager.prototype.runAction = function (id, listener, action, data)
{
const self = this;
this.actions[action.type](action, function (data)
{
self.app.eventManager.trigger(id + '-' + listener.key + '-' + action.key, id, data);
}, id);
};
if (!this.actions.hasOwnProperty(action.type)) {
jsOMS.Log.Logger.instance.warning('Undefined action ' + action.type);
return;
}
action.data = data;
this.actions[action.type](action, function (data)
/**
* Add action callback.
*
* @param {string} name Action identifier
* @param {function} callback Action callback
*
* @return {void}
*
* @since 1.0.0
*/
add (name, callback)
{
self.app.eventManager.trigger(id + '-' + listener.key + '-' + action.key, id, data);
}, id);
};
/**
* Add action callback.
*
* @param {string} name Action identifier
* @param {function} callback Action callback
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
jsOMS.UI.ActionManager.prototype.add = function (name, callback)
{
this.actions[name] = callback;
};
this.actions[name] = callback;
};
}
}(window.jsOMS = window.jsOMS || {}));

View File

@ -17,6 +17,8 @@
/**
* @constructor
*
* @param {Object} app Application
*
* @since 1.0.0
*/
constructor (app)
@ -31,6 +33,8 @@
*
* @param {string} id Form Id
*
* @return {void}
*
* @since 1.0.0
*/
get (id)
@ -43,6 +47,8 @@
*
* @param {string} id Form Id
*
* @return {boolean}
*
* @since 1.0.0
*/
isIgnored (id)
@ -55,6 +61,8 @@
*
* @param {string} id Form Id
*
* @return {void}
*
* @since 1.0.0
*/
unbind (id)
@ -67,6 +75,8 @@
*
* @param {string} id Form Id (optional)
*
* @return {void}
*
* @since 1.0.0
*/
bind (id)
@ -91,6 +101,8 @@
*
* @param {string} id Form Id
*
* @return {void}
*
* @since 1.0.0
*/
bindForm (id)
@ -122,6 +134,8 @@
*
* @param {string} id Form Id
*
* @return {boolean}
*
* @since 1.0.0
*/
unbindForm (id)
@ -146,6 +160,8 @@
*
* @param {Object} form Form object
*
* @return {void}
*
* @since 1.0.0
*/
submit (form)
@ -189,6 +205,8 @@
*
* @param {Object} form Form object
*
* @return {void}
*
* @since 1.0.0
*/
submitForm (form)
@ -267,7 +285,7 @@
/**
* Count the bound forms
*
* @return {number}
* @return {int}
*
* @since 1.0.0
*/

View File

@ -19,6 +19,8 @@
*
* @param {Object} input Input element
*
* @return {void}
*
* @since 1.0.0
*/
static unbind = function (input)
@ -29,9 +31,11 @@
};
/**
* Bind input elment
* Bind input element
*
* @param {Object} input Input elment
* @param {Object} input Input element
*
* @return {void}
*
* @since 1.0.0
*/
@ -94,8 +98,10 @@
*
* This only applies for datalists that have remote options
*
* @param {Object} input Input elment
* @param {Object} datalist Datalist elment
* @param {Object} input Input element
* @param {Object} datalist Datalist element
*
* @return {void}
*
* @since 1.0.0
*/
@ -144,7 +150,9 @@
/**
* Remove all datalist options from datalist
*
* @param {Object} datalist Datalist elment
* @param {Object} datalist Datalist element
*
* @return {void}
*
* @since 1.0.0
*/

View File

@ -18,9 +18,8 @@
*
* @since 1.0.0
*/
constructor (responseManager)
constructor ()
{
this.responseManager = responseManager;
};
/**
@ -28,7 +27,7 @@
*
* @param {string} [id] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -38,7 +37,7 @@
const e = document.getElementById(id);
if (e) {
this.bindElement();
this.bindElement(e);
}
} else {
const tabs = document.querySelectorAll('.tabview'),
@ -53,9 +52,9 @@
/**
* Bind & rebind UI element.
*
* @param {Object} [e] Element id
* @param {Object} e Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/

View File

@ -16,6 +16,8 @@
/**
* @constructor
*
* @param {Object} app Application
*
* @since 1.0.0
*/
constructor(app)
@ -30,7 +32,7 @@
*
* @param {string} [id] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -56,6 +58,8 @@
*
* @param {string} id Table Id
*
* @return {void}
*
* @since 1.0.0
*/
unbind (id)
@ -68,7 +72,7 @@
*
* @param {Object} [id] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -113,6 +117,16 @@
}
};
/**
* Removes the closest row on click.
*
* @param {Element} remove Remove button
* @param {Object} id Element id
*
* @return {void}
*
* @since 1.0.0
*/
bindRemovable(remove, id)
{
remove.addEventListener('click', function (event)
@ -123,6 +137,16 @@
});
};
/**
* Swaps the row on click.
*
* @param {Element} sorting Swap button
* @param {Object} id Element id
*
* @return {void}
*
* @since 1.0.0
*/
bindReorder(sorting, id)
{
sorting.addEventListener('click', function (event)
@ -143,6 +167,16 @@
});
};
/**
* Sorts the table.
*
* @param {Element} sorting Sort button
* @param {Object} id Table id
*
* @return {void}
*
* @since 1.0.0
*/
bindSorting(sorting, id)
{
sorting.addEventListener('click', function (event)
@ -193,6 +227,16 @@
});
};
/**
* Filters the table.
*
* @param {Element} filtering Filter button
* @param {Object} id Table id
*
* @return {void}
*
* @since 1.0.0
*/
bindFiltering(filtering, id)
{
filtering.addEventListener('click', function (event)

View File

@ -31,6 +31,8 @@
*
* @param {Object} element DOM element
*
* @return {void}
*
* @since 1.0.0
*/
unbind (element)
@ -42,6 +44,8 @@
*
* @param {Object} id DOM element
*
* @return {void}
*
* @since 1.0.0
*/
bind (id)
@ -63,7 +67,9 @@
/**
* Bind DOM elment
*
* @param {string} id DOM elment
* @param {string} id DOM element
*
* @return {void}
*
* @since 1.0.0
*/

View File

@ -29,7 +29,7 @@
*
* @param {string} [id] Button id (optional)
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -49,7 +49,7 @@
*
* @param {Object} [e] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -71,7 +71,7 @@
*
* @param {Object} [e] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/

View File

@ -32,6 +32,8 @@
* @param {Array} keys Keyboard keys
* @param {callback} callback Callback
*
* @return {void}
*
* @since 1.0.0
*/
add (element, keys, callback)
@ -50,6 +52,8 @@
*
* @param {string} element Container id
*
* @return {void}
*
* @since 1.0.0
*/
bind (element)
@ -77,6 +81,10 @@
* @param {string} element Container id
* @param {Object} event Key event
*
* @return {void}
*
* @throws {Error}
*
* @since 1.0.0
*/
run (element, event)

View File

@ -34,6 +34,8 @@
* @param {callback} callback Callback
* @param {bool} exact ??? todo: can't remember why this was important oO!!!
*
* @return {void}
*
* @since 1.0.0
*/
add (element, type, button, callback, exact)
@ -52,6 +54,8 @@
* @param {string} element Element id
* @param {int} type Action type
*
* @return {void}
*
* @since 1.0.0
*/
bind (element, type)
@ -98,6 +102,8 @@
* @param {string} element Element id
* @param {Object} event Click event
*
* @return {void}
*
* @since 1.0.0
*/
run (element, event)

View File

@ -33,6 +33,8 @@
*
* This is called in between swipes in order to reset previous swipe data.
*
* @return {void}
*
* @since 1.0.0
*/
resetSwipe ()
@ -43,7 +45,9 @@
/**
* Adding swipe functionality.
*
* Forwarding swipe to arrow keyes.
* Forwarding swipe to arrow keys.
*
* @return {void}
*
* @since 1.0.0
*/

View File

@ -30,6 +30,8 @@
/**
* @constructor
*
* @param {string} lang Localization
*
* @since 1.0.0
*/
constructor (lang = 'en-US')

View File

@ -30,6 +30,10 @@
/**
* @constructor
*
* @param {Object} app Application
* @param {Object} commands Available commands
* @param {string} lang Localization
*
* @since 1.0.0
*/
constructor(app, commands = {}, lang = 'en-US')
@ -49,7 +53,7 @@
/**
* Setup or re-initialize voice manager.
*
* @method
* @return {void}
*
* @since 1.0.0
*/

View File

@ -25,7 +25,7 @@
{
this.app = app;
this.formManager = new jsOMS.UI.Component.Form(this.app);
this.tabManager = new jsOMS.UI.Component.Tab(this.app.responseManager);
this.tabManager = new jsOMS.UI.Component.Tab();
this.tableManager = new jsOMS.UI.Component.Table(this.app);
this.actionManager = new jsOMS.UI.ActionManager(this.app);
this.dragNDrop = new jsOMS.UI.DragNDrop(this.app);
@ -47,7 +47,7 @@
*
* @param {string} [id] Element id
*
* @method
* @return {void}
*
* @since 1.0.0
*/
@ -86,8 +86,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getFormManager()
@ -100,8 +98,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getActionManager()
@ -114,8 +110,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getDragNDrop()
@ -128,8 +122,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getTabManager()
@ -142,8 +134,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getTableManager()
@ -156,8 +146,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getDOMObserver()
@ -170,8 +158,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
getGeneralUI()

View File

@ -1,7 +1,7 @@
/**
* Http Uri.
*
* This class is for creating, modifying and analysing http uris.
* This class is for creating, modifying and analyzing http uris.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
@ -41,15 +41,13 @@
/**
* Parse uri
*
* @param {string} str Url to parse
* @param {string} str Url to parse
* @param {string} [mode] Parsing mode
*
* @return {Object}
*
* @throws {Error}
*
* @function
*
* @since 1.0.0
*/
static parseUrl (str, mode = 'php')
@ -86,12 +84,10 @@
* Get Uri query parameters.
*
* @param {string} query Uri query
* @param {string} name Name of the query to return
* @param {string} name Name of the query to return
*
* @return {null|string}
*
* @method
*
* @since 1.0.0
*/
static getUriQueryParameter (query, name)
@ -111,8 +107,6 @@
*
* @return {Object}
*
* @method
*
* @since 1.0.0
*/
static getAllUriQueryParameters (query)
@ -153,8 +147,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
set (uri)
@ -191,8 +183,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
setRootPath(rootPath)
@ -206,8 +196,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getBase()
@ -220,8 +208,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getScheme()
@ -234,8 +220,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getHost()
@ -248,8 +232,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getPort()
@ -262,8 +244,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getUser()
@ -276,8 +256,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getPass()
@ -290,8 +268,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getQuery()
@ -304,8 +280,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getUri()
@ -318,8 +292,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getFragment()
@ -332,8 +304,6 @@
*
* @return {string}
*
* @method
*
* @since 1.0.0
*/
getPath()
@ -346,8 +316,6 @@
*
* @return {int}
*
* @method
*
* @since 1.0.0
*/
getPathOffset()

View File

@ -17,14 +17,12 @@
/**
* Set uri query
*
* @param {string} key Query key
* @param {string} value Query value
* @param {string} key Query key
* @param {string} value Query value
* @param {boolean} [overwrite] Overwrite if already exists?
*
* @return {boolean}
*
* @function
*
* @since 1.0.0
*/
static setQuery (key, value, overwrite)
@ -47,8 +45,6 @@
*
* @return {null|string}
*
* @method
*
* @since 1.0.0
*/
static getQuery (key)
@ -61,8 +57,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
static clearAll ()
@ -79,8 +73,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
static clear (key)
@ -101,8 +93,6 @@
*
* @return {boolean}
*
* @method
*
* @since 1.0.0
*/
static clearLike (pattern)
@ -129,8 +119,6 @@
*
* @return {string}
*
* @function
*
* @since 1.0.0
*/
static unique (url)
@ -174,10 +162,10 @@
* $ = Other data
* % = Current url
*
* @param {string} uri Raw uri
* @param {string} uri Raw uri
* @param {Object} [toMatch] Key/value pair to replace in raw
*
* @function
* @return {string}
*
* @since 1.0.0
*/
@ -216,9 +204,7 @@
parsed = parsed.replace('&', '?');
}
parsed = jsOMS.Uri.UriFactory.unique(parsed);
return parsed;
return jsOMS.Uri.UriFactory.unique(parsed);
};
/**
@ -226,8 +212,6 @@
*
* @return {void}
*
* @method
*
* @since 1.0.0
*/
static setupUriBuilder (uri)

View File

@ -19,9 +19,7 @@
* @param {Object} data Object
* @param {string} delim Path delimiter
*
* @return
*
* @function
* @return {mixed}
*
* @since 1.0.0
*/

View File

@ -17,7 +17,7 @@
*
* Used to fire event after delay
*
* @function
* @return {callback}
*
* @since 1.0.0
*/
@ -37,9 +37,7 @@
* @param target Target array
* @param source Source array
*
* @return Array
*
* @function
* @return {Array}
*
* @since 1.0.0
*/
@ -75,6 +73,15 @@
return obj;
};
/**
* Check if a value/variable is set
*
* @param variable Variable to check for existence.
*
* @return {boolean}
*
* @since 1.0.0
*/
jsOMS.isset = function (variable)
{
return typeof variable !== 'undefined' && variable !== null;

View File

@ -15,13 +15,11 @@
/**
* Trim char from string
*
* @param {string} str String to trim from
* @param {string} str String to trim from
* @param {string} char Char to trim
*
* @return {string}
*
* @function
*
* @since 1.0.0
*/
jsOMS.trim = function(str, char = ' ')
@ -32,13 +30,11 @@
/**
* Trim char from right part of string
*
* @param {string} str String to trim from
* @param {string} str String to trim from
* @param {string} char Char to trim
*
* @return {string}
*
* @function
*
* @since 1.0.0
*/
jsOMS.rtrim = function(str, char = ' ')
@ -49,13 +45,11 @@
/**
* Trim char from left part of string
*
* @param {string} str String to trim from
* @param {string} str String to trim from
* @param {string} char Char to trim
*
* @return {string}
*
* @function
*
* @since 1.0.0
*/
jsOMS.ltrim = function(str, char = ' ')
@ -68,7 +62,7 @@
*
* @param {string} jsonString String to validate
*
* @function
* @return {boolean}
*
* @since 1.0.0
*/
@ -85,13 +79,11 @@
/**
* Count string in string
*
* @param {string} str String to inspect
* @param {string} str String to inspect
* @param {string} substr Substring to count
*
* @return {int}
*
* @function
*
* @since 1.0.0
*/
jsOMS.substr_count = function(str, substr) {
@ -128,8 +120,6 @@
*
* @return {int}
*
* @function
*
* @since 1.0.0
*/
jsOMS.hash = function (str)
@ -144,6 +134,16 @@
return res;
};
/**
* Get the remaining string after finding a certain char
*
* @param {string} haystack String to to search in
* @param {array} chars Chars to search for
*
* @return {string}
*
* @since 1.0.0
*/
jsOMS.strpbrk = function (haystack, chars)
{
const length = chars.length;
@ -159,6 +159,16 @@
return haystack.slice(min);
};
/**
* Encodes special html characters
*
* @param {string} text String to encode
* @param {boolean} quotes Should quotes be allowed
*
* @return {string}
*
* @since 1.0.0
*/
jsOMS.htmlspecialchars = function (text, quotes) {
let map = {
'&': '&amp;',

View File

@ -22,8 +22,6 @@
*
* @return {boolean}
*
* @function
*
* @since 1.0.0
*/
jsOMS.hasClass = function (ele, cls)
@ -42,7 +40,7 @@
* @param ele DOM Element
* @param cls Class to add
*
* @function
* @return {void}
*
* @since 1.0.0
*/
@ -61,7 +59,7 @@
* @param ele DOM Element
* @param cls Class to remove
*
* @function
* @return {void}
*
* @since 1.0.0
*/
@ -76,11 +74,11 @@
/**
* Action prevent
*
* Preventing event from firering and passing through
* Preventing event from firing and passing through
*
* @param event Event Event to stop
*
* @function
* @return {void}
*
* @since 1.0.0
*/
@ -100,9 +98,9 @@
*
* Invoking a function after page load
*
* @param func Callback function
* @param {callback} func Callback function
*
* @function
* @return {void}
*
* @since 1.0.0
*/
@ -129,7 +127,7 @@
*
* @param ele DOM Element
*
* @function
* @return {void}
*
* @since 1.0.0
*/
@ -149,8 +147,6 @@
*
* @return {boolean}
*
* @function
*
* @since 1.0.0
*/
jsOMS.isNode = function (ele)
@ -170,8 +166,6 @@
*
* @return {boolean}
*
* @function
*
* @since 1.0.0
*/
jsOMS.isElement = function (o)
@ -190,9 +184,7 @@
* @param ele DOM Element
* @param cls Class to find
*
* @return Element
*
* @function
* @return {Element}
*
* @since 1.0.0
*/
@ -212,11 +204,11 @@
/**
* Adding event listener to multiple elements
*
* @param e DOM Elements
* @param {string} event Event name
* @param e DOM Elements
* @param {string} event Event name
* @param {function} callback Event callback
*
* @function
* @return {void}
*
* @since 1.0.0
*/

View File

@ -40,6 +40,8 @@
*
* Pulled out since this is used in a cleanup process
*
* @return {void}
*
* @since 1.0.0
*/
initializeMembers ()
@ -73,11 +75,25 @@
return this.action;
};
/**
* Get time of last submit
*
* @return {int}
*
* @since 1.0.0
*/
getLastSubmit ()
{
return this.lastSubmit;
};
/**
* Update last submit time
*
* @return {void}
*
* @since 1.0.0
*/
updateLastSubmit ()
{
this.lastSubmit = Math.floor(Date.now());
@ -116,6 +132,8 @@
*
* @param {callback} callback Callback
*
* @return {void}
*
* @since 1.0.0
*/
setSuccess (callback)
@ -128,6 +146,8 @@
*
* @param {callback} callback Callback
*
* @return {void}
*
* @since 1.0.0
*/
injectSubmit (callback)
@ -321,6 +341,8 @@
/**
* Bind form
*
* @return {void}
*
* @since 1.0.0
*/
bind ()
@ -361,6 +383,8 @@
/**
* Unbind form
*
* @return {void}
*
* @since 1.0.0
*/
unbind ()
@ -390,6 +414,8 @@
/**
* Clean form
*
* @return {void}
*
* @since 1.0.0
*/
clean ()

View File

@ -1,24 +1,44 @@
/**
* Table view.
*
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @since 1.0.0
*/
(function (jsOMS) {
"use strict";
jsOMS.Autoloader.defineNamespace('jsOMS.Views');
jsOMS.Views.TableView = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor (id) {
this.id = id;
this.bind();
};
/**
* Bind the table
*
* @return {void}
*
* @since 1.0.0
*/
bind ()
{
const e = document.getElementById(this.id);
};
/**
* Get sorting elements
* Get table header elements which provide sorting
*
* @return {Object}
* @return {array}
*
* @since 1.0.0
*/
@ -30,6 +50,27 @@
);
};
/**
* Get table header elements which provide filter functionality
*
* @return {array}
*
* @since 1.0.0
*/
getFilter()
{
return document.querySelectorAll(
'#' + this.id + ' thead .filter'
);
};
/**
* Get row elements which allow to swap the current row with another row
*
* @return {array}
*
* @since 1.0.0
*/
getSortableRows()
{
return document.querySelectorAll(
@ -38,18 +79,18 @@
);
};
/**
* Get row elements which allow to remove a row element
*
* @return {array}
*
* @since 1.0.0
*/
getRemovable()
{
return document.querySelectorAll(
'#' + this.id + ' tbody .remove'
);
};
getFilter()
{
return document.querySelectorAll(
'#' + this.id + ' thead .filter'
);
};
}
}(window.jsOMS = window.jsOMS || {}));

View File

@ -1,34 +0,0 @@
(function (jsOMS) {
"use strict";
jsOMS.ViewAbstract = class {
constructor ()
{
this.element = null;
this.data = [];
};
bind (node)
{
this.element = node;
};
addData(id, data, overwrite)
{
overwrite = typeof overwrite !== 'undefined' ? overwrite : false;
if (typeof this.data[id] === 'undefined' || overwrite) {
this.data[id] = data;
return true;
}
return false;
};
getData(id)
{
return typeof this.data[id] !== 'undefined' ? this.data[id] : undefined;
};
}
}(window.jsOMS = window.jsOMS || {}));