Skip to content

Commit

Permalink
fix(cards): imagesUrl when module is loaded asychronously
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Sep 26, 2016
1 parent b4b86f1 commit abc6a86
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ Install with [npm](http://blog.npmjs.org/post/85484771375/how-to-install-npm)

### Browser

Include the package from your project

````html
<link rel="stylesheet" type="text/css" href="./node_modules/cardsJS/dist/cards.min.css" />
<script src="./node_modules/cardsJS/dist/cards.min.js" type="text/javascript"></script>
````

or from the [unpkg CDN](https://unpkg.com)
Include the package from the [unpkg CDN](https://unpkg.com)

````html
<link rel="stylesheet" type="text/css" href="https://unpkg.com/cardsJS/dist/cards.min.css" />
<script src="https://unpkg.com/cardsJS/dist/cards.min.js" type="text/javascript"></script>

<script src="https://unpkg.com/cardsJS/dist/cards.min.js" type="text/javascript"></script>
````

## Cards
Expand Down
7 changes: 4 additions & 3 deletions cards.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*jslint vars: true, plusplus: true, -W003 */
/*globals window, document, define, exports, module, require */

var cardsScript = document.currentScript;

(function (root, factory) {
'use strict';
Expand Down Expand Up @@ -302,9 +304,8 @@
});

// Default imagesUrl to a subfolder of the script source.
var mySource = document.currentScript.src;
if (mySource) {
var path = mySource.substring(0, mySource.lastIndexOf('/')) + '/cards/';
if (cardsScript && cardsScript.src) {
var path = cardsScript.src.substring(0, cardsScript.src.lastIndexOf('/')) + '/cards/';
module.options.imagesUrl = path;
}

Expand Down

0 comments on commit abc6a86

Please sign in to comment.