-
Notifications
You must be signed in to change notification settings - Fork 0
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
Tuan Nguyen
committed
Jan 15, 2019
1 parent
cf589c2
commit 904f10d
Showing
9 changed files
with
242 additions
and
1 deletion.
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
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,9 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-SymbolicName: svysignature | ||
Bundle-Name: svysignature | ||
Bundle-Version: 1.0.0 | ||
Package-Type: Web-Component | ||
|
||
Name: pad/pad.spec | ||
Web-Component: True | ||
|
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 |
---|---|---|
@@ -1,2 +1,26 @@ | ||
# svySignature | ||
Signature component for Servoy | ||
|
||
Getting started | ||
------------- | ||
|
||
Get the latest version from the [releases](https://github.com/Servoy/svySignature/releases). Download and import the [svySignatureExample.servoy](https://github.com/Servoy/svySignature/releases) example solution or check out source directly from github. | ||
|
||
Documentation | ||
------------- | ||
See the [Wiki](https://github.com/Servoy/svySignature/wiki) for the available documentation | ||
|
||
|
||
Feature Requests & Bugs | ||
----------------------- | ||
Found a bug or would like to see a new feature implemented? Raise an issue in the [Issue Tracker](https://github.com/Servoy/svySignature/issues) | ||
|
||
|
||
Contributing | ||
------------- | ||
Eager to fix a bug or introduce a new feature? Clone the repository and issue a pull request | ||
|
||
|
||
License | ||
------- | ||
svySignature is licensed under the [MIT license](https://opensource.org/licenses/MIT) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
<div id="{{::model.svyMarkupId}}-wrapper" ng-class=model.styleClass style="height:100%;width:100%;"> | ||
<canvas id="{{::model.svyMarkupId}}" ng-class=model.styleClass style="height:100%;width:100%;"></canvas> | ||
</div> |
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,94 @@ | ||
angular.module('svysignaturePad', ['servoy']).directive('svysignaturePad', function() { | ||
return { | ||
restrict: 'E', | ||
scope: { | ||
model: '=svyModel', | ||
handlers: "=svyHandlers", | ||
api: "=svyApi", | ||
svyServoyapi: "=" | ||
}, | ||
controller: function($scope, $element, $attrs) { | ||
$scope.signaturePad = null; | ||
|
||
/* | ||
* Draw image with a base 64 string | ||
* @param {String} data base64 data string to draw | ||
* | ||
*/ | ||
$scope.api.setDataUrl = function(data) { | ||
return $scope.signaturePad.fromDataURL(data); | ||
}; | ||
|
||
/* | ||
* Get image as base64 string | ||
* @param {String} [type] image mimetype to save as ("image/jpeg","image/png") full list at https://mdn.io/todataurl | ||
* | ||
* @private | ||
*/ | ||
$scope.api.getDataUrl = function(type) { | ||
|
||
var datatemp = $scope.signaturePad.toData(); | ||
setTimeout(function() { | ||
$scope.signaturePad.fromData(datatemp); | ||
}, 500); | ||
|
||
var data = $scope.signaturePad.toDataURL(type); | ||
|
||
return data; | ||
}; | ||
|
||
/* | ||
* Clear Signature Pad | ||
*/ | ||
$scope.api.clear = function() { | ||
$scope.signaturePad.clear(); | ||
}; | ||
|
||
/* | ||
* Initialize Signature Pad | ||
* @param {Object} options additional options | ||
* Options {} | ||
* dotSize : (float or function) Radius of a single dot. | ||
* minWidth : (float) Minimum width of a line. Defaults to 0.5. | ||
* maxWidth : (float) Maximum width of a line. Defaults to 2.5. | ||
* throttle : (integer) Draw the next point at most once per every x milliseconds. Set it to 0 to turn off throttling. Defaults to 16. | ||
* minDistance : (integer) Add the next point only if the previous one is farther than x pixels. Defaults to 5. | ||
* backgroundColor : (string) Color used to clear the background. Can be any color format accepted by context.fillStyle. | ||
* Defaults to "rgba(0,0,0,0)" (transparent black). Use a non-transparent color e.g. "rgb(255,255,255)" (opaque white) | ||
* if you'd like to save signatures as JPEG images. | ||
* penColor: (string) Color used to draw the lines. Can be any color format accepted by context.fillStyle. Defaults to "black". | ||
* velocityFilterWeight : (float) Weight used to modify new velocity based on the previous velocity. Defaults to 0.7. | ||
* onBegin : (function) Callback when stroke begin. | ||
* onEnd : (function) Callback when stroke end. | ||
*/ | ||
$scope.api.init = function(options) { | ||
var element = document.getElementById($scope.model.svyMarkupId + '-wrapper'); | ||
var canvas = document.getElementById($scope.model.svyMarkupId); | ||
|
||
//add onBegin/onEnd Handlers | ||
if ($scope.handlers.onBegin) { | ||
options.onBegin = $scope.handlers.onBegin | ||
} | ||
if ($scope.handlers.onEnd) { | ||
options.onEnd = $scope.handlers.onEnd | ||
} | ||
$scope.signaturePad = new SignaturePad(canvas, options); | ||
|
||
function resizeCanvas() { | ||
var data = $scope.signaturePad.toData() | ||
var ratio = Math.max(window.devicePixelRatio || 1, 1); | ||
canvas.width = canvas.offsetWidth * ratio; | ||
canvas.height = canvas.offsetHeight * ratio; | ||
canvas.getContext("2d").scale(ratio, ratio); | ||
$scope.signaturePad.clear(); // otherwise isEmpty() might return incorrect value | ||
$scope.signaturePad.fromData(data); | ||
} | ||
|
||
window.addEventListener("resize", resizeCanvas); | ||
resizeCanvas(); | ||
|
||
}; | ||
}, | ||
templateUrl: 'svysignature/pad/pad.html' | ||
}; | ||
}) |
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,98 @@ | ||
{ | ||
"name": "svysignature-pad", | ||
"displayName": "pad", | ||
"version": 1, | ||
"definition": "svysignature/pad/pad.js", | ||
"libraries": | ||
[ | ||
{ | ||
"name": "signature_pad.min.js", | ||
"version": "2.3.2", | ||
"url": "svysignature/pad/lib/signature_pad.min.js", | ||
"mimetype": "text/javascript" | ||
} | ||
], | ||
|
||
"model": | ||
{ | ||
"styleClass": | ||
{ | ||
"type": "styleclass", | ||
"tags": | ||
{ | ||
"scope": "design" | ||
}, | ||
|
||
"default": "", | ||
"values": | ||
[ | ||
] | ||
} | ||
}, | ||
|
||
"handlers": | ||
{ | ||
"onBegin": | ||
{ | ||
"parameters": | ||
[ | ||
|
||
] | ||
}, | ||
|
||
"onEnd": | ||
{ | ||
"parameters": | ||
[ | ||
|
||
] | ||
} | ||
}, | ||
|
||
"api": | ||
{ | ||
"init": | ||
{ | ||
"parameters": | ||
[ | ||
{ | ||
"name": "options", | ||
"type": "object" | ||
} | ||
], | ||
|
||
"returns": "boolean" | ||
}, | ||
|
||
"getDataUrl": | ||
{ | ||
"parameters": | ||
[ | ||
{ | ||
"name": "type", | ||
"type": "string" | ||
} | ||
], | ||
|
||
"returns": "string" | ||
}, | ||
|
||
"setDataUrl": | ||
{ | ||
"parameters": | ||
[ | ||
{ | ||
"name": "data", | ||
"type": "string" | ||
} | ||
], | ||
|
||
"returns": "boolean" | ||
}, | ||
|
||
"clear": | ||
{ | ||
"returns": "boolean" | ||
} | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"name": "svySignature", | ||
"displayName": "svySignature", | ||
"packageType": "Web-Component", | ||
"icon": "https://raw.githubusercontent.com/Servoy/svySignature/master/icon.png", | ||
"description": "Signature component for Servoy", | ||
"wikiUrl": "https://github.com/Servoy/svySignature/wiki", | ||
"sourceUrl": "https://github.com/Servoy/svySignature", | ||
"releases": [ | ||
{"version": "1.0.0","url": "https://github.com/Servoy/svySignature/releases/download/v1.0.0/svySignature.zip","servoy-version":"8.2.0"}, | ||
] | ||
} |