Added Polymer
This commit is contained in:
21
rpg-docs/public/bower_components/core-shared-lib/.bower.json
vendored
Normal file
21
rpg-docs/public/bower_components/core-shared-lib/.bower.json
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "core-shared-lib",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"polymer-test-tools": "Polymer/polymer-test-tools#master"
|
||||
},
|
||||
"version": "0.5.1",
|
||||
"homepage": "https://github.com/Polymer/core-shared-lib",
|
||||
"_release": "0.5.1",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.5.1",
|
||||
"commit": "92d3fa2c5b02aa640f765e715e3785d74ae024b0"
|
||||
},
|
||||
"_source": "git://github.com/Polymer/core-shared-lib.git",
|
||||
"_target": "^0.5.0",
|
||||
"_originalSource": "Polymer/core-shared-lib"
|
||||
}
|
||||
4
rpg-docs/public/bower_components/core-shared-lib/README.md
vendored
Normal file
4
rpg-docs/public/bower_components/core-shared-lib/README.md
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
core-shared-lib
|
||||
===============
|
||||
|
||||
See the [component landing page](http://polymer-project.org/docs/elements/core-elements.html#core-shared-lib) for more information.
|
||||
11
rpg-docs/public/bower_components/core-shared-lib/bower.json
vendored
Normal file
11
rpg-docs/public/bower_components/core-shared-lib/bower.json
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "core-shared-lib",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"polymer": "Polymer/polymer#^0.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"polymer-test-tools": "Polymer/polymer-test-tools#master"
|
||||
},
|
||||
"version": "0.5.1"
|
||||
}
|
||||
151
rpg-docs/public/bower_components/core-shared-lib/core-shared-lib.html
vendored
Normal file
151
rpg-docs/public/bower_components/core-shared-lib/core-shared-lib.html
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<link rel="import" href="../polymer/polymer.html">
|
||||
|
||||
<!--
|
||||
Supports sharing a JSONP-based JavaScript library.
|
||||
|
||||
<core-shared-lib on-core-shared-lib-load="{{load}}" url="https://apis.google.com/js/plusone.js?onload=%%callback%%">
|
||||
|
||||
Multiple components can request a library using a `core-shared-lib` component and only one copy of that library will
|
||||
loaded from the network.
|
||||
|
||||
Currently, the library must support JSONP to work as a shared-lib.
|
||||
|
||||
Some libraries require a specific global function be defined. If this is the case, specify the `callbackName` property.
|
||||
|
||||
Where possible, you should use an HTML Import to load library dependencies. Rather than using this element,
|
||||
create an import (`<link rel="import" href="lib.html">`) that wraps loading the .js file:
|
||||
|
||||
lib.html:
|
||||
|
||||
<script src="lib.js"></script>
|
||||
|
||||
@group Polymer Core Elements
|
||||
@element core-shared-lib
|
||||
-->
|
||||
<polymer-element name="core-shared-lib" attributes="url notifyEvent callbackName">
|
||||
<script>
|
||||
(function() {
|
||||
|
||||
Polymer({
|
||||
|
||||
notifyEvent: 'core-shared-lib-load',
|
||||
|
||||
ready: function() {
|
||||
if (!this.url && this.defaultUrl) {
|
||||
this.url = this.defaultUrl;
|
||||
}
|
||||
},
|
||||
|
||||
urlChanged: function() {
|
||||
require(this.url, this, this.callbackName);
|
||||
},
|
||||
|
||||
provide: function() {
|
||||
this.async('notify');
|
||||
},
|
||||
|
||||
notify: function() {
|
||||
this.fire(this.notifyEvent, arguments);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var apiMap = {};
|
||||
|
||||
function require(url, notifiee, callbackName) {
|
||||
// make hashable string form url
|
||||
var name = nameFromUrl(url);
|
||||
// lookup existing loader instance
|
||||
var loader = apiMap[name];
|
||||
// create a loader as needed
|
||||
if (!loader) {
|
||||
loader = apiMap[name] = new Loader(name, url, callbackName);
|
||||
}
|
||||
loader.requestNotify(notifiee);
|
||||
}
|
||||
|
||||
function nameFromUrl(url) {
|
||||
return url.replace(/[\:\/\%\?\&\.\=\-\,]/g, '_') + '_api';
|
||||
}
|
||||
|
||||
var Loader = function(name, url, callbackName) {
|
||||
this.instances = [];
|
||||
this.callbackName = callbackName;
|
||||
if (this.callbackName) {
|
||||
window[this.callbackName] = this.success.bind(this);
|
||||
} else {
|
||||
if (url.indexOf(this.callbackMacro) >= 0) {
|
||||
this.callbackName = name + '_loaded';
|
||||
window[this.callbackName] = this.success.bind(this);
|
||||
url = url.replace(this.callbackMacro, this.callbackName);
|
||||
} else {
|
||||
// TODO(sjmiles): we should probably fallback to listening to script.load
|
||||
throw 'core-shared-api: a %%callback%% parameter is required in the API url';
|
||||
}
|
||||
}
|
||||
//
|
||||
this.addScript(url);
|
||||
};
|
||||
|
||||
Loader.prototype = {
|
||||
|
||||
callbackMacro: '%%callback%%',
|
||||
loaded: false,
|
||||
|
||||
addScript: function(src) {
|
||||
var script = document.createElement('script');
|
||||
script.src = src;
|
||||
script.onerror = this.error.bind(this);
|
||||
var s = document.querySelector('script');
|
||||
s.parentNode.insertBefore(script, s);
|
||||
this.script = script;
|
||||
},
|
||||
|
||||
removeScript: function() {
|
||||
if (this.script.parentNode) {
|
||||
this.script.parentNode.removeChild(this.script);
|
||||
}
|
||||
this.script = null;
|
||||
},
|
||||
|
||||
error: function() {
|
||||
this.cleanup();
|
||||
},
|
||||
|
||||
success: function() {
|
||||
this.loaded = true;
|
||||
this.cleanup();
|
||||
this.result = Array.prototype.slice.call(arguments);
|
||||
this.instances.forEach(this.provide, this);
|
||||
this.instances = null;
|
||||
},
|
||||
|
||||
cleanup: function() {
|
||||
delete window[this.callbackName];
|
||||
},
|
||||
|
||||
provide: function(instance) {
|
||||
instance.notify(instance, this.result);
|
||||
},
|
||||
|
||||
requestNotify: function(instance) {
|
||||
if (this.loaded) {
|
||||
this.provide(instance);
|
||||
} else {
|
||||
this.instances.push(instance);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
})();
|
||||
</script>
|
||||
</polymer-element>
|
||||
33
rpg-docs/public/bower_components/core-shared-lib/demo.html
vendored
Normal file
33
rpg-docs/public/bower_components/core-shared-lib/demo.html
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
|
||||
<link rel="import" href="core-shared-lib.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- three instances, but only one actual network transaction -->
|
||||
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
|
||||
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
|
||||
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
|
||||
|
||||
<script>
|
||||
addEventListener('core-shared-lib-load', function() {
|
||||
console.log('client.js lib load notify');
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
22
rpg-docs/public/bower_components/core-shared-lib/index.html
vendored
Normal file
22
rpg-docs/public/bower_components/core-shared-lib/index.html
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
|
||||
<script src="../webcomponentsjs/webcomponents.js"></script>
|
||||
<link rel="import" href="../core-component-page/core-component-page.html">
|
||||
|
||||
</head>
|
||||
<body unresolved>
|
||||
|
||||
<core-component-page></core-component-page>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
47
rpg-docs/public/bower_components/core-shared-lib/tests/html/core-shared-lib.html
vendored
Normal file
47
rpg-docs/public/bower_components/core-shared-lib/tests/html/core-shared-lib.html
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<!doctype html>
|
||||
<!--
|
||||
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
|
||||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
|
||||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
|
||||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
|
||||
Code distributed by Google as part of the polymer project is also
|
||||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
||||
-->
|
||||
<html>
|
||||
<head>
|
||||
<title>core-shared-lib</title>
|
||||
|
||||
<script src="../../../webcomponentsjs/webcomponents.js"></script>
|
||||
<script src="../../../polymer-test-tools/chai/chai.js"></script>
|
||||
<script src="../../../polymer-test-tools/htmltest.js"></script>
|
||||
|
||||
<link rel="import" href="../../core-shared-lib.html">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
|
||||
|
||||
<template id="t" bind="{{}}">
|
||||
<core-shared-lib url="https://apis.google.com/js/client.js?onload=%%callback%%"></core-shared-lib>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
var count = 0;
|
||||
addEventListener("core-shared-lib-load", function(event) {
|
||||
if (++count === 2) {
|
||||
done();
|
||||
} else {
|
||||
chai.assert.isTrue(count < 2);
|
||||
// request the api again
|
||||
setTimeout(function() {
|
||||
document.querySelector('#t').model = {};
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
3
rpg-docs/public/bower_components/core-shared-lib/tests/js/htmltests.js
vendored
Normal file
3
rpg-docs/public/bower_components/core-shared-lib/tests/js/htmltests.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
htmlSuite('core-shared-lib', function() {
|
||||
htmlTest('html/core-shared-lib.html');
|
||||
});
|
||||
14
rpg-docs/public/bower_components/core-shared-lib/tests/runner.html
vendored
Normal file
14
rpg-docs/public/bower_components/core-shared-lib/tests/runner.html
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
<!doctype htmlz>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
|
||||
<title>Web Component Test Runner</title>
|
||||
<script src="../../polymer-test-tools/ci-support.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
runTests('tests.json');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
6
rpg-docs/public/bower_components/core-shared-lib/tests/tests.json
vendored
Normal file
6
rpg-docs/public/bower_components/core-shared-lib/tests/tests.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"tools": ["chai", "mocha-tdd"],
|
||||
"tests": [
|
||||
"js/htmltests.js"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user