mirror of
https://github.com/Karaka-Management/oms-Draw.git
synced 2026-02-15 14:48:40 +00:00
Make es6 adjustments
This commit is contained in:
parent
3a43f30c97
commit
23204c884c
|
|
@ -1,5 +1,7 @@
|
||||||
(function (jsOMS) {
|
(function (jsOMS) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/** @namespace jsOMS.Modules */
|
||||||
|
jsOMS.Autoloader.defineNamespace('jsOMS.Modules');
|
||||||
|
|
||||||
jsOMS.Modules.Draw = function (app) {
|
jsOMS.Modules.Draw = function (app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
@ -7,7 +9,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
jsOMS.Modules.Draw.prototype.bind = function (id) {
|
jsOMS.Modules.Draw.prototype.bind = function (id) {
|
||||||
var temp = null;
|
let temp = null;
|
||||||
|
|
||||||
if (typeof id !== 'undefined') {
|
if (typeof id !== 'undefined') {
|
||||||
temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id));
|
temp = new jsOMS.Modules.Draw.Editor(document.getElementById(id));
|
||||||
|
|
@ -15,12 +17,13 @@
|
||||||
|
|
||||||
this.editors.push(temp);
|
this.editors.push(temp);
|
||||||
} else {
|
} else {
|
||||||
var canvas = document.getElementsByClassName('m-draw');
|
const canvas = document.getElementsByClassName('m-draw'),
|
||||||
|
length = canvas.length;
|
||||||
|
|
||||||
this.editors = [];
|
this.editors = [];
|
||||||
|
|
||||||
/* Handle media forms */
|
/* Handle media forms */
|
||||||
for (var c = 0; c < canvas.length; c++) {
|
for (let c = 0; c < canvas.length; c++) {
|
||||||
temp = new jsOMS.Modules.Draw.Editor(canvas[c]);
|
temp = new jsOMS.Modules.Draw.Editor(canvas[c]);
|
||||||
temp.bind();
|
temp.bind();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@
|
||||||
*
|
*
|
||||||
* @author OMS Development Team <dev@oms.com>
|
* @author OMS Development Team <dev@oms.com>
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
* @copyright 2013 Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0 * @since 1.0.0
|
* @version 1.0.0 * @since 1.0.0
|
||||||
*/
|
*/
|
||||||
(function (jsOMS)
|
(function (jsOMS)
|
||||||
{
|
{
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/** @namespace jsOMS.Modules.Draw */
|
||||||
|
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Draw');
|
||||||
|
|
||||||
jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({
|
jsOMS.Modules.Draw.DrawTypeEnum = Object.freeze({
|
||||||
DRAW: 0,
|
DRAW: 0,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
(function (jsOMS)
|
(function (jsOMS)
|
||||||
{
|
{
|
||||||
"use strict";
|
"use strict";
|
||||||
|
/** @namespace jsOMS.Modules.Draw */
|
||||||
|
jsOMS.Autoloader.defineNamespace('jsOMS.Modules.Draw');
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor = function (editor)
|
jsOMS.Modules.Draw.Editor = function (editor)
|
||||||
{
|
{
|
||||||
|
|
@ -9,8 +11,8 @@
|
||||||
this.canvasContainer = this.canvas.parentElement;
|
this.canvasContainer = this.canvas.parentElement;
|
||||||
this.ctx = this.canvas.getContext("2d");
|
this.ctx = this.canvas.getContext("2d");
|
||||||
|
|
||||||
var canvasStyle = window.getComputedStyle(this.canvas, null);
|
const canvasStyle = window.getComputedStyle(this.canvas, null),
|
||||||
var canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null);
|
canvasContainerStyle = window.getComputedStyle(this.canvasContainer, null);
|
||||||
|
|
||||||
this.resize({
|
this.resize({
|
||||||
width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth),
|
width: parseFloat(canvasContainerStyle.width) - parseFloat(canvasContainerStyle.paddingLeft) - parseFloat(canvasContainerStyle.paddingRight) - parseFloat(canvasContainerStyle.borderLeftWidth) - parseFloat(canvasStyle.borderLeftWidth),
|
||||||
|
|
@ -36,7 +38,7 @@
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor.prototype.bind = function ()
|
jsOMS.Modules.Draw.Editor.prototype.bind = function ()
|
||||||
{
|
{
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
// Handle draw and resize
|
// Handle draw and resize
|
||||||
this.canvas.addEventListener('mousemove', function (evt)
|
this.canvas.addEventListener('mousemove', function (evt)
|
||||||
|
|
@ -154,7 +156,7 @@
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor.prototype.toImage = function (callback)
|
jsOMS.Modules.Draw.Editor.prototype.toImage = function (callback)
|
||||||
{
|
{
|
||||||
var image = new Image();
|
const image = new Image();
|
||||||
image.onload = function ()
|
image.onload = function ()
|
||||||
{
|
{
|
||||||
callback(image);
|
callback(image);
|
||||||
|
|
@ -167,7 +169,7 @@
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt)
|
jsOMS.Modules.Draw.Editor.prototype.mousePosition = function (evt)
|
||||||
{
|
{
|
||||||
var rect = this.canvas.getBoundingClientRect();
|
const rect = this.canvas.getBoundingClientRect();
|
||||||
return {
|
return {
|
||||||
x: evt.clientX - rect.left - 0.5,
|
x: evt.clientX - rect.left - 0.5,
|
||||||
y: evt.clientY - rect.top - 0.5
|
y: evt.clientY - rect.top - 0.5
|
||||||
|
|
@ -176,7 +178,7 @@
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor.prototype.resize = function (size)
|
jsOMS.Modules.Draw.Editor.prototype.resize = function (size)
|
||||||
{
|
{
|
||||||
var tmpCanvas = document.createElement('canvas');
|
const tmpCanvas = document.createElement('canvas');
|
||||||
tmpCanvas.width = this.canvas.width;
|
tmpCanvas.width = this.canvas.width;
|
||||||
tmpCanvas.height = this.canvas.height;
|
tmpCanvas.height = this.canvas.height;
|
||||||
|
|
||||||
|
|
@ -190,7 +192,7 @@
|
||||||
|
|
||||||
jsOMS.Modules.Draw.Editor.prototype.scale = function (scale)
|
jsOMS.Modules.Draw.Editor.prototype.scale = function (scale)
|
||||||
{
|
{
|
||||||
var tmpCanvas = document.createElement('canvas');
|
const tmpCanvas = document.createElement('canvas');
|
||||||
tmpCanvas.width = this.canvas.width;
|
tmpCanvas.width = this.canvas.width;
|
||||||
tmpCanvas.height = this.canvas.height;
|
tmpCanvas.height = this.canvas.height;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ jsOMS.ready(function ()
|
||||||
*
|
*
|
||||||
* @author OMS Development Team <dev@oms.com>
|
* @author OMS Development Team <dev@oms.com>
|
||||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
* @copyright 2013 Dennis Eichhorn
|
* @copyright Dennis Eichhorn
|
||||||
* @license OMS License 1.0
|
* @license OMS License 1.0
|
||||||
* @version 1.0.0 * @since 1.0.0
|
* @version 1.0.0 * @since 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user