Skip to content

Instantly share code, notes, and snippets.

Created April 22, 2014 15:16
Show Gist options
  • Save anonymous/11183218 to your computer and use it in GitHub Desktop.
Save anonymous/11183218 to your computer and use it in GitHub Desktop.
<skuidpage showsidebar="true" showheader="true">
<model id="Signer" limit="100" query="true" createrowifnonefound="false" sobject="Contact">
<field id="Id"/>
<field id="Name"/>
<field id="Signature__c"/>
<condition type="param" value="id" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior="noquery"/>
<pagetitle model="Signer">
<subtitle>{{Model.label}} Signature Demo</subtitle>
<action type="custom" label="Clear signature" window="self" snippet="clearSignature" icon="ui-silk-pencil-delete"/>
<action type="custom" label="Save signature" window="self" snippet="saveSignature" icon="ui-silk-text-signature"/>
<panelset type="vertical">
<panel width="50%">
<custom name="Sign" uniqueid="idSign"/>
<panel width="50%">
<basicfieldeditor showheader="true" showsavecancel="false" model="Signer" buttonposition="" mode="readonly">
<column width="100%">
<section title="Signer">
<field id="Name"/>
<jsitem location="staticresource" name="JSignatureMaster" cachelocation="false" url="" filepath="jSignature-master/libs/jSignature.min.noconflict.js">var params = arguments[0],
$ = skuid.$;
<jsitem location="inlinecomponent" name="Sign" cachelocation="false" url="">// JSignature and
// demo for saving drawing of signature in Salesforce
// Peter Baeza - 2014-04-22
var element = arguments[0],
$ = skuid.$;
$(document).ready(function() {
// init signature canvas
// Get existing signature from text field
var model = skuid.model.getModel('Signer'),
row = model.getFirstRow(),
sigField = 'Signature__c',
sigData = model.getFieldValue(row,sigField);
if(sigData !== null ) { // read back Signature data
element.jSignature("setData", "data:" + sigData);
<jsitem location="inlinesnippet" name="saveSignature" cachelocation="false">var params = arguments[0],
$ = skuid.$;
var model = skuid.model.getModel('Signer'),
row = model.getFirstRow(),
sigField = 'Signature__c';
// get signature from id
var sig = $("#idSign");
var sigData = sig.jSignature("getData", "base30");
// update signature text field SF and save
model.updateRow(row,sigField,sigData[0] + ',' + sigData[1]);;</jsitem>
<jsitem location="inlinesnippet" name="clearSignature" cachelocation="false">var params = arguments[0],
$ = skuid.$;
// get signature canvas and reset
var sig = $("#idSign");
// get signature field, set to null and save model
var model = skuid.model.getModel('Signer');
var row = model.getFirstRow();
var sigField = 'Signature__c';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment