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} * @return {int}
* *
* @method
*
* @since 1.0.0 * @since 1.0.0
*/ */
getId () getId ()

View File

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

View File

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

View File

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

View File

@ -3,7 +3,7 @@
* *
* The autoloader is responsible for defining namespaces and dynamically loading javascript * 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 * 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. * referenced classes.
* *
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
@ -25,6 +25,8 @@
* *
* @param {string} namespace Namespace * @param {string} namespace Namespace
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Autoloader.defineNamespace = function (namespace) jsOMS.Autoloader.defineNamespace = function (namespace)
@ -51,6 +53,8 @@
/** /**
* Collect all loaded javascript files * Collect all loaded javascript files
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Autoloader.initPreloaded = function () jsOMS.Autoloader.initPreloaded = function ()
@ -74,6 +78,8 @@
* *
* @param {string} file Script URI * @param {string} file Script URI
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Autoloader.addPreloaded = function (file) jsOMS.Autoloader.addPreloaded = function (file)
@ -86,9 +92,11 @@
/** /**
* Include script * Include script
* *
* @param {string} file Script URI * @param {string} file Script URI
* @param {function} callback Callback after script loading * @param {function} callback Callback after script loading
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.Autoloader.include = function (file, callback) jsOMS.Autoloader.include = function (file, callback)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
/** /**
* Browser notification. * Notification manager.
* *
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 1.0 * @license OMS License 1.0
@ -14,12 +14,27 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification'); jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
jsOMS.Message.Notification.NotificationManager = class { jsOMS.Message.Notification.NotificationManager = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor() constructor()
{ {
this.appNotifier = new jsOMS.Message.Notification.App.AppNotification(); this.appNotifier = new jsOMS.Message.Notification.App.AppNotification();
this.browserNotifier = new jsOMS.Message.Notification.Browser.BrowserNotification(); 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) send (message, type)
{ {
if (jsOMS.Message.Notification.NotificationType.APP_NOTIFICATION === 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 () getAppNotifier ()
{ {
return this.appNotifier; return this.appNotifier;
}; };
/**
* Get the browser notification manager.
*
* @return {Object}
*
* @since 1.0.0
*/
getBrowserNotifier () getBrowserNotifier ()
{ {
return this.browserNotifier; return this.browserNotifier;

View File

@ -13,6 +13,15 @@
jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification'); jsOMS.Autoloader.defineNamespace('jsOMS.Message.Notification');
jsOMS.Message.Notification.NotificationMessage = class { 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) constructor(status, title, message)
{ {
this.status = status; this.status = status;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

View File

View File

@ -1,5 +1,5 @@
/** /**
* Form manager class. * Action manager class.
* *
* @copyright Dennis Eichhorn * @copyright Dennis Eichhorn
* @license OMS License 1.0 * @license OMS License 1.0
@ -11,197 +11,187 @@
"use strict"; "use strict";
/** @namespace jsOMS.UI */ /** @namespace jsOMS.UI */
jsOMS.Autoloader.defineNamespace('jsOMS.UI'); jsOMS.Autoloader.defineNamespace('jsOMS.UI.ActionManager');
/** jsOMS.UI.ActionManager = class {
* Constructor /**
* * @constructor
* @param {Object} app Application *
* * @param {Object} app Application
* @method *
* * @since 1.0.0
* @since 1.0.0 */
*/ constructor(app)
jsOMS.UI.ActionManager = function (app) {
{ this.app = app;
this.app = app; this.actions = {};
this.actions = {}; };
};
/** /**
* Bind element. * Bind element.
* *
* @param {string} [id] Element id (optional) * @param {string} [id] Element id (optional)
* *
* @return {void} * @return {void}
* *
* @method * @since 1.0.0
* */
* @since 1.0.0 bind(id)
*/ {
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;
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) { for (let i = 0; i < length; ++i) {
if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) { if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) {
this.bindElement(uiElements[i]); this.bindElement(uiElements[i]);
}
} }
} };
};
/** /**
* Bind element. * Bind element.
* *
* @param {Element} e Element to bind * @param {Element} e Element to bind
* *
* @return {void} * @return {void}
* *
* @method * @since 1.0.0
* */
* @since 1.0.0 bindElement (e)
*/ {
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') + '\'');
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; return;
} }
this.app.eventManager.attach(id + '-' + listener.key + '-' + listener.action[j - 1].key, function (data) // todo: validate json, if invalid log error
{ const listeners = JSON.parse(e.getAttribute('data-action')),
self.runAction(id, listener, listener.action[j], data); listenerLength = listeners.length,
}, removable, true); self = this;
}
// 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 // For everey action an event is registered
document.getElementById(id).addEventListener(listener.listener, function (event) 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) { const self = this,
event.preventDefault(); 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;
});
};
/** this.actions[action.type](action, function (data)
* Run event action. {
* self.app.eventManager.trigger(id + '-' + listener.key + '-' + action.key, id, data);
* @param {string} id Element }, id);
* @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;
if (!this.actions.hasOwnProperty(action.type)) { /**
jsOMS.Log.Logger.instance.warning('Undefined action ' + action.type); * Add action callback.
return; *
} * @param {string} name Action identifier
* @param {function} callback Action callback
action.data = data; *
* @return {void}
this.actions[action.type](action, function (data) *
* @since 1.0.0
*/
add (name, callback)
{ {
self.app.eventManager.trigger(id + '-' + listener.key + '-' + action.key, id, data); this.actions[name] = callback;
}, 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;
};
}(window.jsOMS = window.jsOMS || {})); }(window.jsOMS = window.jsOMS || {}));

View File

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

View File

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

View File

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

View File

@ -16,6 +16,8 @@
/** /**
* @constructor * @constructor
* *
* @param {Object} app Application
*
* @since 1.0.0 * @since 1.0.0
*/ */
constructor(app) constructor(app)
@ -30,7 +32,7 @@
* *
* @param {string} [id] Element id * @param {string} [id] Element id
* *
* @method * @return {void}
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -56,6 +58,8 @@
* *
* @param {string} id Table Id * @param {string} id Table Id
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
unbind (id) unbind (id)
@ -68,7 +72,7 @@
* *
* @param {Object} [id] Element id * @param {Object} [id] Element id
* *
* @method * @return {void}
* *
* @since 1.0.0 * @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) bindRemovable(remove, id)
{ {
remove.addEventListener('click', function (event) 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) bindReorder(sorting, id)
{ {
sorting.addEventListener('click', function (event) 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) bindSorting(sorting, id)
{ {
sorting.addEventListener('click', function (event) 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) bindFiltering(filtering, id)
{ {
filtering.addEventListener('click', function (event) filtering.addEventListener('click', function (event)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,7 +17,7 @@
* *
* Used to fire event after delay * Used to fire event after delay
* *
* @function * @return {callback}
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -37,9 +37,7 @@
* @param target Target array * @param target Target array
* @param source Source array * @param source Source array
* *
* @return Array * @return {Array}
*
* @function
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -75,6 +73,15 @@
return obj; 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) jsOMS.isset = function (variable)
{ {
return typeof variable !== 'undefined' && variable !== null; return typeof variable !== 'undefined' && variable !== null;

View File

@ -15,13 +15,11 @@
/** /**
* Trim char from string * Trim char from string
* *
* @param {string} str String to trim from * @param {string} str String to trim from
* @param {string} char Char to trim * @param {string} char Char to trim
* *
* @return {string} * @return {string}
* *
* @function
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.trim = function(str, char = ' ') jsOMS.trim = function(str, char = ' ')
@ -32,13 +30,11 @@
/** /**
* Trim char from right part of string * 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 * @param {string} char Char to trim
* *
* @return {string} * @return {string}
* *
* @function
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.rtrim = function(str, char = ' ') jsOMS.rtrim = function(str, char = ' ')
@ -49,13 +45,11 @@
/** /**
* Trim char from left part of string * 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 * @param {string} char Char to trim
* *
* @return {string} * @return {string}
* *
* @function
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.ltrim = function(str, char = ' ') jsOMS.ltrim = function(str, char = ' ')
@ -68,7 +62,7 @@
* *
* @param {string} jsonString String to validate * @param {string} jsonString String to validate
* *
* @function * @return {boolean}
* *
* @since 1.0.0 * @since 1.0.0
*/ */
@ -85,13 +79,11 @@
/** /**
* Count string in string * Count string in string
* *
* @param {string} str String to inspect * @param {string} str String to inspect
* @param {string} substr Substring to count * @param {string} substr Substring to count
* *
* @return {int} * @return {int}
* *
* @function
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.substr_count = function(str, substr) { jsOMS.substr_count = function(str, substr) {
@ -128,8 +120,6 @@
* *
* @return {int} * @return {int}
* *
* @function
*
* @since 1.0.0 * @since 1.0.0
*/ */
jsOMS.hash = function (str) jsOMS.hash = function (str)
@ -144,6 +134,16 @@
return res; 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) jsOMS.strpbrk = function (haystack, chars)
{ {
const length = chars.length; const length = chars.length;
@ -159,6 +159,16 @@
return haystack.slice(min); 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) { jsOMS.htmlspecialchars = function (text, quotes) {
let map = { let map = {
'&': '&amp;', '&': '&amp;',

View File

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

View File

@ -40,6 +40,8 @@
* *
* Pulled out since this is used in a cleanup process * Pulled out since this is used in a cleanup process
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
initializeMembers () initializeMembers ()
@ -73,11 +75,25 @@
return this.action; return this.action;
}; };
/**
* Get time of last submit
*
* @return {int}
*
* @since 1.0.0
*/
getLastSubmit () getLastSubmit ()
{ {
return this.lastSubmit; return this.lastSubmit;
}; };
/**
* Update last submit time
*
* @return {void}
*
* @since 1.0.0
*/
updateLastSubmit () updateLastSubmit ()
{ {
this.lastSubmit = Math.floor(Date.now()); this.lastSubmit = Math.floor(Date.now());
@ -116,6 +132,8 @@
* *
* @param {callback} callback Callback * @param {callback} callback Callback
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
setSuccess (callback) setSuccess (callback)
@ -128,6 +146,8 @@
* *
* @param {callback} callback Callback * @param {callback} callback Callback
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
injectSubmit (callback) injectSubmit (callback)
@ -321,6 +341,8 @@
/** /**
* Bind form * Bind form
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
bind () bind ()
@ -361,6 +383,8 @@
/** /**
* Unbind form * Unbind form
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
unbind () unbind ()
@ -390,6 +414,8 @@
/** /**
* Clean form * Clean form
* *
* @return {void}
*
* @since 1.0.0 * @since 1.0.0
*/ */
clean () 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) { (function (jsOMS) {
"use strict"; "use strict";
jsOMS.Autoloader.defineNamespace('jsOMS.Views'); jsOMS.Autoloader.defineNamespace('jsOMS.Views');
jsOMS.Views.TableView = class { jsOMS.Views.TableView = class {
/**
* @constructor
*
* @since 1.0.0
*/
constructor (id) { constructor (id) {
this.id = id; this.id = id;
this.bind(); this.bind();
}; };
/**
* Bind the table
*
* @return {void}
*
* @since 1.0.0
*/
bind () bind ()
{ {
const e = document.getElementById(this.id); const e = document.getElementById(this.id);
}; };
/** /**
* Get sorting elements * Get table header elements which provide sorting
* *
* @return {Object} * @return {array}
* *
* @since 1.0.0 * @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() getSortableRows()
{ {
return document.querySelectorAll( return document.querySelectorAll(
@ -38,18 +79,18 @@
); );
}; };
/**
* Get row elements which allow to remove a row element
*
* @return {array}
*
* @since 1.0.0
*/
getRemovable() getRemovable()
{ {
return document.querySelectorAll( return document.querySelectorAll(
'#' + this.id + ' tbody .remove' '#' + this.id + ' tbody .remove'
); );
}; };
getFilter()
{
return document.querySelectorAll(
'#' + this.id + ' thead .filter'
);
};
} }
}(window.jsOMS = window.jsOMS || {})); }(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 || {}));