Initial commit

This commit is contained in:
2011-09-28 03:37:39 -07:00
commit b1fbb339c2
373 changed files with 52305 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
end

View File

@@ -0,0 +1,86 @@
class ContractTemplatesController < ApplicationController
# GET /contract_templates
# GET /contract_templates.xml
def index
@contract_templates = ContractTemplate.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contract_templates }
end
end
# GET /contract_templates/1
# GET /contract_templates/1.xml
def show
@contract_template = ContractTemplate.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contract_template }
format.text do
render :text => @contract_template.boilerplate
end
end
end
# GET /contract_templates/new
# GET /contract_templates/new.xml
def new
@contract_template = ContractTemplate.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contract_template }
end
end
# GET /contract_templates/1/edit
def edit
@contract_template = ContractTemplate.find(params[:id])
end
# POST /contract_templates
# POST /contract_templates.xml
def create
@contract_template = ContractTemplate.new(params[:contract_template])
respond_to do |format|
if @contract_template.save
format.html { redirect_to(@contract_template, :notice => 'ContractTemplate was successfully created.') }
format.xml { render :xml => @contract_template, :status => :created, :location => @contract_template }
else
format.html { render :action => "new" }
format.xml { render :xml => @contract_template.errors, :status => :unprocessable_entity }
end
end
end
# PUT /contract_templates/1
# PUT /contract_templates/1.xml
def update
@contract_template = ContractTemplate.find(params[:id])
respond_to do |format|
if @contract_template.update_attributes(params[:contract_template])
format.html { redirect_to(@contract_template, :notice => 'ContractTemplate was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @contract_template.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /contract_templates/1
# DELETE /contract_templates/1.xml
def destroy
@contract_template = ContractTemplate.find(params[:id])
@contract_template.destroy
respond_to do |format|
format.html { redirect_to(contract_templates_url) }
format.xml { head :ok }
end
end
end

View File

@@ -0,0 +1,90 @@
class ContractsController < ApplicationController
# GET /contracts
# GET /contracts.xml
def index
@contracts = Contract.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @contracts }
end
end
# GET /contracts/1
# GET /contracts/1.xml
def show
@contract = Contract.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @contract }
end
end
# GET /contracts/new
# GET /contracts/new.xml
def new
@contract = Contract.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @contract }
end
end
# GET /contracts/1/edit
def edit
@contract = Contract.find(params[:id])
end
# POST /contracts
# POST /contracts.xml
def create
@contract = Contract.new(params[:contract])
@contract_template = ContractTemplate.find(params[:boilerplateid])
@contract.name = @contract_template.name
@contract.boilerplate = @contract_template.boilerplate
@contract.datesigned = Time.current
@contract.signinghash = Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s
respond_to do |format|
if @contract.save
format.html { redirect_to(@contract, :notice => 'Contract was successfully created.') }
format.xml { render :xml => @contract, :status => :created, :location => @contract }
else
format.html { render :action => "new" }
format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }
end
end
end
# PUT /contracts/1
# PUT /contracts/1.xml
def update
@contract = Contract.find(params[:id])
respond_to do |format|
# if @contract.update_attributes(params[:contract])
# format.html { redirect_to(@contract, :notice => 'Contract was successfully updated.') }
# format.xml { head :ok }
# else
format.html { redirect_to(@contract, :notice => 'Contracts cannot be edited.') }
format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }
# end
end
end
# DELETE /contracts/1
# DELETE /contracts/1.xml
def destroy
@contract = Contract.find(params[:id])
@contract.destroy
respond_to do |format|
format.html { redirect_to(contracts_url) }
format.xml { head :ok }
end
end
end

View File

@@ -0,0 +1,26 @@
class QuicksignController < ApplicationController
def new
@contract = Contract.new
@contract.signer = Signer.new
respond_to do |format|
format.html # new.html.erb
end
end
def create
@contract = Contract.new(params[:contract])
@contract.datesigned = Time.current
@contract.signinghash = Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s
@contract.save
respond_to do |format|
format.html { redirect_to(@contract, :notice => 'Contract was successfully created.') }
end
end
end

View File

@@ -0,0 +1,83 @@
class SignersController < ApplicationController
# GET /signers
# GET /signers.xml
def index
@signers = Signer.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @signers }
end
end
# GET /signers/1
# GET /signers/1.xml
def show
@signer = Signer.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @signer }
end
end
# GET /signers/new
# GET /signers/new.xml
def new
@signer = Signer.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @signer }
end
end
# GET /signers/1/edit
def edit
@signer = Signer.find(params[:id])
end
# POST /signers
# POST /signers.xml
def create
@signer = Signer.new(params[:signer])
respond_to do |format|
if @signer.save
format.html { redirect_to(@signer, :notice => 'Signer was successfully created.') }
format.xml { render :xml => @signer, :status => :created, :location => @signer }
else
format.html { render :action => "new" }
format.xml { render :xml => @signer.errors, :status => :unprocessable_entity }
end
end
end
# PUT /signers/1
# PUT /signers/1.xml
def update
@signer = Signer.find(params[:id])
respond_to do |format|
if @signer.update_attributes(params[:signer])
format.html { redirect_to(@signer, :notice => 'Signer was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @signer.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /signers/1
# DELETE /signers/1.xml
def destroy
@signer = Signer.find(params[:id])
@signer.destroy
respond_to do |format|
format.html { redirect_to(signers_url) }
format.xml { head :ok }
end
end
end

View File

@@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end

View File

@@ -0,0 +1,2 @@
module ContractTemplatesHelper
end

View File

@@ -0,0 +1,2 @@
module ContractsHelper
end

View File

@@ -0,0 +1,2 @@
module SignersHelper
end

View File

@@ -0,0 +1,2 @@
module TemplatesHelper
end

4
app/models/contract.rb Normal file
View File

@@ -0,0 +1,4 @@
class Contract < ActiveRecord::Base
belongs_to :signer
accepts_nested_attributes_for :signer
end

View File

@@ -0,0 +1,2 @@
class ContractTemplate < ActiveRecord::Base
end

3
app/models/signer.rb Normal file
View File

@@ -0,0 +1,3 @@
class Signer < ActiveRecord::Base
has_many :contracts
end

View File

@@ -0,0 +1,29 @@
<!-- TinyMCE -->
<script type="text/javascript" src="/javascripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
<h1>Editing contract_template</h1>
<% form_for(@contract_template) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_area :boilerplate %>
</p>
<p>
<%= f.submit 'Edit' %>
</p>
<% end %>
<%= link_to 'Back', contract_templates_path %>

View File

@@ -0,0 +1,22 @@
<h1>Listing contract_templates</h1>
<table>
<tr>
<th>Name</th>
<th>Boilerplate</th>
</tr>
<% @contract_templates.each do |contract_template| %>
<tr>
<td><%=h contract_template.name %></td>
<td><%= truncate(contract_template.boilerplate, :length => 1000) %></td>
<td><%= link_to 'Show', contract_template %></td>
<td><%= link_to 'Edit', edit_contract_template_path(contract_template) %></td>
<td><%= link_to 'Destroy', contract_template, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New contract_template', new_contract_template_path %>

View File

@@ -0,0 +1,29 @@
<!-- TinyMCE -->
<script type="text/javascript" src="/javascripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "simple"
});
</script>
<!-- /TinyMCE -->
<h1>New contract_template</h1>
<% form_for(@contract_template) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_area :boilerplate %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', contract_templates_path %>

View File

@@ -0,0 +1 @@
<%=@contract_template.boilerplate %>

View File

@@ -0,0 +1,24 @@
<h1>Editing contract</h1>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_field :boilerplate %>
</p>
<p>
<%= f.label :signature %><br />
<%= f.text_field :signature %>
</p>
<p>
<%= f.label :signinghash %><br />
<%= f.text_field :signinghash %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @contract %> |
<%= link_to 'Back', contracts_path %>

View File

@@ -0,0 +1,24 @@
<h1>Listing contracts</h1>
<table>
<tr>
<th>Date</th>
<th>Name</th>
<th>Signer</th>
</tr>
<% @contracts.each do |contract| %>
<tr>
<td><%=h contract.datesigned %></td>
<td><%=h contract.name %></td>
<td><% if(!contract.signer.blank?) then %><%=h contract.signer.first_name %> <%=h contract.signer.last_name %><% end %></td>
<td><%= link_to 'Show', contract %></td>
<td><%= link_to 'Edit', edit_contract_path(contract) %></td>
<td><%= link_to 'Destroy', contract, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New contract', new_contract_path %>

View File

@@ -0,0 +1,182 @@
<script language="javascript">
function showboiler(id) {
if(id>0) {
$.ajax({
url: "/contract_templates/"+id+".txt",
context: document.body,
success: function(data){
document.getElementById('boilerdisplay').innerHTML = data;
document.getElementById('contract_boilerplate').value = data;
}
});
}
else {
document.getElementById('boilerdisplay').innerHTML = "";
document.getElementById('contract_boilerplate').value = "";
}
}
function clearme() {
context.clearRect(0, 0, canvas.width, canvas.height);
context.beginPath();
}
</script>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :Template %>
<%= select_tag("boilerplate_select", options_for_select(ContractTemplate.all.collect{ |c| [c.name, c.id] }.insert(0, '')), {:onchange => "showboiler(this.value)"}) %>
<%= f.hidden_field :signature %>
<%= f.hidden_field :boilerplate %>
</p>
<div id="boilerdisplay"></div>
<meta name = "viewport" content = "width = device-width">
<style type="text/css">
html, body {
margin:0;
padding:0;
}
#canvas {
border: 1px solid black;
}
</style>
<body id="body">
<input type="button" value="Clear" onclick="clearme()" />
<div id="container"> <!-- container. start -->
<canvas width="800" height="200" id="canvas">
</canvas>
</div><!-- container. end -->
<!-- <p id="debug"></p> -->
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>
<!-- JavaScript -->
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var oldX,oldY,sofX,sofY,down=false,drag=false;
var q = new Array;
var body = document.getElementById("body");
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
body.addEventListener("touchmove", touch, false);
canvas.addEventListener("touchstart", touchStart, false);
canvas.addEventListener("touchmove", touchMove, false);
canvas.addEventListener("touchend", drawEnd, false);
canvas.addEventListener("touchcancel", drawEnd, false);
body.addEventListener('mouseup', drawEnd);
canvas.addEventListener('mousedown', mouseDown);
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener('mouseup', drawEnd);
function touch(event) {
// console.log(event);
event.preventDefault();
element = document.getElementById("debug");
element.innerHTML = event.touches.length+" touch ("+event.touches[0].pageX+","+event.touches[0].pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function touchStart(event) {
touch(event);
drawStart([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
}
function mouseDown(event) {
drawStart([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
element = document.getElementById("debug");
element.innerHTML = q.length+" ("+event.pageX+","+event.pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function drawStart(point) {
var x=point[0], y=point[1];
q = [point];
down = true;
context.lineWidth = 1;
context.strokeStyle = '#000000';
}
function touchMove(event) {
touch(event);
drawMove([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
};
function mouseMove(event) {
drawMove([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
}
function drawMove(point) {
var x=point[0], y=point[1];
drag=true;
if(down && drag && q.length>=4) {
q.push(point);
// context.fillRect(q[1][0], q[1][1], 1, 1);
// context.fillRect(q[2][0], q[2][1], 1, 1);
context.beginPath();
context.moveTo(q[0][0], q[0][1]);
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
q.shift();
q.shift();
q.shift();
// context.closePath();
context.stroke();
} else if(down && drag) {
q.push(point);
}
oldX = x;
oldY = y;
sofX = oldX;
sofY = oldY;
}
// Finished drawing (mouse up)
function drawEnd(event) {
// touch(event);
if(q.length>=2) {
if(q.length==4){
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
}
if(q.length==3){
context.quadraticCurveTo(q[1][0], q[1][1],q[2][0], q[2][1]);
}
if(q.length==2){
context.lineTo(q[1][0], q[1][1]);
}
context.stroke();
q=[];
}
if(down && drag==false || q.length==1) {
// context.fillRect(q[0][0],q[0][1], 2, 2);
context.beginPath();
context.arc(q[0][0],q[0][1],1,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.fill();
}
down = false;
drag = false;
// Write the canvas to a data url
$("#contract_signature")[0].value = canvas.toDataURL("image/png")
}
</script>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<h1>New contract</h1>
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :boilerplate %><br />
<%= f.text_field :boilerplate %>
</p>
<p>
<%= f.label :signature %><br />
<%= f.text_field :signature %>
</p>
<p>
<%= f.label :signinghash %><br />
<%= f.text_field :signinghash %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>

View File

@@ -0,0 +1,27 @@
<p>
<b>Boilerplate:</b>
<%=@contract.boilerplate %>
</p>
<p>
<b>Signature:</b>
<img src="<%=@contract.signature %>" />
</p>
<p>
<b>Date Signed:</b>
<%=h @contract.datesigned %>
</p>
<p>
<b>Hash:</b>
<%=h @contract.signinghash %>
</p>
<p>
<b>Verification:</b>
<%=Digest::SHA1.hexdigest @contract.boilerplate+@contract.signature+@contract.datesigned.to_s%>
</p>
<%= link_to 'Edit', edit_contract_path(@contract) %> |
<%= link_to 'Back', contracts_path %>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name.capitalize %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title><%= controller.controller_name.capitalize %>: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Signers: <%= controller.action_name %></title>
<%= stylesheet_link_tag 'scaffold' %>
</head>
<body>
<div id="topnav">
<b><a href="/quicksign/new">Quicksign</a></b>
<a href="/signers">Signers</a>
<a href="/contracts">Contracts</a>
<a href="/contract_templates">Templates</a>
</div>
<p style="color: green"><%= notice %></p>
<%= yield %>
</body>
</html>

View File

@@ -0,0 +1,215 @@
<script language="javascript">
function showboiler(id) {
if(id>0) {
$.ajax({
url: "/contract_templates/"+id+".txt",
context: document.body,
success: function(data){
document.getElementById('boilerdisplay').innerHTML = data;
document.getElementById('boilerplateid').value = id;
}
});
}
else {
document.getElementById('boilerdisplay').innerHTML = "";
document.getElementById('boilerplateid').value = "";
}
}
function clearme() {
context.clearRect(0, 0, canvas.width, canvas.height);
context.beginPath();
}
</script>
<style type="text/css">
html, body {
margin:0;
padding:0;
font-size: 1.2em;
font-family: Arial, Helvetica, sans-serif;
}
#canvas {
border: 1px solid black;
}
#boilerdisplay {
height: 45%;
overflow: scroll;
font-size: 20pt !important;
}
input,select { width: 40%; font-size: 1.2em; }
p { margin: 0.2em 0; }
</style>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="user-scalable=no, width=device-width" />
<link rel="apple-touch-icon" href="./apple-touch-icon.png" />
<body id="body">
<% form_for(@contract) do |f| %>
<%= f.error_messages %>
<% f.fields_for :signer do |signer_fields| %>
<p>
First Name:
<%= signer_fields.text_field :first_name %>
</p>
<p>
Last Name:
<%= signer_fields.text_field :last_name %>
</p>
<p>
Minor:
<%= signer_fields.text_field :cosigner %>
(if applicable)
</p>
<% end %>
<p>
<%= f.label :Contract %>
<%= select_tag("boilerplate_select", options_for_select(ContractTemplate.all.collect{ |c| [c.name, c.id] }.insert(0, '')), {:onchange => "showboiler(this.value)"}) %>
<%= f.hidden_field :signature %>
<%= hidden_field_tag :boilerplateid %>
</p>
<div id="boilerdisplay"></div>
<div id="container"> <!-- container. start -->
<canvas width="800" height="200" id="canvas">
</canvas>
</div><!-- container. end -->
<!-- <p id="debug"></p> -->
<p>
<input type="button" value="Clear Signature" onclick="clearme()" /> <%= f.submit 'Submit' %>
</p>
<% end %>
<%= link_to 'Back', contracts_path %>
<!-- JavaScript -->
<script type="text/javascript" src="/javascripts/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
var oldX,oldY,sofX,sofY,down=false,drag=false;
var q = new Array;
var body = document.getElementById("body");
var canvas = document.getElementById("canvas");
var context = canvas.getContext('2d');
// body.addEventListener("touchmove", touch, false);
canvas.addEventListener("touchstart", touchStart, false);
canvas.addEventListener("touchmove", touchMove, false);
canvas.addEventListener("touchend", drawEnd, false);
canvas.addEventListener("touchcancel", drawEnd, false);
body.addEventListener('mouseup', drawEnd);
canvas.addEventListener('mousedown', mouseDown);
canvas.addEventListener('mousemove', mouseMove);
canvas.addEventListener('mouseup', drawEnd);
function touch(event) {
// console.log(event);
event.preventDefault();
// element = document.getElementById("debug");
// element.innerHTML = event.touches.length+" touch ("+event.touches[0].pageX+","+event.touches[0].pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function touchStart(event) {
touch(event);
drawStart([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
}
function mouseDown(event) {
drawStart([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
// element = document.getElementById("debug");
// element.innerHTML = q.length+" ("+event.pageX+","+event.pageY+")("+$(canvas).offset().left+","+$(canvas).offset().top+") down:"+down+" drag:"+drag;
}
function drawStart(point) {
var x=point[0], y=point[1];
q = [point];
down = true;
context.lineWidth = 1;
context.strokeStyle = '#000000';
}
function touchMove(event) {
touch(event);
drawMove([event.touches[0].pageX - $(canvas).offset().left,event.touches[0].pageY - $(canvas).offset().top]);
};
function mouseMove(event) {
drawMove([event.pageX - $(canvas).offset().left,event.pageY - $(canvas).offset().top]);
}
function drawMove(point) {
var x=point[0], y=point[1];
drag=true;
if(down && drag && q.length>=4) {
q.push(point);
// context.fillRect(q[1][0], q[1][1], 1, 1);
// context.fillRect(q[2][0], q[2][1], 1, 1);
context.beginPath();
context.moveTo(q[0][0], q[0][1]);
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
q.shift();
q.shift();
q.shift();
// context.closePath();
context.stroke();
} else if(down && drag) {
q.push(point);
}
oldX = x;
oldY = y;
sofX = oldX;
sofY = oldY;
}
// Finished drawing (mouse up)
function drawEnd(event) {
// touch(event);
if(q.length>=2) {
if(q.length==4){
context.bezierCurveTo(q[1][0], q[1][1], q[2][0], q[2][1], q[3][0], q[3][1]);
}
if(q.length==3){
context.quadraticCurveTo(q[1][0], q[1][1],q[2][0], q[2][1]);
}
if(q.length==2){
context.lineTo(q[1][0], q[1][1]);
}
context.stroke();
q=[];
}
if(down && drag==false || q.length==1) {
// context.fillRect(q[0][0],q[0][1], 2, 2);
context.beginPath();
context.arc(q[0][0],q[0][1],1,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.fill();
}
down = false;
drag = false;
// Write the canvas to a data url
$("#contract_signature")[0].value = canvas.toDataURL("image/png")
}
</script>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<h1>Editing signer</h1>
<% form_for(@signer) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :cosigner %><br />
<%= f.text_field :cosigner %>
</p>
<p>
<%= f.submit 'Update' %>
</p>
<% end %>
<%= link_to 'Show', @signer %> |
<%= link_to 'Back', signers_path %>

View File

@@ -0,0 +1,24 @@
<h1>Listing signers</h1>
<table>
<tr>
<th>First name</th>
<th>Last name</th>
<th>Cosigner</th>
</tr>
<% @signers.each do |signer| %>
<tr>
<td><%=h signer.first_name %></td>
<td><%=h signer.last_name %></td>
<td><%=h signer.cosigner %></td>
<td><%= link_to 'Show', signer %></td>
<td><%= link_to 'Edit', edit_signer_path(signer) %></td>
<td><%= link_to 'Destroy', signer, :confirm => 'Are you sure?', :method => :delete %></td>
</tr>
<% end %>
</table>
<br />
<%= link_to 'New signer', new_signer_path %>

View File

@@ -0,0 +1,23 @@
<h1>New signer</h1>
<% form_for(@signer) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :first_name %><br />
<%= f.text_field :first_name %>
</p>
<p>
<%= f.label :last_name %><br />
<%= f.text_field :last_name %>
</p>
<p>
<%= f.label :cosigner %><br />
<%= f.text_field :cosigner %>
</p>
<p>
<%= f.submit 'Create' %>
</p>
<% end %>
<%= link_to 'Back', signers_path %>

View File

@@ -0,0 +1,25 @@
<p>
<b>First name:</b>
<%=h @signer.first_name %>
</p>
<p>
<b>Last name:</b>
<%=h @signer.last_name %>
</p>
<p>
<b>Cosigner:</b>
<%=h @signer.cosigner %>
</p>
<b>Contracts:</b>
<ul>
<% @signer.contracts.each do |c| %>
<li><%= link_to c.name, contract_path(c) %> (<%= c.datesigned %>)</li>
<% end %>
</ul>
<%= link_to 'Edit', edit_signer_path(@signer) %> |
<%= link_to 'Back', signers_path %>