Skip to content

Commit

Permalink
Tag v 1.0.23 all methods accepts either jQuery elements or HTMLElement
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflabs committed Aug 3, 2018
1 parent 260084f commit b7d85ba
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 81 deletions.
18 changes: 9 additions & 9 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ elements with class `keepstyle` not its children

**Parameters**

- `the_svg` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** The SVG element on which to apply the
- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/) \| [HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element))** The SVG element on which to apply the
modifications
- `opts` **[FSOptions](#fsoptions)** The options, in particular, it will check if `clone` is true

Expand All @@ -54,7 +54,7 @@ Wrapper around html2canvas to accept either a DOMNode or a Cash/jQuery selector

**Parameters**

- `element` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [jQuery](https://api.jquery.com/jQuery/))** The element
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** The element
- `options` **[FSOptions](#fsoptions)** The options

Returns **[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement)** Canvas element
Expand All @@ -65,7 +65,7 @@ Takes a jQuery container, finds its contained SVG, transforms it into a canvas

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** container of an SVG element to transform into canvas
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** container of an SVG element to transform into canvas
- `options` **[FSOptions](#fsoptions)** options to pass to canvg

Returns **[Promise](http://bluebirdjs.com/docs/api-reference.html)<[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement)>** a promise that unfolds to a Canvas element
Expand All @@ -76,7 +76,7 @@ Takes a jQuery container, finds its contained SVG, transforms it into an image

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** container of an SVG element to transform into image
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** container of an SVG element to transform into image
- `options` **[FSOptions](#fsoptions)?** options

Returns **[Promise](http://bluebirdjs.com/docs/api-reference.html)<[HTMLImageElement](https://developer.mozilla.org/docs/Web/API/HTMLImageElement)>** a promise than resolves to an Image element
Expand All @@ -88,7 +88,7 @@ Creates a hidden clone of a Cash/jQuery selector and appends it to the screen

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** The Cash/jQuery selector of the original container
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** The Cash/jQuery selector of the original container

Returns **[HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element)** the DOM node of the clone
___
Expand All @@ -99,7 +99,7 @@ Given a jQuery container, takes a screenshot of it and returns it as an HTMLCanv

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector of the element to transform into canvas
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector of the element to transform into canvas
- `options` **[FSOptions](#fsoptions)?** options to pass to canvg and html2canvas

Returns **[Promise](http://bluebirdjs.com/docs/api-reference.html)<[HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement)>** a promise that unfolds to a [HTMLCanvasElement](https://developer.mozilla.org/docs/Web/API/HTMLCanvasElement)
Expand All @@ -111,7 +111,7 @@ from SVG to images with classname `.temporary_element`. Original SVG element is

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `selector` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a CSS selector like `.className` or `#id`
___
## selectorToCanvas
Expand All @@ -121,7 +121,7 @@ from SVG to canvases with classname `.temporary_element`. Original SVG element i

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `selector` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a CSS selector like `.className` or `#id`
___
## selectorToSVG
Expand All @@ -131,5 +131,5 @@ removing elements with classname `.temporary_element` and showing the original S

**Parameters**

- `jqContainer` **([Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `jqContainer` **([HTMLElement](https://developer.mozilla.org/docs/Web/HTML/Element) \| [Cash](https://github.com/kenwheeler/cash) \| [jQuery](https://api.jquery.com/jQuery/))** Cash/jQuery selector that contains N nodes with the specified selector
- `selector` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a CSS selector like `.className` or `#id`
37 changes: 20 additions & 17 deletions dist/ig_screenshot.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -12659,19 +12659,19 @@ function setDefaultOptions(options) {
* Adjust common C3 styles to avoid distorted images. This function won't modify
* elements with class `keepstyle` not its children
*
* @param {Cash|jQuery} the_svg The SVG element on which to apply the
* @param {Cash|jQuery|HTMLElement} jqContainer The SVG element on which to apply the
* modifications
* @param {FSOptions} opts The options, in particular, it will check if `clone` is true
* @return {Cash|jQuery} a clone of the original svg element with modified
* styles
*/
function adjustStyles(the_svg, opts) {
function adjustStyles(jqContainer, opts) {

if (the_svg instanceof HTMLElement) {
the_svg = cash(the_svg);
if (jqContainer instanceof HTMLElement) {
jqContainer = cash(jqContainer);
}

var clone = opts.clone ? the_svg.clone() : the_svg;
var clone = opts.clone ? jqContainer.clone() : jqContainer;

clone.find('g').removeAttr('clip-path');
clone.find('g.c3-regions').remove();
Expand Down Expand Up @@ -12704,22 +12704,25 @@ function adjustStyles(the_svg, opts) {
/**
* Wrapper around html2canvas to accept either a DOMNode or a Cash/jQuery selector
*
* @param {HTMLElement|jQuery} element The element
* @param {HTMLElement|Cash|jQuery} jqContainer The element
* @param {FSOptions} options The options
*
* @returns {HTMLCanvasElement} Canvas element
*/
function html2canvas(element, options) {
function html2canvas(jqContainer, options) {

var opts = setDefaultOptions(options);

if (opts.adjust_styles === true) {
adjustStyles(element, opts);
if (jqContainer instanceof HTMLElement) {
jqContainer = cash(jqContainer);
}
if (!(element instanceof HTMLElement)) {
element = element[0];

if (opts.adjust_styles === true) {
adjustStyles(jqContainer, opts);
}

var element = jqContainer[0];

return new Promise(function (resolve, reject) {
window.setTimeout(function () {
index(element, opts).then(function (canvas) {
Expand All @@ -12734,7 +12737,7 @@ function html2canvas(element, options) {
/**
* Takes a jQuery container, finds its contained SVG, transforms it into a canvas
*
* @param {Cash|jQuery} jqContainer container of an SVG element to transform into canvas
* @param {HTMLElement|Cash|jQuery} jqContainer container of an SVG element to transform into canvas
* @param {FSOptions} options - options to pass to canvg
*
* @returns {Promise<HTMLCanvasElement>} a promise that unfolds to a Canvas element
Expand Down Expand Up @@ -12798,7 +12801,7 @@ function svgToCanvas(jqContainer, options) {
/**
* Takes a jQuery container, finds its contained SVG, transforms it into an image
*
* @param {Cash|jQuery} jqContainer container of an SVG element to transform into image
* @param {HTMLElement|Cash|jQuery} jqContainer container of an SVG element to transform into image
* @param {FSOptions} [options] options
*
* @returns {Promise<HTMLImageElement>} a promise than resolves to an Image element
Expand Down Expand Up @@ -12845,7 +12848,7 @@ function svgToImg(jqContainer, options) {
* Creates a hidden clone of a Cash/jQuery selector and appends it to the screen
* (allows to capture sections that are hidden due to scrolling behavior)
*
* @param {Cash|jQuery} jqContainer The Cash/jQuery selector of the original container
* @param {HTMLElement|Cash|jQuery} jqContainer The Cash/jQuery selector of the original container
* @return {HTMLElement} the DOM node of the clone
*/
function hiddenClone(jqContainer) {
Expand Down Expand Up @@ -12875,7 +12878,7 @@ function hiddenClone(jqContainer) {
* Given a jQuery container, takes a screenshot of it and returns it as an HTMLCanvasElement
* (it can capture the container contents even if they are hidden due to overlay hidden, auto or scroll CSS properties)
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector of the element to transform into canvas
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector of the element to transform into canvas
* @param {FSOptions} [options] options to pass to canvg and html2canvas
* @return {Promise<HTMLCanvasElement>} a promise that unfolds to a {@link HTMLCanvasElement}
*/
Expand Down Expand Up @@ -12922,7 +12925,7 @@ var infoScreenShot = function infoScreenShot(jqContainer, options) {
* Transforms all contents of `selector` nodes found in `jqContainer`
* from SVG to images with classname `.temporary_element`. Original SVG element is hidden
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {string} selector a CSS selector like `.className` or `#id`
*/
var selectorToImg = function selectorToImg(jqContainer, selector) {
Expand All @@ -12939,7 +12942,7 @@ var selectorToImg = function selectorToImg(jqContainer, selector) {
* Removes all childs from `selector` nodes found in `jqContainer`
* removing elements with classname `.temporary_element` and showing the original SVG
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {string} selector a CSS selector like `.className` or `#id`
*/
var selectorToSVG = function selectorToSVG(jqContainer, selector) {
Expand Down
37 changes: 20 additions & 17 deletions dist/ig_screenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -12665,19 +12665,19 @@ function setDefaultOptions(options) {
* Adjust common C3 styles to avoid distorted images. This function won't modify
* elements with class `keepstyle` not its children
*
* @param {Cash|jQuery} the_svg The SVG element on which to apply the
* @param {Cash|jQuery|HTMLElement} jqContainer The SVG element on which to apply the
* modifications
* @param {FSOptions} opts The options, in particular, it will check if `clone` is true
* @return {Cash|jQuery} a clone of the original svg element with modified
* styles
*/
function adjustStyles(the_svg, opts) {
function adjustStyles(jqContainer, opts) {

if (the_svg instanceof HTMLElement) {
the_svg = cash(the_svg);
if (jqContainer instanceof HTMLElement) {
jqContainer = cash(jqContainer);
}

var clone = opts.clone ? the_svg.clone() : the_svg;
var clone = opts.clone ? jqContainer.clone() : jqContainer;

clone.find('g').removeAttr('clip-path');
clone.find('g.c3-regions').remove();
Expand Down Expand Up @@ -12710,22 +12710,25 @@ function adjustStyles(the_svg, opts) {
/**
* Wrapper around html2canvas to accept either a DOMNode or a Cash/jQuery selector
*
* @param {HTMLElement|jQuery} element The element
* @param {HTMLElement|Cash|jQuery} jqContainer The element
* @param {FSOptions} options The options
*
* @returns {HTMLCanvasElement} Canvas element
*/
function html2canvas(element, options) {
function html2canvas(jqContainer, options) {

var opts = setDefaultOptions(options);

if (opts.adjust_styles === true) {
adjustStyles(element, opts);
if (jqContainer instanceof HTMLElement) {
jqContainer = cash(jqContainer);
}
if (!(element instanceof HTMLElement)) {
element = element[0];

if (opts.adjust_styles === true) {
adjustStyles(jqContainer, opts);
}

var element = jqContainer[0];

return new Promise(function (resolve, reject) {
window.setTimeout(function () {
index(element, opts).then(function (canvas) {
Expand All @@ -12740,7 +12743,7 @@ function html2canvas(element, options) {
/**
* Takes a jQuery container, finds its contained SVG, transforms it into a canvas
*
* @param {Cash|jQuery} jqContainer container of an SVG element to transform into canvas
* @param {HTMLElement|Cash|jQuery} jqContainer container of an SVG element to transform into canvas
* @param {FSOptions} options - options to pass to canvg
*
* @returns {Promise<HTMLCanvasElement>} a promise that unfolds to a Canvas element
Expand Down Expand Up @@ -12804,7 +12807,7 @@ function svgToCanvas(jqContainer, options) {
/**
* Takes a jQuery container, finds its contained SVG, transforms it into an image
*
* @param {Cash|jQuery} jqContainer container of an SVG element to transform into image
* @param {HTMLElement|Cash|jQuery} jqContainer container of an SVG element to transform into image
* @param {FSOptions} [options] options
*
* @returns {Promise<HTMLImageElement>} a promise than resolves to an Image element
Expand Down Expand Up @@ -12851,7 +12854,7 @@ function svgToImg(jqContainer, options) {
* Creates a hidden clone of a Cash/jQuery selector and appends it to the screen
* (allows to capture sections that are hidden due to scrolling behavior)
*
* @param {Cash|jQuery} jqContainer The Cash/jQuery selector of the original container
* @param {HTMLElement|Cash|jQuery} jqContainer The Cash/jQuery selector of the original container
* @return {HTMLElement} the DOM node of the clone
*/
function hiddenClone(jqContainer) {
Expand Down Expand Up @@ -12881,7 +12884,7 @@ function hiddenClone(jqContainer) {
* Given a jQuery container, takes a screenshot of it and returns it as an HTMLCanvasElement
* (it can capture the container contents even if they are hidden due to overlay hidden, auto or scroll CSS properties)
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector of the element to transform into canvas
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector of the element to transform into canvas
* @param {FSOptions} [options] options to pass to canvg and html2canvas
* @return {Promise<HTMLCanvasElement>} a promise that unfolds to a {@link HTMLCanvasElement}
*/
Expand Down Expand Up @@ -12928,7 +12931,7 @@ var infoScreenShot = function infoScreenShot(jqContainer, options) {
* Transforms all contents of `selector` nodes found in `jqContainer`
* from SVG to images with classname `.temporary_element`. Original SVG element is hidden
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {string} selector a CSS selector like `.className` or `#id`
*/
var selectorToImg = function selectorToImg(jqContainer, selector) {
Expand All @@ -12945,7 +12948,7 @@ var selectorToImg = function selectorToImg(jqContainer, selector) {
* Removes all childs from `selector` nodes found in `jqContainer`
* removing elements with classname `.temporary_element` and showing the original SVG
*
* @param {Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {HTMLElement|Cash|jQuery} jqContainer Cash/jQuery selector that contains N nodes with the specified selector
* @param {string} selector a CSS selector like `.className` or `#id`
*/
var selectorToSVG = function selectorToSVG(jqContainer, selector) {
Expand Down
2 changes: 1 addition & 1 deletion dist/ig_screenshot.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/ig_screenshot.min.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit b7d85ba

Please sign in to comment.