dr-jekylls-materials 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/assets/css/materialize.scss +42 -0
- data/assets/css/site.css +10 -0
- data/assets/fonts/roboto/Roboto-Bold.eot +0 -0
- data/assets/fonts/roboto/Roboto-Bold.ttf +0 -0
- data/assets/fonts/roboto/Roboto-Bold.woff +0 -0
- data/assets/fonts/roboto/Roboto-Bold.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Light.eot +0 -0
- data/assets/fonts/roboto/Roboto-Light.ttf +0 -0
- data/assets/fonts/roboto/Roboto-Light.woff +0 -0
- data/assets/fonts/roboto/Roboto-Light.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Medium.eot +0 -0
- data/assets/fonts/roboto/Roboto-Medium.ttf +0 -0
- data/assets/fonts/roboto/Roboto-Medium.woff +0 -0
- data/assets/fonts/roboto/Roboto-Medium.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Regular.eot +0 -0
- data/assets/fonts/roboto/Roboto-Regular.ttf +0 -0
- data/assets/fonts/roboto/Roboto-Regular.woff +0 -0
- data/assets/fonts/roboto/Roboto-Regular.woff2 +0 -0
- data/assets/fonts/roboto/Roboto-Thin.eot +0 -0
- data/assets/fonts/roboto/Roboto-Thin.ttf +0 -0
- data/assets/fonts/roboto/Roboto-Thin.woff +0 -0
- data/assets/fonts/roboto/Roboto-Thin.woff2 +0 -0
- data/assets/js/animation.js +9 -0
- data/assets/js/bin/materialize.js +7778 -0
- data/assets/js/bin/materialize.min.js +10 -0
- data/assets/js/buttons.js +267 -0
- data/assets/js/cards.js +26 -0
- data/assets/js/carousel.js +454 -0
- data/assets/js/character_counter.js +72 -0
- data/assets/js/chips.js +289 -0
- data/assets/js/collapsible.js +160 -0
- data/assets/js/date_picker/picker.date.js +1430 -0
- data/assets/js/date_picker/picker.js +1123 -0
- data/assets/js/dropdown.js +265 -0
- data/assets/js/forms.js +682 -0
- data/assets/js/global.js +98 -0
- data/assets/js/hammer.min.js +1 -0
- data/assets/js/initial.js +11 -0
- data/assets/js/jquery.easing.1.3.js +205 -0
- data/assets/js/jquery.hammer.js +33 -0
- data/assets/js/materialbox.js +269 -0
- data/assets/js/materialize-readies.js +14 -0
- data/assets/js/materialize.js +7779 -0
- data/assets/js/materialize.min.js +10 -0
- data/assets/js/modal.js +184 -0
- data/assets/js/parallax.js +58 -0
- data/assets/js/pushpin.js +71 -0
- data/assets/js/scrollFire.js +48 -0
- data/assets/js/scrollspy.js +284 -0
- data/assets/js/sideNav.js +370 -0
- data/assets/js/slider.js +321 -0
- data/assets/js/tabs.js +164 -0
- data/assets/js/toasts.js +137 -0
- data/assets/js/tooltip.js +236 -0
- data/assets/js/transitions.js +169 -0
- data/assets/js/velocity.min.js +5 -0
- data/assets/js/waves.js +338 -0
- data/assets/materialize-LICENSE +21 -0
- data/assets/materialize-README.md +48 -0
- data/assets/site.css +2 -0
- metadata +61 -1
data/assets/js/tabs.js
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
var methods = {
|
4
|
+
init : function(options) {
|
5
|
+
var defaults = {
|
6
|
+
onShow: null
|
7
|
+
};
|
8
|
+
options = $.extend(defaults, options);
|
9
|
+
|
10
|
+
return this.each(function() {
|
11
|
+
|
12
|
+
// For each set of tabs, we want to keep track of
|
13
|
+
// which tab is active and its associated content
|
14
|
+
var $this = $(this),
|
15
|
+
window_width = $(window).width();
|
16
|
+
|
17
|
+
var $active, $content, $links = $this.find('li.tab a'),
|
18
|
+
$tabs_width = $this.width(),
|
19
|
+
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length,
|
20
|
+
$index = 0;
|
21
|
+
|
22
|
+
// Finds right attribute for indicator based on active tab.
|
23
|
+
// el: jQuery Object
|
24
|
+
var calcRightPos = function(el) {
|
25
|
+
return $tabs_width - el.position().left - el.outerWidth() - $this.scrollLeft();
|
26
|
+
};
|
27
|
+
|
28
|
+
// Finds left attribute for indicator based on active tab.
|
29
|
+
// el: jQuery Object
|
30
|
+
var calcLeftPos = function(el) {
|
31
|
+
return el.position().left + $this.scrollLeft();
|
32
|
+
};
|
33
|
+
|
34
|
+
// If the location.hash matches one of the links, use that as the active tab.
|
35
|
+
$active = $($links.filter('[href="'+location.hash+'"]'));
|
36
|
+
|
37
|
+
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
38
|
+
if ($active.length === 0) {
|
39
|
+
$active = $(this).find('li.tab a.active').first();
|
40
|
+
}
|
41
|
+
if ($active.length === 0) {
|
42
|
+
$active = $(this).find('li.tab a').first();
|
43
|
+
}
|
44
|
+
|
45
|
+
$active.addClass('active');
|
46
|
+
$index = $links.index($active);
|
47
|
+
if ($index < 0) {
|
48
|
+
$index = 0;
|
49
|
+
}
|
50
|
+
|
51
|
+
if ($active[0] !== undefined) {
|
52
|
+
$content = $($active[0].hash);
|
53
|
+
}
|
54
|
+
|
55
|
+
// append indicator then set indicator width to tab width
|
56
|
+
$this.append('<div class="indicator"></div>');
|
57
|
+
var $indicator = $this.find('.indicator');
|
58
|
+
if ($this.is(":visible")) {
|
59
|
+
// $indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
|
60
|
+
// $indicator.css({"left": $index * $tab_width});
|
61
|
+
setTimeout(function() {
|
62
|
+
$indicator.css({"right": calcRightPos($active) });
|
63
|
+
$indicator.css({"left": calcLeftPos($active) });
|
64
|
+
}, 0);
|
65
|
+
}
|
66
|
+
$(window).resize(function () {
|
67
|
+
$tabs_width = $this.width();
|
68
|
+
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
|
69
|
+
if ($index < 0) {
|
70
|
+
$index = 0;
|
71
|
+
}
|
72
|
+
if ($tab_width !== 0 && $tabs_width !== 0) {
|
73
|
+
$indicator.css({"right": calcRightPos($active) });
|
74
|
+
$indicator.css({"left": calcLeftPos($active) });
|
75
|
+
}
|
76
|
+
});
|
77
|
+
|
78
|
+
// Hide the remaining content
|
79
|
+
$links.not($active).each(function () {
|
80
|
+
$(Materialize.escapeHash(this.hash)).hide();
|
81
|
+
});
|
82
|
+
|
83
|
+
|
84
|
+
// Bind the click event handler
|
85
|
+
$this.on('click', 'a', function(e) {
|
86
|
+
if ($(this).parent().hasClass('disabled')) {
|
87
|
+
e.preventDefault();
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
// Act as regular link if target attribute is specified.
|
92
|
+
if (!!$(this).attr("target")) {
|
93
|
+
return;
|
94
|
+
}
|
95
|
+
|
96
|
+
$tabs_width = $this.width();
|
97
|
+
$tab_width = Math.max($tabs_width, $this[0].scrollWidth) / $links.length;
|
98
|
+
|
99
|
+
// Make the old tab inactive.
|
100
|
+
$active.removeClass('active');
|
101
|
+
if ($content !== undefined) {
|
102
|
+
$content.hide();
|
103
|
+
}
|
104
|
+
|
105
|
+
// Update the variables with the new link and content
|
106
|
+
$active = $(this);
|
107
|
+
$content = $(Materialize.escapeHash(this.hash));
|
108
|
+
$links = $this.find('li.tab a');
|
109
|
+
var activeRect = $active.position();
|
110
|
+
|
111
|
+
// Make the tab active.
|
112
|
+
$active.addClass('active');
|
113
|
+
var $prev_index = $index;
|
114
|
+
$index = $links.index($(this));
|
115
|
+
if ($index < 0) {
|
116
|
+
$index = 0;
|
117
|
+
}
|
118
|
+
// Change url to current tab
|
119
|
+
// window.location.hash = $active.attr('href');
|
120
|
+
|
121
|
+
if ($content !== undefined) {
|
122
|
+
$content.show();
|
123
|
+
if (typeof(options.onShow) === "function") {
|
124
|
+
options.onShow.call(this, $content);
|
125
|
+
}
|
126
|
+
}
|
127
|
+
|
128
|
+
// Update indicator
|
129
|
+
|
130
|
+
if (($index - $prev_index) >= 0) {
|
131
|
+
$indicator.velocity({"right": calcRightPos($active) }, { duration: 300, queue: false, easing: 'easeOutQuad'});
|
132
|
+
$indicator.velocity({"left": calcLeftPos($active) }, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
|
133
|
+
|
134
|
+
} else {
|
135
|
+
$indicator.velocity({"left": calcLeftPos($active) }, { duration: 300, queue: false, easing: 'easeOutQuad'});
|
136
|
+
$indicator.velocity({"right": calcRightPos($active) }, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
|
137
|
+
}
|
138
|
+
|
139
|
+
// Prevent the anchor's default click action
|
140
|
+
e.preventDefault();
|
141
|
+
});
|
142
|
+
});
|
143
|
+
|
144
|
+
},
|
145
|
+
select_tab : function( id ) {
|
146
|
+
this.find('a[href="#' + id + '"]').trigger('click');
|
147
|
+
}
|
148
|
+
};
|
149
|
+
|
150
|
+
$.fn.tabs = function(methodOrOptions) {
|
151
|
+
if ( methods[methodOrOptions] ) {
|
152
|
+
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
153
|
+
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
154
|
+
// Default to "init"
|
155
|
+
return methods.init.apply( this, arguments );
|
156
|
+
} else {
|
157
|
+
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tabs' );
|
158
|
+
}
|
159
|
+
};
|
160
|
+
|
161
|
+
$(document).ready(function(){
|
162
|
+
$('ul.tabs').tabs();
|
163
|
+
});
|
164
|
+
}( jQuery ));
|
data/assets/js/toasts.js
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
Materialize.toast = function (message, displayLength, className, completeCallback) {
|
2
|
+
className = className || "";
|
3
|
+
|
4
|
+
var container = document.getElementById('toast-container');
|
5
|
+
|
6
|
+
// Create toast container if it does not exist
|
7
|
+
if (container === null) {
|
8
|
+
// create notification container
|
9
|
+
container = document.createElement('div');
|
10
|
+
container.id = 'toast-container';
|
11
|
+
document.body.appendChild(container);
|
12
|
+
}
|
13
|
+
|
14
|
+
// Select and append toast
|
15
|
+
var newToast = createToast(message);
|
16
|
+
|
17
|
+
// only append toast if message is not undefined
|
18
|
+
if(message){
|
19
|
+
container.appendChild(newToast);
|
20
|
+
}
|
21
|
+
|
22
|
+
newToast.style.top = '35px';
|
23
|
+
newToast.style.opacity = 0;
|
24
|
+
|
25
|
+
// Animate toast in
|
26
|
+
Vel(newToast, { "top" : "0px", opacity: 1 }, {duration: 300,
|
27
|
+
easing: 'easeOutCubic',
|
28
|
+
queue: false});
|
29
|
+
|
30
|
+
// Allows timer to be pause while being panned
|
31
|
+
var timeLeft = displayLength;
|
32
|
+
var counterInterval;
|
33
|
+
if (timeLeft != null) {
|
34
|
+
counterInterval = setInterval (function(){
|
35
|
+
if (newToast.parentNode === null)
|
36
|
+
window.clearInterval(counterInterval);
|
37
|
+
|
38
|
+
// If toast is not being dragged, decrease its time remaining
|
39
|
+
if (!newToast.classList.contains('panning')) {
|
40
|
+
timeLeft -= 20;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (timeLeft <= 0) {
|
44
|
+
// Animate toast out
|
45
|
+
Vel(newToast, {"opacity": 0, marginTop: '-40px'}, { duration: 375,
|
46
|
+
easing: 'easeOutExpo',
|
47
|
+
queue: false,
|
48
|
+
complete: function(){
|
49
|
+
// Call the optional callback
|
50
|
+
if(typeof(completeCallback) === "function")
|
51
|
+
completeCallback();
|
52
|
+
// Remove toast after it times out
|
53
|
+
this[0].parentNode.removeChild(this[0]);
|
54
|
+
}
|
55
|
+
});
|
56
|
+
window.clearInterval(counterInterval);
|
57
|
+
}
|
58
|
+
}, 20);
|
59
|
+
}
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
function createToast(html) {
|
64
|
+
|
65
|
+
// Create toast
|
66
|
+
var toast = document.createElement('div');
|
67
|
+
toast.classList.add('toast');
|
68
|
+
if (className) {
|
69
|
+
var classes = className.split(' ');
|
70
|
+
|
71
|
+
for (var i = 0, count = classes.length; i < count; i++) {
|
72
|
+
toast.classList.add(classes[i]);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
// If type of parameter is HTML Element
|
76
|
+
if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
|
77
|
+
) {
|
78
|
+
toast.appendChild(html);
|
79
|
+
}
|
80
|
+
else if (html instanceof jQuery) {
|
81
|
+
// Check if it is jQuery object
|
82
|
+
toast.appendChild(html[0]);
|
83
|
+
}
|
84
|
+
else {
|
85
|
+
// Insert as text;
|
86
|
+
toast.innerHTML = html;
|
87
|
+
}
|
88
|
+
// Bind hammer
|
89
|
+
var hammerHandler = new Hammer(toast, {prevent_default: false});
|
90
|
+
hammerHandler.on('pan', function(e) {
|
91
|
+
var deltaX = e.deltaX;
|
92
|
+
var activationDistance = 80;
|
93
|
+
|
94
|
+
// Change toast state
|
95
|
+
if (!toast.classList.contains('panning')){
|
96
|
+
toast.classList.add('panning');
|
97
|
+
}
|
98
|
+
|
99
|
+
var opacityPercent = 1-Math.abs(deltaX / activationDistance);
|
100
|
+
if (opacityPercent < 0)
|
101
|
+
opacityPercent = 0;
|
102
|
+
|
103
|
+
Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
104
|
+
|
105
|
+
});
|
106
|
+
|
107
|
+
hammerHandler.on('panend', function(e) {
|
108
|
+
var deltaX = e.deltaX;
|
109
|
+
var activationDistance = 80;
|
110
|
+
|
111
|
+
// If toast dragged past activation point
|
112
|
+
if (Math.abs(deltaX) > activationDistance) {
|
113
|
+
Vel(toast, {marginTop: '-40px'}, { duration: 375,
|
114
|
+
easing: 'easeOutExpo',
|
115
|
+
queue: false,
|
116
|
+
complete: function(){
|
117
|
+
if(typeof(completeCallback) === "function") {
|
118
|
+
completeCallback();
|
119
|
+
}
|
120
|
+
toast.parentNode.removeChild(toast);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
|
124
|
+
} else {
|
125
|
+
toast.classList.remove('panning');
|
126
|
+
// Put toast back into original position
|
127
|
+
Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
|
128
|
+
easing: 'easeOutExpo',
|
129
|
+
queue: false
|
130
|
+
});
|
131
|
+
|
132
|
+
}
|
133
|
+
});
|
134
|
+
|
135
|
+
return toast;
|
136
|
+
}
|
137
|
+
};
|
@@ -0,0 +1,236 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$.fn.tooltip = function (options) {
|
3
|
+
var timeout = null,
|
4
|
+
margin = 5;
|
5
|
+
|
6
|
+
// Defaults
|
7
|
+
var defaults = {
|
8
|
+
delay: 350,
|
9
|
+
tooltip: '',
|
10
|
+
position: 'bottom',
|
11
|
+
html: false
|
12
|
+
};
|
13
|
+
|
14
|
+
// Remove tooltip from the activator
|
15
|
+
if (options === "remove") {
|
16
|
+
this.each(function() {
|
17
|
+
$('#' + $(this).attr('data-tooltip-id')).remove();
|
18
|
+
$(this).off('mouseenter.tooltip mouseleave.tooltip');
|
19
|
+
});
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
options = $.extend(defaults, options);
|
24
|
+
|
25
|
+
return this.each(function() {
|
26
|
+
var tooltipId = Materialize.guid();
|
27
|
+
var origin = $(this);
|
28
|
+
|
29
|
+
// Destroy old tooltip
|
30
|
+
if (origin.attr('data-tooltip-id')) {
|
31
|
+
$('#' + origin.attr('data-tooltip-id')).remove();
|
32
|
+
}
|
33
|
+
|
34
|
+
origin.attr('data-tooltip-id', tooltipId);
|
35
|
+
|
36
|
+
// Get attributes.
|
37
|
+
var allowHtml,
|
38
|
+
tooltipDelay,
|
39
|
+
tooltipPosition,
|
40
|
+
tooltipText,
|
41
|
+
tooltipEl,
|
42
|
+
backdrop;
|
43
|
+
var setAttributes = function() {
|
44
|
+
allowHtml = origin.attr('data-html') ? origin.attr('data-html') === 'true' : options.html;
|
45
|
+
tooltipDelay = origin.attr('data-delay');
|
46
|
+
tooltipDelay = (tooltipDelay === undefined || tooltipDelay === '') ?
|
47
|
+
options.delay : tooltipDelay;
|
48
|
+
tooltipPosition = origin.attr('data-position');
|
49
|
+
tooltipPosition = (tooltipPosition === undefined || tooltipPosition === '') ?
|
50
|
+
options.position : tooltipPosition;
|
51
|
+
tooltipText = origin.attr('data-tooltip');
|
52
|
+
tooltipText = (tooltipText === undefined || tooltipText === '') ?
|
53
|
+
options.tooltip : tooltipText;
|
54
|
+
};
|
55
|
+
setAttributes();
|
56
|
+
|
57
|
+
var renderTooltipEl = function() {
|
58
|
+
var tooltip = $('<div class="material-tooltip"></div>');
|
59
|
+
|
60
|
+
// Create Text span
|
61
|
+
if (allowHtml) {
|
62
|
+
tooltipText = $('<span></span>').html(tooltipText);
|
63
|
+
} else{
|
64
|
+
tooltipText = $('<span></span>').text(tooltipText);
|
65
|
+
}
|
66
|
+
|
67
|
+
// Create tooltip
|
68
|
+
tooltip.append(tooltipText)
|
69
|
+
.appendTo($('body'))
|
70
|
+
.attr('id', tooltipId);
|
71
|
+
|
72
|
+
// Create backdrop
|
73
|
+
backdrop = $('<div class="backdrop"></div>');
|
74
|
+
backdrop.appendTo(tooltip);
|
75
|
+
return tooltip;
|
76
|
+
};
|
77
|
+
tooltipEl = renderTooltipEl();
|
78
|
+
|
79
|
+
// Destroy previously binded events
|
80
|
+
origin.off('mouseenter.tooltip mouseleave.tooltip');
|
81
|
+
// Mouse In
|
82
|
+
var started = false, timeoutRef;
|
83
|
+
origin.on({'mouseenter.tooltip': function(e) {
|
84
|
+
var showTooltip = function() {
|
85
|
+
setAttributes();
|
86
|
+
started = true;
|
87
|
+
tooltipEl.velocity('stop');
|
88
|
+
backdrop.velocity('stop');
|
89
|
+
tooltipEl.css({ display: 'block', left: '0px', top: '0px' });
|
90
|
+
|
91
|
+
// Tooltip positioning
|
92
|
+
var originWidth = origin.outerWidth();
|
93
|
+
var originHeight = origin.outerHeight();
|
94
|
+
|
95
|
+
var tooltipHeight = tooltipEl.outerHeight();
|
96
|
+
var tooltipWidth = tooltipEl.outerWidth();
|
97
|
+
var tooltipVerticalMovement = '0px';
|
98
|
+
var tooltipHorizontalMovement = '0px';
|
99
|
+
var scaleXFactor = 8;
|
100
|
+
var scaleYFactor = 8;
|
101
|
+
var targetTop, targetLeft, newCoordinates;
|
102
|
+
|
103
|
+
if (tooltipPosition === "top") {
|
104
|
+
// Top Position
|
105
|
+
targetTop = origin.offset().top - tooltipHeight - margin;
|
106
|
+
targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
|
107
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
108
|
+
|
109
|
+
tooltipVerticalMovement = '-10px';
|
110
|
+
backdrop.css({
|
111
|
+
bottom: 0,
|
112
|
+
left: 0,
|
113
|
+
borderRadius: '14px 14px 0 0',
|
114
|
+
transformOrigin: '50% 100%',
|
115
|
+
marginTop: tooltipHeight,
|
116
|
+
marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
|
117
|
+
});
|
118
|
+
}
|
119
|
+
// Left Position
|
120
|
+
else if (tooltipPosition === "left") {
|
121
|
+
targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
|
122
|
+
targetLeft = origin.offset().left - tooltipWidth - margin;
|
123
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
124
|
+
|
125
|
+
tooltipHorizontalMovement = '-10px';
|
126
|
+
backdrop.css({
|
127
|
+
top: '-7px',
|
128
|
+
right: 0,
|
129
|
+
width: '14px',
|
130
|
+
height: '14px',
|
131
|
+
borderRadius: '14px 0 0 14px',
|
132
|
+
transformOrigin: '95% 50%',
|
133
|
+
marginTop: tooltipHeight/2,
|
134
|
+
marginLeft: tooltipWidth
|
135
|
+
});
|
136
|
+
}
|
137
|
+
// Right Position
|
138
|
+
else if (tooltipPosition === "right") {
|
139
|
+
targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
|
140
|
+
targetLeft = origin.offset().left + originWidth + margin;
|
141
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
142
|
+
|
143
|
+
tooltipHorizontalMovement = '+10px';
|
144
|
+
backdrop.css({
|
145
|
+
top: '-7px',
|
146
|
+
left: 0,
|
147
|
+
width: '14px',
|
148
|
+
height: '14px',
|
149
|
+
borderRadius: '0 14px 14px 0',
|
150
|
+
transformOrigin: '5% 50%',
|
151
|
+
marginTop: tooltipHeight/2,
|
152
|
+
marginLeft: '0px'
|
153
|
+
});
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
// Bottom Position
|
157
|
+
targetTop = origin.offset().top + origin.outerHeight() + margin;
|
158
|
+
targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
|
159
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
160
|
+
tooltipVerticalMovement = '+10px';
|
161
|
+
backdrop.css({
|
162
|
+
top: 0,
|
163
|
+
left: 0,
|
164
|
+
marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
|
165
|
+
});
|
166
|
+
}
|
167
|
+
|
168
|
+
// Set tooptip css placement
|
169
|
+
tooltipEl.css({
|
170
|
+
top: newCoordinates.y,
|
171
|
+
left: newCoordinates.x
|
172
|
+
});
|
173
|
+
|
174
|
+
// Calculate Scale to fill
|
175
|
+
scaleXFactor = Math.SQRT2 * tooltipWidth / parseInt(backdrop.css('width'));
|
176
|
+
scaleYFactor = Math.SQRT2 * tooltipHeight / parseInt(backdrop.css('height'));
|
177
|
+
|
178
|
+
tooltipEl.velocity({ marginTop: tooltipVerticalMovement, marginLeft: tooltipHorizontalMovement}, { duration: 350, queue: false })
|
179
|
+
.velocity({opacity: 1}, {duration: 300, delay: 50, queue: false});
|
180
|
+
backdrop.css({ display: 'block' })
|
181
|
+
.velocity({opacity:1},{duration: 55, delay: 0, queue: false})
|
182
|
+
.velocity({scaleX: scaleXFactor, scaleY: scaleYFactor}, {duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad'});
|
183
|
+
};
|
184
|
+
|
185
|
+
timeoutRef = setTimeout(showTooltip, tooltipDelay); // End Interval
|
186
|
+
|
187
|
+
// Mouse Out
|
188
|
+
},
|
189
|
+
'mouseleave.tooltip': function(){
|
190
|
+
// Reset State
|
191
|
+
started = false;
|
192
|
+
clearTimeout(timeoutRef);
|
193
|
+
|
194
|
+
// Animate back
|
195
|
+
setTimeout(function() {
|
196
|
+
if (started !== true) {
|
197
|
+
tooltipEl.velocity({
|
198
|
+
opacity: 0, marginTop: 0, marginLeft: 0}, { duration: 225, queue: false});
|
199
|
+
backdrop.velocity({opacity: 0, scaleX: 1, scaleY: 1}, {
|
200
|
+
duration:225,
|
201
|
+
queue: false,
|
202
|
+
complete: function(){
|
203
|
+
backdrop.css('display', 'none');
|
204
|
+
tooltipEl.css('display', 'none');
|
205
|
+
started = false;}
|
206
|
+
});
|
207
|
+
}
|
208
|
+
},225);
|
209
|
+
}
|
210
|
+
});
|
211
|
+
});
|
212
|
+
};
|
213
|
+
|
214
|
+
var repositionWithinScreen = function(x, y, width, height) {
|
215
|
+
var newX = x;
|
216
|
+
var newY = y;
|
217
|
+
|
218
|
+
if (newX < 0) {
|
219
|
+
newX = 4;
|
220
|
+
} else if (newX + width > window.innerWidth) {
|
221
|
+
newX -= newX + width - window.innerWidth;
|
222
|
+
}
|
223
|
+
|
224
|
+
if (newY < 0) {
|
225
|
+
newY = 4;
|
226
|
+
} else if (newY + height > window.innerHeight + $(window).scrollTop) {
|
227
|
+
newY -= newY + height - window.innerHeight;
|
228
|
+
}
|
229
|
+
|
230
|
+
return {x: newX, y: newY};
|
231
|
+
};
|
232
|
+
|
233
|
+
$(document).ready(function(){
|
234
|
+
$('.tooltipped').tooltip();
|
235
|
+
});
|
236
|
+
}( jQuery ));
|