diff --git a/3D/Loader/ObjLoader.js b/3D/Loader/ObjLoader.js
index bea301d..a0fdc73 100755
--- a/3D/Loader/ObjLoader.js
+++ b/3D/Loader/ObjLoader.js
@@ -8,12 +8,12 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/** @namespace jsOMS.ThreeD.Loader.ObjLoader */
jsOMS.Autoloader.defineNamespace('jsOMS.ThreeD.Loader.ObjLoader');
- jsOMS.ThreeD.Loader.ObjLoader = function(manager) {
+ jsOMS.ThreeD.Loader.ObjLoader = function (manager) {
/** global: THREE */
this.manager = (manager !== undefined) ? manager : THREE.DefaultLoadingManager;
this.materials = null;
@@ -32,26 +32,26 @@
};
};
- jsOMS.ThreeD.Loader.ObjLoader.prototype.setPath = function(path)
+ jsOMS.ThreeD.Loader.ObjLoader.prototype.setPath = function (path)
{
this.path = path;
};
- jsOMS.ThreeD.Loader.ObjLoader.prototype.setMaterials = function(materials)
+ jsOMS.ThreeD.Loader.ObjLoader.prototype.setMaterials = function (materials)
{
this.materials = materials;
};
- jsOMS.ThreeD.Loader.ObjLoader.prototype.load = function(uri, onLoad, onProgress, onError)
+ jsOMS.ThreeD.Loader.ObjLoader.prototype.load = function (uri, onLoad, onProgress, onError)
{
let self = this,
loader = new THREE.FileLoader(this.manager);
loader.setPath(this.path);
- loader.load(uri, function(text) { onLoad(self.parse(text))}, onProgress, onError);
+ loader.load(uri, function (text) { onLoad(self.parse(text))}, onProgress, onError);
};
- jsOMS.ThreeD.Loader.ObjLoader.prototype.createParserState = function()
+ jsOMS.ThreeD.Loader.ObjLoader.prototype.createParserState = function ()
{
let state = {
objects : [],
@@ -84,7 +84,7 @@
},
materials : [],
smooth : true,
- startMaterial : function(name, libraries) {
+ startMaterial : function (name, libraries) {
let previous = this._finalize(false);
if (previous && (previous.inherited || previous.groupCount <= 0)) {
@@ -101,7 +101,7 @@
groupCount : -1,
inherited : false,
- clone : function(index) {
+ clone : function (index) {
const cloned = {
index : (typeof index === 'number' ? index : this.index),
name : this.name,
@@ -122,7 +122,7 @@
return material;
},
- currentMaterial : function() {
+ currentMaterial : function () {
if (this.materials.length > 0) {
return this.materials[this.materials.length - 1];
}
@@ -130,7 +130,7 @@
return undefined;
},
- _finalize : function(end) {
+ _finalize : function (end) {
let lastMultiMaterial = this.currentMaterial();
if (lastMultiMaterial && lastMultiMaterial.groupEnd === -1) {
@@ -166,7 +166,7 @@
this.objects.push(this.object);
},
- finalize : function() {
+ finalize : function () {
if (this.object && typeof this.object._finalize === 'function') {
this.object._finalize(true);
}
@@ -310,7 +310,7 @@
return state;
};
- jsOMS.ThreeD.Loader.ObjLoader.prototype.parse = function(text)
+ jsOMS.ThreeD.Loader.ObjLoader.prototype.parse = function (text)
{
let state = this.createParserState();
diff --git a/Account/Account.js b/Account/Account.js
index 02be4ba..fa83d4e 100755
--- a/Account/Account.js
+++ b/Account/Account.js
@@ -15,13 +15,14 @@ export class Account
*/
constructor ()
{
+ /** @type {number} id Account id */
this.id = 0;
};
/**
* Get id.
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
@@ -29,4 +30,4 @@ export class Account
{
return this.id;
};
-};
\ No newline at end of file
+};
diff --git a/Account/AccountManager.js b/Account/AccountManager.js
index 3672c22..30d288e 100755
--- a/Account/AccountManager.js
+++ b/Account/AccountManager.js
@@ -1,3 +1,5 @@
+import { Account } from './Account.js';
+
/**
* Account Manager.
*
@@ -15,13 +17,14 @@ export class AccountManager
*/
constructor ()
{
+ /** @type {Account[]} accounts Accounts */
this.accounts = [];
};
/**
* Add account.
*
- * @param {Object} account Account
+ * @param {Account} account Account
*
* @return {void}
*
@@ -35,9 +38,9 @@ export class AccountManager
/**
* Remove account.
*
- * @param {int} id Account id
+ * @param {number} id Account id
*
- * @return {void}
+ * @return {boolean}
*
* @since 1.0.0
*/
@@ -55,9 +58,9 @@ export class AccountManager
/**
* Get account by id.
*
- * @param {int} id Account id
+ * @param {number} id Account id
*
- * @return {null|Object}
+ * @return {null|Account}
*
* @since 1.0.0
*/
diff --git a/Animation/Animation.js b/Animation/Animation.js
index 331a906..fcb14cb 100755
--- a/Animation/Animation.js
+++ b/Animation/Animation.js
@@ -8,7 +8,7 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/** @namespace jsOMS.Animation.Animation */
jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Animation');
@@ -24,12 +24,12 @@
*/
jsOMS.Animation.Animation.requestAnimationFrame = (function ()
{
- return window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function (callback)
+ return window.requestAnimationFrame
+ || window.webkitRequestAnimationFrame
+ || window.mozRequestAnimationFrame
+ || window.oRequestAnimationFrame
+ || window.msRequestAnimationFrame
+ || function (callback)
{
window.setTimeout(callback, 1000 / 60);
};
diff --git a/Animation/Canvas/Particle.js b/Animation/Canvas/Particle.js
index 31f7678..151847e 100755
--- a/Animation/Canvas/Particle.js
+++ b/Animation/Canvas/Particle.js
@@ -8,7 +8,7 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/** @namespace jsOMS.Animation.Canvas */
jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Canvas');
@@ -28,13 +28,13 @@
this.radius = radius;
- this.color = {r: 255, g: 255, b: 255, a: 0.5};
+ this.color = { r: 255, g: 255, b: 255, a: 0.5 };
};
/**
* Get particle radius
*
- * @return {int}
+ * @return {number}
*
* @method
*
@@ -48,8 +48,8 @@
/**
* Set particle position
*
- * @param {int} posX Position x
- * @param {int} posY Position y
+ * @param {number} posX Position x
+ * @param {number} posY Position y
*
* @return {void}
*
@@ -74,7 +74,7 @@
*/
getPosition ()
{
- return {x: this.posX, y: this.posY};
+ return { x: this.posX, y: this.posY };
};
/**
@@ -106,7 +106,7 @@
*/
getVelocity ()
{
- return {x: this.velX, y: this.velY};
+ return { x: this.velX, y: this.velY };
};
/**
@@ -127,5 +127,5 @@
ctx.arc(this.posX, this.posY, this.radius, 0, Math.PI * 2, false);
ctx.fill();
};
- }
+ };
}(window.jsOMS = window.jsOMS || {}));
diff --git a/Animation/Canvas/ParticleAnimation.js b/Animation/Canvas/ParticleAnimation.js
index 150f8ac..2b4b7d4 100755
--- a/Animation/Canvas/ParticleAnimation.js
+++ b/Animation/Canvas/ParticleAnimation.js
@@ -8,7 +8,7 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/** @namespace jsOMS.Animation.Canvas */
jsOMS.Autoloader.defineNamespace('jsOMS.Animation.Canvas');
@@ -103,10 +103,10 @@
*/
updateParticles ()
{
- let particle,
- pos,
- vel,
- radius;
+ let particle;
+ let pos;
+ let vel;
+ let radius;
const length = this.particles.length;
@@ -155,14 +155,14 @@
*/
updateDistance (p1, p2)
{
- const pos1 = p1.getPosition(),
- pos2 = p2.getPosition(),
- dx = pos1.x - pos2.x,
- dy = pos1.y - pos2.y,
- dist = Math.sqrt(dx * dx + dy * dy);
+ const pos1 = p1.getPosition();
+ const pos2 = p2.getPosition();
+ const dx = pos1.x - pos2.x;
+ const dy = pos1.y - pos2.y;
+ const dist = Math.sqrt(dx * dx + dy * dy);
- let vel1 = p1.getVelocity(),
- vel2 = p2.getVelocity();
+ const vel1 = p1.getVelocity();
+ const vel2 = p2.getVelocity();
// Draw line if particles are close
if (dist <= this.maxDistance) {
@@ -174,8 +174,8 @@
this.ctx.closePath();
// Accelerate based on distance (no acceleration yet)
- let ax = dx / this.gravitation,
- ay = dy / this.gravitation;
+ const ax = dx / this.gravitation;
+ const ay = dy / this.gravitation;
vel1.x -= ax;
vel1.y -= ay;
@@ -186,5 +186,5 @@
p2.setVelocity(vel2.x, vel2.y);
}
};
- }
-}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
+ };
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Asset/AssetManager.js b/Asset/AssetManager.js
index bbbaabf..fb0076a 100755
--- a/Asset/AssetManager.js
+++ b/Asset/AssetManager.js
@@ -15,7 +15,9 @@ export class AssetManager
*/
constructor ()
{
+ /** @type {string[]} assets */
this.assets = {};
+
this.registerLoadedAssets();
};
@@ -28,8 +30,8 @@ export class AssetManager
*/
registerLoadedAssets ()
{
- const scripts = document.getElementsByTagName('script'),
- length = !scripts ? 0 : scripts.length;
+ const scripts = document.getElementsByTagName('script');
+ const length = !scripts ? 0 : scripts.length;
this.assets = {};
@@ -41,16 +43,17 @@ export class AssetManager
/**
* Load asset.
*
- * @param {string} path Asset path
- * @param {string} filetype Filetype of the asset
- * @param {requestCallback} [callback] Callback after load
+ * @param {string} path Asset path
+ * @param {string} filetype Filetype of the asset
+ * @param {function} callback Callback after load
*
- * @return {string|boolean}
+ * @return {boolean|number}
*
* @since 1.0.0
*/
load (path, filetype, callback)
{
+ /** @type {number} hash */
let hash;
if (!this.assets[(hash = jsOMS.hash(path))]) {
@@ -92,7 +95,7 @@ export class AssetManager
}
if (callback) {
- fileref.onreadystatechange ()
+ fileref.onreadystatechange = function ()
{
if (this.readyState === 'complete') {
callback();
@@ -113,12 +116,13 @@ export class AssetManager
*
* @param {string} key Key of the asset
*
- * @return {null|string}
+ * @return {null|number}
*
* @since 1.0.0
*/
get (key)
{
+ /** @type {number} key */
key = jsOMS.hash(key);
if (this.assets[key]) {
@@ -139,6 +143,7 @@ export class AssetManager
*/
remove (key)
{
+ /** @type {number} key */
key = jsOMS.hash(key);
if (typeof this.assets[key] !== 'undefined') {
@@ -150,4 +155,3 @@ export class AssetManager
return false;
};
};
-
diff --git a/Auth/Auth.js b/Auth/Auth.js
index 6bb3348..3e8e9c6 100755
--- a/Auth/Auth.js
+++ b/Auth/Auth.js
@@ -1,6 +1,7 @@
-import { Request } from '../../Message/Request/Request.js';
-import { RequestMethod } from '../../Message/Request/RequestMethod.js';
-import { RequestType } from '../../Message/Request/RequestType.js';
+import { Account } from '../Account/Account.js';
+import { Request } from '../Message/Request/Request.js';
+import { RequestMethod } from '../Message/Request/RequestMethod.js';
+import { RequestType } from '../Message/Request/RequestType.js';
/**
* Auth class.
@@ -21,14 +22,17 @@ export class Auth
*/
constructor (uri)
{
+ /** @type {Account} account */
this.account = null;
- this.uri = uri;
+
+ /** @type {string} uri */
+ this.uri = uri;
};
/**
* Set account for authentication.
*
- * @param {Object} account Account
+ * @param {Account} account Account
*
* @since 1.0.0
*/
@@ -40,7 +44,7 @@ export class Auth
/**
* Get account.
*
- * @return {Object}
+ * @return {Account}
*
* @since 1.0.0
*/
@@ -64,6 +68,8 @@ export class Auth
authRequest.setMethod(RequestMethod.POST);
authRequest.setResponseType(RequestType.JSON);
authRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+
+ /** @type {XMLHttpRequest} xhr */
authRequest.setSuccess(function (xhr)
{
this.loginResult(xhr);
@@ -87,6 +93,8 @@ export class Auth
/**
* Handle login result.
*
+ * @param {XMLHttpRequest} xhr Request
+ *
* @return {void}
*
* @since 1.0.0
diff --git a/Autoloader.js b/Autoloader.js
index 483deb6..e8d896c 100755
--- a/Autoloader.js
+++ b/Autoloader.js
@@ -15,8 +15,13 @@ import { AssetManager } from './Asset/AssetManager.js';
*/
export const Autoloader = {};
-Autoloader.loaded = [];
-Autoloader.namespaced = [];
+/** @type {string[]} Autoloader.loaded */
+Autoloader.loaded = [];
+
+/** @type {string[]} Autoloader.namespaced */
+Autoloader.namespaced = [];
+
+/** @type {AssetManager} Autoloader.assetLoader */
Autoloader.assetLoader = new AssetManager();
/**
@@ -31,7 +36,7 @@ Autoloader.assetLoader = new AssetManager();
Autoloader.defineNamespace = function (namespace)
{
if (Autoloader.namespaced.indexOf(namespace) === -1) {
- let paths = namespace.split('.');
+ const paths = namespace.split('.');
paths.splice(0, 1);
const length = paths.length;
@@ -58,8 +63,8 @@ Autoloader.defineNamespace = function (namespace)
*/
Autoloader.initPreloaded = function ()
{
- const scripts = document.getElementsByTagName('script'),
- length = !scripts ? 0 : scripts.length;
+ const scripts = document.getElementsByTagName('script');
+ const length = !scripts ? 0 : scripts.length;
for (let i = 0; i < length; ++i) {
/** global: URL */
diff --git a/Chart/AreaChart.js b/Chart/AreaChart.js
deleted file mode 100755
index e6c1343..0000000
--- a/Chart/AreaChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.AreaChart = function (id)
- {
- this.chart = new jsOMS.Chart.LineChart(id);
- this.chart.getChart().subtype = 'area';
- };
-
- jsOMS.Chart.AreaChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.AreaChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.AreaChart.prototype.draw = function ()
- {
- return this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/Axis.js b/Chart/Axis.js
deleted file mode 100755
index e47a062..0000000
--- a/Chart/Axis.js
+++ /dev/null
@@ -1,6 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Chart.TextElement = function() {
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/BarChart.js b/Chart/BarChart.js
deleted file mode 100755
index 87874e8..0000000
--- a/Chart/BarChart.js
+++ /dev/null
@@ -1,204 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.BarChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: false
- },
- y: {
- visible: true
- }
- };
-
- this.chart.dataSettings.marker.visible = false;
- this.chart.subtype = 'stacked';
- };
-
- jsOMS.Chart.BarChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.BarChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.BarChart.prototype.draw = function ()
- {
- let rect, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- if (this.chart.subtype === 'grouped') {
- this.chart.axis.y.max = d3.max(this.chart.dataset, function (layer)
- {
- return d3.max(layer.points, function (d)
- {
- return d.y;
- });
- });
- } else {
- this.chart.axis.y.max = d3.max(this.chart.dataset, function (layer)
- {
- return d3.max(layer.points, function (d)
- {
- return d.y0 + d.y;
- });
- });
- }
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('linear');
- y = this.chart.createYScale('ordinal');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain([0, this.chart.axis.y.max + 1]);
- y.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.height - this.chart.margin.top - this.chart.margin.bottom], .1);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
-
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawMarker(svg, x, y, dataPointEnter, dataPoint);
- this.chart.drawLegend(svg, dataPointEnter, dataPoint);
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.BarChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.BarChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- let rect;
-
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
- {
- return c.id;
- });
-
- dataPointEnter = dataPoint.enter().append("g").attr("class", "dataPoint")
- .style("fill", function (d)
- {
- return self.chart.color(d.name);
- });
-
- rect = dataPointEnter.selectAll("rect")
- .data(function (d)
- {
- return d.points;
- })
- .enter().append("rect")
- .attr("y", function (d)
- {
- return y(d.x);
- })
- .attr("x", 0)
- .attr("width", 0)
- .attr("height", y.rangeBand());
-
- if (this.chart.subtype === 'stacked') {
- rect.transition()
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("x", function (d)
- {
- return x(d.y0);
- })
- .attr("width", function (d)
- {
- return x(d.y);
- });
- } else {
- rect.transition()
- .duration(500)
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("y", function (d, i, j)
- {
- return y(d.x) + y.rangeBand() / self.chart.dataset.length * j;
- })
- .attr("height", y.rangeBand() / self.chart.dataset.length)
- .transition()
- .attr("x", 0)
- .attr("width", function (d)
- {
- return x(d.y);
- });
- }
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/BoxplotChart.js b/Chart/BoxplotChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/CalendarChart.js b/Chart/CalendarChart.js
deleted file mode 100755
index d00ddcc..0000000
--- a/Chart/CalendarChart.js
+++ /dev/null
@@ -1,155 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.CalendarChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.quantize()
- .domain([-.05, .05])
- .range(d3.range(11).map(function(d) { return "q" + d + "-11"; }));
-
- this.chart.subtype = 'calendar';
- };
-
- jsOMS.Chart.CalendarChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.CalendarChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.CalendarChart.prototype.draw = function ()
- {
- let percent = d3.format(".1%"),
- format = d3.time.format("%Y-%m-%d"),
- svg, self = this;
-
- this.chart.calculateDimension();
- this.chart.cellSize = Math.min(this.chart.dimension.width / (12 * 5), this.chart.dimension.height / (8));
-
- document.getElementById(this.chart.chartId)
- .style.height = (this.chart.dimension.height * this.chart.dataset.length) + 'px';
-
- svg = this.chart.chartSelect.selectAll('svg').data(this.chart.dataset).enter().append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .attr("class", "RdYlGn")
- .append("g")
- .attr("transform", "translate("
- + ((this.chart.dimension.width - this.chart.cellSize * 53) / 2)
- + "," + (this.chart.dimension.height - this.chart.cellSize * 7 - 1) + ")");
-
- svg.append("text")
- .attr("transform", "translate(-6," + this.chart.cellSize * 3.5 + ")rotate(-90)")
- .style("text-anchor", "middle")
- .text(function(d) { return d.name; });
-
- let rect = svg.selectAll(".day")
- .data(function(d) { return d3.time.days(new Date(parseInt(d.name), 0, 1), new Date(parseInt(d.name) + 1, 0, 1)); })
- .enter().append("rect")
- .attr("class", "day")
- .attr("width", this.chart.cellSize)
- .attr("height", this.chart.cellSize)
- .attr("x", function(d) { return d3.time.weekOfYear(d) * self.chart.cellSize; })
- .attr("y", function(d) { return d.getDay() * self.chart.cellSize; })
- .datum(format);
-
- rect.append("title")
- .text(function(d) { });
-
- svg.selectAll(".month")
- .data(function(d) { return d3.time.months(new Date(parseInt(d.name), 0, 1), new Date(parseInt(d.name) + 1, 0, 1)); })
- .enter().append("path")
- .attr("class", "month")
- .attr("d", function(t0) {
- let t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0),
- d0 = t0.getDay(), w0 = d3.time.weekOfYear(t0),
- d1 = t1.getDay(), w1 = d3.time.weekOfYear(t1);
-
- return "M" + (w0 + 1) * self.chart.cellSize + "," + d0 * self.chart.cellSize
- + "H" + w0 * self.chart.cellSize + "V" + 7 * self.chart.cellSize
- + "H" + w1 * self.chart.cellSize + "V" + (d1 + 1) * self.chart.cellSize
- + "H" + (w1 + 1) * self.chart.cellSize + "V" + 0
- + "H" + (w0 + 1) * self.chart.cellSize + "Z";
- });
-
- rect.filter(function(d) {
- let year = d.split('-')[0],
- length = self.chart.dataset.length;
-
- for (let i = 0; i < length; ++i) {
- if (self.chart.dataset[i].name != year) {
- continue;
- }
-
- let dataLength = self.chart.dataset[i].points.length;
-
- for (let j = 0; j < dataLength; ++j) {
- if (self.chart.dataset[i].points[j].x === d) {
- return true;
- }
- }
-
- return false;
- }
-
- return false;
- })
- .attr("class", function(d) {
- let year = d.split('-')[0],
- length = self.chart.dataset.length;
-
- for (let i = 0; i < length; ++i) {
- if (self.chart.dataset[i].name != year) {
- continue;
- }
-
- let dataLength = self.chart.dataset[i].points.length;
-
- for (let j = 0; j < dataLength; ++j) {
- if (self.chart.dataset[i].points[j].x === d) {
- return "day " + self.chart.color(self.chart.dataset[i].points[j].y);
- }
- }
-
- throw "Should not happen";
- }
- })
- .select("title")
- .text(function(d) {
- let year = d.split('-')[0],
- length = self.chart.dataset.length;
-
- for (let i = 0; i < length; ++i) {
- if (self.chart.dataset[i].name != year) {
- continue;
- }
-
- let dataLength = self.chart.dataset[i].points.length;
-
- for (let j = 0; j < dataLength; ++j) {
- if (self.chart.dataset[i].points[j].x === d) {
- return d + ": " + self.chart.dataset[i].points[j].y;
- }
- }
-
- throw "Should not happen";
- }
- });
- };
-
- jsOMS.Chart.CalendarChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/CandlestickChart.js b/Chart/CandlestickChart.js
deleted file mode 100755
index a46dbf6..0000000
--- a/Chart/CandlestickChart.js
+++ /dev/null
@@ -1,154 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.CandlestickChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y0: {
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: true
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'candlestick';
- };
-
- jsOMS.Chart.CandlestickChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.CandlestickChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.CandlestickChart.prototype.draw = function ()
- {
- let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom,
- self = this,
- mm = 50;
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('linear');
- y = this.chart.createYScale('linear');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain([this.chart.axis.x.min - 1, this.chart.axis.x.max + 1]);
- y.domain([this.chart.axis.y0.min - 1, this.chart.axis.y.max + 1]);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- if (this.chart.subtype === 'candlestick') {
- svg.selectAll("rect")
- .data(this.chart.dataset[0].points)
- .enter().append("svg:rect")
- .attr("x", function(d) { return x(d.x) - 0.5 * mm / 2; })
- .attr("y", function(d) { return y(Math.max(d.open, d.close)); })
- .attr("height", function(d) { return Math.max(1, y(Math.min(d.open, d.close)) - y(Math.max(d.open, d.close)));})
- .attr("width", function(d) { return 0.5 * mm; })
- .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; });
- } else {
- let datapoint = svg.selectAll("rect")
- .data(this.chart.dataset[0].points)
- .enter();
-
- datapoint.append("svg:rect")
- .attr("x", function(d) { return x(d.x) - 0.25 * mm / 2; })
- .attr("y", function(d) {return y(d.open);})
- .attr("height", function(d) { return 1;})
- .attr("width", function(d) { return 0.25 * mm / 2; })
- .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; });
-
- datapoint.append("svg:rect")
- .attr("x", function(d) { return x(d.x); })
- .attr("y", function(d) {return y(d.close);})
- .attr("height", function(d) { return 1;})
- .attr("width", function(d) { return 0.25 * mm / 2; })
- .attr("fill",function(d) { return d.open > d.close ? "red" : "green"; });
- }
-
- svg.selectAll("line.stem")
- .data(this.chart.dataset[0].points)
- .enter().append("svg:line")
- .attr("class", "stem")
- .attr("x1", function(d) { return x(d.x);})
- .attr("x2", function(d) { return x(d.x);})
- .attr("y1", function(d) { return y(d.y);})
- .attr("y2", function(d) { return y(d.y0); })
- .attr("stroke", function(d){ return d.open > d.close ? "red" : "green"; });
-
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.CandlestickChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/Chart.js b/Chart/Chart.js
deleted file mode 100755
index e47a062..0000000
--- a/Chart/Chart.js
+++ /dev/null
@@ -1,6 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Chart.TextElement = function() {
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/ChartAbstract.js b/Chart/ChartAbstract.js
deleted file mode 100755
index 3ddd43b..0000000
--- a/Chart/ChartAbstract.js
+++ /dev/null
@@ -1,642 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- /** @namespace jsOMS.Chart */
- jsOMS.Autoloader.defineNamespace('jsOMS.Chart');
-
- jsOMS.Chart.ChartAbstract = function (id)
- {
- /** global: d3 */
- this.chartId = id;
- this.chartSelect = d3.select('#' + this.chartId);
-
- this.title = {
- visible: true,
- text: "",
- anchor: "middle",
- position: "center"
- };
-
- this.subtitle = {
- visible: true,
- text: "",
- anchor: "middle",
- position: "center"
- };
-
- this.footer = {
- visible: true,
- text: "",
- anchor: "end",
- position: "right"
- };
-
- this.legend = {
- visible: true
- };
-
- this.color = d3.scale.category10();
- this.dataset = [];
- this.dataSettings = {
- style: {
- strokewidth: 3,
- padding: 0
- },
- marker: {
- visible: true,
- type: 'circle'
- },
- info: {
- visible: true
- },
- extremum: {
- visible: false
- },
- values: {
- visible: false
- },
- dataset: true, /* show dataset below */
- interpolate: "linear" /* splines interpolation? */
- };
-
- this.dimension = {width: 0, height: 0};
- this.margin = {top: 0, right: 0, bottom: 0, left: 0};
-
- this.axis = {};
- this.grid = {};
- this.subtype = '';
-
- this.clean();
- };
-
- jsOMS.Chart.ChartAbstract.prototype.calculateHorizontalPosition = function (position)
- {
- let x = 0;
- if (position === 'center') {
- x = (
- this.dimension.width
- - this.margin.right
- - this.margin.left
- ) / 2;
- } else if (position === 'left') {
- x = 0;
- } else if (position === 'right') {
- x = this.dimension.width - this.margin.right - this.margin.left;
- }
-
- return x;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.calculateVerticalPosition = function (position)
- {
- let y = 0;
- if (position === 'center') {
- y = -(this.dimension.height
- - this.margin.top
- - this.margin.bottom
- ) / 2;
- } else if (position === 'bottom') {
- y = -(this.dimension.height
- - this.margin.top
- - this.margin.bottom
- );
- } else if (position === 'top') {
- y = -this.margin.top;
- }
-
- return y;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setColor = function (color)
- {
- this.color = color;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getColor = function ()
- {
- return this.color;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setAxis = function (id, axis)
- {
- this.axis[id] = jsOMS.merge(this.axis[id], axis);
-
- // Setting axis dimensions in case dataset existss
- if (Object.keys(this.dataset).length > 0) {
- this.axis[id].max = d3.max(this.dataset, function (m)
- {
- return d3.max(m.points, function (d)
- {
- return d[id];
- });
- });
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setMargin = function (top, right, bottom, left)
- {
- this.margin = {top: top, right: right, bottom: bottom, left: left};
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setDimension = function (width, height)
- {
- this.dimension = {width: width, height: height};
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getDimension = function ()
- {
- return this.dimension;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setDimensionRelative = function (relative)
- {
- this.relative = relative;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setTitle = function (title)
- {
- this.title = jsOMS.merge(this.title, title);
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getTitle = function ()
- {
- return this.title;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setSubtitle = function (subtitle)
- {
- this.subtitle = subtitle;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getSubtitle = function ()
- {
- return this.subtitle;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setFooter = function (footer)
- {
- this.footer = footer;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getFooter = function ()
- {
- return this.footer;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setSubtype = function (subtype)
- {
- this.subtype = subtype;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getSubtype = function ()
- {
- return this.subtype;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setLegend = function (legend)
- {
- this.legend = jsOMS.merge(this.legend, legend);
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getLegend = function ()
- {
- if (!this.legend) {
- this.legend = new jsOMS.Chart.ChartAbstractLegend();
- }
-
- return this.legend;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.addDataset = function (dataset)
- {
- this.dataset.push(dataset);
-
- this.findAxisDomain();
- };
-
- jsOMS.Chart.ChartAbstract.prototype.setData = function (data)
- {
- this.dataset = data;
-
- this.findAxisDomain();
- };
-
- jsOMS.Chart.ChartAbstract.prototype.findAxisDomain = function ()
- {
- for (const id in this.axis) {
- if (!this.axis.hasOwnProperty(id)) {
- continue;
- }
-
- this.axis[id].max = d3.max(this.dataset, function (m)
- {
- return d3.max(m.points, function (d)
- {
- return d[id];
- });
- });
-
- this.axis[id].min = d3.min(this.dataset, function (d)
- {
- return d3.min(d.points, function (t)
- {
- return t[id];
- });
- });
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.getData = function ()
- {
- return this.dataset;
- };
-
- jsOMS.Chart.ChartAbstract.prototype.drawLegend = function (svg, dataPointEnter, dataPoint)
- {
- const self = this;
-
- if (typeof this.legend !== 'undefined' && this.legend.visible) {
- dataPointEnter.append("text").attr('class', 'dataPoint-name');
- dataPoint.select("text.dataPoint-name").attr("x",
- this.dimension.width
- - this.margin.right
- - this.margin.left + 20
- ).attr("y", function (d, i)
- {
- return i * 20 + 10 - 1;
- }).attr("dy", ".35em").text(function (d)
- {
- return d.name;
- });
- dataPointEnter.append('circle').attr('class', 'dataPoint-dot');
- dataPoint.select('circle.dataPoint-dot').attr('cx',
- this.dimension.width
- - this.margin.right
- - this.margin.left + 10
- ).attr('cy', function (d, i)
- {
- return i * 20 + 10;
- }).attr('r', 4).style('stroke', function (d)
- {
- return self.color(d.name);
- });
- dataPoint.exit().remove();
-
- let tlength = this.chartSelect.select('.dataPoint-name').node().getComputedTextLength();
-
- // Adding margin for legend
- if (this.margin.right < tlength) {
- this.margin.right = tlength + 30;
- this.shouldRedraw = true;
- }
- } else if (this.margin.right > 10) {
- this.margin.right = 10;
- this.shouldRedraw = true;
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.drawMarker = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- let temp;
-
- if (this.dataSettings.marker.visible) {
- temp = dataPointEnter.append('g').attr('class', 'dots').attr('clip-path', 'url(#clipper1)').selectAll('circle').data(function (d)
- {
- return d.points;
- }).enter().append('circle').attr('class', 'dot');
- dataPoint.select('.dots').style('stroke', function (d)
- {
- return self.color(d.name);
- }).selectAll('circle').transition().duration(500).attr('cy', function (d)
- {
- return y(d.y);
- }).attr('cx', function (d)
- {
- return x(d.x);
- }).attr('r', 4);
- }
-
- if (this.dataSettings.info.visible && this.dataSettings.marker.visible) {
- temp = dataPointEnter.append('g').attr('class', 'dots');
-
- let div = this.chartSelect.append("div").attr("class", "charttooltip").style("opacity", 0);
- div.html(self.axis.x.label.text + ': ' + 100 + "
" + self.axis.y.label.text + ': ' + 100);
-
- temp.on("mouseover", function (d) {
- let dim = div.node().getBoundingClientRect();
- let pos = this.getBoundingClientRect();
-
- div.transition()
- .duration(200)
- .style("opacity", .9);
-
- div.html(self.axis.x.label.text + ': ' + d.x + "
" + self.axis.y.label.text + ': ' + d.y)
- .style("left", (x(d.x) + dim.width / 2) + "px")
- .style("top", (y(d.y) + dim.height) + "px");
- })
- .on("mouseout", function (d) {
- div.transition()
- .duration(500)
- .style("opacity", 0);
- });
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.drawText = function (svg)
- {
- let temp, pos = 0, topmargin = 0;
-
- /* No subtitle without title */
- if (typeof this.subtitle !== 'undefined' && this.subtitle.text !== '' && this.subtitle.visible && typeof this.title !== 'undefined' && this.title.text !== '' && this.title.visible) {
- pos = this.calculateHorizontalPosition(this.subtitle.position);
-
- temp = svg.append("text")
- .attr("class", "subtitle")
- .attr('y', this.position.title.top)
- .attr('x', pos)
- .style("text-anchor", this.subtitle.anchor)
- .text(this.subtitle.text);
-
- topmargin = 10;
- /* only add margin if subtitle exists */
-
- if (!this.defined.text.subtitle) {
- this.position.subtitle.top = temp.node().getBoundingClientRect().height / 2;
- this.margin.top += temp.node().getBoundingClientRect().height / 2 + topmargin;
- this.defined.text.subtitle = true;
- this.shouldRedraw = true;
- }
- }
-
- if (typeof this.title !== 'undefined' && this.title.text !== '' && this.title.visible) {
- pos = this.calculateHorizontalPosition(this.title.position);
-
- temp = svg.append("text")
- .attr("class", "title")
- .attr('y', -this.position.subtitle.top - topmargin)
- .attr('x', pos)
- .style("text-anchor", this.title.anchor)
- .text(this.title.text);
-
- if (!this.defined.text.title) {
- this.position.title.top = 0;
- this.margin.top += (temp.node().getBoundingClientRect().height) / 2 + this.position.subtitle.top / 2;
- this.defined.text.title = true;
- this.shouldRedraw = true;
- }
- }
-
- if (typeof this.footer !== 'undefined' && this.footer.text !== '' && this.footer.visible) {
- let spacer = 0;
-
- // if no x axis available an element less will be drawn and the footer
- // will be out of bounds.
- if (typeof this.axis.x === 'undefined') {
- spacer = -this.margin.top;
- }
-
- pos = this.calculateHorizontalPosition(this.footer.position);
-
- temp = svg.append("text")
- .attr("class", "footer")
- .attr('y', this.dimension.height
- - this.margin.bottom + spacer + this.position.footer.top)
- .attr('x', pos)
- .style("text-anchor", this.footer.anchor)
- .text(this.footer.text);
-
- if (!this.defined.text.footer) {
- this.position.footer.top = temp.node().getBoundingClientRect().height;
- this.margin.bottom += temp.node().getBoundingClientRect().height + 10;
- this.defined.text.footer = true;
- this.shouldRedraw = true;
- }
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.drawAxis = function (svg, xAxis1, yAxis1)
- {
- // draw clipper
- let defs = svg.append('svg').attr('width', 0).attr('height', 0).append('defs'), pos = 0, temp;
- defs.append('clipPath').attr('id', 'clipper1').append('rect').attr('x', 0).attr('y', 0)
- .attr('width',
- this.dimension.width
- - this.margin.right
- - this.margin.left
- )
- .attr('height',
- this.dimension.height
- - this.margin.top
- - this.margin.bottom
- );
-
- if (typeof this.axis.x !== 'undefined' && this.axis.x.visible) {
- temp = svg.append("g")
- .attr("class", "x axis")
- .attr("transform", "translate(0," + (
- this.dimension.height
- - this.margin.top
- - this.margin.bottom
- ) + ")")
- .call(xAxis1);
-
- if (this.axis.x.label.visible) {
- pos = this.calculateHorizontalPosition(this.axis.x.label.position);
-
- temp.append("text")
- .attr('y', 45)
- .attr('x', pos)
- .style("text-anchor", this.axis.x.label.anchor)
- .text(this.axis.x.label.text);
- }
-
- if (!this.defined.axis.x) {
- this.margin.bottom += 50;
- this.defined.axis.x = true;
- this.shouldRedraw = true;
- }
- }
-
- if (typeof this.axis.y !== 'undefined' && this.axis.y.visible) {
- temp = svg.append("g")
- .attr("class", "y axis")
- .attr("transform", "translate(0,0)")
- .call(yAxis1);
-
- if (this.axis.y.label.visible) {
- pos = this.calculateVerticalPosition(this.axis.y.label.position);
-
- temp.append("text")
- .attr("transform", "rotate(-90)")
- .attr("y", -this.margin.left + 10)
- .attr('x', pos)
- .style("text-anchor", this.axis.y.label.anchor)
- .text(this.axis.y.label.text);
- }
-
- if (!this.defined.axis.y) {
- this.margin.left += svg.select('.y.axis .tick').node().getBoundingClientRect().width + 25;
- this.defined.axis.y = true;
- this.shouldRedraw = true;
- }
- }
-
- if (typeof this.axis.x2 !== 'undefined') {
-
- }
-
- if (typeof this.axis.y2 !== 'undefined') {
-
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.drawGrid = function (svg, xGrid, yGrid)
- {
- if (typeof this.grid.x !== 'undefined' && this.grid.x.visible) {
- svg.append("g")
- .attr("class", "x grid")
- .attr("transform", "translate(0," + (this.dimension.height - this.margin.top - this.margin.bottom) + ")")
- .call(xGrid);
- }
-
- if (typeof this.grid.y !== 'undefined' && this.grid.y.visible) {
- svg.append("g")
- .attr("class", "y grid")
- .call(yGrid);
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createXScale = function (type)
- {
- if (type === 'ordinal') {
- return d3.scale.ordinal().rangeRoundBands([
- 0,
- this.dimension.width
- - this.margin.right
- - this.margin.left
- ], 0.3);
- } else {
- return d3.scale.linear().range([
- 0,
- this.dimension.width
- - this.margin.right
- - this.margin.left
- ]);
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createYScale = function (type)
- {
- if (type === 'ordinal') {
- return d3.scale.ordinal().rangeRoundBands([
- 0,
- this.dimension.height
- - this.margin.top
- - this.margin.bottom
- ], 0.3);
- } else {
- return d3.scale.linear().range([
- this.dimension.height
- - this.margin.top
- - this.margin.bottom,
- 10
- ]);
- }
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createXAxis = function (x) {
- const self = this;
-
- return d3.svg.axis().scale(x).tickFormat(function (d)
- {
- return self.axis.x.tick.prefix + d;
- }).orient("bottom").outerTickSize(self.axis.x.tick.size)
- .innerTickSize(self.axis.x.tick.size).tickPadding(7);
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createYAxis = function (y) {
- const self = this;
-
- return d3.svg.axis().scale(y).tickFormat(function (d)
- {
- return self.axis.y.tick.prefix + d;
- }).orient("left").outerTickSize(this.axis.y.tick.size)
- .innerTickSize(this.axis.y.tick.size).tickPadding(7);
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createXGrid = function (x) {
- return d3.svg.axis()
- .scale(x)
- .orient("bottom")
- //.ticks(0)
- .tickSize(
- -(this.dimension.height
- - this.margin.top - 10
- - this.margin.bottom), 0, 0)
- .tickFormat("");
- };
-
- jsOMS.Chart.ChartAbstract.prototype.createYGrid = function (y) {
- return d3.svg.axis()
- .scale(y)
- .orient("left")
- //.ticks(0)
- .tickSize(
- -this.dimension.width
- + this.margin.right
- + this.margin.left, 0, 0)
- .tickFormat("");
- };
-
- jsOMS.Chart.ChartAbstract.prototype.calculateDimension = function ()
- {
- let box = this.chartSelect.node().getBoundingClientRect();
-
- this.dimension = {
- width: box.width,
- height: box.height
- };
- };
-
- jsOMS.Chart.ChartAbstract.prototype.clean = function ()
- {
- this.margin = {top: 0, right: 0, bottom: 0, left: 0};
- this.dimension = {width: 0, height: 0};
- this.position = {
- title: {
- top: 0,
- left: 0
- },
- subtitle: {
- top: 0,
- left: 0
- },
- footer: {
- top: 0,
- left: 0
- },
- zoompanel: {
- top: 0,
- left: 0
- }
- };
-
- this.shouldRedraw = false;
- this.defined = {
- axis: {
- x: false,
- y: false
- },
- text: {
- title: false,
- subtitle: false,
- footer: false
- },
- legend: false
- };
-
- this.chartSelect.select("*").remove();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/ChartLegend.js b/Chart/ChartLegend.js
deleted file mode 100755
index 4c76b38..0000000
--- a/Chart/ChartLegend.js
+++ /dev/null
@@ -1,49 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Chart.Legend = function () {
- this.position = {x: 0, y: 0};
- this.relative = true;
- this.horizontal = false;
- this.visible = true;
- this.labels = []; // {title, color, marker}
- };
-
- jsOMS.Chart.Legend.prototype.addLabel = function(label) {
- this.labels.push(label);
- };
-
- jsOMS.Chart.Legend.prototype.setVisibility = function(visibility) {
- this.visible = visibility;
- };
-
- jsOMS.Chart.Legend.prototype.getVisibility = function() {
- return this.visible;
- };
-
- jsOMS.Chart.Legend.prototype.setPosition = function(position) {
- this.position = position;
- };
-
- jsOMS.Chart.Legend.prototype.getPosition = function() {
- return this.position;
- };
-
- jsOMS.Chart.Legend.prototype.setRelative = function(relative) {
- this.relative = relative;
- };
-
- jsOMS.Chart.Legend.prototype.isRelative = function() {
- return this.relative;
- };
-
- jsOMS.Chart.Legend.prototype.setHorizontal = function(horizontal) {
- this.horizontal = horizontal;
- };
-
- jsOMS.Chart.Legend.prototype.isHorizontal = function() {
- return this.horizontal;
- };
-
-
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/Colors.js b/Chart/Colors.js
deleted file mode 100755
index e47a062..0000000
--- a/Chart/Colors.js
+++ /dev/null
@@ -1,6 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Chart.TextElement = function() {
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/ColumnChart.js b/Chart/ColumnChart.js
deleted file mode 100755
index c1c6981..0000000
--- a/Chart/ColumnChart.js
+++ /dev/null
@@ -1,258 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.ColumnChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: false
- },
- y: {
- visible: true
- }
- };
-
- this.chart.dataSettings.marker.visible = false;
- this.chart.subtype = 'stacked';
- };
-
- jsOMS.Chart.ColumnChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.ColumnChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.ColumnChart.prototype.draw = function ()
- {
- let rect, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- if (this.chart.subtype === 'grouped') {
- this.chart.axis.y.max = d3.max(this.chart.dataset, function (layer)
- {
- return d3.max(layer.points, function (d)
- {
- return d.y;
- });
- });
- } else {
- this.chart.axis.y.max = d3.max(this.chart.dataset, function (layer)
- {
- return d3.max(layer.points, function (d)
- {
- return d.y0 + d.y;
- });
- });
- }
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('ordinal');
- y = this.chart.createYScale('linear');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain(d3.range(this.chart.dataset[0].points.length)).rangeRoundBands([0, this.chart.dimension.width - this.chart.margin.right - this.chart.margin.left], .1);
- y.domain([0, this.chart.axis.y.max + 1]);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawMarker(svg, x, y, dataPointEnter, dataPoint);
- this.chart.drawLegend(svg, dataPointEnter, dataPoint);
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.ColumnChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.ColumnChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- let rect;
-
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
- {
- return c.id;
- });
-
- dataPointEnter = dataPoint.enter().append("g").attr("class", "dataPoint")
- .style("fill", function (d)
- {
- return self.chart.color(d.name);
- });
-
- rect = dataPointEnter.selectAll("rect")
- .data(function (d)
- {
- return d.points;
- })
- .enter().append("rect")
- .attr("x", function (d)
- {
- return x(d.x);
- })
- .attr("y", this.chart.dimension.height - this.chart.margin.top - this.chart.margin.bottom)
- .attr("width", x.rangeBand())
- .attr("height", 0);
-
- if (this.chart.subtype === 'stacked') {
- rect.transition()
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("y", function (d)
- {
- return y(d.y0 + d.y);
- })
- .attr("height", function (d)
- {
- return y(d.y0) - y(d.y0 + d.y);
- });
- } else {
- rect.transition()
- .duration(500)
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("x", function (d, i, j)
- {
- return x(d.x) + x.rangeBand() / self.chart.dataset.length * j;
- })
- .attr("width", x.rangeBand() / self.chart.dataset.length)
- .transition()
- .attr("y", function (d)
- {
- return y(d.y);
- })
- .attr("height", function (d)
- {
- return self.chart.dimension.height - self.chart.margin.top - self.chart.margin.bottom - y(d.y);
- });
- }
-
- return [dataPointEnter, dataPoint];
- };
-
- jsOMS.Chart.ColumnChart.prototype.transitionGrouped = function (x, y, rect, yMin, yMax)
- {
- y.domain([yMin, yMax]);
-
- rect.transition()
- .duration(500)
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("x", function (d, i, j)
- {
- return x(d.x) + x.rangeBand() / n * j;
- })
- .attr("width", x.rangeBand() / n)
- .transition()
- .attr("y", function (d)
- {
- return y(d.y);
- })
- .attr("height", function (d)
- {
- return self.chart.dimension.height - self.chart.margin.top - self.chart.margin.bottom - y(d.y);
- });
- };
-
- jsOMS.Chart.ColumnChart.prototype.transitionStacked = function (x, y, rect, yMin, yMax)
- {
- y.domain([yMin, yMax]);
-
- rect.transition()
- .duration(500)
- .delay(function (d, i)
- {
- return i * 10;
- })
- .attr("y", function (d)
- {
- return y(d.y0 + d.y);
- })
- .attr("height", function (d)
- {
- return y(d.y0) - y(d.y0 + d.y);
- })
- .transition()
- .attr("x", function (d)
- {
- return x(d.x);
- })
- .attr("width", x.rangeBand());
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/DiffAreaChart.js b/Chart/DiffAreaChart.js
deleted file mode 100755
index 1156c78..0000000
--- a/Chart/DiffAreaChart.js
+++ /dev/null
@@ -1,26 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.DiffAreaChart = function (id)
- {
- this.chart = new jsOMS.Chart.LineChart(id);
- this.chart.getChart().dataSettings.marker.visible = false;
- this.chart.getChart().subtype = 'diffarea';
- };
-
- jsOMS.Chart.DiffAreaChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.DiffAreaChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.DiffAreaChart.prototype.draw = function ()
- {
- return this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/DonutChart.js b/Chart/DonutChart.js
deleted file mode 100755
index ed53c33..0000000
--- a/Chart/DonutChart.js
+++ /dev/null
@@ -1,28 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.DonutChart = function (id)
- {
- this.chart = new jsOMS.Chart.PieChart(id);
-
- // Setting default chart values
- this.chart.getChart().dataSettings.style.strokewidth = 0.3;
- this.chart.getChart().subtype = 'donut';
- };
-
- jsOMS.Chart.DonutChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.DonutChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.DonutChart.prototype.draw = function ()
- {
- this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/FillGougeChart.js b/Chart/FillGougeChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/GanttChart.js b/Chart/GanttChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/GougeChart.js b/Chart/GougeChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/GroupedBarChart.js b/Chart/GroupedBarChart.js
deleted file mode 100755
index 6acfc88..0000000
--- a/Chart/GroupedBarChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.GroupedBarChart = function (id)
- {
- this.chart = new jsOMS.Chart.BarChart(id);
- this.chart.getChart().subtype = 'grouped';
- };
-
- jsOMS.Chart.GroupedBarChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.GroupedBarChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.GroupedBarChart.prototype.draw = function ()
- {
- this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/GroupedColumnChart.js b/Chart/GroupedColumnChart.js
deleted file mode 100755
index 4995c3e..0000000
--- a/Chart/GroupedColumnChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.GroupedColumnChart = function (id)
- {
- this.chart = new jsOMS.Chart.ColumnChart(id);
- this.chart.getChart().subtype = 'grouped';
- };
-
- jsOMS.Chart.GroupedColumnChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.GroupedColumnChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.GroupedColumnChart.prototype.draw = function ()
- {
- this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/LineChart.js b/Chart/LineChart.js
deleted file mode 100755
index e4d859c..0000000
--- a/Chart/LineChart.js
+++ /dev/null
@@ -1,265 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.LineChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y0: {
- visible: false,
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: true
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'line';
- };
-
- jsOMS.Chart.LineChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.LineChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.LineChart.prototype.draw = function ()
- {
- let line, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('linear');
- y = this.chart.createYScale('linear');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]);
- y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]);
-
- if (this.chart.subtype === 'area') {
- line = d3.svg.area().interpolate(this.chart.dataSettings.interpolate).x(function (d)
- {
- return x(d.x);
- }).y0(this.chart.getDimension().height).y1(function (d)
- {
- return y(d.y);
- });
- } else if (this.chart.subtype === 'diffarea') {
- y.domain([this.chart.axis.y0.min - 1, this.chart.axis.y.max + 1]);
-
- line = d3.svg.area().interpolate(this.chart.dataSettings.interpolate).x(function (d)
- {
- return x(d.x);
- }).y0(function (d) {
- return y(d.y0);
- }).y1(function (d)
- {
- return y(d.y);
- });
- } else if (this.chart.subtype === 'stacked') {
- line = d3.svg.area().interpolate(this.chart.dataSettings.interpolate).x(function (d)
- {
- return x(d.x);
- }).y0(function (d)
- {
- return y(d.y0);
- }).y1(function (d)
- {
- return y(d.y + d.y0);
- });
- } else if (this.chart.subtype === 'line') {
- line = d3.svg.line().interpolate(this.chart.dataSettings.interpolate).x(function (d)
- {
- return x(d.x);
- }).y(function (d)
- {
- return y(d.y);
- });
- } else {
- return;
- }
-
- zoom = d3.behavior.zoom().x(x).scaleExtent([1, 2]).on('zoom', function ()
- {
- let tx, ty;
- tx = d3.event.translate[0];
- ty = d3.event.translate[1];
- tx = Math.min(1,
- Math.max(tx,
- self.chart.dimension.width
- - self.chart.margin.right
- - self.chart.margin.left
- - Math.round(x(self.chart.axis.y.max) - x(1)),
- self.chart.dimension.width
- - self.chart.margin.right
- - self.chart.margin.left
- - Math.round(x(self.chart.axis.y.max) - x(1)) * d3.event.scale));
-
- zoom.translate([tx, ty]);
- svg.select('.x.axis').call(xAxis1);
- svg.select('.x.grid').call(xGrid);
- svg.selectAll('.line').attr("d", function (d)
- {
- return line(d.points);
- }).style("stroke", function (d)
- {
- return self.chart.color(d.name);
- });
-
- if (self.chart.subtype === 'stacked') {
- return svg.selectAll('circle.dot').attr('cy', function (d)
- {
- return y(d.y + d.y0);
- }).attr('cx', function (d)
- {
- return x(d.x);
- }).attr('r', 4);
- } else {
- return svg.selectAll('circle.dot').attr('cy', function (d)
- {
- return y(d.y);
- }).attr('cx', function (d)
- {
- return x(d.x);
- }).attr('r', 4);
- }
- });
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
- this.drawZoomPanel(svg, zoom);
-
- zoom.scaleExtent([1, Number.MAX_VALUE]);
- //svg.selectAll('.x.grid').transition().duration(500).call(xGrid);
- //svg.selectAll('.x.axis').transition().duration(500).call(xAxis1);
- //svg.selectAll('.y.axis').transition().duration(500).call(yAxis1);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, line, dataPointEnter, dataPoint);
-
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawMarker(svg, x, y, dataPointEnter, dataPoint);
- this.chart.drawLegend(svg, dataPointEnter, dataPoint);
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
-
- return zoom.x(x);
- };
-
- jsOMS.Chart.LineChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.LineChart.prototype.drawData = function (svg, line, dataPointEnter, dataPoint)
- {
- const self = this;
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
- {
- return c.id;
- });
-
- dataPointEnter = dataPoint.enter().append("g").attr("class", "dataPoint");
- dataPointEnter.append("path").attr('clip-path', 'url(#clipper1)').attr("class", self.chart.subtype);
- dataPoint.select('path').style("stroke-width", this.chart.dataSettings.style.strokewidth).transition().duration(500).attr("d", function (d)
- {
- return line(d.points);
- }).style("stroke", function (d)
- {
- return self.chart.color(d.name);
- }).style("fill", function (d)
- {
- if (self.chart.subtype === 'area' || self.chart.subtype === 'stacked') {
- return self.chart.color(d.name);
- }
- });
-
- return [dataPointEnter, dataPoint];
- };
-
- jsOMS.Chart.LineChart.prototype.drawZoomPanel = function (svg, zoom)
- {
- this.chart.position.zoompanel.top = 10;
-
- svg.append("rect")
- .attr('class', 'zoom-panel')
- .attr('y', this.chart.position.zoompanel.top)
- .attr("width",
- this.chart.dimension.width
- - this.chart.margin.right
- - this.chart.margin.left
- )
- .attr("height",
- this.chart.dimension.height
- - this.chart.margin.top
- - this.chart.margin.bottom - this.chart.position.zoompanel.top
- ).call(zoom);
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/OhlcChart.js b/Chart/OhlcChart.js
deleted file mode 100755
index 3bc5140..0000000
--- a/Chart/OhlcChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.OhlcChart = function (id)
- {
- this.chart = new jsOMS.Chart.CandlestickChart(id);
- this.chart.getChart().subtype = 'ohlc';
- };
-
- jsOMS.Chart.OhlcChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.OhlcChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.OhlcChart.prototype.draw = function ()
- {
- return this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/PieChart.js b/Chart/PieChart.js
deleted file mode 100755
index b2e7229..0000000
--- a/Chart/PieChart.js
+++ /dev/null
@@ -1,104 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.PieChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
-
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.dataSettings.style.strokewidth = 1;
- this.chart.dataSettings.style.padding = 3;
- this.chart.subtype = 'pie';
- };
-
- jsOMS.Chart.PieChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.PieChart.prototype.draw = function ()
- {
- let svg, arc;
-
- this.chart.calculateDimension();
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawLegend(svg, dataPointEnter, dataPoint);
- this.chart.drawText(svg);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.PieChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.PieChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.PieChart.prototype.drawData = function (svg, dataPointEnter, dataPoint)
- {
- const self = this;
- let pie = d3.layout.pie()
- .sort(null)
- .value(function (d)
- {
- return d.value;
- }),
- radius = (
- Math.min(this.chart.dimension.width, this.chart.dimension.height) / 2
- - Math.max(this.chart.margin.right + this.chart.margin.left,
- this.chart.margin.top + this.chart.margin.bottom)
- ),
- innerRadius = radius - radius * self.chart.dataSettings.style.strokewidth,
- arc = d3.svg.arc()
- .outerRadius(function() { return radius; })
- .innerRadius(function() { return innerRadius; });
-
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset);
-
- dataPoint.enter().append("g").attr("class", "dataPoint");
-
- dataPointEnter = dataPoint.selectAll("path")
- .data(function (d)
- {
- return pie(d.points);
- }).enter().append('path')
- .attr("transform", "translate("
- + ((this.chart.dimension.width - this.chart.margin.left - this.chart.margin.right) / 2 ) + ","
- + ((this.chart.dimension.height - this.chart.margin.bottom - this.chart.margin.top) / 2) + ")")
- .attr('fill', function (d)
- {
- return self.chart.color(d.data.name);
- })
- .attr('d', arc)
- .style('stroke', '#fff')
- .style('stroke-width', this.chart.dataSettings.style.padding);
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/Position.js b/Chart/Position.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/PositionEnum.js b/Chart/PositionEnum.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/PyramidChart.js b/Chart/PyramidChart.js
deleted file mode 100755
index d7f7af8..0000000
--- a/Chart/PyramidChart.js
+++ /dev/null
@@ -1,204 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.PyramidChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: false
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'waterfall';
- };
-
- jsOMS.Chart.PyramidChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.PyramidChart.prototype.setData = function (data)
- {
- let dataset = [{id: 1, name: 'Dataset', points: []}],
- length = data.length,
- add = 0;
-
- for (let i = 0; i < length - 1; ++i) {
- dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
- add += data[i].value;
- }
-
- dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
-
- this.chart.setData(dataset);
- };
-
- jsOMS.Chart.PyramidChart.prototype.draw = function ()
- {
- let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom,
- self = this,
- box = this.chart.chartSelect.node().getBoundingClientRect();
-
- this.chart.dimension = {
- width: box.width,
- height: box.height
- };
-
- x = d3.scale.ordinal().rangeRoundBands([
- 0,
- this.chart.dimension.width
- - this.chart.margin.right
- - this.chart.margin.left
- ], 0.3);
-
- y = d3.scale.linear().range([
- this.chart.dimension.height
- - this.chart.margin.top
- - this.chart.margin.bottom,
- 10
- ]);
-
- xAxis1 = d3.svg.axis().scale(x).tickFormat(function (d)
- {
- return self.chart.axis.x.tick.prefix + d;
- }).orient("bottom").outerTickSize(this.chart.axis.x.tick.size)
- .innerTickSize(this.chart.axis.x.tick.size).tickPadding(7);
-
- yAxis1 = d3.svg.axis().scale(y).tickFormat(function (d)
- {
- return self.chart.axis.y.tick.prefix + d;
- }).orient("left").outerTickSize(this.chart.axis.y.tick.size)
- .innerTickSize(this.chart.axis.y.tick.size).tickPadding(7);
-
- xGrid = d3.svg.axis()
- .scale(x)
- .orient("bottom")
- //.ticks(0)
- .tickSize(
- -(this.chart.dimension.height
- - this.chart.margin.top - 10
- - this.chart.margin.bottom), 0, 0)
- .tickFormat("");
-
- yGrid = d3.svg.axis()
- .scale(y)
- .orient("left")
- //.ticks(0)
- .tickSize(
- -this.chart.dimension.width
- + this.chart.margin.right
- + this.chart.margin.left, 0, 0)
- .tickFormat("");
-
- x.domain(this.chart.dataset[0].points.map(function(d) { return d.name; }));
- y.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y * 1.05; })]);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.PyramidChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.PyramidChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
-
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c)
- {
- return c.name;
- });
-
- dataPointEnter = dataPoint.enter().append("g")
- .attr("class", function(d) { return "dataPoint " + (d.y < d.y0 ? 'negative' : 'positive'); })
- .attr("transform", function(d) { return "translate(" + x(d.name) + ",0)"; });
-
- dataPointEnter.append("rect")
- .attr("y", function(d) { return y( Math.max(d.y0, d.y) ); })
- .attr("height", function(d) { return Math.abs( y(d.y0) - y(d.y) ); })
- .attr("width", x.rangeBand());
-
- dataPointEnter.append("text")
- .attr("x", x.rangeBand() / 2)
- .attr("y", function(d) { return y(d.y) + 5; })
- .attr("dy", function(d) { return ((d.y < d.y0) ? '-' : '') + ".75em" })
- .text(function(d) { return d.y - d.y0; });
-
- dataPointEnter.filter(function(d) { return d.class != "total" }).append("line")
- .attr("class", "connector")
- .attr("x1", x.rangeBand() + 5 )
- .attr("y1", function(d) { return y(d.y) } )
- .attr("x2", x.rangeBand() / ( 1 - 5) - 5 )
- .attr("y2", function(d) { return y(d.y) } );
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/RadarChart.js b/Chart/RadarChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/ScatterplotChart.js b/Chart/ScatterplotChart.js
deleted file mode 100755
index 24fe8b7..0000000
--- a/Chart/ScatterplotChart.js
+++ /dev/null
@@ -1,143 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.ScatterplotChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
-
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: true
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'scatterplot';
- };
-
- jsOMS.Chart.ScatterplotChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.ScatterplotChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.ScatterplotChart.prototype.draw = function ()
- {
- let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- this.chart.calculateDimension('linear');
-
- x = this.chart.createXScale('linear');
- y = this.chart.createYScale('linear');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain([this.chart.axis.x.min, this.chart.axis.x.max + 1]);
- y.domain([this.chart.axis.y.min - 1, this.chart.axis.y.max + 1]);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawLegend(svg, dataPointEnter, dataPoint);
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.ScatterplotChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.ScatterplotChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset, function (c)
- {
- return c.id;
- });
-
- dataPointEnter = dataPoint.enter().append("g")
- .attr("class", "dataPoint")
- .style("fill", function(d) { return self.chart.color(d.name); });
-
- dataPointEnter.selectAll("circle")
- .data(function (d)
- {
- return d.points;
- })
- .enter().append("circle")
- .attr("class", "dataPoint")
- .attr("r", function(d) { return d.y0; })
- .attr("cx", function(d) { return x(d.x); })
- .attr("cy", function(d) { return y(d.y); });
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/StackedAreaChart.js b/Chart/StackedAreaChart.js
deleted file mode 100755
index 8e552af..0000000
--- a/Chart/StackedAreaChart.js
+++ /dev/null
@@ -1,26 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.StackedAreaChart = function (id)
- {
- this.chart = new jsOMS.Chart.LineChart(id);
- this.chart.getChart().dataSettings.marker.visible = false;
- this.chart.getChart().subtype = 'stacked';
- };
-
- jsOMS.Chart.StackedAreaChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.StackedAreaChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.StackedAreaChart.prototype.draw = function ()
- {
- return this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/StackedBarChart.js b/Chart/StackedBarChart.js
deleted file mode 100755
index 30cde2b..0000000
--- a/Chart/StackedBarChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.StackedBarChart = function (id)
- {
- this.chart = new jsOMS.Chart.BarChart(id);
- this.chart.getChart().subtype = 'stacked';
- };
-
- jsOMS.Chart.StackedBarChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.StackedBarChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.StackedBarChart.prototype.draw = function ()
- {
- this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/StackedColumnChart.js b/Chart/StackedColumnChart.js
deleted file mode 100755
index 0f19cd3..0000000
--- a/Chart/StackedColumnChart.js
+++ /dev/null
@@ -1,25 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.StackedColumnChart = function (id)
- {
- this.chart = new jsOMS.Chart.ColumnChart(id);
- this.chart.getChart().subtype = 'stacked';
- };
-
- jsOMS.Chart.StackedColumnChart.prototype.getChart = function ()
- {
- return this.chart.getChart();
- };
-
- jsOMS.Chart.StackedColumnChart.prototype.setData = function (data)
- {
- this.chart.setData(data);
- };
-
- jsOMS.Chart.StackedColumnChart.prototype.draw = function ()
- {
- this.chart.draw();
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/TextElement.js b/Chart/TextElement.js
deleted file mode 100755
index e47a062..0000000
--- a/Chart/TextElement.js
+++ /dev/null
@@ -1,6 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Chart.TextElement = function() {
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/TreeChart.js b/Chart/TreeChart.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Chart/VWaterfallChart.js b/Chart/VWaterfallChart.js
deleted file mode 100755
index 584d14f..0000000
--- a/Chart/VWaterfallChart.js
+++ /dev/null
@@ -1,154 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.VWaterfallChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
-
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: false
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'vwaterfall';
- };
-
- jsOMS.Chart.VWaterfallChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.VWaterfallChart.prototype.setData = function (data)
- {
- let dataset = [{id: 1, name: 'Dataset', points: []}],
- length = data.length,
- add = 0;
-
- for (let i = 0; i < length - 1; ++i) {
- dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
- add += data[i].value;
- }
-
- dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
-
- this.chart.setData(dataset);
- };
-
- jsOMS.Chart.VWaterfallChart.prototype.draw = function ()
- {
- let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('linear');
- y = this.chart.createYScale('ordinal');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y * 1.05; })]);
- y.domain(this.chart.dataset[0].points.map(function(d) { return d.name; }));
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.VWaterfallChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.VWaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c)
- {
- return c.name;
- });
-
- dataPointEnter = dataPoint.enter().append("g")
- .attr("class", function(d) { return "dataPoint " + (d.y < d.y0 ? 'negative' : 'positive'); })
- .attr("transform", function(d) { return "translate(0," + y(d.name) + ")"; });
-
- dataPointEnter.append("rect")
- .attr("x", function(d) { return x( Math.min(d.y0, d.y) ); })
- .attr("width", function(d) { return Math.abs( x(d.y0) - x(d.y) ); })
- .attr("height", y.rangeBand());
-
- dataPointEnter.filter(function(d) { return d.class != "total" }).append("line")
- .attr("class", "connector")
- .attr("x1", y.rangeBand() + 5 )
- .attr("y1", function(d) { return x(d.y) } )
- .attr("x2", y.rangeBand() / ( 1 - 5) - 5 )
- .attr("y2", function(d) { return x(d.y) } );
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Chart/WaterfallChart.js b/Chart/WaterfallChart.js
deleted file mode 100755
index f19ba7a..0000000
--- a/Chart/WaterfallChart.js
+++ /dev/null
@@ -1,160 +0,0 @@
-(function (jsOMS)
-{
- "use strict";
-
- jsOMS.Chart.WaterfallChart = function (id)
- {
- this.chart = new jsOMS.Chart.ChartAbstract(id);
-
- // Setting default chart values
- this.chart.margin = {top: 5, right: 0, bottom: 0, left: 0};
-
- /** global: d3 */
- this.chart.color = d3.scale.category10();
- this.chart.axis = {
- x: {
- visible: true,
- label: {
- visible: true,
- text: 'X-Axis',
- position: "center",
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- },
- y: {
- visible: true,
- label: {
- visible: true,
- text: 'Y-Axis',
- position: 'center',
- anchor: 'middle'
- },
- tick: {
- prefix: '',
- orientation: 'bottom',
- size: 7
- },
- min: 0,
- max: 0
- }
- };
-
- this.chart.grid = {
- x: {
- visible: false
- },
- y: {
- visible: true
- }
- };
-
- this.chart.subtype = 'waterfall';
- };
-
- jsOMS.Chart.WaterfallChart.prototype.getChart = function ()
- {
- return this.chart;
- };
-
- jsOMS.Chart.WaterfallChart.prototype.setData = function (data)
- {
- let dataset = [{id: 1, name: 'Dataset', points: []}],
- length = data.length,
- add = 0;
-
- for (let i = 0; i < length - 1; ++i) {
- dataset[0].points[i] = { name: data[i].name, y0: add, y: data[i].value + add };
- add += data[i].value;
- }
-
- dataset[0].points[length - 1] = { name: data[length - 1].name, y0: 0, y: add };
-
- this.chart.setData(dataset);
- };
-
- jsOMS.Chart.WaterfallChart.prototype.draw = function ()
- {
- let bar, svg, x, xAxis1, xAxis2, y, yAxis1, yAxis2, xGrid, yGrid, zoom, self = this;
-
- this.chart.calculateDimension();
-
- x = this.chart.createXScale('ordinal');
- y = this.chart.createYScale('linear');
- xAxis1 = this.chart.createXAxis(x);
- yAxis1 = this.chart.createYAxis(y);
- xGrid = this.chart.createXGrid(x);
- yGrid = this.chart.createYGrid(y);
-
- x.domain(this.chart.dataset[0].points.map(function(d) { return d.name; }));
- y.domain([0, d3.max(this.chart.dataset[0].points, function(d) { return d.y * 1.05; })]);
-
- svg = this.chart.chartSelect.append("svg")
- .attr("width", this.chart.dimension.width)
- .attr("height", this.chart.dimension.height)
- .append("g").attr("transform", "translate("
- + (this.chart.margin.left) + ","
- + (this.chart.margin.top) + ")");
-
- this.chart.drawGrid(svg, xGrid, yGrid);
-
- let dataPoint = null,
- dataPointEnter = null,
- temp = this.drawData(svg, x, y, dataPointEnter, dataPoint);
- dataPointEnter = temp[0];
- dataPoint = temp[1];
-
- this.chart.drawText(svg);
- this.chart.drawAxis(svg, xAxis1, yAxis1);
-
- if (this.chart.shouldRedraw) {
- this.redraw();
- }
- };
-
- jsOMS.Chart.WaterfallChart.prototype.redraw = function ()
- {
- this.chart.shouldRedraw = false;
- this.chart.chartSelect.select("*").remove();
- this.draw();
- };
-
- jsOMS.Chart.WaterfallChart.prototype.drawData = function (svg, x, y, dataPointEnter, dataPoint)
- {
- const self = this;
- dataPoint = svg.selectAll(".dataPoint").data(this.chart.dataset[0].points, function (c)
- {
- return c.name;
- });
-
- dataPointEnter = dataPoint.enter().append("g")
- .attr("class", function(d) { return "dataPoint " + (d.y < d.y0 ? 'negative' : 'positive'); })
- .attr("transform", function(d) { return "translate(" + x(d.name) + ",0)"; });
-
- dataPointEnter.append("rect")
- .attr("y", function(d) { return y( Math.max(d.y0, d.y) ); })
- .attr("height", function(d) { return Math.abs( y(d.y0) - y(d.y) ); })
- .attr("width", x.rangeBand());
-
- dataPointEnter.append("text")
- .attr("x", x.rangeBand() / 2)
- .attr("y", function(d) { return y(d.y) + 5; })
- .attr("dy", function(d) { return ((d.y < d.y0) ? '-' : '') + ".75em" })
- .text(function(d) { return d.y - d.y0; });
-
- dataPointEnter.filter(function(d) { return d.class != "total" }).append("line")
- .attr("class", "connector")
- .attr("x1", x.rangeBand() + 5 )
- .attr("y1", function(d) { return y(d.y) } )
- .attr("x2", x.rangeBand() / ( 1 - 5) - 5 )
- .attr("y2", function(d) { return y(d.y) } );
-
- return [dataPointEnter, dataPoint];
- };
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Config/Options.js b/Config/Options.js
index 34c6c04..cfdbc09 100755
--- a/Config/Options.js
+++ b/Config/Options.js
@@ -24,9 +24,9 @@ export class Options
/**
* Set option.
*
- * @param {int|string} key Option key
- * @param {boolean|int|float|string|Array} value Option value
- * @param {boolean} [overwrite] Overwrite value
+ * @param {number|string} key Option key
+ * @param {boolean|number|string|Object} value Option value
+ * @param {boolean} [overwrite] Overwrite value
*
* @return {boolean}
*
@@ -46,9 +46,9 @@ export class Options
/**
* Get option.
*
- * @param {int|string} key Option key
+ * @param {number|string} key Option key
*
- * @return {boolean|int|float|string|Array}
+ * @return {null|boolean|number|string|Object}
*
* @since 1.0.0
*/
@@ -64,7 +64,7 @@ export class Options
/**
* Remove option.
*
- * @param {int|string} key Option key
+ * @param {number|string} key Option key
*
* @return {boolean}
*
diff --git a/DataStorage/LocalStorage.js b/DataStorage/LocalStorage.js
index 29093b9..1b85415 100755
--- a/DataStorage/LocalStorage.js
+++ b/DataStorage/LocalStorage.js
@@ -24,7 +24,7 @@ export class LocalStorage
*
* @since 1.0.0
*/
- static available()
+ static available ()
{
try {
return 'localStorage' in window && window.localStorage !== null;
diff --git a/Dispatcher/Dispatcher.js b/Dispatcher/Dispatcher.js
deleted file mode 100755
index 7a4fc67..0000000
--- a/Dispatcher/Dispatcher.js
+++ /dev/null
@@ -1,6 +0,0 @@
-export class Dispatcher
-{
- constructor ()
- {
- };
-};
diff --git a/Event/EventManager.js b/Event/EventManager.js
index be8a5d3..2c5e4e1 100755
--- a/Event/EventManager.js
+++ b/Event/EventManager.js
@@ -19,8 +19,13 @@ export class EventManager
*/
constructor ()
{
- this.logger = Logger.getInstance();
- this.groups = {};
+ /** @type {Logger} logger */
+ this.logger = Logger.getInstance();
+
+ /** @type {Object.} groups */
+ this.groups = {};
+
+ /** @type {Object.} callbacks */
this.callbacks = {};
};
@@ -29,8 +34,8 @@ export class EventManager
*
* Adding the same event overwrites the existing one as "waiting"
*
- * @param {string|int} group Group id
- * @param {string|int} id Event id
+ * @param {string|number} group Group id
+ * @param {string|number} id Event id
*
* @return {void}
*
@@ -48,7 +53,7 @@ export class EventManager
/**
* Resets the group status
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
* @return {void}
*
@@ -57,7 +62,7 @@ export class EventManager
reset (group)
{
for (const id in this.groups[group]) {
- if (this.groups[group].hasOwnProperty(id)) {
+ if (Object.prototype.hasOwnProperty.call(this.groups[group], id)) {
this.groups[group][id] = false;
}
}
@@ -66,7 +71,7 @@ export class EventManager
/**
* Does group have outstanding events
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
* @return {boolean}
*
@@ -79,7 +84,7 @@ export class EventManager
}
for (const id in this.groups[group]) {
- if (!this.groups[group].hasOwnProperty(id) || !this.groups[group][id]) {
+ if (!Object.prototype.hasOwnProperty.call(this.groups[group], id) || !this.groups[group][id]) {
return true;
}
}
@@ -90,9 +95,9 @@ export class EventManager
/**
* Trigger event based on regex for group and/or id
*
- * @param {string|int} group Group id (can be regex)
- * @param {string|int} [id] Event id (can be regex)
- * @param {Object} [data] Data for event
+ * @param {string|number} group Group id (can be regex)
+ * @param {string|number} [id] Event id (can be regex)
+ * @param {null|Object} [data] Data for event
*
* @return {boolean}
*
@@ -146,16 +151,16 @@ export class EventManager
}
return triggerValue;
- }
+ };
/**
* Trigger event finished
*
* 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|number} group Group id
+ * @param {string|number} [id] Event id
+ * @param {null|Object} [data] Data for event
*
* @return {boolean}
*
@@ -198,7 +203,7 @@ export class EventManager
/**
* Detach event
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
* @return {void}
*
@@ -212,15 +217,15 @@ export class EventManager
/**
* Detach callback
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
- * @return {void}
+ * @return {boolean}
*
* @since 1.0.0
*/
- detachCallback(group)
+ detachCallback (group)
{
- if (this.callbacks.hasOwnProperty(group)) {
+ if (Object.prototype.hasOwnProperty.call(this.callbacks, group)) {
delete this.callbacks[group];
return true;
@@ -232,15 +237,15 @@ export class EventManager
/**
* Detach group
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
- * @return {void}
+ * @return {boolean}
*
* @since 1.0.0
*/
- detachGroup(group)
+ detachGroup (group)
{
- if (this.groups.hasOwnProperty(group)) {
+ if (Object.prototype.hasOwnProperty.call(this.groups, group)) {
delete this.groups[group];
return true;
@@ -252,10 +257,10 @@ export class EventManager
/**
* 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|number} 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}
*
@@ -263,8 +268,8 @@ export class EventManager
*/
attach (group, callback, remove = false, reset = false)
{
- if (!this.callbacks.hasOwnProperty(group)) {
- this.callbacks[group] = {remove: remove, reset: reset, callbacks: [], lastRun: 0};
+ if (!Object.prototype.hasOwnProperty.call(this.callbacks, group)) {
+ this.callbacks[group] = { remove: remove, reset: reset, callbacks: [], lastRun: 0 };
}
this.callbacks[group].callbacks.push(callback);
@@ -275,7 +280,7 @@ export class EventManager
/**
* Is a certain group allready attached
*
- * @param {string|int} group Group id
+ * @param {string|number} group Group id
*
* @return {boolean}
*
@@ -283,13 +288,13 @@ export class EventManager
*/
isAttached (group)
{
- return this.callbacks.hasOwnProperty(group);
+ return Object.prototype.hasOwnProperty.call(this.callbacks, group);
};
/**
* Count events
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
@@ -297,4 +302,4 @@ export class EventManager
{
return Object.keys(this.callbacks).length;
};
-};
\ No newline at end of file
+};
diff --git a/Localization/README.md b/Localization/README.md
deleted file mode 100755
index e69de29..0000000
diff --git a/Log/Logger.js b/Log/Logger.js
index a349bfb..4c0a3c9 100755
--- a/Log/Logger.js
+++ b/Log/Logger.js
@@ -14,17 +14,22 @@ export class Logger
/**
* @constructor
*
- * @param {boolean} verbose Verbose logging
- * @param {boolean} ui Ui logging
- * @param {boolean} remote Remote logging
+ * @param {boolean} [verbose] Verbose logging
+ * @param {boolean} [ui] Ui logging
+ * @param {boolean} [remote] Remote logging
*
* @since 1.0.0
*/
constructor (verbose = true, ui = true, remote = false)
{
+ /** @type {boolean} verbose */
this.verbose = verbose;
- this.ui = ui;
- this.remote = remote;
+
+ /** @type {boolean} ui */
+ this.ui = ui;
+
+ /** @type {boolean} remote */
+ this.remote = remote;
};
/**
@@ -34,7 +39,7 @@ export class Logger
* @param {boolean} [ui] Ui logging
* @param {boolean} [remote] Remote logging
*
- * @return {Object}
+ * @return {Logger}
*
* @since 1.0.0
*/
@@ -63,7 +68,7 @@ export class Logger
message = typeof message === 'undefined' ? Logger.MSG_FULL : message;
for (const replace in context) {
- if (context.hasOwnProperty(replace) && typeof message === 'string') {
+ if (Object.prototype.hasOwnProperty.call(context, replace) && typeof message === 'string') {
message = message.replace('{' + replace + '}', context[replace]);
}
}
@@ -123,19 +128,30 @@ export class Logger
}
};
+ /**
+ * Create ui log message
+ *
+ * @param {string} message Message to display
+ * @param {Object} [context] Context to put into message
+ * @param {string} level Log level
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
writeUi (message, context, level)
{
+ /** global: Notification */
if (Notification.permission !== 'granted' && Notification.permission !== 'denied') {
- Notification.requestPermission().then(function(permission) { });
+ Notification.requestPermission().then(function (permission) { });
}
- /** global: Notification */
- const notification = new Notification('Logger', {body: this.interpolate(message, context, level)});
+ const notification = new Notification('Logger', { body: this.interpolate(message, context, level) });
setTimeout(notification.close.bind(notification), 4000);
};
/**
- * Create local log message
+ * Create local log message in console
*
* @param {string} message Message to display
* @param {Object} [context] Context to put into message
@@ -186,7 +202,7 @@ export class Logger
*/
writeRemote (message, context, level)
{
- let request = new Request();
+ const request = new Request();
request.setData(context);
request.setType(jsOMS.Message.Response.Response.ResponseType.JSON);
request.setUri('/{/lang}/api/log');
diff --git a/Math/MathProcessor.js b/Math/MathProcessor.js
index c06494d..6fa80ef 100755
--- a/Math/MathProcessor.js
+++ b/Math/MathProcessor.js
@@ -7,29 +7,29 @@
* @since 1.0.0
*/
(function (jsOMS) {
- "use strict";
+ 'use strict';
/**
* Evaluate math formula
*
* @param {string} equation Equation
*
- * @return {null|int|float}
+ * @return {null|number}
*
* @since 1.0.0
*/
- jsOMS.mathEvaluate = function(equation)
+ jsOMS.mathEvaluate = function (equation)
{
- const stack = [],
- postfix = jsOMS.shuntingYard(equation);
- length = postfix.length;
+ const stack = [];
+ const postfix = jsOMS.shuntingYard(equation);
+ const length = postfix.length;
for (let i = 0; i < length; ++i) {
if (!isNaN(parseFloat(postfix[i])) && isFinite(postfix[i])) {
stack.push(postfix[i]);
} else {
- let a = jsOMS.parseValue(stack.pop());
- let b = jsOMS.parseValue(stack.pop());
+ const a = jsOMS.parseValue(stack.pop());
+ const b = jsOMS.parseValue(stack.pop());
if (postfix[i] === '+') {
stack.push(a + b);
@@ -55,14 +55,14 @@
*
* @param {string} value Value to parse
*
- * @return {int|float}
+ * @return {number}
*
* @since 1.0.0
*/
- jsOMS.parseValue = function(value)
+ jsOMS.parseValue = function (value)
{
return typeof value === 'string' ? (value.indexOf('.') === -1 ? parseInt(value) : parseFloat(value)) : value;
- }
+ };
/**
* Perform shunting yard
@@ -73,20 +73,20 @@
*
* @since 1.0.0
*/
- jsOMS.shuntingYard = function(equation)
+ jsOMS.shuntingYard = function (equation)
{
const stack = [];
const operators = {
- '^': {precedence: 4, order: 1},
- '*': {precedence: 3, order: -1},
- '/': {precedence: 3, order: -1},
- '+': {precedence: 2, order: -1},
- '-': {precedence: 2, order: -1},
+ '^': { precedence: 4, order: 1 },
+ '*': { precedence: 3, order: -1 },
+ '/': { precedence: 3, order: -1 },
+ '+': { precedence: 2, order: -1 },
+ '-': { precedence: 2, order: -1 }
};
- let output = [];
+ const output = [];
equation = equation.replace(/\s+/g, '');
- equation = equation.split(/([\+\-\*\/\^\(\)])/).filter(function (n) { return n !== '' });
+ equation = equation.split(/([\+\-\*\/\^\(\)])/).filter(function (n) { return n !== ''; });
const length = equation.length;
let token;
@@ -97,8 +97,8 @@
if (!isNaN(parseFloat(token)) && isFinite(token)) {
output.push(token);
} else if ('^*/+-'.indexOf(token) !== -1) {
- let o1 = token;
- let o2 = stack[stack.length - 1];
+ const o1 = token;
+ let o2 = stack[stack.length - 1];
while ('^*/+-'.indexOf(o2) !== -1
&& ((operators[o1].order === -1 && operators[o1].precedence <= operators[o2].precedence)
@@ -126,6 +126,4 @@
return output;
};
-
-
-}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Media/Video/CameraRecognition.js b/Media/Video/CameraRecognition.js
index 62e4156..3d40b1a 100755
--- a/Media/Video/CameraRecognition.js
+++ b/Media/Video/CameraRecognition.js
@@ -2,4 +2,4 @@
// take images every x ms
// call calback on canvas to check image
// stop if match or manual stop
-// return callback result
\ No newline at end of file
+// return callback result
diff --git a/Message/Notification/App/AppNotification.js b/Message/Notification/App/AppNotification.js
index 611ef03..588b515 100755
--- a/Message/Notification/App/AppNotification.js
+++ b/Message/Notification/App/AppNotification.js
@@ -1,3 +1,5 @@
+import { NotificationMessage } from '../NotificationMessage.js';
+
/**
* App notification.
*
@@ -15,13 +17,14 @@ export class AppNotification
*/
constructor ()
{
+ /** @type {number} status */
this.status = 0;
};
/**
* Set notification status.
*
- * @param {int} status Notification status
+ * @param {number} status Notification status
*
* @return {void}
*
@@ -35,7 +38,7 @@ export class AppNotification
/**
* Create notification
*
- * @param {Object} msg Notification
+ * @param {NotificationMessage} msg Notification
*
* @return {void}
*
@@ -52,7 +55,7 @@ export class AppNotification
const output = document.importNode(tpl.content, true);
output.querySelector('.log-msg').classList.add('log-msg-status-' + msg.status);
output.querySelector('.log-msg-content').innerHTML = msg.message;
- output.querySelector('.close').addEventListener('click', function() {
+ output.querySelector('.close').addEventListener('click', function () {
this.parentNode.remove();
});
diff --git a/Message/Notification/Browser/BrowserNotification.js b/Message/Notification/Browser/BrowserNotification.js
index 44f9972..b3a5a6b 100755
--- a/Message/Notification/Browser/BrowserNotification.js
+++ b/Message/Notification/Browser/BrowserNotification.js
@@ -1,3 +1,5 @@
+import { NotificationMessage } from '../NotificationMessage.js';
+
/**
* Browser notification.
*
@@ -13,15 +15,16 @@ export class BrowserNotification
*
* @since 1.0.0
*/
- constructor()
+ constructor ()
{
+ /** @type {number} status */
this.status = 0;
};
/**
* Set notification status.
*
- * @param {int} status Notification status
+ * @param {number} status Notification status
*
* @return {void}
*
@@ -43,14 +46,14 @@ export class BrowserNotification
{
/** global: Notification */
if (Notification.permission !== 'granted' && Notification.permission !== 'denied') {
- Notification.requestPermission().then(function(permission) { });
+ Notification.requestPermission().then(function (permission) { });
}
};
/**
* Create notification
*
- * @param {Object} msg Notification
+ * @param {NotificationMessage} msg Notification
*
* @return {void}
*
@@ -59,10 +62,10 @@ export class BrowserNotification
send (msg)
{
/** global: Notification */
- if (Notification.permission === "granted") {
+ if (Notification.permission === 'granted') {
const notification = new Notification(msg.title, { body: msg.message, vibrate: [msg.vibrate ? 200 : 0] });
setTimeout(notification.close.bind(notification), 5000);
}
};
-};
\ No newline at end of file
+};
diff --git a/Message/Notification/NotificationManager.js b/Message/Notification/NotificationManager.js
index a071854..dadd198 100755
--- a/Message/Notification/NotificationManager.js
+++ b/Message/Notification/NotificationManager.js
@@ -17,9 +17,12 @@ export class NotificationManager
*
* @since 1.0.0
*/
- constructor()
+ constructor ()
{
- this.appNotifier = new AppNotification();
+ /** @type {AppNotification} appNotifier */
+ this.appNotifier = new AppNotification();
+
+ /** @type {BrowserNotification} appNotifier */
this.browserNotifier = new BrowserNotification();
};
@@ -27,7 +30,7 @@ export class NotificationManager
* Create notification.
*
* @param {Object} message Message object
- * @param {int} type Notification type
+ * @param {number} type Notification type
*
* @return {void}
*
@@ -45,7 +48,7 @@ export class NotificationManager
/**
* Get the app notification manager.
*
- * @return {Object}
+ * @return {AppNotification}
*
* @since 1.0.0
*/
@@ -57,7 +60,7 @@ export class NotificationManager
/**
* Get the browser notification manager.
*
- * @return {Object}
+ * @return {BrowserNotification}
*
* @since 1.0.0
*/
@@ -65,4 +68,4 @@ export class NotificationManager
{
return this.browserNotifier;
};
-};
\ No newline at end of file
+};
diff --git a/Message/Notification/NotificationMessage.js b/Message/Notification/NotificationMessage.js
index a0b57f3..34ed762 100755
--- a/Message/Notification/NotificationMessage.js
+++ b/Message/Notification/NotificationMessage.js
@@ -1,29 +1,39 @@
-/**
- * App notification.
- *
- * @copyright Dennis Eichhorn
- * @license OMS License 1.0
- * @version 1.0.0
- * @since 1.0.0
- */
-export class NotificationMessage
-{
- /**
- * @constructor
- *
- * @param {string} status Message status
- * @param {string} title Message title
- * @param {string} message Message content
- * @param {bool} [vibrate] Vibrate
- *
- * @since 1.0.0
- */
- constructor(status, title, message, vibrate = false, isSticky = false)
- {
- this.status = status;
- this.title = title;
- this.message = message;
- this.vibrate = vibrate
- this.isSticky = isSticky
- };
-};
\ No newline at end of file
+/**
+ * App notification message.
+ *
+ * @copyright Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0
+ * @since 1.0.0
+ */
+export class NotificationMessage
+{
+ /**
+ * @constructor
+ *
+ * @param {string} status Message status
+ * @param {string} title Message title
+ * @param {string} message Message content
+ * @param {boolean} [vibrate] Vibrate
+ * @param {boolean} [isSticky] Should remain in the ui until manually removed
+ *
+ * @since 1.0.0
+ */
+ constructor (status, title, message, vibrate = false, isSticky = false)
+ {
+ /** @type {number} status */
+ this.status = status;
+
+ /** @type {string} title */
+ this.title = title;
+
+ /** @type {string} message */
+ this.message = message;
+
+ /** @type {boolean} vibrate */
+ this.vibrate = vibrate;
+
+ /** @type {boolean} isSticky */
+ this.isSticky = isSticky;
+ };
+};
diff --git a/Message/Request/OSType.js b/Message/Request/OSType.js
index c6fe0c6..54c2b5f 100755
--- a/Message/Request/OSType.js
+++ b/Message/Request/OSType.js
@@ -23,7 +23,7 @@ export const OSType = Object.freeze({
MAC_OS_X: 'macintosh', /* Mac OS X */
MAC_OS_X_2: 'mac os x', /* Mac OS X */
MAC_OS_9: 'mac_powerpc', /* Mac OS 9 */
- LINUX : 'linux', /* Linux */
+ LINUX: 'linux', /* Linux */
UBUNTU: 'ubuntu', /* Ubuntu */
IPHONE: 'iphone', /* IPhone */
IPOD: 'ipod', /* IPod */
diff --git a/Message/Request/Request.js b/Message/Request/Request.js
index a59976b..94ac886 100755
--- a/Message/Request/Request.js
+++ b/Message/Request/Request.js
@@ -18,45 +18,60 @@ export class Request
/**
* @constructor
*
- * @param {string} uri Request uri
- * @param {string} method Request method/verb
- * @param {string} type Request content type
+ * @param {null|string} [uri] Request uri
+ * @param {null|string} [method] Request method/verb
+ * @param {null|string} [type] Request content type
*
* @since 1.0.0
*/
- constructor (uri = null, method, type)
+ constructor (uri = null, method = null, type = null)
{
- this.uri = uri;
- this.method = typeof method !== 'undefined' ? method : RequestMethod.GET;
- this.requestHeader = [];
- this.result = {};
- this.type = typeof type !== 'undefined' ? type : RequestType.JSON;
- this.data = {};
+ /** @type {null|string} uri */
+ this.uri = uri;
+
+ /** @type {string} method */
+ this.method = method !== null ? method : RequestMethod.GET;
+
+ /** @type {Object} requestHeader */
+ this.requestHeader = {};
+
+ /** @type {Object} result */
+ this.result = {};
+
+ /** @type {string} type */
+ this.type = type !== null ? type : RequestType.JSON;
+
+ /** @type {Object} data */
+ this.data = {};
this.requestHeader['Content-Type'] = this.setContentTypeBasedOnType(this.type);
if (this.type === RequestType.FORM_DATA) {
delete this.requestHeader['Content-Type'];
}
- this.result[0] = function(xhr)
+ /** @type {XMLHttpRequest} xhr */
+ this.result[0] = function (xhr)
{
Logger.getInstance().info('Unhandled response from "' + xhr.responseURL + '" with response data "' + xhr.response + '"');
};
- /** global: XMLHttpRequest */
+ // global: XMLHttpRequest
+ /** @type {XMLHttpRequest} xhr */
this.xhr = new XMLHttpRequest();
};
/**
* Defines the request content type based on the type
*
+ * @param {string} type Request type
+ *
* @return {string}
*
* @since 1.0.0
*/
- setContentTypeBasedOnType(type)
+ setContentTypeBasedOnType (type)
{
- switch(type) {
+ switch (type) {
case RequestType.JSON:
return 'application/json';
case RequestType.URL_ENCODE:
@@ -77,7 +92,7 @@ export class Request
*
* @since 1.0.0
*/
- static getBrowser()
+ static getBrowser ()
{
/** global: InstallTrigger */
/** global: navigator */
@@ -87,7 +102,7 @@ export class Request
return BrowserType.FIREFOX;
} else if (Object.toString.call(window.HTMLElement).indexOf('Constructor') > 0) {
return BrowserType.SAFARI;
- } else if (/*@cc_on!@*/false || !!document.documentMode) {
+ } else if ( /* @cc_on!@ */false || !!document.documentMode) {
return BrowserType.IE;
} else if (!!window.StyleMedia) {
return BrowserType.EDGE;
@@ -110,10 +125,10 @@ export class Request
*
* @since 1.0.0
*/
- static getOS()
+ static getOS ()
{
for (const os in OSType) {
- if (OSType.hasOwnProperty(os)) {
+ if (Object.prototype.hasOwnProperty.call(OSType, os)) {
/** global: navigator */
if (navigator.appVersion.toLowerCase().indexOf(OSType[os]) !== -1) {
return OSType[os];
@@ -127,15 +142,13 @@ export class Request
/**
* Set request method.
*
- * EnumRequestMethod
- *
* @param {string} method Method type
*
* @return {void}
*
* @since 1.0.0
*/
- setMethod(method)
+ setMethod (method)
{
this.method = method;
};
@@ -149,7 +162,7 @@ export class Request
*
* @since 1.0.0
*/
- getMethod()
+ getMethod ()
{
return this.method;
};
@@ -157,15 +170,13 @@ export class Request
/**
* Set response type.
*
- * EnumResponseType
- *
* @param {string} type Method type
*
* @return {void}
*
* @since 1.0.0
*/
- setResponseType(type)
+ setResponseType (type)
{
this.xhr.responseType = type;
};
@@ -173,13 +184,11 @@ export class Request
/**
* Get response type.
*
- * EnumResponseType
- *
* @return {string}
*
* @since 1.0.0
*/
- getResponseType()
+ getResponseType ()
{
return this.responseType;
};
@@ -194,7 +203,7 @@ export class Request
*
* @since 1.0.0
*/
- setRequestHeader(type, header)
+ setRequestHeader (type, header)
{
this.requestHeader[type] = header;
@@ -206,11 +215,11 @@ export class Request
/**
* Get request header.
*
- * @return {Array}
+ * @return {Object}
*
* @since 1.0.0
*/
- getRequestHeader()
+ getRequestHeader ()
{
return this.requestHeader;
};
@@ -224,7 +233,7 @@ export class Request
*
* @since 1.0.0
*/
- setUri(uri)
+ setUri (uri)
{
this.uri = uri;
};
@@ -232,11 +241,11 @@ export class Request
/**
* Get request uri.
*
- * @return {string}
+ * @return {null|string}
*
* @since 1.0.0
*/
- getUri()
+ getUri ()
{
return this.uri;
};
@@ -244,13 +253,13 @@ export class Request
/**
* Set success callback.
*
- * @param {requestCallback} callback - Success callback
+ * @param {function} callback - Success callback
*
* @return {void}
*
* @since 1.0.0
*/
- setSuccess(callback)
+ setSuccess (callback)
{
this.result[200] = callback;
};
@@ -258,14 +267,14 @@ export class Request
/**
* Set result callback.
*
- * @param {int} status Http response status
+ * @param {number} status Http response status
* @param {function} callback Callback
*
* @return {void}
*
* @since 1.0.0
*/
- setResultCallback(status, callback)
+ setResultCallback (status, callback)
{
this.result[status] = callback;
};
@@ -273,13 +282,13 @@ export class Request
/**
* Set request data.
*
- * @param {Array} data Request data
+ * @param {Object} data Request data
*
* @return {void}
*
* @since 1.0.0
*/
- setData(data)
+ setData (data)
{
this.data = data;
};
@@ -287,11 +296,11 @@ export class Request
/**
* Get request data.
*
- * @return {Array}
+ * @return {Object}
*
* @since 1.0.0
*/
- getData()
+ getData ()
{
return this.data;
};
@@ -299,15 +308,13 @@ export class Request
/**
* Set request type.
*
- * EnumRequestType
- *
* @param {string} type Method type
*
* @return {void}
*
* @since 1.0.0
*/
- setType(type)
+ setType (type)
{
this.type = type;
this.requestHeader['Content-Type'] = this.setContentTypeBasedOnType(this.type);
@@ -320,13 +327,11 @@ export class Request
/**
* Get request type.
*
- * EnumRequestType
- *
* @return {string}
*
* @since 1.0.0
*/
- getType()
+ getType ()
{
return this.type;
};
@@ -334,30 +339,32 @@ export class Request
/**
* Create query from object.
*
+ * @param {Object} obj Object to turn into uri query
+ *
* @return {string}
*
* @since 1.0.0
*/
- queryfy(obj)
+ queryfy (obj)
{
const str = [];
for (const p in obj) {
- if (obj.hasOwnProperty(p)) {
- str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
+ if (Object.prototype.hasOwnProperty.call(obj, p)) {
+ str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
}
}
- return str.join("&");
+ return str.join('&');
};
/**
- * Get request data.
+ * Send request.
*
- * @return {Array}
+ * @return {void}
*
* @since 1.0.0
*/
- send()
+ send ()
{
if (this.uri === '') {
return;
@@ -369,7 +376,7 @@ export class Request
this.xhr.open(this.method, UriFactory.build(this.uri));
for (const p in this.requestHeader) {
- if (this.requestHeader.hasOwnProperty(p) && this.requestHeader[p] !== '') {
+ if (Object.prototype.hasOwnProperty.call(this.requestHeader, p) && this.requestHeader[p] !== '') {
this.xhr.setRequestHeader(p, this.requestHeader[p]);
}
}
@@ -378,7 +385,7 @@ export class Request
console.log(UriFactory.build(this.uri));
console.log(this.xhr);
- this.xhr.onreadystatechange = function()
+ this.xhr.onreadystatechange = function ()
{
switch (self.xhr.readyState) {
case 4:
diff --git a/Message/Response/Response.js b/Message/Response/Response.js
index 1c4d796..94fe8cc 100755
--- a/Message/Response/Response.js
+++ b/Message/Response/Response.js
@@ -13,33 +13,34 @@ export class Response
/**
* @constructor
*
- * @param {mixed} data Response data
+ * @param {Object} data Response data
*
* @since 1.0.0
*/
constructor (data)
{
+ /** @type {Object} responses */
this.responses = data;
};
/**
* Get response by id.
*
- * @param {string} id Response id
+ * @param {null|string} [id] Response id
*
- * @return {mixed}
+ * @return {any}
*
* @since 1.0.0
*/
- get (id)
+ get (id = null)
{
- return typeof id === 'undefined' ? this.responses : this.responses[id];
+ return id === null ? this.responses : this.responses[id];
};
/**
* Count the amount of responses.
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
@@ -47,4 +48,4 @@ export class Response
{
return this.responses.length;
};
-};
\ No newline at end of file
+};
diff --git a/Message/Response/ResponseManager.js b/Message/Response/ResponseManager.js
index 8e121a9..e012ae0 100755
--- a/Message/Response/ResponseManager.js
+++ b/Message/Response/ResponseManager.js
@@ -1,3 +1,5 @@
+import { Request } from '../Request/Request.js';
+
/**
* Response manager class.
*
@@ -15,8 +17,9 @@ export class ResponseManager
*
* @since 1.0.0
*/
- constructor()
+ constructor ()
{
+ /** @type {Object} messages */
this.messages = {};
};
@@ -25,15 +28,15 @@ export class ResponseManager
*
* This allows the response handler to generally handle responses and also handle specific requests if defined.
*
- * @param {string} key Response key
- * @param {requestCallback} message Callback for message
- * @param {string} [request] Request id in order to only handle a specific request
+ * @param {string} key Response key
+ * @param {function} message Callback for message
+ * @param {null|string} [request] Request id in order to only handle a specific request
*
* @return {void}
*
* @since 1.0.0
*/
- add(key, message, request)
+ add (key, message, request = null)
{
request = typeof request !== 'undefined' ? request : 'any';
if (typeof this.messages[key] === 'undefined') {
@@ -48,17 +51,20 @@ export class ResponseManager
*
* Tries to execute a request specific callback or otherwise a general callback if defined.
*
- * @param {string} key Response key
- * @param {Array|Object} data Date to use in callback
- * @param {jsOMS.Message.Request.Request} [request] Request id for request specific execution
+ * @param {string} key Response key
+ * @param {Object} data Date to use in callback
+ * @param {null|Request} [request] Request id for request specific execution
*
* @return {void}
*
* @since 1.0.0
*/
- run(key, data, request)
+ run (key, data, request = null)
{
- if (typeof request !== 'undefined' && typeof this.messages[key] !== 'undefined' && typeof this.messages[key][request] !== 'undefined') {
+ if (request !== null
+ && typeof this.messages[key] !== 'undefined'
+ && typeof this.messages[key][request] !== 'undefined'
+ ) {
this.messages[key][request](data);
} else if (typeof this.messages[key] !== 'undefined') {
this.messages[key].any(data);
diff --git a/Model/Action/Dom/Click.js b/Model/Action/Dom/Click.js
index e6dc1a3..311529d 100755
--- a/Model/Action/Dom/Click.js
+++ b/Model/Action/Dom/Click.js
@@ -9,9 +9,13 @@
*/
export function domClickAction (action, callback, id)
{
- "use strict";
+ 'use strict';
- const click = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
+ const click = action.base === 'self'
+ ? (action.selector === ''
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
if (!click) {
return;
@@ -22,4 +26,4 @@ export function domClickAction (action, callback, id)
}
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/Datalist/Append.js b/Model/Action/Dom/Datalist/Append.js
index 9c832ff..5f098d3 100755
--- a/Model/Action/Dom/Datalist/Append.js
+++ b/Model/Action/Dom/Datalist/Append.js
@@ -8,10 +8,10 @@
*/
export function datalistAppend (action, callback)
{
- "use strict";
+ 'use strict';
- const datalist = document.getElementById(action.id),
- dataLength = action.data.length;
+ const datalist = document.getElementById(action.id);
+ const dataLength = action.data.length;
let option;
diff --git a/Model/Action/Dom/Datalist/Clear.js b/Model/Action/Dom/Datalist/Clear.js
index 46795ed..bd0bba2 100755
--- a/Model/Action/Dom/Datalist/Clear.js
+++ b/Model/Action/Dom/Datalist/Clear.js
@@ -8,7 +8,7 @@
*/
export function datalistClear (action, callback)
{
- "use strict";
+ 'use strict';
const e = document.getElementById(action.id);
diff --git a/Model/Action/Dom/Focus.js b/Model/Action/Dom/Focus.js
index 8ff1227..f1a5daf 100755
--- a/Model/Action/Dom/Focus.js
+++ b/Model/Action/Dom/Focus.js
@@ -8,7 +8,7 @@
*/
export function focusAction (action, callback)
{
- "use strict";
+ 'use strict';
const focus = document.getElementById(action.id);
@@ -19,4 +19,4 @@ export function focusAction (action, callback)
focus.focus();
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/FormSubmit.js b/Model/Action/Dom/FormSubmit.js
index a5cfb2b..dea2401 100755
--- a/Model/Action/Dom/FormSubmit.js
+++ b/Model/Action/Dom/FormSubmit.js
@@ -9,7 +9,7 @@
*/
export function formSubmitAction (action, callback, id)
{
- "use strict";
+ 'use strict';
const submit = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
@@ -24,4 +24,4 @@ export function formSubmitAction (action, callback, id)
}
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/GetValue.js b/Model/Action/Dom/GetValue.js
index e9136c3..74da4d8 100755
--- a/Model/Action/Dom/GetValue.js
+++ b/Model/Action/Dom/GetValue.js
@@ -9,22 +9,32 @@
*/
export function domGetValue (action, callback, id)
{
- "use strict";
+ 'use strict';
+
+ const e = action.base === 'self'
+ ? (action.selector === '' || typeof action.selector === 'undefined'
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
- const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
let value = {};
for (const i in e) {
/** global: HTMLElement */
- if (!e.hasOwnProperty(i) || !(e[i] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(e, i) || !(e[i] instanceof HTMLElement)) {
continue;
}
- let eId = (typeof e[i].getAttribute('name') !== 'undefined' && e[i].getAttribute('name') !== '' && e[i].getAttribute('name') !== null) ? e[i].getAttribute('name') : e[i].getAttribute('id');
+ const eId = (typeof e[i].getAttribute('name') !== 'undefined' && e[i].getAttribute('name') !== '' && e[i].getAttribute('name') !== null)
+ ? e[i].getAttribute('name')
+ : e[i].getAttribute('id');
- if (e[i].tagName === 'INPUT' || e[i].tagName === 'SELECTS' || e[i].tagName === 'BUTTON') {
+ if (e[i].tagName.toLowerCase() === 'input'
+ || e[i].tagName.toLowerCase() === 'selects'
+ || e[i].tagName.toLowerCase() === 'button'
+ ) {
value[eId] = e[i].getAttribute('value');
- } else if (e[i].tagName === 'FORM') {
+ } else if (e[i].tagName.toLowerCase() === 'form') {
value = window.omsApp.uiManager.getFormManager().get(eId).getData();
break;
} else {
@@ -33,4 +43,4 @@ export function domGetValue (action, callback, id)
}
callback(value);
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/Hide.js b/Model/Action/Dom/Hide.js
index d46b2d9..3c5320f 100755
--- a/Model/Action/Dom/Hide.js
+++ b/Model/Action/Dom/Hide.js
@@ -8,7 +8,7 @@
*/
export function hideAction (action, callback)
{
- "use strict";
+ 'use strict';
const hide = document.getElementById(action.id);
@@ -20,4 +20,4 @@ export function hideAction (action, callback)
jsOMS.addClass(hide, 'vh');
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/Popup.js b/Model/Action/Dom/Popup.js
index 4e19d87..9643eb0 100755
--- a/Model/Action/Dom/Popup.js
+++ b/Model/Action/Dom/Popup.js
@@ -9,13 +9,17 @@
*/
export function popupButtonAction (action, callback, id)
{
- "use strict";
+ 'use strict';
- const popup = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
+ const popup = action.base === 'self'
+ ? (action.selector === ''
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
for (const i in popup) {
/** global: HTMLElement */
- if (!popup.hasOwnProperty(i) || !popup[i] || !(popup[i] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(popup, i) || !popup[i] || !(popup[i] instanceof HTMLElement)) {
continue;
}
@@ -27,7 +31,7 @@ export function popupButtonAction (action, callback, id)
}
for (const j in clone) {
- if (!clone.hasOwnProperty(j) || !(clone[j] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(clone, j) || !(clone[j] instanceof HTMLElement)) {
continue;
}
@@ -36,7 +40,7 @@ export function popupButtonAction (action, callback, id)
document.body.insertBefore(clone, document.body.firstChild);
- let e = document.getElementById(popup[i].id.substr(0, popup[i].id.length - 4));
+ const e = document.getElementById(popup[i].id.substr(0, popup[i].id.length - 4));
if (!e) {
continue;
diff --git a/Model/Action/Dom/Reload.js b/Model/Action/Dom/Reload.js
index 6fc8af8..eabae4e 100755
--- a/Model/Action/Dom/Reload.js
+++ b/Model/Action/Dom/Reload.js
@@ -9,7 +9,7 @@
*/
export function reloadButtonAction (action, callback, id)
{
- "use strict";
+ 'use strict';
setTimeout(function () {
document.location.reload(true);
diff --git a/Model/Action/Dom/Remove.js b/Model/Action/Dom/Remove.js
index 548dfe5..f8b92aa 100755
--- a/Model/Action/Dom/Remove.js
+++ b/Model/Action/Dom/Remove.js
@@ -9,14 +9,19 @@
*/
export function removeButtonAction (action, callback, id)
{
- "use strict";
+ 'use strict';
+
+ const e = action.base === 'self'
+ ? (action.selector === '' || typeof action.selector === 'undefined'
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
- const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
const dim = document.getElementById('dim');
for (const i in e) {
/** global: HTMLElement */
- if (!e.hasOwnProperty(i) || !e[i] || !(e[i] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(e, i) || !e[i] || !(e[i] instanceof HTMLElement)) {
continue;
}
diff --git a/Model/Action/Dom/RemoveValue.js b/Model/Action/Dom/RemoveValue.js
index 97578da..22b8119 100755
--- a/Model/Action/Dom/RemoveValue.js
+++ b/Model/Action/Dom/RemoveValue.js
@@ -9,13 +9,17 @@
*/
export function domRemoveValue (action, callback, id)
{
- "use strict";
+ 'use strict';
- const e = action.base === 'self' ? (action.selector === '' || typeof action.selector === 'undefined' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
+ const e = action.base === 'self'
+ ? (action.selector === '' || typeof action.selector === 'undefined'
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
for (const i in e) {
/** global: HTMLElement */
- if (!e.hasOwnProperty(i) || !(e[i] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(e, i) || !(e[i] instanceof HTMLElement)) {
continue;
}
@@ -35,4 +39,4 @@ export function domRemoveValue (action, callback, id)
}
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/SetValue.js b/Model/Action/Dom/SetValue.js
index 89010f2..2e2489f 100755
--- a/Model/Action/Dom/SetValue.js
+++ b/Model/Action/Dom/SetValue.js
@@ -9,15 +9,14 @@
*/
export function domSetValue (action, callback, id)
{
- "use strict";
+ 'use strict';
- let dataPath = action['value'],
- path = '',
- tempDataValue = '',
- values = [],
- replaceText = '',
- start = 0,
- end = 0;
+ let dataPath = action.value;
+ let path = '';
+ let tempDataValue = '';
+ let replaceText = '';
+ let start = 0;
+ let end = 0;
while ((start = dataPath.indexOf('{', start)) !== -1) {
end = dataPath.indexOf('}', start);
@@ -31,11 +30,15 @@ export function domSetValue (action, callback, id)
dataPath = dataPath.replace(new RegExp(replaceText.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), tempDataValue);
}
- const fill = action.base === 'self' ? (action.selector === '' ? [document.getElementById(id)] : document.getElementById(id).querySelectorAll(action.selector)) : document.querySelectorAll(action.selector);
+ const fill = action.base === 'self'
+ ? (action.selector === ''
+ ? [document.getElementById(id)]
+ : document.getElementById(id).querySelectorAll(action.selector))
+ : document.querySelectorAll(action.selector);
for (const i in fill) {
/** global: HTMLElement */
- if (!fill.hasOwnProperty(i) || !(fill[i] instanceof HTMLElement)) {
+ if (!Object.prototype.hasOwnProperty.call(fill, i) || !(fill[i] instanceof HTMLElement)) {
continue;
}
@@ -65,4 +68,4 @@ export function domSetValue (action, callback, id)
}
callback(action.data);
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/Show.js b/Model/Action/Dom/Show.js
index 6211321..a88ca9b 100755
--- a/Model/Action/Dom/Show.js
+++ b/Model/Action/Dom/Show.js
@@ -9,7 +9,7 @@
*/
export function showAction (action, callback, id)
{
- "use strict";
+ 'use strict';
const show = document.getElementById(action.id);
@@ -21,4 +21,4 @@ export function showAction (action, callback, id)
jsOMS.removeClass(show, 'vh');
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Dom/Table/Append.js b/Model/Action/Dom/Table/Append.js
index 5bd99ab..f5dfe8d 100755
--- a/Model/Action/Dom/Table/Append.js
+++ b/Model/Action/Dom/Table/Append.js
@@ -8,15 +8,17 @@
*/
export function tableAppend (action, callback)
{
- "use strict";
+ 'use strict';
- const table = document.getElementById(action.id),
- tbody = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('tbody')[0] : null,
- headers = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('thead')[0].getElementsByTagName('th') : null,
- dataLength = action.data.length,
- headerLength = headers !== null && typeof headers !== 'undefined' ? headers.length : 0;
+ const table = document.getElementById(action.id);
+ const tbody = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('tbody')[0] : null;
+ const headers = table !== null && typeof table !== 'undefined' ? table.getElementsByTagName('thead')[0].getElementsByTagName('th') : null;
+ const dataLength = action.data.length;
+ const headerLength = headers !== null && typeof headers !== 'undefined' ? headers.length : 0;
- let row, cell, text, rawText;
+ let row;
+ let cell;
+ let rawText;
for (let i = 0; i < dataLength; ++i) {
if (tbody === null) {
diff --git a/Model/Action/Dom/Table/Clear.js b/Model/Action/Dom/Table/Clear.js
index b0a967f..b3034ab 100755
--- a/Model/Action/Dom/Table/Clear.js
+++ b/Model/Action/Dom/Table/Clear.js
@@ -8,7 +8,7 @@
*/
export function tableClear (action, callback)
{
- "use strict";
+ 'use strict';
const e = document.getElementById(action.id).getElementsByTagName('tbody')[0];
diff --git a/Model/Action/Event/Prevent.js b/Model/Action/Event/Prevent.js
index 00fe5f4..81ac9fd 100755
--- a/Model/Action/Event/Prevent.js
+++ b/Model/Action/Event/Prevent.js
@@ -9,11 +9,11 @@
*/
export function preventEvent (action, callback, id)
{
- "use strict";
+ 'use strict';
console.log('prevented');
jsOMS.preventAll(action.data);
callback();
-};
\ No newline at end of file
+};
diff --git a/Model/Action/Message/Log.js b/Model/Action/Message/Log.js
index d4d26ed..fea4e4d 100755
--- a/Model/Action/Message/Log.js
+++ b/Model/Action/Message/Log.js
@@ -1,26 +1,26 @@
-import { NotificationMessage } from '../../../Message/Notification/NotificationMessage.js';
-import { NotificationType } from '../../../Message/Notification/NotificationType.js';
-
-/**
- * Log.
- *
- * @param {Object} action Action data
- * @param {function} callback Callback
- * @param {string} id Action element
- *
- * @since 1.0.0
- */
-export function logAction (action, callback, id)
-{
- "use strict";
-
- window.omsApp.notifyManager.send(
- new NotificationMessage(
- action.data.status,
- action.data.title,
- action.data.message
- ), NotificationType.APP_NOTIFICATION
- );
-
- callback();
-};
+import { NotificationMessage } from '../../../Message/Notification/NotificationMessage.js';
+import { NotificationType } from '../../../Message/Notification/NotificationType.js';
+
+/**
+ * Log.
+ *
+ * @param {Object} action Action data
+ * @param {function} callback Callback
+ * @param {string} id Action element
+ *
+ * @since 1.0.0
+ */
+export function logAction (action, callback, id)
+{
+ 'use strict';
+
+ window.omsApp.notifyManager.send(
+ new NotificationMessage(
+ action.data.status,
+ action.data.title,
+ action.data.message
+ ), NotificationType.APP_NOTIFICATION
+ );
+
+ callback();
+};
diff --git a/Model/Action/Message/Request.js b/Model/Action/Message/Request.js
index 36704d9..8d64e1a 100755
--- a/Model/Action/Message/Request.js
+++ b/Model/Action/Message/Request.js
@@ -10,12 +10,12 @@ import { Request } from '../../../Message/Request/Request.js';
*/
export function requestAction (action, callback)
{
- "use strict";
+ 'use strict';
/** global: jsOMS */
const request = new Request(action.uri, action.method, action.request_type);
- request.setSuccess(function(xhr) {
+ request.setSuccess(function (xhr) {
console.log(xhr.responseText);
callback(JSON.parse(xhr.responseText));
});
diff --git a/Model/Action/Utils/DataCollector.js b/Model/Action/Utils/DataCollector.js
index ee907d1..04cd446 100755
--- a/Model/Action/Utils/DataCollector.js
+++ b/Model/Action/Utils/DataCollector.js
@@ -8,19 +8,20 @@
*/
export function dataCollectionAction (action, callback)
{
- "use strict";
+ 'use strict';
- let elements, data = {};
+ let elements;
+ const data = {};
for (const selector in action.collect) {
- if (!action.collect.hasOwnProperty(selector)) {
+ if (!Object.prototype.hasOwnProperty.call(action.collect, selector)) {
continue;
}
elements = document.querySelectorAll(action.collect[selector]);
for (const e in elements) {
- if (!elements.hasOwnProperty(e)) {
+ if (!Object.prototype.hasOwnProperty.call(elements, e)) {
continue;
}
diff --git a/Model/Action/Utils/Timer.js b/Model/Action/Utils/Timer.js
index d870247..fb42515 100755
--- a/Model/Action/Utils/Timer.js
+++ b/Model/Action/Utils/Timer.js
@@ -9,14 +9,14 @@
const timerActionDelay = {};
export function timerAction (action, callback, data)
{
- "use strict";
+ 'use strict';
if (timerActionDelay[action.id]) {
clearTimeout(timerActionDelay[action.id]);
- delete timerActionDelay[action.id]
+ delete timerActionDelay[action.id];
}
- timerActionDelay[action.id] = setTimeout(function() {
+ timerActionDelay[action.id] = setTimeout(function () {
delete timerActionDelay[action.id];
callback(data);
}, action.delay);
diff --git a/Model/Action/Validate/Keypress.js b/Model/Action/Validate/Keypress.js
index 782a7d9..4c7d91f 100755
--- a/Model/Action/Validate/Keypress.js
+++ b/Model/Action/Validate/Keypress.js
@@ -8,10 +8,10 @@
*/
export function validateKeypress (action, callback)
{
- "use strict";
+ 'use strict';
- const invertValidate = action.pressed.startsWith('!'),
- keyPressCheck = invertValidate ? action.pressed.split('!') : action.pressed.split('|');
+ const invertValidate = action.pressed.startsWith('!');
+ const keyPressCheck = invertValidate ? action.pressed.split('!') : action.pressed.split('|');
if (typeof action.data.keyCode !== 'undefined'
&& ((!invertValidate && keyPressCheck.indexOf(action.data.keyCode.toString()) !== -1)
diff --git a/Model/Message/DomAction.js b/Model/Message/DomAction.js
index 86fe19a..1f30098 100755
--- a/Model/Message/DomAction.js
+++ b/Model/Message/DomAction.js
@@ -24,4 +24,4 @@ export function domAction (data)
* identifier: #element or .elements or query
* anim: someclass
* delay: 0
- */
\ No newline at end of file
+ */
diff --git a/Model/Message/FormValidation.js b/Model/Message/FormValidation.js
index 41535c0..80943a4 100755
--- a/Model/Message/FormValidation.js
+++ b/Model/Message/FormValidation.js
@@ -16,7 +16,7 @@ export function formValidationMessage (data) {
while (eEles.length > 0) {
eEles[0].parentNode.removeChild(eEles[0]);
- }
+ };
/**
* @param {{msg:string}} error Error data
@@ -28,8 +28,8 @@ export function formValidationMessage (data) {
return;
}
- const msgEle = document.createElement('i'),
- msg = document.createTextNode(error.msg);
+ const msgEle = document.createElement('i');
+ const msg = document.createTextNode(error.msg);
msgEle.id = 'i-' + error.id;
msgEle.class = 'i-' + data.form;
diff --git a/Model/Message/Notify.js b/Model/Message/Notify.js
index e12070f..f5e6d2c 100755
--- a/Model/Message/Notify.js
+++ b/Model/Message/Notify.js
@@ -9,11 +9,11 @@ export function notifyMessage (data)
{
setTimeout(function ()
{
- const notify = document.createElement('div'),
- h = document.createElement('h1'),
- inner = document.createElement('div'),
- title = document.createTextNode(data.title),
- content = document.createTextNode(data.msg);
+ const notify = document.createElement('div');
+ const h = document.createElement('h1');
+ const inner = document.createElement('div');
+ const title = document.createTextNode(data.title);
+ const content = document.createTextNode(data.msg);
notify.id = 'notify';
notify.class = data.level;
diff --git a/Model/Message/NotifyType.js b/Model/Message/NotifyType.js
index 9cc6195..fd8fde6 100755
--- a/Model/Message/NotifyType.js
+++ b/Model/Message/NotifyType.js
@@ -13,4 +13,3 @@ export const EnumNotifyType = Object.freeze({
ERROR: 3,
FATAL: 4
});
-
diff --git a/Module/ModuleManager.js b/Module/ModuleManager.js
index 5d85762..48583e4 100755
--- a/Module/ModuleManager.js
+++ b/Module/ModuleManager.js
@@ -16,7 +16,7 @@ export class ModuleManager
*
* @since 1.0.0
*/
- constructor(app)
+ constructor (app)
{
this.modules = {};
this.app = app;
@@ -39,4 +39,4 @@ export class ModuleManager
return this.modules[module];
};
-};
\ No newline at end of file
+};
diff --git a/Route/Route.js b/Route/Route.js
deleted file mode 100755
index e59d610..0000000
--- a/Route/Route.js
+++ /dev/null
@@ -1,18 +0,0 @@
-(function (jsOMS) {
- "use strict";
-
- jsOMS.Autoloader.defineNamespace('jsOMS.Route');
-
- jsOMS.Route.Route = class {
- constructor ()
- {
- this.routes = null;
- };
-
- add (path, callback, exact)
- {
- exact = typeof exact !== 'undefined' ? exact : true;
-
- };
- }
-}(window.jsOMS = window.jsOMS || {}));
diff --git a/Socket/Client/Client.js b/Socket/Client/Client.js
index 2492fb6..f51eecf 100755
--- a/Socket/Client/Client.js
+++ b/Socket/Client/Client.js
@@ -1,5 +1,5 @@
(function (jsOMS) {
- "use strict";
+ 'use strict';
jsOMS.Client = function (ip, port, protocol) {
this.port = port;
@@ -9,38 +9,38 @@
this.messages = [];
};
- jsOMS.Client.prototype.setMessage = function(id, callback) {
+ jsOMS.Client.prototype.setMessage = function (id, callback) {
this.messages[id] = callback;
};
- jsOMS.Client.prototype.setIp = function(ip) {
+ jsOMS.Client.prototype.setIp = function (ip) {
this.ip = ip;
};
- jsOMS.Client.prototype.setPort = function(port) {
+ jsOMS.Client.prototype.setPort = function (port) {
this.port = port;
};
- jsOMS.Client.prototype.setProtocol = function(protocol) {
+ jsOMS.Client.prototype.setProtocol = function (protocol) {
this.protocol = protocol;
};
- jsOMS.Client.prototype.connect = function() {
+ jsOMS.Client.prototype.connect = function () {
var self = this;
this.connection = new WebSocket(this.ip, this.protocol);
- this.connection.onmessage = function(event) {
+ this.connection.onmessage = function (event) {
var msg = JSON.parse(event.data);
self.messages[msg.type](msg);
};
};
- jsOMS.Client.prototype.send = function(msg) {
+ jsOMS.Client.prototype.send = function (msg) {
this.connection.send(JSON.stringify(msg));
};
- jsOMS.Client.prototype.close = function() {
+ jsOMS.Client.prototype.close = function () {
this.connection.close();
};
}(window.jsOMS = window.jsOMS || {}));
diff --git a/Spreadsheet/Cell.js b/Spreadsheet/Cell.js
deleted file mode 100755
index 0708fa1..0000000
--- a/Spreadsheet/Cell.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * Cell.
- *
- * @copyright Dennis Eichhorn
- * @license OMS License 1.0
- * @version 1.0.0
- * @since 1.0.0
- */
-(function (jsOMS)
-{
- "use strict";
- /** @namespace jsOMS.Spreadsheet */
- jsOMS.Autoloader.defineNamespace('jsOMS.Spreadsheet');
-
- jsOMS.Spreadsheet.Cell = function(id, raw)
- {
- this.id = id;
- this.raw = raw;
- this.formatting = raw.formatting;
- };
-}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
diff --git a/Spreadsheet/Formatting.js b/Spreadsheet/Formatting.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Spreadsheet/Functions.js b/Spreadsheet/Functions.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Spreadsheet/Sheet.js b/Spreadsheet/Sheet.js
deleted file mode 100755
index e69de29..0000000
diff --git a/Spreadsheet/Spreadsheet.js b/Spreadsheet/Spreadsheet.js
deleted file mode 100755
index fb062c0..0000000
--- a/Spreadsheet/Spreadsheet.js
+++ /dev/null
@@ -1,50 +0,0 @@
-/**
- * Spreadsheet view.
- *
- * @copyright Dennis Eichhorn
- * @license OMS License 1.0
- * @version 1.0.0
- * @since 1.0.0
- */
-(function (jsOMS)
-{
- "use strict";
- /** @namespace jsOMS.Spreadsheet */
- jsOMS.Autoloader.defineNamespace('jsOMS.Spreadsheet');
-
- jsOMS.Spreadsheet.Spreadsheet = function(id, dataset, options)
- {
- this.spreadsheet = document.getElementById(id);
- this.title = '';
- this.sheets = [];
- this.columns = true;
- this.rows = true;
- this.dataset = [];
- this.compiledData = [];
- this.scroll = {h: false, v: false};
- };
-
- jsOMS.SpreadSheet.prototype.draw = function()
- {
- let col = 0,
- row = 0,
- cRows = this.dataset.length(),
- cCols = 0;
- j = 0,
- this.compiledData = this.dataset;
-
- for (let i = 0; i < cRows; ++i) {
- cCols = this.compiledData[i].length();
-
- for (j = 0; j < cCols; ++j) {
- this.compiledData[i][j] = Functions.evaluate(this.compiledData[i][j], compiledData);
-
- this.drawCell(this.compiledData[i][j]);
- }
- }
- };
-
- jsOMS.SpreadSheet.prototype.drawCell = function()
- {
- };
-}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
diff --git a/UI/ActionManager.js b/UI/ActionManager.js
index 4a5fc1c..5efeb7d 100755
--- a/UI/ActionManager.js
+++ b/UI/ActionManager.js
@@ -34,7 +34,7 @@ export class ActionManager
*
* @since 1.0.0
*/
- constructor(app)
+ constructor (app)
{
this.logger = Logger.getInstance();
this.app = app;
@@ -44,16 +44,16 @@ export class ActionManager
/**
* Bind element.
*
- * @param {string} [id] Element id (optional)
+ * @param {null|string} [id] Element id (optional)
*
* @return {void}
*
* @since 1.0.0
*/
- bind(id)
+ bind (id = null)
{
- const uiElements = typeof id === 'undefined' ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]),
- length = uiElements.length;
+ const uiElements = id == null ? document.querySelectorAll('[data-action]') : (typeof id.length !== 'undefined' ? id : [id]);
+ const length = uiElements.length;
for (let i = 0; i < length; ++i) {
if (uiElements[i] !== null && uiElements[i].hasAttribute('data-action')) {
@@ -79,21 +79,22 @@ export class ActionManager
return;
}
- const listeners = JSON.parse(e.getAttribute('data-action')),
- listenerLength = listeners.length,
- self = this;
+ const listeners = JSON.parse(e.getAttribute('data-action'));
+ const listenerLength = listeners.length;
+ const self = this;
// For every action an event is registered
for (let i = 0; i < listenerLength; ++i) {
- let c = [e], hasSelector = false;
+ let c = [e];
+ let hasSelector = false;
// the selector must be a child of e!!!
- if (listeners[i].hasOwnProperty('selector')) {
+ if (Object.prototype.hasOwnProperty.call(listeners[i], 'selector')) {
c = document.querySelectorAll(listeners[i].selector);
hasSelector = true;
}
- let childLength = c.length;
+ const childLength = c.length;
for (let j = 0; j < childLength; ++j) {
this.bindListener(c[j].id, listeners[i]);
}
@@ -108,7 +109,7 @@ export class ActionManager
const observeConfig = { childList: false, attributes: true, subtree: false };
if (hasSelector) {
- this.app.eventManager.attach(e.id + '-childList', function(data) {
+ this.app.eventManager.attach(e.id + '-childList', function (data) {
const length = data.addedNodes.length;
for (let j = 0; j < length; ++j) {
@@ -124,7 +125,7 @@ export class ActionManager
observeConfig.subtree = true;
}
- this.app.eventManager.attach(e.id + '-attributes', function(data) {});
+ this.app.eventManager.attach(e.id + '-attributes', function (data) {});
this.app.uiManager.getDOMObserver().observe(e, observeConfig);
}
};
@@ -141,8 +142,8 @@ export class ActionManager
*/
bindListener (id, listener, removable = false)
{
- const self = this,
- actionLength = listener.action.length;
+ const self = this;
+ const actionLength = listener.action.length;
for (let j = 1; j < actionLength; ++j) {
if (typeof id === 'undefined' || typeof listener.key === 'undefined') {
@@ -187,7 +188,7 @@ export class ActionManager
{
const self = this;
- if (!this.actions.hasOwnProperty(action.type)) {
+ if (!Object.prototype.hasOwnProperty.call(this.actions, action.type)) {
this.logger.warning('Undefined action ' + action.type);
return;
}
@@ -214,4 +215,4 @@ export class ActionManager
{
this.actions[name] = callback;
};
-};
\ No newline at end of file
+};
diff --git a/UI/Component/AdvancedInput.js b/UI/Component/AdvancedInput.js
index b46986c..c1d25da 100755
--- a/UI/Component/AdvancedInput.js
+++ b/UI/Component/AdvancedInput.js
@@ -1,4 +1,5 @@
import { Request } from '../../Message/Request/Request.js';
+import { EventManager } from '../../Event/EventManager.js';
/**
* Advanced input class.
@@ -13,14 +14,20 @@ export class AdvancedInput
/**
* @constructor
*
- * @param {Object} e Element to bind
+ * @param {Element} e Element to bind
+ * @param {EventManager} eventManager Event manager
+ * @param {Object} observer Observer
*
* @since 1.0.0
*/
constructor (e, eventManager, observer)
{
- this.id = e.id;
- this.inputComponent = e;
+ /** @type {string} id */
+ this.id = e.id;
+
+ /** @type {Element} e */
+ this.inputComponent = e;
+
this.inputField = this.inputComponent.getElementsByClassName('input')[0];
this.dropdownElement = document.getElementById(this.id + '-popup');
this.tagElement = document.getElementById(this.id + '-tags');
@@ -31,23 +38,23 @@ export class AdvancedInput
this.src = this.inputField.getAttribute('data-src');
const self = this;
- this.inputField.addEventListener('focusout', function(e) {
+ this.inputField.addEventListener('focusout', function (e) {
/**
* @todo Karaka/Modules#63
* If you click anything outside of the input element the dropdown list closes.
* This is also true if you click something inside of the dropdown list e.g. sort/filter etc.
* This might be fixable by changing the focus from the input element to the dropdown element and keep the dropdown element visible if it has focus.
*/
- if (e.relatedTarget === null ||
- e.relatedTarget.parentElement === null ||
- e.relatedTarget.parentElement.parentElement === null ||
- !jsOMS.hasClass(e.relatedTarget.parentElement.parentElement.parentElement, 'popup')
+ if (e.relatedTarget === null
+ || e.relatedTarget.parentElement === null
+ || e.relatedTarget.parentElement.parentElement === null
+ || !jsOMS.hasClass(e.relatedTarget.parentElement.parentElement.parentElement, 'popup')
) {
jsOMS.removeClass(self.dropdownElement, 'active');
}
});
- this.inputField.addEventListener('keydown', function(e) {
+ this.inputField.addEventListener('keydown', function (e) {
if (e.keyCode === 13 || e.keyCode === 40) {
jsOMS.preventAll(e);
}
@@ -58,15 +65,15 @@ export class AdvancedInput
jsOMS.preventAll(e);
} else {
// handle change delay
- self.inputTimeDelay({id: self.id, delay: 300}, self.changeCallback, self, e);
+ self.inputTimeDelay({ id: self.id, delay: 300 }, self.changeCallback, self, e);
}
});
- this.inputField.addEventListener('focusin', function(e) {
+ this.inputField.addEventListener('focusin', function (e) {
jsOMS.addClass(self.dropdownElement, 'active');
});
- this.dropdownElement.addEventListener('keydown', function(e) {
+ this.dropdownElement.addEventListener('keydown', function (e) {
jsOMS.preventAll(e);
/**
@@ -99,12 +106,12 @@ export class AdvancedInput
}
});
- this.dropdownElement.addEventListener('focusout', function(e) {
+ this.dropdownElement.addEventListener('focusout', function (e) {
self.clearDataListSelection(self);
jsOMS.removeClass(self.dropdownElement, 'active');
});
- this.dropdownElement.addEventListener('click', function(e) {
+ this.dropdownElement.addEventListener('click', function (e) {
if (document.activeElement.tagName.toLowerCase() !== 'tr') {
return;
}
@@ -115,7 +122,7 @@ export class AdvancedInput
});
observer.observe(this.tagElement, { childList: true, attributes: false, subtree: false });
- eventManager.attach(this.id + '-tags-childList', function(data) {
+ eventManager.attach(this.id + '-tags-childList', function (data) {
const removes = data.target.querySelectorAll('.fa-times');
const removesLength = removes === null ? 0 : removes.length;
@@ -123,7 +130,7 @@ export class AdvancedInput
return;
}
- removes[removesLength - 1].addEventListener('click', function(e) {
+ removes[removesLength - 1].addEventListener('click', function (e) {
if (e.target.parentNode.parentNode === null) {
return;
}
@@ -131,7 +138,6 @@ export class AdvancedInput
e.target.parentNode.parentNode.removeChild(e.target.parentNode);
});
});
-
};
/**
@@ -139,14 +145,14 @@ export class AdvancedInput
*
* This method adds remote results to the dropdown list for selecting
*
- * @param {Object} self This reference
- * @param {Object} data Response data
+ * @param {AdvancedInput} self This reference
+ * @param {Object} data Response data
*
* @return {void}
*
* @since 1.0.0
*/
- remoteCallback(self, data)
+ remoteCallback (self, data)
{
console.log(data);
data = JSON.parse(data.response)[0];
@@ -189,7 +195,7 @@ export class AdvancedInput
newRow.firstElementChild.setAttribute('data-data', JSON.stringify(data[i]));
self.dataListBody.appendChild(newRow);
- self.dataListBody.lastElementChild.addEventListener('focusout', function(e) {
+ self.dataListBody.lastElementChild.addEventListener('focusout', function (e) {
if (e.relatedTarget === null) {
return;
}
@@ -209,13 +215,13 @@ export class AdvancedInput
/**
* Callback for input field content change
*
- * @param {Object} self This reference
+ * @param {AdvancedInput} self This reference
*
* @return {void}
*
* @since 1.0.0
*/
- changeCallback(self)
+ changeCallback (self)
{
// if remote data
if (typeof self.src !== 'undefined' && self.src !== '') {
@@ -228,13 +234,13 @@ export class AdvancedInput
/**
* Select element in dropdown (only mark it as selected)
*
- * @param {Object} e Element to select in dropdown
+ * @param {Element} e Element to select in dropdown
*
* @return {void}
*
* @since 1.0.0
*/
- selectOption(e)
+ selectOption (e)
{
e.focus();
@@ -249,19 +255,18 @@ export class AdvancedInput
/**
* Clear all selected/marked options in dropdown
*
- * @param {Object} self This reference
+ * @param {AdvancedInput} self This reference
*
* @return {void}
*
* @since 1.0.0
*/
- clearDataListSelection(self)
+ clearDataListSelection (self)
{
- const list = self.dataListBody.getElementsByTagName('tr'),
- length = list.length;
+ const list = self.dataListBody.getElementsByTagName('tr');
+ const length = list.length;
for (let i = 0; i < length; ++i) {
-
/**
* @todo Karaka/jsOMS#70
* Implement external styles for selections instead of inline css
@@ -276,14 +281,14 @@ export class AdvancedInput
*
* This can add the selected dropdown elements to a table, badge list etc. depending on the template structure.
*
- * @param {Object} self This reference
- * @param {Element} e Element
+ * @param {AdvancedInput} self This reference
+ * @param {Element} e Element
*
* @return {void}
*
* @since 1.0.0
*/
- addToResultList(self, e) {
+ addToResultList (self, e) {
const data = JSON.parse(e.getAttribute('data-data'));
if (self.inputField.getAttribute('data-autocomplete') === 'true') {
@@ -350,7 +355,7 @@ export class AdvancedInput
// allow limit
if (self.tagElement.childElementCount >= self.tagElement.getAttribute('data-limit')
- && self.tagElement.getAttribute('data-limit') != 0
+ && self.tagElement.getAttribute('data-limit') !== '0'
) {
self.tagElement.removeChild(self.tagElement.firstElementChild);
}
@@ -370,27 +375,27 @@ export class AdvancedInput
*
* After waiting for a delay a callback can be triggered.
*
- * @param {Object} action Action type
- * @param {function} callback Callback to be triggered
- * @param {Object} self This reference (passed to callback)
- * @param {Object} data Data (passed to callback)
+ * @param {Object} action Action type
+ * @param {function} callback Callback to be triggered
+ * @param {AdvancedInput} self This reference (passed to callback)
+ * @param {Object} data Data (passed to callback)
*
* @return {void}
*
* @since 1.0.0
*/
- inputTimeDelay(action, callback, self, data)
+ inputTimeDelay (action, callback, self, data)
{
if (AdvancedInput.timerDelay[action.id]) {
clearTimeout(AdvancedInput.timerDelay[action.id]);
- delete AdvancedInput.timerDelay[action.id]
+ delete AdvancedInput.timerDelay[action.id];
}
- AdvancedInput.timerDelay[action.id] = setTimeout(function() {
+ AdvancedInput.timerDelay[action.id] = setTimeout(function () {
delete AdvancedInput.timerDelay[action.id];
callback(self, data);
}, action.delay);
};
};
-AdvancedInput.timerDelay = {};
\ No newline at end of file
+AdvancedInput.timerDelay = {};
diff --git a/UI/Component/AdvancedSelect.js b/UI/Component/AdvancedSelect.js
index e41f8c0..2a0e61c 100755
--- a/UI/Component/AdvancedSelect.js
+++ b/UI/Component/AdvancedSelect.js
@@ -24,7 +24,7 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- constructor(e) {
+ constructor (e) {
this.id = e.id;
this.selectComponent = e;
this.selectField = this.selectComponent.getElementsByClassName('input')[0];
@@ -44,10 +44,10 @@ export class AdvancedSelect
* This is also true if you click something inside of the dropdown list e.g. sort/filter etc.
* This might be fixable by changing the focus from the input element to the dropdown element and keep the dropdown element visible if it has focus.
*/
- if (e.relatedTarget === null ||
- e.relatedTarget.parentElement === null ||
- e.relatedTarget.parentElement.parentElement === null ||
- !jsOMS.hasClass(e.relatedTarget.parentElement.parentElement.parentElement, 'popup')
+ if (e.relatedTarget === null
+ || e.relatedTarget.parentElement === null
+ || e.relatedTarget.parentElement.parentElement === null
+ || !jsOMS.hasClass(e.relatedTarget.parentElement.parentElement.parentElement, 'popup')
) {
jsOMS.removeClass(self.dropdownElement, 'active');
}
@@ -132,7 +132,7 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- remoteCallback(self, data) {
+ remoteCallback (self, data) {
console.log(data);
data = JSON.parse(data.response)[0];
const dataLength = data.length;
@@ -197,7 +197,7 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- changeCallback(self) {
+ changeCallback (self) {
// if remote data
if (typeof self.src !== 'undefined' && self.src !== '') {
const request = new Request(self.src);
@@ -215,7 +215,7 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- selectOption(e) {
+ selectOption (e) {
e.focus();
/**
* @todo Karaka/jsOMS#70
@@ -234,9 +234,9 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- clearDataListSelection(self) {
- const list = self.dataListBody.getElementsByTagName('tr'),
- length = list.length;
+ clearDataListSelection (self) {
+ const list = self.dataListBody.getElementsByTagName('tr');
+ const length = list.length;
for (let i = 0; i < length; ++i) {
/**
@@ -259,7 +259,7 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- addToResultList(self) {
+ addToResultList (self) {
if (self.inputField.getAttribute('data-autocomplete') === 'true') {
self.inputField.value = document.activeElement.querySelectorAll('[data-tpl-value="' + self.inputField.getAttribute('data-value') + '"]')[0].getAttribute('data-value');
}
@@ -309,7 +309,7 @@ export class AdvancedSelect
// allow limit
if (self.tagElement.childElementCount >= self.tagElement.getAttribute('data-limit')
- && self.tagElement.getAttribute('data-limit') != 0
+ && self.tagElement.getAttribute('data-limit') !== '0'
) {
self.tagElement.removeChild(self.tagElement.firstElementChild);
}
@@ -338,10 +338,10 @@ export class AdvancedSelect
*
* @since 1.0.0
*/
- inputTimeDelay(action, callback, self, data) {
+ inputTimeDelay (action, callback, self, data) {
if (AdvancedSelect.timerDelay[action.id]) {
clearTimeout(AdvancedSelect.timerDelay[action.id]);
- delete AdvancedSelect.timerDelay[action.id]
+ delete AdvancedSelect.timerDelay[action.id];
}
AdvancedSelect.timerDelay[action.id] = setTimeout(function () {
@@ -351,4 +351,4 @@ export class AdvancedSelect
};
};
-AdvancedSelect.timerDelay = {};
\ No newline at end of file
+AdvancedSelect.timerDelay = {};
diff --git a/UI/Component/Form.js b/UI/Component/Form.js
index 459dad8..e2503bc 100755
--- a/UI/Component/Form.js
+++ b/UI/Component/Form.js
@@ -41,8 +41,12 @@ export class Form
*/
constructor (app)
{
- this.app = app;
- this.forms = {};
+ this.app = app;
+
+ /** @type {FormView[]} forms */
+ this.forms = {};
+
+ /** @type {Object} ignore Forms to ignore */
this.ignore = {};
};
@@ -57,7 +61,7 @@ export class Form
*/
get (id)
{
- if (!this.forms.hasOwnProperty(id)) {
+ if (!Object.prototype.hasOwnProperty.call(this.forms, id)) {
this.bind(id);
}
@@ -78,42 +82,30 @@ export class Form
return this.ignore.indexOf(id) !== -1;
};
- /**
- * Unbind form
- *
- * @param {string} id Form Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- unbind (id)
- {
-
- };
-
/**
* Bind form
*
- * @param {string} id Form Id (optional)
+ * @param {string} id Form Id (optional, if omitted all forms are searched and bound)
*
* @return {void}
*
* @since 1.0.0
*/
- bind (id)
+ bind (id = null)
{
- if (typeof id !== 'undefined' && typeof this.ignore[id] === 'undefined') {
+ if (id !== null && typeof this.ignore[id] === 'undefined') {
this.bindForm(id);
} else {
- const forms = document.querySelectorAll('form, [data-tag=form]'),
- length = !forms ? 0 : forms.length;
+ const forms = document.querySelectorAll('form, [data-tag=form]');
+ const length = !forms ? 0 : forms.length;
for (let i = 0; i < length; ++i) {
- let formId = forms[i].getAttribute('id');
+ const formId = forms[i].getAttribute('id');
if (typeof formId !== 'undefined' && formId !== null && typeof this.ignore[formId] === 'undefined') {
this.bindForm(formId);
+ } else {
+ Logger.instance.info('A form doesn\'t have an ID.');
}
}
}
@@ -122,33 +114,574 @@ export class Form
/**
* Bind form
*
- * @param {string} id Form Id
+ * @param {null|string} id Form Id
*
* @return {void}
*
* @since 1.0.0
*/
- bindForm (id)
+ bindForm (id = null)
{
- if (typeof id === 'undefined' || !id) {
+ if (id === null) {
Logger.instance.info('A form doesn\'t have an ID.');
return;
}
- // don't overwrite bind
- if (this.forms.hasOwnProperty(id)) {
+ // don't overwrite existing bind
+ if (Object.prototype.hasOwnProperty.call(this.forms, id)) {
return;
}
- const self = this;
this.forms[id] = new FormView(id);
+ const self = this;
let length = 0;
- const submits = this.forms[id].getSubmit()
- const submitLength = submits.length;
+ // bind form clicks
+ this.forms[id].form.addEventListener('click', function (event) {
+ let elementIndex = 0;
- this.unbind(id);
- this.bindButtons(id);
+ if ((elementIndex = Array.from(self.forms[id].getRemove()).indexOf(event.target)) !== -1) {
+ // handle remove
+
+ const remove = self.forms[id].getRemove()[elementIndex];
+ const callback = function () {
+ const parent = remove.closest(document.getElementById(id).getAttribute('data-ui-element'));
+ console.log(document.getElementById(id).getAttribute('data-ui-element'));
+ parent.parentNode.removeChild(parent);
+ };
+
+ const container = document.getElementById(id);
+
+ // container can be the table tr, form or just a div
+ if (container !== null
+ && ((container.tagName.toLowerCase() !== 'form' && container.getAttribute('data-method') !== null)
+ || (container.tagName.toLowerCase() === 'form' && container.getAttribute('method') !== 'NONE'))
+ ) {
+ const deleteRequest = new Request(
+ container.tagName.toLowerCase() !== 'form' ? container.getAttribute('data-method') : container.getAttribute('method'),
+ RequestMethod.DELETE
+ );
+ deleteRequest.setSuccess(callback);
+ deleteRequest.send();
+ } else {
+ callback();
+ }
+ } else if ((elementIndex = Array.from(self.forms[id].getAdd()).indexOf(event.target)) !== -1) {
+ // handle add
+
+ /* The form is the UI element the user can edit.
+ * This will be added to the UI on click.
+ * Since the add is inline no form exists which the user can use, hence it must be created
+ */
+ if (document.getElementById(id).getAttribute('data-add-form') !== null) {
+ // handline inline add
+
+ const formElement = self.forms[id].getFormElement();
+ const subMain = formElement.getAttribute('data-add-content').charAt(0) === '#'
+ ? document.querySelector(formElement.getAttribute('data-add-content'))
+ : formElement.querySelector(formElement.getAttribute('data-add-content'));
+
+ /**
+ * @todo Karaka/jsOMS#76
+ * In the beginning there was a fixed amount of templates required (even if some were not used) for adding new dom elements to a lest, table etc.
+ * This no longer works especially for inline editing
+ * ```js
+ * const newEle = subMain.getElementsByTagName('template')[0].content.cloneNode(true);
+ * ```
+ */
+ const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true);
+ let eleId = '';
+
+ do {
+ eleId = 'f' + Math.random().toString(36).substring(7);
+ } while (document.getElementById(eleId) !== null);
+
+ newEle.firstElementChild.id = eleId;
+ newEle.firstElementChild.getElementsByTagName('form')[0].id = eleId + '-form';
+
+ const fields = newEle.firstElementChild.querySelectorAll('[data-form="' + id + '"]');
+ const length = fields.length;
+
+ for (let i = 0; i < length; ++i) {
+ fields[i].setAttribute('data-form', eleId + '-form');
+ }
+
+ subMain.appendChild(newEle.firstElementChild);
+
+ /**
+ * @todo Karaka/jsOMS#82
+ * The container element for inline adding isn't always tbody
+ */
+ self.app.uiManager.getFormManager().get(eleId + '-form').injectSubmit(function () {
+ self.forms[id].getFormElement().getElementsByTagName('tbody')[0].removeChild(
+ document.getElementById(eleId)
+ );
+ });
+ } else {
+ // handle external add
+ if (!self.forms[id].isValid()) {
+ return;
+ }
+
+ const formElement = self.forms[id].getFormElement();
+ const parents = [];
+ const selectors = formElement.getAttribute('data-add-element').split(',');
+ const selectorLength = selectors.length;
+ const addTpl = formElement.getAttribute('data-add-tpl').split(',');
+
+ const subMain = formElement.getAttribute('data-add-content').charAt(0) === '#'
+ ? document.querySelector(formElement.getAttribute('data-add-content'))
+ : formElement.querySelector(formElement.getAttribute('data-add-content'));
+
+ let values = [];
+ let text = [];
+ const newEle = [];
+
+ for (let i = 0; i < selectorLength; ++i) {
+ // this handles selectors such as 'ancestor > child/or/sibling' and many more
+ const selector = selectors[i].trim(' ').split(' ');
+
+ let subSelector = '';
+ if (selector.length !== 0) {
+ selector.shift();
+ subSelector = selector.join(' ').trim();
+ }
+
+ newEle.push(document.querySelector(addTpl[i]).content.cloneNode(true));
+
+ const tplValue = newEle[i].querySelector('[data-tpl-value]').getAttribute('data-tpl-value');
+ parents.push(
+ tplValue.startsWith('http') || tplValue.startsWith('{')
+ ? ( // data is only added from remote response after adding
+ selector.length === 0
+ ? newEle[i].firstElementChild
+ : newEle[i].firstElementChild.querySelector(subSelector)
+ )
+ : formElement // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
+ );
+
+ values = values.concat(
+ parents[i].hasAttribute('data-tpl-value')
+ ? parents[i]
+ : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]'))
+ );
+ text = text.concat(
+ parents[i].hasAttribute('data-tpl-text')
+ ? parents[i]
+ : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]'))
+ );
+
+ Form.setRandomIdForTemplateElement(newEle[i]);
+ }
+
+ // insert row values data into form
+ const remoteUrls = {};
+ Form.insertDataIntoNewFormElement('value', newEle, values, remoteUrls);
+
+ // insert row text data into form
+ Form.insertDataIntoNewFormElement('text', newEle, text, remoteUrls);
+
+ for (let i = 0; i < selectorLength; ++i) {
+ // The data could be added to an external element which uses external forms for updates.
+ // The buttons then belong to the external element and not the update form!
+ const formId = document.querySelector('[data-update-form="' + id + '"]');
+
+ // @todo: bind added element in general (e.g. self.app.uiManager.bind(newEle[i].firstElementChild));
+ // Problem 1 is sometimes the bind functions expect an id, sometimes an element
+ // Problem 2 is that sorting is handled in the Table.js which should be part of the form? because a new sorting should also get submitted to the backend!
+
+ subMain.appendChild(newEle[i].firstElementChild);
+ }
+
+ self.forms[id].setSuccess(function (response) {
+ if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN) {
+ self.app.notifyManager.send(
+ new NotificationMessage(response.get('status'), response.get('title'), response.get('message')), NotificationType.APP_NOTIFICATION
+ );
+ }
+
+ console.log(remoteUrls);
+
+ UriFactory.setQuery('$id', response.get('response').id);
+
+ Form.setDataFromRemoteUrls(remoteUrls);
+ });
+
+ self.forms[id].resetValues();
+ }
+ } else if ((elementIndex = Array.from(self.forms[id].getSave()).indexOf(event.target)) !== -1) {
+ const mainForm = document.querySelector('[data-update-form="' + id + '"');
+ if (mainForm !== null) {
+ id = mainForm.getAttribute('id');
+ }
+
+ // handle save button
+ const formElement = self.forms[id].getFormElement();
+ const parentsTpl = {};
+ const parentsContent = {};
+ const selectors = formElement.getAttribute('data-update-element').split(',');
+ const selectorLength = selectors.length;
+
+ let values = [];
+ let text = [];
+
+ // find all values, texts and parents for every selector
+ for (let i = 0; i < selectorLength; ++i) {
+ selectors[i] = selectors[i].trim();
+ // this handles selectors such as 'ancestor > child/or/sibling' and many more
+ let selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
+ const selLength = selector.length;
+ let closest = selector[0].trim();
+
+ // template elements (= elements which just got added due to the update/edit button, here the new data is stored)
+ // @todo i don't really remember how this works and why this was needed. Try to understand it and write a comment afterwards
+ let subSelector = '';
+ if (selLength > 1) {
+ selector.shift();
+ subSelector = selector.join(' ').trim() + '[data-marker=tpl]';
+ } else {
+ closest += '[data-marker=tpl]';
+ }
+
+ let parentTplName;
+ if (selLength === 1 && selector[0].startsWith('#')) {
+ parentTplName = selector[0] + '[data-marker=tpl]';
+ } else {
+ parentTplName = selLength === 1 ? closest : closest + subSelector;
+ }
+
+ if (!Object.prototype.hasOwnProperty.call(parentsTpl, parentTplName)) {
+ if (selLength === 1 && selector[0].startsWith('#')) {
+ parentsTpl[parentTplName] = document.querySelector(selector[0]).parentNode;
+ } else {
+ parentsTpl[parentTplName] = selLength === 1
+ ? this.closest(closest)
+ : this.closest(closest).querySelector(subSelector);
+ /* @todo: parentNode because of media edit. maybe I need a data-ui-parent element? */
+ }
+ }
+
+ // content elements
+ selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
+ closest = selector[0].trim();
+ subSelector = '';
+ if (selLength > 1) {
+ selector.shift();
+ subSelector = selector.join(' ').trim() + ':not([data-marker=tpl])';
+ } else {
+ closest += ':not([data-marker=tpl])';
+ }
+
+ let parentContentName;
+ if (selLength === 1 && selector[0].startsWith('#')) {
+ parentContentName = selector[0] + ':not([data-marker=tpl])';
+ } else {
+ parentContentName = selLength === 1 ? closest : closest + subSelector;
+ }
+
+ if (!Object.prototype.hasOwnProperty.call(parentsContent, parentContentName)) {
+ if (selLength === 1 && selector[0].startsWith('#')) {
+ parentsContent[parentContentName] = document.querySelector(selector[0]).parentNode;
+ } else {
+ parentsContent[parentContentName] = selLength === 1
+ ? this.closest(closest)
+ : this.closest(closest).querySelector(subSelector).parentNode;
+ /* @todo: parentNode because of media edit. maybe I need a data-ui-parent element? */
+ }
+ }
+
+ values = values.concat(
+ parentsTpl[parentTplName].hasAttribute('data-tpl-value')
+ ? parentsTpl[parentTplName]
+ : Array.prototype.slice.call(parentsTpl[parentTplName].querySelectorAll('[data-tpl-value]'))
+ );
+ text = text.concat(
+ parentsContent[parentContentName].hasAttribute('data-tpl-text')
+ ? parentsContent[parentContentName]
+ : Array.prototype.slice.call(parentsContent[parentContentName].querySelectorAll('[data-tpl-text]'))
+ );
+ }
+
+ values = values.filter(function (value, index, self) { return self.indexOf(value) === index; });
+ text = text.filter(function (value, index, self) { return self.indexOf(value) === index; });
+
+ // overwrite old values data in ui
+ const remoteUrls = {};
+ const changedValueNodes = []; // prevent same node touching
+ length = values.length;
+ for (const parent in parentsTpl) { // loop every selector which has elements to change
+ for (let i = 0; i < length; ++i) { // loop every value
+ const matches = parentsTpl[parent].querySelectorAll('[data-tpl-value="' + values[i].getAttribute('data-tpl-value') + '"');
+
+ const matchLength = matches.length;
+ for (let c = 0; c < matchLength; ++c) { // loop every found element in the selector to change
+ if (changedValueNodes.includes(matches[c])) {
+ continue;
+ }
+
+ changedValueNodes.push(matches[c]);
+ const path = matches[c].hasAttribute('data-tpl-value-path') ? matches[c].getAttribute('data-tpl-value-path') : null;
+
+ if (values[i].getAttribute('data-tpl-value').startsWith('http')
+ || values[i].getAttribute('data-tpl-value').startsWith('{')
+ ) {
+ Form.populateRemoteUrls('value', values[i], path, remoteUrls);
+ } else {
+ GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(values[i]));
+ }
+ }
+ }
+ }
+
+ // overwrite old text data in ui
+ const changedTextNodes = [];
+ length = text.length;
+ for (const parent in parentsContent) {
+ for (let i = 0; i < length; ++i) {
+ const matches = parentsContent[parent].querySelectorAll('[data-tpl-text="' + text[i].getAttribute('data-tpl-text') + '"');
+
+ const matchLength = matches.length;
+ for (let c = 0; c < matchLength; ++c) {
+ if (changedTextNodes.includes(matches[c])) {
+ continue;
+ }
+
+ changedTextNodes.push(matches[c]);
+
+ const path = matches[c].hasAttribute('data-tpl-text-path') ? matches[c].getAttribute('data-tpl-text-path') : null;
+ if (text[i].getAttribute('data-tpl-text').startsWith('http')
+ || text[i].getAttribute('data-tpl-text').startsWith('{')
+ ) {
+ Form.populateRemoteUrls('text', text[i], path, remoteUrls)
+ } else {
+ GeneralUI.setTextOfElement(matches[c], GeneralUI.getTextFromDataSource(text[i]));
+ }
+ }
+ }
+ }
+
+ // todo bind failure here, if failure do cancel, if success to remove edit template
+ self.forms[id].setSuccess(function () {
+ // overwrite old values from remote response
+ Form.setDataFromRemoteUrls(remoteUrls);
+ });
+
+ // @todo: does this submit and the previous submit in updatable mean I'm sending the data twice???? That would be bad!
+ self.submit(self.forms[id]);
+ self.removeEditTemplate(this, id);
+ } else if ((elementIndex = Array.from(self.forms[id].getCancel()).indexOf(event.target)) !== -1) {
+ // handle cancel
+ const ele = document.getElementById(id);
+ if (ele.getAttribute('data-update-form') === null && ele.tagName.toLowerCase() !== 'form') {
+ self.removeEditTemplate(this, id);
+ } else {
+ self.forms[id].resetValues();
+
+ let length = 0;
+
+ // show add button + hide update + hide cancel
+ const addButtons = self.forms[id].getAdd();
+ length = addButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.removeClass(addButtons[i], 'hidden');
+ }
+
+ const saveButtons = self.forms[id].getSave();
+ length = saveButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.addClass(saveButtons[i], 'hidden');
+ }
+
+ const cancelButtons = self.forms[id].getCancel();
+ length = cancelButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.addClass(cancelButtons[i], 'hidden');
+ }
+
+ jsOMS.preventAll(event);
+ }
+ } else if ((elementIndex = Array.from(self.forms[id].getUpdate()).indexOf(event.target)) !== -1) {
+ // handle update button which populates the update form
+ if (document.getElementById(id).getAttribute('data-update-form') === null) {
+ const formElement = self.forms[id].getFormElement();
+ const parents = [];
+ const selectors = formElement.getAttribute('data-update-element').split(',');
+ const selectorLength = selectors.length;
+ const updatableTpl = formElement.getAttribute('data-update-tpl').split(',');
+
+ if (formElement.getAttribute('data-id') !== null) {
+ UriFactory.setQuery('$id', formElement.getAttribute('data-id'));
+ }
+
+ let values = [];
+ let text = [];
+ const newEle = [];
+
+ for (let i = 0; i < selectorLength; ++i) {
+ selectors[i] = selectors[i].trim();
+ // this handles selectors such as 'ancestor > child/or/sibling' and many more
+ const selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
+ const selLength = selector.length;
+ const closest = selector[0].trim();
+
+ let subSelector = '';
+ if (selLength > 1) {
+ selector.shift();
+ subSelector = selector.join(' ').trim();
+ }
+
+ if (selLength === 1 && selector[0].startsWith('#')) {
+ parents.push(document.querySelector(selector[0]));
+ } else {
+ parents.push(selLength === 1
+ ? this.closest(closest)
+ : this.closest(closest).querySelector(subSelector)
+ );
+ }
+
+ values = values.concat(
+ parents[i].hasAttribute('data-tpl-value')
+ ? parents[i]
+ : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]'))
+ );
+ text = text.concat(
+ parents[i].hasAttribute('data-tpl-text')
+ ? parents[i]
+ : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]'))
+ );
+
+ jsOMS.addClass(parents[i], 'hidden');
+
+ newEle.push(document.querySelector(updatableTpl[i]).content.cloneNode(true));
+
+ Form.setRandomIdForTemplateElement(newEle[i]);
+ }
+
+ const fields = [];
+ for (let i = 0; i < selectorLength; ++i) {
+ fields.concat(
+ newEle[i].firstElementChild.hasAttribute('data-form')
+ ? newEle[i].firstElementChild
+ : newEle[i].firstElementChild.querySelectorAll('[data-form="' + id + '"]')
+ );
+ }
+
+ let length = fields.length;
+ for (let i = 0; i < length; ++i) {
+ fields[i].setAttribute('data-form', eleId);
+ }
+
+ // insert row values data into form
+ const remoteUrls = {};
+ Form.insertDataIntoNewFormElement('value', newEle, values, remoteUrls);
+
+ // insert row text data into form
+ Form.insertDataIntoNewFormElement('text', newEle, text, remoteUrls);
+
+ Form.setDataFromRemoteUrls(remoteUrls);
+
+ for (let i = 0; i < selectorLength; ++i) {
+ newEle[i].firstElementChild.setAttribute('data-marker', 'tpl');
+ parents[i].parentNode.insertBefore(newEle[i].firstElementChild, parents[i]);
+ }
+
+ // self.bindCreateForm(eleId, id); // @todo: why this bind???
+ // @todo: this is not working!!!!!!!!!!
+ /*
+ self.app.uiManager.getFormManager().get(eleId).injectSubmit(function () {
+ // @todo: simplify this?
+ self.closest(self.getAttribute('data-ui-element')).parentNode.removeChild(
+ document.getElementById(eleId)
+ );
+ }); */
+
+ jsOMS.addClass(this, 'hidden');
+
+ const saveButtons = self.forms[id].getSave();
+ length = saveButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.removeClass(saveButtons[i], 'hidden');
+ }
+
+ const cancelButtons = self.forms[id].getCancel();
+ length = cancelButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.removeClass(cancelButtons[i], 'hidden');
+ }
+ } else {
+ const formElement = self.forms[id].getFormElement();
+ const parent = event.target.closest(formElement.getAttribute('data-update-element'));
+ const formId = formElement.getAttribute('data-update-form');
+ const values = parent.querySelectorAll('[data-tpl-value]');
+ const text = parent.querySelectorAll('[data-tpl-text]');
+
+ const fields = self.forms[formId].getFormElement().querySelectorAll('[data-form="' + id + '"]');
+ let length = 0;
+
+ // clear form values to prevent old values getting mixed with update values
+ self.forms[formId].resetValues();
+
+ // hide add button + show update + show cancel
+ const addButtons = self.forms[formId].getAdd();
+ length = addButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.addClass(addButtons[i], 'hidden');
+ }
+
+ const saveButtons = self.forms[formId].getSave();
+ length = saveButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.removeClass(saveButtons[i], 'hidden');
+ }
+
+ const cancelButtons = self.forms[formId].getCancel();
+ length = cancelButtons.length;
+ for (let i = 0; i < length; ++i) {
+ jsOMS.removeClass(cancelButtons[i], 'hidden');
+ }
+
+ // set form id to fields for easier identification
+ length = fields.length;
+ for (let i = 0; i < length; ++i) {
+ fields[i].setAttribute('data-form', eleId);
+ }
+
+ // insert row values data into form
+ const remoteUrls = {};
+ Form.insertDataIntoForm(self, 'value', formId, values, remoteUrls);
+
+ // insert row text data into form
+ Form.insertDataIntoForm(self, 'text', formId, text, remoteUrls);
+
+ self.forms[formId].setSuccess(function (response) {
+ if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN) {
+ self.app.notifyManager.send(
+ new NotificationMessage(response.get('status'), response.get('title'), response.get('message')), NotificationType.APP_NOTIFICATION
+ );
+ }
+
+ console.log(remoteUrls);
+
+ UriFactory.setQuery('$id', response.get('response').id);
+
+ Form.setDataFromRemoteUrls(remoteUrls);
+ });
+ }
+ } else if ((elementIndex = Array.from(self.forms[id].getSubmit()).indexOf(event.target)) !== -1) {
+ jsOMS.preventAll(event);
+ self.submit(self.forms[id], self.forms[id].getSubmit()[elementIndex]);
+ }
+
+ // remote actions (maybe solvable with callbacks?):
+ // filter
+ // sort
+ // reorder
+ // remove
+ // add
+ // save
+ // update
+ // dragndrop
+ });
const imgPreviews = this.forms[id].getImagePreviews();
length = imgPreviews === null ? 0 : imgPreviews.length;
@@ -156,14 +689,6 @@ export class Form
this.bindImagePreview(imgPreviews[i], id);
}
- for (let i = 0; i < submitLength; ++i) {
- submits[i].addEventListener('click', function (event)
- {
- jsOMS.preventAll(event);
- self.submit(self.forms[id], submits[i]);
- });
- }
-
// if true submit form on change
if (this.forms[id].isOnChange()) {
const hasUiContainer = this.forms[id].getFormElement().getAttribute('data-ui-content');
@@ -189,43 +714,6 @@ export class Form
}
};
- bindButtons (id, e = null)
- {
- let length = 0;
-
- const removable = this.forms[id].getRemove(e);
- length = removable === null ? 0 : removable.length;
- for (let i = 0; i < length; ++i) {
- this.bindRemovable(removable[i], id);
- }
-
- const addable = this.forms[id].getAdd(e);
- length = addable === null ? 0 : addable.length;
- for (let i = 0; i < length; ++i) {
- this.bindAdd(addable[i], id);
- }
-
- const save = this.forms[id].getSave(e);
- length = save === null ? 0 : save.length;
- for (let i = 0; i < length; ++i) {
- this.bindSaveInline(save[i], id);
- }
-
- // @todo implement bindSaveExternal ???
-
- const cancel = this.forms[id].getCancel(e);
- length = cancel === null ? 0 : cancel.length;
- for (let i = 0; i < length; ++i) {
- this.bindCancel(cancel[i], id);
- }
-
- const update = this.forms[id].getUpdate(e);
- length = update === null ? 0 : update.length;
- for (let i = 0; i < length; ++i) {
- this.bindUpdatable(update[i], id);
- }
- };
-
/**
* Create the new input
*
@@ -243,38 +731,17 @@ export class Form
preview.src = window.URL.createObjectURL(imageUpload.files[0]);
preview.onload = function () {
window.URL.revokeObjectURL(this.src);
- }
+ };
});
};
- /**
- * Unbind form
- *
- * @param {string} id Form Id
- *
- * @return {boolean}
- *
- * @since 1.0.0
- */
- unbindForm (id)
- {
- if ((findex = this.forms[id]) !== 'undefined') {
- this.forms[id].unbind();
- this.forms.splice(id, 1);
-
- return true;
- }
-
- return false;
- };
-
/**
* Submit form
*
* Calls injections first before executing the actual form submit
*
- * @param {Object} form Form object
- * @param {Element} button Action different from the form action (e.g. formaction=*)
+ * @param {FormView} form Form object
+ * @param {Element} button Action different from the form action (e.g. formaction=*)
*
* @return {void}
*
@@ -283,9 +750,9 @@ export class Form
submit (form, button = null, container = null)
{
/* Handle injects */
- const self = this,
- injects = form.getSubmitInjects();
- let counter = 0;
+ const self = this;
+ const injects = form.getSubmitInjects();
+ let counter = 0;
let action = null;
@@ -303,9 +770,9 @@ export class Form
// Run all injects first
for (const property in injects) {
- if (injects.hasOwnProperty(property)) {
+ if (Object.prototype.hasOwnProperty.call(injects, property)) {
++counter;
- //this.app.eventManager.addGroup(form.getId(), counter);
+ // this.app.eventManager.addGroup(form.getId(), counter);
const result = injects[property](form, form.getId());
if (result === false) {
@@ -330,8 +797,8 @@ export class Form
*
* Submits the main form data
*
- * @param {Object} form Form object
- * @param {string} [action] Action different from the form action (e.g. formaction=*)
+ * @param {FormView} form Form object
+ * @param {string} [action] Action different from the form action (e.g. formaction=*)
*
* @return {void}
*
@@ -363,8 +830,8 @@ export class Form
form.updateLastSubmit();
/* Handle default submit */
- const request = new Request(),
- self = this;
+ const request = new Request();
+ const self = this;
request.setData(data);
request.setType(RequestType.FORM_DATA);
@@ -400,8 +867,8 @@ export class Form
document.body.removeChild(doc);
} else {
try {
- const o = JSON.parse(xhr.response)[0],
- response = new Response(o);
+ const o = JSON.parse(xhr.response)[0];
+ const response = new Response(o);
let successInject = null;
if ((successInject = form.getSuccess()) !== null) {
@@ -443,20 +910,6 @@ export class Form
}
};
- static formClickEvent(event)
- {
- // submit button?
-
- // filter
- // sort
- // reorder
- // remove
- // add
- // save
- // update
- // dragndrop
- };
-
/**
* Count the bound forms
*
@@ -469,131 +922,11 @@ export class Form
return this.forms.length;
};
- /**
- * Create the ui element
- *
- * @param {string} create Create form button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindAddExternal(create, id)
- {
- const self = this;
-
- /**
- * @todo Karaka/jsOMS#75
- * Currently only one add button is allowed per form. Allow multiple/different add buttons in a form.
- */
- create.addEventListener('click', function () {
- if (!self.forms[id].isValid()) {
- return;
- }
-
- const formElement = self.forms[id].getFormElement();
- const parents = [];
- const selectors = formElement.getAttribute('data-add-element').split(','),
- selectorLength = selectors.length;
- const addTpl = formElement.getAttribute('data-add-tpl').split(',');
-
- const subMain = formElement.getAttribute('data-add-content').charAt(0) === '#'
- ? document.querySelector(formElement.getAttribute('data-add-content'))
- : formElement.querySelector(formElement.getAttribute('data-add-content'));
-
- let values = [];
- let text = [];
- const newEle = [];
-
- for (let i = 0; i < selectorLength; ++i) {
- // this handles selectors such as 'ancestor > child/or/sibling' and many more
- const selector = selectors[i].trim(' ').split(' ');
-
- let subSelector = '';
- if (selector.length !== 0) {
- selector.shift();
- subSelector = selector.join(' ').trim();
- }
-
- newEle.push(document.querySelector(addTpl[i]).content.cloneNode(true));
-
- const tplValue = newEle[i].querySelector('[data-tpl-value]').getAttribute('data-tpl-value');
- parents.push(
- tplValue.startsWith('http') || tplValue.startsWith('{')
- ? ( // data is only added from remote response after adding
- selector.length === 0
- ? newEle[i].firstElementChild
- : newEle[i].firstElementChild.querySelector(subSelector)
- )
- : formElement // data comes from the form (even if the api returns something after adding). What if remote returns a DB id? how do we add it? is this a @todo ? probably yes, maybe first use local data and then if remote data available replace local data?
- );
-
- values = values.concat(
- parents[i].hasAttribute('data-tpl-value')
- ? parents[i]
- : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]'))
- );
- text = text.concat(
- parents[i].hasAttribute('data-tpl-text')
- ? parents[i]
- : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]'))
- );
-
- Form.setRandomIdForTemplateElement(newEle[i]);
- }
-
- // insert row values data into form
- const remoteUrls = {};
- Form.insertDataIntoNewFormElement('value', newEle, values, remoteUrls);
-
- // insert row text data into form
- Form.insertDataIntoNewFormElement('text', newEle, text, remoteUrls)
-
- for (let i = 0; i < selectorLength; ++i) {
- // The data could be added to an external element which uses external forms for updates.
- // The buttons then belong to the external element and not the update form!
- const formId = document.querySelector('[data-update-form="' + id + '"]');
-
- self.bindButtons(formId === null ? id : formId.id, newEle[i].firstElementChild);
-
- // @todo: bind added element in general (e.g. self.app.uiManager.bind(newEle[i].firstElementChild));
- // Problem 1 is sometimes the bind functions expect an id, sometimes an element
- // Problem 2 is that sorting is handled in the Table.js which should be part of the form? because a new sorting should also get submitted to the backend!
-
- subMain.appendChild(newEle[i].firstElementChild);
- }
-
- self.forms[id].setSuccess(function(response) {
- if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN) {
- self.app.notifyManager.send(
- new NotificationMessage(response.get('status'), response.get('title'), response.get('message')), NotificationType.APP_NOTIFICATION
- );
- }
-
- console.log(remoteUrls);
-
- UriFactory.setQuery('$id', response.get('response').id);
-
- Form.setDataFromRemoteUrls(remoteUrls);
- });
-
- self.forms[id].resetValues();
-
- // @todo bind update
- });
-
- /**
- * @todo Karaka/jsOMS#85
- * Invalid backend/api responses (!201) should undo/stop UI changes
- */
- };
-
static setDataFromRemoteUrls (remoteUrls)
{
for (const e in remoteUrls) {
const request = new Request(e);
- request.setResultCallback(200, function(xhr) {
+ request.setResultCallback(200, function (xhr) {
/**
* @todo Karaka/jsOMS#84
* Remote data responses need to be parsed
@@ -644,6 +977,7 @@ export class Form
const path = data[i].hasAttribute('data-tpl-' + type + '-path') ? data[i].getAttribute('data-tpl-' + type + '-path') : null;
for (let j = 0; j < templateLength; ++j) {
+ // BUG: matches contains the same elment for radio/checkbox
const matches = templateElements[j].firstElementChild.hasAttribute('data-tpl-' + type)
&& templateElements[j].firstElementChild.getAttribute('data-tpl-' + type) === data[i].getAttribute('data-tpl-' + type)
? [templateElements[j].firstElementChild]
@@ -654,7 +988,7 @@ export class Form
const matchLength = matches.length;
for (let c = 0; c < matchLength; ++c) {
if (changedNodes.includes(matches[c])
- || (path !== null && path !== matches[c].getAttribute('data-tpl-' + type + '-path')) // ensure correct element. if this doesn't exist the matches from above contains alle elements with the same uri/path but eventually different tpl-paths @todo maybe fix it by improving the loop nesting or instead of storing the uri in the remoteUrls store the path? and then just check the path?
+ || (path !== null && path !== matches[c].getAttribute('data-tpl-' + type + '-path')) // ensure correct element. if this doesn't exist the matches from above contains alle elements with the same uri/path but eventually different tpl-paths
) {
continue;
}
@@ -664,7 +998,7 @@ export class Form
if (data[i].getAttribute('data-tpl-' + type).startsWith('http')
|| data[i].getAttribute('data-tpl-' + type).startsWith('{')
) {
- Form.populateRemoteUrls(type, data[i], path, remoteUrls)
+ Form.populateRemoteUrls(type, data[i], path, remoteUrls);
} else {
if (type === 'value') {
GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(data[i]));
@@ -677,7 +1011,7 @@ export class Form
}
};
- static insertDataIntoForm (type, formId, data, remoteUrls = {})
+ static insertDataIntoForm (self, type, formId, data, remoteUrls = {})
{
const length = data.length;
for (let i = 0; i < length; ++i) {
@@ -689,7 +1023,7 @@ export class Form
if (data[i].getAttribute('data-tpl-' + type).startsWith('http')
|| data[i].getAttribute('data-tpl-' + type).startsWith('{')
) {
- Form.populateRemoteUrls(type, data[i], path, remoteUrls)
+ Form.populateRemoteUrls(type, data[i], path, remoteUrls);
} else {
if (type === 'value') {
GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(data[i]));
@@ -703,540 +1037,36 @@ export class Form
static populateRemoteUrls (type, data, path, remoteUrls)
{
- const uri = data[i].getAttribute('data-tpl-' + type).startsWith('/')
+ const uri = data.getAttribute('data-tpl-' + type).startsWith('/')
? document.getElementsByTagName('base')[0].href
: '';
- if (remoteUrls[uri + data[i].getAttribute('data-tpl-' + type)] === undefined) {
- remoteUrls[uri + data[i].getAttribute('data-tpl-' + type)] = [];
+ if (remoteUrls[uri + data.getAttribute('data-tpl-' + type)] === undefined) {
+ remoteUrls[uri + data.getAttribute('data-tpl-' + type)] = [];
}
- remoteUrls[uri + data[i].getAttribute('data-tpl-' + type)].push({
+ remoteUrls[uri + data.getAttribute('data-tpl-' + type)].push({
path: path,
element: matches[c],
type: type
});
};
- /**
- * Create the new input
- *
- * @param {string} createForm Create form button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindAddInline(createForm, id)
- {
- const self = this;
-
- createForm.addEventListener('click', function () {
- const formElement = self.forms[id].getFormElement();
- const subMain = formElement.getAttribute('data-add-content').charAt(0) === '#'
- ? document.querySelector(formElement.getAttribute('data-add-content'))
- : formElement.querySelector(formElement.getAttribute('data-add-content'));
-
- /**
- * @todo Karaka/jsOMS#76
- * In the beginning there was a fixed amount of templates required (even if some were not used) for adding new dom elements to a lest, table etc.
- * This no longer works especially for inline editing
- * ```js
- * const newEle = subMain.getElementsByTagName('template')[0].content.cloneNode(true);
- * ```
- */
- const newEle = subMain.getElementsByTagName('template')[1].content.cloneNode(true);
- let eleId = '';
-
- do {
- eleId = 'f' + Math.random().toString(36).substring(7);
- } while (document.getElementById(eleId) !== null);
-
- newEle.firstElementChild.id = eleId;
- newEle.firstElementChild.getElementsByTagName('form')[0].id = eleId + '-form';
-
- const fields = newEle.firstElementChild.querySelectorAll('[data-form="' + id + '"]');
- const length = fields.length;
-
- for (let i = 0; i < length; ++i) {
- fields[i].setAttribute('data-form', eleId + '-form');
- }
-
- subMain.appendChild(newEle.firstElementChild);
-
- /**
- * @todo Karaka/jsOMS#82
- * The container element for inline adding isn't always tbody
- */
- self.app.uiManager.getFormManager().get(eleId + '-form').injectSubmit(function () {
- self.forms[id].getFormElement().getElementsByTagName('tbody')[0].removeChild(
- document.getElementById(eleId)
- );
- });
-
- /**
- * @todo Karaka/jsOMS#78
- * After adding a new element some require a binding for removal
- *
- * @todo Karaka/jsOMS#79
- * After adding a new element some require a binding for editing
- */
- });
-
- /**
- * @todo Karaka/jsOMS#80
- * Consider to do UI action as success inject after a backend response.
- * This will prevent bugs where the backand couldn't complete a action but the user sees it in the frontend.
- * This should be probably optional optional because sometimes there will be no calls to the backend.
- *
- * @todo Karaka/jsOMS#81
- * A template can contain elements which must/should have an id (e.g. a form).
- * If this element gets added to the DOM the id should be changed to a unique id because it could be added multiple times to the DOM.
- * In order to bind these elements (e.g. forms) they must have a unique id.
- * Maybe check all elements for ids and add a random part e.g. `-random_string`
- */
- };
-
- /**
- * Bind edit button
- *
- * @param {string} add Add button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindAdd(add, id)
- {
- /* The form is the UI element the user can edit.
- * This will be added to the UI on click.
- * Since the add is inline no form exists which the user can use, hence it must be created
- */
- if (document.getElementById(id).getAttribute('data-add-form') !== null) {
- this.bindAddInline(add, id);
- } else {
- this.bindAddExternal(add, id);
- }
- };
-
- /**
- * Bind edit button
- *
- * @param {string} update Update button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindUpdatable(update, id)
- {
- if (document.getElementById(id).getAttribute('data-update-form') === null) {
- this.bindUpdatableInline(update, id);
- } else {
- this.bindUpdatableExternal(update, id);
- }
- };
-
- /**
- * Bind inline edit button
- *
- * @param {string} update Update button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindUpdatableInline(update, id)
- {
- const self = this;
-
- update.addEventListener('click', function () {
- const formElement = self.forms[id].getFormElement();
- const parents = [];
- const selectors = formElement.getAttribute('data-update-element').split(','),
- selectorLength = selectors.length;
- const updatableTpl = formElement.getAttribute('data-update-tpl').split(',');
-
- if (formElement.getAttribute('data-id') !== null) {
- UriFactory.setQuery('$id', formElement.getAttribute('data-id'));
- }
-
- let values = [];
- let text = [];
- const newEle = [];
-
- for (let i = 0; i < selectorLength; ++i) {
- selectors[i] = selectors[i].trim();
- // this handles selectors such as 'ancestor > child/or/sibling' and many more
- const selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
- const selLength = selector.length;
- const closest = selector[0].trim();
-
- let subSelector = '';
- if (selLength > 1) {
- selector.shift();
- subSelector = selector.join(' ').trim();
- }
-
- if (selLength === 1 && selector[0].startsWith('#')) {
- parents.push(document.querySelector(selector[0]));
- } else {
- parents.push(selLength === 1
- ? this.closest(closest)
- : this.closest(closest).querySelector(subSelector)
- );
- }
-
- values = values.concat(
- parents[i].hasAttribute('data-tpl-value')
- ? parents[i]
- : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-value]'))
- );
- text = text.concat(
- parents[i].hasAttribute('data-tpl-text')
- ? parents[i]
- : Array.prototype.slice.call(parents[i].querySelectorAll('[data-tpl-text]'))
- );
-
- jsOMS.addClass(parents[i], 'hidden');
-
- newEle.push(document.querySelector(updatableTpl[i]).content.cloneNode(true));
-
- Form.setRandomIdForTemplateElement(newEle[i]);
- }
-
- const fields = [];
- for (let i = 0; i < selectorLength; ++i) {
- fields.concat(
- newEle[i].firstElementChild.hasAttribute('data-form')
- ? newEle[i].firstElementChild
- : newEle[i].firstElementChild.querySelectorAll('[data-form="' + id + '"]')
- );
- }
-
- let length = fields.length;
- for (let i = 0; i < length; ++i) {
- fields[i].setAttribute('data-form', eleId);
- }
-
- // insert row values data into form
- const remoteUrls = {};
- Form.insertDataIntoNewFormElement('value', newEle, values, remoteUrls);
-
- // insert row text data into form
- Form.insertDataIntoNewFormElement('text', newEle, text, remoteUrls);
-
- Form.setDataFromRemoteUrls(remoteUrls);
-
- for (let i = 0; i < selectorLength; ++i) {
- newEle[i].firstElementChild.setAttribute('data-marker', 'tpl');
- parents[i].parentNode.insertBefore(newEle[i].firstElementChild, parents[i]);
- }
-
- //self.bindCreateForm(eleId, id); // @todo: why this bind???
- // @todo: this is not working!!!!!!!!!!
- /*
- self.app.uiManager.getFormManager().get(eleId).injectSubmit(function () {
- // @todo: simplify this?
- self.closest(self.getAttribute('data-ui-element')).parentNode.removeChild(
- document.getElementById(eleId)
- );
- });*/
-
- jsOMS.addClass(this, 'hidden');
-
- const saveButtons = self.forms[id].getSave();
- length = saveButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.removeClass(saveButtons[i], 'hidden');
- }
-
- const cancelButtons = self.forms[id].getCancel();
- length = cancelButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.removeClass(cancelButtons[i], 'hidden');
- }
-
- // @todo: on save button click insert data into hidden row and show hidden row again, delete form row
- });
-
- /**
- * @todo Karaka/jsOMS#85
- * Invalid backend/api responses (!201) should undo/stop UI changes
- */
- };
-
- /**
- * Bind cancel button
- *
- * @param {string} update Update button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindCancel(cancel, id)
- {
- const ele = document.getElementById(id);
- if (ele.getAttribute('data-update-form') === null && ele.tagName.toLowerCase() !== 'form') {
- this.bindCancelInline(cancel, id);
- } else {
- this.bindCancelExternal(cancel, id);
- }
- };
-
- /**
- * Bind inline cancel button
- *
- * @param {string} cancel Cancel button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindCancelInline(cancel, id)
- {
- const self = this;
-
- cancel.addEventListener('click', function () {
- self.removeEditTemplate(this, id);
- });
- };
-
- /**
- * Bind external/form cancel button
- *
- * @param {string} cancel Cancel button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindCancelExternal(cancel, id)
- {
- const self = this;
-
- cancel.addEventListener('click', function (e) {
- self.forms[id].resetValues();
-
- let length = 0;
-
- // show add button + hide update + hide cancel
- const addButtons = self.forms[id].getAdd();
- length = addButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.removeClass(addButtons[i], 'hidden');
- }
-
- const saveButtons = self.forms[id].getSave();
- length = saveButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.addClass(saveButtons[i], 'hidden');
- }
-
- const cancelButtons = self.forms[id].getCancel();
- length = cancelButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.addClass(cancelButtons[i], 'hidden');
- }
-
- jsOMS.preventAll(e);
- });
- };
-
- /**
- * Bind inline save button
- *
- * @param {string} save Save button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindSaveInline(save, id)
- {
- const self = this;
-
- save.addEventListener('click', function () {
- const formElement = self.forms[id].getFormElement();
- const parentsTpl = {};
- const parentsContent = {};
- const selectors = formElement.getAttribute('data-update-element').split(','),
- selectorLength = selectors.length;
-
- let values = [];
- let text = [];
-
- // find all values, texts and parents for every selector
- for (let i = 0; i < selectorLength; ++i) {
- selectors[i] = selectors[i].trim();
- // this handles selectors such as 'ancestor > child/or/sibling' and many more
- let selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
- const selLength = selector.length;
- let closest = selector[0].trim();
-
- // template elements (= elements which just got added due to the update/edit button, here the new data is stored)
- // @todo i don't really remember how this works and why this was needed. Try to understand it and write a comment afterwards
- let subSelector = '';
- if (selLength > 1) {
- selector.shift();
- subSelector = selector.join(' ').trim() + '[data-marker=tpl]';
- } else {
- closest += '[data-marker=tpl]';
- }
-
- let parentTplName;
- if (selLength === 1 && selector[0].startsWith('#')) {
- parentTplName = selector[0] + '[data-marker=tpl]';
- } else {
- parentTplName = selLength === 1 ? closest : closest + subSelector;
- }
-
- if (!parentsTpl.hasOwnProperty(parentTplName)) {
- if (selLength === 1 && selector[0].startsWith('#')) {
- parentsTpl[parentTplName] = document.querySelector(selector[0]).parentNode;
- } else {
- parentsTpl[parentTplName] = selLength === 1
- ? this.closest(closest)
- : this.closest(closest).querySelector(subSelector);
- /* @todo: parentNode because of media edit. maybe I need a data-ui-parent element? */
- }
- }
-
- // content elements
- selector = !selectors[i].startsWith('#') ? selectors[i].split(' ') : [selectors[i]];
- closest = selector[0].trim();
- subSelector = '';
- if (selLength > 1) {
- selector.shift();
- subSelector = selector.join(' ').trim() + ':not([data-marker=tpl])';
- } else {
- closest += ':not([data-marker=tpl])';
- }
-
- let parentContentName;
- if (selLength === 1 && selector[0].startsWith('#')) {
- parentContentName = selector[0] + ':not([data-marker=tpl])';
- } else {
- parentContentName = selLength === 1 ? closest : closest + subSelector;
- }
-
- if (!parentsContent.hasOwnProperty(parentContentName)) {
- if (selLength === 1 && selector[0].startsWith('#')) {
- parentsContent[parentContentName] = document.querySelector(selector[0]).parentNode;
- } else {
- parentsContent[parentContentName] = selLength === 1
- ? this.closest(closest)
- : this.closest(closest).querySelector(subSelector).parentNode;
- /* @todo: parentNode because of media edit. maybe I need a data-ui-parent element? */
- }
- }
-
- values = values.concat(
- parentsTpl[parentTplName].hasAttribute('data-tpl-value')
- ? parentsTpl[parentTplName]
- : Array.prototype.slice.call(parentsTpl[parentTplName].querySelectorAll('[data-tpl-value]'))
- );
- text = text.concat(
- parentsContent[parentContentName].hasAttribute('data-tpl-text')
- ? parentsContent[parentContentName]
- : Array.prototype.slice.call(parentsContent[parentContentName].querySelectorAll('[data-tpl-text]'))
- );
- }
-
- values = values.filter(function(value, index, self) { return self.indexOf(value) === index; });
- text = text.filter(function(value, index, self) { return self.indexOf(value) === index; });
-
- // overwrite old values data in ui
- const remoteUrls = {};
- const changedValueNodes = []; // prevent same node touching
- length = values.length;
- for (let parent in parentsTpl) { // loop every selector which has elements to change
- for (let i = 0; i < length; ++i) { // loop every value
- const matches = parentsTpl[parent].querySelectorAll('[data-tpl-value="' + values[i].getAttribute('data-tpl-value') + '"');
-
- const matchLength = matches.length;
- for (let c = 0; c < matchLength; ++c) { // loop every found element in the selector to change
- if (changedValueNodes.includes(matches[c])) {
- continue;
- }
-
- changedValueNodes.push(matches[c]);
- const path = matches[c].hasAttribute('data-tpl-value-path') ? matches[c].getAttribute('data-tpl-value-path') : null;
-
- if (values[i].getAttribute('data-tpl-value').startsWith('http')
- || values[i].getAttribute('data-tpl-value').startsWith('{')
- ) {
- Form.populateRemoteUrls('value', values[i], path, remoteUrls)
- } else {
- GeneralUI.setValueOfElement(matches[c], GeneralUI.getValueFromDataSource(values[i]));
- }
- }
- }
- }
-
- // overwrite old text data in ui
- const changedTextNodes = [];
- length = text.length;
- for (let parent in parentsContent) {
- for (let i = 0; i < length; ++i) {
- const matches = parentsContent[parent].querySelectorAll('[data-tpl-text="' + text[i].getAttribute('data-tpl-text') + '"');
-
- const matchLength = matches.length;
- for (let c = 0; c < matchLength; ++c) {
- if (changedTextNodes.includes(matches[c])) {
- continue;
- }
-
- changedTextNodes.push(matches[c]);
-
- const path = matches[c].hasAttribute('data-tpl-text-path') ? matches[c].getAttribute('data-tpl-text-path') : null;
- if (text[i].getAttribute('data-tpl-text').startsWith('http')
- || text[i].getAttribute('data-tpl-text').startsWith('{')
- ) {
- Form.populateRemoteUrls('text', text[i], path, remoteUrls)
- } else {
- GeneralUI.setTextOfElement(matches[c], GeneralUI.getTextFromDataSource(text[i]));
- }
- }
- }
- }
-
- // todo bind failure here, if failure do cancel, if success to remove edit template
- self.forms[id].setSuccess(function() {
- // overwrite old values from remote response
- Form.setDataFromRemoteUrls(remoteUrls);
- });
-
- // @todo: does this submit and the previous submit in updatable mean I'm sending the data twice???? That would be bad!
- self.submit(self.forms[id]);
- self.removeEditTemplate(this, id);
- });
- };
-
/**
* Remove inline edit template
*
- * @param {string} ele Inline edit element
- * @param {Object} id Id
+ * @param {Element} ele Inline edit element
+ * @param {string} id Id
*
* @return {void}
*
* @since 1.0.0
*/
- removeEditTemplate(ele, id)
+ removeEditTemplate (ele, id)
{
- const formElement = document.getElementById(id);
- const selectors = formElement.getAttribute('data-update-element').split(','),
- selectorLength = selectors.length;
+ const formElement = document.getElementById(id);
+ const selectors = formElement.getAttribute('data-update-element').split(',');
+ const selectorLength = selectors.length;
const saveButtons = this.forms[id].getSave();
let length = saveButtons.length;
@@ -1276,8 +1106,8 @@ export class Form
content = selLength === 1 ? ele.closest(closest) : ele.closest(closest).querySelector(subSelector);
}
- const tpls = content.parentNode.querySelectorAll('[data-marker=tpl]'),
- tplsLength = tpls.length;
+ const tpls = content.parentNode.querySelectorAll('[data-marker=tpl]');
+ const tplsLength = tpls.length;
for (let j = 0; j < tplsLength; ++j) {
tpls[j].parentNode.removeChild(tpls[j]);
@@ -1292,124 +1122,4 @@ export class Form
jsOMS.removeClass(content, 'hidden');
}
};
-
- /**
- * Bind edit button where data is edited externally
- *
- * @param {string} update Update button
- * @param {Object} id Id
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- bindUpdatableExternal(update, id)
- {
- const self = this;
-
- update.addEventListener('click', function () {
- const formElement = self.forms[id].getFormElement();
- const parent = this.closest(formElement.getAttribute('data-update-element'));
- const formId = formElement.getAttribute('data-update-form');
- const values = parent.querySelectorAll('[data-tpl-value]');
- const text = parent.querySelectorAll('[data-tpl-text]');
-
- const fields = self.forms[formId].getFormElement().querySelectorAll('[data-form="' + id + '"]');
- let length = 0;
-
- // clear form values to prevent old values getting mixed with update values
- self.forms[formId].resetValues();
-
- // hide add button + show update + show cancel
- const addButtons = self.forms[formId].getAdd();
- length = addButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.addClass(addButtons[i], 'hidden');
- }
-
- const saveButtons = self.forms[formId].getSave();
- length = saveButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.removeClass(saveButtons[i], 'hidden');
- }
-
- const cancelButtons = self.forms[formId].getCancel();
- length = cancelButtons.length;
- for (let i = 0; i < length; ++i) {
- jsOMS.removeClass(cancelButtons[i], 'hidden');
- }
-
- // set form id to fields for easier identification
- length = fields.length;
- for (let i = 0; i < length; ++i) {
- fields[i].setAttribute('data-form', eleId);
- }
-
- // insert row values data into form
- const remoteUrls = {};
- Form.insertDataIntoForm('value', formId, values, remoteUrls);
-
- // insert row text data into form
- Form.insertDataIntoForm('text', formId, text, remoteUrls);
-
- self.forms[formId].setSuccess(function(response) {
- if (response.get('status') !== 'undefined' && response.get('status') !== NotificationLevel.HIDDEN) {
- self.app.notifyManager.send(
- new NotificationMessage(response.get('status'), response.get('title'), response.get('message')), NotificationType.APP_NOTIFICATION
- );
- }
-
- console.log(remoteUrls);
-
- UriFactory.setQuery('$id', response.get('response').id);
-
- Form.setDataFromRemoteUrls(remoteUrls);
- });
-
- /**
- * @todo Karaka/jsOMS#85
- * Invalid backend/api responses (!201) should undo/stop UI changes
- *
- * @todo Karaka/jsOMS#87
- * On edit highlight the data which is changed
- */
- });
- };
-
- /**
- * 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 () {
- const callback = function() {
- const parent = remove.closest(document.getElementById(id).getAttribute('data-ui-element'));
- parent.parentNode.removeChild(parent);
- };
-
- const container = document.getElementById(id);
-
- // container can be the table tr, form or just a div
- if (container !== null
- && ((container.tagName.toLowerCase() !== 'form' && container.getAttribute('data-method') !== null)
- || (container.tagName.toLowerCase() === 'form' && container.getAttribute('method') !== 'NONE'))
- ) {
- const deleteRequest = new Request(
- container.tagName.toLowerCase() !== 'form' ? container.getAttribute('data-method') : container.getAttribute('method'),
- RequestMethod.DELETE
- );
- deleteRequest.setSuccess(callback);
- deleteRequest.send();
- } else {
- callback();
- }
- });
- };
-};
\ No newline at end of file
+};
diff --git a/UI/Component/Input.js b/UI/Component/Input.js
index d724850..5965327 100755
--- a/UI/Component/Input.js
+++ b/UI/Component/Input.js
@@ -1,4 +1,7 @@
import { Request } from '../../Message/Request/Request.js';
+import { Response } from '../../Message/Response/Response.js';
+import { RequestMethod } from '../../Message/Request/RequestMethod.js';
+import { ResponseType } from '../../Message/Response/ResponseType.js';
/**
* Form manager class.
@@ -23,32 +26,32 @@ export class Input
/**
* Unbind input element
*
- * @param {Object} input Input element
+ * @param {Element} input Input element
*
* @return {void}
*
* @since 1.0.0
*/
- static unbind(input)
+ static unbind (input)
{
this.app.inputManager.getKeyboardManager().unbind(input);
/** global: changeBind */
- input.removeEventListener('change', changeBind, false);
+ // input.removeEventListener('change', changeBind, false);
};
/**
* Bind input element
*
- * @param {Object} input Input element
+ * @param {Element} input Input element
*
* @return {void}
*
* @since 1.0.0
*/
- static bindElement(input)
+ static bindElement (input = null)
{
- if (typeof input === 'undefined') {
- throw 'Input element required';
+ if (input === null) {
+ throw new Error('Input element required');
}
const type = input.type;
@@ -56,7 +59,7 @@ export class Input
const removeContentButton = input.parentNode.querySelector('.fa-times');
if (removeContentButton !== null
&& type !== 'submit' && type !== 'button') {
- removeContentButton.addEventListener('click', function() {
+ removeContentButton.addEventListener('click', function () {
input.value = '';
input.focus();
});
@@ -68,14 +71,14 @@ export class Input
*
* This only applies for datalists that have remote options
*
- * @param {Object} input Input element
- * @param {Object} datalist Datalist element
+ * @param {Element} input Input element
+ * @param {Element} datalist Datalist element
*
* @return {void}
*
* @since 1.0.0
*/
- static addRemoteDatalistOptions(input, datalist)
+ static addRemoteDatalistOptions (input, datalist)
{
this.clearDatalistOptions(datalist);
@@ -88,18 +91,18 @@ export class Input
request.setSuccess(function (xhr)
{
try {
- const o = JSON.parse(xhr.response),
- response = new Response(o),
- responseLength = response.count();
- let tempResponse = null,
- success = null;
+ const o = JSON.parse(xhr.response);
+ const response = new Response(o);
+ const responseLength = response.count();
+ let tempResponse = null;
+ let success = null;
for (let k = 0; k < responseLength; ++k) {
tempResponse = response.getByIndex(k);
- let option = null,
- data = tempResponse.getData(),
- length = data.length;
+ let option = null;
+ const data = tempResponse.getData();
+ const length = data.length;
for (let i = 0; i < length; ++i) {
option = document.createElement('option');
@@ -120,13 +123,13 @@ export class Input
/**
* Remove all datalist options from datalist
*
- * @param {Object} datalist Datalist element
+ * @param {Element} datalist Datalist element
*
* @return {void}
*
* @since 1.0.0
*/
- static clearDatalistOptions(datalist)
+ static clearDatalistOptions (datalist)
{
const length = datalist.options.length;
diff --git a/UI/Component/Tab.js b/UI/Component/Tab.js
index 09fb260..3b502e3 100755
--- a/UI/Component/Tab.js
+++ b/UI/Component/Tab.js
@@ -14,6 +14,8 @@ export class Tab
/**
* @constructor
*
+ * @param {Object} app Application
+ *
* @since 1.0.0
*/
constructor (app)
@@ -24,15 +26,15 @@ export class Tab
/**
* Bind & rebind UI elements.
*
- * @param {string} [id] Element id
+ * @param {null|string} [id] Element id
*
* @return {void}
*
* @since 1.0.0
*/
- bind (id)
+ bind (id = null)
{
- if (typeof id !== 'undefined') {
+ if (id !== null) {
const e = document.getElementById(id);
if (e) {
@@ -51,7 +53,7 @@ export class Tab
/**
* Bind & rebind UI element.
*
- * @param {Object} e Element
+ * @param {Element} e Element
*
* @return {void}
*
@@ -59,8 +61,8 @@ export class Tab
*/
bindElement (e)
{
- const nodes = e.querySelectorAll('.tab-links li'),
- length = nodes.length;
+ const nodes = e.querySelectorAll('.tab-links li');
+ const length = nodes.length;
for (let i = 0; i < length; ++i) {
nodes[i].addEventListener('click', function (evt)
@@ -71,8 +73,8 @@ export class Tab
/* Remove selected tab */
const oldActive = this.parentNode.getElementsByClassName('active');
if (oldActive.length > 0) {
- let fragments = fragmentString.split('&');
- const index = fragments.indexOf(oldActive[0].getElementsByTagName('label')[0].getAttribute('for'));
+ const fragments = fragmentString.split('&');
+ const index = fragments.indexOf(oldActive[0].getElementsByTagName('label')[0].getAttribute('for'));
if (index > -1) {
fragments.splice(index, 1);
@@ -84,13 +86,13 @@ export class Tab
jsOMS.removeClass(oldActive[0], 'active');
}
- let fragments = fragmentString.split('&');
- const index = fragments.indexOf(this.getElementsByTagName('label')[0].getAttribute('for'));
+ const fragments = fragmentString.split('&');
+ const index = fragments.indexOf(this.getElementsByTagName('label')[0].getAttribute('for'));
/**
if (index > -1) {
fragments.splice(index, 1);
- }*/
+ } */
// find old active and remove it
fragmentString = fragments.join('&');
@@ -116,21 +118,21 @@ export class Tab
*
* This allows to link a specific open tab to a user or make it a bookmark
*
- * @param {Object} e Element
+ * @param {Element} e Element
*
* @return {void}
*
* @since 1.0.0
*/
- activateTabUri(e)
+ activateTabUri (e)
{
const fragmentString = window.location.href.includes('#') ? HttpUri.parseUrl(window.location.href).fragment : '';
- const fragments = fragmentString.split('&'),
- fragLength = fragments.length;
+ const fragments = fragmentString.split('&');
+ const fragLength = fragments.length;
if (fragLength > 0 && fragmentString !== '') {
for (let i = 0; i < fragLength; ++i) {
- let label = e.querySelectorAll('label[for="' + fragments[i] + '"]')[0];
+ const label = e.querySelectorAll('label[for="' + fragments[i] + '"]')[0];
if (typeof label !== 'undefined') {
label.click();
}
diff --git a/UI/Component/Table.js b/UI/Component/Table.js
index 7cdf886..8b328d5 100755
--- a/UI/Component/Table.js
+++ b/UI/Component/Table.js
@@ -41,7 +41,7 @@ export class Table
*
* @since 1.0.0
*/
- constructor(app)
+ constructor (app)
{
this.app = app;
@@ -53,22 +53,22 @@ export class Table
/**
* Bind & rebind UI elements.
*
- * @param {string} [id] Element id
+ * @param {null|string} [id] Element id
*
* @return {void}
*
* @since 1.0.0
*/
- bind (id)
+ bind (id = null)
{
- if (typeof id !== 'undefined' && typeof this.ignore[id] === 'undefined') {
+ if (id !== null && typeof this.ignore[id] === 'undefined') {
this.bindTable(id);
} else {
- const tables = document.getElementsByTagName('table'),
- length = !tables ? 0 : tables.length;
+ const tables = document.getElementsByTagName('table');
+ const length = !tables ? 0 : tables.length;
for (let i = 0; i < length; ++i) {
- let tableId = tables[i].getAttribute('id');
+ const tableId = tables[i].getAttribute('id');
if (typeof tableId !== 'undefined' && tableId !== null && typeof this.ignore[tableId] === 'undefined') {
this.bindTable(tableId);
}
@@ -138,12 +138,6 @@ export class Table
this.bindSorting(sorting[i], id);
}
- const order = this.tables[id].getSortableRows();
- length = order.length;
- for (let i = 0; i < length; ++i) {
- this.bindReorder(order[i], id);
- }
-
const filters = this.tables[id].getFilter();
length = filters.length;
for (let i = 0; i < length; ++i) {
@@ -169,7 +163,7 @@ export class Table
*
* @since 1.0.0
*/
- bindExport(exports)
+ bindExport (exports)
{
const button = exports.getExport();
@@ -190,7 +184,7 @@ export class Table
});
};
- /**
+ /**
* Bind column visibility
*
* @param {Element} header Header
@@ -199,7 +193,7 @@ export class Table
*
* @since 1.0.0
*/
- bindColumnVisibility(header)
+ bindColumnVisibility (header)
{
header.addEventListener('contextmenu', function (event) {
jsOMS.preventAll(event);
@@ -219,9 +213,9 @@ export class Table
const menu = document.getElementById('table-context-menu');
const columns = header.querySelectorAll('td');
- let length = columns.length;
+ const length = columns.length;
- let baseMenuLine = menu.getElementsByClassName('context-line')[0].cloneNode(true);
+ const baseMenuLine = menu.getElementsByClassName('context-line')[0].cloneNode(true);
for (let i = 0; i < length; ++i) {
if (typeof columns[i].firstChild === 'undefined'
@@ -256,14 +250,14 @@ export class Table
menu.getElementsByTagName('ul')[0].removeChild(menu.getElementsByClassName('context-line')[0]);
const rect = tpl.parentElement.getBoundingClientRect();
- menu.style.top = (event.clientY - rect.top) + "px";
- menu.style.left = (event.clientX - rect.left) + "px";
+ menu.style.top = (event.clientY - rect.top) + 'px';
+ menu.style.left = (event.clientX - rect.left) + 'px';
document.addEventListener('click', Table.hideMenuClickHandler);
});
};
- static hideMenuClickHandler(event)
+ static hideMenuClickHandler (event)
{
const menu = document.getElementById('table-context-menu');
const isClickedOutside = !menu.contains(event.target);
@@ -274,59 +268,34 @@ export class Table
}
};
- /**
- * 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)
- {
- jsOMS.preventAll(event);
-
- const table = document.getElementById(id),
- rows = table.getElementsByTagName('tbody')[0].rows,
- rowLength = rows.length,
- rowId = this.closest('tr').rowIndex - 1,
- orderType = jsOMS.hasClass(this, 'order-up') ? 1 : -1;
-
- if (orderType === 1 && rowId > 0) {
- rows[rowId].parentNode.insertBefore(rows[rowId], rows[rowId - 1]);
- } else if (orderType === -1 && rowId < rowLength) {
- rows[rowId].parentNode.insertBefore(rows[rowId], rows[rowId + 2]);
- }
- });
- };
-
/**
* Sorts the table.
*
* @param {Element} sorting Sort button
- * @param {Object} id Table id
+ * @param {string} id Table id
*
* @return {void}
*
* @since 1.0.0
*/
- bindSorting(sorting, id)
+ bindSorting (sorting, id)
{
sorting.addEventListener('click', function (event)
{
- const table = document.getElementById(id),
- rows = table.getElementsByTagName('tbody')[0].rows,
- rowLength = rows.length,
- cellId = this.closest('td').cellIndex,
- sortType = jsOMS.hasClass(this, 'sort-asc') ? 1 : -1;
+ const table = document.getElementById(id);
+ const rows = table.getElementsByTagName('tbody')[0].rows;
+ const rowLength = rows.length;
+ const cellId = this.closest('td').cellIndex;
+ const sortType = jsOMS.hasClass(this, 'sort-asc') ? 1 : -1;
- let j, i, row1, row2, content1, content2,
- order = false,
- shouldSwitch = false;
+ let j;
+ let i;
+ let row1;
+ let row2;
+ let content1;
+ let content2;
+ let order = false;
+ let shouldSwitch = false;
const columnName = this.closest('td').getAttribute('data-name');
@@ -346,10 +315,11 @@ export class Table
row1 = rows[j].getElementsByTagName('td')[cellId];
content1 = row1.getAttribute('data-content') !== null ? row1.getAttribute('data-content').toLowerCase() : row1.textContent.toLowerCase();
content1 = !isNaN(content1)
- ? parseFloat(content1)
- : (!isNaN(new Date(content1))
- ? new Date(content1)
- : content1);
+ ? parseFloat(content1)
+ : (!isNaN(new Date(content1))
+ ? new Date(content1)
+ : content1
+ );
for (i = j + 1; i < rowLength; ++i) {
row2 = rows[i].getElementsByTagName('td')[cellId];
@@ -386,13 +356,13 @@ export class Table
* Filters the table.
*
* @param {Element} filtering Filter button
- * @param {Object} id Table id
+ * @param {string} id Table id
*
* @return {void}
*
* @since 1.0.0
*/
- bindFiltering(filtering, id)
+ bindFiltering (filtering, id)
{
filtering.addEventListener('click', function (event)
{
@@ -404,13 +374,13 @@ export class Table
* Checkbox select.
*
* @param {Element} checkbox Filter button
- * @param {Object} id Table id
+ * @param {string} id Table id
*
* @return {void}
*
* @since 1.0.0
*/
- bindCheckbox(checkbox, id)
+ bindCheckbox (checkbox, id)
{
checkbox.addEventListener('click', function (event)
{
@@ -452,7 +422,7 @@ export class Table
request.send();
};
- static emptyTable(table)
+ static emptyTable (table)
{
const rows = table.getElementsByTagName('tr');
const length = rows.length;
@@ -462,7 +432,7 @@ export class Table
}
};
- static addToTable(table, data)
+ static addToTable (table, data)
{
const dataLength = data.length;
diff --git a/UI/DragNDrop.js b/UI/DragNDrop.js
index e3c89ed..195b145 100755
--- a/UI/DragNDrop.js
+++ b/UI/DragNDrop.js
@@ -22,38 +22,25 @@ export class DragNDrop
this.dragging = null;
};
- /**
- * Unbind element
- *
- * @param {Object} element DOM element
- *
- * @return {void}
- *
- * @since 1.0.0
- */
- unbind (element)
- {
- };
-
/**
* Bind element
*
- * @param {Object} [element] DOM element
+ * @param {null|Element} element DOM element
*
* @return {void}
*
* @since 1.0.0
*/
- bind (element)
+ bind (element = null)
{
- if (typeof element !== 'undefined') {
+ if (element !== null) {
this.bindElement(element);
} else {
- const elements = document.querySelectorAll('[draggable]'),
- length = !elements ? 0 : elements.length;
+ const elements = document.querySelectorAll('.dragcontainer');
+ const length = !elements ? 0 : elements.length;
for (let i = 0; i < length; ++i) {
- this.bindElement(elements[i]);
+ this.bindElement(elements[i]);
}
}
};
@@ -61,7 +48,7 @@ export class DragNDrop
/**
* Bind DOM element
*
- * @param {string} id DOM element
+ * @param {Element} element DOM element
*
* @return {void}
*
@@ -75,21 +62,23 @@ export class DragNDrop
return;
}
- element.addEventListener('dragstart', function(e) {
+ element.addEventListener('dragstart', function (e) {
if (self.dragging === null) {
- self.dragging = this;
+ self.dragging = e.target;
e.dataTransfer.effectAllowed = 'move';
- e.dataTransfer.setData('text/html', this.innerHTML);
+ e.dataTransfer.setData('text/html', e.target.innerHTML);
}
}, false);
- element.addEventListener('dragenter', function(e) {
- const rowIndex = Array.from(this.parentElement.children).indexOf(this);
- const dragIndex = Array.from(self.dragging.parentElement.children).indexOf(self.dragging);
+ element.addEventListener('dragenter', function (e) {
+ const thisElement = e.target.closest('.dragcontainer ' + this.children[this.children.length - 1].tagName);
- const oldPlaceholder = this.parentNode.querySelector('.drag-placeholder');
+ const rowIndex = Array.from(this.children).indexOf(thisElement);
+ const dragIndex = Array.from(self.dragging.children).indexOf(self.dragging);
+
+ const oldPlaceholder = this.querySelector('.drag-placeholder');
if (oldPlaceholder !== null) {
- this.parentNode.removeChild(oldPlaceholder);
+ this.removeChild(oldPlaceholder);
}
const placeholder = document.createElement(self.dragging.tagName);
@@ -105,39 +94,39 @@ export class DragNDrop
jsOMS.addClass(placeholder, 'drag-placeholder');
if (dragIndex < rowIndex) {
- this.parentNode.insertBefore(placeholder, this.nextSibling);
+ this.insertBefore(placeholder, thisElement.nextSibling);
} else {
- this.parentNode.insertBefore(placeholder, this);
+ this.insertBefore(placeholder, thisElement);
}
}, false);
- element.addEventListener('dragover', function(e) {
+ element.addEventListener('dragover', function (e) {
e.preventDefault();
e.dataTransfer.dropEffect = 'move';
}, false);
- element.addEventListener('dragleave', function(e) {
+ element.addEventListener('dragleave', function (e) {
e.preventDefault();
}, false);
- element.addEventListener('dragend', function(e) {
+ element.addEventListener('dragend', function (e) {
e.preventDefault();
- const oldPlaceholder = this.parentNode.querySelector('.drag-placeholder');
+ const oldPlaceholder = this.querySelector('.drag-placeholder');
if (oldPlaceholder === null) {
return;
}
- this.parentNode.insertBefore(self.dragging, oldPlaceholder);
- this.parentNode.removeChild(oldPlaceholder);
+ this.insertBefore(self.dragging, oldPlaceholder);
+ this.removeChild(oldPlaceholder);
self.dragging = null;
}, false);
- element.addEventListener('drop', function(e) {
+ element.addEventListener('drop', function (e) {
e.stopPropagation();
e.preventDefault();
}, false);
}
-};
\ No newline at end of file
+};
diff --git a/UI/GeneralUI.js b/UI/GeneralUI.js
index 2382172..6540839 100755
--- a/UI/GeneralUI.js
+++ b/UI/GeneralUI.js
@@ -21,23 +21,25 @@ export class GeneralUI
*/
constructor (app)
{
+ /** @type {null|IntersectionObserver} visObs */
this.visObs = null;
- this.app = app;
+
+ this.app = app;
};
/**
* Bind button.
*
- * @param {string} [id] Button id (optional)
+ * @param {null|string} [id] Button id (optional)
*
* @return {void}
*
* @since 1.0.0
*/
- bind (id)
+ bind (id = null)
{
let e = null;
- if (typeof id !== 'undefined' && id !== null) {
+ if (id !== null) {
e = document.getElementById(id);
}
@@ -50,15 +52,18 @@ export class GeneralUI
/**
* Bind & rebind UI element.
*
- * @param {Object} [e] Element
+ * @param {null|Element} [e] Element
*
* @return {void}
*
* @since 1.0.0
*/
- bindHref (e)
+ bindHref (e = null)
{
- e = e !== null ? e.querySelectorAll('[data-href], [href]') : document.querySelectorAll('[data-href], [href]');
+ e = e !== null
+ ? e.querySelectorAll('[data-href], [href]')
+ : document.querySelectorAll('[data-href], [href]');
+
const length = e.length;
for (let i = 0; i < length; ++i) {
@@ -67,7 +72,7 @@ export class GeneralUI
}
// @todo: implement middle mouse click
- e[i].addEventListener('click', function(event) {
+ e[i].addEventListener('click', function (event) {
if ((event.target.parentElement !== this
&& event.target.parentElement.getElementsByTagName('input').length > 0)
|| (event.target.getElementsByTagName('input').length > 0)
@@ -99,15 +104,18 @@ export class GeneralUI
/**
* Bind & rebind UI element.
*
- * @param {Object} [e] Element id
+ * @param {null|Element} [e] Element id
*
* @return {void}
*
* @since 1.0.0
*/
- bindIframe (e)
+ bindIframe (e = null)
{
- e = e !== null ? e : document.getElementsByTagName('iframe');
+ e = e !== null
+ ? e
+ : document.getElementsByTagName('iframe');
+
const length = e.length;
for (let i = 0; i < length; ++i) {
@@ -115,29 +123,32 @@ export class GeneralUI
e[i].height = e[i].contentWindow.document.body.scrollHeight + 25;
}
- e[i].addEventListener('load', function() {
+ e[i].addEventListener('load', function () {
this.height = this.contentWindow.document.body.scrollHeight + 25;
});
}
- }
+ };
/**
* Bind & rebind UI element.
*
- * @param {Object} [e] Element id
+ * @param {null|Element} [e] Element id
*
* @return {void}
*
* @since 1.0.0
*/
- bindLazyLoad (e)
+ bindLazyLoad (e = null)
{
- e = e !== null ? e.querySelectorAll('[data-lazyload]') : document.querySelectorAll('[data-lazyload]');
+ e = e !== null
+ ? e.querySelectorAll('[data-lazyload]')
+ : document.querySelectorAll('[data-lazyload]');
+
const length = e.length;
/** global: IntersectionObserver */
if (!this.visObs && window.IntersectionObserver) {
- this.visObs = new IntersectionObserver(function(eles, obs) {
+ this.visObs = new IntersectionObserver(function (eles, obs) {
eles.forEach(ele => {
if (ele.intersectionRatio > 0) {
obs.unobserve(ele.target);
@@ -161,15 +172,18 @@ export class GeneralUI
/**
* Bind & rebind UI element.
*
- * @param {Object} [e] Element id
+ * @param {null|Element} [e] Element id
*
* @return {void}
*
* @since 1.0.0
*/
- bindInput (e)
+ bindInput (e = null)
{
- e = e !== null ? [e] : document.getElementsByClassName('advancedInput');
+ e = e !== null
+ ? [e]
+ : document.getElementsByClassName('advancedInput');
+
const length = e.length;
for (let i = 0; i < length; ++i) {
@@ -177,7 +191,17 @@ export class GeneralUI
}
};
- static setValueOfElement(src, value)
+ /**
+ * Set the value for an elment
+ *
+ * @param {Element} src Element to change the value for
+ * @param {any} value Value to set
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
+ static setValueOfElement (src, value)
{
if (src.hasAttribute('data-value')) {
src.setAttribute('data-value', value);
@@ -196,7 +220,7 @@ export class GeneralUI
src.innerHTML = jsOMS.htmlspecialchars_encode(value);
break;
- case 'select':
+ case 'select': {
const optionLength = src.options.length;
for (let i = 0; i < optionLength; ++i) {
if (src.options[i].value === value) {
@@ -207,29 +231,38 @@ export class GeneralUI
}
break;
+ }
case 'input':
if (src.type === 'radio') {
src.checked = false;
if (src.value === value) {
src.checked = true;
}
-
- break;
} else if (src.type === 'checkbox') {
src.checked = false;
const values = value.split(',');
if (values.includes(src.value)) {
src.checked = true;
}
-
- break;
}
+
+ break;
default:
src.value = jsOMS.htmlspecialchars_decode(value);
}
};
- static setTextOfElement(src, value)
+ /**
+ * Set the text for an elment
+ *
+ * @param {Element} src Element to change the text for
+ * @param {string} value Text to set
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
+ static setTextOfElement (src, value)
{
switch (src.tagName.toLowerCase()) {
case 'select':
@@ -252,7 +285,16 @@ export class GeneralUI
}
};
- static getValueFromDataSource(src)
+ /**
+ * Get value from element
+ *
+ * @param {Element} src Element to get the value from
+ *
+ * @return {any}
+ *
+ * @since 1.0.0
+ */
+ static getValueFromDataSource (src)
{
if (src.getAttribute('data-value') !== null) {
return src.getAttribute('data-value');
@@ -268,11 +310,34 @@ export class GeneralUI
case 'h1':
return src.innerText.trim(' ');
default:
+ if (src.getAttribute('type') === 'radio') {
+ const checked = document.querySelector('input[type=radio][name="' + src.name + '"]:checked');
+
+ if (checked === null) {
+ return '';
+ }
+
+ src = checked;
+ } else if (src.getAttribute('type') === 'checkbox') {
+ if (!src.checked) {
+ return '';
+ }
+ }
+
return src.value;
}
};
- static getTextFromDataSource(src)
+ /**
+ * Get text from element
+ *
+ * @param {Element} src Element to get the text from
+ *
+ * @return {string}
+ *
+ * @since 1.0.0
+ */
+ static getTextFromDataSource (src)
{
switch (src.tagName.toLowerCase()) {
case 'td':
@@ -286,9 +351,23 @@ export class GeneralUI
case 'select':
return src.options[src.selectedIndex].text;
case 'input':
- if (src.getAttribute('type') === 'checkbox' || src.getAttribute('type') === 'radio') {
+ if (src.getAttribute('type') === 'radio') {
+ const checked = document.querySelector('input[type=radio][name="' + src.name + '"]:checked');
+
+ if (checked === null) {
+ return '';
+ }
+
+ return document.querySelector('label[for="' + checked.id + '"]').innerText.trim(' ');
+ } else if (src.getAttribute('type') === 'checkbox') {
+ if (!src.checked) {
+ return '';
+ }
+
return document.querySelector('label[for="' + src.id + '"]').innerText.trim(' ');
}
+
+ return src.value;
default:
return src.value;
}
diff --git a/UI/Input/InputManager.js b/UI/Input/InputManager.js
index 286cae3..0163318 100755
--- a/UI/Input/InputManager.js
+++ b/UI/Input/InputManager.js
@@ -19,7 +19,7 @@ export class InputManager
*
* @since 1.0.0
*/
- constructor(app)
+ constructor (app)
{
this.keyboardManager = new KeyboardManager();
this.mouseManager = new MouseManager();
diff --git a/UI/Input/Keyboard/KeyboardManager.js b/UI/Input/Keyboard/KeyboardManager.js
index ce41aca..3505339 100755
--- a/UI/Input/Keyboard/KeyboardManager.js
+++ b/UI/Input/Keyboard/KeyboardManager.js
@@ -22,9 +22,9 @@ export class KeyboardManager
/**
* Add input listener.
*
- * @param {string} element Container id
- * @param {Array} keys Keyboard keys
- * @param {callback} callback Callback
+ * @param {string} element Container id
+ * @param {Array} keys Keyboard keys
+ * @param {function} callback Callback
*
* @return {void}
*
@@ -38,7 +38,7 @@ export class KeyboardManager
this.bind(element);
}
- this.elements[element].push({keys: keys, callback: callback});
+ this.elements[element].push({ keys: keys, callback: callback });
};
/**
@@ -53,17 +53,17 @@ export class KeyboardManager
bind (element)
{
const self = this;
- const elements = element === '' ? [document] : document.querySelectorAll(element),
- length = elements.length;
+ const elements = element === '' ? [document] : document.querySelectorAll(element);
+ const length = elements.length;
for (let i = 0; i < length; ++i) {
- elements[i].addEventListener('keydown', function keyBind(event)
+ elements[i].addEventListener('keydown', function (event)
{
self.down.push(event.keyCode);
self.run(element, event);
});
- elements[i].addEventListener('keyup', function keyBind(event)
+ elements[i].addEventListener('keyup', function (event)
{
let index = self.down.indexOf(event.keyCode);
while (index > -1) {
@@ -78,7 +78,7 @@ export class KeyboardManager
* Execute callback based on key presses.
*
* @param {string} element Container id
- * @param {Object} event Key event
+ * @param {Event} event Key event
*
* @return {void}
*
@@ -89,12 +89,12 @@ export class KeyboardManager
run (element, event)
{
if (typeof this.elements[element] === 'undefined') {
- throw 'Unexpected elmenet!';
+ throw new Error('Unexpected elmenet!');
}
- const actions = this.elements[element].concat(this.elements['']),
- actionsLength = actions.length,
- downKeyLength = this.down.length;
+ const actions = this.elements[element].concat(this.elements['']);
+ const actionsLength = actions.length;
+ const downKeyLength = this.down.length;
for (let i = 0; i < actionsLength; ++i) {
const actionKeyLength = actions[i].keys.length;
diff --git a/UI/Input/Mouse/MouseManager.js b/UI/Input/Mouse/MouseManager.js
index 2de874b..004750e 100755
--- a/UI/Input/Mouse/MouseManager.js
+++ b/UI/Input/Mouse/MouseManager.js
@@ -18,17 +18,17 @@ export class MouseManager
constructor ()
{
this.elements = {};
- this.click = {time: 0};
+ this.click = { time: 0 };
};
/**
* Add input listener.
*
- * @param {string} element Container id
- * @param {int} type Action type
- * @param {int} button Button
- * @param {callback} callback Callback
- * @param {bool} exact ??? todo: can't remember why this was important oO!!!
+ * @param {string} element Container id
+ * @param {number} type Action type
+ * @param {number} button Button
+ * @param {function} callback Callback
+ * @param {boolean} exact ??? todo: can't remember why this was important oO!!!
*
* @return {void}
*
@@ -41,14 +41,14 @@ export class MouseManager
}
this.bind(element, type);
- this.elements[element].push({callback: callback, type: type, button: button, exact: exact});
+ this.elements[element].push({ callback: callback, type: type, button: button, exact: exact });
};
/**
* Add input listener.
*
* @param {string} element Element id
- * @param {int} type Action type
+ * @param {number} type Action type
*
* @return {void}
*
@@ -56,8 +56,8 @@ export class MouseManager
*/
bind (element, type)
{
- const self = this,
- e = document.getElementById(element);
+ const self = this;
+ const e = document.getElementById(element);
if (!e) {
return;
@@ -96,7 +96,7 @@ export class MouseManager
* Run mouse input callback.
*
* @param {string} element Element id
- * @param {Object} event Click event
+ * @param {Event} event Click event
*
* @return {void}
*
@@ -105,11 +105,11 @@ export class MouseManager
run (element, event)
{
if (typeof this.elements[element] === 'undefined') {
- throw 'Unexpected elmenet!';
+ throw new Error('Unexpected elmenet!');
}
- const actions = this.elements[element],
- length = actions.length;
+ const actions = this.elements[element];
+ const length = actions.length;
for (let i = 0; i < length; ++i) {
if ((!actions[i].exact || event.target.getAttribute('id') === element)
diff --git a/UI/Input/Touch/TouchManager.js b/UI/Input/Touch/TouchManager.js
index 0fa75f1..d2e42d3 100755
--- a/UI/Input/Touch/TouchManager.js
+++ b/UI/Input/Touch/TouchManager.js
@@ -33,7 +33,7 @@ export class TouchManager
*/
resetSwipe ()
{
- this.activeSwipe = {'startX': null, 'startY': null, 'time': null};
+ this.activeSwipe = { startX: null, startY: null, time: null };
};
/**
@@ -41,14 +41,16 @@ export class TouchManager
*
* Forwarding swipe to arrow keys.
*
+ * @param {string} surface Surface id
+ *
* @return {void}
*
* @since 1.0.0
*/
add (surface)
{
- const e = document.getElementById(surface),
- self = this;
+ const e = document.getElementById(surface);
+ const self = this;
if (!e) {
return;
@@ -72,17 +74,17 @@ export class TouchManager
e.addEventListener('touchend', function (event)
{
- const touch = this.changedTouches[0],
- distX = touch.pageX - self.activeSwipe.startX,
- distY = touch.pageY - self.activeSwipe.startY,
- elapsedTime = new Date().getTime() - self.activeSwipe.time;
+ const touch = this.changedTouches[0];
+ const distX = touch.pageX - self.activeSwipe.startX;
+ const distY = touch.pageY - self.activeSwipe.startY;
+ const elapsedTime = new Date().getTime() - self.activeSwipe.time;
self.resetSwipe();
if (elapsedTime > 300 && distY < 3 && distX < 3) {
jsOMS.preventAll(event);
- let rightClick = MouseEvent('click',
+ const rightClick = MouseEvent('click',
{
bubbles: true,
cancelable: true,
diff --git a/UI/Input/Voice/ReadManager.js b/UI/Input/Voice/ReadManager.js
index 04360e9..1cd084b 100755
--- a/UI/Input/Voice/ReadManager.js
+++ b/UI/Input/Voice/ReadManager.js
@@ -41,7 +41,7 @@ export class ReadManager
read (text)
{
/** global: SpeechSynthesisUtterance */
- let utter = new SpeechSynthesisUtterance(text);
+ const utter = new SpeechSynthesisUtterance(text);
utter.lang = this.lang;
utter.voice = this.voice;
utter.pitch = this.pitch;
@@ -119,4 +119,4 @@ var SpeechGrammarList = typeof SpeechGrammarList !== 'undefined' ? SpeechGrammar
/** global: webkitSpeechRecognitionEvent */
/** global: SpeechRecognitionEvent */
-var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null;
\ No newline at end of file
+var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null;
diff --git a/UI/Input/Voice/VoiceManager.js b/UI/Input/Voice/VoiceManager.js
index 1a9aaff..4b0004d 100755
--- a/UI/Input/Voice/VoiceManager.js
+++ b/UI/Input/Voice/VoiceManager.js
@@ -19,7 +19,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- constructor(app, commands = {}, lang = 'en-US')
+ constructor (app, commands = {}, lang = 'en-US')
{
this.app = app;
this.commands = commands;
@@ -40,7 +40,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- setup()
+ setup ()
{
if (SpeechRecognition === null) {
return;
@@ -58,33 +58,32 @@ export class VoiceManager
this.recognition.grammars = this.speechRecognitionList;
}
- this.recognition.onstart = function() {};
+ this.recognition.onstart = function () {};
// @todo find a way to run a re-init after end every x seconds (where x = 3 or 5 seconds)
- //this.recognition.addEventListener('end', reset(function() {return self.recognition.start}, 3000));
+ // this.recognition.addEventListener('end', reset(function () {return self.recognition.start}, 3000));
- this.recognition.onresult = function(event)
+ this.recognition.onresult = function (event)
{
- let result = jsOMS.trim(event.results[event.resultIndex][0].transcript);
-
+ const result = jsOMS.trim(event.results[event.resultIndex][0].transcript);
const commands = Object.keys(self.commands);
- for (let command of commands) {
+ for (const command of commands) {
if (result.startsWith(command)) {
self.commands[command](result.substr(command.length).trim());
}
}
};
- this.recognition.onspeechend = function()
+ this.recognition.onspeechend = function ()
{
};
- this.recognition.onnomatch = function(event)
+ this.recognition.onnomatch = function (event)
{
Logger.instance.warning('Couldn\'t recognize speech');
};
- this.recognition.onerror = function(event)
+ this.recognition.onerror = function (event)
{
Logger.instance.warning('Error during speech recognition: ' + event.error);
};
@@ -97,7 +96,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- getCommandsString()
+ getCommandsString ()
{
return '#JSGF V1.0; grammar phrase; public = ' + Object.keys(this.commands).join(' | ') + ' ;';
};
@@ -111,7 +110,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- setLanguage(lang)
+ setLanguage (lang)
{
this.recognition.lang = lang;
};
@@ -126,7 +125,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- add(command, callback)
+ add (command, callback)
{
this.commands[command] = callback;
};
@@ -138,7 +137,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- start()
+ start ()
{
if (SpeechRecognition === null) {
return;
@@ -154,7 +153,7 @@ export class VoiceManager
*
* @since 1.0.0
*/
- stop()
+ stop ()
{
if (SpeechRecognition === null) {
return;
@@ -178,4 +177,4 @@ var SpeechGrammarList = typeof SpeechGrammarList !== 'undefined' ? SpeechGrammar
/** global: webkitSpeechRecognitionEvent */
/** global: SpeechRecognitionEvent */
-var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null;
\ No newline at end of file
+var SpeechRecognitionEvent = typeof SpeechRecognitionEvent !== 'undefined' ? SpeechRecognitionEvent : typeof webkitSpeechRecognitionEvent !== 'undefined' ? webkitSpeechRecognitionEvent : null;
diff --git a/UI/Loader.js b/UI/Loader.js
index ec38ab4..1257e7c 100755
--- a/UI/Loader.js
+++ b/UI/Loader.js
@@ -1 +1 @@
-/* responsible for loading external ui elements (css,html,js) */
\ No newline at end of file
+/* responsible for loading external ui elements (css,html,js) */
diff --git a/UI/Order.js b/UI/Order.js
new file mode 100644
index 0000000..b23c9a4
--- /dev/null
+++ b/UI/Order.js
@@ -0,0 +1,83 @@
+/**
+ * Manual order class.
+ *
+ * @copyright Dennis Eichhorn
+ * @license OMS License 1.0
+ * @version 1.0.0
+ * @since 1.0.0
+ */
+export class Order
+{
+ /**
+ * @constructor
+ *
+ * @param {Object} app Application
+ *
+ * @since 1.0.0
+ */
+ constructor (app)
+ {
+ this.app = app;
+ };
+
+ /**
+ * Bind element
+ *
+ * @param {Object} [element] DOM element
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
+ bind (element)
+ {
+ if (typeof element !== 'undefined') {
+ this.bindElement(element);
+ } else {
+ const elements = document.querySelectorAll('.ordercontainer');
+ const length = !elements ? 0 : elements.length;
+
+ for (let i = 0; i < length; ++i) {
+ this.bindElement(elements[i]);
+ }
+ }
+ };
+
+ /**
+ * Bind DOM element
+ *
+ * @param {string} id DOM element
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
+ bindElement (element)
+ {
+ if (!element) {
+ return;
+ }
+
+ element.addEventListener('click', function (event) {
+ if (!jsOMS.hasClass(event.target, 'order-up')
+ && !jsOMS.hasClass(event.target, 'order-down')
+ ) {
+ return;
+ }
+
+ jsOMS.preventAll(event);
+
+ const rowLength = element.children.length;
+ const thisElement = event.target.closest('.ordercontainer ' + this.children[rowLength - 1].tagName);
+
+ const rowId = Array.from(element.children).indexOf(thisElement);
+ const orderType = jsOMS.hasClass(event.target, 'order-up') ? 1 : -1;
+
+ if (orderType === 1 && rowId > 0) {
+ element.insertBefore(element.children[rowId], element.children[rowId - 1]);
+ } else if (orderType === -1 && rowId < rowLength) {
+ element.insertBefore(element.children[rowId], element.children[rowId + 2]);
+ }
+ }, false);
+ }
+};
diff --git a/UI/UIManager.js b/UI/UIManager.js
index 9b7bef3..2f5d075 100755
--- a/UI/UIManager.js
+++ b/UI/UIManager.js
@@ -3,6 +3,7 @@ import { Tab } from '../UI/Component/Tab.js';
import { Table } from '../UI/Component/Table.js';
import { ActionManager } from '../UI/ActionManager.js';
import { DragNDrop } from '../UI/DragNDrop.js';
+import { Order } from '../UI/Order.js';
import { GeneralUI } from '../UI/GeneralUI.js';
/**
@@ -22,7 +23,7 @@ export class UIManager
*
* @since 1.0.0
*/
- constructor(app)
+ constructor (app)
{
this.app = app;
this.formManager = new Form(this.app);
@@ -30,11 +31,12 @@ export class UIManager
this.tableManager = new Table(this.app);
this.actionManager = new ActionManager(this.app);
this.dragNDrop = new DragNDrop(this.app);
+ this.order = new Order(this.app);
this.generalUI = new GeneralUI(this.app);
const self = this;
/** global: MutationObserver */
- this.domObserver = new MutationObserver(function(mutations) {
+ this.domObserver = new MutationObserver(function (mutations) {
const length = mutations.length;
for (let i = 0; i < length; ++i) {
@@ -52,7 +54,7 @@ export class UIManager
*
* @since 1.0.0
*/
- bind(id)
+ bind (id)
{
if (typeof id === 'undefined') {
this.formManager.bind();
@@ -60,6 +62,7 @@ export class UIManager
this.tableManager.bind();
this.actionManager.bind();
this.dragNDrop.bind();
+ this.order.bind();
this.generalUI.bind();
} else {
const tag = document.getElementById(id);
@@ -89,7 +92,7 @@ export class UIManager
*
* @since 1.0.0
*/
- getFormManager()
+ getFormManager ()
{
return this.formManager;
};
@@ -101,7 +104,7 @@ export class UIManager
*
* @since 1.0.0
*/
- getActionManager()
+ getActionManager ()
{
return this.actionManager;
};
@@ -113,11 +116,23 @@ export class UIManager
*
* @since 1.0.0
*/
- getDragNDrop()
+ getDragNDrop ()
{
return this.dragNDrop;
};
+ /**
+ * Get drag and drop manager.
+ *
+ * @return {Object}
+ *
+ * @since 1.0.0
+ */
+ getOrder ()
+ {
+ return this.order;
+ };
+
/**
* Get tab manager.
*
@@ -125,7 +140,7 @@ export class UIManager
*
* @since 1.0.0
*/
- getTabManager()
+ getTabManager ()
{
return this.tabManager;
};
@@ -137,7 +152,7 @@ export class UIManager
*
* @since 1.0.0
*/
- getTableManager()
+ getTableManager ()
{
return this.tabManager;
};
@@ -149,7 +164,7 @@ export class UIManager
*
* @since 1.0.0
*/
- getDOMObserver()
+ getDOMObserver ()
{
return this.domObserver;
};
@@ -161,8 +176,8 @@ export class UIManager
*
* @since 1.0.0
*/
- getGeneralUI()
+ getGeneralUI ()
{
return this.generalUI;
};
-};
\ No newline at end of file
+};
diff --git a/UnhandledException.js b/UnhandledException.js
index 68078f8..76467db 100755
--- a/UnhandledException.js
+++ b/UnhandledException.js
@@ -10,12 +10,14 @@
*/
(function ()
{
- "use strict";
+ 'use strict';
+
+ /** @type {Error} e */
window.addEventListener('error', function (e)
{
/** global: jsOMS */
- //jsOMS.Log.Logger.instance.error(e.error);
+ // jsOMS.Log.Logger.instance.error(e.error);
return false;
});
-}(window.jsOMS = window.jsOMS || {}));
\ No newline at end of file
+}(window.jsOMS = window.jsOMS || {}));
diff --git a/Uri/HttpUri.js b/Uri/HttpUri.js
index 60f5e2f..4252fe6 100755
--- a/Uri/HttpUri.js
+++ b/Uri/HttpUri.js
@@ -17,19 +17,40 @@ export class HttpUri
*
* @since 1.0.0
*/
- constructor(uri)
+ constructor (uri)
{
- this.uri = '';
- this.scheme = '';
- this.host = '';
- this.port = '';
- this.user = '';
- this.pass = '';
- this.query = null;
+ /** @type {string} uri */
+ this.uri = '';
+
+ /** @type {string} scheme */
+ this.scheme = '';
+
+ /** @type {string} host */
+ this.host = '';
+
+ /** @type {string} port */
+ this.port = '';
+
+ /** @type {string} user */
+ this.user = '';
+
+ /** @type {string} pass */
+ this.pass = '';
+
+ /** @type {null|Object} query */
+ this.query = null;
+
+ /** @type {null|string} queryString */
this.queryString = '';
- this.fragment = '';
- this.base = '';
- this.root = '/';
+
+ /** @type {string} fragment */
+ this.fragment = '';
+
+ /** @type {string} base */
+ this.base = '';
+
+ /** @type {string} root */
+ this.root = '/';
this.set(uri);
};
@@ -44,29 +65,30 @@ export class HttpUri
*
* @throws {Error}
*
- * @todo The default parseer fails for uris which have a query without a value but a fragment e.g. ?debug#something.
+ * @todo The default parser fails for uris which have a query without a value but a fragment e.g. ?debug#something.
* In such a case something#something is returned as fragment instead of just #something or something
*
* @since 1.0.0
*/
static parseUrl (str, mode = 'php')
{
- const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
+ const key = ['source', 'scheme', 'authority', 'userInfo', 'user', 'pass', 'host', 'port',
'relative', 'path', 'directory', 'file', 'query', 'fragment'
- ],
- parser = {
- php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
+ ];
+
+ const parser = {
+ php: /^(?:([^:\/?#]+):)?(?:\/\/()(?:(?:()(?:([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?()(?:(()(?:(?:[^?#\/]*\/)*)()(?:[^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
- loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
+ loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/\/?)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // Added one optional slash to post-scheme to catch file:/// (should restrict this)
};
- if (!parser.hasOwnProperty(mode)) {
+ if (!Object.prototype.hasOwnProperty.call(parser, mode)) {
throw new Error('Unexpected parsing mode.', 'UriFactory', 52);
}
- const m = parser[mode].exec(str),
- uri = {};
- let i = 14;
+ const m = parser[mode].exec(str);
+ const uri = {};
+ let i = 14;
while (--i) {
if (m[i]) {
@@ -85,16 +107,16 @@ export class HttpUri
* @param {string} query Uri query
* @param {string} name Name of the query to return
*
- * @return {null|string}
+ * @return {string}
*
* @since 1.0.0
*/
static getUriQueryParameter (query, name)
{
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
- const regex = new RegExp("[\\?&]*" + name + "=([^]*)"),
- results = regex.exec(query);
+ const regex = new RegExp('[\\?&]*' + name + '=([^]*)');
+ const results = regex.exec(query);
return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
};
@@ -111,14 +133,14 @@ export class HttpUri
static getAllUriQueryParameters (query)
{
const params = {};
- let keyValPairs = [],
- pairNum = null;
+ let keyValPairs = [];
+ let pairNum = null;
if (query.length) {
keyValPairs = query.split('&');
for (pairNum in keyValPairs) {
- if (!keyValPairs.hasOwnProperty(pairNum)) {
+ if (!Object.prototype.hasOwnProperty.call(keyValPairs, pairNum)) {
continue;
}
@@ -154,24 +176,24 @@ export class HttpUri
const parsed = HttpUri.parseUrl(this.uri, 'php');
- this.scheme = parsed['scheme'];
- this.host = parsed['host'];
- this.port = parsed['port'];
- this.user = parsed['user'];
- this.pass = parsed['pass'];
- this.path = parsed['path'];
+ this.scheme = parsed.scheme;
+ this.host = parsed.host;
+ this.port = parsed.port;
+ this.user = parsed.user;
+ this.pass = parsed.pass;
+ this.path = parsed.path;
if (this.path.endsWith('.php')) {
this.path = this.path.substr(0, -4);
}
- this.queryString = typeof parsed['query'] !== 'undefined' ? parsed['query'] : [];
+ this.queryString = typeof parsed.query !== 'undefined' ? parsed.query : [];
if (this.queryString !== null) {
this.query = HttpUri.getAllUriQueryParameters(this.queryString);
}
- this.fragment = typeof parsed['fragment'] !== 'undefined' ? parsed['fragment'] : '';
+ this.fragment = typeof parsed.fragment !== 'undefined' ? parsed.fragment : '';
this.base = this.scheme + '://' + this.host + this.root;
};
@@ -184,7 +206,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- setRootPath(rootPath)
+ setRootPath (rootPath)
{
this.root = rootPath;
this.set(this.uri);
@@ -197,7 +219,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getBase()
+ getBase ()
{
return this.base;
};
@@ -209,7 +231,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getScheme()
+ getScheme ()
{
return this.scheme;
};
@@ -221,7 +243,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getHost()
+ getHost ()
{
return this.host;
};
@@ -233,7 +255,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getPort()
+ getPort ()
{
return this.port;
};
@@ -245,7 +267,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getUser()
+ getUser ()
{
return this.user;
};
@@ -257,7 +279,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getPass()
+ getPass ()
{
return this.pass;
};
@@ -269,7 +291,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getQuery()
+ getQuery ()
{
return this.queryString;
};
@@ -281,7 +303,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getUri()
+ getUri ()
{
return this.uri;
};
@@ -293,7 +315,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getFragment()
+ getFragment ()
{
return this.fragment;
};
@@ -305,7 +327,7 @@ export class HttpUri
*
* @since 1.0.0
*/
- getPath()
+ getPath ()
{
return this.path;
};
@@ -313,12 +335,12 @@ export class HttpUri
/**
* Get Uri path offset
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
- getPathOffset()
+ getPathOffset ()
{
return jsOMS.substr_count(this.root, '/') - 1;
};
-};
\ No newline at end of file
+};
diff --git a/Uri/UriFactory.js b/Uri/UriFactory.js
index 880e0fe..8558ed0 100755
--- a/Uri/UriFactory.js
+++ b/Uri/UriFactory.js
@@ -28,11 +28,9 @@ export class UriFactory
*
* @since 1.0.0
*/
- static setQuery (key, value, overwrite)
+ static setQuery (key, value, overwrite = true)
{
- overwrite = typeof overwrite !== 'undefined' ? overwrite : true;
-
- if (overwrite || !UriFactory.uri.hasOwnProperty(key)) {
+ if (overwrite || !Object.prototype.hasOwnProperty.call(UriFactory.uri, key)) {
UriFactory.uri[key] = value;
return true;
@@ -52,7 +50,7 @@ export class UriFactory
*/
static getQuery (key)
{
- return UriFactory.uri.hasOwnProperty(key) ? UriFactory.uri[key] : null;
+ return Object.prototype.hasOwnProperty.call(UriFactory.uri, key) ? UriFactory.uri[key] : null;
};
/**
@@ -80,7 +78,7 @@ export class UriFactory
*/
static clear (key)
{
- if (UriFactory.uri.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(UriFactory.uri, key)) {
delete UriFactory.uri[key];
return true;
@@ -104,7 +102,7 @@ export class UriFactory
const regexp = new RegExp(pattern);
for (const key in UriFactory.uri) {
- if (UriFactory.uri.hasOwnProperty(key) && regexp.test(key)) {
+ if (Object.prototype.hasOwnProperty.call(UriFactory.uri, key) && regexp.test(key)) {
delete UriFactory.uri[key];
success = true;
}
@@ -134,15 +132,15 @@ export class UriFactory
// unique queries
const parts = typeof parsed.query === 'undefined' ? [] : parsed.query.replace(/\?/g, '&').split('&');
- let comps = {},
- spl = null,
- length = parts.length;
+ const comps = {};
+ const length = parts.length;
+ let spl = null;
// fix bug for queries such as https://127.0.0.1/test?something#frag where no value is specified for a query parameter
if ((typeof parsed.fragment === 'undefined' || parsed.fragment === null)
&& parts[length - 1].includes('#')
) {
- const lastQuery = parts[length - 1].split('#')[1];;
+ const lastQuery = parts[length - 1].split('#')[1];
parsed.fragment = lastQuery[1];
parts[length - 1] = lastQuery[0];
@@ -154,9 +152,9 @@ export class UriFactory
}
for (const a in comps) {
- if (comps.hasOwnProperty(a) && comps[a] !== '' && comps[a] !== null && typeof comps[a] !== 'undefined') {
+ if (Object.prototype.hasOwnProperty.call(comps, a) && comps[a] !== '' && comps[a] !== null && typeof comps[a] !== 'undefined') {
pars.push(a + '=' + (comps[a].includes('%') ? comps[a] : encodeURIComponent(comps[a])));
- } else if (comps.hasOwnProperty(a)) {
+ } else if (Object.prototype.hasOwnProperty.call(comps, a)) {
pars.push(a);
}
}
@@ -187,20 +185,20 @@ export class UriFactory
* $ = Other data
* % = Current url
*
- * @param {string} uri Raw uri
- * @param {Object} [toMatch] Key/value pair to replace in raw
+ * @param {string} uri Raw uri
+ * @param {null|Object} [toMatch] Key/value pair to replace in raw
*
* @return {string}
*
* @since 1.0.0
*/
- static build (uri, toMatch)
+ static build (uri, toMatch = null)
{
const current = HttpUri.parseUrl(window.location.href);
const query = HttpUri.getAllUriQueryParameters(typeof current.query === 'undefined' ? {} : current.query);
for (const key in query) {
- if (query.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(query, key)) {
UriFactory.setQuery('?' + key, query[key]);
}
}
@@ -208,7 +206,7 @@ export class UriFactory
let parsed = uri.replace(new RegExp('\{[\/#\?%@\.\$\!][a-zA-Z0-9\-\#\.]*\}', 'g'), function (match) {
match = match.substr(1, match.length - 2);
- if (typeof toMatch !== 'undefined' && toMatch.hasOwnProperty(match)) {
+ if (toMatch !== null && Object.prototype.hasOwnProperty.call(toMatch, match)) {
return toMatch[match];
} else if (typeof UriFactory.uri[match] !== 'undefined') {
return UriFactory.uri[match];
@@ -226,7 +224,7 @@ export class UriFactory
let value = '';
const form = (new FormView(e.id)).getData();
- for (let pair of form.entries()) {
+ for (const pair of form.entries()) {
value += '&' + pair[0] + '=' + pair[1];
}
@@ -245,7 +243,7 @@ export class UriFactory
let value = '';
const form = (new FormView(e.id)).getData();
- for (let pair of form.entries()) {
+ for (const pair of form.entries()) {
value += '&' + pair[0] + '=' + pair[1];
}
@@ -280,6 +278,8 @@ export class UriFactory
/**
* Set uri builder components.
*
+ * @param {HttpUri} uri Uri
+ *
* @return {void}
*
* @since 1.0.0
@@ -299,4 +299,3 @@ export class UriFactory
* @since 1.0.0
*/
UriFactory.uri = {};
-
diff --git a/Utils/ArrayUtils.js b/Utils/ArrayUtils.js
index f01292a..5e4ddde 100755
--- a/Utils/ArrayUtils.js
+++ b/Utils/ArrayUtils.js
@@ -10,30 +10,31 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/**
* Get value from array/object
*
- * @param {string} path Array path
- * @param {Object} data Object
- * @param {string} delim Path delimiter
+ * @param {string} path Array path
+ * @param {Object} data Object
+ * @param {string} [delim] Path delimiter
*
- * @return {mixed}
+ * @return {any}
*
* @since 1.0.0
*/
- jsOMS.getArray = function(path, data, delim = '/')
+ jsOMS.getArray = function (path, data, delim = '/')
{
- let pathParts = jsOMS.ltrim(path, delim).split(delim);
- let current = data;
+ /** @type {Object} pathParts */
+ const pathParts = jsOMS.ltrim(path, delim).split(delim);
+ let current = data;
for (const key in pathParts) {
- if (!pathParts.hasOwnProperty(key)) {
+ if (!Object.prototype.hasOwnProperty.call(pathParts, key)) {
continue;
}
- if (typeof current === 'undefined' || !current.hasOwnProperty(pathParts[key])) {
+ if (typeof current === 'undefined' || !Object.prototype.hasOwnProperty.call(current, pathParts[key])) {
return null;
}
diff --git a/Utils/Debug.js b/Utils/Debug.js
index d7cb368..020b931 100755
--- a/Utils/Debug.js
+++ b/Utils/Debug.js
@@ -1,36 +1,34 @@
-var visited = [];
-var findings = {};
-var cssSelectors = {},
- cssSelectorsLength = 0;
-const cssFiles = ['http://127.0.0.1/cssOMS/styles.css'];
-const cssFilesLength = cssFiles.length;
-const domain = window.location.hostname;
-const pageLimit = 10;
+const visited = [];
+const findings = {};
+const cssSelectors = {};
+const cssFiles = ['http://127.0.0.1/cssOMS/styles.css'];
+const cssFilesLength = cssFiles.length;
+const domain = window.location.hostname;
+const pageLimit = 10;
-var cssRequest = new XMLHttpRequest();
-cssRequest.onreadystatechange = function()
+const cssRequest = new XMLHttpRequest();
+cssRequest.onreadystatechange = function ()
{
- if (cssRequest.readyState == 4 && cssRequest.status == 200) {
- const cssText = this.responseText;
- const result = cssText.match(/[a-zA-Z0-9\ :>~\.\"'#,\[\]=\-\(\)\*]+{/g),
- resultLength = result.length;
+ if (cssRequest.readyState === 4 && cssRequest.status === 200) {
+ const cssText = this.responseText;
+ const result = cssText.match(/[a-zA-Z0-9\ :>~\.\"'#,\[\]=\-\(\)\*]+{/g);
+ const resultLength = result.length;
for (let i = 1; i < resultLength; ++i) {
- let sel = result[i].substring(0, result[i].length - 1).trimLeft().trimRight().trimRight();
- if (!cssSelectors.hasOwnProperty(sel)) {
+ const sel = result[i].substring(0, result[i].length - 1).trimLeft().trimRight().trimRight();
+ if (!Object.prototype.hasOwnProperty.call(cssSelectors, sel)) {
cssSelectors[sel] = 0;
- ++cssSelectorsLength;
}
}
}
-}
+};
for (let i = 0; i < cssFilesLength; ++i) {
cssRequest.open('GET', cssFiles[i], true);
cssRequest.send();
}
-validatePage = function(url)
+const validatePage = function (url)
{
if (visited.includes(url) || visited.length > pageLimit - 1) {
return;
@@ -41,59 +39,59 @@ validatePage = function(url)
findings[url] = {};
// web request
- var webRequest = new XMLHttpRequest();
- webRequest.onreadystatechange = function()
+ const webRequest = new XMLHttpRequest();
+ webRequest.onreadystatechange = function ()
{
- if (webRequest.readyState == 4 && webRequest.status == 200) {
+ if (webRequest.readyState === 4 && webRequest.status === 200) {
// replace content
document.open();
document.write(this.responseText);
document.close();
// analyze img alt attribute
- let imgAlt = document.querySelectorAll('img:not([alt]), img[alt=""], img[alt=" "]');
- findings[url]['img_alt'] = imgAlt.length;
+ const imgAlt = document.querySelectorAll('img:not([alt]), img[alt=""], img[alt=" "]');
+ findings[url].img_alt = imgAlt.length;
// analyze img src
- let imgSrc = document.querySelectorAll('img:not([src]), img[src=""], img[src=" "]');
- findings[url]['img_src'] = imgSrc.length;
+ const imgSrc = document.querySelectorAll('img:not([src]), img[src=""], img[src=" "]');
+ findings[url].img_src = imgSrc.length;
// analyze empty link
- let aHref = document.querySelectorAll('a:not([alt]), a[href=""], a[href=" "], a[href="#"]');
- findings[url]['href_empty'] = aHref.length;
+ const aHref = document.querySelectorAll('a:not([alt]), a[href=""], a[href=" "], a[href="#"]');
+ findings[url].href_empty = aHref.length;
// analyze inline on* function
- let onFunction = document.querySelectorAll('[onafterprint], [onbeforeprint], [onbeforeunload], [onerror], [onhaschange], [onload], [onmessage], [onoffline], [ononline], [onpagehide], [onpageshow], [onpopstate], [onredo], [onresize], [onstorage], [onundo], [onunload], [onblur], [onchage], [oncontextmenu], [onfocus], [onformchange], [onforminput], [oninput], [oninvalid], [onreset], [onselect], [onsubmit], [onkeydown], [onkeypress], [onkeyup], [onclick], [ondblclick], [ondrag], [ondragend], [ondragenter], [ondragleave], [ondragover], [ondragstart], [ondrop], [onmousedown], [onmousemove], [onmouseout], [onmouseover], [onmouseup], [onmousewheel], [onscroll], [onabort], [oncanplay], [oncanplaythrough], [ondurationchange], [onemptied], [onended], [onerror], [onloadeddata], [onloadedmetadata], [onloadstart], [onpause], [onplay], [onplaying], [onprogress], [onratechange], [onreadystatechange], [onseeked], [onseeking], [onstalled], [onsuspend], [ontimeupdate], [onvolumechange], [onwaiting]');
- findings[url]['js_on'] = onFunction.length;
+ const onFunction = document.querySelectorAll('[onafterprint], [onbeforeprint], [onbeforeunload], [onerror], [onhaschange], [onload], [onmessage], [onoffline], [ononline], [onpagehide], [onpageshow], [onpopstate], [onredo], [onresize], [onstorage], [onundo], [onunload], [onblur], [onchage], [oncontextmenu], [onfocus], [onformchange], [onforminput], [oninput], [oninvalid], [onreset], [onselect], [onsubmit], [onkeydown], [onkeypress], [onkeyup], [onclick], [ondblclick], [ondrag], [ondragend], [ondragenter], [ondragleave], [ondragover], [ondragstart], [ondrop], [onmousedown], [onmousemove], [onmouseout], [onmouseover], [onmouseup], [onmousewheel], [onscroll], [onabort], [oncanplay], [oncanplaythrough], [ondurationchange], [onemptied], [onended], [onerror], [onloadeddata], [onloadedmetadata], [onloadstart], [onpause], [onplay], [onplaying], [onprogress], [onratechange], [onreadystatechange], [onseeked], [onseeking], [onstalled], [onsuspend], [ontimeupdate], [onvolumechange], [onwaiting]');
+ findings[url].js_on = onFunction.length;
// analyze missing form element attributes
- let formElements = document.querySelectorAll('input:not([id]), input[type=""], select:not([id]), textarea:not([id]), label:not([for]), label[for=""], label[for=" "], input:not([name]), select:not([name]), textarea:not([name]), form:not([id]), form:not([action]), form[action=""], form[action=" "], form[action="#"]');
- findings[url]['form_elements'] = formElements.length;
+ const formElements = document.querySelectorAll('input:not([id]), input[type=""], select:not([id]), textarea:not([id]), label:not([for]), label[for=""], label[for=" "], input:not([name]), select:not([name]), textarea:not([name]), form:not([id]), form:not([action]), form[action=""], form[action=" "], form[action="#"]');
+ findings[url].form_elements = formElements.length;
// analyze invalid container-children relationship (e.g. empty containers, invalid children)
- let invalidContainerChildren = document.querySelectorAll(':not(tr) > td, :not(tr) > th, colgroup *:not(col), :not(colgroup) > col, tr > :not(td):not(th), optgroup > :not(option), :not(select) > option, :not(fieldset) > legend, select > :not(option):not(optgroup), :not(select):not(optgroup) > option, table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption)');
- findings[url]['invalid_container_children'] = invalidContainerChildren.length;
+ const invalidContainerChildren = document.querySelectorAll(':not(tr) > td, :not(tr) > th, colgroup *:not(col), :not(colgroup) > col, tr > :not(td):not(th), optgroup > :not(option), :not(select) > option, :not(fieldset) > legend, select > :not(option):not(optgroup), :not(select):not(optgroup) > option, table > *:not(thead):not(tfoot):not(tbody):not(tr):not(colgroup):not(caption)');
+ findings[url].invalid_container_children = invalidContainerChildren.length;
// has inline styles
- let hasInlineStyles = document.querySelectorAll('*[style]');
- findings[url]['form_elements'] = hasInlineStyles.length;
+ const hasInlineStyles = document.querySelectorAll('*[style]');
+ findings[url].form_elements = hasInlineStyles.length;
// analyze css usage
let cssFound;
for (const i in cssSelectors) {
try {
cssFound = document.querySelectorAll(i.replace(/:hover|:active/gi, ''));
- cssSelectors[i] = cssFound === null ? 0 : cssFound.length
+ cssSelectors[i] = cssFound === null ? 0 : cssFound.length;
} catch (e) {}
}
// check other pages
- let links = document.querySelectorAll('a'),
- linkLength = links.length;
+ const links = document.querySelectorAll('a');
+ const linkLength = links.length;
for (let i = 0; i < linkLength; ++i) {
- if (visited.includes(links[i].href) ||
- (!links[i].href.startsWith('/') && links[i].href.startsWith('http') && !links[i].href.includes(domain))
+ if (visited.includes(links[i].href)
+ || (!links[i].href.startsWith('/') && links[i].href.startsWith('http') && !links[i].href.includes(domain))
) {
continue;
}
@@ -110,4 +108,4 @@ validatePage = function(url)
validatePage(location.href);
console.table(findings);
-console.table(cssSelectors);
\ No newline at end of file
+console.table(cssSelectors);
diff --git a/Utils/GeneralUtils.js b/Utils/GeneralUtils.js
index 8372ab3..048cd03 100755
--- a/Utils/GeneralUtils.js
+++ b/Utils/GeneralUtils.js
@@ -10,7 +10,7 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/**
* Delayed watcher
@@ -21,7 +21,7 @@
*
* @since 1.0.0
*/
- jsOMS.watcher = function ()
+ jsOMS.watcher = (function ()
{
var timer = 0;
return function (callback, ms)
@@ -29,7 +29,7 @@
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
- }();
+ })();
/**
* Merging two arrays recursively
@@ -46,14 +46,12 @@
const out = jsOMS.clone(target);
for (const p in source) {
- if (source.hasOwnProperty(p)) {
+ if (Object.prototype.hasOwnProperty.call(source, p)) {
// Property in destination object set; update its value.
if (typeof source[p] === 'object') {
out[p] = jsOMS.merge(out[p], source[p]);
-
} else {
out[p] = source[p];
-
}
} else {
out[p] = source[p];
diff --git a/Utils/Parser/Markdown.js b/Utils/Parser/Markdown.js
index 4b5f849..688599c 100755
--- a/Utils/Parser/Markdown.js
+++ b/Utils/Parser/Markdown.js
@@ -190,7 +190,7 @@
}
}
return ret;
- }
+ };
/**
* Created by Tivie on 06-01-2015.
@@ -555,7 +555,7 @@
}
}
return ret;
- }
+ };
/**
* Validate extension
@@ -579,7 +579,7 @@
if (!showdown.hasOwnProperty('helper')) {
showdown.helper = {};
- }
+ };
/**
* Check if var is string
@@ -644,7 +644,7 @@
throw new Error('callback param is required');
}
- if (!showdown.helper.isFunction(callback)) {
+ if (!showdown.helper.isfunction (callback)) {
throw new Error('callback param must be a function/closure');
}
@@ -680,7 +680,7 @@
'use strict';
var charCodeToEscape = m1.charCodeAt(0);
return '¨E' + charCodeToEscape + 'E';
- }
+ };
/**
* Callback used to escape characters when passing through String.replace
@@ -826,7 +826,7 @@
showdown.helper.replaceRecursiveRegExp = function (str, replacement, left, right, flags) {
'use strict';
- if (!showdown.helper.isFunction(replacement)) {
+ if (!showdown.helper.isfunction (replacement)) {
var repStr = replacement;
replacement = function () {
return repStr;
@@ -984,7 +984,7 @@
throw msg;
}
};
- }
+ };
/**
* Common regexes.
@@ -2234,13 +2234,13 @@
format: ''
};
- _constructor();
+ _constructor ();
/**
* Converter constructor
* @private
*/
- function _constructor() {
+ function _constructor () {
converterOptions = converterOptions || {};
for (var gOpt in globalOptions) {
diff --git a/Utils/StringUtils.js b/Utils/StringUtils.js
index 881c8c5..9644a63 100755
--- a/Utils/StringUtils.js
+++ b/Utils/StringUtils.js
@@ -10,13 +10,13 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/**
* Trim char from string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -30,8 +30,8 @@
/**
* Trim char from right part of string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -39,14 +39,14 @@
*/
jsOMS.rtrim = function (str, char = ' ')
{
- return str.replace(new RegExp("[" + char + "]*$"), '');
+ return str.replace(new RegExp('[' + char + ']*$'), '');
};
/**
* Trim char from left part of string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -54,7 +54,7 @@
*/
jsOMS.ltrim = function (str, char = ' ')
{
- return str.replace(new RegExp("^[" + char + "]*"), '');
+ return str.replace(new RegExp('^[' + char + ']*'), '');
};
jsOMS.htmlspecialchars = [
@@ -137,11 +137,12 @@
* @param {string} str String to inspect
* @param {string} substr Substring to count
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
- jsOMS.substr_count = function (str, substr) {
+ jsOMS.substr_count = function (str, substr)
+ {
str += '';
substr += '';
@@ -151,8 +152,8 @@
return (str.length + 1);
}
- let n = 0,
- pos = 0;
+ let n = 0;
+ let pos = 0;
while (true) {
pos = str.indexOf(substr, pos);
@@ -173,13 +174,13 @@
*
* @param {string} str String to hash
*
- * @return {int}
+ * @return {number}
*
* @since 1.0.0
*/
jsOMS.hash = function (str)
{
- let res = 0
+ let res = 0;
const len = str.length;
for (let i = 0; i < len; ++i) {
@@ -193,7 +194,7 @@
* Get the remaining string after finding a certain char
*
* @param {string} haystack String to to search in
- * @param {Array} chars Chars to search for
+ * @param {Array} chars Chars to search for
*
* @return {string}
*
diff --git a/Utils/UiUtils.js b/Utils/UiUtils.js
index 1f4c470..be964ae 100755
--- a/Utils/UiUtils.js
+++ b/Utils/UiUtils.js
@@ -10,7 +10,7 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/**
* Class finder
@@ -35,7 +35,7 @@
/**
* Trigger an event
*
- * @param {element} element Element where the event is assigned
+ * @param {Element} element Element where the event is assigned
* @param {string} eventName Name of the event
*
* @return void
@@ -64,8 +64,8 @@
*
* Adding a class to an element
*
- * @param ele DOM Element
- * @param cls Class to add
+ * @param {Element} DOM Element
+ * @param {string} Class to add
*
* @return {void}
*
@@ -74,7 +74,7 @@
jsOMS.addClass = function (ele, cls)
{
if (!jsOMS.hasClass(ele, cls)) {
- ele.className += ele.className !== '' ? " " + cls : cls;
+ ele.className += ele.className !== '' ? ' ' + cls : cls;
}
};
@@ -83,8 +83,8 @@
*
* Removing a class form an element
*
- * @param ele DOM Element
- * @param cls Class to remove
+ * @param {Element} DOM Element
+ * @param {string} Class to remove
*
* @return {void}
*
@@ -101,7 +101,7 @@
/**
* Get element value
*
- * @param ele DOM Element
+ * @param {Element} DOM Element
*
* @return {string}
*
@@ -125,7 +125,7 @@
*
* Preventing event from firing and passing through
*
- * @param event Event Event to stop
+ * @param {Event} event Event to stop
*
* @return {void}
*
@@ -143,7 +143,7 @@
*
* Invoking a function after page load
*
- * @param {callback} func Callback function
+ * @param {function} func Callback function
*
* @return {void}
*
@@ -157,7 +157,7 @@
) {
func();
} else {
- document.addEventListener("DOMContentLoaded", function (event)
+ document.addEventListener('DOMContentLoaded', function (event)
{
func();
});
@@ -169,7 +169,7 @@
*
* Deleting content from element
*
- * @param ele DOM Element
+ * @param {Element} DOM Element
*
* @return {void}
*
@@ -187,7 +187,7 @@
*
* Checking if a selection is a node
*
- * @param ele DOM Node
+ * @param {Node} DOM Node
*
* @return {boolean}
*
@@ -197,7 +197,7 @@
{
/** global: Node */
return (
- typeof Node === "object" ? ele instanceof Node : ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
+ typeof Node === 'object' ? ele instanceof Node : ele && typeof ele === 'object' && typeof ele.nodeType === 'number' && typeof ele.nodeName === 'string'
);
};
@@ -206,7 +206,7 @@
*
* Checking if a selection is a element
*
- * @param o DOM Element
+ * @param {HTMLElement} DOM Element
*
* @return {boolean}
*
@@ -216,7 +216,7 @@
{
/** global: HTMLElement */
return (
- typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
+ typeof HTMLElement === 'object' ? o instanceof HTMLElement : o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string'
);
};
@@ -225,10 +225,10 @@
*
* Getting a element by class in the first level
*
- * @param ele DOM Element
- * @param cls Class to find
+ * @param {Element} DOM Element
+ * @param {string} Class to find
*
- * @return {Element}
+ * @return {null|Element}
*
* @since 1.0.0
*/
@@ -248,7 +248,7 @@
/**
* Adding event listener to multiple elements
*
- * @param e DOM Elements
+ * @param {Element} e DOM Elements
* @param {string} event Event name
* @param {function} callback Event callback
*
diff --git a/Utils/oLib.js b/Utils/oLib.js
index 6e8c07e..07b8089 100755
--- a/Utils/oLib.js
+++ b/Utils/oLib.js
@@ -10,12 +10,12 @@
*/
(function (jsOMS)
{
- "use strict";
+ 'use strict';
/**
* Trigger an event
*
- * @param {element} element Element where the event is assigned
+ * @param {Element} element Element where the event is assigned
* @param {string} eventName Name of the event
*
* @return void
@@ -42,11 +42,11 @@
/**
* Trim char from string
*
- * @param {string} path Array path
- * @param {Object} data Object
- * @param {string} delim Path delimiter
+ * @param {string} path Array path
+ * @param {Object} data Object
+ * @param {string} [delim] Path delimiter
*
- * @return
+ * @return {any}
*
* @function
*
@@ -58,11 +58,11 @@
let current = data;
for (const key in pathParts) {
- if (!pathParts.hasOwnProperty(key)) {
+ if (!Object.prototype.hasOwnProperty.call(pathParts, key)) {
continue;
}
- if (typeof current === 'undefined' || !current.hasOwnProperty(pathParts[key])) {
+ if (typeof current === 'undefined' || !Object.prototype.hasOwnProperty.call(current, pathParts[key])) {
return null;
}
@@ -75,8 +75,8 @@
/**
* Trim char from string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -92,8 +92,8 @@
/**
* Trim char from right part of string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -103,14 +103,14 @@
*/
jsOMS.rtrim = function (str, char = ' ')
{
- return str.replace(new RegExp("[" + char + "]*$"), '');
+ return str.replace(new RegExp('[' + char + ']*$'), '');
};
/**
* Trim char from left part of string
*
- * @param {string} str String to trim from
- * @param {string} char Char to trim
+ * @param {string} str String to trim from
+ * @param {string} [char] Char to trim
*
* @return {string}
*
@@ -120,7 +120,7 @@
*/
jsOMS.ltrim = function (str, char = ' ')
{
- return str.replace(new RegExp("^[" + char + "]*"), '');
+ return str.replace(new RegExp('^[' + char + ']*'), '');
};
jsOMS.htmlspecialchars = [
@@ -184,13 +184,14 @@
* @param {string} str String to inspect
* @param {string} substr Substring to count
*
- * @return {int}
+ * @return {number}
*
* @function
*
* @since 1.0.0
*/
- jsOMS.substr_count = function (str, substr) {
+ jsOMS.substr_count = function (str, substr)
+ {
str += '';
substr += '';
@@ -198,9 +199,9 @@
return (str.length + 1);
}
- let n = 0,
- pos = 0,
- step = substr.length;
+ let n = 0;
+ let pos = 0;
+ const step = substr.length;
while (true) {
pos = str.indexOf(substr, pos);
@@ -221,8 +222,8 @@
*
* Checking if a element has a class
*
- * @param {Object} ele DOM Element
- * @param {string} cls Class to find
+ * @param {Element} ele DOM Element
+ * @param {string} cls Class to find
*
* @return {boolean}
*
@@ -245,8 +246,10 @@
*
* Adding a class to an element
*
- * @param ele DOM Element
- * @param cls Class to add
+ * @param {Element} DOM Element
+ * @param {string} Class to add
+ *
+ * @return {void}
*
* @function
*
@@ -256,7 +259,7 @@
{
if (!jsOMS.hasClass(ele, cls)) {
if (typeof ele.className === 'string') {
- ele.className += ele.className !== '' ? " " + cls : cls;
+ ele.className += ele.className !== '' ? ' ' + cls : cls;
} else if (typeof ele.className.baseVal === 'string') {
ele.className.baseVal += ele.className.baseVal !== '' ? ' ' + cls : cls;
}
@@ -268,8 +271,10 @@
*
* Removing a class form an element
*
- * @param ele DOM Element
- * @param cls Class to remove
+ * @param {Element} DOM Element
+ * @param {string} Class to remove
+ *
+ * @return {void}
*
* @function
*
@@ -293,11 +298,13 @@
*
* Used to fire event after delay
*
+ * @return {callback}
+ *
* @function
*
* @since 1.0.0
*/
- jsOMS.watcher = function ()
+ jsOMS.watcher = (function ()
{
var timer = 0;
return function (callback, ms)
@@ -305,14 +312,16 @@
clearTimeout(timer);
timer = setTimeout(callback, ms);
};
- }();
+ })();
/**
* Action prevent
*
* Preventing event from firering and passing through
*
- * @param event Event Event to stop
+ * @param {Event} Event Event to stop
+ *
+ * @return {boolean}
*
* @function
*
@@ -332,7 +341,9 @@
*
* Invoking a function after page load
*
- * @param func Callback function
+ * @param {function} Callback function
+ *
+ * @return {void}
*
* @function
*
@@ -343,7 +354,7 @@
if (document.readyState === 'complete' || document.readyState === 'loaded' || document.readyState === 'interactive') {
func();
} else {
- document.addEventListener("DOMContentLoaded", function (event)
+ document.addEventListener('DOMContentLoaded', function (event)
{
func();
});
@@ -353,7 +364,7 @@
/**
* Get element value
*
- * @param ele DOM Element
+ * @param {Element} DOM Element
*
* @return {string}
*
@@ -377,7 +388,9 @@
*
* Deleting content from element
*
- * @param ele DOM Element
+ * @param {Element} DOM Element
+ *
+ * @return {void}
*
* @function
*
@@ -395,7 +408,7 @@
*
* @param {string} str String to hash
*
- * @return {int}
+ * @return {number}
*
* @function
*
@@ -418,7 +431,7 @@
*
* Checking if a selection is a node
*
- * @param ele DOM Node
+ * @param {Node} DOM Node
*
* @return {boolean}
*
@@ -430,7 +443,7 @@
{
/** global: Node */
return (
- typeof Node === "object" ? ele instanceof Node : ele && typeof ele === "object" && typeof ele.nodeType === "number" && typeof ele.nodeName === "string"
+ typeof Node === 'object' ? ele instanceof Node : ele && typeof ele === 'object' && typeof ele.nodeType === 'number' && typeof ele.nodeName === 'string'
);
};
@@ -439,7 +452,7 @@
*
* Checking if a selection is a element
*
- * @param o DOM Element
+ * @param {HTMLElement} DOM Element
*
* @return {boolean}
*
@@ -451,7 +464,7 @@
{
/** global: HTMLElement */
return (
- typeof HTMLElement === "object" ? o instanceof HTMLElement : o && typeof o === "object" && o !== null && o.nodeType === 1 && typeof o.nodeName === "string"
+ typeof HTMLElement === 'object' ? o instanceof HTMLElement : o && typeof o === 'object' && o !== null && o.nodeType === 1 && typeof o.nodeName === 'string'
);
};
@@ -460,10 +473,10 @@
*
* Getting a element by class in the first level
*
- * @param ele DOM Element
- * @param cls Class to find
+ * @param {Element} DOM Element
+ * @param {string} Class to find
*
- * @return Element
+ * @return {null|Element}
*
* @function
*
@@ -485,10 +498,12 @@
/**
* Adding event listener to multiple elements
*
- * @param e DOM Elements
- * @param {string} event Event name
+ * @param {Element} e DOM Elements
+ * @param {string} event Event name
* @param {function} callback Event callback
*
+ * @return {void}
+ *
* @function
*
* @since 1.0.0
@@ -507,6 +522,8 @@
*
* @param {string} jsonString String to validate
*
+ * @return {boolean}
+ *
* @function
*
* @since 1.0.0
@@ -524,10 +541,10 @@
/**
* Merging two arrays recursively
*
- * @param target Target array
- * @param source Source array
+ * @param {Object} target Target object
+ * @param {Object} source Source object
*
- * @return Array
+ * @return {Object}
*
* @function
*
@@ -538,14 +555,12 @@
const out = jsOMS.clone(target);
for (const p in source) {
- if (source.hasOwnProperty(p)) {
+ if (Object.prototype.hasOwnProperty.call(source, p)) {
// Property in destination object set; update its value.
if (typeof source[p] === 'object') {
out[p] = jsOMS.merge(out[p], source[p]);
-
} else {
out[p] = source[p];
-
}
} else {
out[p] = source[p];
@@ -569,11 +584,30 @@
return { ...obj };
};
+ /**
+ * Is variable set
+ *
+ * @param {any} variable Variable
+ *
+ * @returns {boolean}
+ *
+ * @since 1.0.0
+ */
jsOMS.isset = function (variable)
{
return typeof variable !== 'undefined' && variable !== null;
};
+ /**
+ * 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;
@@ -588,10 +622,4 @@
return haystack.slice(min);
};
-
- jsOMS.nearest = function (e, selector) {
- // same level first
- // parent level second
- // child level third
- };
}(window.jsOMS = window.jsOMS || {}));
diff --git a/Views/FormView.js b/Views/FormView.js
index 47cef80..a8e6ee1 100755
--- a/Views/FormView.js
+++ b/Views/FormView.js
@@ -32,15 +32,30 @@ export class FormView
*/
constructor (id)
{
+ /** @type {string} id */
this.id = id;
- this.success = null;
- this.finally = null;
+ /** @type {function} success */
+ this.success = null;
+
+ /** @type {function} finally */
+ this.finally = null;
+
+ /** @type {number} lastSubmit Last submit date time */
this.lastSubmit = 0;
+ /** @type {null|Element} form */
this.form = null;
- this.initializeMembers();
+ /** @type {Array} submitInjects */
+ this.submitInjects = [];
+
+ /** @type {string} method */
+ this.method = 'POST';
+
+ /** @type {string} action */
+ this.action = '';
+
this.bind();
};
@@ -108,6 +123,13 @@ export class FormView
this.lastSubmit = Math.floor(Date.now());
};
+ /**
+ * Is form data submitted on change?
+ *
+ * @return {boolean}
+ *
+ * @since 1.0.0
+ */
isOnChange ()
{
const isOnChange = this.getFormElement().getAttribute('data-on-change');
@@ -118,6 +140,8 @@ export class FormView
/**
* Get submit elements
*
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
* @return {NodeListOf}
*
* @since 1.0.0
@@ -143,7 +167,7 @@ export class FormView
*
* @since 1.0.0
*/
- getImagePreviews() {
+ getImagePreviews () {
return document.querySelectorAll(
'#' + this.id + ' input[type=file].preview'
);
@@ -152,7 +176,9 @@ export class FormView
/**
* Get edit elements
*
- * @return {NodeListOf}
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
+ * @return {NodeListOf}
*
* @since 1.0.0
*/
@@ -171,7 +197,9 @@ export class FormView
/**
* Get save elements
*
- * @return {NodeListOf}
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
+ * @return {NodeListOf}
*
* @since 1.0.0
*/
@@ -190,7 +218,9 @@ export class FormView
/**
* Get save elements
*
- * @return {NodeListOf}
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
+ * @return {NodeListOf}
*
* @since 1.0.0
*/
@@ -209,7 +239,9 @@ export class FormView
/**
* Get remove buttons
*
- * @return {NodeListOf}
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
+ * @return {NodeListOf}
*
* @since 1.0.0
*/
@@ -230,7 +262,9 @@ export class FormView
*
* The add button is different from the submit button since sometimes you want to show data to the user before you submit it.
*
- * @return {NodeListOf}
+ * @param {null|Element} [e] Root element for search (null = whole document)
+ *
+ * @return {NodeListOf}
*
* @since 1.0.0
*/
@@ -249,7 +283,7 @@ export class FormView
/**
* Get success callback
*
- * @return {callback}
+ * @return {function}
*
* @since 1.0.0
*/
@@ -261,7 +295,7 @@ export class FormView
/**
* Set success callback
*
- * @param {callback} callback Callback
+ * @param {function} callback Callback
*
* @return {void}
*
@@ -275,7 +309,7 @@ export class FormView
/**
* Get finally callback
*
- * @return {callback}
+ * @return {function}
*
* @since 1.0.0
*/
@@ -287,20 +321,20 @@ export class FormView
/**
* Set finally callback
*
- * @param {callback} callback Callback
+ * @param {function} callback Callback
*
* @return {void}
*
* @since 1.0.0
*/
- setFinally(callback) {
+ setFinally (callback) {
this.finally = callback;
};
/**
* Inject submit with post callback
*
- * @param {callback} callback Callback
+ * @param {function} callback Callback
*
* @return {void}
*
@@ -314,31 +348,30 @@ export class FormView
/**
* Get form elements
*
- * @param {object} container Data container, null = entire form or element e.g. table row
+ * @param {null|Object} [container] Data container, null = entire form or element e.g. table row
*
- * @return {Array}
+ * @return {Element[]}
*
* @since 1.0.0
*/
getFormElements (container = null)
{
const form = container === null ? this.getFormElement() : container;
-
if (!form) {
return [];
}
- const selects = form.getElementsByTagName('select'),
- textareas = form.getElementsByTagName('textarea'),
- inputs = [].slice.call(form.getElementsByTagName('input')),
- buttons = form.getElementsByTagName('button'),
- canvas = form.getElementsByTagName('canvas'),
- external = [].slice.call(document.querySelectorAll(':not(#' + this.id + ') [form=' + this.id + ']')),
- special = form.querySelectorAll('[data-name]'),
- specialExt = document.querySelectorAll(':not(#' + this.id + ') [data-form=' + this.id + ']'),
- inputLength = inputs.length,
- externalLength = external.length,
- specialLength = specialExt.length;
+ const selects = form.getElementsByTagName('select');
+ const textareas = form.getElementsByTagName('textarea');
+ const inputs = [].slice.call(form.getElementsByTagName('input'));
+ const buttons = form.getElementsByTagName('button');
+ const canvas = form.getElementsByTagName('canvas');
+ const external = [].slice.call(document.querySelectorAll(':not(#' + this.id + ') [form=' + this.id + ']'));
+ const special = form.querySelectorAll('[data-name]');
+ const specialExt = document.querySelectorAll(':not(#' + this.id + ') [data-form=' + this.id + ']');
+ const inputLength = inputs.length;
+ const externalLength = external.length;
+ const specialLength = specialExt.length;
for (let i = 0; i < inputLength; ++i) {
if (inputs[i] === undefined
@@ -359,7 +392,7 @@ export class FormView
continue;
}
- if ( external[i] === undefined
+ if (external[i] === undefined
|| (typeof external[i] !== 'undefined'
&& (external[i].type === 'checkbox' || external[i].type === 'radio')
&& !external[i].checked)
@@ -386,9 +419,20 @@ export class FormView
Array.prototype.slice.call(special),
Array.prototype.slice.call(specialExt),
Array.prototype.slice.call(canvas)
- ).filter(function(val) { return val; });
+ ).filter(function (val) { return val; });
};
+ /**
+ * Get first form element
+ *
+ * E.g. used to auto select first form element.
+ *
+ * @param {Element} e Root element for search (null = whole document)
+ *
+ * @return {Element}
+ *
+ * @since 1.0.0
+ */
getFirstInputElement (e = null)
{
const parent = e === null ? document : e;
@@ -413,17 +457,17 @@ export class FormView
*/
getUniqueFormElements (arr)
{
- let seen = {};
+ const seen = {};
- return arr.filter(function(item) {
- return seen.hasOwnProperty(item.name) ? false : (seen[item.name] = true);
+ return arr.filter(function (item) {
+ return Object.prototype.hasOwnProperty.call(seen, item.name) ? false : (seen[item.name] = true);
});
};
/**
* Get form data
*
- * @param {container} Data container. Null = entire form, container e.g. single row in a table
+ * @param {null|Element} Data container. Null = entire form, container e.g. single row in a table
*
* @return {FormData}
*
@@ -431,10 +475,10 @@ export class FormView
*/
getData (container = null)
{
- const data = {},
- formData = new FormData(),
- elements = this.getFormElements(container),
- length = elements.length;
+ const data = {};
+ const formData = new FormData();
+ const elements = this.getFormElements(container);
+ const length = elements.length;
let value = null;
@@ -459,14 +503,14 @@ export class FormView
Array.prototype.slice.call(
elements[i].contentWindow.document.querySelectorAll('[data-form=' + this.id + '] [data-name]')
)
- ).filter(function(val) { return val; });
+ ).filter(function (val) { return val; });
const iframeLength = iframeElements.length;
for (let j = 0; j < iframeLength; ++j) {
value = iframeElements[j].value;
const iframeId = FormView.getElementId(iframeElements[j]);
- if (data.hasOwnProperty(iframeId)) {
+ if (Object.prototype.hasOwnProperty.call(data, iframeId)) {
if (data[iframeId].constructor !== Array) {
data[iframeId] = [data[iframeId]];
}
@@ -487,7 +531,7 @@ export class FormView
}
// handle array data (e.g. table rows with same name)
- if (data.hasOwnProperty(id)) {
+ if (Object.prototype.hasOwnProperty.call(data, id)) {
if (data[id].constructor !== Array) {
data[id] = [data[id]];
}
@@ -499,7 +543,7 @@ export class FormView
}
for (const key in data) {
- if (data.hasOwnProperty(key)) {
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
formData.append(key, data[key] !== null && data[key].constructor === Array ? JSON.stringify(data[key]) : data[key]);
}
}
@@ -507,10 +551,17 @@ export class FormView
return formData;
};
+ /**
+ * Reset the form values to the default values
+ *
+ * @return {void}
+ *
+ * @since 1.0.0
+ */
resetValues ()
{
- const elements = this.getFormElements(),
- length = elements.length;
+ const elements = this.getFormElements();
+ const length = elements.length;
const form = this.getFormElement();
form.reset();
@@ -529,7 +580,7 @@ export class FormView
elements[i].setAttribute('data-value', '');
}
}
- }
+ };
/**
* Get form id
@@ -543,6 +594,13 @@ export class FormView
return this.id;
};
+ /**
+ * Get the form element
+ *
+ * @return {Element}
+ *
+ * @since 1.0.0
+ */
getFormElement ()
{
return this.form === null ? (this.form = document.getElementById(this.id)) : this.form;
@@ -551,13 +609,15 @@ export class FormView
/**
* Validate form
*
+ * @param {null|Element[]}
+ *
* @return {boolean}
*
* @since 1.0.0
*/
- isValid (data)
+ isValid (data = null)
{
- const elements = typeof data === 'undefined' ? this.getFormElements() : data;
+ const elements = data === null ? this.getFormElements() : data;
const length = elements.length;
try {
@@ -575,15 +635,25 @@ export class FormView
}
}
} catch (e) {
+ /** global: jsOMS */
jsOMS.Log.Logger.instance.error(e);
}
return true;
};
- getInvalid (data)
+ /**
+ * Get invalid data
+ *
+ * @param {null|Element[]}
+ *
+ * @return {Element[]}
+ *
+ * @since 1.0.0
+ */
+ getInvalid (data = null)
{
- const elements = typeof data === 'undefined' ? this.getFormElements() : data;
+ const elements = data === null ? this.getFormElements() : data;
const length = elements.length;
const invalid = [];
@@ -603,16 +673,19 @@ export class FormView
}
}
} catch (e) {
+ /** global: jsOMS */
jsOMS.Log.Logger.instance.error(e);
}
return invalid;
- }
+ };
/**
* Get form element id
*
- * @return {string}
+ * @param {Element} e Element to get id from
+ *
+ * @return {null|string}
*
* @since 1.0.0
*/
@@ -654,30 +727,29 @@ export class FormView
{
this.clean();
- const e = this.getFormElement();
-
- if (!e) {
+ this.form = this.getFormElement();
+ if (this.form === null) {
return;
}
- if (typeof e.attributes['method'] !== 'undefined') {
- this.method = e.attributes['method'].value;
- } else if (typeof e.attributes['data-method'] !== 'undefined') {
- this.method = e.attributes['data-method'].value;
+ if (typeof this.form.attributes.method !== 'undefined') {
+ this.method = this.form.attributes.method.value;
+ } else if (typeof this.form.attributes['data-method'] !== 'undefined') {
+ this.method = this.form.attributes['data-method'].value;
} else {
this.method = 'EMPTY';
}
- if (typeof e.attributes['action'] !== 'undefined') {
- this.action = e.attributes['action'].value;
- } else if (typeof e.attributes['data-uri'] !== 'undefined') {
- this.action = e.attributes['data-uri'].value;
+ if (typeof this.form.attributes.action !== 'undefined') {
+ this.action = this.form.attributes.action.value;
+ } else if (typeof this.form.attributes['data-uri'] !== 'undefined') {
+ this.action = this.form.attributes['data-uri'].value;
} else {
this.action = 'EMPTY';
}
- const elements = this.getFormElements(),
- length = elements.length;
+ const elements = this.getFormElements();
+ const length = elements.length;
for (let i = 0; i < length; ++i) {
switch (elements[i].tagName.toLowerCase()) {
@@ -685,13 +757,13 @@ export class FormView
Input.bindElement(elements[i]);
break;
case 'select':
- //this.bindSelect(elements[i]);
+ // this.bindSelect(elements[i]);
break;
case 'textarea':
- //this.bindTextarea(elements[i]);
+ // this.bindTextarea(elements[i]);
break;
case 'button':
- //this.bindButton(elements[i]);
+ // this.bindButton(elements[i]);
break;
default:
}
@@ -707,8 +779,8 @@ export class FormView
*/
unbind ()
{
- const elements = this.getFormElements(),
- length = elements.length;
+ const elements = this.getFormElements();
+ const length = elements.length;
for (let i = 0; i < length; ++i) {
switch (elements[i].tagName) {
diff --git a/Views/TableView.js b/Views/TableView.js
index 50aaf4c..7a2960e 100755
--- a/Views/TableView.js
+++ b/Views/TableView.js
@@ -34,9 +34,11 @@ export class TableView
* @since 1.0.0
*/
constructor (id) {
+ /** @type {string} id */
this.id = id;
- this.bind();
+ /** @type {null|Element} table */
+ this.table = null;
};
/**
@@ -48,7 +50,7 @@ export class TableView
*/
bind ()
{
- const e = document.getElementById(this.id);
+ this.table = document.getElementById(this.id);
};
/**
@@ -58,10 +60,10 @@ export class TableView
*
* @since 1.0.0
*/
- serialize()
+ serialize ()
{
const table = document.getElementById(this.id);
- let data = {
+ const data = {
caption: null,
header: [],
rows: []
@@ -69,21 +71,21 @@ export class TableView
data.caption = table.getElementsByTagName('caption')[0].innerText;
- const header = table.querySelectorAll('thead tr td, thead tr th'),
- headerLength = header.length;
+ const header = table.querySelectorAll('thead tr td, thead tr th');
+ const headerLength = header.length;
for (let i = 0; i < headerLength; ++i) {
data.header.push(header[i].innerText);
}
- const rows = table.querySelectorAll('tbody tr'),
- rowsLength = rows.length;
+ const rows = table.querySelectorAll('tbody tr');
+ const rowsLength = rows.length;
for (let i = 0; i < rowsLength; ++i) {
data.rows[i] = [];
- const columns = rows[i].querySelectorAll('td, th'),
- columnLength = columns.length;
+ const columns = rows[i].querySelectorAll('td, th');
+ const columnLength = columns.length;
for (let j = 0; j < columnLength; ++j) {
data.rows[i].push(columns[j].innerText);
@@ -91,7 +93,7 @@ export class TableView
}
return data;
- }
+ };
/**
* Get table export button
@@ -100,7 +102,7 @@ export class TableView
*
* @since 1.0.0
*/
- getExport()
+ getExport ()
{
return document.querySelectorAll('#' + this.id + ' .download')[0];
};
@@ -112,7 +114,7 @@ export class TableView
*
* @since 1.0.0
*/
- getSorting()
+ getSorting ()
{
return document.querySelectorAll(
'#' + this.id + ' thead .sort-asc,'
@@ -127,7 +129,7 @@ export class TableView
*
* @since 1.0.0
*/
- getFilter()
+ getFilter ()
{
return document.querySelectorAll(
'#' + this.id + ' .filter'
@@ -141,7 +143,7 @@ export class TableView
*
* @since 1.0.0
*/
- getHeader()
+ getHeader ()
{
return document.querySelector(
'#' + this.id + ' thead'
@@ -155,7 +157,7 @@ export class TableView
*
* @since 1.0.0
*/
- getCheckboxes()
+ getCheckboxes ()
{
return document.querySelectorAll(
'#' + this.id + ' thead input[type=checkbox]'
@@ -169,7 +171,7 @@ export class TableView
*
* @since 1.0.0
*/
- getSortableRows()
+ getSortableRows ()
{
return document.querySelectorAll(
'#' + this.id + ' tbody .order-up,'
diff --git a/tests/3D/3DViewerTest.js b/tests/3D/3DViewerTest.js
index 1c87191..3b82f57 100755
--- a/tests/3D/3DViewerTest.js
+++ b/tests/3D/3DViewerTest.js
@@ -1,6 +1,6 @@
describe('3DViewerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/3D/Loader/DdsLoaderTest.js b/tests/3D/Loader/DdsLoaderTest.js
index 1e63a0e..d5a29d4 100755
--- a/tests/3D/Loader/DdsLoaderTest.js
+++ b/tests/3D/Loader/DdsLoaderTest.js
@@ -1,6 +1,6 @@
describe('DdsLoaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/3D/Loader/MtlLoaderTest.js b/tests/3D/Loader/MtlLoaderTest.js
index bc5f3d2..29ae86e 100755
--- a/tests/3D/Loader/MtlLoaderTest.js
+++ b/tests/3D/Loader/MtlLoaderTest.js
@@ -1,6 +1,6 @@
describe('MtlLoaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/3D/Loader/ObjLoaderTest.js b/tests/3D/Loader/ObjLoaderTest.js
index 6693124..cd01774 100755
--- a/tests/3D/Loader/ObjLoaderTest.js
+++ b/tests/3D/Loader/ObjLoaderTest.js
@@ -1,6 +1,6 @@
describe('ObjLoaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/3D/Loader/StlLoaderTest.js b/tests/3D/Loader/StlLoaderTest.js
index a20148b..042aed8 100755
--- a/tests/3D/Loader/StlLoaderTest.js
+++ b/tests/3D/Loader/StlLoaderTest.js
@@ -1,6 +1,6 @@
describe('StlLoaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Account/AccountManagerTest.js b/tests/Account/AccountManagerTest.js
index 6af6c7f..8a5522d 100755
--- a/tests/Account/AccountManagerTest.js
+++ b/tests/Account/AccountManagerTest.js
@@ -2,7 +2,7 @@ import { AccountManager } from '../Account/AccountManager.js';
describe('AccountManagerTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Account/AccountTest.js b/tests/Account/AccountTest.js
index ebf7276..e2056b8 100755
--- a/tests/Account/AccountTest.js
+++ b/tests/Account/AccountTest.js
@@ -2,7 +2,7 @@ import { Account } from '../Account/Account.js';
describe('AccountTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Account/AccountTypeTest.js b/tests/Account/AccountTypeTest.js
index b2eeb79..55330d8 100755
--- a/tests/Account/AccountTypeTest.js
+++ b/tests/Account/AccountTypeTest.js
@@ -2,7 +2,7 @@ import { AccountType } from '../Account/AccountType.js';
describe('AccountTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Animation/AnimationTest.js b/tests/Animation/AnimationTest.js
index 31e6e87..e32420d 100755
--- a/tests/Animation/AnimationTest.js
+++ b/tests/Animation/AnimationTest.js
@@ -1,6 +1,6 @@
describe('AnimationTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Animation/Canvas/ParticleAnimationTest.js b/tests/Animation/Canvas/ParticleAnimationTest.js
index 25d3d59..d89eff1 100755
--- a/tests/Animation/Canvas/ParticleAnimationTest.js
+++ b/tests/Animation/Canvas/ParticleAnimationTest.js
@@ -1,6 +1,6 @@
describe('ParticleAnimationTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Animation/Canvas/ParticleTest.js b/tests/Animation/Canvas/ParticleTest.js
index ca6867c..5a855bf 100755
--- a/tests/Animation/Canvas/ParticleTest.js
+++ b/tests/Animation/Canvas/ParticleTest.js
@@ -1,6 +1,6 @@
describe('ParticleTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Asset/AssetManagerTest.js b/tests/Asset/AssetManagerTest.js
index 5efd51d..57d4cba 100755
--- a/tests/Asset/AssetManagerTest.js
+++ b/tests/Asset/AssetManagerTest.js
@@ -2,7 +2,7 @@ import { AssetManager } from '../Asset/AssetManager.js';
describe('AssetManagerTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Auth/AuthTest.js b/tests/Auth/AuthTest.js
index 442c441..8e58801 100755
--- a/tests/Auth/AuthTest.js
+++ b/tests/Auth/AuthTest.js
@@ -1,6 +1,6 @@
describe('AuthTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/AutoloaderTest.js b/tests/AutoloaderTest.js
index a8bbe45..d85aae1 100755
--- a/tests/AutoloaderTest.js
+++ b/tests/AutoloaderTest.js
@@ -1,6 +1,6 @@
describe('AutoloaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/AreaChartTest.js b/tests/Chart/AreaChartTest.js
index 8e14e39..b6d7f15 100755
--- a/tests/Chart/AreaChartTest.js
+++ b/tests/Chart/AreaChartTest.js
@@ -1,6 +1,6 @@
describe('AreaChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/BarChartTest.js b/tests/Chart/BarChartTest.js
index 2ea1800..90686e5 100755
--- a/tests/Chart/BarChartTest.js
+++ b/tests/Chart/BarChartTest.js
@@ -1,6 +1,6 @@
describe('BarChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/BoxplotChartTest.js b/tests/Chart/BoxplotChartTest.js
index 50674cf..a9e8338 100755
--- a/tests/Chart/BoxplotChartTest.js
+++ b/tests/Chart/BoxplotChartTest.js
@@ -1,6 +1,6 @@
describe('BoxplotChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/CalendarChartTest.js b/tests/Chart/CalendarChartTest.js
index 22ba505..d666e31 100755
--- a/tests/Chart/CalendarChartTest.js
+++ b/tests/Chart/CalendarChartTest.js
@@ -1,6 +1,6 @@
describe('CalendarChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/CandlestickChartTest.js b/tests/Chart/CandlestickChartTest.js
index bd8ab15..0abe1ad 100755
--- a/tests/Chart/CandlestickChartTest.js
+++ b/tests/Chart/CandlestickChartTest.js
@@ -1,6 +1,6 @@
describe('CandlestickChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/ChartLegendTest.js b/tests/Chart/ChartLegendTest.js
index 7a94c1d..2ea89fd 100755
--- a/tests/Chart/ChartLegendTest.js
+++ b/tests/Chart/ChartLegendTest.js
@@ -1,6 +1,6 @@
describe('ChartLegendTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/ColumnChartTest.js b/tests/Chart/ColumnChartTest.js
index 97e3de4..ca9b19a 100755
--- a/tests/Chart/ColumnChartTest.js
+++ b/tests/Chart/ColumnChartTest.js
@@ -1,6 +1,6 @@
describe('ColumnChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/DiffAreaChartTest.js b/tests/Chart/DiffAreaChartTest.js
index 1aad4ea..e82fafc 100755
--- a/tests/Chart/DiffAreaChartTest.js
+++ b/tests/Chart/DiffAreaChartTest.js
@@ -1,6 +1,6 @@
describe('DiffAreaChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/DonutChartTest.js b/tests/Chart/DonutChartTest.js
index 77f235c..c11c9f2 100755
--- a/tests/Chart/DonutChartTest.js
+++ b/tests/Chart/DonutChartTest.js
@@ -1,6 +1,6 @@
describe('DonutChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/FillGougeChartTest.js b/tests/Chart/FillGougeChartTest.js
index 82ad650..3001bb5 100755
--- a/tests/Chart/FillGougeChartTest.js
+++ b/tests/Chart/FillGougeChartTest.js
@@ -1,6 +1,6 @@
describe('FillGougeChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/GanttChartTest.js b/tests/Chart/GanttChartTest.js
index f514e2f..3f583ea 100755
--- a/tests/Chart/GanttChartTest.js
+++ b/tests/Chart/GanttChartTest.js
@@ -1,6 +1,6 @@
describe('GanttChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/GougeChartTest.js b/tests/Chart/GougeChartTest.js
index b8e1101..96e273f 100755
--- a/tests/Chart/GougeChartTest.js
+++ b/tests/Chart/GougeChartTest.js
@@ -1,6 +1,6 @@
describe('GougeChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/GroupedBarChartTest.js b/tests/Chart/GroupedBarChartTest.js
index 9f0d48f..2ec128d 100755
--- a/tests/Chart/GroupedBarChartTest.js
+++ b/tests/Chart/GroupedBarChartTest.js
@@ -1,6 +1,6 @@
describe('GroupedBarChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/GroupedColumnChartTest.js b/tests/Chart/GroupedColumnChartTest.js
index e225acc..ce333b7 100755
--- a/tests/Chart/GroupedColumnChartTest.js
+++ b/tests/Chart/GroupedColumnChartTest.js
@@ -1,6 +1,6 @@
describe('GroupedColumnChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/LineChartTest.js b/tests/Chart/LineChartTest.js
index 620ca2f..d644918 100755
--- a/tests/Chart/LineChartTest.js
+++ b/tests/Chart/LineChartTest.js
@@ -1,6 +1,6 @@
describe('LineChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/OhlcChartTest.js b/tests/Chart/OhlcChartTest.js
index 1e57204..0dff2ca 100755
--- a/tests/Chart/OhlcChartTest.js
+++ b/tests/Chart/OhlcChartTest.js
@@ -1,6 +1,6 @@
describe('OhlcChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/PieChartTest.js b/tests/Chart/PieChartTest.js
index a296678..5617711 100755
--- a/tests/Chart/PieChartTest.js
+++ b/tests/Chart/PieChartTest.js
@@ -1,6 +1,6 @@
describe('PieChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/PositionEnumTest.js b/tests/Chart/PositionEnumTest.js
index 36d1076..e531b82 100755
--- a/tests/Chart/PositionEnumTest.js
+++ b/tests/Chart/PositionEnumTest.js
@@ -1,6 +1,6 @@
describe('PositionEnumTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/PositionTest.enum.js b/tests/Chart/PositionTest.enum.js
index 9505ab2..e495b45 100755
--- a/tests/Chart/PositionTest.enum.js
+++ b/tests/Chart/PositionTest.enum.js
@@ -1,6 +1,6 @@
describe('PositionTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/PyramidChartTest.js b/tests/Chart/PyramidChartTest.js
index 7fe7d00..ba0c879 100755
--- a/tests/Chart/PyramidChartTest.js
+++ b/tests/Chart/PyramidChartTest.js
@@ -1,6 +1,6 @@
describe('PyramidChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/RadarChartTest.js b/tests/Chart/RadarChartTest.js
index b3323ee..406862c 100755
--- a/tests/Chart/RadarChartTest.js
+++ b/tests/Chart/RadarChartTest.js
@@ -1,6 +1,6 @@
describe('RadarChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/ScatterplotChartTest.js b/tests/Chart/ScatterplotChartTest.js
index 2efc290..76d91f8 100755
--- a/tests/Chart/ScatterplotChartTest.js
+++ b/tests/Chart/ScatterplotChartTest.js
@@ -1,6 +1,6 @@
describe('ScatterplotChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/StackedAreaChartTest.js b/tests/Chart/StackedAreaChartTest.js
index a26290f..5f26f39 100755
--- a/tests/Chart/StackedAreaChartTest.js
+++ b/tests/Chart/StackedAreaChartTest.js
@@ -1,6 +1,6 @@
describe('StackedAreaChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/StackedBarChartTest.js b/tests/Chart/StackedBarChartTest.js
index 3494ec1..e21d265 100755
--- a/tests/Chart/StackedBarChartTest.js
+++ b/tests/Chart/StackedBarChartTest.js
@@ -1,6 +1,6 @@
describe('StackedBarChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/StackedColumnChartTest.js b/tests/Chart/StackedColumnChartTest.js
index bf95d0a..6167f4f 100755
--- a/tests/Chart/StackedColumnChartTest.js
+++ b/tests/Chart/StackedColumnChartTest.js
@@ -1,6 +1,6 @@
describe('StackedColumnChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/TextElementTest.js b/tests/Chart/TextElementTest.js
index 2bc0380..b4ab579 100755
--- a/tests/Chart/TextElementTest.js
+++ b/tests/Chart/TextElementTest.js
@@ -1,6 +1,6 @@
describe('TextElementTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/TreeChartTest.js b/tests/Chart/TreeChartTest.js
index 0e8725e..b469175 100755
--- a/tests/Chart/TreeChartTest.js
+++ b/tests/Chart/TreeChartTest.js
@@ -1,6 +1,6 @@
describe('TreeChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/VWaterfallChartTest.js b/tests/Chart/VWaterfallChartTest.js
index 9920574..7d4c041 100755
--- a/tests/Chart/VWaterfallChartTest.js
+++ b/tests/Chart/VWaterfallChartTest.js
@@ -1,6 +1,6 @@
describe('VWaterfallChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Chart/WaterfallChartTest.js b/tests/Chart/WaterfallChartTest.js
index d5bb20a..cd81cc5 100755
--- a/tests/Chart/WaterfallChartTest.js
+++ b/tests/Chart/WaterfallChartTest.js
@@ -1,6 +1,6 @@
describe('WaterfallChartTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Config/OptionsTest.js b/tests/Config/OptionsTest.js
index 048c360..bc91df3 100755
--- a/tests/Config/OptionsTest.js
+++ b/tests/Config/OptionsTest.js
@@ -2,7 +2,7 @@ import { Options } from '../Config/Options.js';
describe('OptionsTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/DataStorage/CacheManagerTest.js b/tests/DataStorage/CacheManagerTest.js
index ec07584..16ce01f 100755
--- a/tests/DataStorage/CacheManagerTest.js
+++ b/tests/DataStorage/CacheManagerTest.js
@@ -1,6 +1,6 @@
describe('CacheManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/DataStorage/LocalStorageTest.js b/tests/DataStorage/LocalStorageTest.js
index cb0c0d8..d8d2611 100755
--- a/tests/DataStorage/LocalStorageTest.js
+++ b/tests/DataStorage/LocalStorageTest.js
@@ -2,7 +2,7 @@ import { LocalStorage } from '../DataStorage/LocalStorage.js';
describe('LocalStorageTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/DataStorage/StorageManagerTest.js b/tests/DataStorage/StorageManagerTest.js
index 03f1856..1919367 100755
--- a/tests/DataStorage/StorageManagerTest.js
+++ b/tests/DataStorage/StorageManagerTest.js
@@ -1,6 +1,6 @@
describe('StorageManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Dispatcher/DispatcherTest.js b/tests/Dispatcher/DispatcherTest.js
index 62bee6a..53a44ba 100755
--- a/tests/Dispatcher/DispatcherTest.js
+++ b/tests/Dispatcher/DispatcherTest.js
@@ -1,6 +1,6 @@
describe('DispatcherTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Event/EventManagerTest.js b/tests/Event/EventManagerTest.js
index eb69540..1ea7eca 100755
--- a/tests/Event/EventManagerTest.js
+++ b/tests/Event/EventManagerTest.js
@@ -2,7 +2,7 @@ import { EventManager } from '../Event/EventManager.js';
describe('EventManagerTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
@@ -22,8 +22,8 @@ describe('EventManagerTest', function ()
{
let manager = new EventManager();
- expect(manager.attach('group', function() { return true; }, false, false)).toBeTruthy();
- expect(manager.attach('group', function() { return true; }, false, false)).toBeTruthy();
+ expect(manager.attach('group', function () { return true; }, false, false)).toBeTruthy();
+ expect(manager.attach('group', function () { return true; }, false, false)).toBeTruthy();
expect(manager.count()).toBe(1);
});
});
@@ -34,7 +34,7 @@ describe('EventManagerTest', function ()
{
let manager = new EventManager();
- expect(manager.attach('group', function() { return true; }, false, true)).toBeTruthy();
+ expect(manager.attach('group', function () { return true; }, false, true)).toBeTruthy();
manager.addGroup('group', 'id1');
manager.addGroup('group', 'id2');
@@ -51,7 +51,7 @@ describe('EventManagerTest', function ()
{
let manager = new EventManager();
- expect(manager.attach('group', function() { return true; }, false, true)).toBeTruthy();
+ expect(manager.attach('group', function () { return true; }, false, true)).toBeTruthy();
manager.addGroup('group', 'id1');
manager.addGroup('group', 'id2');
@@ -68,8 +68,8 @@ describe('EventManagerTest', function ()
{
let manager = new EventManager();
- expect(manager.attach('group1', function() { return true; }, true, false)).toBeTruthy();
- expect(manager.attach('group2', function() { return true; }, true, false)).toBeTruthy();
+ expect(manager.attach('group1', function () { return true; }, true, false)).toBeTruthy();
+ expect(manager.attach('group2', function () { return true; }, true, false)).toBeTruthy();
expect(manager.count()).toBe(2);
manager.trigger('group1');
diff --git a/tests/Log/LogLevelTest.js b/tests/Log/LogLevelTest.js
index d96e5ba..467632d 100755
--- a/tests/Log/LogLevelTest.js
+++ b/tests/Log/LogLevelTest.js
@@ -2,7 +2,7 @@ import { LogLevel } from '../../Log/LogLevel.js';
describe('LogLevelTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Log/LoggerTest.js b/tests/Log/LoggerTest.js
index 3321915..d929649 100755
--- a/tests/Log/LoggerTest.js
+++ b/tests/Log/LoggerTest.js
@@ -2,7 +2,7 @@ import { Logger } from '../../Log/Logger.js';
describe('LoggerTest', function ()
{
- "use strict";
+ 'use strict';
describe('testLocalLogging', function ()
{
diff --git a/tests/Math/MathProcessorTest.js b/tests/Math/MathProcessorTest.js
index 64fdb83..3986ee1 100755
--- a/tests/Math/MathProcessorTest.js
+++ b/tests/Math/MathProcessorTest.js
@@ -1,6 +1,6 @@
describe('MathProcessorTest', function ()
{
- "use strict";
+ 'use strict';
describe('testBasicEvaluation', function ()
{
diff --git a/tests/Media/Audio/UISoundTest.js b/tests/Media/Audio/UISoundTest.js
index 970d6f6..cabc6dc 100755
--- a/tests/Media/Audio/UISoundTest.js
+++ b/tests/Media/Audio/UISoundTest.js
@@ -1,6 +1,6 @@
describe('UISoundTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Media/Video/CameraRecognitionTest.js b/tests/Media/Video/CameraRecognitionTest.js
index 47643c1..579ae8c 100755
--- a/tests/Media/Video/CameraRecognitionTest.js
+++ b/tests/Media/Video/CameraRecognitionTest.js
@@ -1,6 +1,6 @@
describe('CameraRecognitionTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Message/Notification/NotificationLevelTest.js b/tests/Message/Notification/NotificationLevelTest.js
index 0e552dd..1876acd 100755
--- a/tests/Message/Notification/NotificationLevelTest.js
+++ b/tests/Message/Notification/NotificationLevelTest.js
@@ -2,7 +2,7 @@ import { NotificationLevel } from '../Message/Notification/NotificationLevel.js'
describe('NotificationLevelTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Notification/NotificationManagerTest.js b/tests/Message/Notification/NotificationManagerTest.js
index b4ed1df..7598716 100755
--- a/tests/Message/Notification/NotificationManagerTest.js
+++ b/tests/Message/Notification/NotificationManagerTest.js
@@ -2,7 +2,7 @@ import { NotificationManager } from '../Message/Notification/NotificationManager
describe('NotificationManagerTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Message/Notification/NotificationMessageTest.js b/tests/Message/Notification/NotificationMessageTest.js
index aed2f71..f73a9e5 100755
--- a/tests/Message/Notification/NotificationMessageTest.js
+++ b/tests/Message/Notification/NotificationMessageTest.js
@@ -2,7 +2,7 @@ import { NotificationMessage } from '../Message/Notification/NotificationMessage
describe('NotificationMessageTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Message/Notification/NotificationTypeTest.js b/tests/Message/Notification/NotificationTypeTest.js
index ff73770..d4bfe8d 100755
--- a/tests/Message/Notification/NotificationTypeTest.js
+++ b/tests/Message/Notification/NotificationTypeTest.js
@@ -2,7 +2,7 @@ import { NotificationType } from '../Message/Notification/NotificationType.js';
describe('NotificationTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Request/BrowserTypeTest.js b/tests/Message/Request/BrowserTypeTest.js
index 96585d1..5703edf 100755
--- a/tests/Message/Request/BrowserTypeTest.js
+++ b/tests/Message/Request/BrowserTypeTest.js
@@ -2,7 +2,7 @@ import { BrowserType } from '../Message/Request/BrowserType.js';
describe('BrowserTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Request/OSTypeTest.js b/tests/Message/Request/OSTypeTest.js
index f39fab2..a37b097 100755
--- a/tests/Message/Request/OSTypeTest.js
+++ b/tests/Message/Request/OSTypeTest.js
@@ -2,7 +2,7 @@ import { OSType } from '../Message/Request/OSType.js';
describe('OSTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Request/RequestMethodTest.js b/tests/Message/Request/RequestMethodTest.js
index 6e8f1be..9153a1e 100755
--- a/tests/Message/Request/RequestMethodTest.js
+++ b/tests/Message/Request/RequestMethodTest.js
@@ -2,7 +2,7 @@ import { RequestMethod } from '../Message/Request/RequestMethod.js';
describe('RequestMethodTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Request/RequestTest.js b/tests/Message/Request/RequestTest.js
index 72bda5d..dd785ec 100755
--- a/tests/Message/Request/RequestTest.js
+++ b/tests/Message/Request/RequestTest.js
@@ -1,7 +1,7 @@
describe('RequestTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Message/Request/RequestTypeTest.js b/tests/Message/Request/RequestTypeTest.js
index 38b2419..f9fdf06 100755
--- a/tests/Message/Request/RequestTypeTest.js
+++ b/tests/Message/Request/RequestTypeTest.js
@@ -2,7 +2,7 @@ import { RequestType } from '../Message/Request/RequestType.js';
describe('RequestTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Message/Response/ResponseManagerTest.js b/tests/Message/Response/ResponseManagerTest.js
index 8daa4a9..035dedb 100755
--- a/tests/Message/Response/ResponseManagerTest.js
+++ b/tests/Message/Response/ResponseManagerTest.js
@@ -1,6 +1,6 @@
describe('ResponseManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Message/Response/ResponseTest.js b/tests/Message/Response/ResponseTest.js
index d345dec..80d2863 100755
--- a/tests/Message/Response/ResponseTest.js
+++ b/tests/Message/Response/ResponseTest.js
@@ -1,6 +1,6 @@
describe('ResponseTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Message/Response/ResponseTypeTest.js b/tests/Message/Response/ResponseTypeTest.js
index 68e2a34..9b5406d 100755
--- a/tests/Message/Response/ResponseTypeTest.js
+++ b/tests/Message/Response/ResponseTypeTest.js
@@ -2,7 +2,7 @@ import { ResponseType } from '../Message/Response/ResponseType.js';
describe('ResponseTypeTest', function ()
{
- "use strict";
+ 'use strict';
describe('testEnum', function ()
{
diff --git a/tests/Module/ModuleFactoryTest.js b/tests/Module/ModuleFactoryTest.js
index 13b2587..c8f071e 100755
--- a/tests/Module/ModuleFactoryTest.js
+++ b/tests/Module/ModuleFactoryTest.js
@@ -1,6 +1,6 @@
describe('ModuleFactoryTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Module/ModuleManagerTest.js b/tests/Module/ModuleManagerTest.js
index 0ea8dbc..e3e3cc0 100755
--- a/tests/Module/ModuleManagerTest.js
+++ b/tests/Module/ModuleManagerTest.js
@@ -1,6 +1,6 @@
describe('ModuleManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Route/RouteTest.js b/tests/Route/RouteTest.js
index 1c195cb..26eb5f7 100755
--- a/tests/Route/RouteTest.js
+++ b/tests/Route/RouteTest.js
@@ -1,6 +1,6 @@
describe('RouteTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Security/Hash/Sha1Test.js b/tests/Security/Hash/Sha1Test.js
index c5ee878..477aa96 100755
--- a/tests/Security/Hash/Sha1Test.js
+++ b/tests/Security/Hash/Sha1Test.js
@@ -1,6 +1,6 @@
describe('Sha1Test', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Security/Hash/Sha1bTest.js b/tests/Security/Hash/Sha1bTest.js
index 841edf6..3693644 100755
--- a/tests/Security/Hash/Sha1bTest.js
+++ b/tests/Security/Hash/Sha1bTest.js
@@ -1,6 +1,6 @@
describe('Sha1bTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Socket/Client/ClientTest.js b/tests/Socket/Client/ClientTest.js
index 53ca592..55ec71a 100755
--- a/tests/Socket/Client/ClientTest.js
+++ b/tests/Socket/Client/ClientTest.js
@@ -1,6 +1,6 @@
describe('ClientTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Spreadsheet/CellTest.js b/tests/Spreadsheet/CellTest.js
index be49e51..f60c3d4 100755
--- a/tests/Spreadsheet/CellTest.js
+++ b/tests/Spreadsheet/CellTest.js
@@ -1,6 +1,6 @@
describe('CellTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Spreadsheet/FormattingTest.js b/tests/Spreadsheet/FormattingTest.js
index f2bacb0..277b232 100755
--- a/tests/Spreadsheet/FormattingTest.js
+++ b/tests/Spreadsheet/FormattingTest.js
@@ -1,6 +1,6 @@
describe('FormattingTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Spreadsheet/FunctionsTest.js b/tests/Spreadsheet/FunctionsTest.js
index 7a36aa5..3ed199e 100755
--- a/tests/Spreadsheet/FunctionsTest.js
+++ b/tests/Spreadsheet/FunctionsTest.js
@@ -1,6 +1,6 @@
describe('FunctionsTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Spreadsheet/SheetTest.js b/tests/Spreadsheet/SheetTest.js
index 642991d..0934c5b 100755
--- a/tests/Spreadsheet/SheetTest.js
+++ b/tests/Spreadsheet/SheetTest.js
@@ -1,6 +1,6 @@
describe('SheetTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Spreadsheet/SpreadsheetTest.js b/tests/Spreadsheet/SpreadsheetTest.js
index 0a03377..c183416 100755
--- a/tests/Spreadsheet/SpreadsheetTest.js
+++ b/tests/Spreadsheet/SpreadsheetTest.js
@@ -1,6 +1,6 @@
describe('SpreadsheetTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/ActionManagerTest.js b/tests/UI/ActionManagerTest.js
index 79020d4..979e416 100755
--- a/tests/UI/ActionManagerTest.js
+++ b/tests/UI/ActionManagerTest.js
@@ -1,6 +1,6 @@
describe('ActionManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/AutocompleteTest.js b/tests/UI/Component/AutocompleteTest.js
index 6a8298c..6d28a22 100755
--- a/tests/UI/Component/AutocompleteTest.js
+++ b/tests/UI/Component/AutocompleteTest.js
@@ -1,6 +1,6 @@
describe('AutocompleteTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/FormTest.js b/tests/UI/Component/FormTest.js
index a5d51a3..3505ba7 100755
--- a/tests/UI/Component/FormTest.js
+++ b/tests/UI/Component/FormTest.js
@@ -1,6 +1,6 @@
describe('FormTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/InputTest.js b/tests/UI/Component/InputTest.js
index d59969b..e6d4490 100755
--- a/tests/UI/Component/InputTest.js
+++ b/tests/UI/Component/InputTest.js
@@ -1,6 +1,6 @@
describe('InputTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/TabTest.js b/tests/UI/Component/TabTest.js
index 8a84435..5a588eb 100755
--- a/tests/UI/Component/TabTest.js
+++ b/tests/UI/Component/TabTest.js
@@ -1,6 +1,6 @@
describe('TabTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/TableTest.js b/tests/UI/Component/TableTest.js
index bff06c5..a629b3e 100755
--- a/tests/UI/Component/TableTest.js
+++ b/tests/UI/Component/TableTest.js
@@ -1,6 +1,6 @@
describe('TableTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/TagInputTest.js b/tests/UI/Component/TagInputTest.js
index afef75a..572afaa 100755
--- a/tests/UI/Component/TagInputTest.js
+++ b/tests/UI/Component/TagInputTest.js
@@ -1,6 +1,6 @@
describe('TagInputTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Component/TagListTest.js b/tests/UI/Component/TagListTest.js
index 0f0258b..1f96740 100755
--- a/tests/UI/Component/TagListTest.js
+++ b/tests/UI/Component/TagListTest.js
@@ -1,6 +1,6 @@
describe('TagListTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/DragNDropTest.js b/tests/UI/DragNDropTest.js
index 133d662..a7b0d90 100755
--- a/tests/UI/DragNDropTest.js
+++ b/tests/UI/DragNDropTest.js
@@ -1,6 +1,6 @@
describe('DragNDropTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/GeneralUITest.js b/tests/UI/GeneralUITest.js
index c50837c..579d038 100755
--- a/tests/UI/GeneralUITest.js
+++ b/tests/UI/GeneralUITest.js
@@ -1,6 +1,6 @@
describe('GeneralUITest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/InputManagerTest.js b/tests/UI/Input/InputManagerTest.js
index b540f4d..8dce574 100755
--- a/tests/UI/Input/InputManagerTest.js
+++ b/tests/UI/Input/InputManagerTest.js
@@ -1,6 +1,6 @@
describe('InputManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Keyboard/KeyboardManagerTest.js b/tests/UI/Input/Keyboard/KeyboardManagerTest.js
index e87f7d3..1b7ad59 100755
--- a/tests/UI/Input/Keyboard/KeyboardManagerTest.js
+++ b/tests/UI/Input/Keyboard/KeyboardManagerTest.js
@@ -1,6 +1,6 @@
describe('KeyboardManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Mouse/MouseManagerTest.js b/tests/UI/Input/Mouse/MouseManagerTest.js
index b9feffd..592df33 100755
--- a/tests/UI/Input/Mouse/MouseManagerTest.js
+++ b/tests/UI/Input/Mouse/MouseManagerTest.js
@@ -1,6 +1,6 @@
describe('MouseManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Touch/TouchManagerTest.js b/tests/UI/Input/Touch/TouchManagerTest.js
index febcde2..a00e9e9 100755
--- a/tests/UI/Input/Touch/TouchManagerTest.js
+++ b/tests/UI/Input/Touch/TouchManagerTest.js
@@ -1,6 +1,6 @@
describe('TouchManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Voice/ReadManagerTest.js b/tests/UI/Input/Voice/ReadManagerTest.js
index 61ada8c..a66ee24 100755
--- a/tests/UI/Input/Voice/ReadManagerTest.js
+++ b/tests/UI/Input/Voice/ReadManagerTest.js
@@ -1,6 +1,6 @@
describe('ReadManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Voice/SpeechManagerTest.js b/tests/UI/Input/Voice/SpeechManagerTest.js
index 75346d5..dc4b4af 100755
--- a/tests/UI/Input/Voice/SpeechManagerTest.js
+++ b/tests/UI/Input/Voice/SpeechManagerTest.js
@@ -1,6 +1,6 @@
describe('SpeechManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/Input/Voice/VoiceManagerTest.js b/tests/UI/Input/Voice/VoiceManagerTest.js
index 9d123c4..264dd44 100755
--- a/tests/UI/Input/Voice/VoiceManagerTest.js
+++ b/tests/UI/Input/Voice/VoiceManagerTest.js
@@ -1,6 +1,6 @@
describe('VoiceManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/LoaderTest.js b/tests/UI/LoaderTest.js
index 19e303f..a6dfbf3 100755
--- a/tests/UI/LoaderTest.js
+++ b/tests/UI/LoaderTest.js
@@ -1,6 +1,6 @@
describe('LoaderTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UI/UIManagerTest.js b/tests/UI/UIManagerTest.js
index c746f46..038570f 100755
--- a/tests/UI/UIManagerTest.js
+++ b/tests/UI/UIManagerTest.js
@@ -1,6 +1,6 @@
describe('UIManagerTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/UnhandledExceptionTest.js b/tests/UnhandledExceptionTest.js
index e516276..4bc7ae5 100755
--- a/tests/UnhandledExceptionTest.js
+++ b/tests/UnhandledExceptionTest.js
@@ -1,6 +1,6 @@
describe('UnhandledExceptionTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Uri/HttpUriTest.js b/tests/Uri/HttpUriTest.js
index d8b557b..7cf6ff9 100755
--- a/tests/Uri/HttpUriTest.js
+++ b/tests/Uri/HttpUriTest.js
@@ -2,7 +2,7 @@ import { HttpUri } from '../../Uri/HttpUri.js';
describe('HttpTest', function ()
{
- "use strict";
+ 'use strict';
describe('testParseUrl', function ()
{
diff --git a/tests/Uri/UriFactoryTest.js b/tests/Uri/UriFactoryTest.js
index e60c578..8148d61 100755
--- a/tests/Uri/UriFactoryTest.js
+++ b/tests/Uri/UriFactoryTest.js
@@ -2,7 +2,7 @@ import { UriFactory } from '../../Uri/UriFactory.js';
describe('UriFactoryTest', function ()
{
- "use strict";
+ 'use strict';
describe('testDefault', function ()
{
diff --git a/tests/Utils/ArrayUtilsTest.js b/tests/Utils/ArrayUtilsTest.js
index 8e34e2d..7342700 100755
--- a/tests/Utils/ArrayUtilsTest.js
+++ b/tests/Utils/ArrayUtilsTest.js
@@ -1,6 +1,6 @@
describe('ArrayUtilsTest', function ()
{
- "use strict";
+ 'use strict';
describe('testGetArray', function ()
{
diff --git a/tests/Utils/GeneralUtilsTest.js b/tests/Utils/GeneralUtilsTest.js
index ac4e537..0a0bbc0 100755
--- a/tests/Utils/GeneralUtilsTest.js
+++ b/tests/Utils/GeneralUtilsTest.js
@@ -1,6 +1,6 @@
describe('GeneralUtilsTest', function ()
{
- "use strict";
+ 'use strict';
describe('testIsset', function ()
{
diff --git a/tests/Utils/StringUtilsTest.js b/tests/Utils/StringUtilsTest.js
index d029a43..a148dff 100755
--- a/tests/Utils/StringUtilsTest.js
+++ b/tests/Utils/StringUtilsTest.js
@@ -1,6 +1,6 @@
describe('StringUtilsTest', function ()
{
- "use strict";
+ 'use strict';
describe('testTrim', function ()
{
diff --git a/tests/Utils/oLibTest.js b/tests/Utils/oLibTest.js
index 3754d11..8f186b3 100755
--- a/tests/Utils/oLibTest.js
+++ b/tests/Utils/oLibTest.js
@@ -1,6 +1,6 @@
describe('oLibTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{
diff --git a/tests/Views/FormViewTest.js b/tests/Views/FormViewTest.js
index 9acadfc..87fd57e 100755
--- a/tests/Views/FormViewTest.js
+++ b/tests/Views/FormViewTest.js
@@ -1,6 +1,6 @@
describe('FormViewTest', function ()
{
- "use strict";
+ 'use strict';
var testId = 'testForm';
beforeEach(function ()
diff --git a/tests/Views/TableViewTest.js b/tests/Views/TableViewTest.js
index 02f005f..251b2dc 100755
--- a/tests/Views/TableViewTest.js
+++ b/tests/Views/TableViewTest.js
@@ -1,6 +1,6 @@
describe('TableViewTest', function ()
{
- "use strict";
+ 'use strict';
beforeEach(function ()
{