materialize-sass 0.95.3.4 → 0.96.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +1 -1
- data/app/assets/javascripts/materialize-sprockets.js +2 -1
- data/app/assets/javascripts/materialize.js +832 -522
- data/app/assets/javascripts/materialize/character_counter.js +59 -0
- data/app/assets/javascripts/materialize/dropdown.js +64 -61
- data/app/assets/javascripts/materialize/forms.js +14 -0
- data/app/assets/javascripts/materialize/global.js +13 -0
- data/app/assets/javascripts/materialize/init.js +5 -1
- data/app/assets/javascripts/materialize/leanModal.js +4 -5
- data/app/assets/javascripts/materialize/parallax.js +9 -12
- data/app/assets/javascripts/materialize/scrollFire.js +24 -24
- data/app/assets/javascripts/materialize/toasts.js +6 -2
- data/app/assets/stylesheets/materialize/components/_buttons.scss +16 -7
- data/app/assets/stylesheets/materialize/components/_cards.scss +9 -9
- data/app/assets/stylesheets/materialize/components/_collapsible.scss +19 -1
- data/app/assets/stylesheets/materialize/components/_color.scss +3 -2
- data/app/assets/stylesheets/materialize/components/_dropdown.scss +16 -10
- data/app/assets/stylesheets/materialize/components/_form.scss +93 -5
- data/app/assets/stylesheets/materialize/components/_global.scss +37 -6
- data/app/assets/stylesheets/materialize/components/_modal.scss +2 -2
- data/app/assets/stylesheets/materialize/components/_navbar.scss +5 -7
- data/app/assets/stylesheets/materialize/components/_normalize.scss +2 -2
- data/app/assets/stylesheets/materialize/components/_prefixer.scss +4 -4
- data/app/assets/stylesheets/materialize/components/_sideNav.scss +6 -0
- data/app/assets/stylesheets/materialize/components/_tabs.scss +1 -2
- data/app/assets/stylesheets/materialize/components/_typography.scss +2 -1
- data/app/assets/stylesheets/materialize/components/_variables.scss +1 -0
- data/lib/materialize-sass/version.rb +1 -1
- metadata +16 -7
- checksums.yaml +0 -7
@@ -0,0 +1,59 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
$.fn.characterCounter = function(){
|
4
|
+
return this.each(function(){
|
5
|
+
|
6
|
+
itHasLengthAttribute = $(this).attr('length') != undefined;
|
7
|
+
|
8
|
+
if(itHasLengthAttribute){
|
9
|
+
$(this).on('input', updateCounter);
|
10
|
+
$(this).on('focus', updateCounter);
|
11
|
+
$(this).on('blur', removeCounterElement);
|
12
|
+
|
13
|
+
addCounterElement($(this));
|
14
|
+
}
|
15
|
+
|
16
|
+
});
|
17
|
+
};
|
18
|
+
|
19
|
+
function updateCounter(){
|
20
|
+
var maxLength = +$(this).attr('length'),
|
21
|
+
actualLength = +$(this).val().length,
|
22
|
+
isValidLength = actualLength <= maxLength;
|
23
|
+
|
24
|
+
$(this).parent().find('span[class="character-counter"]')
|
25
|
+
.html( actualLength + '/' + maxLength);
|
26
|
+
|
27
|
+
addInputStyle(isValidLength, $(this));
|
28
|
+
}
|
29
|
+
|
30
|
+
function addCounterElement($input){
|
31
|
+
$counterElement = $('<span/>')
|
32
|
+
.addClass('character-counter')
|
33
|
+
.css('float','right')
|
34
|
+
.css('font-size','12px')
|
35
|
+
.css('height', 1);
|
36
|
+
|
37
|
+
$input.parent().append($counterElement);
|
38
|
+
}
|
39
|
+
|
40
|
+
function removeCounterElement(){
|
41
|
+
$(this).parent().find('span[class="character-counter"]').html('');
|
42
|
+
}
|
43
|
+
|
44
|
+
function addInputStyle(isValidLength, $input){
|
45
|
+
inputHasInvalidClass = $input.hasClass('invalid');
|
46
|
+
if (isValidLength && inputHasInvalidClass) {
|
47
|
+
$input.removeClass('invalid');
|
48
|
+
}
|
49
|
+
else if(!isValidLength && !inputHasInvalidClass){
|
50
|
+
$input.removeClass('valid');
|
51
|
+
$input.addClass('invalid');
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
$(document).ready(function(){
|
56
|
+
$('input, textarea').characterCounter();
|
57
|
+
});
|
58
|
+
|
59
|
+
}( jQuery ));
|
@@ -7,7 +7,7 @@
|
|
7
7
|
return this;
|
8
8
|
};
|
9
9
|
|
10
|
-
$.fn.dropdown = function (
|
10
|
+
$.fn.dropdown = function (option) {
|
11
11
|
var defaults = {
|
12
12
|
inDuration: 300,
|
13
13
|
outDuration: 225,
|
@@ -17,9 +17,9 @@
|
|
17
17
|
belowOrigin: false
|
18
18
|
}
|
19
19
|
|
20
|
-
options = $.extend(defaults, options);
|
21
20
|
this.each(function(){
|
22
21
|
var origin = $(this);
|
22
|
+
var options = $.extend({}, defaults, option);
|
23
23
|
|
24
24
|
// Dropdown menu
|
25
25
|
var activates = $("#"+ origin.attr('data-activates'));
|
@@ -41,13 +41,16 @@
|
|
41
41
|
|
42
42
|
updateOptions();
|
43
43
|
|
44
|
-
//
|
45
|
-
if (
|
46
|
-
|
47
|
-
$('body').append(activates);
|
44
|
+
// Attach dropdown to its activator
|
45
|
+
if (origin.hasClass('select-dropdown')) {
|
46
|
+
origin.after(activates)
|
48
47
|
}
|
48
|
+
else {
|
49
|
+
origin.append(activates);
|
50
|
+
}
|
51
|
+
|
52
|
+
|
49
53
|
|
50
|
-
var dropdownRealHeight = activates.height();
|
51
54
|
|
52
55
|
/*
|
53
56
|
Helper function to position and resize dropdown.
|
@@ -57,6 +60,7 @@
|
|
57
60
|
// Check html data attributes
|
58
61
|
updateOptions();
|
59
62
|
|
63
|
+
// Constrain width
|
60
64
|
if (options.constrain_width == true) {
|
61
65
|
activates.css('width', origin.outerWidth());
|
62
66
|
}
|
@@ -71,79 +75,63 @@
|
|
71
75
|
var width_difference = 0;
|
72
76
|
var gutter_spacing = options.gutter;
|
73
77
|
|
78
|
+
|
74
79
|
if (offsetLeft + activates.innerWidth() > $(window).width()) {
|
75
80
|
width_difference = origin.innerWidth() - activates.innerWidth();
|
76
81
|
gutter_spacing = gutter_spacing * -1;
|
77
82
|
}
|
78
|
-
|
83
|
+
// If fixed placement
|
84
|
+
if (Materialize.elementOrParentIsFixed(origin[0])) {
|
79
85
|
activates.css({
|
80
|
-
|
81
|
-
|
82
|
-
height: 0,
|
83
|
-
top: origin.offset().top - $(window).scrollTop() + offset,
|
84
|
-
left: origin.offset().left + width_difference + gutter_spacing
|
86
|
+
top: 0 + offset,
|
87
|
+
left: 0 + width_difference + gutter_spacing
|
85
88
|
});
|
86
89
|
}
|
90
|
+
// If relative placement
|
87
91
|
else {
|
92
|
+
|
88
93
|
activates.css({
|
89
|
-
|
90
|
-
top:
|
91
|
-
left:
|
92
|
-
height: 0
|
94
|
+
position: 'absolute',
|
95
|
+
top: 0 + offset,
|
96
|
+
left: 0 + width_difference + gutter_spacing
|
93
97
|
});
|
98
|
+
|
94
99
|
}
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
},
|
100
|
-
{duration: options.inDuration,
|
100
|
+
|
101
|
+
// Show dropdown
|
102
|
+
activates.stop(true, true).css('opacity', 0)
|
103
|
+
.slideDown({
|
101
104
|
queue: false,
|
105
|
+
duration: options.inDuration,
|
102
106
|
easing: 'easeOutCubic',
|
103
|
-
complete: function(){
|
104
|
-
|
107
|
+
complete: function() {
|
108
|
+
$(this).css('height', '');
|
105
109
|
}
|
106
|
-
})
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
var $checkElements = $element.add($element.parents());
|
111
|
-
var isFixed = false;
|
112
|
-
$checkElements.each(function(){
|
113
|
-
if ($(this).css("position") === "fixed") {
|
114
|
-
isFixed = true;
|
115
|
-
return false;
|
116
|
-
}
|
117
|
-
});
|
118
|
-
return isFixed;
|
110
|
+
})
|
111
|
+
.animate( {opacity: 1}, {queue: false, duration: options.inDuration, easing: 'easeOutSine'});
|
112
|
+
|
113
|
+
|
119
114
|
}
|
120
115
|
|
116
|
+
|
121
117
|
function hideDropdown() {
|
122
|
-
activates.
|
123
|
-
{
|
124
|
-
opacity: 0
|
125
|
-
},
|
126
|
-
{
|
127
|
-
duration: options.outDuration,
|
128
|
-
easing: 'easeOutQuad',
|
129
|
-
complete: function(){
|
130
|
-
activates.css({
|
131
|
-
display: 'none',
|
132
|
-
'overflow-y': ''
|
133
|
-
});
|
134
|
-
}
|
135
|
-
});
|
118
|
+
activates.fadeOut(options.outDuration);
|
136
119
|
}
|
137
120
|
|
121
|
+
activates.on('hover', function(e) {
|
122
|
+
e.stopPropagation();
|
123
|
+
});
|
124
|
+
|
138
125
|
// Hover
|
139
126
|
if (options.hover) {
|
127
|
+
origin.unbind('click.' + origin.attr('id'));
|
140
128
|
// Hover handler to show dropdown
|
141
|
-
origin.on('
|
129
|
+
origin.on('mouseenter', function(e){ // Mouse over
|
142
130
|
placeDropdown();
|
143
131
|
});
|
144
132
|
|
145
|
-
//
|
146
|
-
|
133
|
+
origin.on('mouseleave', function(e){ // Mouse out
|
134
|
+
activates.stop(true, true);
|
147
135
|
hideDropdown();
|
148
136
|
});
|
149
137
|
|
@@ -154,18 +142,33 @@
|
|
154
142
|
// Click handler to show dropdown
|
155
143
|
origin.unbind('click.' + origin.attr('id'));
|
156
144
|
origin.bind('click.'+origin.attr('id'), function(e){
|
157
|
-
|
158
|
-
|
145
|
+
// Handles case for select plugin
|
146
|
+
if (origin.hasClass('select-dropdown')) {
|
147
|
+
return false;
|
148
|
+
}
|
149
|
+
if ( origin[0] == e.currentTarget && ($(e.target).closest('.dropdown-content').length === 0) ) {
|
159
150
|
e.preventDefault(); // Prevents button click from moving window
|
160
151
|
placeDropdown();
|
161
|
-
|
152
|
+
open = true;
|
162
153
|
|
163
|
-
|
164
|
-
|
154
|
+
}
|
155
|
+
// If origin is clicked and menu is open, close menu
|
156
|
+
else {
|
157
|
+
if (open === true) {
|
165
158
|
hideDropdown();
|
166
159
|
$(document).unbind('click.' + activates.attr('id'));
|
160
|
+
open = false;
|
167
161
|
}
|
168
|
-
}
|
162
|
+
}
|
163
|
+
// If menu open, add click close handler to document
|
164
|
+
if (open === true) {
|
165
|
+
$(document).bind('click.'+ activates.attr('id'), function (e) {
|
166
|
+
if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length > 0) ) {
|
167
|
+
hideDropdown();
|
168
|
+
$(document).unbind('click.' + activates.attr('id'));
|
169
|
+
}
|
170
|
+
});
|
171
|
+
}
|
169
172
|
});
|
170
173
|
|
171
174
|
} // End else
|
@@ -37,6 +37,7 @@
|
|
37
37
|
$(document).on('reset', function(e) {
|
38
38
|
if ($(e.target).is('form')) {
|
39
39
|
$(this).find(input_selector).removeClass('valid').removeClass('invalid');
|
40
|
+
$(this).find(input_selector).siblings('label, i').removeClass('active');
|
40
41
|
|
41
42
|
// Reset select
|
42
43
|
$(this).find('select.initialized').each(function () {
|
@@ -227,9 +228,16 @@
|
|
227
228
|
$('ul#select-options-'+lastID).remove();
|
228
229
|
}
|
229
230
|
|
231
|
+
// If destroying the select, remove the selelct-id and reset it to it's uninitialized state.
|
232
|
+
if(callback === 'destroy') {
|
233
|
+
$select.data('select-id', null).removeClass('initialized');
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
230
237
|
var uniqueID = Materialize.guid();
|
231
238
|
$select.data('select-id', uniqueID);
|
232
239
|
var wrapper = $('<div class="select-wrapper"></div>');
|
240
|
+
wrapper.addClass($select.attr('class'));
|
233
241
|
var options = $('<ul id="select-options-' + uniqueID+'" class="dropdown-content select-dropdown"></ul>');
|
234
242
|
var selectOptions = $select.children('option');
|
235
243
|
if ($select.find('option:selected') !== undefined) {
|
@@ -279,6 +287,12 @@
|
|
279
287
|
if (!$select.is(':disabled')) {
|
280
288
|
$newSelect.dropdown({"hover": false});
|
281
289
|
}
|
290
|
+
|
291
|
+
// Copy tabindex
|
292
|
+
if ($select.attr('tabindex')) {
|
293
|
+
$($newSelect[0]).attr('tabindex', $select.attr('tabindex'));
|
294
|
+
}
|
295
|
+
|
282
296
|
$select.addClass('initialized');
|
283
297
|
|
284
298
|
$newSelect.on('focus', function(){
|
@@ -13,6 +13,19 @@ Materialize.guid = (function() {
|
|
13
13
|
};
|
14
14
|
})();
|
15
15
|
|
16
|
+
Materialize.elementOrParentIsFixed = function(element) {
|
17
|
+
var $element = $(element);
|
18
|
+
var $checkElements = $element.add($element.parents());
|
19
|
+
var isFixed = false;
|
20
|
+
$checkElements.each(function(){
|
21
|
+
if ($(this).css("position") === "fixed") {
|
22
|
+
isFixed = true;
|
23
|
+
return false;
|
24
|
+
}
|
25
|
+
});
|
26
|
+
return isFixed;
|
27
|
+
}
|
28
|
+
|
16
29
|
// Velocity has conflicts when loaded with jQuery, this will check for it
|
17
30
|
var Vel;
|
18
31
|
if ($) { Vel = $.Velocity } else { Vel = Velocity};
|
@@ -8,9 +8,13 @@
|
|
8
8
|
if (/^#[0-9A-F]{6}$/i.test(rgb)) { return rgb; }
|
9
9
|
|
10
10
|
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
11
|
+
|
12
|
+
if (rgb === null) { return "N/A"; }
|
13
|
+
|
11
14
|
function hex(x) {
|
12
15
|
return ("0" + parseInt(x).toString(16)).slice(-2);
|
13
16
|
}
|
17
|
+
|
14
18
|
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
15
19
|
}
|
16
20
|
|
@@ -19,7 +23,7 @@
|
|
19
23
|
var color = $(this).css('background-color'),
|
20
24
|
classes = $(this).attr('class');
|
21
25
|
$(this).html(rgb2hex(color) + " " + classes);
|
22
|
-
if (classes.indexOf("darken") >= 0) {
|
26
|
+
if (classes.indexOf("darken") >= 0 || $(this).hasClass('black')) {
|
23
27
|
$(this).css('color', 'rgba(255,255,255,.9');
|
24
28
|
}
|
25
29
|
});
|
@@ -7,8 +7,8 @@
|
|
7
7
|
|
8
8
|
var defaults = {
|
9
9
|
opacity: 0.5,
|
10
|
-
in_duration:
|
11
|
-
out_duration:
|
10
|
+
in_duration: 350,
|
11
|
+
out_duration: 250,
|
12
12
|
ready: undefined,
|
13
13
|
complete: undefined,
|
14
14
|
dismissible: true
|
@@ -45,7 +45,6 @@
|
|
45
45
|
|
46
46
|
// Define Bottom Sheet animation
|
47
47
|
if ($(modal).hasClass('bottom-sheet')) {
|
48
|
-
console.log("Bottom");
|
49
48
|
$(modal).velocity({bottom: "0", opacity: 1}, {
|
50
49
|
duration: options.in_duration,
|
51
50
|
queue: false,
|
@@ -80,7 +79,7 @@
|
|
80
79
|
$.fn.extend({
|
81
80
|
closeModal: function(options) {
|
82
81
|
var defaults = {
|
83
|
-
out_duration:
|
82
|
+
out_duration: 250,
|
84
83
|
complete: undefined
|
85
84
|
}
|
86
85
|
var options = $.extend(defaults, options);
|
@@ -130,7 +129,7 @@
|
|
130
129
|
return this.each(function() {
|
131
130
|
// Close Handlers
|
132
131
|
$(this).click(function(e) {
|
133
|
-
var modal_id = $(this).attr("href");
|
132
|
+
var modal_id = $(this).attr("href") || '#' + $(this).data('target');
|
134
133
|
$(modal_id).openModal(options);
|
135
134
|
e.preventDefault();
|
136
135
|
}); // done set on click
|
@@ -7,20 +7,16 @@
|
|
7
7
|
var $this = $(this);
|
8
8
|
$this.addClass('parallax');
|
9
9
|
|
10
|
-
$this.find('img').each(function () {
|
11
|
-
$(this).css('background-image', 'url(' + $(this).attr('src') + ')' );
|
12
|
-
$(this).attr('src', 'data:image/gif;base64,R0lGODlhAQABAIABAP///wAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
|
13
|
-
});
|
14
|
-
|
15
10
|
function updateParallax(initial) {
|
16
11
|
var container_height;
|
17
|
-
if (window_width <
|
12
|
+
if (window_width < 601) {
|
18
13
|
container_height = ($this.height() > 0) ? $this.height() : $this.children("img").height();
|
19
14
|
}
|
20
15
|
else {
|
21
16
|
container_height = ($this.height() > 0) ? $this.height() : 500;
|
22
17
|
}
|
23
|
-
var
|
18
|
+
var $img = $this.children("img").first();
|
19
|
+
var img_height = $img.height();
|
24
20
|
var parallax_dist = img_height - container_height;
|
25
21
|
var bottom = $this.offset().top + container_height;
|
26
22
|
var top = $this.offset().top;
|
@@ -28,14 +24,15 @@
|
|
28
24
|
var windowHeight = window.innerHeight;
|
29
25
|
var windowBottom = scrollTop + windowHeight;
|
30
26
|
var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
|
31
|
-
var parallax =
|
27
|
+
var parallax = Math.round((parallax_dist * percentScrolled));
|
32
28
|
|
33
|
-
if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
|
34
|
-
$this.children("img").first().css('bottom', parallax + "px");
|
35
|
-
}
|
36
29
|
if (initial) {
|
37
|
-
$
|
30
|
+
$img.css('display', 'block');
|
38
31
|
}
|
32
|
+
if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
|
33
|
+
$img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
|
34
|
+
}
|
35
|
+
|
39
36
|
}
|
40
37
|
|
41
38
|
// Wait for image load
|
@@ -12,32 +12,32 @@
|
|
12
12
|
|
13
13
|
// Rate limit to 100ms
|
14
14
|
setInterval(function() {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
}
|
15
|
+
if(didScroll) {
|
16
|
+
didScroll = false;
|
17
|
+
|
18
|
+
var windowScroll = window.pageYOffset + window.innerHeight;
|
19
|
+
|
20
|
+
for (var i = 0 ; i < options.length; i++) {
|
21
|
+
// Get options from each line
|
22
|
+
var value = options[i];
|
23
|
+
var selector = value.selector,
|
24
|
+
offset = value.offset,
|
25
|
+
callback = value.callback;
|
26
|
+
|
27
|
+
var currentElement = document.querySelector(selector);
|
28
|
+
if ( currentElement !== null) {
|
29
|
+
var elementOffset = currentElement.getBoundingClientRect().top + document.body.scrollTop;
|
30
|
+
|
31
|
+
if (windowScroll > (elementOffset + offset)) {
|
32
|
+
if (value.done != true) {
|
33
|
+
var callbackFunc = new Function(callback);
|
34
|
+
callbackFunc();
|
35
|
+
value.done = true;
|
37
36
|
}
|
38
37
|
}
|
39
|
-
}
|
40
|
-
|
38
|
+
}
|
39
|
+
};
|
40
|
+
}
|
41
41
|
}, 100);
|
42
42
|
|
43
43
|
|