74249687
Luigi Serra
Cross browser con...
|
1
2
3
4
5
6
|
(function ($) {
$(document).ready(function() {
// jQuery reverse
$.fn.reverse = [].reverse;
|
a1a3bc73
Luigi Serra
graphs updates
|
7
8
|
// Hover behaviour: make sure this doesn't work on .click-to-toggle FABs!
$(document).on('mouseenter.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
|
74249687
Luigi Serra
Cross browser con...
|
9
10
|
var $this = $(this);
openFABMenu($this);
|
74249687
Luigi Serra
Cross browser con...
|
11
|
});
|
a1a3bc73
Luigi Serra
graphs updates
|
12
|
$(document).on('mouseleave.fixedActionBtn', '.fixed-action-btn:not(.click-to-toggle)', function(e) {
|
74249687
Luigi Serra
Cross browser con...
|
13
14
15
16
|
var $this = $(this);
closeFABMenu($this);
});
|
a1a3bc73
Luigi Serra
graphs updates
|
17
18
19
20
21
22
23
24
25
26
27
|
// Toggle-on-click behaviour.
$(document).on('click.fixedActionBtn', '.fixed-action-btn.click-to-toggle > a', function(e) {
var $this = $(this);
var $menu = $this.parent();
if ($menu.hasClass('active')) {
closeFABMenu($menu);
} else {
openFABMenu($menu);
}
});
|
74249687
Luigi Serra
Cross browser con...
|
28
29
30
31
|
});
$.fn.extend({
openFAB: function() {
|
a1a3bc73
Luigi Serra
graphs updates
|
32
|
openFABMenu($(this));
|
74249687
Luigi Serra
Cross browser con...
|
33
34
|
},
closeFAB: function() {
|
a1a3bc73
Luigi Serra
graphs updates
|
35
|
closeFABMenu($(this));
|
74249687
Luigi Serra
Cross browser con...
|
36
37
38
39
40
41
42
|
}
});
var openFABMenu = function (btn) {
$this = btn;
if ($this.hasClass('active') === false) {
|
a1a3bc73
Luigi Serra
graphs updates
|
43
44
45
46
47
48
49
50
51
52
53
|
// Get direction option
var horizontal = $this.hasClass('horizontal');
var offsetY, offsetX;
if (horizontal === true) {
offsetX = 40;
} else {
offsetY = 40;
}
|
74249687
Luigi Serra
Cross browser con...
|
54
55
|
$this.addClass('active');
$this.find('ul .btn-floating').velocity(
|
a1a3bc73
Luigi Serra
graphs updates
|
56
|
{ scaleY: ".4", scaleX: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
|
74249687
Luigi Serra
Cross browser con...
|
57
58
59
|
{ duration: 0 });
var time = 0;
|
a1a3bc73
Luigi Serra
graphs updates
|
60
|
$this.find('ul .btn-floating').reverse().each( function () {
|
74249687
Luigi Serra
Cross browser con...
|
61
|
$(this).velocity(
|
a1a3bc73
Luigi Serra
graphs updates
|
62
|
{ opacity: "1", scaleX: "1", scaleY: "1", translateY: "0", translateX: '0'},
|
74249687
Luigi Serra
Cross browser con...
|
63
64
65
66
67
68
69
70
|
{ duration: 80, delay: time });
time += 40;
});
}
};
var closeFABMenu = function (btn) {
$this = btn;
|
a1a3bc73
Luigi Serra
graphs updates
|
71
72
73
74
75
76
77
78
79
80
|
// Get direction option
var horizontal = $this.hasClass('horizontal');
var offsetY, offsetX;
if (horizontal === true) {
offsetX = 40;
} else {
offsetY = 40;
}
|
74249687
Luigi Serra
Cross browser con...
|
81
82
83
84
|
$this.removeClass('active');
var time = 0;
$this.find('ul .btn-floating').velocity("stop", true);
$this.find('ul .btn-floating').velocity(
|
a1a3bc73
Luigi Serra
graphs updates
|
85
|
{ opacity: "0", scaleX: ".4", scaleY: ".4", translateY: offsetY + 'px', translateX: offsetX + 'px'},
|
74249687
Luigi Serra
Cross browser con...
|
86
87
88
89
90
91
|
{ duration: 80 }
);
};
}( jQuery ));
|