materialize-rails 0.97.5.custom1
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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +63 -0
- data/Rakefile +1 -0
- data/lib/materialize-rails.rb +25 -0
- data/lib/materialize-rails/engine.rb +14 -0
- data/lib/materialize-rails/version.rb +3 -0
- data/materialize-rails.gemspec +25 -0
- data/vendor/assets/fonts/materialize/material-design-icons/LICENSE.txt +428 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.eot +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.svg +769 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.ttf +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.woff +0 -0
- data/vendor/assets/fonts/materialize/material-design-icons/Material-Design-Icons.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Bold.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Light.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Medium.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Regular.woff2 +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.eot +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.ttf +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.woff +0 -0
- data/vendor/assets/fonts/materialize/roboto/Roboto-Thin.woff2 +0 -0
- data/vendor/assets/javascripts/materialize.js +30 -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 +29 -0
- data/vendor/assets/javascripts/materialize/carousel.js +350 -0
- data/vendor/assets/javascripts/materialize/character_counter.js +59 -0
- data/vendor/assets/javascripts/materialize/chips.js +9 -0
- data/vendor/assets/javascripts/materialize/collapsible.js +137 -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 +228 -0
- data/vendor/assets/javascripts/materialize/forms.js +581 -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/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/leanModal.js +178 -0
- data/vendor/assets/javascripts/materialize/materialbox.js +269 -0
- data/vendor/assets/javascripts/materialize/parallax.js +58 -0
- data/vendor/assets/javascripts/materialize/pushpin.js +62 -0
- data/vendor/assets/javascripts/materialize/scrollFire.js +44 -0
- data/vendor/assets/javascripts/materialize/scrollspy.js +285 -0
- data/vendor/assets/javascripts/materialize/sideNav.js +315 -0
- data/vendor/assets/javascripts/materialize/slider.js +321 -0
- data/vendor/assets/javascripts/materialize/tabs.js +129 -0
- data/vendor/assets/javascripts/materialize/toasts.js +136 -0
- data/vendor/assets/javascripts/materialize/tooltip.js +203 -0
- data/vendor/assets/javascripts/materialize/transitions.js +154 -0
- data/vendor/assets/javascripts/materialize/velocity.min.js +5 -0
- data/vendor/assets/javascripts/materialize/waves.js +338 -0
- data/vendor/assets/stylesheets/components/_buttons.scss +181 -0
- data/vendor/assets/stylesheets/components/_cards.scss +134 -0
- data/vendor/assets/stylesheets/components/_carousel.scss +34 -0
- data/vendor/assets/stylesheets/components/_chips.scss +27 -0
- data/vendor/assets/stylesheets/components/_collapsible.scss +85 -0
- data/vendor/assets/stylesheets/components/_color.scss +412 -0
- data/vendor/assets/stylesheets/components/_dropdown.scss +57 -0
- data/vendor/assets/stylesheets/components/_form.scss +918 -0
- data/vendor/assets/stylesheets/components/_global.scss +766 -0
- data/vendor/assets/stylesheets/components/_grid.scss +146 -0
- data/vendor/assets/stylesheets/components/_icons-material-design.scss +3263 -0
- data/vendor/assets/stylesheets/components/_materialbox.scss +42 -0
- data/vendor/assets/stylesheets/components/_mixins.scss +5 -0
- data/vendor/assets/stylesheets/components/_modal.scss +90 -0
- data/vendor/assets/stylesheets/components/_navbar.scss +171 -0
- data/vendor/assets/stylesheets/components/_normalize.scss +427 -0
- data/vendor/assets/stylesheets/components/_prefixer.scss +384 -0
- data/vendor/assets/stylesheets/components/_preloader.scss +334 -0
- data/vendor/assets/stylesheets/components/_roboto.scss +49 -0
- data/vendor/assets/stylesheets/components/_sideNav.scss +112 -0
- data/vendor/assets/stylesheets/components/_slider.scss +92 -0
- data/vendor/assets/stylesheets/components/_table_of_contents.scss +33 -0
- data/vendor/assets/stylesheets/components/_tabs.scss +56 -0
- data/vendor/assets/stylesheets/components/_toast.scss +65 -0
- data/vendor/assets/stylesheets/components/_tooltip.scss +33 -0
- data/vendor/assets/stylesheets/components/_typography.scss +61 -0
- data/vendor/assets/stylesheets/components/_variables.scss +161 -0
- data/vendor/assets/stylesheets/components/_waves.scss +173 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.date.scss +435 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.scss +201 -0
- data/vendor/assets/stylesheets/components/date_picker/_default.time.scss +125 -0
- data/vendor/assets/stylesheets/materialize.scss +40 -0
- metadata +199 -0
@@ -0,0 +1,129 @@
|
|
1
|
+
(function ($) {
|
2
|
+
|
3
|
+
var methods = {
|
4
|
+
init : function() {
|
5
|
+
return this.each(function() {
|
6
|
+
|
7
|
+
// For each set of tabs, we want to keep track of
|
8
|
+
// which tab is active and its associated content
|
9
|
+
var $this = $(this),
|
10
|
+
window_width = $(window).width();
|
11
|
+
|
12
|
+
$this.width('100%');
|
13
|
+
var $active, $content, $links = $this.find('li.tab a'),
|
14
|
+
$tabs_width = $this.width(),
|
15
|
+
$tab_width = $this.find('li').first().outerWidth(),
|
16
|
+
$index = 0;
|
17
|
+
|
18
|
+
// If the location.hash matches one of the links, use that as the active tab.
|
19
|
+
$active = $($links.filter('[href="'+location.hash+'"]'));
|
20
|
+
|
21
|
+
// If no match is found, use the first link or any with class 'active' as the initial active tab.
|
22
|
+
if ($active.length === 0) {
|
23
|
+
$active = $(this).find('li.tab a.active').first();
|
24
|
+
}
|
25
|
+
if ($active.length === 0) {
|
26
|
+
$active = $(this).find('li.tab a').first();
|
27
|
+
}
|
28
|
+
|
29
|
+
$active.addClass('active');
|
30
|
+
$index = $links.index($active);
|
31
|
+
if ($index < 0) {
|
32
|
+
$index = 0;
|
33
|
+
}
|
34
|
+
|
35
|
+
$content = $($active[0].hash);
|
36
|
+
|
37
|
+
// append indicator then set indicator width to tab width
|
38
|
+
$this.append('<div class="indicator"></div>');
|
39
|
+
var $indicator = $this.find('.indicator');
|
40
|
+
if ($this.is(":visible")) {
|
41
|
+
$indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
|
42
|
+
$indicator.css({"left": $index * $tab_width});
|
43
|
+
}
|
44
|
+
$(window).resize(function () {
|
45
|
+
$tabs_width = $this.width();
|
46
|
+
$tab_width = $this.find('li').first().outerWidth();
|
47
|
+
if ($index < 0) {
|
48
|
+
$index = 0;
|
49
|
+
}
|
50
|
+
if ($tab_width !== 0 && $tabs_width !== 0) {
|
51
|
+
$indicator.css({"right": $tabs_width - (($index + 1) * $tab_width)});
|
52
|
+
$indicator.css({"left": $index * $tab_width});
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
// Hide the remaining content
|
57
|
+
$links.not($active).each(function () {
|
58
|
+
$(this.hash).hide();
|
59
|
+
});
|
60
|
+
|
61
|
+
|
62
|
+
// Bind the click event handler
|
63
|
+
$this.on('click', 'a', function(e) {
|
64
|
+
if ($(this).parent().hasClass('disabled')) {
|
65
|
+
e.preventDefault();
|
66
|
+
return;
|
67
|
+
}
|
68
|
+
|
69
|
+
$tabs_width = $this.width();
|
70
|
+
$tab_width = $this.find('li').first().outerWidth();
|
71
|
+
|
72
|
+
// Make the old tab inactive.
|
73
|
+
$active.removeClass('active');
|
74
|
+
$content.hide();
|
75
|
+
|
76
|
+
// Update the variables with the new link and content
|
77
|
+
$active = $(this);
|
78
|
+
$content = $(this.hash);
|
79
|
+
$links = $this.find('li.tab a');
|
80
|
+
|
81
|
+
// Make the tab active.
|
82
|
+
$active.addClass('active');
|
83
|
+
var $prev_index = $index;
|
84
|
+
$index = $links.index($(this));
|
85
|
+
if ($index < 0) {
|
86
|
+
$index = 0;
|
87
|
+
}
|
88
|
+
// Change url to current tab
|
89
|
+
// window.location.hash = $active.attr('href');
|
90
|
+
|
91
|
+
$content.show();
|
92
|
+
|
93
|
+
// Update indicator
|
94
|
+
if (($index - $prev_index) >= 0) {
|
95
|
+
$indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, { duration: 300, queue: false, easing: 'easeOutQuad'});
|
96
|
+
$indicator.velocity({"left": $index * $tab_width}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
|
97
|
+
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
$indicator.velocity({"left": $index * $tab_width}, { duration: 300, queue: false, easing: 'easeOutQuad'});
|
101
|
+
$indicator.velocity({"right": $tabs_width - (($index + 1) * $tab_width)}, {duration: 300, queue: false, easing: 'easeOutQuad', delay: 90});
|
102
|
+
}
|
103
|
+
|
104
|
+
// Prevent the anchor's default click action
|
105
|
+
e.preventDefault();
|
106
|
+
});
|
107
|
+
});
|
108
|
+
|
109
|
+
},
|
110
|
+
select_tab : function( id ) {
|
111
|
+
this.find('a[href="#' + id + '"]').trigger('click');
|
112
|
+
}
|
113
|
+
};
|
114
|
+
|
115
|
+
$.fn.tabs = function(methodOrOptions) {
|
116
|
+
if ( methods[methodOrOptions] ) {
|
117
|
+
return methods[ methodOrOptions ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
118
|
+
} else if ( typeof methodOrOptions === 'object' || ! methodOrOptions ) {
|
119
|
+
// Default to "init"
|
120
|
+
return methods.init.apply( this, arguments );
|
121
|
+
} else {
|
122
|
+
$.error( 'Method ' + methodOrOptions + ' does not exist on jQuery.tooltip' );
|
123
|
+
}
|
124
|
+
};
|
125
|
+
|
126
|
+
$(document).ready(function(){
|
127
|
+
$('ul.tabs').tabs();
|
128
|
+
});
|
129
|
+
}( jQuery ));
|
@@ -0,0 +1,136 @@
|
|
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 = setInterval (function(){
|
33
|
+
|
34
|
+
|
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
|
+
function createToast(html) {
|
63
|
+
|
64
|
+
// Create toast
|
65
|
+
var toast = document.createElement('div');
|
66
|
+
toast.classList.add('toast');
|
67
|
+
if (className) {
|
68
|
+
var classes = className.split(' ');
|
69
|
+
|
70
|
+
for (var i = 0, count = classes.length; i < count; i++) {
|
71
|
+
toast.classList.add(classes[i]);
|
72
|
+
}
|
73
|
+
}
|
74
|
+
// If type of parameter is HTML Element
|
75
|
+
if ( typeof HTMLElement === "object" ? html instanceof HTMLElement : html && typeof html === "object" && html !== null && html.nodeType === 1 && typeof html.nodeName==="string"
|
76
|
+
) {
|
77
|
+
toast.appendChild(html);
|
78
|
+
}
|
79
|
+
else if (html instanceof jQuery) {
|
80
|
+
// Check if it is jQuery object
|
81
|
+
toast.appendChild(html[0]);
|
82
|
+
}
|
83
|
+
else {
|
84
|
+
// Insert as text;
|
85
|
+
toast.innerHTML = html;
|
86
|
+
}
|
87
|
+
// Bind hammer
|
88
|
+
var hammerHandler = new Hammer(toast, {prevent_default: false});
|
89
|
+
hammerHandler.on('pan', function(e) {
|
90
|
+
var deltaX = e.deltaX;
|
91
|
+
var activationDistance = 80;
|
92
|
+
|
93
|
+
// Change toast state
|
94
|
+
if (!toast.classList.contains('panning')){
|
95
|
+
toast.classList.add('panning');
|
96
|
+
}
|
97
|
+
|
98
|
+
var opacityPercent = 1-Math.abs(deltaX / activationDistance);
|
99
|
+
if (opacityPercent < 0)
|
100
|
+
opacityPercent = 0;
|
101
|
+
|
102
|
+
Vel(toast, {left: deltaX, opacity: opacityPercent }, {duration: 50, queue: false, easing: 'easeOutQuad'});
|
103
|
+
|
104
|
+
});
|
105
|
+
|
106
|
+
hammerHandler.on('panend', function(e) {
|
107
|
+
var deltaX = e.deltaX;
|
108
|
+
var activationDistance = 80;
|
109
|
+
|
110
|
+
// If toast dragged past activation point
|
111
|
+
if (Math.abs(deltaX) > activationDistance) {
|
112
|
+
Vel(toast, {marginTop: '-40px'}, { duration: 375,
|
113
|
+
easing: 'easeOutExpo',
|
114
|
+
queue: false,
|
115
|
+
complete: function(){
|
116
|
+
if(typeof(completeCallback) === "function") {
|
117
|
+
completeCallback();
|
118
|
+
}
|
119
|
+
toast.parentNode.removeChild(toast);
|
120
|
+
}
|
121
|
+
});
|
122
|
+
|
123
|
+
} else {
|
124
|
+
toast.classList.remove('panning');
|
125
|
+
// Put toast back into original position
|
126
|
+
Vel(toast, { left: 0, opacity: 1 }, { duration: 300,
|
127
|
+
easing: 'easeOutExpo',
|
128
|
+
queue: false
|
129
|
+
});
|
130
|
+
|
131
|
+
}
|
132
|
+
});
|
133
|
+
|
134
|
+
return toast;
|
135
|
+
}
|
136
|
+
};
|
@@ -0,0 +1,203 @@
|
|
1
|
+
(function ($) {
|
2
|
+
$.fn.tooltip = function (options) {
|
3
|
+
var timeout = null,
|
4
|
+
margin = 5;
|
5
|
+
|
6
|
+
// Defaults
|
7
|
+
var defaults = {
|
8
|
+
delay: 350
|
9
|
+
};
|
10
|
+
|
11
|
+
// Remove tooltip from the activator
|
12
|
+
if (options === "remove") {
|
13
|
+
this.each(function(){
|
14
|
+
$('#' + $(this).attr('data-tooltip-id')).remove();
|
15
|
+
$(this).off('mouseenter.tooltip mouseleave.tooltip');
|
16
|
+
});
|
17
|
+
return false;
|
18
|
+
}
|
19
|
+
|
20
|
+
options = $.extend(defaults, options);
|
21
|
+
|
22
|
+
|
23
|
+
return this.each(function(){
|
24
|
+
var tooltipId = Materialize.guid();
|
25
|
+
var origin = $(this);
|
26
|
+
origin.attr('data-tooltip-id', tooltipId);
|
27
|
+
|
28
|
+
// Create Text span
|
29
|
+
var tooltip_text = $('<span></span>').text(origin.attr('data-tooltip'));
|
30
|
+
|
31
|
+
// Create tooltip
|
32
|
+
var newTooltip = $('<div></div>');
|
33
|
+
newTooltip.addClass('material-tooltip').append(tooltip_text)
|
34
|
+
.appendTo($('body'))
|
35
|
+
.attr('id', tooltipId);
|
36
|
+
|
37
|
+
var backdrop = $('<div></div>').addClass('backdrop');
|
38
|
+
backdrop.appendTo(newTooltip);
|
39
|
+
backdrop.css({ top: 0, left:0 });
|
40
|
+
|
41
|
+
|
42
|
+
//Destroy previously binded events
|
43
|
+
origin.off('mouseenter.tooltip mouseleave.tooltip');
|
44
|
+
// Mouse In
|
45
|
+
var started = false, timeoutRef;
|
46
|
+
origin.on({
|
47
|
+
'mouseenter.tooltip': function(e) {
|
48
|
+
var tooltip_delay = origin.attr('data-delay');
|
49
|
+
tooltip_delay = (tooltip_delay === undefined || tooltip_delay === '') ?
|
50
|
+
options.delay : tooltip_delay;
|
51
|
+
timeoutRef = setTimeout(function(){
|
52
|
+
started = true;
|
53
|
+
newTooltip.velocity('stop');
|
54
|
+
backdrop.velocity('stop');
|
55
|
+
newTooltip.css({ display: 'block', left: '0px', top: '0px' });
|
56
|
+
|
57
|
+
// Set Tooltip text
|
58
|
+
newTooltip.children('span').text(origin.attr('data-tooltip'));
|
59
|
+
|
60
|
+
// Tooltip positioning
|
61
|
+
var originWidth = origin.outerWidth();
|
62
|
+
var originHeight = origin.outerHeight();
|
63
|
+
var tooltipPosition = origin.attr('data-position');
|
64
|
+
var tooltipHeight = newTooltip.outerHeight();
|
65
|
+
var tooltipWidth = newTooltip.outerWidth();
|
66
|
+
var tooltipVerticalMovement = '0px';
|
67
|
+
var tooltipHorizontalMovement = '0px';
|
68
|
+
var scale_factor = 8;
|
69
|
+
var targetTop, targetLeft, newCoordinates;
|
70
|
+
|
71
|
+
if (tooltipPosition === "top") {
|
72
|
+
// Top Position
|
73
|
+
targetTop = origin.offset().top - tooltipHeight - margin;
|
74
|
+
targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
|
75
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
76
|
+
|
77
|
+
tooltipVerticalMovement = '-10px';
|
78
|
+
backdrop.css({
|
79
|
+
borderRadius: '14px 14px 0 0',
|
80
|
+
transformOrigin: '50% 90%',
|
81
|
+
marginTop: tooltipHeight,
|
82
|
+
marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
|
83
|
+
});
|
84
|
+
}
|
85
|
+
// Left Position
|
86
|
+
else if (tooltipPosition === "left") {
|
87
|
+
targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
|
88
|
+
targetLeft = origin.offset().left - tooltipWidth - margin;
|
89
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
90
|
+
|
91
|
+
tooltipHorizontalMovement = '-10px';
|
92
|
+
backdrop.css({
|
93
|
+
width: '14px',
|
94
|
+
height: '14px',
|
95
|
+
borderRadius: '14px 0 0 14px',
|
96
|
+
transformOrigin: '95% 50%',
|
97
|
+
marginTop: tooltipHeight/2,
|
98
|
+
marginLeft: tooltipWidth
|
99
|
+
});
|
100
|
+
}
|
101
|
+
// Right Position
|
102
|
+
else if (tooltipPosition === "right") {
|
103
|
+
targetTop = origin.offset().top + originHeight/2 - tooltipHeight/2;
|
104
|
+
targetLeft = origin.offset().left + originWidth + margin;
|
105
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
106
|
+
|
107
|
+
tooltipHorizontalMovement = '+10px';
|
108
|
+
backdrop.css({
|
109
|
+
width: '14px',
|
110
|
+
height: '14px',
|
111
|
+
borderRadius: '0 14px 14px 0',
|
112
|
+
transformOrigin: '5% 50%',
|
113
|
+
marginTop: tooltipHeight/2,
|
114
|
+
marginLeft: '0px'
|
115
|
+
});
|
116
|
+
}
|
117
|
+
else {
|
118
|
+
// Bottom Position
|
119
|
+
targetTop = origin.offset().top + origin.outerHeight() + margin;
|
120
|
+
targetLeft = origin.offset().left + originWidth/2 - tooltipWidth/2;
|
121
|
+
newCoordinates = repositionWithinScreen(targetLeft, targetTop, tooltipWidth, tooltipHeight);
|
122
|
+
tooltipVerticalMovement = '+10px';
|
123
|
+
backdrop.css({
|
124
|
+
marginLeft: (tooltipWidth/2) - (backdrop.width()/2)
|
125
|
+
});
|
126
|
+
}
|
127
|
+
|
128
|
+
// Set tooptip css placement
|
129
|
+
newTooltip.css({
|
130
|
+
top: newCoordinates.y,
|
131
|
+
left: newCoordinates.x
|
132
|
+
});
|
133
|
+
|
134
|
+
// Calculate Scale to fill
|
135
|
+
scale_factor = tooltipWidth / 8;
|
136
|
+
if (scale_factor < 8) {
|
137
|
+
scale_factor = 8;
|
138
|
+
}
|
139
|
+
if (tooltipPosition === "right" || tooltipPosition === "left") {
|
140
|
+
scale_factor = tooltipWidth / 10;
|
141
|
+
if (scale_factor < 6)
|
142
|
+
scale_factor = 6;
|
143
|
+
}
|
144
|
+
|
145
|
+
newTooltip.velocity({ marginTop: tooltipVerticalMovement, marginLeft: tooltipHorizontalMovement}, { duration: 350, queue: false })
|
146
|
+
.velocity({opacity: 1}, {duration: 300, delay: 50, queue: false});
|
147
|
+
backdrop.css({ display: 'block' })
|
148
|
+
.velocity({opacity:1},{duration: 55, delay: 0, queue: false})
|
149
|
+
.velocity({scale: scale_factor}, {duration: 300, delay: 0, queue: false, easing: 'easeInOutQuad'});
|
150
|
+
|
151
|
+
|
152
|
+
}, tooltip_delay); // End Interval
|
153
|
+
|
154
|
+
// Mouse Out
|
155
|
+
},
|
156
|
+
'mouseleave.tooltip': function(){
|
157
|
+
// Reset State
|
158
|
+
started = false;
|
159
|
+
clearTimeout(timeoutRef);
|
160
|
+
|
161
|
+
// Animate back
|
162
|
+
setTimeout(function() {
|
163
|
+
if (started != true) {
|
164
|
+
newTooltip.velocity({
|
165
|
+
opacity: 0, marginTop: 0, marginLeft: 0}, { duration: 225, queue: false});
|
166
|
+
backdrop.velocity({opacity: 0, scale: 1}, {
|
167
|
+
duration:225,
|
168
|
+
queue: false,
|
169
|
+
complete: function(){
|
170
|
+
backdrop.css('display', 'none');
|
171
|
+
newTooltip.css('display', 'none');
|
172
|
+
started = false;}
|
173
|
+
});
|
174
|
+
}
|
175
|
+
},225);
|
176
|
+
}
|
177
|
+
});
|
178
|
+
});
|
179
|
+
};
|
180
|
+
|
181
|
+
var repositionWithinScreen = function(x, y, width, height) {
|
182
|
+
var newX = x
|
183
|
+
var newY = y;
|
184
|
+
|
185
|
+
if (newX < 0) {
|
186
|
+
newX = 4;
|
187
|
+
} else if (newX + width > window.innerWidth) {
|
188
|
+
newX -= newX + width - window.innerWidth;
|
189
|
+
}
|
190
|
+
|
191
|
+
if (newY < 0) {
|
192
|
+
newY = 4;
|
193
|
+
} else if (newY + height > window.innerHeight + $(window).scrollTop) {
|
194
|
+
newY -= newY + height - window.innerHeight;
|
195
|
+
}
|
196
|
+
|
197
|
+
return {x: newX, y: newY};
|
198
|
+
};
|
199
|
+
|
200
|
+
$(document).ready(function(){
|
201
|
+
$('.tooltipped').tooltip();
|
202
|
+
});
|
203
|
+
}( jQuery ));
|