mtl 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/Gemfile +9 -0
- data/LICENSE.txt +22 -0
- data/README.md +104 -0
- data/Rakefile +6 -0
- data/app/assets/javascripts/mtl/clickables.coffee +25 -0
- data/app/assets/javascripts/mtl/collapsible.coffee +43 -0
- data/app/assets/javascripts/mtl/configuration.coffee.erb +1 -0
- data/app/assets/javascripts/mtl/document_modal.coffee +130 -0
- data/app/assets/javascripts/mtl/dropdown.coffee +24 -0
- data/app/assets/javascripts/mtl/hooks.coffee +14 -0
- data/app/assets/javascripts/mtl/icon.coffee.erb +17 -0
- data/app/assets/javascripts/mtl/modal.coffee +32 -0
- data/app/assets/javascripts/mtl/select.coffee +44 -0
- data/app/assets/javascripts/mtl/templates.coffee +4 -0
- data/app/assets/javascripts/mtl/toc.coffee +31 -0
- data/app/assets/javascripts/mtl.js +42 -0
- data/app/assets/stylesheets/mtl/all.scss +69 -0
- data/app/assets/stylesheets/mtl/extend/_avatars.scss +37 -0
- data/app/assets/stylesheets/mtl/extend/_buttons.scss +31 -0
- data/app/assets/stylesheets/mtl/extend/_cards.scss +21 -0
- data/app/assets/stylesheets/mtl/extend/_chips.scss +3 -0
- data/app/assets/stylesheets/mtl/extend/_collection-files.scss +108 -0
- data/app/assets/stylesheets/mtl/extend/_document-modals.scss +95 -0
- data/app/assets/stylesheets/mtl/extend/_dropdown.scss +12 -0
- data/app/assets/stylesheets/mtl/extend/_forms.scss +66 -0
- data/app/assets/stylesheets/mtl/extend/_global.scss +77 -0
- data/app/assets/stylesheets/mtl/extend/_grid.scss +25 -0
- data/app/assets/stylesheets/mtl/extend/_material-icons.scss +37 -0
- data/app/assets/stylesheets/mtl/extend/_mixins.scss +10 -0
- data/app/assets/stylesheets/mtl/extend/_roboto-rails.scss +49 -0
- data/app/assets/stylesheets/mtl/extend/_side-nav.scss +22 -0
- data/app/assets/stylesheets/mtl/extend/_toc.scss +12 -0
- data/app/assets/stylesheets/mtl/extend/_typography.scss +32 -0
- data/app/assets/stylesheets/mtl/extend/forms/_input-fields.scss +50 -0
- data/app/assets/stylesheets/mtl/layouts/_default.scss +220 -0
- data/app/assets/stylesheets/mtl/layouts/_single.scss +25 -0
- data/app/views/mtl/header.html.erb +25 -0
- data/bin/coffeelint.rb +16 -0
- data/lib/generators/mtl/install_generator.rb +20 -0
- data/lib/generators/mtl/templates/_color.scss +410 -0
- data/lib/generators/mtl/templates/_variables.scss +330 -0
- data/lib/generators/mtl/templates/mtl.scss +8 -0
- data/lib/generators/mtl/templates/simple_form.rb +211 -0
- data/lib/mtl/rails/card_file_presenter.rb +70 -0
- data/lib/mtl/rails/view_helpers.rb +412 -0
- data/lib/mtl/simple_form/suffix.rb +52 -0
- data/lib/mtl/version.rb +6 -0
- data/lib/mtl.rb +38 -0
- data/mtl.gemspec +35 -0
- data/package.json +11 -0
- data/spec/mtl/rails/card_file_presenter_spec.rb +126 -0
- data/spec/mtl/rails/view_helpers_spec.rb +193 -0
- data/spec/mtl/simple_form/suffix_spec.rb +39 -0
- data/spec/mtl_spec.rb +34 -0
- data/spec/spec_helper.rb +18 -0
- data/spec/support/dom.rb +15 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.eot +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ijmap +1 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.svg +2373 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.ttf +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff +0 -0
- data/vendor/assets/fonts/material-icons/MaterialIcons-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.eot +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/vendor/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/vendor/assets/javascripts/lodash.js +16607 -0
- data/vendor/assets/javascripts/materialize/animation.js +9 -0
- data/vendor/assets/javascripts/materialize/buttons.js +91 -0
- data/vendor/assets/javascripts/materialize/cards.js +26 -0
- data/vendor/assets/javascripts/materialize/carousel.js +454 -0
- data/vendor/assets/javascripts/materialize/character_counter.js +72 -0
- data/vendor/assets/javascripts/materialize/chips.js +267 -0
- data/vendor/assets/javascripts/materialize/collapsible.js +160 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.date.js +1430 -0
- data/vendor/assets/javascripts/materialize/date_picker/picker.js +1123 -0
- data/vendor/assets/javascripts/materialize/dropdown.js +265 -0
- data/vendor/assets/javascripts/materialize/forms.js +681 -0
- data/vendor/assets/javascripts/materialize/global.js +45 -0
- data/vendor/assets/javascripts/materialize/hammer.min.js +1 -0
- data/vendor/assets/javascripts/materialize/init.js +173 -0
- data/vendor/assets/javascripts/materialize/initial.js +11 -0
- data/vendor/assets/javascripts/materialize/jquery.easing.1.3.js +205 -0
- data/vendor/assets/javascripts/materialize/jquery.hammer.js +33 -0
- data/vendor/assets/javascripts/materialize/jquery.timeago.min.js +1 -0
- data/vendor/assets/javascripts/materialize/leanModal.js +192 -0
- data/vendor/assets/javascripts/materialize/materialbox.js +269 -0
- data/vendor/assets/javascripts/materialize/parallax.js +58 -0
- data/vendor/assets/javascripts/materialize/prism.js +8 -0
- data/vendor/assets/javascripts/materialize/pushpin.js +71 -0
- data/vendor/assets/javascripts/materialize/scrollFire.js +48 -0
- data/vendor/assets/javascripts/materialize/scrollspy.js +283 -0
- data/vendor/assets/javascripts/materialize/sideNav.js +352 -0
- data/vendor/assets/javascripts/materialize/slider.js +321 -0
- data/vendor/assets/javascripts/materialize/tabs.js +148 -0
- data/vendor/assets/javascripts/materialize/toasts.js +136 -0
- data/vendor/assets/javascripts/materialize/tooltip.js +230 -0
- data/vendor/assets/javascripts/materialize/transitions.js +169 -0
- data/vendor/assets/javascripts/materialize/velocity.min.js +5 -0
- data/vendor/assets/javascripts/materialize/waves.js +338 -0
- data/vendor/assets/javascripts/pdfobject.js +254 -0
- data/vendor/assets/stylesheets/materialize/_buttons.scss +211 -0
- data/vendor/assets/stylesheets/materialize/_cards.scss +185 -0
- data/vendor/assets/stylesheets/materialize/_carousel.scss +85 -0
- data/vendor/assets/stylesheets/materialize/_chips.scss +74 -0
- data/vendor/assets/stylesheets/materialize/_collapsible.scss +90 -0
- data/vendor/assets/stylesheets/materialize/_color.scss +412 -0
- data/vendor/assets/stylesheets/materialize/_dropdown.scss +57 -0
- data/vendor/assets/stylesheets/materialize/_global.scss +781 -0
- data/vendor/assets/stylesheets/materialize/_grid.scss +147 -0
- data/vendor/assets/stylesheets/materialize/_icons-material-design.scss +5 -0
- data/vendor/assets/stylesheets/materialize/_materialbox.scss +42 -0
- data/vendor/assets/stylesheets/materialize/_mixins.scss +5 -0
- data/vendor/assets/stylesheets/materialize/_modal.scss +90 -0
- data/vendor/assets/stylesheets/materialize/_navbar.scss +182 -0
- data/vendor/assets/stylesheets/materialize/_normalize.scss +424 -0
- data/vendor/assets/stylesheets/materialize/_prefixer.scss +384 -0
- data/vendor/assets/stylesheets/materialize/_preloader.scss +334 -0
- data/vendor/assets/stylesheets/materialize/_roboto.scss +49 -0
- data/vendor/assets/stylesheets/materialize/_sideNav.scss +219 -0
- data/vendor/assets/stylesheets/materialize/_slider.scss +92 -0
- data/vendor/assets/stylesheets/materialize/_table_of_contents.scss +33 -0
- data/vendor/assets/stylesheets/materialize/_tabs.scss +56 -0
- data/vendor/assets/stylesheets/materialize/_toast.scss +65 -0
- data/vendor/assets/stylesheets/materialize/_tooltip.scss +32 -0
- data/vendor/assets/stylesheets/materialize/_typography.scss +61 -0
- data/vendor/assets/stylesheets/materialize/_variables.scss +313 -0
- data/vendor/assets/stylesheets/materialize/_waves.scss +177 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.date.scss +435 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.scss +201 -0
- data/vendor/assets/stylesheets/materialize/date_picker/_default.time.scss +125 -0
- data/vendor/assets/stylesheets/materialize/forms/_checkboxes.scss +220 -0
- data/vendor/assets/stylesheets/materialize/forms/_file-input.scss +38 -0
- data/vendor/assets/stylesheets/materialize/forms/_forms.scss +22 -0
- data/vendor/assets/stylesheets/materialize/forms/_input-fields.scss +273 -0
- data/vendor/assets/stylesheets/materialize/forms/_radio-buttons.scss +119 -0
- data/vendor/assets/stylesheets/materialize/forms/_range.scss +159 -0
- data/vendor/assets/stylesheets/materialize/forms/_select.scss +116 -0
- data/vendor/assets/stylesheets/materialize/forms/_switches.scss +78 -0
- metadata +309 -0
@@ -0,0 +1,265 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
// Add posibility to scroll to selected option
|
4
|
+
// usefull for select for example
|
5
|
+
$.fn.scrollTo = function(elem) {
|
6
|
+
$(this).scrollTop($(this).scrollTop() - $(this).offset().top + $(elem).offset().top);
|
7
|
+
return this;
|
8
|
+
};
|
9
|
+
|
10
|
+
$.fn.dropdown = function (options) {
|
11
|
+
var defaults = {
|
12
|
+
inDuration: 300,
|
13
|
+
outDuration: 225,
|
14
|
+
constrain_width: true, // Constrains width of dropdown to the activator
|
15
|
+
hover: false,
|
16
|
+
gutter: 0, // Spacing from edge
|
17
|
+
belowOrigin: false,
|
18
|
+
alignment: 'left',
|
19
|
+
stopPropagation: false
|
20
|
+
};
|
21
|
+
|
22
|
+
// Open dropdown.
|
23
|
+
if (options === "open") {
|
24
|
+
this.each(function() {
|
25
|
+
$(this).trigger('open');
|
26
|
+
});
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
|
30
|
+
// Close dropdown.
|
31
|
+
if (options === "close") {
|
32
|
+
this.each(function() {
|
33
|
+
$(this).trigger('close');
|
34
|
+
});
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
|
38
|
+
this.each(function(){
|
39
|
+
var origin = $(this);
|
40
|
+
var options = $.extend({}, defaults, options);
|
41
|
+
var isFocused = false;
|
42
|
+
|
43
|
+
// Dropdown menu
|
44
|
+
var activates = $("#"+ origin.attr('data-activates'));
|
45
|
+
|
46
|
+
function updateOptions() {
|
47
|
+
if (origin.data('induration') !== undefined)
|
48
|
+
options.inDuration = origin.data('induration');
|
49
|
+
if (origin.data('outduration') !== undefined)
|
50
|
+
options.outDuration = origin.data('outduration');
|
51
|
+
if (origin.data('constrainwidth') !== undefined)
|
52
|
+
options.constrain_width = origin.data('constrainwidth');
|
53
|
+
if (origin.data('hover') !== undefined)
|
54
|
+
options.hover = origin.data('hover');
|
55
|
+
if (origin.data('gutter') !== undefined)
|
56
|
+
options.gutter = origin.data('gutter');
|
57
|
+
if (origin.data('beloworigin') !== undefined)
|
58
|
+
options.belowOrigin = origin.data('beloworigin');
|
59
|
+
if (origin.data('alignment') !== undefined)
|
60
|
+
options.alignment = origin.data('alignment');
|
61
|
+
if (origin.data('stoppropagation') !== undefined)
|
62
|
+
options.stopPropagation = origin.data('stoppropagation');
|
63
|
+
}
|
64
|
+
|
65
|
+
updateOptions();
|
66
|
+
|
67
|
+
// Attach dropdown to its activator
|
68
|
+
origin.after(activates);
|
69
|
+
|
70
|
+
/*
|
71
|
+
Helper function to position and resize dropdown.
|
72
|
+
Used in hover and click handler.
|
73
|
+
*/
|
74
|
+
function placeDropdown(eventType) {
|
75
|
+
// Check for simultaneous focus and click events.
|
76
|
+
if (eventType === 'focus') {
|
77
|
+
isFocused = true;
|
78
|
+
}
|
79
|
+
|
80
|
+
// Check html data attributes
|
81
|
+
updateOptions();
|
82
|
+
|
83
|
+
// Set Dropdown state
|
84
|
+
activates.addClass('active');
|
85
|
+
origin.addClass('active');
|
86
|
+
|
87
|
+
// Constrain width
|
88
|
+
if (options.constrain_width === true) {
|
89
|
+
activates.css('width', origin.outerWidth());
|
90
|
+
|
91
|
+
} else {
|
92
|
+
activates.css('white-space', 'nowrap');
|
93
|
+
}
|
94
|
+
|
95
|
+
// Offscreen detection
|
96
|
+
var windowHeight = window.innerHeight;
|
97
|
+
var originHeight = origin.innerHeight();
|
98
|
+
var offsetLeft = origin.offset().left;
|
99
|
+
var offsetTop = origin.offset().top - $(window).scrollTop();
|
100
|
+
var currAlignment = options.alignment;
|
101
|
+
var gutterSpacing = 0;
|
102
|
+
var leftPosition = 0;
|
103
|
+
|
104
|
+
// Below Origin
|
105
|
+
var verticalOffset = 0;
|
106
|
+
if (options.belowOrigin === true) {
|
107
|
+
verticalOffset = originHeight;
|
108
|
+
}
|
109
|
+
|
110
|
+
// Check for scrolling positioned container.
|
111
|
+
var scrollYOffset = 0;
|
112
|
+
var scrollXOffset = 0;
|
113
|
+
var wrapper = origin.parent();
|
114
|
+
if (!wrapper.is('body')) {
|
115
|
+
if (wrapper[0].scrollHeight > wrapper[0].clientHeight) {
|
116
|
+
scrollYOffset = wrapper[0].scrollTop;
|
117
|
+
}
|
118
|
+
if (wrapper[0].scrollWidth > wrapper[0].clientWidth) {
|
119
|
+
scrollXOffset = wrapper[0].scrollLeft;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
if (offsetLeft + activates.innerWidth() > $(window).width()) {
|
125
|
+
// Dropdown goes past screen on right, force right alignment
|
126
|
+
currAlignment = 'right';
|
127
|
+
|
128
|
+
} else if (offsetLeft - activates.innerWidth() + origin.innerWidth() < 0) {
|
129
|
+
// Dropdown goes past screen on left, force left alignment
|
130
|
+
currAlignment = 'left';
|
131
|
+
}
|
132
|
+
// Vertical bottom offscreen detection
|
133
|
+
if (offsetTop + activates.innerHeight() > windowHeight) {
|
134
|
+
// If going upwards still goes offscreen, just crop height of dropdown.
|
135
|
+
if (offsetTop + originHeight - activates.innerHeight() < 0) {
|
136
|
+
var adjustedHeight = windowHeight - offsetTop - verticalOffset;
|
137
|
+
activates.css('max-height', adjustedHeight);
|
138
|
+
} else {
|
139
|
+
// Flow upwards.
|
140
|
+
if (!verticalOffset) {
|
141
|
+
verticalOffset += originHeight;
|
142
|
+
}
|
143
|
+
verticalOffset -= activates.innerHeight();
|
144
|
+
}
|
145
|
+
}
|
146
|
+
|
147
|
+
// Handle edge alignment
|
148
|
+
if (currAlignment === 'left') {
|
149
|
+
gutterSpacing = options.gutter;
|
150
|
+
leftPosition = origin.position().left + gutterSpacing;
|
151
|
+
}
|
152
|
+
else if (currAlignment === 'right') {
|
153
|
+
var offsetRight = origin.position().left + origin.outerWidth() - activates.outerWidth();
|
154
|
+
gutterSpacing = -options.gutter;
|
155
|
+
leftPosition = offsetRight + gutterSpacing;
|
156
|
+
}
|
157
|
+
|
158
|
+
// Position dropdown
|
159
|
+
activates.css({
|
160
|
+
position: 'absolute',
|
161
|
+
top: origin.position().top + verticalOffset + scrollYOffset,
|
162
|
+
left: leftPosition + scrollXOffset
|
163
|
+
});
|
164
|
+
|
165
|
+
|
166
|
+
// Show dropdown
|
167
|
+
activates.stop(true, true).css('opacity', 0)
|
168
|
+
.slideDown({
|
169
|
+
queue: false,
|
170
|
+
duration: options.inDuration,
|
171
|
+
easing: 'easeOutCubic',
|
172
|
+
complete: function() {
|
173
|
+
$(this).css('height', '');
|
174
|
+
}
|
175
|
+
})
|
176
|
+
.animate( {opacity: 1}, {queue: false, duration: options.inDuration, easing: 'easeOutSine'});
|
177
|
+
}
|
178
|
+
|
179
|
+
function hideDropdown() {
|
180
|
+
// Check for simultaneous focus and click events.
|
181
|
+
isFocused = false;
|
182
|
+
activates.fadeOut(options.outDuration);
|
183
|
+
activates.removeClass('active');
|
184
|
+
origin.removeClass('active');
|
185
|
+
setTimeout(function() { activates.css('max-height', ''); }, options.outDuration);
|
186
|
+
}
|
187
|
+
|
188
|
+
// Hover
|
189
|
+
if (options.hover) {
|
190
|
+
var open = false;
|
191
|
+
origin.unbind('click.' + origin.attr('id'));
|
192
|
+
// Hover handler to show dropdown
|
193
|
+
origin.on('mouseenter', function(e){ // Mouse over
|
194
|
+
if (open === false) {
|
195
|
+
placeDropdown();
|
196
|
+
open = true;
|
197
|
+
}
|
198
|
+
});
|
199
|
+
origin.on('mouseleave', function(e){
|
200
|
+
// If hover on origin then to something other than dropdown content, then close
|
201
|
+
var toEl = e.toElement || e.relatedTarget; // added browser compatibility for target element
|
202
|
+
if(!$(toEl).closest('.dropdown-content').is(activates)) {
|
203
|
+
activates.stop(true, true);
|
204
|
+
hideDropdown();
|
205
|
+
open = false;
|
206
|
+
}
|
207
|
+
});
|
208
|
+
|
209
|
+
activates.on('mouseleave', function(e){ // Mouse out
|
210
|
+
var toEl = e.toElement || e.relatedTarget;
|
211
|
+
if(!$(toEl).closest('.dropdown-button').is(origin)) {
|
212
|
+
activates.stop(true, true);
|
213
|
+
hideDropdown();
|
214
|
+
open = false;
|
215
|
+
}
|
216
|
+
});
|
217
|
+
|
218
|
+
// Click
|
219
|
+
} else {
|
220
|
+
// Click handler to show dropdown
|
221
|
+
origin.unbind('click.' + origin.attr('id'));
|
222
|
+
origin.bind('click.'+origin.attr('id'), function(e){
|
223
|
+
if (!isFocused) {
|
224
|
+
if ( origin[0] == e.currentTarget &&
|
225
|
+
!origin.hasClass('active') &&
|
226
|
+
($(e.target).closest('.dropdown-content').length === 0)) {
|
227
|
+
e.preventDefault(); // Prevents button click from moving window
|
228
|
+
if (options.stopPropagation) {
|
229
|
+
e.stopPropagation();
|
230
|
+
}
|
231
|
+
placeDropdown('click');
|
232
|
+
}
|
233
|
+
// If origin is clicked and menu is open, close menu
|
234
|
+
else if (origin.hasClass('active')) {
|
235
|
+
hideDropdown();
|
236
|
+
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
237
|
+
}
|
238
|
+
// If menu open, add click close handler to document
|
239
|
+
if (activates.hasClass('active')) {
|
240
|
+
$(document).bind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'), function (e) {
|
241
|
+
if (!activates.is(e.target) && !origin.is(e.target) && (!origin.find(e.target).length) ) {
|
242
|
+
hideDropdown();
|
243
|
+
$(document).unbind('click.'+ activates.attr('id') + ' touchstart.' + activates.attr('id'));
|
244
|
+
}
|
245
|
+
});
|
246
|
+
}
|
247
|
+
}
|
248
|
+
});
|
249
|
+
|
250
|
+
} // End else
|
251
|
+
|
252
|
+
// Listen to open and close event - useful for select component
|
253
|
+
origin.on('open', function(e, eventType) {
|
254
|
+
placeDropdown(eventType);
|
255
|
+
});
|
256
|
+
origin.on('close', hideDropdown);
|
257
|
+
|
258
|
+
|
259
|
+
});
|
260
|
+
}; // End dropdown plugin
|
261
|
+
|
262
|
+
$(document).ready(function(){
|
263
|
+
$('.dropdown-button').dropdown();
|
264
|
+
});
|
265
|
+
}( jQuery ));
|