This commit is contained in:
Dennis Eichhorn 2015-12-18 17:43:42 +01:00
commit 6462260d5a
15 changed files with 1059 additions and 0 deletions

View File

@ -0,0 +1,38 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\Draw\Admin\Install;
/**
* Navigation class.
*
* @category Modules
* @package Modules\Admin
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Navigation
{
public static function install($dbPool)
{
$navData = json_decode(file_get_contents(__DIR__ . '/nav.install.json'), true);
$class = '\\Modules\\Navigation\\Admin\\Installer';
$class::installExternal($dbPool, $navData);
}
}

View File

@ -0,0 +1,48 @@
[
{
"id": 1005201001,
"pid": "754a08ddf8bcb1cf22f310f09206dd783d42f7dd",
"type": 2,
"subtype": 1,
"name": "Draw",
"uri": "/{/lang}/backend/draw/list",
"target": "self",
"icon": null,
"order": 70,
"from": "Draw",
"permission": null,
"parent": 1003301001,
"children": [
{
"id": 1005202001,
"pid": "e19f4e17662b65bae885bc55cbb55797677ecc40",
"type": 3,
"subtype": 1,
"name": "List",
"uri": "/{/lang}/backend/draw/list",
"target": "self",
"icon": null,
"order": 1,
"from": "Draw",
"permission": null,
"parent": 1005201001,
"children": []
},
{
"id": 1005202101,
"pid": "e19f4e17662b65bae885bc55cbb55797677ecc40",
"type": 3,
"subtype": 5,
"name": "Create",
"uri": "/{/lang}/backend/draw/create",
"target": "self",
"icon": null,
"order": 15,
"from": "Draw",
"permission": null,
"parent": 1005201001,
"children": []
}
]
}
]

48
Admin/Installer.php Normal file
View File

@ -0,0 +1,48 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\Draw\Admin;
use phpOMS\DataStorage\Database\DatabaseType;
use phpOMS\DataStorage\Database\Pool;
use phpOMS\Module\InstallerAbstract;
/**
* Calendar install class.
*
* @category Modules
* @package Modules\Calendar
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Installer extends InstallerAbstract
{
/**
* {@inheritdoc}
*/
public static function install(Pool $dbPool, array $info)
{
parent::install($dbPool, $info);
switch ($dbPool->get('core')->getType()) {
case DatabaseType::MYSQL:
break;
}
}
}

42
Controller.js Normal file
View File

@ -0,0 +1,42 @@
(function (jsOMS, undefined) {
jsOMS.Modules.Draw = function (app) {
this.app = app;
this.editors = [];
};
jsOMS.Modules.Draw.prototype.bind = function (id) {
var temp = null;
if (typeof id !== 'undefined') {
temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id));
temp.bind();
this.editors.push(temp);
} else {
var canvas = document.getElementsByClassName('m-draw');
this.editors = [];
/* Handle media forms */
for (var c = 0; c < canvas.length; c++) {
temp = new jsOMS.Modules.Draw.Editor(canvas[c]);
temp.bind();
this.editors.push(temp);
}
}
}
jsOMS.Modules.Draw.prototype.getElements = function() {
return this.editors;
}
jsOMS.Modules.Draw.prototype.count = function() {
return this.editors.length;
}
}(window.jsOMS = window.jsOMS || {}));
jsOMS.ready(function () {
window.omsApp.moduleManager.initModule('Draw');
window.omsApp.moduleManager.get('Draw').bind();
});

170
Controller.php Normal file
View File

@ -0,0 +1,170 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
namespace Modules\Draw;
use Modules\Navigation\Models\Navigation;
use Modules\Navigation\Views\NavigationView;
use phpOMS\Asset\AssetType;
use phpOMS\Contract\RenderableInterface;
use phpOMS\Message\RequestAbstract;
use phpOMS\Message\RequestDestination;
use phpOMS\Message\ResponseAbstract;
use phpOMS\Module\ModuleAbstract;
use phpOMS\Module\WebInterface;
use phpOMS\Views\View;
use phpOMS\Views\ViewLayout;
/**
* Calendar controller class.
*
* @category Modules
* @package Draw
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @license OMS License 1.0
* @link http://orange-management.com
* @since 1.0.0
*/
class Controller extends ModuleAbstract implements WebInterface
{
/**
* Module name.
*
* @var \string
* @since 1.0.0
*/
protected static $module = 'Draw';
/**
* Localization files.
*
* @var \string
* @since 1.0.0
*/
protected static $localization = [
RequestDestination::BACKEND => ['backend'],
];
/**
* Providing.
*
* @var \string
* @since 1.0.0
*/
protected static $providing = [
'Content',
];
/**
* Dependencies.
*
* @var \string
* @since 1.0.0
*/
protected static $dependencies = [
];
/**
* Routing elements.
*
* @var array
* @since 1.0.0
*/
protected static $routes = [
'^.*/backend/draw/create.*$' => [
['dest' => '\Modules\Draw\Controller:setUpDrawEditor', 'method' => 'GET', 'type' => ViewLayout::NULL],
['dest' => '\Modules\Draw\Controller:viewDrawCreate', 'method' => 'GET', 'type' => ViewLayout::MAIN],
],
'^.*/backend/draw/list.*$' => [['dest' => '\Modules\Draw\Controller:viewDrawList', 'method' => 'GET', 'type' => ViewLayout::MAIN],],
];
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return void
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function setUpDrawEditor(RequestAbstract $request, ResponseAbstract $response, $data = null)
{
$head = $response->getHead();
$head->addAsset(AssetType::JS, $request->getUri()->getBase() . 'Modules/Draw/ModuleDraw.js');
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewDrawCreate(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Draw/Theme/backend/draw-create');
$view->addData('nav', $this->createNavigation(1005201001, $request, $response));
return $view;
}
/**
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
* @param mixed $data Generic data
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
public function viewDrawList(RequestAbstract $request, ResponseAbstract $response, $data = null) : RenderableInterface
{
$view = new View($this->app, $request, $response);
$view->setTemplate('/Modules/Draw/Theme/backend/draw-list');
$view->addData('nav', $this->createNavigation(1005201001, $request, $response));
return $view;
}
/**
* @param int $pageId Page/parent Id for navigation
* @param RequestAbstract $request Request
* @param ResponseAbstract $response Response
*
* @return RenderableInterface
*
* @since 1.0.0
* @author Dennis Eichhorn <d.eichhorn@oms.com>
*/
private function createNavigation(\int $pageId, RequestAbstract $request, ResponseAbstract $response)
{
$nav = Navigation::getInstance($request, $this->app->dbPool);
$navView = new NavigationView($this->app, $request, $response);
$navView->setTemplate('/Modules/Navigation/Theme/backend/mid');
$navView->setNav($nav->getNav());
$navView->setLanguage($request->getL11n()->language);
$navView->setParent($pageId);
return $navView;
}
}

18
Models/DrawType.enum.js Normal file
View File

@ -0,0 +1,18 @@
/**
* DrawType.
*
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0 * @since 1.0.0
*/
(function (jsOMS, undefined)
{
jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({
DRAW: 0,
LINE: 1,
RECTANGLE: 2,
CIRCLE: 3,
});
}(window.jsOMS = window.jsOMS || {}));

199
Models/Editor.js Normal file
View File

@ -0,0 +1,199 @@
(function (jsOMS, undefined)
{
jsOMS.Modules.Draw.Editor = function (editor)
{
this.editor = editor;
this.canvas = document.getElementsByTagName('canvas')[0];
this.canvasContainer = this.canvas.parentElement;
this.ctx = this.canvas.getContext("2d");
var canvasStyle = window.getComputedStyle(this.canvas, null);
var canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null);
this.resize({
width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth),
height: parseFloat(canvasContainerStyle.height) - parseFloat(canvasContainerStyle.paddingTop) - parseFloat(canvasContainerStyle.paddingBottom) - parseFloat(canvasContainerStyle.borderRightWidth) - parseFloat(canvasStyle.borderRightWidth)
});
// Backup for undo.
this.canvasBackup = document.createElement('canvas');
this.ctxBackup = this.canvasBackup.getContext("2d");
this.size = 1;
this.type = jsOMS.Modules.Draw.DrawTypeEnum.DRAW;
this.color = '#000000';
this.drawFlag = false;
this.oldPos = {x: 0, y: 0};
this.newPos = {x: 0, y: 0};
// All backup steps need to be stored here (draw, resize etc.)
// Undo means the whole canvas will be redrawn on the canvasBackup without the last step
this.undoHistory = [];
this.redoHistory = [];
};
jsOMS.Modules.Draw.Editor.prototype.bind = function ()
{
var self = this;
// Handle draw and resize
this.canvas.addEventListener('mousemove', function (evt)
{
if (!self.drawFlag || self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'nwse-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'nwse-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'nesw-resize';
} else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'nesw-resize';
} else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) {
document.body.style.cursor = 'ew-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) {
document.body.style.cursor = 'ew-resize';
} else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'ns-resize';
} else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'ns-resize';
} else {
document.body.style.cursor = 'default';
}
if (self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.draw(self.oldPos, self.newPos);
}
}
}, false);
this.canvas.addEventListener("mousedown", function (evt)
{
self.drawFlag = true;
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.draw(self.newPos, self.newPos);
} else if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
}
}, false);
this.canvas.addEventListener("mouseup", function (evt)
{
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
self.draw(self.oldPos, self.newPos);
}
self.drawFlag = false;
}, false);
this.canvas.addEventListener("mouseout", function (evt)
{
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
self.draw(self.oldPos, self.newPos);
self.drawFlag = false;
document.body.style.cursor = 'default';
}, false);
};
jsOMS.Modules.Draw.Editor.prototype.draw = function (start, end)
{
if (this.drawFlag) {
this.ctx.beginPath();
this.ctx.strokeStyle = this.color;
this.ctx.lineWidth = this.size;
if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
this.ctx.moveTo(start.x, start.y);
this.ctx.lineTo(end.x, end.y);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE) {
this.ctx.rect(start.x, start.y, end.x - start.x, end.y - start.y);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
this.ctx.arc(start.x, start.y, Math.sqrt((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)), 0, 2 * Math.PI);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE) {
this.ctx.moveTo(start.x, start.y);
this.ctx.lineTo(end.x, end.y);
}
this.ctx.stroke();
// this.ctx.closePath();
// check if undo has space
// create backup to backup canvas
// remove x first undos from history
// add this step to undo
}
}
jsOMS.Modules.Draw.Editor.prototype.setSize = function (size)
{
this.size = size;
}
jsOMS.Modules.Draw.Editor.prototype.setType = function (type)
{
this.type = type;
}
jsOMS.Modules.Draw.Editor.prototype.setColor = function (color)
{
this.color = color;
}
jsOMS.Modules.Draw.Editor.prototype.toImage = function (callback)
{
var image = new Image();
image.onload = function ()
{
callback(image);
}
image.src = this.canvas.toDataURL('image/png');
// return image;
}
jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt)
{
var rect = this.canvas.getBoundingClientRect();
return {
x: evt.clientX - rect.left - 0.5,
y: evt.clientY - rect.top - 0.5
};
}
jsOMS.Modules.Draw.Editor.prototype.resize = function (size)
{
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = this.canvas.width;
tmpCanvas.height = this.canvas.height;
tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0);
this.canvas.width = size.width;
this.canvas.height = size.height;
this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, this.canvas.width, this.canvas.height);
}
jsOMS.Modules.Draw.Editor.prototype.scale = function (scale)
{
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = this.canvas.width;
tmpCanvas.height = this.canvas.height;
tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0);
this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, scale.width, scale.height);
}
}(window.jsOMS = window.jsOMS || {}));

254
ModuleDraw.js Normal file
View File

@ -0,0 +1,254 @@
(function (jsOMS, undefined)
{
jsOMS.Modules.Draw = function (app)
{
this.app = app;
this.editors = [];
};
jsOMS.Modules.Draw.prototype.bind = function (id)
{
var temp = null;
if (typeof id !== 'undefined') {
temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id));
temp.bind();
this.editors.push(temp);
} else {
var canvas = document.getElementsByClassName('m-draw');
this.editors = [];
/* Handle media forms */
for (var c = 0; c < canvas.length; c++) {
temp = new jsOMS.Modules.Draw.Editor(canvas[c]);
temp.bind();
this.editors.push(temp);
}
}
}
jsOMS.Modules.Draw.prototype.getElements = function ()
{
return this.editors;
}
jsOMS.Modules.Draw.prototype.count = function ()
{
return this.editors.length;
}
}(window.jsOMS = window.jsOMS || {}));
jsOMS.ready(function ()
{
window.omsApp.moduleManager.initModule('Draw');
window.omsApp.moduleManager.get('Draw').bind();
});
/**
* DrawType.
*
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0 * @since 1.0.0
*/
(function (jsOMS, undefined)
{
jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({
DRAW: 0,
LINE: 1,
RECTANGLE: 2,
CIRCLE: 3,
});
}(window.jsOMS = window.jsOMS || {}));
(function (jsOMS, undefined)
{
jsOMS.Modules.Draw.Editor = function (editor)
{
this.editor = editor;
this.canvas = document.getElementsByTagName('canvas')[0];
this.canvasContainer = this.canvas.parentElement;
this.ctx = this.canvas.getContext("2d");
var canvasStyle = window.getComputedStyle(this.canvas, null);
var canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null);
this.resize({
width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth),
height: parseFloat(canvasContainerStyle.height) - parseFloat(canvasContainerStyle.paddingTop) - parseFloat(canvasContainerStyle.paddingBottom) - parseFloat(canvasContainerStyle.borderRightWidth) - parseFloat(canvasStyle.borderRightWidth)
});
// Backup for undo.
this.canvasBackup = document.createElement('canvas');
this.ctxBackup = this.canvasBackup.getContext("2d");
this.size = 1;
this.type = jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE;
this.color = '#000000';
this.drawFlag = false;
this.oldPos = {x: 0, y: 0};
this.newPos = {x: 0, y: 0};
// All backup steps need to be stored here (draw, resize etc.)
// Undo means the whole canvas will be redrawn on the canvasBackup without the last step
this.undoHistory = [];
this.redoHistory = [];
};
jsOMS.Modules.Draw.Editor.prototype.bind = function ()
{
var self = this;
// Handle draw and resize
this.canvas.addEventListener('mousemove', function (evt)
{
if (!self.drawFlag || self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'nwse-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'nwse-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'nesw-resize';
} else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'nesw-resize';
} else if (self.newPos.x < self.canvas.width - 1 && self.newPos.x > self.canvas.width - 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) {
document.body.style.cursor = 'ew-resize';
} else if (self.newPos.x > 1 && self.newPos.x < 5 && self.newPos.y > 5 && self.newPos.y < self.canvas.height - 5) {
document.body.style.cursor = 'ew-resize';
} else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y < self.canvas.height - 1 && self.newPos.y > self.canvas.height - 5) {
document.body.style.cursor = 'ns-resize';
} else if (self.newPos.x > 5 && self.newPos.x < self.canvas.width - 5 && self.newPos.y > 1 && self.newPos.y < 5) {
document.body.style.cursor = 'ns-resize';
} else {
document.body.style.cursor = 'default';
}
if (self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.draw(self.oldPos, self.newPos);
}
}
}, false);
this.canvas.addEventListener("mousedown", function (evt)
{
self.drawFlag = true;
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
self.draw(self.newPos, self.newPos);
} else if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
}
}, false);
this.canvas.addEventListener("mouseup", function (evt)
{
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
if (self.drawFlag && self.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE || self.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
self.draw(self.oldPos, self.newPos);
}
self.drawFlag = false;
}, false);
this.canvas.addEventListener("mouseout", function (evt)
{
self.oldPos = self.newPos;
self.newPos = self.mousePosition(evt);
self.draw(self.oldPos, self.newPos);
self.drawFlag = false;
document.body.style.cursor = 'default';
}, false);
};
jsOMS.Modules.Draw.Editor.prototype.draw = function (start, end)
{
if (this.drawFlag) {
this.ctx.beginPath();
this.ctx.strokeStyle = this.color;
this.ctx.lineWidth = this.size;
if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.DRAW) {
this.ctx.moveTo(start.x, start.y);
this.ctx.lineTo(end.x, end.y);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.RECTANGLE) {
this.ctx.rect(start.x, start.y, end.x - start.x, end.y - start.y);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.CIRCLE) {
this.ctx.arc(start.x, start.y, Math.sqrt((end.x - start.x) * (end.x - start.x) + (end.y - start.y) * (end.y - start.y)), 0, 2 * Math.PI);
} else if (this.type === jsOMS.Modules.Draw.DrawTypeEnum.LINE) {
this.ctx.moveTo(start.x, start.y);
this.ctx.lineTo(end.x, end.y);
}
this.ctx.stroke();
// this.ctx.closePath();
// check if undo has space
// create backup to backup canvas
// remove x first undos from history
// add this step to undo
}
}
jsOMS.Modules.Draw.Editor.prototype.setSize = function (size)
{
this.size = size;
}
jsOMS.Modules.Draw.Editor.prototype.setType = function (type)
{
this.type = type;
}
jsOMS.Modules.Draw.Editor.prototype.setColor = function (color)
{
this.color = color;
}
jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt)
{
var rect = this.canvas.getBoundingClientRect();
return {
x: evt.clientX - rect.left - 0.5,
y: evt.clientY - rect.top - 0.5
};
}
jsOMS.Modules.Draw.Editor.prototype.resize = function (size)
{
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = this.canvas.width;
tmpCanvas.height = this.canvas.height;
tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0);
this.canvas.width = size.width;
this.canvas.height = size.height;
this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, this.canvas.width, this.canvas.height);
}
jsOMS.Modules.Draw.Editor.prototype.scale = function (scale)
{
var tmpCanvas = document.createElement('canvas');
tmpCanvas.width = this.canvas.width;
tmpCanvas.height = this.canvas.height;
tmpCanvas.getContext('2d').drawImage(this.canvas, 0, 0);
this.canvas.getContext('2d').drawImage(tmpCanvas, 0, 0, tmpCanvas.width, tmpCanvas.height, 0, 0, scale.width, scale.height);
}
}(window.jsOMS = window.jsOMS || {}));

0
README.md Normal file
View File

View File

@ -0,0 +1,84 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
echo $this->getData('nav')->render(); ?>
<section class="box w-100">
<div class="inner">
<form>
<input type="text" class="wf-100">
</form>
</div>
</section>
<section class="box w-100">
<div class="tabular">
<ul class="tab-links">
<li><label for="c-tab-1"><?= $this->l11n->lang['Draw']['Start'] ?></label>
<li><label for="c-tab-2"><?= $this->l11n->lang['Draw']['Layout'] ?></label>
</ul>
<div class="tab-content">
<input type="radio" id="c-tab-1" name="tabular-1" checked>
<div class="tab">
<ul class="h-list">
<li><i class="fa fa-lg fa-floppy-o"></i>
<li><i class="fa fa-lg fa-cloud-download"></i>
<li><i class="fa fa-lg fa-undo"></i>
<li><i class="fa fa-lg fa-repeat"></i>
<li><i class="fa fa-lg fa-pencil"></i>
<li><i class="fa fa-lg fa-paint-brush"></i>
<li><i class="fa fa-lg fa-eraser"></i>
<li><i class="fa fa-lg fa-minus"></i>
<li><i class="fa fa-lg fa-square-o"></i>
<li><i class="fa fa-lg fa-circle-thin"></i>
<li><i class="fa fa-lg fa-tint"></i>
<li><i class="fa fa-lg fa-bars"></i>
<li><i class="fa fa-lg fa-i-cursor"></i>
<li><i class="fa fa-lg fa-text-height"></i>
</ul>
</div>
<input type="radio" id="c-tab-2" name="tabular-1">
<div class="tab">
</div>
</div>
</div>
</section>
<div class="m-draw">
<section class="box w-100" style="height: 30%;">
<div class="inner">
<canvas></canvas>
</div>
</section>
</div>
<section class="box w-100">
<div class="inner">
<form>
<table class="layout">
<tr><td colspan="2"><label><?= $this->l11n->lang['Draw']['Permission'] ?></label>
<tr><td><select>
<option>
</select>
<tr><td colspan="2"><label><?= $this->l11n->lang['Draw']['GroupUser'] ?></label>
<tr><td><input id="iPermission" name="group" type="text" placeholder="&#xf084;"><td><button><?= $this->l11n->lang[0]['Add'] ?></button>
</table>
</form>
</div>
</section>

View File

@ -0,0 +1,44 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
/**
* @var \phpOMS\Views\View $this
*/
$footerView = new \Web\Views\Lists\PaginationView($this->app, $this->request, $this->response);
$footerView->setTemplate('/Web/Templates/Lists/Footer/PaginationBig');
$footerView->setPages(20);
$footerView->setPage(1);
echo $this->getData('nav')->render(); ?>
<section class="box">
<table class="table">
<caption><?= $this->l11n->lang['Draw']['Images']; ?></caption>
<thead>
<tr>
<td class="wf-100"><?= $this->l11n->lang['Draw']['Name']; ?>
<td><?= $this->l11n->lang['Draw']['Creator']; ?>
<td><?= $this->l11n->lang['Draw']['Created']; ?>
<tfoot>
<tr>
<td colspan="3"><?= $footerView->render(); ?>
<tbody>
<?php $count = 0; foreach([] as $key => $value) : $count++; ?>
<?php endforeach; ?>
<?php if($count === 0) : ?>
<tr><td colspan="5" class="empty"><?= $this->l11n->lang[0]['Empty']; ?>
<?php endif; ?>
</table>
</section>

View File

@ -0,0 +1,17 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
$MODLANG['Navigation'] = [
];

View File

@ -0,0 +1,26 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
$MODLANG['Draw'] = [
'Created' => 'Created',
'Creator' => 'Creator',
'Draw' => 'Draw',
'GroupUser' => 'Group/User',
'Images' => 'Images',
'Layout' => 'Layout',
'Name' => 'Name',
'Permission' => 'Permission',
'Start' => 'Start',
];

View File

@ -0,0 +1,20 @@
<?php
/**
* Orange Management
*
* PHP Version 7.0
*
* @category TBD
* @package TBD
* @author OMS Development Team <dev@oms.com>
* @author Dennis Eichhorn <d.eichhorn@oms.com>
* @copyright 2013 Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link http://orange-management.com
*/
$MODLANG['Navigation'] = [
'Create' => 'Create',
'Draw' => 'Draw',
'List' => 'List',
];

51
info.json Normal file
View File

@ -0,0 +1,51 @@
{
"name": {
"id": 1005200000,
"internal": "Draw",
"external": "OMS Draw"
},
"version": "1.0.0",
"requirements": {
"phpOMS": "1.0.0",
"phpOMS-db": "1.0.0"
},
"creator": {
"name": "Orange Management",
"website": "www.spl1nes.com"
},
"description": "The administration module.",
"directory": "Draw",
"dependencies": {},
"providing": {
"Navigation": "*"
},
"load": [
{
"pid": [
"e19f4e17662b65bae885bc55cbb55797677ecc40"
],
"type": 4,
"for": "Content",
"file": "Draw",
"from": "Draw"
},
{
"pid": [
"e19f4e17662b65bae885bc55cbb55797677ecc40"
],
"type": 5,
"for": "Content",
"file": "backend",
"from": "Draw"
},
{
"pid": [
"754a08ddf8bcb1cf22f310f09206dd783d42f7dd"
],
"type": 5,
"from": "Draw",
"for": "Navigation",
"file": "nav.backend"
}
]
}