diff --git a/config.yml b/config.yml index 10df19b..e638633 100644 --- a/config.yml +++ b/config.yml @@ -64,7 +64,8 @@ targets: name: 'Mercury' title: 'Mercury (coming soon)' orbit: - model: 'mercury_orb_all' + models: + - slug: 'mercury_orb_all' models: - slug: 'tao_mercury_sw' started_at: "1990-01-01T01:30:00" @@ -76,7 +77,8 @@ targets: name: 'Venus' title: 'Venus' orbit: - model: 'venus_orb_all' + models: + - slug: 'venus_orb_all' semimajor: 0.72333199 semiminor: 0.7233154 models: @@ -90,7 +92,8 @@ targets: name: 'Earth' title: 'Earth (coming soon)' orbit: - model: 'earth_orb_all' + models: + - slug: 'earth_orb_all' #model: 'tao_earth_sw' locked: true default: true @@ -103,7 +106,8 @@ targets: started_at: "1990-01-01T01:30:00" stopped_at: "2017-02-19T00:00:00" orbit: - model: 'mars_orb_all' + models: + - slug: 'mars_orb_all' semimajor: 1.52366231 semiminor: 1.51700011 locked: false @@ -116,10 +120,14 @@ targets: - slug: 'tao_jup_sw' started_at: "1990-01-01T01:30:00" stopped_at: "2017-02-19T00:00:00" + - slug: 'tao_jup_swrt' + started_at: "2017-01-01T00:00:00" + stopped_at: ~ # started_at: "1990-01-01T01:30:00" # stopped_at: "2017-02-19T00:00:00" orbit: - model: 'jupiter_orb_all' + models: + - slug: 'jupiter_orb_all' semimajor: 5.45516759 semiminor: 4.95155843 locked: false @@ -129,7 +137,8 @@ targets: name: 'Saturn' title: 'Saturn' orbit: - model: 'saturn_orb_all' + models: + - slug: 'saturn_orb_all' semimajor: 9.53707032 semiminor: 9.5230773 models: @@ -143,7 +152,8 @@ targets: name: 'Rosetta' title: 'Rosetta (coming soon)' orbit: - model: 'ros_orb_cruise' + models: + - slug: 'ros_orb_cruise' models: - slug: 'tao_ros_sw' started_at: "1990-01-01T01:30:00" @@ -155,7 +165,8 @@ targets: name: 'Juno' title: 'Juno (coming soon)' orbit: - model: 'juno_cruise_all' + models: + - slug: 'juno_cruise_all' models: - slug: 'tao_juno_sw' started_at: "1990-01-01T01:30:00" @@ -164,10 +175,11 @@ targets: default: false - type: 'comet' slug: 'tchouri' - name: 'Tchouri' - title: 'Tchouri (coming soon)' + name: 'Churyumov-Gerasimenko' + title: 'Churyumov-Gerasimenko (coming soon)' orbit: - model: 'p67_orb_all' + models: + - slug: 'p67_orb_all' locked: true default: false diff --git a/web/run.py b/web/run.py index 8384eff..5bdb7d5 100755 --- a/web/run.py +++ b/web/run.py @@ -169,7 +169,8 @@ def is_list_in_list(needle, haystack): def datetime_from_list(time_list): """ Datetimes in retrieved CDFs are stored as lists of numbers, - with DayOfYear starting at 0. We want it starting at 1 for default parsers. + with DayOfYear starting at 0. We want it starting at 1 because it's what + vendor parsers use, both in python and javascript. """ # Day Of Year starts at 0, but for our datetime parser it starts at 1 doy = '{:03d}'.format(int(''.join(time_list[4:7])) + 1) @@ -222,7 +223,8 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at): if remote_gzip_files == 'ERROR': raise Exception("API returned an error at '%s'." % url) if remote_gzip_files == ['OUTOFTIME']: # it happens - raise Exception("API says it's out of time at '%s'." % url) + return [] + # raise Exception("API says it's out of time at '%s'." % url) success = True except Exception as e: log.warn("Failed (%d/3) '%s' : %s" % (retries+1, url, e.message)) @@ -244,7 +246,7 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at): if remote_gzip_file in ['OUTOFTIME', 'ERROR']: continue # sometimes half the response is okay, the other not if remote_gzip_file.endswith('/.gz'): - continue + continue # this is just a plain bug remote_gzip_file = remote_gzip_file.replace('cdpp1', 'cdpp', 1) ################################################ filename = "%s_%s" % (orbiter, str(remote_gzip_file).split('/')[-1]) @@ -276,14 +278,15 @@ def retrieve_amda_netcdf(orbiter, what, started_at, stopped_at): return local_netc_files -# The available parameters in the generated CSV and NetCDF files. +# The available parameters in the generated CSV files. # The order matters. If you change this you also need to change the # innermost loop of `get_data_for_target`. # The javascript knows the targets' properties under these names. -# DEPRECATED, use PARAMETERS instead PROPERTIES = ('time', 'vrad', 'vtan', 'vlen', 'magn', 'temp', 'pdyn', 'dens', 'angl', 'xhci', 'yhci') +# The parameters that the users can handle. +# The slug must be one of the properties above. PARAMETERS = { 'pdyn': { 'slug': 'pdyn', @@ -299,7 +302,7 @@ PARAMETERS = { }, 'magn': { 'slug': 'magn', - 'name': 'Magnetism', + 'name': 'B Tangential', 'title': 'B Tangential.', 'units': 'nT', }, @@ -329,27 +332,39 @@ def get_data_for_target(target_config, started_at, stopped_at): :return: dict whose keys are datetime as str, values tuples of data """ log.debug("Grabbing data for '%s'..." % target_config['slug']) - # @todo iterate on models when there are many + try: - model_slug = target_config['models'][0]['slug'] + models = target_config['models'] except Exception as e: abort(500, "Invalid model configuration for '%s' : %s" % (target_config['slug'], str(e))) try: - orbit_slug = target_config['orbit']['model'] + orbits = target_config['orbit']['models'] except Exception as e: abort(500, "Invalid orbit configuration for '%s' : %s" % (target_config['slug'], str(e))) # Grab the list of netCDF files from Myriam's API - # http://cdpp.irap.omp.eu/BASE/DDService/getDataUrl.php?dataSet=jupiter_orb_all&StartTime=2014-02-23T10:00:10&StopTime=2017-02-24T23:59:00 - # http://cdpp.irap.omp.eu/BASE/DATA/TAO/JUPITER/SW/sw_2014.nc.gz - model_files = retrieve_amda_netcdf(target_config['slug'], model_slug, - started_at, stopped_at) - orbit_files = retrieve_amda_netcdf(target_config['slug'], orbit_slug, - started_at, stopped_at) - - precision = "%Y-%m-%dT%H" # model and orbits times are equal-ish + model_files = [] + orbit_files = [] + for model in models: + model_files = model_files + retrieve_amda_netcdf( + target_config['slug'], model['slug'], started_at, stopped_at + ) + for orbit in orbits: + orbit_files = orbit_files + retrieve_amda_netcdf( + target_config['slug'], orbit['slug'], started_at, stopped_at + ) + # Remove possible duplicates + model_files = set(model_files) + orbit_files = set(orbit_files) + + # if not len(model_files): + # abort(500, "No model files found for '%s'." % target_config['slug']) + # if not len(orbit_files): + # abort(500, "No orbit files found for '%s'." % target_config['slug']) + + precision = "%Y-%m-%dT%H" # model and orbits times are only equal-ish orbit_data = {} # keys are datetime as str, values arrays of XY for orbit_file in orbit_files: log.debug("%s: opening orbit NETCDF4 '%s'..." % @@ -424,7 +439,19 @@ def generate_csv_file_if_needed(target_slug, started_at, stopped_at): started_at.strftime(FILE_DATE_FMT), stopped_at.strftime(FILE_DATE_FMT)) local_csv_file = get_path("../cache/%s" % filename) - if not isfile(local_csv_file): + + generate = True + if isfile(local_csv_file): + # It need to have more than one line to not be empty (headers) + with open(local_csv_file) as f: + cnt = 0 + for _ in f: + cnt += 1 + if cnt > 1: + generate = False + break + + if generate: log.info("Generating CSV '%s'..." % local_csv_file) try: with open(local_csv_file, mode="w+") as f: diff --git a/web/static/css/main.css b/web/static/css/main.css index baca3ab..8d551fc 100755 --- a/web/static/css/main.css +++ b/web/static/css/main.css @@ -279,11 +279,17 @@ ul li { /** MEDIA QUERIES ************************************************************/ -@media all and (max-width: 980px) { - #page-container{ - width: 100%; - } -} +/*@media all and (max-width: 980px) {*/ + /*#page-container{*/ + /*width: 100%;*/ + /*}*/ +/*}*/ + +/*@media all and (max-width: 1024px) {*/ + /*.mdl-layout__drawer {*/ + /*transform: translateX(0px);*/ + /*}*/ +/*}*/ @media all and (max-width: 515px) { dt { width: 130px; } diff --git a/web/static/img/target/empty_128.png b/web/static/img/target/empty_128.png new file mode 100644 index 0000000..3e6f4ee Binary files /dev/null and b/web/static/img/target/empty_128.png differ diff --git a/web/static/js/swapp.js b/web/static/js/swapp.js index 06f99bd..addca91 100644 --- a/web/static/js/swapp.js +++ b/web/static/js/swapp.js @@ -37,7 +37,7 @@ return this$.parameters[p['id']] = p; }); this.orbiter = null; - this.timeSeries = []; + this.time_series = []; } SpaceWeather.prototype.init = function(){ "This is called by the inline bootstrap javascript code.\nThis ain't in the constructor because it might return a Promise later on.\n(for the loader, for example)"; @@ -82,7 +82,7 @@ }; SpaceWeather.prototype.enableTarget = function(target_slug){ var this$ = this; - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (ts.target.slug === target_slug && this$.parameters[ts.parameter].active) { return ts.show(); } @@ -91,7 +91,7 @@ return this; }; SpaceWeather.prototype.disableTarget = function(target_slug){ - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (ts.target.slug === target_slug) { return ts.hide(); } @@ -104,7 +104,7 @@ if ((ref$ = this.orbits) != null) { ref$.resize(); } - return this.timeSeries.forEach(function(ts){ + return this.time_series.forEach(function(ts){ return ts.resize(); }); }; @@ -132,10 +132,10 @@ return data[parameter['id']] = []; }); if (!csv) { - reject("CSV is empty or nonexistent at URL '" + url + "'."); + reject('invalid'); } if (!csv.length) { - reject("CSV is empty at '" + url + "'."); + reject('empty'); } csv.forEach(function(d){ var dtime; @@ -161,7 +161,7 @@ }); }; SpaceWeather.prototype.loadAndCreatePlots = function(started_at, stopped_at){ - "started_at: moment(.js) object\nstopped_at: moment(.js) object"; + "started_at: moment(.js) datetime object\nstopped_at: moment(.js) datetime object"; var k, this$ = this; this.showLoader(); this.started_at = started_at; @@ -181,6 +181,7 @@ targetButton = $(".targets-filters .target." + target.slug); targetButton.addClass('loading'); targetButton.removeClass('failed'); + targetButton.removeClass('empty'); return this$.loadData(target.slug, started_at, stopped_at).then(function(data){ console.info("Loaded CSV data of " + target.name + ".", data); this$.createTimeSeries(target, data); @@ -192,8 +193,19 @@ return this$.disableTarget(target.slug); } }, function(error){ - console.error("Failed loading CSV data of " + target.name + ".", error); - alert("There was an error with " + target.name + ".\nPlease retry."); + var msg; + switch (error) { + case 'invalid': + console.error("Failed loading CSV data of " + target.name + "."); + alert("There was an error with " + target.name + ".\nPlease retry in a few moments."); + this$.is_invalid = true; + break; + case 'empty': + msg = "No data for " + target.name + "\n during interval from \n" + started_at + " to " + stopped_at + "."; + console.warn(msg); + targetButton.addClass('empty'); + break; + } targetButton.addClass('failed'); targetButton.removeClass('loading'); return this$.hideLoader(); @@ -202,11 +214,11 @@ }; SpaceWeather.prototype.clearPlots = function(){ this.orbits.clear(); - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ return ts.clear(); }); this.orbits = null; - this.timeSeries = []; + this.time_series = []; return this; }; SpaceWeather.prototype.createTimeSeries = function(target, data){ @@ -219,24 +231,24 @@ if (!(id in data)) { console.error("No data for id '" + id + "'.", data); } - return this$.timeSeries.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container)); + return this$.time_series.push(new TimeSeries(id, title, target, data[id], this$.parameters[id].active, container)); }); - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ ts.options['onMouseOver'] = function(){ - this$.timeSeries.forEach(function(ts2){ + this$.time_series.forEach(function(ts2){ return ts2.showCursor(); }); return true; }; ts.options['onMouseOut'] = function(){ - this$.timeSeries.forEach(function(ts2){ + this$.time_series.forEach(function(ts2){ return ts2.hideCursor(); }); return true; }; ts.options['onMouseMove'] = function(t){ var ref$; - this$.timeSeries.forEach(function(ts2){ + this$.time_series.forEach(function(ts2){ return ts2.moveCursor(t); }); if ((ref$ = this$.orbits) != null) { @@ -257,7 +269,7 @@ return true; }; }); - return this.timeSeries; + return this.time_series; }; SpaceWeather.prototype.enableParameter = function(parameter_slug){ var this$ = this; @@ -265,7 +277,7 @@ console.error("Unknown parameter " + parameter_slug + "."); } this.parameters[parameter_slug].active = true; - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (ts.parameter === parameter_slug && this$.targets[ts.target.slug].active) { return ts.show(); } @@ -277,7 +289,7 @@ console.error("Unknown parameter " + parameter_slug + "."); } this.parameters[parameter_slug].active = false; - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (ts.parameter === parameter_slug) { return ts.hide(); } @@ -307,20 +319,21 @@ this.setStartAndStop(started_at, stopped_at); formatted_started_at = started_at.format(); formatted_stopped_at = stopped_at.format(); - if ((this.started_at <= started_at && started_at <= this.stopped_at) && (this.started_at <= stopped_at && stopped_at <= this.stopped_at)) { + if (!this.is_invalid && (this.started_at <= started_at && started_at <= this.stopped_at) && (this.started_at <= stopped_at && stopped_at <= this.stopped_at)) { console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " without fetching new data…"); - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (!ts.visible) { return ts.zoomIn(started_at, stopped_at); } }); - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ if (ts.visible) { return ts.zoomIn(started_at, stopped_at); } }); this.orbits.resizeDomain(started_at, stopped_at); } else { + this.is_invalid = false; console.info("Resizing the temporal domain from " + formatted_started_at + " to " + formatted_stopped_at + " and fetching new data…"); console.warn("This might take a while… Why not see what else we're up to on http://cdpp.eu while you're waiting?"); this.clearPlots(); @@ -329,7 +342,7 @@ return this; }; SpaceWeather.prototype.resetZoom = function(){ - this.timeSeries.forEach(function(ts){ + this.time_series.forEach(function(ts){ return ts.resetZoom(); }); this.orbits.resetZoom(); diff --git a/web/static/js/swapp.ls b/web/static/js/swapp.ls index 7cfa9ae..80d8eb5 100644 --- a/web/static/js/swapp.ls +++ b/web/static/js/swapp.ls @@ -63,8 +63,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE @configuration['parameters'].forEach((p) ~> @parameters[p['id']] = p ) - @orbiter = null # our Orbiter - @timeSeries = [] # a List of TimeSeries objects + @orbiter = null # our Orbiter defined below + @time_series = [] # a List of TimeSeries objects init: -> """ @@ -107,18 +107,18 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE # this enableTarget: (target_slug) -> - @timeSeries.forEach((ts) ~> ts.show() if ts.target.slug == target_slug && @parameters[ts.parameter].active) + @time_series.forEach((ts) ~> ts.show() if ts.target.slug == target_slug && @parameters[ts.parameter].active) @targets[target_slug].active = true this disableTarget: (target_slug) -> - @timeSeries.forEach((ts) -> ts.hide() if ts.target.slug == target_slug) + @time_series.forEach((ts) -> ts.hide() if ts.target.slug == target_slug) @targets[target_slug].active = false this resize: -> @orbits?.resize(); - @timeSeries.forEach((ts) -> ts.resize()) + @time_series.forEach((ts) -> ts.resize()) showLoader: -> $('#plots_loader').show(); @@ -142,8 +142,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE configuration['parameters'].forEach((parameter) -> data[parameter['id']] = [] ) - unless csv then reject "CSV is empty or nonexistent at URL '#{url}'." - unless csv.length then reject "CSV is empty at '#{url}'." + unless csv then reject 'invalid' + unless csv.length then reject 'empty' csv.forEach((d) -> dtime = timeFormat(d['time']) configuration['parameters'].forEach((parameter) -> @@ -161,8 +161,8 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE loadAndCreatePlots: (started_at, stopped_at) -> """ - started_at: moment(.js) object - stopped_at: moment(.js) object + started_at: moment(.js) datetime object + stopped_at: moment(.js) datetime object """ @showLoader() @started_at = started_at @@ -176,6 +176,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE targetButton = $(".targets-filters .target.#{target.slug}") targetButton.addClass('loading') targetButton.removeClass('failed') + targetButton.removeClass('empty') # fixme @loadData(target.slug, started_at, stopped_at).then( (data) ~> console.info "Loaded CSV data of #{target.name}.", data @@ -185,21 +186,32 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE if target.active then @hideLoader() else @disableTarget(target.slug) , (error) ~> - # Sometimes, AMDA's API returns garbage, so the CSV sometime fails - # But when we re-generate it a second time, usually it's okay. - console.error("Failed loading CSV data of #{target.name}.", error) - alert("There was an error with #{target.name}.\nPlease retry.") + switch error + case 'invalid' + console.error("Failed loading CSV data of #{target.name}.") + # Sometimes, AMDA's API returns garbage, so the CSV sometime fails + # But when we re-generate it a second time, usually it's okay. + alert("There was an error with #{target.name}.\nPlease retry in a few moments.") + @is_invalid = true + break + case 'empty' + msg = "No data for #{target.name}\n during interval from \n#{started_at} to #{stopped_at}." + console.warn(msg) + targetButton.addClass('empty') +# alert(msg) + break targetButton.addClass('failed') targetButton.removeClass('loading') @hideLoader() + ) ) clearPlots: -> @orbits.clear() - @timeSeries.forEach((ts) -> ts.clear()) + @time_series.forEach((ts) -> ts.clear()) @orbits = null - @timeSeries = [] # do we de-reference everything ? listeners ? #memleak? + @time_series = [] # do we de-reference everything ? listeners ? #memleak? this createTimeSeries: (target, data) -> @@ -207,35 +219,35 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE container = @configuration['time_series_container'] id = parameter['id'] ; title = parameter['title'] if id not of data then console.error("No data for id '#{id}'.", data) - @timeSeries.push(new TimeSeries( + @time_series.push(new TimeSeries( id, title, target, data[id], @parameters[id].active, container )) ) - @timeSeries.forEach((ts) ~> # returning true may be faster + @time_series.forEach((ts) ~> # returning true may be faster ts.options['onMouseOver'] = ~> - @timeSeries.forEach((ts2) -> ts2.showCursor()) ; true + @time_series.forEach((ts2) -> ts2.showCursor()) ; true ts.options['onMouseOut'] = ~> - @timeSeries.forEach((ts2) -> ts2.hideCursor()) ; true + @time_series.forEach((ts2) -> ts2.hideCursor()) ; true ts.options['onMouseMove'] = (t) ~> - @timeSeries.forEach((ts2) -> ts2.moveCursor(t)) + @time_series.forEach((ts2) -> ts2.moveCursor(t)) @orbits?.moveToDate(t) ; true ts.options['onBrushEnd'] = (sta, sto) ~> @resizeDomain(moment(sta), moment(sto)) ; true ts.options['onDblClick'] = ~> @resetZoom() ; $("\#zoom_controls_help")?.remove() ; true ) - @timeSeries + @time_series enableParameter: (parameter_slug) -> if parameter_slug not of @parameters then console.error("Unknown parameter #{parameter_slug}.") @parameters[parameter_slug].active = true - @timeSeries.forEach((ts) ~> ts.show() if ts.parameter == parameter_slug && @targets[ts.target.slug].active) + @time_series.forEach((ts) ~> ts.show() if ts.parameter == parameter_slug && @targets[ts.target.slug].active) this disableParameter: (parameter_slug) -> if parameter_slug not of @parameters then console.error("Unknown parameter #{parameter_slug}.") @parameters[parameter_slug].active = false - @timeSeries.forEach((ts) -> ts.hide() if ts.parameter == parameter_slug) + @time_series.forEach((ts) -> ts.hide() if ts.parameter == parameter_slug) this getDomain: -> @@ -258,15 +270,17 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE formatted_started_at = started_at.format() formatted_stopped_at = stopped_at.format() - if (@started_at <= started_at <= @stopped_at) and + if (not @is_invalid) and + (@started_at <= started_at <= @stopped_at) and (@started_at <= stopped_at <= @stopped_at) then console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} without fetching new data…" # We first resize the hidden time series and only afterwards we resize # the visible ones, for a smoother transition. - @timeSeries.forEach((ts) -> if not ts.visible then ts.zoomIn(started_at, stopped_at)) - @timeSeries.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) + @time_series.forEach((ts) -> if not ts.visible then ts.zoomIn(started_at, stopped_at)) + @time_series.forEach((ts) -> if ts.visible then ts.zoomIn(started_at, stopped_at)) @orbits.resizeDomain started_at, stopped_at else + @is_invalid = false console.info "Resizing the temporal domain from #{formatted_started_at} to #{formatted_stopped_at} and fetching new data…" console.warn "This might take a while… Why not see what else we're up to on http://cdpp.eu while you're waiting?" # fetch new data and remake the plots @@ -276,7 +290,7 @@ https://gitlab.irap.omp.eu/CDPP/SPACEWEATHERONLINE this resetZoom: -> - @timeSeries.forEach((ts) -> ts.resetZoom()) + @time_series.forEach((ts) -> ts.resetZoom()) @orbits.resetZoom() @setStartAndStop(@started_at, @stopped_at) this diff --git a/web/static/js/vendor/d3-custom.js b/web/static/js/vendor/d3-custom.js index 8eb6013..9dbf1dd 100644 --- a/web/static/js/vendor/d3-custom.js +++ b/web/static/js/vendor/d3-custom.js @@ -4482,7 +4482,7 @@ function brush$1(dim) { } point = point1; moving = true; - //noevent$1(); + //noevent$1(); // enable event bubbling move(); } diff --git a/web/static/js/vendor/material-custom.js b/web/static/js/vendor/material-custom.js new file mode 100644 index 0000000..ae1d05d --- /dev/null +++ b/web/static/js/vendor/material-custom.js @@ -0,0 +1,3996 @@ +;(function() { +"use strict"; + +/** CHANGED LINE 3381, the container is such buggy voodoo + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A component handler interface using the revealing module design pattern. + * More details on this design pattern here: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @author Jason Mayes. + */ +/* exported componentHandler */ + +// Pre-defining the componentHandler interface, for closure documentation and +// static verification. +var componentHandler = { + /** + * Searches existing DOM for elements of our component type and upgrades them + * if they have not already been upgraded. + * + * @param {string=} optJsClass the programatic name of the element class we + * need to create a new instance of. + * @param {string=} optCssClass the name of the CSS class elements of this + * type will have. + */ + upgradeDom: function(optJsClass, optCssClass) {}, + /** + * Upgrades a specific element rather than all in the DOM. + * + * @param {!Element} element The element we wish to upgrade. + * @param {string=} optJsClass Optional name of the class we want to upgrade + * the element to. + */ + upgradeElement: function(element, optJsClass) {}, + /** + * Upgrades a specific list of elements rather than all in the DOM. + * + * @param {!Element|!Array|!NodeList|!HTMLCollection} elements + * The elements we wish to upgrade. + */ + upgradeElements: function(elements) {}, + /** + * Upgrades all registered components found in the current DOM. This is + * automatically called on window load. + */ + upgradeAllRegistered: function() {}, + /** + * Allows user to be alerted to any upgrades that are performed for a given + * component type + * + * @param {string} jsClass The class name of the MDL component we wish + * to hook into for any upgrades performed. + * @param {function(!HTMLElement)} callback The function to call upon an + * upgrade. This function should expect 1 parameter - the HTMLElement which + * got upgraded. + */ + registerUpgradedCallback: function(jsClass, callback) {}, + /** + * Registers a class for future use and attempts to upgrade existing DOM. + * + * @param {componentHandler.ComponentConfigPublic} config the registration configuration + */ + register: function(config) {}, + /** + * Downgrade either a given node, an array of nodes, or a NodeList. + * + * @param {!Node|!Array|!NodeList} nodes + */ + downgradeElements: function(nodes) {} +}; + +componentHandler = (function() { + 'use strict'; + + /** @type {!Array} */ + var registeredComponents_ = []; + + /** @type {!Array} */ + var createdComponents_ = []; + + var componentConfigProperty_ = 'mdlComponentConfigInternal_'; + + /** + * Searches registered components for a class we are interested in using. + * Optionally replaces a match with passed object if specified. + * + * @param {string} name The name of a class we want to use. + * @param {componentHandler.ComponentConfig=} optReplace Optional object to replace match with. + * @return {!Object|boolean} + * @private + */ + function findRegisteredClass_(name, optReplace) { + for (var i = 0; i < registeredComponents_.length; i++) { + if (registeredComponents_[i].className === name) { + if (typeof optReplace !== 'undefined') { + registeredComponents_[i] = optReplace; + } + return registeredComponents_[i]; + } + } + return false; + } + + /** + * Returns an array of the classNames of the upgraded classes on the element. + * + * @param {!Element} element The element to fetch data from. + * @return {!Array} + * @private + */ + function getUpgradedListOfElement_(element) { + var dataUpgraded = element.getAttribute('data-upgraded'); + // Use `['']` as default value to conform the `,name,name...` style. + return dataUpgraded === null ? [''] : dataUpgraded.split(','); + } + + /** + * Returns true if the given element has already been upgraded for the given + * class. + * + * @param {!Element} element The element we want to check. + * @param {string} jsClass The class to check for. + * @returns {boolean} + * @private + */ + function isElementUpgraded_(element, jsClass) { + var upgradedList = getUpgradedListOfElement_(element); + return upgradedList.indexOf(jsClass) !== -1; + } + + /** + * Create an event object. + * + * @param {string} eventType The type name of the event. + * @param {boolean} bubbles Whether the event should bubble up the DOM. + * @param {boolean} cancelable Whether the event can be canceled. + * @returns {!Event} + */ + function createEvent_(eventType, bubbles, cancelable) { + if ('CustomEvent' in window && typeof window.CustomEvent === 'function') { + return new CustomEvent(eventType, { + bubbles: bubbles, + cancelable: cancelable + }); + } else { + var ev = document.createEvent('Events'); + ev.initEvent(eventType, bubbles, cancelable); + return ev; + } + } + + /** + * Searches existing DOM for elements of our component type and upgrades them + * if they have not already been upgraded. + * + * @param {string=} optJsClass the programatic name of the element class we + * need to create a new instance of. + * @param {string=} optCssClass the name of the CSS class elements of this + * type will have. + */ + function upgradeDomInternal(optJsClass, optCssClass) { + if (typeof optJsClass === 'undefined' && + typeof optCssClass === 'undefined') { + for (var i = 0; i < registeredComponents_.length; i++) { + upgradeDomInternal(registeredComponents_[i].className, + registeredComponents_[i].cssClass); + } + } else { + var jsClass = /** @type {string} */ (optJsClass); + if (typeof optCssClass === 'undefined') { + var registeredClass = findRegisteredClass_(jsClass); + if (registeredClass) { + optCssClass = registeredClass.cssClass; + } + } + + var elements = document.querySelectorAll('.' + optCssClass); + for (var n = 0; n < elements.length; n++) { + upgradeElementInternal(elements[n], jsClass); + } + } + } + + /** + * Upgrades a specific element rather than all in the DOM. + * + * @param {!Element} element The element we wish to upgrade. + * @param {string=} optJsClass Optional name of the class we want to upgrade + * the element to. + */ + function upgradeElementInternal(element, optJsClass) { + // Verify argument type. + if (!(typeof element === 'object' && element instanceof Element)) { + throw new Error('Invalid argument provided to upgrade MDL element.'); + } + // Allow upgrade to be canceled by canceling emitted event. + var upgradingEv = createEvent_('mdl-componentupgrading', true, true); + element.dispatchEvent(upgradingEv); + if (upgradingEv.defaultPrevented) { + return; + } + + var upgradedList = getUpgradedListOfElement_(element); + var classesToUpgrade = []; + // If jsClass is not provided scan the registered components to find the + // ones matching the element's CSS classList. + if (!optJsClass) { + var classList = element.classList; + registeredComponents_.forEach(function(component) { + // Match CSS & Not to be upgraded & Not upgraded. + if (classList.contains(component.cssClass) && + classesToUpgrade.indexOf(component) === -1 && + !isElementUpgraded_(element, component.className)) { + classesToUpgrade.push(component); + } + }); + } else if (!isElementUpgraded_(element, optJsClass)) { + classesToUpgrade.push(findRegisteredClass_(optJsClass)); + } + + // Upgrade the element for each classes. + for (var i = 0, n = classesToUpgrade.length, registeredClass; i < n; i++) { + registeredClass = classesToUpgrade[i]; + if (registeredClass) { + // Mark element as upgraded. + upgradedList.push(registeredClass.className); + element.setAttribute('data-upgraded', upgradedList.join(',')); + var instance = new registeredClass.classConstructor(element); + instance[componentConfigProperty_] = registeredClass; + createdComponents_.push(instance); + // Call any callbacks the user has registered with this component type. + for (var j = 0, m = registeredClass.callbacks.length; j < m; j++) { + registeredClass.callbacks[j](element); + } + + if (registeredClass.widget) { + // Assign per element instance for control over API + element[registeredClass.className] = instance; + } + } else { + throw new Error( + 'Unable to find a registered component for the given class.'); + } + + var upgradedEv = createEvent_('mdl-componentupgraded', true, false); + element.dispatchEvent(upgradedEv); + } + } + + /** + * Upgrades a specific list of elements rather than all in the DOM. + * + * @param {!Element|!Array|!NodeList|!HTMLCollection} elements + * The elements we wish to upgrade. + */ + function upgradeElementsInternal(elements) { + if (!Array.isArray(elements)) { + if (elements instanceof Element) { + elements = [elements]; + } else { + elements = Array.prototype.slice.call(elements); + } + } + for (var i = 0, n = elements.length, element; i < n; i++) { + element = elements[i]; + if (element instanceof HTMLElement) { + upgradeElementInternal(element); + if (element.children.length > 0) { + upgradeElementsInternal(element.children); + } + } + } + } + + /** + * Registers a class for future use and attempts to upgrade existing DOM. + * + * @param {componentHandler.ComponentConfigPublic} config + */ + function registerInternal(config) { + // In order to support both Closure-compiled and uncompiled code accessing + // this method, we need to allow for both the dot and array syntax for + // property access. You'll therefore see the `foo.bar || foo['bar']` + // pattern repeated across this method. + var widgetMissing = (typeof config.widget === 'undefined' && + typeof config['widget'] === 'undefined'); + var widget = true; + + if (!widgetMissing) { + widget = config.widget || config['widget']; + } + + var newConfig = /** @type {componentHandler.ComponentConfig} */ ({ + classConstructor: config.constructor || config['constructor'], + className: config.classAsString || config['classAsString'], + cssClass: config.cssClass || config['cssClass'], + widget: widget, + callbacks: [] + }); + + registeredComponents_.forEach(function(item) { + if (item.cssClass === newConfig.cssClass) { + throw new Error('The provided cssClass has already been registered: ' + item.cssClass); + } + if (item.className === newConfig.className) { + throw new Error('The provided className has already been registered'); + } + }); + + if (config.constructor.prototype + .hasOwnProperty(componentConfigProperty_)) { + throw new Error( + 'MDL component classes must not have ' + componentConfigProperty_ + + ' defined as a property.'); + } + + var found = findRegisteredClass_(config.classAsString, newConfig); + + if (!found) { + registeredComponents_.push(newConfig); + } + } + + /** + * Allows user to be alerted to any upgrades that are performed for a given + * component type + * + * @param {string} jsClass The class name of the MDL component we wish + * to hook into for any upgrades performed. + * @param {function(!HTMLElement)} callback The function to call upon an + * upgrade. This function should expect 1 parameter - the HTMLElement which + * got upgraded. + */ + function registerUpgradedCallbackInternal(jsClass, callback) { + var regClass = findRegisteredClass_(jsClass); + if (regClass) { + regClass.callbacks.push(callback); + } + } + + /** + * Upgrades all registered components found in the current DOM. This is + * automatically called on window load. + */ + function upgradeAllRegisteredInternal() { + for (var n = 0; n < registeredComponents_.length; n++) { + upgradeDomInternal(registeredComponents_[n].className); + } + } + + /** + * Check the component for the downgrade method. + * Execute if found. + * Remove component from createdComponents list. + * + * @param {?componentHandler.Component} component + */ + function deconstructComponentInternal(component) { + if (component) { + var componentIndex = createdComponents_.indexOf(component); + createdComponents_.splice(componentIndex, 1); + + var upgrades = component.element_.getAttribute('data-upgraded').split(','); + var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString); + upgrades.splice(componentPlace, 1); + component.element_.setAttribute('data-upgraded', upgrades.join(',')); + + var ev = createEvent_('mdl-componentdowngraded', true, false); + component.element_.dispatchEvent(ev); + } + } + + /** + * Downgrade either a given node, an array of nodes, or a NodeList. + * + * @param {!Node|!Array|!NodeList} nodes + */ + function downgradeNodesInternal(nodes) { + /** + * Auxiliary function to downgrade a single node. + * @param {!Node} node the node to be downgraded + */ + var downgradeNode = function(node) { + createdComponents_.filter(function(item) { + return item.element_ === node; + }).forEach(deconstructComponentInternal); + }; + if (nodes instanceof Array || nodes instanceof NodeList) { + for (var n = 0; n < nodes.length; n++) { + downgradeNode(nodes[n]); + } + } else if (nodes instanceof Node) { + downgradeNode(nodes); + } else { + throw new Error('Invalid argument provided to downgrade MDL nodes.'); + } + } + + // Now return the functions that should be made public with their publicly + // facing names... + return { + upgradeDom: upgradeDomInternal, + upgradeElement: upgradeElementInternal, + upgradeElements: upgradeElementsInternal, + upgradeAllRegistered: upgradeAllRegisteredInternal, + registerUpgradedCallback: registerUpgradedCallbackInternal, + register: registerInternal, + downgradeElements: downgradeNodesInternal + }; +})(); + +/** + * Describes the type of a registered component type managed by + * componentHandler. Provided for benefit of the Closure compiler. + * + * @typedef {{ + * constructor: Function, + * classAsString: string, + * cssClass: string, + * widget: (string|boolean|undefined) + * }} + */ +componentHandler.ComponentConfigPublic; // jshint ignore:line + +/** + * Describes the type of a registered component type managed by + * componentHandler. Provided for benefit of the Closure compiler. + * + * @typedef {{ + * constructor: !Function, + * className: string, + * cssClass: string, + * widget: (string|boolean), + * callbacks: !Array + * }} + */ +componentHandler.ComponentConfig; // jshint ignore:line + +/** + * Created component (i.e., upgraded element) type as managed by + * componentHandler. Provided for benefit of the Closure compiler. + * + * @typedef {{ + * element_: !HTMLElement, + * className: string, + * classAsString: string, + * cssClass: string, + * widget: string + * }} + */ +componentHandler.Component; // jshint ignore:line + +// Export all symbols, for the benefit of Closure compiler. +// No effect on uncompiled code. +componentHandler['upgradeDom'] = componentHandler.upgradeDom; +componentHandler['upgradeElement'] = componentHandler.upgradeElement; +componentHandler['upgradeElements'] = componentHandler.upgradeElements; +componentHandler['upgradeAllRegistered'] = + componentHandler.upgradeAllRegistered; +componentHandler['registerUpgradedCallback'] = + componentHandler.registerUpgradedCallback; +componentHandler['register'] = componentHandler.register; +componentHandler['downgradeElements'] = componentHandler.downgradeElements; +window.componentHandler = componentHandler; +window['componentHandler'] = componentHandler; + +window.addEventListener('load', function() { + 'use strict'; + + /** + * Performs a "Cutting the mustard" test. If the browser supports the features + * tested, adds a mdl-js class to the element. It then upgrades all MDL + * components requiring JavaScript. + */ + if ('classList' in document.createElement('div') && + 'querySelector' in document && + 'addEventListener' in window && Array.prototype.forEach) { + document.documentElement.classList.add('mdl-js'); + componentHandler.upgradeAllRegistered(); + } else { + /** + * Dummy function to avoid JS errors. + */ + componentHandler.upgradeElement = function() {}; + /** + * Dummy function to avoid JS errors. + */ + componentHandler.register = function() {}; + } +}); + +// Source: https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js +// Adapted from https://gist.github.com/paulirish/1579671 which derived from +// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ +// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating +// requestAnimationFrame polyfill by Erik Möller. +// Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon +// MIT license +if (!Date.now) { + /** + * Date.now polyfill. + * @return {number} the current Date + */ + Date.now = function () { + return new Date().getTime(); + }; + Date['now'] = Date.now; +} +var vendors = [ + 'webkit', + 'moz' +]; +for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { + var vp = vendors[i]; + window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; + window.cancelAnimationFrame = window[vp + 'CancelAnimationFrame'] || window[vp + 'CancelRequestAnimationFrame']; + window['requestAnimationFrame'] = window.requestAnimationFrame; + window['cancelAnimationFrame'] = window.cancelAnimationFrame; +} +if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { + var lastTime = 0; + /** + * requestAnimationFrame polyfill. + * @param {!Function} callback the callback function. + */ + window.requestAnimationFrame = function (callback) { + var now = Date.now(); + var nextTime = Math.max(lastTime + 16, now); + return setTimeout(function () { + callback(lastTime = nextTime); + }, nextTime - now); + }; + window.cancelAnimationFrame = clearTimeout; + window['requestAnimationFrame'] = window.requestAnimationFrame; + window['cancelAnimationFrame'] = window.cancelAnimationFrame; +} +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Button MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialButton = function MaterialButton(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialButton'] = MaterialButton; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialButton.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialButton.prototype.CssClasses_ = { + RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_CONTAINER: 'mdl-button__ripple-container', + RIPPLE: 'mdl-ripple' +}; +/** + * Handle blur of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialButton.prototype.blurHandler_ = function (event) { + if (event) { + this.element_.blur(); + } +}; +// Public methods. +/** + * Disable button. + * + * @public + */ +MaterialButton.prototype.disable = function () { + this.element_.disabled = true; +}; +MaterialButton.prototype['disable'] = MaterialButton.prototype.disable; +/** + * Enable button. + * + * @public + */ +MaterialButton.prototype.enable = function () { + this.element_.disabled = false; +}; +MaterialButton.prototype['enable'] = MaterialButton.prototype.enable; +/** + * Initialize element. + */ +MaterialButton.prototype.init = function () { + if (this.element_) { + if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { + var rippleContainer = document.createElement('span'); + rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER); + this.rippleElement_ = document.createElement('span'); + this.rippleElement_.classList.add(this.CssClasses_.RIPPLE); + rippleContainer.appendChild(this.rippleElement_); + this.boundRippleBlurHandler = this.blurHandler_.bind(this); + this.rippleElement_.addEventListener('mouseup', this.boundRippleBlurHandler); + this.element_.appendChild(rippleContainer); + } + this.boundButtonBlurHandler = this.blurHandler_.bind(this); + this.element_.addEventListener('mouseup', this.boundButtonBlurHandler); + this.element_.addEventListener('mouseleave', this.boundButtonBlurHandler); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialButton, + classAsString: 'MaterialButton', + cssClass: 'mdl-js-button', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Checkbox MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialCheckbox = function MaterialCheckbox(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialCheckbox'] = MaterialCheckbox; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialCheckbox.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialCheckbox.prototype.CssClasses_ = { + INPUT: 'mdl-checkbox__input', + BOX_OUTLINE: 'mdl-checkbox__box-outline', + FOCUS_HELPER: 'mdl-checkbox__focus-helper', + TICK_OUTLINE: 'mdl-checkbox__tick-outline', + RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + RIPPLE_CONTAINER: 'mdl-checkbox__ripple-container', + RIPPLE_CENTER: 'mdl-ripple--center', + RIPPLE: 'mdl-ripple', + IS_FOCUSED: 'is-focused', + IS_DISABLED: 'is-disabled', + IS_CHECKED: 'is-checked', + IS_UPGRADED: 'is-upgraded' +}; +/** + * Handle change of state. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialCheckbox.prototype.onChange_ = function (event) { + this.updateClasses_(); +}; +/** + * Handle focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialCheckbox.prototype.onFocus_ = function (event) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle lost focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialCheckbox.prototype.onBlur_ = function (event) { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle mouseup. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialCheckbox.prototype.onMouseUp_ = function (event) { + this.blur_(); +}; +/** + * Handle class updates. + * + * @private + */ +MaterialCheckbox.prototype.updateClasses_ = function () { + this.checkDisabled(); + this.checkToggleState(); +}; +/** + * Add blur. + * + * @private + */ +MaterialCheckbox.prototype.blur_ = function () { + // TODO: figure out why there's a focus event being fired after our blur, + // so that we can avoid this hack. + window.setTimeout(function () { + this.inputElement_.blur(); + }.bind(this), this.Constant_.TINY_TIMEOUT); +}; +// Public methods. +/** + * Check the inputs toggle state and update display. + * + * @public + */ +MaterialCheckbox.prototype.checkToggleState = function () { + if (this.inputElement_.checked) { + this.element_.classList.add(this.CssClasses_.IS_CHECKED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_CHECKED); + } +}; +MaterialCheckbox.prototype['checkToggleState'] = MaterialCheckbox.prototype.checkToggleState; +/** + * Check the inputs disabled state and update display. + * + * @public + */ +MaterialCheckbox.prototype.checkDisabled = function () { + if (this.inputElement_.disabled) { + this.element_.classList.add(this.CssClasses_.IS_DISABLED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DISABLED); + } +}; +MaterialCheckbox.prototype['checkDisabled'] = MaterialCheckbox.prototype.checkDisabled; +/** + * Disable checkbox. + * + * @public + */ +MaterialCheckbox.prototype.disable = function () { + this.inputElement_.disabled = true; + this.updateClasses_(); +}; +MaterialCheckbox.prototype['disable'] = MaterialCheckbox.prototype.disable; +/** + * Enable checkbox. + * + * @public + */ +MaterialCheckbox.prototype.enable = function () { + this.inputElement_.disabled = false; + this.updateClasses_(); +}; +MaterialCheckbox.prototype['enable'] = MaterialCheckbox.prototype.enable; +/** + * Check checkbox. + * + * @public + */ +MaterialCheckbox.prototype.check = function () { + this.inputElement_.checked = true; + this.updateClasses_(); +}; +MaterialCheckbox.prototype['check'] = MaterialCheckbox.prototype.check; +/** + * Uncheck checkbox. + * + * @public + */ +MaterialCheckbox.prototype.uncheck = function () { + this.inputElement_.checked = false; + this.updateClasses_(); +}; +MaterialCheckbox.prototype['uncheck'] = MaterialCheckbox.prototype.uncheck; +/** + * Initialize element. + */ +MaterialCheckbox.prototype.init = function () { + if (this.element_) { + this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); + var boxOutline = document.createElement('span'); + boxOutline.classList.add(this.CssClasses_.BOX_OUTLINE); + var tickContainer = document.createElement('span'); + tickContainer.classList.add(this.CssClasses_.FOCUS_HELPER); + var tickOutline = document.createElement('span'); + tickOutline.classList.add(this.CssClasses_.TICK_OUTLINE); + boxOutline.appendChild(tickOutline); + this.element_.appendChild(tickContainer); + this.element_.appendChild(boxOutline); + if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + this.rippleContainerElement_ = document.createElement('span'); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); + this.boundRippleMouseUp = this.onMouseUp_.bind(this); + this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp); + var ripple = document.createElement('span'); + ripple.classList.add(this.CssClasses_.RIPPLE); + this.rippleContainerElement_.appendChild(ripple); + this.element_.appendChild(this.rippleContainerElement_); + } + this.boundInputOnChange = this.onChange_.bind(this); + this.boundInputOnFocus = this.onFocus_.bind(this); + this.boundInputOnBlur = this.onBlur_.bind(this); + this.boundElementMouseUp = this.onMouseUp_.bind(this); + this.inputElement_.addEventListener('change', this.boundInputOnChange); + this.inputElement_.addEventListener('focus', this.boundInputOnFocus); + this.inputElement_.addEventListener('blur', this.boundInputOnBlur); + this.element_.addEventListener('mouseup', this.boundElementMouseUp); + this.updateClasses_(); + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialCheckbox, + classAsString: 'MaterialCheckbox', + cssClass: 'mdl-js-checkbox', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for icon toggle MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialIconToggle = function MaterialIconToggle(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialIconToggle'] = MaterialIconToggle; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialIconToggle.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialIconToggle.prototype.CssClasses_ = { + INPUT: 'mdl-icon-toggle__input', + JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + RIPPLE_CONTAINER: 'mdl-icon-toggle__ripple-container', + RIPPLE_CENTER: 'mdl-ripple--center', + RIPPLE: 'mdl-ripple', + IS_FOCUSED: 'is-focused', + IS_DISABLED: 'is-disabled', + IS_CHECKED: 'is-checked' +}; +/** + * Handle change of state. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialIconToggle.prototype.onChange_ = function (event) { + this.updateClasses_(); +}; +/** + * Handle focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialIconToggle.prototype.onFocus_ = function (event) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle lost focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialIconToggle.prototype.onBlur_ = function (event) { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle mouseup. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialIconToggle.prototype.onMouseUp_ = function (event) { + this.blur_(); +}; +/** + * Handle class updates. + * + * @private + */ +MaterialIconToggle.prototype.updateClasses_ = function () { + this.checkDisabled(); + this.checkToggleState(); +}; +/** + * Add blur. + * + * @private + */ +MaterialIconToggle.prototype.blur_ = function () { + // TODO: figure out why there's a focus event being fired after our blur, + // so that we can avoid this hack. + window.setTimeout(function () { + this.inputElement_.blur(); + }.bind(this), this.Constant_.TINY_TIMEOUT); +}; +// Public methods. +/** + * Check the inputs toggle state and update display. + * + * @public + */ +MaterialIconToggle.prototype.checkToggleState = function () { + if (this.inputElement_.checked) { + this.element_.classList.add(this.CssClasses_.IS_CHECKED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_CHECKED); + } +}; +MaterialIconToggle.prototype['checkToggleState'] = MaterialIconToggle.prototype.checkToggleState; +/** + * Check the inputs disabled state and update display. + * + * @public + */ +MaterialIconToggle.prototype.checkDisabled = function () { + if (this.inputElement_.disabled) { + this.element_.classList.add(this.CssClasses_.IS_DISABLED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DISABLED); + } +}; +MaterialIconToggle.prototype['checkDisabled'] = MaterialIconToggle.prototype.checkDisabled; +/** + * Disable icon toggle. + * + * @public + */ +MaterialIconToggle.prototype.disable = function () { + this.inputElement_.disabled = true; + this.updateClasses_(); +}; +MaterialIconToggle.prototype['disable'] = MaterialIconToggle.prototype.disable; +/** + * Enable icon toggle. + * + * @public + */ +MaterialIconToggle.prototype.enable = function () { + this.inputElement_.disabled = false; + this.updateClasses_(); +}; +MaterialIconToggle.prototype['enable'] = MaterialIconToggle.prototype.enable; +/** + * Check icon toggle. + * + * @public + */ +MaterialIconToggle.prototype.check = function () { + this.inputElement_.checked = true; + this.updateClasses_(); +}; +MaterialIconToggle.prototype['check'] = MaterialIconToggle.prototype.check; +/** + * Uncheck icon toggle. + * + * @public + */ +MaterialIconToggle.prototype.uncheck = function () { + this.inputElement_.checked = false; + this.updateClasses_(); +}; +MaterialIconToggle.prototype['uncheck'] = MaterialIconToggle.prototype.uncheck; +/** + * Initialize element. + */ +MaterialIconToggle.prototype.init = function () { + if (this.element_) { + this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); + if (this.element_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + this.rippleContainerElement_ = document.createElement('span'); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); + this.rippleContainerElement_.classList.add(this.CssClasses_.JS_RIPPLE_EFFECT); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); + this.boundRippleMouseUp = this.onMouseUp_.bind(this); + this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp); + var ripple = document.createElement('span'); + ripple.classList.add(this.CssClasses_.RIPPLE); + this.rippleContainerElement_.appendChild(ripple); + this.element_.appendChild(this.rippleContainerElement_); + } + this.boundInputOnChange = this.onChange_.bind(this); + this.boundInputOnFocus = this.onFocus_.bind(this); + this.boundInputOnBlur = this.onBlur_.bind(this); + this.boundElementOnMouseUp = this.onMouseUp_.bind(this); + this.inputElement_.addEventListener('change', this.boundInputOnChange); + this.inputElement_.addEventListener('focus', this.boundInputOnFocus); + this.inputElement_.addEventListener('blur', this.boundInputOnBlur); + this.element_.addEventListener('mouseup', this.boundElementOnMouseUp); + this.updateClasses_(); + this.element_.classList.add('is-upgraded'); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialIconToggle, + classAsString: 'MaterialIconToggle', + cssClass: 'mdl-js-icon-toggle', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for dropdown MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialMenu = function MaterialMenu(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialMenu'] = MaterialMenu; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialMenu.prototype.Constant_ = { + // Total duration of the menu animation. + TRANSITION_DURATION_SECONDS: 0.3, + // The fraction of the total duration we want to use for menu item animations. + TRANSITION_DURATION_FRACTION: 0.8, + // How long the menu stays open after choosing an option (so the user can see + // the ripple). + CLOSE_TIMEOUT: 150 +}; +/** + * Keycodes, for code readability. + * + * @enum {number} + * @private + */ +MaterialMenu.prototype.Keycodes_ = { + ENTER: 13, + ESCAPE: 27, + SPACE: 32, + UP_ARROW: 38, + DOWN_ARROW: 40 +}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialMenu.prototype.CssClasses_ = { + CONTAINER: 'mdl-menu__container', + OUTLINE: 'mdl-menu__outline', + ITEM: 'mdl-menu__item', + ITEM_RIPPLE_CONTAINER: 'mdl-menu__item-ripple-container', + RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + RIPPLE: 'mdl-ripple', + // Statuses + IS_UPGRADED: 'is-upgraded', + IS_VISIBLE: 'is-visible', + IS_ANIMATING: 'is-animating', + // Alignment options + BOTTOM_LEFT: 'mdl-menu--bottom-left', + // This is the default. + BOTTOM_RIGHT: 'mdl-menu--bottom-right', + TOP_LEFT: 'mdl-menu--top-left', + TOP_RIGHT: 'mdl-menu--top-right', + UNALIGNED: 'mdl-menu--unaligned' +}; +/** + * Initialize element. + */ +MaterialMenu.prototype.init = function () { + if (this.element_) { + // Create container for the menu. + var container = document.createElement('div'); + container.classList.add(this.CssClasses_.CONTAINER); + this.element_.parentElement.insertBefore(container, this.element_); + this.element_.parentElement.removeChild(this.element_); + container.appendChild(this.element_); + this.container_ = container; + // Create outline for the menu (shadow and background). + var outline = document.createElement('div'); + outline.classList.add(this.CssClasses_.OUTLINE); + this.outline_ = outline; + container.insertBefore(outline, this.element_); + // Find the "for" element and bind events to it. + var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for'); + var forEl = null; + if (forElId) { + forEl = document.getElementById(forElId); + if (forEl) { + this.forElement_ = forEl; + forEl.addEventListener('click', this.handleForClick_.bind(this)); + forEl.addEventListener('keydown', this.handleForKeyboardEvent_.bind(this)); + } + } + var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); + this.boundItemKeydown_ = this.handleItemKeyboardEvent_.bind(this); + this.boundItemClick_ = this.handleItemClick_.bind(this); + for (var i = 0; i < items.length; i++) { + // Add a listener to each menu item. + items[i].addEventListener('click', this.boundItemClick_); + // Add a tab index to each menu item. + items[i].tabIndex = '-1'; + // Add a keyboard listener to each menu item. + items[i].addEventListener('keydown', this.boundItemKeydown_); + } + // Add ripple classes to each item, if the user has enabled ripples. + if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + for (i = 0; i < items.length; i++) { + var item = items[i]; + var rippleContainer = document.createElement('span'); + rippleContainer.classList.add(this.CssClasses_.ITEM_RIPPLE_CONTAINER); + var ripple = document.createElement('span'); + ripple.classList.add(this.CssClasses_.RIPPLE); + rippleContainer.appendChild(ripple); + item.appendChild(rippleContainer); + item.classList.add(this.CssClasses_.RIPPLE_EFFECT); + } + } + // Copy alignment classes to the container, so the outline can use them. + if (this.element_.classList.contains(this.CssClasses_.BOTTOM_LEFT)) { + this.outline_.classList.add(this.CssClasses_.BOTTOM_LEFT); + } + if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { + this.outline_.classList.add(this.CssClasses_.BOTTOM_RIGHT); + } + if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { + this.outline_.classList.add(this.CssClasses_.TOP_LEFT); + } + if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { + this.outline_.classList.add(this.CssClasses_.TOP_RIGHT); + } + if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { + this.outline_.classList.add(this.CssClasses_.UNALIGNED); + } + container.classList.add(this.CssClasses_.IS_UPGRADED); + } +}; +/** + * Handles a click on the "for" element, by positioning the menu and then + * toggling it. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialMenu.prototype.handleForClick_ = function (evt) { + if (this.element_ && this.forElement_) { + var rect = this.forElement_.getBoundingClientRect(); + var forRect = this.forElement_.parentElement.getBoundingClientRect(); + if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { + } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { + // Position below the "for" element, aligned to its right. + this.container_.style.right = forRect.right - rect.right + 'px'; + this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px'; + } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { + // Position above the "for" element, aligned to its left. + this.container_.style.left = this.forElement_.offsetLeft + 'px'; + this.container_.style.bottom = forRect.bottom - rect.top + 'px'; + } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { + // Position above the "for" element, aligned to its right. + this.container_.style.right = forRect.right - rect.right + 'px'; + this.container_.style.bottom = forRect.bottom - rect.top + 'px'; + } else { + // Default: position below the "for" element, aligned to its left. + this.container_.style.left = this.forElement_.offsetLeft + 'px'; + this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px'; + } + } + this.toggle(evt); +}; +/** + * Handles a keyboard event on the "for" element. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialMenu.prototype.handleForKeyboardEvent_ = function (evt) { + if (this.element_ && this.container_ && this.forElement_) { + var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])'); + if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { + if (evt.keyCode === this.Keycodes_.UP_ARROW) { + evt.preventDefault(); + items[items.length - 1].focus(); + } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) { + evt.preventDefault(); + items[0].focus(); + } + } + } +}; +/** + * Handles a keyboard event on an item. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialMenu.prototype.handleItemKeyboardEvent_ = function (evt) { + if (this.element_ && this.container_) { + var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])'); + if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { + var currentIndex = Array.prototype.slice.call(items).indexOf(evt.target); + if (evt.keyCode === this.Keycodes_.UP_ARROW) { + evt.preventDefault(); + if (currentIndex > 0) { + items[currentIndex - 1].focus(); + } else { + items[items.length - 1].focus(); + } + } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) { + evt.preventDefault(); + if (items.length > currentIndex + 1) { + items[currentIndex + 1].focus(); + } else { + items[0].focus(); + } + } else if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) { + evt.preventDefault(); + // Send mousedown and mouseup to trigger ripple. + var e = new MouseEvent('mousedown'); + evt.target.dispatchEvent(e); + e = new MouseEvent('mouseup'); + evt.target.dispatchEvent(e); + // Send click. + evt.target.click(); + } else if (evt.keyCode === this.Keycodes_.ESCAPE) { + evt.preventDefault(); + this.hide(); + } + } + } +}; +/** + * Handles a click event on an item. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialMenu.prototype.handleItemClick_ = function (evt) { + if (evt.target.hasAttribute('disabled')) { + evt.stopPropagation(); + } else { + // Wait some time before closing menu, so the user can see the ripple. + this.closing_ = true; + window.setTimeout(function (evt) { + this.hide(); + this.closing_ = false; + }.bind(this), this.Constant_.CLOSE_TIMEOUT); + } +}; +/** + * Calculates the initial clip (for opening the menu) or final clip (for closing + * it), and applies it. This allows us to animate from or to the correct point, + * that is, the point it's aligned to in the "for" element. + * + * @param {number} height Height of the clip rectangle + * @param {number} width Width of the clip rectangle + * @private + */ +MaterialMenu.prototype.applyClip_ = function (height, width) { + if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { + // Do not clip. + this.element_.style.clip = ''; + } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { + // Clip to the top right corner of the menu. + this.element_.style.clip = 'rect(0 ' + width + 'px ' + '0 ' + width + 'px)'; + } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { + // Clip to the bottom left corner of the menu. + this.element_.style.clip = 'rect(' + height + 'px 0 ' + height + 'px 0)'; + } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { + // Clip to the bottom right corner of the menu. + this.element_.style.clip = 'rect(' + height + 'px ' + width + 'px ' + height + 'px ' + width + 'px)'; + } else { + // Default: do not clip (same as clipping to the top left corner). + this.element_.style.clip = ''; + } +}; +/** + * Cleanup function to remove animation listeners. + * + * @param {Event} evt + * @private + */ +MaterialMenu.prototype.removeAnimationEndListener_ = function (evt) { + evt.target.classList.remove(MaterialMenu.prototype.CssClasses_.IS_ANIMATING); +}; +/** + * Adds an event listener to clean up after the animation ends. + * + * @private + */ +MaterialMenu.prototype.addAnimationEndListener_ = function () { + this.element_.addEventListener('transitionend', this.removeAnimationEndListener_); + this.element_.addEventListener('webkitTransitionEnd', this.removeAnimationEndListener_); +}; +/** + * Displays the menu. + * + * @public + */ +MaterialMenu.prototype.show = function (evt) { + if (this.element_ && this.container_ && this.outline_) { + // Measure the inner element. + var height = this.element_.getBoundingClientRect().height; + var width = this.element_.getBoundingClientRect().width; + // Apply the inner element's size to the container and outline. + this.container_.style.width = width + 'px'; + this.container_.style.height = height + 'px'; + this.outline_.style.width = width + 'px'; + this.outline_.style.height = height + 'px'; + var transitionDuration = this.Constant_.TRANSITION_DURATION_SECONDS * this.Constant_.TRANSITION_DURATION_FRACTION; + // Calculate transition delays for individual menu items, so that they fade + // in one at a time. + var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); + for (var i = 0; i < items.length; i++) { + var itemDelay = null; + if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT) || this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { + itemDelay = (height - items[i].offsetTop - items[i].offsetHeight) / height * transitionDuration + 's'; + } else { + itemDelay = items[i].offsetTop / height * transitionDuration + 's'; + } + items[i].style.transitionDelay = itemDelay; + } + // Apply the initial clip to the text before we start animating. + this.applyClip_(height, width); + // Wait for the next frame, turn on animation, and apply the final clip. + // Also make it visible. This triggers the transitions. + window.requestAnimationFrame(function () { + this.element_.classList.add(this.CssClasses_.IS_ANIMATING); + this.element_.style.clip = 'rect(0 ' + width + 'px ' + height + 'px 0)'; + this.container_.classList.add(this.CssClasses_.IS_VISIBLE); + }.bind(this)); + // Clean up after the animation is complete. + this.addAnimationEndListener_(); + // Add a click listener to the document, to close the menu. + var callback = function (e) { + // Check to see if the document is processing the same event that + // displayed the menu in the first place. If so, do nothing. + // Also check to see if the menu is in the process of closing itself, and + // do nothing in that case. + // Also check if the clicked element is a menu item + // if so, do nothing. + if (e !== evt && !this.closing_ && e.target.parentNode !== this.element_) { + document.removeEventListener('click', callback); + this.hide(); + } + }.bind(this); + document.addEventListener('click', callback); + } +}; +MaterialMenu.prototype['show'] = MaterialMenu.prototype.show; +/** + * Hides the menu. + * + * @public + */ +MaterialMenu.prototype.hide = function () { + if (this.element_ && this.container_ && this.outline_) { + var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); + // Remove all transition delays; menu items fade out concurrently. + for (var i = 0; i < items.length; i++) { + items[i].style.removeProperty('transition-delay'); + } + // Measure the inner element. + var rect = this.element_.getBoundingClientRect(); + var height = rect.height; + var width = rect.width; + // Turn on animation, and apply the final clip. Also make invisible. + // This triggers the transitions. + this.element_.classList.add(this.CssClasses_.IS_ANIMATING); + this.applyClip_(height, width); + this.container_.classList.remove(this.CssClasses_.IS_VISIBLE); + // Clean up after the animation is complete. + this.addAnimationEndListener_(); + } +}; +MaterialMenu.prototype['hide'] = MaterialMenu.prototype.hide; +/** + * Displays or hides the menu, depending on current state. + * + * @public + */ +MaterialMenu.prototype.toggle = function (evt) { + if (this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { + this.hide(); + } else { + this.show(evt); + } +}; +MaterialMenu.prototype['toggle'] = MaterialMenu.prototype.toggle; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialMenu, + classAsString: 'MaterialMenu', + cssClass: 'mdl-js-menu', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Progress MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialProgress = function MaterialProgress(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialProgress'] = MaterialProgress; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialProgress.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialProgress.prototype.CssClasses_ = { INDETERMINATE_CLASS: 'mdl-progress__indeterminate' }; +/** + * Set the current progress of the progressbar. + * + * @param {number} p Percentage of the progress (0-100) + * @public + */ +MaterialProgress.prototype.setProgress = function (p) { + if (this.element_.classList.contains(this.CssClasses_.INDETERMINATE_CLASS)) { + return; + } + this.progressbar_.style.width = p + '%'; +}; +MaterialProgress.prototype['setProgress'] = MaterialProgress.prototype.setProgress; +/** + * Set the current progress of the buffer. + * + * @param {number} p Percentage of the buffer (0-100) + * @public + */ +MaterialProgress.prototype.setBuffer = function (p) { + this.bufferbar_.style.width = p + '%'; + this.auxbar_.style.width = 100 - p + '%'; +}; +MaterialProgress.prototype['setBuffer'] = MaterialProgress.prototype.setBuffer; +/** + * Initialize element. + */ +MaterialProgress.prototype.init = function () { + if (this.element_) { + var el = document.createElement('div'); + el.className = 'progressbar bar bar1'; + this.element_.appendChild(el); + this.progressbar_ = el; + el = document.createElement('div'); + el.className = 'bufferbar bar bar2'; + this.element_.appendChild(el); + this.bufferbar_ = el; + el = document.createElement('div'); + el.className = 'auxbar bar bar3'; + this.element_.appendChild(el); + this.auxbar_ = el; + this.progressbar_.style.width = '0%'; + this.bufferbar_.style.width = '100%'; + this.auxbar_.style.width = '0%'; + this.element_.classList.add('is-upgraded'); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialProgress, + classAsString: 'MaterialProgress', + cssClass: 'mdl-js-progress', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Radio MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialRadio = function MaterialRadio(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialRadio'] = MaterialRadio; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialRadio.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialRadio.prototype.CssClasses_ = { + IS_FOCUSED: 'is-focused', + IS_DISABLED: 'is-disabled', + IS_CHECKED: 'is-checked', + IS_UPGRADED: 'is-upgraded', + JS_RADIO: 'mdl-js-radio', + RADIO_BTN: 'mdl-radio__button', + RADIO_OUTER_CIRCLE: 'mdl-radio__outer-circle', + RADIO_INNER_CIRCLE: 'mdl-radio__inner-circle', + RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + RIPPLE_CONTAINER: 'mdl-radio__ripple-container', + RIPPLE_CENTER: 'mdl-ripple--center', + RIPPLE: 'mdl-ripple' +}; +/** + * Handle change of state. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRadio.prototype.onChange_ = function (event) { + // Since other radio buttons don't get change events, we need to look for + // them to update their classes. + var radios = document.getElementsByClassName(this.CssClasses_.JS_RADIO); + for (var i = 0; i < radios.length; i++) { + var button = radios[i].querySelector('.' + this.CssClasses_.RADIO_BTN); + // Different name == different group, so no point updating those. + if (button.getAttribute('name') === this.btnElement_.getAttribute('name')) { + if (typeof radios[i]['MaterialRadio'] !== 'undefined') { + radios[i]['MaterialRadio'].updateClasses_(); + } + } + } +}; +/** + * Handle focus. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRadio.prototype.onFocus_ = function (event) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle lost focus. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRadio.prototype.onBlur_ = function (event) { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle mouseup. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRadio.prototype.onMouseup_ = function (event) { + this.blur_(); +}; +/** + * Update classes. + * + * @private + */ +MaterialRadio.prototype.updateClasses_ = function () { + this.checkDisabled(); + this.checkToggleState(); +}; +/** + * Add blur. + * + * @private + */ +MaterialRadio.prototype.blur_ = function () { + // TODO: figure out why there's a focus event being fired after our blur, + // so that we can avoid this hack. + window.setTimeout(function () { + this.btnElement_.blur(); + }.bind(this), this.Constant_.TINY_TIMEOUT); +}; +// Public methods. +/** + * Check the components disabled state. + * + * @public + */ +MaterialRadio.prototype.checkDisabled = function () { + if (this.btnElement_.disabled) { + this.element_.classList.add(this.CssClasses_.IS_DISABLED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DISABLED); + } +}; +MaterialRadio.prototype['checkDisabled'] = MaterialRadio.prototype.checkDisabled; +/** + * Check the components toggled state. + * + * @public + */ +MaterialRadio.prototype.checkToggleState = function () { + if (this.btnElement_.checked) { + this.element_.classList.add(this.CssClasses_.IS_CHECKED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_CHECKED); + } +}; +MaterialRadio.prototype['checkToggleState'] = MaterialRadio.prototype.checkToggleState; +/** + * Disable radio. + * + * @public + */ +MaterialRadio.prototype.disable = function () { + this.btnElement_.disabled = true; + this.updateClasses_(); +}; +MaterialRadio.prototype['disable'] = MaterialRadio.prototype.disable; +/** + * Enable radio. + * + * @public + */ +MaterialRadio.prototype.enable = function () { + this.btnElement_.disabled = false; + this.updateClasses_(); +}; +MaterialRadio.prototype['enable'] = MaterialRadio.prototype.enable; +/** + * Check radio. + * + * @public + */ +MaterialRadio.prototype.check = function () { + this.btnElement_.checked = true; + this.onChange_(null); +}; +MaterialRadio.prototype['check'] = MaterialRadio.prototype.check; +/** + * Uncheck radio. + * + * @public + */ +MaterialRadio.prototype.uncheck = function () { + this.btnElement_.checked = false; + this.onChange_(null); +}; +MaterialRadio.prototype['uncheck'] = MaterialRadio.prototype.uncheck; +/** + * Initialize element. + */ +MaterialRadio.prototype.init = function () { + if (this.element_) { + this.btnElement_ = this.element_.querySelector('.' + this.CssClasses_.RADIO_BTN); + this.boundChangeHandler_ = this.onChange_.bind(this); + this.boundFocusHandler_ = this.onChange_.bind(this); + this.boundBlurHandler_ = this.onBlur_.bind(this); + this.boundMouseUpHandler_ = this.onMouseup_.bind(this); + var outerCircle = document.createElement('span'); + outerCircle.classList.add(this.CssClasses_.RADIO_OUTER_CIRCLE); + var innerCircle = document.createElement('span'); + innerCircle.classList.add(this.CssClasses_.RADIO_INNER_CIRCLE); + this.element_.appendChild(outerCircle); + this.element_.appendChild(innerCircle); + var rippleContainer; + if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + rippleContainer = document.createElement('span'); + rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER); + rippleContainer.classList.add(this.CssClasses_.RIPPLE_EFFECT); + rippleContainer.classList.add(this.CssClasses_.RIPPLE_CENTER); + rippleContainer.addEventListener('mouseup', this.boundMouseUpHandler_); + var ripple = document.createElement('span'); + ripple.classList.add(this.CssClasses_.RIPPLE); + rippleContainer.appendChild(ripple); + this.element_.appendChild(rippleContainer); + } + this.btnElement_.addEventListener('change', this.boundChangeHandler_); + this.btnElement_.addEventListener('focus', this.boundFocusHandler_); + this.btnElement_.addEventListener('blur', this.boundBlurHandler_); + this.element_.addEventListener('mouseup', this.boundMouseUpHandler_); + this.updateClasses_(); + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialRadio, + classAsString: 'MaterialRadio', + cssClass: 'mdl-js-radio', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Slider MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialSlider = function MaterialSlider(element) { + this.element_ = element; + // Browser feature detection. + this.isIE_ = window.navigator.msPointerEnabled; + // Initialize instance. + this.init(); +}; +window['MaterialSlider'] = MaterialSlider; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialSlider.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialSlider.prototype.CssClasses_ = { + IE_CONTAINER: 'mdl-slider__ie-container', + SLIDER_CONTAINER: 'mdl-slider__container', + BACKGROUND_FLEX: 'mdl-slider__background-flex', + BACKGROUND_LOWER: 'mdl-slider__background-lower', + BACKGROUND_UPPER: 'mdl-slider__background-upper', + IS_LOWEST_VALUE: 'is-lowest-value', + IS_UPGRADED: 'is-upgraded' +}; +/** + * Handle input on element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSlider.prototype.onInput_ = function (event) { + this.updateValueStyles_(); +}; +/** + * Handle change on element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSlider.prototype.onChange_ = function (event) { + this.updateValueStyles_(); +}; +/** + * Handle mouseup on element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSlider.prototype.onMouseUp_ = function (event) { + event.target.blur(); +}; +/** + * Handle mousedown on container element. + * This handler is purpose is to not require the use to click + * exactly on the 2px slider element, as FireFox seems to be very + * strict about this. + * + * @param {Event} event The event that fired. + * @private + * @suppress {missingProperties} + */ +MaterialSlider.prototype.onContainerMouseDown_ = function (event) { + // If this click is not on the parent element (but rather some child) + // ignore. It may still bubble up. + if (event.target !== this.element_.parentElement) { + return; + } + // Discard the original event and create a new event that + // is on the slider element. + event.preventDefault(); + var newEvent = new MouseEvent('mousedown', { + target: event.target, + buttons: event.buttons, + clientX: event.clientX, + clientY: this.element_.getBoundingClientRect().y + }); + this.element_.dispatchEvent(newEvent); +}; +/** + * Handle updating of values. + * + * @private + */ +MaterialSlider.prototype.updateValueStyles_ = function () { + // Calculate and apply percentages to div structure behind slider. + var fraction = (this.element_.value - this.element_.min) / (this.element_.max - this.element_.min); + if (fraction === 0) { + this.element_.classList.add(this.CssClasses_.IS_LOWEST_VALUE); + } else { + this.element_.classList.remove(this.CssClasses_.IS_LOWEST_VALUE); + } + if (!this.isIE_) { + this.backgroundLower_.style.flex = fraction; + this.backgroundLower_.style.webkitFlex = fraction; + this.backgroundUpper_.style.flex = 1 - fraction; + this.backgroundUpper_.style.webkitFlex = 1 - fraction; + } +}; +// Public methods. +/** + * Disable slider. + * + * @public + */ +MaterialSlider.prototype.disable = function () { + this.element_.disabled = true; +}; +MaterialSlider.prototype['disable'] = MaterialSlider.prototype.disable; +/** + * Enable slider. + * + * @public + */ +MaterialSlider.prototype.enable = function () { + this.element_.disabled = false; +}; +MaterialSlider.prototype['enable'] = MaterialSlider.prototype.enable; +/** + * Update slider value. + * + * @param {number} value The value to which to set the control (optional). + * @public + */ +MaterialSlider.prototype.change = function (value) { + if (typeof value !== 'undefined') { + this.element_.value = value; + } + this.updateValueStyles_(); +}; +MaterialSlider.prototype['change'] = MaterialSlider.prototype.change; +/** + * Initialize element. + */ +MaterialSlider.prototype.init = function () { + if (this.element_) { + if (this.isIE_) { + // Since we need to specify a very large height in IE due to + // implementation limitations, we add a parent here that trims it down to + // a reasonable size. + var containerIE = document.createElement('div'); + containerIE.classList.add(this.CssClasses_.IE_CONTAINER); + this.element_.parentElement.insertBefore(containerIE, this.element_); + this.element_.parentElement.removeChild(this.element_); + containerIE.appendChild(this.element_); + } else { + // For non-IE browsers, we need a div structure that sits behind the + // slider and allows us to style the left and right sides of it with + // different colors. + var container = document.createElement('div'); + container.classList.add(this.CssClasses_.SLIDER_CONTAINER); + this.element_.parentElement.insertBefore(container, this.element_); + this.element_.parentElement.removeChild(this.element_); + container.appendChild(this.element_); + var backgroundFlex = document.createElement('div'); + backgroundFlex.classList.add(this.CssClasses_.BACKGROUND_FLEX); + container.appendChild(backgroundFlex); + this.backgroundLower_ = document.createElement('div'); + this.backgroundLower_.classList.add(this.CssClasses_.BACKGROUND_LOWER); + backgroundFlex.appendChild(this.backgroundLower_); + this.backgroundUpper_ = document.createElement('div'); + this.backgroundUpper_.classList.add(this.CssClasses_.BACKGROUND_UPPER); + backgroundFlex.appendChild(this.backgroundUpper_); + } + this.boundInputHandler = this.onInput_.bind(this); + this.boundChangeHandler = this.onChange_.bind(this); + this.boundMouseUpHandler = this.onMouseUp_.bind(this); + this.boundContainerMouseDownHandler = this.onContainerMouseDown_.bind(this); + this.element_.addEventListener('input', this.boundInputHandler); + this.element_.addEventListener('change', this.boundChangeHandler); + this.element_.addEventListener('mouseup', this.boundMouseUpHandler); + this.element_.parentElement.addEventListener('mousedown', this.boundContainerMouseDownHandler); + this.updateValueStyles_(); + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialSlider, + classAsString: 'MaterialSlider', + cssClass: 'mdl-js-slider', + widget: true +}); +/** + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Snackbar MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialSnackbar = function MaterialSnackbar(element) { + this.element_ = element; + this.textElement_ = this.element_.querySelector('.' + this.cssClasses_.MESSAGE); + this.actionElement_ = this.element_.querySelector('.' + this.cssClasses_.ACTION); + if (!this.textElement_) { + throw new Error('There must be a message element for a snackbar.'); + } + if (!this.actionElement_) { + throw new Error('There must be an action element for a snackbar.'); + } + this.active = false; + this.actionHandler_ = undefined; + this.message_ = undefined; + this.actionText_ = undefined; + this.queuedNotifications_ = []; + this.setActionHidden_(true); +}; +window['MaterialSnackbar'] = MaterialSnackbar; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialSnackbar.prototype.Constant_ = { + // The duration of the snackbar show/hide animation, in ms. + ANIMATION_LENGTH: 250 +}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialSnackbar.prototype.cssClasses_ = { + SNACKBAR: 'mdl-snackbar', + MESSAGE: 'mdl-snackbar__text', + ACTION: 'mdl-snackbar__action', + ACTIVE: 'mdl-snackbar--active' +}; +/** + * Display the snackbar. + * + * @private + */ +MaterialSnackbar.prototype.displaySnackbar_ = function () { + this.element_.setAttribute('aria-hidden', 'true'); + if (this.actionHandler_) { + this.actionElement_.textContent = this.actionText_; + this.actionElement_.addEventListener('click', this.actionHandler_); + this.setActionHidden_(false); + } + 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_); +}; +/** + * Show the snackbar. + * + * @param {Object} data The data for the notification. + * @public + */ +MaterialSnackbar.prototype.showSnackbar = function (data) { + if (data === undefined) { + throw new Error('Please provide a data object with at least a message to display.'); + } + if (data['message'] === undefined) { + throw new Error('Please provide a message to be displayed.'); + } + if (data['actionHandler'] && !data['actionText']) { + throw new Error('Please provide action text with the handler.'); + } + if (this.active) { + this.queuedNotifications_.push(data); + } else { + this.active = true; + this.message_ = data['message']; + if (data['timeout']) { + this.timeout_ = data['timeout']; + } else { + this.timeout_ = 2750; + } + if (data['actionHandler']) { + this.actionHandler_ = data['actionHandler']; + } + if (data['actionText']) { + this.actionText_ = data['actionText']; + } + this.displaySnackbar_(); + } +}; +MaterialSnackbar.prototype['showSnackbar'] = MaterialSnackbar.prototype.showSnackbar; +/** + * Check if the queue has items within it. + * If it does, display the next entry. + * + * @private + */ +MaterialSnackbar.prototype.checkQueue_ = function () { + if (this.queuedNotifications_.length > 0) { + this.showSnackbar(this.queuedNotifications_.shift()); + } +}; +/** + * Cleanup the snackbar event listeners and accessiblity attributes. + * + * @private + */ +MaterialSnackbar.prototype.cleanup_ = function () { + this.element_.classList.remove(this.cssClasses_.ACTIVE); + setTimeout(function () { + this.element_.setAttribute('aria-hidden', 'true'); + this.textElement_.textContent = ''; + if (!Boolean(this.actionElement_.getAttribute('aria-hidden'))) { + this.setActionHidden_(true); + this.actionElement_.textContent = ''; + this.actionElement_.removeEventListener('click', this.actionHandler_); + } + this.actionHandler_ = undefined; + this.message_ = undefined; + this.actionText_ = undefined; + this.active = false; + this.checkQueue_(); + }.bind(this), this.Constant_.ANIMATION_LENGTH); +}; +/** + * Set the action handler hidden state. + * + * @param {boolean} value + * @private + */ +MaterialSnackbar.prototype.setActionHidden_ = function (value) { + if (value) { + this.actionElement_.setAttribute('aria-hidden', 'true'); + } else { + this.actionElement_.removeAttribute('aria-hidden'); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialSnackbar, + classAsString: 'MaterialSnackbar', + cssClass: 'mdl-js-snackbar', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Spinner MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @param {HTMLElement} element The element that will be upgraded. + * @constructor + */ +var MaterialSpinner = function MaterialSpinner(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialSpinner'] = MaterialSpinner; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialSpinner.prototype.Constant_ = { MDL_SPINNER_LAYER_COUNT: 4 }; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialSpinner.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' +}; +/** + * Auxiliary method to create a spinner layer. + * + * @param {number} index Index of the layer to be created. + * @public + */ +MaterialSpinner.prototype.createLayer = function (index) { + var layer = document.createElement('div'); + layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER); + layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER + '-' + index); + var leftClipper = document.createElement('div'); + leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER); + leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_LEFT); + var gapPatch = document.createElement('div'); + gapPatch.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH); + var rightClipper = document.createElement('div'); + rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER); + rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT); + var circleOwners = [ + leftClipper, + gapPatch, + rightClipper + ]; + for (var i = 0; i < circleOwners.length; i++) { + var circle = document.createElement('div'); + circle.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE); + circleOwners[i].appendChild(circle); + } + layer.appendChild(leftClipper); + layer.appendChild(gapPatch); + layer.appendChild(rightClipper); + this.element_.appendChild(layer); +}; +MaterialSpinner.prototype['createLayer'] = MaterialSpinner.prototype.createLayer; +/** + * Stops the spinner animation. + * Public method for users who need to stop the spinner for any reason. + * + * @public + */ +MaterialSpinner.prototype.stop = function () { + this.element_.classList.remove('is-active'); +}; +MaterialSpinner.prototype['stop'] = MaterialSpinner.prototype.stop; +/** + * Starts the spinner animation. + * Public method for users who need to manually start the spinner for any reason + * (instead of just adding the 'is-active' class to their markup). + * + * @public + */ +MaterialSpinner.prototype.start = function () { + this.element_.classList.add('is-active'); +}; +MaterialSpinner.prototype['start'] = MaterialSpinner.prototype.start; +/** + * Initialize element. + */ +MaterialSpinner.prototype.init = function () { + if (this.element_) { + for (var i = 1; i <= this.Constant_.MDL_SPINNER_LAYER_COUNT; i++) { + this.createLayer(i); + } + this.element_.classList.add('is-upgraded'); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialSpinner, + classAsString: 'MaterialSpinner', + cssClass: 'mdl-js-spinner', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Checkbox MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialSwitch = function MaterialSwitch(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialSwitch'] = MaterialSwitch; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialSwitch.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialSwitch.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' +}; +/** + * Handle change of state. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSwitch.prototype.onChange_ = function (event) { + this.updateClasses_(); +}; +/** + * Handle focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSwitch.prototype.onFocus_ = function (event) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle lost focus of element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSwitch.prototype.onBlur_ = function (event) { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle mouseup. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialSwitch.prototype.onMouseUp_ = function (event) { + this.blur_(); +}; +/** + * Handle class updates. + * + * @private + */ +MaterialSwitch.prototype.updateClasses_ = function () { + this.checkDisabled(); + this.checkToggleState(); +}; +/** + * Add blur. + * + * @private + */ +MaterialSwitch.prototype.blur_ = function () { + // TODO: figure out why there's a focus event being fired after our blur, + // so that we can avoid this hack. + window.setTimeout(function () { + this.inputElement_.blur(); + }.bind(this), this.Constant_.TINY_TIMEOUT); +}; +// Public methods. +/** + * Check the components disabled state. + * + * @public + */ +MaterialSwitch.prototype.checkDisabled = function () { + if (this.inputElement_.disabled) { + this.element_.classList.add(this.CssClasses_.IS_DISABLED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DISABLED); + } +}; +MaterialSwitch.prototype['checkDisabled'] = MaterialSwitch.prototype.checkDisabled; +/** + * Check the components toggled state. + * + * @public + */ +MaterialSwitch.prototype.checkToggleState = function () { + if (this.inputElement_.checked) { + this.element_.classList.add(this.CssClasses_.IS_CHECKED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_CHECKED); + } +}; +MaterialSwitch.prototype['checkToggleState'] = MaterialSwitch.prototype.checkToggleState; +/** + * Disable switch. + * + * @public + */ +MaterialSwitch.prototype.disable = function () { + this.inputElement_.disabled = true; + this.updateClasses_(); +}; +MaterialSwitch.prototype['disable'] = MaterialSwitch.prototype.disable; +/** + * Enable switch. + * + * @public + */ +MaterialSwitch.prototype.enable = function () { + this.inputElement_.disabled = false; + this.updateClasses_(); +}; +MaterialSwitch.prototype['enable'] = MaterialSwitch.prototype.enable; +/** + * Activate switch. + * + * @public + */ +MaterialSwitch.prototype.on = function () { + this.inputElement_.checked = true; + this.updateClasses_(); +}; +MaterialSwitch.prototype['on'] = MaterialSwitch.prototype.on; +/** + * Deactivate switch. + * + * @public + */ +MaterialSwitch.prototype.off = function () { + this.inputElement_.checked = false; + this.updateClasses_(); +}; +MaterialSwitch.prototype['off'] = MaterialSwitch.prototype.off; +/** + * Initialize element. + */ +MaterialSwitch.prototype.init = function () { + if (this.element_) { + this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); + var track = document.createElement('div'); + track.classList.add(this.CssClasses_.TRACK); + var thumb = document.createElement('div'); + thumb.classList.add(this.CssClasses_.THUMB); + var focusHelper = document.createElement('span'); + focusHelper.classList.add(this.CssClasses_.FOCUS_HELPER); + thumb.appendChild(focusHelper); + this.element_.appendChild(track); + this.element_.appendChild(thumb); + this.boundMouseUpHandler = this.onMouseUp_.bind(this); + if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + this.rippleContainerElement_ = document.createElement('span'); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT); + this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); + this.rippleContainerElement_.addEventListener('mouseup', this.boundMouseUpHandler); + var ripple = document.createElement('span'); + ripple.classList.add(this.CssClasses_.RIPPLE); + this.rippleContainerElement_.appendChild(ripple); + this.element_.appendChild(this.rippleContainerElement_); + } + this.boundChangeHandler = this.onChange_.bind(this); + this.boundFocusHandler = this.onFocus_.bind(this); + this.boundBlurHandler = this.onBlur_.bind(this); + this.inputElement_.addEventListener('change', this.boundChangeHandler); + this.inputElement_.addEventListener('focus', this.boundFocusHandler); + this.inputElement_.addEventListener('blur', this.boundBlurHandler); + this.element_.addEventListener('mouseup', this.boundMouseUpHandler); + this.updateClasses_(); + this.element_.classList.add('is-upgraded'); + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialSwitch, + classAsString: 'MaterialSwitch', + cssClass: 'mdl-js-switch', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Tabs MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {Element} element The element that will be upgraded. + */ +var MaterialTabs = function MaterialTabs(element) { + // Stores the HTML element. + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialTabs'] = MaterialTabs; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string} + * @private + */ +MaterialTabs.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialTabs.prototype.CssClasses_ = { + TAB_CLASS: 'mdl-tabs__tab', + PANEL_CLASS: 'mdl-tabs__panel', + ACTIVE_CLASS: 'is-active', + UPGRADED_CLASS: 'is-upgraded', + MDL_JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', + MDL_RIPPLE_CONTAINER: 'mdl-tabs__ripple-container', + MDL_RIPPLE: 'mdl-ripple', + MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events' +}; +/** + * Handle clicks to a tabs component + * + * @private + */ +MaterialTabs.prototype.initTabs_ = function () { + if (this.element_.classList.contains(this.CssClasses_.MDL_JS_RIPPLE_EFFECT)) { + this.element_.classList.add(this.CssClasses_.MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS); + } + // Select element tabs, document panels + this.tabs_ = this.element_.querySelectorAll('.' + this.CssClasses_.TAB_CLASS); + this.panels_ = this.element_.querySelectorAll('.' + this.CssClasses_.PANEL_CLASS); + // Create new tabs for each tab element + for (var i = 0; i < this.tabs_.length; i++) { + new MaterialTab(this.tabs_[i], this); + } + this.element_.classList.add(this.CssClasses_.UPGRADED_CLASS); +}; +/** + * Reset tab state, dropping active classes + * + * @private + */ +MaterialTabs.prototype.resetTabState_ = function () { + for (var k = 0; k < this.tabs_.length; k++) { + this.tabs_[k].classList.remove(this.CssClasses_.ACTIVE_CLASS); + } +}; +/** + * Reset panel state, droping active classes + * + * @private + */ +MaterialTabs.prototype.resetPanelState_ = function () { + for (var j = 0; j < this.panels_.length; j++) { + this.panels_[j].classList.remove(this.CssClasses_.ACTIVE_CLASS); + } +}; +/** + * Initialize element. + */ +MaterialTabs.prototype.init = function () { + if (this.element_) { + this.initTabs_(); + } +}; +/** + * Constructor for an individual tab. + * + * @constructor + * @param {Element} tab The HTML element for the tab. + * @param {MaterialTabs} ctx The MaterialTabs object that owns the tab. + */ +function MaterialTab(tab, ctx) { + if (tab) { + if (ctx.element_.classList.contains(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT)) { + var rippleContainer = document.createElement('span'); + rippleContainer.classList.add(ctx.CssClasses_.MDL_RIPPLE_CONTAINER); + rippleContainer.classList.add(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT); + var ripple = document.createElement('span'); + ripple.classList.add(ctx.CssClasses_.MDL_RIPPLE); + rippleContainer.appendChild(ripple); + tab.appendChild(rippleContainer); + } + tab.addEventListener('click', function (e) { + if (tab.getAttribute('href').charAt(0) === '#') { + e.preventDefault(); + var href = tab.href.split('#')[1]; + var panel = ctx.element_.querySelector('#' + href); + ctx.resetTabState_(); + ctx.resetPanelState_(); + tab.classList.add(ctx.CssClasses_.ACTIVE_CLASS); + panel.classList.add(ctx.CssClasses_.ACTIVE_CLASS); + } + }); + } +} +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialTabs, + classAsString: 'MaterialTabs', + cssClass: 'mdl-js-tabs' +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Textfield MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialTextfield = function MaterialTextfield(element) { + this.element_ = element; + this.maxRows = this.Constant_.NO_MAX_ROWS; + // Initialize instance. + this.init(); +}; +window['MaterialTextfield'] = MaterialTextfield; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialTextfield.prototype.Constant_ = { + NO_MAX_ROWS: -1, + MAX_ROWS_ATTRIBUTE: 'maxrows' +}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialTextfield.prototype.CssClasses_ = { + LABEL: 'mdl-textfield__label', + INPUT: 'mdl-textfield__input', + IS_DIRTY: 'is-dirty', + IS_FOCUSED: 'is-focused', + IS_DISABLED: 'is-disabled', + IS_INVALID: 'is-invalid', + IS_UPGRADED: 'is-upgraded', + HAS_PLACEHOLDER: 'has-placeholder' +}; +/** + * Handle input being entered. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialTextfield.prototype.onKeyDown_ = function (event) { + var currentRowCount = event.target.value.split('\n').length; + if (event.keyCode === 13) { + if (currentRowCount >= this.maxRows) { + event.preventDefault(); + } + } +}; +/** + * Handle focus. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialTextfield.prototype.onFocus_ = function (event) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle lost focus. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialTextfield.prototype.onBlur_ = function (event) { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); +}; +/** + * Handle reset event from out side. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialTextfield.prototype.onReset_ = function (event) { + this.updateClasses_(); +}; +/** + * Handle class updates. + * + * @private + */ +MaterialTextfield.prototype.updateClasses_ = function () { + this.checkDisabled(); + this.checkValidity(); + this.checkDirty(); + this.checkFocus(); +}; +// Public methods. +/** + * Check the disabled state and update field accordingly. + * + * @public + */ +MaterialTextfield.prototype.checkDisabled = function () { + if (this.input_.disabled) { + this.element_.classList.add(this.CssClasses_.IS_DISABLED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DISABLED); + } +}; +MaterialTextfield.prototype['checkDisabled'] = MaterialTextfield.prototype.checkDisabled; +/** + * Check the focus state and update field accordingly. + * + * @public + */ +MaterialTextfield.prototype.checkFocus = function () { + if (Boolean(this.element_.querySelector(':focus'))) { + this.element_.classList.add(this.CssClasses_.IS_FOCUSED); + } else { + this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); + } +}; +MaterialTextfield.prototype['checkFocus'] = MaterialTextfield.prototype.checkFocus; +/** + * Check the validity state and update field accordingly. + * + * @public + */ +MaterialTextfield.prototype.checkValidity = function () { + if (this.input_.validity) { + if (this.input_.validity.valid) { + this.element_.classList.remove(this.CssClasses_.IS_INVALID); + } else { + this.element_.classList.add(this.CssClasses_.IS_INVALID); + } + } +}; +MaterialTextfield.prototype['checkValidity'] = MaterialTextfield.prototype.checkValidity; +/** + * Check the dirty state and update field accordingly. + * + * @public + */ +MaterialTextfield.prototype.checkDirty = function () { + if (this.input_.value && this.input_.value.length > 0) { + this.element_.classList.add(this.CssClasses_.IS_DIRTY); + } else { + this.element_.classList.remove(this.CssClasses_.IS_DIRTY); + } +}; +MaterialTextfield.prototype['checkDirty'] = MaterialTextfield.prototype.checkDirty; +/** + * Disable text field. + * + * @public + */ +MaterialTextfield.prototype.disable = function () { + this.input_.disabled = true; + this.updateClasses_(); +}; +MaterialTextfield.prototype['disable'] = MaterialTextfield.prototype.disable; +/** + * Enable text field. + * + * @public + */ +MaterialTextfield.prototype.enable = function () { + this.input_.disabled = false; + this.updateClasses_(); +}; +MaterialTextfield.prototype['enable'] = MaterialTextfield.prototype.enable; +/** + * Update text field value. + * + * @param {string} value The value to which to set the control (optional). + * @public + */ +MaterialTextfield.prototype.change = function (value) { + this.input_.value = value || ''; + this.updateClasses_(); +}; +MaterialTextfield.prototype['change'] = MaterialTextfield.prototype.change; +/** + * Initialize element. + */ +MaterialTextfield.prototype.init = function () { + if (this.element_) { + this.label_ = this.element_.querySelector('.' + this.CssClasses_.LABEL); + this.input_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); + if (this.input_) { + if (this.input_.hasAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE)) { + this.maxRows = parseInt(this.input_.getAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE), 10); + if (isNaN(this.maxRows)) { + this.maxRows = this.Constant_.NO_MAX_ROWS; + } + } + if (this.input_.hasAttribute('placeholder')) { + this.element_.classList.add(this.CssClasses_.HAS_PLACEHOLDER); + } + this.boundUpdateClassesHandler = this.updateClasses_.bind(this); + this.boundFocusHandler = this.onFocus_.bind(this); + this.boundBlurHandler = this.onBlur_.bind(this); + this.boundResetHandler = this.onReset_.bind(this); + this.input_.addEventListener('input', this.boundUpdateClassesHandler); + this.input_.addEventListener('focus', this.boundFocusHandler); + this.input_.addEventListener('blur', this.boundBlurHandler); + this.input_.addEventListener('reset', this.boundResetHandler); + if (this.maxRows !== this.Constant_.NO_MAX_ROWS) { + // TODO: This should handle pasting multi line text. + // Currently doesn't. + this.boundKeyDownHandler = this.onKeyDown_.bind(this); + this.input_.addEventListener('keydown', this.boundKeyDownHandler); + } + var invalid = this.element_.classList.contains(this.CssClasses_.IS_INVALID); + this.updateClasses_(); + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + if (invalid) { + this.element_.classList.add(this.CssClasses_.IS_INVALID); + } + if (this.input_.hasAttribute('autofocus')) { + this.element_.focus(); + this.checkFocus(); + } + } + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialTextfield, + classAsString: 'MaterialTextfield', + cssClass: 'mdl-js-textfield', + widget: true +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Tooltip MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialTooltip = function MaterialTooltip(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialTooltip'] = MaterialTooltip; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialTooltip.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialTooltip.prototype.CssClasses_ = { + IS_ACTIVE: 'is-active', + BOTTOM: 'mdl-tooltip--bottom', + LEFT: 'mdl-tooltip--left', + RIGHT: 'mdl-tooltip--right', + TOP: 'mdl-tooltip--top' +}; +/** + * Handle mouseenter for tooltip. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialTooltip.prototype.handleMouseEnter_ = function (event) { + var props = event.target.getBoundingClientRect(); + var left = props.left + props.width / 2; + var top = props.top + props.height / 2; + var marginLeft = -1 * (this.element_.offsetWidth / 2); + var marginTop = -1 * (this.element_.offsetHeight / 2); + if (this.element_.classList.contains(this.CssClasses_.LEFT) || this.element_.classList.contains(this.CssClasses_.RIGHT)) { + left = props.width / 2; + if (top + marginTop < 0) { + this.element_.style.top = '0'; + this.element_.style.marginTop = '0'; + } else { + this.element_.style.top = top + 'px'; + this.element_.style.marginTop = marginTop + 'px'; + } + } else { + if (left + marginLeft < 0) { + this.element_.style.left = '0'; + this.element_.style.marginLeft = '0'; + } else { + this.element_.style.left = left + 'px'; + this.element_.style.marginLeft = marginLeft + 'px'; + } + } + if (this.element_.classList.contains(this.CssClasses_.TOP)) { + this.element_.style.top = props.top - this.element_.offsetHeight - 10 + 'px'; + } else if (this.element_.classList.contains(this.CssClasses_.RIGHT)) { + this.element_.style.left = props.left + props.width + 10 + 'px'; + } else if (this.element_.classList.contains(this.CssClasses_.LEFT)) { + this.element_.style.left = props.left - this.element_.offsetWidth - 10 + 'px'; + } else { + this.element_.style.top = props.top + props.height + 10 + 'px'; + } + this.element_.classList.add(this.CssClasses_.IS_ACTIVE); +}; +/** + * Hide tooltip on mouseleave or scroll + * + * @private + */ +MaterialTooltip.prototype.hideTooltip_ = function () { + this.element_.classList.remove(this.CssClasses_.IS_ACTIVE); +}; +/** + * Initialize element. + */ +MaterialTooltip.prototype.init = function () { + if (this.element_) { + var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for'); + if (forElId) { + this.forElement_ = document.getElementById(forElId); + } + if (this.forElement_) { + // It's left here because it prevents accidental text selection on Android + if (!this.forElement_.hasAttribute('tabindex')) { + this.forElement_.setAttribute('tabindex', '0'); + } + this.boundMouseEnterHandler = this.handleMouseEnter_.bind(this); + this.boundMouseLeaveAndScrollHandler = this.hideTooltip_.bind(this); + this.forElement_.addEventListener('mouseenter', this.boundMouseEnterHandler, false); + this.forElement_.addEventListener('touchend', this.boundMouseEnterHandler, false); + this.forElement_.addEventListener('mouseleave', this.boundMouseLeaveAndScrollHandler, false); + window.addEventListener('scroll', this.boundMouseLeaveAndScrollHandler, true); + window.addEventListener('touchstart', this.boundMouseLeaveAndScrollHandler); + } + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialTooltip, + classAsString: 'MaterialTooltip', + cssClass: 'mdl-tooltip' +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Layout MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialLayout = function MaterialLayout(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialLayout'] = MaterialLayout; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialLayout.prototype.Constant_ = { + MAX_WIDTH: '(max-width: 1024px)', + TAB_SCROLL_PIXELS: 100, + RESIZE_TIMEOUT: 100, + MENU_ICON: '', + CHEVRON_LEFT: 'chevron_left', + CHEVRON_RIGHT: 'chevron_right' +}; +/** + * Keycodes, for code readability. + * + * @enum {number} + * @private + */ +MaterialLayout.prototype.Keycodes_ = { + ENTER: 13, + ESCAPE: 27, + SPACE: 32 +}; +/** + * Modes. + * + * @enum {number} + * @private + */ +MaterialLayout.prototype.Mode_ = { + STANDARD: 0, + SEAMED: 1, + WATERFALL: 2, + SCROLL: 3 +}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialLayout.prototype.CssClasses_ = { + CONTAINER: 'mdl-layout__container', + HEADER: 'mdl-layout__header', + DRAWER: 'mdl-layout__drawer', + CONTENT: 'mdl-layout__content', + DRAWER_BTN: 'mdl-layout__drawer-button', + ICON: 'material-icons', + JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', + RIPPLE_CONTAINER: 'mdl-layout__tab-ripple-container', + RIPPLE: 'mdl-ripple', + RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + HEADER_SEAMED: 'mdl-layout__header--seamed', + HEADER_WATERFALL: 'mdl-layout__header--waterfall', + HEADER_SCROLL: 'mdl-layout__header--scroll', + FIXED_HEADER: 'mdl-layout--fixed-header', + OBFUSCATOR: 'mdl-layout__obfuscator', + TAB_BAR: 'mdl-layout__tab-bar', + TAB_CONTAINER: 'mdl-layout__tab-bar-container', + TAB: 'mdl-layout__tab', + TAB_BAR_BUTTON: 'mdl-layout__tab-bar-button', + TAB_BAR_LEFT_BUTTON: 'mdl-layout__tab-bar-left-button', + TAB_BAR_RIGHT_BUTTON: 'mdl-layout__tab-bar-right-button', + TAB_MANUAL_SWITCH: 'mdl-layout__tab-manual-switch', + PANEL: 'mdl-layout__tab-panel', + HAS_DRAWER: 'has-drawer', + HAS_TABS: 'has-tabs', + HAS_SCROLLING_HEADER: 'has-scrolling-header', + CASTING_SHADOW: 'is-casting-shadow', + IS_COMPACT: 'is-compact', + IS_SMALL_SCREEN: 'is-small-screen', + IS_DRAWER_OPEN: 'is-visible', + IS_ACTIVE: 'is-active', + IS_UPGRADED: 'is-upgraded', + IS_ANIMATING: 'is-animating', + ON_LARGE_SCREEN: 'mdl-layout--large-screen-only', + ON_SMALL_SCREEN: 'mdl-layout--small-screen-only' +}; +/** + * Handles scrolling on the content. + * + * @private + */ +MaterialLayout.prototype.contentScrollHandler_ = function () { + if (this.header_.classList.contains(this.CssClasses_.IS_ANIMATING)) { + return; + } + var headerVisible = !this.element_.classList.contains(this.CssClasses_.IS_SMALL_SCREEN) || this.element_.classList.contains(this.CssClasses_.FIXED_HEADER); + if (this.content_.scrollTop > 0 && !this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { + this.header_.classList.add(this.CssClasses_.CASTING_SHADOW); + this.header_.classList.add(this.CssClasses_.IS_COMPACT); + if (headerVisible) { + this.header_.classList.add(this.CssClasses_.IS_ANIMATING); + } + } else if (this.content_.scrollTop <= 0 && this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { + this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW); + this.header_.classList.remove(this.CssClasses_.IS_COMPACT); + if (headerVisible) { + this.header_.classList.add(this.CssClasses_.IS_ANIMATING); + } + } +}; +/** + * Handles a keyboard event on the drawer. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialLayout.prototype.keyboardEventHandler_ = function (evt) { + // Only react when the drawer is open. + if (evt.keyCode === this.Keycodes_.ESCAPE && this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) { + this.toggleDrawer(); + } +}; +/** + * Handles changes in screen size. + * + * @private + */ +MaterialLayout.prototype.screenSizeHandler_ = function () { + if (this.screenSizeMediaQuery_.matches) { + this.element_.classList.add(this.CssClasses_.IS_SMALL_SCREEN); + } else { + this.element_.classList.remove(this.CssClasses_.IS_SMALL_SCREEN); + // Collapse drawer (if any) when moving to a large screen size. + if (this.drawer_) { + this.drawer_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN); + this.obfuscator_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN); + } + } +}; +/** + * Handles events of drawer button. + * + * @param {Event} evt The event that fired. + * @private + */ +MaterialLayout.prototype.drawerToggleHandler_ = function (evt) { + if (evt && evt.type === 'keydown') { + if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) { + // prevent scrolling in drawer nav + evt.preventDefault(); + } else { + // prevent other keys + return; + } + } + this.toggleDrawer(); +}; +/** + * Handles (un)setting the `is-animating` class + * + * @private + */ +MaterialLayout.prototype.headerTransitionEndHandler_ = function () { + this.header_.classList.remove(this.CssClasses_.IS_ANIMATING); +}; +/** + * Handles expanding the header on click + * + * @private + */ +MaterialLayout.prototype.headerClickHandler_ = function () { + if (this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { + this.header_.classList.remove(this.CssClasses_.IS_COMPACT); + this.header_.classList.add(this.CssClasses_.IS_ANIMATING); + } +}; +/** + * Reset tab state, dropping active classes + * + * @private + */ +MaterialLayout.prototype.resetTabState_ = function (tabBar) { + for (var k = 0; k < tabBar.length; k++) { + tabBar[k].classList.remove(this.CssClasses_.IS_ACTIVE); + } +}; +/** + * Reset panel state, droping active classes + * + * @private + */ +MaterialLayout.prototype.resetPanelState_ = function (panels) { + for (var j = 0; j < panels.length; j++) { + panels[j].classList.remove(this.CssClasses_.IS_ACTIVE); + } +}; +/** + * Toggle drawer state + * + * @public + */ +MaterialLayout.prototype.toggleDrawer = function () { + var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN); + this.drawer_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN); + this.obfuscator_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN); + // Set accessibility properties. + if (this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) { + this.drawer_.setAttribute('aria-hidden', 'false'); + drawerButton.setAttribute('aria-expanded', 'true'); + } else { + this.drawer_.setAttribute('aria-hidden', 'true'); + drawerButton.setAttribute('aria-expanded', 'false'); + } +}; +MaterialLayout.prototype['toggleDrawer'] = MaterialLayout.prototype.toggleDrawer; +/** + * Initialize element. + */ +MaterialLayout.prototype.init = function () { + if (this.element_) { + var container = document.createElement('div'); + container.classList.add(this.CssClasses_.CONTAINER + '-nobug'); // here + var focusedElement = this.element_.querySelector(':focus'); + this.element_.parentElement.insertBefore(container, this.element_); + this.element_.parentElement.removeChild(this.element_); + container.appendChild(this.element_); + if (focusedElement) { + focusedElement.focus(); + } + var directChildren = this.element_.childNodes; + var numChildren = directChildren.length; + for (var c = 0; c < numChildren; c++) { + var child = directChildren[c]; + if (child.classList && child.classList.contains(this.CssClasses_.HEADER)) { + this.header_ = child; + } + if (child.classList && child.classList.contains(this.CssClasses_.DRAWER)) { + this.drawer_ = child; + } + if (child.classList && child.classList.contains(this.CssClasses_.CONTENT)) { + this.content_ = child; + } + } + window.addEventListener('pageshow', function (e) { + if (e.persisted) { + // when page is loaded from back/forward cache + // trigger repaint to let layout scroll in safari + this.element_.style.overflowY = 'hidden'; + requestAnimationFrame(function () { + this.element_.style.overflowY = ''; + }.bind(this)); + } + }.bind(this), false); + if (this.header_) { + this.tabBar_ = this.header_.querySelector('.' + this.CssClasses_.TAB_BAR); + } + var mode = this.Mode_.STANDARD; + if (this.header_) { + if (this.header_.classList.contains(this.CssClasses_.HEADER_SEAMED)) { + mode = this.Mode_.SEAMED; + } else if (this.header_.classList.contains(this.CssClasses_.HEADER_WATERFALL)) { + mode = this.Mode_.WATERFALL; + this.header_.addEventListener('transitionend', this.headerTransitionEndHandler_.bind(this)); + this.header_.addEventListener('click', this.headerClickHandler_.bind(this)); + } else if (this.header_.classList.contains(this.CssClasses_.HEADER_SCROLL)) { + mode = this.Mode_.SCROLL; + container.classList.add(this.CssClasses_.HAS_SCROLLING_HEADER); + } + if (mode === this.Mode_.STANDARD) { + this.header_.classList.add(this.CssClasses_.CASTING_SHADOW); + if (this.tabBar_) { + this.tabBar_.classList.add(this.CssClasses_.CASTING_SHADOW); + } + } else if (mode === this.Mode_.SEAMED || mode === this.Mode_.SCROLL) { + this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW); + if (this.tabBar_) { + this.tabBar_.classList.remove(this.CssClasses_.CASTING_SHADOW); + } + } else if (mode === this.Mode_.WATERFALL) { + // Add and remove shadows depending on scroll position. + // Also add/remove auxiliary class for styling of the compact version of + // the header. + this.content_.addEventListener('scroll', this.contentScrollHandler_.bind(this)); + this.contentScrollHandler_(); + } + } + // Add drawer toggling button to our layout, if we have an openable drawer. + if (this.drawer_) { + var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN); + if (!drawerButton) { + drawerButton = document.createElement('div'); + drawerButton.setAttribute('aria-expanded', 'false'); + drawerButton.setAttribute('role', 'button'); + drawerButton.setAttribute('tabindex', '0'); + drawerButton.classList.add(this.CssClasses_.DRAWER_BTN); + var drawerButtonIcon = document.createElement('i'); + drawerButtonIcon.classList.add(this.CssClasses_.ICON); + drawerButtonIcon.innerHTML = this.Constant_.MENU_ICON; + drawerButton.appendChild(drawerButtonIcon); + } + if (this.drawer_.classList.contains(this.CssClasses_.ON_LARGE_SCREEN)) { + //If drawer has ON_LARGE_SCREEN class then add it to the drawer toggle button as well. + drawerButton.classList.add(this.CssClasses_.ON_LARGE_SCREEN); + } else if (this.drawer_.classList.contains(this.CssClasses_.ON_SMALL_SCREEN)) { + //If drawer has ON_SMALL_SCREEN class then add it to the drawer toggle button as well. + drawerButton.classList.add(this.CssClasses_.ON_SMALL_SCREEN); + } + drawerButton.addEventListener('click', this.drawerToggleHandler_.bind(this)); + drawerButton.addEventListener('keydown', this.drawerToggleHandler_.bind(this)); + // Add a class if the layout has a drawer, for altering the left padding. + // Adds the HAS_DRAWER to the elements since this.header_ may or may + // not be present. + this.element_.classList.add(this.CssClasses_.HAS_DRAWER); + // If we have a fixed header, add the button to the header rather than + // the layout. + if (this.element_.classList.contains(this.CssClasses_.FIXED_HEADER)) { + this.header_.insertBefore(drawerButton, this.header_.firstChild); + } else { + this.element_.insertBefore(drawerButton, this.content_); + } + var obfuscator = document.createElement('div'); + obfuscator.classList.add(this.CssClasses_.OBFUSCATOR); + this.element_.appendChild(obfuscator); + obfuscator.addEventListener('click', this.drawerToggleHandler_.bind(this)); + this.obfuscator_ = obfuscator; + this.drawer_.addEventListener('keydown', this.keyboardEventHandler_.bind(this)); + this.drawer_.setAttribute('aria-hidden', 'true'); + } + // Keep an eye on screen size, and add/remove auxiliary class for styling + // of small screens. + this.screenSizeMediaQuery_ = window.matchMedia(this.Constant_.MAX_WIDTH); + this.screenSizeMediaQuery_.addListener(this.screenSizeHandler_.bind(this)); + this.screenSizeHandler_(); + // Initialize tabs, if any. + if (this.header_ && this.tabBar_) { + this.element_.classList.add(this.CssClasses_.HAS_TABS); + var tabContainer = document.createElement('div'); + tabContainer.classList.add(this.CssClasses_.TAB_CONTAINER); + this.header_.insertBefore(tabContainer, this.tabBar_); + this.header_.removeChild(this.tabBar_); + var leftButton = document.createElement('div'); + leftButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON); + leftButton.classList.add(this.CssClasses_.TAB_BAR_LEFT_BUTTON); + var leftButtonIcon = document.createElement('i'); + leftButtonIcon.classList.add(this.CssClasses_.ICON); + leftButtonIcon.textContent = this.Constant_.CHEVRON_LEFT; + leftButton.appendChild(leftButtonIcon); + leftButton.addEventListener('click', function () { + this.tabBar_.scrollLeft -= this.Constant_.TAB_SCROLL_PIXELS; + }.bind(this)); + var rightButton = document.createElement('div'); + rightButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON); + rightButton.classList.add(this.CssClasses_.TAB_BAR_RIGHT_BUTTON); + var rightButtonIcon = document.createElement('i'); + rightButtonIcon.classList.add(this.CssClasses_.ICON); + rightButtonIcon.textContent = this.Constant_.CHEVRON_RIGHT; + rightButton.appendChild(rightButtonIcon); + rightButton.addEventListener('click', function () { + this.tabBar_.scrollLeft += this.Constant_.TAB_SCROLL_PIXELS; + }.bind(this)); + tabContainer.appendChild(leftButton); + tabContainer.appendChild(this.tabBar_); + tabContainer.appendChild(rightButton); + // Add and remove tab buttons depending on scroll position and total + // window size. + var tabUpdateHandler = function () { + if (this.tabBar_.scrollLeft > 0) { + leftButton.classList.add(this.CssClasses_.IS_ACTIVE); + } else { + leftButton.classList.remove(this.CssClasses_.IS_ACTIVE); + } + if (this.tabBar_.scrollLeft < this.tabBar_.scrollWidth - this.tabBar_.offsetWidth) { + rightButton.classList.add(this.CssClasses_.IS_ACTIVE); + } else { + rightButton.classList.remove(this.CssClasses_.IS_ACTIVE); + } + }.bind(this); + this.tabBar_.addEventListener('scroll', tabUpdateHandler); + tabUpdateHandler(); + // Update tabs when the window resizes. + var windowResizeHandler = function () { + // Use timeouts to make sure it doesn't happen too often. + if (this.resizeTimeoutId_) { + clearTimeout(this.resizeTimeoutId_); + } + this.resizeTimeoutId_ = setTimeout(function () { + tabUpdateHandler(); + this.resizeTimeoutId_ = null; + }.bind(this), this.Constant_.RESIZE_TIMEOUT); + }.bind(this); + window.addEventListener('resize', windowResizeHandler); + if (this.tabBar_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) { + this.tabBar_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); + } + // Select element tabs, document panels + var tabs = this.tabBar_.querySelectorAll('.' + this.CssClasses_.TAB); + var panels = this.content_.querySelectorAll('.' + this.CssClasses_.PANEL); + // Create new tabs for each tab element + for (var i = 0; i < tabs.length; i++) { + new MaterialLayoutTab(tabs[i], tabs, panels, this); + } + } + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + } +}; +/** + * Constructor for an individual tab. + * + * @constructor + * @param {HTMLElement} tab The HTML element for the tab. + * @param {!Array} tabs Array with HTML elements for all tabs. + * @param {!Array} panels Array with HTML elements for all panels. + * @param {MaterialLayout} layout The MaterialLayout object that owns the tab. + */ +function MaterialLayoutTab(tab, tabs, panels, layout) { + /** + * Auxiliary method to programmatically select a tab in the UI. + */ + function selectTab() { + var href = tab.href.split('#')[1]; + var panel = layout.content_.querySelector('#' + href); + layout.resetTabState_(tabs); + layout.resetPanelState_(panels); + tab.classList.add(layout.CssClasses_.IS_ACTIVE); + panel.classList.add(layout.CssClasses_.IS_ACTIVE); + } + if (layout.tabBar_.classList.contains(layout.CssClasses_.JS_RIPPLE_EFFECT)) { + var rippleContainer = document.createElement('span'); + rippleContainer.classList.add(layout.CssClasses_.RIPPLE_CONTAINER); + rippleContainer.classList.add(layout.CssClasses_.JS_RIPPLE_EFFECT); + var ripple = document.createElement('span'); + ripple.classList.add(layout.CssClasses_.RIPPLE); + rippleContainer.appendChild(ripple); + tab.appendChild(rippleContainer); + } + if (!layout.tabBar_.classList.contains(layout.CssClasses_.TAB_MANUAL_SWITCH)) { + tab.addEventListener('click', function (e) { + if (tab.getAttribute('href').charAt(0) === '#') { + e.preventDefault(); + selectTab(); + } + }); + } + tab.show = selectTab; +} +window['MaterialLayoutTab'] = MaterialLayoutTab; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialLayout, + classAsString: 'MaterialLayout', + cssClass: 'mdl-js-layout' +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Data Table Card MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {Element} element The element that will be upgraded. + */ +var MaterialDataTable = function MaterialDataTable(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialDataTable'] = MaterialDataTable; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialDataTable.prototype.Constant_ = {}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialDataTable.prototype.CssClasses_ = { + DATA_TABLE: 'mdl-data-table', + SELECTABLE: 'mdl-data-table--selectable', + SELECT_ELEMENT: 'mdl-data-table__select', + IS_SELECTED: 'is-selected', + IS_UPGRADED: 'is-upgraded' +}; +/** + * Generates and returns a function that toggles the selection state of a + * single row (or multiple rows). + * + * @param {Element} checkbox Checkbox that toggles the selection state. + * @param {Element} row Row to toggle when checkbox changes. + * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes. + * @private + */ +MaterialDataTable.prototype.selectRow_ = function (checkbox, row, opt_rows) { + if (row) { + return function () { + if (checkbox.checked) { + row.classList.add(this.CssClasses_.IS_SELECTED); + } else { + row.classList.remove(this.CssClasses_.IS_SELECTED); + } + }.bind(this); + } + if (opt_rows) { + return function () { + var i; + var el; + if (checkbox.checked) { + for (i = 0; i < opt_rows.length; i++) { + el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox'); + el['MaterialCheckbox'].check(); + opt_rows[i].classList.add(this.CssClasses_.IS_SELECTED); + } + } else { + for (i = 0; i < opt_rows.length; i++) { + el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox'); + el['MaterialCheckbox'].uncheck(); + opt_rows[i].classList.remove(this.CssClasses_.IS_SELECTED); + } + } + }.bind(this); + } +}; +/** + * Creates a checkbox for a single or or multiple rows and hooks up the + * event handling. + * + * @param {Element} row Row to toggle when checkbox changes. + * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes. + * @private + */ +MaterialDataTable.prototype.createCheckbox_ = function (row, opt_rows) { + var label = document.createElement('label'); + var labelClasses = [ + 'mdl-checkbox', + 'mdl-js-checkbox', + 'mdl-js-ripple-effect', + this.CssClasses_.SELECT_ELEMENT + ]; + label.className = labelClasses.join(' '); + var checkbox = document.createElement('input'); + checkbox.type = 'checkbox'; + checkbox.classList.add('mdl-checkbox__input'); + if (row) { + checkbox.checked = row.classList.contains(this.CssClasses_.IS_SELECTED); + checkbox.addEventListener('change', this.selectRow_(checkbox, row)); + } else if (opt_rows) { + checkbox.addEventListener('change', this.selectRow_(checkbox, null, opt_rows)); + } + label.appendChild(checkbox); + componentHandler.upgradeElement(label, 'MaterialCheckbox'); + return label; +}; +/** + * Initialize element. + */ +MaterialDataTable.prototype.init = function () { + if (this.element_) { + var firstHeader = this.element_.querySelector('th'); + var bodyRows = Array.prototype.slice.call(this.element_.querySelectorAll('tbody tr')); + var footRows = Array.prototype.slice.call(this.element_.querySelectorAll('tfoot tr')); + var rows = bodyRows.concat(footRows); + if (this.element_.classList.contains(this.CssClasses_.SELECTABLE)) { + var th = document.createElement('th'); + var headerCheckbox = this.createCheckbox_(null, rows); + th.appendChild(headerCheckbox); + firstHeader.parentElement.insertBefore(th, firstHeader); + for (var i = 0; i < rows.length; i++) { + var firstCell = rows[i].querySelector('td'); + if (firstCell) { + var td = document.createElement('td'); + if (rows[i].parentNode.nodeName.toUpperCase() === 'TBODY') { + var rowCheckbox = this.createCheckbox_(rows[i]); + td.appendChild(rowCheckbox); + } + rows[i].insertBefore(td, firstCell); + } + } + this.element_.classList.add(this.CssClasses_.IS_UPGRADED); + } + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialDataTable, + classAsString: 'MaterialDataTable', + cssClass: 'mdl-js-data-table' +}); +/** + * @license + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * Class constructor for Ripple MDL component. + * Implements MDL component design pattern defined at: + * https://github.com/jasonmayes/mdl-component-design-pattern + * + * @constructor + * @param {HTMLElement} element The element that will be upgraded. + */ +var MaterialRipple = function MaterialRipple(element) { + this.element_ = element; + // Initialize instance. + this.init(); +}; +window['MaterialRipple'] = MaterialRipple; +/** + * Store constants in one place so they can be updated easily. + * + * @enum {string | number} + * @private + */ +MaterialRipple.prototype.Constant_ = { + INITIAL_SCALE: 'scale(0.0001, 0.0001)', + INITIAL_SIZE: '1px', + INITIAL_OPACITY: '0.4', + FINAL_OPACITY: '0', + FINAL_SCALE: '' +}; +/** + * Store strings for class names defined by this component that are used in + * JavaScript. This allows us to simply change it in one place should we + * decide to modify at a later date. + * + * @enum {string} + * @private + */ +MaterialRipple.prototype.CssClasses_ = { + RIPPLE_CENTER: 'mdl-ripple--center', + RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', + RIPPLE: 'mdl-ripple', + IS_ANIMATING: 'is-animating', + IS_VISIBLE: 'is-visible' +}; +/** + * Handle mouse / finger down on element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRipple.prototype.downHandler_ = function (event) { + if (!this.rippleElement_.style.width && !this.rippleElement_.style.height) { + var rect = this.element_.getBoundingClientRect(); + this.boundHeight = rect.height; + this.boundWidth = rect.width; + this.rippleSize_ = Math.sqrt(rect.width * rect.width + rect.height * rect.height) * 2 + 2; + this.rippleElement_.style.width = this.rippleSize_ + 'px'; + this.rippleElement_.style.height = this.rippleSize_ + 'px'; + } + this.rippleElement_.classList.add(this.CssClasses_.IS_VISIBLE); + if (event.type === 'mousedown' && this.ignoringMouseDown_) { + this.ignoringMouseDown_ = false; + } else { + if (event.type === 'touchstart') { + this.ignoringMouseDown_ = true; + } + var frameCount = this.getFrameCount(); + if (frameCount > 0) { + return; + } + this.setFrameCount(1); + var bound = event.currentTarget.getBoundingClientRect(); + var x; + var y; + // Check if we are handling a keyboard click. + if (event.clientX === 0 && event.clientY === 0) { + x = Math.round(bound.width / 2); + y = Math.round(bound.height / 2); + } else { + var clientX = event.clientX !== undefined ? event.clientX : event.touches[0].clientX; + var clientY = event.clientY !== undefined ? event.clientY : event.touches[0].clientY; + x = Math.round(clientX - bound.left); + y = Math.round(clientY - bound.top); + } + this.setRippleXY(x, y); + this.setRippleStyles(true); + window.requestAnimationFrame(this.animFrameHandler.bind(this)); + } +}; +/** + * Handle mouse / finger up on element. + * + * @param {Event} event The event that fired. + * @private + */ +MaterialRipple.prototype.upHandler_ = function (event) { + // Don't fire for the artificial "mouseup" generated by a double-click. + if (event && event.detail !== 2) { + // Allow a repaint to occur before removing this class, so the animation + // shows for tap events, which seem to trigger a mouseup too soon after + // mousedown. + window.setTimeout(function () { + this.rippleElement_.classList.remove(this.CssClasses_.IS_VISIBLE); + }.bind(this), 0); + } +}; +/** + * Initialize element. + */ +MaterialRipple.prototype.init = function () { + if (this.element_) { + var recentering = this.element_.classList.contains(this.CssClasses_.RIPPLE_CENTER); + if (!this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT_IGNORE_EVENTS)) { + this.rippleElement_ = this.element_.querySelector('.' + this.CssClasses_.RIPPLE); + this.frameCount_ = 0; + this.rippleSize_ = 0; + this.x_ = 0; + this.y_ = 0; + // Touch start produces a compat mouse down event, which would cause a + // second ripples. To avoid that, we use this property to ignore the first + // mouse down after a touch start. + this.ignoringMouseDown_ = false; + this.boundDownHandler = this.downHandler_.bind(this); + this.element_.addEventListener('mousedown', this.boundDownHandler); + this.element_.addEventListener('touchstart', this.boundDownHandler); + this.boundUpHandler = this.upHandler_.bind(this); + this.element_.addEventListener('mouseup', this.boundUpHandler); + this.element_.addEventListener('mouseleave', this.boundUpHandler); + this.element_.addEventListener('touchend', this.boundUpHandler); + this.element_.addEventListener('blur', this.boundUpHandler); + /** + * Getter for frameCount_. + * @return {number} the frame count. + */ + this.getFrameCount = function () { + return this.frameCount_; + }; + /** + * Setter for frameCount_. + * @param {number} fC the frame count. + */ + this.setFrameCount = function (fC) { + this.frameCount_ = fC; + }; + /** + * Getter for rippleElement_. + * @return {Element} the ripple element. + */ + this.getRippleElement = function () { + return this.rippleElement_; + }; + /** + * Sets the ripple X and Y coordinates. + * @param {number} newX the new X coordinate + * @param {number} newY the new Y coordinate + */ + this.setRippleXY = function (newX, newY) { + this.x_ = newX; + this.y_ = newY; + }; + /** + * Sets the ripple styles. + * @param {boolean} start whether or not this is the start frame. + */ + this.setRippleStyles = function (start) { + if (this.rippleElement_ !== null) { + var transformString; + var scale; + var size; + var offset = 'translate(' + this.x_ + 'px, ' + this.y_ + 'px)'; + if (start) { + scale = this.Constant_.INITIAL_SCALE; + size = this.Constant_.INITIAL_SIZE; + } else { + scale = this.Constant_.FINAL_SCALE; + size = this.rippleSize_ + 'px'; + if (recentering) { + offset = 'translate(' + this.boundWidth / 2 + 'px, ' + this.boundHeight / 2 + 'px)'; + } + } + transformString = 'translate(-50%, -50%) ' + offset + scale; + this.rippleElement_.style.webkitTransform = transformString; + this.rippleElement_.style.msTransform = transformString; + this.rippleElement_.style.transform = transformString; + if (start) { + this.rippleElement_.classList.remove(this.CssClasses_.IS_ANIMATING); + } else { + this.rippleElement_.classList.add(this.CssClasses_.IS_ANIMATING); + } + } + }; + /** + * Handles an animation frame. + */ + this.animFrameHandler = function () { + if (this.frameCount_-- > 0) { + window.requestAnimationFrame(this.animFrameHandler.bind(this)); + } else { + this.setRippleStyles(false); + } + }; + } + } +}; +// The component registers itself. It can assume componentHandler is available +// in the global scope. +componentHandler.register({ + constructor: MaterialRipple, + classAsString: 'MaterialRipple', + cssClass: 'mdl-js-ripple-effect', + widget: false +}); +}()); diff --git a/web/static/js/vendor/material.js b/web/static/js/vendor/material.js deleted file mode 100644 index 994825a..0000000 --- a/web/static/js/vendor/material.js +++ /dev/null @@ -1,3996 +0,0 @@ -;(function() { -"use strict"; - -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A component handler interface using the revealing module design pattern. - * More details on this design pattern here: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @author Jason Mayes. - */ -/* exported componentHandler */ - -// Pre-defining the componentHandler interface, for closure documentation and -// static verification. -var componentHandler = { - /** - * Searches existing DOM for elements of our component type and upgrades them - * if they have not already been upgraded. - * - * @param {string=} optJsClass the programatic name of the element class we - * need to create a new instance of. - * @param {string=} optCssClass the name of the CSS class elements of this - * type will have. - */ - upgradeDom: function(optJsClass, optCssClass) {}, - /** - * Upgrades a specific element rather than all in the DOM. - * - * @param {!Element} element The element we wish to upgrade. - * @param {string=} optJsClass Optional name of the class we want to upgrade - * the element to. - */ - upgradeElement: function(element, optJsClass) {}, - /** - * Upgrades a specific list of elements rather than all in the DOM. - * - * @param {!Element|!Array|!NodeList|!HTMLCollection} elements - * The elements we wish to upgrade. - */ - upgradeElements: function(elements) {}, - /** - * Upgrades all registered components found in the current DOM. This is - * automatically called on window load. - */ - upgradeAllRegistered: function() {}, - /** - * Allows user to be alerted to any upgrades that are performed for a given - * component type - * - * @param {string} jsClass The class name of the MDL component we wish - * to hook into for any upgrades performed. - * @param {function(!HTMLElement)} callback The function to call upon an - * upgrade. This function should expect 1 parameter - the HTMLElement which - * got upgraded. - */ - registerUpgradedCallback: function(jsClass, callback) {}, - /** - * Registers a class for future use and attempts to upgrade existing DOM. - * - * @param {componentHandler.ComponentConfigPublic} config the registration configuration - */ - register: function(config) {}, - /** - * Downgrade either a given node, an array of nodes, or a NodeList. - * - * @param {!Node|!Array|!NodeList} nodes - */ - downgradeElements: function(nodes) {} -}; - -componentHandler = (function() { - 'use strict'; - - /** @type {!Array} */ - var registeredComponents_ = []; - - /** @type {!Array} */ - var createdComponents_ = []; - - var componentConfigProperty_ = 'mdlComponentConfigInternal_'; - - /** - * Searches registered components for a class we are interested in using. - * Optionally replaces a match with passed object if specified. - * - * @param {string} name The name of a class we want to use. - * @param {componentHandler.ComponentConfig=} optReplace Optional object to replace match with. - * @return {!Object|boolean} - * @private - */ - function findRegisteredClass_(name, optReplace) { - for (var i = 0; i < registeredComponents_.length; i++) { - if (registeredComponents_[i].className === name) { - if (typeof optReplace !== 'undefined') { - registeredComponents_[i] = optReplace; - } - return registeredComponents_[i]; - } - } - return false; - } - - /** - * Returns an array of the classNames of the upgraded classes on the element. - * - * @param {!Element} element The element to fetch data from. - * @return {!Array} - * @private - */ - function getUpgradedListOfElement_(element) { - var dataUpgraded = element.getAttribute('data-upgraded'); - // Use `['']` as default value to conform the `,name,name...` style. - return dataUpgraded === null ? [''] : dataUpgraded.split(','); - } - - /** - * Returns true if the given element has already been upgraded for the given - * class. - * - * @param {!Element} element The element we want to check. - * @param {string} jsClass The class to check for. - * @returns {boolean} - * @private - */ - function isElementUpgraded_(element, jsClass) { - var upgradedList = getUpgradedListOfElement_(element); - return upgradedList.indexOf(jsClass) !== -1; - } - - /** - * Create an event object. - * - * @param {string} eventType The type name of the event. - * @param {boolean} bubbles Whether the event should bubble up the DOM. - * @param {boolean} cancelable Whether the event can be canceled. - * @returns {!Event} - */ - function createEvent_(eventType, bubbles, cancelable) { - if ('CustomEvent' in window && typeof window.CustomEvent === 'function') { - return new CustomEvent(eventType, { - bubbles: bubbles, - cancelable: cancelable - }); - } else { - var ev = document.createEvent('Events'); - ev.initEvent(eventType, bubbles, cancelable); - return ev; - } - } - - /** - * Searches existing DOM for elements of our component type and upgrades them - * if they have not already been upgraded. - * - * @param {string=} optJsClass the programatic name of the element class we - * need to create a new instance of. - * @param {string=} optCssClass the name of the CSS class elements of this - * type will have. - */ - function upgradeDomInternal(optJsClass, optCssClass) { - if (typeof optJsClass === 'undefined' && - typeof optCssClass === 'undefined') { - for (var i = 0; i < registeredComponents_.length; i++) { - upgradeDomInternal(registeredComponents_[i].className, - registeredComponents_[i].cssClass); - } - } else { - var jsClass = /** @type {string} */ (optJsClass); - if (typeof optCssClass === 'undefined') { - var registeredClass = findRegisteredClass_(jsClass); - if (registeredClass) { - optCssClass = registeredClass.cssClass; - } - } - - var elements = document.querySelectorAll('.' + optCssClass); - for (var n = 0; n < elements.length; n++) { - upgradeElementInternal(elements[n], jsClass); - } - } - } - - /** - * Upgrades a specific element rather than all in the DOM. - * - * @param {!Element} element The element we wish to upgrade. - * @param {string=} optJsClass Optional name of the class we want to upgrade - * the element to. - */ - function upgradeElementInternal(element, optJsClass) { - // Verify argument type. - if (!(typeof element === 'object' && element instanceof Element)) { - throw new Error('Invalid argument provided to upgrade MDL element.'); - } - // Allow upgrade to be canceled by canceling emitted event. - var upgradingEv = createEvent_('mdl-componentupgrading', true, true); - element.dispatchEvent(upgradingEv); - if (upgradingEv.defaultPrevented) { - return; - } - - var upgradedList = getUpgradedListOfElement_(element); - var classesToUpgrade = []; - // If jsClass is not provided scan the registered components to find the - // ones matching the element's CSS classList. - if (!optJsClass) { - var classList = element.classList; - registeredComponents_.forEach(function(component) { - // Match CSS & Not to be upgraded & Not upgraded. - if (classList.contains(component.cssClass) && - classesToUpgrade.indexOf(component) === -1 && - !isElementUpgraded_(element, component.className)) { - classesToUpgrade.push(component); - } - }); - } else if (!isElementUpgraded_(element, optJsClass)) { - classesToUpgrade.push(findRegisteredClass_(optJsClass)); - } - - // Upgrade the element for each classes. - for (var i = 0, n = classesToUpgrade.length, registeredClass; i < n; i++) { - registeredClass = classesToUpgrade[i]; - if (registeredClass) { - // Mark element as upgraded. - upgradedList.push(registeredClass.className); - element.setAttribute('data-upgraded', upgradedList.join(',')); - var instance = new registeredClass.classConstructor(element); - instance[componentConfigProperty_] = registeredClass; - createdComponents_.push(instance); - // Call any callbacks the user has registered with this component type. - for (var j = 0, m = registeredClass.callbacks.length; j < m; j++) { - registeredClass.callbacks[j](element); - } - - if (registeredClass.widget) { - // Assign per element instance for control over API - element[registeredClass.className] = instance; - } - } else { - throw new Error( - 'Unable to find a registered component for the given class.'); - } - - var upgradedEv = createEvent_('mdl-componentupgraded', true, false); - element.dispatchEvent(upgradedEv); - } - } - - /** - * Upgrades a specific list of elements rather than all in the DOM. - * - * @param {!Element|!Array|!NodeList|!HTMLCollection} elements - * The elements we wish to upgrade. - */ - function upgradeElementsInternal(elements) { - if (!Array.isArray(elements)) { - if (elements instanceof Element) { - elements = [elements]; - } else { - elements = Array.prototype.slice.call(elements); - } - } - for (var i = 0, n = elements.length, element; i < n; i++) { - element = elements[i]; - if (element instanceof HTMLElement) { - upgradeElementInternal(element); - if (element.children.length > 0) { - upgradeElementsInternal(element.children); - } - } - } - } - - /** - * Registers a class for future use and attempts to upgrade existing DOM. - * - * @param {componentHandler.ComponentConfigPublic} config - */ - function registerInternal(config) { - // In order to support both Closure-compiled and uncompiled code accessing - // this method, we need to allow for both the dot and array syntax for - // property access. You'll therefore see the `foo.bar || foo['bar']` - // pattern repeated across this method. - var widgetMissing = (typeof config.widget === 'undefined' && - typeof config['widget'] === 'undefined'); - var widget = true; - - if (!widgetMissing) { - widget = config.widget || config['widget']; - } - - var newConfig = /** @type {componentHandler.ComponentConfig} */ ({ - classConstructor: config.constructor || config['constructor'], - className: config.classAsString || config['classAsString'], - cssClass: config.cssClass || config['cssClass'], - widget: widget, - callbacks: [] - }); - - registeredComponents_.forEach(function(item) { - if (item.cssClass === newConfig.cssClass) { - throw new Error('The provided cssClass has already been registered: ' + item.cssClass); - } - if (item.className === newConfig.className) { - throw new Error('The provided className has already been registered'); - } - }); - - if (config.constructor.prototype - .hasOwnProperty(componentConfigProperty_)) { - throw new Error( - 'MDL component classes must not have ' + componentConfigProperty_ + - ' defined as a property.'); - } - - var found = findRegisteredClass_(config.classAsString, newConfig); - - if (!found) { - registeredComponents_.push(newConfig); - } - } - - /** - * Allows user to be alerted to any upgrades that are performed for a given - * component type - * - * @param {string} jsClass The class name of the MDL component we wish - * to hook into for any upgrades performed. - * @param {function(!HTMLElement)} callback The function to call upon an - * upgrade. This function should expect 1 parameter - the HTMLElement which - * got upgraded. - */ - function registerUpgradedCallbackInternal(jsClass, callback) { - var regClass = findRegisteredClass_(jsClass); - if (regClass) { - regClass.callbacks.push(callback); - } - } - - /** - * Upgrades all registered components found in the current DOM. This is - * automatically called on window load. - */ - function upgradeAllRegisteredInternal() { - for (var n = 0; n < registeredComponents_.length; n++) { - upgradeDomInternal(registeredComponents_[n].className); - } - } - - /** - * Check the component for the downgrade method. - * Execute if found. - * Remove component from createdComponents list. - * - * @param {?componentHandler.Component} component - */ - function deconstructComponentInternal(component) { - if (component) { - var componentIndex = createdComponents_.indexOf(component); - createdComponents_.splice(componentIndex, 1); - - var upgrades = component.element_.getAttribute('data-upgraded').split(','); - var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString); - upgrades.splice(componentPlace, 1); - component.element_.setAttribute('data-upgraded', upgrades.join(',')); - - var ev = createEvent_('mdl-componentdowngraded', true, false); - component.element_.dispatchEvent(ev); - } - } - - /** - * Downgrade either a given node, an array of nodes, or a NodeList. - * - * @param {!Node|!Array|!NodeList} nodes - */ - function downgradeNodesInternal(nodes) { - /** - * Auxiliary function to downgrade a single node. - * @param {!Node} node the node to be downgraded - */ - var downgradeNode = function(node) { - createdComponents_.filter(function(item) { - return item.element_ === node; - }).forEach(deconstructComponentInternal); - }; - if (nodes instanceof Array || nodes instanceof NodeList) { - for (var n = 0; n < nodes.length; n++) { - downgradeNode(nodes[n]); - } - } else if (nodes instanceof Node) { - downgradeNode(nodes); - } else { - throw new Error('Invalid argument provided to downgrade MDL nodes.'); - } - } - - // Now return the functions that should be made public with their publicly - // facing names... - return { - upgradeDom: upgradeDomInternal, - upgradeElement: upgradeElementInternal, - upgradeElements: upgradeElementsInternal, - upgradeAllRegistered: upgradeAllRegisteredInternal, - registerUpgradedCallback: registerUpgradedCallbackInternal, - register: registerInternal, - downgradeElements: downgradeNodesInternal - }; -})(); - -/** - * Describes the type of a registered component type managed by - * componentHandler. Provided for benefit of the Closure compiler. - * - * @typedef {{ - * constructor: Function, - * classAsString: string, - * cssClass: string, - * widget: (string|boolean|undefined) - * }} - */ -componentHandler.ComponentConfigPublic; // jshint ignore:line - -/** - * Describes the type of a registered component type managed by - * componentHandler. Provided for benefit of the Closure compiler. - * - * @typedef {{ - * constructor: !Function, - * className: string, - * cssClass: string, - * widget: (string|boolean), - * callbacks: !Array - * }} - */ -componentHandler.ComponentConfig; // jshint ignore:line - -/** - * Created component (i.e., upgraded element) type as managed by - * componentHandler. Provided for benefit of the Closure compiler. - * - * @typedef {{ - * element_: !HTMLElement, - * className: string, - * classAsString: string, - * cssClass: string, - * widget: string - * }} - */ -componentHandler.Component; // jshint ignore:line - -// Export all symbols, for the benefit of Closure compiler. -// No effect on uncompiled code. -componentHandler['upgradeDom'] = componentHandler.upgradeDom; -componentHandler['upgradeElement'] = componentHandler.upgradeElement; -componentHandler['upgradeElements'] = componentHandler.upgradeElements; -componentHandler['upgradeAllRegistered'] = - componentHandler.upgradeAllRegistered; -componentHandler['registerUpgradedCallback'] = - componentHandler.registerUpgradedCallback; -componentHandler['register'] = componentHandler.register; -componentHandler['downgradeElements'] = componentHandler.downgradeElements; -window.componentHandler = componentHandler; -window['componentHandler'] = componentHandler; - -window.addEventListener('load', function() { - 'use strict'; - - /** - * Performs a "Cutting the mustard" test. If the browser supports the features - * tested, adds a mdl-js class to the element. It then upgrades all MDL - * components requiring JavaScript. - */ - if ('classList' in document.createElement('div') && - 'querySelector' in document && - 'addEventListener' in window && Array.prototype.forEach) { - document.documentElement.classList.add('mdl-js'); - componentHandler.upgradeAllRegistered(); - } else { - /** - * Dummy function to avoid JS errors. - */ - componentHandler.upgradeElement = function() {}; - /** - * Dummy function to avoid JS errors. - */ - componentHandler.register = function() {}; - } -}); - -// Source: https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js -// Adapted from https://gist.github.com/paulirish/1579671 which derived from -// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ -// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating -// requestAnimationFrame polyfill by Erik Möller. -// Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon -// MIT license -if (!Date.now) { - /** - * Date.now polyfill. - * @return {number} the current Date - */ - Date.now = function () { - return new Date().getTime(); - }; - Date['now'] = Date.now; -} -var vendors = [ - 'webkit', - 'moz' -]; -for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) { - var vp = vendors[i]; - window.requestAnimationFrame = window[vp + 'RequestAnimationFrame']; - window.cancelAnimationFrame = window[vp + 'CancelAnimationFrame'] || window[vp + 'CancelRequestAnimationFrame']; - window['requestAnimationFrame'] = window.requestAnimationFrame; - window['cancelAnimationFrame'] = window.cancelAnimationFrame; -} -if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) { - var lastTime = 0; - /** - * requestAnimationFrame polyfill. - * @param {!Function} callback the callback function. - */ - window.requestAnimationFrame = function (callback) { - var now = Date.now(); - var nextTime = Math.max(lastTime + 16, now); - return setTimeout(function () { - callback(lastTime = nextTime); - }, nextTime - now); - }; - window.cancelAnimationFrame = clearTimeout; - window['requestAnimationFrame'] = window.requestAnimationFrame; - window['cancelAnimationFrame'] = window.cancelAnimationFrame; -} -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Button MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialButton = function MaterialButton(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialButton'] = MaterialButton; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialButton.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialButton.prototype.CssClasses_ = { - RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_CONTAINER: 'mdl-button__ripple-container', - RIPPLE: 'mdl-ripple' -}; -/** - * Handle blur of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialButton.prototype.blurHandler_ = function (event) { - if (event) { - this.element_.blur(); - } -}; -// Public methods. -/** - * Disable button. - * - * @public - */ -MaterialButton.prototype.disable = function () { - this.element_.disabled = true; -}; -MaterialButton.prototype['disable'] = MaterialButton.prototype.disable; -/** - * Enable button. - * - * @public - */ -MaterialButton.prototype.enable = function () { - this.element_.disabled = false; -}; -MaterialButton.prototype['enable'] = MaterialButton.prototype.enable; -/** - * Initialize element. - */ -MaterialButton.prototype.init = function () { - if (this.element_) { - if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { - var rippleContainer = document.createElement('span'); - rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER); - this.rippleElement_ = document.createElement('span'); - this.rippleElement_.classList.add(this.CssClasses_.RIPPLE); - rippleContainer.appendChild(this.rippleElement_); - this.boundRippleBlurHandler = this.blurHandler_.bind(this); - this.rippleElement_.addEventListener('mouseup', this.boundRippleBlurHandler); - this.element_.appendChild(rippleContainer); - } - this.boundButtonBlurHandler = this.blurHandler_.bind(this); - this.element_.addEventListener('mouseup', this.boundButtonBlurHandler); - this.element_.addEventListener('mouseleave', this.boundButtonBlurHandler); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialButton, - classAsString: 'MaterialButton', - cssClass: 'mdl-js-button', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Checkbox MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialCheckbox = function MaterialCheckbox(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialCheckbox'] = MaterialCheckbox; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialCheckbox.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialCheckbox.prototype.CssClasses_ = { - INPUT: 'mdl-checkbox__input', - BOX_OUTLINE: 'mdl-checkbox__box-outline', - FOCUS_HELPER: 'mdl-checkbox__focus-helper', - TICK_OUTLINE: 'mdl-checkbox__tick-outline', - RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - RIPPLE_CONTAINER: 'mdl-checkbox__ripple-container', - RIPPLE_CENTER: 'mdl-ripple--center', - RIPPLE: 'mdl-ripple', - IS_FOCUSED: 'is-focused', - IS_DISABLED: 'is-disabled', - IS_CHECKED: 'is-checked', - IS_UPGRADED: 'is-upgraded' -}; -/** - * Handle change of state. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialCheckbox.prototype.onChange_ = function (event) { - this.updateClasses_(); -}; -/** - * Handle focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialCheckbox.prototype.onFocus_ = function (event) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle lost focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialCheckbox.prototype.onBlur_ = function (event) { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle mouseup. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialCheckbox.prototype.onMouseUp_ = function (event) { - this.blur_(); -}; -/** - * Handle class updates. - * - * @private - */ -MaterialCheckbox.prototype.updateClasses_ = function () { - this.checkDisabled(); - this.checkToggleState(); -}; -/** - * Add blur. - * - * @private - */ -MaterialCheckbox.prototype.blur_ = function () { - // TODO: figure out why there's a focus event being fired after our blur, - // so that we can avoid this hack. - window.setTimeout(function () { - this.inputElement_.blur(); - }.bind(this), this.Constant_.TINY_TIMEOUT); -}; -// Public methods. -/** - * Check the inputs toggle state and update display. - * - * @public - */ -MaterialCheckbox.prototype.checkToggleState = function () { - if (this.inputElement_.checked) { - this.element_.classList.add(this.CssClasses_.IS_CHECKED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_CHECKED); - } -}; -MaterialCheckbox.prototype['checkToggleState'] = MaterialCheckbox.prototype.checkToggleState; -/** - * Check the inputs disabled state and update display. - * - * @public - */ -MaterialCheckbox.prototype.checkDisabled = function () { - if (this.inputElement_.disabled) { - this.element_.classList.add(this.CssClasses_.IS_DISABLED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DISABLED); - } -}; -MaterialCheckbox.prototype['checkDisabled'] = MaterialCheckbox.prototype.checkDisabled; -/** - * Disable checkbox. - * - * @public - */ -MaterialCheckbox.prototype.disable = function () { - this.inputElement_.disabled = true; - this.updateClasses_(); -}; -MaterialCheckbox.prototype['disable'] = MaterialCheckbox.prototype.disable; -/** - * Enable checkbox. - * - * @public - */ -MaterialCheckbox.prototype.enable = function () { - this.inputElement_.disabled = false; - this.updateClasses_(); -}; -MaterialCheckbox.prototype['enable'] = MaterialCheckbox.prototype.enable; -/** - * Check checkbox. - * - * @public - */ -MaterialCheckbox.prototype.check = function () { - this.inputElement_.checked = true; - this.updateClasses_(); -}; -MaterialCheckbox.prototype['check'] = MaterialCheckbox.prototype.check; -/** - * Uncheck checkbox. - * - * @public - */ -MaterialCheckbox.prototype.uncheck = function () { - this.inputElement_.checked = false; - this.updateClasses_(); -}; -MaterialCheckbox.prototype['uncheck'] = MaterialCheckbox.prototype.uncheck; -/** - * Initialize element. - */ -MaterialCheckbox.prototype.init = function () { - if (this.element_) { - this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); - var boxOutline = document.createElement('span'); - boxOutline.classList.add(this.CssClasses_.BOX_OUTLINE); - var tickContainer = document.createElement('span'); - tickContainer.classList.add(this.CssClasses_.FOCUS_HELPER); - var tickOutline = document.createElement('span'); - tickOutline.classList.add(this.CssClasses_.TICK_OUTLINE); - boxOutline.appendChild(tickOutline); - this.element_.appendChild(tickContainer); - this.element_.appendChild(boxOutline); - if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - this.rippleContainerElement_ = document.createElement('span'); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); - this.boundRippleMouseUp = this.onMouseUp_.bind(this); - this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp); - var ripple = document.createElement('span'); - ripple.classList.add(this.CssClasses_.RIPPLE); - this.rippleContainerElement_.appendChild(ripple); - this.element_.appendChild(this.rippleContainerElement_); - } - this.boundInputOnChange = this.onChange_.bind(this); - this.boundInputOnFocus = this.onFocus_.bind(this); - this.boundInputOnBlur = this.onBlur_.bind(this); - this.boundElementMouseUp = this.onMouseUp_.bind(this); - this.inputElement_.addEventListener('change', this.boundInputOnChange); - this.inputElement_.addEventListener('focus', this.boundInputOnFocus); - this.inputElement_.addEventListener('blur', this.boundInputOnBlur); - this.element_.addEventListener('mouseup', this.boundElementMouseUp); - this.updateClasses_(); - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialCheckbox, - classAsString: 'MaterialCheckbox', - cssClass: 'mdl-js-checkbox', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for icon toggle MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialIconToggle = function MaterialIconToggle(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialIconToggle'] = MaterialIconToggle; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialIconToggle.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialIconToggle.prototype.CssClasses_ = { - INPUT: 'mdl-icon-toggle__input', - JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - RIPPLE_CONTAINER: 'mdl-icon-toggle__ripple-container', - RIPPLE_CENTER: 'mdl-ripple--center', - RIPPLE: 'mdl-ripple', - IS_FOCUSED: 'is-focused', - IS_DISABLED: 'is-disabled', - IS_CHECKED: 'is-checked' -}; -/** - * Handle change of state. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialIconToggle.prototype.onChange_ = function (event) { - this.updateClasses_(); -}; -/** - * Handle focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialIconToggle.prototype.onFocus_ = function (event) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle lost focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialIconToggle.prototype.onBlur_ = function (event) { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle mouseup. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialIconToggle.prototype.onMouseUp_ = function (event) { - this.blur_(); -}; -/** - * Handle class updates. - * - * @private - */ -MaterialIconToggle.prototype.updateClasses_ = function () { - this.checkDisabled(); - this.checkToggleState(); -}; -/** - * Add blur. - * - * @private - */ -MaterialIconToggle.prototype.blur_ = function () { - // TODO: figure out why there's a focus event being fired after our blur, - // so that we can avoid this hack. - window.setTimeout(function () { - this.inputElement_.blur(); - }.bind(this), this.Constant_.TINY_TIMEOUT); -}; -// Public methods. -/** - * Check the inputs toggle state and update display. - * - * @public - */ -MaterialIconToggle.prototype.checkToggleState = function () { - if (this.inputElement_.checked) { - this.element_.classList.add(this.CssClasses_.IS_CHECKED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_CHECKED); - } -}; -MaterialIconToggle.prototype['checkToggleState'] = MaterialIconToggle.prototype.checkToggleState; -/** - * Check the inputs disabled state and update display. - * - * @public - */ -MaterialIconToggle.prototype.checkDisabled = function () { - if (this.inputElement_.disabled) { - this.element_.classList.add(this.CssClasses_.IS_DISABLED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DISABLED); - } -}; -MaterialIconToggle.prototype['checkDisabled'] = MaterialIconToggle.prototype.checkDisabled; -/** - * Disable icon toggle. - * - * @public - */ -MaterialIconToggle.prototype.disable = function () { - this.inputElement_.disabled = true; - this.updateClasses_(); -}; -MaterialIconToggle.prototype['disable'] = MaterialIconToggle.prototype.disable; -/** - * Enable icon toggle. - * - * @public - */ -MaterialIconToggle.prototype.enable = function () { - this.inputElement_.disabled = false; - this.updateClasses_(); -}; -MaterialIconToggle.prototype['enable'] = MaterialIconToggle.prototype.enable; -/** - * Check icon toggle. - * - * @public - */ -MaterialIconToggle.prototype.check = function () { - this.inputElement_.checked = true; - this.updateClasses_(); -}; -MaterialIconToggle.prototype['check'] = MaterialIconToggle.prototype.check; -/** - * Uncheck icon toggle. - * - * @public - */ -MaterialIconToggle.prototype.uncheck = function () { - this.inputElement_.checked = false; - this.updateClasses_(); -}; -MaterialIconToggle.prototype['uncheck'] = MaterialIconToggle.prototype.uncheck; -/** - * Initialize element. - */ -MaterialIconToggle.prototype.init = function () { - if (this.element_) { - this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); - if (this.element_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - this.rippleContainerElement_ = document.createElement('span'); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); - this.rippleContainerElement_.classList.add(this.CssClasses_.JS_RIPPLE_EFFECT); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); - this.boundRippleMouseUp = this.onMouseUp_.bind(this); - this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp); - var ripple = document.createElement('span'); - ripple.classList.add(this.CssClasses_.RIPPLE); - this.rippleContainerElement_.appendChild(ripple); - this.element_.appendChild(this.rippleContainerElement_); - } - this.boundInputOnChange = this.onChange_.bind(this); - this.boundInputOnFocus = this.onFocus_.bind(this); - this.boundInputOnBlur = this.onBlur_.bind(this); - this.boundElementOnMouseUp = this.onMouseUp_.bind(this); - this.inputElement_.addEventListener('change', this.boundInputOnChange); - this.inputElement_.addEventListener('focus', this.boundInputOnFocus); - this.inputElement_.addEventListener('blur', this.boundInputOnBlur); - this.element_.addEventListener('mouseup', this.boundElementOnMouseUp); - this.updateClasses_(); - this.element_.classList.add('is-upgraded'); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialIconToggle, - classAsString: 'MaterialIconToggle', - cssClass: 'mdl-js-icon-toggle', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for dropdown MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialMenu = function MaterialMenu(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialMenu'] = MaterialMenu; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialMenu.prototype.Constant_ = { - // Total duration of the menu animation. - TRANSITION_DURATION_SECONDS: 0.3, - // The fraction of the total duration we want to use for menu item animations. - TRANSITION_DURATION_FRACTION: 0.8, - // How long the menu stays open after choosing an option (so the user can see - // the ripple). - CLOSE_TIMEOUT: 150 -}; -/** - * Keycodes, for code readability. - * - * @enum {number} - * @private - */ -MaterialMenu.prototype.Keycodes_ = { - ENTER: 13, - ESCAPE: 27, - SPACE: 32, - UP_ARROW: 38, - DOWN_ARROW: 40 -}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialMenu.prototype.CssClasses_ = { - CONTAINER: 'mdl-menu__container', - OUTLINE: 'mdl-menu__outline', - ITEM: 'mdl-menu__item', - ITEM_RIPPLE_CONTAINER: 'mdl-menu__item-ripple-container', - RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - RIPPLE: 'mdl-ripple', - // Statuses - IS_UPGRADED: 'is-upgraded', - IS_VISIBLE: 'is-visible', - IS_ANIMATING: 'is-animating', - // Alignment options - BOTTOM_LEFT: 'mdl-menu--bottom-left', - // This is the default. - BOTTOM_RIGHT: 'mdl-menu--bottom-right', - TOP_LEFT: 'mdl-menu--top-left', - TOP_RIGHT: 'mdl-menu--top-right', - UNALIGNED: 'mdl-menu--unaligned' -}; -/** - * Initialize element. - */ -MaterialMenu.prototype.init = function () { - if (this.element_) { - // Create container for the menu. - var container = document.createElement('div'); - container.classList.add(this.CssClasses_.CONTAINER); - this.element_.parentElement.insertBefore(container, this.element_); - this.element_.parentElement.removeChild(this.element_); - container.appendChild(this.element_); - this.container_ = container; - // Create outline for the menu (shadow and background). - var outline = document.createElement('div'); - outline.classList.add(this.CssClasses_.OUTLINE); - this.outline_ = outline; - container.insertBefore(outline, this.element_); - // Find the "for" element and bind events to it. - var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for'); - var forEl = null; - if (forElId) { - forEl = document.getElementById(forElId); - if (forEl) { - this.forElement_ = forEl; - forEl.addEventListener('click', this.handleForClick_.bind(this)); - forEl.addEventListener('keydown', this.handleForKeyboardEvent_.bind(this)); - } - } - var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); - this.boundItemKeydown_ = this.handleItemKeyboardEvent_.bind(this); - this.boundItemClick_ = this.handleItemClick_.bind(this); - for (var i = 0; i < items.length; i++) { - // Add a listener to each menu item. - items[i].addEventListener('click', this.boundItemClick_); - // Add a tab index to each menu item. - items[i].tabIndex = '-1'; - // Add a keyboard listener to each menu item. - items[i].addEventListener('keydown', this.boundItemKeydown_); - } - // Add ripple classes to each item, if the user has enabled ripples. - if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - for (i = 0; i < items.length; i++) { - var item = items[i]; - var rippleContainer = document.createElement('span'); - rippleContainer.classList.add(this.CssClasses_.ITEM_RIPPLE_CONTAINER); - var ripple = document.createElement('span'); - ripple.classList.add(this.CssClasses_.RIPPLE); - rippleContainer.appendChild(ripple); - item.appendChild(rippleContainer); - item.classList.add(this.CssClasses_.RIPPLE_EFFECT); - } - } - // Copy alignment classes to the container, so the outline can use them. - if (this.element_.classList.contains(this.CssClasses_.BOTTOM_LEFT)) { - this.outline_.classList.add(this.CssClasses_.BOTTOM_LEFT); - } - if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { - this.outline_.classList.add(this.CssClasses_.BOTTOM_RIGHT); - } - if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { - this.outline_.classList.add(this.CssClasses_.TOP_LEFT); - } - if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { - this.outline_.classList.add(this.CssClasses_.TOP_RIGHT); - } - if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { - this.outline_.classList.add(this.CssClasses_.UNALIGNED); - } - container.classList.add(this.CssClasses_.IS_UPGRADED); - } -}; -/** - * Handles a click on the "for" element, by positioning the menu and then - * toggling it. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialMenu.prototype.handleForClick_ = function (evt) { - if (this.element_ && this.forElement_) { - var rect = this.forElement_.getBoundingClientRect(); - var forRect = this.forElement_.parentElement.getBoundingClientRect(); - if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { - } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { - // Position below the "for" element, aligned to its right. - this.container_.style.right = forRect.right - rect.right + 'px'; - this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px'; - } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { - // Position above the "for" element, aligned to its left. - this.container_.style.left = this.forElement_.offsetLeft + 'px'; - this.container_.style.bottom = forRect.bottom - rect.top + 'px'; - } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { - // Position above the "for" element, aligned to its right. - this.container_.style.right = forRect.right - rect.right + 'px'; - this.container_.style.bottom = forRect.bottom - rect.top + 'px'; - } else { - // Default: position below the "for" element, aligned to its left. - this.container_.style.left = this.forElement_.offsetLeft + 'px'; - this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px'; - } - } - this.toggle(evt); -}; -/** - * Handles a keyboard event on the "for" element. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialMenu.prototype.handleForKeyboardEvent_ = function (evt) { - if (this.element_ && this.container_ && this.forElement_) { - var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])'); - if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { - if (evt.keyCode === this.Keycodes_.UP_ARROW) { - evt.preventDefault(); - items[items.length - 1].focus(); - } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) { - evt.preventDefault(); - items[0].focus(); - } - } - } -}; -/** - * Handles a keyboard event on an item. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialMenu.prototype.handleItemKeyboardEvent_ = function (evt) { - if (this.element_ && this.container_) { - var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])'); - if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { - var currentIndex = Array.prototype.slice.call(items).indexOf(evt.target); - if (evt.keyCode === this.Keycodes_.UP_ARROW) { - evt.preventDefault(); - if (currentIndex > 0) { - items[currentIndex - 1].focus(); - } else { - items[items.length - 1].focus(); - } - } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) { - evt.preventDefault(); - if (items.length > currentIndex + 1) { - items[currentIndex + 1].focus(); - } else { - items[0].focus(); - } - } else if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) { - evt.preventDefault(); - // Send mousedown and mouseup to trigger ripple. - var e = new MouseEvent('mousedown'); - evt.target.dispatchEvent(e); - e = new MouseEvent('mouseup'); - evt.target.dispatchEvent(e); - // Send click. - evt.target.click(); - } else if (evt.keyCode === this.Keycodes_.ESCAPE) { - evt.preventDefault(); - this.hide(); - } - } - } -}; -/** - * Handles a click event on an item. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialMenu.prototype.handleItemClick_ = function (evt) { - if (evt.target.hasAttribute('disabled')) { - evt.stopPropagation(); - } else { - // Wait some time before closing menu, so the user can see the ripple. - this.closing_ = true; - window.setTimeout(function (evt) { - this.hide(); - this.closing_ = false; - }.bind(this), this.Constant_.CLOSE_TIMEOUT); - } -}; -/** - * Calculates the initial clip (for opening the menu) or final clip (for closing - * it), and applies it. This allows us to animate from or to the correct point, - * that is, the point it's aligned to in the "for" element. - * - * @param {number} height Height of the clip rectangle - * @param {number} width Width of the clip rectangle - * @private - */ -MaterialMenu.prototype.applyClip_ = function (height, width) { - if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) { - // Do not clip. - this.element_.style.clip = ''; - } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) { - // Clip to the top right corner of the menu. - this.element_.style.clip = 'rect(0 ' + width + 'px ' + '0 ' + width + 'px)'; - } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) { - // Clip to the bottom left corner of the menu. - this.element_.style.clip = 'rect(' + height + 'px 0 ' + height + 'px 0)'; - } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { - // Clip to the bottom right corner of the menu. - this.element_.style.clip = 'rect(' + height + 'px ' + width + 'px ' + height + 'px ' + width + 'px)'; - } else { - // Default: do not clip (same as clipping to the top left corner). - this.element_.style.clip = ''; - } -}; -/** - * Cleanup function to remove animation listeners. - * - * @param {Event} evt - * @private - */ -MaterialMenu.prototype.removeAnimationEndListener_ = function (evt) { - evt.target.classList.remove(MaterialMenu.prototype.CssClasses_.IS_ANIMATING); -}; -/** - * Adds an event listener to clean up after the animation ends. - * - * @private - */ -MaterialMenu.prototype.addAnimationEndListener_ = function () { - this.element_.addEventListener('transitionend', this.removeAnimationEndListener_); - this.element_.addEventListener('webkitTransitionEnd', this.removeAnimationEndListener_); -}; -/** - * Displays the menu. - * - * @public - */ -MaterialMenu.prototype.show = function (evt) { - if (this.element_ && this.container_ && this.outline_) { - // Measure the inner element. - var height = this.element_.getBoundingClientRect().height; - var width = this.element_.getBoundingClientRect().width; - // Apply the inner element's size to the container and outline. - this.container_.style.width = width + 'px'; - this.container_.style.height = height + 'px'; - this.outline_.style.width = width + 'px'; - this.outline_.style.height = height + 'px'; - var transitionDuration = this.Constant_.TRANSITION_DURATION_SECONDS * this.Constant_.TRANSITION_DURATION_FRACTION; - // Calculate transition delays for individual menu items, so that they fade - // in one at a time. - var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); - for (var i = 0; i < items.length; i++) { - var itemDelay = null; - if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT) || this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) { - itemDelay = (height - items[i].offsetTop - items[i].offsetHeight) / height * transitionDuration + 's'; - } else { - itemDelay = items[i].offsetTop / height * transitionDuration + 's'; - } - items[i].style.transitionDelay = itemDelay; - } - // Apply the initial clip to the text before we start animating. - this.applyClip_(height, width); - // Wait for the next frame, turn on animation, and apply the final clip. - // Also make it visible. This triggers the transitions. - window.requestAnimationFrame(function () { - this.element_.classList.add(this.CssClasses_.IS_ANIMATING); - this.element_.style.clip = 'rect(0 ' + width + 'px ' + height + 'px 0)'; - this.container_.classList.add(this.CssClasses_.IS_VISIBLE); - }.bind(this)); - // Clean up after the animation is complete. - this.addAnimationEndListener_(); - // Add a click listener to the document, to close the menu. - var callback = function (e) { - // Check to see if the document is processing the same event that - // displayed the menu in the first place. If so, do nothing. - // Also check to see if the menu is in the process of closing itself, and - // do nothing in that case. - // Also check if the clicked element is a menu item - // if so, do nothing. - if (e !== evt && !this.closing_ && e.target.parentNode !== this.element_) { - document.removeEventListener('click', callback); - this.hide(); - } - }.bind(this); - document.addEventListener('click', callback); - } -}; -MaterialMenu.prototype['show'] = MaterialMenu.prototype.show; -/** - * Hides the menu. - * - * @public - */ -MaterialMenu.prototype.hide = function () { - if (this.element_ && this.container_ && this.outline_) { - var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM); - // Remove all transition delays; menu items fade out concurrently. - for (var i = 0; i < items.length; i++) { - items[i].style.removeProperty('transition-delay'); - } - // Measure the inner element. - var rect = this.element_.getBoundingClientRect(); - var height = rect.height; - var width = rect.width; - // Turn on animation, and apply the final clip. Also make invisible. - // This triggers the transitions. - this.element_.classList.add(this.CssClasses_.IS_ANIMATING); - this.applyClip_(height, width); - this.container_.classList.remove(this.CssClasses_.IS_VISIBLE); - // Clean up after the animation is complete. - this.addAnimationEndListener_(); - } -}; -MaterialMenu.prototype['hide'] = MaterialMenu.prototype.hide; -/** - * Displays or hides the menu, depending on current state. - * - * @public - */ -MaterialMenu.prototype.toggle = function (evt) { - if (this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) { - this.hide(); - } else { - this.show(evt); - } -}; -MaterialMenu.prototype['toggle'] = MaterialMenu.prototype.toggle; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialMenu, - classAsString: 'MaterialMenu', - cssClass: 'mdl-js-menu', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Progress MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialProgress = function MaterialProgress(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialProgress'] = MaterialProgress; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialProgress.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialProgress.prototype.CssClasses_ = { INDETERMINATE_CLASS: 'mdl-progress__indeterminate' }; -/** - * Set the current progress of the progressbar. - * - * @param {number} p Percentage of the progress (0-100) - * @public - */ -MaterialProgress.prototype.setProgress = function (p) { - if (this.element_.classList.contains(this.CssClasses_.INDETERMINATE_CLASS)) { - return; - } - this.progressbar_.style.width = p + '%'; -}; -MaterialProgress.prototype['setProgress'] = MaterialProgress.prototype.setProgress; -/** - * Set the current progress of the buffer. - * - * @param {number} p Percentage of the buffer (0-100) - * @public - */ -MaterialProgress.prototype.setBuffer = function (p) { - this.bufferbar_.style.width = p + '%'; - this.auxbar_.style.width = 100 - p + '%'; -}; -MaterialProgress.prototype['setBuffer'] = MaterialProgress.prototype.setBuffer; -/** - * Initialize element. - */ -MaterialProgress.prototype.init = function () { - if (this.element_) { - var el = document.createElement('div'); - el.className = 'progressbar bar bar1'; - this.element_.appendChild(el); - this.progressbar_ = el; - el = document.createElement('div'); - el.className = 'bufferbar bar bar2'; - this.element_.appendChild(el); - this.bufferbar_ = el; - el = document.createElement('div'); - el.className = 'auxbar bar bar3'; - this.element_.appendChild(el); - this.auxbar_ = el; - this.progressbar_.style.width = '0%'; - this.bufferbar_.style.width = '100%'; - this.auxbar_.style.width = '0%'; - this.element_.classList.add('is-upgraded'); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialProgress, - classAsString: 'MaterialProgress', - cssClass: 'mdl-js-progress', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Radio MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialRadio = function MaterialRadio(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialRadio'] = MaterialRadio; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialRadio.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialRadio.prototype.CssClasses_ = { - IS_FOCUSED: 'is-focused', - IS_DISABLED: 'is-disabled', - IS_CHECKED: 'is-checked', - IS_UPGRADED: 'is-upgraded', - JS_RADIO: 'mdl-js-radio', - RADIO_BTN: 'mdl-radio__button', - RADIO_OUTER_CIRCLE: 'mdl-radio__outer-circle', - RADIO_INNER_CIRCLE: 'mdl-radio__inner-circle', - RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - RIPPLE_CONTAINER: 'mdl-radio__ripple-container', - RIPPLE_CENTER: 'mdl-ripple--center', - RIPPLE: 'mdl-ripple' -}; -/** - * Handle change of state. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRadio.prototype.onChange_ = function (event) { - // Since other radio buttons don't get change events, we need to look for - // them to update their classes. - var radios = document.getElementsByClassName(this.CssClasses_.JS_RADIO); - for (var i = 0; i < radios.length; i++) { - var button = radios[i].querySelector('.' + this.CssClasses_.RADIO_BTN); - // Different name == different group, so no point updating those. - if (button.getAttribute('name') === this.btnElement_.getAttribute('name')) { - if (typeof radios[i]['MaterialRadio'] !== 'undefined') { - radios[i]['MaterialRadio'].updateClasses_(); - } - } - } -}; -/** - * Handle focus. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRadio.prototype.onFocus_ = function (event) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle lost focus. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRadio.prototype.onBlur_ = function (event) { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle mouseup. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRadio.prototype.onMouseup_ = function (event) { - this.blur_(); -}; -/** - * Update classes. - * - * @private - */ -MaterialRadio.prototype.updateClasses_ = function () { - this.checkDisabled(); - this.checkToggleState(); -}; -/** - * Add blur. - * - * @private - */ -MaterialRadio.prototype.blur_ = function () { - // TODO: figure out why there's a focus event being fired after our blur, - // so that we can avoid this hack. - window.setTimeout(function () { - this.btnElement_.blur(); - }.bind(this), this.Constant_.TINY_TIMEOUT); -}; -// Public methods. -/** - * Check the components disabled state. - * - * @public - */ -MaterialRadio.prototype.checkDisabled = function () { - if (this.btnElement_.disabled) { - this.element_.classList.add(this.CssClasses_.IS_DISABLED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DISABLED); - } -}; -MaterialRadio.prototype['checkDisabled'] = MaterialRadio.prototype.checkDisabled; -/** - * Check the components toggled state. - * - * @public - */ -MaterialRadio.prototype.checkToggleState = function () { - if (this.btnElement_.checked) { - this.element_.classList.add(this.CssClasses_.IS_CHECKED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_CHECKED); - } -}; -MaterialRadio.prototype['checkToggleState'] = MaterialRadio.prototype.checkToggleState; -/** - * Disable radio. - * - * @public - */ -MaterialRadio.prototype.disable = function () { - this.btnElement_.disabled = true; - this.updateClasses_(); -}; -MaterialRadio.prototype['disable'] = MaterialRadio.prototype.disable; -/** - * Enable radio. - * - * @public - */ -MaterialRadio.prototype.enable = function () { - this.btnElement_.disabled = false; - this.updateClasses_(); -}; -MaterialRadio.prototype['enable'] = MaterialRadio.prototype.enable; -/** - * Check radio. - * - * @public - */ -MaterialRadio.prototype.check = function () { - this.btnElement_.checked = true; - this.onChange_(null); -}; -MaterialRadio.prototype['check'] = MaterialRadio.prototype.check; -/** - * Uncheck radio. - * - * @public - */ -MaterialRadio.prototype.uncheck = function () { - this.btnElement_.checked = false; - this.onChange_(null); -}; -MaterialRadio.prototype['uncheck'] = MaterialRadio.prototype.uncheck; -/** - * Initialize element. - */ -MaterialRadio.prototype.init = function () { - if (this.element_) { - this.btnElement_ = this.element_.querySelector('.' + this.CssClasses_.RADIO_BTN); - this.boundChangeHandler_ = this.onChange_.bind(this); - this.boundFocusHandler_ = this.onChange_.bind(this); - this.boundBlurHandler_ = this.onBlur_.bind(this); - this.boundMouseUpHandler_ = this.onMouseup_.bind(this); - var outerCircle = document.createElement('span'); - outerCircle.classList.add(this.CssClasses_.RADIO_OUTER_CIRCLE); - var innerCircle = document.createElement('span'); - innerCircle.classList.add(this.CssClasses_.RADIO_INNER_CIRCLE); - this.element_.appendChild(outerCircle); - this.element_.appendChild(innerCircle); - var rippleContainer; - if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - rippleContainer = document.createElement('span'); - rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER); - rippleContainer.classList.add(this.CssClasses_.RIPPLE_EFFECT); - rippleContainer.classList.add(this.CssClasses_.RIPPLE_CENTER); - rippleContainer.addEventListener('mouseup', this.boundMouseUpHandler_); - var ripple = document.createElement('span'); - ripple.classList.add(this.CssClasses_.RIPPLE); - rippleContainer.appendChild(ripple); - this.element_.appendChild(rippleContainer); - } - this.btnElement_.addEventListener('change', this.boundChangeHandler_); - this.btnElement_.addEventListener('focus', this.boundFocusHandler_); - this.btnElement_.addEventListener('blur', this.boundBlurHandler_); - this.element_.addEventListener('mouseup', this.boundMouseUpHandler_); - this.updateClasses_(); - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialRadio, - classAsString: 'MaterialRadio', - cssClass: 'mdl-js-radio', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Slider MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialSlider = function MaterialSlider(element) { - this.element_ = element; - // Browser feature detection. - this.isIE_ = window.navigator.msPointerEnabled; - // Initialize instance. - this.init(); -}; -window['MaterialSlider'] = MaterialSlider; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialSlider.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialSlider.prototype.CssClasses_ = { - IE_CONTAINER: 'mdl-slider__ie-container', - SLIDER_CONTAINER: 'mdl-slider__container', - BACKGROUND_FLEX: 'mdl-slider__background-flex', - BACKGROUND_LOWER: 'mdl-slider__background-lower', - BACKGROUND_UPPER: 'mdl-slider__background-upper', - IS_LOWEST_VALUE: 'is-lowest-value', - IS_UPGRADED: 'is-upgraded' -}; -/** - * Handle input on element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSlider.prototype.onInput_ = function (event) { - this.updateValueStyles_(); -}; -/** - * Handle change on element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSlider.prototype.onChange_ = function (event) { - this.updateValueStyles_(); -}; -/** - * Handle mouseup on element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSlider.prototype.onMouseUp_ = function (event) { - event.target.blur(); -}; -/** - * Handle mousedown on container element. - * This handler is purpose is to not require the use to click - * exactly on the 2px slider element, as FireFox seems to be very - * strict about this. - * - * @param {Event} event The event that fired. - * @private - * @suppress {missingProperties} - */ -MaterialSlider.prototype.onContainerMouseDown_ = function (event) { - // If this click is not on the parent element (but rather some child) - // ignore. It may still bubble up. - if (event.target !== this.element_.parentElement) { - return; - } - // Discard the original event and create a new event that - // is on the slider element. - event.preventDefault(); - var newEvent = new MouseEvent('mousedown', { - target: event.target, - buttons: event.buttons, - clientX: event.clientX, - clientY: this.element_.getBoundingClientRect().y - }); - this.element_.dispatchEvent(newEvent); -}; -/** - * Handle updating of values. - * - * @private - */ -MaterialSlider.prototype.updateValueStyles_ = function () { - // Calculate and apply percentages to div structure behind slider. - var fraction = (this.element_.value - this.element_.min) / (this.element_.max - this.element_.min); - if (fraction === 0) { - this.element_.classList.add(this.CssClasses_.IS_LOWEST_VALUE); - } else { - this.element_.classList.remove(this.CssClasses_.IS_LOWEST_VALUE); - } - if (!this.isIE_) { - this.backgroundLower_.style.flex = fraction; - this.backgroundLower_.style.webkitFlex = fraction; - this.backgroundUpper_.style.flex = 1 - fraction; - this.backgroundUpper_.style.webkitFlex = 1 - fraction; - } -}; -// Public methods. -/** - * Disable slider. - * - * @public - */ -MaterialSlider.prototype.disable = function () { - this.element_.disabled = true; -}; -MaterialSlider.prototype['disable'] = MaterialSlider.prototype.disable; -/** - * Enable slider. - * - * @public - */ -MaterialSlider.prototype.enable = function () { - this.element_.disabled = false; -}; -MaterialSlider.prototype['enable'] = MaterialSlider.prototype.enable; -/** - * Update slider value. - * - * @param {number} value The value to which to set the control (optional). - * @public - */ -MaterialSlider.prototype.change = function (value) { - if (typeof value !== 'undefined') { - this.element_.value = value; - } - this.updateValueStyles_(); -}; -MaterialSlider.prototype['change'] = MaterialSlider.prototype.change; -/** - * Initialize element. - */ -MaterialSlider.prototype.init = function () { - if (this.element_) { - if (this.isIE_) { - // Since we need to specify a very large height in IE due to - // implementation limitations, we add a parent here that trims it down to - // a reasonable size. - var containerIE = document.createElement('div'); - containerIE.classList.add(this.CssClasses_.IE_CONTAINER); - this.element_.parentElement.insertBefore(containerIE, this.element_); - this.element_.parentElement.removeChild(this.element_); - containerIE.appendChild(this.element_); - } else { - // For non-IE browsers, we need a div structure that sits behind the - // slider and allows us to style the left and right sides of it with - // different colors. - var container = document.createElement('div'); - container.classList.add(this.CssClasses_.SLIDER_CONTAINER); - this.element_.parentElement.insertBefore(container, this.element_); - this.element_.parentElement.removeChild(this.element_); - container.appendChild(this.element_); - var backgroundFlex = document.createElement('div'); - backgroundFlex.classList.add(this.CssClasses_.BACKGROUND_FLEX); - container.appendChild(backgroundFlex); - this.backgroundLower_ = document.createElement('div'); - this.backgroundLower_.classList.add(this.CssClasses_.BACKGROUND_LOWER); - backgroundFlex.appendChild(this.backgroundLower_); - this.backgroundUpper_ = document.createElement('div'); - this.backgroundUpper_.classList.add(this.CssClasses_.BACKGROUND_UPPER); - backgroundFlex.appendChild(this.backgroundUpper_); - } - this.boundInputHandler = this.onInput_.bind(this); - this.boundChangeHandler = this.onChange_.bind(this); - this.boundMouseUpHandler = this.onMouseUp_.bind(this); - this.boundContainerMouseDownHandler = this.onContainerMouseDown_.bind(this); - this.element_.addEventListener('input', this.boundInputHandler); - this.element_.addEventListener('change', this.boundChangeHandler); - this.element_.addEventListener('mouseup', this.boundMouseUpHandler); - this.element_.parentElement.addEventListener('mousedown', this.boundContainerMouseDownHandler); - this.updateValueStyles_(); - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialSlider, - classAsString: 'MaterialSlider', - cssClass: 'mdl-js-slider', - widget: true -}); -/** - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Snackbar MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialSnackbar = function MaterialSnackbar(element) { - this.element_ = element; - this.textElement_ = this.element_.querySelector('.' + this.cssClasses_.MESSAGE); - this.actionElement_ = this.element_.querySelector('.' + this.cssClasses_.ACTION); - if (!this.textElement_) { - throw new Error('There must be a message element for a snackbar.'); - } - if (!this.actionElement_) { - throw new Error('There must be an action element for a snackbar.'); - } - this.active = false; - this.actionHandler_ = undefined; - this.message_ = undefined; - this.actionText_ = undefined; - this.queuedNotifications_ = []; - this.setActionHidden_(true); -}; -window['MaterialSnackbar'] = MaterialSnackbar; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialSnackbar.prototype.Constant_ = { - // The duration of the snackbar show/hide animation, in ms. - ANIMATION_LENGTH: 250 -}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialSnackbar.prototype.cssClasses_ = { - SNACKBAR: 'mdl-snackbar', - MESSAGE: 'mdl-snackbar__text', - ACTION: 'mdl-snackbar__action', - ACTIVE: 'mdl-snackbar--active' -}; -/** - * Display the snackbar. - * - * @private - */ -MaterialSnackbar.prototype.displaySnackbar_ = function () { - this.element_.setAttribute('aria-hidden', 'true'); - if (this.actionHandler_) { - this.actionElement_.textContent = this.actionText_; - this.actionElement_.addEventListener('click', this.actionHandler_); - this.setActionHidden_(false); - } - 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_); -}; -/** - * Show the snackbar. - * - * @param {Object} data The data for the notification. - * @public - */ -MaterialSnackbar.prototype.showSnackbar = function (data) { - if (data === undefined) { - throw new Error('Please provide a data object with at least a message to display.'); - } - if (data['message'] === undefined) { - throw new Error('Please provide a message to be displayed.'); - } - if (data['actionHandler'] && !data['actionText']) { - throw new Error('Please provide action text with the handler.'); - } - if (this.active) { - this.queuedNotifications_.push(data); - } else { - this.active = true; - this.message_ = data['message']; - if (data['timeout']) { - this.timeout_ = data['timeout']; - } else { - this.timeout_ = 2750; - } - if (data['actionHandler']) { - this.actionHandler_ = data['actionHandler']; - } - if (data['actionText']) { - this.actionText_ = data['actionText']; - } - this.displaySnackbar_(); - } -}; -MaterialSnackbar.prototype['showSnackbar'] = MaterialSnackbar.prototype.showSnackbar; -/** - * Check if the queue has items within it. - * If it does, display the next entry. - * - * @private - */ -MaterialSnackbar.prototype.checkQueue_ = function () { - if (this.queuedNotifications_.length > 0) { - this.showSnackbar(this.queuedNotifications_.shift()); - } -}; -/** - * Cleanup the snackbar event listeners and accessiblity attributes. - * - * @private - */ -MaterialSnackbar.prototype.cleanup_ = function () { - this.element_.classList.remove(this.cssClasses_.ACTIVE); - setTimeout(function () { - this.element_.setAttribute('aria-hidden', 'true'); - this.textElement_.textContent = ''; - if (!Boolean(this.actionElement_.getAttribute('aria-hidden'))) { - this.setActionHidden_(true); - this.actionElement_.textContent = ''; - this.actionElement_.removeEventListener('click', this.actionHandler_); - } - this.actionHandler_ = undefined; - this.message_ = undefined; - this.actionText_ = undefined; - this.active = false; - this.checkQueue_(); - }.bind(this), this.Constant_.ANIMATION_LENGTH); -}; -/** - * Set the action handler hidden state. - * - * @param {boolean} value - * @private - */ -MaterialSnackbar.prototype.setActionHidden_ = function (value) { - if (value) { - this.actionElement_.setAttribute('aria-hidden', 'true'); - } else { - this.actionElement_.removeAttribute('aria-hidden'); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialSnackbar, - classAsString: 'MaterialSnackbar', - cssClass: 'mdl-js-snackbar', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Spinner MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @param {HTMLElement} element The element that will be upgraded. - * @constructor - */ -var MaterialSpinner = function MaterialSpinner(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialSpinner'] = MaterialSpinner; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialSpinner.prototype.Constant_ = { MDL_SPINNER_LAYER_COUNT: 4 }; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialSpinner.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' -}; -/** - * Auxiliary method to create a spinner layer. - * - * @param {number} index Index of the layer to be created. - * @public - */ -MaterialSpinner.prototype.createLayer = function (index) { - var layer = document.createElement('div'); - layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER); - layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER + '-' + index); - var leftClipper = document.createElement('div'); - leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER); - leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_LEFT); - var gapPatch = document.createElement('div'); - gapPatch.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH); - var rightClipper = document.createElement('div'); - rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER); - rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT); - var circleOwners = [ - leftClipper, - gapPatch, - rightClipper - ]; - for (var i = 0; i < circleOwners.length; i++) { - var circle = document.createElement('div'); - circle.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE); - circleOwners[i].appendChild(circle); - } - layer.appendChild(leftClipper); - layer.appendChild(gapPatch); - layer.appendChild(rightClipper); - this.element_.appendChild(layer); -}; -MaterialSpinner.prototype['createLayer'] = MaterialSpinner.prototype.createLayer; -/** - * Stops the spinner animation. - * Public method for users who need to stop the spinner for any reason. - * - * @public - */ -MaterialSpinner.prototype.stop = function () { - this.element_.classList.remove('is-active'); -}; -MaterialSpinner.prototype['stop'] = MaterialSpinner.prototype.stop; -/** - * Starts the spinner animation. - * Public method for users who need to manually start the spinner for any reason - * (instead of just adding the 'is-active' class to their markup). - * - * @public - */ -MaterialSpinner.prototype.start = function () { - this.element_.classList.add('is-active'); -}; -MaterialSpinner.prototype['start'] = MaterialSpinner.prototype.start; -/** - * Initialize element. - */ -MaterialSpinner.prototype.init = function () { - if (this.element_) { - for (var i = 1; i <= this.Constant_.MDL_SPINNER_LAYER_COUNT; i++) { - this.createLayer(i); - } - this.element_.classList.add('is-upgraded'); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialSpinner, - classAsString: 'MaterialSpinner', - cssClass: 'mdl-js-spinner', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Checkbox MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialSwitch = function MaterialSwitch(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialSwitch'] = MaterialSwitch; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialSwitch.prototype.Constant_ = { TINY_TIMEOUT: 0.001 }; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialSwitch.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' -}; -/** - * Handle change of state. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSwitch.prototype.onChange_ = function (event) { - this.updateClasses_(); -}; -/** - * Handle focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSwitch.prototype.onFocus_ = function (event) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle lost focus of element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSwitch.prototype.onBlur_ = function (event) { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle mouseup. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialSwitch.prototype.onMouseUp_ = function (event) { - this.blur_(); -}; -/** - * Handle class updates. - * - * @private - */ -MaterialSwitch.prototype.updateClasses_ = function () { - this.checkDisabled(); - this.checkToggleState(); -}; -/** - * Add blur. - * - * @private - */ -MaterialSwitch.prototype.blur_ = function () { - // TODO: figure out why there's a focus event being fired after our blur, - // so that we can avoid this hack. - window.setTimeout(function () { - this.inputElement_.blur(); - }.bind(this), this.Constant_.TINY_TIMEOUT); -}; -// Public methods. -/** - * Check the components disabled state. - * - * @public - */ -MaterialSwitch.prototype.checkDisabled = function () { - if (this.inputElement_.disabled) { - this.element_.classList.add(this.CssClasses_.IS_DISABLED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DISABLED); - } -}; -MaterialSwitch.prototype['checkDisabled'] = MaterialSwitch.prototype.checkDisabled; -/** - * Check the components toggled state. - * - * @public - */ -MaterialSwitch.prototype.checkToggleState = function () { - if (this.inputElement_.checked) { - this.element_.classList.add(this.CssClasses_.IS_CHECKED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_CHECKED); - } -}; -MaterialSwitch.prototype['checkToggleState'] = MaterialSwitch.prototype.checkToggleState; -/** - * Disable switch. - * - * @public - */ -MaterialSwitch.prototype.disable = function () { - this.inputElement_.disabled = true; - this.updateClasses_(); -}; -MaterialSwitch.prototype['disable'] = MaterialSwitch.prototype.disable; -/** - * Enable switch. - * - * @public - */ -MaterialSwitch.prototype.enable = function () { - this.inputElement_.disabled = false; - this.updateClasses_(); -}; -MaterialSwitch.prototype['enable'] = MaterialSwitch.prototype.enable; -/** - * Activate switch. - * - * @public - */ -MaterialSwitch.prototype.on = function () { - this.inputElement_.checked = true; - this.updateClasses_(); -}; -MaterialSwitch.prototype['on'] = MaterialSwitch.prototype.on; -/** - * Deactivate switch. - * - * @public - */ -MaterialSwitch.prototype.off = function () { - this.inputElement_.checked = false; - this.updateClasses_(); -}; -MaterialSwitch.prototype['off'] = MaterialSwitch.prototype.off; -/** - * Initialize element. - */ -MaterialSwitch.prototype.init = function () { - if (this.element_) { - this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); - var track = document.createElement('div'); - track.classList.add(this.CssClasses_.TRACK); - var thumb = document.createElement('div'); - thumb.classList.add(this.CssClasses_.THUMB); - var focusHelper = document.createElement('span'); - focusHelper.classList.add(this.CssClasses_.FOCUS_HELPER); - thumb.appendChild(focusHelper); - this.element_.appendChild(track); - this.element_.appendChild(thumb); - this.boundMouseUpHandler = this.onMouseUp_.bind(this); - if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - this.rippleContainerElement_ = document.createElement('span'); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT); - this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER); - this.rippleContainerElement_.addEventListener('mouseup', this.boundMouseUpHandler); - var ripple = document.createElement('span'); - ripple.classList.add(this.CssClasses_.RIPPLE); - this.rippleContainerElement_.appendChild(ripple); - this.element_.appendChild(this.rippleContainerElement_); - } - this.boundChangeHandler = this.onChange_.bind(this); - this.boundFocusHandler = this.onFocus_.bind(this); - this.boundBlurHandler = this.onBlur_.bind(this); - this.inputElement_.addEventListener('change', this.boundChangeHandler); - this.inputElement_.addEventListener('focus', this.boundFocusHandler); - this.inputElement_.addEventListener('blur', this.boundBlurHandler); - this.element_.addEventListener('mouseup', this.boundMouseUpHandler); - this.updateClasses_(); - this.element_.classList.add('is-upgraded'); - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialSwitch, - classAsString: 'MaterialSwitch', - cssClass: 'mdl-js-switch', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Tabs MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {Element} element The element that will be upgraded. - */ -var MaterialTabs = function MaterialTabs(element) { - // Stores the HTML element. - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialTabs'] = MaterialTabs; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string} - * @private - */ -MaterialTabs.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialTabs.prototype.CssClasses_ = { - TAB_CLASS: 'mdl-tabs__tab', - PANEL_CLASS: 'mdl-tabs__panel', - ACTIVE_CLASS: 'is-active', - UPGRADED_CLASS: 'is-upgraded', - MDL_JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', - MDL_RIPPLE_CONTAINER: 'mdl-tabs__ripple-container', - MDL_RIPPLE: 'mdl-ripple', - MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events' -}; -/** - * Handle clicks to a tabs component - * - * @private - */ -MaterialTabs.prototype.initTabs_ = function () { - if (this.element_.classList.contains(this.CssClasses_.MDL_JS_RIPPLE_EFFECT)) { - this.element_.classList.add(this.CssClasses_.MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS); - } - // Select element tabs, document panels - this.tabs_ = this.element_.querySelectorAll('.' + this.CssClasses_.TAB_CLASS); - this.panels_ = this.element_.querySelectorAll('.' + this.CssClasses_.PANEL_CLASS); - // Create new tabs for each tab element - for (var i = 0; i < this.tabs_.length; i++) { - new MaterialTab(this.tabs_[i], this); - } - this.element_.classList.add(this.CssClasses_.UPGRADED_CLASS); -}; -/** - * Reset tab state, dropping active classes - * - * @private - */ -MaterialTabs.prototype.resetTabState_ = function () { - for (var k = 0; k < this.tabs_.length; k++) { - this.tabs_[k].classList.remove(this.CssClasses_.ACTIVE_CLASS); - } -}; -/** - * Reset panel state, droping active classes - * - * @private - */ -MaterialTabs.prototype.resetPanelState_ = function () { - for (var j = 0; j < this.panels_.length; j++) { - this.panels_[j].classList.remove(this.CssClasses_.ACTIVE_CLASS); - } -}; -/** - * Initialize element. - */ -MaterialTabs.prototype.init = function () { - if (this.element_) { - this.initTabs_(); - } -}; -/** - * Constructor for an individual tab. - * - * @constructor - * @param {Element} tab The HTML element for the tab. - * @param {MaterialTabs} ctx The MaterialTabs object that owns the tab. - */ -function MaterialTab(tab, ctx) { - if (tab) { - if (ctx.element_.classList.contains(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT)) { - var rippleContainer = document.createElement('span'); - rippleContainer.classList.add(ctx.CssClasses_.MDL_RIPPLE_CONTAINER); - rippleContainer.classList.add(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT); - var ripple = document.createElement('span'); - ripple.classList.add(ctx.CssClasses_.MDL_RIPPLE); - rippleContainer.appendChild(ripple); - tab.appendChild(rippleContainer); - } - tab.addEventListener('click', function (e) { - if (tab.getAttribute('href').charAt(0) === '#') { - e.preventDefault(); - var href = tab.href.split('#')[1]; - var panel = ctx.element_.querySelector('#' + href); - ctx.resetTabState_(); - ctx.resetPanelState_(); - tab.classList.add(ctx.CssClasses_.ACTIVE_CLASS); - panel.classList.add(ctx.CssClasses_.ACTIVE_CLASS); - } - }); - } -} -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialTabs, - classAsString: 'MaterialTabs', - cssClass: 'mdl-js-tabs' -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Textfield MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialTextfield = function MaterialTextfield(element) { - this.element_ = element; - this.maxRows = this.Constant_.NO_MAX_ROWS; - // Initialize instance. - this.init(); -}; -window['MaterialTextfield'] = MaterialTextfield; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialTextfield.prototype.Constant_ = { - NO_MAX_ROWS: -1, - MAX_ROWS_ATTRIBUTE: 'maxrows' -}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialTextfield.prototype.CssClasses_ = { - LABEL: 'mdl-textfield__label', - INPUT: 'mdl-textfield__input', - IS_DIRTY: 'is-dirty', - IS_FOCUSED: 'is-focused', - IS_DISABLED: 'is-disabled', - IS_INVALID: 'is-invalid', - IS_UPGRADED: 'is-upgraded', - HAS_PLACEHOLDER: 'has-placeholder' -}; -/** - * Handle input being entered. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialTextfield.prototype.onKeyDown_ = function (event) { - var currentRowCount = event.target.value.split('\n').length; - if (event.keyCode === 13) { - if (currentRowCount >= this.maxRows) { - event.preventDefault(); - } - } -}; -/** - * Handle focus. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialTextfield.prototype.onFocus_ = function (event) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle lost focus. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialTextfield.prototype.onBlur_ = function (event) { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); -}; -/** - * Handle reset event from out side. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialTextfield.prototype.onReset_ = function (event) { - this.updateClasses_(); -}; -/** - * Handle class updates. - * - * @private - */ -MaterialTextfield.prototype.updateClasses_ = function () { - this.checkDisabled(); - this.checkValidity(); - this.checkDirty(); - this.checkFocus(); -}; -// Public methods. -/** - * Check the disabled state and update field accordingly. - * - * @public - */ -MaterialTextfield.prototype.checkDisabled = function () { - if (this.input_.disabled) { - this.element_.classList.add(this.CssClasses_.IS_DISABLED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DISABLED); - } -}; -MaterialTextfield.prototype['checkDisabled'] = MaterialTextfield.prototype.checkDisabled; -/** - * Check the focus state and update field accordingly. - * - * @public - */ -MaterialTextfield.prototype.checkFocus = function () { - if (Boolean(this.element_.querySelector(':focus'))) { - this.element_.classList.add(this.CssClasses_.IS_FOCUSED); - } else { - this.element_.classList.remove(this.CssClasses_.IS_FOCUSED); - } -}; -MaterialTextfield.prototype['checkFocus'] = MaterialTextfield.prototype.checkFocus; -/** - * Check the validity state and update field accordingly. - * - * @public - */ -MaterialTextfield.prototype.checkValidity = function () { - if (this.input_.validity) { - if (this.input_.validity.valid) { - this.element_.classList.remove(this.CssClasses_.IS_INVALID); - } else { - this.element_.classList.add(this.CssClasses_.IS_INVALID); - } - } -}; -MaterialTextfield.prototype['checkValidity'] = MaterialTextfield.prototype.checkValidity; -/** - * Check the dirty state and update field accordingly. - * - * @public - */ -MaterialTextfield.prototype.checkDirty = function () { - if (this.input_.value && this.input_.value.length > 0) { - this.element_.classList.add(this.CssClasses_.IS_DIRTY); - } else { - this.element_.classList.remove(this.CssClasses_.IS_DIRTY); - } -}; -MaterialTextfield.prototype['checkDirty'] = MaterialTextfield.prototype.checkDirty; -/** - * Disable text field. - * - * @public - */ -MaterialTextfield.prototype.disable = function () { - this.input_.disabled = true; - this.updateClasses_(); -}; -MaterialTextfield.prototype['disable'] = MaterialTextfield.prototype.disable; -/** - * Enable text field. - * - * @public - */ -MaterialTextfield.prototype.enable = function () { - this.input_.disabled = false; - this.updateClasses_(); -}; -MaterialTextfield.prototype['enable'] = MaterialTextfield.prototype.enable; -/** - * Update text field value. - * - * @param {string} value The value to which to set the control (optional). - * @public - */ -MaterialTextfield.prototype.change = function (value) { - this.input_.value = value || ''; - this.updateClasses_(); -}; -MaterialTextfield.prototype['change'] = MaterialTextfield.prototype.change; -/** - * Initialize element. - */ -MaterialTextfield.prototype.init = function () { - if (this.element_) { - this.label_ = this.element_.querySelector('.' + this.CssClasses_.LABEL); - this.input_ = this.element_.querySelector('.' + this.CssClasses_.INPUT); - if (this.input_) { - if (this.input_.hasAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE)) { - this.maxRows = parseInt(this.input_.getAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE), 10); - if (isNaN(this.maxRows)) { - this.maxRows = this.Constant_.NO_MAX_ROWS; - } - } - if (this.input_.hasAttribute('placeholder')) { - this.element_.classList.add(this.CssClasses_.HAS_PLACEHOLDER); - } - this.boundUpdateClassesHandler = this.updateClasses_.bind(this); - this.boundFocusHandler = this.onFocus_.bind(this); - this.boundBlurHandler = this.onBlur_.bind(this); - this.boundResetHandler = this.onReset_.bind(this); - this.input_.addEventListener('input', this.boundUpdateClassesHandler); - this.input_.addEventListener('focus', this.boundFocusHandler); - this.input_.addEventListener('blur', this.boundBlurHandler); - this.input_.addEventListener('reset', this.boundResetHandler); - if (this.maxRows !== this.Constant_.NO_MAX_ROWS) { - // TODO: This should handle pasting multi line text. - // Currently doesn't. - this.boundKeyDownHandler = this.onKeyDown_.bind(this); - this.input_.addEventListener('keydown', this.boundKeyDownHandler); - } - var invalid = this.element_.classList.contains(this.CssClasses_.IS_INVALID); - this.updateClasses_(); - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - if (invalid) { - this.element_.classList.add(this.CssClasses_.IS_INVALID); - } - if (this.input_.hasAttribute('autofocus')) { - this.element_.focus(); - this.checkFocus(); - } - } - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialTextfield, - classAsString: 'MaterialTextfield', - cssClass: 'mdl-js-textfield', - widget: true -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Tooltip MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialTooltip = function MaterialTooltip(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialTooltip'] = MaterialTooltip; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialTooltip.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialTooltip.prototype.CssClasses_ = { - IS_ACTIVE: 'is-active', - BOTTOM: 'mdl-tooltip--bottom', - LEFT: 'mdl-tooltip--left', - RIGHT: 'mdl-tooltip--right', - TOP: 'mdl-tooltip--top' -}; -/** - * Handle mouseenter for tooltip. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialTooltip.prototype.handleMouseEnter_ = function (event) { - var props = event.target.getBoundingClientRect(); - var left = props.left + props.width / 2; - var top = props.top + props.height / 2; - var marginLeft = -1 * (this.element_.offsetWidth / 2); - var marginTop = -1 * (this.element_.offsetHeight / 2); - if (this.element_.classList.contains(this.CssClasses_.LEFT) || this.element_.classList.contains(this.CssClasses_.RIGHT)) { - left = props.width / 2; - if (top + marginTop < 0) { - this.element_.style.top = '0'; - this.element_.style.marginTop = '0'; - } else { - this.element_.style.top = top + 'px'; - this.element_.style.marginTop = marginTop + 'px'; - } - } else { - if (left + marginLeft < 0) { - this.element_.style.left = '0'; - this.element_.style.marginLeft = '0'; - } else { - this.element_.style.left = left + 'px'; - this.element_.style.marginLeft = marginLeft + 'px'; - } - } - if (this.element_.classList.contains(this.CssClasses_.TOP)) { - this.element_.style.top = props.top - this.element_.offsetHeight - 10 + 'px'; - } else if (this.element_.classList.contains(this.CssClasses_.RIGHT)) { - this.element_.style.left = props.left + props.width + 10 + 'px'; - } else if (this.element_.classList.contains(this.CssClasses_.LEFT)) { - this.element_.style.left = props.left - this.element_.offsetWidth - 10 + 'px'; - } else { - this.element_.style.top = props.top + props.height + 10 + 'px'; - } - this.element_.classList.add(this.CssClasses_.IS_ACTIVE); -}; -/** - * Hide tooltip on mouseleave or scroll - * - * @private - */ -MaterialTooltip.prototype.hideTooltip_ = function () { - this.element_.classList.remove(this.CssClasses_.IS_ACTIVE); -}; -/** - * Initialize element. - */ -MaterialTooltip.prototype.init = function () { - if (this.element_) { - var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for'); - if (forElId) { - this.forElement_ = document.getElementById(forElId); - } - if (this.forElement_) { - // It's left here because it prevents accidental text selection on Android - if (!this.forElement_.hasAttribute('tabindex')) { - this.forElement_.setAttribute('tabindex', '0'); - } - this.boundMouseEnterHandler = this.handleMouseEnter_.bind(this); - this.boundMouseLeaveAndScrollHandler = this.hideTooltip_.bind(this); - this.forElement_.addEventListener('mouseenter', this.boundMouseEnterHandler, false); - this.forElement_.addEventListener('touchend', this.boundMouseEnterHandler, false); - this.forElement_.addEventListener('mouseleave', this.boundMouseLeaveAndScrollHandler, false); - window.addEventListener('scroll', this.boundMouseLeaveAndScrollHandler, true); - window.addEventListener('touchstart', this.boundMouseLeaveAndScrollHandler); - } - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialTooltip, - classAsString: 'MaterialTooltip', - cssClass: 'mdl-tooltip' -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Layout MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialLayout = function MaterialLayout(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialLayout'] = MaterialLayout; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialLayout.prototype.Constant_ = { - MAX_WIDTH: '(max-width: 1024px)', - TAB_SCROLL_PIXELS: 100, - RESIZE_TIMEOUT: 100, - MENU_ICON: '', - CHEVRON_LEFT: 'chevron_left', - CHEVRON_RIGHT: 'chevron_right' -}; -/** - * Keycodes, for code readability. - * - * @enum {number} - * @private - */ -MaterialLayout.prototype.Keycodes_ = { - ENTER: 13, - ESCAPE: 27, - SPACE: 32 -}; -/** - * Modes. - * - * @enum {number} - * @private - */ -MaterialLayout.prototype.Mode_ = { - STANDARD: 0, - SEAMED: 1, - WATERFALL: 2, - SCROLL: 3 -}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialLayout.prototype.CssClasses_ = { - CONTAINER: 'mdl-layout__container', - HEADER: 'mdl-layout__header', - DRAWER: 'mdl-layout__drawer', - CONTENT: 'mdl-layout__content', - DRAWER_BTN: 'mdl-layout__drawer-button', - ICON: 'material-icons', - JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect', - RIPPLE_CONTAINER: 'mdl-layout__tab-ripple-container', - RIPPLE: 'mdl-ripple', - RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - HEADER_SEAMED: 'mdl-layout__header--seamed', - HEADER_WATERFALL: 'mdl-layout__header--waterfall', - HEADER_SCROLL: 'mdl-layout__header--scroll', - FIXED_HEADER: 'mdl-layout--fixed-header', - OBFUSCATOR: 'mdl-layout__obfuscator', - TAB_BAR: 'mdl-layout__tab-bar', - TAB_CONTAINER: 'mdl-layout__tab-bar-container', - TAB: 'mdl-layout__tab', - TAB_BAR_BUTTON: 'mdl-layout__tab-bar-button', - TAB_BAR_LEFT_BUTTON: 'mdl-layout__tab-bar-left-button', - TAB_BAR_RIGHT_BUTTON: 'mdl-layout__tab-bar-right-button', - TAB_MANUAL_SWITCH: 'mdl-layout__tab-manual-switch', - PANEL: 'mdl-layout__tab-panel', - HAS_DRAWER: 'has-drawer', - HAS_TABS: 'has-tabs', - HAS_SCROLLING_HEADER: 'has-scrolling-header', - CASTING_SHADOW: 'is-casting-shadow', - IS_COMPACT: 'is-compact', - IS_SMALL_SCREEN: 'is-small-screen', - IS_DRAWER_OPEN: 'is-visible', - IS_ACTIVE: 'is-active', - IS_UPGRADED: 'is-upgraded', - IS_ANIMATING: 'is-animating', - ON_LARGE_SCREEN: 'mdl-layout--large-screen-only', - ON_SMALL_SCREEN: 'mdl-layout--small-screen-only' -}; -/** - * Handles scrolling on the content. - * - * @private - */ -MaterialLayout.prototype.contentScrollHandler_ = function () { - if (this.header_.classList.contains(this.CssClasses_.IS_ANIMATING)) { - return; - } - var headerVisible = !this.element_.classList.contains(this.CssClasses_.IS_SMALL_SCREEN) || this.element_.classList.contains(this.CssClasses_.FIXED_HEADER); - if (this.content_.scrollTop > 0 && !this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { - this.header_.classList.add(this.CssClasses_.CASTING_SHADOW); - this.header_.classList.add(this.CssClasses_.IS_COMPACT); - if (headerVisible) { - this.header_.classList.add(this.CssClasses_.IS_ANIMATING); - } - } else if (this.content_.scrollTop <= 0 && this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { - this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW); - this.header_.classList.remove(this.CssClasses_.IS_COMPACT); - if (headerVisible) { - this.header_.classList.add(this.CssClasses_.IS_ANIMATING); - } - } -}; -/** - * Handles a keyboard event on the drawer. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialLayout.prototype.keyboardEventHandler_ = function (evt) { - // Only react when the drawer is open. - if (evt.keyCode === this.Keycodes_.ESCAPE && this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) { - this.toggleDrawer(); - } -}; -/** - * Handles changes in screen size. - * - * @private - */ -MaterialLayout.prototype.screenSizeHandler_ = function () { - if (this.screenSizeMediaQuery_.matches) { - this.element_.classList.add(this.CssClasses_.IS_SMALL_SCREEN); - } else { - this.element_.classList.remove(this.CssClasses_.IS_SMALL_SCREEN); - // Collapse drawer (if any) when moving to a large screen size. - if (this.drawer_) { - this.drawer_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN); - this.obfuscator_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN); - } - } -}; -/** - * Handles events of drawer button. - * - * @param {Event} evt The event that fired. - * @private - */ -MaterialLayout.prototype.drawerToggleHandler_ = function (evt) { - if (evt && evt.type === 'keydown') { - if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) { - // prevent scrolling in drawer nav - evt.preventDefault(); - } else { - // prevent other keys - return; - } - } - this.toggleDrawer(); -}; -/** - * Handles (un)setting the `is-animating` class - * - * @private - */ -MaterialLayout.prototype.headerTransitionEndHandler_ = function () { - this.header_.classList.remove(this.CssClasses_.IS_ANIMATING); -}; -/** - * Handles expanding the header on click - * - * @private - */ -MaterialLayout.prototype.headerClickHandler_ = function () { - if (this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) { - this.header_.classList.remove(this.CssClasses_.IS_COMPACT); - this.header_.classList.add(this.CssClasses_.IS_ANIMATING); - } -}; -/** - * Reset tab state, dropping active classes - * - * @private - */ -MaterialLayout.prototype.resetTabState_ = function (tabBar) { - for (var k = 0; k < tabBar.length; k++) { - tabBar[k].classList.remove(this.CssClasses_.IS_ACTIVE); - } -}; -/** - * Reset panel state, droping active classes - * - * @private - */ -MaterialLayout.prototype.resetPanelState_ = function (panels) { - for (var j = 0; j < panels.length; j++) { - panels[j].classList.remove(this.CssClasses_.IS_ACTIVE); - } -}; -/** - * Toggle drawer state - * - * @public - */ -MaterialLayout.prototype.toggleDrawer = function () { - var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN); - this.drawer_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN); - this.obfuscator_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN); - // Set accessibility properties. - if (this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) { - this.drawer_.setAttribute('aria-hidden', 'false'); - drawerButton.setAttribute('aria-expanded', 'true'); - } else { - this.drawer_.setAttribute('aria-hidden', 'true'); - drawerButton.setAttribute('aria-expanded', 'false'); - } -}; -MaterialLayout.prototype['toggleDrawer'] = MaterialLayout.prototype.toggleDrawer; -/** - * Initialize element. - */ -MaterialLayout.prototype.init = function () { - if (this.element_) { - var container = document.createElement('div'); - container.classList.add(this.CssClasses_.CONTAINER); - var focusedElement = this.element_.querySelector(':focus'); - this.element_.parentElement.insertBefore(container, this.element_); - this.element_.parentElement.removeChild(this.element_); - container.appendChild(this.element_); - if (focusedElement) { - focusedElement.focus(); - } - var directChildren = this.element_.childNodes; - var numChildren = directChildren.length; - for (var c = 0; c < numChildren; c++) { - var child = directChildren[c]; - if (child.classList && child.classList.contains(this.CssClasses_.HEADER)) { - this.header_ = child; - } - if (child.classList && child.classList.contains(this.CssClasses_.DRAWER)) { - this.drawer_ = child; - } - if (child.classList && child.classList.contains(this.CssClasses_.CONTENT)) { - this.content_ = child; - } - } - window.addEventListener('pageshow', function (e) { - if (e.persisted) { - // when page is loaded from back/forward cache - // trigger repaint to let layout scroll in safari - this.element_.style.overflowY = 'hidden'; - requestAnimationFrame(function () { - this.element_.style.overflowY = ''; - }.bind(this)); - } - }.bind(this), false); - if (this.header_) { - this.tabBar_ = this.header_.querySelector('.' + this.CssClasses_.TAB_BAR); - } - var mode = this.Mode_.STANDARD; - if (this.header_) { - if (this.header_.classList.contains(this.CssClasses_.HEADER_SEAMED)) { - mode = this.Mode_.SEAMED; - } else if (this.header_.classList.contains(this.CssClasses_.HEADER_WATERFALL)) { - mode = this.Mode_.WATERFALL; - this.header_.addEventListener('transitionend', this.headerTransitionEndHandler_.bind(this)); - this.header_.addEventListener('click', this.headerClickHandler_.bind(this)); - } else if (this.header_.classList.contains(this.CssClasses_.HEADER_SCROLL)) { - mode = this.Mode_.SCROLL; - container.classList.add(this.CssClasses_.HAS_SCROLLING_HEADER); - } - if (mode === this.Mode_.STANDARD) { - this.header_.classList.add(this.CssClasses_.CASTING_SHADOW); - if (this.tabBar_) { - this.tabBar_.classList.add(this.CssClasses_.CASTING_SHADOW); - } - } else if (mode === this.Mode_.SEAMED || mode === this.Mode_.SCROLL) { - this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW); - if (this.tabBar_) { - this.tabBar_.classList.remove(this.CssClasses_.CASTING_SHADOW); - } - } else if (mode === this.Mode_.WATERFALL) { - // Add and remove shadows depending on scroll position. - // Also add/remove auxiliary class for styling of the compact version of - // the header. - this.content_.addEventListener('scroll', this.contentScrollHandler_.bind(this)); - this.contentScrollHandler_(); - } - } - // Add drawer toggling button to our layout, if we have an openable drawer. - if (this.drawer_) { - var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN); - if (!drawerButton) { - drawerButton = document.createElement('div'); - drawerButton.setAttribute('aria-expanded', 'false'); - drawerButton.setAttribute('role', 'button'); - drawerButton.setAttribute('tabindex', '0'); - drawerButton.classList.add(this.CssClasses_.DRAWER_BTN); - var drawerButtonIcon = document.createElement('i'); - drawerButtonIcon.classList.add(this.CssClasses_.ICON); - drawerButtonIcon.innerHTML = this.Constant_.MENU_ICON; - drawerButton.appendChild(drawerButtonIcon); - } - if (this.drawer_.classList.contains(this.CssClasses_.ON_LARGE_SCREEN)) { - //If drawer has ON_LARGE_SCREEN class then add it to the drawer toggle button as well. - drawerButton.classList.add(this.CssClasses_.ON_LARGE_SCREEN); - } else if (this.drawer_.classList.contains(this.CssClasses_.ON_SMALL_SCREEN)) { - //If drawer has ON_SMALL_SCREEN class then add it to the drawer toggle button as well. - drawerButton.classList.add(this.CssClasses_.ON_SMALL_SCREEN); - } - drawerButton.addEventListener('click', this.drawerToggleHandler_.bind(this)); - drawerButton.addEventListener('keydown', this.drawerToggleHandler_.bind(this)); - // Add a class if the layout has a drawer, for altering the left padding. - // Adds the HAS_DRAWER to the elements since this.header_ may or may - // not be present. - this.element_.classList.add(this.CssClasses_.HAS_DRAWER); - // If we have a fixed header, add the button to the header rather than - // the layout. - if (this.element_.classList.contains(this.CssClasses_.FIXED_HEADER)) { - this.header_.insertBefore(drawerButton, this.header_.firstChild); - } else { - this.element_.insertBefore(drawerButton, this.content_); - } - var obfuscator = document.createElement('div'); - obfuscator.classList.add(this.CssClasses_.OBFUSCATOR); - this.element_.appendChild(obfuscator); - obfuscator.addEventListener('click', this.drawerToggleHandler_.bind(this)); - this.obfuscator_ = obfuscator; - this.drawer_.addEventListener('keydown', this.keyboardEventHandler_.bind(this)); - this.drawer_.setAttribute('aria-hidden', 'true'); - } - // Keep an eye on screen size, and add/remove auxiliary class for styling - // of small screens. - this.screenSizeMediaQuery_ = window.matchMedia(this.Constant_.MAX_WIDTH); - this.screenSizeMediaQuery_.addListener(this.screenSizeHandler_.bind(this)); - this.screenSizeHandler_(); - // Initialize tabs, if any. - if (this.header_ && this.tabBar_) { - this.element_.classList.add(this.CssClasses_.HAS_TABS); - var tabContainer = document.createElement('div'); - tabContainer.classList.add(this.CssClasses_.TAB_CONTAINER); - this.header_.insertBefore(tabContainer, this.tabBar_); - this.header_.removeChild(this.tabBar_); - var leftButton = document.createElement('div'); - leftButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON); - leftButton.classList.add(this.CssClasses_.TAB_BAR_LEFT_BUTTON); - var leftButtonIcon = document.createElement('i'); - leftButtonIcon.classList.add(this.CssClasses_.ICON); - leftButtonIcon.textContent = this.Constant_.CHEVRON_LEFT; - leftButton.appendChild(leftButtonIcon); - leftButton.addEventListener('click', function () { - this.tabBar_.scrollLeft -= this.Constant_.TAB_SCROLL_PIXELS; - }.bind(this)); - var rightButton = document.createElement('div'); - rightButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON); - rightButton.classList.add(this.CssClasses_.TAB_BAR_RIGHT_BUTTON); - var rightButtonIcon = document.createElement('i'); - rightButtonIcon.classList.add(this.CssClasses_.ICON); - rightButtonIcon.textContent = this.Constant_.CHEVRON_RIGHT; - rightButton.appendChild(rightButtonIcon); - rightButton.addEventListener('click', function () { - this.tabBar_.scrollLeft += this.Constant_.TAB_SCROLL_PIXELS; - }.bind(this)); - tabContainer.appendChild(leftButton); - tabContainer.appendChild(this.tabBar_); - tabContainer.appendChild(rightButton); - // Add and remove tab buttons depending on scroll position and total - // window size. - var tabUpdateHandler = function () { - if (this.tabBar_.scrollLeft > 0) { - leftButton.classList.add(this.CssClasses_.IS_ACTIVE); - } else { - leftButton.classList.remove(this.CssClasses_.IS_ACTIVE); - } - if (this.tabBar_.scrollLeft < this.tabBar_.scrollWidth - this.tabBar_.offsetWidth) { - rightButton.classList.add(this.CssClasses_.IS_ACTIVE); - } else { - rightButton.classList.remove(this.CssClasses_.IS_ACTIVE); - } - }.bind(this); - this.tabBar_.addEventListener('scroll', tabUpdateHandler); - tabUpdateHandler(); - // Update tabs when the window resizes. - var windowResizeHandler = function () { - // Use timeouts to make sure it doesn't happen too often. - if (this.resizeTimeoutId_) { - clearTimeout(this.resizeTimeoutId_); - } - this.resizeTimeoutId_ = setTimeout(function () { - tabUpdateHandler(); - this.resizeTimeoutId_ = null; - }.bind(this), this.Constant_.RESIZE_TIMEOUT); - }.bind(this); - window.addEventListener('resize', windowResizeHandler); - if (this.tabBar_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) { - this.tabBar_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS); - } - // Select element tabs, document panels - var tabs = this.tabBar_.querySelectorAll('.' + this.CssClasses_.TAB); - var panels = this.content_.querySelectorAll('.' + this.CssClasses_.PANEL); - // Create new tabs for each tab element - for (var i = 0; i < tabs.length; i++) { - new MaterialLayoutTab(tabs[i], tabs, panels, this); - } - } - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - } -}; -/** - * Constructor for an individual tab. - * - * @constructor - * @param {HTMLElement} tab The HTML element for the tab. - * @param {!Array} tabs Array with HTML elements for all tabs. - * @param {!Array} panels Array with HTML elements for all panels. - * @param {MaterialLayout} layout The MaterialLayout object that owns the tab. - */ -function MaterialLayoutTab(tab, tabs, panels, layout) { - /** - * Auxiliary method to programmatically select a tab in the UI. - */ - function selectTab() { - var href = tab.href.split('#')[1]; - var panel = layout.content_.querySelector('#' + href); - layout.resetTabState_(tabs); - layout.resetPanelState_(panels); - tab.classList.add(layout.CssClasses_.IS_ACTIVE); - panel.classList.add(layout.CssClasses_.IS_ACTIVE); - } - if (layout.tabBar_.classList.contains(layout.CssClasses_.JS_RIPPLE_EFFECT)) { - var rippleContainer = document.createElement('span'); - rippleContainer.classList.add(layout.CssClasses_.RIPPLE_CONTAINER); - rippleContainer.classList.add(layout.CssClasses_.JS_RIPPLE_EFFECT); - var ripple = document.createElement('span'); - ripple.classList.add(layout.CssClasses_.RIPPLE); - rippleContainer.appendChild(ripple); - tab.appendChild(rippleContainer); - } - if (!layout.tabBar_.classList.contains(layout.CssClasses_.TAB_MANUAL_SWITCH)) { - tab.addEventListener('click', function (e) { - if (tab.getAttribute('href').charAt(0) === '#') { - e.preventDefault(); - selectTab(); - } - }); - } - tab.show = selectTab; -} -window['MaterialLayoutTab'] = MaterialLayoutTab; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialLayout, - classAsString: 'MaterialLayout', - cssClass: 'mdl-js-layout' -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Data Table Card MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {Element} element The element that will be upgraded. - */ -var MaterialDataTable = function MaterialDataTable(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialDataTable'] = MaterialDataTable; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialDataTable.prototype.Constant_ = {}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialDataTable.prototype.CssClasses_ = { - DATA_TABLE: 'mdl-data-table', - SELECTABLE: 'mdl-data-table--selectable', - SELECT_ELEMENT: 'mdl-data-table__select', - IS_SELECTED: 'is-selected', - IS_UPGRADED: 'is-upgraded' -}; -/** - * Generates and returns a function that toggles the selection state of a - * single row (or multiple rows). - * - * @param {Element} checkbox Checkbox that toggles the selection state. - * @param {Element} row Row to toggle when checkbox changes. - * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes. - * @private - */ -MaterialDataTable.prototype.selectRow_ = function (checkbox, row, opt_rows) { - if (row) { - return function () { - if (checkbox.checked) { - row.classList.add(this.CssClasses_.IS_SELECTED); - } else { - row.classList.remove(this.CssClasses_.IS_SELECTED); - } - }.bind(this); - } - if (opt_rows) { - return function () { - var i; - var el; - if (checkbox.checked) { - for (i = 0; i < opt_rows.length; i++) { - el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox'); - el['MaterialCheckbox'].check(); - opt_rows[i].classList.add(this.CssClasses_.IS_SELECTED); - } - } else { - for (i = 0; i < opt_rows.length; i++) { - el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox'); - el['MaterialCheckbox'].uncheck(); - opt_rows[i].classList.remove(this.CssClasses_.IS_SELECTED); - } - } - }.bind(this); - } -}; -/** - * Creates a checkbox for a single or or multiple rows and hooks up the - * event handling. - * - * @param {Element} row Row to toggle when checkbox changes. - * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes. - * @private - */ -MaterialDataTable.prototype.createCheckbox_ = function (row, opt_rows) { - var label = document.createElement('label'); - var labelClasses = [ - 'mdl-checkbox', - 'mdl-js-checkbox', - 'mdl-js-ripple-effect', - this.CssClasses_.SELECT_ELEMENT - ]; - label.className = labelClasses.join(' '); - var checkbox = document.createElement('input'); - checkbox.type = 'checkbox'; - checkbox.classList.add('mdl-checkbox__input'); - if (row) { - checkbox.checked = row.classList.contains(this.CssClasses_.IS_SELECTED); - checkbox.addEventListener('change', this.selectRow_(checkbox, row)); - } else if (opt_rows) { - checkbox.addEventListener('change', this.selectRow_(checkbox, null, opt_rows)); - } - label.appendChild(checkbox); - componentHandler.upgradeElement(label, 'MaterialCheckbox'); - return label; -}; -/** - * Initialize element. - */ -MaterialDataTable.prototype.init = function () { - if (this.element_) { - var firstHeader = this.element_.querySelector('th'); - var bodyRows = Array.prototype.slice.call(this.element_.querySelectorAll('tbody tr')); - var footRows = Array.prototype.slice.call(this.element_.querySelectorAll('tfoot tr')); - var rows = bodyRows.concat(footRows); - if (this.element_.classList.contains(this.CssClasses_.SELECTABLE)) { - var th = document.createElement('th'); - var headerCheckbox = this.createCheckbox_(null, rows); - th.appendChild(headerCheckbox); - firstHeader.parentElement.insertBefore(th, firstHeader); - for (var i = 0; i < rows.length; i++) { - var firstCell = rows[i].querySelector('td'); - if (firstCell) { - var td = document.createElement('td'); - if (rows[i].parentNode.nodeName.toUpperCase() === 'TBODY') { - var rowCheckbox = this.createCheckbox_(rows[i]); - td.appendChild(rowCheckbox); - } - rows[i].insertBefore(td, firstCell); - } - } - this.element_.classList.add(this.CssClasses_.IS_UPGRADED); - } - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialDataTable, - classAsString: 'MaterialDataTable', - cssClass: 'mdl-js-data-table' -}); -/** - * @license - * Copyright 2015 Google Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/** - * Class constructor for Ripple MDL component. - * Implements MDL component design pattern defined at: - * https://github.com/jasonmayes/mdl-component-design-pattern - * - * @constructor - * @param {HTMLElement} element The element that will be upgraded. - */ -var MaterialRipple = function MaterialRipple(element) { - this.element_ = element; - // Initialize instance. - this.init(); -}; -window['MaterialRipple'] = MaterialRipple; -/** - * Store constants in one place so they can be updated easily. - * - * @enum {string | number} - * @private - */ -MaterialRipple.prototype.Constant_ = { - INITIAL_SCALE: 'scale(0.0001, 0.0001)', - INITIAL_SIZE: '1px', - INITIAL_OPACITY: '0.4', - FINAL_OPACITY: '0', - FINAL_SCALE: '' -}; -/** - * Store strings for class names defined by this component that are used in - * JavaScript. This allows us to simply change it in one place should we - * decide to modify at a later date. - * - * @enum {string} - * @private - */ -MaterialRipple.prototype.CssClasses_ = { - RIPPLE_CENTER: 'mdl-ripple--center', - RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events', - RIPPLE: 'mdl-ripple', - IS_ANIMATING: 'is-animating', - IS_VISIBLE: 'is-visible' -}; -/** - * Handle mouse / finger down on element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRipple.prototype.downHandler_ = function (event) { - if (!this.rippleElement_.style.width && !this.rippleElement_.style.height) { - var rect = this.element_.getBoundingClientRect(); - this.boundHeight = rect.height; - this.boundWidth = rect.width; - this.rippleSize_ = Math.sqrt(rect.width * rect.width + rect.height * rect.height) * 2 + 2; - this.rippleElement_.style.width = this.rippleSize_ + 'px'; - this.rippleElement_.style.height = this.rippleSize_ + 'px'; - } - this.rippleElement_.classList.add(this.CssClasses_.IS_VISIBLE); - if (event.type === 'mousedown' && this.ignoringMouseDown_) { - this.ignoringMouseDown_ = false; - } else { - if (event.type === 'touchstart') { - this.ignoringMouseDown_ = true; - } - var frameCount = this.getFrameCount(); - if (frameCount > 0) { - return; - } - this.setFrameCount(1); - var bound = event.currentTarget.getBoundingClientRect(); - var x; - var y; - // Check if we are handling a keyboard click. - if (event.clientX === 0 && event.clientY === 0) { - x = Math.round(bound.width / 2); - y = Math.round(bound.height / 2); - } else { - var clientX = event.clientX !== undefined ? event.clientX : event.touches[0].clientX; - var clientY = event.clientY !== undefined ? event.clientY : event.touches[0].clientY; - x = Math.round(clientX - bound.left); - y = Math.round(clientY - bound.top); - } - this.setRippleXY(x, y); - this.setRippleStyles(true); - window.requestAnimationFrame(this.animFrameHandler.bind(this)); - } -}; -/** - * Handle mouse / finger up on element. - * - * @param {Event} event The event that fired. - * @private - */ -MaterialRipple.prototype.upHandler_ = function (event) { - // Don't fire for the artificial "mouseup" generated by a double-click. - if (event && event.detail !== 2) { - // Allow a repaint to occur before removing this class, so the animation - // shows for tap events, which seem to trigger a mouseup too soon after - // mousedown. - window.setTimeout(function () { - this.rippleElement_.classList.remove(this.CssClasses_.IS_VISIBLE); - }.bind(this), 0); - } -}; -/** - * Initialize element. - */ -MaterialRipple.prototype.init = function () { - if (this.element_) { - var recentering = this.element_.classList.contains(this.CssClasses_.RIPPLE_CENTER); - if (!this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT_IGNORE_EVENTS)) { - this.rippleElement_ = this.element_.querySelector('.' + this.CssClasses_.RIPPLE); - this.frameCount_ = 0; - this.rippleSize_ = 0; - this.x_ = 0; - this.y_ = 0; - // Touch start produces a compat mouse down event, which would cause a - // second ripples. To avoid that, we use this property to ignore the first - // mouse down after a touch start. - this.ignoringMouseDown_ = false; - this.boundDownHandler = this.downHandler_.bind(this); - this.element_.addEventListener('mousedown', this.boundDownHandler); - this.element_.addEventListener('touchstart', this.boundDownHandler); - this.boundUpHandler = this.upHandler_.bind(this); - this.element_.addEventListener('mouseup', this.boundUpHandler); - this.element_.addEventListener('mouseleave', this.boundUpHandler); - this.element_.addEventListener('touchend', this.boundUpHandler); - this.element_.addEventListener('blur', this.boundUpHandler); - /** - * Getter for frameCount_. - * @return {number} the frame count. - */ - this.getFrameCount = function () { - return this.frameCount_; - }; - /** - * Setter for frameCount_. - * @param {number} fC the frame count. - */ - this.setFrameCount = function (fC) { - this.frameCount_ = fC; - }; - /** - * Getter for rippleElement_. - * @return {Element} the ripple element. - */ - this.getRippleElement = function () { - return this.rippleElement_; - }; - /** - * Sets the ripple X and Y coordinates. - * @param {number} newX the new X coordinate - * @param {number} newY the new Y coordinate - */ - this.setRippleXY = function (newX, newY) { - this.x_ = newX; - this.y_ = newY; - }; - /** - * Sets the ripple styles. - * @param {boolean} start whether or not this is the start frame. - */ - this.setRippleStyles = function (start) { - if (this.rippleElement_ !== null) { - var transformString; - var scale; - var size; - var offset = 'translate(' + this.x_ + 'px, ' + this.y_ + 'px)'; - if (start) { - scale = this.Constant_.INITIAL_SCALE; - size = this.Constant_.INITIAL_SIZE; - } else { - scale = this.Constant_.FINAL_SCALE; - size = this.rippleSize_ + 'px'; - if (recentering) { - offset = 'translate(' + this.boundWidth / 2 + 'px, ' + this.boundHeight / 2 + 'px)'; - } - } - transformString = 'translate(-50%, -50%) ' + offset + scale; - this.rippleElement_.style.webkitTransform = transformString; - this.rippleElement_.style.msTransform = transformString; - this.rippleElement_.style.transform = transformString; - if (start) { - this.rippleElement_.classList.remove(this.CssClasses_.IS_ANIMATING); - } else { - this.rippleElement_.classList.add(this.CssClasses_.IS_ANIMATING); - } - } - }; - /** - * Handles an animation frame. - */ - this.animFrameHandler = function () { - if (this.frameCount_-- > 0) { - window.requestAnimationFrame(this.animFrameHandler.bind(this)); - } else { - this.setRippleStyles(false); - } - }; - } - } -}; -// The component registers itself. It can assume componentHandler is available -// in the global scope. -componentHandler.register({ - constructor: MaterialRipple, - classAsString: 'MaterialRipple', - cssClass: 'mdl-js-ripple-effect', - widget: false -}); -}()); diff --git a/web/static/js/vendor/material.min.js b/web/static/js/vendor/material.min.js deleted file mode 100644 index 46524fb..0000000 --- a/web/static/js/vendor/material.min.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * material-design-lite - Material Design Components in CSS, JS and HTML - * @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){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;s0&&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;e0&&this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)&&(e.keyCode===this.Keycodes_.UP_ARROW?(e.preventDefault(),t[t.length-1].focus()):e.keyCode===this.Keycodes_.DOWN_ARROW&&(e.preventDefault(),t[0].focus()))}},d.prototype.handleItemKeyboardEvent_=function(e){if(this.element_&&this.container_){var t=this.element_.querySelectorAll("."+this.CssClasses_.ITEM+":not([disabled])");if(t&&t.length>0&&this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)){var s=Array.prototype.slice.call(t).indexOf(e.target);if(e.keyCode===this.Keycodes_.UP_ARROW)e.preventDefault(),s>0?t[s-1].focus():t[t.length-1].focus();else if(e.keyCode===this.Keycodes_.DOWN_ARROW)e.preventDefault(),t.length>s+1?t[s+1].focus():t[0].focus();else if(e.keyCode===this.Keycodes_.SPACE||e.keyCode===this.Keycodes_.ENTER){e.preventDefault();var i=new MouseEvent("mousedown");e.target.dispatchEvent(i),i=new MouseEvent("mouseup"),e.target.dispatchEvent(i),e.target.click()}else e.keyCode===this.Keycodes_.ESCAPE&&(e.preventDefault(),this.hide())}}},d.prototype.handleItemClick_=function(e){e.target.hasAttribute("disabled")?e.stopPropagation():(this.closing_=!0,window.setTimeout(function(e){this.hide(),this.closing_=!1}.bind(this),this.Constant_.CLOSE_TIMEOUT))},d.prototype.applyClip_=function(e,t){this.element_.classList.contains(this.CssClasses_.UNALIGNED)?this.element_.style.clip="":this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)?this.element_.style.clip="rect(0 "+t+"px 0 "+t+"px)":this.element_.classList.contains(this.CssClasses_.TOP_LEFT)?this.element_.style.clip="rect("+e+"px 0 "+e+"px 0)":this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)?this.element_.style.clip="rect("+e+"px "+t+"px "+e+"px "+t+"px)":this.element_.style.clip=""},d.prototype.removeAnimationEndListener_=function(e){e.target.classList.remove(d.prototype.CssClasses_.IS_ANIMATING)},d.prototype.addAnimationEndListener_=function(){this.element_.addEventListener("transitionend",this.removeAnimationEndListener_),this.element_.addEventListener("webkitTransitionEnd",this.removeAnimationEndListener_)},d.prototype.show=function(e){if(this.element_&&this.container_&&this.outline_){var t=this.element_.getBoundingClientRect().height,s=this.element_.getBoundingClientRect().width;this.container_.style.width=s+"px",this.container_.style.height=t+"px",this.outline_.style.width=s+"px",this.outline_.style.height=t+"px";for(var i=this.Constant_.TRANSITION_DURATION_SECONDS*this.Constant_.TRANSITION_DURATION_FRACTION,n=this.element_.querySelectorAll("."+this.CssClasses_.ITEM),a=0;a0&&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=this.maxRows&&e.preventDefault()},L.prototype.onFocus_=function(e){this.element_.classList.add(this.CssClasses_.IS_FOCUSED)},L.prototype.onBlur_=function(e){this.element_.classList.remove(this.CssClasses_.IS_FOCUSED)},L.prototype.onReset_=function(e){this.updateClasses_()},L.prototype.updateClasses_=function(){this.checkDisabled(),this.checkValidity(),this.checkDirty(),this.checkFocus()},L.prototype.checkDisabled=function(){this.input_.disabled?this.element_.classList.add(this.CssClasses_.IS_DISABLED):this.element_.classList.remove(this.CssClasses_.IS_DISABLED)},L.prototype.checkDisabled=L.prototype.checkDisabled,L.prototype.checkFocus=function(){Boolean(this.element_.querySelector(":focus"))?this.element_.classList.add(this.CssClasses_.IS_FOCUSED):this.element_.classList.remove(this.CssClasses_.IS_FOCUSED)},L.prototype.checkFocus=L.prototype.checkFocus,L.prototype.checkValidity=function(){this.input_.validity&&(this.input_.validity.valid?this.element_.classList.remove(this.CssClasses_.IS_INVALID):this.element_.classList.add(this.CssClasses_.IS_INVALID))},L.prototype.checkValidity=L.prototype.checkValidity,L.prototype.checkDirty=function(){this.input_.value&&this.input_.value.length>0?this.element_.classList.add(this.CssClasses_.IS_DIRTY):this.element_.classList.remove(this.CssClasses_.IS_DIRTY)},L.prototype.checkDirty=L.prototype.checkDirty,L.prototype.disable=function(){this.input_.disabled=!0,this.updateClasses_()},L.prototype.disable=L.prototype.disable,L.prototype.enable=function(){this.input_.disabled=!1,this.updateClasses_()},L.prototype.enable=L.prototype.enable,L.prototype.change=function(e){this.input_.value=e||"",this.updateClasses_()},L.prototype.change=L.prototype.change,L.prototype.init=function(){if(this.element_&&(this.label_=this.element_.querySelector("."+this.CssClasses_.LABEL),this.input_=this.element_.querySelector("."+this.CssClasses_.INPUT),this.input_)){this.input_.hasAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE)&&(this.maxRows=parseInt(this.input_.getAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE),10),isNaN(this.maxRows)&&(this.maxRows=this.Constant_.NO_MAX_ROWS)),this.input_.hasAttribute("placeholder")&&this.element_.classList.add(this.CssClasses_.HAS_PLACEHOLDER),this.boundUpdateClassesHandler=this.updateClasses_.bind(this),this.boundFocusHandler=this.onFocus_.bind(this),this.boundBlurHandler=this.onBlur_.bind(this),this.boundResetHandler=this.onReset_.bind(this),this.input_.addEventListener("input",this.boundUpdateClassesHandler),this.input_.addEventListener("focus",this.boundFocusHandler),this.input_.addEventListener("blur",this.boundBlurHandler),this.input_.addEventListener("reset",this.boundResetHandler),this.maxRows!==this.Constant_.NO_MAX_ROWS&&(this.boundKeyDownHandler=this.onKeyDown_.bind(this),this.input_.addEventListener("keydown",this.boundKeyDownHandler));var e=this.element_.classList.contains(this.CssClasses_.IS_INVALID);this.updateClasses_(),this.element_.classList.add(this.CssClasses_.IS_UPGRADED),e&&this.element_.classList.add(this.CssClasses_.IS_INVALID),this.input_.hasAttribute("autofocus")&&(this.element_.focus(),this.checkFocus())}},s.register({constructor:L,classAsString:"MaterialTextfield",cssClass:"mdl-js-textfield",widget:!0});var I=function(e){this.element_=e,this.init()};window.MaterialTooltip=I,I.prototype.Constant_={},I.prototype.CssClasses_={IS_ACTIVE:"is-active",BOTTOM:"mdl-tooltip--bottom",LEFT:"mdl-tooltip--left",RIGHT:"mdl-tooltip--right",TOP:"mdl-tooltip--top"},I.prototype.handleMouseEnter_=function(e){var t=e.target.getBoundingClientRect(),s=t.left+t.width/2,i=t.top+t.height/2,n=-1*(this.element_.offsetWidth/2),a=-1*(this.element_.offsetHeight/2);this.element_.classList.contains(this.CssClasses_.LEFT)||this.element_.classList.contains(this.CssClasses_.RIGHT)?(s=t.width/2,i+a<0?(this.element_.style.top="0",this.element_.style.marginTop="0"):(this.element_.style.top=i+"px",this.element_.style.marginTop=a+"px")):s+n<0?(this.element_.style.left="0",this.element_.style.marginLeft="0"):(this.element_.style.left=s+"px",this.element_.style.marginLeft=n+"px"),this.element_.classList.contains(this.CssClasses_.TOP)?this.element_.style.top=t.top-this.element_.offsetHeight-10+"px":this.element_.classList.contains(this.CssClasses_.RIGHT)?this.element_.style.left=t.left+t.width+10+"px":this.element_.classList.contains(this.CssClasses_.LEFT)?this.element_.style.left=t.left-this.element_.offsetWidth-10+"px":this.element_.style.top=t.top+t.height+10+"px",this.element_.classList.add(this.CssClasses_.IS_ACTIVE)},I.prototype.hideTooltip_=function(){this.element_.classList.remove(this.CssClasses_.IS_ACTIVE)},I.prototype.init=function(){if(this.element_){var e=this.element_.getAttribute("for")||this.element_.getAttribute("data-mdl-for");e&&(this.forElement_=document.getElementById(e)),this.forElement_&&(this.forElement_.hasAttribute("tabindex")||this.forElement_.setAttribute("tabindex","0"),this.boundMouseEnterHandler=this.handleMouseEnter_.bind(this),this.boundMouseLeaveAndScrollHandler=this.hideTooltip_.bind(this),this.forElement_.addEventListener("mouseenter",this.boundMouseEnterHandler,!1),this.forElement_.addEventListener("touchend",this.boundMouseEnterHandler,!1),this.forElement_.addEventListener("mouseleave",this.boundMouseLeaveAndScrollHandler,!1),window.addEventListener("scroll",this.boundMouseLeaveAndScrollHandler,!0),window.addEventListener("touchstart",this.boundMouseLeaveAndScrollHandler))}},s.register({constructor:I,classAsString:"MaterialTooltip",cssClass:"mdl-tooltip"});var f=function(e){this.element_=e,this.init()};window.MaterialLayout=f,f.prototype.Constant_={MAX_WIDTH:"(max-width: 1024px)",TAB_SCROLL_PIXELS:100,RESIZE_TIMEOUT:100,MENU_ICON:"",CHEVRON_LEFT:"chevron_left",CHEVRON_RIGHT:"chevron_right"},f.prototype.Keycodes_={ENTER:13,ESCAPE:27,SPACE:32},f.prototype.Mode_={STANDARD:0,SEAMED:1,WATERFALL:2,SCROLL:3},f.prototype.CssClasses_={CONTAINER:"mdl-layout__container",HEADER:"mdl-layout__header",DRAWER:"mdl-layout__drawer",CONTENT:"mdl-layout__content",DRAWER_BTN:"mdl-layout__drawer-button",ICON:"material-icons",JS_RIPPLE_EFFECT:"mdl-js-ripple-effect",RIPPLE_CONTAINER:"mdl-layout__tab-ripple-container",RIPPLE:"mdl-ripple",RIPPLE_IGNORE_EVENTS:"mdl-js-ripple-effect--ignore-events",HEADER_SEAMED:"mdl-layout__header--seamed",HEADER_WATERFALL:"mdl-layout__header--waterfall",HEADER_SCROLL:"mdl-layout__header--scroll",FIXED_HEADER:"mdl-layout--fixed-header",OBFUSCATOR:"mdl-layout__obfuscator",TAB_BAR:"mdl-layout__tab-bar",TAB_CONTAINER:"mdl-layout__tab-bar-container",TAB:"mdl-layout__tab",TAB_BAR_BUTTON:"mdl-layout__tab-bar-button",TAB_BAR_LEFT_BUTTON:"mdl-layout__tab-bar-left-button",TAB_BAR_RIGHT_BUTTON:"mdl-layout__tab-bar-right-button",TAB_MANUAL_SWITCH:"mdl-layout__tab-manual-switch",PANEL:"mdl-layout__tab-panel",HAS_DRAWER:"has-drawer",HAS_TABS:"has-tabs",HAS_SCROLLING_HEADER:"has-scrolling-header",CASTING_SHADOW:"is-casting-shadow",IS_COMPACT:"is-compact",IS_SMALL_SCREEN:"is-small-screen",IS_DRAWER_OPEN:"is-visible",IS_ACTIVE:"is-active",IS_UPGRADED:"is-upgraded",IS_ANIMATING:"is-animating",ON_LARGE_SCREEN:"mdl-layout--large-screen-only",ON_SMALL_SCREEN:"mdl-layout--small-screen-only"},f.prototype.contentScrollHandler_=function(){if(!this.header_.classList.contains(this.CssClasses_.IS_ANIMATING)){var e=!this.element_.classList.contains(this.CssClasses_.IS_SMALL_SCREEN)||this.element_.classList.contains(this.CssClasses_.FIXED_HEADER);this.content_.scrollTop>0&&!this.header_.classList.contains(this.CssClasses_.IS_COMPACT)?(this.header_.classList.add(this.CssClasses_.CASTING_SHADOW),this.header_.classList.add(this.CssClasses_.IS_COMPACT),e&&this.header_.classList.add(this.CssClasses_.IS_ANIMATING)):this.content_.scrollTop<=0&&this.header_.classList.contains(this.CssClasses_.IS_COMPACT)&&(this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW),this.header_.classList.remove(this.CssClasses_.IS_COMPACT),e&&this.header_.classList.add(this.CssClasses_.IS_ANIMATING))}},f.prototype.keyboardEventHandler_=function(e){e.keyCode===this.Keycodes_.ESCAPE&&this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)&&this.toggleDrawer()},f.prototype.screenSizeHandler_=function(){this.screenSizeMediaQuery_.matches?this.element_.classList.add(this.CssClasses_.IS_SMALL_SCREEN):(this.element_.classList.remove(this.CssClasses_.IS_SMALL_SCREEN),this.drawer_&&(this.drawer_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN),this.obfuscator_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN)))},f.prototype.drawerToggleHandler_=function(e){if(e&&"keydown"===e.type){if(e.keyCode!==this.Keycodes_.SPACE&&e.keyCode!==this.Keycodes_.ENTER)return;e.preventDefault()}this.toggleDrawer()},f.prototype.headerTransitionEndHandler_=function(){this.header_.classList.remove(this.CssClasses_.IS_ANIMATING)},f.prototype.headerClickHandler_=function(){this.header_.classList.contains(this.CssClasses_.IS_COMPACT)&&(this.header_.classList.remove(this.CssClasses_.IS_COMPACT),this.header_.classList.add(this.CssClasses_.IS_ANIMATING))},f.prototype.resetTabState_=function(e){for(var t=0;t0?c.classList.add(this.CssClasses_.IS_ACTIVE):c.classList.remove(this.CssClasses_.IS_ACTIVE),this.tabBar_.scrollLeft0)return;this.setFrameCount(1);var i,n,a=e.currentTarget.getBoundingClientRect();if(0===e.clientX&&0===e.clientY)i=Math.round(a.width/2),n=Math.round(a.height/2);else{var l=void 0!==e.clientX?e.clientX:e.touches[0].clientX,o=void 0!==e.clientY?e.clientY:e.touches[0].clientY;i=Math.round(l-a.left),n=Math.round(o-a.top)}this.setRippleXY(i,n),this.setRippleStyles(!0),window.requestAnimationFrame(this.animFrameHandler.bind(this))}},S.prototype.upHandler_=function(e){e&&2!==e.detail&&window.setTimeout(function(){this.rippleElement_.classList.remove(this.CssClasses_.IS_VISIBLE)}.bind(this),0)},S.prototype.init=function(){if(this.element_){var e=this.element_.classList.contains(this.CssClasses_.RIPPLE_CENTER);this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT_IGNORE_EVENTS)||(this.rippleElement_=this.element_.querySelector("."+this.CssClasses_.RIPPLE),this.frameCount_=0,this.rippleSize_=0,this.x_=0,this.y_=0,this.ignoringMouseDown_=!1,this.boundDownHandler=this.downHandler_.bind(this),this.element_.addEventListener("mousedown",this.boundDownHandler),this.element_.addEventListener("touchstart",this.boundDownHandler),this.boundUpHandler=this.upHandler_.bind(this),this.element_.addEventListener("mouseup",this.boundUpHandler),this.element_.addEventListener("mouseleave",this.boundUpHandler),this.element_.addEventListener("touchend",this.boundUpHandler),this.element_.addEventListener("blur",this.boundUpHandler),this.getFrameCount=function(){return this.frameCount_},this.setFrameCount=function(e){this.frameCount_=e},this.getRippleElement=function(){return this.rippleElement_},this.setRippleXY=function(e,t){this.x_=e,this.y_=t},this.setRippleStyles=function(t){if(null!==this.rippleElement_){var s,i,n,a="translate("+this.x_+"px, "+this.y_+"px)";t?(i=this.Constant_.INITIAL_SCALE,n=this.Constant_.INITIAL_SIZE):(i=this.Constant_.FINAL_SCALE,n=this.rippleSize_+"px",e&&(a="translate("+this.boundWidth/2+"px, "+this.boundHeight/2+"px)")),s="translate(-50%, -50%) "+a+i,this.rippleElement_.style.webkitTransform=s,this.rippleElement_.style.msTransform=s,this.rippleElement_.style.transform=s,t?this.rippleElement_.classList.remove(this.CssClasses_.IS_ANIMATING):this.rippleElement_.classList.add(this.CssClasses_.IS_ANIMATING)}},this.animFrameHandler=function(){this.frameCount_-- >0?window.requestAnimationFrame(this.animFrameHandler.bind(this)):this.setRippleStyles(!1)})}},s.register({constructor:S,classAsString:"MaterialRipple",cssClass:"mdl-js-ripple-effect",widget:!1})}(); -//# sourceMappingURL=material.min.js.map diff --git a/web/static/js/vendor/material.min.js.map b/web/static/js/vendor/material.min.js.map deleted file mode 100644 index 05336c3..0000000 --- a/web/static/js/vendor/material.min.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["tabs.js","layout.js","mdlComponentHandler.js","rAF.js","button.js","checkbox.js","icon-toggle.js","menu.js","progress.js","radio.js","slider.js","snackbar.js","spinner.js","switch.js","textfield.js","tooltip.js","data-table.js","ripple.js"],"names":["MaterialTab","tab","ctx","element_","classList","contains","CssClasses_","MDL_JS_RIPPLE_EFFECT","rippleContainer","document","createElement","add","MDL_RIPPLE_CONTAINER","ripple","MDL_RIPPLE","appendChild","addEventListener","e","getAttribute","charAt","preventDefault","href","split","panel","querySelector","resetTabState_","resetPanelState_","ACTIVE_CLASS","MaterialLayoutTab","tabs","panels","layout","selectTab","content_","IS_ACTIVE","tabBar_","JS_RIPPLE_EFFECT","RIPPLE_CONTAINER","RIPPLE","TAB_MANUAL_SWITCH","show","componentHandler","upgradeDom","optJsClass","optCssClass","upgradeElement","element","upgradeElements","elements","upgradeAllRegistered","registerUpgradedCallback","jsClass","callback","register","config","downgradeElements","nodes","findRegisteredClass_","name","optReplace","i","registeredComponents_","length","className","getUpgradedListOfElement_","dataUpgraded","isElementUpgraded_","upgradedList","indexOf","createEvent_","eventType","bubbles","cancelable","window","CustomEvent","ev","createEvent","initEvent","upgradeDomInternal","cssClass","registeredClass","querySelectorAll","n","upgradeElementInternal","Element","Error","upgradingEv","dispatchEvent","defaultPrevented","classesToUpgrade","push","forEach","component","setAttribute","join","instance","classConstructor","componentConfigProperty_","createdComponents_","j","m","callbacks","widget","upgradedEv","upgradeElementsInternal","Array","isArray","prototype","slice","call","HTMLElement","children","registerInternal","widgetMissing","newConfig","constructor","classAsString","item","hasOwnProperty","found","registerUpgradedCallbackInternal","regClass","upgradeAllRegisteredInternal","deconstructComponentInternal","componentIndex","splice","upgrades","componentPlace","downgradeNodesInternal","downgradeNode","node","filter","NodeList","Node","ComponentConfigPublic","ComponentConfig","Component","documentElement","Date","now","getTime","vendors","requestAnimationFrame","vp","cancelAnimationFrame","test","navigator","userAgent","lastTime","nextTime","Math","max","setTimeout","clearTimeout","MaterialButton","this","init","Constant_","RIPPLE_EFFECT","blurHandler_","event","blur","disable","disabled","enable","rippleElement_","boundRippleBlurHandler","bind","boundButtonBlurHandler","MaterialCheckbox","TINY_TIMEOUT","INPUT","BOX_OUTLINE","FOCUS_HELPER","TICK_OUTLINE","RIPPLE_IGNORE_EVENTS","RIPPLE_CENTER","IS_FOCUSED","IS_DISABLED","IS_CHECKED","IS_UPGRADED","onChange_","updateClasses_","onFocus_","onBlur_","remove","onMouseUp_","blur_","checkDisabled","checkToggleState","inputElement_","checked","check","uncheck","boxOutline","tickContainer","tickOutline","rippleContainerElement_","boundRippleMouseUp","boundInputOnChange","boundInputOnFocus","boundInputOnBlur","boundElementMouseUp","MaterialIconToggle","boundElementOnMouseUp","MaterialMenu","TRANSITION_DURATION_SECONDS","TRANSITION_DURATION_FRACTION","CLOSE_TIMEOUT","Keycodes_","ENTER","ESCAPE","SPACE","UP_ARROW","DOWN_ARROW","CONTAINER","OUTLINE","ITEM","ITEM_RIPPLE_CONTAINER","IS_VISIBLE","IS_ANIMATING","BOTTOM_LEFT","BOTTOM_RIGHT","TOP_LEFT","TOP_RIGHT","UNALIGNED","container","parentElement","insertBefore","removeChild","container_","outline","outline_","forElId","forEl","getElementById","forElement_","handleForClick_","handleForKeyboardEvent_","items","boundItemKeydown_","handleItemKeyboardEvent_","boundItemClick_","handleItemClick_","tabIndex","evt","rect","getBoundingClientRect","forRect","style","right","top","offsetTop","offsetHeight","left","offsetLeft","bottom","toggle","keyCode","focus","currentIndex","target","MouseEvent","click","hide","hasAttribute","stopPropagation","closing_","applyClip_","height","width","clip","removeAnimationEndListener_","addAnimationEndListener_","transitionDuration","itemDelay","transitionDelay","parentNode","removeEventListener","removeProperty","MaterialProgress","INDETERMINATE_CLASS","setProgress","p","progressbar_","setBuffer","bufferbar_","auxbar_","el","MaterialRadio","JS_RADIO","RADIO_BTN","RADIO_OUTER_CIRCLE","RADIO_INNER_CIRCLE","radios","getElementsByClassName","button","btnElement_","onMouseup_","boundChangeHandler_","boundFocusHandler_","boundBlurHandler_","boundMouseUpHandler_","outerCircle","innerCircle","MaterialSlider","isIE_","msPointerEnabled","IE_CONTAINER","SLIDER_CONTAINER","BACKGROUND_FLEX","BACKGROUND_LOWER","BACKGROUND_UPPER","IS_LOWEST_VALUE","onInput_","updateValueStyles_","onContainerMouseDown_","newEvent","buttons","clientX","clientY","y","fraction","value","min","backgroundLower_","flex","webkitFlex","backgroundUpper_","change","containerIE","backgroundFlex","boundInputHandler","boundChangeHandler","boundMouseUpHandler","boundContainerMouseDownHandler","MaterialSnackbar","textElement_","cssClasses_","MESSAGE","actionElement_","ACTION","active","actionHandler_","undefined","message_","actionText_","queuedNotifications_","setActionHidden_","ANIMATION_LENGTH","SNACKBAR","ACTIVE","displaySnackbar_","textContent","cleanup_","timeout_","showSnackbar","data","checkQueue_","shift","Boolean","removeAttribute","MaterialSpinner","MDL_SPINNER_LAYER_COUNT","MDL_SPINNER_LAYER","MDL_SPINNER_CIRCLE_CLIPPER","MDL_SPINNER_CIRCLE","MDL_SPINNER_GAP_PATCH","MDL_SPINNER_LEFT","MDL_SPINNER_RIGHT","createLayer","index","layer","leftClipper","gapPatch","rightClipper","circleOwners","circle","stop","start","MaterialSwitch","TRACK","THUMB","on","off","track","thumb","focusHelper","boundFocusHandler","boundBlurHandler","MaterialTabs","TAB_CLASS","PANEL_CLASS","UPGRADED_CLASS","MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS","initTabs_","tabs_","panels_","k","MaterialTextfield","maxRows","NO_MAX_ROWS","MAX_ROWS_ATTRIBUTE","LABEL","IS_DIRTY","IS_INVALID","HAS_PLACEHOLDER","onKeyDown_","currentRowCount","onReset_","checkValidity","checkDirty","checkFocus","input_","validity","valid","label_","parseInt","isNaN","boundUpdateClassesHandler","boundResetHandler","boundKeyDownHandler","invalid","MaterialTooltip","BOTTOM","LEFT","RIGHT","TOP","handleMouseEnter_","props","marginLeft","offsetWidth","marginTop","hideTooltip_","boundMouseEnterHandler","boundMouseLeaveAndScrollHandler","MaterialLayout","MAX_WIDTH","TAB_SCROLL_PIXELS","RESIZE_TIMEOUT","MENU_ICON","CHEVRON_LEFT","CHEVRON_RIGHT","Mode_","STANDARD","SEAMED","WATERFALL","SCROLL","HEADER","DRAWER","CONTENT","DRAWER_BTN","ICON","HEADER_SEAMED","HEADER_WATERFALL","HEADER_SCROLL","FIXED_HEADER","OBFUSCATOR","TAB_BAR","TAB_CONTAINER","TAB","TAB_BAR_BUTTON","TAB_BAR_LEFT_BUTTON","TAB_BAR_RIGHT_BUTTON","PANEL","HAS_DRAWER","HAS_TABS","HAS_SCROLLING_HEADER","CASTING_SHADOW","IS_COMPACT","IS_SMALL_SCREEN","IS_DRAWER_OPEN","ON_LARGE_SCREEN","ON_SMALL_SCREEN","contentScrollHandler_","header_","headerVisible","scrollTop","keyboardEventHandler_","drawer_","toggleDrawer","screenSizeHandler_","screenSizeMediaQuery_","matches","obfuscator_","drawerToggleHandler_","type","headerTransitionEndHandler_","headerClickHandler_","tabBar","drawerButton","focusedElement","directChildren","childNodes","numChildren","c","child","persisted","overflowY","mode","drawerButtonIcon","innerHTML","firstChild","obfuscator","matchMedia","addListener","tabContainer","leftButton","leftButtonIcon","scrollLeft","rightButton","rightButtonIcon","tabUpdateHandler","scrollWidth","windowResizeHandler","resizeTimeoutId_","MaterialDataTable","DATA_TABLE","SELECTABLE","SELECT_ELEMENT","IS_SELECTED","selectRow_","checkbox","row","opt_rows","createCheckbox_","label","labelClasses","firstHeader","bodyRows","footRows","rows","concat","th","headerCheckbox","firstCell","td","nodeName","toUpperCase","rowCheckbox","MaterialRipple","INITIAL_SCALE","INITIAL_SIZE","INITIAL_OPACITY","FINAL_OPACITY","FINAL_SCALE","RIPPLE_EFFECT_IGNORE_EVENTS","downHandler_","boundHeight","boundWidth","rippleSize_","sqrt","ignoringMouseDown_","frameCount","getFrameCount","setFrameCount","x","bound","currentTarget","round","touches","setRippleXY","setRippleStyles","animFrameHandler","upHandler_","detail","recentering","frameCount_","x_","y_","boundDownHandler","boundUpHandler","fC","getRippleElement","newX","newY","transformString","scale","size","offset","webkitTransform","msTransform","transform"],"mappings":";;;;;;;wBA6GA,SAAAA,GAAAC,EAAAC,GACA,GAAAD,EAAA,CACA,GAAAC,EAAAC,SAAAC,UAAAC,SAAAH,EAAAI,YAAAC,sBAAA,CACA,GAAAC,GAAAC,SAAAC,cAAA,OACA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QAAA","file":"material.min.js","sourcesContent":["/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Tabs MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {Element} element The element that will be upgraded.\n */\nvar MaterialTabs = function MaterialTabs(element) {\n // Stores the HTML element.\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialTabs'] = MaterialTabs;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string}\n * @private\n */\nMaterialTabs.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialTabs.prototype.CssClasses_ = {\n TAB_CLASS: 'mdl-tabs__tab',\n PANEL_CLASS: 'mdl-tabs__panel',\n ACTIVE_CLASS: 'is-active',\n UPGRADED_CLASS: 'is-upgraded',\n MDL_JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n MDL_RIPPLE_CONTAINER: 'mdl-tabs__ripple-container',\n MDL_RIPPLE: 'mdl-ripple',\n MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events'\n};\n/**\n * Handle clicks to a tabs component\n *\n * @private\n */\nMaterialTabs.prototype.initTabs_ = function () {\n if (this.element_.classList.contains(this.CssClasses_.MDL_JS_RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.MDL_JS_RIPPLE_EFFECT_IGNORE_EVENTS);\n }\n // Select element tabs, document panels\n this.tabs_ = this.element_.querySelectorAll('.' + this.CssClasses_.TAB_CLASS);\n this.panels_ = this.element_.querySelectorAll('.' + this.CssClasses_.PANEL_CLASS);\n // Create new tabs for each tab element\n for (var i = 0; i < this.tabs_.length; i++) {\n new MaterialTab(this.tabs_[i], this);\n }\n this.element_.classList.add(this.CssClasses_.UPGRADED_CLASS);\n};\n/**\n * Reset tab state, dropping active classes\n *\n * @private\n */\nMaterialTabs.prototype.resetTabState_ = function () {\n for (var k = 0; k < this.tabs_.length; k++) {\n this.tabs_[k].classList.remove(this.CssClasses_.ACTIVE_CLASS);\n }\n};\n/**\n * Reset panel state, droping active classes\n *\n * @private\n */\nMaterialTabs.prototype.resetPanelState_ = function () {\n for (var j = 0; j < this.panels_.length; j++) {\n this.panels_[j].classList.remove(this.CssClasses_.ACTIVE_CLASS);\n }\n};\n/**\n * Initialize element.\n */\nMaterialTabs.prototype.init = function () {\n if (this.element_) {\n this.initTabs_();\n }\n};\n/**\n * Constructor for an individual tab.\n *\n * @constructor\n * @param {Element} tab The HTML element for the tab.\n * @param {MaterialTabs} ctx The MaterialTabs object that owns the tab.\n */\nfunction MaterialTab(tab, ctx) {\n if (tab) {\n if (ctx.element_.classList.contains(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT)) {\n var rippleContainer = document.createElement('span');\n rippleContainer.classList.add(ctx.CssClasses_.MDL_RIPPLE_CONTAINER);\n rippleContainer.classList.add(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT);\n var ripple = document.createElement('span');\n ripple.classList.add(ctx.CssClasses_.MDL_RIPPLE);\n rippleContainer.appendChild(ripple);\n tab.appendChild(rippleContainer);\n }\n tab.addEventListener('click', function (e) {\n if (tab.getAttribute('href').charAt(0) === '#') {\n e.preventDefault();\n var href = tab.href.split('#')[1];\n var panel = ctx.element_.querySelector('#' + href);\n ctx.resetTabState_();\n ctx.resetPanelState_();\n tab.classList.add(ctx.CssClasses_.ACTIVE_CLASS);\n panel.classList.add(ctx.CssClasses_.ACTIVE_CLASS);\n }\n });\n }\n}\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialTabs,\n classAsString: 'MaterialTabs',\n cssClass: 'mdl-js-tabs'\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Layout MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialLayout = function MaterialLayout(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialLayout'] = MaterialLayout;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialLayout.prototype.Constant_ = {\n MAX_WIDTH: '(max-width: 1024px)',\n TAB_SCROLL_PIXELS: 100,\n RESIZE_TIMEOUT: 100,\n MENU_ICON: '',\n CHEVRON_LEFT: 'chevron_left',\n CHEVRON_RIGHT: 'chevron_right'\n};\n/**\n * Keycodes, for code readability.\n *\n * @enum {number}\n * @private\n */\nMaterialLayout.prototype.Keycodes_ = {\n ENTER: 13,\n ESCAPE: 27,\n SPACE: 32\n};\n/**\n * Modes.\n *\n * @enum {number}\n * @private\n */\nMaterialLayout.prototype.Mode_ = {\n STANDARD: 0,\n SEAMED: 1,\n WATERFALL: 2,\n SCROLL: 3\n};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialLayout.prototype.CssClasses_ = {\n CONTAINER: 'mdl-layout__container',\n HEADER: 'mdl-layout__header',\n DRAWER: 'mdl-layout__drawer',\n CONTENT: 'mdl-layout__content',\n DRAWER_BTN: 'mdl-layout__drawer-button',\n ICON: 'material-icons',\n JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_CONTAINER: 'mdl-layout__tab-ripple-container',\n RIPPLE: 'mdl-ripple',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n HEADER_SEAMED: 'mdl-layout__header--seamed',\n HEADER_WATERFALL: 'mdl-layout__header--waterfall',\n HEADER_SCROLL: 'mdl-layout__header--scroll',\n FIXED_HEADER: 'mdl-layout--fixed-header',\n OBFUSCATOR: 'mdl-layout__obfuscator',\n TAB_BAR: 'mdl-layout__tab-bar',\n TAB_CONTAINER: 'mdl-layout__tab-bar-container',\n TAB: 'mdl-layout__tab',\n TAB_BAR_BUTTON: 'mdl-layout__tab-bar-button',\n TAB_BAR_LEFT_BUTTON: 'mdl-layout__tab-bar-left-button',\n TAB_BAR_RIGHT_BUTTON: 'mdl-layout__tab-bar-right-button',\n TAB_MANUAL_SWITCH: 'mdl-layout__tab-manual-switch',\n PANEL: 'mdl-layout__tab-panel',\n HAS_DRAWER: 'has-drawer',\n HAS_TABS: 'has-tabs',\n HAS_SCROLLING_HEADER: 'has-scrolling-header',\n CASTING_SHADOW: 'is-casting-shadow',\n IS_COMPACT: 'is-compact',\n IS_SMALL_SCREEN: 'is-small-screen',\n IS_DRAWER_OPEN: 'is-visible',\n IS_ACTIVE: 'is-active',\n IS_UPGRADED: 'is-upgraded',\n IS_ANIMATING: 'is-animating',\n ON_LARGE_SCREEN: 'mdl-layout--large-screen-only',\n ON_SMALL_SCREEN: 'mdl-layout--small-screen-only'\n};\n/**\n * Handles scrolling on the content.\n *\n * @private\n */\nMaterialLayout.prototype.contentScrollHandler_ = function () {\n if (this.header_.classList.contains(this.CssClasses_.IS_ANIMATING)) {\n return;\n }\n var headerVisible = !this.element_.classList.contains(this.CssClasses_.IS_SMALL_SCREEN) || this.element_.classList.contains(this.CssClasses_.FIXED_HEADER);\n if (this.content_.scrollTop > 0 && !this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) {\n this.header_.classList.add(this.CssClasses_.CASTING_SHADOW);\n this.header_.classList.add(this.CssClasses_.IS_COMPACT);\n if (headerVisible) {\n this.header_.classList.add(this.CssClasses_.IS_ANIMATING);\n }\n } else if (this.content_.scrollTop <= 0 && this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) {\n this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW);\n this.header_.classList.remove(this.CssClasses_.IS_COMPACT);\n if (headerVisible) {\n this.header_.classList.add(this.CssClasses_.IS_ANIMATING);\n }\n }\n};\n/**\n * Handles a keyboard event on the drawer.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialLayout.prototype.keyboardEventHandler_ = function (evt) {\n // Only react when the drawer is open.\n if (evt.keyCode === this.Keycodes_.ESCAPE && this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) {\n this.toggleDrawer();\n }\n};\n/**\n * Handles changes in screen size.\n *\n * @private\n */\nMaterialLayout.prototype.screenSizeHandler_ = function () {\n if (this.screenSizeMediaQuery_.matches) {\n this.element_.classList.add(this.CssClasses_.IS_SMALL_SCREEN);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_SMALL_SCREEN);\n // Collapse drawer (if any) when moving to a large screen size.\n if (this.drawer_) {\n this.drawer_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN);\n this.obfuscator_.classList.remove(this.CssClasses_.IS_DRAWER_OPEN);\n }\n }\n};\n/**\n * Handles events of drawer button.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialLayout.prototype.drawerToggleHandler_ = function (evt) {\n if (evt && evt.type === 'keydown') {\n if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) {\n // prevent scrolling in drawer nav\n evt.preventDefault();\n } else {\n // prevent other keys\n return;\n }\n }\n this.toggleDrawer();\n};\n/**\n * Handles (un)setting the `is-animating` class\n *\n * @private\n */\nMaterialLayout.prototype.headerTransitionEndHandler_ = function () {\n this.header_.classList.remove(this.CssClasses_.IS_ANIMATING);\n};\n/**\n * Handles expanding the header on click\n *\n * @private\n */\nMaterialLayout.prototype.headerClickHandler_ = function () {\n if (this.header_.classList.contains(this.CssClasses_.IS_COMPACT)) {\n this.header_.classList.remove(this.CssClasses_.IS_COMPACT);\n this.header_.classList.add(this.CssClasses_.IS_ANIMATING);\n }\n};\n/**\n * Reset tab state, dropping active classes\n *\n * @private\n */\nMaterialLayout.prototype.resetTabState_ = function (tabBar) {\n for (var k = 0; k < tabBar.length; k++) {\n tabBar[k].classList.remove(this.CssClasses_.IS_ACTIVE);\n }\n};\n/**\n * Reset panel state, droping active classes\n *\n * @private\n */\nMaterialLayout.prototype.resetPanelState_ = function (panels) {\n for (var j = 0; j < panels.length; j++) {\n panels[j].classList.remove(this.CssClasses_.IS_ACTIVE);\n }\n};\n/**\n * Toggle drawer state\n *\n * @public\n */\nMaterialLayout.prototype.toggleDrawer = function () {\n var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN);\n this.drawer_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN);\n this.obfuscator_.classList.toggle(this.CssClasses_.IS_DRAWER_OPEN);\n // Set accessibility properties.\n if (this.drawer_.classList.contains(this.CssClasses_.IS_DRAWER_OPEN)) {\n this.drawer_.setAttribute('aria-hidden', 'false');\n drawerButton.setAttribute('aria-expanded', 'true');\n } else {\n this.drawer_.setAttribute('aria-hidden', 'true');\n drawerButton.setAttribute('aria-expanded', 'false');\n }\n};\nMaterialLayout.prototype['toggleDrawer'] = MaterialLayout.prototype.toggleDrawer;\n/**\n * Initialize element.\n */\nMaterialLayout.prototype.init = function () {\n if (this.element_) {\n var container = document.createElement('div');\n container.classList.add(this.CssClasses_.CONTAINER);\n var focusedElement = this.element_.querySelector(':focus');\n this.element_.parentElement.insertBefore(container, this.element_);\n this.element_.parentElement.removeChild(this.element_);\n container.appendChild(this.element_);\n if (focusedElement) {\n focusedElement.focus();\n }\n var directChildren = this.element_.childNodes;\n var numChildren = directChildren.length;\n for (var c = 0; c < numChildren; c++) {\n var child = directChildren[c];\n if (child.classList && child.classList.contains(this.CssClasses_.HEADER)) {\n this.header_ = child;\n }\n if (child.classList && child.classList.contains(this.CssClasses_.DRAWER)) {\n this.drawer_ = child;\n }\n if (child.classList && child.classList.contains(this.CssClasses_.CONTENT)) {\n this.content_ = child;\n }\n }\n window.addEventListener('pageshow', function (e) {\n if (e.persisted) {\n // when page is loaded from back/forward cache\n // trigger repaint to let layout scroll in safari\n this.element_.style.overflowY = 'hidden';\n requestAnimationFrame(function () {\n this.element_.style.overflowY = '';\n }.bind(this));\n }\n }.bind(this), false);\n if (this.header_) {\n this.tabBar_ = this.header_.querySelector('.' + this.CssClasses_.TAB_BAR);\n }\n var mode = this.Mode_.STANDARD;\n if (this.header_) {\n if (this.header_.classList.contains(this.CssClasses_.HEADER_SEAMED)) {\n mode = this.Mode_.SEAMED;\n } else if (this.header_.classList.contains(this.CssClasses_.HEADER_WATERFALL)) {\n mode = this.Mode_.WATERFALL;\n this.header_.addEventListener('transitionend', this.headerTransitionEndHandler_.bind(this));\n this.header_.addEventListener('click', this.headerClickHandler_.bind(this));\n } else if (this.header_.classList.contains(this.CssClasses_.HEADER_SCROLL)) {\n mode = this.Mode_.SCROLL;\n container.classList.add(this.CssClasses_.HAS_SCROLLING_HEADER);\n }\n if (mode === this.Mode_.STANDARD) {\n this.header_.classList.add(this.CssClasses_.CASTING_SHADOW);\n if (this.tabBar_) {\n this.tabBar_.classList.add(this.CssClasses_.CASTING_SHADOW);\n }\n } else if (mode === this.Mode_.SEAMED || mode === this.Mode_.SCROLL) {\n this.header_.classList.remove(this.CssClasses_.CASTING_SHADOW);\n if (this.tabBar_) {\n this.tabBar_.classList.remove(this.CssClasses_.CASTING_SHADOW);\n }\n } else if (mode === this.Mode_.WATERFALL) {\n // Add and remove shadows depending on scroll position.\n // Also add/remove auxiliary class for styling of the compact version of\n // the header.\n this.content_.addEventListener('scroll', this.contentScrollHandler_.bind(this));\n this.contentScrollHandler_();\n }\n }\n // Add drawer toggling button to our layout, if we have an openable drawer.\n if (this.drawer_) {\n var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN);\n if (!drawerButton) {\n drawerButton = document.createElement('div');\n drawerButton.setAttribute('aria-expanded', 'false');\n drawerButton.setAttribute('role', 'button');\n drawerButton.setAttribute('tabindex', '0');\n drawerButton.classList.add(this.CssClasses_.DRAWER_BTN);\n var drawerButtonIcon = document.createElement('i');\n drawerButtonIcon.classList.add(this.CssClasses_.ICON);\n drawerButtonIcon.innerHTML = this.Constant_.MENU_ICON;\n drawerButton.appendChild(drawerButtonIcon);\n }\n if (this.drawer_.classList.contains(this.CssClasses_.ON_LARGE_SCREEN)) {\n //If drawer has ON_LARGE_SCREEN class then add it to the drawer toggle button as well.\n drawerButton.classList.add(this.CssClasses_.ON_LARGE_SCREEN);\n } else if (this.drawer_.classList.contains(this.CssClasses_.ON_SMALL_SCREEN)) {\n //If drawer has ON_SMALL_SCREEN class then add it to the drawer toggle button as well.\n drawerButton.classList.add(this.CssClasses_.ON_SMALL_SCREEN);\n }\n drawerButton.addEventListener('click', this.drawerToggleHandler_.bind(this));\n drawerButton.addEventListener('keydown', this.drawerToggleHandler_.bind(this));\n // Add a class if the layout has a drawer, for altering the left padding.\n // Adds the HAS_DRAWER to the elements since this.header_ may or may\n // not be present.\n this.element_.classList.add(this.CssClasses_.HAS_DRAWER);\n // If we have a fixed header, add the button to the header rather than\n // the layout.\n if (this.element_.classList.contains(this.CssClasses_.FIXED_HEADER)) {\n this.header_.insertBefore(drawerButton, this.header_.firstChild);\n } else {\n this.element_.insertBefore(drawerButton, this.content_);\n }\n var obfuscator = document.createElement('div');\n obfuscator.classList.add(this.CssClasses_.OBFUSCATOR);\n this.element_.appendChild(obfuscator);\n obfuscator.addEventListener('click', this.drawerToggleHandler_.bind(this));\n this.obfuscator_ = obfuscator;\n this.drawer_.addEventListener('keydown', this.keyboardEventHandler_.bind(this));\n this.drawer_.setAttribute('aria-hidden', 'true');\n }\n // Keep an eye on screen size, and add/remove auxiliary class for styling\n // of small screens.\n this.screenSizeMediaQuery_ = window.matchMedia(this.Constant_.MAX_WIDTH);\n this.screenSizeMediaQuery_.addListener(this.screenSizeHandler_.bind(this));\n this.screenSizeHandler_();\n // Initialize tabs, if any.\n if (this.header_ && this.tabBar_) {\n this.element_.classList.add(this.CssClasses_.HAS_TABS);\n var tabContainer = document.createElement('div');\n tabContainer.classList.add(this.CssClasses_.TAB_CONTAINER);\n this.header_.insertBefore(tabContainer, this.tabBar_);\n this.header_.removeChild(this.tabBar_);\n var leftButton = document.createElement('div');\n leftButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON);\n leftButton.classList.add(this.CssClasses_.TAB_BAR_LEFT_BUTTON);\n var leftButtonIcon = document.createElement('i');\n leftButtonIcon.classList.add(this.CssClasses_.ICON);\n leftButtonIcon.textContent = this.Constant_.CHEVRON_LEFT;\n leftButton.appendChild(leftButtonIcon);\n leftButton.addEventListener('click', function () {\n this.tabBar_.scrollLeft -= this.Constant_.TAB_SCROLL_PIXELS;\n }.bind(this));\n var rightButton = document.createElement('div');\n rightButton.classList.add(this.CssClasses_.TAB_BAR_BUTTON);\n rightButton.classList.add(this.CssClasses_.TAB_BAR_RIGHT_BUTTON);\n var rightButtonIcon = document.createElement('i');\n rightButtonIcon.classList.add(this.CssClasses_.ICON);\n rightButtonIcon.textContent = this.Constant_.CHEVRON_RIGHT;\n rightButton.appendChild(rightButtonIcon);\n rightButton.addEventListener('click', function () {\n this.tabBar_.scrollLeft += this.Constant_.TAB_SCROLL_PIXELS;\n }.bind(this));\n tabContainer.appendChild(leftButton);\n tabContainer.appendChild(this.tabBar_);\n tabContainer.appendChild(rightButton);\n // Add and remove tab buttons depending on scroll position and total\n // window size.\n var tabUpdateHandler = function () {\n if (this.tabBar_.scrollLeft > 0) {\n leftButton.classList.add(this.CssClasses_.IS_ACTIVE);\n } else {\n leftButton.classList.remove(this.CssClasses_.IS_ACTIVE);\n }\n if (this.tabBar_.scrollLeft < this.tabBar_.scrollWidth - this.tabBar_.offsetWidth) {\n rightButton.classList.add(this.CssClasses_.IS_ACTIVE);\n } else {\n rightButton.classList.remove(this.CssClasses_.IS_ACTIVE);\n }\n }.bind(this);\n this.tabBar_.addEventListener('scroll', tabUpdateHandler);\n tabUpdateHandler();\n // Update tabs when the window resizes.\n var windowResizeHandler = function () {\n // Use timeouts to make sure it doesn't happen too often.\n if (this.resizeTimeoutId_) {\n clearTimeout(this.resizeTimeoutId_);\n }\n this.resizeTimeoutId_ = setTimeout(function () {\n tabUpdateHandler();\n this.resizeTimeoutId_ = null;\n }.bind(this), this.Constant_.RESIZE_TIMEOUT);\n }.bind(this);\n window.addEventListener('resize', windowResizeHandler);\n if (this.tabBar_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) {\n this.tabBar_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n }\n // Select element tabs, document panels\n var tabs = this.tabBar_.querySelectorAll('.' + this.CssClasses_.TAB);\n var panels = this.content_.querySelectorAll('.' + this.CssClasses_.PANEL);\n // Create new tabs for each tab element\n for (var i = 0; i < tabs.length; i++) {\n new MaterialLayoutTab(tabs[i], tabs, panels, this);\n }\n }\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n};\n/**\n * Constructor for an individual tab.\n *\n * @constructor\n * @param {HTMLElement} tab The HTML element for the tab.\n * @param {!Array} tabs Array with HTML elements for all tabs.\n * @param {!Array} panels Array with HTML elements for all panels.\n * @param {MaterialLayout} layout The MaterialLayout object that owns the tab.\n */\nfunction MaterialLayoutTab(tab, tabs, panels, layout) {\n /**\n * Auxiliary method to programmatically select a tab in the UI.\n */\n function selectTab() {\n var href = tab.href.split('#')[1];\n var panel = layout.content_.querySelector('#' + href);\n layout.resetTabState_(tabs);\n layout.resetPanelState_(panels);\n tab.classList.add(layout.CssClasses_.IS_ACTIVE);\n panel.classList.add(layout.CssClasses_.IS_ACTIVE);\n }\n if (layout.tabBar_.classList.contains(layout.CssClasses_.JS_RIPPLE_EFFECT)) {\n var rippleContainer = document.createElement('span');\n rippleContainer.classList.add(layout.CssClasses_.RIPPLE_CONTAINER);\n rippleContainer.classList.add(layout.CssClasses_.JS_RIPPLE_EFFECT);\n var ripple = document.createElement('span');\n ripple.classList.add(layout.CssClasses_.RIPPLE);\n rippleContainer.appendChild(ripple);\n tab.appendChild(rippleContainer);\n }\n if (!layout.tabBar_.classList.contains(layout.CssClasses_.TAB_MANUAL_SWITCH)) {\n tab.addEventListener('click', function (e) {\n if (tab.getAttribute('href').charAt(0) === '#') {\n e.preventDefault();\n selectTab();\n }\n });\n }\n tab.show = selectTab;\n}\nwindow['MaterialLayoutTab'] = MaterialLayoutTab;\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialLayout,\n classAsString: 'MaterialLayout',\n cssClass: 'mdl-js-layout'\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * A component handler interface using the revealing module design pattern.\n * More details on this design pattern here:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @author Jason Mayes.\n */\n/* exported componentHandler */\n\n// Pre-defining the componentHandler interface, for closure documentation and\n// static verification.\nvar componentHandler = {\n /**\n * Searches existing DOM for elements of our component type and upgrades them\n * if they have not already been upgraded.\n *\n * @param {string=} optJsClass the programatic name of the element class we\n * need to create a new instance of.\n * @param {string=} optCssClass the name of the CSS class elements of this\n * type will have.\n */\n upgradeDom: function(optJsClass, optCssClass) {},\n /**\n * Upgrades a specific element rather than all in the DOM.\n *\n * @param {!Element} element The element we wish to upgrade.\n * @param {string=} optJsClass Optional name of the class we want to upgrade\n * the element to.\n */\n upgradeElement: function(element, optJsClass) {},\n /**\n * Upgrades a specific list of elements rather than all in the DOM.\n *\n * @param {!Element|!Array|!NodeList|!HTMLCollection} elements\n * The elements we wish to upgrade.\n */\n upgradeElements: function(elements) {},\n /**\n * Upgrades all registered components found in the current DOM. This is\n * automatically called on window load.\n */\n upgradeAllRegistered: function() {},\n /**\n * Allows user to be alerted to any upgrades that are performed for a given\n * component type\n *\n * @param {string} jsClass The class name of the MDL component we wish\n * to hook into for any upgrades performed.\n * @param {function(!HTMLElement)} callback The function to call upon an\n * upgrade. This function should expect 1 parameter - the HTMLElement which\n * got upgraded.\n */\n registerUpgradedCallback: function(jsClass, callback) {},\n /**\n * Registers a class for future use and attempts to upgrade existing DOM.\n *\n * @param {componentHandler.ComponentConfigPublic} config the registration configuration\n */\n register: function(config) {},\n /**\n * Downgrade either a given node, an array of nodes, or a NodeList.\n *\n * @param {!Node|!Array|!NodeList} nodes\n */\n downgradeElements: function(nodes) {}\n};\n\ncomponentHandler = (function() {\n 'use strict';\n\n /** @type {!Array} */\n var registeredComponents_ = [];\n\n /** @type {!Array} */\n var createdComponents_ = [];\n\n var componentConfigProperty_ = 'mdlComponentConfigInternal_';\n\n /**\n * Searches registered components for a class we are interested in using.\n * Optionally replaces a match with passed object if specified.\n *\n * @param {string} name The name of a class we want to use.\n * @param {componentHandler.ComponentConfig=} optReplace Optional object to replace match with.\n * @return {!Object|boolean}\n * @private\n */\n function findRegisteredClass_(name, optReplace) {\n for (var i = 0; i < registeredComponents_.length; i++) {\n if (registeredComponents_[i].className === name) {\n if (typeof optReplace !== 'undefined') {\n registeredComponents_[i] = optReplace;\n }\n return registeredComponents_[i];\n }\n }\n return false;\n }\n\n /**\n * Returns an array of the classNames of the upgraded classes on the element.\n *\n * @param {!Element} element The element to fetch data from.\n * @return {!Array}\n * @private\n */\n function getUpgradedListOfElement_(element) {\n var dataUpgraded = element.getAttribute('data-upgraded');\n // Use `['']` as default value to conform the `,name,name...` style.\n return dataUpgraded === null ? [''] : dataUpgraded.split(',');\n }\n\n /**\n * Returns true if the given element has already been upgraded for the given\n * class.\n *\n * @param {!Element} element The element we want to check.\n * @param {string} jsClass The class to check for.\n * @returns {boolean}\n * @private\n */\n function isElementUpgraded_(element, jsClass) {\n var upgradedList = getUpgradedListOfElement_(element);\n return upgradedList.indexOf(jsClass) !== -1;\n }\n\n /**\n * Create an event object.\n *\n * @param {string} eventType The type name of the event.\n * @param {boolean} bubbles Whether the event should bubble up the DOM.\n * @param {boolean} cancelable Whether the event can be canceled.\n * @returns {!Event}\n */\n function createEvent_(eventType, bubbles, cancelable) {\n if ('CustomEvent' in window && typeof window.CustomEvent === 'function') {\n return new CustomEvent(eventType, {\n bubbles: bubbles,\n cancelable: cancelable\n });\n } else {\n var ev = document.createEvent('Events');\n ev.initEvent(eventType, bubbles, cancelable);\n return ev;\n }\n }\n\n /**\n * Searches existing DOM for elements of our component type and upgrades them\n * if they have not already been upgraded.\n *\n * @param {string=} optJsClass the programatic name of the element class we\n * need to create a new instance of.\n * @param {string=} optCssClass the name of the CSS class elements of this\n * type will have.\n */\n function upgradeDomInternal(optJsClass, optCssClass) {\n if (typeof optJsClass === 'undefined' &&\n typeof optCssClass === 'undefined') {\n for (var i = 0; i < registeredComponents_.length; i++) {\n upgradeDomInternal(registeredComponents_[i].className,\n registeredComponents_[i].cssClass);\n }\n } else {\n var jsClass = /** @type {string} */ (optJsClass);\n if (typeof optCssClass === 'undefined') {\n var registeredClass = findRegisteredClass_(jsClass);\n if (registeredClass) {\n optCssClass = registeredClass.cssClass;\n }\n }\n\n var elements = document.querySelectorAll('.' + optCssClass);\n for (var n = 0; n < elements.length; n++) {\n upgradeElementInternal(elements[n], jsClass);\n }\n }\n }\n\n /**\n * Upgrades a specific element rather than all in the DOM.\n *\n * @param {!Element} element The element we wish to upgrade.\n * @param {string=} optJsClass Optional name of the class we want to upgrade\n * the element to.\n */\n function upgradeElementInternal(element, optJsClass) {\n // Verify argument type.\n if (!(typeof element === 'object' && element instanceof Element)) {\n throw new Error('Invalid argument provided to upgrade MDL element.');\n }\n // Allow upgrade to be canceled by canceling emitted event.\n var upgradingEv = createEvent_('mdl-componentupgrading', true, true);\n element.dispatchEvent(upgradingEv);\n if (upgradingEv.defaultPrevented) {\n return;\n }\n\n var upgradedList = getUpgradedListOfElement_(element);\n var classesToUpgrade = [];\n // If jsClass is not provided scan the registered components to find the\n // ones matching the element's CSS classList.\n if (!optJsClass) {\n var classList = element.classList;\n registeredComponents_.forEach(function(component) {\n // Match CSS & Not to be upgraded & Not upgraded.\n if (classList.contains(component.cssClass) &&\n classesToUpgrade.indexOf(component) === -1 &&\n !isElementUpgraded_(element, component.className)) {\n classesToUpgrade.push(component);\n }\n });\n } else if (!isElementUpgraded_(element, optJsClass)) {\n classesToUpgrade.push(findRegisteredClass_(optJsClass));\n }\n\n // Upgrade the element for each classes.\n for (var i = 0, n = classesToUpgrade.length, registeredClass; i < n; i++) {\n registeredClass = classesToUpgrade[i];\n if (registeredClass) {\n // Mark element as upgraded.\n upgradedList.push(registeredClass.className);\n element.setAttribute('data-upgraded', upgradedList.join(','));\n var instance = new registeredClass.classConstructor(element);\n instance[componentConfigProperty_] = registeredClass;\n createdComponents_.push(instance);\n // Call any callbacks the user has registered with this component type.\n for (var j = 0, m = registeredClass.callbacks.length; j < m; j++) {\n registeredClass.callbacks[j](element);\n }\n\n if (registeredClass.widget) {\n // Assign per element instance for control over API\n element[registeredClass.className] = instance;\n }\n } else {\n throw new Error(\n 'Unable to find a registered component for the given class.');\n }\n\n var upgradedEv = createEvent_('mdl-componentupgraded', true, false);\n element.dispatchEvent(upgradedEv);\n }\n }\n\n /**\n * Upgrades a specific list of elements rather than all in the DOM.\n *\n * @param {!Element|!Array|!NodeList|!HTMLCollection} elements\n * The elements we wish to upgrade.\n */\n function upgradeElementsInternal(elements) {\n if (!Array.isArray(elements)) {\n if (elements instanceof Element) {\n elements = [elements];\n } else {\n elements = Array.prototype.slice.call(elements);\n }\n }\n for (var i = 0, n = elements.length, element; i < n; i++) {\n element = elements[i];\n if (element instanceof HTMLElement) {\n upgradeElementInternal(element);\n if (element.children.length > 0) {\n upgradeElementsInternal(element.children);\n }\n }\n }\n }\n\n /**\n * Registers a class for future use and attempts to upgrade existing DOM.\n *\n * @param {componentHandler.ComponentConfigPublic} config\n */\n function registerInternal(config) {\n // In order to support both Closure-compiled and uncompiled code accessing\n // this method, we need to allow for both the dot and array syntax for\n // property access. You'll therefore see the `foo.bar || foo['bar']`\n // pattern repeated across this method.\n var widgetMissing = (typeof config.widget === 'undefined' &&\n typeof config['widget'] === 'undefined');\n var widget = true;\n\n if (!widgetMissing) {\n widget = config.widget || config['widget'];\n }\n\n var newConfig = /** @type {componentHandler.ComponentConfig} */ ({\n classConstructor: config.constructor || config['constructor'],\n className: config.classAsString || config['classAsString'],\n cssClass: config.cssClass || config['cssClass'],\n widget: widget,\n callbacks: []\n });\n\n registeredComponents_.forEach(function(item) {\n if (item.cssClass === newConfig.cssClass) {\n throw new Error('The provided cssClass has already been registered: ' + item.cssClass);\n }\n if (item.className === newConfig.className) {\n throw new Error('The provided className has already been registered');\n }\n });\n\n if (config.constructor.prototype\n .hasOwnProperty(componentConfigProperty_)) {\n throw new Error(\n 'MDL component classes must not have ' + componentConfigProperty_ +\n ' defined as a property.');\n }\n\n var found = findRegisteredClass_(config.classAsString, newConfig);\n\n if (!found) {\n registeredComponents_.push(newConfig);\n }\n }\n\n /**\n * Allows user to be alerted to any upgrades that are performed for a given\n * component type\n *\n * @param {string} jsClass The class name of the MDL component we wish\n * to hook into for any upgrades performed.\n * @param {function(!HTMLElement)} callback The function to call upon an\n * upgrade. This function should expect 1 parameter - the HTMLElement which\n * got upgraded.\n */\n function registerUpgradedCallbackInternal(jsClass, callback) {\n var regClass = findRegisteredClass_(jsClass);\n if (regClass) {\n regClass.callbacks.push(callback);\n }\n }\n\n /**\n * Upgrades all registered components found in the current DOM. This is\n * automatically called on window load.\n */\n function upgradeAllRegisteredInternal() {\n for (var n = 0; n < registeredComponents_.length; n++) {\n upgradeDomInternal(registeredComponents_[n].className);\n }\n }\n\n /**\n * Check the component for the downgrade method.\n * Execute if found.\n * Remove component from createdComponents list.\n *\n * @param {?componentHandler.Component} component\n */\n function deconstructComponentInternal(component) {\n if (component) {\n var componentIndex = createdComponents_.indexOf(component);\n createdComponents_.splice(componentIndex, 1);\n\n var upgrades = component.element_.getAttribute('data-upgraded').split(',');\n var componentPlace = upgrades.indexOf(component[componentConfigProperty_].classAsString);\n upgrades.splice(componentPlace, 1);\n component.element_.setAttribute('data-upgraded', upgrades.join(','));\n\n var ev = createEvent_('mdl-componentdowngraded', true, false);\n component.element_.dispatchEvent(ev);\n }\n }\n\n /**\n * Downgrade either a given node, an array of nodes, or a NodeList.\n *\n * @param {!Node|!Array|!NodeList} nodes\n */\n function downgradeNodesInternal(nodes) {\n /**\n * Auxiliary function to downgrade a single node.\n * @param {!Node} node the node to be downgraded\n */\n var downgradeNode = function(node) {\n createdComponents_.filter(function(item) {\n return item.element_ === node;\n }).forEach(deconstructComponentInternal);\n };\n if (nodes instanceof Array || nodes instanceof NodeList) {\n for (var n = 0; n < nodes.length; n++) {\n downgradeNode(nodes[n]);\n }\n } else if (nodes instanceof Node) {\n downgradeNode(nodes);\n } else {\n throw new Error('Invalid argument provided to downgrade MDL nodes.');\n }\n }\n\n // Now return the functions that should be made public with their publicly\n // facing names...\n return {\n upgradeDom: upgradeDomInternal,\n upgradeElement: upgradeElementInternal,\n upgradeElements: upgradeElementsInternal,\n upgradeAllRegistered: upgradeAllRegisteredInternal,\n registerUpgradedCallback: registerUpgradedCallbackInternal,\n register: registerInternal,\n downgradeElements: downgradeNodesInternal\n };\n})();\n\n/**\n * Describes the type of a registered component type managed by\n * componentHandler. Provided for benefit of the Closure compiler.\n *\n * @typedef {{\n * constructor: Function,\n * classAsString: string,\n * cssClass: string,\n * widget: (string|boolean|undefined)\n * }}\n */\ncomponentHandler.ComponentConfigPublic; // jshint ignore:line\n\n/**\n * Describes the type of a registered component type managed by\n * componentHandler. Provided for benefit of the Closure compiler.\n *\n * @typedef {{\n * constructor: !Function,\n * className: string,\n * cssClass: string,\n * widget: (string|boolean),\n * callbacks: !Array\n * }}\n */\ncomponentHandler.ComponentConfig; // jshint ignore:line\n\n/**\n * Created component (i.e., upgraded element) type as managed by\n * componentHandler. Provided for benefit of the Closure compiler.\n *\n * @typedef {{\n * element_: !HTMLElement,\n * className: string,\n * classAsString: string,\n * cssClass: string,\n * widget: string\n * }}\n */\ncomponentHandler.Component; // jshint ignore:line\n\n// Export all symbols, for the benefit of Closure compiler.\n// No effect on uncompiled code.\ncomponentHandler['upgradeDom'] = componentHandler.upgradeDom;\ncomponentHandler['upgradeElement'] = componentHandler.upgradeElement;\ncomponentHandler['upgradeElements'] = componentHandler.upgradeElements;\ncomponentHandler['upgradeAllRegistered'] =\n componentHandler.upgradeAllRegistered;\ncomponentHandler['registerUpgradedCallback'] =\n componentHandler.registerUpgradedCallback;\ncomponentHandler['register'] = componentHandler.register;\ncomponentHandler['downgradeElements'] = componentHandler.downgradeElements;\nwindow.componentHandler = componentHandler;\nwindow['componentHandler'] = componentHandler;\n\nwindow.addEventListener('load', function() {\n 'use strict';\n\n /**\n * Performs a \"Cutting the mustard\" test. If the browser supports the features\n * tested, adds a mdl-js class to the element. It then upgrades all MDL\n * components requiring JavaScript.\n */\n if ('classList' in document.createElement('div') &&\n 'querySelector' in document &&\n 'addEventListener' in window && Array.prototype.forEach) {\n document.documentElement.classList.add('mdl-js');\n componentHandler.upgradeAllRegistered();\n } else {\n /**\n * Dummy function to avoid JS errors.\n */\n componentHandler.upgradeElement = function() {};\n /**\n * Dummy function to avoid JS errors.\n */\n componentHandler.register = function() {};\n }\n});\n","// Source: https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js\n// Adapted from https://gist.github.com/paulirish/1579671 which derived from\n// http://paulirish.com/2011/requestanimationframe-for-smart-animating/\n// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating\n// requestAnimationFrame polyfill by Erik Möller.\n// Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon\n// MIT license\nif (!Date.now) {\n /**\n * Date.now polyfill.\n * @return {number} the current Date\n */\n Date.now = function () {\n return new Date().getTime();\n };\n Date['now'] = Date.now;\n}\nvar vendors = [\n 'webkit',\n 'moz'\n];\nfor (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {\n var vp = vendors[i];\n window.requestAnimationFrame = window[vp + 'RequestAnimationFrame'];\n window.cancelAnimationFrame = window[vp + 'CancelAnimationFrame'] || window[vp + 'CancelRequestAnimationFrame'];\n window['requestAnimationFrame'] = window.requestAnimationFrame;\n window['cancelAnimationFrame'] = window.cancelAnimationFrame;\n}\nif (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) {\n var lastTime = 0;\n /**\n * requestAnimationFrame polyfill.\n * @param {!Function} callback the callback function.\n */\n window.requestAnimationFrame = function (callback) {\n var now = Date.now();\n var nextTime = Math.max(lastTime + 16, now);\n return setTimeout(function () {\n callback(lastTime = nextTime);\n }, nextTime - now);\n };\n window.cancelAnimationFrame = clearTimeout;\n window['requestAnimationFrame'] = window.requestAnimationFrame;\n window['cancelAnimationFrame'] = window.cancelAnimationFrame;\n}","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Button MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialButton = function MaterialButton(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialButton'] = MaterialButton;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialButton.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialButton.prototype.CssClasses_ = {\n RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_CONTAINER: 'mdl-button__ripple-container',\n RIPPLE: 'mdl-ripple'\n};\n/**\n * Handle blur of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialButton.prototype.blurHandler_ = function (event) {\n if (event) {\n this.element_.blur();\n }\n};\n// Public methods.\n/**\n * Disable button.\n *\n * @public\n */\nMaterialButton.prototype.disable = function () {\n this.element_.disabled = true;\n};\nMaterialButton.prototype['disable'] = MaterialButton.prototype.disable;\n/**\n * Enable button.\n *\n * @public\n */\nMaterialButton.prototype.enable = function () {\n this.element_.disabled = false;\n};\nMaterialButton.prototype['enable'] = MaterialButton.prototype.enable;\n/**\n * Initialize element.\n */\nMaterialButton.prototype.init = function () {\n if (this.element_) {\n if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) {\n var rippleContainer = document.createElement('span');\n rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER);\n this.rippleElement_ = document.createElement('span');\n this.rippleElement_.classList.add(this.CssClasses_.RIPPLE);\n rippleContainer.appendChild(this.rippleElement_);\n this.boundRippleBlurHandler = this.blurHandler_.bind(this);\n this.rippleElement_.addEventListener('mouseup', this.boundRippleBlurHandler);\n this.element_.appendChild(rippleContainer);\n }\n this.boundButtonBlurHandler = this.blurHandler_.bind(this);\n this.element_.addEventListener('mouseup', this.boundButtonBlurHandler);\n this.element_.addEventListener('mouseleave', this.boundButtonBlurHandler);\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialButton,\n classAsString: 'MaterialButton',\n cssClass: 'mdl-js-button',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Checkbox MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialCheckbox = function MaterialCheckbox(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialCheckbox'] = MaterialCheckbox;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialCheckbox.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialCheckbox.prototype.CssClasses_ = {\n INPUT: 'mdl-checkbox__input',\n BOX_OUTLINE: 'mdl-checkbox__box-outline',\n FOCUS_HELPER: 'mdl-checkbox__focus-helper',\n TICK_OUTLINE: 'mdl-checkbox__tick-outline',\n RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE_CONTAINER: 'mdl-checkbox__ripple-container',\n RIPPLE_CENTER: 'mdl-ripple--center',\n RIPPLE: 'mdl-ripple',\n IS_FOCUSED: 'is-focused',\n IS_DISABLED: 'is-disabled',\n IS_CHECKED: 'is-checked',\n IS_UPGRADED: 'is-upgraded'\n};\n/**\n * Handle change of state.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialCheckbox.prototype.onChange_ = function (event) {\n this.updateClasses_();\n};\n/**\n * Handle focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialCheckbox.prototype.onFocus_ = function (event) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle lost focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialCheckbox.prototype.onBlur_ = function (event) {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle mouseup.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialCheckbox.prototype.onMouseUp_ = function (event) {\n this.blur_();\n};\n/**\n * Handle class updates.\n *\n * @private\n */\nMaterialCheckbox.prototype.updateClasses_ = function () {\n this.checkDisabled();\n this.checkToggleState();\n};\n/**\n * Add blur.\n *\n * @private\n */\nMaterialCheckbox.prototype.blur_ = function () {\n // TODO: figure out why there's a focus event being fired after our blur,\n // so that we can avoid this hack.\n window.setTimeout(function () {\n this.inputElement_.blur();\n }.bind(this), this.Constant_.TINY_TIMEOUT);\n};\n// Public methods.\n/**\n * Check the inputs toggle state and update display.\n *\n * @public\n */\nMaterialCheckbox.prototype.checkToggleState = function () {\n if (this.inputElement_.checked) {\n this.element_.classList.add(this.CssClasses_.IS_CHECKED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_CHECKED);\n }\n};\nMaterialCheckbox.prototype['checkToggleState'] = MaterialCheckbox.prototype.checkToggleState;\n/**\n * Check the inputs disabled state and update display.\n *\n * @public\n */\nMaterialCheckbox.prototype.checkDisabled = function () {\n if (this.inputElement_.disabled) {\n this.element_.classList.add(this.CssClasses_.IS_DISABLED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DISABLED);\n }\n};\nMaterialCheckbox.prototype['checkDisabled'] = MaterialCheckbox.prototype.checkDisabled;\n/**\n * Disable checkbox.\n *\n * @public\n */\nMaterialCheckbox.prototype.disable = function () {\n this.inputElement_.disabled = true;\n this.updateClasses_();\n};\nMaterialCheckbox.prototype['disable'] = MaterialCheckbox.prototype.disable;\n/**\n * Enable checkbox.\n *\n * @public\n */\nMaterialCheckbox.prototype.enable = function () {\n this.inputElement_.disabled = false;\n this.updateClasses_();\n};\nMaterialCheckbox.prototype['enable'] = MaterialCheckbox.prototype.enable;\n/**\n * Check checkbox.\n *\n * @public\n */\nMaterialCheckbox.prototype.check = function () {\n this.inputElement_.checked = true;\n this.updateClasses_();\n};\nMaterialCheckbox.prototype['check'] = MaterialCheckbox.prototype.check;\n/**\n * Uncheck checkbox.\n *\n * @public\n */\nMaterialCheckbox.prototype.uncheck = function () {\n this.inputElement_.checked = false;\n this.updateClasses_();\n};\nMaterialCheckbox.prototype['uncheck'] = MaterialCheckbox.prototype.uncheck;\n/**\n * Initialize element.\n */\nMaterialCheckbox.prototype.init = function () {\n if (this.element_) {\n this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT);\n var boxOutline = document.createElement('span');\n boxOutline.classList.add(this.CssClasses_.BOX_OUTLINE);\n var tickContainer = document.createElement('span');\n tickContainer.classList.add(this.CssClasses_.FOCUS_HELPER);\n var tickOutline = document.createElement('span');\n tickOutline.classList.add(this.CssClasses_.TICK_OUTLINE);\n boxOutline.appendChild(tickOutline);\n this.element_.appendChild(tickContainer);\n this.element_.appendChild(boxOutline);\n if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n this.rippleContainerElement_ = document.createElement('span');\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER);\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT);\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER);\n this.boundRippleMouseUp = this.onMouseUp_.bind(this);\n this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp);\n var ripple = document.createElement('span');\n ripple.classList.add(this.CssClasses_.RIPPLE);\n this.rippleContainerElement_.appendChild(ripple);\n this.element_.appendChild(this.rippleContainerElement_);\n }\n this.boundInputOnChange = this.onChange_.bind(this);\n this.boundInputOnFocus = this.onFocus_.bind(this);\n this.boundInputOnBlur = this.onBlur_.bind(this);\n this.boundElementMouseUp = this.onMouseUp_.bind(this);\n this.inputElement_.addEventListener('change', this.boundInputOnChange);\n this.inputElement_.addEventListener('focus', this.boundInputOnFocus);\n this.inputElement_.addEventListener('blur', this.boundInputOnBlur);\n this.element_.addEventListener('mouseup', this.boundElementMouseUp);\n this.updateClasses_();\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialCheckbox,\n classAsString: 'MaterialCheckbox',\n cssClass: 'mdl-js-checkbox',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for icon toggle MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialIconToggle = function MaterialIconToggle(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialIconToggle'] = MaterialIconToggle;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialIconToggle.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialIconToggle.prototype.CssClasses_ = {\n INPUT: 'mdl-icon-toggle__input',\n JS_RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE_CONTAINER: 'mdl-icon-toggle__ripple-container',\n RIPPLE_CENTER: 'mdl-ripple--center',\n RIPPLE: 'mdl-ripple',\n IS_FOCUSED: 'is-focused',\n IS_DISABLED: 'is-disabled',\n IS_CHECKED: 'is-checked'\n};\n/**\n * Handle change of state.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialIconToggle.prototype.onChange_ = function (event) {\n this.updateClasses_();\n};\n/**\n * Handle focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialIconToggle.prototype.onFocus_ = function (event) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle lost focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialIconToggle.prototype.onBlur_ = function (event) {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle mouseup.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialIconToggle.prototype.onMouseUp_ = function (event) {\n this.blur_();\n};\n/**\n * Handle class updates.\n *\n * @private\n */\nMaterialIconToggle.prototype.updateClasses_ = function () {\n this.checkDisabled();\n this.checkToggleState();\n};\n/**\n * Add blur.\n *\n * @private\n */\nMaterialIconToggle.prototype.blur_ = function () {\n // TODO: figure out why there's a focus event being fired after our blur,\n // so that we can avoid this hack.\n window.setTimeout(function () {\n this.inputElement_.blur();\n }.bind(this), this.Constant_.TINY_TIMEOUT);\n};\n// Public methods.\n/**\n * Check the inputs toggle state and update display.\n *\n * @public\n */\nMaterialIconToggle.prototype.checkToggleState = function () {\n if (this.inputElement_.checked) {\n this.element_.classList.add(this.CssClasses_.IS_CHECKED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_CHECKED);\n }\n};\nMaterialIconToggle.prototype['checkToggleState'] = MaterialIconToggle.prototype.checkToggleState;\n/**\n * Check the inputs disabled state and update display.\n *\n * @public\n */\nMaterialIconToggle.prototype.checkDisabled = function () {\n if (this.inputElement_.disabled) {\n this.element_.classList.add(this.CssClasses_.IS_DISABLED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DISABLED);\n }\n};\nMaterialIconToggle.prototype['checkDisabled'] = MaterialIconToggle.prototype.checkDisabled;\n/**\n * Disable icon toggle.\n *\n * @public\n */\nMaterialIconToggle.prototype.disable = function () {\n this.inputElement_.disabled = true;\n this.updateClasses_();\n};\nMaterialIconToggle.prototype['disable'] = MaterialIconToggle.prototype.disable;\n/**\n * Enable icon toggle.\n *\n * @public\n */\nMaterialIconToggle.prototype.enable = function () {\n this.inputElement_.disabled = false;\n this.updateClasses_();\n};\nMaterialIconToggle.prototype['enable'] = MaterialIconToggle.prototype.enable;\n/**\n * Check icon toggle.\n *\n * @public\n */\nMaterialIconToggle.prototype.check = function () {\n this.inputElement_.checked = true;\n this.updateClasses_();\n};\nMaterialIconToggle.prototype['check'] = MaterialIconToggle.prototype.check;\n/**\n * Uncheck icon toggle.\n *\n * @public\n */\nMaterialIconToggle.prototype.uncheck = function () {\n this.inputElement_.checked = false;\n this.updateClasses_();\n};\nMaterialIconToggle.prototype['uncheck'] = MaterialIconToggle.prototype.uncheck;\n/**\n * Initialize element.\n */\nMaterialIconToggle.prototype.init = function () {\n if (this.element_) {\n this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT);\n if (this.element_.classList.contains(this.CssClasses_.JS_RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n this.rippleContainerElement_ = document.createElement('span');\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER);\n this.rippleContainerElement_.classList.add(this.CssClasses_.JS_RIPPLE_EFFECT);\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER);\n this.boundRippleMouseUp = this.onMouseUp_.bind(this);\n this.rippleContainerElement_.addEventListener('mouseup', this.boundRippleMouseUp);\n var ripple = document.createElement('span');\n ripple.classList.add(this.CssClasses_.RIPPLE);\n this.rippleContainerElement_.appendChild(ripple);\n this.element_.appendChild(this.rippleContainerElement_);\n }\n this.boundInputOnChange = this.onChange_.bind(this);\n this.boundInputOnFocus = this.onFocus_.bind(this);\n this.boundInputOnBlur = this.onBlur_.bind(this);\n this.boundElementOnMouseUp = this.onMouseUp_.bind(this);\n this.inputElement_.addEventListener('change', this.boundInputOnChange);\n this.inputElement_.addEventListener('focus', this.boundInputOnFocus);\n this.inputElement_.addEventListener('blur', this.boundInputOnBlur);\n this.element_.addEventListener('mouseup', this.boundElementOnMouseUp);\n this.updateClasses_();\n this.element_.classList.add('is-upgraded');\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialIconToggle,\n classAsString: 'MaterialIconToggle',\n cssClass: 'mdl-js-icon-toggle',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for dropdown MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialMenu = function MaterialMenu(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialMenu'] = MaterialMenu;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialMenu.prototype.Constant_ = {\n // Total duration of the menu animation.\n TRANSITION_DURATION_SECONDS: 0.3,\n // The fraction of the total duration we want to use for menu item animations.\n TRANSITION_DURATION_FRACTION: 0.8,\n // How long the menu stays open after choosing an option (so the user can see\n // the ripple).\n CLOSE_TIMEOUT: 150\n};\n/**\n * Keycodes, for code readability.\n *\n * @enum {number}\n * @private\n */\nMaterialMenu.prototype.Keycodes_ = {\n ENTER: 13,\n ESCAPE: 27,\n SPACE: 32,\n UP_ARROW: 38,\n DOWN_ARROW: 40\n};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialMenu.prototype.CssClasses_ = {\n CONTAINER: 'mdl-menu__container',\n OUTLINE: 'mdl-menu__outline',\n ITEM: 'mdl-menu__item',\n ITEM_RIPPLE_CONTAINER: 'mdl-menu__item-ripple-container',\n RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE: 'mdl-ripple',\n // Statuses\n IS_UPGRADED: 'is-upgraded',\n IS_VISIBLE: 'is-visible',\n IS_ANIMATING: 'is-animating',\n // Alignment options\n BOTTOM_LEFT: 'mdl-menu--bottom-left',\n // This is the default.\n BOTTOM_RIGHT: 'mdl-menu--bottom-right',\n TOP_LEFT: 'mdl-menu--top-left',\n TOP_RIGHT: 'mdl-menu--top-right',\n UNALIGNED: 'mdl-menu--unaligned'\n};\n/**\n * Initialize element.\n */\nMaterialMenu.prototype.init = function () {\n if (this.element_) {\n // Create container for the menu.\n var container = document.createElement('div');\n container.classList.add(this.CssClasses_.CONTAINER);\n this.element_.parentElement.insertBefore(container, this.element_);\n this.element_.parentElement.removeChild(this.element_);\n container.appendChild(this.element_);\n this.container_ = container;\n // Create outline for the menu (shadow and background).\n var outline = document.createElement('div');\n outline.classList.add(this.CssClasses_.OUTLINE);\n this.outline_ = outline;\n container.insertBefore(outline, this.element_);\n // Find the \"for\" element and bind events to it.\n var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for');\n var forEl = null;\n if (forElId) {\n forEl = document.getElementById(forElId);\n if (forEl) {\n this.forElement_ = forEl;\n forEl.addEventListener('click', this.handleForClick_.bind(this));\n forEl.addEventListener('keydown', this.handleForKeyboardEvent_.bind(this));\n }\n }\n var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM);\n this.boundItemKeydown_ = this.handleItemKeyboardEvent_.bind(this);\n this.boundItemClick_ = this.handleItemClick_.bind(this);\n for (var i = 0; i < items.length; i++) {\n // Add a listener to each menu item.\n items[i].addEventListener('click', this.boundItemClick_);\n // Add a tab index to each menu item.\n items[i].tabIndex = '-1';\n // Add a keyboard listener to each menu item.\n items[i].addEventListener('keydown', this.boundItemKeydown_);\n }\n // Add ripple classes to each item, if the user has enabled ripples.\n if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n for (i = 0; i < items.length; i++) {\n var item = items[i];\n var rippleContainer = document.createElement('span');\n rippleContainer.classList.add(this.CssClasses_.ITEM_RIPPLE_CONTAINER);\n var ripple = document.createElement('span');\n ripple.classList.add(this.CssClasses_.RIPPLE);\n rippleContainer.appendChild(ripple);\n item.appendChild(rippleContainer);\n item.classList.add(this.CssClasses_.RIPPLE_EFFECT);\n }\n }\n // Copy alignment classes to the container, so the outline can use them.\n if (this.element_.classList.contains(this.CssClasses_.BOTTOM_LEFT)) {\n this.outline_.classList.add(this.CssClasses_.BOTTOM_LEFT);\n }\n if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) {\n this.outline_.classList.add(this.CssClasses_.BOTTOM_RIGHT);\n }\n if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) {\n this.outline_.classList.add(this.CssClasses_.TOP_LEFT);\n }\n if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) {\n this.outline_.classList.add(this.CssClasses_.TOP_RIGHT);\n }\n if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) {\n this.outline_.classList.add(this.CssClasses_.UNALIGNED);\n }\n container.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n};\n/**\n * Handles a click on the \"for\" element, by positioning the menu and then\n * toggling it.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialMenu.prototype.handleForClick_ = function (evt) {\n if (this.element_ && this.forElement_) {\n var rect = this.forElement_.getBoundingClientRect();\n var forRect = this.forElement_.parentElement.getBoundingClientRect();\n if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) {\n } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) {\n // Position below the \"for\" element, aligned to its right.\n this.container_.style.right = forRect.right - rect.right + 'px';\n this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px';\n } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) {\n // Position above the \"for\" element, aligned to its left.\n this.container_.style.left = this.forElement_.offsetLeft + 'px';\n this.container_.style.bottom = forRect.bottom - rect.top + 'px';\n } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) {\n // Position above the \"for\" element, aligned to its right.\n this.container_.style.right = forRect.right - rect.right + 'px';\n this.container_.style.bottom = forRect.bottom - rect.top + 'px';\n } else {\n // Default: position below the \"for\" element, aligned to its left.\n this.container_.style.left = this.forElement_.offsetLeft + 'px';\n this.container_.style.top = this.forElement_.offsetTop + this.forElement_.offsetHeight + 'px';\n }\n }\n this.toggle(evt);\n};\n/**\n * Handles a keyboard event on the \"for\" element.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialMenu.prototype.handleForKeyboardEvent_ = function (evt) {\n if (this.element_ && this.container_ && this.forElement_) {\n var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])');\n if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) {\n if (evt.keyCode === this.Keycodes_.UP_ARROW) {\n evt.preventDefault();\n items[items.length - 1].focus();\n } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) {\n evt.preventDefault();\n items[0].focus();\n }\n }\n }\n};\n/**\n * Handles a keyboard event on an item.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialMenu.prototype.handleItemKeyboardEvent_ = function (evt) {\n if (this.element_ && this.container_) {\n var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM + ':not([disabled])');\n if (items && items.length > 0 && this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) {\n var currentIndex = Array.prototype.slice.call(items).indexOf(evt.target);\n if (evt.keyCode === this.Keycodes_.UP_ARROW) {\n evt.preventDefault();\n if (currentIndex > 0) {\n items[currentIndex - 1].focus();\n } else {\n items[items.length - 1].focus();\n }\n } else if (evt.keyCode === this.Keycodes_.DOWN_ARROW) {\n evt.preventDefault();\n if (items.length > currentIndex + 1) {\n items[currentIndex + 1].focus();\n } else {\n items[0].focus();\n }\n } else if (evt.keyCode === this.Keycodes_.SPACE || evt.keyCode === this.Keycodes_.ENTER) {\n evt.preventDefault();\n // Send mousedown and mouseup to trigger ripple.\n var e = new MouseEvent('mousedown');\n evt.target.dispatchEvent(e);\n e = new MouseEvent('mouseup');\n evt.target.dispatchEvent(e);\n // Send click.\n evt.target.click();\n } else if (evt.keyCode === this.Keycodes_.ESCAPE) {\n evt.preventDefault();\n this.hide();\n }\n }\n }\n};\n/**\n * Handles a click event on an item.\n *\n * @param {Event} evt The event that fired.\n * @private\n */\nMaterialMenu.prototype.handleItemClick_ = function (evt) {\n if (evt.target.hasAttribute('disabled')) {\n evt.stopPropagation();\n } else {\n // Wait some time before closing menu, so the user can see the ripple.\n this.closing_ = true;\n window.setTimeout(function (evt) {\n this.hide();\n this.closing_ = false;\n }.bind(this), this.Constant_.CLOSE_TIMEOUT);\n }\n};\n/**\n * Calculates the initial clip (for opening the menu) or final clip (for closing\n * it), and applies it. This allows us to animate from or to the correct point,\n * that is, the point it's aligned to in the \"for\" element.\n *\n * @param {number} height Height of the clip rectangle\n * @param {number} width Width of the clip rectangle\n * @private\n */\nMaterialMenu.prototype.applyClip_ = function (height, width) {\n if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) {\n // Do not clip.\n this.element_.style.clip = '';\n } else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) {\n // Clip to the top right corner of the menu.\n this.element_.style.clip = 'rect(0 ' + width + 'px ' + '0 ' + width + 'px)';\n } else if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT)) {\n // Clip to the bottom left corner of the menu.\n this.element_.style.clip = 'rect(' + height + 'px 0 ' + height + 'px 0)';\n } else if (this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) {\n // Clip to the bottom right corner of the menu.\n this.element_.style.clip = 'rect(' + height + 'px ' + width + 'px ' + height + 'px ' + width + 'px)';\n } else {\n // Default: do not clip (same as clipping to the top left corner).\n this.element_.style.clip = '';\n }\n};\n/**\n * Cleanup function to remove animation listeners.\n *\n * @param {Event} evt\n * @private\n */\nMaterialMenu.prototype.removeAnimationEndListener_ = function (evt) {\n evt.target.classList.remove(MaterialMenu.prototype.CssClasses_.IS_ANIMATING);\n};\n/**\n * Adds an event listener to clean up after the animation ends.\n *\n * @private\n */\nMaterialMenu.prototype.addAnimationEndListener_ = function () {\n this.element_.addEventListener('transitionend', this.removeAnimationEndListener_);\n this.element_.addEventListener('webkitTransitionEnd', this.removeAnimationEndListener_);\n};\n/**\n * Displays the menu.\n *\n * @public\n */\nMaterialMenu.prototype.show = function (evt) {\n if (this.element_ && this.container_ && this.outline_) {\n // Measure the inner element.\n var height = this.element_.getBoundingClientRect().height;\n var width = this.element_.getBoundingClientRect().width;\n // Apply the inner element's size to the container and outline.\n this.container_.style.width = width + 'px';\n this.container_.style.height = height + 'px';\n this.outline_.style.width = width + 'px';\n this.outline_.style.height = height + 'px';\n var transitionDuration = this.Constant_.TRANSITION_DURATION_SECONDS * this.Constant_.TRANSITION_DURATION_FRACTION;\n // Calculate transition delays for individual menu items, so that they fade\n // in one at a time.\n var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM);\n for (var i = 0; i < items.length; i++) {\n var itemDelay = null;\n if (this.element_.classList.contains(this.CssClasses_.TOP_LEFT) || this.element_.classList.contains(this.CssClasses_.TOP_RIGHT)) {\n itemDelay = (height - items[i].offsetTop - items[i].offsetHeight) / height * transitionDuration + 's';\n } else {\n itemDelay = items[i].offsetTop / height * transitionDuration + 's';\n }\n items[i].style.transitionDelay = itemDelay;\n }\n // Apply the initial clip to the text before we start animating.\n this.applyClip_(height, width);\n // Wait for the next frame, turn on animation, and apply the final clip.\n // Also make it visible. This triggers the transitions.\n window.requestAnimationFrame(function () {\n this.element_.classList.add(this.CssClasses_.IS_ANIMATING);\n this.element_.style.clip = 'rect(0 ' + width + 'px ' + height + 'px 0)';\n this.container_.classList.add(this.CssClasses_.IS_VISIBLE);\n }.bind(this));\n // Clean up after the animation is complete.\n this.addAnimationEndListener_();\n // Add a click listener to the document, to close the menu.\n var callback = function (e) {\n // Check to see if the document is processing the same event that\n // displayed the menu in the first place. If so, do nothing.\n // Also check to see if the menu is in the process of closing itself, and\n // do nothing in that case.\n // Also check if the clicked element is a menu item\n // if so, do nothing.\n if (e !== evt && !this.closing_ && e.target.parentNode !== this.element_) {\n document.removeEventListener('click', callback);\n this.hide();\n }\n }.bind(this);\n document.addEventListener('click', callback);\n }\n};\nMaterialMenu.prototype['show'] = MaterialMenu.prototype.show;\n/**\n * Hides the menu.\n *\n * @public\n */\nMaterialMenu.prototype.hide = function () {\n if (this.element_ && this.container_ && this.outline_) {\n var items = this.element_.querySelectorAll('.' + this.CssClasses_.ITEM);\n // Remove all transition delays; menu items fade out concurrently.\n for (var i = 0; i < items.length; i++) {\n items[i].style.removeProperty('transition-delay');\n }\n // Measure the inner element.\n var rect = this.element_.getBoundingClientRect();\n var height = rect.height;\n var width = rect.width;\n // Turn on animation, and apply the final clip. Also make invisible.\n // This triggers the transitions.\n this.element_.classList.add(this.CssClasses_.IS_ANIMATING);\n this.applyClip_(height, width);\n this.container_.classList.remove(this.CssClasses_.IS_VISIBLE);\n // Clean up after the animation is complete.\n this.addAnimationEndListener_();\n }\n};\nMaterialMenu.prototype['hide'] = MaterialMenu.prototype.hide;\n/**\n * Displays or hides the menu, depending on current state.\n *\n * @public\n */\nMaterialMenu.prototype.toggle = function (evt) {\n if (this.container_.classList.contains(this.CssClasses_.IS_VISIBLE)) {\n this.hide();\n } else {\n this.show(evt);\n }\n};\nMaterialMenu.prototype['toggle'] = MaterialMenu.prototype.toggle;\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialMenu,\n classAsString: 'MaterialMenu',\n cssClass: 'mdl-js-menu',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Progress MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialProgress = function MaterialProgress(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialProgress'] = MaterialProgress;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialProgress.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialProgress.prototype.CssClasses_ = { INDETERMINATE_CLASS: 'mdl-progress__indeterminate' };\n/**\n * Set the current progress of the progressbar.\n *\n * @param {number} p Percentage of the progress (0-100)\n * @public\n */\nMaterialProgress.prototype.setProgress = function (p) {\n if (this.element_.classList.contains(this.CssClasses_.INDETERMINATE_CLASS)) {\n return;\n }\n this.progressbar_.style.width = p + '%';\n};\nMaterialProgress.prototype['setProgress'] = MaterialProgress.prototype.setProgress;\n/**\n * Set the current progress of the buffer.\n *\n * @param {number} p Percentage of the buffer (0-100)\n * @public\n */\nMaterialProgress.prototype.setBuffer = function (p) {\n this.bufferbar_.style.width = p + '%';\n this.auxbar_.style.width = 100 - p + '%';\n};\nMaterialProgress.prototype['setBuffer'] = MaterialProgress.prototype.setBuffer;\n/**\n * Initialize element.\n */\nMaterialProgress.prototype.init = function () {\n if (this.element_) {\n var el = document.createElement('div');\n el.className = 'progressbar bar bar1';\n this.element_.appendChild(el);\n this.progressbar_ = el;\n el = document.createElement('div');\n el.className = 'bufferbar bar bar2';\n this.element_.appendChild(el);\n this.bufferbar_ = el;\n el = document.createElement('div');\n el.className = 'auxbar bar bar3';\n this.element_.appendChild(el);\n this.auxbar_ = el;\n this.progressbar_.style.width = '0%';\n this.bufferbar_.style.width = '100%';\n this.auxbar_.style.width = '0%';\n this.element_.classList.add('is-upgraded');\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialProgress,\n classAsString: 'MaterialProgress',\n cssClass: 'mdl-js-progress',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Radio MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialRadio = function MaterialRadio(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialRadio'] = MaterialRadio;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialRadio.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialRadio.prototype.CssClasses_ = {\n IS_FOCUSED: 'is-focused',\n IS_DISABLED: 'is-disabled',\n IS_CHECKED: 'is-checked',\n IS_UPGRADED: 'is-upgraded',\n JS_RADIO: 'mdl-js-radio',\n RADIO_BTN: 'mdl-radio__button',\n RADIO_OUTER_CIRCLE: 'mdl-radio__outer-circle',\n RADIO_INNER_CIRCLE: 'mdl-radio__inner-circle',\n RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE_CONTAINER: 'mdl-radio__ripple-container',\n RIPPLE_CENTER: 'mdl-ripple--center',\n RIPPLE: 'mdl-ripple'\n};\n/**\n * Handle change of state.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRadio.prototype.onChange_ = function (event) {\n // Since other radio buttons don't get change events, we need to look for\n // them to update their classes.\n var radios = document.getElementsByClassName(this.CssClasses_.JS_RADIO);\n for (var i = 0; i < radios.length; i++) {\n var button = radios[i].querySelector('.' + this.CssClasses_.RADIO_BTN);\n // Different name == different group, so no point updating those.\n if (button.getAttribute('name') === this.btnElement_.getAttribute('name')) {\n if (typeof radios[i]['MaterialRadio'] !== 'undefined') {\n radios[i]['MaterialRadio'].updateClasses_();\n }\n }\n }\n};\n/**\n * Handle focus.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRadio.prototype.onFocus_ = function (event) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle lost focus.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRadio.prototype.onBlur_ = function (event) {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle mouseup.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRadio.prototype.onMouseup_ = function (event) {\n this.blur_();\n};\n/**\n * Update classes.\n *\n * @private\n */\nMaterialRadio.prototype.updateClasses_ = function () {\n this.checkDisabled();\n this.checkToggleState();\n};\n/**\n * Add blur.\n *\n * @private\n */\nMaterialRadio.prototype.blur_ = function () {\n // TODO: figure out why there's a focus event being fired after our blur,\n // so that we can avoid this hack.\n window.setTimeout(function () {\n this.btnElement_.blur();\n }.bind(this), this.Constant_.TINY_TIMEOUT);\n};\n// Public methods.\n/**\n * Check the components disabled state.\n *\n * @public\n */\nMaterialRadio.prototype.checkDisabled = function () {\n if (this.btnElement_.disabled) {\n this.element_.classList.add(this.CssClasses_.IS_DISABLED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DISABLED);\n }\n};\nMaterialRadio.prototype['checkDisabled'] = MaterialRadio.prototype.checkDisabled;\n/**\n * Check the components toggled state.\n *\n * @public\n */\nMaterialRadio.prototype.checkToggleState = function () {\n if (this.btnElement_.checked) {\n this.element_.classList.add(this.CssClasses_.IS_CHECKED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_CHECKED);\n }\n};\nMaterialRadio.prototype['checkToggleState'] = MaterialRadio.prototype.checkToggleState;\n/**\n * Disable radio.\n *\n * @public\n */\nMaterialRadio.prototype.disable = function () {\n this.btnElement_.disabled = true;\n this.updateClasses_();\n};\nMaterialRadio.prototype['disable'] = MaterialRadio.prototype.disable;\n/**\n * Enable radio.\n *\n * @public\n */\nMaterialRadio.prototype.enable = function () {\n this.btnElement_.disabled = false;\n this.updateClasses_();\n};\nMaterialRadio.prototype['enable'] = MaterialRadio.prototype.enable;\n/**\n * Check radio.\n *\n * @public\n */\nMaterialRadio.prototype.check = function () {\n this.btnElement_.checked = true;\n this.onChange_(null);\n};\nMaterialRadio.prototype['check'] = MaterialRadio.prototype.check;\n/**\n * Uncheck radio.\n *\n * @public\n */\nMaterialRadio.prototype.uncheck = function () {\n this.btnElement_.checked = false;\n this.onChange_(null);\n};\nMaterialRadio.prototype['uncheck'] = MaterialRadio.prototype.uncheck;\n/**\n * Initialize element.\n */\nMaterialRadio.prototype.init = function () {\n if (this.element_) {\n this.btnElement_ = this.element_.querySelector('.' + this.CssClasses_.RADIO_BTN);\n this.boundChangeHandler_ = this.onChange_.bind(this);\n this.boundFocusHandler_ = this.onChange_.bind(this);\n this.boundBlurHandler_ = this.onBlur_.bind(this);\n this.boundMouseUpHandler_ = this.onMouseup_.bind(this);\n var outerCircle = document.createElement('span');\n outerCircle.classList.add(this.CssClasses_.RADIO_OUTER_CIRCLE);\n var innerCircle = document.createElement('span');\n innerCircle.classList.add(this.CssClasses_.RADIO_INNER_CIRCLE);\n this.element_.appendChild(outerCircle);\n this.element_.appendChild(innerCircle);\n var rippleContainer;\n if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n rippleContainer = document.createElement('span');\n rippleContainer.classList.add(this.CssClasses_.RIPPLE_CONTAINER);\n rippleContainer.classList.add(this.CssClasses_.RIPPLE_EFFECT);\n rippleContainer.classList.add(this.CssClasses_.RIPPLE_CENTER);\n rippleContainer.addEventListener('mouseup', this.boundMouseUpHandler_);\n var ripple = document.createElement('span');\n ripple.classList.add(this.CssClasses_.RIPPLE);\n rippleContainer.appendChild(ripple);\n this.element_.appendChild(rippleContainer);\n }\n this.btnElement_.addEventListener('change', this.boundChangeHandler_);\n this.btnElement_.addEventListener('focus', this.boundFocusHandler_);\n this.btnElement_.addEventListener('blur', this.boundBlurHandler_);\n this.element_.addEventListener('mouseup', this.boundMouseUpHandler_);\n this.updateClasses_();\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialRadio,\n classAsString: 'MaterialRadio',\n cssClass: 'mdl-js-radio',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Slider MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialSlider = function MaterialSlider(element) {\n this.element_ = element;\n // Browser feature detection.\n this.isIE_ = window.navigator.msPointerEnabled;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialSlider'] = MaterialSlider;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialSlider.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialSlider.prototype.CssClasses_ = {\n IE_CONTAINER: 'mdl-slider__ie-container',\n SLIDER_CONTAINER: 'mdl-slider__container',\n BACKGROUND_FLEX: 'mdl-slider__background-flex',\n BACKGROUND_LOWER: 'mdl-slider__background-lower',\n BACKGROUND_UPPER: 'mdl-slider__background-upper',\n IS_LOWEST_VALUE: 'is-lowest-value',\n IS_UPGRADED: 'is-upgraded'\n};\n/**\n * Handle input on element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSlider.prototype.onInput_ = function (event) {\n this.updateValueStyles_();\n};\n/**\n * Handle change on element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSlider.prototype.onChange_ = function (event) {\n this.updateValueStyles_();\n};\n/**\n * Handle mouseup on element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSlider.prototype.onMouseUp_ = function (event) {\n event.target.blur();\n};\n/**\n * Handle mousedown on container element.\n * This handler is purpose is to not require the use to click\n * exactly on the 2px slider element, as FireFox seems to be very\n * strict about this.\n *\n * @param {Event} event The event that fired.\n * @private\n * @suppress {missingProperties}\n */\nMaterialSlider.prototype.onContainerMouseDown_ = function (event) {\n // If this click is not on the parent element (but rather some child)\n // ignore. It may still bubble up.\n if (event.target !== this.element_.parentElement) {\n return;\n }\n // Discard the original event and create a new event that\n // is on the slider element.\n event.preventDefault();\n var newEvent = new MouseEvent('mousedown', {\n target: event.target,\n buttons: event.buttons,\n clientX: event.clientX,\n clientY: this.element_.getBoundingClientRect().y\n });\n this.element_.dispatchEvent(newEvent);\n};\n/**\n * Handle updating of values.\n *\n * @private\n */\nMaterialSlider.prototype.updateValueStyles_ = function () {\n // Calculate and apply percentages to div structure behind slider.\n var fraction = (this.element_.value - this.element_.min) / (this.element_.max - this.element_.min);\n if (fraction === 0) {\n this.element_.classList.add(this.CssClasses_.IS_LOWEST_VALUE);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_LOWEST_VALUE);\n }\n if (!this.isIE_) {\n this.backgroundLower_.style.flex = fraction;\n this.backgroundLower_.style.webkitFlex = fraction;\n this.backgroundUpper_.style.flex = 1 - fraction;\n this.backgroundUpper_.style.webkitFlex = 1 - fraction;\n }\n};\n// Public methods.\n/**\n * Disable slider.\n *\n * @public\n */\nMaterialSlider.prototype.disable = function () {\n this.element_.disabled = true;\n};\nMaterialSlider.prototype['disable'] = MaterialSlider.prototype.disable;\n/**\n * Enable slider.\n *\n * @public\n */\nMaterialSlider.prototype.enable = function () {\n this.element_.disabled = false;\n};\nMaterialSlider.prototype['enable'] = MaterialSlider.prototype.enable;\n/**\n * Update slider value.\n *\n * @param {number} value The value to which to set the control (optional).\n * @public\n */\nMaterialSlider.prototype.change = function (value) {\n if (typeof value !== 'undefined') {\n this.element_.value = value;\n }\n this.updateValueStyles_();\n};\nMaterialSlider.prototype['change'] = MaterialSlider.prototype.change;\n/**\n * Initialize element.\n */\nMaterialSlider.prototype.init = function () {\n if (this.element_) {\n if (this.isIE_) {\n // Since we need to specify a very large height in IE due to\n // implementation limitations, we add a parent here that trims it down to\n // a reasonable size.\n var containerIE = document.createElement('div');\n containerIE.classList.add(this.CssClasses_.IE_CONTAINER);\n this.element_.parentElement.insertBefore(containerIE, this.element_);\n this.element_.parentElement.removeChild(this.element_);\n containerIE.appendChild(this.element_);\n } else {\n // For non-IE browsers, we need a div structure that sits behind the\n // slider and allows us to style the left and right sides of it with\n // different colors.\n var container = document.createElement('div');\n container.classList.add(this.CssClasses_.SLIDER_CONTAINER);\n this.element_.parentElement.insertBefore(container, this.element_);\n this.element_.parentElement.removeChild(this.element_);\n container.appendChild(this.element_);\n var backgroundFlex = document.createElement('div');\n backgroundFlex.classList.add(this.CssClasses_.BACKGROUND_FLEX);\n container.appendChild(backgroundFlex);\n this.backgroundLower_ = document.createElement('div');\n this.backgroundLower_.classList.add(this.CssClasses_.BACKGROUND_LOWER);\n backgroundFlex.appendChild(this.backgroundLower_);\n this.backgroundUpper_ = document.createElement('div');\n this.backgroundUpper_.classList.add(this.CssClasses_.BACKGROUND_UPPER);\n backgroundFlex.appendChild(this.backgroundUpper_);\n }\n this.boundInputHandler = this.onInput_.bind(this);\n this.boundChangeHandler = this.onChange_.bind(this);\n this.boundMouseUpHandler = this.onMouseUp_.bind(this);\n this.boundContainerMouseDownHandler = this.onContainerMouseDown_.bind(this);\n this.element_.addEventListener('input', this.boundInputHandler);\n this.element_.addEventListener('change', this.boundChangeHandler);\n this.element_.addEventListener('mouseup', this.boundMouseUpHandler);\n this.element_.parentElement.addEventListener('mousedown', this.boundContainerMouseDownHandler);\n this.updateValueStyles_();\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialSlider,\n classAsString: 'MaterialSlider',\n cssClass: 'mdl-js-slider',\n widget: true\n});","/**\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Snackbar MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialSnackbar = function MaterialSnackbar(element) {\n this.element_ = element;\n this.textElement_ = this.element_.querySelector('.' + this.cssClasses_.MESSAGE);\n this.actionElement_ = this.element_.querySelector('.' + this.cssClasses_.ACTION);\n if (!this.textElement_) {\n throw new Error('There must be a message element for a snackbar.');\n }\n if (!this.actionElement_) {\n throw new Error('There must be an action element for a snackbar.');\n }\n this.active = false;\n this.actionHandler_ = undefined;\n this.message_ = undefined;\n this.actionText_ = undefined;\n this.queuedNotifications_ = [];\n this.setActionHidden_(true);\n};\nwindow['MaterialSnackbar'] = MaterialSnackbar;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialSnackbar.prototype.Constant_ = {\n // The duration of the snackbar show/hide animation, in ms.\n ANIMATION_LENGTH: 250\n};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialSnackbar.prototype.cssClasses_ = {\n SNACKBAR: 'mdl-snackbar',\n MESSAGE: 'mdl-snackbar__text',\n ACTION: 'mdl-snackbar__action',\n ACTIVE: 'mdl-snackbar--active'\n};\n/**\n * Display the snackbar.\n *\n * @private\n */\nMaterialSnackbar.prototype.displaySnackbar_ = function () {\n this.element_.setAttribute('aria-hidden', 'true');\n if (this.actionHandler_) {\n this.actionElement_.textContent = this.actionText_;\n this.actionElement_.addEventListener('click', this.actionHandler_);\n this.setActionHidden_(false);\n }\n this.textElement_.textContent = this.message_;\n this.element_.classList.add(this.cssClasses_.ACTIVE);\n this.element_.setAttribute('aria-hidden', 'false');\n setTimeout(this.cleanup_.bind(this), this.timeout_);\n};\n/**\n * Show the snackbar.\n *\n * @param {Object} data The data for the notification.\n * @public\n */\nMaterialSnackbar.prototype.showSnackbar = function (data) {\n if (data === undefined) {\n throw new Error('Please provide a data object with at least a message to display.');\n }\n if (data['message'] === undefined) {\n throw new Error('Please provide a message to be displayed.');\n }\n if (data['actionHandler'] && !data['actionText']) {\n throw new Error('Please provide action text with the handler.');\n }\n if (this.active) {\n this.queuedNotifications_.push(data);\n } else {\n this.active = true;\n this.message_ = data['message'];\n if (data['timeout']) {\n this.timeout_ = data['timeout'];\n } else {\n this.timeout_ = 2750;\n }\n if (data['actionHandler']) {\n this.actionHandler_ = data['actionHandler'];\n }\n if (data['actionText']) {\n this.actionText_ = data['actionText'];\n }\n this.displaySnackbar_();\n }\n};\nMaterialSnackbar.prototype['showSnackbar'] = MaterialSnackbar.prototype.showSnackbar;\n/**\n * Check if the queue has items within it.\n * If it does, display the next entry.\n *\n * @private\n */\nMaterialSnackbar.prototype.checkQueue_ = function () {\n if (this.queuedNotifications_.length > 0) {\n this.showSnackbar(this.queuedNotifications_.shift());\n }\n};\n/**\n * Cleanup the snackbar event listeners and accessiblity attributes.\n *\n * @private\n */\nMaterialSnackbar.prototype.cleanup_ = function () {\n this.element_.classList.remove(this.cssClasses_.ACTIVE);\n setTimeout(function () {\n this.element_.setAttribute('aria-hidden', 'true');\n this.textElement_.textContent = '';\n if (!Boolean(this.actionElement_.getAttribute('aria-hidden'))) {\n this.setActionHidden_(true);\n this.actionElement_.textContent = '';\n this.actionElement_.removeEventListener('click', this.actionHandler_);\n }\n this.actionHandler_ = undefined;\n this.message_ = undefined;\n this.actionText_ = undefined;\n this.active = false;\n this.checkQueue_();\n }.bind(this), this.Constant_.ANIMATION_LENGTH);\n};\n/**\n * Set the action handler hidden state.\n *\n * @param {boolean} value\n * @private\n */\nMaterialSnackbar.prototype.setActionHidden_ = function (value) {\n if (value) {\n this.actionElement_.setAttribute('aria-hidden', 'true');\n } else {\n this.actionElement_.removeAttribute('aria-hidden');\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialSnackbar,\n classAsString: 'MaterialSnackbar',\n cssClass: 'mdl-js-snackbar',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Spinner MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @param {HTMLElement} element The element that will be upgraded.\n * @constructor\n */\nvar MaterialSpinner = function MaterialSpinner(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialSpinner'] = MaterialSpinner;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialSpinner.prototype.Constant_ = { MDL_SPINNER_LAYER_COUNT: 4 };\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialSpinner.prototype.CssClasses_ = {\n MDL_SPINNER_LAYER: 'mdl-spinner__layer',\n MDL_SPINNER_CIRCLE_CLIPPER: 'mdl-spinner__circle-clipper',\n MDL_SPINNER_CIRCLE: 'mdl-spinner__circle',\n MDL_SPINNER_GAP_PATCH: 'mdl-spinner__gap-patch',\n MDL_SPINNER_LEFT: 'mdl-spinner__left',\n MDL_SPINNER_RIGHT: 'mdl-spinner__right'\n};\n/**\n * Auxiliary method to create a spinner layer.\n *\n * @param {number} index Index of the layer to be created.\n * @public\n */\nMaterialSpinner.prototype.createLayer = function (index) {\n var layer = document.createElement('div');\n layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER);\n layer.classList.add(this.CssClasses_.MDL_SPINNER_LAYER + '-' + index);\n var leftClipper = document.createElement('div');\n leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER);\n leftClipper.classList.add(this.CssClasses_.MDL_SPINNER_LEFT);\n var gapPatch = document.createElement('div');\n gapPatch.classList.add(this.CssClasses_.MDL_SPINNER_GAP_PATCH);\n var rightClipper = document.createElement('div');\n rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE_CLIPPER);\n rightClipper.classList.add(this.CssClasses_.MDL_SPINNER_RIGHT);\n var circleOwners = [\n leftClipper,\n gapPatch,\n rightClipper\n ];\n for (var i = 0; i < circleOwners.length; i++) {\n var circle = document.createElement('div');\n circle.classList.add(this.CssClasses_.MDL_SPINNER_CIRCLE);\n circleOwners[i].appendChild(circle);\n }\n layer.appendChild(leftClipper);\n layer.appendChild(gapPatch);\n layer.appendChild(rightClipper);\n this.element_.appendChild(layer);\n};\nMaterialSpinner.prototype['createLayer'] = MaterialSpinner.prototype.createLayer;\n/**\n * Stops the spinner animation.\n * Public method for users who need to stop the spinner for any reason.\n *\n * @public\n */\nMaterialSpinner.prototype.stop = function () {\n this.element_.classList.remove('is-active');\n};\nMaterialSpinner.prototype['stop'] = MaterialSpinner.prototype.stop;\n/**\n * Starts the spinner animation.\n * Public method for users who need to manually start the spinner for any reason\n * (instead of just adding the 'is-active' class to their markup).\n *\n * @public\n */\nMaterialSpinner.prototype.start = function () {\n this.element_.classList.add('is-active');\n};\nMaterialSpinner.prototype['start'] = MaterialSpinner.prototype.start;\n/**\n * Initialize element.\n */\nMaterialSpinner.prototype.init = function () {\n if (this.element_) {\n for (var i = 1; i <= this.Constant_.MDL_SPINNER_LAYER_COUNT; i++) {\n this.createLayer(i);\n }\n this.element_.classList.add('is-upgraded');\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialSpinner,\n classAsString: 'MaterialSpinner',\n cssClass: 'mdl-js-spinner',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Checkbox MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialSwitch = function MaterialSwitch(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialSwitch'] = MaterialSwitch;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialSwitch.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialSwitch.prototype.CssClasses_ = {\n INPUT: 'mdl-switch__input',\n TRACK: 'mdl-switch__track',\n THUMB: 'mdl-switch__thumb',\n FOCUS_HELPER: 'mdl-switch__focus-helper',\n RIPPLE_EFFECT: 'mdl-js-ripple-effect',\n RIPPLE_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE_CONTAINER: 'mdl-switch__ripple-container',\n RIPPLE_CENTER: 'mdl-ripple--center',\n RIPPLE: 'mdl-ripple',\n IS_FOCUSED: 'is-focused',\n IS_DISABLED: 'is-disabled',\n IS_CHECKED: 'is-checked'\n};\n/**\n * Handle change of state.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSwitch.prototype.onChange_ = function (event) {\n this.updateClasses_();\n};\n/**\n * Handle focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSwitch.prototype.onFocus_ = function (event) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle lost focus of element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSwitch.prototype.onBlur_ = function (event) {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle mouseup.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialSwitch.prototype.onMouseUp_ = function (event) {\n this.blur_();\n};\n/**\n * Handle class updates.\n *\n * @private\n */\nMaterialSwitch.prototype.updateClasses_ = function () {\n this.checkDisabled();\n this.checkToggleState();\n};\n/**\n * Add blur.\n *\n * @private\n */\nMaterialSwitch.prototype.blur_ = function () {\n // TODO: figure out why there's a focus event being fired after our blur,\n // so that we can avoid this hack.\n window.setTimeout(function () {\n this.inputElement_.blur();\n }.bind(this), this.Constant_.TINY_TIMEOUT);\n};\n// Public methods.\n/**\n * Check the components disabled state.\n *\n * @public\n */\nMaterialSwitch.prototype.checkDisabled = function () {\n if (this.inputElement_.disabled) {\n this.element_.classList.add(this.CssClasses_.IS_DISABLED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DISABLED);\n }\n};\nMaterialSwitch.prototype['checkDisabled'] = MaterialSwitch.prototype.checkDisabled;\n/**\n * Check the components toggled state.\n *\n * @public\n */\nMaterialSwitch.prototype.checkToggleState = function () {\n if (this.inputElement_.checked) {\n this.element_.classList.add(this.CssClasses_.IS_CHECKED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_CHECKED);\n }\n};\nMaterialSwitch.prototype['checkToggleState'] = MaterialSwitch.prototype.checkToggleState;\n/**\n * Disable switch.\n *\n * @public\n */\nMaterialSwitch.prototype.disable = function () {\n this.inputElement_.disabled = true;\n this.updateClasses_();\n};\nMaterialSwitch.prototype['disable'] = MaterialSwitch.prototype.disable;\n/**\n * Enable switch.\n *\n * @public\n */\nMaterialSwitch.prototype.enable = function () {\n this.inputElement_.disabled = false;\n this.updateClasses_();\n};\nMaterialSwitch.prototype['enable'] = MaterialSwitch.prototype.enable;\n/**\n * Activate switch.\n *\n * @public\n */\nMaterialSwitch.prototype.on = function () {\n this.inputElement_.checked = true;\n this.updateClasses_();\n};\nMaterialSwitch.prototype['on'] = MaterialSwitch.prototype.on;\n/**\n * Deactivate switch.\n *\n * @public\n */\nMaterialSwitch.prototype.off = function () {\n this.inputElement_.checked = false;\n this.updateClasses_();\n};\nMaterialSwitch.prototype['off'] = MaterialSwitch.prototype.off;\n/**\n * Initialize element.\n */\nMaterialSwitch.prototype.init = function () {\n if (this.element_) {\n this.inputElement_ = this.element_.querySelector('.' + this.CssClasses_.INPUT);\n var track = document.createElement('div');\n track.classList.add(this.CssClasses_.TRACK);\n var thumb = document.createElement('div');\n thumb.classList.add(this.CssClasses_.THUMB);\n var focusHelper = document.createElement('span');\n focusHelper.classList.add(this.CssClasses_.FOCUS_HELPER);\n thumb.appendChild(focusHelper);\n this.element_.appendChild(track);\n this.element_.appendChild(thumb);\n this.boundMouseUpHandler = this.onMouseUp_.bind(this);\n if (this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT)) {\n this.element_.classList.add(this.CssClasses_.RIPPLE_IGNORE_EVENTS);\n this.rippleContainerElement_ = document.createElement('span');\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CONTAINER);\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_EFFECT);\n this.rippleContainerElement_.classList.add(this.CssClasses_.RIPPLE_CENTER);\n this.rippleContainerElement_.addEventListener('mouseup', this.boundMouseUpHandler);\n var ripple = document.createElement('span');\n ripple.classList.add(this.CssClasses_.RIPPLE);\n this.rippleContainerElement_.appendChild(ripple);\n this.element_.appendChild(this.rippleContainerElement_);\n }\n this.boundChangeHandler = this.onChange_.bind(this);\n this.boundFocusHandler = this.onFocus_.bind(this);\n this.boundBlurHandler = this.onBlur_.bind(this);\n this.inputElement_.addEventListener('change', this.boundChangeHandler);\n this.inputElement_.addEventListener('focus', this.boundFocusHandler);\n this.inputElement_.addEventListener('blur', this.boundBlurHandler);\n this.element_.addEventListener('mouseup', this.boundMouseUpHandler);\n this.updateClasses_();\n this.element_.classList.add('is-upgraded');\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialSwitch,\n classAsString: 'MaterialSwitch',\n cssClass: 'mdl-js-switch',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Textfield MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialTextfield = function MaterialTextfield(element) {\n this.element_ = element;\n this.maxRows = this.Constant_.NO_MAX_ROWS;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialTextfield'] = MaterialTextfield;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialTextfield.prototype.Constant_ = {\n NO_MAX_ROWS: -1,\n MAX_ROWS_ATTRIBUTE: 'maxrows'\n};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialTextfield.prototype.CssClasses_ = {\n LABEL: 'mdl-textfield__label',\n INPUT: 'mdl-textfield__input',\n IS_DIRTY: 'is-dirty',\n IS_FOCUSED: 'is-focused',\n IS_DISABLED: 'is-disabled',\n IS_INVALID: 'is-invalid',\n IS_UPGRADED: 'is-upgraded',\n HAS_PLACEHOLDER: 'has-placeholder'\n};\n/**\n * Handle input being entered.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialTextfield.prototype.onKeyDown_ = function (event) {\n var currentRowCount = event.target.value.split('\\n').length;\n if (event.keyCode === 13) {\n if (currentRowCount >= this.maxRows) {\n event.preventDefault();\n }\n }\n};\n/**\n * Handle focus.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialTextfield.prototype.onFocus_ = function (event) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle lost focus.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialTextfield.prototype.onBlur_ = function (event) {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n};\n/**\n * Handle reset event from out side.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialTextfield.prototype.onReset_ = function (event) {\n this.updateClasses_();\n};\n/**\n * Handle class updates.\n *\n * @private\n */\nMaterialTextfield.prototype.updateClasses_ = function () {\n this.checkDisabled();\n this.checkValidity();\n this.checkDirty();\n this.checkFocus();\n};\n// Public methods.\n/**\n * Check the disabled state and update field accordingly.\n *\n * @public\n */\nMaterialTextfield.prototype.checkDisabled = function () {\n if (this.input_.disabled) {\n this.element_.classList.add(this.CssClasses_.IS_DISABLED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DISABLED);\n }\n};\nMaterialTextfield.prototype['checkDisabled'] = MaterialTextfield.prototype.checkDisabled;\n/**\n * Check the focus state and update field accordingly.\n *\n * @public\n */\nMaterialTextfield.prototype.checkFocus = function () {\n if (Boolean(this.element_.querySelector(':focus'))) {\n this.element_.classList.add(this.CssClasses_.IS_FOCUSED);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_FOCUSED);\n }\n};\nMaterialTextfield.prototype['checkFocus'] = MaterialTextfield.prototype.checkFocus;\n/**\n * Check the validity state and update field accordingly.\n *\n * @public\n */\nMaterialTextfield.prototype.checkValidity = function () {\n if (this.input_.validity) {\n if (this.input_.validity.valid) {\n this.element_.classList.remove(this.CssClasses_.IS_INVALID);\n } else {\n this.element_.classList.add(this.CssClasses_.IS_INVALID);\n }\n }\n};\nMaterialTextfield.prototype['checkValidity'] = MaterialTextfield.prototype.checkValidity;\n/**\n * Check the dirty state and update field accordingly.\n *\n * @public\n */\nMaterialTextfield.prototype.checkDirty = function () {\n if (this.input_.value && this.input_.value.length > 0) {\n this.element_.classList.add(this.CssClasses_.IS_DIRTY);\n } else {\n this.element_.classList.remove(this.CssClasses_.IS_DIRTY);\n }\n};\nMaterialTextfield.prototype['checkDirty'] = MaterialTextfield.prototype.checkDirty;\n/**\n * Disable text field.\n *\n * @public\n */\nMaterialTextfield.prototype.disable = function () {\n this.input_.disabled = true;\n this.updateClasses_();\n};\nMaterialTextfield.prototype['disable'] = MaterialTextfield.prototype.disable;\n/**\n * Enable text field.\n *\n * @public\n */\nMaterialTextfield.prototype.enable = function () {\n this.input_.disabled = false;\n this.updateClasses_();\n};\nMaterialTextfield.prototype['enable'] = MaterialTextfield.prototype.enable;\n/**\n * Update text field value.\n *\n * @param {string} value The value to which to set the control (optional).\n * @public\n */\nMaterialTextfield.prototype.change = function (value) {\n this.input_.value = value || '';\n this.updateClasses_();\n};\nMaterialTextfield.prototype['change'] = MaterialTextfield.prototype.change;\n/**\n * Initialize element.\n */\nMaterialTextfield.prototype.init = function () {\n if (this.element_) {\n this.label_ = this.element_.querySelector('.' + this.CssClasses_.LABEL);\n this.input_ = this.element_.querySelector('.' + this.CssClasses_.INPUT);\n if (this.input_) {\n if (this.input_.hasAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE)) {\n this.maxRows = parseInt(this.input_.getAttribute(this.Constant_.MAX_ROWS_ATTRIBUTE), 10);\n if (isNaN(this.maxRows)) {\n this.maxRows = this.Constant_.NO_MAX_ROWS;\n }\n }\n if (this.input_.hasAttribute('placeholder')) {\n this.element_.classList.add(this.CssClasses_.HAS_PLACEHOLDER);\n }\n this.boundUpdateClassesHandler = this.updateClasses_.bind(this);\n this.boundFocusHandler = this.onFocus_.bind(this);\n this.boundBlurHandler = this.onBlur_.bind(this);\n this.boundResetHandler = this.onReset_.bind(this);\n this.input_.addEventListener('input', this.boundUpdateClassesHandler);\n this.input_.addEventListener('focus', this.boundFocusHandler);\n this.input_.addEventListener('blur', this.boundBlurHandler);\n this.input_.addEventListener('reset', this.boundResetHandler);\n if (this.maxRows !== this.Constant_.NO_MAX_ROWS) {\n // TODO: This should handle pasting multi line text.\n // Currently doesn't.\n this.boundKeyDownHandler = this.onKeyDown_.bind(this);\n this.input_.addEventListener('keydown', this.boundKeyDownHandler);\n }\n var invalid = this.element_.classList.contains(this.CssClasses_.IS_INVALID);\n this.updateClasses_();\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n if (invalid) {\n this.element_.classList.add(this.CssClasses_.IS_INVALID);\n }\n if (this.input_.hasAttribute('autofocus')) {\n this.element_.focus();\n this.checkFocus();\n }\n }\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialTextfield,\n classAsString: 'MaterialTextfield',\n cssClass: 'mdl-js-textfield',\n widget: true\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Tooltip MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialTooltip = function MaterialTooltip(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialTooltip'] = MaterialTooltip;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialTooltip.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialTooltip.prototype.CssClasses_ = {\n IS_ACTIVE: 'is-active',\n BOTTOM: 'mdl-tooltip--bottom',\n LEFT: 'mdl-tooltip--left',\n RIGHT: 'mdl-tooltip--right',\n TOP: 'mdl-tooltip--top'\n};\n/**\n * Handle mouseenter for tooltip.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialTooltip.prototype.handleMouseEnter_ = function (event) {\n var props = event.target.getBoundingClientRect();\n var left = props.left + props.width / 2;\n var top = props.top + props.height / 2;\n var marginLeft = -1 * (this.element_.offsetWidth / 2);\n var marginTop = -1 * (this.element_.offsetHeight / 2);\n if (this.element_.classList.contains(this.CssClasses_.LEFT) || this.element_.classList.contains(this.CssClasses_.RIGHT)) {\n left = props.width / 2;\n if (top + marginTop < 0) {\n this.element_.style.top = '0';\n this.element_.style.marginTop = '0';\n } else {\n this.element_.style.top = top + 'px';\n this.element_.style.marginTop = marginTop + 'px';\n }\n } else {\n if (left + marginLeft < 0) {\n this.element_.style.left = '0';\n this.element_.style.marginLeft = '0';\n } else {\n this.element_.style.left = left + 'px';\n this.element_.style.marginLeft = marginLeft + 'px';\n }\n }\n if (this.element_.classList.contains(this.CssClasses_.TOP)) {\n this.element_.style.top = props.top - this.element_.offsetHeight - 10 + 'px';\n } else if (this.element_.classList.contains(this.CssClasses_.RIGHT)) {\n this.element_.style.left = props.left + props.width + 10 + 'px';\n } else if (this.element_.classList.contains(this.CssClasses_.LEFT)) {\n this.element_.style.left = props.left - this.element_.offsetWidth - 10 + 'px';\n } else {\n this.element_.style.top = props.top + props.height + 10 + 'px';\n }\n this.element_.classList.add(this.CssClasses_.IS_ACTIVE);\n};\n/**\n * Hide tooltip on mouseleave or scroll\n *\n * @private\n */\nMaterialTooltip.prototype.hideTooltip_ = function () {\n this.element_.classList.remove(this.CssClasses_.IS_ACTIVE);\n};\n/**\n * Initialize element.\n */\nMaterialTooltip.prototype.init = function () {\n if (this.element_) {\n var forElId = this.element_.getAttribute('for') || this.element_.getAttribute('data-mdl-for');\n if (forElId) {\n this.forElement_ = document.getElementById(forElId);\n }\n if (this.forElement_) {\n // It's left here because it prevents accidental text selection on Android\n if (!this.forElement_.hasAttribute('tabindex')) {\n this.forElement_.setAttribute('tabindex', '0');\n }\n this.boundMouseEnterHandler = this.handleMouseEnter_.bind(this);\n this.boundMouseLeaveAndScrollHandler = this.hideTooltip_.bind(this);\n this.forElement_.addEventListener('mouseenter', this.boundMouseEnterHandler, false);\n this.forElement_.addEventListener('touchend', this.boundMouseEnterHandler, false);\n this.forElement_.addEventListener('mouseleave', this.boundMouseLeaveAndScrollHandler, false);\n window.addEventListener('scroll', this.boundMouseLeaveAndScrollHandler, true);\n window.addEventListener('touchstart', this.boundMouseLeaveAndScrollHandler);\n }\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialTooltip,\n classAsString: 'MaterialTooltip',\n cssClass: 'mdl-tooltip'\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Data Table Card MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {Element} element The element that will be upgraded.\n */\nvar MaterialDataTable = function MaterialDataTable(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialDataTable'] = MaterialDataTable;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialDataTable.prototype.Constant_ = {};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialDataTable.prototype.CssClasses_ = {\n DATA_TABLE: 'mdl-data-table',\n SELECTABLE: 'mdl-data-table--selectable',\n SELECT_ELEMENT: 'mdl-data-table__select',\n IS_SELECTED: 'is-selected',\n IS_UPGRADED: 'is-upgraded'\n};\n/**\n * Generates and returns a function that toggles the selection state of a\n * single row (or multiple rows).\n *\n * @param {Element} checkbox Checkbox that toggles the selection state.\n * @param {Element} row Row to toggle when checkbox changes.\n * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes.\n * @private\n */\nMaterialDataTable.prototype.selectRow_ = function (checkbox, row, opt_rows) {\n if (row) {\n return function () {\n if (checkbox.checked) {\n row.classList.add(this.CssClasses_.IS_SELECTED);\n } else {\n row.classList.remove(this.CssClasses_.IS_SELECTED);\n }\n }.bind(this);\n }\n if (opt_rows) {\n return function () {\n var i;\n var el;\n if (checkbox.checked) {\n for (i = 0; i < opt_rows.length; i++) {\n el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox');\n el['MaterialCheckbox'].check();\n opt_rows[i].classList.add(this.CssClasses_.IS_SELECTED);\n }\n } else {\n for (i = 0; i < opt_rows.length; i++) {\n el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox');\n el['MaterialCheckbox'].uncheck();\n opt_rows[i].classList.remove(this.CssClasses_.IS_SELECTED);\n }\n }\n }.bind(this);\n }\n};\n/**\n * Creates a checkbox for a single or or multiple rows and hooks up the\n * event handling.\n *\n * @param {Element} row Row to toggle when checkbox changes.\n * @param {(Array|NodeList)=} opt_rows Rows to toggle when checkbox changes.\n * @private\n */\nMaterialDataTable.prototype.createCheckbox_ = function (row, opt_rows) {\n var label = document.createElement('label');\n var labelClasses = [\n 'mdl-checkbox',\n 'mdl-js-checkbox',\n 'mdl-js-ripple-effect',\n this.CssClasses_.SELECT_ELEMENT\n ];\n label.className = labelClasses.join(' ');\n var checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.classList.add('mdl-checkbox__input');\n if (row) {\n checkbox.checked = row.classList.contains(this.CssClasses_.IS_SELECTED);\n checkbox.addEventListener('change', this.selectRow_(checkbox, row));\n } else if (opt_rows) {\n checkbox.addEventListener('change', this.selectRow_(checkbox, null, opt_rows));\n }\n label.appendChild(checkbox);\n componentHandler.upgradeElement(label, 'MaterialCheckbox');\n return label;\n};\n/**\n * Initialize element.\n */\nMaterialDataTable.prototype.init = function () {\n if (this.element_) {\n var firstHeader = this.element_.querySelector('th');\n var bodyRows = Array.prototype.slice.call(this.element_.querySelectorAll('tbody tr'));\n var footRows = Array.prototype.slice.call(this.element_.querySelectorAll('tfoot tr'));\n var rows = bodyRows.concat(footRows);\n if (this.element_.classList.contains(this.CssClasses_.SELECTABLE)) {\n var th = document.createElement('th');\n var headerCheckbox = this.createCheckbox_(null, rows);\n th.appendChild(headerCheckbox);\n firstHeader.parentElement.insertBefore(th, firstHeader);\n for (var i = 0; i < rows.length; i++) {\n var firstCell = rows[i].querySelector('td');\n if (firstCell) {\n var td = document.createElement('td');\n if (rows[i].parentNode.nodeName.toUpperCase() === 'TBODY') {\n var rowCheckbox = this.createCheckbox_(rows[i]);\n td.appendChild(rowCheckbox);\n }\n rows[i].insertBefore(td, firstCell);\n }\n }\n this.element_.classList.add(this.CssClasses_.IS_UPGRADED);\n }\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialDataTable,\n classAsString: 'MaterialDataTable',\n cssClass: 'mdl-js-data-table'\n});","/**\n * @license\n * Copyright 2015 Google Inc. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Class constructor for Ripple MDL component.\n * Implements MDL component design pattern defined at:\n * https://github.com/jasonmayes/mdl-component-design-pattern\n *\n * @constructor\n * @param {HTMLElement} element The element that will be upgraded.\n */\nvar MaterialRipple = function MaterialRipple(element) {\n this.element_ = element;\n // Initialize instance.\n this.init();\n};\nwindow['MaterialRipple'] = MaterialRipple;\n/**\n * Store constants in one place so they can be updated easily.\n *\n * @enum {string | number}\n * @private\n */\nMaterialRipple.prototype.Constant_ = {\n INITIAL_SCALE: 'scale(0.0001, 0.0001)',\n INITIAL_SIZE: '1px',\n INITIAL_OPACITY: '0.4',\n FINAL_OPACITY: '0',\n FINAL_SCALE: ''\n};\n/**\n * Store strings for class names defined by this component that are used in\n * JavaScript. This allows us to simply change it in one place should we\n * decide to modify at a later date.\n *\n * @enum {string}\n * @private\n */\nMaterialRipple.prototype.CssClasses_ = {\n RIPPLE_CENTER: 'mdl-ripple--center',\n RIPPLE_EFFECT_IGNORE_EVENTS: 'mdl-js-ripple-effect--ignore-events',\n RIPPLE: 'mdl-ripple',\n IS_ANIMATING: 'is-animating',\n IS_VISIBLE: 'is-visible'\n};\n/**\n * Handle mouse / finger down on element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRipple.prototype.downHandler_ = function (event) {\n if (!this.rippleElement_.style.width && !this.rippleElement_.style.height) {\n var rect = this.element_.getBoundingClientRect();\n this.boundHeight = rect.height;\n this.boundWidth = rect.width;\n this.rippleSize_ = Math.sqrt(rect.width * rect.width + rect.height * rect.height) * 2 + 2;\n this.rippleElement_.style.width = this.rippleSize_ + 'px';\n this.rippleElement_.style.height = this.rippleSize_ + 'px';\n }\n this.rippleElement_.classList.add(this.CssClasses_.IS_VISIBLE);\n if (event.type === 'mousedown' && this.ignoringMouseDown_) {\n this.ignoringMouseDown_ = false;\n } else {\n if (event.type === 'touchstart') {\n this.ignoringMouseDown_ = true;\n }\n var frameCount = this.getFrameCount();\n if (frameCount > 0) {\n return;\n }\n this.setFrameCount(1);\n var bound = event.currentTarget.getBoundingClientRect();\n var x;\n var y;\n // Check if we are handling a keyboard click.\n if (event.clientX === 0 && event.clientY === 0) {\n x = Math.round(bound.width / 2);\n y = Math.round(bound.height / 2);\n } else {\n var clientX = event.clientX !== undefined ? event.clientX : event.touches[0].clientX;\n var clientY = event.clientY !== undefined ? event.clientY : event.touches[0].clientY;\n x = Math.round(clientX - bound.left);\n y = Math.round(clientY - bound.top);\n }\n this.setRippleXY(x, y);\n this.setRippleStyles(true);\n window.requestAnimationFrame(this.animFrameHandler.bind(this));\n }\n};\n/**\n * Handle mouse / finger up on element.\n *\n * @param {Event} event The event that fired.\n * @private\n */\nMaterialRipple.prototype.upHandler_ = function (event) {\n // Don't fire for the artificial \"mouseup\" generated by a double-click.\n if (event && event.detail !== 2) {\n // Allow a repaint to occur before removing this class, so the animation\n // shows for tap events, which seem to trigger a mouseup too soon after\n // mousedown.\n window.setTimeout(function () {\n this.rippleElement_.classList.remove(this.CssClasses_.IS_VISIBLE);\n }.bind(this), 0);\n }\n};\n/**\n * Initialize element.\n */\nMaterialRipple.prototype.init = function () {\n if (this.element_) {\n var recentering = this.element_.classList.contains(this.CssClasses_.RIPPLE_CENTER);\n if (!this.element_.classList.contains(this.CssClasses_.RIPPLE_EFFECT_IGNORE_EVENTS)) {\n this.rippleElement_ = this.element_.querySelector('.' + this.CssClasses_.RIPPLE);\n this.frameCount_ = 0;\n this.rippleSize_ = 0;\n this.x_ = 0;\n this.y_ = 0;\n // Touch start produces a compat mouse down event, which would cause a\n // second ripples. To avoid that, we use this property to ignore the first\n // mouse down after a touch start.\n this.ignoringMouseDown_ = false;\n this.boundDownHandler = this.downHandler_.bind(this);\n this.element_.addEventListener('mousedown', this.boundDownHandler);\n this.element_.addEventListener('touchstart', this.boundDownHandler);\n this.boundUpHandler = this.upHandler_.bind(this);\n this.element_.addEventListener('mouseup', this.boundUpHandler);\n this.element_.addEventListener('mouseleave', this.boundUpHandler);\n this.element_.addEventListener('touchend', this.boundUpHandler);\n this.element_.addEventListener('blur', this.boundUpHandler);\n /**\n * Getter for frameCount_.\n * @return {number} the frame count.\n */\n this.getFrameCount = function () {\n return this.frameCount_;\n };\n /**\n * Setter for frameCount_.\n * @param {number} fC the frame count.\n */\n this.setFrameCount = function (fC) {\n this.frameCount_ = fC;\n };\n /**\n * Getter for rippleElement_.\n * @return {Element} the ripple element.\n */\n this.getRippleElement = function () {\n return this.rippleElement_;\n };\n /**\n * Sets the ripple X and Y coordinates.\n * @param {number} newX the new X coordinate\n * @param {number} newY the new Y coordinate\n */\n this.setRippleXY = function (newX, newY) {\n this.x_ = newX;\n this.y_ = newY;\n };\n /**\n * Sets the ripple styles.\n * @param {boolean} start whether or not this is the start frame.\n */\n this.setRippleStyles = function (start) {\n if (this.rippleElement_ !== null) {\n var transformString;\n var scale;\n var size;\n var offset = 'translate(' + this.x_ + 'px, ' + this.y_ + 'px)';\n if (start) {\n scale = this.Constant_.INITIAL_SCALE;\n size = this.Constant_.INITIAL_SIZE;\n } else {\n scale = this.Constant_.FINAL_SCALE;\n size = this.rippleSize_ + 'px';\n if (recentering) {\n offset = 'translate(' + this.boundWidth / 2 + 'px, ' + this.boundHeight / 2 + 'px)';\n }\n }\n transformString = 'translate(-50%, -50%) ' + offset + scale;\n this.rippleElement_.style.webkitTransform = transformString;\n this.rippleElement_.style.msTransform = transformString;\n this.rippleElement_.style.transform = transformString;\n if (start) {\n this.rippleElement_.classList.remove(this.CssClasses_.IS_ANIMATING);\n } else {\n this.rippleElement_.classList.add(this.CssClasses_.IS_ANIMATING);\n }\n }\n };\n /**\n * Handles an animation frame.\n */\n this.animFrameHandler = function () {\n if (this.frameCount_-- > 0) {\n window.requestAnimationFrame(this.animFrameHandler.bind(this));\n } else {\n this.setRippleStyles(false);\n }\n };\n }\n }\n};\n// The component registers itself. It can assume componentHandler is available\n// in the global scope.\ncomponentHandler.register({\n constructor: MaterialRipple,\n classAsString: 'MaterialRipple',\n cssClass: 'mdl-js-ripple-effect',\n widget: false\n});"]} \ No newline at end of file diff --git a/web/static/js/vendor/samp.js b/web/static/js/vendor/samp.js new file mode 100755 index 0000000..e61e824 --- /dev/null +++ b/web/static/js/vendor/samp.js @@ -0,0 +1,1307 @@ +// samp +// ---- +// Provides capabilities for using the SAMP Web Profile from JavaScript. +// Exported tokens are in the samp.* namespace. +// Inline documentation is somewhat patchy (partly because I don't know +// what javascript documentation is supposed to look like) - it is +// suggested to use it conjunction with the provided examples, +// currently visible at http://astrojs.github.com/sampjs/ +// (gh-pages branch of github sources). + +var samp = (function() { + + // Constants defining well-known location of SAMP Web Profile hub etc. + var WEBSAMP_PORT = 21012; + var WEBSAMP_PATH = "/"; + var WEBSAMP_PREFIX = "samp.webhub."; + var WEBSAMP_CLIENT_PREFIX = ""; + + // Tokens representing permissible types in a SAMP object (e.g. a message) + TYPE_STRING = "string"; + TYPE_LIST = "list"; + TYPE_MAP = "map"; + + var heir = function(proto) { + function F() {}; + F.prototype = proto; + return new F(); + }; + + // Utility functions for navigating DOM etc. + // ----------------------------------------- + + var getSampType = function(obj) { + if (typeof obj === "string") { + return TYPE_STRING; + } + else if (obj instanceof Array) { + return TYPE_LIST; + } + else if (obj instanceof Object && obj !== null) { + return TYPE_MAP; + } + else { + throw new Error("Not legal SAMP object type: " + obj); + } + }; + var getChildElements = function(el, childTagName) { + var children = el.childNodes; + var child; + var childEls = []; + var i; + for (i = 0; i < children.length; i++) { + child = children[i]; + if (child.nodeType === 1) { // Element + if (childTagName && (child.tagName !== childTagName)) { + throw new Error("Child <" + children[i].tagName + ">" + + " of <" + el.tagName + ">" + + " is not a <" + childTagName + ">"); + } + childEls.push(child); + } + } + return childEls; + }; + var getSoleChild = function(el, childTagName) { + var children = getChildElements(el, childTagName); + if (children.length === 1 ) { + return children[0]; + } + else { + throw new Error("No sole child of <" + el.tagName + ">"); + } + }; + var getTextContent = function(el) { + var txt = ""; + var i; + var child; + for (i = 0; i < el.childNodes.length; i++ ) { + child = el.childNodes[i]; + if (child.nodeType === 1) { // Element + throw new Error("Element found in text content"); + } + else if (child.nodeType === 3 || // Text + child.nodeType === 4 ) { // CDATASection + txt += child.nodeValue; + } + } + return txt; + }; + var stringify = function(obj) { + return typeof JSON === "undefined" ? "..." : JSON.stringify(obj); + }; + + // XmlRpc class: + // Utilities for packing and unpacking XML-RPC messages. + // See xml-rpc.com. + + var XmlRpc = {}; + + // Takes text and turns it into something suitable for use as the content + // of an XML-RPC string - special characters are escaped. + XmlRpc.escapeXml = function(s) { + return s.replace(/&/g, "&") + .replace(//g, ">"); + }; + + // Asserts that the elements of paramList match the types given by typeList. + // TypeList must be an array containing only TYPE_STRING, TYPE_LIST + // and TYPE_MAP objects in some combination. paramList must be the + // same length. + // In case of mismatch an error is thrown. + XmlRpc.checkParams = function(paramList, typeList) { + var i; + for (i = 0; i < typeList.length; i++) { + if (typeList[i] !== TYPE_STRING && + typeList[i] !== TYPE_LIST && + typeList[i] !== TYPE_MAP) { + throw new Error("Unknown type " + typeList[i] + + " in check list"); + } + } + var npar = paramList.length; + var actualTypeList = []; + var ok = true; + for (i = 0; i < npar; i++) { + actualTypeList.push(getSampType(paramList[i])); + } + ok = ok && (typeList.length === npar); + for (i = 0; ok && i < npar; i++ ) { + ok = ok && typeList[i] === actualTypeList[i]; + } + if (!ok) { + throw new Error("Param type list mismatch: " + + "[" + typeList + "] != " + + "[" + actualTypeList + "]"); + } + }; + + // Turns a SAMP object (structure of strings, lists, maps) into an + // XML string suitable for use with XML-RPC. + XmlRpc.valueToXml = function v2x(obj, prefix) { + prefix = prefix || ""; + var a; + var i; + var result; + var type = getSampType(obj); + if (type === TYPE_STRING) { + return prefix + + "" + + XmlRpc.escapeXml(obj) + + ""; + } + else if (type === TYPE_LIST) { + result = []; + result.push(prefix + "", + prefix + " ", + prefix + " "); + for (i = 0; i < obj.length; i++) { + result.push(v2x(obj[i], prefix + " ")); + } + result.push(prefix + " ", + prefix + " ", + prefix + ""); + + return result.join("\n"); + } + else if (type === TYPE_MAP) { + result = []; + result.push(prefix + ""); + result.push(prefix + " "); + for (i in obj) { + result.push(prefix + " "); + result.push(prefix + " " + + XmlRpc.escapeXml(i) + + ""); + result.push(v2x(obj[i], prefix + " ")); + result.push(prefix + " "); + } + result.push(prefix + " "); + result.push(prefix + ""); + return result.join("\n"); + } + else { + throw new Error("bad type"); // shouldn't get here + } + }; + + // Turns an XML string from and XML-RPC message into a SAMP object + // (structure of strings, lists, maps). + XmlRpc.xmlToValue = function x2v(valueEl, allowInt) { + var childEls = getChildElements(valueEl); + var i; + var j; + var txt; + var node; + var childEl; + var elName; + if (childEls.length === 0) { + return getTextContent(valueEl); + } + else if (childEls.length === 1) { + childEl = childEls[0]; + elName = childEl.tagName; + if (elName === "string") { + return getTextContent(childEl); + } + else if (elName === "array") { + var valueEls = + getChildElements(getSoleChild(childEl, "data"), "value"); + var list = []; + for (i = 0; i < valueEls.length; i++) { + list.push(x2v(valueEls[i], allowInt)); + } + return list; + } + else if (elName === "struct") { + var memberEls = getChildElements(childEl, "member"); + var map = {}; + var s_name; + var s_value; + var jc; + for (i = 0; i < memberEls.length; i++) { + s_name = undefined; + s_value = undefined; + for (j = 0; j < memberEls[i].childNodes.length; j++) { + jc = memberEls[i].childNodes[j]; + if (jc.nodeType == 1) { + if (jc.tagName === "name") { + s_name = getTextContent(jc); + } + else if (jc.tagName === "value") { + s_value = x2v(jc, allowInt); + } + } + } + if (s_name !== undefined && s_value !== undefined) { + map[s_name] = s_value; + } + else { + throw new Error("No and/or " + + "in ?"); + } + } + return map; + } + else if (allowInt && (elName === "int" || elName === "i4")) { + return getTextContent(childEl); + } + else { + throw new Error("Non SAMP-friendly value content: " + + "<" + elName + ">"); + } + } + else { + throw new Error("Bad XML-RPC content - multiple elements"); + } + }; + + // Turns the content of an XML-RPC element into an array of + // SAMP objects. + XmlRpc.decodeParams = function(paramsEl) { + var paramEls = getChildElements(paramsEl, "param"); + var i; + var results = []; + for (i = 0; i < paramEls.length; i++) { + results.push(XmlRpc.xmlToValue(getSoleChild(paramEls[i], "value"))); + } + return results; + }; + + // Turns the content of an XML-RPC element into an XmlRpc.Fault + // object. + XmlRpc.decodeFault = function(faultEl) { + var faultObj = XmlRpc.xmlToValue(getSoleChild(faultEl, "value"), true); + return new XmlRpc.Fault(faultObj.faultString, faultObj.faultCode); + }; + + // Turns an XML-RPC response element (should be ) into + // either a SAMP response object or an XmlRpc.Fault object. + // Note that a fault response does not throw an error, so check for + // the type of the result if you want to know whether a fault occurred. + // An error will however be thrown if the supplied XML does not + // correspond to a legal XML-RPC response. + XmlRpc.decodeResponse = function(xml) { + var mrEl = xml.documentElement; + if (mrEl.tagName !== "methodResponse") { + throw new Error("Response element is not "); + } + var contentEl = getSoleChild(mrEl); + if (contentEl.tagName === "fault") { + return XmlRpc.decodeFault(contentEl); + } + else if (contentEl.tagName === "params") { + return XmlRpc.decodeParams(contentEl)[0]; + } + else { + throw new Error("Bad XML-RPC response - unknown element" + + " <" + contentEl.tagName + ">"); + } + }; + + // XmlRpc.Fault class: + // Represents an XML-RPC Fault response. + XmlRpc.Fault = function(faultString, faultCode) { + this.faultString = faultString; + this.faultCode = faultCode; + }; + XmlRpc.Fault.prototype.toString = function() { + return "XML-RPC Fault (" + this.faultCode + "): " + this.faultString; + }; + + // XmlRpcRequest class: + // Represents an call which can be sent to an XML-RPC server. + var XmlRpcRequest = function(methodName, params) { + this.methodName = methodName; + this.params = params || []; + } + XmlRpcRequest.prototype.toString = function() { + return this.methodName + "(" + stringify(this.params) + ")"; + }; + XmlRpcRequest.prototype.addParam = function(param) { + this.params.push(param); + return this; + }; + XmlRpcRequest.prototype.addParams = function(params) { + var i; + for (i = 0; i < params.length; i++) { + this.params.push(params[i]); + } + return this; + }; + XmlRpcRequest.prototype.checkParams = function(typeList) { + XmlRpc.checkParams(this.params, typeList); + }; + XmlRpcRequest.prototype.toXml = function() { + var lines = []; + lines.push( + "", + "", + " " + this.methodName + "", + " "); + for (var i = 0; i < this.params.length; i++) { + lines.push(" ", + XmlRpc.valueToXml(this.params[i], " "), + " "); + } + lines.push( + " ", + ""); + return lines.join("\n"); + }; + + // XmlRpcClient class: + // Object capable of sending XML-RPC calls to an XML-RPC server. + // That server will typically reside on the host on which the + // javascript is running; it is not likely to reside on the host + // which served the javascript. That means that sandboxing restrictions + // will be in effect. Much of the work done here is therefore to + // do the client-side work required to potentially escape the sandbox. + // The endpoint parameter, if supplied, is the URL of the XML-RPC server. + // If absent, the default SAMP Web Profile server is used. + var XmlRpcClient = function(endpoint) { + this.endpoint = endpoint || + "http://localhost:" + WEBSAMP_PORT + WEBSAMP_PATH; + }; + + // Creates an XHR facade - an object that presents an interface + // resembling that of an XMLHttpRequest Level 2. + // This facade may be based on an actual XMLHttpRequest Level 2 object + // (on browsers that support it), or it may fake one using other + // available technology. + // + // The created facade in any case presents the following interface: + // + // open(method, url) + // send(body) + // abort() + // setContentType() + // responseText + // responseXML + // onload + // onerror(err) - includes timeout; abort is ignored + // + // See the documentation at http://www.w3.org/TR/XMLHttpRequest/ + // for semantics. + // + // XMLHttpRequest Level 2 supports Cross-Origin Resource Sharing (CORS) + // which makes sandbox evasion possible. Faked XHRL2s returned by + // this method may use CORS or some other technology to evade the + // sandbox. The SAMP hub itself may selectively allow some of these + // technologies and not others, according to configuration. + XmlRpcClient.createXHR = function() { + + // Creates an XHR facade based on a genuine XMLHttpRequest Level 2. + var XhrL2 = function(xhr) { + this.xhr = xhr; + xhr.onreadystatechange = (function(l2) { + return function() { + if (xhr.readyState !== 4) { + return; + } + else if (!l2.completed) { + if (+xhr.status === 200) { + l2.completed = true; + l2.responseText = xhr.responseText; + l2.responseXML = xhr.responseXML; + if (l2.onload) { + l2.onload(); + } + } + } + }; + })(this); + xhr.onerror = (function(l2) { + return function(event) { + if (!l2.completed) { + l2.completed = true; + if (l2.onerror) { + if (event) { + event.toString = function() {return "No hub?";}; + } + else { + event = "No hub?"; + } + l2.onerror(event); + } + } + }; + })(this); + xhr.ontimeout = (function(l2) { + return function(event) { + if (!l2.completed) { + l2.completed = true; + if (l2.onerror) { + l2.onerror("timeout"); + } + } + }; + })(this); + }; + XhrL2.prototype.open = function(method, url) { + this.xhr.open(method, url); + }; + XhrL2.prototype.send = function(body) { + this.xhr.send(body); + }; + XhrL2.prototype.abort = function() { + this.xhr.abort(); + } + XhrL2.prototype.setContentType = function(mimeType) { + if ("setRequestHeader" in this.xhr) { + this.xhr.setRequestHeader("Content-Type", mimeType); + } + } + + // Creates an XHR facade based on an XDomainRequest (IE8+ only). + var XdrL2 = function(xdr) { + this.xdr = xdr; + xdr.onload = (function(l2) { + return function() { + var e; + l2.responseText = xdr.responseText; + if (xdr.contentType === "text/xml" || + xdr.contentType === "application/xml" || + /\/x-/.test(xdr.contentType)) { + try { + var xdoc = new ActiveXObject("Microsoft.XMLDOM"); + xdoc.loadXML(xdr.responseText); + l2.responseXML = xdoc; + } + catch (e) { + l2.responseXML = e; + } + } + if (l2.onload) { + l2.onload(); + } + }; + })(this); + xdr.onerror = (function(l2) { + return function(event) { + if (l2.onerror) { + l2.onerror(event); + } + }; + })(this); + xdr.ontimeout = (function(l2) { + return function(event) { + if (l2.onerror) { + l2.onerror(event); + } + }; + })(this); + }; + XdrL2.prototype.open = function(method, url) { + this.xdr.open(method, url); + }; + XdrL2.prototype.send = function(body) { + this.xdr.send(body); + }; + XdrL2.prototype.abort = function() { + this.xdr.abort(); + }; + XdrL2.prototype.setContentType = function(mimeType) { + // can't do it. + }; + + // Creates an XHR Facade based on available XMLHttpRequest-type + // capabilibities. + // If an actual XMLHttpRequest Level 2 is available, use that. + if (typeof XMLHttpRequest !== "undefined") { + var xhr = new XMLHttpRequest(); + if ("withCredentials" in xhr) { + return new XhrL2(xhr); + } + } + + // Else if an XDomainRequest is available, use that. + if (typeof XDomainRequest !== "undefined") { + return new XdrL2(new XDomainRequest()); + } + + // Else fake an XMLHttpRequest using Flash/flXHR, if available + // and use that. + if (typeof flensed.flXHR !== "undefined") { + return new XhrL2(new flensed.flXHR({instancePooling: true})); + } + + // No luck. + throw new Error("no cross-origin mechanism available"); + }; + + // Executes a request by passing it to the XML-RPC server. + // On success, the result is passed to the resultHandler. + // On failure, the errHandler is called with one of two possible + // arguments: an XmlRpc.Fault object, or an Error object. + XmlRpcClient.prototype.execute = function(req, resultHandler, errHandler) { + (function(xClient) { + var xhr; + var e; + try { + xhr = XmlRpcClient.createXHR(); + xhr.open("POST", xClient.endpoint); + xhr.setContentType("text/xml"); + } + catch (e) { + errHandler(e); + throw e; + } + xhr.onload = function() { + var xml = xhr.responseXML; + var result; + var e; + if (xml) { + try { + result = XmlRpc.decodeResponse(xml); + } + catch (e) { + if (errHandler) { + errHandler(e); + } + return; + } + } + else { + if (errHandler) { + errHandler("no XML response"); + } + return; + } + if (result instanceof XmlRpc.Fault) { + if (errHandler) { + errHandler(result); + } + } + else { + if (resultHandler) { + resultHandler(result); + } + } + }; + xhr.onerror = function(event) { + if (event) { + event.toString = function() {return "No hub?";} + } + else { + event = "No hub"; + } + if (errHandler) { + errHandler(event); + } + }; + xhr.send(req.toXml()); + return xhr; + })(this); + }; + + // Message class: + // Aggregates an MType string and a params map. + var Message = function(mtype, params) { + this["samp.mtype"] = mtype; + this["samp.params"] = params; + }; + + // Connection class: + // this is what clients use to communicate with the hub. + // + // All the methods from the Hub Abstract API as described in the + // SAMP standard are available as methods of a Connection object. + // The initial private-key argument required by the Web Profile is + // handled internally by this object - you do not need to supply it + // when calling one of the methods. + // + // All these calls have the same form: + // + // connection.method([method-args], resultHandler, errorHandler) + // + // the first argument is an array of the arguments (as per the SAMP + // abstract hub API), the second argument is a function which is + // called on successful completion with the result of the SAMP call + // as its argument, and the third argument is a function which is + // called on unsuccessful completion with an error object as its + // argument. The resultHandler and errorHandler arguments are optional. + // + // So for instance if you have a Connection object conn, + // you can send a notify message to all other clients by doing, e.g.: + // + // conn.notifyAll([new samp.Message(mtype, params)]) + // + // Connection has other methods as well as the hub API ones + // as documented below. + var Connection = function(regInfo) { + this.regInfo = regInfo; + this.privateKey = regInfo["samp.private-key"]; + if (! typeof(this.privateKey) === "string") { + throw new Error("Bad registration object"); + } + this.xClient = new XmlRpcClient(); + }; + (function() { + var connMethods = { + call: [TYPE_STRING, TYPE_STRING, TYPE_MAP], + callAll: [TYPE_STRING, TYPE_MAP], + callAndWait: [TYPE_STRING, TYPE_MAP, TYPE_STRING], + declareMetadata: [TYPE_MAP], + declareSubscriptions: [TYPE_MAP], + getMetadata: [TYPE_STRING], + getRegisteredClients: [], + getSubscribedClients: [TYPE_STRING], + getSubscriptions: [TYPE_STRING], + notify: [TYPE_STRING, TYPE_MAP], + notifyAll: [TYPE_MAP], + ping: [], + reply: [TYPE_STRING, TYPE_MAP] + }; + var fn; + var types; + for (fn in connMethods) { + (function(fname, types) { + // errHandler may be passed an XmlRpc.Fault or a thrown Error. + Connection.prototype[fname] = + function(sampArgs, resultHandler, errHandler) { + var closer = + (function(c) {return function() {c.close()}})(this); + errHandler = errHandler || closer + XmlRpc.checkParams(sampArgs, types); + var request = new XmlRpcRequest(WEBSAMP_PREFIX + fname); + request.addParam(this.privateKey); + request.addParams(sampArgs); + return this.xClient. + execute(request, resultHandler, errHandler); + }; + })(fn, connMethods[fn]); + } + })(); + Connection.prototype.unregister = function() { + var e; + if (this.callbackRequest) { + try { + this.callbackRequest.abort(); + } + catch (e) { + } + } + var request = new XmlRpcRequest(WEBSAMP_PREFIX + "unregister"); + request.addParam(this.privateKey); + try { + this.xClient.execute(request); + } + catch (e) { + // log unregister failed + } + delete this.regInfo; + delete this.privateKey; + }; + + // Closes this connection. It unregisters from the hub if still + // registered, but may harmlessly be called multiple times. + Connection.prototype.close = function() { + var e; + if (this.closed) { + return; + } + this.closed = true; + try { + if (this.regInfo) { + this.unregister(); + } + } + catch (e) { + } + if (this.onclose) { + oc = this.onclose; + delete this.onclose; + try { + oc(); + } + catch (e) { + } + } + }; + + // Arranges for this connection to receive callbacks. + // + // The callableClient argument must be an object implementing the + // SAMP callable client API, i.e. it must have the following methods: + // + // receiveNotification(string sender-id, map message) + // receiveCall(string sender-id, string msg-id, map message) + // receiveResponse(string responder-id, string msg-tag, map response) + // + // The successHandler argument will be called with no arguments if the + // allowCallbacks hub method completes successfully - it is a suitable + // hook to use for declaring subscriptions. + // + // The CallableClient class provides a suitable implementation, see below. + Connection.prototype.setCallable = function(callableClient, + successHandler) { + var e; + if (this.callbackRequest) { + try { + this.callbackRequest.abort(); + } + catch (e) { + } + finally { + delete this.callbackRequest; + } + } + if (!callableClient && !this.regInfo) { + return; + } + var request = + new XmlRpcRequest(WEBSAMP_PREFIX + "allowReverseCallbacks"); + request.addParam(this.privateKey); + request.addParam(callableClient ? "1" : "0"); + var closer = (function(c) {return function() {c.close()}})(this); + if (callableClient) { + (function(connection) { + var invokeCallback = function(callback) { + var methodName = callback["samp.methodName"]; + var methodParams = callback["samp.params"]; + var handlerFunc = undefined; + if (methodName === WEBSAMP_CLIENT_PREFIX + + "receiveNotification") { + handlerFunc = callableClient.receiveNotification; + } + else if (methodName === WEBSAMP_CLIENT_PREFIX + + "receiveCall") { + handlerFunc = callableClient.receiveCall; + } + else if (methodName === WEBSAMP_CLIENT_PREFIX + + "receiveResponse") { + handlerFunc = callableClient.receiveResponse; + } + else { + // unknown callback?? + } + if (handlerFunc) { + handlerFunc.apply(callableClient, methodParams); + } + }; + var startTime; + var resultHandler = function(result) { + if (getSampType(result) != TYPE_LIST) { + errHandler(new Error("pullCallbacks result not List")); + return; + } + var i; + var e; + for (i = 0; i < result.length; i++) { + try { + invokeCallback(result[i]); + } + catch (e) { + // log here? + } + } + callWaiter(); + }; + var errHandler = function(error) { + var elapsed = new Date().getTime() - startTime; + if (elapsed < 1000) { + connection.close() + } + else { + // probably a timeout + callWaiter(); + } + }; + var callWaiter = function() { + if (!connection.regInfo) { + return; + } + var request = + new XmlRpcRequest(WEBSAMP_PREFIX + "pullCallbacks"); + request.addParam(connection.privateKey); + request.addParam("600"); + startTime = new Date().getTime(); + connection.callbackRequest = + connection.xClient. + execute(request, resultHandler, errHandler); + }; + var sHandler = function() { + callWaiter(); + successHandler(); + }; + connection.xClient.execute(request, sHandler, closer); + })(this); + } + else { + this.xClient.execute(request, successHandler, closer); + } + }; + + // Takes a public URL and returns a URL that can be used from within + // this javascript context. Some translation may be required, since + // a URL sent by an external application may be cross-domain, in which + // case browser sandboxing would typically disallow access to it. + Connection.prototype.translateUrl = function(url) { + var translator = this.regInfo["samp.url-translator"] || ""; + return translator + url; + }; + Connection.Action = function(actName, actArgs, resultKey) { + this.actName = actName; + this.actArgs = actArgs; + this.resultKey = resultKey; + }; + + // Suitable implementation for a callable client object which can + // be supplied to Connection.setCallable(). + // Its callHandler and replyHandler members are string->function maps + // which can be used to provide handler functions for MTypes and + // message tags respectively. + // + // In more detail: + // The callHandler member maps a string representing an MType to + // a function with arguments (senderId, message, isCall). + // The replyHandler member maps a string representing a message tag to + // a function with arguments (responderId, msgTag, response). + var CallableClient = function(connection) { + this.callHandler = {}; + this.replyHandler = {}; + }; + CallableClient.prototype.init = function(connection) { + }; + CallableClient.prototype.receiveNotification = function(senderId, message) { + var mtype = message["samp.mtype"]; + var handled = false; + var e; + if (mtype in this.callHandler) { + try { + this.callHandler[mtype](senderId, message, false); + } + catch (e) { + } + handled = true; + } + return handled; + }; + CallableClient.prototype.receiveCall = function(senderId, msgId, message) { + var mtype = message["samp.mtype"]; + var handled = false; + var response; + var result; + var e; + if (mtype in this.callHandler) { + try { + result = this.callHandler[mtype](senderId, message, true) || {}; + response = {"samp.status": "samp.ok", + "samp.result": result}; + handled = true; + } + catch (e) { + response = {"samp.status": "samp.error", + "samp.error": {"samp.errortxt": e.toString()}}; + } + } + else { + response = {"samp.status": "samp.warning", + "samp.result": {}, + "samp.error": {"samp.errortxt": "no action"}}; + } + this.connection.reply([msgId, response]); + return handled; + }; + CallableClient.prototype.receiveResponse = function(responderId, msgTag, + response) { + var handled = false; + var e; + if (msgTag in this.replyHandler) { + try { + this.replyHandler[msgTag](responderId, msgTag, response); + handled = true; + } + catch (e) { + } + } + return handled; + }; + CallableClient.prototype.calculateSubscriptions = function() { + var subs = {}; + var mt; + for (mt in this.callHandler) { + subs[mt] = {}; + } + return subs; + }; + + // ClientTracker is a CallableClient which also provides tracking of + // registered clients. + // + // Its onchange member, if defined, will be called with arguments + // (client-id, change-type, associated-data) whenever the list or + // characteristics of registered clients has changed. + var ClientTracker = function() { + var tracker = this; + this.ids = {}; + this.metas = {}; + this.subs = {}; + this.replyHandler = {}; + this.callHandler = { + "samp.hub.event.shutdown": function(senderId, message) { + tracker.connection.close(); + }, + "samp.hub.disconnect": function(senderId, message) { + tracker.connection.close(); + }, + "samp.hub.event.register": function(senderId, message) { + var id = message["samp.params"]["id"]; + tracker.ids[id] = true; + tracker.changed(id, "register", null); + }, + "samp.hub.event.unregister": function(senderId, message) { + var id = message["samp.params"]["id"]; + delete tracker.ids[id]; + delete tracker.metas[id]; + delete tracker.subs[id]; + tracker.changed(id, "unregister", null); + }, + "samp.hub.event.metadata": function(senderId, message) { + var id = message["samp.params"]["id"]; + var meta = message["samp.params"]["metadata"]; + tracker.metas[id] = meta; + tracker.changed(id, "meta", meta); + }, + "samp.hub.event.subscriptions": function(senderId, message) { + var id = message["samp.params"]["id"]; + var subs = message["samp.params"]["subscriptions"]; + tracker.subs[id] = subs; + tracker.changed(id, "subs", subs); + } + }; + }; + ClientTracker.prototype = heir(CallableClient.prototype); + ClientTracker.prototype.changed = function(id, type, data) { + if (this.onchange) { + this.onchange(id, type, data); + } + }; + ClientTracker.prototype.init = function(connection) { + var tracker = this; + this.connection = connection; + var retrieveInfo = function(id, type, infoFuncName, infoArray) { + connection[infoFuncName]([id], function(info) { + infoArray[id] = info; + tracker.changed(id, type, info); + }); + }; + connection.getRegisteredClients([], function(idlist) { + var i; + var id; + tracker.ids = {}; + for (i = 0; i < idlist.length; i++) { + id = idlist[i]; + tracker.ids[id] = true; + retrieveInfo(id, "meta", "getMetadata", tracker.metas); + retrieveInfo(id, "subs", "getSubscriptions", tracker.subs); + } + tracker.changed(null, "ids", null); + }); + }; + ClientTracker.prototype.getName = function(id) { + var meta = this.metas[id]; + return (meta && meta["samp.name"]) ? meta["samp.name"] : "[" + id + "]"; + }; + + // Connector class: + // A higher level class which can manage transparent hub + // registration/unregistration and client tracking. + // + // On construction, the name argument is mandatory, and corresponds + // to the samp.name item submitted at registration time. + // The other arguments are optional. + // meta is a metadata map (if absent, no metadata is declared) + // callableClient is a callable client object for receiving callbacks + // (if absent, the client is not callable). + // subs is a subscriptions map (if absent, no subscriptions are declared) + var Connector = function(name, meta, callableClient, subs) { + this.name = name; + this.meta = meta; + this.callableClient = callableClient; + this.subs = subs; + this.regTextNodes = []; + this.whenRegs = []; + this.whenUnregs = []; + this.connection = undefined; + this.onreg = undefined; + this.onunreg = undefined; + }; + var setRegText = function(connector, txt) { + var i; + var nodes = connector.regTextNodes; + var node; + for (i = 0; i < nodes.length; i++) { + node = nodes[i]; + node.innerHTML = ""; + node.appendChild(document.createTextNode(txt)); + } + }; + Connector.prototype.setConnection = function(conn) { + var connector = this; + var e; + if (this.connection) { + this.connection.close(); + if (this.onunreg) { + try { + this.onunreg(); + } + catch (e) { + } + } + } + this.connection = conn; + if (conn) { + conn.onclose = function() { + connector.connection = null; + if (connector.onunreg) { + try { + connector.onunreg(); + } + catch (e) { + } + } + connector.update(); + }; + if (this.meta) { + conn.declareMetadata([this.meta]); + } + if (this.callableClient) { + if (this.callableClient.init) { + this.callableClient.init(conn); + } + conn.setCallable(this.callableClient, function() { + conn.declareSubscriptions([connector.subs]); + }); + } + if (this.onreg) { + try { + this.onreg(conn); + } + catch (e) { + } + } + } + this.update(); + }; + Connector.prototype.register = function() { + var connector = this; + var regErrHandler = function(err) { + setRegText(connector, "no (" + err.toString() + ")"); + }; + var regSuccessHandler = function(conn) { + connector.setConnection(conn); + setRegText(connector, conn ? "Yes" : "No"); + }; + register(this.name, regSuccessHandler, regErrHandler); + }; + Connector.prototype.unregister = function() { + if (this.connection) { + this.connection.unregister([]); + this.setConnection(null); + } + }; + + // Returns a document fragment which contains Register/Unregister + // buttons for use by the user to attempt to connect/disconnect + // with the hub. This is useful for models where explicit + // user registration is encouraged or required, but when using + // the register-on-demand model such buttons are not necessary. + Connector.prototype.createRegButtons = function() { + var connector = this; + var regButt = document.createElement("button"); + regButt.setAttribute("type", "button"); + regButt.appendChild(document.createTextNode("Register")); + regButt.onclick = function() {connector.register();}; + this.whenUnregs.push(regButt); + var unregButt = document.createElement("button"); + unregButt.setAttribute("type", "button"); + unregButt.appendChild(document.createTextNode("Unregister")); + unregButt.onclick = function() {connector.unregister();}; + this.whenRegs.push(unregButt); + var regText = document.createElement("span"); + this.regTextNodes.push(regText); + var node = document.createDocumentFragment(); + node.appendChild(regButt); + node.appendChild(document.createTextNode(" ")); + node.appendChild(unregButt); + var label = document.createElement("span"); + label.innerHTML = " Registered: "; + node.appendChild(label); + node.appendChild(regText); + this.update(); + return node; + }; + + Connector.prototype.update = function() { + var i; + var isConnected = !! this.connection; + var enableds = isConnected ? this.whenRegs : this.whenUnregs; + var disableds = isConnected ? this.whenUnregs : this.whenRegs; + for (i = 0; i < enableds.length; i++) { + enableds[i].removeAttribute("disabled"); + } + for (i = 0; i < disableds.length; i++) { + disableds[i].setAttribute("disabled", "disabled"); + } + setRegText(this, "No"); + }; + + // Provides execution of a SAMP operation with register-on-demand. + // You can use this method to provide lightweight registration/use + // of web SAMP. Simply provide a connHandler function which + // does something with a connection (e.g. sends a message) and + // Connector.runWithConnection on it. This will connect if not + // already connected, and call the connHandler on with the connection. + // No explicit registration action is then required from the user. + // + // If the regErrorHandler argument is supplied, it is a function of + // one (error) argument called in the case that registration-on-demand + // fails. + // + // This is a more-or-less complete sampjs page: + // + // + Connector.prototype.runWithConnection = + function(connHandler, regErrorHandler) { + var connector = this; + var regSuccessHandler = function(conn) { + connector.setConnection(conn); + connHandler(conn); + }; + var regFailureHandler = function(e) { + connector.setConnection(undefined); + regErrorHandler(e); + }; + var pingResultHandler = function(result) { + connHandler(connector.connection); + }; + var pingErrorHandler = function(err) { + register(this.name, regSuccessHandler, regFailureHandler); + }; + if (this.connection) { + // Use getRegisteredClients as the most lightweight check + // I can think of that this connection is still OK. + // Ping doesn't work because the server replies even if the + // private-key is incorrect/invalid. Is that a bug or not? + this.connection. + getRegisteredClients([], pingResultHandler, pingErrorHandler); + } + else { + register(this.name, regSuccessHandler, regFailureHandler); + } + }; + + // Sets up an interval timer to run at intervals and notify a callback + // about whether a hub is currently running. + // Every millis milliseconds, the supplied availHandler function is + // called with a boolean argument: true if a (web profile) hub is + // running, false if not. + // Returns the interval timer (can be passed to clearInterval()). + Connector.prototype.onHubAvailability = function(availHandler, millis) { + samp.ping(availHandler); + + // Could use the W3C Page Visibility API to avoid making these + // checks when the page is not visible. + return setInterval(function() {samp.ping(availHandler);}, millis); + }; + + // Determines whether a given subscriptions map indicates subscription + // to a given mtype. + var isSubscribed = function(subs, mtype) { + var matching = function(pattern, mtype) { + if (pattern == mtype) { + return true; + } + else if (pattern === "*") { + return true; + } + else { + var prefix; + var split = /^(.*)\.\*$/.exec(pat); + if (split) { + prefix = split[1]; + if (prefix === mtype.substring(0, prefix.length)) { + return true; + } + } + } + return false; + }; + var pat; + for (pat in subs) { + if (matching(pat, mtype)) { + return true; + } + } + return false; + }; + + // Attempts registration with a SAMP hub. + // On success the supplied connectionHandler function is called + // with the connection as an argument, on failure the supplied + // errorHandler is called with an argument that may be an Error + // or an XmlRpc.Fault. + var register = function(appName, connectionHandler, errorHandler) { + var xClient = new XmlRpcClient(); + var regRequest = new XmlRpcRequest(WEBSAMP_PREFIX + "register"); + var securityInfo = {"samp.name": appName}; + regRequest.addParam(securityInfo); + regRequest.checkParams([TYPE_MAP]); + var resultHandler = function(result) { + var conn; + var e; + try { + conn = new Connection(result, 1000); + } + catch (e) { + errorHandler(e); + return; + } + connectionHandler(conn); + }; + xClient.execute(regRequest, resultHandler, errorHandler); + }; + + // Calls the hub ping method once. It is not necessary to be + // registered to do this. + // The supplied pingHandler function is called with a boolean argument: + // true if a (web profile) hub is running, false if not. + var ping = function(pingHandler) { + var xClient = new XmlRpcClient(); + var pingRequest = new XmlRpcRequest(WEBSAMP_PREFIX + "ping"); + var resultHandler = function(result) { + pingHandler(true); + }; + var errorHandler = function(error) { + pingHandler(false); + }; + xClient.execute(pingRequest, resultHandler, errorHandler); + }; + + + /* Exports. */ + var jss = {}; + jss.XmlRpcRequest = XmlRpcRequest; + jss.XmlRpcClient = XmlRpcClient; + jss.Message = Message; + jss.TYPE_STRING = TYPE_STRING; + jss.TYPE_LIST = TYPE_LIST; + jss.TYPE_MAP = TYPE_MAP; + jss.register = register; + jss.ping = ping; + jss.isSubscribed = isSubscribed; + jss.Connector = Connector; + jss.CallableClient = CallableClient; + jss.ClientTracker = ClientTracker; + + return jss; +})(); + diff --git a/web/view/home.html.jinja2 b/web/view/home.html.jinja2 index 007258e..1deb1a1 100755 --- a/web/view/home.html.jinja2 +++ b/web/view/home.html.jinja2 @@ -8,13 +8,41 @@ {% block content %} {% macro target_button(target) -%} - {{ target.name }} +
+ {{ target.name }} + No data for {{ target.name }} +{# Loader for {{ target.name }}#} +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
{%- endmacro %} {% macro icon(name) %}{% endmacro %} @@ -83,17 +111,19 @@
+ +
-
+
-
+

Drag to zoom in, double click to zoom out.

@@ -105,6 +135,7 @@ {% endblock %} +{#### CSS ####################################################################} {% block styles %} {% endblock %} +{#### JAVASCRIPT #############################################################} + {% block scripts_footer %} + #} + -- libgit2 0.21.2