From b83b9577400915c98a1a499d885a2b47a35c40d3 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 29 Dec 2018 11:55:32 +0100 Subject: [PATCH] Docblock and general minor cleanup --- Account/Account.js | 2 - Account/AccountManager.js | 6 +- Asset/AssetManager.js | 14 +- Auth/Auth.js | 12 +- Autoloader.js | 12 +- Config/Options.js | 12 +- DataStorage/LocalStorage.js | 2 - Event/EventManager.js | 42 +-- Log/Logger.js | 78 ++-- Math/MathProcessor.js | 27 ++ Message/Notification/App/AppNotification.js | 23 ++ .../Browser/BrowserNotification.js | 31 ++ Message/Notification/NotificationManager.js | 31 +- Message/Notification/NotificationMessage.js | 9 + Message/Request/Request.js | 47 +-- Message/Response/Response.js | 23 ++ Message/Response/ResponseManager.js | 4 +- Module/ModuleFactory.js | 4 +- Module/ModuleManager.js | 4 +- Stdlib/README.md | 0 System/README.md | 0 UI/ActionManager.js | 346 +++++++++--------- UI/Component/Form.js | 20 +- UI/Component/Input.js | 18 +- UI/Component/Tab.js | 11 +- UI/Component/Table.js | 48 ++- UI/DragNDrop.js | 8 +- UI/GeneralUI.js | 6 +- UI/Input/Keyboard/KeyboardManager.js | 8 + UI/Input/Mouse/MouseManager.js | 6 + UI/Input/Touch/TouchManager.js | 6 +- UI/Input/Voice/ReadManager.js | 2 + UI/Input/Voice/VoiceManager.js | 6 +- UI/UIManager.js | 18 +- Uri/Http.js | 38 +- Uri/UriFactory.js | 26 +- Utils/ArrayUtils.js | 4 +- Utils/GeneralUtils.js | 15 +- Utils/StringUtils.js | 40 +- Utils/UiUtils.js | 30 +- Views/FormView.js | 26 ++ Views/TableView.js | 59 ++- Views/ViewAbstract.js | 34 -- 43 files changed, 641 insertions(+), 517 deletions(-) delete mode 100644 Stdlib/README.md delete mode 100644 System/README.md delete mode 100644 Views/ViewAbstract.js diff --git a/Account/Account.js b/Account/Account.js index 6d64fa9..8d64267 100644 --- a/Account/Account.js +++ b/Account/Account.js @@ -28,8 +28,6 @@ * * @return {int} * - * @method - * * @since 1.0.0 */ getId () diff --git a/Account/AccountManager.js b/Account/AccountManager.js index 28b89ef..3ea3289 100644 --- a/Account/AccountManager.js +++ b/Account/AccountManager.js @@ -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) diff --git a/Asset/AssetManager.js b/Asset/AssetManager.js index fc9d61d..cce5185 100644 --- a/Asset/AssetManager.js +++ b/Asset/AssetManager.js @@ -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) diff --git a/Auth/Auth.js b/Auth/Auth.js index 7fe589a..09e4e1f 100644 --- a/Auth/Auth.js +++ b/Auth/Auth.js @@ -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 */ diff --git a/Autoloader.js b/Autoloader.js index 2ccea7a..7d77f7b 100644 --- a/Autoloader.js +++ b/Autoloader.js @@ -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) diff --git a/Config/Options.js b/Config/Options.js index 83bc3d4..35ebc30 100644 --- a/Config/Options.js +++ b/Config/Options.js @@ -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) diff --git a/DataStorage/LocalStorage.js b/DataStorage/LocalStorage.js index 1ce39f6..ff356e2 100644 --- a/DataStorage/LocalStorage.js +++ b/DataStorage/LocalStorage.js @@ -27,8 +27,6 @@ * * @return {boolean} * - * @method - * * @since 1.0.0 */ static available() diff --git a/Event/EventManager.js b/Event/EventManager.js index 4b42d66..ed9bd7b 100644 --- a/Event/EventManager.js +++ b/Event/EventManager.js @@ -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 () diff --git a/Log/Logger.js b/Log/Logger.js index 41b3f14..4e76438 100644 --- a/Log/Logger.js +++ b/Log/Logger.js @@ -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 = {}) diff --git a/Math/MathProcessor.js b/Math/MathProcessor.js index 5f405dd..bf423cc 100644 --- a/Math/MathProcessor.js +++ b/Math/MathProcessor.js @@ -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 = []; diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js index 96a2e51..703dd49 100644 --- a/Message/Notification/App/AppNotification.js +++ b/Message/Notification/App/AppNotification.js @@ -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'); diff --git a/Message/Notification/Browser/BrowserNotification.js b/Message/Notification/Browser/BrowserNotification.js index f248b6a..5515324 100644 --- a/Message/Notification/Browser/BrowserNotification.js +++ b/Message/Notification/Browser/BrowserNotification.js @@ -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(/* ... */); }; diff --git a/Message/Notification/NotificationManager.js b/Message/Notification/NotificationManager.js index d7b8658..375c487 100644 --- a/Message/Notification/NotificationManager.js +++ b/Message/Notification/NotificationManager.js @@ -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; diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js index 8398021..ebcd1d7 100644 --- a/Message/Notification/NotificationMessage.js +++ b/Message/Notification/NotificationMessage.js @@ -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; diff --git a/Message/Request/Request.js b/Message/Request/Request.js index b75934a..010d2e9 100644 --- a/Message/Request/Request.js +++ b/Message/Request/Request.js @@ -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() diff --git a/Message/Response/Response.js b/Message/Response/Response.js index 876fa25..de87c59 100644 --- a/Message/Response/Response.js +++ b/Message/Response/Response.js @@ -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; diff --git a/Message/Response/ResponseManager.js b/Message/Response/ResponseManager.js index e5f8894..0390efa 100644 --- a/Message/Response/ResponseManager.js +++ b/Message/Response/ResponseManager.js @@ -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 */ diff --git a/Module/ModuleFactory.js b/Module/ModuleFactory.js index 0d1ba8e..9c39c11 100644 --- a/Module/ModuleFactory.js +++ b/Module/ModuleFactory.js @@ -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) diff --git a/Module/ModuleManager.js b/Module/ModuleManager.js index 3553a68..8ee2348 100644 --- a/Module/ModuleManager.js +++ b/Module/ModuleManager.js @@ -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) diff --git a/Stdlib/README.md b/Stdlib/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/System/README.md b/System/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/UI/ActionManager.js b/UI/ActionManager.js index 5354937..bf8576e 100644 --- a/UI/ActionManager.js +++ b/UI/ActionManager.js @@ -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 || {})); diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 222f445..70a73a9 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -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 */ diff --git a/UI/Component/Input.js b/UI/Component/Input.js index 9968159..dd37468 100644 --- a/UI/Component/Input.js +++ b/UI/Component/Input.js @@ -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 */ diff --git a/UI/Component/Tab.js b/UI/Component/Tab.js index 3be4a22..4542f09 100644 --- a/UI/Component/Tab.js +++ b/UI/Component/Tab.js @@ -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 */ diff --git a/UI/Component/Table.js b/UI/Component/Table.js index 8e6b098..5769fec 100644 --- a/UI/Component/Table.js +++ b/UI/Component/Table.js @@ -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) diff --git a/UI/DragNDrop.js b/UI/DragNDrop.js index 833245e..8da66cc 100644 --- a/UI/DragNDrop.js +++ b/UI/DragNDrop.js @@ -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 */ diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js index 591ff4e..8ffbf5d 100644 --- a/UI/GeneralUI.js +++ b/UI/GeneralUI.js @@ -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 */ diff --git a/UI/Input/Keyboard/KeyboardManager.js b/UI/Input/Keyboard/KeyboardManager.js index c21c102..c20cd4d 100644 --- a/UI/Input/Keyboard/KeyboardManager.js +++ b/UI/Input/Keyboard/KeyboardManager.js @@ -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) diff --git a/UI/Input/Mouse/MouseManager.js b/UI/Input/Mouse/MouseManager.js index 5afa620..0e9b7d4 100644 --- a/UI/Input/Mouse/MouseManager.js +++ b/UI/Input/Mouse/MouseManager.js @@ -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) diff --git a/UI/Input/Touch/TouchManager.js b/UI/Input/Touch/TouchManager.js index 74703ef..2d47f47 100644 --- a/UI/Input/Touch/TouchManager.js +++ b/UI/Input/Touch/TouchManager.js @@ -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 */ diff --git a/UI/Input/Voice/ReadManager.js b/UI/Input/Voice/ReadManager.js index ca0fb6a..1ce5f7f 100644 --- a/UI/Input/Voice/ReadManager.js +++ b/UI/Input/Voice/ReadManager.js @@ -30,6 +30,8 @@ /** * @constructor * + * @param {string} lang Localization + * * @since 1.0.0 */ constructor (lang = 'en-US') diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js index 8fb49cd..82f6525 100644 --- a/UI/Input/Voice/VoiceManager.js +++ b/UI/Input/Voice/VoiceManager.js @@ -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 */ diff --git a/UI/UIManager.js b/UI/UIManager.js index 35fde75..9efe42b 100644 --- a/UI/UIManager.js +++ b/UI/UIManager.js @@ -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() diff --git a/Uri/Http.js b/Uri/Http.js index 603a841..5fbddc9 100644 --- a/Uri/Http.js +++ b/Uri/Http.js @@ -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() diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js index d3e1096..c35eeba 100644 --- a/Uri/UriFactory.js +++ b/Uri/UriFactory.js @@ -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) diff --git a/Utils/ArrayUtils.js b/Utils/ArrayUtils.js index 2a9d2ee..61b2215 100644 --- a/Utils/ArrayUtils.js +++ b/Utils/ArrayUtils.js @@ -19,9 +19,7 @@ * @param {Object} data Object * @param {string} delim Path delimiter * - * @return - * - * @function + * @return {mixed} * * @since 1.0.0 */ diff --git a/Utils/GeneralUtils.js b/Utils/GeneralUtils.js index 2cb1676..084e5f8 100644 --- a/Utils/GeneralUtils.js +++ b/Utils/GeneralUtils.js @@ -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; diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js index 170a6f1..0899d13 100644 --- a/Utils/StringUtils.js +++ b/Utils/StringUtils.js @@ -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 = { '&': '&', diff --git a/Utils/UiUtils.js b/Utils/UiUtils.js index ac02deb..f3445c5 100644 --- a/Utils/UiUtils.js +++ b/Utils/UiUtils.js @@ -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 */ diff --git a/Views/FormView.js b/Views/FormView.js index a43cabf..f8aea9f 100644 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -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 () diff --git a/Views/TableView.js b/Views/TableView.js index a7db297..0b9acb6 100644 --- a/Views/TableView.js +++ b/Views/TableView.js @@ -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 || {})); diff --git a/Views/ViewAbstract.js b/Views/ViewAbstract.js deleted file mode 100644 index b7ac24d..0000000 --- a/Views/ViewAbstract.js +++ /dev/null @@ -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 || {}));