material_design_lite-rails 1.0.3 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/material_design_lite/rails/version.rb +1 -1
- data/vendor/assets/javascripts/material.js +363 -139
- data/vendor/assets/stylesheets/material.css +30 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b63e9602083c05a4eee06a292a0833fec32e92
|
4
|
+
data.tar.gz: c5871a118f4e38855a0add8db3ee3320f1111415
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 149b17475b32bd9abe60e766cd97c80c2cf2e916bd2db4ba10312fa1b83d0693fd7eb61594c60e896534be436e1ef5e52db38b3bf5f5bdbd33167691d25d40fb
|
7
|
+
data.tar.gz: 319b801a7fd0f8404b8bae6cea2b133622a13953d80ba2d1f83546885c5e926a8e6ce40e0f5316a51325d00c6d548803059e3954f8a475c6f371d41fa4ec84b3
|
@@ -26,7 +26,66 @@
|
|
26
26
|
* @author Jason Mayes.
|
27
27
|
*/
|
28
28
|
/* exported componentHandler */
|
29
|
-
|
29
|
+
|
30
|
+
// Pre-defining the componentHandler interface, for closure documentation and
|
31
|
+
// static verification.
|
32
|
+
var componentHandler = {
|
33
|
+
/**
|
34
|
+
* Searches existing DOM for elements of our component type and upgrades them
|
35
|
+
* if they have not already been upgraded.
|
36
|
+
*
|
37
|
+
* @param {string=} optJsClass the programatic name of the element class we
|
38
|
+
* need to create a new instance of.
|
39
|
+
* @param {string=} optCssClass the name of the CSS class elements of this
|
40
|
+
* type will have.
|
41
|
+
*/
|
42
|
+
upgradeDom: function(optJsClass, optCssClass) {},
|
43
|
+
/**
|
44
|
+
* Upgrades a specific element rather than all in the DOM.
|
45
|
+
*
|
46
|
+
* @param {!Element} element The element we wish to upgrade.
|
47
|
+
* @param {string=} optJsClass Optional name of the class we want to upgrade
|
48
|
+
* the element to.
|
49
|
+
*/
|
50
|
+
upgradeElement: function(element, optJsClass) {},
|
51
|
+
/**
|
52
|
+
* Upgrades a specific list of elements rather than all in the DOM.
|
53
|
+
*
|
54
|
+
* @param {!Element|!Array<!Element>|!NodeList|!HTMLCollection} elements
|
55
|
+
* The elements we wish to upgrade.
|
56
|
+
*/
|
57
|
+
upgradeElements: function(elements) {},
|
58
|
+
/**
|
59
|
+
* Upgrades all registered components found in the current DOM. This is
|
60
|
+
* automatically called on window load.
|
61
|
+
*/
|
62
|
+
upgradeAllRegistered: function() {},
|
63
|
+
/**
|
64
|
+
* Allows user to be alerted to any upgrades that are performed for a given
|
65
|
+
* component type
|
66
|
+
*
|
67
|
+
* @param {string} jsClass The class name of the MDL component we wish
|
68
|
+
* to hook into for any upgrades performed.
|
69
|
+
* @param {function(!HTMLElement)} callback The function to call upon an
|
70
|
+
* upgrade. This function should expect 1 parameter - the HTMLElement which
|
71
|
+
* got upgraded.
|
72
|
+
*/
|
73
|
+
registerUpgradedCallback: function(jsClass, callback) {},
|
74
|
+
/**
|
75
|
+
* Registers a class for future use and attempts to upgrade existing DOM.
|
76
|
+
*
|
77
|
+
* @param {componentHandler.ComponentConfigPublic} config the registration configuration
|
78
|
+
*/
|
79
|
+
register: function(config) {},
|
80
|
+
/**
|
81
|
+
* Downgrade either a given node, an array of nodes, or a NodeList.
|
82
|
+
*
|
83
|
+
* @param {!Node|!Array<!Node>|!NodeList} nodes
|
84
|
+
*/
|
85
|
+
downgradeElements: function(nodes) {}
|
86
|
+
};
|
87
|
+
|
88
|
+
componentHandler = (function() {
|
30
89
|
'use strict';
|
31
90
|
|
32
91
|
/** @type {!Array<componentHandler.ComponentConfig>} */
|
@@ -42,15 +101,15 @@ window.componentHandler = (function() {
|
|
42
101
|
* Searches registered components for a class we are interested in using.
|
43
102
|
* Optionally replaces a match with passed object if specified.
|
44
103
|
*
|
45
|
-
* @param {
|
104
|
+
* @param {string} name The name of a class we want to use.
|
46
105
|
* @param {componentHandler.ComponentConfig=} optReplace Optional object to replace match with.
|
47
|
-
* @return {!Object|
|
106
|
+
* @return {!Object|boolean}
|
48
107
|
* @private
|
49
108
|
*/
|
50
109
|
function findRegisteredClass_(name, optReplace) {
|
51
110
|
for (var i = 0; i < registeredComponents_.length; i++) {
|
52
111
|
if (registeredComponents_[i].className === name) {
|
53
|
-
if (optReplace !== undefined) {
|
112
|
+
if (typeof optReplace !== 'undefined') {
|
54
113
|
registeredComponents_[i] = optReplace;
|
55
114
|
}
|
56
115
|
return registeredComponents_[i];
|
@@ -62,8 +121,8 @@ window.componentHandler = (function() {
|
|
62
121
|
/**
|
63
122
|
* Returns an array of the classNames of the upgraded classes on the element.
|
64
123
|
*
|
65
|
-
* @param {!
|
66
|
-
* @return {!Array<
|
124
|
+
* @param {!Element} element The element to fetch data from.
|
125
|
+
* @return {!Array<string>}
|
67
126
|
* @private
|
68
127
|
*/
|
69
128
|
function getUpgradedListOfElement_(element) {
|
@@ -76,9 +135,9 @@ window.componentHandler = (function() {
|
|
76
135
|
* Returns true if the given element has already been upgraded for the given
|
77
136
|
* class.
|
78
137
|
*
|
79
|
-
* @param {!
|
80
|
-
* @param {
|
81
|
-
* @returns {
|
138
|
+
* @param {!Element} element The element we want to check.
|
139
|
+
* @param {string} jsClass The class to check for.
|
140
|
+
* @returns {boolean}
|
82
141
|
* @private
|
83
142
|
*/
|
84
143
|
function isElementUpgraded_(element, jsClass) {
|
@@ -90,20 +149,21 @@ window.componentHandler = (function() {
|
|
90
149
|
* Searches existing DOM for elements of our component type and upgrades them
|
91
150
|
* if they have not already been upgraded.
|
92
151
|
*
|
93
|
-
* @param {
|
152
|
+
* @param {string=} optJsClass the programatic name of the element class we
|
94
153
|
* need to create a new instance of.
|
95
|
-
* @param {
|
154
|
+
* @param {string=} optCssClass the name of the CSS class elements of this
|
96
155
|
* type will have.
|
97
156
|
*/
|
98
157
|
function upgradeDomInternal(optJsClass, optCssClass) {
|
99
|
-
if (optJsClass === undefined &&
|
158
|
+
if (typeof optJsClass === 'undefined' &&
|
159
|
+
typeof optCssClass === 'undefined') {
|
100
160
|
for (var i = 0; i < registeredComponents_.length; i++) {
|
101
161
|
upgradeDomInternal(registeredComponents_[i].className,
|
102
162
|
registeredComponents_[i].cssClass);
|
103
163
|
}
|
104
164
|
} else {
|
105
|
-
var jsClass = /** @type {
|
106
|
-
if (optCssClass === undefined) {
|
165
|
+
var jsClass = /** @type {string} */ (optJsClass);
|
166
|
+
if (typeof optCssClass === 'undefined') {
|
107
167
|
var registeredClass = findRegisteredClass_(jsClass);
|
108
168
|
if (registeredClass) {
|
109
169
|
optCssClass = registeredClass.cssClass;
|
@@ -120,8 +180,8 @@ window.componentHandler = (function() {
|
|
120
180
|
/**
|
121
181
|
* Upgrades a specific element rather than all in the DOM.
|
122
182
|
*
|
123
|
-
* @param {!
|
124
|
-
* @param {
|
183
|
+
* @param {!Element} element The element we wish to upgrade.
|
184
|
+
* @param {string=} optJsClass Optional name of the class we want to upgrade
|
125
185
|
* the element to.
|
126
186
|
*/
|
127
187
|
function upgradeElementInternal(element, optJsClass) {
|
@@ -180,7 +240,7 @@ window.componentHandler = (function() {
|
|
180
240
|
/**
|
181
241
|
* Upgrades a specific list of elements rather than all in the DOM.
|
182
242
|
*
|
183
|
-
* @param {!
|
243
|
+
* @param {!Element|!Array<!Element>|!NodeList|!HTMLCollection} elements
|
184
244
|
* The elements we wish to upgrade.
|
185
245
|
*/
|
186
246
|
function upgradeElementsInternal(elements) {
|
@@ -194,10 +254,10 @@ window.componentHandler = (function() {
|
|
194
254
|
for (var i = 0, n = elements.length, element; i < n; i++) {
|
195
255
|
element = elements[i];
|
196
256
|
if (element instanceof HTMLElement) {
|
257
|
+
upgradeElementInternal(element);
|
197
258
|
if (element.children.length > 0) {
|
198
259
|
upgradeElementsInternal(element.children);
|
199
260
|
}
|
200
|
-
upgradeElementInternal(element);
|
201
261
|
}
|
202
262
|
}
|
203
263
|
}
|
@@ -205,20 +265,32 @@ window.componentHandler = (function() {
|
|
205
265
|
/**
|
206
266
|
* Registers a class for future use and attempts to upgrade existing DOM.
|
207
267
|
*
|
208
|
-
* @param {
|
268
|
+
* @param {componentHandler.ComponentConfigPublic} config
|
209
269
|
*/
|
210
270
|
function registerInternal(config) {
|
271
|
+
// In order to support both Closure-compiled and uncompiled code accessing
|
272
|
+
// this method, we need to allow for both the dot and array syntax for
|
273
|
+
// property access. You'll therefore see the `foo.bar || foo['bar']`
|
274
|
+
// pattern repeated across this method.
|
275
|
+
var widgetMissing = (typeof config.widget === 'undefined' &&
|
276
|
+
typeof config['widget'] === 'undefined');
|
277
|
+
var widget = true;
|
278
|
+
|
279
|
+
if (!widgetMissing) {
|
280
|
+
widget = config.widget || config['widget'];
|
281
|
+
}
|
282
|
+
|
211
283
|
var newConfig = /** @type {componentHandler.ComponentConfig} */ ({
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
284
|
+
classConstructor: config.constructor || config['constructor'],
|
285
|
+
className: config.classAsString || config['classAsString'],
|
286
|
+
cssClass: config.cssClass || config['cssClass'],
|
287
|
+
widget: widget,
|
288
|
+
callbacks: []
|
217
289
|
});
|
218
290
|
|
219
291
|
registeredComponents_.forEach(function(item) {
|
220
292
|
if (item.cssClass === newConfig.cssClass) {
|
221
|
-
throw new Error('The provided cssClass has already been registered.
|
293
|
+
throw new Error('The provided cssClass has already been registered: ' + item.cssClass);
|
222
294
|
}
|
223
295
|
if (item.className === newConfig.className) {
|
224
296
|
throw new Error('The provided className has already been registered');
|
@@ -243,7 +315,7 @@ window.componentHandler = (function() {
|
|
243
315
|
* Allows user to be alerted to any upgrades that are performed for a given
|
244
316
|
* component type
|
245
317
|
*
|
246
|
-
* @param {
|
318
|
+
* @param {string} jsClass The class name of the MDL component we wish
|
247
319
|
* to hook into for any upgrades performed.
|
248
320
|
* @param {function(!HTMLElement)} callback The function to call upon an
|
249
321
|
* upgrade. This function should expect 1 parameter - the HTMLElement which
|
@@ -315,6 +387,10 @@ window.componentHandler = (function() {
|
|
315
387
|
* @param {!Node|!Array<!Node>|!NodeList} nodes
|
316
388
|
*/
|
317
389
|
function downgradeNodesInternal(nodes) {
|
390
|
+
/**
|
391
|
+
* Auxiliary function to downgrade a single node.
|
392
|
+
* @param {!Node} node the node to be downgraded
|
393
|
+
*/
|
318
394
|
var downgradeNode = function(node) {
|
319
395
|
deconstructComponentInternal(findCreatedComponentByNodeInternal(node));
|
320
396
|
};
|
@@ -342,24 +418,18 @@ window.componentHandler = (function() {
|
|
342
418
|
};
|
343
419
|
})();
|
344
420
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
componentHandler.upgradeAllRegistered();
|
358
|
-
} else {
|
359
|
-
componentHandler.upgradeElement =
|
360
|
-
componentHandler.register = function() {};
|
361
|
-
}
|
362
|
-
});
|
421
|
+
/**
|
422
|
+
* Describes the type of a registered component type managed by
|
423
|
+
* componentHandler. Provided for benefit of the Closure compiler.
|
424
|
+
*
|
425
|
+
* @typedef {{
|
426
|
+
* constructor: Function,
|
427
|
+
* classAsString: string,
|
428
|
+
* cssClass: string,
|
429
|
+
* widget: (string|boolean|undefined)
|
430
|
+
* }}
|
431
|
+
*/
|
432
|
+
componentHandler.ComponentConfigPublic; // jshint ignore:line
|
363
433
|
|
364
434
|
/**
|
365
435
|
* Describes the type of a registered component type managed by
|
@@ -367,9 +437,9 @@ window.addEventListener('load', function() {
|
|
367
437
|
*
|
368
438
|
* @typedef {{
|
369
439
|
* constructor: !Function,
|
370
|
-
* className:
|
371
|
-
* cssClass:
|
372
|
-
* widget:
|
440
|
+
* className: string,
|
441
|
+
* cssClass: string,
|
442
|
+
* widget: (string|boolean),
|
373
443
|
* callbacks: !Array<function(!HTMLElement)>
|
374
444
|
* }}
|
375
445
|
*/
|
@@ -381,14 +451,53 @@ componentHandler.ComponentConfig; // jshint ignore:line
|
|
381
451
|
*
|
382
452
|
* @typedef {{
|
383
453
|
* element_: !HTMLElement,
|
384
|
-
* className:
|
385
|
-
* classAsString:
|
386
|
-
* cssClass:
|
387
|
-
* widget:
|
454
|
+
* className: string,
|
455
|
+
* classAsString: string,
|
456
|
+
* cssClass: string,
|
457
|
+
* widget: string
|
388
458
|
* }}
|
389
459
|
*/
|
390
460
|
componentHandler.Component; // jshint ignore:line
|
391
461
|
|
462
|
+
// Export all symbols, for the benefit of Closure compiler.
|
463
|
+
// No effect on uncompiled code.
|
464
|
+
componentHandler['upgradeDom'] = componentHandler.upgradeDom;
|
465
|
+
componentHandler['upgradeElement'] = componentHandler.upgradeElement;
|
466
|
+
componentHandler['upgradeElements'] = componentHandler.upgradeElements;
|
467
|
+
componentHandler['upgradeAllRegistered'] =
|
468
|
+
componentHandler.upgradeAllRegistered;
|
469
|
+
componentHandler['registerUpgradedCallback'] =
|
470
|
+
componentHandler.registerUpgradedCallback;
|
471
|
+
componentHandler['register'] = componentHandler.register;
|
472
|
+
componentHandler['downgradeElements'] = componentHandler.downgradeElements;
|
473
|
+
window.componentHandler = componentHandler;
|
474
|
+
window['componentHandler'] = componentHandler;
|
475
|
+
|
476
|
+
window.addEventListener('load', function() {
|
477
|
+
'use strict';
|
478
|
+
|
479
|
+
/**
|
480
|
+
* Performs a "Cutting the mustard" test. If the browser supports the features
|
481
|
+
* tested, adds a mdl-js class to the <html> element. It then upgrades all MDL
|
482
|
+
* components requiring JavaScript.
|
483
|
+
*/
|
484
|
+
if ('classList' in document.createElement('div') &&
|
485
|
+
'querySelector' in document &&
|
486
|
+
'addEventListener' in window && Array.prototype.forEach) {
|
487
|
+
document.documentElement.classList.add('mdl-js');
|
488
|
+
componentHandler.upgradeAllRegistered();
|
489
|
+
} else {
|
490
|
+
/**
|
491
|
+
* Dummy function to avoid JS errors.
|
492
|
+
*/
|
493
|
+
componentHandler.upgradeElement = function() {};
|
494
|
+
/**
|
495
|
+
* Dummy function to avoid JS errors.
|
496
|
+
*/
|
497
|
+
componentHandler.register = function() {};
|
498
|
+
}
|
499
|
+
});
|
500
|
+
|
392
501
|
// Source: https://github.com/darius/requestAnimationFrame/blob/master/requestAnimationFrame.js
|
393
502
|
// Adapted from https://gist.github.com/paulirish/1579671 which derived from
|
394
503
|
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
@@ -397,9 +506,14 @@ componentHandler.Component; // jshint ignore:line
|
|
397
506
|
// Fixes from Paul Irish, Tino Zijdel, Andrew Mao, Klemen Slavič, Darius Bacon
|
398
507
|
// MIT license
|
399
508
|
if (!Date.now) {
|
509
|
+
/**
|
510
|
+
* Date.now polyfill.
|
511
|
+
* @return {number} the current Date
|
512
|
+
*/
|
400
513
|
Date.now = function () {
|
401
514
|
return new Date().getTime();
|
402
515
|
};
|
516
|
+
Date['now'] = Date.now;
|
403
517
|
}
|
404
518
|
var vendors = [
|
405
519
|
'webkit',
|
@@ -409,9 +523,15 @@ for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
|
|
409
523
|
var vp = vendors[i];
|
410
524
|
window.requestAnimationFrame = window[vp + 'RequestAnimationFrame'];
|
411
525
|
window.cancelAnimationFrame = window[vp + 'CancelAnimationFrame'] || window[vp + 'CancelRequestAnimationFrame'];
|
526
|
+
window['requestAnimationFrame'] = window.requestAnimationFrame;
|
527
|
+
window['cancelAnimationFrame'] = window.cancelAnimationFrame;
|
412
528
|
}
|
413
529
|
if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAnimationFrame || !window.cancelAnimationFrame) {
|
414
530
|
var lastTime = 0;
|
531
|
+
/**
|
532
|
+
* requestAnimationFrame polyfill.
|
533
|
+
* @param {!Function} callback the callback function.
|
534
|
+
*/
|
415
535
|
window.requestAnimationFrame = function (callback) {
|
416
536
|
var now = Date.now();
|
417
537
|
var nextTime = Math.max(lastTime + 16, now);
|
@@ -420,6 +540,8 @@ if (/iP(ad|hone|od).*OS 6/.test(window.navigator.userAgent) || !window.requestAn
|
|
420
540
|
}, nextTime - now);
|
421
541
|
};
|
422
542
|
window.cancelAnimationFrame = clearTimeout;
|
543
|
+
window['requestAnimationFrame'] = window.requestAnimationFrame;
|
544
|
+
window['cancelAnimationFrame'] = window.cancelAnimationFrame;
|
423
545
|
}
|
424
546
|
/**
|
425
547
|
* @license
|
@@ -449,11 +571,11 @@ var MaterialButton = function MaterialButton(element) {
|
|
449
571
|
// Initialize instance.
|
450
572
|
this.init();
|
451
573
|
};
|
452
|
-
window
|
574
|
+
window['MaterialButton'] = MaterialButton;
|
453
575
|
/**
|
454
576
|
* Store constants in one place so they can be updated easily.
|
455
577
|
*
|
456
|
-
* @enum {
|
578
|
+
* @enum {string | number}
|
457
579
|
* @private
|
458
580
|
*/
|
459
581
|
MaterialButton.prototype.Constant_ = {};
|
@@ -462,7 +584,7 @@ MaterialButton.prototype.Constant_ = {};
|
|
462
584
|
* JavaScript. This allows us to simply change it in one place should we
|
463
585
|
* decide to modify at a later date.
|
464
586
|
*
|
465
|
-
* @enum {
|
587
|
+
* @enum {string}
|
466
588
|
* @private
|
467
589
|
*/
|
468
590
|
MaterialButton.prototype.CssClasses_ = {
|
@@ -490,6 +612,7 @@ MaterialButton.prototype.blurHandler_ = function (event) {
|
|
490
612
|
MaterialButton.prototype.disable = function () {
|
491
613
|
this.element_.disabled = true;
|
492
614
|
};
|
615
|
+
MaterialButton.prototype['disable'] = MaterialButton.prototype.disable;
|
493
616
|
/**
|
494
617
|
* Enable button.
|
495
618
|
*
|
@@ -498,6 +621,7 @@ MaterialButton.prototype.disable = function () {
|
|
498
621
|
MaterialButton.prototype.enable = function () {
|
499
622
|
this.element_.disabled = false;
|
500
623
|
};
|
624
|
+
MaterialButton.prototype['enable'] = MaterialButton.prototype.enable;
|
501
625
|
/**
|
502
626
|
* Initialize element.
|
503
627
|
*/
|
@@ -559,6 +683,7 @@ componentHandler.register({
|
|
559
683
|
* Implements MDL component design pattern defined at:
|
560
684
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
561
685
|
*
|
686
|
+
* @constructor
|
562
687
|
* @param {HTMLElement} element The element that will be upgraded.
|
563
688
|
*/
|
564
689
|
var MaterialCheckbox = function MaterialCheckbox(element) {
|
@@ -566,11 +691,11 @@ var MaterialCheckbox = function MaterialCheckbox(element) {
|
|
566
691
|
// Initialize instance.
|
567
692
|
this.init();
|
568
693
|
};
|
569
|
-
window
|
694
|
+
window['MaterialCheckbox'] = MaterialCheckbox;
|
570
695
|
/**
|
571
696
|
* Store constants in one place so they can be updated easily.
|
572
697
|
*
|
573
|
-
* @enum {
|
698
|
+
* @enum {string | number}
|
574
699
|
* @private
|
575
700
|
*/
|
576
701
|
MaterialCheckbox.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
@@ -579,7 +704,7 @@ MaterialCheckbox.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
|
579
704
|
* JavaScript. This allows us to simply change it in one place should we
|
580
705
|
* decide to modify at a later date.
|
581
706
|
*
|
582
|
-
* @enum {
|
707
|
+
* @enum {string}
|
583
708
|
* @private
|
584
709
|
*/
|
585
710
|
MaterialCheckbox.prototype.CssClasses_ = {
|
@@ -645,10 +770,9 @@ MaterialCheckbox.prototype.updateClasses_ = function () {
|
|
645
770
|
/**
|
646
771
|
* Add blur.
|
647
772
|
*
|
648
|
-
* @param {Event} event The event that fired.
|
649
773
|
* @private
|
650
774
|
*/
|
651
|
-
MaterialCheckbox.prototype.blur_ = function (
|
775
|
+
MaterialCheckbox.prototype.blur_ = function () {
|
652
776
|
// TODO: figure out why there's a focus event being fired after our blur,
|
653
777
|
// so that we can avoid this hack.
|
654
778
|
window.setTimeout(function () {
|
@@ -668,6 +792,7 @@ MaterialCheckbox.prototype.checkToggleState = function () {
|
|
668
792
|
this.element_.classList.remove(this.CssClasses_.IS_CHECKED);
|
669
793
|
}
|
670
794
|
};
|
795
|
+
MaterialCheckbox.prototype['checkToggleState'] = MaterialCheckbox.prototype.checkToggleState;
|
671
796
|
/**
|
672
797
|
* Check the inputs disabled state and update display.
|
673
798
|
*
|
@@ -680,6 +805,7 @@ MaterialCheckbox.prototype.checkDisabled = function () {
|
|
680
805
|
this.element_.classList.remove(this.CssClasses_.IS_DISABLED);
|
681
806
|
}
|
682
807
|
};
|
808
|
+
MaterialCheckbox.prototype['checkDisabled'] = MaterialCheckbox.prototype.checkDisabled;
|
683
809
|
/**
|
684
810
|
* Disable checkbox.
|
685
811
|
*
|
@@ -689,6 +815,7 @@ MaterialCheckbox.prototype.disable = function () {
|
|
689
815
|
this.inputElement_.disabled = true;
|
690
816
|
this.updateClasses_();
|
691
817
|
};
|
818
|
+
MaterialCheckbox.prototype['disable'] = MaterialCheckbox.prototype.disable;
|
692
819
|
/**
|
693
820
|
* Enable checkbox.
|
694
821
|
*
|
@@ -698,6 +825,7 @@ MaterialCheckbox.prototype.enable = function () {
|
|
698
825
|
this.inputElement_.disabled = false;
|
699
826
|
this.updateClasses_();
|
700
827
|
};
|
828
|
+
MaterialCheckbox.prototype['enable'] = MaterialCheckbox.prototype.enable;
|
701
829
|
/**
|
702
830
|
* Check checkbox.
|
703
831
|
*
|
@@ -707,6 +835,7 @@ MaterialCheckbox.prototype.check = function () {
|
|
707
835
|
this.inputElement_.checked = true;
|
708
836
|
this.updateClasses_();
|
709
837
|
};
|
838
|
+
MaterialCheckbox.prototype['check'] = MaterialCheckbox.prototype.check;
|
710
839
|
/**
|
711
840
|
* Uncheck checkbox.
|
712
841
|
*
|
@@ -716,6 +845,7 @@ MaterialCheckbox.prototype.uncheck = function () {
|
|
716
845
|
this.inputElement_.checked = false;
|
717
846
|
this.updateClasses_();
|
718
847
|
};
|
848
|
+
MaterialCheckbox.prototype['uncheck'] = MaterialCheckbox.prototype.uncheck;
|
719
849
|
/**
|
720
850
|
* Initialize element.
|
721
851
|
*/
|
@@ -799,6 +929,7 @@ componentHandler.register({
|
|
799
929
|
* Implements MDL component design pattern defined at:
|
800
930
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
801
931
|
*
|
932
|
+
* @constructor
|
802
933
|
* @param {HTMLElement} element The element that will be upgraded.
|
803
934
|
*/
|
804
935
|
var MaterialIconToggle = function MaterialIconToggle(element) {
|
@@ -806,11 +937,11 @@ var MaterialIconToggle = function MaterialIconToggle(element) {
|
|
806
937
|
// Initialize instance.
|
807
938
|
this.init();
|
808
939
|
};
|
809
|
-
window
|
940
|
+
window['MaterialIconToggle'] = MaterialIconToggle;
|
810
941
|
/**
|
811
942
|
* Store constants in one place so they can be updated easily.
|
812
943
|
*
|
813
|
-
* @enum {
|
944
|
+
* @enum {string | number}
|
814
945
|
* @private
|
815
946
|
*/
|
816
947
|
MaterialIconToggle.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
@@ -819,7 +950,7 @@ MaterialIconToggle.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
|
819
950
|
* JavaScript. This allows us to simply change it in one place should we
|
820
951
|
* decide to modify at a later date.
|
821
952
|
*
|
822
|
-
* @enum {
|
953
|
+
* @enum {string}
|
823
954
|
* @private
|
824
955
|
*/
|
825
956
|
MaterialIconToggle.prototype.CssClasses_ = {
|
@@ -881,10 +1012,9 @@ MaterialIconToggle.prototype.updateClasses_ = function () {
|
|
881
1012
|
/**
|
882
1013
|
* Add blur.
|
883
1014
|
*
|
884
|
-
* @param {Event} event The event that fired.
|
885
1015
|
* @private
|
886
1016
|
*/
|
887
|
-
MaterialIconToggle.prototype.blur_ = function (
|
1017
|
+
MaterialIconToggle.prototype.blur_ = function () {
|
888
1018
|
// TODO: figure out why there's a focus event being fired after our blur,
|
889
1019
|
// so that we can avoid this hack.
|
890
1020
|
window.setTimeout(function () {
|
@@ -904,6 +1034,7 @@ MaterialIconToggle.prototype.checkToggleState = function () {
|
|
904
1034
|
this.element_.classList.remove(this.CssClasses_.IS_CHECKED);
|
905
1035
|
}
|
906
1036
|
};
|
1037
|
+
MaterialIconToggle.prototype['checkToggleState'] = MaterialIconToggle.prototype.checkToggleState;
|
907
1038
|
/**
|
908
1039
|
* Check the inputs disabled state and update display.
|
909
1040
|
*
|
@@ -916,6 +1047,7 @@ MaterialIconToggle.prototype.checkDisabled = function () {
|
|
916
1047
|
this.element_.classList.remove(this.CssClasses_.IS_DISABLED);
|
917
1048
|
}
|
918
1049
|
};
|
1050
|
+
MaterialIconToggle.prototype['checkDisabled'] = MaterialIconToggle.prototype.checkDisabled;
|
919
1051
|
/**
|
920
1052
|
* Disable icon toggle.
|
921
1053
|
*
|
@@ -925,6 +1057,7 @@ MaterialIconToggle.prototype.disable = function () {
|
|
925
1057
|
this.inputElement_.disabled = true;
|
926
1058
|
this.updateClasses_();
|
927
1059
|
};
|
1060
|
+
MaterialIconToggle.prototype['disable'] = MaterialIconToggle.prototype.disable;
|
928
1061
|
/**
|
929
1062
|
* Enable icon toggle.
|
930
1063
|
*
|
@@ -934,6 +1067,7 @@ MaterialIconToggle.prototype.enable = function () {
|
|
934
1067
|
this.inputElement_.disabled = false;
|
935
1068
|
this.updateClasses_();
|
936
1069
|
};
|
1070
|
+
MaterialIconToggle.prototype['enable'] = MaterialIconToggle.prototype.enable;
|
937
1071
|
/**
|
938
1072
|
* Check icon toggle.
|
939
1073
|
*
|
@@ -943,6 +1077,7 @@ MaterialIconToggle.prototype.check = function () {
|
|
943
1077
|
this.inputElement_.checked = true;
|
944
1078
|
this.updateClasses_();
|
945
1079
|
};
|
1080
|
+
MaterialIconToggle.prototype['check'] = MaterialIconToggle.prototype.check;
|
946
1081
|
/**
|
947
1082
|
* Uncheck icon toggle.
|
948
1083
|
*
|
@@ -952,6 +1087,7 @@ MaterialIconToggle.prototype.uncheck = function () {
|
|
952
1087
|
this.inputElement_.checked = false;
|
953
1088
|
this.updateClasses_();
|
954
1089
|
};
|
1090
|
+
MaterialIconToggle.prototype['uncheck'] = MaterialIconToggle.prototype.uncheck;
|
955
1091
|
/**
|
956
1092
|
* Initialize element.
|
957
1093
|
*/
|
@@ -1026,6 +1162,7 @@ componentHandler.register({
|
|
1026
1162
|
* Implements MDL component design pattern defined at:
|
1027
1163
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
1028
1164
|
*
|
1165
|
+
* @constructor
|
1029
1166
|
* @param {HTMLElement} element The element that will be upgraded.
|
1030
1167
|
*/
|
1031
1168
|
var MaterialMenu = function MaterialMenu(element) {
|
@@ -1033,11 +1170,11 @@ var MaterialMenu = function MaterialMenu(element) {
|
|
1033
1170
|
// Initialize instance.
|
1034
1171
|
this.init();
|
1035
1172
|
};
|
1036
|
-
window
|
1173
|
+
window['MaterialMenu'] = MaterialMenu;
|
1037
1174
|
/**
|
1038
1175
|
* Store constants in one place so they can be updated easily.
|
1039
1176
|
*
|
1040
|
-
* @enum {
|
1177
|
+
* @enum {string | number}
|
1041
1178
|
* @private
|
1042
1179
|
*/
|
1043
1180
|
MaterialMenu.prototype.Constant_ = {
|
@@ -1052,7 +1189,7 @@ MaterialMenu.prototype.Constant_ = {
|
|
1052
1189
|
/**
|
1053
1190
|
* Keycodes, for code readability.
|
1054
1191
|
*
|
1055
|
-
* @enum {
|
1192
|
+
* @enum {number}
|
1056
1193
|
* @private
|
1057
1194
|
*/
|
1058
1195
|
MaterialMenu.prototype.Keycodes_ = {
|
@@ -1067,7 +1204,7 @@ MaterialMenu.prototype.Keycodes_ = {
|
|
1067
1204
|
* JavaScript. This allows us to simply change it in one place should we
|
1068
1205
|
* decide to modify at a later date.
|
1069
1206
|
*
|
1070
|
-
* @enum {
|
1207
|
+
* @enum {string}
|
1071
1208
|
* @private
|
1072
1209
|
*/
|
1073
1210
|
MaterialMenu.prototype.CssClasses_ = {
|
@@ -1278,14 +1415,14 @@ MaterialMenu.prototype.handleItemClick_ = function (evt) {
|
|
1278
1415
|
* it), and applies it. This allows us to animate from or to the correct point,
|
1279
1416
|
* that is, the point it's aligned to in the "for" element.
|
1280
1417
|
*
|
1281
|
-
* @param {
|
1282
|
-
* @param {
|
1418
|
+
* @param {number} height Height of the clip rectangle
|
1419
|
+
* @param {number} width Width of the clip rectangle
|
1283
1420
|
* @private
|
1284
1421
|
*/
|
1285
1422
|
MaterialMenu.prototype.applyClip_ = function (height, width) {
|
1286
1423
|
if (this.element_.classList.contains(this.CssClasses_.UNALIGNED)) {
|
1287
1424
|
// Do not clip.
|
1288
|
-
this.element_.style.clip =
|
1425
|
+
this.element_.style.clip = '';
|
1289
1426
|
} else if (this.element_.classList.contains(this.CssClasses_.BOTTOM_RIGHT)) {
|
1290
1427
|
// Clip to the top right corner of the menu.
|
1291
1428
|
this.element_.style.clip = 'rect(0 ' + width + 'px ' + '0 ' + width + 'px)';
|
@@ -1297,7 +1434,7 @@ MaterialMenu.prototype.applyClip_ = function (height, width) {
|
|
1297
1434
|
this.element_.style.clip = 'rect(' + height + 'px ' + width + 'px ' + height + 'px ' + width + 'px)';
|
1298
1435
|
} else {
|
1299
1436
|
// Default: do not clip (same as clipping to the top left corner).
|
1300
|
-
this.element_.style.clip =
|
1437
|
+
this.element_.style.clip = '';
|
1301
1438
|
}
|
1302
1439
|
};
|
1303
1440
|
/**
|
@@ -1368,6 +1505,7 @@ MaterialMenu.prototype.show = function (evt) {
|
|
1368
1505
|
document.addEventListener('click', callback);
|
1369
1506
|
}
|
1370
1507
|
};
|
1508
|
+
MaterialMenu.prototype['show'] = MaterialMenu.prototype.show;
|
1371
1509
|
/**
|
1372
1510
|
* Hides the menu.
|
1373
1511
|
*
|
@@ -1392,6 +1530,7 @@ MaterialMenu.prototype.hide = function () {
|
|
1392
1530
|
this.addAnimationEndListener_();
|
1393
1531
|
}
|
1394
1532
|
};
|
1533
|
+
MaterialMenu.prototype['hide'] = MaterialMenu.prototype.hide;
|
1395
1534
|
/**
|
1396
1535
|
* Displays or hides the menu, depending on current state.
|
1397
1536
|
*
|
@@ -1404,6 +1543,7 @@ MaterialMenu.prototype.toggle = function (evt) {
|
|
1404
1543
|
this.show(evt);
|
1405
1544
|
}
|
1406
1545
|
};
|
1546
|
+
MaterialMenu.prototype['toggle'] = MaterialMenu.prototype.toggle;
|
1407
1547
|
/**
|
1408
1548
|
* Downgrade the component.
|
1409
1549
|
*
|
@@ -1445,6 +1585,7 @@ componentHandler.register({
|
|
1445
1585
|
* Implements MDL component design pattern defined at:
|
1446
1586
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
1447
1587
|
*
|
1588
|
+
* @constructor
|
1448
1589
|
* @param {HTMLElement} element The element that will be upgraded.
|
1449
1590
|
*/
|
1450
1591
|
var MaterialProgress = function MaterialProgress(element) {
|
@@ -1452,11 +1593,11 @@ var MaterialProgress = function MaterialProgress(element) {
|
|
1452
1593
|
// Initialize instance.
|
1453
1594
|
this.init();
|
1454
1595
|
};
|
1455
|
-
window
|
1596
|
+
window['MaterialProgress'] = MaterialProgress;
|
1456
1597
|
/**
|
1457
1598
|
* Store constants in one place so they can be updated easily.
|
1458
1599
|
*
|
1459
|
-
* @enum {
|
1600
|
+
* @enum {string | number}
|
1460
1601
|
* @private
|
1461
1602
|
*/
|
1462
1603
|
MaterialProgress.prototype.Constant_ = {};
|
@@ -1465,14 +1606,14 @@ MaterialProgress.prototype.Constant_ = {};
|
|
1465
1606
|
* JavaScript. This allows us to simply change it in one place should we
|
1466
1607
|
* decide to modify at a later date.
|
1467
1608
|
*
|
1468
|
-
* @enum {
|
1609
|
+
* @enum {string}
|
1469
1610
|
* @private
|
1470
1611
|
*/
|
1471
1612
|
MaterialProgress.prototype.CssClasses_ = { INDETERMINATE_CLASS: 'mdl-progress__indeterminate' };
|
1472
1613
|
/**
|
1473
1614
|
* Set the current progress of the progressbar.
|
1474
1615
|
*
|
1475
|
-
* @param {
|
1616
|
+
* @param {number} p Percentage of the progress (0-100)
|
1476
1617
|
* @public
|
1477
1618
|
*/
|
1478
1619
|
MaterialProgress.prototype.setProgress = function (p) {
|
@@ -1481,16 +1622,18 @@ MaterialProgress.prototype.setProgress = function (p) {
|
|
1481
1622
|
}
|
1482
1623
|
this.progressbar_.style.width = p + '%';
|
1483
1624
|
};
|
1625
|
+
MaterialProgress.prototype['setProgress'] = MaterialProgress.prototype.setProgress;
|
1484
1626
|
/**
|
1485
1627
|
* Set the current progress of the buffer.
|
1486
1628
|
*
|
1487
|
-
* @param {
|
1629
|
+
* @param {number} p Percentage of the buffer (0-100)
|
1488
1630
|
* @public
|
1489
1631
|
*/
|
1490
1632
|
MaterialProgress.prototype.setBuffer = function (p) {
|
1491
1633
|
this.bufferbar_.style.width = p + '%';
|
1492
1634
|
this.auxbar_.style.width = 100 - p + '%';
|
1493
1635
|
};
|
1636
|
+
MaterialProgress.prototype['setBuffer'] = MaterialProgress.prototype.setBuffer;
|
1494
1637
|
/**
|
1495
1638
|
* Initialize element.
|
1496
1639
|
*/
|
@@ -1553,6 +1696,7 @@ componentHandler.register({
|
|
1553
1696
|
* Implements MDL component design pattern defined at:
|
1554
1697
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
1555
1698
|
*
|
1699
|
+
* @constructor
|
1556
1700
|
* @param {HTMLElement} element The element that will be upgraded.
|
1557
1701
|
*/
|
1558
1702
|
var MaterialRadio = function MaterialRadio(element) {
|
@@ -1560,11 +1704,11 @@ var MaterialRadio = function MaterialRadio(element) {
|
|
1560
1704
|
// Initialize instance.
|
1561
1705
|
this.init();
|
1562
1706
|
};
|
1563
|
-
window
|
1707
|
+
window['MaterialRadio'] = MaterialRadio;
|
1564
1708
|
/**
|
1565
1709
|
* Store constants in one place so they can be updated easily.
|
1566
1710
|
*
|
1567
|
-
* @enum {
|
1711
|
+
* @enum {string | number}
|
1568
1712
|
* @private
|
1569
1713
|
*/
|
1570
1714
|
MaterialRadio.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
@@ -1573,7 +1717,7 @@ MaterialRadio.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
|
1573
1717
|
* JavaScript. This allows us to simply change it in one place should we
|
1574
1718
|
* decide to modify at a later date.
|
1575
1719
|
*
|
1576
|
-
* @enum {
|
1720
|
+
* @enum {string}
|
1577
1721
|
* @private
|
1578
1722
|
*/
|
1579
1723
|
MaterialRadio.prototype.CssClasses_ = {
|
@@ -1605,7 +1749,7 @@ MaterialRadio.prototype.onChange_ = function (event) {
|
|
1605
1749
|
var button = radios[i].querySelector('.' + this.CssClasses_.RADIO_BTN);
|
1606
1750
|
// Different name == different group, so no point updating those.
|
1607
1751
|
if (button.getAttribute('name') === this.btnElement_.getAttribute('name')) {
|
1608
|
-
radios[i]
|
1752
|
+
radios[i]['MaterialRadio'].updateClasses_();
|
1609
1753
|
}
|
1610
1754
|
}
|
1611
1755
|
};
|
@@ -1648,10 +1792,9 @@ MaterialRadio.prototype.updateClasses_ = function () {
|
|
1648
1792
|
/**
|
1649
1793
|
* Add blur.
|
1650
1794
|
*
|
1651
|
-
* @param {Event} event The event that fired.
|
1652
1795
|
* @private
|
1653
1796
|
*/
|
1654
|
-
MaterialRadio.prototype.blur_ = function (
|
1797
|
+
MaterialRadio.prototype.blur_ = function () {
|
1655
1798
|
// TODO: figure out why there's a focus event being fired after our blur,
|
1656
1799
|
// so that we can avoid this hack.
|
1657
1800
|
window.setTimeout(function () {
|
@@ -1671,6 +1814,7 @@ MaterialRadio.prototype.checkDisabled = function () {
|
|
1671
1814
|
this.element_.classList.remove(this.CssClasses_.IS_DISABLED);
|
1672
1815
|
}
|
1673
1816
|
};
|
1817
|
+
MaterialRadio.prototype['checkDisabled'] = MaterialRadio.prototype.checkDisabled;
|
1674
1818
|
/**
|
1675
1819
|
* Check the components toggled state.
|
1676
1820
|
*
|
@@ -1683,6 +1827,7 @@ MaterialRadio.prototype.checkToggleState = function () {
|
|
1683
1827
|
this.element_.classList.remove(this.CssClasses_.IS_CHECKED);
|
1684
1828
|
}
|
1685
1829
|
};
|
1830
|
+
MaterialRadio.prototype['checkToggleState'] = MaterialRadio.prototype.checkToggleState;
|
1686
1831
|
/**
|
1687
1832
|
* Disable radio.
|
1688
1833
|
*
|
@@ -1692,6 +1837,7 @@ MaterialRadio.prototype.disable = function () {
|
|
1692
1837
|
this.btnElement_.disabled = true;
|
1693
1838
|
this.updateClasses_();
|
1694
1839
|
};
|
1840
|
+
MaterialRadio.prototype['disable'] = MaterialRadio.prototype.disable;
|
1695
1841
|
/**
|
1696
1842
|
* Enable radio.
|
1697
1843
|
*
|
@@ -1701,6 +1847,7 @@ MaterialRadio.prototype.enable = function () {
|
|
1701
1847
|
this.btnElement_.disabled = false;
|
1702
1848
|
this.updateClasses_();
|
1703
1849
|
};
|
1850
|
+
MaterialRadio.prototype['enable'] = MaterialRadio.prototype.enable;
|
1704
1851
|
/**
|
1705
1852
|
* Check radio.
|
1706
1853
|
*
|
@@ -1710,6 +1857,7 @@ MaterialRadio.prototype.check = function () {
|
|
1710
1857
|
this.btnElement_.checked = true;
|
1711
1858
|
this.updateClasses_();
|
1712
1859
|
};
|
1860
|
+
MaterialRadio.prototype['check'] = MaterialRadio.prototype.check;
|
1713
1861
|
/**
|
1714
1862
|
* Uncheck radio.
|
1715
1863
|
*
|
@@ -1719,6 +1867,7 @@ MaterialRadio.prototype.uncheck = function () {
|
|
1719
1867
|
this.btnElement_.checked = false;
|
1720
1868
|
this.updateClasses_();
|
1721
1869
|
};
|
1870
|
+
MaterialRadio.prototype['uncheck'] = MaterialRadio.prototype.uncheck;
|
1722
1871
|
/**
|
1723
1872
|
* Initialize element.
|
1724
1873
|
*/
|
@@ -1781,6 +1930,7 @@ componentHandler.register({
|
|
1781
1930
|
* Implements MDL component design pattern defined at:
|
1782
1931
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
1783
1932
|
*
|
1933
|
+
* @constructor
|
1784
1934
|
* @param {HTMLElement} element The element that will be upgraded.
|
1785
1935
|
*/
|
1786
1936
|
var MaterialSlider = function MaterialSlider(element) {
|
@@ -1790,11 +1940,11 @@ var MaterialSlider = function MaterialSlider(element) {
|
|
1790
1940
|
// Initialize instance.
|
1791
1941
|
this.init();
|
1792
1942
|
};
|
1793
|
-
window
|
1943
|
+
window['MaterialSlider'] = MaterialSlider;
|
1794
1944
|
/**
|
1795
1945
|
* Store constants in one place so they can be updated easily.
|
1796
1946
|
*
|
1797
|
-
* @enum {
|
1947
|
+
* @enum {string | number}
|
1798
1948
|
* @private
|
1799
1949
|
*/
|
1800
1950
|
MaterialSlider.prototype.Constant_ = {};
|
@@ -1803,7 +1953,7 @@ MaterialSlider.prototype.Constant_ = {};
|
|
1803
1953
|
* JavaScript. This allows us to simply change it in one place should we
|
1804
1954
|
* decide to modify at a later date.
|
1805
1955
|
*
|
1806
|
-
* @enum {
|
1956
|
+
* @enum {string}
|
1807
1957
|
* @private
|
1808
1958
|
*/
|
1809
1959
|
MaterialSlider.prototype.CssClasses_ = {
|
@@ -1850,6 +2000,7 @@ MaterialSlider.prototype.onMouseUp_ = function (event) {
|
|
1850
2000
|
*
|
1851
2001
|
* @param {Event} event The event that fired.
|
1852
2002
|
* @private
|
2003
|
+
* @suppress {missingProperties}
|
1853
2004
|
*/
|
1854
2005
|
MaterialSlider.prototype.onContainerMouseDown_ = function (event) {
|
1855
2006
|
// If this click is not on the parent element (but rather some child)
|
@@ -1871,10 +2022,9 @@ MaterialSlider.prototype.onContainerMouseDown_ = function (event) {
|
|
1871
2022
|
/**
|
1872
2023
|
* Handle updating of values.
|
1873
2024
|
*
|
1874
|
-
* @param {Event} event The event that fired.
|
1875
2025
|
* @private
|
1876
2026
|
*/
|
1877
|
-
MaterialSlider.prototype.updateValueStyles_ = function (
|
2027
|
+
MaterialSlider.prototype.updateValueStyles_ = function () {
|
1878
2028
|
// Calculate and apply percentages to div structure behind slider.
|
1879
2029
|
var fraction = (this.element_.value - this.element_.min) / (this.element_.max - this.element_.min);
|
1880
2030
|
if (fraction === 0) {
|
@@ -1898,6 +2048,7 @@ MaterialSlider.prototype.updateValueStyles_ = function (event) {
|
|
1898
2048
|
MaterialSlider.prototype.disable = function () {
|
1899
2049
|
this.element_.disabled = true;
|
1900
2050
|
};
|
2051
|
+
MaterialSlider.prototype['disable'] = MaterialSlider.prototype.disable;
|
1901
2052
|
/**
|
1902
2053
|
* Enable slider.
|
1903
2054
|
*
|
@@ -1906,10 +2057,11 @@ MaterialSlider.prototype.disable = function () {
|
|
1906
2057
|
MaterialSlider.prototype.enable = function () {
|
1907
2058
|
this.element_.disabled = false;
|
1908
2059
|
};
|
2060
|
+
MaterialSlider.prototype['enable'] = MaterialSlider.prototype.enable;
|
1909
2061
|
/**
|
1910
2062
|
* Update slider value.
|
1911
2063
|
*
|
1912
|
-
* @param {
|
2064
|
+
* @param {number} value The value to which to set the control (optional).
|
1913
2065
|
* @public
|
1914
2066
|
*/
|
1915
2067
|
MaterialSlider.prototype.change = function (value) {
|
@@ -1918,6 +2070,7 @@ MaterialSlider.prototype.change = function (value) {
|
|
1918
2070
|
}
|
1919
2071
|
this.updateValueStyles_();
|
1920
2072
|
};
|
2073
|
+
MaterialSlider.prototype['change'] = MaterialSlider.prototype.change;
|
1921
2074
|
/**
|
1922
2075
|
* Initialize element.
|
1923
2076
|
*/
|
@@ -2011,11 +2164,11 @@ var MaterialSpinner = function MaterialSpinner(element) {
|
|
2011
2164
|
// Initialize instance.
|
2012
2165
|
this.init();
|
2013
2166
|
};
|
2014
|
-
window
|
2167
|
+
window['MaterialSpinner'] = MaterialSpinner;
|
2015
2168
|
/**
|
2016
2169
|
* Store constants in one place so they can be updated easily.
|
2017
2170
|
*
|
2018
|
-
* @enum {
|
2171
|
+
* @enum {string | number}
|
2019
2172
|
* @private
|
2020
2173
|
*/
|
2021
2174
|
MaterialSpinner.prototype.Constant_ = { MDL_SPINNER_LAYER_COUNT: 4 };
|
@@ -2024,7 +2177,7 @@ MaterialSpinner.prototype.Constant_ = { MDL_SPINNER_LAYER_COUNT: 4 };
|
|
2024
2177
|
* JavaScript. This allows us to simply change it in one place should we
|
2025
2178
|
* decide to modify at a later date.
|
2026
2179
|
*
|
2027
|
-
* @enum {
|
2180
|
+
* @enum {string}
|
2028
2181
|
* @private
|
2029
2182
|
*/
|
2030
2183
|
MaterialSpinner.prototype.CssClasses_ = {
|
@@ -2038,7 +2191,7 @@ MaterialSpinner.prototype.CssClasses_ = {
|
|
2038
2191
|
/**
|
2039
2192
|
* Auxiliary method to create a spinner layer.
|
2040
2193
|
*
|
2041
|
-
* @param {
|
2194
|
+
* @param {number} index Index of the layer to be created.
|
2042
2195
|
* @public
|
2043
2196
|
*/
|
2044
2197
|
MaterialSpinner.prototype.createLayer = function (index) {
|
@@ -2068,6 +2221,7 @@ MaterialSpinner.prototype.createLayer = function (index) {
|
|
2068
2221
|
layer.appendChild(rightClipper);
|
2069
2222
|
this.element_.appendChild(layer);
|
2070
2223
|
};
|
2224
|
+
MaterialSpinner.prototype['createLayer'] = MaterialSpinner.prototype.createLayer;
|
2071
2225
|
/**
|
2072
2226
|
* Stops the spinner animation.
|
2073
2227
|
* Public method for users who need to stop the spinner for any reason.
|
@@ -2077,6 +2231,7 @@ MaterialSpinner.prototype.createLayer = function (index) {
|
|
2077
2231
|
MaterialSpinner.prototype.stop = function () {
|
2078
2232
|
this.element_.classList.remove('is-active');
|
2079
2233
|
};
|
2234
|
+
MaterialSpinner.prototype['stop'] = MaterialSpinner.prototype.stop;
|
2080
2235
|
/**
|
2081
2236
|
* Starts the spinner animation.
|
2082
2237
|
* Public method for users who need to manually start the spinner for any reason
|
@@ -2087,6 +2242,7 @@ MaterialSpinner.prototype.stop = function () {
|
|
2087
2242
|
MaterialSpinner.prototype.start = function () {
|
2088
2243
|
this.element_.classList.add('is-active');
|
2089
2244
|
};
|
2245
|
+
MaterialSpinner.prototype['start'] = MaterialSpinner.prototype.start;
|
2090
2246
|
/**
|
2091
2247
|
* Initialize element.
|
2092
2248
|
*/
|
@@ -2127,6 +2283,7 @@ componentHandler.register({
|
|
2127
2283
|
* Implements MDL component design pattern defined at:
|
2128
2284
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
2129
2285
|
*
|
2286
|
+
* @constructor
|
2130
2287
|
* @param {HTMLElement} element The element that will be upgraded.
|
2131
2288
|
*/
|
2132
2289
|
var MaterialSwitch = function MaterialSwitch(element) {
|
@@ -2134,11 +2291,11 @@ var MaterialSwitch = function MaterialSwitch(element) {
|
|
2134
2291
|
// Initialize instance.
|
2135
2292
|
this.init();
|
2136
2293
|
};
|
2137
|
-
window
|
2294
|
+
window['MaterialSwitch'] = MaterialSwitch;
|
2138
2295
|
/**
|
2139
2296
|
* Store constants in one place so they can be updated easily.
|
2140
2297
|
*
|
2141
|
-
* @enum {
|
2298
|
+
* @enum {string | number}
|
2142
2299
|
* @private
|
2143
2300
|
*/
|
2144
2301
|
MaterialSwitch.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
@@ -2147,7 +2304,7 @@ MaterialSwitch.prototype.Constant_ = { TINY_TIMEOUT: 0.001 };
|
|
2147
2304
|
* JavaScript. This allows us to simply change it in one place should we
|
2148
2305
|
* decide to modify at a later date.
|
2149
2306
|
*
|
2150
|
-
* @enum {
|
2307
|
+
* @enum {string}
|
2151
2308
|
* @private
|
2152
2309
|
*/
|
2153
2310
|
MaterialSwitch.prototype.CssClasses_ = {
|
@@ -2214,7 +2371,7 @@ MaterialSwitch.prototype.updateClasses_ = function () {
|
|
2214
2371
|
*
|
2215
2372
|
* @private
|
2216
2373
|
*/
|
2217
|
-
MaterialSwitch.prototype.blur_ = function (
|
2374
|
+
MaterialSwitch.prototype.blur_ = function () {
|
2218
2375
|
// TODO: figure out why there's a focus event being fired after our blur,
|
2219
2376
|
// so that we can avoid this hack.
|
2220
2377
|
window.setTimeout(function () {
|
@@ -2234,6 +2391,7 @@ MaterialSwitch.prototype.checkDisabled = function () {
|
|
2234
2391
|
this.element_.classList.remove(this.CssClasses_.IS_DISABLED);
|
2235
2392
|
}
|
2236
2393
|
};
|
2394
|
+
MaterialSwitch.prototype['checkDisabled'] = MaterialSwitch.prototype.checkDisabled;
|
2237
2395
|
/**
|
2238
2396
|
* Check the components toggled state.
|
2239
2397
|
*
|
@@ -2246,6 +2404,7 @@ MaterialSwitch.prototype.checkToggleState = function () {
|
|
2246
2404
|
this.element_.classList.remove(this.CssClasses_.IS_CHECKED);
|
2247
2405
|
}
|
2248
2406
|
};
|
2407
|
+
MaterialSwitch.prototype['checkToggleState'] = MaterialSwitch.prototype.checkToggleState;
|
2249
2408
|
/**
|
2250
2409
|
* Disable switch.
|
2251
2410
|
*
|
@@ -2255,6 +2414,7 @@ MaterialSwitch.prototype.disable = function () {
|
|
2255
2414
|
this.inputElement_.disabled = true;
|
2256
2415
|
this.updateClasses_();
|
2257
2416
|
};
|
2417
|
+
MaterialSwitch.prototype['disable'] = MaterialSwitch.prototype.disable;
|
2258
2418
|
/**
|
2259
2419
|
* Enable switch.
|
2260
2420
|
*
|
@@ -2264,6 +2424,7 @@ MaterialSwitch.prototype.enable = function () {
|
|
2264
2424
|
this.inputElement_.disabled = false;
|
2265
2425
|
this.updateClasses_();
|
2266
2426
|
};
|
2427
|
+
MaterialSwitch.prototype['enable'] = MaterialSwitch.prototype.enable;
|
2267
2428
|
/**
|
2268
2429
|
* Activate switch.
|
2269
2430
|
*
|
@@ -2273,6 +2434,7 @@ MaterialSwitch.prototype.on = function () {
|
|
2273
2434
|
this.inputElement_.checked = true;
|
2274
2435
|
this.updateClasses_();
|
2275
2436
|
};
|
2437
|
+
MaterialSwitch.prototype['on'] = MaterialSwitch.prototype.on;
|
2276
2438
|
/**
|
2277
2439
|
* Deactivate switch.
|
2278
2440
|
*
|
@@ -2282,6 +2444,7 @@ MaterialSwitch.prototype.off = function () {
|
|
2282
2444
|
this.inputElement_.checked = false;
|
2283
2445
|
this.updateClasses_();
|
2284
2446
|
};
|
2447
|
+
MaterialSwitch.prototype['off'] = MaterialSwitch.prototype.off;
|
2285
2448
|
/**
|
2286
2449
|
* Initialize element.
|
2287
2450
|
*/
|
@@ -2364,6 +2527,7 @@ componentHandler.register({
|
|
2364
2527
|
* Implements MDL component design pattern defined at:
|
2365
2528
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
2366
2529
|
*
|
2530
|
+
* @constructor
|
2367
2531
|
* @param {HTMLElement} element The element that will be upgraded.
|
2368
2532
|
*/
|
2369
2533
|
var MaterialTabs = function MaterialTabs(element) {
|
@@ -2372,11 +2536,11 @@ var MaterialTabs = function MaterialTabs(element) {
|
|
2372
2536
|
// Initialize instance.
|
2373
2537
|
this.init();
|
2374
2538
|
};
|
2375
|
-
window
|
2539
|
+
window['MaterialTabs'] = MaterialTabs;
|
2376
2540
|
/**
|
2377
2541
|
* Store constants in one place so they can be updated easily.
|
2378
2542
|
*
|
2379
|
-
* @enum {
|
2543
|
+
* @enum {string}
|
2380
2544
|
* @private
|
2381
2545
|
*/
|
2382
2546
|
MaterialTabs.prototype.Constant_ = {};
|
@@ -2385,7 +2549,7 @@ MaterialTabs.prototype.Constant_ = {};
|
|
2385
2549
|
* JavaScript. This allows us to simply change it in one place should we
|
2386
2550
|
* decide to modify at a later date.
|
2387
2551
|
*
|
2388
|
-
* @enum {
|
2552
|
+
* @enum {string}
|
2389
2553
|
* @private
|
2390
2554
|
*/
|
2391
2555
|
MaterialTabs.prototype.CssClasses_ = {
|
@@ -2444,6 +2608,13 @@ MaterialTabs.prototype.init = function () {
|
|
2444
2608
|
this.initTabs_();
|
2445
2609
|
}
|
2446
2610
|
};
|
2611
|
+
/**
|
2612
|
+
* Constructor for an individual tab.
|
2613
|
+
*
|
2614
|
+
* @constructor
|
2615
|
+
* @param {HTMLElement} tab The HTML element for the tab.
|
2616
|
+
* @param {MaterialTabs} ctx The MaterialTabs object that owns the tab.
|
2617
|
+
*/
|
2447
2618
|
function MaterialTab(tab, ctx) {
|
2448
2619
|
if (tab) {
|
2449
2620
|
if (ctx.element_.classList.contains(ctx.CssClasses_.MDL_JS_RIPPLE_EFFECT)) {
|
@@ -2494,6 +2665,7 @@ componentHandler.register({
|
|
2494
2665
|
* Implements MDL component design pattern defined at:
|
2495
2666
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
2496
2667
|
*
|
2668
|
+
* @constructor
|
2497
2669
|
* @param {HTMLElement} element The element that will be upgraded.
|
2498
2670
|
*/
|
2499
2671
|
var MaterialTextfield = function MaterialTextfield(element) {
|
@@ -2502,11 +2674,11 @@ var MaterialTextfield = function MaterialTextfield(element) {
|
|
2502
2674
|
// Initialize instance.
|
2503
2675
|
this.init();
|
2504
2676
|
};
|
2505
|
-
window
|
2677
|
+
window['MaterialTextfield'] = MaterialTextfield;
|
2506
2678
|
/**
|
2507
2679
|
* Store constants in one place so they can be updated easily.
|
2508
2680
|
*
|
2509
|
-
* @enum {
|
2681
|
+
* @enum {string | number}
|
2510
2682
|
* @private
|
2511
2683
|
*/
|
2512
2684
|
MaterialTextfield.prototype.Constant_ = {
|
@@ -2518,7 +2690,7 @@ MaterialTextfield.prototype.Constant_ = {
|
|
2518
2690
|
* JavaScript. This allows us to simply change it in one place should we
|
2519
2691
|
* decide to modify at a later date.
|
2520
2692
|
*
|
2521
|
-
* @enum {
|
2693
|
+
* @enum {string}
|
2522
2694
|
* @private
|
2523
2695
|
*/
|
2524
2696
|
MaterialTextfield.prototype.CssClasses_ = {
|
@@ -2585,6 +2757,7 @@ MaterialTextfield.prototype.checkDisabled = function () {
|
|
2585
2757
|
this.element_.classList.remove(this.CssClasses_.IS_DISABLED);
|
2586
2758
|
}
|
2587
2759
|
};
|
2760
|
+
MaterialTextfield.prototype['checkDisabled'] = MaterialTextfield.prototype.checkDisabled;
|
2588
2761
|
/**
|
2589
2762
|
* Check the validity state and update field accordingly.
|
2590
2763
|
*
|
@@ -2597,6 +2770,7 @@ MaterialTextfield.prototype.checkValidity = function () {
|
|
2597
2770
|
this.element_.classList.add(this.CssClasses_.IS_INVALID);
|
2598
2771
|
}
|
2599
2772
|
};
|
2773
|
+
MaterialTextfield.prototype['checkValidity'] = MaterialTextfield.prototype.checkValidity;
|
2600
2774
|
/**
|
2601
2775
|
* Check the dirty state and update field accordingly.
|
2602
2776
|
*
|
@@ -2609,6 +2783,7 @@ MaterialTextfield.prototype.checkDirty = function () {
|
|
2609
2783
|
this.element_.classList.remove(this.CssClasses_.IS_DIRTY);
|
2610
2784
|
}
|
2611
2785
|
};
|
2786
|
+
MaterialTextfield.prototype['checkDirty'] = MaterialTextfield.prototype.checkDirty;
|
2612
2787
|
/**
|
2613
2788
|
* Disable text field.
|
2614
2789
|
*
|
@@ -2618,6 +2793,7 @@ MaterialTextfield.prototype.disable = function () {
|
|
2618
2793
|
this.input_.disabled = true;
|
2619
2794
|
this.updateClasses_();
|
2620
2795
|
};
|
2796
|
+
MaterialTextfield.prototype['disable'] = MaterialTextfield.prototype.disable;
|
2621
2797
|
/**
|
2622
2798
|
* Enable text field.
|
2623
2799
|
*
|
@@ -2627,18 +2803,22 @@ MaterialTextfield.prototype.enable = function () {
|
|
2627
2803
|
this.input_.disabled = false;
|
2628
2804
|
this.updateClasses_();
|
2629
2805
|
};
|
2806
|
+
MaterialTextfield.prototype['enable'] = MaterialTextfield.prototype.enable;
|
2630
2807
|
/**
|
2631
2808
|
* Update text field value.
|
2632
2809
|
*
|
2633
|
-
* @param {
|
2810
|
+
* @param {string} value The value to which to set the control (optional).
|
2634
2811
|
* @public
|
2635
2812
|
*/
|
2636
2813
|
MaterialTextfield.prototype.change = function (value) {
|
2637
2814
|
if (value) {
|
2638
2815
|
this.input_.value = value;
|
2816
|
+
} else {
|
2817
|
+
this.input_.value = '';
|
2639
2818
|
}
|
2640
2819
|
this.updateClasses_();
|
2641
2820
|
};
|
2821
|
+
MaterialTextfield.prototype['change'] = MaterialTextfield.prototype.change;
|
2642
2822
|
/**
|
2643
2823
|
* Initialize element.
|
2644
2824
|
*/
|
@@ -2712,6 +2892,7 @@ componentHandler.register({
|
|
2712
2892
|
* Implements MDL component design pattern defined at:
|
2713
2893
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
2714
2894
|
*
|
2895
|
+
* @constructor
|
2715
2896
|
* @param {HTMLElement} element The element that will be upgraded.
|
2716
2897
|
*/
|
2717
2898
|
var MaterialTooltip = function MaterialTooltip(element) {
|
@@ -2719,11 +2900,11 @@ var MaterialTooltip = function MaterialTooltip(element) {
|
|
2719
2900
|
// Initialize instance.
|
2720
2901
|
this.init();
|
2721
2902
|
};
|
2722
|
-
window
|
2903
|
+
window['MaterialTooltip'] = MaterialTooltip;
|
2723
2904
|
/**
|
2724
2905
|
* Store constants in one place so they can be updated easily.
|
2725
2906
|
*
|
2726
|
-
* @enum {
|
2907
|
+
* @enum {string | number}
|
2727
2908
|
* @private
|
2728
2909
|
*/
|
2729
2910
|
MaterialTooltip.prototype.Constant_ = {};
|
@@ -2732,7 +2913,7 @@ MaterialTooltip.prototype.Constant_ = {};
|
|
2732
2913
|
* JavaScript. This allows us to simply change it in one place should we
|
2733
2914
|
* decide to modify at a later date.
|
2734
2915
|
*
|
2735
|
-
* @enum {
|
2916
|
+
* @enum {string}
|
2736
2917
|
* @private
|
2737
2918
|
*/
|
2738
2919
|
MaterialTooltip.prototype.CssClasses_ = { IS_ACTIVE: 'is-active' };
|
@@ -2836,6 +3017,7 @@ componentHandler.register({
|
|
2836
3017
|
* Implements MDL component design pattern defined at:
|
2837
3018
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
2838
3019
|
*
|
3020
|
+
* @constructor
|
2839
3021
|
* @param {HTMLElement} element The element that will be upgraded.
|
2840
3022
|
*/
|
2841
3023
|
var MaterialLayout = function MaterialLayout(element) {
|
@@ -2843,11 +3025,11 @@ var MaterialLayout = function MaterialLayout(element) {
|
|
2843
3025
|
// Initialize instance.
|
2844
3026
|
this.init();
|
2845
3027
|
};
|
2846
|
-
window
|
3028
|
+
window['MaterialLayout'] = MaterialLayout;
|
2847
3029
|
/**
|
2848
3030
|
* Store constants in one place so they can be updated easily.
|
2849
3031
|
*
|
2850
|
-
* @enum {
|
3032
|
+
* @enum {string | number}
|
2851
3033
|
* @private
|
2852
3034
|
*/
|
2853
3035
|
MaterialLayout.prototype.Constant_ = {
|
@@ -2860,7 +3042,7 @@ MaterialLayout.prototype.Constant_ = {
|
|
2860
3042
|
/**
|
2861
3043
|
* Modes.
|
2862
3044
|
*
|
2863
|
-
* @enum {
|
3045
|
+
* @enum {number}
|
2864
3046
|
* @private
|
2865
3047
|
*/
|
2866
3048
|
MaterialLayout.prototype.Mode_ = {
|
@@ -2874,7 +3056,7 @@ MaterialLayout.prototype.Mode_ = {
|
|
2874
3056
|
* JavaScript. This allows us to simply change it in one place should we
|
2875
3057
|
* decide to modify at a later date.
|
2876
3058
|
*
|
2877
|
-
* @enum {
|
3059
|
+
* @enum {string}
|
2878
3060
|
* @private
|
2879
3061
|
*/
|
2880
3062
|
MaterialLayout.prototype.CssClasses_ = {
|
@@ -3056,13 +3238,24 @@ MaterialLayout.prototype.init = function () {
|
|
3056
3238
|
this.contentScrollHandler_();
|
3057
3239
|
}
|
3058
3240
|
}
|
3241
|
+
/**
|
3242
|
+
* Prevents an event from triggering the default behaviour.
|
3243
|
+
* @param {Event} ev the event to eat.
|
3244
|
+
*/
|
3059
3245
|
var eatEvent = function (ev) {
|
3060
3246
|
ev.preventDefault();
|
3061
3247
|
};
|
3062
3248
|
// Add drawer toggling button to our layout, if we have an openable drawer.
|
3063
3249
|
if (this.drawer_) {
|
3064
|
-
var drawerButton =
|
3065
|
-
drawerButton
|
3250
|
+
var drawerButton = this.element_.querySelector('.' + this.CssClasses_.DRAWER_BTN);
|
3251
|
+
if (typeof drawerButton === 'undefined' || drawerButton === null) {
|
3252
|
+
drawerButton = document.createElement('div');
|
3253
|
+
drawerButton.classList.add(this.CssClasses_.DRAWER_BTN);
|
3254
|
+
var drawerButtonIcon = document.createElement('i');
|
3255
|
+
drawerButtonIcon.classList.add(this.CssClasses_.ICON);
|
3256
|
+
drawerButtonIcon.textContent = this.Constant_.MENU_ICON;
|
3257
|
+
drawerButton.appendChild(drawerButtonIcon);
|
3258
|
+
}
|
3066
3259
|
if (this.drawer_.classList.contains(this.CssClasses_.ON_LARGE_SCREEN)) {
|
3067
3260
|
//If drawer has ON_LARGE_SCREEN class then add it to the drawer toggle button as well.
|
3068
3261
|
drawerButton.classList.add(this.CssClasses_.ON_LARGE_SCREEN);
|
@@ -3070,10 +3263,6 @@ MaterialLayout.prototype.init = function () {
|
|
3070
3263
|
//If drawer has ON_SMALL_SCREEN class then add it to the drawer toggle button as well.
|
3071
3264
|
drawerButton.classList.add(this.CssClasses_.ON_SMALL_SCREEN);
|
3072
3265
|
}
|
3073
|
-
var drawerButtonIcon = document.createElement('i');
|
3074
|
-
drawerButtonIcon.classList.add(this.CssClasses_.ICON);
|
3075
|
-
drawerButtonIcon.textContent = this.Constant_.MENU_ICON;
|
3076
|
-
drawerButton.appendChild(drawerButtonIcon);
|
3077
3266
|
drawerButton.addEventListener('click', this.drawerToggleHandler_.bind(this));
|
3078
3267
|
// Add a class if the layout has a drawer, for altering the left padding.
|
3079
3268
|
// Adds the HAS_DRAWER to the elements since this.header_ may or may
|
@@ -3152,6 +3341,15 @@ MaterialLayout.prototype.init = function () {
|
|
3152
3341
|
this.element_.classList.add(this.CssClasses_.IS_UPGRADED);
|
3153
3342
|
}
|
3154
3343
|
};
|
3344
|
+
/**
|
3345
|
+
* Constructor for an individual tab.
|
3346
|
+
*
|
3347
|
+
* @constructor
|
3348
|
+
* @param {HTMLElement} tab The HTML element for the tab.
|
3349
|
+
* @param {!Array<HTMLElement>} tabs Array with HTML elements for all tabs.
|
3350
|
+
* @param {!Array<HTMLElement>} panels Array with HTML elements for all panels.
|
3351
|
+
* @param {MaterialLayout} layout The MaterialLayout object that owns the tab.
|
3352
|
+
*/
|
3155
3353
|
function MaterialLayoutTab(tab, tabs, panels, layout) {
|
3156
3354
|
if (tab) {
|
3157
3355
|
if (layout.tabBar_.classList.contains(layout.CssClasses_.JS_RIPPLE_EFFECT)) {
|
@@ -3202,6 +3400,7 @@ componentHandler.register({
|
|
3202
3400
|
* Implements MDL component design pattern defined at:
|
3203
3401
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
3204
3402
|
*
|
3403
|
+
* @constructor
|
3205
3404
|
* @param {HTMLElement} element The element that will be upgraded.
|
3206
3405
|
*/
|
3207
3406
|
var MaterialDataTable = function MaterialDataTable(element) {
|
@@ -3209,11 +3408,11 @@ var MaterialDataTable = function MaterialDataTable(element) {
|
|
3209
3408
|
// Initialize instance.
|
3210
3409
|
this.init();
|
3211
3410
|
};
|
3212
|
-
window
|
3411
|
+
window['MaterialDataTable'] = MaterialDataTable;
|
3213
3412
|
/**
|
3214
3413
|
* Store constants in one place so they can be updated easily.
|
3215
3414
|
*
|
3216
|
-
* @enum {
|
3415
|
+
* @enum {string | number}
|
3217
3416
|
* @private
|
3218
3417
|
*/
|
3219
3418
|
MaterialDataTable.prototype.Constant_ = {};
|
@@ -3222,7 +3421,7 @@ MaterialDataTable.prototype.Constant_ = {};
|
|
3222
3421
|
* JavaScript. This allows us to simply change it in one place should we
|
3223
3422
|
* decide to modify at a later date.
|
3224
3423
|
*
|
3225
|
-
* @enum {
|
3424
|
+
* @enum {string}
|
3226
3425
|
* @private
|
3227
3426
|
*/
|
3228
3427
|
MaterialDataTable.prototype.CssClasses_ = {
|
@@ -3235,12 +3434,12 @@ MaterialDataTable.prototype.CssClasses_ = {
|
|
3235
3434
|
* Generates and returns a function that toggles the selection state of a
|
3236
3435
|
* single row (or multiple rows).
|
3237
3436
|
*
|
3238
|
-
* @param {
|
3437
|
+
* @param {Element} checkbox Checkbox that toggles the selection state.
|
3239
3438
|
* @param {HTMLElement} row Row to toggle when checkbox changes.
|
3240
|
-
* @param {
|
3439
|
+
* @param {(Array<Object>|NodeList)=} opt_rows Rows to toggle when checkbox changes.
|
3241
3440
|
* @private
|
3242
3441
|
*/
|
3243
|
-
MaterialDataTable.prototype.selectRow_ = function (checkbox, row,
|
3442
|
+
MaterialDataTable.prototype.selectRow_ = function (checkbox, row, opt_rows) {
|
3244
3443
|
if (row) {
|
3245
3444
|
return function () {
|
3246
3445
|
if (checkbox.checked) {
|
@@ -3250,21 +3449,21 @@ MaterialDataTable.prototype.selectRow_ = function (checkbox, row, rows) {
|
|
3250
3449
|
}
|
3251
3450
|
}.bind(this);
|
3252
3451
|
}
|
3253
|
-
if (
|
3452
|
+
if (opt_rows) {
|
3254
3453
|
return function () {
|
3255
3454
|
var i;
|
3256
3455
|
var el;
|
3257
3456
|
if (checkbox.checked) {
|
3258
|
-
for (i = 0; i <
|
3259
|
-
el =
|
3260
|
-
el
|
3261
|
-
|
3457
|
+
for (i = 0; i < opt_rows.length; i++) {
|
3458
|
+
el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox');
|
3459
|
+
el['MaterialCheckbox'].check();
|
3460
|
+
opt_rows[i].classList.add(this.CssClasses_.IS_SELECTED);
|
3262
3461
|
}
|
3263
3462
|
} else {
|
3264
|
-
for (i = 0; i <
|
3265
|
-
el =
|
3266
|
-
el
|
3267
|
-
|
3463
|
+
for (i = 0; i < opt_rows.length; i++) {
|
3464
|
+
el = opt_rows[i].querySelector('td').querySelector('.mdl-checkbox');
|
3465
|
+
el['MaterialCheckbox'].uncheck();
|
3466
|
+
opt_rows[i].classList.remove(this.CssClasses_.IS_SELECTED);
|
3268
3467
|
}
|
3269
3468
|
}
|
3270
3469
|
}.bind(this);
|
@@ -3275,10 +3474,10 @@ MaterialDataTable.prototype.selectRow_ = function (checkbox, row, rows) {
|
|
3275
3474
|
* event handling.
|
3276
3475
|
*
|
3277
3476
|
* @param {HTMLElement} row Row to toggle when checkbox changes.
|
3278
|
-
* @param {
|
3477
|
+
* @param {(Array<Object>|NodeList)=} opt_rows Rows to toggle when checkbox changes.
|
3279
3478
|
* @private
|
3280
3479
|
*/
|
3281
|
-
MaterialDataTable.prototype.createCheckbox_ = function (row,
|
3480
|
+
MaterialDataTable.prototype.createCheckbox_ = function (row, opt_rows) {
|
3282
3481
|
var label = document.createElement('label');
|
3283
3482
|
label.classList.add('mdl-checkbox');
|
3284
3483
|
label.classList.add('mdl-js-checkbox');
|
@@ -3289,8 +3488,8 @@ MaterialDataTable.prototype.createCheckbox_ = function (row, rows) {
|
|
3289
3488
|
checkbox.classList.add('mdl-checkbox__input');
|
3290
3489
|
if (row) {
|
3291
3490
|
checkbox.addEventListener('change', this.selectRow_(checkbox, row));
|
3292
|
-
} else if (
|
3293
|
-
checkbox.addEventListener('change', this.selectRow_(checkbox, null,
|
3491
|
+
} else if (opt_rows) {
|
3492
|
+
checkbox.addEventListener('change', this.selectRow_(checkbox, null, opt_rows));
|
3294
3493
|
}
|
3295
3494
|
label.appendChild(checkbox);
|
3296
3495
|
componentHandler.upgradeElement(label, 'MaterialCheckbox');
|
@@ -3349,6 +3548,7 @@ componentHandler.register({
|
|
3349
3548
|
* Implements MDL component design pattern defined at:
|
3350
3549
|
* https://github.com/jasonmayes/mdl-component-design-pattern
|
3351
3550
|
*
|
3551
|
+
* @constructor
|
3352
3552
|
* @param {HTMLElement} element The element that will be upgraded.
|
3353
3553
|
*/
|
3354
3554
|
var MaterialRipple = function MaterialRipple(element) {
|
@@ -3356,11 +3556,11 @@ var MaterialRipple = function MaterialRipple(element) {
|
|
3356
3556
|
// Initialize instance.
|
3357
3557
|
this.init();
|
3358
3558
|
};
|
3359
|
-
window
|
3559
|
+
window['MaterialRipple'] = MaterialRipple;
|
3360
3560
|
/**
|
3361
3561
|
* Store constants in one place so they can be updated easily.
|
3362
3562
|
*
|
3363
|
-
* @enum {
|
3563
|
+
* @enum {string | number}
|
3364
3564
|
* @private
|
3365
3565
|
*/
|
3366
3566
|
MaterialRipple.prototype.Constant_ = {
|
@@ -3375,7 +3575,7 @@ MaterialRipple.prototype.Constant_ = {
|
|
3375
3575
|
* JavaScript. This allows us to simply change it in one place should we
|
3376
3576
|
* decide to modify at a later date.
|
3377
3577
|
*
|
3378
|
-
* @enum {
|
3578
|
+
* @enum {string}
|
3379
3579
|
* @private
|
3380
3580
|
*/
|
3381
3581
|
MaterialRipple.prototype.CssClasses_ = {
|
@@ -3472,19 +3672,40 @@ MaterialRipple.prototype.init = function () {
|
|
3472
3672
|
this.element_.addEventListener('mouseleave', this.boundUpHandler);
|
3473
3673
|
this.element_.addEventListener('touchend', this.boundUpHandler);
|
3474
3674
|
this.element_.addEventListener('blur', this.boundUpHandler);
|
3675
|
+
/**
|
3676
|
+
* Getter for frameCount_.
|
3677
|
+
* @return {number} the frame count.
|
3678
|
+
*/
|
3475
3679
|
this.getFrameCount = function () {
|
3476
3680
|
return this.frameCount_;
|
3477
3681
|
};
|
3682
|
+
/**
|
3683
|
+
* Setter for frameCount_.
|
3684
|
+
* @param {number} fC the frame count.
|
3685
|
+
*/
|
3478
3686
|
this.setFrameCount = function (fC) {
|
3479
3687
|
this.frameCount_ = fC;
|
3480
3688
|
};
|
3689
|
+
/**
|
3690
|
+
* Getter for rippleElement_.
|
3691
|
+
* @return {Element} the ripple element.
|
3692
|
+
*/
|
3481
3693
|
this.getRippleElement = function () {
|
3482
3694
|
return this.rippleElement_;
|
3483
3695
|
};
|
3696
|
+
/**
|
3697
|
+
* Sets the ripple X and Y coordinates.
|
3698
|
+
* @param {number} newX the new X coordinate
|
3699
|
+
* @param {number} newY the new Y coordinate
|
3700
|
+
*/
|
3484
3701
|
this.setRippleXY = function (newX, newY) {
|
3485
3702
|
this.x_ = newX;
|
3486
3703
|
this.y_ = newY;
|
3487
3704
|
};
|
3705
|
+
/**
|
3706
|
+
* Sets the ripple styles.
|
3707
|
+
* @param {boolean} start whether or not this is the start frame.
|
3708
|
+
*/
|
3488
3709
|
this.setRippleStyles = function (start) {
|
3489
3710
|
if (this.rippleElement_ !== null) {
|
3490
3711
|
var transformString;
|
@@ -3512,6 +3733,9 @@ MaterialRipple.prototype.init = function () {
|
|
3512
3733
|
}
|
3513
3734
|
}
|
3514
3735
|
};
|
3736
|
+
/**
|
3737
|
+
* Handles an animation frame.
|
3738
|
+
*/
|
3515
3739
|
this.animFrameHandler = function () {
|
3516
3740
|
if (this.frameCount_-- > 0) {
|
3517
3741
|
window.requestAnimationFrame(this.animFrameHandler.bind(this));
|