Skip to content

Commit

Permalink
Support async loading + clean up a little
Browse files Browse the repository at this point in the history
  • Loading branch information
wiredearp committed Dec 19, 2017
1 parent 7c79f9b commit d819bf2
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 26 deletions.
24 changes: 1 addition & 23 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,6 @@ module.exports = function(grunt) {
}
},

tsjs: {
// setup 'ts.js'
dev: {
files: {
'temp/ts.js': 'src/runtime/ts.js'
}
},
// setup 'ts.js' for jasmine tests
jasmine: {
files: {
'temp/ts.js': 'src/runtime/ts.js'
}
},
// setup 'ts.js' for CDN
cdn: {
files: {
'temp/ts.js': 'src/runtime/ts.js'
}
}
},

tsless: {
// concatenate the LESS (so that devs may copy-paste it from the web)
cdn: {
Expand Down Expand Up @@ -472,7 +451,6 @@ module.exports = function(grunt) {
function generateJsConcurrent(target = 'cdn') {
return [
'edbml', // edbml -> js
`tsjs:${target}`,
[
// generate ts.js
`tsless:${returnDevForJasmine(target)}`, // generate ts.less
Expand Down Expand Up @@ -588,7 +566,7 @@ module.exports = function(grunt) {
* @returns {Array<string>}
*/
function getcombobuilds() {
return ['temp/ts.js'].concat(getapibuilds()).concat(getguibuilds());
return getapibuilds().concat(getguibuilds());
}

/**
Expand Down
38 changes: 38 additions & 0 deletions docs/dist/TEST.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en-us" class="ts-docs" spellcheck="false">

<head>
<title>Testing</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<script src="//d5wfroyti11sa.cloudfront.net/prod/client/ts-9.3.13.min.js"></script>
<script src="/dist/assets/dox.min.js"></script>
<script src="/dist/assets/mark.min.js"></script>
<script src="/dist/assets/jquery-2.2.4.min.js"></script>
<link rel="stylesheet" href="//d5wfroyti11sa.cloudfront.net/prod/client/ts-9.3.13.min.css">
<link rel="stylesheet" href="/dist/assets/dox.css">
<script>
var script = document.createElement('script');
script.src = '//172.31.98.151:10111/dist/ts.js';
setTimeout(function() {
document.head.appendChild(script);
console.log('Did it work?');
}, 1000);
</script>
</head>

<body>
<button data-ts="Button" class="ts-primary">Hell World</button>
<aside data-ts="Note" class="sticky ts-bg-yellow">
<p>If you find a bug or need a feature&#x2026;</p>
<menu class="ts-buttons">
<li>
<a data-ts="Button" target="_blank" href="https://github.com/Tradeshift/tradeshift-ui/issues/new" title="Submit new issue" class="ts-secondary">
<span>Create GitHub Issue&#x2026;</span>
</a>
</li>
</menu>
</aside>
</body>

</html>
2 changes: 1 addition & 1 deletion docs/dist/lunr.json

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions docs/src/xhtml/TEST.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html>
<head>
<title>Testing</title>
<script>
var script = document.createElement('script');
script.src = '//172.31.98.151:10111/dist/ts.js';
setTimeout(function() {
document.head.appendChild(script);
console.log('Did it work?');
}, 1000);
</script>
</head>
<body>
<button data-ts="Button" class="ts-primary">Hell World</button>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,33 @@ gui.Document = (function() {
target.addEventListener(type, that, capture);
});
};
add(document, 'DOMContentLoaded visibilitychange');
add(document, 'visibilitychange');
add(document, 'click mousedown mouseup', true);
add(window, 'load hashchange resize');
add(window, 'hashchange resize');
if (!gui.hosted) {
add(window, 'orientationchange');
}
if (!(window.chrome && chrome.app && chrome.runtime)) {
add(window, 'unload');
}
/*
* Setup to support async loading (via `script.defer` or similar)
*/
if (document.readyState === 'loading') {
add(document, 'DOMContentLoaded');
add(window, 'load');
} else {
setImmediate(
function parseTheRestOfTheScript() {
this._ondom();
if (document.readyState === 'interactive') {
add(window, 'load');
} else {
this._onload();
}
}.bind(this)
);
}
},

/**
Expand Down

0 comments on commit d819bf2

Please sign in to comment.