-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ae0b9dc
Showing
10 changed files
with
618 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nbproject/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# QSignaturePad | ||
|
||
## QSignaturePad | ||
QSignaturePad is a QCubed wrapper for the excellent HTML5 canvas based smooth signature drawing by Szymon Nowak. | ||
|
||
Home page for the lib is https://github.com/szimek/signature_pad | ||
and demo is at http://szimek.github.io/signature_pad/, where you | ||
can see example of use and configuration. | ||
|
||
This control is installable by Composer. To install, execute the following on the command line from your main | ||
install directory: | ||
``` | ||
composer require qcubed/plugin_signaturepad | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "qcubed/plugin_signaturepad", | ||
"description": "QCubed wrapper for the HTML5 canvas based smooth signature drawing http://szimek.github.io/signature_pad/.", | ||
"type": "qcubed-plugin", | ||
"keywords": ["qcubed", "signature", "digital signature"], | ||
"license": "MIT", | ||
"require": { | ||
"php": ">=5.4" | ||
}, | ||
"autoload": { | ||
"psr-4": { "QCubed\\Plugin\\": "includes/" } | ||
}, | ||
"extra": { | ||
"examples": ["signaturepad.php"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
/** | ||
* Called by the ModelConnector Designer to create a list of controls appropriate for the given database field type. | ||
* The control will be available in the list of controls that appear in ModelConnector desginer dialog | ||
* in the ControlClass entry. | ||
*/ | ||
|
||
$controls[QDatabaseFieldType::VarChar][] = 'QCubed\Plugin\QSignaturePad'; | ||
$controls[QDatabaseFieldType::Blob][] = 'QCubed\Plugin\QSignaturePad'; | ||
//$controls[QDatabaseFieldType::Char][] = ''; | ||
//$controls[QDatabaseFieldType::Integer][] = ''; | ||
//$controls[QDatabaseFieldType::Float][] = ''; | ||
//$controls[QDatabaseFieldType::Bit][] = ''; | ||
//$controls[QDatabaseFieldType::DateTime][] = ''; | ||
//$controls[QDatabaseFieldType::Date][] = ''; | ||
//$controls[QDatabaseFieldType::Time][] = ''; | ||
//$controls[QType::ArrayType][] = ''; // Many-to-one. Includes forward and unique reverse references. | ||
//$controls[QType::Association][] = ''; // Many-to-many. | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
require('../../../framework/qcubed.inc.php'); | ||
|
||
use QCubed\Plugin\QSignaturePad; | ||
|
||
class SampleForm extends QForm { | ||
protected $txtSignaturePad1; | ||
protected $lblImageLink; | ||
protected $btnClear; | ||
protected $btnSave; | ||
|
||
protected function Form_Create() { | ||
$this->txtSignaturePad1 = new QSignaturePad($this); | ||
$this->lblImageLink = new QLabel($this); | ||
$this->lblImageLink->Name = QApplication::Translate("Image data"); | ||
$this->btnClear = new QButton($this); | ||
$this->btnClear->Name = QApplication::Translate("Clear"); | ||
$this->btnClear->AddAction(new QClickEvent, new QAjaxAction("btnClear_Click")); | ||
$this->btnSave = new QButton($this); | ||
$this->btnSave->Name = QApplication::Translate("Save"); | ||
$this->btnSave->AddAction(new QClickEvent, new QAjaxAction("btnSave_Click")); | ||
} | ||
} | ||
|
||
SampleForm::Run('SampleForm'); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php require(__DOCROOT__ . __EXAMPLES__ . '/includes/header.inc.php'); ?> | ||
<?php $this->RenderBegin(); ?> | ||
|
||
<div class="instructions"> | ||
<h1 class="instruction_title">QSignaturePad: enter a hand-written digital signature</h1> | ||
|
||
<b>QSignaturePad</b> is basen on the signature_pad.js file. It allows you to | ||
enter a hand-written digital signature. See | ||
<a href="https://github.com/szimek/signature_pad" target="_blank">SignaturePad Home Page</a> | ||
for a complete description and examples of usage. | ||
|
||
</div> | ||
|
||
<p><?php $this->txtSignaturePad1->Render(); ?></p> | ||
<p> | ||
<?php $this->btnClear->Render(); ?> | ||
<?php $this->btnSave->Render(); ?> | ||
</p> | ||
<p><?php $this->lblImageLink->RenderWithName(); ?></p> | ||
|
||
|
||
<?php $this->RenderEnd(); ?> | ||
<?php require(__DOCROOT__ . __EXAMPLES__ . '/includes/footer.inc.php'); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* Wrapper for the QTickpickerBoxGen class. This is the glue between the jQuery widget | ||
* and QCubed. Formatting is based on the current jQuery UI theme. | ||
*/ | ||
|
||
namespace QCubed\Plugin; | ||
|
||
//use \QType, \QDateTime, \QCallerException, \QInvalidCastException, \QModelConnectorParam; | ||
|
||
class QSignaturePadBase extends QSignaturePadGen { | ||
|
||
public function __construct($objParentObject, $strControlId = null) { | ||
parent::__construct($objParentObject, $strControlId); | ||
$this->registerFiles(); | ||
} | ||
|
||
protected function registerFiles() { | ||
//$this->AddCssFile(__JQUERY_CSS__); // make sure they know | ||
$this->AddPluginJavascriptFile("signaturepad", "signature_pad.js"); | ||
//$this->AddPluginCssFile("signaturepad", "signature_pad.css"); | ||
} | ||
|
||
} | ||
|
||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
<?php | ||
/** | ||
* | ||
* API for the signature_pad.js widget. Very basic implementation. | ||
* | ||
* @property string $Data The data:image/png;base64 image data | ||
*/ | ||
namespace QCubed\Plugin; | ||
use \QType, \QApplication, \QInvalidCastException, \QCallerException; | ||
|
||
class QSignaturePadGen extends QBlockControl { | ||
/** @var string HTML tag to be used by the control (such as div or span) */ | ||
protected $strTagName = 'canvas'; | ||
|
||
protected function getJsObjectString() { | ||
$strControlId = $this->ControlId; | ||
$strId = "SignaturePad_" . $this->ControlId; | ||
$strCode = <<<JS | ||
((function(){ | ||
if ("undefined" === typeof window["$strId"]) { | ||
var canvas = document.getElementById("$strId"); | ||
var signaturePad = new SignaturePad(canvas); | ||
window["$strId"] = signaturePad; | ||
signaturePad.onEnd = function() { | ||
qcubed.recordControlModification("$strControlId", "_Value", window["$strId"].toDataURL()); | ||
} | ||
} | ||
return window["$strId"]; | ||
})()) | ||
JS; | ||
} | ||
|
||
protected function ExecuteFunction($strFunctionName /*, ... */) { | ||
$args = func_get_args(); | ||
array_shift ($args); | ||
$strJsObjectCode = $this->getJsObjectString(); | ||
$strArgsArray = array(); | ||
if ($args) { | ||
foreach ($args as $a) { | ||
$strArgsArray[] = JavaScriptHelper::toJsObject(); | ||
} | ||
} | ||
$strArgs = ""; | ||
if ($strArgsArray) { | ||
$strArgs = ", " . implode(",", $strArgsArray); | ||
} | ||
$strCode = $strJsObjectCode . "." . $strFunctionName . "(" . $strArgs . ")"; | ||
QApplication::ExecuteJavaScript($strCode); | ||
} | ||
|
||
public function GetEndScript() { | ||
$strJsObjectCode = $this->getJsObjectString(); | ||
return $strJsObjectCode . "; " . parent::GetEndScript(); | ||
} | ||
|
||
/** | ||
* Remove the timepicker functionality completely. This will return the | ||
* element back to its pre-init state. | ||
*/ | ||
public function Clear() { | ||
$this->ExecuteFunction('clear'); | ||
} | ||
|
||
public function __get($strName) { | ||
switch ($strName) { | ||
case 'Data': return $this->strData; | ||
default: | ||
try { | ||
return parent::__get($strName); | ||
} catch (QCallerException $objExc) { | ||
$objExc->IncrementOffset(); | ||
throw $objExc; | ||
} | ||
} | ||
} | ||
|
||
public function __set($strName, $mixValue) { | ||
switch ($strName) { | ||
case 'Data': | ||
try { | ||
$this->strData = QType::Cast($mixValue, QType::String); | ||
$this->ExecuteFunction('fromDataURL', $this->strData); | ||
break; | ||
} catch (QInvalidCastException $objExc) { | ||
$objExc->IncrementOffset(); | ||
throw $objExc; | ||
} | ||
case '_Value': | ||
try { | ||
$this->strData = QType::Cast($mixValue, QType::String); | ||
break; | ||
} catch (QInvalidCastException $objExc) { | ||
$objExc->IncrementOffset(); | ||
throw $objExc; | ||
} | ||
|
||
default: | ||
try { | ||
parent::__set($strName, $mixValue); | ||
break; | ||
} catch (QCallerException $objExc) { | ||
$objExc->IncrementOffset(); | ||
throw $objExc; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Get an array of QModelConnectorParam types to use for displaying options in the ModelConnector dialog. | ||
* @return \QModelConnectorParam[] | ||
*/ | ||
public static function GetModelConnectorParams() { | ||
return array_merge(parent::GetModelConnectorParams(), array()); | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* | ||
* Wrapper for the QTickpickerBoxBase class. This is the place you can make your own | ||
* application specific customizations. If you do change this file, move it to | ||
* project/includes/plugins so that it will be picked up by the autoloader, and won't | ||
* be overwritten by composer on the next update. | ||
*/ | ||
|
||
namespace QCubed\Plugin; | ||
|
||
class QSignaturePad extends QSignaturePadBase { | ||
|
||
} | ||
|
||
|
||
?> |
Oops, something went wrong.