mirror of
https://github.com/Karaka-Management/oms-Draw.git
synced 2026-01-29 06:18:42 +00:00
Init canvas from image
This commit is contained in:
parent
a0c9ced34a
commit
1aa533428d
|
|
@ -20,6 +20,10 @@ return [
|
|||
],
|
||||
],
|
||||
'^.*/backend/draw/single.*$' => [
|
||||
[
|
||||
'dest' => '\Modules\Draw\Controller:setUpDrawEditor',
|
||||
'verb' => RouteVerb::GET,
|
||||
],
|
||||
[
|
||||
'dest' => '\Modules\Draw\Controller:viewDrawSingle',
|
||||
'verb' => RouteVerb::GET,
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
return $view;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
|
|
@ -133,12 +134,14 @@ class Controller extends ModuleAbstract implements WebInterface
|
|||
* @since 1.0.0
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
*/
|
||||
public function viewDrawImage(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
public function viewDrawSingle(RequestAbstract $request, ResponseAbstract $response, $data = null) : \Serializable
|
||||
{
|
||||
$view = new View($this->app, $request, $response);
|
||||
$view->setTemplate('/Modules/Draw/Theme/Backend/draw-create');
|
||||
$view->setTemplate('/Modules/Draw/Theme/Backend/draw-single');
|
||||
$view->addData('nav', $this->app->moduleManager->get('Navigation')->createNavigationMid(1005201001, $request, $response));
|
||||
|
||||
$view->addData('image', DrawImageMapper::get($request->getData('id')));
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@
|
|||
{
|
||||
const self = this;
|
||||
|
||||
this.initCanvas();
|
||||
|
||||
this.canvasContainer.addEventListener('DOMAttrModified', function(evt) {
|
||||
self.canvasStyle = window.getComputedStyle(self.canvas, null);
|
||||
self.canvasContainerStyle = window.getComputedStyle(self.canvasContainer, null);
|
||||
|
|
@ -100,6 +102,15 @@
|
|||
}, false);
|
||||
};
|
||||
|
||||
jsOMS.Modules.Draw.Editor.prototype.initCanvas = function()
|
||||
{
|
||||
const img = this.editor.getElementsByTagName('img');
|
||||
|
||||
if(img.length > 0) {
|
||||
this.canvas.getContext("2d").drawImage(img[0], 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
jsOMS.Modules.Draw.Editor.prototype.draw = function (start, end)
|
||||
{
|
||||
if (this.drawFlag) {
|
||||
|
|
|
|||
31
Models/NullDrawImage.php
Normal file
31
Models/NullDrawImage.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @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\Models;
|
||||
|
||||
/**
|
||||
* News article class.
|
||||
*
|
||||
* @category Module
|
||||
* @package Framework
|
||||
* @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 NullDrawImage extends DrawImage
|
||||
{
|
||||
}
|
||||
103
Theme/Backend/draw-single.tpl.php
Normal file
103
Theme/Backend/draw-single.tpl.php
Normal file
|
|
@ -0,0 +1,103 @@
|
|||
<?php
|
||||
/**
|
||||
* Orange Management
|
||||
*
|
||||
* PHP Version 7.1
|
||||
*
|
||||
* @category TBD
|
||||
* @package TBD
|
||||
* @author OMS Development Team <dev@oms.com>
|
||||
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link http://orange-management.com
|
||||
*/
|
||||
/**
|
||||
* @var \phpOMS\Views\View $this
|
||||
*/
|
||||
|
||||
$image = $this->getData('image');
|
||||
|
||||
echo $this->getData('nav')->render(); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<form id="drawForm" action="<?= \phpOMS\Uri\UriFactory::build('/{/lang}/api/draw?csrf={$CSRF}'); ?>" method="POST">
|
||||
<input type="text" id="iTitle" name="title" class="wf-100" value="<?= $image->getMedia()->getName(); ?>"><input type="submit" value="<?= $this->getText('Save', 0, 0); ?>">
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="box wf-100">
|
||||
<div class="tabular">
|
||||
<ul class="tab-links">
|
||||
<li><label for="c-tab-1"><?= $this->getText('Start') ?></label>
|
||||
<li><label for="c-tab-2"><?= $this->getText('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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<div class="m-draw">
|
||||
<section class="box wf-100" style="height: 30%;">
|
||||
<div class="inner resizable">
|
||||
<img class="hidden" src="<?= $this->request->getUri()->getBase() . $image->getMedia()->getPath(); ?>">
|
||||
<canvas id="canvasImage resizable" name="image" form="drawForm"></canvas>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<section class="box wf-100">
|
||||
<div class="inner">
|
||||
<form>
|
||||
<table class="layout">
|
||||
<tr><td colspan="2"><label><?= $this->getText('Permission') ?></label>
|
||||
<tr><td><select>
|
||||
<option>
|
||||
</select>
|
||||
<tr><td colspan="2"><label><?= $this->getText('GroupUser') ?></label>
|
||||
<tr><td><input id="iPermission" name="group" type="text" placeholder=""><td><button><?= $this->getText('Add', 0, 0) ?></button>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -42,9 +42,9 @@ echo $this->getData('nav')->render(); ?>
|
|||
<?php $count = 0; foreach($images as $key => $value) : $count++;
|
||||
$url = \phpOMS\Uri\UriFactory::build('/{/lang}/backend/draw/single?id=' . $value->getId()); ?>
|
||||
<tr>
|
||||
<td><?= $value->getMedia()->getName(); ?>
|
||||
<td><?= $value->getMedia()->getCreatedBy(); ?>
|
||||
<td><?= $value->getMedia()->getCreatedAt()->format('Y-m-d'); ?>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getMedia()->getName(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getMedia()->getCreatedBy(); ?></a>
|
||||
<td><a href="<?= $url; ?>"><?= $value->getMedia()->getCreatedAt()->format('Y-m-d'); ?></a>
|
||||
<?php endforeach; ?>
|
||||
<?php if($count === 0) : ?>
|
||||
<tr><td colspan="5" class="empty"><?= $this->getText('Empty', 0, 0); ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user