extract scripts

This commit is contained in:
Luke Pulverenti 2015-06-10 00:01:14 -04:00
parent d84e09e501
commit 6c97b11f21
41 changed files with 8363 additions and 204 deletions

View File

@ -4,7 +4,7 @@
<title>${TitlePlugins}</title>
</head>
<body>
<div id="addPluginPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/registrationservices,scripts/ratingdialog">
<div id="addPluginPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/registrationservices,scripts/ratingdialog,scripts/addplugin">
<div data-role="content">
<div class="content-primary">
@ -125,9 +125,6 @@
</div>
</div>
</div>
<script type="text/javascript">
$('.addPluginForm').off('submit', AddPluginPage.onSubmit).on('submit', AddPluginPage.onSubmit);
</script>
</div>
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 588 KiB

After

Width:  |  Height:  |  Size: 100 KiB

View File

@ -3,8 +3,8 @@
}
.nowPlayingPageImage img {
max-height: 300px;
max-width: 300px;
max-height: 250px;
max-width: 250px;
}
.nowPlayingPage .positionSliderContainer {
@ -77,6 +77,14 @@
}
}
@media all and (max-height: 600px) {
.nowPlayingPageImage img {
max-height: 160px;
max-width: 250px;
}
}
@media all and (max-width: 500px) {

View File

@ -151,7 +151,7 @@
font-family: Roboto;
outline: none;
vertical-align: middle;
width: 90%;
width: 85%;
}
.searchInputIcon {
@ -171,6 +171,12 @@
z-index: 1000;
}
@media all and (min-width: 600px) {
.headerSearchInput {
width: 90%;
}
}
@media all and (min-width: 800px) {
.headerSearchInput {
width: 93%;

View File

@ -4,7 +4,7 @@
<title>${TitleServer}</title>
</head>
<body>
<div id="dashboardPage" data-role="page" class="page type-interior dashboardHomePage">
<div id="dashboardPage" data-role="page" class="page type-interior dashboardHomePage" data-require="scripts/dashboardpage">
<div data-role="content">
<div class="content-primary">

View File

@ -200,7 +200,7 @@
</select>
<div>${LabelEnableItemPreviewsHelp}</div>
</div>
<div class="fldFullscreen">
<br />
<div>
@ -210,6 +210,17 @@
</div>
</div>
</div>
<div class="fldSyncPath">
<br />
<div>
<label for="txtSyncPath">${LabelSyncPath}</label>
<div style="display: inline-block; width: 92%;">
<input type="text" id="txtSyncPath" readonly />
</div>
<button class="btnSelectSyncPath" type="button" data-icon="search" data-iconpos="notext" data-inline="true"></button>
</div>
</div>
</div>
</div>

View File

@ -4,7 +4,7 @@
<title>${TitlePlugins}</title>
</head>
<body>
<div id="pluginCatalogPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/ratingdialog">
<div id="pluginCatalogPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/ratingdialog,scripts/plugincatalogpage">
<div data-role="content">
<div class="content-primary">
<div data-role="controlgroup" data-type="horizontal" data-mini="true">

View File

@ -4,7 +4,7 @@
<title>${TitlePlugins}</title>
</head>
<body>
<div id="pluginsPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins">
<div id="pluginsPage" data-role="page" class="page type-interior pluginConfigurationPage" data-helpurl="https://github.com/MediaBrowser/Wiki/wiki/Plugins" data-require="scripts/pluginspage">
<div data-role="content">
<div class="content-primary">

View File

@ -169,7 +169,11 @@
Dashboard.hideLoadingMsg();
}
$(document).on('pageshowready', "#addPluginPage", function () {
$(document).on('pageinitdepends', "#addPluginPage", function () {
$('.addPluginForm').off('submit', AddPluginPage.onSubmit).on('submit', AddPluginPage.onSubmit);
}).on('pageshowready', "#addPluginPage", function () {
var page = this;
@ -188,7 +192,6 @@
});
}).on('pagebeforeshow pageinit pageshow', "#addPluginPage", function () {
// This needs both events for the helpurl to get done at the right time

View File

@ -37,36 +37,39 @@
function renderInstalled(page, availablePlugins, installedPlugins) {
var category = getCategories()[0];
requirejs(['scripts/pluginspage'], function() {
var category = getCategories()[0];
installedPlugins = installedPlugins.filter(function (i) {
installedPlugins = installedPlugins.filter(function (i) {
var catalogEntry = availablePlugins.filter(function (a) {
return a.guid == i.Id;
})[0];
var catalogEntry = availablePlugins.filter(function (a) {
return a.guid == i.Id;
})[0];
return catalogEntry && catalogEntry.category == category;
return catalogEntry && catalogEntry.category == category;
});
PluginsPage.renderPlugins(page, installedPlugins);
});
PluginsPage.renderPlugins(page, installedPlugins);
}
function renderCatalog(page, availablePlugins, installedPlugins) {
var categories = getCategories();
requirejs(['scripts/plugincatalogpage'], function () {
var categories = getCategories();
PluginCatalog.renderCatalog({
PluginCatalog.renderCatalog({
catalogElement: $('.catalog', page),
availablePlugins: availablePlugins,
installedPlugins: installedPlugins,
categories: categories,
showCategory: false,
context: getParameterByName('context'),
targetSystem: 'Server'
catalogElement: $('.catalog', page),
availablePlugins: availablePlugins,
installedPlugins: installedPlugins,
categories: categories,
showCategory: false,
context: getParameterByName('context'),
targetSystem: 'Server'
});
});
}
$(document).on('pagebeforeshow pageinit pageshow', "#appServicesPage", function () {
@ -93,7 +96,7 @@
page.setAttribute('data-helpurl', 'https://github.com/MediaBrowser/Wiki/wiki/Notifications');
}
}).on('pageshow', "#appServicesPage", function () {
}).on('pageshowready', "#appServicesPage", function () {
// This needs both events for the helpurl to get done at the right time

View File

@ -55,6 +55,14 @@
}
return store.getItem('enableFullScreen') == 'true';
},
syncPath: function (val) {
if (val != null) {
update('syncPath', val.toString());
}
return store.getItem('syncPath');
}
};

View File

@ -30,6 +30,7 @@
shape: "backdrop",
context: 'channels',
showTitle: true,
lazy: true,
centerText: true,
preferThumb: true
});

View File

@ -523,7 +523,8 @@
return;
}
if (target.parents('a').length || target.parents('button').length) {
var buttonParents = target.parents('a:not(.card,.cardContent),button:not(.card,.cardContent)');
if (buttonParents.length) {
return;
}

View File

@ -608,7 +608,7 @@
if (mediaSource.SupportsDirectPlay && mediaSource.Protocol == 'File') {
return FileSystem.fileExists(mediaSource.Path);
return FileSystemBridge.fileExists(mediaSource.Path);
}
return false;

View File

@ -22,6 +22,8 @@
$('#chkEnableChromecastAc3', page).checked(AppSettings.enableChromecastAc3()).checkboxradio("refresh");
$('#txtSyncPath', page).val(AppSettings.syncPath());
Dashboard.hideLoadingMsg();
}
@ -59,6 +61,8 @@
AppSettings.enableChromecastAc3($('#chkEnableChromecastAc3', page).checked());
AppSettings.syncPath($('#txtSyncPath', page).val());
var userId = getParameterByName('userId') || Dashboard.getCurrentUserId();
ApiClient.getDisplayPreferences('home', userId, 'webclient').done(function (result) {
@ -77,6 +81,15 @@
$('.webClientPreferencesForm', page).off('submit', onSubmit).on('submit', onSubmit);
$('.btnSelectSyncPath', page).on('click', function () {
require(['nativedirectorychooser'], function () {
NativeDirectoryChooser.chooseDirectory().done(function (path) {
$('#txtSyncPath', page).val(path);
});
});
});
}).on('pageshowready', "#webClientPreferencesPage", function () {
var page = this;
@ -112,6 +125,12 @@
} else {
$('.fldFullscreen', page).hide();
}
if (AppInfo.supportsSyncPathSetting) {
$('.fldSyncPath', page).show();
} else {
$('.fldSyncPath', page).hide();
}
});
})(jQuery, window, document);

View File

@ -186,7 +186,7 @@
Dashboard.hideLoadingMsg();
}
$(document).on('pageinit', "#pluginCatalogPage", function () {
$(document).on('pageinitdepends', "#pluginCatalogPage", function () {
var page = this;
@ -214,7 +214,7 @@
reloadList(page);
});
}).on('pageshow', "#pluginCatalogPage", function () {
}).on('pageshowready', "#pluginCatalogPage", function () {
var page = this;

View File

@ -213,7 +213,7 @@
});
}
$(document).on('pageshow', "#pluginsPage", function () {
$(document).on('pageshowready', "#pluginsPage", function () {
reloadList(this);
});

View File

@ -1586,6 +1586,7 @@ var AppInfo = {};
AppInfo.enableBackButton = (isIOS && window.navigator.standalone) || (isCordova && isIOS);
AppInfo.supportsFullScreen = isCordova && isAndroid;
AppInfo.supportsSyncPathSetting = isCordova && isAndroid;
}
function initializeApiClient(apiClient) {
@ -1893,6 +1894,10 @@ var AppInfo = {};
define("filesystem", ["thirdparty/filesystem"]);
}
if (Dashboard.isRunningInCordova() && $.browser.android) {
define("nativedirectorychooser", ["thirdparty/cordova/android/nativedirectorychooser"]);
}
define("connectservice", ["thirdparty/apiclient/connectservice"]);
//requirejs(['http://viblast.com/player/free-version/qy2fdwajo1/viblast.js']);
@ -2019,6 +2024,8 @@ $(document).on('pagecreate', ".page", function () {
var page = this;
var require = this.getAttribute('data-require');
Dashboard.ensurePageTitle($(page));
if (require) {
requirejs(require.split(','), function () {
@ -2088,7 +2095,6 @@ $(document).on('pagecreate', ".page", function () {
Dashboard.firePageEvent(page, 'pageshowready');
Dashboard.ensureHeader(page);
Dashboard.ensurePageTitle(page);
if (apiClient && !apiClient.isWebSocketOpen()) {
Dashboard.refreshSystemInfoFromServer();

View File

@ -1,6 +1,6 @@
(function () {
window.FileSystem = {
window.FileSystemBridge = {
fileExists: function (path) {
return NativeFileSystem.fileExists(path);

View File

@ -1,5 +1,4 @@

(function () {
(function () {
function setImageIntoElement(elem, url) {
@ -12,62 +11,20 @@
}
}
// IndexedDB
var indexedDb = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.OIndexedDB || window.msIndexedDB,
dbVersion = 1.0;
var fileSystem;
function getFileSystem() {
var dbName = "emby7";
var imagesStoreName = "images";
var deferred = DeferredBuilder.Deferred();
function createObjectStore(dataBase) {
// Create an objectStore
console.log("Creating objectStore");
dataBase.createObjectStore(imagesStoreName);
}
function openDb() {
var deferred = $.Deferred();
// Create/open database
var request = indexedDb.open(dbName, dbVersion);
request.onerror = function (event) {
console.log("Error creating/accessing IndexedDB database");
deferred.reject();
};
request.onsuccess = function (event) {
console.log("Success creating/accessing IndexedDB database");
var db = request.result || event.target.result;
db.onerror = function (event) {
console.log("Error creating/accessing IndexedDB database");
};
// Interim solution for Google Chrome to create an objectStore. Will be deprecated
if (db.setVersion) {
if (db.version != dbVersion) {
var setVersion = db.setVersion(dbVersion);
setVersion.onsuccess = function () {
createObjectStore(db);
deferred.resolveWith(null, [db]);
};
} else {
deferred.resolveWith(null, [db]);
}
} else {
deferred.resolveWith(null, [db]);
}
if (fileSystem) {
deferred.resolveWith(null, [fileSystem]);
} else {
requestFileSystem(PERSISTENT, 0, function (fs) {
fileSystem = fs;
deferred.resolveWith(null, [fileSystem]);
});
}
// For future use. Currently only in latest Firefox versions
request.onupgradeneeded = function (event) {
createObjectStore(event.target.result);
};
return deferred.promise();
}
@ -75,70 +32,6 @@
var self = this;
openDb().done(function (db) {
self._db = db;
window.ImageStore = self;
});
self.addImageToDatabase = function (blob, key, deferred) {
console.log("addImageToDatabase");
// Open a transaction to the database
var transaction = self.db().transaction([imagesStoreName], "readwrite");
// Put the blob into the dabase
var putRequest = transaction.objectStore(imagesStoreName).put(blob, key);
putRequest.onsuccess = function (event) {
deferred.resolve();
};
putRequest.onerror = function () {
deferred.reject();
};
};
self.db = function () {
return self._db;
};
self.get = function (key) {
var deferred = DeferredBuilder.Deferred();
var transaction = self.db().transaction([imagesStoreName], "readonly");
// Open a transaction to the database
var getRequest = transaction.objectStore(imagesStoreName).get(key);
getRequest.onsuccess = function (event) {
var imgFile = event.target.result;
if (imgFile) {
// Get window.URL object
var URL = window.URL || window.webkitURL;
// Create and revoke ObjectURL
var imgUrl = URL.createObjectURL(imgFile);
deferred.resolveWith(null, [imgUrl]);
} else {
deferred.reject();
}
};
getRequest.onerror = function () {
deferred.reject();
};
return deferred.promise();
};
function getCacheKey(url) {
// Try to strip off the domain to share the cache between local and remote connections
@ -160,66 +53,41 @@
self.getImageUrl = function (originalUrl) {
console.log('getImageUrl:' + originalUrl);
var key = getCacheKey(originalUrl);
if ($.browser.android && originalUrl.indexOf('tag=') != -1) {
originalUrl += "&format=webp";
}
var deferred = DeferredBuilder.Deferred();
var key = getCacheKey(originalUrl);
self.get(key).done(function (url) {
console.log('getImageUrl:' + originalUrl);
deferred.resolveWith(null, [url]);
getFileSystem().done(function (fileSystem) {
var path = fileSystem.root.toURL() + "/emby/cache/" + key;
}).fail(function () {
resolveLocalFileSystemURL(path, function (fileEntry) {
var localUrl = fileEntry.toURL();
console.log('returning cached file: ' + localUrl);
console.log(localUrl);
deferred.resolveWith(null, [localUrl]);
self.downloadImage(originalUrl, key).done(function () {
self.get(key).done(function (url) {
}, function () {
deferred.resolveWith(null, [url]);
console.log('downloading: ' + originalUrl);
var ft = new FileTransfer();
ft.download(originalUrl, path, function (entry) {
}).fail(function () {
var localUrl = entry.toURL();
deferred.reject();
console.log(localUrl);
deferred.resolveWith(null, [localUrl]);
});
}).fail(function () {
deferred.reject();
});
});
return deferred.promise();
};
self.downloadImage = function (url, key) {
var deferred = DeferredBuilder.Deferred();
console.log('downloadImage:' + url);
// Create XHR
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
// Set the responseType to blob
xhr.responseType = "blob";
xhr.addEventListener("load", function () {
if (xhr.status === 200) {
console.log("Image retrieved");
// Put the received blob into IndexedDB
self.addImageToDatabase(this.response, key, deferred);
} else {
deferred.reject();
}
}, false);
// Send XHR
xhr.send();
return deferred.promise();
};
self.setImageInto = function (elem, url) {
function onFail() {
@ -232,6 +100,8 @@
}).fail(onFail);
};
window.ImageStore = self;
}
new indexedDbBlobImageStore();

View File

@ -0,0 +1,31 @@
(function () {
var currentDeferred;
function chooseDirectory() {
var deferred = DeferredBuilder.Deferred();
AndroidDirectoryChooser.chooseDirectory();
currentDeferred = deferred;
return deferred.promise();
}
function onChosen(path) {
var deferred = currentDeferred;
if (deferred) {
if (path) {
deferred.resolveWith(null, [path]);
} else {
deferred.reject();
}
currentDeferred = null;
}
}
window.NativeDirectoryChooser = {
chooseDirectory: chooseDirectory,
onChosen: onChosen
};
})();

View File

@ -1,6 +1,6 @@
(function () {
window.FileSystem = {
window.FileSystemBridge = {
fileExists: function (path) {
return false;

View File

@ -1,6 +1,6 @@
(function () {
window.FileSystem = {
window.FileSystemBridge = {
fileExists: function (path) {
return false;

View File

@ -18,7 +18,7 @@
// If less than 100, the search window ends up not getting images
// If less than 200, this happens on the home page
// Need to fix those before this can be set to 0
return 200;
return 500;
}
$.fn.unveil = function () {

View File

@ -0,0 +1,27 @@
// Copyright (c) 2014 The Polymer Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,26 @@
{
"name": "polymer",
"version": "1.0.0",
"main": [
"polymer.html"
],
"license": "http://polymer.github.io/LICENSE.txt",
"ignore": [
"/.*",
"/test/"
],
"authors": [
"The Polymer Authors (http://polymer.github.io/AUTHORS.txt)"
],
"repository": {
"type": "git",
"url": "https://github.com/Polymer/polymer.git"
},
"dependencies": {
"webcomponentsjs": "^0.7.2"
},
"devDependencies": {
"web-component-tester": "*"
},
"private": true
}

View File

@ -0,0 +1,544 @@
<!--
@license
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
--><script>(function() {
function resolve() {
document.body.removeAttribute("unresolved");
}
if (window.WebComponents) {
addEventListener("WebComponentsReady", resolve);
} else {
resolve();
}
})();
Polymer = {
Settings: function() {
var user = window.Polymer || {};
location.search.slice(1).split("&").forEach(function(o) {
o = o.split("=");
o[0] && (user[o[0]] = o[1] || true);
});
var wantShadow = user.dom === "shadow";
var hasShadow = Boolean(Element.prototype.createShadowRoot);
var nativeShadow = hasShadow && !window.ShadowDOMPolyfill;
var useShadow = wantShadow && hasShadow;
var hasNativeImports = Boolean("import" in document.createElement("link"));
var useNativeImports = hasNativeImports;
var useNativeCustomElements = !window.CustomElements || window.CustomElements.useNative;
return {
wantShadow: wantShadow,
hasShadow: hasShadow,
nativeShadow: nativeShadow,
useShadow: useShadow,
useNativeShadow: useShadow && nativeShadow,
useNativeImports: useNativeImports,
useNativeCustomElements: useNativeCustomElements
};
}()
};
(function() {
var userPolymer = window.Polymer;
window.Polymer = function(prototype) {
var ctor = desugar(prototype);
prototype = ctor.prototype;
var options = {
prototype: prototype
};
if (prototype.extends) {
options.extends = prototype.extends;
}
Polymer.telemetry._registrate(prototype);
document.registerElement(prototype.is, options);
return ctor;
};
var desugar = function(prototype) {
prototype = Polymer.Base.chainObject(prototype, Polymer.Base);
prototype.registerCallback();
return prototype.constructor;
};
window.Polymer = Polymer;
if (userPolymer) {
for (var i in userPolymer) {
Polymer[i] = userPolymer[i];
}
}
Polymer.Class = desugar;
})();
Polymer.telemetry = {
registrations: [],
_regLog: function(prototype) {
console.log("[" + prototype.is + "]: registered");
},
_registrate: function(prototype) {
this.registrations.push(prototype);
Polymer.log && this._regLog(prototype);
},
dumpRegistrations: function() {
this.registrations.forEach(this._regLog);
}
};
Object.defineProperty(window, "currentImport", {
enumerable: true,
configurable: true,
get: function() {
return (document._currentScript || document.currentScript).ownerDocument;
}
});
Polymer.Base = {
_addFeature: function(feature) {
this.extend(this, feature);
},
registerCallback: function() {
this._registerFeatures();
this._doBehavior("registered");
},
createdCallback: function() {
Polymer.telemetry.instanceCount++;
this.root = this;
this._doBehavior("created");
this._initFeatures();
},
attachedCallback: function() {
this.isAttached = true;
this._doBehavior("attached");
},
detachedCallback: function() {
this.isAttached = false;
this._doBehavior("detached");
},
attributeChangedCallback: function(name) {
this._setAttributeToProperty(this, name);
this._doBehavior("attributeChanged", arguments);
},
extend: function(prototype, api) {
if (prototype && api) {
Object.getOwnPropertyNames(api).forEach(function(n) {
this.copyOwnProperty(n, api, prototype);
}, this);
}
return prototype || api;
},
copyOwnProperty: function(name, source, target) {
var pd = Object.getOwnPropertyDescriptor(source, name);
if (pd) {
Object.defineProperty(target, name, pd);
}
},
_log: console.log.apply.bind(console.log, console),
_warn: console.warn.apply.bind(console.warn, console),
_error: console.error.apply.bind(console.error, console),
_logf: function() {
return this._logPrefix.concat([ this.is ]).concat(Array.prototype.slice.call(arguments, 0));
}
};
Polymer.Base._logPrefix = function() {
var color = window.chrome || /firefox/i.test(navigator.userAgent);
return color ? [ "%c[%s::%s]:", "font-weight: bold; background-color:#EEEE00;" ] : [ "[%s::%s]:" ];
}();
Polymer.Base.chainObject = function(object, inherited) {
if (object && inherited && object !== inherited) {
if (!Object.__proto__) {
object = Polymer.Base.extend(Object.create(inherited), object);
}
object.__proto__ = inherited;
}
return object;
};
Polymer.Base = Polymer.Base.chainObject(Polymer.Base, HTMLElement.prototype);
Polymer.telemetry.instanceCount = 0;
(function() {
var modules = {};
var DomModule = function() {
return document.createElement("dom-module");
};
DomModule.prototype = Object.create(HTMLElement.prototype);
DomModule.prototype.constructor = DomModule;
DomModule.prototype.createdCallback = function() {
var id = this.id || this.getAttribute("name") || this.getAttribute("is");
if (id) {
this.id = id;
modules[id] = this;
}
};
DomModule.prototype.import = function(id, slctr) {
var m = modules[id];
if (!m) {
forceDocumentUpgrade();
m = modules[id];
}
if (m && slctr) {
m = m.querySelector(slctr);
}
return m;
};
var cePolyfill = window.CustomElements && !CustomElements.useNative;
if (cePolyfill) {
var ready = CustomElements.ready;
CustomElements.ready = true;
}
document.registerElement("dom-module", DomModule);
if (cePolyfill) {
CustomElements.ready = ready;
}
function forceDocumentUpgrade() {
if (cePolyfill) {
var script = document._currentScript || document.currentScript;
if (script) {
CustomElements.upgradeAll(script.ownerDocument);
}
}
}
})();
Polymer.Base._addFeature({
_prepIs: function() {
if (!this.is) {
var module = (document._currentScript || document.currentScript).parentNode;
if (module.localName === "dom-module") {
var id = module.id || module.getAttribute("name") || module.getAttribute("is");
this.is = id;
}
}
}
});
Polymer.Base._addFeature({
behaviors: [],
_prepBehaviors: function() {
if (this.behaviors.length) {
this.behaviors = this._flattenBehaviorsList(this.behaviors);
}
this._prepAllBehaviors(this.behaviors);
},
_flattenBehaviorsList: function(behaviors) {
var flat = [];
behaviors.forEach(function(b) {
if (b instanceof Array) {
flat = flat.concat(this._flattenBehaviorsList(b));
} else if (b) {
flat.push(b);
} else {
this._warn(this._logf("_flattenBehaviorsList", "behavior is null, check for missing or 404 import"));
}
}, this);
return flat;
},
_prepAllBehaviors: function(behaviors) {
for (var i = behaviors.length - 1; i >= 0; i--) {
this._mixinBehavior(behaviors[i]);
}
for (var i = 0, l = behaviors.length; i < l; i++) {
this._prepBehavior(behaviors[i]);
}
this._prepBehavior(this);
},
_mixinBehavior: function(b) {
Object.getOwnPropertyNames(b).forEach(function(n) {
switch (n) {
case "hostAttributes":
case "registered":
case "properties":
case "observers":
case "listeners":
case "created":
case "attached":
case "detached":
case "attributeChanged":
case "configure":
case "ready":
break;
default:
if (!this.hasOwnProperty(n)) {
this.copyOwnProperty(n, b, this);
}
break;
}
}, this);
},
_doBehavior: function(name, args) {
this.behaviors.forEach(function(b) {
this._invokeBehavior(b, name, args);
}, this);
this._invokeBehavior(this, name, args);
},
_invokeBehavior: function(b, name, args) {
var fn = b[name];
if (fn) {
fn.apply(this, args || Polymer.nar);
}
},
_marshalBehaviors: function() {
this.behaviors.forEach(function(b) {
this._marshalBehavior(b);
}, this);
this._marshalBehavior(this);
}
});
Polymer.Base._addFeature({
_prepExtends: function() {
if (this.extends) {
this.__proto__ = this._getExtendedPrototype(this.extends);
}
},
_getExtendedPrototype: function(tag) {
return this._getExtendedNativePrototype(tag);
},
_nativePrototypes: {},
_getExtendedNativePrototype: function(tag) {
var p = this._nativePrototypes[tag];
if (!p) {
var np = this.getNativePrototype(tag);
p = this.extend(Object.create(np), Polymer.Base);
this._nativePrototypes[tag] = p;
}
return p;
},
getNativePrototype: function(tag) {
return Object.getPrototypeOf(document.createElement(tag));
}
});
Polymer.Base._addFeature({
_prepConstructor: function() {
this._factoryArgs = this.extends ? [ this.extends, this.is ] : [ this.is ];
var ctor = function() {
return this._factory(arguments);
};
if (this.hasOwnProperty("extends")) {
ctor.extends = this.extends;
}
Object.defineProperty(this, "constructor", {
value: ctor,
writable: true,
configurable: true
});
ctor.prototype = this;
},
_factory: function(args) {
var elt = document.createElement.apply(document, this._factoryArgs);
if (this.factoryImpl) {
this.factoryImpl.apply(elt, args);
}
return elt;
}
});
Polymer.nob = Object.create(null);
Polymer.Base._addFeature({
properties: {},
getPropertyInfo: function(property) {
var info = this._getPropertyInfo(property, this.properties);
if (!info) {
this.behaviors.some(function(b) {
return info = this._getPropertyInfo(property, b.properties);
}, this);
}
return info || Polymer.nob;
},
_getPropertyInfo: function(property, properties) {
var p = properties && properties[property];
if (typeof p === "function") {
p = properties[property] = {
type: p
};
}
if (p) {
p.defined = true;
}
return p;
}
});
Polymer.CaseMap = {
_caseMap: {},
dashToCamelCase: function(dash) {
var mapped = Polymer.CaseMap._caseMap[dash];
if (mapped) {
return mapped;
}
if (dash.indexOf("-") < 0) {
return Polymer.CaseMap._caseMap[dash] = dash;
}
return Polymer.CaseMap._caseMap[dash] = dash.replace(/-([a-z])/g, function(m) {
return m[1].toUpperCase();
});
},
camelToDashCase: function(camel) {
var mapped = Polymer.CaseMap._caseMap[camel];
if (mapped) {
return mapped;
}
return Polymer.CaseMap._caseMap[camel] = camel.replace(/([a-z][A-Z])/g, function(g) {
return g[0] + "-" + g[1].toLowerCase();
});
}
};
Polymer.Base._addFeature({
_prepAttributes: function() {
this._aggregatedAttributes = {};
},
_addHostAttributes: function(attributes) {
if (attributes) {
this.mixin(this._aggregatedAttributes, attributes);
}
},
_marshalHostAttributes: function() {
this._applyAttributes(this, this._aggregatedAttributes);
},
_applyAttributes: function(node, attr$) {
for (var n in attr$) {
if (!this.hasAttribute(n) && n !== "class") {
this.serializeValueToAttribute(attr$[n], n, this);
}
}
},
_marshalAttributes: function() {
this._takeAttributesToModel(this);
},
_takeAttributesToModel: function(model) {
for (var i = 0, l = this.attributes.length; i < l; i++) {
this._setAttributeToProperty(model, this.attributes[i].name);
}
},
_setAttributeToProperty: function(model, attrName) {
if (!this._serializing) {
var propName = Polymer.CaseMap.dashToCamelCase(attrName);
var info = this.getPropertyInfo(propName);
if (info.defined || this._propertyEffects && this._propertyEffects[propName]) {
var val = this.getAttribute(attrName);
model[propName] = this.deserialize(val, info.type);
}
}
},
_serializing: false,
reflectPropertyToAttribute: function(name) {
this._serializing = true;
this.serializeValueToAttribute(this[name], Polymer.CaseMap.camelToDashCase(name));
this._serializing = false;
},
serializeValueToAttribute: function(value, attribute, node) {
var str = this.serialize(value);
(node || this)[str === undefined ? "removeAttribute" : "setAttribute"](attribute, str);
},
deserialize: function(value, type) {
switch (type) {
case Number:
value = Number(value);
break;
case Boolean:
value = value !== null;
break;
case Object:
try {
value = JSON.parse(value);
} catch (x) {}
break;
case Array:
try {
value = JSON.parse(value);
} catch (x) {
value = null;
console.warn("Polymer::Attributes: couldn`t decode Array as JSON");
}
break;
case Date:
value = new Date(value);
break;
case String:
default:
break;
}
return value;
},
serialize: function(value) {
switch (typeof value) {
case "boolean":
return value ? "" : undefined;
case "object":
if (value instanceof Date) {
return value;
} else if (value) {
try {
return JSON.stringify(value);
} catch (x) {
return "";
}
}
default:
return value != null ? value : undefined;
}
}
});
Polymer.Base._addFeature({
_setupDebouncers: function() {
this._debouncers = {};
},
debounce: function(jobName, callback, wait) {
this._debouncers[jobName] = Polymer.Debounce.call(this, this._debouncers[jobName], callback, wait);
},
isDebouncerActive: function(jobName) {
var debouncer = this._debouncers[jobName];
return debouncer && debouncer.finish;
},
flushDebouncer: function(jobName) {
var debouncer = this._debouncers[jobName];
if (debouncer) {
debouncer.complete();
}
},
cancelDebouncer: function(jobName) {
var debouncer = this._debouncers[jobName];
if (debouncer) {
debouncer.stop();
}
}
});
Polymer.version = "1.0.0";
Polymer.Base._addFeature({
_registerFeatures: function() {
this._prepIs();
this._prepAttributes();
this._prepBehaviors();
this._prepExtends();
this._prepConstructor();
},
_prepBehavior: function(b) {
this._addHostAttributes(b.hostAttributes);
},
_marshalBehavior: function(b) {},
_initFeatures: function() {
this._marshalHostAttributes();
this._setupDebouncers();
this._marshalBehaviors();
}
});</script>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,956 @@
/**
* @license
* 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
*/
// @version 0.7.3
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
var counter = Date.now() % 1e9;
var WeakMap = function() {
this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
};
WeakMap.prototype = {
set: function(key, value) {
var entry = key[this.name];
if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
value: [ key, value ],
writable: true
});
return this;
},
get: function(key) {
var entry;
return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
},
"delete": function(key) {
var entry = key[this.name];
if (!entry || entry[0] !== key) return false;
entry[0] = entry[1] = undefined;
return true;
},
has: function(key) {
var entry = key[this.name];
if (!entry) return false;
return entry[0] === key;
}
};
window.WeakMap = WeakMap;
})();
}
(function(global) {
var registrationsTable = new WeakMap();
var setImmediate;
if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout;
} else if (window.setImmediate) {
setImmediate = window.setImmediate;
} else {
var setImmediateQueue = [];
var sentinel = String(Math.random());
window.addEventListener("message", function(e) {
if (e.data === sentinel) {
var queue = setImmediateQueue;
setImmediateQueue = [];
queue.forEach(function(func) {
func();
});
}
});
setImmediate = function(func) {
setImmediateQueue.push(func);
window.postMessage(sentinel, "*");
};
}
var isScheduled = false;
var scheduledObservers = [];
function scheduleCallback(observer) {
scheduledObservers.push(observer);
if (!isScheduled) {
isScheduled = true;
setImmediate(dispatchCallbacks);
}
}
function wrapIfNeeded(node) {
return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
}
function dispatchCallbacks() {
isScheduled = false;
var observers = scheduledObservers;
scheduledObservers = [];
observers.sort(function(o1, o2) {
return o1.uid_ - o2.uid_;
});
var anyNonEmpty = false;
observers.forEach(function(observer) {
var queue = observer.takeRecords();
removeTransientObserversFor(observer);
if (queue.length) {
observer.callback_(queue, observer);
anyNonEmpty = true;
}
});
if (anyNonEmpty) dispatchCallbacks();
}
function removeTransientObserversFor(observer) {
observer.nodes_.forEach(function(node) {
var registrations = registrationsTable.get(node);
if (!registrations) return;
registrations.forEach(function(registration) {
if (registration.observer === observer) registration.removeTransientObservers();
});
});
}
function forEachAncestorAndObserverEnqueueRecord(target, callback) {
for (var node = target; node; node = node.parentNode) {
var registrations = registrationsTable.get(node);
if (registrations) {
for (var j = 0; j < registrations.length; j++) {
var registration = registrations[j];
var options = registration.options;
if (node !== target && !options.subtree) continue;
var record = callback(options);
if (record) registration.enqueue(record);
}
}
}
}
var uidCounter = 0;
function JsMutationObserver(callback) {
this.callback_ = callback;
this.nodes_ = [];
this.records_ = [];
this.uid_ = ++uidCounter;
}
JsMutationObserver.prototype = {
observe: function(target, options) {
target = wrapIfNeeded(target);
if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
throw new SyntaxError();
}
var registrations = registrationsTable.get(target);
if (!registrations) registrationsTable.set(target, registrations = []);
var registration;
for (var i = 0; i < registrations.length; i++) {
if (registrations[i].observer === this) {
registration = registrations[i];
registration.removeListeners();
registration.options = options;
break;
}
}
if (!registration) {
registration = new Registration(this, target, options);
registrations.push(registration);
this.nodes_.push(target);
}
registration.addListeners();
},
disconnect: function() {
this.nodes_.forEach(function(node) {
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
var registration = registrations[i];
if (registration.observer === this) {
registration.removeListeners();
registrations.splice(i, 1);
break;
}
}
}, this);
this.records_ = [];
},
takeRecords: function() {
var copyOfRecords = this.records_;
this.records_ = [];
return copyOfRecords;
}
};
function MutationRecord(type, target) {
this.type = type;
this.target = target;
this.addedNodes = [];
this.removedNodes = [];
this.previousSibling = null;
this.nextSibling = null;
this.attributeName = null;
this.attributeNamespace = null;
this.oldValue = null;
}
function copyMutationRecord(original) {
var record = new MutationRecord(original.type, original.target);
record.addedNodes = original.addedNodes.slice();
record.removedNodes = original.removedNodes.slice();
record.previousSibling = original.previousSibling;
record.nextSibling = original.nextSibling;
record.attributeName = original.attributeName;
record.attributeNamespace = original.attributeNamespace;
record.oldValue = original.oldValue;
return record;
}
var currentRecord, recordWithOldValue;
function getRecord(type, target) {
return currentRecord = new MutationRecord(type, target);
}
function getRecordWithOldValue(oldValue) {
if (recordWithOldValue) return recordWithOldValue;
recordWithOldValue = copyMutationRecord(currentRecord);
recordWithOldValue.oldValue = oldValue;
return recordWithOldValue;
}
function clearRecords() {
currentRecord = recordWithOldValue = undefined;
}
function recordRepresentsCurrentMutation(record) {
return record === recordWithOldValue || record === currentRecord;
}
function selectRecord(lastRecord, newRecord) {
if (lastRecord === newRecord) return lastRecord;
if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
return null;
}
function Registration(observer, target, options) {
this.observer = observer;
this.target = target;
this.options = options;
this.transientObservedNodes = [];
}
Registration.prototype = {
enqueue: function(record) {
var records = this.observer.records_;
var length = records.length;
if (records.length > 0) {
var lastRecord = records[length - 1];
var recordToReplaceLast = selectRecord(lastRecord, record);
if (recordToReplaceLast) {
records[length - 1] = recordToReplaceLast;
return;
}
} else {
scheduleCallback(this.observer);
}
records[length] = record;
},
addListeners: function() {
this.addListeners_(this.target);
},
addListeners_: function(node) {
var options = this.options;
if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
},
removeListeners: function() {
this.removeListeners_(this.target);
},
removeListeners_: function(node) {
var options = this.options;
if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
},
addTransientObserver: function(node) {
if (node === this.target) return;
this.addListeners_(node);
this.transientObservedNodes.push(node);
var registrations = registrationsTable.get(node);
if (!registrations) registrationsTable.set(node, registrations = []);
registrations.push(this);
},
removeTransientObservers: function() {
var transientObservedNodes = this.transientObservedNodes;
this.transientObservedNodes = [];
transientObservedNodes.forEach(function(node) {
this.removeListeners_(node);
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
if (registrations[i] === this) {
registrations.splice(i, 1);
break;
}
}
}, this);
},
handleEvent: function(e) {
e.stopImmediatePropagation();
switch (e.type) {
case "DOMAttrModified":
var name = e.attrName;
var namespace = e.relatedNode.namespaceURI;
var target = e.target;
var record = new getRecord("attributes", target);
record.attributeName = name;
record.attributeNamespace = namespace;
var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
if (!options.attributes) return;
if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
return;
}
if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMCharacterDataModified":
var target = e.target;
var record = getRecord("characterData", target);
var oldValue = e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
if (!options.characterData) return;
if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMNodeRemoved":
this.addTransientObserver(e.target);
case "DOMNodeInserted":
var changedNode = e.target;
var addedNodes, removedNodes;
if (e.type === "DOMNodeInserted") {
addedNodes = [ changedNode ];
removedNodes = [];
} else {
addedNodes = [];
removedNodes = [ changedNode ];
}
var previousSibling = changedNode.previousSibling;
var nextSibling = changedNode.nextSibling;
var record = getRecord("childList", e.target.parentNode);
record.addedNodes = addedNodes;
record.removedNodes = removedNodes;
record.previousSibling = previousSibling;
record.nextSibling = nextSibling;
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
if (!options.childList) return;
return record;
});
}
clearRecords();
}
};
global.JsMutationObserver = JsMutationObserver;
if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
})(this);
window.CustomElements = window.CustomElements || {
flags: {}
};
(function(scope) {
var flags = scope.flags;
var modules = [];
var addModule = function(module) {
modules.push(module);
};
var initializeModules = function() {
modules.forEach(function(module) {
module(scope);
});
};
scope.addModule = addModule;
scope.initializeModules = initializeModules;
scope.hasNative = Boolean(document.registerElement);
scope.useNative = !flags.register && scope.hasNative && !window.ShadowDOMPolyfill && (!window.HTMLImports || HTMLImports.useNative);
})(window.CustomElements);
window.CustomElements.addModule(function(scope) {
var IMPORT_LINK_TYPE = window.HTMLImports ? HTMLImports.IMPORT_LINK_TYPE : "none";
function forSubtree(node, cb) {
findAllElements(node, function(e) {
if (cb(e)) {
return true;
}
forRoots(e, cb);
});
forRoots(node, cb);
}
function findAllElements(node, find, data) {
var e = node.firstElementChild;
if (!e) {
e = node.firstChild;
while (e && e.nodeType !== Node.ELEMENT_NODE) {
e = e.nextSibling;
}
}
while (e) {
if (find(e, data) !== true) {
findAllElements(e, find, data);
}
e = e.nextElementSibling;
}
return null;
}
function forRoots(node, cb) {
var root = node.shadowRoot;
while (root) {
forSubtree(root, cb);
root = root.olderShadowRoot;
}
}
function forDocumentTree(doc, cb) {
_forDocumentTree(doc, cb, []);
}
function _forDocumentTree(doc, cb, processingDocuments) {
doc = wrap(doc);
if (processingDocuments.indexOf(doc) >= 0) {
return;
}
processingDocuments.push(doc);
var imports = doc.querySelectorAll("link[rel=" + IMPORT_LINK_TYPE + "]");
for (var i = 0, l = imports.length, n; i < l && (n = imports[i]); i++) {
if (n.import) {
_forDocumentTree(n.import, cb, processingDocuments);
}
}
cb(doc);
}
scope.forDocumentTree = forDocumentTree;
scope.forSubtree = forSubtree;
});
window.CustomElements.addModule(function(scope) {
var flags = scope.flags;
var forSubtree = scope.forSubtree;
var forDocumentTree = scope.forDocumentTree;
function addedNode(node) {
return added(node) || addedSubtree(node);
}
function added(node) {
if (scope.upgrade(node)) {
return true;
}
attached(node);
}
function addedSubtree(node) {
forSubtree(node, function(e) {
if (added(e)) {
return true;
}
});
}
function attachedNode(node) {
attached(node);
if (inDocument(node)) {
forSubtree(node, function(e) {
attached(e);
});
}
}
var hasPolyfillMutations = !window.MutationObserver || window.MutationObserver === window.JsMutationObserver;
scope.hasPolyfillMutations = hasPolyfillMutations;
var isPendingMutations = false;
var pendingMutations = [];
function deferMutation(fn) {
pendingMutations.push(fn);
if (!isPendingMutations) {
isPendingMutations = true;
setTimeout(takeMutations);
}
}
function takeMutations() {
isPendingMutations = false;
var $p = pendingMutations;
for (var i = 0, l = $p.length, p; i < l && (p = $p[i]); i++) {
p();
}
pendingMutations = [];
}
function attached(element) {
if (hasPolyfillMutations) {
deferMutation(function() {
_attached(element);
});
} else {
_attached(element);
}
}
function _attached(element) {
if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) {
if (!element.__attached && inDocument(element)) {
element.__attached = true;
if (element.attachedCallback) {
element.attachedCallback();
}
}
}
}
function detachedNode(node) {
detached(node);
forSubtree(node, function(e) {
detached(e);
});
}
function detached(element) {
if (hasPolyfillMutations) {
deferMutation(function() {
_detached(element);
});
} else {
_detached(element);
}
}
function _detached(element) {
if (element.__upgraded__ && (element.attachedCallback || element.detachedCallback)) {
if (element.__attached && !inDocument(element)) {
element.__attached = false;
if (element.detachedCallback) {
element.detachedCallback();
}
}
}
}
function inDocument(element) {
var p = element;
var doc = wrap(document);
while (p) {
if (p == doc) {
return true;
}
p = p.parentNode || p.nodeType === Node.DOCUMENT_FRAGMENT_NODE && p.host;
}
}
function watchShadow(node) {
if (node.shadowRoot && !node.shadowRoot.__watched) {
flags.dom && console.log("watching shadow-root for: ", node.localName);
var root = node.shadowRoot;
while (root) {
observe(root);
root = root.olderShadowRoot;
}
}
}
function handler(mutations) {
if (flags.dom) {
var mx = mutations[0];
if (mx && mx.type === "childList" && mx.addedNodes) {
if (mx.addedNodes) {
var d = mx.addedNodes[0];
while (d && d !== document && !d.host) {
d = d.parentNode;
}
var u = d && (d.URL || d._URL || d.host && d.host.localName) || "";
u = u.split("/?").shift().split("/").pop();
}
}
console.group("mutations (%d) [%s]", mutations.length, u || "");
}
mutations.forEach(function(mx) {
if (mx.type === "childList") {
forEach(mx.addedNodes, function(n) {
if (!n.localName) {
return;
}
addedNode(n);
});
forEach(mx.removedNodes, function(n) {
if (!n.localName) {
return;
}
detachedNode(n);
});
}
});
flags.dom && console.groupEnd();
}
function takeRecords(node) {
node = wrap(node);
if (!node) {
node = wrap(document);
}
while (node.parentNode) {
node = node.parentNode;
}
var observer = node.__observer;
if (observer) {
handler(observer.takeRecords());
takeMutations();
}
}
var forEach = Array.prototype.forEach.call.bind(Array.prototype.forEach);
function observe(inRoot) {
if (inRoot.__observer) {
return;
}
var observer = new MutationObserver(handler);
observer.observe(inRoot, {
childList: true,
subtree: true
});
inRoot.__observer = observer;
}
function upgradeDocument(doc) {
doc = wrap(doc);
flags.dom && console.group("upgradeDocument: ", doc.baseURI.split("/").pop());
addedNode(doc);
observe(doc);
flags.dom && console.groupEnd();
}
function upgradeDocumentTree(doc) {
forDocumentTree(doc, upgradeDocument);
}
var originalCreateShadowRoot = Element.prototype.createShadowRoot;
if (originalCreateShadowRoot) {
Element.prototype.createShadowRoot = function() {
var root = originalCreateShadowRoot.call(this);
CustomElements.watchShadow(this);
return root;
};
}
scope.watchShadow = watchShadow;
scope.upgradeDocumentTree = upgradeDocumentTree;
scope.upgradeSubtree = addedSubtree;
scope.upgradeAll = addedNode;
scope.attachedNode = attachedNode;
scope.takeRecords = takeRecords;
});
window.CustomElements.addModule(function(scope) {
var flags = scope.flags;
function upgrade(node) {
if (!node.__upgraded__ && node.nodeType === Node.ELEMENT_NODE) {
var is = node.getAttribute("is");
var definition = scope.getRegisteredDefinition(is || node.localName);
if (definition) {
if (is && definition.tag == node.localName) {
return upgradeWithDefinition(node, definition);
} else if (!is && !definition.extends) {
return upgradeWithDefinition(node, definition);
}
}
}
}
function upgradeWithDefinition(element, definition) {
flags.upgrade && console.group("upgrade:", element.localName);
if (definition.is) {
element.setAttribute("is", definition.is);
}
implementPrototype(element, definition);
element.__upgraded__ = true;
created(element);
scope.attachedNode(element);
scope.upgradeSubtree(element);
flags.upgrade && console.groupEnd();
return element;
}
function implementPrototype(element, definition) {
if (Object.__proto__) {
element.__proto__ = definition.prototype;
} else {
customMixin(element, definition.prototype, definition.native);
element.__proto__ = definition.prototype;
}
}
function customMixin(inTarget, inSrc, inNative) {
var used = {};
var p = inSrc;
while (p !== inNative && p !== HTMLElement.prototype) {
var keys = Object.getOwnPropertyNames(p);
for (var i = 0, k; k = keys[i]; i++) {
if (!used[k]) {
Object.defineProperty(inTarget, k, Object.getOwnPropertyDescriptor(p, k));
used[k] = 1;
}
}
p = Object.getPrototypeOf(p);
}
}
function created(element) {
if (element.createdCallback) {
element.createdCallback();
}
}
scope.upgrade = upgrade;
scope.upgradeWithDefinition = upgradeWithDefinition;
scope.implementPrototype = implementPrototype;
});
window.CustomElements.addModule(function(scope) {
var isIE11OrOlder = scope.isIE11OrOlder;
var upgradeDocumentTree = scope.upgradeDocumentTree;
var upgradeAll = scope.upgradeAll;
var upgradeWithDefinition = scope.upgradeWithDefinition;
var implementPrototype = scope.implementPrototype;
var useNative = scope.useNative;
function register(name, options) {
var definition = options || {};
if (!name) {
throw new Error("document.registerElement: first argument `name` must not be empty");
}
if (name.indexOf("-") < 0) {
throw new Error("document.registerElement: first argument ('name') must contain a dash ('-'). Argument provided was '" + String(name) + "'.");
}
if (isReservedTag(name)) {
throw new Error("Failed to execute 'registerElement' on 'Document': Registration failed for type '" + String(name) + "'. The type name is invalid.");
}
if (getRegisteredDefinition(name)) {
throw new Error("DuplicateDefinitionError: a type with name '" + String(name) + "' is already registered");
}
if (!definition.prototype) {
definition.prototype = Object.create(HTMLElement.prototype);
}
definition.__name = name.toLowerCase();
definition.lifecycle = definition.lifecycle || {};
definition.ancestry = ancestry(definition.extends);
resolveTagName(definition);
resolvePrototypeChain(definition);
overrideAttributeApi(definition.prototype);
registerDefinition(definition.__name, definition);
definition.ctor = generateConstructor(definition);
definition.ctor.prototype = definition.prototype;
definition.prototype.constructor = definition.ctor;
if (scope.ready) {
upgradeDocumentTree(document);
}
return definition.ctor;
}
function overrideAttributeApi(prototype) {
if (prototype.setAttribute._polyfilled) {
return;
}
var setAttribute = prototype.setAttribute;
prototype.setAttribute = function(name, value) {
changeAttribute.call(this, name, value, setAttribute);
};
var removeAttribute = prototype.removeAttribute;
prototype.removeAttribute = function(name) {
changeAttribute.call(this, name, null, removeAttribute);
};
prototype.setAttribute._polyfilled = true;
}
function changeAttribute(name, value, operation) {
name = name.toLowerCase();
var oldValue = this.getAttribute(name);
operation.apply(this, arguments);
var newValue = this.getAttribute(name);
if (this.attributeChangedCallback && newValue !== oldValue) {
this.attributeChangedCallback(name, oldValue, newValue);
}
}
function isReservedTag(name) {
for (var i = 0; i < reservedTagList.length; i++) {
if (name === reservedTagList[i]) {
return true;
}
}
}
var reservedTagList = [ "annotation-xml", "color-profile", "font-face", "font-face-src", "font-face-uri", "font-face-format", "font-face-name", "missing-glyph" ];
function ancestry(extnds) {
var extendee = getRegisteredDefinition(extnds);
if (extendee) {
return ancestry(extendee.extends).concat([ extendee ]);
}
return [];
}
function resolveTagName(definition) {
var baseTag = definition.extends;
for (var i = 0, a; a = definition.ancestry[i]; i++) {
baseTag = a.is && a.tag;
}
definition.tag = baseTag || definition.__name;
if (baseTag) {
definition.is = definition.__name;
}
}
function resolvePrototypeChain(definition) {
if (!Object.__proto__) {
var nativePrototype = HTMLElement.prototype;
if (definition.is) {
var inst = document.createElement(definition.tag);
var expectedPrototype = Object.getPrototypeOf(inst);
if (expectedPrototype === definition.prototype) {
nativePrototype = expectedPrototype;
}
}
var proto = definition.prototype, ancestor;
while (proto && proto !== nativePrototype) {
ancestor = Object.getPrototypeOf(proto);
proto.__proto__ = ancestor;
proto = ancestor;
}
definition.native = nativePrototype;
}
}
function instantiate(definition) {
return upgradeWithDefinition(domCreateElement(definition.tag), definition);
}
var registry = {};
function getRegisteredDefinition(name) {
if (name) {
return registry[name.toLowerCase()];
}
}
function registerDefinition(name, definition) {
registry[name] = definition;
}
function generateConstructor(definition) {
return function() {
return instantiate(definition);
};
}
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
function createElementNS(namespace, tag, typeExtension) {
if (namespace === HTML_NAMESPACE) {
return createElement(tag, typeExtension);
} else {
return domCreateElementNS(namespace, tag);
}
}
function createElement(tag, typeExtension) {
if (tag) {
tag = tag.toLowerCase();
}
if (typeExtension) {
typeExtension = typeExtension.toLowerCase();
}
var definition = getRegisteredDefinition(typeExtension || tag);
if (definition) {
if (tag == definition.tag && typeExtension == definition.is) {
return new definition.ctor();
}
if (!typeExtension && !definition.is) {
return new definition.ctor();
}
}
var element;
if (typeExtension) {
element = createElement(tag);
element.setAttribute("is", typeExtension);
return element;
}
element = domCreateElement(tag);
if (tag.indexOf("-") >= 0) {
implementPrototype(element, HTMLElement);
}
return element;
}
var domCreateElement = document.createElement.bind(document);
var domCreateElementNS = document.createElementNS.bind(document);
var isInstance;
if (!Object.__proto__ && !useNative) {
isInstance = function(obj, ctor) {
var p = obj;
while (p) {
if (p === ctor.prototype) {
return true;
}
p = p.__proto__;
}
return false;
};
} else {
isInstance = function(obj, base) {
return obj instanceof base;
};
}
function wrapDomMethodToForceUpgrade(obj, methodName) {
var orig = obj[methodName];
obj[methodName] = function() {
var n = orig.apply(this, arguments);
upgradeAll(n);
return n;
};
}
wrapDomMethodToForceUpgrade(Node.prototype, "cloneNode");
wrapDomMethodToForceUpgrade(document, "importNode");
if (isIE11OrOlder) {
(function() {
var importNode = document.importNode;
document.importNode = function() {
var n = importNode.apply(document, arguments);
if (n.nodeType == n.DOCUMENT_FRAGMENT_NODE) {
var f = document.createDocumentFragment();
f.appendChild(n);
return f;
} else {
return n;
}
};
})();
}
document.registerElement = register;
document.createElement = createElement;
document.createElementNS = createElementNS;
scope.registry = registry;
scope.instanceof = isInstance;
scope.reservedTagList = reservedTagList;
scope.getRegisteredDefinition = getRegisteredDefinition;
document.register = document.registerElement;
});
(function(scope) {
var useNative = scope.useNative;
var initializeModules = scope.initializeModules;
var isIE11OrOlder = /Trident/.test(navigator.userAgent);
if (useNative) {
var nop = function() {};
scope.watchShadow = nop;
scope.upgrade = nop;
scope.upgradeAll = nop;
scope.upgradeDocumentTree = nop;
scope.upgradeSubtree = nop;
scope.takeRecords = nop;
scope.instanceof = function(obj, base) {
return obj instanceof base;
};
} else {
initializeModules();
}
var upgradeDocumentTree = scope.upgradeDocumentTree;
if (!window.wrap) {
if (window.ShadowDOMPolyfill) {
window.wrap = ShadowDOMPolyfill.wrapIfNeeded;
window.unwrap = ShadowDOMPolyfill.unwrapIfNeeded;
} else {
window.wrap = window.unwrap = function(node) {
return node;
};
}
}
function bootstrap() {
upgradeDocumentTree(wrap(document));
if (window.HTMLImports) {
HTMLImports.__importsParsingHook = function(elt) {
upgradeDocumentTree(wrap(elt.import));
};
}
CustomElements.ready = true;
setTimeout(function() {
CustomElements.readyTime = Date.now();
if (window.HTMLImports) {
CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime;
}
document.dispatchEvent(new CustomEvent("WebComponentsReady", {
bubbles: true
}));
});
}
if (isIE11OrOlder && typeof window.CustomEvent !== "function") {
window.CustomEvent = function(inType, params) {
params = params || {};
var e = document.createEvent("CustomEvent");
e.initCustomEvent(inType, Boolean(params.bubbles), Boolean(params.cancelable), params.detail);
return e;
};
window.CustomEvent.prototype = window.Event.prototype;
}
if (document.readyState === "complete" || scope.flags.eager) {
bootstrap();
} else if (document.readyState === "interactive" && !window.attachEvent && (!window.HTMLImports || window.HTMLImports.ready)) {
bootstrap();
} else {
var loadEvent = window.HTMLImports && !HTMLImports.ready ? "HTMLImportsLoaded" : "DOMContentLoaded";
window.addEventListener(loadEvent, bootstrap);
}
scope.isIE11OrOlder = isIE11OrOlder;
})(window.CustomElements);

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,344 @@
/**
* @license
* 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
*/
// @version 0.7.3
if (typeof WeakMap === "undefined") {
(function() {
var defineProperty = Object.defineProperty;
var counter = Date.now() % 1e9;
var WeakMap = function() {
this.name = "__st" + (Math.random() * 1e9 >>> 0) + (counter++ + "__");
};
WeakMap.prototype = {
set: function(key, value) {
var entry = key[this.name];
if (entry && entry[0] === key) entry[1] = value; else defineProperty(key, this.name, {
value: [ key, value ],
writable: true
});
return this;
},
get: function(key) {
var entry;
return (entry = key[this.name]) && entry[0] === key ? entry[1] : undefined;
},
"delete": function(key) {
var entry = key[this.name];
if (!entry || entry[0] !== key) return false;
entry[0] = entry[1] = undefined;
return true;
},
has: function(key) {
var entry = key[this.name];
if (!entry) return false;
return entry[0] === key;
}
};
window.WeakMap = WeakMap;
})();
}
(function(global) {
var registrationsTable = new WeakMap();
var setImmediate;
if (/Trident|Edge/.test(navigator.userAgent)) {
setImmediate = setTimeout;
} else if (window.setImmediate) {
setImmediate = window.setImmediate;
} else {
var setImmediateQueue = [];
var sentinel = String(Math.random());
window.addEventListener("message", function(e) {
if (e.data === sentinel) {
var queue = setImmediateQueue;
setImmediateQueue = [];
queue.forEach(function(func) {
func();
});
}
});
setImmediate = function(func) {
setImmediateQueue.push(func);
window.postMessage(sentinel, "*");
};
}
var isScheduled = false;
var scheduledObservers = [];
function scheduleCallback(observer) {
scheduledObservers.push(observer);
if (!isScheduled) {
isScheduled = true;
setImmediate(dispatchCallbacks);
}
}
function wrapIfNeeded(node) {
return window.ShadowDOMPolyfill && window.ShadowDOMPolyfill.wrapIfNeeded(node) || node;
}
function dispatchCallbacks() {
isScheduled = false;
var observers = scheduledObservers;
scheduledObservers = [];
observers.sort(function(o1, o2) {
return o1.uid_ - o2.uid_;
});
var anyNonEmpty = false;
observers.forEach(function(observer) {
var queue = observer.takeRecords();
removeTransientObserversFor(observer);
if (queue.length) {
observer.callback_(queue, observer);
anyNonEmpty = true;
}
});
if (anyNonEmpty) dispatchCallbacks();
}
function removeTransientObserversFor(observer) {
observer.nodes_.forEach(function(node) {
var registrations = registrationsTable.get(node);
if (!registrations) return;
registrations.forEach(function(registration) {
if (registration.observer === observer) registration.removeTransientObservers();
});
});
}
function forEachAncestorAndObserverEnqueueRecord(target, callback) {
for (var node = target; node; node = node.parentNode) {
var registrations = registrationsTable.get(node);
if (registrations) {
for (var j = 0; j < registrations.length; j++) {
var registration = registrations[j];
var options = registration.options;
if (node !== target && !options.subtree) continue;
var record = callback(options);
if (record) registration.enqueue(record);
}
}
}
}
var uidCounter = 0;
function JsMutationObserver(callback) {
this.callback_ = callback;
this.nodes_ = [];
this.records_ = [];
this.uid_ = ++uidCounter;
}
JsMutationObserver.prototype = {
observe: function(target, options) {
target = wrapIfNeeded(target);
if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
throw new SyntaxError();
}
var registrations = registrationsTable.get(target);
if (!registrations) registrationsTable.set(target, registrations = []);
var registration;
for (var i = 0; i < registrations.length; i++) {
if (registrations[i].observer === this) {
registration = registrations[i];
registration.removeListeners();
registration.options = options;
break;
}
}
if (!registration) {
registration = new Registration(this, target, options);
registrations.push(registration);
this.nodes_.push(target);
}
registration.addListeners();
},
disconnect: function() {
this.nodes_.forEach(function(node) {
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
var registration = registrations[i];
if (registration.observer === this) {
registration.removeListeners();
registrations.splice(i, 1);
break;
}
}
}, this);
this.records_ = [];
},
takeRecords: function() {
var copyOfRecords = this.records_;
this.records_ = [];
return copyOfRecords;
}
};
function MutationRecord(type, target) {
this.type = type;
this.target = target;
this.addedNodes = [];
this.removedNodes = [];
this.previousSibling = null;
this.nextSibling = null;
this.attributeName = null;
this.attributeNamespace = null;
this.oldValue = null;
}
function copyMutationRecord(original) {
var record = new MutationRecord(original.type, original.target);
record.addedNodes = original.addedNodes.slice();
record.removedNodes = original.removedNodes.slice();
record.previousSibling = original.previousSibling;
record.nextSibling = original.nextSibling;
record.attributeName = original.attributeName;
record.attributeNamespace = original.attributeNamespace;
record.oldValue = original.oldValue;
return record;
}
var currentRecord, recordWithOldValue;
function getRecord(type, target) {
return currentRecord = new MutationRecord(type, target);
}
function getRecordWithOldValue(oldValue) {
if (recordWithOldValue) return recordWithOldValue;
recordWithOldValue = copyMutationRecord(currentRecord);
recordWithOldValue.oldValue = oldValue;
return recordWithOldValue;
}
function clearRecords() {
currentRecord = recordWithOldValue = undefined;
}
function recordRepresentsCurrentMutation(record) {
return record === recordWithOldValue || record === currentRecord;
}
function selectRecord(lastRecord, newRecord) {
if (lastRecord === newRecord) return lastRecord;
if (recordWithOldValue && recordRepresentsCurrentMutation(lastRecord)) return recordWithOldValue;
return null;
}
function Registration(observer, target, options) {
this.observer = observer;
this.target = target;
this.options = options;
this.transientObservedNodes = [];
}
Registration.prototype = {
enqueue: function(record) {
var records = this.observer.records_;
var length = records.length;
if (records.length > 0) {
var lastRecord = records[length - 1];
var recordToReplaceLast = selectRecord(lastRecord, record);
if (recordToReplaceLast) {
records[length - 1] = recordToReplaceLast;
return;
}
} else {
scheduleCallback(this.observer);
}
records[length] = record;
},
addListeners: function() {
this.addListeners_(this.target);
},
addListeners_: function(node) {
var options = this.options;
if (options.attributes) node.addEventListener("DOMAttrModified", this, true);
if (options.characterData) node.addEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.addEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.addEventListener("DOMNodeRemoved", this, true);
},
removeListeners: function() {
this.removeListeners_(this.target);
},
removeListeners_: function(node) {
var options = this.options;
if (options.attributes) node.removeEventListener("DOMAttrModified", this, true);
if (options.characterData) node.removeEventListener("DOMCharacterDataModified", this, true);
if (options.childList) node.removeEventListener("DOMNodeInserted", this, true);
if (options.childList || options.subtree) node.removeEventListener("DOMNodeRemoved", this, true);
},
addTransientObserver: function(node) {
if (node === this.target) return;
this.addListeners_(node);
this.transientObservedNodes.push(node);
var registrations = registrationsTable.get(node);
if (!registrations) registrationsTable.set(node, registrations = []);
registrations.push(this);
},
removeTransientObservers: function() {
var transientObservedNodes = this.transientObservedNodes;
this.transientObservedNodes = [];
transientObservedNodes.forEach(function(node) {
this.removeListeners_(node);
var registrations = registrationsTable.get(node);
for (var i = 0; i < registrations.length; i++) {
if (registrations[i] === this) {
registrations.splice(i, 1);
break;
}
}
}, this);
},
handleEvent: function(e) {
e.stopImmediatePropagation();
switch (e.type) {
case "DOMAttrModified":
var name = e.attrName;
var namespace = e.relatedNode.namespaceURI;
var target = e.target;
var record = new getRecord("attributes", target);
record.attributeName = name;
record.attributeNamespace = namespace;
var oldValue = e.attrChange === MutationEvent.ADDITION ? null : e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
if (!options.attributes) return;
if (options.attributeFilter && options.attributeFilter.length && options.attributeFilter.indexOf(name) === -1 && options.attributeFilter.indexOf(namespace) === -1) {
return;
}
if (options.attributeOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMCharacterDataModified":
var target = e.target;
var record = getRecord("characterData", target);
var oldValue = e.prevValue;
forEachAncestorAndObserverEnqueueRecord(target, function(options) {
if (!options.characterData) return;
if (options.characterDataOldValue) return getRecordWithOldValue(oldValue);
return record;
});
break;
case "DOMNodeRemoved":
this.addTransientObserver(e.target);
case "DOMNodeInserted":
var changedNode = e.target;
var addedNodes, removedNodes;
if (e.type === "DOMNodeInserted") {
addedNodes = [ changedNode ];
removedNodes = [];
} else {
addedNodes = [];
removedNodes = [ changedNode ];
}
var previousSibling = changedNode.previousSibling;
var nextSibling = changedNode.nextSibling;
var record = getRecord("childList", e.target.parentNode);
record.addedNodes = addedNodes;
record.removedNodes = removedNodes;
record.previousSibling = previousSibling;
record.nextSibling = nextSibling;
forEachAncestorAndObserverEnqueueRecord(e.relatedNode, function(options) {
if (!options.childList) return;
return record;
});
}
clearRecords();
}
};
global.JsMutationObserver = JsMutationObserver;
if (!global.MutationObserver) global.MutationObserver = JsMutationObserver;
})(this);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,14 @@
{
"name": "webcomponentsjs",
"main": "webcomponents.js",
"version": "0.7.3",
"homepage": "http://webcomponents.org",
"authors": [
"The Polymer Authors"
],
"keywords": [
"webcomponents"
],
"license": "BSD",
"ignore": []
}

View File

@ -0,0 +1,31 @@
{
"name": "webcomponents.js",
"version": "0.7.3",
"description": "webcomponents.js",
"main": "webcomponents.js",
"directories": {
"test": "tests"
},
"repository": {
"type": "git",
"url": "https://github.com/webcomponents/webcomponentsjs.git"
},
"author": "The Polymer Authors",
"license": {
"type": "BSD-3-Clause",
"url": "http://polymer.github.io/LICENSE.txt"
},
"bugs": {
"url": "https://github.com/webcomponents/webcomponentsjs/issues"
},
"homepage": "http://webcomponents.org",
"devDependencies": {
"gulp": "^3.8.8",
"gulp-audit": "^1.0.0",
"gulp-concat": "^2.4.1",
"gulp-header": "^1.1.1",
"gulp-uglify": "^1.0.1",
"run-sequence": "^1.0.1",
"web-component-tester": "*"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long