first commit
This commit is contained in:
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/LICENSE.txt
generated
vendored
Normal file
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/LICENSE.txt
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Downloadify: Client Side File Creation
|
||||
JavaScript + Flash Library
|
||||
|
||||
Copyright (c) 2009 Douglas C. Neiner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
113
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/README.textile
generated
vendored
Normal file
113
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/README.textile
generated
vendored
Normal file
@ -0,0 +1,113 @@
|
||||
h2. Downloadify: Client Side File Creation
|
||||
|
||||
*_Important! The swf has been compiled for online use only. Testing from the file path (i.e. file:// ) will not work as it will violate the security sandbox._*
|
||||
|
||||
h3. Overview
|
||||
|
||||
This library is a tiny JavaScript + Flash library that allows you to generate files on the fly, in the browser, without server interaction. Web applications that allow you to generate vCards, color palettes, custom code, etc would benefit from using this library. In addition to increasing speed (no round trip to the server) this solution can reduce the database and server load of existing web applications. _This is not a library to 'force download' a file from a server. It does not interact with a server at all._
|
||||
|
||||
h3. Demo
|
||||
|
||||
A "very simple demo is available":http://pixelgraphics.us/downloadify/test.html that lets you supply your own content and filename and test out saving, canceling, and the error functionality when the file is blank.
|
||||
|
||||
For a real world usage, see "Starter for jQuery":http://starter.pixelgraphics.us . To quickly demo the usage, just click "Load Example Data" then click Download. After the initial page load, no further contact is made with the server. Everything happens on the client side.
|
||||
|
||||
h3. Download
|
||||
|
||||
Please download from the "Downloads":http://github.com/dcneiner/Downloadify/downloads section of this project.
|
||||
|
||||
h3. Support
|
||||
|
||||
For support, please use the "Issues":http://github.com/dcneiner/Downloadify/issues section of this project. You can also try to hit me up on "Twitter at @dougneiner":http://twitter.com/dougneiner but I might just ask you to file an issue. :)
|
||||
|
||||
h3. Dependencies
|
||||
|
||||
_The end user must have Flash 10 or higher installed for this plugin to work. As of September 2009, it was at a 93% saturation, so most users should already have it installed._
|
||||
|
||||
Downloadify is only dependent on "SWFObject 2.0":http://code.google.com/p/swfobject/ which is included with the download. It is compatible with any JavaScript framework but has a helper for both jQuery and MooTools. Neither helper will be activatd if Downloadify is inserted prior to including the framework library.
|
||||
|
||||
h3. Usage
|
||||
|
||||
*Any JavaScript framework*:
|
||||
|
||||
<pre>Downloadify.create( id_or_DOM_element, options );</pre>
|
||||
|
||||
*jQuery*:
|
||||
|
||||
<pre>$("#element").downloadify( options );</pre>
|
||||
|
||||
*MooTools:*
|
||||
|
||||
<pre>$("elementid").downloadify( options );</pre>
|
||||
|
||||
h3. Options
|
||||
|
||||
Unless you are using the jQuery plugin included with Downloadify, you must supply all required options with your call to the <tt>Downloadify.create</tt> function.
|
||||
|
||||
*Defaults and Required Options*
|
||||
|
||||
* <tt>swf</tt>: <tt>'media/downloadify.swf'</tt> <span style="color:red">*Required*</span> <br />_Path to the SWF File. Can be relative from the page, or an absolute path._
|
||||
* <tt>downloadImage</tt>: <tt>'images/download.png'</tt> <span style="color:red">*Required*</span> <br />_Path to the Button Image. Can be relative from the page or an absolute path._
|
||||
* <tt>width</tt>: 175 <span style="color:red">*Required*</span> <br />_Width of the button (and the flash movie)_
|
||||
* <tt>height</tt>: 55 <span style="color:red">*Required*</span> <br />_Height of the button. This will be 1/4 the height of the image._
|
||||
* <tt>filename</tt>: <span style="color:red">*Required*</span><br /> _Can be a String or a function callback. If a function, the return value of the function will be used as the filename._
|
||||
* <tt>data</tt>: <span style="color:red">*Required*</span><br /> _Can be a normal String, base64 encoded String, or a function callback. If a function, the return value of the function will be used as the file data._
|
||||
* <tt>dataType</tt>: <tt>'string'</tt><br /> _Must be a String with the value <tt>string</tt> or <tt>base64</tt>. Data paired with the <tt>dataType</tt> of <tt>base64</tt> will be decoded into a <tt>ByteArray</tt> prior to saving._
|
||||
* <tt>transparent</tt>: false <br />_Set this to true to use wmode=transparent on the flash movie._
|
||||
* <tt>append</tt>: false <br />_By default the contents of the targeted DOM element are removed. Set this to true to keep the contents and append the button._
|
||||
|
||||
*Event Callbacks*
|
||||
|
||||
No data is passed into these functions, they are simply called.
|
||||
|
||||
* <tt>onError</tt>: _Called when the Download button is clicked but your <tt>data</tt> callback returns <tt>""</tt>._
|
||||
* <tt>onCancel</tt>: _Called when the Download button is clicked but the user then cancels without saving._
|
||||
* <tt>onComplete</tt>: _Called when the Download button is clicked and the file is saved to the user's computer._
|
||||
|
||||
h3. Setting Up the Image
|
||||
|
||||
Downloadify supports (i.e. requires) three button states with limited support for a fourth. The states are:
|
||||
|
||||
* *Normal*
|
||||
* *Over* ( When the mouse hovers over the button )
|
||||
* *Down* ( When the button is pressed )
|
||||
* *Disabled* ( Limited support, when .disable() is called on the Downloadify.Container object )
|
||||
|
||||
In trying to keep this plugin as simple as possible, all four states are always assumed to be present. You should prepare your button image as a single image the width you want your button, and four times the height of the button. All four states should then live in that one image in the same order as the previous list from top to bottom.
|
||||
|
||||
h3. Potential Issues
|
||||
|
||||
When working with different button images, you may find Flash has cached your image. This is the desired behavior on a live site, but not during development. To get around this, simply supply a ?rev=1 or ?rev=2 etc on the end of your downloadImage url.
|
||||
|
||||
h3. Compiling Notes
|
||||
|
||||
I develop locally using Xcode and the Flex 4 SDK Beta 2. Please do not submit request on how to setup a local testing environment. If you are interested in my Xcode project files, send me a message.
|
||||
|
||||
h3. Developers
|
||||
|
||||
*Core Developer:* "Doug Neiner":http://dougneiner.com
|
||||
|
||||
*Contributors:*
|
||||
|
||||
* "David Walsh":http://davidwalsh.name -- Contributed the MooTools helper
|
||||
|
||||
h3. Change Log
|
||||
|
||||
* *Version 0.2*:
|
||||
** Added support for <tt>base64</tt> via the "as3base64 Library":http://github.com/spjwebster/as3base64
|
||||
** Added <tt>dataType</tt> option
|
||||
** Added MooTools helper (Thanks David!)
|
||||
** Upgraded SWFObject to v2.2
|
||||
* *Original Release:* Version 0.1
|
||||
|
||||
h3. License Information: MIT
|
||||
|
||||
as3base64: "Copyright (c) 2006 Steve Webster":http://github.com/spjwebster/as3base64
|
||||
|
||||
All Downloadify Code: Copyright (c) 2009 Douglas C. Neiner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
BIN
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/images/download.png
generated
vendored
Normal file
BIN
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/images/download.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
3
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/js/downloadify.min.js
generated
vendored
Normal file
3
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/js/downloadify.min.js
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
/* Downloadify 0.2 (c) 2009 by Douglas Neiner. Licensed under the MIT license */
|
||||
/* See http://github.com/dcneiner/Downloadify for license and more info */
|
||||
(function(){Downloadify=window.Downloadify={queue:{},uid:new Date().getTime(),getTextForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getData();return""},getFileNameForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getFilename();return""},getDataTypeForSave:function(a){var b=Downloadify.queue[a];if(b)return b.getDataType();return""},saveComplete:function(a){var b=Downloadify.queue[a];if(b)b.complete();return true},saveCancel:function(a){var b=Downloadify.queue[a];if(b)b.cancel();return true},saveError:function(a){var b=Downloadify.queue[a];if(b)b.error();return true},addToQueue:function(a){Downloadify.queue[a.queue_name]=a},getUID:function(a){if(a.id=="")a.id='downloadify_'+Downloadify.uid++;return a.id}};Downloadify.create=function(a,b){var c=(typeof(a)=="string"?document.getElementById(a):a);return new Downloadify.Container(c,b)};Downloadify.Container=function(d,e){var f=this;f.el=d;f.enabled=true;f.dataCallback=null;f.filenameCallback=null;f.data=null;f.filename=null;var g=function(){f.options=e;if(!f.options.append)f.el.innerHTML="";f.flashContainer=document.createElement('span');f.el.appendChild(f.flashContainer);f.queue_name=Downloadify.getUID(f.flashContainer);if(typeof(f.options.filename)==="function")f.filenameCallback=f.options.filename;else if(f.options.filename)f.filename=f.options.filename;if(typeof(f.options.data)==="function")f.dataCallback=f.options.data;else if(f.options.data)f.data=f.options.data;var a={queue_name:f.queue_name,width:f.options.width,height:f.options.height};var b={allowScriptAccess:'always'};var c={id:f.flashContainer.id,name:f.flashContainer.id};if(f.options.enabled===false)f.enabled=false;if(f.options.transparent===true)b.wmode="transparent";if(f.options.downloadImage)a.downloadImage=f.options.downloadImage;swfobject.embedSWF(f.options.swf,f.flashContainer.id,f.options.width,f.options.height,"10",null,a,b,c);Downloadify.addToQueue(f)};f.enable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(true);f.enabled=true};f.disable=function(){var a=document.getElementById(f.flashContainer.id);a.setEnabled(false);f.enabled=false};f.getData=function(){if(!f.enabled)return"";if(f.dataCallback)return f.dataCallback();else if(f.data)return f.data;else return""};f.getFilename=function(){if(f.filenameCallback)return f.filenameCallback();else if(f.filename)return f.filename;else return""};f.getDataType=function(){if(f.options.dataType)return f.options.dataType;return"string"};f.complete=function(){if(typeof(f.options.onComplete)==="function")f.options.onComplete()};f.cancel=function(){if(typeof(f.options.onCancel)==="function")f.options.onCancel()};f.error=function(){if(typeof(f.options.onError)==="function")f.options.onError()};g()};Downloadify.defaultOptions={swf:'media/downloadify.swf',downloadImage:'images/download.png',width:100,height:30,transparent:true,append:false,dataType:"string"}})();if(typeof(jQuery)!="undefined"){(function($){$.fn.downloadify=function(b){return this.each(function(){b=$.extend({},Downloadify.defaultOptions,b);var a=Downloadify.create(this,b);$(this).data('Downloadify',a)})}})(jQuery)};if(typeof(MooTools)!='undefined'){Element.implement({downloadify:function(a){a=$merge(Downloadify.defaultOptions,a);return this.store('Downloadify',Downloadify.create(this,a))}})};
|
||||
4
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/js/swfobject.js
generated
vendored
Normal file
4
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/js/swfobject.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/media/downloadify.swf
generated
vendored
Normal file
BIN
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/media/downloadify.swf
generated
vendored
Normal file
Binary file not shown.
173
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/Downloadify.as
generated
vendored
Normal file
173
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/Downloadify.as
generated
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
/*
|
||||
Downloadify: Client Side File Creation
|
||||
JavaScript + Flash Library
|
||||
|
||||
Version: 0.2
|
||||
|
||||
Copyright (c) 2009 Douglas C. Neiner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
package {
|
||||
import flash.system.Security;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.net.FileReference;
|
||||
import flash.net.FileFilter;
|
||||
import flash.net.URLRequest;
|
||||
import flash.display.*;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.external.ExternalInterface;
|
||||
import com.dynamicflash.util.Base64;
|
||||
|
||||
[SWF(backgroundColor="#CCCCCC")]
|
||||
[SWF(backgroundAlpha=0)]
|
||||
public class Downloadify extends Sprite {
|
||||
|
||||
private var options:Object,
|
||||
file:FileReference = new FileReference(),
|
||||
queue_name:String = "",
|
||||
|
||||
_width:Number = 0,
|
||||
_height:Number = 0,
|
||||
|
||||
enabled:Boolean = true,
|
||||
over:Boolean = false,
|
||||
down:Boolean = false,
|
||||
|
||||
buttonImage:String = "images/download.png",
|
||||
|
||||
button:Loader;
|
||||
|
||||
public function Downloadify() {
|
||||
Security.allowDomain('*');
|
||||
|
||||
stage.align = StageAlign.TOP_LEFT;
|
||||
stage.scaleMode = StageScaleMode.NO_SCALE;
|
||||
|
||||
options = this.root.loaderInfo.parameters;
|
||||
|
||||
queue_name = options.queue_name.toString();
|
||||
|
||||
_width = options.width;
|
||||
_height = options.height;
|
||||
|
||||
if(options.downloadImage){
|
||||
buttonImage = options.downloadImage;
|
||||
}
|
||||
|
||||
setupDefaultButton();
|
||||
addChild(button);
|
||||
|
||||
this.buttonMode = true;
|
||||
|
||||
this.addEventListener(MouseEvent.CLICK, onMouseClickEvent);
|
||||
this.addEventListener(MouseEvent.ROLL_OVER , onMouseEnter);
|
||||
this.addEventListener(MouseEvent.ROLL_OUT , onMouseLeave);
|
||||
this.addEventListener(MouseEvent.MOUSE_DOWN , onMouseDown);
|
||||
this.addEventListener(MouseEvent.MOUSE_UP , onMouseUp);
|
||||
|
||||
ExternalInterface.addCallback('setEnabled', setEnabled);
|
||||
|
||||
file.addEventListener(Event.COMPLETE, onSaveComplete);
|
||||
file.addEventListener(Event.CANCEL, onSaveCancel);
|
||||
}
|
||||
|
||||
private function setEnabled(isEnabled:Boolean):Boolean {
|
||||
enabled = isEnabled;
|
||||
if(enabled === true){
|
||||
button.y = 0;
|
||||
this.buttonMode = true;
|
||||
} else {
|
||||
button.y = (-3 * _height);
|
||||
this.buttonMode = false;
|
||||
}
|
||||
return enabled;
|
||||
}
|
||||
|
||||
private function setupDefaultButton():void {
|
||||
button = new Loader();
|
||||
var urlReq:URLRequest = new URLRequest(buttonImage);
|
||||
button.load(urlReq);
|
||||
button.x = 0;
|
||||
button.y = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function onMouseEnter(event:Event):void {
|
||||
if(enabled === true){
|
||||
if(down === false) button.y = (-1 * _height);
|
||||
over = true;
|
||||
}
|
||||
}
|
||||
protected function onMouseLeave(event:Event):void {
|
||||
if(enabled === true){
|
||||
if(down === false) button.y = 0;
|
||||
over = false;
|
||||
}
|
||||
}
|
||||
protected function onMouseDown(event:Event):void {
|
||||
if(enabled === true){
|
||||
button.y = button.y = (-2 * _height);
|
||||
down = true;
|
||||
}
|
||||
}
|
||||
protected function onMouseUp(event:Event):void {
|
||||
if(enabled === true){
|
||||
if(over === false){
|
||||
button.y = 0;
|
||||
} else {
|
||||
button.y = (-1 * _height);
|
||||
}
|
||||
down = false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function onMouseClickEvent(event:Event):void{
|
||||
var theData:String = ExternalInterface.call('Downloadify.getTextForSave',queue_name),
|
||||
filename:String = ExternalInterface.call('Downloadify.getFileNameForSave',queue_name),
|
||||
dataType:String = ExternalInterface.call('Downloadify.getDataTypeForSave',queue_name);
|
||||
|
||||
if (dataType == "string" && theData != "") {
|
||||
file.save(theData, filename);
|
||||
} else if (dataType == "base64" && theData){
|
||||
file.save(Base64.decodeToByteArray(theData), filename);
|
||||
} else {
|
||||
onSaveError();
|
||||
}
|
||||
}
|
||||
|
||||
protected function onSaveComplete(event:Event):void{
|
||||
trace('Save Complete');
|
||||
ExternalInterface.call('Downloadify.saveComplete',queue_name);
|
||||
}
|
||||
|
||||
protected function onSaveCancel(event:Event):void{
|
||||
trace('Save Cancel');
|
||||
ExternalInterface.call('Downloadify.saveCancel',queue_name);
|
||||
}
|
||||
|
||||
protected function onSaveError():void{
|
||||
trace('Save Error');
|
||||
ExternalInterface.call('Downloadify.saveError',queue_name);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
135
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/com/dynamicflash/util/Base64.as
generated
vendored
Normal file
135
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/com/dynamicflash/util/Base64.as
generated
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/*
|
||||
Base64 - 1.1.0
|
||||
|
||||
Copyright (c) 2006 Steve Webster
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.dynamicflash.util {
|
||||
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
public class Base64 {
|
||||
|
||||
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
public static const version:String = "1.1.0";
|
||||
|
||||
public static function encode(data:String):String {
|
||||
// Convert string to ByteArray
|
||||
var bytes:ByteArray = new ByteArray();
|
||||
bytes.writeUTFBytes(data);
|
||||
|
||||
// Return encoded ByteArray
|
||||
return encodeByteArray(bytes);
|
||||
}
|
||||
|
||||
public static function encodeByteArray(data:ByteArray):String {
|
||||
// Initialise output
|
||||
var output:String = "";
|
||||
|
||||
// Create data and output buffers
|
||||
var dataBuffer:Array;
|
||||
var outputBuffer:Array = new Array(4);
|
||||
|
||||
// Rewind ByteArray
|
||||
data.position = 0;
|
||||
|
||||
// while there are still bytes to be processed
|
||||
while (data.bytesAvailable > 0) {
|
||||
// Create new data buffer and populate next 3 bytes from data
|
||||
dataBuffer = new Array();
|
||||
for (var i:uint = 0; i < 3 && data.bytesAvailable > 0; i++) {
|
||||
dataBuffer[i] = data.readUnsignedByte();
|
||||
}
|
||||
|
||||
// Convert to data buffer Base64 character positions and
|
||||
// store in output buffer
|
||||
outputBuffer[0] = (dataBuffer[0] & 0xfc) >> 2;
|
||||
outputBuffer[1] = ((dataBuffer[0] & 0x03) << 4) | ((dataBuffer[1]) >> 4);
|
||||
outputBuffer[2] = ((dataBuffer[1] & 0x0f) << 2) | ((dataBuffer[2]) >> 6);
|
||||
outputBuffer[3] = dataBuffer[2] & 0x3f;
|
||||
|
||||
// If data buffer was short (i.e not 3 characters) then set
|
||||
// end character indexes in data buffer to index of '=' symbol.
|
||||
// This is necessary because Base64 data is always a multiple of
|
||||
// 4 bytes and is basses with '=' symbols.
|
||||
for (var j:uint = dataBuffer.length; j < 3; j++) {
|
||||
outputBuffer[j + 1] = 64;
|
||||
}
|
||||
|
||||
// Loop through output buffer and add Base64 characters to
|
||||
// encoded data string for each character.
|
||||
for (var k:uint = 0; k < outputBuffer.length; k++) {
|
||||
output += BASE64_CHARS.charAt(outputBuffer[k]);
|
||||
}
|
||||
}
|
||||
|
||||
// Return encoded data
|
||||
return output;
|
||||
}
|
||||
|
||||
public static function decode(data:String):String {
|
||||
// Decode data to ByteArray
|
||||
var bytes:ByteArray = decodeToByteArray(data);
|
||||
|
||||
// Convert to string and return
|
||||
return bytes.readUTFBytes(bytes.length);
|
||||
}
|
||||
|
||||
public static function decodeToByteArray(data:String):ByteArray {
|
||||
// Initialise output ByteArray for decoded data
|
||||
var output:ByteArray = new ByteArray();
|
||||
|
||||
// Create data and output buffers
|
||||
var dataBuffer:Array = new Array(4);
|
||||
var outputBuffer:Array = new Array(3);
|
||||
|
||||
// While there are data bytes left to be processed
|
||||
for (var i:uint = 0; i < data.length; i += 4) {
|
||||
// Populate data buffer with position of Base64 characters for
|
||||
// next 4 bytes from encoded data
|
||||
for (var j:uint = 0; j < 4 && i + j < data.length; j++) {
|
||||
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt(i + j));
|
||||
}
|
||||
|
||||
// Decode data buffer back into bytes
|
||||
outputBuffer[0] = (dataBuffer[0] << 2) + ((dataBuffer[1] & 0x30) >> 4);
|
||||
outputBuffer[1] = ((dataBuffer[1] & 0x0f) << 4) + ((dataBuffer[2] & 0x3c) >> 2);
|
||||
outputBuffer[2] = ((dataBuffer[2] & 0x03) << 6) + dataBuffer[3];
|
||||
|
||||
// Add all non-padded bytes in output buffer to decoded data
|
||||
for (var k:uint = 0; k < outputBuffer.length; k++) {
|
||||
if (dataBuffer[k+1] == 64) break;
|
||||
output.writeByte(outputBuffer[k]);
|
||||
}
|
||||
}
|
||||
|
||||
// Rewind decoded data ByteArray
|
||||
output.position = 0;
|
||||
|
||||
// Return decoded data
|
||||
return output;
|
||||
}
|
||||
|
||||
public function Base64() {
|
||||
throw new Error("Base64 class is static container only");
|
||||
}
|
||||
}
|
||||
}
|
||||
60
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/com/dynamicflash/util/tests/Base64Test.as
generated
vendored
Normal file
60
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/com/dynamicflash/util/tests/Base64Test.as
generated
vendored
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (c) 2006 Steve Webster
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package com.dynamicflash.util.tests {
|
||||
|
||||
import flexunit.framework.TestCase;
|
||||
import flexunit.framework.TestSuite;
|
||||
import flash.utils.ByteArray;
|
||||
|
||||
import com.dynamicflash.util.Base64;
|
||||
|
||||
public class Base64Test extends TestCase {
|
||||
|
||||
public function Base64Test(methodName:String = null) {
|
||||
super(methodName);
|
||||
}
|
||||
|
||||
public function testEncode():void {
|
||||
assertEquals("VGhpcyBpcyBhIHRlc3Q=",Base64.encode("This is a test"));
|
||||
}
|
||||
|
||||
public function testEncodeDecodeBytes():void {
|
||||
var obj:Object = {name:"Dynamic Flash", url:"http://dynamicflash.com"};
|
||||
var source:ByteArray = new ByteArray();
|
||||
source.writeObject(obj);
|
||||
var encoded:String = Base64.encodeByteArray(source);
|
||||
var decoded:ByteArray = Base64.decodeToByteArray(encoded);
|
||||
var obj2:Object = decoded.readObject();
|
||||
assertEquals(obj.name, obj2.name);
|
||||
assertEquals(obj.url, obj2.url);
|
||||
}
|
||||
|
||||
public function testDecode():void {
|
||||
assertEquals("This is a test",Base64.decode("VGhpcyBpcyBhIHRlc3Q="));
|
||||
}
|
||||
|
||||
public function testEncodeDecode():void {
|
||||
var string:String = "The quick brown fox jumped over the lazy dogs";
|
||||
assertEquals(string, Base64.decode(Base64.encode(string)));
|
||||
}
|
||||
}
|
||||
}
|
||||
213
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/downloadify.js
generated
vendored
Normal file
213
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/src/downloadify.js
generated
vendored
Normal file
@ -0,0 +1,213 @@
|
||||
/*
|
||||
Downloadify: Client Side File Creation
|
||||
JavaScript + Flash Library
|
||||
|
||||
Version: 0.2
|
||||
|
||||
Copyright (c) 2009 Douglas C. Neiner
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
*/
|
||||
|
||||
(function(){
|
||||
Downloadify = window.Downloadify = {
|
||||
queue: {},
|
||||
uid: new Date().getTime(),
|
||||
getTextForSave: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) return obj.getData();
|
||||
return "";
|
||||
},
|
||||
getFileNameForSave: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) return obj.getFilename();
|
||||
return "";
|
||||
},
|
||||
getDataTypeForSave: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) return obj.getDataType();
|
||||
return "";
|
||||
},
|
||||
saveComplete: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) obj.complete();
|
||||
return true;
|
||||
},
|
||||
saveCancel: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) obj.cancel();
|
||||
return true;
|
||||
},
|
||||
saveError: function(queue){
|
||||
var obj = Downloadify.queue[queue];
|
||||
if(obj) obj.error();
|
||||
return true;
|
||||
},
|
||||
addToQueue: function(container){
|
||||
Downloadify.queue[container.queue_name] = container;
|
||||
},
|
||||
// Concept adapted from: http://tinyurl.com/yzsyfto
|
||||
// SWF object runs off of ID's, so this is the good way to get a unique ID
|
||||
getUID: function(el){
|
||||
if(el.id == "") el.id = 'downloadify_' + Downloadify.uid++;
|
||||
return el.id;
|
||||
}
|
||||
};
|
||||
|
||||
Downloadify.create = function( idOrDOM, options ){
|
||||
var el = (typeof(idOrDOM) == "string" ? document.getElementById(idOrDOM) : idOrDOM );
|
||||
return new Downloadify.Container(el, options);
|
||||
};
|
||||
|
||||
Downloadify.Container = function(el, options){
|
||||
var base = this;
|
||||
|
||||
base.el = el;
|
||||
base.enabled = true;
|
||||
base.dataCallback = null;
|
||||
base.filenameCallback = null;
|
||||
base.data = null;
|
||||
base.filename = null;
|
||||
|
||||
var init = function(){
|
||||
base.options = options;
|
||||
|
||||
if( !base.options.append ) base.el.innerHTML = "";
|
||||
|
||||
base.flashContainer = document.createElement('span');
|
||||
base.el.appendChild(base.flashContainer);
|
||||
|
||||
base.queue_name = Downloadify.getUID( base.flashContainer );
|
||||
|
||||
if( typeof(base.options.filename) === "function" )
|
||||
base.filenameCallback = base.options.filename;
|
||||
else if (base.options.filename)
|
||||
base.filename = base.options.filename;
|
||||
|
||||
if( typeof(base.options.data) === "function" )
|
||||
base.dataCallback = base.options.data;
|
||||
else if (base.options.data)
|
||||
base.data = base.options.data;
|
||||
|
||||
|
||||
var flashVars = {
|
||||
queue_name: base.queue_name,
|
||||
width: base.options.width,
|
||||
height: base.options.height
|
||||
};
|
||||
|
||||
var params = {
|
||||
allowScriptAccess: 'always'
|
||||
};
|
||||
|
||||
var attributes = {
|
||||
id: base.flashContainer.id,
|
||||
name: base.flashContainer.id
|
||||
};
|
||||
|
||||
if(base.options.enabled === false) base.enabled = false;
|
||||
|
||||
if(base.options.transparent === true) params.wmode = "transparent";
|
||||
|
||||
if(base.options.downloadImage) flashVars.downloadImage = base.options.downloadImage;
|
||||
|
||||
swfobject.embedSWF(base.options.swf, base.flashContainer.id, base.options.width, base.options.height, "10", null, flashVars, params, attributes );
|
||||
|
||||
Downloadify.addToQueue( base );
|
||||
};
|
||||
|
||||
base.enable = function(){
|
||||
var swf = document.getElementById(base.flashContainer.id);
|
||||
swf.setEnabled(true);
|
||||
base.enabled = true;
|
||||
};
|
||||
|
||||
base.disable = function(){
|
||||
var swf = document.getElementById(base.flashContainer.id);
|
||||
swf.setEnabled(false);
|
||||
base.enabled = false;
|
||||
};
|
||||
|
||||
base.getData = function(){
|
||||
if( !base.enabled ) return "";
|
||||
if( base.dataCallback ) return base.dataCallback();
|
||||
else if (base.data) return base.data;
|
||||
else return "";
|
||||
};
|
||||
|
||||
base.getFilename = function(){
|
||||
if( base.filenameCallback ) return base.filenameCallback();
|
||||
else if (base.filename) return base.filename;
|
||||
else return "";
|
||||
};
|
||||
|
||||
base.getDataType = function(){
|
||||
if (base.options.dataType) return base.options.dataType;
|
||||
return "string";
|
||||
};
|
||||
|
||||
base.complete = function(){
|
||||
if( typeof(base.options.onComplete) === "function" ) base.options.onComplete();
|
||||
};
|
||||
|
||||
base.cancel = function(){
|
||||
if( typeof(base.options.onCancel) === "function" ) base.options.onCancel();
|
||||
};
|
||||
|
||||
base.error = function(){
|
||||
if( typeof(base.options.onError) === "function" ) base.options.onError();
|
||||
};
|
||||
|
||||
init();
|
||||
};
|
||||
|
||||
Downloadify.defaultOptions = {
|
||||
swf: 'media/downloadify.swf',
|
||||
downloadImage: 'images/download.png',
|
||||
width: 100,
|
||||
height: 30,
|
||||
transparent: true,
|
||||
append: false,
|
||||
dataType: "string"
|
||||
};
|
||||
})();
|
||||
|
||||
// Support for jQuery
|
||||
if(typeof(jQuery) != "undefined"){
|
||||
(function($){
|
||||
$.fn.downloadify = function(options){
|
||||
return this.each(function(){
|
||||
options = $.extend({}, Downloadify.defaultOptions, options);
|
||||
var dl = Downloadify.create( this, options);
|
||||
$(this).data('Downloadify', dl);
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
};
|
||||
|
||||
/* mootools helper */
|
||||
if(typeof(MooTools) != 'undefined'){
|
||||
Element.implement({
|
||||
downloadify: function(options) {
|
||||
options = $merge(Downloadify.defaultOptions,options);
|
||||
return this.store('Downloadify',Downloadify.create(this,options));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
84
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/test.html
generated
vendored
Normal file
84
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/Downloadify/test.html
generated
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>Downloadify</title>
|
||||
<style type="text/css" media="screen">
|
||||
body {background: #fff; width: 500px; margin: 20px auto;}
|
||||
label, input, textarea, h1, h2, p { font-family: Arial, sans-serif; font-size: 12pt;}
|
||||
input, textarea { border: solid 1px #aaa; padding: 4px; width: 98%;}
|
||||
label { font-weight: bold;}
|
||||
h1 { font-size: 30pt; font-weight: bold; letter-spacing: -1px;}
|
||||
h2 { font-size: 14pt;}
|
||||
pre { overflow: auto; padding: 10px; background: #222; color: #ccc;}
|
||||
</style>
|
||||
<script type="text/javascript" src="js/swfobject.js"></script>
|
||||
<script type="text/javascript" src="js/downloadify.min.js"></script>
|
||||
</head>
|
||||
<body onload="load();">
|
||||
<h1>Downloadify Example</h1>
|
||||
<p>More info available at the <a href="http://github.com/dcneiner/Downloadify">Github Project Page</a></p>
|
||||
<form>
|
||||
<p>
|
||||
<label for="filename">Filename</label><br />
|
||||
<input type="text" name="filename" value="testfile.txt" id="filename" />
|
||||
</p>
|
||||
<p>
|
||||
<label for="data">File Contents</label><br />
|
||||
<textarea cols="60" rows="10" name="data" id="data">
|
||||
Whatever you put in this text box will be downloaded and saved in the file. If you leave it blank, no file will be downloaded</textarea>
|
||||
</p>
|
||||
<p id="downloadify">
|
||||
You must have Flash 10 installed to download this file.
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
function load(){
|
||||
Downloadify.create('downloadify',{
|
||||
filename: function(){
|
||||
return document.getElementById('filename').value;
|
||||
},
|
||||
data: function(){
|
||||
return document.getElementById('data').value;
|
||||
},
|
||||
onComplete: function(){ alert('Your File Has Been Saved!'); },
|
||||
onCancel: function(){ alert('You have cancelled the saving of this file.'); },
|
||||
onError: function(){ alert('You must put something in the File Contents or there will be nothing to save!'); },
|
||||
swf: 'media/downloadify.swf',
|
||||
downloadImage: 'images/download.png',
|
||||
width: 100,
|
||||
height: 30,
|
||||
transparent: true,
|
||||
append: false
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<h2>Downloadify Invoke Script For This Page</h2>
|
||||
<pre>
|
||||
Downloadify.create('downloadify',{
|
||||
filename: function(){
|
||||
return document.getElementById('filename').value;
|
||||
},
|
||||
data: function(){
|
||||
return document.getElementById('data').value;
|
||||
},
|
||||
onComplete: function(){
|
||||
alert('Your File Has Been Saved!');
|
||||
},
|
||||
onCancel: function(){
|
||||
alert('You have cancelled the saving of this file.');
|
||||
},
|
||||
onError: function(){
|
||||
alert('You must put something in the File Contents or there will be nothing to save!');
|
||||
},
|
||||
swf: 'media/downloadify.swf',
|
||||
downloadImage: 'images/download.png',
|
||||
width: 100,
|
||||
height: 30,
|
||||
transparent: true,
|
||||
append: false
|
||||
});
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
1
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/README
generated
vendored
Normal file
1
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/README
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
Downloadify is lazily loaded as a fix for IE6-9
|
||||
10
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/README.md
generated
vendored
Normal file
10
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/README.md
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
#About
|
||||
This fork of canvg provides compatibility with the c2d plugin.
|
||||
Several changes needed to be made to ensure that our _fake_
|
||||
canvas is compatible with the canvg rendering engine.
|
||||
|
||||
This library was copied from [https://github.com/Flamenco/canvg](https://github.com/Flamenco/canvg).
|
||||
|
||||
#Usage
|
||||
For examples converting HTML pages and SVG elements into PDF using canvg and the context2d plugin,
|
||||
see the examples in the /examples/canvg_context2d directory.
|
||||
3155
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/canvg.js
generated
vendored
Normal file
3155
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/canvg.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
655
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/libs/StackBlur.js
generated
vendored
Normal file
655
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/libs/StackBlur.js
generated
vendored
Normal file
@ -0,0 +1,655 @@
|
||||
/*
|
||||
|
||||
StackBlur - a fast almost Gaussian Blur For Canvas
|
||||
|
||||
Version: 0.5
|
||||
Author: Mario Klingemann
|
||||
Contact: mario@quasimondo.com
|
||||
Website: http://www.quasimondo.com/StackBlurForCanvas
|
||||
Twitter: @quasimondo
|
||||
|
||||
In case you find this class useful - especially in commercial projects -
|
||||
I am not totally unhappy for a small donation to my PayPal account
|
||||
mario@quasimondo.de
|
||||
|
||||
Or support me on flattr:
|
||||
https://flattr.com/thing/72791/StackBlur-a-fast-almost-Gaussian-Blur-Effect-for-CanvasJavascript
|
||||
|
||||
Copyright (c) 2010 Mario Klingemann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
(function ( global ) {
|
||||
|
||||
var mul_table = [
|
||||
512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,
|
||||
454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,
|
||||
482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,
|
||||
437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,
|
||||
497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,
|
||||
320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,
|
||||
446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,
|
||||
329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,
|
||||
505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,
|
||||
399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,
|
||||
324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,
|
||||
268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,
|
||||
451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
|
||||
385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
|
||||
332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
|
||||
289,287,285,282,280,278,275,273,271,269,267,265,263,261,259];
|
||||
|
||||
|
||||
var shg_table = [
|
||||
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
|
||||
19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
|
||||
20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
|
||||
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
|
||||
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
|
||||
23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
|
||||
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 ];
|
||||
|
||||
function premultiplyAlpha(imageData)
|
||||
{
|
||||
var pixels = imageData.data;
|
||||
var size = imageData.width * imageData.height * 4;
|
||||
|
||||
for (var i=0; i<size; i+=4)
|
||||
{
|
||||
var a = pixels[i+3] / 255;
|
||||
pixels[i ] *= a;
|
||||
pixels[i+1] *= a;
|
||||
pixels[i+2] *= a;
|
||||
}
|
||||
}
|
||||
|
||||
function unpremultiplyAlpha(imageData)
|
||||
{
|
||||
var pixels = imageData.data;
|
||||
var size = imageData.width * imageData.height * 4;
|
||||
|
||||
for (var i=0; i<size; i+=4)
|
||||
{
|
||||
var a = pixels[i+3];
|
||||
if (a != 0)
|
||||
{
|
||||
a = 255 / a;
|
||||
pixels[i ] *= a;
|
||||
pixels[i+1] *= a;
|
||||
pixels[i+2] *= a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function stackBlurImage( imageID, canvasID, radius, blurAlphaChannel )
|
||||
{
|
||||
|
||||
var img = document.getElementById( imageID );
|
||||
var w = img.naturalWidth;
|
||||
var h = img.naturalHeight;
|
||||
|
||||
var canvas = document.getElementById( canvasID );
|
||||
|
||||
canvas.style.width = w + "px";
|
||||
canvas.style.height = h + "px";
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
|
||||
var context = canvas.getContext("2d");
|
||||
context.clearRect( 0, 0, w, h );
|
||||
context.drawImage( img, 0, 0 );
|
||||
|
||||
if ( isNaN(radius) || radius < 1 ) return;
|
||||
|
||||
if ( blurAlphaChannel )
|
||||
stackBlurCanvasRGBA( canvasID, 0, 0, w, h, radius );
|
||||
else
|
||||
stackBlurCanvasRGB( canvasID, 0, 0, w, h, radius );
|
||||
}
|
||||
|
||||
|
||||
function stackBlurCanvasRGBA( id, top_x, top_y, width, height, radius )
|
||||
{
|
||||
if ( isNaN(radius) || radius < 1 ) return;
|
||||
radius |= 0;
|
||||
|
||||
var canvas = document.getElementById( id );
|
||||
var context = canvas.getContext("2d");
|
||||
var imageData;
|
||||
|
||||
try {
|
||||
try {
|
||||
imageData = context.getImageData( top_x, top_y, width, height );
|
||||
} catch(e) {
|
||||
|
||||
// NOTE: this part is supposedly only needed if you want to work with local files
|
||||
// so it might be okay to remove the whole try/catch block and just use
|
||||
// imageData = context.getImageData( top_x, top_y, width, height );
|
||||
try {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
imageData = context.getImageData( top_x, top_y, width, height );
|
||||
} catch(e) {
|
||||
alert("Cannot access local image");
|
||||
throw new Error("unable to access local image data: " + e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
alert("Cannot access image");
|
||||
throw new Error("unable to access image data: " + e);
|
||||
}
|
||||
|
||||
premultiplyAlpha(imageData);
|
||||
|
||||
var pixels = imageData.data;
|
||||
|
||||
var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum,
|
||||
r_out_sum, g_out_sum, b_out_sum, a_out_sum,
|
||||
r_in_sum, g_in_sum, b_in_sum, a_in_sum,
|
||||
pr, pg, pb, pa, rbs;
|
||||
|
||||
var div = radius + radius + 1;
|
||||
var w4 = width << 2;
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * ( radiusPlus1 + 1 ) / 2;
|
||||
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
for ( i = 1; i < div; i++ )
|
||||
{
|
||||
stack = stack.next = new BlurStack();
|
||||
if ( i == radiusPlus1 ) var stackEnd = stack;
|
||||
}
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
|
||||
yw = yi = 0;
|
||||
|
||||
var mul_sum = mul_table[radius];
|
||||
var shg_sum = shg_table[radius];
|
||||
|
||||
for ( y = 0; y < height; y++ )
|
||||
{
|
||||
r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
|
||||
|
||||
r_out_sum = radiusPlus1 * ( pr = pixels[yi] );
|
||||
g_out_sum = radiusPlus1 * ( pg = pixels[yi+1] );
|
||||
b_out_sum = radiusPlus1 * ( pb = pixels[yi+2] );
|
||||
a_out_sum = radiusPlus1 * ( pa = pixels[yi+3] );
|
||||
|
||||
r_sum += sumFactor * pr;
|
||||
g_sum += sumFactor * pg;
|
||||
b_sum += sumFactor * pb;
|
||||
a_sum += sumFactor * pa;
|
||||
|
||||
stack = stackStart;
|
||||
|
||||
for( i = 0; i < radiusPlus1; i++ )
|
||||
{
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for( i = 1; i < radiusPlus1; i++ )
|
||||
{
|
||||
p = yi + (( widthMinus1 < i ? widthMinus1 : i ) << 2 );
|
||||
r_sum += ( stack.r = ( pr = pixels[p])) * ( rbs = radiusPlus1 - i );
|
||||
g_sum += ( stack.g = ( pg = pixels[p+1])) * rbs;
|
||||
b_sum += ( stack.b = ( pb = pixels[p+2])) * rbs;
|
||||
a_sum += ( stack.a = ( pa = pixels[p+3])) * rbs;
|
||||
|
||||
r_in_sum += pr;
|
||||
g_in_sum += pg;
|
||||
b_in_sum += pb;
|
||||
a_in_sum += pa;
|
||||
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
pixels[yi] = (r_sum * mul_sum) >> shg_sum;
|
||||
pixels[yi+1] = (g_sum * mul_sum) >> shg_sum;
|
||||
pixels[yi+2] = (b_sum * mul_sum) >> shg_sum;
|
||||
pixels[yi+3] = (a_sum * mul_sum) >> shg_sum;
|
||||
|
||||
r_sum -= r_out_sum;
|
||||
g_sum -= g_out_sum;
|
||||
b_sum -= b_out_sum;
|
||||
a_sum -= a_out_sum;
|
||||
|
||||
r_out_sum -= stackIn.r;
|
||||
g_out_sum -= stackIn.g;
|
||||
b_out_sum -= stackIn.b;
|
||||
a_out_sum -= stackIn.a;
|
||||
|
||||
p = ( yw + ( ( p = x + radius + 1 ) < widthMinus1 ? p : widthMinus1 ) ) << 2;
|
||||
|
||||
r_in_sum += ( stackIn.r = pixels[p]);
|
||||
g_in_sum += ( stackIn.g = pixels[p+1]);
|
||||
b_in_sum += ( stackIn.b = pixels[p+2]);
|
||||
a_in_sum += ( stackIn.a = pixels[p+3]);
|
||||
|
||||
r_sum += r_in_sum;
|
||||
g_sum += g_in_sum;
|
||||
b_sum += b_in_sum;
|
||||
a_sum += a_in_sum;
|
||||
|
||||
stackIn = stackIn.next;
|
||||
|
||||
r_out_sum += ( pr = stackOut.r );
|
||||
g_out_sum += ( pg = stackOut.g );
|
||||
b_out_sum += ( pb = stackOut.b );
|
||||
a_out_sum += ( pa = stackOut.a );
|
||||
|
||||
r_in_sum -= pr;
|
||||
g_in_sum -= pg;
|
||||
b_in_sum -= pb;
|
||||
a_in_sum -= pa;
|
||||
|
||||
stackOut = stackOut.next;
|
||||
|
||||
yi += 4;
|
||||
}
|
||||
yw += width;
|
||||
}
|
||||
|
||||
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
|
||||
|
||||
yi = x << 2;
|
||||
r_out_sum = radiusPlus1 * ( pr = pixels[yi]);
|
||||
g_out_sum = radiusPlus1 * ( pg = pixels[yi+1]);
|
||||
b_out_sum = radiusPlus1 * ( pb = pixels[yi+2]);
|
||||
a_out_sum = radiusPlus1 * ( pa = pixels[yi+3]);
|
||||
|
||||
r_sum += sumFactor * pr;
|
||||
g_sum += sumFactor * pg;
|
||||
b_sum += sumFactor * pb;
|
||||
a_sum += sumFactor * pa;
|
||||
|
||||
stack = stackStart;
|
||||
|
||||
for( i = 0; i < radiusPlus1; i++ )
|
||||
{
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack.a = pa;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for( i = 1; i <= radius; i++ )
|
||||
{
|
||||
yi = ( yp + x ) << 2;
|
||||
|
||||
r_sum += ( stack.r = ( pr = pixels[yi])) * ( rbs = radiusPlus1 - i );
|
||||
g_sum += ( stack.g = ( pg = pixels[yi+1])) * rbs;
|
||||
b_sum += ( stack.b = ( pb = pixels[yi+2])) * rbs;
|
||||
a_sum += ( stack.a = ( pa = pixels[yi+3])) * rbs;
|
||||
|
||||
r_in_sum += pr;
|
||||
g_in_sum += pg;
|
||||
b_in_sum += pb;
|
||||
a_in_sum += pa;
|
||||
|
||||
stack = stack.next;
|
||||
|
||||
if( i < heightMinus1 )
|
||||
{
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
for ( y = 0; y < height; y++ )
|
||||
{
|
||||
p = yi << 2;
|
||||
pixels[p] = (r_sum * mul_sum) >> shg_sum;
|
||||
pixels[p+1] = (g_sum * mul_sum) >> shg_sum;
|
||||
pixels[p+2] = (b_sum * mul_sum) >> shg_sum;
|
||||
pixels[p+3] = (a_sum * mul_sum) >> shg_sum;
|
||||
|
||||
r_sum -= r_out_sum;
|
||||
g_sum -= g_out_sum;
|
||||
b_sum -= b_out_sum;
|
||||
a_sum -= a_out_sum;
|
||||
|
||||
r_out_sum -= stackIn.r;
|
||||
g_out_sum -= stackIn.g;
|
||||
b_out_sum -= stackIn.b;
|
||||
a_out_sum -= stackIn.a;
|
||||
|
||||
p = ( x + (( ( p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1 ) * width )) << 2;
|
||||
|
||||
r_sum += ( r_in_sum += ( stackIn.r = pixels[p]));
|
||||
g_sum += ( g_in_sum += ( stackIn.g = pixels[p+1]));
|
||||
b_sum += ( b_in_sum += ( stackIn.b = pixels[p+2]));
|
||||
a_sum += ( a_in_sum += ( stackIn.a = pixels[p+3]));
|
||||
|
||||
stackIn = stackIn.next;
|
||||
|
||||
r_out_sum += ( pr = stackOut.r );
|
||||
g_out_sum += ( pg = stackOut.g );
|
||||
b_out_sum += ( pb = stackOut.b );
|
||||
a_out_sum += ( pa = stackOut.a );
|
||||
|
||||
r_in_sum -= pr;
|
||||
g_in_sum -= pg;
|
||||
b_in_sum -= pb;
|
||||
a_in_sum -= pa;
|
||||
|
||||
stackOut = stackOut.next;
|
||||
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
unpremultiplyAlpha(imageData);
|
||||
|
||||
context.putImageData( imageData, top_x, top_y );
|
||||
}
|
||||
|
||||
|
||||
function stackBlurCanvasRGB( id, top_x, top_y, width, height, radius )
|
||||
{
|
||||
if ( isNaN(radius) || radius < 1 ) return;
|
||||
radius |= 0;
|
||||
|
||||
var canvas = document.getElementById( id );
|
||||
var context = canvas.getContext("2d");
|
||||
var imageData;
|
||||
|
||||
try {
|
||||
try {
|
||||
imageData = context.getImageData( top_x, top_y, width, height );
|
||||
} catch(e) {
|
||||
|
||||
// NOTE: this part is supposedly only needed if you want to work with local files
|
||||
// so it might be okay to remove the whole try/catch block and just use
|
||||
// imageData = context.getImageData( top_x, top_y, width, height );
|
||||
try {
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
|
||||
imageData = context.getImageData( top_x, top_y, width, height );
|
||||
} catch(e) {
|
||||
alert("Cannot access local image");
|
||||
throw new Error("unable to access local image data: " + e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
alert("Cannot access image");
|
||||
throw new Error("unable to access image data: " + e);
|
||||
}
|
||||
|
||||
var pixels = imageData.data;
|
||||
|
||||
var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum,
|
||||
r_out_sum, g_out_sum, b_out_sum,
|
||||
r_in_sum, g_in_sum, b_in_sum,
|
||||
pr, pg, pb, rbs;
|
||||
|
||||
var div = radius + radius + 1;
|
||||
var w4 = width << 2;
|
||||
var widthMinus1 = width - 1;
|
||||
var heightMinus1 = height - 1;
|
||||
var radiusPlus1 = radius + 1;
|
||||
var sumFactor = radiusPlus1 * ( radiusPlus1 + 1 ) / 2;
|
||||
|
||||
var stackStart = new BlurStack();
|
||||
var stack = stackStart;
|
||||
for ( i = 1; i < div; i++ )
|
||||
{
|
||||
stack = stack.next = new BlurStack();
|
||||
if ( i == radiusPlus1 ) var stackEnd = stack;
|
||||
}
|
||||
stack.next = stackStart;
|
||||
var stackIn = null;
|
||||
var stackOut = null;
|
||||
|
||||
yw = yi = 0;
|
||||
|
||||
var mul_sum = mul_table[radius];
|
||||
var shg_sum = shg_table[radius];
|
||||
|
||||
for ( y = 0; y < height; y++ )
|
||||
{
|
||||
r_in_sum = g_in_sum = b_in_sum = r_sum = g_sum = b_sum = 0;
|
||||
|
||||
r_out_sum = radiusPlus1 * ( pr = pixels[yi] );
|
||||
g_out_sum = radiusPlus1 * ( pg = pixels[yi+1] );
|
||||
b_out_sum = radiusPlus1 * ( pb = pixels[yi+2] );
|
||||
|
||||
r_sum += sumFactor * pr;
|
||||
g_sum += sumFactor * pg;
|
||||
b_sum += sumFactor * pb;
|
||||
|
||||
stack = stackStart;
|
||||
|
||||
for( i = 0; i < radiusPlus1; i++ )
|
||||
{
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
for( i = 1; i < radiusPlus1; i++ )
|
||||
{
|
||||
p = yi + (( widthMinus1 < i ? widthMinus1 : i ) << 2 );
|
||||
r_sum += ( stack.r = ( pr = pixels[p])) * ( rbs = radiusPlus1 - i );
|
||||
g_sum += ( stack.g = ( pg = pixels[p+1])) * rbs;
|
||||
b_sum += ( stack.b = ( pb = pixels[p+2])) * rbs;
|
||||
|
||||
r_in_sum += pr;
|
||||
g_in_sum += pg;
|
||||
b_in_sum += pb;
|
||||
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
pixels[yi] = (r_sum * mul_sum) >> shg_sum;
|
||||
pixels[yi+1] = (g_sum * mul_sum) >> shg_sum;
|
||||
pixels[yi+2] = (b_sum * mul_sum) >> shg_sum;
|
||||
|
||||
r_sum -= r_out_sum;
|
||||
g_sum -= g_out_sum;
|
||||
b_sum -= b_out_sum;
|
||||
|
||||
r_out_sum -= stackIn.r;
|
||||
g_out_sum -= stackIn.g;
|
||||
b_out_sum -= stackIn.b;
|
||||
|
||||
p = ( yw + ( ( p = x + radius + 1 ) < widthMinus1 ? p : widthMinus1 ) ) << 2;
|
||||
|
||||
r_in_sum += ( stackIn.r = pixels[p]);
|
||||
g_in_sum += ( stackIn.g = pixels[p+1]);
|
||||
b_in_sum += ( stackIn.b = pixels[p+2]);
|
||||
|
||||
r_sum += r_in_sum;
|
||||
g_sum += g_in_sum;
|
||||
b_sum += b_in_sum;
|
||||
|
||||
stackIn = stackIn.next;
|
||||
|
||||
r_out_sum += ( pr = stackOut.r );
|
||||
g_out_sum += ( pg = stackOut.g );
|
||||
b_out_sum += ( pb = stackOut.b );
|
||||
|
||||
r_in_sum -= pr;
|
||||
g_in_sum -= pg;
|
||||
b_in_sum -= pb;
|
||||
|
||||
stackOut = stackOut.next;
|
||||
|
||||
yi += 4;
|
||||
}
|
||||
yw += width;
|
||||
}
|
||||
|
||||
|
||||
for ( x = 0; x < width; x++ )
|
||||
{
|
||||
g_in_sum = b_in_sum = r_in_sum = g_sum = b_sum = r_sum = 0;
|
||||
|
||||
yi = x << 2;
|
||||
r_out_sum = radiusPlus1 * ( pr = pixels[yi]);
|
||||
g_out_sum = radiusPlus1 * ( pg = pixels[yi+1]);
|
||||
b_out_sum = radiusPlus1 * ( pb = pixels[yi+2]);
|
||||
|
||||
r_sum += sumFactor * pr;
|
||||
g_sum += sumFactor * pg;
|
||||
b_sum += sumFactor * pb;
|
||||
|
||||
stack = stackStart;
|
||||
|
||||
for( i = 0; i < radiusPlus1; i++ )
|
||||
{
|
||||
stack.r = pr;
|
||||
stack.g = pg;
|
||||
stack.b = pb;
|
||||
stack = stack.next;
|
||||
}
|
||||
|
||||
yp = width;
|
||||
|
||||
for( i = 1; i <= radius; i++ )
|
||||
{
|
||||
yi = ( yp + x ) << 2;
|
||||
|
||||
r_sum += ( stack.r = ( pr = pixels[yi])) * ( rbs = radiusPlus1 - i );
|
||||
g_sum += ( stack.g = ( pg = pixels[yi+1])) * rbs;
|
||||
b_sum += ( stack.b = ( pb = pixels[yi+2])) * rbs;
|
||||
|
||||
r_in_sum += pr;
|
||||
g_in_sum += pg;
|
||||
b_in_sum += pb;
|
||||
|
||||
stack = stack.next;
|
||||
|
||||
if( i < heightMinus1 )
|
||||
{
|
||||
yp += width;
|
||||
}
|
||||
}
|
||||
|
||||
yi = x;
|
||||
stackIn = stackStart;
|
||||
stackOut = stackEnd;
|
||||
for ( y = 0; y < height; y++ )
|
||||
{
|
||||
p = yi << 2;
|
||||
pixels[p] = (r_sum * mul_sum) >> shg_sum;
|
||||
pixels[p+1] = (g_sum * mul_sum) >> shg_sum;
|
||||
pixels[p+2] = (b_sum * mul_sum) >> shg_sum;
|
||||
|
||||
r_sum -= r_out_sum;
|
||||
g_sum -= g_out_sum;
|
||||
b_sum -= b_out_sum;
|
||||
|
||||
r_out_sum -= stackIn.r;
|
||||
g_out_sum -= stackIn.g;
|
||||
b_out_sum -= stackIn.b;
|
||||
|
||||
p = ( x + (( ( p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1 ) * width )) << 2;
|
||||
|
||||
r_sum += ( r_in_sum += ( stackIn.r = pixels[p]));
|
||||
g_sum += ( g_in_sum += ( stackIn.g = pixels[p+1]));
|
||||
b_sum += ( b_in_sum += ( stackIn.b = pixels[p+2]));
|
||||
|
||||
stackIn = stackIn.next;
|
||||
|
||||
r_out_sum += ( pr = stackOut.r );
|
||||
g_out_sum += ( pg = stackOut.g );
|
||||
b_out_sum += ( pb = stackOut.b );
|
||||
|
||||
r_in_sum -= pr;
|
||||
g_in_sum -= pg;
|
||||
b_in_sum -= pb;
|
||||
|
||||
stackOut = stackOut.next;
|
||||
|
||||
yi += width;
|
||||
}
|
||||
}
|
||||
|
||||
context.putImageData( imageData, top_x, top_y );
|
||||
|
||||
}
|
||||
|
||||
function BlurStack()
|
||||
{
|
||||
this.r = 0;
|
||||
this.g = 0;
|
||||
this.b = 0;
|
||||
this.a = 0;
|
||||
this.next = null;
|
||||
}
|
||||
|
||||
var stackBlur = {
|
||||
image: stackBlurImage,
|
||||
canvasRGBA: stackBlurCanvasRGBA,
|
||||
canvasRGB: stackBlurCanvasRGB
|
||||
};
|
||||
|
||||
// export as AMD...
|
||||
if ( typeof define !== 'undefined' && define.amd ) {
|
||||
define( function () { return stackBlur; });
|
||||
}
|
||||
|
||||
// ...or as browserify
|
||||
else if ( typeof module !== 'undefined' && module.exports ) {
|
||||
module.exports = stackBlur;
|
||||
}
|
||||
|
||||
global.stackBlur = stackBlur;
|
||||
|
||||
}( typeof window !== 'undefined' ? window : this ));
|
||||
304
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/libs/rgbcolor.js
generated
vendored
Normal file
304
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/canvg_context2d/libs/rgbcolor.js
generated
vendored
Normal file
@ -0,0 +1,304 @@
|
||||
/**
|
||||
* A class to parse color values
|
||||
* @author Stoyan Stefanov <sstoo@gmail.com>
|
||||
* @link http://www.phpied.com/rgb-color-parser-in-javascript/
|
||||
* @license Use it if you like it
|
||||
*/
|
||||
|
||||
(function ( global ) {
|
||||
|
||||
function RGBColor(color_string)
|
||||
{
|
||||
this.ok = false;
|
||||
|
||||
// strip any leading #
|
||||
if (color_string.charAt(0) == '#') { // remove # if any
|
||||
color_string = color_string.substr(1,6);
|
||||
}
|
||||
|
||||
color_string = color_string.replace(/ /g,'');
|
||||
color_string = color_string.toLowerCase();
|
||||
|
||||
// before getting into regexps, try simple matches
|
||||
// and overwrite the input
|
||||
var simple_colors = {
|
||||
aliceblue: 'f0f8ff',
|
||||
antiquewhite: 'faebd7',
|
||||
aqua: '00ffff',
|
||||
aquamarine: '7fffd4',
|
||||
azure: 'f0ffff',
|
||||
beige: 'f5f5dc',
|
||||
bisque: 'ffe4c4',
|
||||
black: '000000',
|
||||
blanchedalmond: 'ffebcd',
|
||||
blue: '0000ff',
|
||||
blueviolet: '8a2be2',
|
||||
brown: 'a52a2a',
|
||||
burlywood: 'deb887',
|
||||
cadetblue: '5f9ea0',
|
||||
chartreuse: '7fff00',
|
||||
chocolate: 'd2691e',
|
||||
coral: 'ff7f50',
|
||||
cornflowerblue: '6495ed',
|
||||
cornsilk: 'fff8dc',
|
||||
crimson: 'dc143c',
|
||||
cyan: '00ffff',
|
||||
darkblue: '00008b',
|
||||
darkcyan: '008b8b',
|
||||
darkgoldenrod: 'b8860b',
|
||||
darkgray: 'a9a9a9',
|
||||
darkgreen: '006400',
|
||||
darkkhaki: 'bdb76b',
|
||||
darkmagenta: '8b008b',
|
||||
darkolivegreen: '556b2f',
|
||||
darkorange: 'ff8c00',
|
||||
darkorchid: '9932cc',
|
||||
darkred: '8b0000',
|
||||
darksalmon: 'e9967a',
|
||||
darkseagreen: '8fbc8f',
|
||||
darkslateblue: '483d8b',
|
||||
darkslategray: '2f4f4f',
|
||||
darkturquoise: '00ced1',
|
||||
darkviolet: '9400d3',
|
||||
deeppink: 'ff1493',
|
||||
deepskyblue: '00bfff',
|
||||
dimgray: '696969',
|
||||
dodgerblue: '1e90ff',
|
||||
feldspar: 'd19275',
|
||||
firebrick: 'b22222',
|
||||
floralwhite: 'fffaf0',
|
||||
forestgreen: '228b22',
|
||||
fuchsia: 'ff00ff',
|
||||
gainsboro: 'dcdcdc',
|
||||
ghostwhite: 'f8f8ff',
|
||||
gold: 'ffd700',
|
||||
goldenrod: 'daa520',
|
||||
gray: '808080',
|
||||
green: '008000',
|
||||
greenyellow: 'adff2f',
|
||||
honeydew: 'f0fff0',
|
||||
hotpink: 'ff69b4',
|
||||
indianred : 'cd5c5c',
|
||||
indigo : '4b0082',
|
||||
ivory: 'fffff0',
|
||||
khaki: 'f0e68c',
|
||||
lavender: 'e6e6fa',
|
||||
lavenderblush: 'fff0f5',
|
||||
lawngreen: '7cfc00',
|
||||
lemonchiffon: 'fffacd',
|
||||
lightblue: 'add8e6',
|
||||
lightcoral: 'f08080',
|
||||
lightcyan: 'e0ffff',
|
||||
lightgoldenrodyellow: 'fafad2',
|
||||
lightgrey: 'd3d3d3',
|
||||
lightgreen: '90ee90',
|
||||
lightpink: 'ffb6c1',
|
||||
lightsalmon: 'ffa07a',
|
||||
lightseagreen: '20b2aa',
|
||||
lightskyblue: '87cefa',
|
||||
lightslateblue: '8470ff',
|
||||
lightslategray: '778899',
|
||||
lightsteelblue: 'b0c4de',
|
||||
lightyellow: 'ffffe0',
|
||||
lime: '00ff00',
|
||||
limegreen: '32cd32',
|
||||
linen: 'faf0e6',
|
||||
magenta: 'ff00ff',
|
||||
maroon: '800000',
|
||||
mediumaquamarine: '66cdaa',
|
||||
mediumblue: '0000cd',
|
||||
mediumorchid: 'ba55d3',
|
||||
mediumpurple: '9370d8',
|
||||
mediumseagreen: '3cb371',
|
||||
mediumslateblue: '7b68ee',
|
||||
mediumspringgreen: '00fa9a',
|
||||
mediumturquoise: '48d1cc',
|
||||
mediumvioletred: 'c71585',
|
||||
midnightblue: '191970',
|
||||
mintcream: 'f5fffa',
|
||||
mistyrose: 'ffe4e1',
|
||||
moccasin: 'ffe4b5',
|
||||
navajowhite: 'ffdead',
|
||||
navy: '000080',
|
||||
oldlace: 'fdf5e6',
|
||||
olive: '808000',
|
||||
olivedrab: '6b8e23',
|
||||
orange: 'ffa500',
|
||||
orangered: 'ff4500',
|
||||
orchid: 'da70d6',
|
||||
palegoldenrod: 'eee8aa',
|
||||
palegreen: '98fb98',
|
||||
paleturquoise: 'afeeee',
|
||||
palevioletred: 'd87093',
|
||||
papayawhip: 'ffefd5',
|
||||
peachpuff: 'ffdab9',
|
||||
peru: 'cd853f',
|
||||
pink: 'ffc0cb',
|
||||
plum: 'dda0dd',
|
||||
powderblue: 'b0e0e6',
|
||||
purple: '800080',
|
||||
red: 'ff0000',
|
||||
rosybrown: 'bc8f8f',
|
||||
royalblue: '4169e1',
|
||||
saddlebrown: '8b4513',
|
||||
salmon: 'fa8072',
|
||||
sandybrown: 'f4a460',
|
||||
seagreen: '2e8b57',
|
||||
seashell: 'fff5ee',
|
||||
sienna: 'a0522d',
|
||||
silver: 'c0c0c0',
|
||||
skyblue: '87ceeb',
|
||||
slateblue: '6a5acd',
|
||||
slategray: '708090',
|
||||
snow: 'fffafa',
|
||||
springgreen: '00ff7f',
|
||||
steelblue: '4682b4',
|
||||
tan: 'd2b48c',
|
||||
teal: '008080',
|
||||
thistle: 'd8bfd8',
|
||||
tomato: 'ff6347',
|
||||
turquoise: '40e0d0',
|
||||
violet: 'ee82ee',
|
||||
violetred: 'd02090',
|
||||
wheat: 'f5deb3',
|
||||
white: 'ffffff',
|
||||
whitesmoke: 'f5f5f5',
|
||||
yellow: 'ffff00',
|
||||
yellowgreen: '9acd32'
|
||||
};
|
||||
for (var key in simple_colors) {
|
||||
if (color_string == key) {
|
||||
color_string = simple_colors[key];
|
||||
}
|
||||
}
|
||||
// emd of simple type-in colors
|
||||
|
||||
// array of color definition objects
|
||||
var color_defs = [
|
||||
{
|
||||
re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,
|
||||
example: ['rgb(123, 234, 45)', 'rgb(255,234,245)'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1]),
|
||||
parseInt(bits[2]),
|
||||
parseInt(bits[3])
|
||||
];
|
||||
}
|
||||
},
|
||||
{
|
||||
re: /^(\w{2})(\w{2})(\w{2})$/,
|
||||
example: ['#00ff00', '336699'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1], 16),
|
||||
parseInt(bits[2], 16),
|
||||
parseInt(bits[3], 16)
|
||||
];
|
||||
}
|
||||
},
|
||||
{
|
||||
re: /^(\w{1})(\w{1})(\w{1})$/,
|
||||
example: ['#fb0', 'f0f'],
|
||||
process: function (bits){
|
||||
return [
|
||||
parseInt(bits[1] + bits[1], 16),
|
||||
parseInt(bits[2] + bits[2], 16),
|
||||
parseInt(bits[3] + bits[3], 16)
|
||||
];
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
// search through the definitions to find a match
|
||||
for (var i = 0; i < color_defs.length; i++) {
|
||||
var re = color_defs[i].re;
|
||||
var processor = color_defs[i].process;
|
||||
var bits = re.exec(color_string);
|
||||
if (bits) {
|
||||
channels = processor(bits);
|
||||
this.r = channels[0];
|
||||
this.g = channels[1];
|
||||
this.b = channels[2];
|
||||
this.ok = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// validate/cleanup values
|
||||
this.r = (this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);
|
||||
this.g = (this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);
|
||||
this.b = (this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);
|
||||
|
||||
// some getters
|
||||
this.toRGB = function () {
|
||||
return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';
|
||||
}
|
||||
this.toHex = function () {
|
||||
var r = this.r.toString(16);
|
||||
var g = this.g.toString(16);
|
||||
var b = this.b.toString(16);
|
||||
if (r.length == 1) r = '0' + r;
|
||||
if (g.length == 1) g = '0' + g;
|
||||
if (b.length == 1) b = '0' + b;
|
||||
return '#' + r + g + b;
|
||||
}
|
||||
|
||||
// help
|
||||
this.getHelpXML = function () {
|
||||
|
||||
var examples = new Array();
|
||||
// add regexps
|
||||
for (var i = 0; i < color_defs.length; i++) {
|
||||
var example = color_defs[i].example;
|
||||
for (var j = 0; j < example.length; j++) {
|
||||
examples[examples.length] = example[j];
|
||||
}
|
||||
}
|
||||
// add type-in colors
|
||||
for (var sc in simple_colors) {
|
||||
examples[examples.length] = sc;
|
||||
}
|
||||
|
||||
var xml = document.createElement('ul');
|
||||
xml.setAttribute('id', 'rgbcolor-examples');
|
||||
for (var i = 0; i < examples.length; i++) {
|
||||
try {
|
||||
var list_item = document.createElement('li');
|
||||
var list_color = new RGBColor(examples[i]);
|
||||
var example_div = document.createElement('div');
|
||||
example_div.style.cssText =
|
||||
'margin: 3px; '
|
||||
+ 'border: 1px solid black; '
|
||||
+ 'background:' + list_color.toHex() + '; '
|
||||
+ 'color:' + list_color.toHex()
|
||||
;
|
||||
example_div.appendChild(document.createTextNode('test'));
|
||||
var list_item_value = document.createTextNode(
|
||||
' ' + examples[i] + ' -> ' + list_color.toRGB() + ' -> ' + list_color.toHex()
|
||||
);
|
||||
list_item.appendChild(example_div);
|
||||
list_item.appendChild(list_item_value);
|
||||
xml.appendChild(list_item);
|
||||
|
||||
} catch(e){}
|
||||
}
|
||||
return xml;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// export as AMD...
|
||||
if ( typeof define !== 'undefined' && define.amd ) {
|
||||
define( function () { return RGBColor; });
|
||||
}
|
||||
|
||||
// ...or as browserify
|
||||
else if ( typeof module !== 'undefined' && module.exports ) {
|
||||
module.exports = RGBColor;
|
||||
}
|
||||
|
||||
global.RGBColor = RGBColor;
|
||||
|
||||
}( typeof window !== 'undefined' ? window : this ));
|
||||
164
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/css_colors.js
generated
vendored
Normal file
164
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/css_colors.js
generated
vendored
Normal file
@ -0,0 +1,164 @@
|
||||
/**
|
||||
* CssColors
|
||||
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
|
||||
*
|
||||
* Licensed under the MIT License.
|
||||
* http://opensource.org/licenses/mit-license
|
||||
*/
|
||||
|
||||
/**
|
||||
* Usage CssColors('red');
|
||||
* Returns RGB hex color with '#' prefix
|
||||
*/
|
||||
|
||||
var CssColors = {};
|
||||
CssColors._colorsTable = {
|
||||
"aliceblue" : "#f0f8ff",
|
||||
"antiquewhite" : "#faebd7",
|
||||
"aqua" : "#00ffff",
|
||||
"aquamarine" : "#7fffd4",
|
||||
"azure" : "#f0ffff",
|
||||
"beige" : "#f5f5dc",
|
||||
"bisque" : "#ffe4c4",
|
||||
"black" : "#000000",
|
||||
"blanchedalmond" : "#ffebcd",
|
||||
"blue" : "#0000ff",
|
||||
"blueviolet" : "#8a2be2",
|
||||
"brown" : "#a52a2a",
|
||||
"burlywood" : "#deb887",
|
||||
"cadetblue" : "#5f9ea0",
|
||||
"chartreuse" : "#7fff00",
|
||||
"chocolate" : "#d2691e",
|
||||
"coral" : "#ff7f50",
|
||||
"cornflowerblue" : "#6495ed",
|
||||
"cornsilk" : "#fff8dc",
|
||||
"crimson" : "#dc143c",
|
||||
"cyan" : "#00ffff",
|
||||
"darkblue" : "#00008b",
|
||||
"darkcyan" : "#008b8b",
|
||||
"darkgoldenrod" : "#b8860b",
|
||||
"darkgray" : "#a9a9a9",
|
||||
"darkgreen" : "#006400",
|
||||
"darkkhaki" : "#bdb76b",
|
||||
"darkmagenta" : "#8b008b",
|
||||
"darkolivegreen" : "#556b2f",
|
||||
"darkorange" : "#ff8c00",
|
||||
"darkorchid" : "#9932cc",
|
||||
"darkred" : "#8b0000",
|
||||
"darksalmon" : "#e9967a",
|
||||
"darkseagreen" : "#8fbc8f",
|
||||
"darkslateblue" : "#483d8b",
|
||||
"darkslategray" : "#2f4f4f",
|
||||
"darkturquoise" : "#00ced1",
|
||||
"darkviolet" : "#9400d3",
|
||||
"deeppink" : "#ff1493",
|
||||
"deepskyblue" : "#00bfff",
|
||||
"dimgray" : "#696969",
|
||||
"dodgerblue" : "#1e90ff",
|
||||
"firebrick" : "#b22222",
|
||||
"floralwhite" : "#fffaf0",
|
||||
"forestgreen" : "#228b22",
|
||||
"fuchsia" : "#ff00ff",
|
||||
"gainsboro" : "#dcdcdc",
|
||||
"ghostwhite" : "#f8f8ff",
|
||||
"gold" : "#ffd700",
|
||||
"goldenrod" : "#daa520",
|
||||
"gray" : "#808080",
|
||||
"green" : "#008000",
|
||||
"greenyellow" : "#adff2f",
|
||||
"honeydew" : "#f0fff0",
|
||||
"hotpink" : "#ff69b4",
|
||||
"indianred " : "#cd5c5c",
|
||||
"indigo" : "#4b0082",
|
||||
"ivory" : "#fffff0",
|
||||
"khaki" : "#f0e68c",
|
||||
"lavender" : "#e6e6fa",
|
||||
"lavenderblush" : "#fff0f5",
|
||||
"lawngreen" : "#7cfc00",
|
||||
"lemonchiffon" : "#fffacd",
|
||||
"lightblue" : "#add8e6",
|
||||
"lightcoral" : "#f08080",
|
||||
"lightcyan" : "#e0ffff",
|
||||
"lightgoldenrodyellow" : "#fafad2",
|
||||
"lightgrey" : "#d3d3d3",
|
||||
"lightgreen" : "#90ee90",
|
||||
"lightpink" : "#ffb6c1",
|
||||
"lightsalmon" : "#ffa07a",
|
||||
"lightseagreen" : "#20b2aa",
|
||||
"lightskyblue" : "#87cefa",
|
||||
"lightslategray" : "#778899",
|
||||
"lightsteelblue" : "#b0c4de",
|
||||
"lightyellow" : "#ffffe0",
|
||||
"lime" : "#00ff00",
|
||||
"limegreen" : "#32cd32",
|
||||
"linen" : "#faf0e6",
|
||||
"magenta" : "#ff00ff",
|
||||
"maroon" : "#800000",
|
||||
"mediumaquamarine" : "#66cdaa",
|
||||
"mediumblue" : "#0000cd",
|
||||
"mediumorchid" : "#ba55d3",
|
||||
"mediumpurple" : "#9370d8",
|
||||
"mediumseagreen" : "#3cb371",
|
||||
"mediumslateblue" : "#7b68ee",
|
||||
"mediumspringgreen" : "#00fa9a",
|
||||
"mediumturquoise" : "#48d1cc",
|
||||
"mediumvioletred" : "#c71585",
|
||||
"midnightblue" : "#191970",
|
||||
"mintcream" : "#f5fffa",
|
||||
"mistyrose" : "#ffe4e1",
|
||||
"moccasin" : "#ffe4b5",
|
||||
"navajowhite" : "#ffdead",
|
||||
"navy" : "#000080",
|
||||
"oldlace" : "#fdf5e6",
|
||||
"olive" : "#808000",
|
||||
"olivedrab" : "#6b8e23",
|
||||
"orange" : "#ffa500",
|
||||
"orangered" : "#ff4500",
|
||||
"orchid" : "#da70d6",
|
||||
"palegoldenrod" : "#eee8aa",
|
||||
"palegreen" : "#98fb98",
|
||||
"paleturquoise" : "#afeeee",
|
||||
"palevioletred" : "#d87093",
|
||||
"papayawhip" : "#ffefd5",
|
||||
"peachpuff" : "#ffdab9",
|
||||
"peru" : "#cd853f",
|
||||
"pink" : "#ffc0cb",
|
||||
"plum" : "#dda0dd",
|
||||
"powderblue" : "#b0e0e6",
|
||||
"purple" : "#800080",
|
||||
"red" : "#ff0000",
|
||||
"rosybrown" : "#bc8f8f",
|
||||
"royalblue" : "#4169e1",
|
||||
"saddlebrown" : "#8b4513",
|
||||
"salmon" : "#fa8072",
|
||||
"sandybrown" : "#f4a460",
|
||||
"seagreen" : "#2e8b57",
|
||||
"seashell" : "#fff5ee",
|
||||
"sienna" : "#a0522d",
|
||||
"silver" : "#c0c0c0",
|
||||
"skyblue" : "#87ceeb",
|
||||
"slateblue" : "#6a5acd",
|
||||
"slategray" : "#708090",
|
||||
"snow" : "#fffafa",
|
||||
"springgreen" : "#00ff7f",
|
||||
"steelblue" : "#4682b4",
|
||||
"tan" : "#d2b48c",
|
||||
"teal" : "#008080",
|
||||
"thistle" : "#d8bfd8",
|
||||
"tomato" : "#ff6347",
|
||||
"turquoise" : "#40e0d0",
|
||||
"violet" : "#ee82ee",
|
||||
"wheat" : "#f5deb3",
|
||||
"white" : "#ffffff",
|
||||
"whitesmoke" : "#f5f5f5",
|
||||
"yellow" : "#ffff00",
|
||||
"yellowgreen" : "#9acd32"
|
||||
};
|
||||
|
||||
CssColors.colorNameToHex = function(color) {
|
||||
color = color.toLowerCase();
|
||||
if (typeof this._colorsTable[color] != 'undefined')
|
||||
return this._colorsTable[color];
|
||||
|
||||
return false;
|
||||
};
|
||||
2056
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/deflate.js
generated
vendored
Normal file
2056
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/deflate.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/LICENSE
generated
vendored
Normal file
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/LICENSE
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright (c) 2012 Niklas von Hertzen
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation
|
||||
files (the "Software"), to deal in the Software without
|
||||
restriction, including without limitation the rights to use,
|
||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following
|
||||
conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
3519
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/dist/html2canvas.js
generated
vendored
Normal file
3519
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/dist/html2canvas.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
90
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/readme.md
generated
vendored
Normal file
90
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/readme.md
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
html2canvas
|
||||
===========
|
||||
|
||||
[Homepage](http://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest) | [Donate](https://www.gittip.com/niklasvh/)
|
||||
|
||||
[](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://travis-ci.org/niklasvh/html2canvas)
|
||||
|
||||
#### JavaScript HTML renderer ####
|
||||
|
||||
The script allows you to take "screenshots" of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.
|
||||
|
||||
|
||||
###How does it work?###
|
||||
The script renders the current page as a canvas image, by reading the DOM and the different styles applied to the elements.
|
||||
|
||||
It does **not require any rendering from the server**, as the whole image is created on the **clients browser**. However, as it is heavily dependent on the browser, this library is *not suitable* to be used in nodejs.
|
||||
It doesn't magically circumvent any browser content policy restrictions either, so rendering cross-origin content will require a [proxy](https://github.com/niklasvh/html2canvas/wiki/Proxies) to get the content to the [same origin](http://en.wikipedia.org/wiki/Same_origin_policy).
|
||||
|
||||
The script is still in a **very experimental state**, so I don't recommend using it in a production environment nor start building applications with it yet, as there will be still major changes made.
|
||||
|
||||
###Browser compatibility###
|
||||
|
||||
The library should work fine on the following browsers (with `Promise` polyfill):
|
||||
|
||||
* Firefox 3.5+
|
||||
* Google Chrome
|
||||
* Opera 12+
|
||||
* IE9+
|
||||
* Safari 6+
|
||||
|
||||
As each CSS property needs to be manually built to be supported, there are a number of properties that are not yet supported.
|
||||
|
||||
### Usage ###
|
||||
|
||||
The html2canvas library utilizes `Promise`s and expects them to be available in the global context. If you wish to
|
||||
support [older browsers](http://caniuse.com/#search=promise) that do not natively support `Promise`s, please include a polyfill such as
|
||||
[es6-promise](https://github.com/jakearchibald/es6-promise) before including `html2canvas`.
|
||||
|
||||
**Note!** These instructions are for using the current dev version of 0.5, for the latest release version (0.4.1), checkout the [old readme](https://github.com/niklasvh/html2canvas/blob/v0.4/readme.md).
|
||||
|
||||
To render an `element` with html2canvas, simply call:
|
||||
` html2canvas(element[, options]);`
|
||||
|
||||
The function returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) containing the `<canvas>` element. Simply add a promise fullfillment handler to the promise using `then`:
|
||||
|
||||
html2canvas(document.body).then(function(canvas) {
|
||||
document.body.appendChild(canvas);
|
||||
});
|
||||
|
||||
### Building ###
|
||||
|
||||
The library uses [grunt](http://gruntjs.com/) for building. Alternatively, you can download the latest build from [here](https://github.com/niklasvh/html2canvas/blob/master/dist/html2canvas.js).
|
||||
|
||||
Clone git repository with submodules:
|
||||
|
||||
$ git clone --recursive git://github.com/niklasvh/html2canvas.git
|
||||
|
||||
Install Grunt and uglifyjs:
|
||||
|
||||
$ npm install -g grunt-cli uglify-js
|
||||
|
||||
Run the full build process (including lint, qunit and webdriver tests):
|
||||
|
||||
$ grunt
|
||||
|
||||
Skip lint and tests and simply build from source:
|
||||
|
||||
$ grunt build
|
||||
|
||||
### Running tests ###
|
||||
|
||||
The library has two sets of tests. The first set is a number of qunit tests that check that different values parsed by browsers are correctly converted in html2canvas. To run these tests with grunt you'll need [phantomjs](http://phantomjs.org/).
|
||||
|
||||
The other set of tests run Firefox, Chrome and Internet Explorer with [webdriver](https://github.com/niklasvh/webdriver.js). The selenium standalone server (runs on Java) is required for these tests and can be downloaded from [here](http://code.google.com/p/selenium/downloads/list). They capture an actual screenshot from the test pages and compare the image to the screenshot created by html2canvas and calculate the percentage differences. These tests generally aren't expected to provide 100% matches, but while commiting changes, these should generally not go decrease from the baseline values.
|
||||
|
||||
Start by downloading the dependencies:
|
||||
|
||||
$ npm install
|
||||
|
||||
Run qunit tests:
|
||||
|
||||
$ grunt test
|
||||
|
||||
### Examples ###
|
||||
|
||||
For more information and examples, please visit the [homepage](http://html2canvas.hertzen.com) or try the [test console](http://html2canvas.hertzen.com/screenshots.html).
|
||||
|
||||
### Contributing ###
|
||||
|
||||
If you wish to contribute to the project, please send the pull requests to the develop branch. Before submitting any changes, try and test that the changes work with all the support browsers. If some CSS property isn't supported or is incomplete, please create appropriate tests for it as well before submitting any code changes.
|
||||
104
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/clone.js
generated
vendored
Normal file
104
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/clone.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
var log = require('./log');
|
||||
|
||||
function restoreOwnerScroll(ownerDocument, x, y) {
|
||||
if (ownerDocument.defaultView && (x !== ownerDocument.defaultView.pageXOffset || y !== ownerDocument.defaultView.pageYOffset)) {
|
||||
ownerDocument.defaultView.scrollTo(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
function cloneCanvasContents(canvas, clonedCanvas) {
|
||||
try {
|
||||
if (clonedCanvas) {
|
||||
clonedCanvas.width = canvas.width;
|
||||
clonedCanvas.height = canvas.height;
|
||||
clonedCanvas.getContext("2d").putImageData(canvas.getContext("2d").getImageData(0, 0, canvas.width, canvas.height), 0, 0);
|
||||
}
|
||||
} catch(e) {
|
||||
log("Unable to copy canvas content from", canvas, e);
|
||||
}
|
||||
}
|
||||
|
||||
function cloneNode(node, javascriptEnabled) {
|
||||
var clone = node.nodeType === 3 ? document.createTextNode(node.nodeValue) : node.cloneNode(false);
|
||||
|
||||
var child = node.firstChild;
|
||||
while(child) {
|
||||
if (javascriptEnabled === true || child.nodeType !== 1 || child.nodeName !== 'SCRIPT') {
|
||||
clone.appendChild(cloneNode(child, javascriptEnabled));
|
||||
}
|
||||
child = child.nextSibling;
|
||||
}
|
||||
|
||||
if (node.nodeType === 1) {
|
||||
clone._scrollTop = node.scrollTop;
|
||||
clone._scrollLeft = node.scrollLeft;
|
||||
if (node.nodeName === "CANVAS") {
|
||||
cloneCanvasContents(node, clone);
|
||||
} else if (node.nodeName === "TEXTAREA" || node.nodeName === "SELECT") {
|
||||
clone.value = node.value;
|
||||
}
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
||||
function initNode(node) {
|
||||
if (node.nodeType === 1) {
|
||||
node.scrollTop = node._scrollTop;
|
||||
node.scrollLeft = node._scrollLeft;
|
||||
|
||||
var child = node.firstChild;
|
||||
while(child) {
|
||||
initNode(child);
|
||||
child = child.nextSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(ownerDocument, containerDocument, width, height, options, x ,y) {
|
||||
var documentElement = cloneNode(ownerDocument.documentElement, options.javascriptEnabled);
|
||||
var container = containerDocument.createElement("iframe");
|
||||
|
||||
container.className = "html2canvas-container";
|
||||
container.style.visibility = "hidden";
|
||||
container.style.position = "fixed";
|
||||
container.style.left = "-10000px";
|
||||
container.style.top = "0px";
|
||||
container.style.border = "0";
|
||||
container.width = width;
|
||||
container.height = height;
|
||||
container.scrolling = "no"; // ios won't scroll without it
|
||||
containerDocument.body.appendChild(container);
|
||||
|
||||
return new Promise(function(resolve) {
|
||||
var documentClone = container.contentWindow.document;
|
||||
|
||||
/* Chrome doesn't detect relative background-images assigned in inline <style> sheets when fetched through getComputedStyle
|
||||
if window url is about:blank, we can assign the url to current by writing onto the document
|
||||
*/
|
||||
container.contentWindow.onload = container.onload = function() {
|
||||
var interval = setInterval(function() {
|
||||
if (documentClone.body.childNodes.length > 0) {
|
||||
initNode(documentClone.documentElement);
|
||||
clearInterval(interval);
|
||||
if (options.type === "view") {
|
||||
container.contentWindow.scrollTo(x, y);
|
||||
if ((/(iPad|iPhone|iPod)/g).test(navigator.userAgent) && (container.contentWindow.scrollY !== y || container.contentWindow.scrollX !== x)) {
|
||||
documentClone.documentElement.style.top = (-y) + "px";
|
||||
documentClone.documentElement.style.left = (-x) + "px";
|
||||
documentClone.documentElement.style.position = 'absolute';
|
||||
}
|
||||
}
|
||||
resolve(container);
|
||||
}
|
||||
}, 50);
|
||||
};
|
||||
|
||||
documentClone.open();
|
||||
documentClone.write("<!DOCTYPE html><html></html>");
|
||||
// Chrome scrolls the parent document for some reason after the write to the cloned window???
|
||||
restoreOwnerScroll(ownerDocument, x, y);
|
||||
documentClone.replaceChild(documentClone.adoptNode(documentElement), documentClone.documentElement);
|
||||
documentClone.close();
|
||||
});
|
||||
};
|
||||
272
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/color.js
generated
vendored
Normal file
272
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/color.js
generated
vendored
Normal file
@ -0,0 +1,272 @@
|
||||
// http://dev.w3.org/csswg/css-color/
|
||||
|
||||
function Color(value) {
|
||||
this.r = 0;
|
||||
this.g = 0;
|
||||
this.b = 0;
|
||||
this.a = null;
|
||||
var result = this.fromArray(value) ||
|
||||
this.namedColor(value) ||
|
||||
this.rgb(value) ||
|
||||
this.rgba(value) ||
|
||||
this.hex6(value) ||
|
||||
this.hex3(value);
|
||||
}
|
||||
|
||||
Color.prototype.darken = function(amount) {
|
||||
var a = 1 - amount;
|
||||
return new Color([
|
||||
Math.round(this.r * a),
|
||||
Math.round(this.g * a),
|
||||
Math.round(this.b * a),
|
||||
this.a
|
||||
]);
|
||||
};
|
||||
|
||||
Color.prototype.isTransparent = function() {
|
||||
return this.a === 0;
|
||||
};
|
||||
|
||||
Color.prototype.isBlack = function() {
|
||||
return this.r === 0 && this.g === 0 && this.b === 0;
|
||||
};
|
||||
|
||||
Color.prototype.fromArray = function(array) {
|
||||
if (Array.isArray(array)) {
|
||||
this.r = Math.min(array[0], 255);
|
||||
this.g = Math.min(array[1], 255);
|
||||
this.b = Math.min(array[2], 255);
|
||||
if (array.length > 3) {
|
||||
this.a = array[3];
|
||||
}
|
||||
}
|
||||
|
||||
return (Array.isArray(array));
|
||||
};
|
||||
|
||||
var _hex3 = /^#([a-f0-9]{3})$/i;
|
||||
|
||||
Color.prototype.hex3 = function(value) {
|
||||
var match = null;
|
||||
if ((match = value.match(_hex3)) !== null) {
|
||||
this.r = parseInt(match[1][0] + match[1][0], 16);
|
||||
this.g = parseInt(match[1][1] + match[1][1], 16);
|
||||
this.b = parseInt(match[1][2] + match[1][2], 16);
|
||||
}
|
||||
return match !== null;
|
||||
};
|
||||
|
||||
var _hex6 = /^#([a-f0-9]{6})$/i;
|
||||
|
||||
Color.prototype.hex6 = function(value) {
|
||||
var match = null;
|
||||
if ((match = value.match(_hex6)) !== null) {
|
||||
this.r = parseInt(match[1].substring(0, 2), 16);
|
||||
this.g = parseInt(match[1].substring(2, 4), 16);
|
||||
this.b = parseInt(match[1].substring(4, 6), 16);
|
||||
}
|
||||
return match !== null;
|
||||
};
|
||||
|
||||
|
||||
var _rgb = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/;
|
||||
|
||||
Color.prototype.rgb = function(value) {
|
||||
var match = null;
|
||||
if ((match = value.match(_rgb)) !== null) {
|
||||
this.r = Number(match[1]);
|
||||
this.g = Number(match[2]);
|
||||
this.b = Number(match[3]);
|
||||
}
|
||||
return match !== null;
|
||||
};
|
||||
|
||||
var _rgba = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d?\.?\d+)\s*\)$/;
|
||||
|
||||
Color.prototype.rgba = function(value) {
|
||||
var match = null;
|
||||
if ((match = value.match(_rgba)) !== null) {
|
||||
this.r = Number(match[1]);
|
||||
this.g = Number(match[2]);
|
||||
this.b = Number(match[3]);
|
||||
this.a = Number(match[4]);
|
||||
}
|
||||
return match !== null;
|
||||
};
|
||||
|
||||
Color.prototype.toString = function() {
|
||||
return this.a !== null && this.a !== 1 ?
|
||||
"rgba(" + [this.r, this.g, this.b, this.a].join(",") + ")" :
|
||||
"rgb(" + [this.r, this.g, this.b].join(",") + ")";
|
||||
};
|
||||
|
||||
Color.prototype.namedColor = function(value) {
|
||||
value = value.toLowerCase();
|
||||
var color = colors[value];
|
||||
if (color) {
|
||||
this.r = color[0];
|
||||
this.g = color[1];
|
||||
this.b = color[2];
|
||||
} else if (value === "transparent") {
|
||||
this.r = this.g = this.b = this.a = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return !!color;
|
||||
};
|
||||
|
||||
Color.prototype.isColor = true;
|
||||
|
||||
// JSON.stringify([].slice.call($$('.named-color-table tr'), 1).map(function(row) { return [row.childNodes[3].textContent, row.childNodes[5].textContent.trim().split(",").map(Number)] }).reduce(function(data, row) {data[row[0]] = row[1]; return data}, {}))
|
||||
var colors = {
|
||||
"aliceblue": [240, 248, 255],
|
||||
"antiquewhite": [250, 235, 215],
|
||||
"aqua": [0, 255, 255],
|
||||
"aquamarine": [127, 255, 212],
|
||||
"azure": [240, 255, 255],
|
||||
"beige": [245, 245, 220],
|
||||
"bisque": [255, 228, 196],
|
||||
"black": [0, 0, 0],
|
||||
"blanchedalmond": [255, 235, 205],
|
||||
"blue": [0, 0, 255],
|
||||
"blueviolet": [138, 43, 226],
|
||||
"brown": [165, 42, 42],
|
||||
"burlywood": [222, 184, 135],
|
||||
"cadetblue": [95, 158, 160],
|
||||
"chartreuse": [127, 255, 0],
|
||||
"chocolate": [210, 105, 30],
|
||||
"coral": [255, 127, 80],
|
||||
"cornflowerblue": [100, 149, 237],
|
||||
"cornsilk": [255, 248, 220],
|
||||
"crimson": [220, 20, 60],
|
||||
"cyan": [0, 255, 255],
|
||||
"darkblue": [0, 0, 139],
|
||||
"darkcyan": [0, 139, 139],
|
||||
"darkgoldenrod": [184, 134, 11],
|
||||
"darkgray": [169, 169, 169],
|
||||
"darkgreen": [0, 100, 0],
|
||||
"darkgrey": [169, 169, 169],
|
||||
"darkkhaki": [189, 183, 107],
|
||||
"darkmagenta": [139, 0, 139],
|
||||
"darkolivegreen": [85, 107, 47],
|
||||
"darkorange": [255, 140, 0],
|
||||
"darkorchid": [153, 50, 204],
|
||||
"darkred": [139, 0, 0],
|
||||
"darksalmon": [233, 150, 122],
|
||||
"darkseagreen": [143, 188, 143],
|
||||
"darkslateblue": [72, 61, 139],
|
||||
"darkslategray": [47, 79, 79],
|
||||
"darkslategrey": [47, 79, 79],
|
||||
"darkturquoise": [0, 206, 209],
|
||||
"darkviolet": [148, 0, 211],
|
||||
"deeppink": [255, 20, 147],
|
||||
"deepskyblue": [0, 191, 255],
|
||||
"dimgray": [105, 105, 105],
|
||||
"dimgrey": [105, 105, 105],
|
||||
"dodgerblue": [30, 144, 255],
|
||||
"firebrick": [178, 34, 34],
|
||||
"floralwhite": [255, 250, 240],
|
||||
"forestgreen": [34, 139, 34],
|
||||
"fuchsia": [255, 0, 255],
|
||||
"gainsboro": [220, 220, 220],
|
||||
"ghostwhite": [248, 248, 255],
|
||||
"gold": [255, 215, 0],
|
||||
"goldenrod": [218, 165, 32],
|
||||
"gray": [128, 128, 128],
|
||||
"green": [0, 128, 0],
|
||||
"greenyellow": [173, 255, 47],
|
||||
"grey": [128, 128, 128],
|
||||
"honeydew": [240, 255, 240],
|
||||
"hotpink": [255, 105, 180],
|
||||
"indianred": [205, 92, 92],
|
||||
"indigo": [75, 0, 130],
|
||||
"ivory": [255, 255, 240],
|
||||
"khaki": [240, 230, 140],
|
||||
"lavender": [230, 230, 250],
|
||||
"lavenderblush": [255, 240, 245],
|
||||
"lawngreen": [124, 252, 0],
|
||||
"lemonchiffon": [255, 250, 205],
|
||||
"lightblue": [173, 216, 230],
|
||||
"lightcoral": [240, 128, 128],
|
||||
"lightcyan": [224, 255, 255],
|
||||
"lightgoldenrodyellow": [250, 250, 210],
|
||||
"lightgray": [211, 211, 211],
|
||||
"lightgreen": [144, 238, 144],
|
||||
"lightgrey": [211, 211, 211],
|
||||
"lightpink": [255, 182, 193],
|
||||
"lightsalmon": [255, 160, 122],
|
||||
"lightseagreen": [32, 178, 170],
|
||||
"lightskyblue": [135, 206, 250],
|
||||
"lightslategray": [119, 136, 153],
|
||||
"lightslategrey": [119, 136, 153],
|
||||
"lightsteelblue": [176, 196, 222],
|
||||
"lightyellow": [255, 255, 224],
|
||||
"lime": [0, 255, 0],
|
||||
"limegreen": [50, 205, 50],
|
||||
"linen": [250, 240, 230],
|
||||
"magenta": [255, 0, 255],
|
||||
"maroon": [128, 0, 0],
|
||||
"mediumaquamarine": [102, 205, 170],
|
||||
"mediumblue": [0, 0, 205],
|
||||
"mediumorchid": [186, 85, 211],
|
||||
"mediumpurple": [147, 112, 219],
|
||||
"mediumseagreen": [60, 179, 113],
|
||||
"mediumslateblue": [123, 104, 238],
|
||||
"mediumspringgreen": [0, 250, 154],
|
||||
"mediumturquoise": [72, 209, 204],
|
||||
"mediumvioletred": [199, 21, 133],
|
||||
"midnightblue": [25, 25, 112],
|
||||
"mintcream": [245, 255, 250],
|
||||
"mistyrose": [255, 228, 225],
|
||||
"moccasin": [255, 228, 181],
|
||||
"navajowhite": [255, 222, 173],
|
||||
"navy": [0, 0, 128],
|
||||
"oldlace": [253, 245, 230],
|
||||
"olive": [128, 128, 0],
|
||||
"olivedrab": [107, 142, 35],
|
||||
"orange": [255, 165, 0],
|
||||
"orangered": [255, 69, 0],
|
||||
"orchid": [218, 112, 214],
|
||||
"palegoldenrod": [238, 232, 170],
|
||||
"palegreen": [152, 251, 152],
|
||||
"paleturquoise": [175, 238, 238],
|
||||
"palevioletred": [219, 112, 147],
|
||||
"papayawhip": [255, 239, 213],
|
||||
"peachpuff": [255, 218, 185],
|
||||
"peru": [205, 133, 63],
|
||||
"pink": [255, 192, 203],
|
||||
"plum": [221, 160, 221],
|
||||
"powderblue": [176, 224, 230],
|
||||
"purple": [128, 0, 128],
|
||||
"rebeccapurple": [102, 51, 153],
|
||||
"red": [255, 0, 0],
|
||||
"rosybrown": [188, 143, 143],
|
||||
"royalblue": [65, 105, 225],
|
||||
"saddlebrown": [139, 69, 19],
|
||||
"salmon": [250, 128, 114],
|
||||
"sandybrown": [244, 164, 96],
|
||||
"seagreen": [46, 139, 87],
|
||||
"seashell": [255, 245, 238],
|
||||
"sienna": [160, 82, 45],
|
||||
"silver": [192, 192, 192],
|
||||
"skyblue": [135, 206, 235],
|
||||
"slateblue": [106, 90, 205],
|
||||
"slategray": [112, 128, 144],
|
||||
"slategrey": [112, 128, 144],
|
||||
"snow": [255, 250, 250],
|
||||
"springgreen": [0, 255, 127],
|
||||
"steelblue": [70, 130, 180],
|
||||
"tan": [210, 180, 140],
|
||||
"teal": [0, 128, 128],
|
||||
"thistle": [216, 191, 216],
|
||||
"tomato": [255, 99, 71],
|
||||
"turquoise": [64, 224, 208],
|
||||
"violet": [238, 130, 238],
|
||||
"wheat": [245, 222, 179],
|
||||
"white": [255, 255, 255],
|
||||
"whitesmoke": [245, 245, 245],
|
||||
"yellow": [255, 255, 0],
|
||||
"yellowgreen": [154, 205, 50]
|
||||
};
|
||||
|
||||
module.exports = Color;
|
||||
155
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/core.js
generated
vendored
Normal file
155
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/core.js
generated
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
var Support = require('./support');
|
||||
var CanvasRenderer = require('./renderers/canvas');
|
||||
var ImageLoader = require('./imageloader');
|
||||
var NodeParser = require('./nodeparser');
|
||||
var NodeContainer = require('./nodecontainer');
|
||||
var log = require('./log');
|
||||
var utils = require('./utils');
|
||||
var createWindowClone = require('./clone');
|
||||
var loadUrlDocument = require('./proxy').loadUrlDocument;
|
||||
var getBounds = utils.getBounds;
|
||||
|
||||
var html2canvasNodeAttribute = "data-html2canvas-node";
|
||||
var html2canvasCloneIndex = 0;
|
||||
|
||||
function html2canvas(nodeList, options) {
|
||||
var index = html2canvasCloneIndex++;
|
||||
options = options || {};
|
||||
if (options.logging) {
|
||||
log.options.logging = true;
|
||||
log.options.start = Date.now();
|
||||
}
|
||||
|
||||
options.async = typeof(options.async) === "undefined" ? true : options.async;
|
||||
options.allowTaint = typeof(options.allowTaint) === "undefined" ? false : options.allowTaint;
|
||||
options.removeContainer = typeof(options.removeContainer) === "undefined" ? true : options.removeContainer;
|
||||
options.javascriptEnabled = typeof(options.javascriptEnabled) === "undefined" ? false : options.javascriptEnabled;
|
||||
options.imageTimeout = typeof(options.imageTimeout) === "undefined" ? 10000 : options.imageTimeout;
|
||||
options.renderer = typeof(options.renderer) === "function" ? options.renderer : CanvasRenderer;
|
||||
options.strict = !!options.strict;
|
||||
|
||||
if (typeof(nodeList) === "string") {
|
||||
if (typeof(options.proxy) !== "string") {
|
||||
return Promise.reject("Proxy must be used when rendering url");
|
||||
}
|
||||
var width = options.width != null ? options.width : window.innerWidth;
|
||||
var height = options.height != null ? options.height : window.innerHeight;
|
||||
return loadUrlDocument(absoluteUrl(nodeList), options.proxy, document, width, height, options).then(function(container) {
|
||||
return renderWindow(container.contentWindow.document.documentElement, container, options, width, height);
|
||||
});
|
||||
}
|
||||
|
||||
var node = ((nodeList === undefined) ? [document.documentElement] : ((nodeList.length) ? nodeList : [nodeList]))[0];
|
||||
node.setAttribute(html2canvasNodeAttribute + index, index);
|
||||
return renderDocument(node.ownerDocument, options, node.ownerDocument.defaultView.innerWidth, node.ownerDocument.defaultView.innerHeight, index).then(function(canvas) {
|
||||
if (typeof(options.onrendered) === "function") {
|
||||
log("options.onrendered is deprecated, html2canvas returns a Promise containing the canvas");
|
||||
options.onrendered(canvas);
|
||||
}
|
||||
return canvas;
|
||||
});
|
||||
}
|
||||
|
||||
html2canvas.CanvasRenderer = CanvasRenderer;
|
||||
html2canvas.NodeContainer = NodeContainer;
|
||||
html2canvas.log = log;
|
||||
html2canvas.utils = utils;
|
||||
|
||||
var html2canvasExport = (typeof(document) === "undefined" || typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") ? function() {
|
||||
return Promise.reject("No canvas support");
|
||||
} : html2canvas;
|
||||
|
||||
module.exports = html2canvasExport;
|
||||
|
||||
if (typeof(define) === 'function' && define.amd) {
|
||||
define('html2canvas', [], function() {
|
||||
return html2canvasExport;
|
||||
});
|
||||
}
|
||||
|
||||
function renderDocument(document, options, windowWidth, windowHeight, html2canvasIndex) {
|
||||
return createWindowClone(document, document, windowWidth, windowHeight, options, document.defaultView.pageXOffset, document.defaultView.pageYOffset).then(function(container) {
|
||||
log("Document cloned");
|
||||
var attributeName = html2canvasNodeAttribute + html2canvasIndex;
|
||||
var selector = "[" + attributeName + "='" + html2canvasIndex + "']";
|
||||
document.querySelector(selector).removeAttribute(attributeName);
|
||||
var clonedWindow = container.contentWindow;
|
||||
var node = clonedWindow.document.querySelector(selector);
|
||||
var oncloneHandler = (typeof(options.onclone) === "function") ? Promise.resolve(options.onclone(clonedWindow.document)) : Promise.resolve(true);
|
||||
return oncloneHandler.then(function() {
|
||||
return renderWindow(node, container, options, windowWidth, windowHeight);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function renderWindow(node, container, options, windowWidth, windowHeight) {
|
||||
var clonedWindow = container.contentWindow;
|
||||
var support = new Support(clonedWindow.document);
|
||||
var imageLoader = new ImageLoader(options, support);
|
||||
var bounds = getBounds(node);
|
||||
var width = options.type === "view" ? windowWidth : documentWidth(clonedWindow.document);
|
||||
var height = options.type === "view" ? windowHeight : documentHeight(clonedWindow.document);
|
||||
var renderer = new options.renderer(width, height, imageLoader, options, document);
|
||||
var parser = new NodeParser(node, renderer, support, imageLoader, options);
|
||||
return parser.ready.then(function() {
|
||||
log("Finished rendering");
|
||||
var canvas;
|
||||
|
||||
if (options.type === "view") {
|
||||
canvas = crop(renderer.canvas, {width: renderer.canvas.width, height: renderer.canvas.height, top: 0, left: 0, x: 0, y: 0});
|
||||
} else if (node === clonedWindow.document.body || node === clonedWindow.document.documentElement || options.canvas != null) {
|
||||
canvas = renderer.canvas;
|
||||
} else {
|
||||
canvas = crop(renderer.canvas, {width: options.width != null ? options.width : bounds.width, height: options.height != null ? options.height : bounds.height, top: bounds.top, left: bounds.left, x: 0, y: 0});
|
||||
}
|
||||
|
||||
cleanupContainer(container, options);
|
||||
return canvas;
|
||||
});
|
||||
}
|
||||
|
||||
function cleanupContainer(container, options) {
|
||||
if (options.removeContainer) {
|
||||
container.parentNode.removeChild(container);
|
||||
log("Cleaned up container");
|
||||
}
|
||||
}
|
||||
|
||||
function crop(canvas, bounds) {
|
||||
var croppedCanvas = document.createElement("canvas");
|
||||
var x1 = Math.min(canvas.width - 1, Math.max(0, bounds.left));
|
||||
var x2 = Math.min(canvas.width, Math.max(1, bounds.left + bounds.width));
|
||||
var y1 = Math.min(canvas.height - 1, Math.max(0, bounds.top));
|
||||
var y2 = Math.min(canvas.height, Math.max(1, bounds.top + bounds.height));
|
||||
croppedCanvas.width = bounds.width;
|
||||
croppedCanvas.height = bounds.height;
|
||||
var width = x2-x1;
|
||||
var height = y2-y1;
|
||||
log("Cropping canvas at:", "left:", bounds.left, "top:", bounds.top, "width:", width, "height:", height);
|
||||
log("Resulting crop with width", bounds.width, "and height", bounds.height, "with x", x1, "and y", y1);
|
||||
croppedCanvas.getContext("2d").drawImage(canvas, x1, y1, width, height, bounds.x, bounds.y, width, height);
|
||||
return croppedCanvas;
|
||||
}
|
||||
|
||||
function documentWidth (doc) {
|
||||
return Math.max(
|
||||
Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth),
|
||||
Math.max(doc.body.offsetWidth, doc.documentElement.offsetWidth),
|
||||
Math.max(doc.body.clientWidth, doc.documentElement.clientWidth)
|
||||
);
|
||||
}
|
||||
|
||||
function documentHeight (doc) {
|
||||
return Math.max(
|
||||
Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight),
|
||||
Math.max(doc.body.offsetHeight, doc.documentElement.offsetHeight),
|
||||
Math.max(doc.body.clientHeight, doc.documentElement.clientHeight)
|
||||
);
|
||||
}
|
||||
|
||||
function absoluteUrl(url) {
|
||||
var link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.href = link.href;
|
||||
return link;
|
||||
}
|
||||
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/dummyimagecontainer.js
generated
vendored
Normal file
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/dummyimagecontainer.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
var log = require('./log');
|
||||
var smallImage = require('./utils').smallImage;
|
||||
|
||||
function DummyImageContainer(src) {
|
||||
this.src = src;
|
||||
log("DummyImageContainer for", src);
|
||||
if (!this.promise || !this.image) {
|
||||
log("Initiating DummyImageContainer");
|
||||
DummyImageContainer.prototype.image = new Image();
|
||||
var image = this.image;
|
||||
DummyImageContainer.prototype.promise = new Promise(function(resolve, reject) {
|
||||
image.onload = resolve;
|
||||
image.onerror = reject;
|
||||
image.src = smallImage();
|
||||
if (image.complete === true) {
|
||||
resolve(image);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DummyImageContainer;
|
||||
6
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/fallback.js
generated
vendored
Normal file
6
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/fallback.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
if (typeof(Object.create) !== "function" || typeof(document.createElement("canvas").getContext) !== "function") {
|
||||
window.html2canvas = function() {
|
||||
return Promise.reject("No canvas support");
|
||||
};
|
||||
//return;
|
||||
}
|
||||
52
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/font.js
generated
vendored
Normal file
52
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/font.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
var smallImage = require('./utils').smallImage;
|
||||
|
||||
function Font(family, size) {
|
||||
var container = document.createElement('div'),
|
||||
img = document.createElement('img'),
|
||||
span = document.createElement('span'),
|
||||
sampleText = 'Hidden Text',
|
||||
baseline,
|
||||
middle;
|
||||
|
||||
container.style.visibility = "hidden";
|
||||
container.style.fontFamily = family;
|
||||
container.style.fontSize = size;
|
||||
container.style.margin = 0;
|
||||
container.style.padding = 0;
|
||||
|
||||
document.body.appendChild(container);
|
||||
|
||||
img.src = smallImage();
|
||||
img.width = 1;
|
||||
img.height = 1;
|
||||
|
||||
img.style.margin = 0;
|
||||
img.style.padding = 0;
|
||||
img.style.verticalAlign = "baseline";
|
||||
|
||||
span.style.fontFamily = family;
|
||||
span.style.fontSize = size;
|
||||
span.style.margin = 0;
|
||||
span.style.padding = 0;
|
||||
|
||||
span.appendChild(document.createTextNode(sampleText));
|
||||
container.appendChild(span);
|
||||
container.appendChild(img);
|
||||
baseline = (img.offsetTop - span.offsetTop) + 1;
|
||||
|
||||
container.removeChild(span);
|
||||
container.appendChild(document.createTextNode(sampleText));
|
||||
|
||||
container.style.lineHeight = "normal";
|
||||
img.style.verticalAlign = "super";
|
||||
|
||||
middle = (img.offsetTop-container.offsetTop) + 1;
|
||||
|
||||
document.body.removeChild(container);
|
||||
|
||||
this.baseline = baseline;
|
||||
this.lineWidth = 1;
|
||||
this.middle = middle;
|
||||
}
|
||||
|
||||
module.exports = Font;
|
||||
14
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/fontmetrics.js
generated
vendored
Normal file
14
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/fontmetrics.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
var Font = require('./font');
|
||||
|
||||
function FontMetrics() {
|
||||
this.data = {};
|
||||
}
|
||||
|
||||
FontMetrics.prototype.getMetrics = function(family, size) {
|
||||
if (this.data[family + "-" + size] === undefined) {
|
||||
this.data[family + "-" + size] = new Font(family, size);
|
||||
}
|
||||
return this.data[family + "-" + size];
|
||||
};
|
||||
|
||||
module.exports = FontMetrics;
|
||||
31
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/framecontainer.js
generated
vendored
Normal file
31
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/framecontainer.js
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
var utils = require('./utils');
|
||||
var getBounds = utils.getBounds;
|
||||
var loadUrlDocument = require('./proxy').loadUrlDocument;
|
||||
|
||||
function FrameContainer(container, sameOrigin, options) {
|
||||
this.image = null;
|
||||
this.src = container;
|
||||
var self = this;
|
||||
var bounds = getBounds(container);
|
||||
this.promise = (!sameOrigin ? this.proxyLoad(options.proxy, bounds, options) : new Promise(function(resolve) {
|
||||
if (container.contentWindow.document.URL === "about:blank" || container.contentWindow.document.documentElement == null) {
|
||||
container.contentWindow.onload = container.onload = function() {
|
||||
resolve(container);
|
||||
};
|
||||
} else {
|
||||
resolve(container);
|
||||
}
|
||||
})).then(function(container) {
|
||||
var html2canvas = require('./core');
|
||||
return html2canvas(container.contentWindow.document.documentElement, {type: 'view', width: container.width, height: container.height, proxy: options.proxy, javascriptEnabled: options.javascriptEnabled, removeContainer: options.removeContainer, allowTaint: options.allowTaint, imageTimeout: options.imageTimeout / 2});
|
||||
}).then(function(canvas) {
|
||||
return self.image = canvas;
|
||||
});
|
||||
}
|
||||
|
||||
FrameContainer.prototype.proxyLoad = function(proxy, bounds, options) {
|
||||
var container = this.src;
|
||||
return loadUrlDocument(container.src, proxy, container.ownerDocument, bounds.width, bounds.height, options);
|
||||
};
|
||||
|
||||
module.exports = FrameContainer;
|
||||
21
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/gradientcontainer.js
generated
vendored
Normal file
21
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/gradientcontainer.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
function GradientContainer(imageData) {
|
||||
this.src = imageData.value;
|
||||
this.colorStops = [];
|
||||
this.type = null;
|
||||
this.x0 = 0.5;
|
||||
this.y0 = 0.5;
|
||||
this.x1 = 0.5;
|
||||
this.y1 = 0.5;
|
||||
this.promise = Promise.resolve(true);
|
||||
}
|
||||
|
||||
GradientContainer.TYPES = {
|
||||
LINEAR: 1,
|
||||
RADIAL: 2
|
||||
};
|
||||
|
||||
// TODO: support hsl[a], negative %/length values
|
||||
// TODO: support <angle> (e.g. -?\d{1,3}(?:\.\d+)deg, etc. : https://developer.mozilla.org/docs/Web/CSS/angle )
|
||||
GradientContainer.REGEXP_COLORSTOP = /^\s*(rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}(?:,\s*[0-9\.]+)?\s*\)|[a-z]{3,20}|#[a-f0-9]{3,6})(?:\s+(\d{1,3}(?:\.\d+)?)(%|px)?)?(?:\s|$)/i;
|
||||
|
||||
module.exports = GradientContainer;
|
||||
19
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/imagecontainer.js
generated
vendored
Normal file
19
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/imagecontainer.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
function ImageContainer(src, cors) {
|
||||
this.src = src;
|
||||
this.image = new Image();
|
||||
var self = this;
|
||||
this.tainted = null;
|
||||
this.promise = new Promise(function(resolve, reject) {
|
||||
self.image.onload = resolve;
|
||||
self.image.onerror = reject;
|
||||
if (cors) {
|
||||
self.image.crossOrigin = "anonymous";
|
||||
}
|
||||
self.image.src = src;
|
||||
if (self.image.complete === true) {
|
||||
resolve(self.image);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ImageContainer;
|
||||
157
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/imageloader.js
generated
vendored
Normal file
157
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/imageloader.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
var log = require('./log');
|
||||
var ImageContainer = require('./imagecontainer');
|
||||
var DummyImageContainer = require('./dummyimagecontainer');
|
||||
var ProxyImageContainer = require('./proxyimagecontainer');
|
||||
var FrameContainer = require('./framecontainer');
|
||||
var SVGContainer = require('./svgcontainer');
|
||||
var SVGNodeContainer = require('./svgnodecontainer');
|
||||
var LinearGradientContainer = require('./lineargradientcontainer');
|
||||
var WebkitGradientContainer = require('./webkitgradientcontainer');
|
||||
var bind = require('./utils').bind;
|
||||
|
||||
function ImageLoader(options, support) {
|
||||
this.link = null;
|
||||
this.options = options;
|
||||
this.support = support;
|
||||
this.origin = this.getOrigin(window.location.href);
|
||||
}
|
||||
|
||||
ImageLoader.prototype.findImages = function(nodes) {
|
||||
var images = [];
|
||||
nodes.reduce(function(imageNodes, container) {
|
||||
switch(container.node.nodeName) {
|
||||
case "IMG":
|
||||
return imageNodes.concat([{
|
||||
args: [container.node.src],
|
||||
method: "url"
|
||||
}]);
|
||||
case "svg":
|
||||
case "IFRAME":
|
||||
return imageNodes.concat([{
|
||||
args: [container.node],
|
||||
method: container.node.nodeName
|
||||
}]);
|
||||
}
|
||||
return imageNodes;
|
||||
}, []).forEach(this.addImage(images, this.loadImage), this);
|
||||
return images;
|
||||
};
|
||||
|
||||
ImageLoader.prototype.findBackgroundImage = function(images, container) {
|
||||
container.parseBackgroundImages().filter(this.hasImageBackground).forEach(this.addImage(images, this.loadImage), this);
|
||||
return images;
|
||||
};
|
||||
|
||||
ImageLoader.prototype.addImage = function(images, callback) {
|
||||
return function(newImage) {
|
||||
newImage.args.forEach(function(image) {
|
||||
if (!this.imageExists(images, image)) {
|
||||
images.splice(0, 0, callback.call(this, newImage));
|
||||
log('Added image #' + (images.length), typeof(image) === "string" ? image.substring(0, 100) : image);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
};
|
||||
|
||||
ImageLoader.prototype.hasImageBackground = function(imageData) {
|
||||
return imageData.method !== "none";
|
||||
};
|
||||
|
||||
ImageLoader.prototype.loadImage = function(imageData) {
|
||||
if (imageData.method === "url") {
|
||||
var src = imageData.args[0];
|
||||
if (this.isSVG(src) && !this.support.svg && !this.options.allowTaint) {
|
||||
return new SVGContainer(src);
|
||||
} else if (src.match(/data:image\/.*;base64,/i)) {
|
||||
return new ImageContainer(src.replace(/url\(['"]{0,}|['"]{0,}\)$/ig, ''), false);
|
||||
} else if (this.isSameOrigin(src) || this.options.allowTaint === true || this.isSVG(src)) {
|
||||
return new ImageContainer(src, false);
|
||||
} else if (this.support.cors && !this.options.allowTaint && this.options.useCORS) {
|
||||
return new ImageContainer(src, true);
|
||||
} else if (this.options.proxy) {
|
||||
return new ProxyImageContainer(src, this.options.proxy);
|
||||
} else {
|
||||
return new DummyImageContainer(src);
|
||||
}
|
||||
} else if (imageData.method === "linear-gradient") {
|
||||
return new LinearGradientContainer(imageData);
|
||||
} else if (imageData.method === "gradient") {
|
||||
return new WebkitGradientContainer(imageData);
|
||||
} else if (imageData.method === "svg") {
|
||||
return new SVGNodeContainer(imageData.args[0], this.support.svg);
|
||||
} else if (imageData.method === "IFRAME") {
|
||||
return new FrameContainer(imageData.args[0], this.isSameOrigin(imageData.args[0].src), this.options);
|
||||
} else {
|
||||
return new DummyImageContainer(imageData);
|
||||
}
|
||||
};
|
||||
|
||||
ImageLoader.prototype.isSVG = function(src) {
|
||||
return src.substring(src.length - 3).toLowerCase() === "svg" || SVGContainer.prototype.isInline(src);
|
||||
};
|
||||
|
||||
ImageLoader.prototype.imageExists = function(images, src) {
|
||||
return images.some(function(image) {
|
||||
return image.src === src;
|
||||
});
|
||||
};
|
||||
|
||||
ImageLoader.prototype.isSameOrigin = function(url) {
|
||||
return (this.getOrigin(url) === this.origin);
|
||||
};
|
||||
|
||||
ImageLoader.prototype.getOrigin = function(url) {
|
||||
var link = this.link || (this.link = document.createElement("a"));
|
||||
link.href = url;
|
||||
link.href = link.href; // IE9, LOL! - http://jsfiddle.net/niklasvh/2e48b/
|
||||
return link.protocol + link.hostname + link.port;
|
||||
};
|
||||
|
||||
ImageLoader.prototype.getPromise = function(container) {
|
||||
return this.timeout(container, this.options.imageTimeout)['catch'](function() {
|
||||
var dummy = new DummyImageContainer(container.src);
|
||||
return dummy.promise.then(function(image) {
|
||||
container.image = image;
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ImageLoader.prototype.get = function(src) {
|
||||
var found = null;
|
||||
return this.images.some(function(img) {
|
||||
return (found = img).src === src;
|
||||
}) ? found : null;
|
||||
};
|
||||
|
||||
ImageLoader.prototype.fetch = function(nodes) {
|
||||
this.images = nodes.reduce(bind(this.findBackgroundImage, this), this.findImages(nodes));
|
||||
this.images.forEach(function(image, index) {
|
||||
image.promise.then(function() {
|
||||
log("Succesfully loaded image #"+ (index+1), image);
|
||||
}, function(e) {
|
||||
log("Failed loading image #"+ (index+1), image, e);
|
||||
});
|
||||
});
|
||||
this.ready = Promise.all(this.images.map(this.getPromise, this));
|
||||
log("Finished searching images");
|
||||
return this;
|
||||
};
|
||||
|
||||
ImageLoader.prototype.timeout = function(container, timeout) {
|
||||
var timer;
|
||||
var promise = Promise.race([container.promise, new Promise(function(res, reject) {
|
||||
timer = setTimeout(function() {
|
||||
log("Timed out loading image", container);
|
||||
reject(container);
|
||||
}, timeout);
|
||||
})]).then(function(container) {
|
||||
clearTimeout(timer);
|
||||
return container;
|
||||
});
|
||||
promise['catch'](function() {
|
||||
clearTimeout(timer);
|
||||
});
|
||||
return promise;
|
||||
};
|
||||
|
||||
module.exports = ImageLoader;
|
||||
102
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/lineargradientcontainer.js
generated
vendored
Normal file
102
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/lineargradientcontainer.js
generated
vendored
Normal file
@ -0,0 +1,102 @@
|
||||
var GradientContainer = require('./gradientcontainer');
|
||||
var Color = require('./color');
|
||||
|
||||
function LinearGradientContainer(imageData) {
|
||||
GradientContainer.apply(this, arguments);
|
||||
this.type = GradientContainer.TYPES.LINEAR;
|
||||
|
||||
var hasDirection = LinearGradientContainer.REGEXP_DIRECTION.test( imageData.args[0] ) ||
|
||||
!GradientContainer.REGEXP_COLORSTOP.test( imageData.args[0] );
|
||||
|
||||
if (hasDirection) {
|
||||
imageData.args[0].split(/\s+/).reverse().forEach(function(position, index) {
|
||||
switch(position) {
|
||||
case "left":
|
||||
this.x0 = 0;
|
||||
this.x1 = 1;
|
||||
break;
|
||||
case "top":
|
||||
this.y0 = 0;
|
||||
this.y1 = 1;
|
||||
break;
|
||||
case "right":
|
||||
this.x0 = 1;
|
||||
this.x1 = 0;
|
||||
break;
|
||||
case "bottom":
|
||||
this.y0 = 1;
|
||||
this.y1 = 0;
|
||||
break;
|
||||
case "to":
|
||||
var y0 = this.y0;
|
||||
var x0 = this.x0;
|
||||
this.y0 = this.y1;
|
||||
this.x0 = this.x1;
|
||||
this.x1 = x0;
|
||||
this.y1 = y0;
|
||||
break;
|
||||
case "center":
|
||||
break; // centered by default
|
||||
// Firefox internally converts position keywords to percentages:
|
||||
// http://www.w3.org/TR/2010/WD-CSS2-20101207/colors.html#propdef-background-position
|
||||
default: // percentage or absolute length
|
||||
// TODO: support absolute start point positions (e.g., use bounds to convert px to a ratio)
|
||||
var ratio = parseFloat(position, 10) * 1e-2;
|
||||
if (isNaN(ratio)) { // invalid or unhandled value
|
||||
break;
|
||||
}
|
||||
if (index === 0) {
|
||||
this.y0 = ratio;
|
||||
this.y1 = 1 - this.y0;
|
||||
} else {
|
||||
this.x0 = ratio;
|
||||
this.x1 = 1 - this.x0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, this);
|
||||
} else {
|
||||
this.y0 = 0;
|
||||
this.y1 = 1;
|
||||
}
|
||||
|
||||
this.colorStops = imageData.args.slice(hasDirection ? 1 : 0).map(function(colorStop) {
|
||||
var colorStopMatch = colorStop.match(GradientContainer.REGEXP_COLORSTOP);
|
||||
var value = +colorStopMatch[2];
|
||||
var unit = value === 0 ? "%" : colorStopMatch[3]; // treat "0" as "0%"
|
||||
return {
|
||||
color: new Color(colorStopMatch[1]),
|
||||
// TODO: support absolute stop positions (e.g., compute gradient line length & convert px to ratio)
|
||||
stop: unit === "%" ? value / 100 : null
|
||||
};
|
||||
});
|
||||
|
||||
if (this.colorStops[0].stop === null) {
|
||||
this.colorStops[0].stop = 0;
|
||||
}
|
||||
|
||||
if (this.colorStops[this.colorStops.length - 1].stop === null) {
|
||||
this.colorStops[this.colorStops.length - 1].stop = 1;
|
||||
}
|
||||
|
||||
// calculates and fills-in explicit stop positions when omitted from rule
|
||||
this.colorStops.forEach(function(colorStop, index) {
|
||||
if (colorStop.stop === null) {
|
||||
this.colorStops.slice(index).some(function(find, count) {
|
||||
if (find.stop !== null) {
|
||||
colorStop.stop = ((find.stop - this.colorStops[index - 1].stop) / (count + 1)) + this.colorStops[index - 1].stop;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
|
||||
LinearGradientContainer.prototype = Object.create(GradientContainer.prototype);
|
||||
|
||||
// TODO: support <angle> (e.g. -?\d{1,3}(?:\.\d+)deg, etc. : https://developer.mozilla.org/docs/Web/CSS/angle )
|
||||
LinearGradientContainer.REGEXP_DIRECTION = /^\s*(?:to|left|right|top|bottom|center|\d{1,3}(?:\.\d+)?%?)(?:\s|$)/i;
|
||||
|
||||
module.exports = LinearGradientContainer;
|
||||
8
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/log.js
generated
vendored
Normal file
8
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/log.js
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
var logger = function() {
|
||||
if (logger.options.logging && window.console && window.console.log) {
|
||||
Function.prototype.bind.call(window.console.log, (window.console)).apply(window.console, [(Date.now() - logger.options.start) + "ms", "html2canvas:"].concat([].slice.call(arguments, 0)));
|
||||
}
|
||||
};
|
||||
|
||||
logger.options = {logging: false};
|
||||
module.exports = logger;
|
||||
296
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/nodecontainer.js
generated
vendored
Normal file
296
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/nodecontainer.js
generated
vendored
Normal file
@ -0,0 +1,296 @@
|
||||
var Color = require('./color');
|
||||
var utils = require('./utils');
|
||||
var getBounds = utils.getBounds;
|
||||
var parseBackgrounds = utils.parseBackgrounds;
|
||||
var offsetBounds = utils.offsetBounds;
|
||||
|
||||
function NodeContainer(node, parent) {
|
||||
this.node = node;
|
||||
this.parent = parent;
|
||||
this.stack = null;
|
||||
this.bounds = null;
|
||||
this.borders = null;
|
||||
this.clip = [];
|
||||
this.backgroundClip = [];
|
||||
this.offsetBounds = null;
|
||||
this.visible = null;
|
||||
this.computedStyles = null;
|
||||
this.colors = {};
|
||||
this.styles = {};
|
||||
this.backgroundImages = null;
|
||||
this.transformData = null;
|
||||
this.transformMatrix = null;
|
||||
this.isPseudoElement = false;
|
||||
this.opacity = null;
|
||||
}
|
||||
|
||||
NodeContainer.prototype.cloneTo = function(stack) {
|
||||
stack.visible = this.visible;
|
||||
stack.borders = this.borders;
|
||||
stack.bounds = this.bounds;
|
||||
stack.clip = this.clip;
|
||||
stack.backgroundClip = this.backgroundClip;
|
||||
stack.computedStyles = this.computedStyles;
|
||||
stack.styles = this.styles;
|
||||
stack.backgroundImages = this.backgroundImages;
|
||||
stack.opacity = this.opacity;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.getOpacity = function() {
|
||||
return this.opacity === null ? (this.opacity = this.cssFloat('opacity')) : this.opacity;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.assignStack = function(stack) {
|
||||
this.stack = stack;
|
||||
stack.children.push(this);
|
||||
};
|
||||
|
||||
NodeContainer.prototype.isElementVisible = function() {
|
||||
return this.node.nodeType === Node.TEXT_NODE ? this.parent.visible : (
|
||||
this.css('display') !== "none" &&
|
||||
this.css('visibility') !== "hidden" &&
|
||||
!this.node.hasAttribute("data-html2canvas-ignore") &&
|
||||
(this.node.nodeName !== "INPUT" || this.node.getAttribute("type") !== "hidden")
|
||||
);
|
||||
};
|
||||
|
||||
NodeContainer.prototype.css = function(attribute) {
|
||||
if (!this.computedStyles) {
|
||||
this.computedStyles = this.isPseudoElement ? this.parent.computedStyle(this.before ? ":before" : ":after") : this.computedStyle(null);
|
||||
}
|
||||
|
||||
return this.styles[attribute] || (this.styles[attribute] = this.computedStyles[attribute]);
|
||||
};
|
||||
|
||||
NodeContainer.prototype.prefixedCss = function(attribute) {
|
||||
var prefixes = ["webkit", "moz", "ms", "o"];
|
||||
var value = this.css(attribute);
|
||||
if (value === undefined) {
|
||||
prefixes.some(function(prefix) {
|
||||
value = this.css(prefix + attribute.substr(0, 1).toUpperCase() + attribute.substr(1));
|
||||
return value !== undefined;
|
||||
}, this);
|
||||
}
|
||||
return value === undefined ? null : value;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.computedStyle = function(type) {
|
||||
return this.node.ownerDocument.defaultView.getComputedStyle(this.node, type);
|
||||
};
|
||||
|
||||
NodeContainer.prototype.cssInt = function(attribute) {
|
||||
var value = parseInt(this.css(attribute), 10);
|
||||
return (isNaN(value)) ? 0 : value; // borders in old IE are throwing 'medium' for demo.html
|
||||
};
|
||||
|
||||
NodeContainer.prototype.color = function(attribute) {
|
||||
return this.colors[attribute] || (this.colors[attribute] = new Color(this.css(attribute)));
|
||||
};
|
||||
|
||||
NodeContainer.prototype.cssFloat = function(attribute) {
|
||||
var value = parseFloat(this.css(attribute));
|
||||
return (isNaN(value)) ? 0 : value;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.fontWeight = function() {
|
||||
var weight = this.css("fontWeight");
|
||||
switch(parseInt(weight, 10)){
|
||||
case 401:
|
||||
weight = "bold";
|
||||
break;
|
||||
case 400:
|
||||
weight = "normal";
|
||||
break;
|
||||
}
|
||||
return weight;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseClip = function() {
|
||||
var matches = this.css('clip').match(this.CLIP);
|
||||
if (matches) {
|
||||
return {
|
||||
top: parseInt(matches[1], 10),
|
||||
right: parseInt(matches[2], 10),
|
||||
bottom: parseInt(matches[3], 10),
|
||||
left: parseInt(matches[4], 10)
|
||||
};
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseBackgroundImages = function() {
|
||||
return this.backgroundImages || (this.backgroundImages = parseBackgrounds(this.css("backgroundImage")));
|
||||
};
|
||||
|
||||
NodeContainer.prototype.cssList = function(property, index) {
|
||||
var value = (this.css(property) || '').split(',');
|
||||
value = value[index || 0] || value[0] || 'auto';
|
||||
value = value.trim().split(' ');
|
||||
if (value.length === 1) {
|
||||
value = [value[0], isPercentage(value[0]) ? 'auto' : value[0]];
|
||||
}
|
||||
return value;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseBackgroundSize = function(bounds, image, index) {
|
||||
var size = this.cssList("backgroundSize", index);
|
||||
var width, height;
|
||||
|
||||
if (isPercentage(size[0])) {
|
||||
width = bounds.width * parseFloat(size[0]) / 100;
|
||||
} else if (/contain|cover/.test(size[0])) {
|
||||
var targetRatio = bounds.width / bounds.height, currentRatio = image.width / image.height;
|
||||
return (targetRatio < currentRatio ^ size[0] === 'contain') ? {width: bounds.height * currentRatio, height: bounds.height} : {width: bounds.width, height: bounds.width / currentRatio};
|
||||
} else {
|
||||
width = parseInt(size[0], 10);
|
||||
}
|
||||
|
||||
if (size[0] === 'auto' && size[1] === 'auto') {
|
||||
height = image.height;
|
||||
} else if (size[1] === 'auto') {
|
||||
height = width / image.width * image.height;
|
||||
} else if (isPercentage(size[1])) {
|
||||
height = bounds.height * parseFloat(size[1]) / 100;
|
||||
} else {
|
||||
height = parseInt(size[1], 10);
|
||||
}
|
||||
|
||||
if (size[0] === 'auto') {
|
||||
width = height / image.height * image.width;
|
||||
}
|
||||
|
||||
return {width: width, height: height};
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseBackgroundPosition = function(bounds, image, index, backgroundSize) {
|
||||
var position = this.cssList('backgroundPosition', index);
|
||||
var left, top;
|
||||
|
||||
if (isPercentage(position[0])){
|
||||
left = (bounds.width - (backgroundSize || image).width) * (parseFloat(position[0]) / 100);
|
||||
} else {
|
||||
left = parseInt(position[0], 10);
|
||||
}
|
||||
|
||||
if (position[1] === 'auto') {
|
||||
top = left / image.width * image.height;
|
||||
} else if (isPercentage(position[1])){
|
||||
top = (bounds.height - (backgroundSize || image).height) * parseFloat(position[1]) / 100;
|
||||
} else {
|
||||
top = parseInt(position[1], 10);
|
||||
}
|
||||
|
||||
if (position[0] === 'auto') {
|
||||
left = top / image.height * image.width;
|
||||
}
|
||||
|
||||
return {left: left, top: top};
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseBackgroundRepeat = function(index) {
|
||||
return this.cssList("backgroundRepeat", index)[0];
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseTextShadows = function() {
|
||||
var textShadow = this.css("textShadow");
|
||||
var results = [];
|
||||
|
||||
if (textShadow && textShadow !== 'none') {
|
||||
var shadows = textShadow.match(this.TEXT_SHADOW_PROPERTY);
|
||||
for (var i = 0; shadows && (i < shadows.length); i++) {
|
||||
var s = shadows[i].match(this.TEXT_SHADOW_VALUES);
|
||||
results.push({
|
||||
color: new Color(s[0]),
|
||||
offsetX: s[1] ? parseFloat(s[1].replace('px', '')) : 0,
|
||||
offsetY: s[2] ? parseFloat(s[2].replace('px', '')) : 0,
|
||||
blur: s[3] ? s[3].replace('px', '') : 0
|
||||
});
|
||||
}
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseTransform = function() {
|
||||
if (!this.transformData) {
|
||||
if (this.hasTransform()) {
|
||||
var offset = this.parseBounds();
|
||||
var origin = this.prefixedCss("transformOrigin").split(" ").map(removePx).map(asFloat);
|
||||
origin[0] += offset.left;
|
||||
origin[1] += offset.top;
|
||||
this.transformData = {
|
||||
origin: origin,
|
||||
matrix: this.parseTransformMatrix()
|
||||
};
|
||||
} else {
|
||||
this.transformData = {
|
||||
origin: [0, 0],
|
||||
matrix: [1, 0, 0, 1, 0, 0]
|
||||
};
|
||||
}
|
||||
}
|
||||
return this.transformData;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseTransformMatrix = function() {
|
||||
if (!this.transformMatrix) {
|
||||
var transform = this.prefixedCss("transform");
|
||||
var matrix = transform ? parseMatrix(transform.match(this.MATRIX_PROPERTY)) : null;
|
||||
this.transformMatrix = matrix ? matrix : [1, 0, 0, 1, 0, 0];
|
||||
}
|
||||
return this.transformMatrix;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.parseBounds = function() {
|
||||
return this.bounds || (this.bounds = this.hasTransform() ? offsetBounds(this.node) : getBounds(this.node));
|
||||
};
|
||||
|
||||
NodeContainer.prototype.hasTransform = function() {
|
||||
return this.parseTransformMatrix().join(",") !== "1,0,0,1,0,0" || (this.parent && this.parent.hasTransform());
|
||||
};
|
||||
|
||||
NodeContainer.prototype.getValue = function() {
|
||||
var value = this.node.value || "";
|
||||
if (this.node.tagName === "SELECT") {
|
||||
value = selectionValue(this.node);
|
||||
} else if (this.node.type === "password") {
|
||||
value = Array(value.length + 1).join('\u2022'); // jshint ignore:line
|
||||
}
|
||||
return value.length === 0 ? (this.node.placeholder || "") : value;
|
||||
};
|
||||
|
||||
NodeContainer.prototype.MATRIX_PROPERTY = /(matrix|matrix3d)\((.+)\)/;
|
||||
NodeContainer.prototype.TEXT_SHADOW_PROPERTY = /((rgba|rgb)\([^\)]+\)(\s-?\d+px){0,})/g;
|
||||
NodeContainer.prototype.TEXT_SHADOW_VALUES = /(-?\d+px)|(#.+)|(rgb\(.+\))|(rgba\(.+\))/g;
|
||||
NodeContainer.prototype.CLIP = /^rect\((\d+)px,? (\d+)px,? (\d+)px,? (\d+)px\)$/;
|
||||
|
||||
function selectionValue(node) {
|
||||
var option = node.options[node.selectedIndex || 0];
|
||||
return option ? (option.text || "") : "";
|
||||
}
|
||||
|
||||
function parseMatrix(match) {
|
||||
if (match && match[1] === "matrix") {
|
||||
return match[2].split(",").map(function(s) {
|
||||
return parseFloat(s.trim());
|
||||
});
|
||||
} else if (match && match[1] === "matrix3d") {
|
||||
var matrix3d = match[2].split(",").map(function(s) {
|
||||
return parseFloat(s.trim());
|
||||
});
|
||||
return [matrix3d[0], matrix3d[1], matrix3d[4], matrix3d[5], matrix3d[12], matrix3d[13]];
|
||||
}
|
||||
}
|
||||
|
||||
function isPercentage(value) {
|
||||
return value.toString().indexOf("%") !== -1;
|
||||
}
|
||||
|
||||
function removePx(str) {
|
||||
return str.replace("px", "");
|
||||
}
|
||||
|
||||
function asFloat(str) {
|
||||
return parseFloat(str);
|
||||
}
|
||||
|
||||
module.exports = NodeContainer;
|
||||
869
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/nodeparser.js
generated
vendored
Normal file
869
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/nodeparser.js
generated
vendored
Normal file
@ -0,0 +1,869 @@
|
||||
var log = require('./log');
|
||||
var punycode = require('punycode');
|
||||
var NodeContainer = require('./nodecontainer');
|
||||
var TextContainer = require('./textcontainer');
|
||||
var PseudoElementContainer = require('./pseudoelementcontainer');
|
||||
var FontMetrics = require('./fontmetrics');
|
||||
var Color = require('./color');
|
||||
var StackingContext = require('./stackingcontext');
|
||||
var utils = require('./utils');
|
||||
var bind = utils.bind;
|
||||
var getBounds = utils.getBounds;
|
||||
var parseBackgrounds = utils.parseBackgrounds;
|
||||
var offsetBounds = utils.offsetBounds;
|
||||
|
||||
function NodeParser(element, renderer, support, imageLoader, options) {
|
||||
log("Starting NodeParser");
|
||||
this.renderer = renderer;
|
||||
this.options = options;
|
||||
this.range = null;
|
||||
this.support = support;
|
||||
this.renderQueue = [];
|
||||
this.stack = new StackingContext(true, 1, element.ownerDocument, null);
|
||||
var parent = new NodeContainer(element, null);
|
||||
if (options.background) {
|
||||
renderer.rectangle(0, 0, renderer.width, renderer.height, new Color(options.background));
|
||||
}
|
||||
if (element === element.ownerDocument.documentElement) {
|
||||
// http://www.w3.org/TR/css3-background/#special-backgrounds
|
||||
var canvasBackground = new NodeContainer(parent.color('backgroundColor').isTransparent() ? element.ownerDocument.body : element.ownerDocument.documentElement, null);
|
||||
renderer.rectangle(0, 0, renderer.width, renderer.height, canvasBackground.color('backgroundColor'));
|
||||
}
|
||||
parent.visibile = parent.isElementVisible();
|
||||
this.createPseudoHideStyles(element.ownerDocument);
|
||||
this.disableAnimations(element.ownerDocument);
|
||||
this.nodes = flatten([parent].concat(this.getChildren(parent)).filter(function(container) {
|
||||
return container.visible = container.isElementVisible();
|
||||
}).map(this.getPseudoElements, this));
|
||||
this.fontMetrics = new FontMetrics();
|
||||
log("Fetched nodes, total:", this.nodes.length);
|
||||
log("Calculate overflow clips");
|
||||
this.calculateOverflowClips();
|
||||
log("Start fetching images");
|
||||
this.images = imageLoader.fetch(this.nodes.filter(isElement));
|
||||
this.ready = this.images.ready.then(bind(function() {
|
||||
log("Images loaded, starting parsing");
|
||||
log("Creating stacking contexts");
|
||||
this.createStackingContexts();
|
||||
log("Sorting stacking contexts");
|
||||
this.sortStackingContexts(this.stack);
|
||||
this.parse(this.stack);
|
||||
log("Render queue created with " + this.renderQueue.length + " items");
|
||||
return new Promise(bind(function(resolve) {
|
||||
if (!options.async) {
|
||||
this.renderQueue.forEach(this.paint, this);
|
||||
resolve();
|
||||
} else if (typeof(options.async) === "function") {
|
||||
options.async.call(this, this.renderQueue, resolve);
|
||||
} else if (this.renderQueue.length > 0){
|
||||
this.renderIndex = 0;
|
||||
this.asyncRenderer(this.renderQueue, resolve);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
}, this));
|
||||
}, this));
|
||||
}
|
||||
|
||||
NodeParser.prototype.calculateOverflowClips = function() {
|
||||
this.nodes.forEach(function(container) {
|
||||
if (isElement(container)) {
|
||||
if (isPseudoElement(container)) {
|
||||
container.appendToDOM();
|
||||
}
|
||||
container.borders = this.parseBorders(container);
|
||||
var clip = (container.css('overflow') === "hidden") ? [container.borders.clip] : [];
|
||||
var cssClip = container.parseClip();
|
||||
if (cssClip && ["absolute", "fixed"].indexOf(container.css('position')) !== -1) {
|
||||
clip.push([["rect",
|
||||
container.bounds.left + cssClip.left,
|
||||
container.bounds.top + cssClip.top,
|
||||
cssClip.right - cssClip.left,
|
||||
cssClip.bottom - cssClip.top
|
||||
]]);
|
||||
}
|
||||
container.clip = hasParentClip(container) ? container.parent.clip.concat(clip) : clip;
|
||||
container.backgroundClip = (container.css('overflow') !== "hidden") ? container.clip.concat([container.borders.clip]) : container.clip;
|
||||
if (isPseudoElement(container)) {
|
||||
container.cleanDOM();
|
||||
}
|
||||
} else if (isTextNode(container)) {
|
||||
container.clip = hasParentClip(container) ? container.parent.clip : [];
|
||||
}
|
||||
if (!isPseudoElement(container)) {
|
||||
container.bounds = null;
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
function hasParentClip(container) {
|
||||
return container.parent && container.parent.clip.length;
|
||||
}
|
||||
|
||||
NodeParser.prototype.asyncRenderer = function(queue, resolve, asyncTimer) {
|
||||
asyncTimer = asyncTimer || Date.now();
|
||||
this.paint(queue[this.renderIndex++]);
|
||||
if (queue.length === this.renderIndex) {
|
||||
resolve();
|
||||
} else if (asyncTimer + 20 > Date.now()) {
|
||||
this.asyncRenderer(queue, resolve, asyncTimer);
|
||||
} else {
|
||||
setTimeout(bind(function() {
|
||||
this.asyncRenderer(queue, resolve);
|
||||
}, this), 0);
|
||||
}
|
||||
};
|
||||
|
||||
NodeParser.prototype.createPseudoHideStyles = function(document) {
|
||||
this.createStyles(document, '.' + PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + ':before { content: "" !important; display: none !important; }' +
|
||||
'.' + PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER + ':after { content: "" !important; display: none !important; }');
|
||||
};
|
||||
|
||||
NodeParser.prototype.disableAnimations = function(document) {
|
||||
this.createStyles(document, '* { -webkit-animation: none !important; -moz-animation: none !important; -o-animation: none !important; animation: none !important; ' +
|
||||
'-webkit-transition: none !important; -moz-transition: none !important; -o-transition: none !important; transition: none !important;}');
|
||||
};
|
||||
|
||||
NodeParser.prototype.createStyles = function(document, styles) {
|
||||
var hidePseudoElements = document.createElement('style');
|
||||
hidePseudoElements.innerHTML = styles;
|
||||
document.body.appendChild(hidePseudoElements);
|
||||
};
|
||||
|
||||
NodeParser.prototype.getPseudoElements = function(container) {
|
||||
var nodes = [[container]];
|
||||
if (container.node.nodeType === Node.ELEMENT_NODE) {
|
||||
var before = this.getPseudoElement(container, ":before");
|
||||
var after = this.getPseudoElement(container, ":after");
|
||||
|
||||
if (before) {
|
||||
nodes.push(before);
|
||||
}
|
||||
|
||||
if (after) {
|
||||
nodes.push(after);
|
||||
}
|
||||
}
|
||||
return flatten(nodes);
|
||||
};
|
||||
|
||||
function toCamelCase(str) {
|
||||
return str.replace(/(\-[a-z])/g, function(match){
|
||||
return match.toUpperCase().replace('-','');
|
||||
});
|
||||
}
|
||||
|
||||
NodeParser.prototype.getPseudoElement = function(container, type) {
|
||||
var style = container.computedStyle(type);
|
||||
if(!style || !style.content || style.content === "none" || style.content === "-moz-alt-content" || style.display === "none") {
|
||||
return null;
|
||||
}
|
||||
|
||||
var content = stripQuotes(style.content);
|
||||
var isImage = content.substr(0, 3) === 'url';
|
||||
var pseudoNode = document.createElement(isImage ? 'img' : 'html2canvaspseudoelement');
|
||||
var pseudoContainer = new PseudoElementContainer(pseudoNode, container, type);
|
||||
|
||||
for (var i = style.length-1; i >= 0; i--) {
|
||||
var property = toCamelCase(style.item(i));
|
||||
pseudoNode.style[property] = style[property];
|
||||
}
|
||||
|
||||
pseudoNode.className = PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE + " " + PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER;
|
||||
|
||||
if (isImage) {
|
||||
pseudoNode.src = parseBackgrounds(content)[0].args[0];
|
||||
return [pseudoContainer];
|
||||
} else {
|
||||
var text = document.createTextNode(content);
|
||||
pseudoNode.appendChild(text);
|
||||
return [pseudoContainer, new TextContainer(text, pseudoContainer)];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
NodeParser.prototype.getChildren = function(parentContainer) {
|
||||
return flatten([].filter.call(parentContainer.node.childNodes, renderableNode).map(function(node) {
|
||||
var container = [node.nodeType === Node.TEXT_NODE ? new TextContainer(node, parentContainer) : new NodeContainer(node, parentContainer)].filter(nonIgnoredElement);
|
||||
return node.nodeType === Node.ELEMENT_NODE && container.length && node.tagName !== "TEXTAREA" ? (container[0].isElementVisible() ? container.concat(this.getChildren(container[0])) : []) : container;
|
||||
}, this));
|
||||
};
|
||||
|
||||
NodeParser.prototype.newStackingContext = function(container, hasOwnStacking) {
|
||||
var stack = new StackingContext(hasOwnStacking, container.getOpacity(), container.node, container.parent);
|
||||
container.cloneTo(stack);
|
||||
var parentStack = hasOwnStacking ? stack.getParentStack(this) : stack.parent.stack;
|
||||
parentStack.contexts.push(stack);
|
||||
container.stack = stack;
|
||||
};
|
||||
|
||||
NodeParser.prototype.createStackingContexts = function() {
|
||||
this.nodes.forEach(function(container) {
|
||||
if (isElement(container) && (this.isRootElement(container) || hasOpacity(container) || isPositionedForStacking(container) || this.isBodyWithTransparentRoot(container) || container.hasTransform())) {
|
||||
this.newStackingContext(container, true);
|
||||
} else if (isElement(container) && ((isPositioned(container) && zIndex0(container)) || isInlineBlock(container) || isFloating(container))) {
|
||||
this.newStackingContext(container, false);
|
||||
} else {
|
||||
container.assignStack(container.parent.stack);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.isBodyWithTransparentRoot = function(container) {
|
||||
return container.node.nodeName === "BODY" && container.parent.color('backgroundColor').isTransparent();
|
||||
};
|
||||
|
||||
NodeParser.prototype.isRootElement = function(container) {
|
||||
return container.parent === null;
|
||||
};
|
||||
|
||||
NodeParser.prototype.sortStackingContexts = function(stack) {
|
||||
stack.contexts.sort(zIndexSort(stack.contexts.slice(0)));
|
||||
stack.contexts.forEach(this.sortStackingContexts, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.parseTextBounds = function(container) {
|
||||
return function(text, index, textList) {
|
||||
if (container.parent.css("textDecoration").substr(0, 4) !== "none" || text.trim().length !== 0) {
|
||||
if (this.support.rangeBounds && !container.parent.hasTransform()) {
|
||||
var offset = textList.slice(0, index).join("").length;
|
||||
return this.getRangeBounds(container.node, offset, text.length);
|
||||
} else if (container.node && typeof(container.node.data) === "string") {
|
||||
var replacementNode = container.node.splitText(text.length);
|
||||
var bounds = this.getWrapperBounds(container.node, container.parent.hasTransform());
|
||||
container.node = replacementNode;
|
||||
return bounds;
|
||||
}
|
||||
} else if(!this.support.rangeBounds || container.parent.hasTransform()){
|
||||
container.node = container.node.splitText(text.length);
|
||||
}
|
||||
return {};
|
||||
};
|
||||
};
|
||||
|
||||
NodeParser.prototype.getWrapperBounds = function(node, transform) {
|
||||
var wrapper = node.ownerDocument.createElement('html2canvaswrapper');
|
||||
var parent = node.parentNode,
|
||||
backupText = node.cloneNode(true);
|
||||
|
||||
wrapper.appendChild(node.cloneNode(true));
|
||||
parent.replaceChild(wrapper, node);
|
||||
var bounds = transform ? offsetBounds(wrapper) : getBounds(wrapper);
|
||||
parent.replaceChild(backupText, wrapper);
|
||||
return bounds;
|
||||
};
|
||||
|
||||
NodeParser.prototype.getRangeBounds = function(node, offset, length) {
|
||||
var range = this.range || (this.range = node.ownerDocument.createRange());
|
||||
range.setStart(node, offset);
|
||||
range.setEnd(node, offset + length);
|
||||
return range.getBoundingClientRect();
|
||||
};
|
||||
|
||||
function ClearTransform() {}
|
||||
|
||||
NodeParser.prototype.parse = function(stack) {
|
||||
// http://www.w3.org/TR/CSS21/visuren.html#z-index
|
||||
var negativeZindex = stack.contexts.filter(negativeZIndex); // 2. the child stacking contexts with negative stack levels (most negative first).
|
||||
var descendantElements = stack.children.filter(isElement);
|
||||
var descendantNonFloats = descendantElements.filter(not(isFloating));
|
||||
var nonInlineNonPositionedDescendants = descendantNonFloats.filter(not(isPositioned)).filter(not(inlineLevel)); // 3 the in-flow, non-inline-level, non-positioned descendants.
|
||||
var nonPositionedFloats = descendantElements.filter(not(isPositioned)).filter(isFloating); // 4. the non-positioned floats.
|
||||
var inFlow = descendantNonFloats.filter(not(isPositioned)).filter(inlineLevel); // 5. the in-flow, inline-level, non-positioned descendants, including inline tables and inline blocks.
|
||||
var stackLevel0 = stack.contexts.concat(descendantNonFloats.filter(isPositioned)).filter(zIndex0); // 6. the child stacking contexts with stack level 0 and the positioned descendants with stack level 0.
|
||||
var text = stack.children.filter(isTextNode).filter(hasText);
|
||||
var positiveZindex = stack.contexts.filter(positiveZIndex); // 7. the child stacking contexts with positive stack levels (least positive first).
|
||||
negativeZindex.concat(nonInlineNonPositionedDescendants).concat(nonPositionedFloats)
|
||||
.concat(inFlow).concat(stackLevel0).concat(text).concat(positiveZindex).forEach(function(container) {
|
||||
this.renderQueue.push(container);
|
||||
if (isStackingContext(container)) {
|
||||
this.parse(container);
|
||||
this.renderQueue.push(new ClearTransform());
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.paint = function(container) {
|
||||
try {
|
||||
if (container instanceof ClearTransform) {
|
||||
this.renderer.ctx.restore();
|
||||
} else if (isTextNode(container)) {
|
||||
if (isPseudoElement(container.parent)) {
|
||||
container.parent.appendToDOM();
|
||||
}
|
||||
this.paintText(container);
|
||||
if (isPseudoElement(container.parent)) {
|
||||
container.parent.cleanDOM();
|
||||
}
|
||||
} else {
|
||||
this.paintNode(container);
|
||||
}
|
||||
} catch(e) {
|
||||
log(e);
|
||||
if (this.options.strict) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintNode = function(container) {
|
||||
if (isStackingContext(container)) {
|
||||
this.renderer.setOpacity(container.opacity);
|
||||
this.renderer.ctx.save();
|
||||
if (container.hasTransform()) {
|
||||
this.renderer.setTransform(container.parseTransform());
|
||||
}
|
||||
}
|
||||
|
||||
if (container.node.nodeName === "INPUT" && container.node.type === "checkbox") {
|
||||
this.paintCheckbox(container);
|
||||
} else if (container.node.nodeName === "INPUT" && container.node.type === "radio") {
|
||||
this.paintRadio(container);
|
||||
} else {
|
||||
this.paintElement(container);
|
||||
}
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintElement = function(container) {
|
||||
var bounds = container.parseBounds();
|
||||
this.renderer.clip(container.backgroundClip, function() {
|
||||
this.renderer.renderBackground(container, bounds, container.borders.borders.map(getWidth));
|
||||
}, this);
|
||||
|
||||
this.renderer.clip(container.clip, function() {
|
||||
this.renderer.renderBorders(container.borders.borders);
|
||||
}, this);
|
||||
|
||||
this.renderer.clip(container.backgroundClip, function() {
|
||||
switch (container.node.nodeName) {
|
||||
case "svg":
|
||||
case "IFRAME":
|
||||
var imgContainer = this.images.get(container.node);
|
||||
if (imgContainer) {
|
||||
this.renderer.renderImage(container, bounds, container.borders, imgContainer);
|
||||
} else {
|
||||
log("Error loading <" + container.node.nodeName + ">", container.node);
|
||||
}
|
||||
break;
|
||||
case "IMG":
|
||||
var imageContainer = this.images.get(container.node.src);
|
||||
if (imageContainer) {
|
||||
this.renderer.renderImage(container, bounds, container.borders, imageContainer);
|
||||
} else {
|
||||
log("Error loading <img>", container.node.src);
|
||||
}
|
||||
break;
|
||||
case "CANVAS":
|
||||
this.renderer.renderImage(container, bounds, container.borders, {image: container.node});
|
||||
break;
|
||||
case "SELECT":
|
||||
case "INPUT":
|
||||
case "TEXTAREA":
|
||||
this.paintFormValue(container);
|
||||
break;
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintCheckbox = function(container) {
|
||||
var b = container.parseBounds();
|
||||
|
||||
var size = Math.min(b.width, b.height);
|
||||
var bounds = {width: size - 1, height: size - 1, top: b.top, left: b.left};
|
||||
var r = [3, 3];
|
||||
var radius = [r, r, r, r];
|
||||
var borders = [1,1,1,1].map(function(w) {
|
||||
return {color: new Color('#A5A5A5'), width: w};
|
||||
});
|
||||
|
||||
var borderPoints = calculateCurvePoints(bounds, radius, borders);
|
||||
|
||||
this.renderer.clip(container.backgroundClip, function() {
|
||||
this.renderer.rectangle(bounds.left + 1, bounds.top + 1, bounds.width - 2, bounds.height - 2, new Color("#DEDEDE"));
|
||||
this.renderer.renderBorders(calculateBorders(borders, bounds, borderPoints, radius));
|
||||
if (container.node.checked) {
|
||||
this.renderer.font(new Color('#424242'), 'normal', 'normal', 'bold', (size - 3) + "px", 'arial');
|
||||
this.renderer.text("\u2714", bounds.left + size / 6, bounds.top + size - 1);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintRadio = function(container) {
|
||||
var bounds = container.parseBounds();
|
||||
|
||||
var size = Math.min(bounds.width, bounds.height) - 2;
|
||||
|
||||
this.renderer.clip(container.backgroundClip, function() {
|
||||
this.renderer.circleStroke(bounds.left + 1, bounds.top + 1, size, new Color('#DEDEDE'), 1, new Color('#A5A5A5'));
|
||||
if (container.node.checked) {
|
||||
this.renderer.circle(Math.ceil(bounds.left + size / 4) + 1, Math.ceil(bounds.top + size / 4) + 1, Math.floor(size / 2), new Color('#424242'));
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintFormValue = function(container) {
|
||||
var value = container.getValue();
|
||||
if (value.length > 0) {
|
||||
var document = container.node.ownerDocument;
|
||||
var wrapper = document.createElement('html2canvaswrapper');
|
||||
var properties = ['lineHeight', 'textAlign', 'fontFamily', 'fontWeight', 'fontSize', 'color',
|
||||
'paddingLeft', 'paddingTop', 'paddingRight', 'paddingBottom',
|
||||
'width', 'height', 'borderLeftStyle', 'borderTopStyle', 'borderLeftWidth', 'borderTopWidth',
|
||||
'boxSizing', 'whiteSpace', 'wordWrap'];
|
||||
|
||||
properties.forEach(function(property) {
|
||||
try {
|
||||
wrapper.style[property] = container.css(property);
|
||||
} catch(e) {
|
||||
// Older IE has issues with "border"
|
||||
log("html2canvas: Parse: Exception caught in renderFormValue: " + e.message);
|
||||
}
|
||||
});
|
||||
var bounds = container.parseBounds();
|
||||
wrapper.style.position = "fixed";
|
||||
wrapper.style.left = bounds.left + "px";
|
||||
wrapper.style.top = bounds.top + "px";
|
||||
wrapper.textContent = value;
|
||||
document.body.appendChild(wrapper);
|
||||
this.paintText(new TextContainer(wrapper.firstChild, container));
|
||||
document.body.removeChild(wrapper);
|
||||
}
|
||||
};
|
||||
|
||||
NodeParser.prototype.paintText = function(container) {
|
||||
container.applyTextTransform();
|
||||
var characters = punycode.ucs2.decode(container.node.data);
|
||||
var textList = (!this.options.letterRendering || noLetterSpacing(container)) && !hasUnicode(container.node.data) ? getWords(characters) : characters.map(function(character) {
|
||||
return punycode.ucs2.encode([character]);
|
||||
});
|
||||
|
||||
var weight = container.parent.fontWeight();
|
||||
var size = container.parent.css('fontSize');
|
||||
var family = container.parent.css('fontFamily');
|
||||
var shadows = container.parent.parseTextShadows();
|
||||
|
||||
this.renderer.font(container.parent.color('color'), container.parent.css('fontStyle'), container.parent.css('fontVariant'), weight, size, family);
|
||||
if (shadows.length) {
|
||||
// TODO: support multiple text shadows
|
||||
this.renderer.fontShadow(shadows[0].color, shadows[0].offsetX, shadows[0].offsetY, shadows[0].blur);
|
||||
} else {
|
||||
this.renderer.clearShadow();
|
||||
}
|
||||
|
||||
this.renderer.clip(container.parent.clip, function() {
|
||||
textList.map(this.parseTextBounds(container), this).forEach(function(bounds, index) {
|
||||
if (bounds) {
|
||||
this.renderer.text(textList[index], bounds.left, bounds.bottom);
|
||||
this.renderTextDecoration(container.parent, bounds, this.fontMetrics.getMetrics(family, size));
|
||||
}
|
||||
}, this);
|
||||
}, this);
|
||||
};
|
||||
|
||||
NodeParser.prototype.renderTextDecoration = function(container, bounds, metrics) {
|
||||
switch(container.css("textDecoration").split(" ")[0]) {
|
||||
case "underline":
|
||||
// Draws a line at the baseline of the font
|
||||
// TODO As some browsers display the line as more than 1px if the font-size is big, need to take that into account both in position and size
|
||||
this.renderer.rectangle(bounds.left, Math.round(bounds.top + metrics.baseline + metrics.lineWidth), bounds.width, 1, container.color("color"));
|
||||
break;
|
||||
case "overline":
|
||||
this.renderer.rectangle(bounds.left, Math.round(bounds.top), bounds.width, 1, container.color("color"));
|
||||
break;
|
||||
case "line-through":
|
||||
// TODO try and find exact position for line-through
|
||||
this.renderer.rectangle(bounds.left, Math.ceil(bounds.top + metrics.middle + metrics.lineWidth), bounds.width, 1, container.color("color"));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
var borderColorTransforms = {
|
||||
inset: [
|
||||
["darken", 0.60],
|
||||
["darken", 0.10],
|
||||
["darken", 0.10],
|
||||
["darken", 0.60]
|
||||
]
|
||||
};
|
||||
|
||||
NodeParser.prototype.parseBorders = function(container) {
|
||||
var nodeBounds = container.parseBounds();
|
||||
var radius = getBorderRadiusData(container);
|
||||
var borders = ["Top", "Right", "Bottom", "Left"].map(function(side, index) {
|
||||
var style = container.css('border' + side + 'Style');
|
||||
var color = container.color('border' + side + 'Color');
|
||||
if (style === "inset" && color.isBlack()) {
|
||||
color = new Color([255, 255, 255, color.a]); // this is wrong, but
|
||||
}
|
||||
var colorTransform = borderColorTransforms[style] ? borderColorTransforms[style][index] : null;
|
||||
return {
|
||||
width: container.cssInt('border' + side + 'Width'),
|
||||
color: colorTransform ? color[colorTransform[0]](colorTransform[1]) : color,
|
||||
args: null
|
||||
};
|
||||
});
|
||||
var borderPoints = calculateCurvePoints(nodeBounds, radius, borders);
|
||||
|
||||
return {
|
||||
clip: this.parseBackgroundClip(container, borderPoints, borders, radius, nodeBounds),
|
||||
borders: calculateBorders(borders, nodeBounds, borderPoints, radius)
|
||||
};
|
||||
};
|
||||
|
||||
function calculateBorders(borders, nodeBounds, borderPoints, radius) {
|
||||
return borders.map(function(border, borderSide) {
|
||||
if (border.width > 0) {
|
||||
var bx = nodeBounds.left;
|
||||
var by = nodeBounds.top;
|
||||
var bw = nodeBounds.width;
|
||||
var bh = nodeBounds.height - (borders[2].width);
|
||||
|
||||
switch(borderSide) {
|
||||
case 0:
|
||||
// top border
|
||||
bh = borders[0].width;
|
||||
border.args = drawSide({
|
||||
c1: [bx, by],
|
||||
c2: [bx + bw, by],
|
||||
c3: [bx + bw - borders[1].width, by + bh],
|
||||
c4: [bx + borders[3].width, by + bh]
|
||||
}, radius[0], radius[1],
|
||||
borderPoints.topLeftOuter, borderPoints.topLeftInner, borderPoints.topRightOuter, borderPoints.topRightInner);
|
||||
break;
|
||||
case 1:
|
||||
// right border
|
||||
bx = nodeBounds.left + nodeBounds.width - (borders[1].width);
|
||||
bw = borders[1].width;
|
||||
|
||||
border.args = drawSide({
|
||||
c1: [bx + bw, by],
|
||||
c2: [bx + bw, by + bh + borders[2].width],
|
||||
c3: [bx, by + bh],
|
||||
c4: [bx, by + borders[0].width]
|
||||
}, radius[1], radius[2],
|
||||
borderPoints.topRightOuter, borderPoints.topRightInner, borderPoints.bottomRightOuter, borderPoints.bottomRightInner);
|
||||
break;
|
||||
case 2:
|
||||
// bottom border
|
||||
by = (by + nodeBounds.height) - (borders[2].width);
|
||||
bh = borders[2].width;
|
||||
border.args = drawSide({
|
||||
c1: [bx + bw, by + bh],
|
||||
c2: [bx, by + bh],
|
||||
c3: [bx + borders[3].width, by],
|
||||
c4: [bx + bw - borders[3].width, by]
|
||||
}, radius[2], radius[3],
|
||||
borderPoints.bottomRightOuter, borderPoints.bottomRightInner, borderPoints.bottomLeftOuter, borderPoints.bottomLeftInner);
|
||||
break;
|
||||
case 3:
|
||||
// left border
|
||||
bw = borders[3].width;
|
||||
border.args = drawSide({
|
||||
c1: [bx, by + bh + borders[2].width],
|
||||
c2: [bx, by],
|
||||
c3: [bx + bw, by + borders[0].width],
|
||||
c4: [bx + bw, by + bh]
|
||||
}, radius[3], radius[0],
|
||||
borderPoints.bottomLeftOuter, borderPoints.bottomLeftInner, borderPoints.topLeftOuter, borderPoints.topLeftInner);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return border;
|
||||
});
|
||||
}
|
||||
|
||||
NodeParser.prototype.parseBackgroundClip = function(container, borderPoints, borders, radius, bounds) {
|
||||
var backgroundClip = container.css('backgroundClip'),
|
||||
borderArgs = [];
|
||||
|
||||
switch(backgroundClip) {
|
||||
case "content-box":
|
||||
case "padding-box":
|
||||
parseCorner(borderArgs, radius[0], radius[1], borderPoints.topLeftInner, borderPoints.topRightInner, bounds.left + borders[3].width, bounds.top + borders[0].width);
|
||||
parseCorner(borderArgs, radius[1], radius[2], borderPoints.topRightInner, borderPoints.bottomRightInner, bounds.left + bounds.width - borders[1].width, bounds.top + borders[0].width);
|
||||
parseCorner(borderArgs, radius[2], radius[3], borderPoints.bottomRightInner, borderPoints.bottomLeftInner, bounds.left + bounds.width - borders[1].width, bounds.top + bounds.height - borders[2].width);
|
||||
parseCorner(borderArgs, radius[3], radius[0], borderPoints.bottomLeftInner, borderPoints.topLeftInner, bounds.left + borders[3].width, bounds.top + bounds.height - borders[2].width);
|
||||
break;
|
||||
|
||||
default:
|
||||
parseCorner(borderArgs, radius[0], radius[1], borderPoints.topLeftOuter, borderPoints.topRightOuter, bounds.left, bounds.top);
|
||||
parseCorner(borderArgs, radius[1], radius[2], borderPoints.topRightOuter, borderPoints.bottomRightOuter, bounds.left + bounds.width, bounds.top);
|
||||
parseCorner(borderArgs, radius[2], radius[3], borderPoints.bottomRightOuter, borderPoints.bottomLeftOuter, bounds.left + bounds.width, bounds.top + bounds.height);
|
||||
parseCorner(borderArgs, radius[3], radius[0], borderPoints.bottomLeftOuter, borderPoints.topLeftOuter, bounds.left, bounds.top + bounds.height);
|
||||
break;
|
||||
}
|
||||
|
||||
return borderArgs;
|
||||
};
|
||||
|
||||
function getCurvePoints(x, y, r1, r2) {
|
||||
var kappa = 4 * ((Math.sqrt(2) - 1) / 3);
|
||||
var ox = (r1) * kappa, // control point offset horizontal
|
||||
oy = (r2) * kappa, // control point offset vertical
|
||||
xm = x + r1, // x-middle
|
||||
ym = y + r2; // y-middle
|
||||
return {
|
||||
topLeft: bezierCurve({x: x, y: ym}, {x: x, y: ym - oy}, {x: xm - ox, y: y}, {x: xm, y: y}),
|
||||
topRight: bezierCurve({x: x, y: y}, {x: x + ox,y: y}, {x: xm, y: ym - oy}, {x: xm, y: ym}),
|
||||
bottomRight: bezierCurve({x: xm, y: y}, {x: xm, y: y + oy}, {x: x + ox, y: ym}, {x: x, y: ym}),
|
||||
bottomLeft: bezierCurve({x: xm, y: ym}, {x: xm - ox, y: ym}, {x: x, y: y + oy}, {x: x, y:y})
|
||||
};
|
||||
}
|
||||
|
||||
function calculateCurvePoints(bounds, borderRadius, borders) {
|
||||
var x = bounds.left,
|
||||
y = bounds.top,
|
||||
width = bounds.width,
|
||||
height = bounds.height,
|
||||
|
||||
tlh = borderRadius[0][0] < width / 2 ? borderRadius[0][0] : width / 2,
|
||||
tlv = borderRadius[0][1] < height / 2 ? borderRadius[0][1] : height / 2,
|
||||
trh = borderRadius[1][0] < width / 2 ? borderRadius[1][0] : width / 2,
|
||||
trv = borderRadius[1][1] < height / 2 ? borderRadius[1][1] : height / 2,
|
||||
brh = borderRadius[2][0] < width / 2 ? borderRadius[2][0] : width / 2,
|
||||
brv = borderRadius[2][1] < height / 2 ? borderRadius[2][1] : height / 2,
|
||||
blh = borderRadius[3][0] < width / 2 ? borderRadius[3][0] : width / 2,
|
||||
blv = borderRadius[3][1] < height / 2 ? borderRadius[3][1] : height / 2;
|
||||
|
||||
var topWidth = width - trh,
|
||||
rightHeight = height - brv,
|
||||
bottomWidth = width - brh,
|
||||
leftHeight = height - blv;
|
||||
|
||||
return {
|
||||
topLeftOuter: getCurvePoints(x, y, tlh, tlv).topLeft.subdivide(0.5),
|
||||
topLeftInner: getCurvePoints(x + borders[3].width, y + borders[0].width, Math.max(0, tlh - borders[3].width), Math.max(0, tlv - borders[0].width)).topLeft.subdivide(0.5),
|
||||
topRightOuter: getCurvePoints(x + topWidth, y, trh, trv).topRight.subdivide(0.5),
|
||||
topRightInner: getCurvePoints(x + Math.min(topWidth, width + borders[3].width), y + borders[0].width, (topWidth > width + borders[3].width) ? 0 :trh - borders[3].width, trv - borders[0].width).topRight.subdivide(0.5),
|
||||
bottomRightOuter: getCurvePoints(x + bottomWidth, y + rightHeight, brh, brv).bottomRight.subdivide(0.5),
|
||||
bottomRightInner: getCurvePoints(x + Math.min(bottomWidth, width - borders[3].width), y + Math.min(rightHeight, height + borders[0].width), Math.max(0, brh - borders[1].width), brv - borders[2].width).bottomRight.subdivide(0.5),
|
||||
bottomLeftOuter: getCurvePoints(x, y + leftHeight, blh, blv).bottomLeft.subdivide(0.5),
|
||||
bottomLeftInner: getCurvePoints(x + borders[3].width, y + leftHeight, Math.max(0, blh - borders[3].width), blv - borders[2].width).bottomLeft.subdivide(0.5)
|
||||
};
|
||||
}
|
||||
|
||||
function bezierCurve(start, startControl, endControl, end) {
|
||||
var lerp = function (a, b, t) {
|
||||
return {
|
||||
x: a.x + (b.x - a.x) * t,
|
||||
y: a.y + (b.y - a.y) * t
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
start: start,
|
||||
startControl: startControl,
|
||||
endControl: endControl,
|
||||
end: end,
|
||||
subdivide: function(t) {
|
||||
var ab = lerp(start, startControl, t),
|
||||
bc = lerp(startControl, endControl, t),
|
||||
cd = lerp(endControl, end, t),
|
||||
abbc = lerp(ab, bc, t),
|
||||
bccd = lerp(bc, cd, t),
|
||||
dest = lerp(abbc, bccd, t);
|
||||
return [bezierCurve(start, ab, abbc, dest), bezierCurve(dest, bccd, cd, end)];
|
||||
},
|
||||
curveTo: function(borderArgs) {
|
||||
borderArgs.push(["bezierCurve", startControl.x, startControl.y, endControl.x, endControl.y, end.x, end.y]);
|
||||
},
|
||||
curveToReversed: function(borderArgs) {
|
||||
borderArgs.push(["bezierCurve", endControl.x, endControl.y, startControl.x, startControl.y, start.x, start.y]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function drawSide(borderData, radius1, radius2, outer1, inner1, outer2, inner2) {
|
||||
var borderArgs = [];
|
||||
|
||||
if (radius1[0] > 0 || radius1[1] > 0) {
|
||||
borderArgs.push(["line", outer1[1].start.x, outer1[1].start.y]);
|
||||
outer1[1].curveTo(borderArgs);
|
||||
} else {
|
||||
borderArgs.push([ "line", borderData.c1[0], borderData.c1[1]]);
|
||||
}
|
||||
|
||||
if (radius2[0] > 0 || radius2[1] > 0) {
|
||||
borderArgs.push(["line", outer2[0].start.x, outer2[0].start.y]);
|
||||
outer2[0].curveTo(borderArgs);
|
||||
borderArgs.push(["line", inner2[0].end.x, inner2[0].end.y]);
|
||||
inner2[0].curveToReversed(borderArgs);
|
||||
} else {
|
||||
borderArgs.push(["line", borderData.c2[0], borderData.c2[1]]);
|
||||
borderArgs.push(["line", borderData.c3[0], borderData.c3[1]]);
|
||||
}
|
||||
|
||||
if (radius1[0] > 0 || radius1[1] > 0) {
|
||||
borderArgs.push(["line", inner1[1].end.x, inner1[1].end.y]);
|
||||
inner1[1].curveToReversed(borderArgs);
|
||||
} else {
|
||||
borderArgs.push(["line", borderData.c4[0], borderData.c4[1]]);
|
||||
}
|
||||
|
||||
return borderArgs;
|
||||
}
|
||||
|
||||
function parseCorner(borderArgs, radius1, radius2, corner1, corner2, x, y) {
|
||||
if (radius1[0] > 0 || radius1[1] > 0) {
|
||||
borderArgs.push(["line", corner1[0].start.x, corner1[0].start.y]);
|
||||
corner1[0].curveTo(borderArgs);
|
||||
corner1[1].curveTo(borderArgs);
|
||||
} else {
|
||||
borderArgs.push(["line", x, y]);
|
||||
}
|
||||
|
||||
if (radius2[0] > 0 || radius2[1] > 0) {
|
||||
borderArgs.push(["line", corner2[0].start.x, corner2[0].start.y]);
|
||||
}
|
||||
}
|
||||
|
||||
function negativeZIndex(container) {
|
||||
return container.cssInt("zIndex") < 0;
|
||||
}
|
||||
|
||||
function positiveZIndex(container) {
|
||||
return container.cssInt("zIndex") > 0;
|
||||
}
|
||||
|
||||
function zIndex0(container) {
|
||||
return container.cssInt("zIndex") === 0;
|
||||
}
|
||||
|
||||
function inlineLevel(container) {
|
||||
return ["inline", "inline-block", "inline-table"].indexOf(container.css("display")) !== -1;
|
||||
}
|
||||
|
||||
function isStackingContext(container) {
|
||||
return (container instanceof StackingContext);
|
||||
}
|
||||
|
||||
function hasText(container) {
|
||||
return container.node.data.trim().length > 0;
|
||||
}
|
||||
|
||||
function noLetterSpacing(container) {
|
||||
return (/^(normal|none|0px)$/.test(container.parent.css("letterSpacing")));
|
||||
}
|
||||
|
||||
function getBorderRadiusData(container) {
|
||||
return ["TopLeft", "TopRight", "BottomRight", "BottomLeft"].map(function(side) {
|
||||
var value = container.css('border' + side + 'Radius');
|
||||
var arr = value.split(" ");
|
||||
if (arr.length <= 1) {
|
||||
arr[1] = arr[0];
|
||||
}
|
||||
return arr.map(asInt);
|
||||
});
|
||||
}
|
||||
|
||||
function renderableNode(node) {
|
||||
return (node.nodeType === Node.TEXT_NODE || node.nodeType === Node.ELEMENT_NODE);
|
||||
}
|
||||
|
||||
function isPositionedForStacking(container) {
|
||||
var position = container.css("position");
|
||||
var zIndex = (["absolute", "relative", "fixed"].indexOf(position) !== -1) ? container.css("zIndex") : "auto";
|
||||
return zIndex !== "auto";
|
||||
}
|
||||
|
||||
function isPositioned(container) {
|
||||
return container.css("position") !== "static";
|
||||
}
|
||||
|
||||
function isFloating(container) {
|
||||
return container.css("float") !== "none";
|
||||
}
|
||||
|
||||
function isInlineBlock(container) {
|
||||
return ["inline-block", "inline-table"].indexOf(container.css("display")) !== -1;
|
||||
}
|
||||
|
||||
function not(callback) {
|
||||
var context = this;
|
||||
return function() {
|
||||
return !callback.apply(context, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
function isElement(container) {
|
||||
return container.node.nodeType === Node.ELEMENT_NODE;
|
||||
}
|
||||
|
||||
function isPseudoElement(container) {
|
||||
return container.isPseudoElement === true;
|
||||
}
|
||||
|
||||
function isTextNode(container) {
|
||||
return container.node.nodeType === Node.TEXT_NODE;
|
||||
}
|
||||
|
||||
function zIndexSort(contexts) {
|
||||
return function(a, b) {
|
||||
return (a.cssInt("zIndex") + (contexts.indexOf(a) / contexts.length)) - (b.cssInt("zIndex") + (contexts.indexOf(b) / contexts.length));
|
||||
};
|
||||
}
|
||||
|
||||
function hasOpacity(container) {
|
||||
return container.getOpacity() < 1;
|
||||
}
|
||||
|
||||
function asInt(value) {
|
||||
return parseInt(value, 10);
|
||||
}
|
||||
|
||||
function getWidth(border) {
|
||||
return border.width;
|
||||
}
|
||||
|
||||
function nonIgnoredElement(nodeContainer) {
|
||||
return (nodeContainer.node.nodeType !== Node.ELEMENT_NODE || ["SCRIPT", "HEAD", "TITLE", "OBJECT", "BR", "OPTION"].indexOf(nodeContainer.node.nodeName) === -1);
|
||||
}
|
||||
|
||||
function flatten(arrays) {
|
||||
return [].concat.apply([], arrays);
|
||||
}
|
||||
|
||||
function stripQuotes(content) {
|
||||
var first = content.substr(0, 1);
|
||||
return (first === content.substr(content.length - 1) && first.match(/'|"/)) ? content.substr(1, content.length - 2) : content;
|
||||
}
|
||||
|
||||
function getWords(characters) {
|
||||
var words = [], i = 0, onWordBoundary = false, word;
|
||||
while(characters.length) {
|
||||
if (isWordBoundary(characters[i]) === onWordBoundary) {
|
||||
word = characters.splice(0, i);
|
||||
if (word.length) {
|
||||
words.push(punycode.ucs2.encode(word));
|
||||
}
|
||||
onWordBoundary =! onWordBoundary;
|
||||
i = 0;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i >= characters.length) {
|
||||
word = characters.splice(0, i);
|
||||
if (word.length) {
|
||||
words.push(punycode.ucs2.encode(word));
|
||||
}
|
||||
}
|
||||
}
|
||||
return words;
|
||||
}
|
||||
|
||||
function isWordBoundary(characterCode) {
|
||||
return [
|
||||
32, // <space>
|
||||
13, // \r
|
||||
10, // \n
|
||||
9, // \t
|
||||
45 // -
|
||||
].indexOf(characterCode) !== -1;
|
||||
}
|
||||
|
||||
function hasUnicode(string) {
|
||||
return (/[^\u0000-\u00ff]/).test(string);
|
||||
}
|
||||
|
||||
module.exports = NodeParser;
|
||||
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/promise.js
generated
vendored
Normal file
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/promise.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
95
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/proxy.js
generated
vendored
Normal file
95
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/proxy.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
var XHR = require('./xhr');
|
||||
var utils = require('./utils');
|
||||
var log = require('./log');
|
||||
var createWindowClone = require('./clone');
|
||||
var decode64 = utils.decode64;
|
||||
|
||||
function Proxy(src, proxyUrl, document) {
|
||||
var supportsCORS = ('withCredentials' in new XMLHttpRequest());
|
||||
if (!proxyUrl) {
|
||||
return Promise.reject("No proxy configured");
|
||||
}
|
||||
var callback = createCallback(supportsCORS);
|
||||
var url = createProxyUrl(proxyUrl, src, callback);
|
||||
|
||||
return supportsCORS ? XHR(url) : (jsonp(document, url, callback).then(function(response) {
|
||||
return decode64(response.content);
|
||||
}));
|
||||
}
|
||||
var proxyCount = 0;
|
||||
|
||||
function ProxyURL(src, proxyUrl, document) {
|
||||
var supportsCORSImage = ('crossOrigin' in new Image());
|
||||
var callback = createCallback(supportsCORSImage);
|
||||
var url = createProxyUrl(proxyUrl, src, callback);
|
||||
return (supportsCORSImage ? Promise.resolve(url) : jsonp(document, url, callback).then(function(response) {
|
||||
return "data:" + response.type + ";base64," + response.content;
|
||||
}));
|
||||
}
|
||||
|
||||
function jsonp(document, url, callback) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var s = document.createElement("script");
|
||||
var cleanup = function() {
|
||||
delete window.html2canvas.proxy[callback];
|
||||
document.body.removeChild(s);
|
||||
};
|
||||
window.html2canvas.proxy[callback] = function(response) {
|
||||
cleanup();
|
||||
resolve(response);
|
||||
};
|
||||
s.src = url;
|
||||
s.onerror = function(e) {
|
||||
cleanup();
|
||||
reject(e);
|
||||
};
|
||||
document.body.appendChild(s);
|
||||
});
|
||||
}
|
||||
|
||||
function createCallback(useCORS) {
|
||||
return !useCORS ? "html2canvas_" + Date.now() + "_" + (++proxyCount) + "_" + Math.round(Math.random() * 100000) : "";
|
||||
}
|
||||
|
||||
function createProxyUrl(proxyUrl, src, callback) {
|
||||
return proxyUrl + "?url=" + encodeURIComponent(src) + (callback.length ? "&callback=html2canvas.proxy." + callback : "");
|
||||
}
|
||||
|
||||
function documentFromHTML(src) {
|
||||
return function(html) {
|
||||
var parser = new DOMParser(), doc;
|
||||
try {
|
||||
doc = parser.parseFromString(html, "text/html");
|
||||
} catch(e) {
|
||||
log("DOMParser not supported, falling back to createHTMLDocument");
|
||||
doc = document.implementation.createHTMLDocument("");
|
||||
try {
|
||||
doc.open();
|
||||
doc.write(html);
|
||||
doc.close();
|
||||
} catch(ee) {
|
||||
log("createHTMLDocument write not supported, falling back to document.body.innerHTML");
|
||||
doc.body.innerHTML = html; // ie9 doesnt support writing to documentElement
|
||||
}
|
||||
}
|
||||
|
||||
var b = doc.querySelector("base");
|
||||
if (!b || !b.href.host) {
|
||||
var base = doc.createElement("base");
|
||||
base.href = src;
|
||||
doc.head.insertBefore(base, doc.head.firstChild);
|
||||
}
|
||||
|
||||
return doc;
|
||||
};
|
||||
}
|
||||
|
||||
function loadUrlDocument(src, proxy, document, width, height, options) {
|
||||
return new Proxy(src, proxy, window.document).then(documentFromHTML(src)).then(function(doc) {
|
||||
return createWindowClone(doc, document, width, height, options, 0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
exports.Proxy = Proxy;
|
||||
exports.ProxyURL = ProxyURL;
|
||||
exports.loadUrlDocument = loadUrlDocument;
|
||||
21
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/proxyimagecontainer.js
generated
vendored
Normal file
21
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/proxyimagecontainer.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
var ProxyURL = require('./proxy').ProxyURL;
|
||||
|
||||
function ProxyImageContainer(src, proxy) {
|
||||
var link = document.createElement("a");
|
||||
link.href = src;
|
||||
src = link.href;
|
||||
this.src = src;
|
||||
this.image = new Image();
|
||||
var self = this;
|
||||
this.promise = new Promise(function(resolve, reject) {
|
||||
self.image.crossOrigin = "Anonymous";
|
||||
self.image.onload = resolve;
|
||||
self.image.onerror = reject;
|
||||
|
||||
new ProxyURL(src, proxy, document).then(function(url) {
|
||||
self.image.src = url;
|
||||
})['catch'](reject);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ProxyImageContainer;
|
||||
38
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/pseudoelementcontainer.js
generated
vendored
Normal file
38
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/pseudoelementcontainer.js
generated
vendored
Normal file
@ -0,0 +1,38 @@
|
||||
var NodeContainer = require('./nodecontainer');
|
||||
|
||||
function PseudoElementContainer(node, parent, type) {
|
||||
NodeContainer.call(this, node, parent);
|
||||
this.isPseudoElement = true;
|
||||
this.before = type === ":before";
|
||||
}
|
||||
|
||||
PseudoElementContainer.prototype.cloneTo = function(stack) {
|
||||
PseudoElementContainer.prototype.cloneTo.call(this, stack);
|
||||
stack.isPseudoElement = true;
|
||||
stack.before = this.before;
|
||||
};
|
||||
|
||||
PseudoElementContainer.prototype = Object.create(NodeContainer.prototype);
|
||||
|
||||
PseudoElementContainer.prototype.appendToDOM = function() {
|
||||
if (this.before) {
|
||||
this.parent.node.insertBefore(this.node, this.parent.node.firstChild);
|
||||
} else {
|
||||
this.parent.node.appendChild(this.node);
|
||||
}
|
||||
this.parent.node.className += " " + this.getHideClass();
|
||||
};
|
||||
|
||||
PseudoElementContainer.prototype.cleanDOM = function() {
|
||||
this.node.parentNode.removeChild(this.node);
|
||||
this.parent.node.className = this.parent.node.className.replace(this.getHideClass(), "");
|
||||
};
|
||||
|
||||
PseudoElementContainer.prototype.getHideClass = function() {
|
||||
return this["PSEUDO_HIDE_ELEMENT_CLASS_" + (this.before ? "BEFORE" : "AFTER")];
|
||||
};
|
||||
|
||||
PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_BEFORE = "___html2canvas___pseudoelement_before";
|
||||
PseudoElementContainer.prototype.PSEUDO_HIDE_ELEMENT_CLASS_AFTER = "___html2canvas___pseudoelement_after";
|
||||
|
||||
module.exports = PseudoElementContainer;
|
||||
108
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/renderer.js
generated
vendored
Normal file
108
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/renderer.js
generated
vendored
Normal file
@ -0,0 +1,108 @@
|
||||
var log = require('./log');
|
||||
|
||||
function Renderer(width, height, images, options, document) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.images = images;
|
||||
this.options = options;
|
||||
this.document = document;
|
||||
}
|
||||
|
||||
Renderer.prototype.renderImage = function(container, bounds, borderData, imageContainer) {
|
||||
var paddingLeft = container.cssInt('paddingLeft'),
|
||||
paddingTop = container.cssInt('paddingTop'),
|
||||
paddingRight = container.cssInt('paddingRight'),
|
||||
paddingBottom = container.cssInt('paddingBottom'),
|
||||
borders = borderData.borders;
|
||||
|
||||
var width = bounds.width - (borders[1].width + borders[3].width + paddingLeft + paddingRight);
|
||||
var height = bounds.height - (borders[0].width + borders[2].width + paddingTop + paddingBottom);
|
||||
this.drawImage(
|
||||
imageContainer,
|
||||
0,
|
||||
0,
|
||||
imageContainer.image.width || width,
|
||||
imageContainer.image.height || height,
|
||||
bounds.left + paddingLeft + borders[3].width,
|
||||
bounds.top + paddingTop + borders[0].width,
|
||||
width,
|
||||
height
|
||||
);
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBackground = function(container, bounds, borderData) {
|
||||
if (bounds.height > 0 && bounds.width > 0) {
|
||||
this.renderBackgroundColor(container, bounds);
|
||||
this.renderBackgroundImage(container, bounds, borderData);
|
||||
}
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBackgroundColor = function(container, bounds) {
|
||||
var color = container.color("backgroundColor");
|
||||
if (!color.isTransparent()) {
|
||||
this.rectangle(bounds.left, bounds.top, bounds.width, bounds.height, color);
|
||||
}
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBorders = function(borders) {
|
||||
borders.forEach(this.renderBorder, this);
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBorder = function(data) {
|
||||
if (!data.color.isTransparent() && data.args !== null) {
|
||||
this.drawShape(data.args, data.color);
|
||||
}
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBackgroundImage = function(container, bounds, borderData) {
|
||||
var backgroundImages = container.parseBackgroundImages();
|
||||
backgroundImages.reverse().forEach(function(backgroundImage, index, arr) {
|
||||
switch(backgroundImage.method) {
|
||||
case "url":
|
||||
var image = this.images.get(backgroundImage.args[0]);
|
||||
if (image) {
|
||||
this.renderBackgroundRepeating(container, bounds, image, arr.length - (index+1), borderData);
|
||||
} else {
|
||||
log("Error loading background-image", backgroundImage.args[0]);
|
||||
}
|
||||
break;
|
||||
case "linear-gradient":
|
||||
case "gradient":
|
||||
var gradientImage = this.images.get(backgroundImage.value);
|
||||
if (gradientImage) {
|
||||
this.renderBackgroundGradient(gradientImage, bounds, borderData);
|
||||
} else {
|
||||
log("Error loading background-image", backgroundImage.args[0]);
|
||||
}
|
||||
break;
|
||||
case "none":
|
||||
break;
|
||||
default:
|
||||
log("Unknown background-image type", backgroundImage.args[0]);
|
||||
}
|
||||
}, this);
|
||||
};
|
||||
|
||||
Renderer.prototype.renderBackgroundRepeating = function(container, bounds, imageContainer, index, borderData) {
|
||||
var size = container.parseBackgroundSize(bounds, imageContainer.image, index);
|
||||
var position = container.parseBackgroundPosition(bounds, imageContainer.image, index, size);
|
||||
var repeat = container.parseBackgroundRepeat(index);
|
||||
switch (repeat) {
|
||||
case "repeat-x":
|
||||
case "repeat no-repeat":
|
||||
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + borderData[3], bounds.top + position.top + borderData[0], 99999, size.height, borderData);
|
||||
break;
|
||||
case "repeat-y":
|
||||
case "no-repeat repeat":
|
||||
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + borderData[0], size.width, 99999, borderData);
|
||||
break;
|
||||
case "no-repeat":
|
||||
this.backgroundRepeatShape(imageContainer, position, size, bounds, bounds.left + position.left + borderData[3], bounds.top + position.top + borderData[0], size.width, size.height, borderData);
|
||||
break;
|
||||
default:
|
||||
this.renderBackgroundRepeat(imageContainer, position, size, {top: bounds.top, left: bounds.left}, borderData[3], borderData[0]);
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Renderer;
|
||||
181
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/renderers/canvas.js
generated
vendored
Normal file
181
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/renderers/canvas.js
generated
vendored
Normal file
@ -0,0 +1,181 @@
|
||||
var Renderer = require('../renderer');
|
||||
var LinearGradientContainer = require('../lineargradientcontainer');
|
||||
var log = require('../log');
|
||||
|
||||
function CanvasRenderer(width, height) {
|
||||
Renderer.apply(this, arguments);
|
||||
this.canvas = this.options.canvas || this.document.createElement("canvas");
|
||||
if (!this.options.canvas) {
|
||||
this.canvas.width = width;
|
||||
this.canvas.height = height;
|
||||
}
|
||||
this.ctx = this.canvas.getContext("2d");
|
||||
this.taintCtx = this.document.createElement("canvas").getContext("2d");
|
||||
this.ctx.textBaseline = "bottom";
|
||||
this.variables = {};
|
||||
log("Initialized CanvasRenderer with size", width, "x", height);
|
||||
}
|
||||
|
||||
CanvasRenderer.prototype = Object.create(Renderer.prototype);
|
||||
|
||||
CanvasRenderer.prototype.setFillStyle = function(fillStyle) {
|
||||
this.ctx.fillStyle = typeof(fillStyle) === "object" && !!fillStyle.isColor ? fillStyle.toString() : fillStyle;
|
||||
return this.ctx;
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.rectangle = function(left, top, width, height, color) {
|
||||
this.setFillStyle(color).fillRect(left, top, width, height);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.circle = function(left, top, size, color) {
|
||||
this.setFillStyle(color);
|
||||
this.ctx.beginPath();
|
||||
this.ctx.arc(left + size / 2, top + size / 2, size / 2, 0, Math.PI*2, true);
|
||||
this.ctx.closePath();
|
||||
this.ctx.fill();
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.circleStroke = function(left, top, size, color, stroke, strokeColor) {
|
||||
this.circle(left, top, size, color);
|
||||
this.ctx.strokeStyle = strokeColor.toString();
|
||||
this.ctx.stroke();
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.drawShape = function(shape, color) {
|
||||
this.shape(shape);
|
||||
this.setFillStyle(color).fill();
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.taints = function(imageContainer) {
|
||||
if (imageContainer.tainted === null) {
|
||||
this.taintCtx.drawImage(imageContainer.image, 0, 0);
|
||||
try {
|
||||
this.taintCtx.getImageData(0, 0, 1, 1);
|
||||
imageContainer.tainted = false;
|
||||
} catch(e) {
|
||||
this.taintCtx = document.createElement("canvas").getContext("2d");
|
||||
imageContainer.tainted = true;
|
||||
}
|
||||
}
|
||||
|
||||
return imageContainer.tainted;
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.drawImage = function(imageContainer, sx, sy, sw, sh, dx, dy, dw, dh) {
|
||||
if (!this.taints(imageContainer) || this.options.allowTaint) {
|
||||
this.ctx.drawImage(imageContainer.image, sx, sy, sw, sh, dx, dy, dw, dh);
|
||||
}
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.clip = function(shapes, callback, context) {
|
||||
this.ctx.save();
|
||||
shapes.filter(hasEntries).forEach(function(shape) {
|
||||
this.shape(shape).clip();
|
||||
}, this);
|
||||
callback.call(context);
|
||||
this.ctx.restore();
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.shape = function(shape) {
|
||||
this.ctx.beginPath();
|
||||
shape.forEach(function(point, index) {
|
||||
if (point[0] === "rect") {
|
||||
this.ctx.rect.apply(this.ctx, point.slice(1));
|
||||
} else {
|
||||
this.ctx[(index === 0) ? "moveTo" : point[0] + "To" ].apply(this.ctx, point.slice(1));
|
||||
}
|
||||
}, this);
|
||||
this.ctx.closePath();
|
||||
return this.ctx;
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.font = function(color, style, variant, weight, size, family) {
|
||||
this.setFillStyle(color).font = [style, variant, weight, size, family].join(" ").split(",")[0];
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.fontShadow = function(color, offsetX, offsetY, blur) {
|
||||
this.setVariable("shadowColor", color.toString())
|
||||
.setVariable("shadowOffsetY", offsetX)
|
||||
.setVariable("shadowOffsetX", offsetY)
|
||||
.setVariable("shadowBlur", blur);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.clearShadow = function() {
|
||||
this.setVariable("shadowColor", "rgba(0,0,0,0)");
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.setOpacity = function(opacity) {
|
||||
this.ctx.globalAlpha = opacity;
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.setTransform = function(transform) {
|
||||
this.ctx.translate(transform.origin[0], transform.origin[1]);
|
||||
this.ctx.transform.apply(this.ctx, transform.matrix);
|
||||
this.ctx.translate(-transform.origin[0], -transform.origin[1]);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.setVariable = function(property, value) {
|
||||
if (this.variables[property] !== value) {
|
||||
this.variables[property] = this.ctx[property] = value;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.text = function(text, left, bottom) {
|
||||
this.ctx.fillText(text, left, bottom);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.backgroundRepeatShape = function(imageContainer, backgroundPosition, size, bounds, left, top, width, height, borderData) {
|
||||
var shape = [
|
||||
["line", Math.round(left), Math.round(top)],
|
||||
["line", Math.round(left + width), Math.round(top)],
|
||||
["line", Math.round(left + width), Math.round(height + top)],
|
||||
["line", Math.round(left), Math.round(height + top)]
|
||||
];
|
||||
this.clip([shape], function() {
|
||||
this.renderBackgroundRepeat(imageContainer, backgroundPosition, size, bounds, borderData[3], borderData[0]);
|
||||
}, this);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.renderBackgroundRepeat = function(imageContainer, backgroundPosition, size, bounds, borderLeft, borderTop) {
|
||||
var offsetX = Math.round(bounds.left + backgroundPosition.left + borderLeft), offsetY = Math.round(bounds.top + backgroundPosition.top + borderTop);
|
||||
this.setFillStyle(this.ctx.createPattern(this.resizeImage(imageContainer, size), "repeat"));
|
||||
this.ctx.translate(offsetX, offsetY);
|
||||
this.ctx.fill();
|
||||
this.ctx.translate(-offsetX, -offsetY);
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.renderBackgroundGradient = function(gradientImage, bounds) {
|
||||
if (gradientImage instanceof LinearGradientContainer) {
|
||||
var gradient = this.ctx.createLinearGradient(
|
||||
bounds.left + bounds.width * gradientImage.x0,
|
||||
bounds.top + bounds.height * gradientImage.y0,
|
||||
bounds.left + bounds.width * gradientImage.x1,
|
||||
bounds.top + bounds.height * gradientImage.y1);
|
||||
gradientImage.colorStops.forEach(function(colorStop) {
|
||||
gradient.addColorStop(colorStop.stop, colorStop.color.toString());
|
||||
});
|
||||
this.rectangle(bounds.left, bounds.top, bounds.width, bounds.height, gradient);
|
||||
}
|
||||
};
|
||||
|
||||
CanvasRenderer.prototype.resizeImage = function(imageContainer, size) {
|
||||
var image = imageContainer.image;
|
||||
if(image.width === size.width && image.height === size.height) {
|
||||
return image;
|
||||
}
|
||||
|
||||
var ctx, canvas = document.createElement('canvas');
|
||||
canvas.width = size.width;
|
||||
canvas.height = size.height;
|
||||
ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, size.width, size.height );
|
||||
return canvas;
|
||||
};
|
||||
|
||||
function hasEntries(array) {
|
||||
return array.length > 0;
|
||||
}
|
||||
|
||||
module.exports = CanvasRenderer;
|
||||
18
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/stackingcontext.js
generated
vendored
Normal file
18
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/stackingcontext.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var NodeContainer = require('./nodecontainer');
|
||||
|
||||
function StackingContext(hasOwnStacking, opacity, element, parent) {
|
||||
NodeContainer.call(this, element, parent);
|
||||
this.ownStacking = hasOwnStacking;
|
||||
this.contexts = [];
|
||||
this.children = [];
|
||||
this.opacity = (this.parent ? this.parent.stack.opacity : 1) * opacity;
|
||||
}
|
||||
|
||||
StackingContext.prototype = Object.create(NodeContainer.prototype);
|
||||
|
||||
StackingContext.prototype.getParentStack = function(context) {
|
||||
var parentStack = (this.parent) ? this.parent.stack : null;
|
||||
return parentStack ? (parentStack.ownStacking ? parentStack : parentStack.getParentStack(context)) : context.stack;
|
||||
};
|
||||
|
||||
module.exports = StackingContext;
|
||||
51
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/support.js
generated
vendored
Normal file
51
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/support.js
generated
vendored
Normal file
@ -0,0 +1,51 @@
|
||||
function Support(document) {
|
||||
this.rangeBounds = this.testRangeBounds(document);
|
||||
this.cors = this.testCORS();
|
||||
this.svg = this.testSVG();
|
||||
}
|
||||
|
||||
Support.prototype.testRangeBounds = function(document) {
|
||||
var range, testElement, rangeBounds, rangeHeight, support = false;
|
||||
|
||||
if (document.createRange) {
|
||||
range = document.createRange();
|
||||
if (range.getBoundingClientRect) {
|
||||
testElement = document.createElement('boundtest');
|
||||
testElement.style.height = "123px";
|
||||
testElement.style.display = "block";
|
||||
document.body.appendChild(testElement);
|
||||
|
||||
range.selectNode(testElement);
|
||||
rangeBounds = range.getBoundingClientRect();
|
||||
rangeHeight = rangeBounds.height;
|
||||
|
||||
if (rangeHeight === 123) {
|
||||
support = true;
|
||||
}
|
||||
document.body.removeChild(testElement);
|
||||
}
|
||||
}
|
||||
|
||||
return support;
|
||||
};
|
||||
|
||||
Support.prototype.testCORS = function() {
|
||||
return typeof((new Image()).crossOrigin) !== "undefined";
|
||||
};
|
||||
|
||||
Support.prototype.testSVG = function() {
|
||||
var img = new Image();
|
||||
var canvas = document.createElement("canvas");
|
||||
var ctx = canvas.getContext("2d");
|
||||
img.src = "data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg'></svg>";
|
||||
|
||||
try {
|
||||
ctx.drawImage(img, 0, 0);
|
||||
canvas.toDataURL();
|
||||
} catch(e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = Support;
|
||||
52
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/svgcontainer.js
generated
vendored
Normal file
52
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/svgcontainer.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
var XHR = require('./xhr');
|
||||
var decode64 = require('./utils').decode64;
|
||||
|
||||
function SVGContainer(src) {
|
||||
this.src = src;
|
||||
this.image = null;
|
||||
var self = this;
|
||||
|
||||
this.promise = this.hasFabric().then(function() {
|
||||
return (self.isInline(src) ? Promise.resolve(self.inlineFormatting(src)) : XHR(src));
|
||||
}).then(function(svg) {
|
||||
return new Promise(function(resolve) {
|
||||
window.html2canvas.svg.fabric.loadSVGFromString(svg, self.createCanvas.call(self, resolve));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SVGContainer.prototype.hasFabric = function() {
|
||||
return !window.html2canvas.svg || !window.html2canvas.svg.fabric ? Promise.reject(new Error("html2canvas.svg.js is not loaded, cannot render svg")) : Promise.resolve();
|
||||
};
|
||||
|
||||
SVGContainer.prototype.inlineFormatting = function(src) {
|
||||
return (/^data:image\/svg\+xml;base64,/.test(src)) ? this.decode64(this.removeContentType(src)) : this.removeContentType(src);
|
||||
};
|
||||
|
||||
SVGContainer.prototype.removeContentType = function(src) {
|
||||
return src.replace(/^data:image\/svg\+xml(;base64)?,/,'');
|
||||
};
|
||||
|
||||
SVGContainer.prototype.isInline = function(src) {
|
||||
return (/^data:image\/svg\+xml/i.test(src));
|
||||
};
|
||||
|
||||
SVGContainer.prototype.createCanvas = function(resolve) {
|
||||
var self = this;
|
||||
return function (objects, options) {
|
||||
var canvas = new window.html2canvas.svg.fabric.StaticCanvas('c');
|
||||
self.image = canvas.lowerCanvasEl;
|
||||
canvas
|
||||
.setWidth(options.width)
|
||||
.setHeight(options.height)
|
||||
.add(window.html2canvas.svg.fabric.util.groupSVGElements(objects, options))
|
||||
.renderAll();
|
||||
resolve(canvas.lowerCanvasEl);
|
||||
};
|
||||
};
|
||||
|
||||
SVGContainer.prototype.decode64 = function(str) {
|
||||
return (typeof(window.atob) === "function") ? window.atob(str) : decode64(str);
|
||||
};
|
||||
|
||||
module.exports = SVGContainer;
|
||||
25
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/svgnodecontainer.js
generated
vendored
Normal file
25
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/svgnodecontainer.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
var SVGContainer = require('./svgcontainer');
|
||||
|
||||
function SVGNodeContainer(node, _native) {
|
||||
this.src = node;
|
||||
this.image = null;
|
||||
var self = this;
|
||||
|
||||
this.promise = _native ? new Promise(function(resolve, reject) {
|
||||
self.image = new Image();
|
||||
self.image.onload = resolve;
|
||||
self.image.onerror = reject;
|
||||
self.image.src = "data:image/svg+xml," + (new XMLSerializer()).serializeToString(node);
|
||||
if (self.image.complete === true) {
|
||||
resolve(self.image);
|
||||
}
|
||||
}) : this.hasFabric().then(function() {
|
||||
return new Promise(function(resolve) {
|
||||
window.html2canvas.svg.fabric.parseSVGDocument(node, self.createCanvas.call(self, resolve));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
SVGNodeContainer.prototype = Object.create(SVGContainer.prototype);
|
||||
|
||||
module.exports = SVGNodeContainer;
|
||||
33
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/textcontainer.js
generated
vendored
Normal file
33
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/textcontainer.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var NodeContainer = require('./nodecontainer');
|
||||
|
||||
function TextContainer(node, parent) {
|
||||
NodeContainer.call(this, node, parent);
|
||||
}
|
||||
|
||||
TextContainer.prototype = Object.create(NodeContainer.prototype);
|
||||
|
||||
TextContainer.prototype.applyTextTransform = function() {
|
||||
this.node.data = this.transform(this.parent.css("textTransform"));
|
||||
};
|
||||
|
||||
TextContainer.prototype.transform = function(transform) {
|
||||
var text = this.node.data;
|
||||
switch(transform){
|
||||
case "lowercase":
|
||||
return text.toLowerCase();
|
||||
case "capitalize":
|
||||
return text.replace(/(^|\s|:|-|\(|\))([a-z])/g, capitalize);
|
||||
case "uppercase":
|
||||
return text.toUpperCase();
|
||||
default:
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
function capitalize(m, p1, p2) {
|
||||
if (m.length > 0) {
|
||||
return p1 + p2.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TextContainer;
|
||||
169
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/utils.js
generated
vendored
Normal file
169
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/utils.js
generated
vendored
Normal file
@ -0,0 +1,169 @@
|
||||
exports.smallImage = function smallImage() {
|
||||
return "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
||||
};
|
||||
|
||||
exports.bind = function(callback, context) {
|
||||
return function() {
|
||||
return callback.apply(context, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* base64-arraybuffer
|
||||
* https://github.com/niklasvh/base64-arraybuffer
|
||||
*
|
||||
* Copyright (c) 2012 Niklas von Hertzen
|
||||
* Licensed under the MIT license.
|
||||
*/
|
||||
|
||||
exports.decode64 = function(base64) {
|
||||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var len = base64.length, i, encoded1, encoded2, encoded3, encoded4, byte1, byte2, byte3;
|
||||
|
||||
var output = "";
|
||||
|
||||
for (i = 0; i < len; i+=4) {
|
||||
encoded1 = chars.indexOf(base64[i]);
|
||||
encoded2 = chars.indexOf(base64[i+1]);
|
||||
encoded3 = chars.indexOf(base64[i+2]);
|
||||
encoded4 = chars.indexOf(base64[i+3]);
|
||||
|
||||
byte1 = (encoded1 << 2) | (encoded2 >> 4);
|
||||
byte2 = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
||||
byte3 = ((encoded3 & 3) << 6) | encoded4;
|
||||
if (encoded3 === 64) {
|
||||
output += String.fromCharCode(byte1);
|
||||
} else if (encoded4 === 64 || encoded4 === -1) {
|
||||
output += String.fromCharCode(byte1, byte2);
|
||||
} else{
|
||||
output += String.fromCharCode(byte1, byte2, byte3);
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
exports.getBounds = function(node) {
|
||||
if (node.getBoundingClientRect) {
|
||||
var clientRect = node.getBoundingClientRect();
|
||||
var width = node.offsetWidth == null ? clientRect.width : node.offsetWidth;
|
||||
return {
|
||||
top: clientRect.top,
|
||||
bottom: clientRect.bottom || (clientRect.top + clientRect.height),
|
||||
right: clientRect.left + width,
|
||||
left: clientRect.left,
|
||||
width: width,
|
||||
height: node.offsetHeight == null ? clientRect.height : node.offsetHeight
|
||||
};
|
||||
}
|
||||
return {};
|
||||
};
|
||||
|
||||
exports.offsetBounds = function(node) {
|
||||
var parent = node.offsetParent ? exports.offsetBounds(node.offsetParent) : {top: 0, left: 0};
|
||||
|
||||
return {
|
||||
top: node.offsetTop + parent.top,
|
||||
bottom: node.offsetTop + node.offsetHeight + parent.top,
|
||||
right: node.offsetLeft + parent.left + node.offsetWidth,
|
||||
left: node.offsetLeft + parent.left,
|
||||
width: node.offsetWidth,
|
||||
height: node.offsetHeight
|
||||
};
|
||||
};
|
||||
|
||||
exports.parseBackgrounds = function(backgroundImage) {
|
||||
var whitespace = ' \r\n\t',
|
||||
method, definition, prefix, prefix_i, block, results = [],
|
||||
mode = 0, numParen = 0, quote, args;
|
||||
var appendResult = function() {
|
||||
if(method) {
|
||||
if (definition.substr(0, 1) === '"') {
|
||||
definition = definition.substr(1, definition.length - 2);
|
||||
}
|
||||
if (definition) {
|
||||
args.push(definition);
|
||||
}
|
||||
if (method.substr(0, 1) === '-' && (prefix_i = method.indexOf('-', 1 ) + 1) > 0) {
|
||||
prefix = method.substr(0, prefix_i);
|
||||
method = method.substr(prefix_i);
|
||||
}
|
||||
results.push({
|
||||
prefix: prefix,
|
||||
method: method.toLowerCase(),
|
||||
value: block,
|
||||
args: args,
|
||||
image: null
|
||||
});
|
||||
}
|
||||
args = [];
|
||||
method = prefix = definition = block = '';
|
||||
};
|
||||
args = [];
|
||||
method = prefix = definition = block = '';
|
||||
backgroundImage.split("").forEach(function(c) {
|
||||
if (mode === 0 && whitespace.indexOf(c) > -1) {
|
||||
return;
|
||||
}
|
||||
switch(c) {
|
||||
case '"':
|
||||
if(!quote) {
|
||||
quote = c;
|
||||
} else if(quote === c) {
|
||||
quote = null;
|
||||
}
|
||||
break;
|
||||
case '(':
|
||||
if(quote) {
|
||||
break;
|
||||
} else if(mode === 0) {
|
||||
mode = 1;
|
||||
block += c;
|
||||
return;
|
||||
} else {
|
||||
numParen++;
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if (quote) {
|
||||
break;
|
||||
} else if(mode === 1) {
|
||||
if(numParen === 0) {
|
||||
mode = 0;
|
||||
block += c;
|
||||
appendResult();
|
||||
return;
|
||||
} else {
|
||||
numParen--;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ',':
|
||||
if (quote) {
|
||||
break;
|
||||
} else if(mode === 0) {
|
||||
appendResult();
|
||||
return;
|
||||
} else if (mode === 1) {
|
||||
if (numParen === 0 && !method.match(/^url$/i)) {
|
||||
args.push(definition);
|
||||
definition = '';
|
||||
block += c;
|
||||
return;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
block += c;
|
||||
if (mode === 0) {
|
||||
method += c;
|
||||
} else {
|
||||
definition += c;
|
||||
}
|
||||
});
|
||||
|
||||
appendResult();
|
||||
return results;
|
||||
};
|
||||
10
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/webkitgradientcontainer.js
generated
vendored
Normal file
10
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/webkitgradientcontainer.js
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
var GradientContainer = require('./gradientcontainer');
|
||||
|
||||
function WebkitGradientContainer(imageData) {
|
||||
GradientContainer.apply(this, arguments);
|
||||
this.type = imageData.args[0] === "linear" ? GradientContainer.TYPES.LINEAR : GradientContainer.TYPES.RADIAL;
|
||||
}
|
||||
|
||||
WebkitGradientContainer.prototype = Object.create(GradientContainer.prototype);
|
||||
|
||||
module.exports = WebkitGradientContainer;
|
||||
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/xhr.js
generated
vendored
Normal file
22
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2canvas/src/xhr.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
function XHR(url) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url);
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status === 200) {
|
||||
resolve(xhr.responseText);
|
||||
} else {
|
||||
reject(new Error(xhr.statusText));
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onerror = function() {
|
||||
reject(new Error("Network Error"));
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = XHR;
|
||||
110
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2pdf.js
generated
vendored
Normal file
110
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/html2pdf.js
generated
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/**
|
||||
* html2pdf.js
|
||||
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
|
||||
*
|
||||
* Licensed under the MIT License.
|
||||
* http://opensource.org/licenses/mit-license
|
||||
*/
|
||||
|
||||
function html2pdf (html,pdf,callback) {
|
||||
var canvas = pdf.canvas;
|
||||
if (!canvas) {
|
||||
alert('jsPDF canvas plugin not installed');
|
||||
return;
|
||||
}
|
||||
canvas.pdf = pdf;
|
||||
pdf.annotations = {
|
||||
|
||||
_nameMap : [],
|
||||
|
||||
createAnnotation : function(href,bounds) {
|
||||
var x = pdf.context2d._wrapX(bounds.left);
|
||||
var y = pdf.context2d._wrapY(bounds.top);
|
||||
var page = pdf.context2d._page(bounds.top);
|
||||
var options;
|
||||
var index = href.indexOf('#');
|
||||
if (index >= 0) {
|
||||
options = {
|
||||
name : href.substring(index + 1)
|
||||
};
|
||||
} else {
|
||||
options = {
|
||||
url : href
|
||||
};
|
||||
}
|
||||
pdf.link(x, y, bounds.right - bounds.left, bounds.bottom - bounds.top, options);
|
||||
},
|
||||
|
||||
setName : function(name,bounds) {
|
||||
var x = pdf.context2d._wrapX(bounds.left);
|
||||
var y = pdf.context2d._wrapY(bounds.top);
|
||||
var page = pdf.context2d._page(bounds.top);
|
||||
this._nameMap[name] = {
|
||||
page : page,
|
||||
x : x,
|
||||
y : y
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
canvas.annotations = pdf.annotations;
|
||||
|
||||
pdf.context2d._pageBreakAt = function(y) {
|
||||
this.pageBreaks.push(y);
|
||||
};
|
||||
|
||||
pdf.context2d._gotoPage = function(pageOneBased) {
|
||||
while (pdf.internal.getNumberOfPages() < pageOneBased) {
|
||||
pdf.addPage();
|
||||
}
|
||||
pdf.setPage(pageOneBased);
|
||||
}
|
||||
|
||||
if (typeof html === 'string') {
|
||||
// remove all scripts
|
||||
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
//iframe.style.width = canvas.width;
|
||||
//iframe.src = "";
|
||||
//iframe.document.domain =
|
||||
document.body.appendChild(iframe);
|
||||
var doc;
|
||||
doc = iframe.contentDocument;
|
||||
if (doc == undefined || doc == null) {
|
||||
doc = iframe.contentWindow.document;
|
||||
}
|
||||
//iframe.setAttribute('style', 'position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
|
||||
|
||||
doc.open();
|
||||
doc.write(html);
|
||||
doc.close();
|
||||
|
||||
var promise = html2canvas(doc.body, {
|
||||
canvas : canvas,
|
||||
onrendered : function(canvas) {
|
||||
if (callback) {
|
||||
if (iframe) {
|
||||
iframe.parentElement.removeChild(iframe);
|
||||
}
|
||||
callback(pdf);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
var body = html;
|
||||
var promise = html2canvas(body, {
|
||||
canvas : canvas,
|
||||
onrendered : function(canvas) {
|
||||
if (callback) {
|
||||
if (iframe) {
|
||||
iframe.parentElement.removeChild(iframe);
|
||||
}
|
||||
callback(pdf);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
469
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/png_support/png.js
generated
vendored
Normal file
469
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/png_support/png.js
generated
vendored
Normal file
@ -0,0 +1,469 @@
|
||||
// Generated by CoffeeScript 1.4.0
|
||||
|
||||
/*
|
||||
# PNG.js
|
||||
# Copyright (c) 2011 Devon Govett
|
||||
# MIT LICENSE
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
# software and associated documentation files (the "Software"), to deal in the Software
|
||||
# without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
# publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
# to whom the Software is furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all copies or
|
||||
# substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
||||
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
(function(global) {
|
||||
var PNG;
|
||||
|
||||
PNG = (function() {
|
||||
var APNG_BLEND_OP_OVER, APNG_BLEND_OP_SOURCE, APNG_DISPOSE_OP_BACKGROUND, APNG_DISPOSE_OP_NONE, APNG_DISPOSE_OP_PREVIOUS, makeImage, scratchCanvas, scratchCtx;
|
||||
|
||||
PNG.load = function(url, canvas, callback) {
|
||||
var xhr,
|
||||
_this = this;
|
||||
if (typeof canvas === 'function') {
|
||||
callback = canvas;
|
||||
}
|
||||
xhr = new XMLHttpRequest;
|
||||
xhr.open("GET", url, true);
|
||||
xhr.responseType = "arraybuffer";
|
||||
xhr.onload = function() {
|
||||
var data, png;
|
||||
data = new Uint8Array(xhr.response || xhr.mozResponseArrayBuffer);
|
||||
png = new PNG(data);
|
||||
if (typeof (canvas != null ? canvas.getContext : void 0) === 'function') {
|
||||
png.render(canvas);
|
||||
}
|
||||
return typeof callback === "function" ? callback(png) : void 0;
|
||||
};
|
||||
return xhr.send(null);
|
||||
};
|
||||
|
||||
APNG_DISPOSE_OP_NONE = 0;
|
||||
|
||||
APNG_DISPOSE_OP_BACKGROUND = 1;
|
||||
|
||||
APNG_DISPOSE_OP_PREVIOUS = 2;
|
||||
|
||||
APNG_BLEND_OP_SOURCE = 0;
|
||||
|
||||
APNG_BLEND_OP_OVER = 1;
|
||||
|
||||
function PNG(data) {
|
||||
var chunkSize, colors, palLen, delayDen, delayNum, frame, i, index, key, section, palShort, text, _i, _j, _ref;
|
||||
this.data = data;
|
||||
this.pos = 8;
|
||||
this.palette = [];
|
||||
this.imgData = [];
|
||||
this.transparency = {};
|
||||
this.animation = null;
|
||||
this.text = {};
|
||||
frame = null;
|
||||
while (true) {
|
||||
chunkSize = this.readUInt32();
|
||||
section = ((function() {
|
||||
var _i, _results;
|
||||
_results = [];
|
||||
for (i = _i = 0; _i < 4; i = ++_i) {
|
||||
_results.push(String.fromCharCode(this.data[this.pos++]));
|
||||
}
|
||||
return _results;
|
||||
}).call(this)).join('');
|
||||
switch (section) {
|
||||
case 'IHDR':
|
||||
this.width = this.readUInt32();
|
||||
this.height = this.readUInt32();
|
||||
this.bits = this.data[this.pos++];
|
||||
this.colorType = this.data[this.pos++];
|
||||
this.compressionMethod = this.data[this.pos++];
|
||||
this.filterMethod = this.data[this.pos++];
|
||||
this.interlaceMethod = this.data[this.pos++];
|
||||
break;
|
||||
case 'acTL':
|
||||
this.animation = {
|
||||
numFrames: this.readUInt32(),
|
||||
numPlays: this.readUInt32() || Infinity,
|
||||
frames: []
|
||||
};
|
||||
break;
|
||||
case 'PLTE':
|
||||
this.palette = this.read(chunkSize);
|
||||
break;
|
||||
case 'fcTL':
|
||||
if (frame) {
|
||||
this.animation.frames.push(frame);
|
||||
}
|
||||
this.pos += 4;
|
||||
frame = {
|
||||
width: this.readUInt32(),
|
||||
height: this.readUInt32(),
|
||||
xOffset: this.readUInt32(),
|
||||
yOffset: this.readUInt32()
|
||||
};
|
||||
delayNum = this.readUInt16();
|
||||
delayDen = this.readUInt16() || 100;
|
||||
frame.delay = 1000 * delayNum / delayDen;
|
||||
frame.disposeOp = this.data[this.pos++];
|
||||
frame.blendOp = this.data[this.pos++];
|
||||
frame.data = [];
|
||||
break;
|
||||
case 'IDAT':
|
||||
case 'fdAT':
|
||||
if (section === 'fdAT') {
|
||||
this.pos += 4;
|
||||
chunkSize -= 4;
|
||||
}
|
||||
data = (frame != null ? frame.data : void 0) || this.imgData;
|
||||
for (i = _i = 0; 0 <= chunkSize ? _i < chunkSize : _i > chunkSize; i = 0 <= chunkSize ? ++_i : --_i) {
|
||||
data.push(this.data[this.pos++]);
|
||||
}
|
||||
break;
|
||||
case 'tRNS':
|
||||
this.transparency = {};
|
||||
switch (this.colorType) {
|
||||
case 3:
|
||||
palLen = this.palette.length/3;
|
||||
this.transparency.indexed = this.read(chunkSize);
|
||||
if(this.transparency.indexed.length > palLen)
|
||||
throw new Error('More transparent colors than palette size');
|
||||
/*
|
||||
* According to the PNG spec trns should be increased to the same size as palette if shorter
|
||||
*/
|
||||
//palShort = 255 - this.transparency.indexed.length;
|
||||
palShort = palLen - this.transparency.indexed.length;
|
||||
if (palShort > 0) {
|
||||
for (i = _j = 0; 0 <= palShort ? _j < palShort : _j > palShort; i = 0 <= palShort ? ++_j : --_j) {
|
||||
this.transparency.indexed.push(255);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
this.transparency.grayscale = this.read(chunkSize)[0];
|
||||
break;
|
||||
case 2:
|
||||
this.transparency.rgb = this.read(chunkSize);
|
||||
}
|
||||
break;
|
||||
case 'tEXt':
|
||||
text = this.read(chunkSize);
|
||||
index = text.indexOf(0);
|
||||
key = String.fromCharCode.apply(String, text.slice(0, index));
|
||||
this.text[key] = String.fromCharCode.apply(String, text.slice(index + 1));
|
||||
break;
|
||||
case 'IEND':
|
||||
if (frame) {
|
||||
this.animation.frames.push(frame);
|
||||
}
|
||||
this.colors = (function() {
|
||||
switch (this.colorType) {
|
||||
case 0:
|
||||
case 3:
|
||||
case 4:
|
||||
return 1;
|
||||
case 2:
|
||||
case 6:
|
||||
return 3;
|
||||
}
|
||||
}).call(this);
|
||||
this.hasAlphaChannel = (_ref = this.colorType) === 4 || _ref === 6;
|
||||
colors = this.colors + (this.hasAlphaChannel ? 1 : 0);
|
||||
this.pixelBitlength = this.bits * colors;
|
||||
this.colorSpace = (function() {
|
||||
switch (this.colors) {
|
||||
case 1:
|
||||
return 'DeviceGray';
|
||||
case 3:
|
||||
return 'DeviceRGB';
|
||||
}
|
||||
}).call(this);
|
||||
this.imgData = new Uint8Array(this.imgData);
|
||||
return;
|
||||
default:
|
||||
this.pos += chunkSize;
|
||||
}
|
||||
this.pos += 4;
|
||||
if (this.pos > this.data.length) {
|
||||
throw new Error("Incomplete or corrupt PNG file");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
PNG.prototype.read = function(bytes) {
|
||||
var i, _i, _results;
|
||||
_results = [];
|
||||
for (i = _i = 0; 0 <= bytes ? _i < bytes : _i > bytes; i = 0 <= bytes ? ++_i : --_i) {
|
||||
_results.push(this.data[this.pos++]);
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
PNG.prototype.readUInt32 = function() {
|
||||
var b1, b2, b3, b4;
|
||||
b1 = this.data[this.pos++] << 24;
|
||||
b2 = this.data[this.pos++] << 16;
|
||||
b3 = this.data[this.pos++] << 8;
|
||||
b4 = this.data[this.pos++];
|
||||
return b1 | b2 | b3 | b4;
|
||||
};
|
||||
|
||||
PNG.prototype.readUInt16 = function() {
|
||||
var b1, b2;
|
||||
b1 = this.data[this.pos++] << 8;
|
||||
b2 = this.data[this.pos++];
|
||||
return b1 | b2;
|
||||
};
|
||||
|
||||
PNG.prototype.decodePixels = function(data) {
|
||||
var abyte, c, col, i, left, length, p, pa, paeth, pb, pc, pixelBytes, pixels, pos, row, scanlineLength, upper, upperLeft, _i, _j, _k, _l, _m;
|
||||
if (data == null) {
|
||||
data = this.imgData;
|
||||
}
|
||||
if (data.length === 0) {
|
||||
return new Uint8Array(0);
|
||||
}
|
||||
data = new FlateStream(data);
|
||||
data = data.getBytes();
|
||||
pixelBytes = this.pixelBitlength / 8;
|
||||
scanlineLength = pixelBytes * this.width;
|
||||
pixels = new Uint8Array(scanlineLength * this.height);
|
||||
length = data.length;
|
||||
row = 0;
|
||||
pos = 0;
|
||||
c = 0;
|
||||
while (pos < length) {
|
||||
switch (data[pos++]) {
|
||||
case 0:
|
||||
for (i = _i = 0; _i < scanlineLength; i = _i += 1) {
|
||||
pixels[c++] = data[pos++];
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
for (i = _j = 0; _j < scanlineLength; i = _j += 1) {
|
||||
abyte = data[pos++];
|
||||
left = i < pixelBytes ? 0 : pixels[c - pixelBytes];
|
||||
pixels[c++] = (abyte + left) % 256;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
for (i = _k = 0; _k < scanlineLength; i = _k += 1) {
|
||||
abyte = data[pos++];
|
||||
col = (i - (i % pixelBytes)) / pixelBytes;
|
||||
upper = row && pixels[(row - 1) * scanlineLength + col * pixelBytes + (i % pixelBytes)];
|
||||
pixels[c++] = (upper + abyte) % 256;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
for (i = _l = 0; _l < scanlineLength; i = _l += 1) {
|
||||
abyte = data[pos++];
|
||||
col = (i - (i % pixelBytes)) / pixelBytes;
|
||||
left = i < pixelBytes ? 0 : pixels[c - pixelBytes];
|
||||
upper = row && pixels[(row - 1) * scanlineLength + col * pixelBytes + (i % pixelBytes)];
|
||||
pixels[c++] = (abyte + Math.floor((left + upper) / 2)) % 256;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
for (i = _m = 0; _m < scanlineLength; i = _m += 1) {
|
||||
abyte = data[pos++];
|
||||
col = (i - (i % pixelBytes)) / pixelBytes;
|
||||
left = i < pixelBytes ? 0 : pixels[c - pixelBytes];
|
||||
if (row === 0) {
|
||||
upper = upperLeft = 0;
|
||||
} else {
|
||||
upper = pixels[(row - 1) * scanlineLength + col * pixelBytes + (i % pixelBytes)];
|
||||
upperLeft = col && pixels[(row - 1) * scanlineLength + (col - 1) * pixelBytes + (i % pixelBytes)];
|
||||
}
|
||||
p = left + upper - upperLeft;
|
||||
pa = Math.abs(p - left);
|
||||
pb = Math.abs(p - upper);
|
||||
pc = Math.abs(p - upperLeft);
|
||||
if (pa <= pb && pa <= pc) {
|
||||
paeth = left;
|
||||
} else if (pb <= pc) {
|
||||
paeth = upper;
|
||||
} else {
|
||||
paeth = upperLeft;
|
||||
}
|
||||
pixels[c++] = (abyte + paeth) % 256;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new Error("Invalid filter algorithm: " + data[pos - 1]);
|
||||
}
|
||||
row++;
|
||||
}
|
||||
return pixels;
|
||||
};
|
||||
|
||||
PNG.prototype.decodePalette = function() {
|
||||
var c, i, length, palette, pos, ret, transparency, _i, _ref, _ref1;
|
||||
palette = this.palette;
|
||||
transparency = this.transparency.indexed || [];
|
||||
ret = new Uint8Array((transparency.length || 0) + palette.length);
|
||||
pos = 0;
|
||||
length = palette.length;
|
||||
c = 0;
|
||||
for (i = _i = 0, _ref = palette.length; _i < _ref; i = _i += 3) {
|
||||
ret[pos++] = palette[i];
|
||||
ret[pos++] = palette[i + 1];
|
||||
ret[pos++] = palette[i + 2];
|
||||
ret[pos++] = (_ref1 = transparency[c++]) != null ? _ref1 : 255;
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
|
||||
PNG.prototype.copyToImageData = function(imageData, pixels) {
|
||||
var alpha, colors, data, i, input, j, k, length, palette, v, _ref;
|
||||
colors = this.colors;
|
||||
palette = null;
|
||||
alpha = this.hasAlphaChannel;
|
||||
if (this.palette.length) {
|
||||
palette = (_ref = this._decodedPalette) != null ? _ref : this._decodedPalette = this.decodePalette();
|
||||
colors = 4;
|
||||
alpha = true;
|
||||
}
|
||||
data = imageData.data || imageData;
|
||||
length = data.length;
|
||||
input = palette || pixels;
|
||||
i = j = 0;
|
||||
if (colors === 1) {
|
||||
while (i < length) {
|
||||
k = palette ? pixels[i / 4] * 4 : j;
|
||||
v = input[k++];
|
||||
data[i++] = v;
|
||||
data[i++] = v;
|
||||
data[i++] = v;
|
||||
data[i++] = alpha ? input[k++] : 255;
|
||||
j = k;
|
||||
}
|
||||
} else {
|
||||
while (i < length) {
|
||||
k = palette ? pixels[i / 4] * 4 : j;
|
||||
data[i++] = input[k++];
|
||||
data[i++] = input[k++];
|
||||
data[i++] = input[k++];
|
||||
data[i++] = alpha ? input[k++] : 255;
|
||||
j = k;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PNG.prototype.decode = function() {
|
||||
var ret;
|
||||
ret = new Uint8Array(this.width * this.height * 4);
|
||||
this.copyToImageData(ret, this.decodePixels());
|
||||
return ret;
|
||||
};
|
||||
|
||||
try {
|
||||
scratchCanvas = global.document.createElement('canvas');
|
||||
scratchCtx = scratchCanvas.getContext('2d');
|
||||
} catch(e) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
makeImage = function(imageData) {
|
||||
var img;
|
||||
scratchCtx.width = imageData.width;
|
||||
scratchCtx.height = imageData.height;
|
||||
scratchCtx.clearRect(0, 0, imageData.width, imageData.height);
|
||||
scratchCtx.putImageData(imageData, 0, 0);
|
||||
img = new Image;
|
||||
img.src = scratchCanvas.toDataURL();
|
||||
return img;
|
||||
};
|
||||
|
||||
PNG.prototype.decodeFrames = function(ctx) {
|
||||
var frame, i, imageData, pixels, _i, _len, _ref, _results;
|
||||
if (!this.animation) {
|
||||
return;
|
||||
}
|
||||
_ref = this.animation.frames;
|
||||
_results = [];
|
||||
for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) {
|
||||
frame = _ref[i];
|
||||
imageData = ctx.createImageData(frame.width, frame.height);
|
||||
pixels = this.decodePixels(new Uint8Array(frame.data));
|
||||
this.copyToImageData(imageData, pixels);
|
||||
frame.imageData = imageData;
|
||||
_results.push(frame.image = makeImage(imageData));
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
||||
PNG.prototype.renderFrame = function(ctx, number) {
|
||||
var frame, frames, prev;
|
||||
frames = this.animation.frames;
|
||||
frame = frames[number];
|
||||
prev = frames[number - 1];
|
||||
if (number === 0) {
|
||||
ctx.clearRect(0, 0, this.width, this.height);
|
||||
}
|
||||
if ((prev != null ? prev.disposeOp : void 0) === APNG_DISPOSE_OP_BACKGROUND) {
|
||||
ctx.clearRect(prev.xOffset, prev.yOffset, prev.width, prev.height);
|
||||
} else if ((prev != null ? prev.disposeOp : void 0) === APNG_DISPOSE_OP_PREVIOUS) {
|
||||
ctx.putImageData(prev.imageData, prev.xOffset, prev.yOffset);
|
||||
}
|
||||
if (frame.blendOp === APNG_BLEND_OP_SOURCE) {
|
||||
ctx.clearRect(frame.xOffset, frame.yOffset, frame.width, frame.height);
|
||||
}
|
||||
return ctx.drawImage(frame.image, frame.xOffset, frame.yOffset);
|
||||
};
|
||||
|
||||
PNG.prototype.animate = function(ctx) {
|
||||
var doFrame, frameNumber, frames, numFrames, numPlays, _ref,
|
||||
_this = this;
|
||||
frameNumber = 0;
|
||||
_ref = this.animation, numFrames = _ref.numFrames, frames = _ref.frames, numPlays = _ref.numPlays;
|
||||
return (doFrame = function() {
|
||||
var f, frame;
|
||||
f = frameNumber++ % numFrames;
|
||||
frame = frames[f];
|
||||
_this.renderFrame(ctx, f);
|
||||
if (numFrames > 1 && frameNumber / numFrames < numPlays) {
|
||||
return _this.animation._timeout = setTimeout(doFrame, frame.delay);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
PNG.prototype.stopAnimation = function() {
|
||||
var _ref;
|
||||
return clearTimeout((_ref = this.animation) != null ? _ref._timeout : void 0);
|
||||
};
|
||||
|
||||
PNG.prototype.render = function(canvas) {
|
||||
var ctx, data;
|
||||
if (canvas._png) {
|
||||
canvas._png.stopAnimation();
|
||||
}
|
||||
canvas._png = this;
|
||||
canvas.width = this.width;
|
||||
canvas.height = this.height;
|
||||
ctx = canvas.getContext("2d");
|
||||
if (this.animation) {
|
||||
this.decodeFrames(ctx);
|
||||
return this.animate(ctx);
|
||||
} else {
|
||||
data = ctx.createImageData(this.width, this.height);
|
||||
this.copyToImageData(data, this.decodePixels());
|
||||
return ctx.putImageData(data, 0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
return PNG;
|
||||
|
||||
})();
|
||||
|
||||
global.PNG = PNG;
|
||||
|
||||
})(typeof window !== "undefined" && window || this);
|
||||
467
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/png_support/zlib.js
generated
vendored
Normal file
467
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/png_support/zlib.js
generated
vendored
Normal file
@ -0,0 +1,467 @@
|
||||
/*
|
||||
* Extracted from pdf.js
|
||||
* https://github.com/andreasgal/pdf.js
|
||||
*
|
||||
* Copyright (c) 2011 Mozilla Foundation
|
||||
*
|
||||
* Contributors: Andreas Gal <gal@mozilla.com>
|
||||
* Chris G Jones <cjones@mozilla.com>
|
||||
* Shaon Barman <shaon.barman@gmail.com>
|
||||
* Vivien Nicolas <21@vingtetun.org>
|
||||
* Justin D'Arcangelo <justindarc@gmail.com>
|
||||
* Yury Delendik
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
var DecodeStream = (function() {
|
||||
function constructor() {
|
||||
this.pos = 0;
|
||||
this.bufferLength = 0;
|
||||
this.eof = false;
|
||||
this.buffer = null;
|
||||
}
|
||||
|
||||
constructor.prototype = {
|
||||
ensureBuffer: function decodestream_ensureBuffer(requested) {
|
||||
var buffer = this.buffer;
|
||||
var current = buffer ? buffer.byteLength : 0;
|
||||
if (requested < current)
|
||||
return buffer;
|
||||
var size = 512;
|
||||
while (size < requested)
|
||||
size <<= 1;
|
||||
var buffer2 = new Uint8Array(size);
|
||||
for (var i = 0; i < current; ++i)
|
||||
buffer2[i] = buffer[i];
|
||||
return this.buffer = buffer2;
|
||||
},
|
||||
getByte: function decodestream_getByte() {
|
||||
var pos = this.pos;
|
||||
while (this.bufferLength <= pos) {
|
||||
if (this.eof)
|
||||
return null;
|
||||
this.readBlock();
|
||||
}
|
||||
return this.buffer[this.pos++];
|
||||
},
|
||||
getBytes: function decodestream_getBytes(length) {
|
||||
var pos = this.pos;
|
||||
|
||||
if (length) {
|
||||
this.ensureBuffer(pos + length);
|
||||
var end = pos + length;
|
||||
|
||||
while (!this.eof && this.bufferLength < end)
|
||||
this.readBlock();
|
||||
|
||||
var bufEnd = this.bufferLength;
|
||||
if (end > bufEnd)
|
||||
end = bufEnd;
|
||||
} else {
|
||||
while (!this.eof)
|
||||
this.readBlock();
|
||||
|
||||
var end = this.bufferLength;
|
||||
}
|
||||
|
||||
this.pos = end;
|
||||
return this.buffer.subarray(pos, end);
|
||||
},
|
||||
lookChar: function decodestream_lookChar() {
|
||||
var pos = this.pos;
|
||||
while (this.bufferLength <= pos) {
|
||||
if (this.eof)
|
||||
return null;
|
||||
this.readBlock();
|
||||
}
|
||||
return String.fromCharCode(this.buffer[this.pos]);
|
||||
},
|
||||
getChar: function decodestream_getChar() {
|
||||
var pos = this.pos;
|
||||
while (this.bufferLength <= pos) {
|
||||
if (this.eof)
|
||||
return null;
|
||||
this.readBlock();
|
||||
}
|
||||
return String.fromCharCode(this.buffer[this.pos++]);
|
||||
},
|
||||
makeSubStream: function decodestream_makeSubstream(start, length, dict) {
|
||||
var end = start + length;
|
||||
while (this.bufferLength <= end && !this.eof)
|
||||
this.readBlock();
|
||||
return new Stream(this.buffer, start, length, dict);
|
||||
},
|
||||
skip: function decodestream_skip(n) {
|
||||
if (!n)
|
||||
n = 1;
|
||||
this.pos += n;
|
||||
},
|
||||
reset: function decodestream_reset() {
|
||||
this.pos = 0;
|
||||
}
|
||||
};
|
||||
|
||||
return constructor;
|
||||
})();
|
||||
|
||||
var FlateStream = (function() {
|
||||
if (typeof Uint32Array === 'undefined') {
|
||||
return undefined;
|
||||
}
|
||||
var codeLenCodeMap = new Uint32Array([
|
||||
16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15
|
||||
]);
|
||||
|
||||
var lengthDecode = new Uint32Array([
|
||||
0x00003, 0x00004, 0x00005, 0x00006, 0x00007, 0x00008, 0x00009, 0x0000a,
|
||||
0x1000b, 0x1000d, 0x1000f, 0x10011, 0x20013, 0x20017, 0x2001b, 0x2001f,
|
||||
0x30023, 0x3002b, 0x30033, 0x3003b, 0x40043, 0x40053, 0x40063, 0x40073,
|
||||
0x50083, 0x500a3, 0x500c3, 0x500e3, 0x00102, 0x00102, 0x00102
|
||||
]);
|
||||
|
||||
var distDecode = new Uint32Array([
|
||||
0x00001, 0x00002, 0x00003, 0x00004, 0x10005, 0x10007, 0x20009, 0x2000d,
|
||||
0x30011, 0x30019, 0x40021, 0x40031, 0x50041, 0x50061, 0x60081, 0x600c1,
|
||||
0x70101, 0x70181, 0x80201, 0x80301, 0x90401, 0x90601, 0xa0801, 0xa0c01,
|
||||
0xb1001, 0xb1801, 0xc2001, 0xc3001, 0xd4001, 0xd6001
|
||||
]);
|
||||
|
||||
var fixedLitCodeTab = [new Uint32Array([
|
||||
0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c0,
|
||||
0x70108, 0x80060, 0x80020, 0x900a0, 0x80000, 0x80080, 0x80040, 0x900e0,
|
||||
0x70104, 0x80058, 0x80018, 0x90090, 0x70114, 0x80078, 0x80038, 0x900d0,
|
||||
0x7010c, 0x80068, 0x80028, 0x900b0, 0x80008, 0x80088, 0x80048, 0x900f0,
|
||||
0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c8,
|
||||
0x7010a, 0x80064, 0x80024, 0x900a8, 0x80004, 0x80084, 0x80044, 0x900e8,
|
||||
0x70106, 0x8005c, 0x8001c, 0x90098, 0x70116, 0x8007c, 0x8003c, 0x900d8,
|
||||
0x7010e, 0x8006c, 0x8002c, 0x900b8, 0x8000c, 0x8008c, 0x8004c, 0x900f8,
|
||||
0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c4,
|
||||
0x70109, 0x80062, 0x80022, 0x900a4, 0x80002, 0x80082, 0x80042, 0x900e4,
|
||||
0x70105, 0x8005a, 0x8001a, 0x90094, 0x70115, 0x8007a, 0x8003a, 0x900d4,
|
||||
0x7010d, 0x8006a, 0x8002a, 0x900b4, 0x8000a, 0x8008a, 0x8004a, 0x900f4,
|
||||
0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cc,
|
||||
0x7010b, 0x80066, 0x80026, 0x900ac, 0x80006, 0x80086, 0x80046, 0x900ec,
|
||||
0x70107, 0x8005e, 0x8001e, 0x9009c, 0x70117, 0x8007e, 0x8003e, 0x900dc,
|
||||
0x7010f, 0x8006e, 0x8002e, 0x900bc, 0x8000e, 0x8008e, 0x8004e, 0x900fc,
|
||||
0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c2,
|
||||
0x70108, 0x80061, 0x80021, 0x900a2, 0x80001, 0x80081, 0x80041, 0x900e2,
|
||||
0x70104, 0x80059, 0x80019, 0x90092, 0x70114, 0x80079, 0x80039, 0x900d2,
|
||||
0x7010c, 0x80069, 0x80029, 0x900b2, 0x80009, 0x80089, 0x80049, 0x900f2,
|
||||
0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900ca,
|
||||
0x7010a, 0x80065, 0x80025, 0x900aa, 0x80005, 0x80085, 0x80045, 0x900ea,
|
||||
0x70106, 0x8005d, 0x8001d, 0x9009a, 0x70116, 0x8007d, 0x8003d, 0x900da,
|
||||
0x7010e, 0x8006d, 0x8002d, 0x900ba, 0x8000d, 0x8008d, 0x8004d, 0x900fa,
|
||||
0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c6,
|
||||
0x70109, 0x80063, 0x80023, 0x900a6, 0x80003, 0x80083, 0x80043, 0x900e6,
|
||||
0x70105, 0x8005b, 0x8001b, 0x90096, 0x70115, 0x8007b, 0x8003b, 0x900d6,
|
||||
0x7010d, 0x8006b, 0x8002b, 0x900b6, 0x8000b, 0x8008b, 0x8004b, 0x900f6,
|
||||
0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900ce,
|
||||
0x7010b, 0x80067, 0x80027, 0x900ae, 0x80007, 0x80087, 0x80047, 0x900ee,
|
||||
0x70107, 0x8005f, 0x8001f, 0x9009e, 0x70117, 0x8007f, 0x8003f, 0x900de,
|
||||
0x7010f, 0x8006f, 0x8002f, 0x900be, 0x8000f, 0x8008f, 0x8004f, 0x900fe,
|
||||
0x70100, 0x80050, 0x80010, 0x80118, 0x70110, 0x80070, 0x80030, 0x900c1,
|
||||
0x70108, 0x80060, 0x80020, 0x900a1, 0x80000, 0x80080, 0x80040, 0x900e1,
|
||||
0x70104, 0x80058, 0x80018, 0x90091, 0x70114, 0x80078, 0x80038, 0x900d1,
|
||||
0x7010c, 0x80068, 0x80028, 0x900b1, 0x80008, 0x80088, 0x80048, 0x900f1,
|
||||
0x70102, 0x80054, 0x80014, 0x8011c, 0x70112, 0x80074, 0x80034, 0x900c9,
|
||||
0x7010a, 0x80064, 0x80024, 0x900a9, 0x80004, 0x80084, 0x80044, 0x900e9,
|
||||
0x70106, 0x8005c, 0x8001c, 0x90099, 0x70116, 0x8007c, 0x8003c, 0x900d9,
|
||||
0x7010e, 0x8006c, 0x8002c, 0x900b9, 0x8000c, 0x8008c, 0x8004c, 0x900f9,
|
||||
0x70101, 0x80052, 0x80012, 0x8011a, 0x70111, 0x80072, 0x80032, 0x900c5,
|
||||
0x70109, 0x80062, 0x80022, 0x900a5, 0x80002, 0x80082, 0x80042, 0x900e5,
|
||||
0x70105, 0x8005a, 0x8001a, 0x90095, 0x70115, 0x8007a, 0x8003a, 0x900d5,
|
||||
0x7010d, 0x8006a, 0x8002a, 0x900b5, 0x8000a, 0x8008a, 0x8004a, 0x900f5,
|
||||
0x70103, 0x80056, 0x80016, 0x8011e, 0x70113, 0x80076, 0x80036, 0x900cd,
|
||||
0x7010b, 0x80066, 0x80026, 0x900ad, 0x80006, 0x80086, 0x80046, 0x900ed,
|
||||
0x70107, 0x8005e, 0x8001e, 0x9009d, 0x70117, 0x8007e, 0x8003e, 0x900dd,
|
||||
0x7010f, 0x8006e, 0x8002e, 0x900bd, 0x8000e, 0x8008e, 0x8004e, 0x900fd,
|
||||
0x70100, 0x80051, 0x80011, 0x80119, 0x70110, 0x80071, 0x80031, 0x900c3,
|
||||
0x70108, 0x80061, 0x80021, 0x900a3, 0x80001, 0x80081, 0x80041, 0x900e3,
|
||||
0x70104, 0x80059, 0x80019, 0x90093, 0x70114, 0x80079, 0x80039, 0x900d3,
|
||||
0x7010c, 0x80069, 0x80029, 0x900b3, 0x80009, 0x80089, 0x80049, 0x900f3,
|
||||
0x70102, 0x80055, 0x80015, 0x8011d, 0x70112, 0x80075, 0x80035, 0x900cb,
|
||||
0x7010a, 0x80065, 0x80025, 0x900ab, 0x80005, 0x80085, 0x80045, 0x900eb,
|
||||
0x70106, 0x8005d, 0x8001d, 0x9009b, 0x70116, 0x8007d, 0x8003d, 0x900db,
|
||||
0x7010e, 0x8006d, 0x8002d, 0x900bb, 0x8000d, 0x8008d, 0x8004d, 0x900fb,
|
||||
0x70101, 0x80053, 0x80013, 0x8011b, 0x70111, 0x80073, 0x80033, 0x900c7,
|
||||
0x70109, 0x80063, 0x80023, 0x900a7, 0x80003, 0x80083, 0x80043, 0x900e7,
|
||||
0x70105, 0x8005b, 0x8001b, 0x90097, 0x70115, 0x8007b, 0x8003b, 0x900d7,
|
||||
0x7010d, 0x8006b, 0x8002b, 0x900b7, 0x8000b, 0x8008b, 0x8004b, 0x900f7,
|
||||
0x70103, 0x80057, 0x80017, 0x8011f, 0x70113, 0x80077, 0x80037, 0x900cf,
|
||||
0x7010b, 0x80067, 0x80027, 0x900af, 0x80007, 0x80087, 0x80047, 0x900ef,
|
||||
0x70107, 0x8005f, 0x8001f, 0x9009f, 0x70117, 0x8007f, 0x8003f, 0x900df,
|
||||
0x7010f, 0x8006f, 0x8002f, 0x900bf, 0x8000f, 0x8008f, 0x8004f, 0x900ff
|
||||
]), 9];
|
||||
|
||||
var fixedDistCodeTab = [new Uint32Array([
|
||||
0x50000, 0x50010, 0x50008, 0x50018, 0x50004, 0x50014, 0x5000c, 0x5001c,
|
||||
0x50002, 0x50012, 0x5000a, 0x5001a, 0x50006, 0x50016, 0x5000e, 0x00000,
|
||||
0x50001, 0x50011, 0x50009, 0x50019, 0x50005, 0x50015, 0x5000d, 0x5001d,
|
||||
0x50003, 0x50013, 0x5000b, 0x5001b, 0x50007, 0x50017, 0x5000f, 0x00000
|
||||
]), 5];
|
||||
|
||||
function error(e) {
|
||||
throw new Error(e)
|
||||
}
|
||||
|
||||
function constructor(bytes) {
|
||||
//var bytes = stream.getBytes();
|
||||
var bytesPos = 0;
|
||||
|
||||
var cmf = bytes[bytesPos++];
|
||||
var flg = bytes[bytesPos++];
|
||||
if (cmf == -1 || flg == -1)
|
||||
error('Invalid header in flate stream');
|
||||
if ((cmf & 0x0f) != 0x08)
|
||||
error('Unknown compression method in flate stream');
|
||||
if ((((cmf << 8) + flg) % 31) != 0)
|
||||
error('Bad FCHECK in flate stream');
|
||||
if (flg & 0x20)
|
||||
error('FDICT bit set in flate stream');
|
||||
|
||||
this.bytes = bytes;
|
||||
this.bytesPos = bytesPos;
|
||||
|
||||
this.codeSize = 0;
|
||||
this.codeBuf = 0;
|
||||
|
||||
DecodeStream.call(this);
|
||||
}
|
||||
|
||||
constructor.prototype = Object.create(DecodeStream.prototype);
|
||||
|
||||
constructor.prototype.getBits = function(bits) {
|
||||
var codeSize = this.codeSize;
|
||||
var codeBuf = this.codeBuf;
|
||||
var bytes = this.bytes;
|
||||
var bytesPos = this.bytesPos;
|
||||
|
||||
var b;
|
||||
while (codeSize < bits) {
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad encoding in flate stream');
|
||||
codeBuf |= b << codeSize;
|
||||
codeSize += 8;
|
||||
}
|
||||
b = codeBuf & ((1 << bits) - 1);
|
||||
this.codeBuf = codeBuf >> bits;
|
||||
this.codeSize = codeSize -= bits;
|
||||
this.bytesPos = bytesPos;
|
||||
return b;
|
||||
};
|
||||
|
||||
constructor.prototype.getCode = function(table) {
|
||||
var codes = table[0];
|
||||
var maxLen = table[1];
|
||||
var codeSize = this.codeSize;
|
||||
var codeBuf = this.codeBuf;
|
||||
var bytes = this.bytes;
|
||||
var bytesPos = this.bytesPos;
|
||||
|
||||
while (codeSize < maxLen) {
|
||||
var b;
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad encoding in flate stream');
|
||||
codeBuf |= (b << codeSize);
|
||||
codeSize += 8;
|
||||
}
|
||||
var code = codes[codeBuf & ((1 << maxLen) - 1)];
|
||||
var codeLen = code >> 16;
|
||||
var codeVal = code & 0xffff;
|
||||
if (codeSize == 0 || codeSize < codeLen || codeLen == 0)
|
||||
error('Bad encoding in flate stream');
|
||||
this.codeBuf = (codeBuf >> codeLen);
|
||||
this.codeSize = (codeSize - codeLen);
|
||||
this.bytesPos = bytesPos;
|
||||
return codeVal;
|
||||
};
|
||||
|
||||
constructor.prototype.generateHuffmanTable = function(lengths) {
|
||||
var n = lengths.length;
|
||||
|
||||
// find max code length
|
||||
var maxLen = 0;
|
||||
for (var i = 0; i < n; ++i) {
|
||||
if (lengths[i] > maxLen)
|
||||
maxLen = lengths[i];
|
||||
}
|
||||
|
||||
// build the table
|
||||
var size = 1 << maxLen;
|
||||
var codes = new Uint32Array(size);
|
||||
for (var len = 1, code = 0, skip = 2;
|
||||
len <= maxLen;
|
||||
++len, code <<= 1, skip <<= 1) {
|
||||
for (var val = 0; val < n; ++val) {
|
||||
if (lengths[val] == len) {
|
||||
// bit-reverse the code
|
||||
var code2 = 0;
|
||||
var t = code;
|
||||
for (var i = 0; i < len; ++i) {
|
||||
code2 = (code2 << 1) | (t & 1);
|
||||
t >>= 1;
|
||||
}
|
||||
|
||||
// fill the table entries
|
||||
for (var i = code2; i < size; i += skip)
|
||||
codes[i] = (len << 16) | val;
|
||||
|
||||
++code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return [codes, maxLen];
|
||||
};
|
||||
|
||||
constructor.prototype.readBlock = function() {
|
||||
function repeat(stream, array, len, offset, what) {
|
||||
var repeat = stream.getBits(len) + offset;
|
||||
while (repeat-- > 0)
|
||||
array[i++] = what;
|
||||
}
|
||||
|
||||
// read block header
|
||||
var hdr = this.getBits(3);
|
||||
if (hdr & 1)
|
||||
this.eof = true;
|
||||
hdr >>= 1;
|
||||
|
||||
if (hdr == 0) { // uncompressed block
|
||||
var bytes = this.bytes;
|
||||
var bytesPos = this.bytesPos;
|
||||
var b;
|
||||
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad block header in flate stream');
|
||||
var blockLen = b;
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad block header in flate stream');
|
||||
blockLen |= (b << 8);
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad block header in flate stream');
|
||||
var check = b;
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined')
|
||||
error('Bad block header in flate stream');
|
||||
check |= (b << 8);
|
||||
if (check != (~blockLen & 0xffff))
|
||||
error('Bad uncompressed block length in flate stream');
|
||||
|
||||
this.codeBuf = 0;
|
||||
this.codeSize = 0;
|
||||
|
||||
var bufferLength = this.bufferLength;
|
||||
var buffer = this.ensureBuffer(bufferLength + blockLen);
|
||||
var end = bufferLength + blockLen;
|
||||
this.bufferLength = end;
|
||||
for (var n = bufferLength; n < end; ++n) {
|
||||
if (typeof (b = bytes[bytesPos++]) == 'undefined') {
|
||||
this.eof = true;
|
||||
break;
|
||||
}
|
||||
buffer[n] = b;
|
||||
}
|
||||
this.bytesPos = bytesPos;
|
||||
return;
|
||||
}
|
||||
|
||||
var litCodeTable;
|
||||
var distCodeTable;
|
||||
if (hdr == 1) { // compressed block, fixed codes
|
||||
litCodeTable = fixedLitCodeTab;
|
||||
distCodeTable = fixedDistCodeTab;
|
||||
} else if (hdr == 2) { // compressed block, dynamic codes
|
||||
var numLitCodes = this.getBits(5) + 257;
|
||||
var numDistCodes = this.getBits(5) + 1;
|
||||
var numCodeLenCodes = this.getBits(4) + 4;
|
||||
|
||||
// build the code lengths code table
|
||||
var codeLenCodeLengths = Array(codeLenCodeMap.length);
|
||||
var i = 0;
|
||||
while (i < numCodeLenCodes)
|
||||
codeLenCodeLengths[codeLenCodeMap[i++]] = this.getBits(3);
|
||||
var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
|
||||
|
||||
// build the literal and distance code tables
|
||||
var len = 0;
|
||||
var i = 0;
|
||||
var codes = numLitCodes + numDistCodes;
|
||||
var codeLengths = new Array(codes);
|
||||
while (i < codes) {
|
||||
var code = this.getCode(codeLenCodeTab);
|
||||
if (code == 16) {
|
||||
repeat(this, codeLengths, 2, 3, len);
|
||||
} else if (code == 17) {
|
||||
repeat(this, codeLengths, 3, 3, len = 0);
|
||||
} else if (code == 18) {
|
||||
repeat(this, codeLengths, 7, 11, len = 0);
|
||||
} else {
|
||||
codeLengths[i++] = len = code;
|
||||
}
|
||||
}
|
||||
|
||||
litCodeTable =
|
||||
this.generateHuffmanTable(codeLengths.slice(0, numLitCodes));
|
||||
distCodeTable =
|
||||
this.generateHuffmanTable(codeLengths.slice(numLitCodes, codes));
|
||||
} else {
|
||||
error('Unknown block type in flate stream');
|
||||
}
|
||||
|
||||
var buffer = this.buffer;
|
||||
var limit = buffer ? buffer.length : 0;
|
||||
var pos = this.bufferLength;
|
||||
while (true) {
|
||||
var code1 = this.getCode(litCodeTable);
|
||||
if (code1 < 256) {
|
||||
if (pos + 1 >= limit) {
|
||||
buffer = this.ensureBuffer(pos + 1);
|
||||
limit = buffer.length;
|
||||
}
|
||||
buffer[pos++] = code1;
|
||||
continue;
|
||||
}
|
||||
if (code1 == 256) {
|
||||
this.bufferLength = pos;
|
||||
return;
|
||||
}
|
||||
code1 -= 257;
|
||||
code1 = lengthDecode[code1];
|
||||
var code2 = code1 >> 16;
|
||||
if (code2 > 0)
|
||||
code2 = this.getBits(code2);
|
||||
var len = (code1 & 0xffff) + code2;
|
||||
code1 = this.getCode(distCodeTable);
|
||||
code1 = distDecode[code1];
|
||||
code2 = code1 >> 16;
|
||||
if (code2 > 0)
|
||||
code2 = this.getBits(code2);
|
||||
var dist = (code1 & 0xffff) + code2;
|
||||
if (pos + len >= limit) {
|
||||
buffer = this.ensureBuffer(pos + len);
|
||||
limit = buffer.length;
|
||||
}
|
||||
for (var k = 0; k < len; ++k, ++pos)
|
||||
buffer[pos] = buffer[pos - dist];
|
||||
}
|
||||
};
|
||||
|
||||
return constructor;
|
||||
})();
|
||||
196
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/polyfill.js
generated
vendored
Normal file
196
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/polyfill.js
generated
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
/**
|
||||
* JavaScript Polyfill functions for jsPDF
|
||||
* Collected from public resources by
|
||||
* https://github.com/diegocr
|
||||
*/
|
||||
|
||||
(function (global) {
|
||||
var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
|
||||
if (typeof global.btoa === 'undefined') {
|
||||
global.btoa = function(data) {
|
||||
// discuss at: http://phpjs.org/functions/base64_encode/
|
||||
// original by: Tyler Akins (http://rumkin.com)
|
||||
// improved by: Bayron Guevara
|
||||
// improved by: Thunder.m
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// improved by: Rafal Kukawski (http://kukawski.pl)
|
||||
// bugfixed by: Pellentesque Malesuada
|
||||
// example 1: base64_encode('Kevin van Zonneveld');
|
||||
// returns 1: 'S2V2aW4gdmFuIFpvbm5ldmVsZA=='
|
||||
|
||||
var o1,o2,o3,h1,h2,h3,h4,bits,i = 0,ac = 0,enc = '',tmp_arr = [];
|
||||
|
||||
if (!data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
do { // pack three octets into four hexets
|
||||
o1 = data.charCodeAt(i++);
|
||||
o2 = data.charCodeAt(i++);
|
||||
o3 = data.charCodeAt(i++);
|
||||
|
||||
bits = o1 << 16 | o2 << 8 | o3;
|
||||
|
||||
h1 = bits >> 18 & 0x3f;
|
||||
h2 = bits >> 12 & 0x3f;
|
||||
h3 = bits >> 6 & 0x3f;
|
||||
h4 = bits & 0x3f;
|
||||
|
||||
// use hexets to index into b64, and append result to encoded string
|
||||
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
|
||||
} while (i < data.length);
|
||||
|
||||
enc = tmp_arr.join('');
|
||||
|
||||
var r = data.length % 3;
|
||||
|
||||
return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3);
|
||||
};
|
||||
}
|
||||
|
||||
if (typeof global.atob === 'undefined') {
|
||||
global.atob = function(data) {
|
||||
// discuss at: http://phpjs.org/functions/base64_decode/
|
||||
// original by: Tyler Akins (http://rumkin.com)
|
||||
// improved by: Thunder.m
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// input by: Aman Gupta
|
||||
// input by: Brett Zamir (http://brett-zamir.me)
|
||||
// bugfixed by: Onno Marsman
|
||||
// bugfixed by: Pellentesque Malesuada
|
||||
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// example 1: base64_decode('S2V2aW4gdmFuIFpvbm5ldmVsZA==');
|
||||
// returns 1: 'Kevin van Zonneveld'
|
||||
|
||||
var o1,o2,o3,h1,h2,h3,h4,bits,i = 0,ac = 0,dec = '',tmp_arr = [];
|
||||
|
||||
if (!data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
data += '';
|
||||
|
||||
do { // unpack four hexets into three octets using index points in b64
|
||||
h1 = b64.indexOf(data.charAt(i++));
|
||||
h2 = b64.indexOf(data.charAt(i++));
|
||||
h3 = b64.indexOf(data.charAt(i++));
|
||||
h4 = b64.indexOf(data.charAt(i++));
|
||||
|
||||
bits = h1 << 18 | h2 << 12 | h3 << 6 | h4;
|
||||
|
||||
o1 = bits >> 16 & 0xff;
|
||||
o2 = bits >> 8 & 0xff;
|
||||
o3 = bits & 0xff;
|
||||
|
||||
if (h3 == 64) {
|
||||
tmp_arr[ac++] = String.fromCharCode(o1);
|
||||
} else if (h4 == 64) {
|
||||
tmp_arr[ac++] = String.fromCharCode(o1, o2);
|
||||
} else {
|
||||
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
|
||||
}
|
||||
} while (i < data.length);
|
||||
|
||||
dec = tmp_arr.join('');
|
||||
|
||||
return dec;
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.prototype.map) {
|
||||
Array.prototype.map = function(fun /*, thisArg */) {
|
||||
if (this === void 0 || this === null || typeof fun !== "function")
|
||||
throw new TypeError();
|
||||
|
||||
var t = Object(this), len = t.length >>> 0, res = new Array(len);
|
||||
var thisArg = arguments.length > 1 ? arguments[1] : void 0;
|
||||
for (var i = 0; i < len; i++) {
|
||||
// NOTE: Absolute correctness would demand Object.defineProperty
|
||||
// be used. But this method is fairly new, and failure is
|
||||
// possible only if Object.prototype or Array.prototype
|
||||
// has a property |i| (very unlikely), so use a less-correct
|
||||
// but more portable alternative.
|
||||
if (i in t)
|
||||
res[i] = fun.call(thisArg, t[i], i, t);
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
if(!Array.isArray) {
|
||||
Array.isArray = function(arg) {
|
||||
return Object.prototype.toString.call(arg) === '[object Array]';
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.prototype.forEach) {
|
||||
Array.prototype.forEach = function(fun, thisArg) {
|
||||
"use strict";
|
||||
|
||||
if (this === void 0 || this === null || typeof fun !== "function")
|
||||
throw new TypeError();
|
||||
|
||||
var t = Object(this), len = t.length >>> 0;
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (i in t)
|
||||
fun.call(thisArg, t[i], i, t);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!Object.keys) {
|
||||
Object.keys = (function () {
|
||||
'use strict';
|
||||
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
|
||||
dontEnums = ['toString','toLocaleString','valueOf','hasOwnProperty',
|
||||
'isPrototypeOf','propertyIsEnumerable','constructor'],
|
||||
dontEnumsLength = dontEnums.length;
|
||||
|
||||
return function (obj) {
|
||||
if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {
|
||||
throw new TypeError();
|
||||
}
|
||||
var result = [], prop, i;
|
||||
|
||||
for (prop in obj) {
|
||||
if (hasOwnProperty.call(obj, prop)) {
|
||||
result.push(prop);
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (i = 0; i < dontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(obj, dontEnums[i])) {
|
||||
result.push(dontEnums[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}());
|
||||
}
|
||||
|
||||
if (!String.prototype.trim) {
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/^\s+|\s+$/g, '');
|
||||
};
|
||||
}
|
||||
if (!String.prototype.trimLeft) {
|
||||
String.prototype.trimLeft = function() {
|
||||
return this.replace(/^\s+/g, "");
|
||||
};
|
||||
}
|
||||
if (!String.prototype.trimRight) {
|
||||
String.prototype.trimRight = function() {
|
||||
return this.replace(/\s+$/g, "");
|
||||
};
|
||||
}
|
||||
|
||||
})(typeof self !== "undefined" && self || typeof window !== "undefined" && window || this);
|
||||
126
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/require/config.js
generated
vendored
Normal file
126
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/require/config.js
generated
vendored
Normal file
@ -0,0 +1,126 @@
|
||||
/**
|
||||
* config.js
|
||||
* Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
|
||||
* Copyright (c) 2015 James Hall (Parallax Agency Ltd) james@parall.ax
|
||||
*
|
||||
* Licensed under the MIT License.
|
||||
* http://opensource.org/licenses/mit-license
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file declaratively defines jsPDF plugin dependencies.
|
||||
*
|
||||
* This allows a host page to simply include require.js and bootstrap the page with a single require statement.
|
||||
*/
|
||||
|
||||
// Skip if Require.JS not installed
|
||||
if (typeof require === 'object') {
|
||||
|
||||
if (typeof require_baseUrl_override === 'undefined'){
|
||||
require_baseUrl_override = '../';
|
||||
}
|
||||
|
||||
require.config({
|
||||
baseUrl: require_baseUrl_override,
|
||||
shim:{
|
||||
'plugins/standard_fonts_metrics':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/split_text_to_size':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/annotations' : {
|
||||
deps:[
|
||||
'jspdf',
|
||||
'plugins/standard_fonts_metrics',
|
||||
'plugins/split_text_to_size'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/outline':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/addimage':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/png_support':{
|
||||
deps:[
|
||||
'jspdf',
|
||||
'libs/png_support/png',
|
||||
'libs/png_support/zlib'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/from_html':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/context2d':{
|
||||
deps:[
|
||||
'jspdf',
|
||||
'plugins/png_support',
|
||||
'plugins/addimage',
|
||||
'libs/css_colors'
|
||||
]
|
||||
},
|
||||
|
||||
'libs/html2canvas/dist/html2canvas':{
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/canvas' : {
|
||||
deps:[
|
||||
'jspdf'
|
||||
]
|
||||
},
|
||||
|
||||
'plugins/acroform': {
|
||||
deps: [
|
||||
'jspdf',
|
||||
'plugins/annotations'
|
||||
]
|
||||
},
|
||||
|
||||
'html2pdf' : {
|
||||
deps:[
|
||||
'jspdf',
|
||||
'plugins/standard_fonts_metrics',
|
||||
'plugins/split_text_to_size',
|
||||
'plugins/png_support',
|
||||
'plugins/context2d',
|
||||
'plugins/canvas',
|
||||
'plugins/annotations',
|
||||
|
||||
'libs/html2canvas/dist/html2canvas'
|
||||
]
|
||||
},
|
||||
|
||||
'test/test_harness':{
|
||||
deps:[
|
||||
'jspdf',
|
||||
'jspdf.plugin.standard_fonts_metrics',
|
||||
'jspdf.plugin.split_text_to_size'
|
||||
]
|
||||
}
|
||||
},
|
||||
paths:{
|
||||
'html2pdf': 'libs/html2pdf'
|
||||
}
|
||||
});
|
||||
} // Require.JS
|
||||
1996
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/require/require.js
generated
vendored
Normal file
1996
WebRoot/node_modules/pdf/jsPDF-1.3.2/libs/require/require.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user