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,192 @@
|
|
1
|
+
(function($) {
|
2
|
+
var _stack = 0,
|
3
|
+
_lastID = 0,
|
4
|
+
_generateID = function() {
|
5
|
+
_lastID++;
|
6
|
+
return 'materialize-lean-overlay-' + _lastID;
|
7
|
+
};
|
8
|
+
|
9
|
+
$.fn.extend({
|
10
|
+
openModal: function(options) {
|
11
|
+
|
12
|
+
var $body = $('body');
|
13
|
+
var oldWidth = $body.innerWidth();
|
14
|
+
$body.css('overflow', 'hidden');
|
15
|
+
$body.width(oldWidth);
|
16
|
+
|
17
|
+
var defaults = {
|
18
|
+
opacity: 0.5,
|
19
|
+
in_duration: 350,
|
20
|
+
out_duration: 250,
|
21
|
+
ready: undefined,
|
22
|
+
complete: undefined,
|
23
|
+
dismissible: true,
|
24
|
+
starting_top: '4%',
|
25
|
+
ending_top: '10%'
|
26
|
+
};
|
27
|
+
var $modal = $(this);
|
28
|
+
|
29
|
+
if ($modal.hasClass('open')) {
|
30
|
+
return;
|
31
|
+
}
|
32
|
+
|
33
|
+
var overlayID = _generateID();
|
34
|
+
var $overlay = $('<div class="lean-overlay"></div>');
|
35
|
+
lStack = (++_stack);
|
36
|
+
|
37
|
+
// Store a reference of the overlay
|
38
|
+
$overlay.attr('id', overlayID).css('z-index', 1000 + lStack * 2);
|
39
|
+
$modal.data('overlay-id', overlayID).css('z-index', 1000 + lStack * 2 + 1);
|
40
|
+
$modal.addClass('open');
|
41
|
+
|
42
|
+
$("body").append($overlay);
|
43
|
+
|
44
|
+
// Override defaults
|
45
|
+
options = $.extend(defaults, options);
|
46
|
+
|
47
|
+
if (options.dismissible) {
|
48
|
+
$overlay.click(function() {
|
49
|
+
$modal.closeModal(options);
|
50
|
+
});
|
51
|
+
// Return on ESC
|
52
|
+
$(document).on('keyup.leanModal' + overlayID, function(e) {
|
53
|
+
if (e.keyCode === 27) { // ESC key
|
54
|
+
$modal.closeModal(options);
|
55
|
+
}
|
56
|
+
});
|
57
|
+
}
|
58
|
+
|
59
|
+
$modal.find(".modal-close").on('click.close', function(e) {
|
60
|
+
$modal.closeModal(options);
|
61
|
+
});
|
62
|
+
|
63
|
+
$overlay.css({ display : "block", opacity : 0 });
|
64
|
+
|
65
|
+
$modal.css({
|
66
|
+
display : "block",
|
67
|
+
opacity: 0
|
68
|
+
});
|
69
|
+
|
70
|
+
$overlay.velocity({opacity: options.opacity}, {duration: options.in_duration, queue: false, ease: "easeOutCubic"});
|
71
|
+
$modal.data('associated-overlay', $overlay[0]);
|
72
|
+
|
73
|
+
// Define Bottom Sheet animation
|
74
|
+
if ($modal.hasClass('bottom-sheet')) {
|
75
|
+
$modal.velocity({bottom: "0", opacity: 1}, {
|
76
|
+
duration: options.in_duration,
|
77
|
+
queue: false,
|
78
|
+
ease: "easeOutCubic",
|
79
|
+
// Handle modal ready callback
|
80
|
+
complete: function() {
|
81
|
+
if (typeof(options.ready) === "function") {
|
82
|
+
options.ready();
|
83
|
+
}
|
84
|
+
}
|
85
|
+
});
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
$.Velocity.hook($modal, "scaleX", 0.7);
|
89
|
+
$modal.css({ top: options.starting_top });
|
90
|
+
$modal.velocity({top: options.ending_top, opacity: 1, scaleX: '1'}, {
|
91
|
+
duration: options.in_duration,
|
92
|
+
queue: false,
|
93
|
+
ease: "easeOutCubic",
|
94
|
+
// Handle modal ready callback
|
95
|
+
complete: function() {
|
96
|
+
if (typeof(options.ready) === "function") {
|
97
|
+
options.ready();
|
98
|
+
}
|
99
|
+
}
|
100
|
+
});
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
}
|
105
|
+
});
|
106
|
+
|
107
|
+
$.fn.extend({
|
108
|
+
closeModal: function(options) {
|
109
|
+
var defaults = {
|
110
|
+
out_duration: 250,
|
111
|
+
complete: undefined
|
112
|
+
};
|
113
|
+
var $modal = $(this);
|
114
|
+
var overlayID = $modal.data('overlay-id');
|
115
|
+
var $overlay = $('#' + overlayID);
|
116
|
+
$modal.removeClass('open');
|
117
|
+
|
118
|
+
options = $.extend(defaults, options);
|
119
|
+
|
120
|
+
// Enable scrolling
|
121
|
+
$('body').css({
|
122
|
+
overflow: '',
|
123
|
+
width: ''
|
124
|
+
});
|
125
|
+
|
126
|
+
$modal.find('.modal-close').off('click.close');
|
127
|
+
$(document).off('keyup.leanModal' + overlayID);
|
128
|
+
|
129
|
+
$overlay.velocity( { opacity: 0}, {duration: options.out_duration, queue: false, ease: "easeOutQuart"});
|
130
|
+
|
131
|
+
|
132
|
+
// Define Bottom Sheet animation
|
133
|
+
if ($modal.hasClass('bottom-sheet')) {
|
134
|
+
$modal.velocity({bottom: "-100%", opacity: 0}, {
|
135
|
+
duration: options.out_duration,
|
136
|
+
queue: false,
|
137
|
+
ease: "easeOutCubic",
|
138
|
+
// Handle modal ready callback
|
139
|
+
complete: function() {
|
140
|
+
$overlay.css({display:"none"});
|
141
|
+
|
142
|
+
// Call complete callback
|
143
|
+
if (typeof(options.complete) === "function") {
|
144
|
+
options.complete();
|
145
|
+
}
|
146
|
+
$overlay.remove();
|
147
|
+
_stack--;
|
148
|
+
}
|
149
|
+
});
|
150
|
+
}
|
151
|
+
else {
|
152
|
+
$modal.velocity(
|
153
|
+
{ top: options.starting_top, opacity: 0, scaleX: 0.7}, {
|
154
|
+
duration: options.out_duration,
|
155
|
+
complete:
|
156
|
+
function() {
|
157
|
+
|
158
|
+
$(this).css('display', 'none');
|
159
|
+
// Call complete callback
|
160
|
+
if (typeof(options.complete) === "function") {
|
161
|
+
options.complete();
|
162
|
+
}
|
163
|
+
$overlay.remove();
|
164
|
+
_stack--;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
});
|
171
|
+
|
172
|
+
$.fn.extend({
|
173
|
+
leanModal: function(option) {
|
174
|
+
return this.each(function() {
|
175
|
+
|
176
|
+
var defaults = {
|
177
|
+
starting_top: '4%'
|
178
|
+
},
|
179
|
+
// Override defaults
|
180
|
+
options = $.extend(defaults, option);
|
181
|
+
|
182
|
+
// Close Handlers
|
183
|
+
$(this).click(function(e) {
|
184
|
+
options.starting_top = ($(this).offset().top - $(window).scrollTop()) /1.15;
|
185
|
+
var modal_id = $(this).attr("href") || '#' + $(this).data('target');
|
186
|
+
$(modal_id).openModal(options);
|
187
|
+
e.preventDefault();
|
188
|
+
}); // done set on click
|
189
|
+
}); // done return
|
190
|
+
}
|
191
|
+
});
|
192
|
+
})(jQuery);
|
@@ -0,0 +1,269 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
$.fn.materialbox = function () {
|
4
|
+
|
5
|
+
return this.each(function() {
|
6
|
+
|
7
|
+
if ($(this).hasClass('initialized')) {
|
8
|
+
return;
|
9
|
+
}
|
10
|
+
|
11
|
+
$(this).addClass('initialized');
|
12
|
+
|
13
|
+
var overlayActive = false;
|
14
|
+
var doneAnimating = true;
|
15
|
+
var inDuration = 275;
|
16
|
+
var outDuration = 200;
|
17
|
+
var origin = $(this);
|
18
|
+
var placeholder = $('<div></div>').addClass('material-placeholder');
|
19
|
+
var originalWidth = 0;
|
20
|
+
var originalHeight = 0;
|
21
|
+
var ancestorsChanged;
|
22
|
+
var ancestor;
|
23
|
+
origin.wrap(placeholder);
|
24
|
+
|
25
|
+
|
26
|
+
origin.on('click', function(){
|
27
|
+
var placeholder = origin.parent('.material-placeholder');
|
28
|
+
var windowWidth = window.innerWidth;
|
29
|
+
var windowHeight = window.innerHeight;
|
30
|
+
var originalWidth = origin.width();
|
31
|
+
var originalHeight = origin.height();
|
32
|
+
|
33
|
+
|
34
|
+
// If already modal, return to original
|
35
|
+
if (doneAnimating === false) {
|
36
|
+
returnToOriginal();
|
37
|
+
return false;
|
38
|
+
}
|
39
|
+
else if (overlayActive && doneAnimating===true) {
|
40
|
+
returnToOriginal();
|
41
|
+
return false;
|
42
|
+
}
|
43
|
+
|
44
|
+
|
45
|
+
// Set states
|
46
|
+
doneAnimating = false;
|
47
|
+
origin.addClass('active');
|
48
|
+
overlayActive = true;
|
49
|
+
|
50
|
+
// Set positioning for placeholder
|
51
|
+
placeholder.css({
|
52
|
+
width: placeholder[0].getBoundingClientRect().width,
|
53
|
+
height: placeholder[0].getBoundingClientRect().height,
|
54
|
+
position: 'relative',
|
55
|
+
top: 0,
|
56
|
+
left: 0
|
57
|
+
});
|
58
|
+
|
59
|
+
// Find ancestor with overflow: hidden; and remove it
|
60
|
+
ancestorsChanged = undefined;
|
61
|
+
ancestor = placeholder[0].parentNode;
|
62
|
+
var count = 0;
|
63
|
+
while (ancestor !== null && !$(ancestor).is(document)) {
|
64
|
+
var curr = $(ancestor);
|
65
|
+
if (curr.css('overflow') !== 'visible') {
|
66
|
+
curr.css('overflow', 'visible');
|
67
|
+
if (ancestorsChanged === undefined) {
|
68
|
+
ancestorsChanged = curr;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
ancestorsChanged = ancestorsChanged.add(curr);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
ancestor = ancestor.parentNode;
|
75
|
+
}
|
76
|
+
|
77
|
+
// Set css on origin
|
78
|
+
origin.css({position: 'absolute', 'z-index': 1000})
|
79
|
+
.data('width', originalWidth)
|
80
|
+
.data('height', originalHeight);
|
81
|
+
|
82
|
+
// Add overlay
|
83
|
+
var overlay = $('<div id="materialbox-overlay"></div>')
|
84
|
+
.css({
|
85
|
+
opacity: 0
|
86
|
+
})
|
87
|
+
.click(function(){
|
88
|
+
if (doneAnimating === true)
|
89
|
+
returnToOriginal();
|
90
|
+
});
|
91
|
+
// Animate Overlay
|
92
|
+
// Put before in origin image to preserve z-index layering.
|
93
|
+
origin.before(overlay);
|
94
|
+
overlay.velocity({opacity: 1},
|
95
|
+
{duration: inDuration, queue: false, easing: 'easeOutQuad'} );
|
96
|
+
|
97
|
+
// Add and animate caption if it exists
|
98
|
+
if (origin.data('caption') !== "") {
|
99
|
+
var $photo_caption = $('<div class="materialbox-caption"></div>');
|
100
|
+
$photo_caption.text(origin.data('caption'));
|
101
|
+
$('body').append($photo_caption);
|
102
|
+
$photo_caption.css({ "display": "inline" });
|
103
|
+
$photo_caption.velocity({opacity: 1}, {duration: inDuration, queue: false, easing: 'easeOutQuad'});
|
104
|
+
}
|
105
|
+
|
106
|
+
// Resize Image
|
107
|
+
var ratio = 0;
|
108
|
+
var widthPercent = originalWidth / windowWidth;
|
109
|
+
var heightPercent = originalHeight / windowHeight;
|
110
|
+
var newWidth = 0;
|
111
|
+
var newHeight = 0;
|
112
|
+
|
113
|
+
if (widthPercent > heightPercent) {
|
114
|
+
ratio = originalHeight / originalWidth;
|
115
|
+
newWidth = windowWidth * 0.9;
|
116
|
+
newHeight = windowWidth * 0.9 * ratio;
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
ratio = originalWidth / originalHeight;
|
120
|
+
newWidth = (windowHeight * 0.9) * ratio;
|
121
|
+
newHeight = windowHeight * 0.9;
|
122
|
+
}
|
123
|
+
|
124
|
+
// Animate image + set z-index
|
125
|
+
if(origin.hasClass('responsive-img')) {
|
126
|
+
origin.velocity({'max-width': newWidth, 'width': originalWidth}, {duration: 0, queue: false,
|
127
|
+
complete: function(){
|
128
|
+
origin.css({left: 0, top: 0})
|
129
|
+
.velocity(
|
130
|
+
{
|
131
|
+
height: newHeight,
|
132
|
+
width: newWidth,
|
133
|
+
left: $(document).scrollLeft() + windowWidth/2 - origin.parent('.material-placeholder').offset().left - newWidth/2,
|
134
|
+
top: $(document).scrollTop() + windowHeight/2 - origin.parent('.material-placeholder').offset().top - newHeight/ 2
|
135
|
+
},
|
136
|
+
{
|
137
|
+
duration: inDuration,
|
138
|
+
queue: false,
|
139
|
+
easing: 'easeOutQuad',
|
140
|
+
complete: function(){doneAnimating = true;}
|
141
|
+
}
|
142
|
+
);
|
143
|
+
} // End Complete
|
144
|
+
}); // End Velocity
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
origin.css('left', 0)
|
148
|
+
.css('top', 0)
|
149
|
+
.velocity(
|
150
|
+
{
|
151
|
+
height: newHeight,
|
152
|
+
width: newWidth,
|
153
|
+
left: $(document).scrollLeft() + windowWidth/2 - origin.parent('.material-placeholder').offset().left - newWidth/2,
|
154
|
+
top: $(document).scrollTop() + windowHeight/2 - origin.parent('.material-placeholder').offset().top - newHeight/ 2
|
155
|
+
},
|
156
|
+
{
|
157
|
+
duration: inDuration,
|
158
|
+
queue: false,
|
159
|
+
easing: 'easeOutQuad',
|
160
|
+
complete: function(){doneAnimating = true;}
|
161
|
+
}
|
162
|
+
); // End Velocity
|
163
|
+
}
|
164
|
+
|
165
|
+
}); // End origin on click
|
166
|
+
|
167
|
+
|
168
|
+
// Return on scroll
|
169
|
+
$(window).scroll(function() {
|
170
|
+
if (overlayActive) {
|
171
|
+
returnToOriginal();
|
172
|
+
}
|
173
|
+
});
|
174
|
+
|
175
|
+
// Return on ESC
|
176
|
+
$(document).keyup(function(e) {
|
177
|
+
|
178
|
+
if (e.keyCode === 27 && doneAnimating === true) { // ESC key
|
179
|
+
if (overlayActive) {
|
180
|
+
returnToOriginal();
|
181
|
+
}
|
182
|
+
}
|
183
|
+
});
|
184
|
+
|
185
|
+
|
186
|
+
// This function returns the modaled image to the original spot
|
187
|
+
function returnToOriginal() {
|
188
|
+
|
189
|
+
doneAnimating = false;
|
190
|
+
|
191
|
+
var placeholder = origin.parent('.material-placeholder');
|
192
|
+
var windowWidth = window.innerWidth;
|
193
|
+
var windowHeight = window.innerHeight;
|
194
|
+
var originalWidth = origin.data('width');
|
195
|
+
var originalHeight = origin.data('height');
|
196
|
+
|
197
|
+
origin.velocity("stop", true);
|
198
|
+
$('#materialbox-overlay').velocity("stop", true);
|
199
|
+
$('.materialbox-caption').velocity("stop", true);
|
200
|
+
|
201
|
+
|
202
|
+
$('#materialbox-overlay').velocity({opacity: 0}, {
|
203
|
+
duration: outDuration, // Delay prevents animation overlapping
|
204
|
+
queue: false, easing: 'easeOutQuad',
|
205
|
+
complete: function(){
|
206
|
+
// Remove Overlay
|
207
|
+
overlayActive = false;
|
208
|
+
$(this).remove();
|
209
|
+
}
|
210
|
+
});
|
211
|
+
|
212
|
+
// Resize Image
|
213
|
+
origin.velocity(
|
214
|
+
{
|
215
|
+
width: originalWidth,
|
216
|
+
height: originalHeight,
|
217
|
+
left: 0,
|
218
|
+
top: 0
|
219
|
+
},
|
220
|
+
{
|
221
|
+
duration: outDuration,
|
222
|
+
queue: false, easing: 'easeOutQuad'
|
223
|
+
}
|
224
|
+
);
|
225
|
+
|
226
|
+
// Remove Caption + reset css settings on image
|
227
|
+
$('.materialbox-caption').velocity({opacity: 0}, {
|
228
|
+
duration: outDuration, // Delay prevents animation overlapping
|
229
|
+
queue: false, easing: 'easeOutQuad',
|
230
|
+
complete: function(){
|
231
|
+
placeholder.css({
|
232
|
+
height: '',
|
233
|
+
width: '',
|
234
|
+
position: '',
|
235
|
+
top: '',
|
236
|
+
left: ''
|
237
|
+
});
|
238
|
+
|
239
|
+
origin.css({
|
240
|
+
height: '',
|
241
|
+
top: '',
|
242
|
+
left: '',
|
243
|
+
width: '',
|
244
|
+
'max-width': '',
|
245
|
+
position: '',
|
246
|
+
'z-index': ''
|
247
|
+
});
|
248
|
+
|
249
|
+
// Remove class
|
250
|
+
origin.removeClass('active');
|
251
|
+
doneAnimating = true;
|
252
|
+
$(this).remove();
|
253
|
+
|
254
|
+
// Remove overflow overrides on ancestors
|
255
|
+
if (ancestorsChanged) {
|
256
|
+
ancestorsChanged.css('overflow', '');
|
257
|
+
}
|
258
|
+
}
|
259
|
+
});
|
260
|
+
|
261
|
+
}
|
262
|
+
});
|
263
|
+
};
|
264
|
+
|
265
|
+
$(document).ready(function(){
|
266
|
+
$('.materialboxed').materialbox();
|
267
|
+
});
|
268
|
+
|
269
|
+
}( jQuery ));
|
@@ -0,0 +1,58 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
$.fn.parallax = function () {
|
4
|
+
var window_width = $(window).width();
|
5
|
+
// Parallax Scripts
|
6
|
+
return this.each(function(i) {
|
7
|
+
var $this = $(this);
|
8
|
+
$this.addClass('parallax');
|
9
|
+
|
10
|
+
function updateParallax(initial) {
|
11
|
+
var container_height;
|
12
|
+
if (window_width < 601) {
|
13
|
+
container_height = ($this.height() > 0) ? $this.height() : $this.children("img").height();
|
14
|
+
}
|
15
|
+
else {
|
16
|
+
container_height = ($this.height() > 0) ? $this.height() : 500;
|
17
|
+
}
|
18
|
+
var $img = $this.children("img").first();
|
19
|
+
var img_height = $img.height();
|
20
|
+
var parallax_dist = img_height - container_height;
|
21
|
+
var bottom = $this.offset().top + container_height;
|
22
|
+
var top = $this.offset().top;
|
23
|
+
var scrollTop = $(window).scrollTop();
|
24
|
+
var windowHeight = window.innerHeight;
|
25
|
+
var windowBottom = scrollTop + windowHeight;
|
26
|
+
var percentScrolled = (windowBottom - top) / (container_height + windowHeight);
|
27
|
+
var parallax = Math.round((parallax_dist * percentScrolled));
|
28
|
+
|
29
|
+
if (initial) {
|
30
|
+
$img.css('display', 'block');
|
31
|
+
}
|
32
|
+
if ((bottom > scrollTop) && (top < (scrollTop + windowHeight))) {
|
33
|
+
$img.css('transform', "translate3D(-50%," + parallax + "px, 0)");
|
34
|
+
}
|
35
|
+
|
36
|
+
}
|
37
|
+
|
38
|
+
// Wait for image load
|
39
|
+
$this.children("img").one("load", function() {
|
40
|
+
updateParallax(true);
|
41
|
+
}).each(function() {
|
42
|
+
if(this.complete) $(this).load();
|
43
|
+
});
|
44
|
+
|
45
|
+
$(window).scroll(function() {
|
46
|
+
window_width = $(window).width();
|
47
|
+
updateParallax(false);
|
48
|
+
});
|
49
|
+
|
50
|
+
$(window).resize(function() {
|
51
|
+
window_width = $(window).width();
|
52
|
+
updateParallax(false);
|
53
|
+
});
|
54
|
+
|
55
|
+
});
|
56
|
+
|
57
|
+
};
|
58
|
+
}( jQuery ));
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+scss+bash */
|
2
|
+
self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=t.util.clone(e[r]));return a;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var r in n)a[r]=n[r];return a},insertBefore:function(e,n,a,r){r=r||t.languages;var i=r[e];if(2==arguments.length){a=arguments[1];for(var l in a)a.hasOwnProperty(l)&&(i[l]=a[l]);return i}var s={};for(var o in i)if(i.hasOwnProperty(o)){if(o==n)for(var l in a)a.hasOwnProperty(l)&&(s[l]=a[l]);s[o]=i[o]}return t.languages.DFS(t.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=s)}),r[e]=s},DFS:function(e,n,a){for(var r in e)e.hasOwnProperty(r)&&(n.call(e,r,e[r],a||r),"Object"===t.util.type(e[r])?t.languages.DFS(e[r],n):"Array"===t.util.type(e[r])&&t.languages.DFS(e[r],n,r))}},highlightAll:function(e,n){for(var a,r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),i=0;a=r[i++];)t.highlightElement(a,e===!0,n)},highlightElement:function(a,r,i){for(var l,s,o=a;o&&!e.test(o.className);)o=o.parentNode;if(o&&(l=(o.className.match(e)||[,""])[1],s=t.languages[l]),s){a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,o=a.parentNode,/pre/i.test(o.nodeName)&&(o.className=o.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var g=a.textContent;if(g){var u={element:a,language:l,grammar:s,code:g};if(t.hooks.run("before-highlight",u),r&&self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){u.highlightedCode=n.stringify(JSON.parse(e.data),l),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,i&&i.call(u.element),t.hooks.run("after-highlight",u)},c.postMessage(JSON.stringify({language:u.language,code:u.code}))}else u.highlightedCode=t.highlight(u.code,u.grammar,u.language),t.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,i&&i.call(a),t.hooks.run("after-highlight",u)}}},highlight:function(e,a,r){var i=t.tokenize(e,a);return n.stringify(t.util.encode(i),r)},tokenize:function(e,n){var a=t.Token,r=[e],i=n.rest;if(i){for(var l in i)n[l]=i[l];delete n.rest}e:for(var l in n)if(n.hasOwnProperty(l)&&n[l]){var s=n[l];s="Array"===t.util.type(s)?s:[s];for(var o=0;o<s.length;++o){var g=s[o],u=g.inside,c=!!g.lookbehind,f=0,h=g.alias;g=g.pattern||g;for(var p=0;p<r.length;p++){var d=r[p];if(r.length>e.length)break e;if(!(d instanceof a)){g.lastIndex=0;var m=g.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),O=[p,1];b&&O.push(b);var N=new a(l,u?t.tokenize(m,u):m,h);O.push(N),w&&O.push(w),Array.prototype.splice.apply(r,O)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("[object Array]"==Object.prototype.toString.call(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+"</"+i.tag+">"},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
|
3
|
+
Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/\&#?[\da-z]{1,8};/gi},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});;
|
4
|
+
Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,punctuation:/[\{\};:]/g,"function":/[-a-z0-9]+(?=\()/gi},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/<style[\w\W]*?>[\w\W]*?<\/style>/gi,inside:{tag:{pattern:/<style[\w\W]*?>|<\/style>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css},alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').+?\1/gi,inside:{"attr-name":{pattern:/^\s*style/gi,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/gi,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag));;
|
5
|
+
Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//g,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*?(\r?\n|$)/g,lookbehind:!0}],string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/gi,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/gi,inside:{punctuation:/\(/}},number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|&{1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};;
|
6
|
+
Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|false|finally|for|function|get|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|set|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|-?Infinity)\b/g,"function":/(?!\d)[a-z0-9_$]+(?=\()/gi}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/<script[\w\W]*?>[\w\W]*?<\/script>/gi,inside:{tag:{pattern:/<script[\w\W]*?>|<\/script>/gi,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript},alias:"language-javascript"}});;
|
7
|
+
Prism.languages.scss=Prism.languages.extend("css",{comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|\/\/.*?(\r?\n|$))/g,lookbehind:!0},atrule:/@[\w-]+(?=\s+(\(|\{|;))/gi,url:/([-a-z]+-)*url(?=\()/gi,selector:/([^@;\{\}\(\)]?([^@;\{\}\(\)]|&|\#\{\$[-_\w]+\})+)(?=\s*\{(\}|\s|[^\}]+(:|\{)[^\}]+))/gm}),Prism.languages.insertBefore("scss","atrule",{keyword:/@(if|else if|else|for|each|while|import|extend|debug|warn|mixin|include|function|return|content)|(?=@for\s+\$[-_\w]+\s)+from/i}),Prism.languages.insertBefore("scss","property",{variable:/((\$[-_\w]+)|(#\{\$[-_\w]+\}))/i}),Prism.languages.insertBefore("scss","ignore",{placeholder:/%[-_\w]+/i,statement:/\B!(default|optional)\b/gi,"boolean":/\b(true|false)\b/g,"null":/\b(null)\b/g,operator:/\s+([-+]{1,2}|={1,2}|!=|\|?\||\?|\*|\/|\%)\s+/g});;
|
8
|
+
Prism.languages.bash=Prism.languages.extend("clike",{comment:{pattern:/(^|[^"{\\])(#.*?(\r?\n|$))/g,lookbehind:!0},string:{pattern:/("|')(\\?[\s\S])*?\1/g,inside:{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^\}]+\})/g}},keyword:/\b(if|then|else|elif|fi|for|break|continue|while|in|case|function|select|do|done|until|echo|exit|return|set|declare)\b/g}),Prism.languages.insertBefore("bash","keyword",{property:/\$([a-zA-Z0-9_#\?\-\*!@]+|\{[^}]+\})/g}),Prism.languages.insertBefore("bash","comment",{important:/(^#!\s*\/bin\/bash)|(^#!\s*\/bin\/sh)/g});;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$.fn.pushpin = function (options) {
|
3
|
+
// Defaults
|
4
|
+
var defaults = {
|
5
|
+
top: 0,
|
6
|
+
bottom: Infinity,
|
7
|
+
offset: 0
|
8
|
+
};
|
9
|
+
|
10
|
+
// Remove pushpin event and classes
|
11
|
+
if (options === "remove") {
|
12
|
+
this.each(function () {
|
13
|
+
if (id = $(this).data('pushpin-id')) {
|
14
|
+
$(window).off('scroll.' + id);
|
15
|
+
$(this).removeData('pushpin-id').removeClass('pin-top pinned pin-bottom').removeAttr('style');
|
16
|
+
}
|
17
|
+
});
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
|
21
|
+
options = $.extend(defaults, options);
|
22
|
+
|
23
|
+
|
24
|
+
$index = 0;
|
25
|
+
return this.each(function() {
|
26
|
+
var $uniqueId = Materialize.guid(),
|
27
|
+
$this = $(this),
|
28
|
+
$original_offset = $(this).offset().top;
|
29
|
+
|
30
|
+
function removePinClasses(object) {
|
31
|
+
object.removeClass('pin-top');
|
32
|
+
object.removeClass('pinned');
|
33
|
+
object.removeClass('pin-bottom');
|
34
|
+
}
|
35
|
+
|
36
|
+
function updateElements(objects, scrolled) {
|
37
|
+
objects.each(function () {
|
38
|
+
// Add position fixed (because its between top and bottom)
|
39
|
+
if (options.top <= scrolled && options.bottom >= scrolled && !$(this).hasClass('pinned')) {
|
40
|
+
removePinClasses($(this));
|
41
|
+
$(this).css('top', options.offset);
|
42
|
+
$(this).addClass('pinned');
|
43
|
+
}
|
44
|
+
|
45
|
+
// Add pin-top (when scrolled position is above top)
|
46
|
+
if (scrolled < options.top && !$(this).hasClass('pin-top')) {
|
47
|
+
removePinClasses($(this));
|
48
|
+
$(this).css('top', 0);
|
49
|
+
$(this).addClass('pin-top');
|
50
|
+
}
|
51
|
+
|
52
|
+
// Add pin-bottom (when scrolled position is below bottom)
|
53
|
+
if (scrolled > options.bottom && !$(this).hasClass('pin-bottom')) {
|
54
|
+
removePinClasses($(this));
|
55
|
+
$(this).addClass('pin-bottom');
|
56
|
+
$(this).css('top', options.bottom - $original_offset);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
|
61
|
+
$(this).data('pushpin-id', $uniqueId);
|
62
|
+
updateElements($this, $(window).scrollTop());
|
63
|
+
$(window).on('scroll.' + $uniqueId, function () {
|
64
|
+
var $scrolled = $(window).scrollTop() + options.offset;
|
65
|
+
updateElements($this, $scrolled);
|
66
|
+
});
|
67
|
+
|
68
|
+
});
|
69
|
+
|
70
|
+
};
|
71
|
+
}( jQuery ));
|
@@ -0,0 +1,48 @@
|
|
1
|
+
(function($) {
|
2
|
+
|
3
|
+
// Input: Array of JSON objects {selector, offset, callback}
|
4
|
+
|
5
|
+
Materialize.scrollFire = function(options) {
|
6
|
+
|
7
|
+
var didScroll = false;
|
8
|
+
|
9
|
+
window.addEventListener("scroll", function() {
|
10
|
+
didScroll = true;
|
11
|
+
});
|
12
|
+
|
13
|
+
// Rate limit to 100ms
|
14
|
+
setInterval(function() {
|
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 + window.pageYOffset;
|
30
|
+
|
31
|
+
if (windowScroll > (elementOffset + offset)) {
|
32
|
+
if (value.done !== true) {
|
33
|
+
if (typeof(callback) === 'function') {
|
34
|
+
callback.call(this, currentElement);
|
35
|
+
} else if (typeof(callback) === 'string') {
|
36
|
+
var callbackFunc = new Function(callback);
|
37
|
+
callbackFunc(currentElement);
|
38
|
+
}
|
39
|
+
value.done = true;
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
}, 100);
|
46
|
+
};
|
47
|
+
|
48
|
+
})(jQuery);
|