Skip to content

Commit

Permalink
designer.appendTo now supports load-callback
Browse files Browse the repository at this point in the history
designer.appendTo(documetn.body, function() {
alert('loaded into documetn.body');
});
  • Loading branch information
muaz-khan committed Oct 25, 2018
1 parent 197233d commit 26ffa66
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
30 changes: 13 additions & 17 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
node_modules
bower_components
# ignore everything
*

*.tar.gz
lib-cov

.*.swp
._*
.DS_Store
.git
.hg
.npmrc
.lock-wscript
.svn
.wafpickle-*
config.gypi
CVS
npm-debug.log
# but not these files...
!canvas-designer-widget.js
!widget.html
!widget.js
!widget.min.js
!dev/webrtc-handler.js
!index.html
!package.json
!bower.json
!server.js
!README.md
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ CanvasDesigner is a widget; that widget should be appended to a DOM object. This

```javascript
designer.appendTo(document.body || document.documentElement);

// or
designer.appendTo(document.body || document.documentElement, function() {
alert('iframe load callback');
});
```

The correct name for `appendTo` is: `append-iframe to target HTML-DOM-element`
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-designer",
"preferGlobal": false,
"version": "1.2.4",
"version": "1.2.5",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down
12 changes: 11 additions & 1 deletion canvas-designer-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function CanvasDesigner() {
pdf: null,
pdf_next: null,
pdf_prev: null,
pdf_close: null,
marker: null,
zoom: null,
lineWidth: null,
Expand Down Expand Up @@ -114,8 +115,17 @@ function CanvasDesigner() {

designer.uid = getRandomString();

designer.appendTo = function(parentNode) {
designer.appendTo = function(parentNode, callback) {
callback = callback || function() {};

designer.iframe = document.createElement('iframe');

// designer load callback
designer.iframe.onload = function() {
callback();
callback = null;
};

designer.iframe.src = designer.widgetHtmlURL + '?widgetJsURL=' + designer.widgetJsURL + '&tools=' + JSON.stringify(tools) + '&selectedIcon=' + selectedIcon + '&icons=' + JSON.stringify(designer.icons);
designer.iframe.style.width = '100%';
designer.iframe.style.height = '100%';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "canvas-designer",
"preferGlobal": false,
"version": "1.2.4",
"version": "1.2.5",
"author": {
"name": "Muaz Khan",
"email": "muazkh@gmail.com",
Expand Down

0 comments on commit 26ffa66

Please sign in to comment.