mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2026-10-25 13:40:28 +00:00
Modernized the UI
Updated Material Design Light Added the Roboto font Updated the icons font Replaced existing icons
This commit is contained in:
1 parent
476703d442
commit
4242eaa37b
19 files changed
+605
-283
No files matched your search
+95
-54
@@ -11,8 +11,8 @@ var windowState = 'normal'; // chrome's windowState, possible values: 'normal' o
|
||||
function attachListeners() {
|
||||
changeUiModeForNaClLoad();
|
||||
|
||||
$('#selectResolution').on('change', saveResolution);
|
||||
$('#selectFramerate').on('change', saveFramerate);
|
||||
$('.resolutionMenu li').on('click', saveResolution);
|
||||
$('.framerateMenu li').on('click', saveFramerate);
|
||||
$('#bitrateSlider').on('input', updateBitrateField); // input occurs every notch you slide
|
||||
$('#bitrateSlider').on('change', saveBitrate); // change occurs once the mouse lets go.
|
||||
$("#remoteAudioEnabledSwitch").on('click', saveRemoteAudio);
|
||||
@@ -64,15 +64,15 @@ function onBoundsChanged() {
|
||||
}
|
||||
|
||||
function changeUiModeForNaClLoad() {
|
||||
$('.mdl-layout__header').children().hide();
|
||||
$('#main-navigation').children().hide();
|
||||
$("#main-content").children().not("#listener, #naclSpinner").hide();
|
||||
$('#naclSpinnerMessage').text('Loading Moonlight plugin...');
|
||||
$('#naclSpinner').css('display', 'inline-block');
|
||||
}
|
||||
|
||||
function restoreUiAfterNaClLoad() {
|
||||
$('.mdl-layout__header').children().not("#quitCurrentApp").show();
|
||||
$("#main-content").children().not("#listener, #naclSpinner, #gameSelection").show();
|
||||
$('#main-navigation').children().not("#quitCurrentApp").show();
|
||||
$("#main-content").children().not("#listener, #naclSpinner, #game-grid").show();
|
||||
$('#naclSpinner').hide();
|
||||
$('#loadingSpinner').css('display', 'none');
|
||||
showHostsAndSettingsMode();
|
||||
@@ -322,10 +322,11 @@ function addHost() {
|
||||
|
||||
|
||||
// host is an NvHTTP object
|
||||
function addHostToGrid(host, ismDNSDiscovered=false) {
|
||||
var outerDiv = $("<div>", {class: 'host-container mdl-cell--3-col', id: 'host-container-' + host.serverUid });
|
||||
var cell = $("<div>", {class: 'mdl-cell mdl-cell--3-col host-cell mdl-button mdl-js-button mdl-js-ripple-effect', id: 'hostgrid-' + host.serverUid, html:host.hostname });
|
||||
$(cell).prepend($("<img>", {src: "static/res/ic_desktop_windows_white_24px.svg"}));
|
||||
function addHostToGrid(host, ismDNSDiscovered) {
|
||||
|
||||
var outerDiv = $("<div>", {class: 'host-container mdl-card mdl-shadow--4dp', id: 'host-container-' + host.serverUid });
|
||||
var cell = $("<div>", {class: 'mdl-card__title mdl-card--expand', id: 'hostgrid-' + host.serverUid });
|
||||
$(cell).prepend($("<h2>", {class: "mdl-card__title-text", html: host.hostname}));
|
||||
var removalButton = $("<div>", {class: "remove-host", id: "removeHostButton-" + host.serverUid});
|
||||
removalButton.off('click');
|
||||
removalButton.click(function () {
|
||||
@@ -347,7 +348,7 @@ function addHostToGrid(host, ismDNSDiscovered=false) {
|
||||
function removeClicked(host) {
|
||||
var deleteHostDialog = document.querySelector('#deleteHostDialog');
|
||||
document.getElementById('deleteHostDialogText').innerHTML =
|
||||
' Are you sure you want like to delete ' + host.hostname + '?';
|
||||
' Are you sure you want to delete ' + host.hostname + '?';
|
||||
deleteHostDialog.showModal();
|
||||
|
||||
$('#cancelDeleteHost').off('click');
|
||||
@@ -393,8 +394,9 @@ function showApps(host) {
|
||||
console.log('Moved into showApps, but `host` did not initialize properly! Failing.');
|
||||
return;
|
||||
}
|
||||
console.log(host);
|
||||
$('#quitCurrentApp').show();
|
||||
$("#game-grid").empty();
|
||||
$("#gameList .game-container").remove();
|
||||
|
||||
// Show a spinner while the applist loads
|
||||
$('#naclSpinnerMessage').text('Loading apps...');
|
||||
@@ -403,6 +405,8 @@ function showApps(host) {
|
||||
host.getAppList().then(function (appList) {
|
||||
$('#naclSpinner').hide();
|
||||
|
||||
$("#game-grid").show();
|
||||
|
||||
// if game grid is populated, empty it
|
||||
appList.forEach(function (app) {
|
||||
host.getBoxArt(app.id).then(function (resolvedPromise) {
|
||||
@@ -412,7 +416,13 @@ function showApps(host) {
|
||||
// to mitigate this we ensure we don't add a duplicate.
|
||||
// This isn't perfect: there's lots of RTTs before the logic prevents anything
|
||||
var imageBlob = new Blob([resolvedPromise], {type: "image/png"});
|
||||
$("#game-grid").append($("<div>", {html:$("<img \>", {src: URL.createObjectURL(imageBlob), id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("<span>", {html: app.title, class:"game-title"})));
|
||||
var outerDiv = $("<div>", {class: 'game-container mdl-card mdl-shadow--4dp', id: 'game-'+app.id, backgroundImage: URL.createObjectURL(imageBlob) });
|
||||
$(outerDiv).append($("<img \>", {src: URL.createObjectURL(imageBlob), id: 'game-'+app.id, name: app.title }));
|
||||
$(outerDiv).append($("<div>", {class: "game-title", html: $("<span>", {html: app.title} )}));
|
||||
$("#game-grid").append(outerDiv);
|
||||
|
||||
|
||||
// $("#gameList").append($("<div>", {html:$("<img \>", {src: URL.createObjectURL(imageBlob), id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("<span>", {html: app.title, class:"game-title"})));
|
||||
$('#game-'+app.id).on('click', function () {
|
||||
startGame(host, app.id);
|
||||
});
|
||||
@@ -430,7 +440,11 @@ function showApps(host) {
|
||||
// double clicking the button will cause multiple box arts to appear.
|
||||
// to mitigate this we ensure we don't add a duplicate.
|
||||
// This isn't perfect: there's lots of RTTs before the logic prevents anything
|
||||
$("#game-grid").append($("<div>", {html:$("<img \>", {src: "static/res/no_app_image.png", id: 'game-'+app.id, name: app.title }), class: 'box-art mdl-cell mdl-cell--3-col'}).append($("<span>", {html: app.title, class:"game-title"})));
|
||||
var outerDiv = $("<div>", {class: 'game-container mdl-card mdl-shadow--4dp', id: 'game-'+app.id, backgroundImage: URL.createObjectURL(imageBlob) });
|
||||
$(outerDiv).append($("<img \>", {src: "static/res/no_app_image.png", id: 'game-'+app.id, name: app.title }));
|
||||
$(outerDiv).append($("<div>", {class: "game-title", html: $("<span>", {html: app.title} )}));
|
||||
$("#game-grid").append(outerDiv);
|
||||
|
||||
$('#game-'+app.id).on('click', function () {
|
||||
startGame(host, app.id);
|
||||
});
|
||||
@@ -454,14 +468,15 @@ function showApps(host) {
|
||||
// set the layout to the initial mode you see when you open moonlight
|
||||
function showHostsAndSettingsMode() {
|
||||
console.log('entering show hosts and settings mode.');
|
||||
$("#main-navigation").show();
|
||||
$(".nav-menu-parent").show();
|
||||
$("#externalAudioBtn").show();
|
||||
$("#main-content").children().not("#listener, #loadingSpinner, #naclSpinner").show();
|
||||
$('#game-grid').hide();
|
||||
$('#backIcon').hide();
|
||||
$('#quitCurrentApp').hide();
|
||||
$(".mdl-layout__header").show();
|
||||
$("#main-content").children().not("#listener, #loadingSpinner, #naclSpinner").show();
|
||||
$("#game-grid").hide();
|
||||
$("#main-content").removeClass("fullscreen");
|
||||
$("#listener").removeClass("fullscreen");
|
||||
$("body").css('backgroundColor', 'white');
|
||||
// We're no longer in a host-specific screen. Null host, and add it back to the polling list
|
||||
if(api) {
|
||||
beginBackgroundPollingOfHost(api);
|
||||
@@ -472,13 +487,15 @@ function showHostsAndSettingsMode() {
|
||||
function showAppsMode() {
|
||||
console.log("entering show apps mode.");
|
||||
$('#backIcon').show();
|
||||
$(".mdl-layout__header").show();
|
||||
$("#main-navigation").show();
|
||||
$("#main-content").children().not("#listener, #loadingSpinner, #naclSpinner").show();
|
||||
$("#streamSettings").hide();
|
||||
$("#hostSettings").hide();
|
||||
$(".nav-menu-parent").hide();
|
||||
$("#externalAudioBtn").hide();
|
||||
$("#host-grid").hide();
|
||||
$("#settings").hide();
|
||||
$("#main-content").removeClass("fullscreen");
|
||||
$("#listener").removeClass("fullscreen");
|
||||
$("body").css('backgroundColor', 'white');
|
||||
}
|
||||
|
||||
|
||||
@@ -527,9 +544,9 @@ function startGame(host, appID) {
|
||||
return;
|
||||
}
|
||||
|
||||
var frameRate = $("#selectFramerate").val();
|
||||
var streamWidth = $('#selectResolution option:selected').val().split(':')[0];
|
||||
var streamHeight = $('#selectResolution option:selected').val().split(':')[1];
|
||||
var frameRate = $('#selectFramerate').data('value').toString();
|
||||
var streamWidth = $('#selectResolution').data('value').split(':')[0];
|
||||
var streamHeight = $('#selectResolution').data('value').split(':')[1];
|
||||
// we told the user it was in Mbps. We're dirty liars and use Kbps behind their back.
|
||||
var bitrate = parseInt($("#bitrateSlider").val()) * 1000;
|
||||
console.log('startRequest:' + host.address + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate);
|
||||
@@ -551,7 +568,7 @@ function startGame(host, appID) {
|
||||
});
|
||||
}
|
||||
|
||||
remote_audio_enabled = $("#remoteAudioEnabledSwitch").parent().hasClass('is-checked') ? 1 : 0;
|
||||
var remote_audio_enabled = $("#remoteAudioEnabledSwitch").parent().hasClass('is-checked') ? 1 : 0;
|
||||
|
||||
host.launchApp(appID,
|
||||
streamWidth + "x" + streamHeight + "x" + frameRate,
|
||||
@@ -576,10 +593,9 @@ function playGameMode() {
|
||||
console.log("entering play game mode");
|
||||
isInGame = true;
|
||||
|
||||
$(".mdl-layout__header").hide();
|
||||
$("#main-navigation").hide();
|
||||
$("#main-content").children().not("#listener, #loadingSpinner").hide();
|
||||
$("#main-content").addClass("fullscreen");
|
||||
$("body").css('backgroundColor', 'black');
|
||||
|
||||
chrome.app.window.current().fullscreen();
|
||||
fullscreenNaclModule();
|
||||
@@ -589,8 +605,8 @@ function playGameMode() {
|
||||
|
||||
// Maximize the size of the nacl module by scaling and resizing appropriately
|
||||
function fullscreenNaclModule() {
|
||||
var streamWidth = $('#selectResolution option:selected').val().split(':')[0];
|
||||
var streamHeight = $('#selectResolution option:selected').val().split(':')[1];
|
||||
var streamWidth = $('#selectResolution').data('value').split(':')[0];
|
||||
var streamHeight = $('#selectResolution').data('value').split(':')[1];
|
||||
var screenWidth = window.innerWidth;
|
||||
var screenHeight = window.innerHeight;
|
||||
|
||||
@@ -678,13 +694,17 @@ function storeData(key, data, callbackFunction) {
|
||||
}
|
||||
|
||||
function saveResolution() {
|
||||
var chosenResolution = $(this).data('value');
|
||||
$('#selectResolution').text($(this).text()).data('value', chosenResolution);
|
||||
storeData('resolution', chosenResolution, null);
|
||||
updateDefaultBitrate();
|
||||
storeData('resolution', $('#selectResolution').val(), null);
|
||||
}
|
||||
|
||||
function saveFramerate() {
|
||||
var chosenFramerate = $(this).data('value');
|
||||
$('#selectFramerate').text($(this).text()).data('value', chosenFramerate);
|
||||
storeData('frameRate', chosenFramerate, null);
|
||||
updateDefaultBitrate();
|
||||
storeData('frameRate', $('#selectFramerate').val(), null);
|
||||
}
|
||||
|
||||
// storing data in chrome.storage takes the data as an object, and shoves it into JSON to store
|
||||
@@ -703,31 +723,33 @@ function saveBitrate() {
|
||||
}
|
||||
|
||||
function saveRemoteAudio() {
|
||||
console.log('saving remote audio state');
|
||||
// problem: when off, and the app is just starting, a tick to the switch doesn't always toggle it
|
||||
// second problem: this callback is called immediately after clicking, so the HTML class `is-checked` isn't toggled yet
|
||||
// to solve the second problem, we invert the boolean. This has worked in all cases I've tried, except for the first case
|
||||
storeData('remoteAudio', !$("#remoteAudioEnabledSwitch").parent().hasClass('is-checked'), null);
|
||||
// MaterialDesignLight uses the mouseup trigger, so we give it some time to change the class name before
|
||||
// checking the new state
|
||||
setTimeout(function() {
|
||||
var remoteAudioState = $("#remoteAudioEnabledSwitch").parent().hasClass('is-checked');
|
||||
console.log('saving remote audio state : ' + remoteAudioState);
|
||||
storeData('remoteAudio', remoteAudioState, null);
|
||||
}, 100);
|
||||
}
|
||||
|
||||
function updateDefaultBitrate() {
|
||||
var res = $('#selectResolution').val();
|
||||
var frameRate = $('#selectFramerate').val();
|
||||
var res = $('#selectResolution').data('value');
|
||||
var frameRate = $('#selectFramerate').data('value').toString();
|
||||
|
||||
if (res.lastIndexOf("1920:1080", 0) === 0) {
|
||||
if (frameRate.lastIndexOf("30", 0) === 0) { // 1080p, 30fps
|
||||
if (res ==="1920:1080") {
|
||||
if (frameRate === "30") { // 1080p, 30fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('10');
|
||||
} else { // 1080p, 60fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('20');
|
||||
}
|
||||
} else if (res.lastIndexOf("1280:720") === 0) {
|
||||
if (frameRate.lastIndexOf("30", 0) === 0) { // 720, 30fps
|
||||
} else if (res === "1280:720") {
|
||||
if (frameRate === "30") { // 720, 30fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('5');
|
||||
} else { // 720, 60fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('10');
|
||||
}
|
||||
} else if (res.lastIndexOf("3840:2160", 0) === 0) {
|
||||
if (frameRate.lastIndexOf("30", 0) === 0) { // 2160p, 30fps
|
||||
} else if (res === "3840:2160") {
|
||||
if (frameRate === "30") { // 2160p, 30fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('40');
|
||||
} else { // 2160p, 60fps
|
||||
$('#bitrateSlider')[0].MaterialSlider.change('80');
|
||||
@@ -750,33 +772,51 @@ function onWindowLoad(){
|
||||
if(chrome.storage) {
|
||||
// load stored resolution prefs
|
||||
chrome.storage.sync.get('resolution', function(previousValue) {
|
||||
$('#selectResolution').val(previousValue.resolution != null ? previousValue.resolution : '1280:720');
|
||||
});
|
||||
chrome.storage.sync.get('remoteAudio', function(previousValue) {
|
||||
if(previousValue.remoteAudio == null) {
|
||||
document.querySelector('#remoteAudioEnabledSwitchContainer').MaterialSwitch.off();
|
||||
return;
|
||||
} else if(previousValue.remoteAudio == false) {
|
||||
document.querySelector('#remoteAudioEnabledSwitchContainer').MaterialSwitch.off();
|
||||
} else {
|
||||
document.querySelector('#remoteAudioEnabledSwitchContainer').MaterialSwitch.on();
|
||||
if(previousValue.resolution != null) {
|
||||
$('.resolutionMenu li').each(function () {
|
||||
if ($(this).data('value') === previousValue.resolution) {
|
||||
$('#selectResolution').text($(this).text()).data('value', previousValue.resolution);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Load stored remote audio prefs
|
||||
chrome.storage.sync.get('remoteAudio', function(previousValue) {
|
||||
if(previousValue.remoteAudio == null) {
|
||||
document.querySelector('#externalAudioBtn').MaterialIconToggle.check();
|
||||
return;
|
||||
} else if(previousValue.remoteAudio == false) {
|
||||
document.querySelector('#externalAudioBtn').MaterialIconToggle.uncheck();
|
||||
} else {
|
||||
document.querySelector('#externalAudioBtn').MaterialIconToggle.check();
|
||||
}
|
||||
});
|
||||
|
||||
// load stored framerate prefs
|
||||
chrome.storage.sync.get('frameRate', function(previousValue) {
|
||||
$('#selectFramerate').val(previousValue.frameRate != null ? previousValue.frameRate : '60');
|
||||
if(previousValue.frameRate != null) {
|
||||
$('.framerateMenu li').each(function () {
|
||||
if ($(this).data('value') === previousValue.frameRate) {
|
||||
$('#selectFramerate').text($(this).text()).data('value', previousValue.frameRate);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// load stored bitrate prefs
|
||||
chrome.storage.sync.get('bitrate', function(previousValue) {
|
||||
$('#bitrateSlider')[0].MaterialSlider.change(previousValue.bitrate != null ? previousValue.bitrate : '10');
|
||||
updateBitrateField();
|
||||
});
|
||||
|
||||
// load the HTTP cert if we have one.
|
||||
chrome.storage.sync.get('cert', function(savedCert) {
|
||||
if (savedCert.cert != null) { // we have a saved cert
|
||||
pairingCert = savedCert.cert;
|
||||
}
|
||||
});
|
||||
|
||||
chrome.storage.sync.get('uniqueid', function(savedUniqueid) {
|
||||
if (savedUniqueid.uniqueid != null) { // we have a saved uniqueid
|
||||
myUniqueid = savedUniqueid.uniqueid;
|
||||
@@ -785,6 +825,7 @@ function onWindowLoad(){
|
||||
storeData('uniqueid', myUniqueid, null);
|
||||
}
|
||||
});
|
||||
|
||||
// load previously connected hosts, which have been killed into an object, and revive them back into a class
|
||||
chrome.storage.sync.get('hosts', function(previousValue) {
|
||||
hosts = previousValue.hosts != null ? previousValue.hosts : {};
|
||||
|
||||
Vendored
+3
-3
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* material-design-lite - Material Design Components in CSS, JS and HTML
|
||||
* @version v1.1.3
|
||||
* @version v1.3.0
|
||||
* @license Apache-2.0
|
||||
* @copyright 2015 Google, Inc.
|
||||
* @link https://github.com/google/material-design-lite
|
||||
*/
|
||||
!function(){"use strict";function e(e,t){if(e){if(t.element_.classList.contains(t.CssClasses_.MDL_JS_RIPPLE_EFFECT)){var s=document.createElement("span");s.classList.add(t.CssClasses_.MDL_RIPPLE_CONTAINER),s.classList.add(t.CssClasses_.MDL_JS_RIPPLE_EFFECT);var i=document.createElement("span");i.classList.add(t.CssClasses_.MDL_RIPPLE),s.appendChild(i),e.appendChild(s)}e.addEventListener("click",function(s){s.preventDefault();var i=e.href.split("#")[1],n=t.element_.querySelector("#"+i);t.resetTabState_(),t.resetPanelState_(),e.classList.add(t.CssClasses_.ACTIVE_CLASS),n.classList.add(t.CssClasses_.ACTIVE_CLASS)})}}function t(e,t,s,i){function n(){var n=e.href.split("#")[1],a=i.content_.querySelector("#"+n);i.resetTabState_(t),i.resetPanelState_(s),e.classList.add(i.CssClasses_.IS_ACTIVE),a.classList.add(i.CssClasses_.IS_ACTIVE)}if(i.tabBar_.classList.contains(i.CssClasses_.JS_RIPPLE_EFFECT)){var a=document.createElement("span");a.classList.add(i.CssClasses_.RIPPLE_CONTAINER),a.classList.add(i.CssClasses_.JS_RIPPLE_EFFECT);var l=document.createElement("span");l.classList.add(i.CssClasses_.RIPPLE),a.appendChild(l),e.appendChild(a)}e.addEventListener("click",function(t){"#"===e.getAttribute("href").charAt(0)&&(t.preventDefault(),n())}),e.show=n}var s={upgradeDom:function(e,t){},upgradeElement:function(e,t){},upgradeElements:function(e){},upgradeAllRegistered:function(){},registerUpgradedCallback:function(e,t){},register:function(e){},downgradeElements:function(e){}};s=function(){function e(e,t){for(var s=0;s<h.length;s++)if(h[s].className===e)return"undefined"!=typeof t&&(h[s]=t),h[s];return!1}function t(e){var t=e.getAttribute("data-upgraded");return null===t?[""]:t.split(",")}function s(e,s){var i=t(e);return-1!==i.indexOf(s)}function i(t,s){if("undefined"==typeof t&&"undefined"==typeof s)for(var a=0;a<h.length;a++)i(h[a].className,h[a].cssClass);else{var l=t;if("undefined"==typeof s){var o=e(l);o&&(s=o.cssClass)}for(var r=document.querySelectorAll("."+s),_=0;_<r.length;_++)n(r[_],l)}}function n(i,n){if(!("object"==typeof i&&i instanceof Element))throw new Error("Invalid argument provided to upgrade MDL element.");var a=t(i),l=[];if(n)s(i,n)||l.push(e(n));else{var o=i.classList;h.forEach(function(e){o.contains(e.cssClass)&&-1===l.indexOf(e)&&!s(i,e.className)&&l.push(e)})}for(var r,_=0,d=l.length;d>_;_++){if(r=l[_],!r)throw new Error("Unable to find a registered component for the given class.");a.push(r.className),i.setAttribute("data-upgraded",a.join(","));var C=new r.classConstructor(i);C[p]=r,c.push(C);for(var u=0,E=r.callbacks.length;E>u;u++)r.callbacks[u](i);r.widget&&(i[r.className]=C);var m;"CustomEvent"in window&&"function"==typeof window.CustomEvent?m=new Event("mdl-componentupgraded",{bubbles:!0,cancelable:!1}):(m=document.createEvent("Events"),m.initEvent("mdl-componentupgraded",!0,!0)),i.dispatchEvent(m)}}function a(e){Array.isArray(e)||(e="function"==typeof e.item?Array.prototype.slice.call(e):[e]);for(var t,s=0,i=e.length;i>s;s++)t=e[s],t instanceof HTMLElement&&(n(t),t.children.length>0&&a(t.children))}function l(t){var s="undefined"==typeof t.widget&&"undefined"==typeof t.widget,i=!0;s||(i=t.widget||t.widget);var n={classConstructor:t.constructor||t.constructor,className:t.classAsString||t.classAsString,cssClass:t.cssClass||t.cssClass,widget:i,callbacks:[]};if(h.forEach(function(e){if(e.cssClass===n.cssClass)throw new Error("The provided cssClass has already been registered: "+e.cssClass);if(e.className===n.className)throw new Error("The provided className has already been registered")}),t.constructor.prototype.hasOwnProperty(p))throw new Error("MDL component classes must not have "+p+" defined as a property.");var a=e(t.classAsString,n);a||h.push(n)}function o(t,s){var i=e(t);i&&i.callbacks.push(s)}function r(){for(var e=0;e<h.length;e++)i(h[e].className)}function _(e){if(e){var t=c.indexOf(e);c.splice(t,1);var s=e.element_.getAttribute("data-upgraded").split(","),i=s.indexOf(e[p].classAsString);s.splice(i,1),e.element_.setAttribute("data-upgraded",s.join(","));var n;"CustomEvent"in window&&"function"==typeof window.CustomEvent?n=new Event("mdl-componentdowngraded",{bubbles:!0,cancelable:!1}):(n=document.createEvent("Events"),n.initEvent("mdl-componentdowngraded",!0,!0))}}function d(e){var t=function(e){c.filter(function(t){return t.element_===e}).forEach(_)};if(e instanceof Array||e instanceof NodeList)for(var s=0;s<e.length;s++)t(e[s]);else{if(!(e instanceof Node))throw new Error("Invalid argument provided to downgrade MDL nodes.");t(e)}}var h=[],c=[],p="mdlComponentConfigInternal_";return{upgradeDom:i,upgradeElement:n,upgradeElements:a,upgradeAllRegistered:r,registerUpgradedCallback:o,register:l,downgradeElements:d}}(),s.ComponentConfigPublic,s.ComponentConfig,s.Component,s.upgradeDom=s.upgradeDom,s.upgradeElement=s.upgradeElement,s.upgradeElements=s.upgradeElements,s.upgradeAllRegistered=s.upgradeAllRegistered,s.registerUpgradedCallback=s.registerUpgradedCallback,s.register=s.register,s.Line truncated
|
||||
this.setActionHidden_(!1)),this.textElement_.textContent=this.message_,this.element_.classList.add(this.cssClasses_.ACTIVE),this.element_.setAttribute("aria-hidden","false"),setTimeout(this.cleanup_.bind(this),this.timeout_)},C.prototype.showSnackbar=function(e){if(void 0===e)throw new Error("Please provide a data object with at least a message to display.");if(void 0===e.message)throw new Error("Please provide a message to be displayed.");if(e.actionHandler&&!e.actionText)throw new Error("Please provide action text with the handler.");this.active?this.queuedNotifications_.push(e):(this.active=!0,this.message_=e.message,e.timeout?this.timeout_=e.timeout:this.timeout_=2750,e.actionHandler&&(this.actionHandler_=e.actionHandler),e.actionText&&(this.actionText_=e.actionText),this.displaySnackbar_())},C.prototype.showSnackbar=C.prototype.showSnackbar,C.prototype.checkQueue_=function(){this.queuedNotifications_.length>0&&this.showSnackbar(this.queuedNotifications_.shift())},C.prototype.cleanup_=function(){this.element_.classList.remove(this.cssClasses_.ACTIVE),setTimeout(function(){this.element_.setAttribute("aria-hidden","true"),this.textElement_.textContent="",Boolean(this.actionElement_.getAttribute("aria-hidden"))||(this.setActionHidden_(!0),this.actionElement_.textContent="",this.actionElement_.removeEventListener("click",this.actionHandler_)),this.actionHandler_=void 0,this.message_=void 0,this.actionText_=void 0,this.active=!1,this.checkQueue_()}.bind(this),this.Constant_.ANIMATION_LENGTH)},C.prototype.setActionHidden_=function(e){e?this.actionElement_.setAttribute("aria-hidden","true"):this.actionElement_.removeAttribute("aria-hidden")},s.register({constructor:C,classAsString:"MaterialSnackbar",cssClass:"mdl-js-snackbar",widget:!0});var u=function(e){this.element_=e,this.init()};window.MaterialSpinner=u,u.prototype.Constant_={MDL_SPINNER_LAYER_COUNT:4},u.prototype.CssClasses_={MDL_SPINNER_LAYER:"mdl-spinner__layer",MDL_SPINNER_CIRCLE_CLIPPER:"mdl-spinner__circle-clipper",MDL_SPINNER_CIRCLE:"mdl-spinner__circle",MDL_SPINNER_GAP_PATCH:"mdl-spinner__gap-patch",MDL_SPINNER_LEFT:"mdl-spinner__left",MDL_SPINNER_RIGHT:"mdl-spinner__right"},u.prototype.createLayer=function(e){var t=document.createElement("div");t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER),t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER+"-"+e);var s=document.createElement("div");s.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),s.classList.add(this.CssClasses_.MDL_SPINNER_LEFT);var i=document.createElement("div");i.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH);var n=document.createElement("div");n.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),n.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT);for(var a=[s,i,n],l=0;l<a.length;l++){var o=document.createElement("div");o.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE),a[l].appendChild(o)}t.appendChild(s),t.appendChild(i),t.appendChild(n),this.element_.appendChild(t)},u.prototype.createLayer=u.prototype.createLayer,u.prototype.stop=function(){this.element_.classList.remove("is-active")},u.prototype.stop=u.prototype.stop,u.prototype.start=function(){this.element_.classList.add("is-active")},u.prototype.start=u.prototype.start,u.prototype.init=function(){if(this.element_){for(var e=1;e<=this.Constant_.MDL_SPINNER_LAYER_COUNT;e++)this.createLayer(e);this.element_.classList.add("is-upgraded")}},s.register({constructor:u,classAsString:"MaterialSpinner",cssClass:"mdl-js-spinner",widget:!0});var E=function(e){this.element_=e,this.init()};window.MaterialSwitch=E,E.prototype.Constant_={TINY_TIMEOUT:.001},E.prototype.CssClasses_={INPUT:"mdl-switch__input",TRACK:"mdl-switch__track",THUMB:"mdl-switch__thumb",FOCUS_HELPER:"mdl-switch__focus-helper",RIPPLE_EFFECT:"mdl-js-ripple-effect",RIPPLE_IGNORE_EVENTS:"mdl-js-ripple-effect--ignore-events",RIPPLE_CONTAINER:"mdl-switch__ripple-container",RIPPLE_CENTER:"mdl-ripple--center",RIPPLE:"mdl-ripple",IS_FOCUSED:"is-focused",IS_DISABLED:"is-disabled",IS_CHECKED:"is-checked"},E.prototype.onChange_=function(e){this.updateClasses_()},E.prototype.onFocus_=function(e){this.element_.classList.add(this.CssClasses_.IS_FOCUSED)},E.prototype.onBlur_=function(e){this.element_.classList.remove(this.CssClasses_.IS_FOCUSED)},E.prototype.onMouseUp_=function(e){this.blur_()},E.prototype.updateClasses_=function(){this.checkDisabled(),this.checkToggleState()},E.prototype.blur_=function(){window.setTimeout(function(){this.inputElement_.blur()}.bind(this),this.Constant_.TINY_TIMEOUT)},E.prototype.checkDisabled=function(){this.inputElement_.disabled?this.element_.classList.add(this.CssClasses_.IS_DISABLED):this.element_.classList.remove(this.CssClasses_.IS_DISABLED)},E.prototype.checkDisabled=E.prototype.checkDisabled,E.prototype.checkToggleState=function(){this.inputElement_.checked?this.element_.classList.add(this.CssClasses_.IS_CHECKED):this.element_.classList.remove(this.CssClasses_.IS_CHECKED)},E.prototype.checkToggleState=E.prototype.checkToLine truncated
|
||||
!function(){"use strict";function e(e,t){if(e){if(t.element_.classList.contains(t.CssClasses_.MDL_JS_RIPPLE_EFFECT)){var s=document.createElement("span");s.classList.add(t.CssClasses_.MDL_RIPPLE_CONTAINER),s.classList.add(t.CssClasses_.MDL_JS_RIPPLE_EFFECT);var i=document.createElement("span");i.classList.add(t.CssClasses_.MDL_RIPPLE),s.appendChild(i),e.appendChild(s)}e.addEventListener("click",function(s){if("#"===e.getAttribute("href").charAt(0)){s.preventDefault();var i=e.href.split("#")[1],n=t.element_.querySelector("#"+i);t.resetTabState_(),t.resetPanelState_(),e.classList.add(t.CssClasses_.ACTIVE_CLASS),n.classList.add(t.CssClasses_.ACTIVE_CLASS)}})}}function t(e,t,s,i){function n(){var n=e.href.split("#")[1],a=i.content_.querySelector("#"+n);i.resetTabState_(t),i.resetPanelState_(s),e.classList.add(i.CssClasses_.IS_ACTIVE),a.classList.add(i.CssClasses_.IS_ACTIVE)}if(i.tabBar_.classList.contains(i.CssClasses_.JS_RIPPLE_EFFECT)){var a=document.createElement("span");a.classList.add(i.CssClasses_.RIPPLE_CONTAINER),a.classList.add(i.CssClasses_.JS_RIPPLE_EFFECT);var l=document.createElement("span");l.classList.add(i.CssClasses_.RIPPLE),a.appendChild(l),e.appendChild(a)}i.tabBar_.classList.contains(i.CssClasses_.TAB_MANUAL_SWITCH)||e.addEventListener("click",function(t){"#"===e.getAttribute("href").charAt(0)&&(t.preventDefault(),n())}),e.show=n}var s={upgradeDom:function(e,t){},upgradeElement:function(e,t){},upgradeElements:function(e){},upgradeAllRegistered:function(){},registerUpgradedCallback:function(e,t){},register:function(e){},downgradeElements:function(e){}};s=function(){function e(e,t){for(var s=0;s<c.length;s++)if(c[s].className===e)return"undefined"!=typeof t&&(c[s]=t),c[s];return!1}function t(e){var t=e.getAttribute("data-upgraded");return null===t?[""]:t.split(",")}function s(e,s){var i=t(e);return i.indexOf(s)!==-1}function i(e,t,s){if("CustomEvent"in window&&"function"==typeof window.CustomEvent)return new CustomEvent(e,{bubbles:t,cancelable:s});var i=document.createEvent("Events");return i.initEvent(e,t,s),i}function n(t,s){if("undefined"==typeof t&&"undefined"==typeof s)for(var i=0;i<c.length;i++)n(c[i].className,c[i].cssClass);else{var l=t;if("undefined"==typeof s){var o=e(l);o&&(s=o.cssClass)}for(var r=document.querySelectorAll("."+s),_=0;_<r.length;_++)a(r[_],l)}}function a(n,a){if(!("object"==typeof n&&n instanceof Element))throw new Error("Invalid argument provided to upgrade MDL element.");var l=i("mdl-componentupgrading",!0,!0);if(n.dispatchEvent(l),!l.defaultPrevented){var o=t(n),r=[];if(a)s(n,a)||r.push(e(a));else{var _=n.classList;c.forEach(function(e){_.contains(e.cssClass)&&r.indexOf(e)===-1&&!s(n,e.className)&&r.push(e)})}for(var d,h=0,u=r.length;h<u;h++){if(d=r[h],!d)throw new Error("Unable to find a registered component for the given class.");o.push(d.className),n.setAttribute("data-upgraded",o.join(","));var E=new d.classConstructor(n);E[C]=d,p.push(E);for(var m=0,L=d.callbacks.length;m<L;m++)d.callbacks[m](n);d.widget&&(n[d.className]=E);var I=i("mdl-componentupgraded",!0,!1);n.dispatchEvent(I)}}}function l(e){Array.isArray(e)||(e=e instanceof Element?[e]:Array.prototype.slice.call(e));for(var t,s=0,i=e.length;s<i;s++)t=e[s],t instanceof HTMLElement&&(a(t),t.children.length>0&&l(t.children))}function o(t){var s="undefined"==typeof t.widget&&"undefined"==typeof t.widget,i=!0;s||(i=t.widget||t.widget);var n={classConstructor:t.constructor||t.constructor,className:t.classAsString||t.classAsString,cssClass:t.cssClass||t.cssClass,widget:i,callbacks:[]};if(c.forEach(function(e){if(e.cssClass===n.cssClass)throw new Error("The provided cssClass has already been registered: "+e.cssClass);if(e.className===n.className)throw new Error("The provided className has already been registered")}),t.constructor.prototype.hasOwnProperty(C))throw new Error("MDL component classes must not have "+C+" defined as a property.");var a=e(t.classAsString,n);a||c.push(n)}function r(t,s){var i=e(t);i&&i.callbacks.push(s)}function _(){for(var e=0;e<c.length;e++)n(c[e].className)}function d(e){if(e){var t=p.indexOf(e);p.splice(t,1);var s=e.element_.getAttribute("data-upgraded").split(","),n=s.indexOf(e[C].classAsString);s.splice(n,1),e.element_.setAttribute("data-upgraded",s.join(","));var a=i("mdl-componentdowngraded",!0,!1);e.element_.dispatchEvent(a)}}function h(e){var t=function(e){p.filter(function(t){return t.element_===e}).forEach(d)};if(e instanceof Array||e instanceof NodeList)for(var s=0;s<e.length;s++)t(e[s]);else{if(!(e instanceof Node))throw new Error("Invalid argument provided to downgrade MDL nodes.");t(e)}}var c=[],p=[],C="mdlComponentConfigInternal_";return{upgradeDom:n,upgradeElement:a,upgradeElements:l,upgradeAllRegistered:_,registerUpgradedCallback:r,register:o,downgradeElements:h}}(),s.ComponentConfigPublic,s.ComponentConfig,s.Component,s.upgradeDom=s.upgradeDom,s.upgradeElement=s.upgradeElement,s.upgradeElements=s.upgradeElements,s.upgradeAllRegistered=s.upgradeAllRegistered,s.registLine truncated
|
||||
this.actionHandler_&&(this.actionElement_.textContent=this.actionText_,this.actionElement_.addEventListener("click",this.actionHandler_),this.setActionHidden_(!1)),this.textElement_.textContent=this.message_,this.element_.classList.add(this.cssClasses_.ACTIVE),this.element_.setAttribute("aria-hidden","false"),setTimeout(this.cleanup_.bind(this),this.timeout_)},C.prototype.showSnackbar=function(e){if(void 0===e)throw new Error("Please provide a data object with at least a message to display.");if(void 0===e.message)throw new Error("Please provide a message to be displayed.");if(e.actionHandler&&!e.actionText)throw new Error("Please provide action text with the handler.");this.active?this.queuedNotifications_.push(e):(this.active=!0,this.message_=e.message,e.timeout?this.timeout_=e.timeout:this.timeout_=2750,e.actionHandler&&(this.actionHandler_=e.actionHandler),e.actionText&&(this.actionText_=e.actionText),this.displaySnackbar_())},C.prototype.showSnackbar=C.prototype.showSnackbar,C.prototype.checkQueue_=function(){this.queuedNotifications_.length>0&&this.showSnackbar(this.queuedNotifications_.shift())},C.prototype.cleanup_=function(){this.element_.classList.remove(this.cssClasses_.ACTIVE),setTimeout(function(){this.element_.setAttribute("aria-hidden","true"),this.textElement_.textContent="",Boolean(this.actionElement_.getAttribute("aria-hidden"))||(this.setActionHidden_(!0),this.actionElement_.textContent="",this.actionElement_.removeEventListener("click",this.actionHandler_)),this.actionHandler_=void 0,this.message_=void 0,this.actionText_=void 0,this.active=!1,this.checkQueue_()}.bind(this),this.Constant_.ANIMATION_LENGTH)},C.prototype.setActionHidden_=function(e){e?this.actionElement_.setAttribute("aria-hidden","true"):this.actionElement_.removeAttribute("aria-hidden")},s.register({constructor:C,classAsString:"MaterialSnackbar",cssClass:"mdl-js-snackbar",widget:!0});var u=function(e){this.element_=e,this.init()};window.MaterialSpinner=u,u.prototype.Constant_={MDL_SPINNER_LAYER_COUNT:4},u.prototype.CssClasses_={MDL_SPINNER_LAYER:"mdl-spinner__layer",MDL_SPINNER_CIRCLE_CLIPPER:"mdl-spinner__circle-clipper",MDL_SPINNER_CIRCLE:"mdl-spinner__circle",MDL_SPINNER_GAP_PATCH:"mdl-spinner__gap-patch",MDL_SPINNER_LEFT:"mdl-spinner__left",MDL_SPINNER_RIGHT:"mdl-spinner__right"},u.prototype.createLayer=function(e){var t=document.createElement("div");t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER),t.classList.add(this.CssClasses_.MDL_SPINNER_LAYER+"-"+e);var s=document.createElement("div");s.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),s.classList.add(this.CssClasses_.MDL_SPINNER_LEFT);var i=document.createElement("div");i.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH);var n=document.createElement("div");n.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER),n.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT);for(var a=[s,i,n],l=0;l<a.length;l++){var o=document.createElement("div");o.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE),a[l].appendChild(o)}t.appendChild(s),t.appendChild(i),t.appendChild(n),this.element_.appendChild(t)},u.prototype.createLayer=u.prototype.createLayer,u.prototype.stop=function(){this.element_.classList.remove("is-active")},u.prototype.stop=u.prototype.stop,u.prototype.start=function(){this.element_.classList.add("is-active")},u.prototype.start=u.prototype.start,u.prototype.init=function(){if(this.element_){for(var e=1;e<=this.Constant_.MDL_SPINNER_LAYER_COUNT;e++)this.createLayer(e);this.element_.classList.add("is-upgraded")}},s.register({constructor:u,classAsString:"MaterialSpinner",cssClass:"mdl-js-spinner",widget:!0});var E=function(e){this.element_=e,this.init()};window.MaterialSwitch=E,E.prototype.Constant_={TINY_TIMEOUT:.001},E.prototype.CssClasses_={INPUT:"mdl-switch__input",TRACK:"mdl-switch__track",THUMB:"mdl-switch__thumb",FOCUS_HELPER:"mdl-switch__focus-helper",RIPPLE_EFFECT:"mdl-js-ripple-effect",RIPPLE_IGNORE_EVENTS:"mdl-js-ripple-effect--ignore-events",RIPPLE_CONTAINER:"mdl-switch__ripple-container",RIPPLE_CENTER:"mdl-ripple--center",RIPPLE:"mdl-ripple",IS_FOCUSED:"is-focused",IS_DISABLED:"is-disabled",IS_CHECKED:"is-checked"},E.prototype.onChange_=function(e){this.updateClasses_()},E.prototype.onFocus_=function(e){this.element_.classList.add(this.CssClasses_.IS_FOCUSED)},E.prototype.onBlur_=function(e){this.element_.classList.remove(this.CssClasses_.IS_FOCUSED)},E.prototype.onMouseUp_=function(e){this.blur_()},E.prototype.updateClasses_=function(){this.checkDisabled(),this.checkToggleState()},E.prototype.blur_=function(){window.setTimeout(function(){this.inputElement_.blur()}.bind(this),this.Constant_.TINY_TIMEOUT)},E.prototype.checkDisabled=function(){this.inputElement_.disabled?this.element_.classList.add(this.CssClasses_.IS_DISABLED):this.element_.classList.remove(this.CssClasses_.IS_DISABLED)},E.prototype.checkDisabled=E.prototype.checkDisabled,E.prototype.checkToggleState=function(){this.inputElement_.checked?this.element_.classList.add(tLine truncated
|
||||
//# sourceMappingURL=material.min.js.map
|
||||
Reference in new issue
Block a user