PluginProbe
Float menu – awesome floating side menu / 3.5.2
Float menu – awesome floating side menu v3.5.2
7.2.5 trunk 2.1 2.2 3.0.1 3.1 3.2.2 3.3.1 3.5 3.5.1 3.5.2 3.5.3. 3.5.4 4.0 4.1 4.1.1 4.2 4.3 4.3.1 4.3.2 5.0 5.0.1 5.0.2 5.0.3 5.1 All 57 releases
float-menu / assets / js / floatMenu.js

floatMenu.js in Float menu – awesome floating side menu 3.5.2, at assets/js/floatMenu.js

1,183 lines 44.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*! ========= INFORMATION ============================
2 - document: Float Menu
3 - author: Wow-Company
4 - url: https://wow-estore.com/item/float-menu-pro/
5 ==================================================== */
6
7 "use strict";
8
9 (function ($) {
10
11 var defaults = {
12 // Main
13 position: ["left", "center"],
14 offset: [0, 0],
15 buttonShape: "round",
16 buttonColor: "custom",
17 buttonOverColor: "custom",
18 iconColor: "white",
19 iconOverColor: "white",
20 labelColor: "match",
21 labelTextColor: "match",
22 labelEffect: "slide-out-fade",
23 labelAnimate: "default",
24 labelConnected: false,
25 labelsOn: true,
26 sideSpace: false,
27 buttonSpace: false,
28 labelSpace: false,
29 mobileEnable: false,
30 mobileScreen: 768,
31 // Subbar
32 subPosition: ["circular", 100, -90, 90],
33 subEffect: ["slide", 30],
34 subAnimate: [400, "easeOutQuad"],
35 subSpace: false,
36 subOpen: "mouseover",
37 // Window
38 windowPosition: ["center", "center"],
39 windowOffset: [0, 0],
40 windowCorners: "match",
41 windowColor: "match",
42 windowShadow: true,
43 // Other
44 showAfterPosition: false,
45 barAnimate: [250, "easeOutQuad"],
46 hideUnderWidth: false,
47 shareTarget: "default"
48 };
49 var labelAnimateDefaults = {
50 "default": [400, "easeOutQuad"],
51 "fade": [200, "easeOutQuad"],
52 "slide-in-in": {
53 show: [400, "easeOutQuad"],
54 hide: [400, "swing"]
55 }
56 };
57
58
59 var methods = {
60 "build": build,
61 "destroy": destroy
62 };
63
64 $.fn.floatingMenu = function (arg) {
65 if (typeof arg === "object" || !arg) {
66 build.apply(this, arguments);
67 } else if (methods[arg]) {
68 methods[arg].apply(this, Array.prototype.slice.call(arguments, 1));
69 } else {
70 $.error("The method " + arg + " does not exist in Float Menu.");
71 }
72 };
73
74 function build(options) {
75 var settings = createSettings(options);
76
77 return this.each(function () {
78 var sidebar = $(this);
79
80 if (sidebar.data("fm-built")) destroy.apply(this);
81 sidebar.data("fm-built", true);
82
83 // VARS
84 var bar = sidebar.children(".fm-bar");
85 var barList = bar.children();
86 var sbwindow = sidebar.children(".fm-window");
87
88 var $window = $(window);
89 var $document = $(document);
90
91 var barVisible = true;
92 var right = false;
93 var csub = null;
94 var cwindow = null;
95 var nextMargins = [];
96
97
98 // INIT
99 if (settings.position[0] === "right") {
100 right = true;
101 bar.addClass("fm-right");
102 }
103
104 if (settings.buttonShape !== "square") bar.addClass("fm-" + settings.buttonShape);
105
106 if (settings.labelConnected) bar.addClass("fm-connected");
107
108 if (settings.buttonColor !== "custom") bar.addClass("fm-" + settings.buttonColor + "-button");
109 if (settings.buttonOverColor !== "custom") bar.addClass("fm-" + settings.buttonOverColor + "-button-over");
110
111 if (settings.iconColor !== "custom") bar.addClass("fm-" + settings.iconColor + "-icon");
112 if (settings.iconOverColor !== "custom") bar.addClass("fm-" + settings.iconOverColor + "-icon-over");
113
114 if (settings.labelColor !== "custom") bar.addClass("fm-" + settings.labelColor + "-label");
115 if (settings.labelTextColor !== "custom") bar.addClass("fm-" + settings.labelTextColor + "-label-text");
116
117 if (settings.sideSpace) bar.addClass("fm-side-space");
118 if (settings.buttonSpace) bar.addClass("fm-button-space");
119 if (settings.labelSpace) bar.addClass("fm-label-space");
120
121 if (settings.windowCorners === "round") sbwindow.addClass("fm-round");
122 if (settings.windowColor !== "custom") sbwindow.addClass("fm-" + settings.windowColor);
123 if (settings.windowShadow) sbwindow.addClass("fm-winshadow");
124
125
126 buildList(bar);
127
128 // Subbar animate fix.
129 barList.each(function (ind) {
130 nextMargins[ind] = getInt(barList.eq(ind).css("margin-top"));
131 });
132
133 sbwindow.children(".fm-shadow").on("click", closeWindow);
134
135 sbwindow.children(".fm-panel").each(buildPanel);
136
137 resize();
138
139 $window.on("resize.superSidebar", resize);
140
141 if (settings.showAfterPosition) {
142 if ($window.scrollTop() < settings.showAfterPosition) {
143 bar.css("opacity", 0).addClass("fm-hide");
144 barVisible = false;
145 }
146
147 $window.on("scroll.superSidebar", function () {
148 if ($window.scrollTop() < settings.showAfterPosition) {
149 if (barVisible) hideBar();
150 } else {
151 if (!barVisible) showBar();
152 }
153 });
154 }
155
156 bar.addClass("fm-css-anim");
157
158 sidebar.addClass("fm-ready");
159
160
161 // FUNCTIONS
162 function buildList(list) {
163 list.children().each(function (i) {
164 if ($(this).hasClass("fm-sub")) buildSub(this, i);
165 else buildButton(this);
166 });
167 }
168
169 function buildButton(btn) {
170 var button = $(btn);
171 var link = button.children("a");
172 var icon = link.children(".fm-icon");
173 var label = link.children(".fm-label");
174 var mask, hit = null;
175
176 var linkClick = 0;
177 var screen = $(window).width();
178
179 var maskHtml = '<div class="fm-mask"></div>';
180 var hitHtml = '<div class="fm-hit"></div>';
181
182 var iw, lw;
183 var side = right ? "right" : "left";
184 var dist = 40;
185 var maskOff = false;
186 var start = {}, show = {}, end = {};
187 var showLabel, hideLabel;
188
189 var showTime = settings.labelAnimate.show[0];
190 var showEase = settings.labelAnimate.show[1];
191 var hideTime = settings.labelAnimate.hide[0];
192 var hideEase = settings.labelAnimate.hide[1];
193
194 if (settings.labelsOn && label.length) {
195 iw = getInt(icon.css("width"));
196 lw = label.outerWidth(true);
197
198 if (settings.buttonShape === "round" || settings.buttonShape === "rounded") maskOff = true;
199
200 if (!settings.labelConnected && (settings.labelSpace || settings.buttonShape === "round" || settings.buttonShape === "rounded" || settings.buttonShape === "rounded-out"))
201 hit = $(hitHtml).appendTo(link);
202
203 switch (settings.labelEffect) {
204 case "fade":
205 start = {"opacity": 0};
206 show = {"opacity": 1};
207
208 label.css(start);
209
210 showLabel = function () {
211 if (hit) hit.addClass("fm-show");
212 label.velocity("stop").addClass("fm-show").velocity(show, showTime, showEase);
213 };
214 hideLabel = function () {
215 label.velocity("stop").velocity(start, hideTime, hideEase, function () {
216 label.removeClass("fm-show");
217 if (hit) hit.removeClass("fm-show");
218 });
219 };
220 break;
221 case "slide-out":
222 case "slide-out-fade":
223 mask = link.wrap(maskHtml).parent();
224 mask.css("width", iw);
225 if (maskOff) mask.addClass("fm-off");
226
227 start[side] = -lw + iw;
228 if (settings.labelConnected) show[side] = 0;
229 else show[side] = iw;
230
231 if (settings.labelEffect === "slide-out-fade") {
232 start["opacity"] = 0;
233 show["opacity"] = 1;
234 }
235
236 label.css(start);
237
238 showLabel = function () {
239 mask.css("width", iw + lw);
240 if (maskOff) mask.removeClass("fm-off");
241 if (hit) hit.addClass("fm-show");
242 label.velocity("stop").addClass("fm-show").velocity(show, showTime, showEase);
243 };
244 hideLabel = function () {
245 label.velocity("stop").velocity(start, hideTime, hideEase, function () {
246 label.removeClass("fm-show");
247 mask.css("width", iw);
248 if (maskOff) mask.addClass("fm-off");
249 if (hit) hit.removeClass("fm-show");
250 });
251 };
252 break;
253 case "slide-in":
254 start = {"opacity": 0};
255 start[side] = iw + dist;
256 show = {"opacity": 1};
257 show[side] = iw;
258
259 label.css(start);
260
261 showLabel = function () {
262 if (hit) hit.addClass("fm-show");
263 label.velocity("stop").addClass("fm-show").velocity(show, showTime, showEase);
264 };
265 hideLabel = function () {
266 label.velocity("stop").velocity(start, hideTime, hideEase, function () {
267 label.removeClass("fm-show");
268 if (hit) hit.removeClass("fm-show");
269 });
270 };
271 break;
272 case "slide-out-out":
273 case "slide-in-in":
274 mask = link.wrap(maskHtml).parent();
275 mask.css("width", iw);
276 if (maskOff) mask.addClass("fm-off");
277
278 if (settings.labelEffect === "slide-out-out") {
279 start[side] = -lw + iw;
280 show[side] = iw;
281 end[side] = iw + dist;
282 } else {
283 start[side] = iw + dist;
284 show[side] = iw;
285 end[side] = -lw + iw;
286 }
287 start["opacity"] = 0;
288 show["opacity"] = 1;
289 end["opacity"] = 0;
290
291 showLabel = function () {
292 mask.css("width", iw + lw + dist);
293 if (maskOff) mask.removeClass("fm-off");
294 if (hit) hit.addClass("fm-show");
295 label.velocity("stop").css(start).addClass("fm-show").velocity(show, showTime, showEase, function () {
296 mask.css("width", iw + lw);
297 });
298 };
299 hideLabel = function () {
300 mask.css("width", iw + lw + dist);
301 label.velocity("stop").velocity(end, hideTime, hideEase, function () {
302 label.removeClass("fm-show");
303 mask.css("width", iw);
304 if (maskOff) mask.addClass("fm-off");
305 if (hit) hit.removeClass("fm-show");
306 });
307 };
308 break;
309 default:
310 showLabel = function () {
311 if (hit) hit.addClass("fm-show");
312 label.addClass("fm-show");
313 };
314 hideLabel = function () {
315 label.removeClass("fm-show");
316 if (hit) hit.removeClass("fm-show");
317 };
318 break;
319 }
320
321
322 if (settings.mobileEnable == true && settings.mobileScreen >= screen) {
323
324 link.on('touchend', function (e) {
325
326 if (linkClick == 0) {
327 e.preventDefault();
328 showLabel();
329 linkClick = 1;
330 setTimeout(function () {
331 hideLabel();
332 linkClick = 0;
333 }, 3000);
334 return;
335 } else if (linkClick == 1) {
336 hideLabel();
337 linkClick = 0;
338 }
339 });
340 } else {
341 link.on("mouseenter", showLabel);
342 link.on("mouseleave", hideLabel);
343 }
344 }
345
346
347 var shareVal = link.data("share");
348 var shareData;
349 var shareUrl;
350 var shareTarget;
351 var href;
352 var labelShow;
353
354 if (shareVal) {
355 if (shareVal === "pinterest") {
356 link.on("click", pinterestShare);
357 } else {
358 shareData = settings.shareServices[shareVal];
359
360 if (shareData) {
361 shareUrl = shareData.url.replace("{URL}", PAGE_URL)
362 .replace("{TITLE}", PAGE_TITLE);
363
364 link.attr("href", shareUrl);
365
366 if (shareData.target === "app") {
367 link.attr("target", "_self");
368 } else {
369 if (settings.shareTarget === "default") shareTarget = shareData.target;
370 else shareTarget = settings.shareTarget;
371
372 if (shareTarget === "popup") {
373 link.on("click", {"url": shareUrl, "params": shareData.popup}, sharePopup);
374 } else {
375 link.attr("target", "_blank");
376 }
377 }
378 } else {
379 warn('There is no share data for "' + shareVal + '".');
380 }
381 }
382 } else {
383 href = link.attr("href");
384
385 if (href && href.indexOf("fm-popup") > -1 && href !== "#") {
386 link.on("click", function () {
387 openWindow(href);
388 return false;
389 });
390 }
391 }
392
393 labelShow = link.attr("data-label");
394
395 if (labelShow === 'show') {
396 showLabel();
397 }
398
399 }
400
401 function buildSub(sub, ind) {
402 var sub = $(sub);
403 var icon = sub.children(".fm-icon");
404 var list = sub.children("ul");
405 var buttonList = list.children();
406 var hit = null;
407 var nextButton = null;
408
409 var hitHtml = '<div class="fm-subhit"></div>';
410
411 var position = settings.subPosition[0];
412 var effect = settings.subEffect[0];
413 var side = right ? "right" : "left";
414 var total = buttonList.length;
415 var iw = getInt(icon.css("width"));
416 var ih = getInt(icon.css("height"));
417 var positions = [];
418 var status = null;
419 var start = {}, show = {};
420 var interval;
421 var showList, hideList;
422 var i;
423 var nextOffset = 0;
424 var prevOffset = 0;
425 var nextMargin;
426 var buttonMargin;
427 var barMargin;
428 var subOpen = false;
429
430 var showTime = settings.subAnimate.show[0];
431 var showEase = settings.subAnimate.show[1];
432 var hideTime = settings.subAnimate.hide[0];
433 var hideEase = settings.subAnimate.hide[1];
434
435
436 buildList(list);
437
438 if (position === "side") sub.addClass("fm-side");
439 if (settings.subSpace) sub.addClass("fm-sub-space");
440
441 if (effect === "linear-slide" || position === "circular")
442 sub.addClass("fm-posabs");
443
444 if ((position === "under" && effect === "linear-slide") ||
445 (position === "circular" && effect === "slide") ||
446 (position === "circular" && effect === "linear-slide")) {
447 buttonList.each(function (i) {
448 $(this).css("z-index", 100 - i);
449 });
450 }
451
452 if (barList[ind + 1]) {
453 nextButton = barList.eq(ind + 1);
454 //nextMargin = getInt(nextButton.css("margin-top"));
455 }
456
457 if (position === "circular") {
458 sub.addClass("fm-circular");
459
460 var r = settings.subPosition[1];
461 var sa = settings.subPosition[2];
462 var ea = settings.subPosition[3];
463
464 var startRad = sa * Math.PI / 180;
465 var endRad = ea * Math.PI / 180;
466 var stepRad = (endRad - startRad) / (total - 1);
467 var a, s, t, p;
468
469 buttonList.each(function (i) {
470 a = i * stepRad + startRad;
471 s = Math.round(r * Math.cos(a));
472 t = Math.round(r * Math.sin(a));
473
474 p = {"top": t};
475 p[side] = s;
476 $(this).css(p);
477 positions[i] = [s, t];
478 });
479
480 hit = $(hitHtml).appendTo(sub);
481 hit.css({
482 "width": r + iw,
483 "height": 2 * r + iw,
484 "border-radius": right ? r + "px 0 0 " + r + "px" : "0 " + r + "px " + r + "px 0",
485 "top": -r
486 });
487
488 buttonMargin = getInt(barList.eq(0).css("margin-bottom"));
489
490 if (ind !== 0) {
491 prevOffset = r + buttonMargin;
492 barMargin = getInt(bar.css("margin-top"));
493 sub.css("margin-top", buttonMargin);
494 }
495
496 if (nextButton) {
497 nextOffset = r + buttonMargin;
498 }
499 } else {
500 if (effect === "linear-slide") {
501 var c = 0;
502 buttonList.each(function (i) {
503 var btn = $(this);
504 btn.css("top", c);
505 positions[i] = c;
506 c += getInt(btn.css("height")) + getInt(btn.css("margin-bottom"));
507 });
508
509 list.css({"width": iw, "height": c});
510 }
511
512 hit = $(hitHtml).appendTo(sub);
513 if (position === "side")
514 hit.css({"width": iw + getInt(list.css("margin-" + side)), "height": ih});
515 else
516 hit.css({"width": iw, "height": ih + getInt(list.css("margin-top"))});
517
518 if (position === "under" && nextButton) {
519 nextOffset = list.outerHeight(true) + getInt(nextButton.css("margin-top")) + getInt(list.css("margin-top"));
520 }
521 }
522
523
524 list.addClass("fm-hide");
525
526 switch (effect) {
527 case "fade":
528 start = {"opacity": 0};
529 show = {"opacity": 1};
530
531 list.css(start);
532
533 showList = function () {
534 list.velocity("stop").removeClass("fm-hide").velocity(show, showTime, showEase);
535 };
536 hideList = function () {
537 list.velocity("stop").velocity(start, hideTime, hideEase, function () {
538 list.addClass("fm-hide");
539 });
540 };
541 break;
542 case "slide":
543 if (position === "circular") {
544 start = {"top": 0, "opacity": 0};
545 start[side] = 0;
546 buttonList.css(start);
547
548 showList = function () {
549 list.removeClass("fm-hide");
550 buttonList.each(function (i) {
551 show = {"top": positions[i][1], "opacity": 1};
552 show[side] = positions[i][0];
553 $(this).velocity("stop").velocity(show, showTime, showEase);
554 });
555 };
556 hideList = function () {
557 buttonList.each(function (i) {
558 $(this).velocity("stop").velocity(start, hideTime, hideEase, function () {
559 if (i === total - 1) list.addClass("fm-hide");
560 });
561 });
562 };
563 } else {
564 if (position === "side") {
565 start[side] = 0;
566 show[side] = iw;
567 } else {
568 start = {"top": 0};
569 show = {"top": 42};
570 }
571 start["opacity"] = 0;
572 show["opacity"] = 1;
573
574 list.css(start);
575
576 showList = function () {
577 list.velocity("stop").removeClass("fm-hide").velocity(show, showTime, showEase);
578 };
579 hideList = function () {
580 list.velocity("stop").velocity(start, hideTime, hideEase, function () {
581 list.addClass("fm-hide");
582 });
583 };
584 }
585 break;
586 case "linear-fade":
587 start = {"opacity": 0};
588 show = {"opacity": 1};
589
590 buttonList.css(start);
591
592 showList = function () {
593 status = "show";
594 list.removeClass("fm-hide");
595 stopInterval();
596 i = 0;
597 interval = setInterval(function () {
598 buttonList.eq(i).velocity("stop").velocity(show, showTime, showEase);
599 if (i === total - 1) stopInterval();
600 else i++;
601 }, settings.subEffect[1]);
602 };
603 hideList = function () {
604 status = "hide";
605 stopInterval();
606 i = total - 1;
607 interval = setInterval(function () {
608 var bi = i;
609 buttonList.eq(i).velocity("stop").velocity(start, showTime, showEase, function () {
610 if (status === "hide" && bi === 0) list.addClass("fm-hide");
611 });
612 if (i === 0) stopInterval();
613 else i--;
614 }, settings.subEffect[1]);
615 };
616 break;
617 case "linear-slide":
618 var first, last, step;
619
620 if (position === "side") start[side] = -iw;
621 else if (position === "circular") {
622 start = {"top": 0};
623 start[side] = 0;
624 } else start = {"top": -ih};
625 start["opacity"] = 0;
626
627 buttonList.css(start);
628
629 showList = function () {
630 status = "show";
631 list.removeClass("fm-hide");
632 stopInterval();
633 i = 0;
634 interval = setInterval(function () {
635 if (position === "side") show[side] = 0;
636 else if (position === "circular") {
637 show = {"top": positions[i][1]};
638 show[side] = positions[i][0];
639 } else show = {"top": positions[i]};
640 show["opacity"] = 1;
641
642 buttonList.eq(i).velocity("stop").velocity(show, showTime, showEase);
643 if (i === total - 1) stopInterval();
644 else i++;
645 }, settings.subEffect[1]);
646 };
647 hideList = function () {
648 status = "hide";
649
650 if (position === "side" || position === "circular") {
651 first = 0;
652 last = total - 1;
653 step = 1;
654 } else {
655 first = total - 1;
656 last = 0;
657 step = -1;
658 }
659
660 stopInterval();
661 i = first;
662 interval = setInterval(function () {
663 var bi = i;
664 buttonList.eq(i).velocity("stop").velocity(start, showTime, showEase, function () {
665 if (status === "hide" && bi === last) list.addClass("fm-hide");
666 });
667 if (i === last) stopInterval();
668 else i += step;
669 }, settings.subEffect[1]);
670 };
671 break;
672 default:
673 showList = function () {
674 list.removeClass("fm-hide");
675 };
676 hideList = function () {
677 list.addClass("fm-hide");
678 };
679 break;
680 }
681
682 function stopInterval() {
683 clearInterval(interval);
684 }
685
686 function showSub() {
687 showList();
688 if (hit) hit.addClass("fm-show");
689
690 if (prevOffset) {
691 bar.velocity("stop").velocity({"margin-top": barMargin - prevOffset + buttonMargin}, showTime, showEase);
692 sub.velocity("stop").velocity({"margin-top": prevOffset}, showTime, showEase);
693 }
694
695 if (nextOffset) {
696 nextButton.velocity("stop").velocity({"margin-top": nextOffset}, showTime, showEase);
697 }
698
699 subOpen = true;
700 csub = sub;
701 }
702
703 function hideSub() {
704 hideList();
705 if (hit) hit.removeClass("fm-show");
706
707 if (prevOffset) {
708 bar.velocity("stop").velocity({"margin-top": barMargin}, showTime, showEase);
709 sub.velocity("stop").velocity({"margin-top": buttonMargin}, showTime, showEase);
710 }
711
712 if (nextOffset) {
713 nextButton.velocity("stop").velocity({"margin-top": nextMargins[ind + 1]}, showTime, showEase);
714 }
715
716 subOpen = false;
717 csub = null;
718 }
719
720 sub.show = showSub;
721 sub.hide = hideSub;
722
723 if (settings.subOpen === "click") {
724 icon.on("click", function (event) {
725 if (subOpen) {
726 hideSub();
727 } else {
728 if (csub) {
729 csub.hide();
730 }
731 showSub();
732 }
733 event.stopPropagation();
734 });
735
736 $document.on("click", function (event) {
737 if (subOpen && !cwindow && !$(event.target).closest(sub).length) {
738 hideSub();
739 }
740 });
741 } else {
742 sub.on("mouseenter", showSub);
743 sub.on("mouseleave", hideSub);
744 }
745 }
746
747 function buildPanel() {
748 var panel = $(this);
749 panel.find(".fm-close").on("click", function (event) {
750 closeWindow();
751 event.stopPropagation();
752 });
753
754 }
755
756
757 function openWindow(name) {
758 sbwindow.addClass("fm-show");
759 cwindow = $(name).addClass("fm-show");
760 posWindow(cwindow);
761 }
762
763 function closeWindow() {
764 sbwindow.removeClass("fm-show");
765 cwindow.removeClass("fm-show");
766 cwindow = null;
767 }
768
769 function position() {
770 posBar();
771 if (cwindow) posWindow(cwindow);
772 }
773
774 function resize() {
775 position();
776
777 if (settings.hideUnderWidth) {
778 if ($window.width() < settings.hideUnderWidth) {
779 sidebar.addClass("fm-vhide");
780 } else {
781 sidebar.removeClass("fm-vhide");
782 }
783 }
784 }
785
786 function posBar() {
787 posObject(bar, settings.position, settings.offset);
788 }
789
790 function posWindow(win) {
791 var pos, off;
792
793 if (win.data("position")) {
794 pos = win.data("position").split("-");
795 if (!pos[1]) pos[1] = defaults.windowPosition[1];
796 } else {
797 pos = settings.windowPosition;
798 }
799
800 if (win.data("offset")) {
801 off = splitOffset(win.data("offset"));
802 } else {
803 off = settings.windowOffset;
804 }
805
806 posObject(win, pos, off);
807 }
808
809 function posObject(tar, pos, off) {
810 if (pos) {
811 var ww = $window.width();
812 var wh = $window.height();
813 var tw = tar.outerWidth(true);
814 var th = tar.outerHeight(true);
815 var x, y;
816 var p;
817
818 if (typeof pos[0] === "number") x = {"left": pos[0] + off[0]};
819 else if (typeof pos[0] === "string") {
820 if (pos[0].indexOf("%") !== -1) {
821 p = getInt(pos[0].split("%")[0]);
822 x = {"left": p / 100 * ww + off[0]};
823 } else {
824 if (pos[0] === "left") x = {"left": 0 + off[0]};
825 else if (pos[0] === "center") x = {"left": (ww - tw) / 2 + off[0]};
826 else if (pos[0] === "right") x = {"right": 0 + off[0]};
827
828 else x = {"left": getInt(pos[0]) + off[0]};
829 }
830 }
831
832 if (typeof pos[1] === "number") y = {"top": pos[1] + off[1]};
833 else if (typeof pos[1] === "string") {
834 if (pos[1].indexOf("%") !== -1) {
835 p = getInt(pos[1].split("%")[0]);
836 y = {"top": p / 100 * wh + off[1]};
837 } else {
838 if (pos[1] === "top") y = {"top": 0 + off[1]};
839 else if (pos[1] === "center") y = {"top": (wh - th) / 2 + off[1]};
840 else if (pos[1] === "bottom") y = {"bottom": 0 + off[1]};
841
842 else y = {"top": getInt(pos[1]) + off[1]};
843 }
844 }
845
846 if (x.left) x.left = Math.round(x.left);
847 if (x.right) x.right = Math.round(x.right);
848
849 if (y.top) y.top = Math.round(y.top);
850 if (y.bottom) y.bottom = Math.round(y.bottom);
851
852 tar.css($.extend({}, x, y));
853 }
854 }
855
856 function pinterestShare(event) {
857 $("body").append('<script src="https://assets.pinterest.com/js/pinmarklet.js" type="text/javascript"></script>');
858 event.preventDefault();
859 }
860
861 function sharePopup(event) {
862 var url = event.data.url;
863 var params = event.data.params;
864 var winLeft;
865 var winParams;
866
867 if (params.left === "center") {
868 winLeft = ($window.width() - params.width) / 2;
869 } else {
870 winLeft = params.left;
871 }
872
873 winParams = "menubar=no,toolbar=no,location=no,scrollbars=no,status=no,resizable=yes,width=" + params.width + ",height=" + params.height + ",top=" + params.top + ",left=" + winLeft;
874
875 window.open(url, "sbShareWindow", winParams);
876
877 event.preventDefault();
878 }
879
880 function showBar() {
881 bar.removeClass("fm-hide");
882 bar.velocity("stop").velocity({"opacity": 1}, settings.barAnimate.show[0], settings.barAnimate.show[1]);
883 barVisible = true;
884 }
885
886 function hideBar() {
887 bar.velocity("stop").velocity({"opacity": 0}, settings.barAnimate.show[0], settings.barAnimate.show[1], function () {
888 bar.addClass("fm-hide");
889 });
890 barVisible = false;
891 }
892 });
893 }
894
895 function destroy() {
896 return this.each(function () {
897 var sidebar = $(this);
898 var bar, sbwindow;
899
900 if (sidebar.data("fm-built")) {
901 sidebar.data("fm-built", false);
902
903 bar = sidebar.children(".fm-bar");
904 sbwindow = sidebar.children(".fm-window");
905
906 bar.attr("class", "fm-bar").removeAttr("style");
907 sbwindow.attr("class", "fm-window");
908
909 destroyList(bar);
910
911 sbwindow.removeClass("fm-show");
912 sbwindow.children(".fm-shadow").off("click");
913 sbwindow.children(".fm-panel").removeClass("fm-show").removeAttr("style").each(destroyPanel);
914
915 $(window).off("resize.superSidebar scroll.superSidebar");
916
917 sidebar.removeClass("fm-ready");
918 }
919
920 function destroyList(list) {
921 list.children().each(function () {
922 if ($(this).hasClass("fm-sub")) destroySub(this);
923 else destroyButton(this);
924 });
925 }
926
927 function destroyButton(btn) {
928 var button = $(btn);
929 var link = button.find("a");
930 var label = link.children(".fm-label");
931
932 if (link.data("share")) link.removeAttr("href target");
933
934 link.children(".fm-hit").remove();
935
936 if (button.children(".fm-mask").length) link.unwrap();
937
938 label.removeAttr("style");
939
940 link.off("mouseenter mouseleave click");
941 }
942
943 function destroySub(sub) {
944 var sub = $(sub);
945 var list = sub.children("ul");
946
947 sub.removeClass("fm-side fm-circular fm-sub-space fm-posabs");
948
949 list.removeClass("fm-hide");
950 list.removeAttr("style");
951 list.children().removeAttr("style");
952
953 sub.children(".fm-subhit").remove();
954
955 sub.off("mouseenter mouseleave");
956 }
957
958 function destroyPanel() {
959 var panel = $(this);
960
961 panel.find(".fm-close").off("click");
962
963 var form = panel.find("form");
964 if (form.length) destroyForm(form);
965 }
966
967 function destroyForm(form) {
968 var fieldList = form.find("input, textarea");
969
970 form.find(".fm-submit").off("click");
971 form.off("submit");
972
973 fieldList.removeClass("fm-formerror").off("focus");
974 fieldList.each(function () {
975 $(this).val("");
976 });
977
978 form.find(".fm-status").attr("class", "fm-status");
979 }
980 });
981 }
982
983 function createSettings(options) {
984 var settings = $.extend({}, defaults, options);
985
986 if (typeof settings.position === "string") {
987 settings.position = settings.position.split("-");
988 }
989 if (settings.position[0] === "center") {
990 settings.position[0] = defaults.position[0];
991 warn('Bar horizontal position cannot be "center". Horizontal position reset to "left".');
992 }
993 if (!settings.position[1]) {
994 settings.position[1] = defaults.position[1];
995 }
996
997 if (settings.offset === 0 || settings.offset === false) {
998 settings.offset = [0, 0];
999 } else if (typeof settings.offset === "string") {
1000 settings.offset = splitOffset(settings.offset);
1001 }
1002
1003 if (!options.buttonShape && options.shape) {
1004 settings.buttonShape = settings.shape;
1005 }
1006 if (settings.buttonShape !== "square") {
1007 if (settings.buttonShape !== "round" && settings.buttonShape !== "rounded" && settings.buttonShape !== "rounded-out") {
1008 settings.buttonShape = "square";
1009 }
1010 }
1011
1012 if (!options.buttonColor && options.color) {
1013 settings.buttonColor = settings.color;
1014 }
1015 if (settings.buttonColor === "default") {
1016 settings.buttonColor = "custom";
1017 }
1018
1019 if (!options.buttonOverColor && options.overColor) {
1020 settings.buttonOverColor = settings.overColor;
1021 }
1022 if (settings.buttonOverColor === "default") {
1023 settings.buttonOverColor = "custom";
1024 }
1025
1026 if (settings.labelColor === "match") {
1027 settings.labelColor = settings.buttonOverColor;
1028 }
1029 if (settings.labelTextColor === "match") {
1030 settings.labelTextColor = settings.iconOverColor;
1031 }
1032
1033 if (settings.labelEffect === "slide") settings.labelEffect = "slide-out";
1034 if (settings.labelEffect === "slide-in-fade") settings.labelEffect = "slide-in";
1035
1036 if (!options.labelAnimate && options.labelAnim) {
1037 settings.labelAnimate = settings.labelAnim;
1038 }
1039 if (settings.labelAnimate === "default") {
1040 if (labelAnimateDefaults[settings.labelEffect]) {
1041 settings.labelAnimate = labelAnimateDefaults[settings.labelEffect];
1042 } else {
1043 settings.labelAnimate = labelAnimateDefaults[0];
1044 }
1045 }
1046 settings.labelAnimate = extendAnimateSetting(settings.labelAnimate);
1047
1048 if (settings.labelConnected) {
1049 if (settings.labelEffect === "slide-in" || settings.labelEffect === "slide-out-out" || settings.labelEffect === "slide-in-in") {
1050 settings.labelConnected = false;
1051 warn('"labelConnected: true" incompatible with "labelEffect: ' + settings.labelEffect + '". "labelConnected" reset to false.');
1052 } else if (settings.labelSpace) {
1053 settings.labelSpace = false;
1054 warn('"labelSpace: true" incompatible with "labelConnected: true". "labelSpace" reset to false.');
1055 }
1056 }
1057
1058
1059 if (typeof settings.subPosition === "string") {
1060 settings.subPosition = [settings.subPosition];
1061 }
1062 if (settings.subPosition[0] === "circular") {
1063 if (!settings.subPosition[1]) settings.subPosition[1] = defaults.subPosition[1];
1064 if (typeof settings.subPosition[2] === "undefined") settings.subPosition[2] = defaults.subPosition[2];
1065 if (typeof settings.subPosition[3] === "undefined") settings.subPosition[3] = defaults.subPosition[3];
1066
1067 if (settings.subSpace) settings.subSpace = false;
1068 }
1069
1070 if (!options.subAnimate && options.subAnim) {
1071 settings.subAnimate = settings.subAnim;
1072 }
1073 if (settings.subAnimate === "default") settings.subAnimate = defaults.subAnimate;
1074
1075 if (typeof settings.subEffect === "string") {
1076 settings.subEffect = [settings.subEffect];
1077 }
1078 if ((settings.subEffect[0] === "linear-fade" || settings.subEffect[0] === "linear-slide") && !settings.subEffect[1]) {
1079 settings.subEffect[1] = defaults.subEffect[1];
1080 }
1081
1082 settings.subAnimate = extendAnimateSetting(settings.subAnimate);
1083
1084
1085 if (typeof settings.windowPosition === "string") {
1086 settings.windowPosition = settings.windowPosition.split("-");
1087 }
1088 if (!settings.windowPosition[1]) {
1089 settings.windowPosition[1] = defaults.windowPosition[1];
1090 }
1091
1092 if (settings.windowOffset === 0 || settings.windowOffset === false) {
1093 settings.windowOffset = [0, 0];
1094 } else if (typeof settings.windowOffset === "string") {
1095 settings.windowOffset = splitOffset(settings.windowOffset);
1096 }
1097
1098 if (settings.windowCorners === "match") {
1099 if (settings.buttonShape === "round" || settings.buttonShape === "rounded" || settings.buttonShape === "rounded-out") {
1100 settings.windowCorners = "round";
1101 }
1102 }
1103
1104 if (settings.windowColor === "match") {
1105 settings.windowColor = settings.buttonColor;
1106 } else if (settings.windowColor === "default") {
1107 settings.windowColor = "custom";
1108 }
1109
1110
1111 if (settings.barAnimate === "default") {
1112 settings.barAnimate = defaults.barAnimate;
1113 }
1114
1115 settings.barAnimate = extendAnimateSetting(settings.barAnimate);
1116
1117 if (settings.hideUnder) {
1118 settings.hideUnderWidth = settings.hideUnder;
1119 }
1120
1121
1122 return settings;
1123 }
1124
1125 function splitOffset(off) {
1126 off = off.split("-");
1127 off[0] = getInt(off[0]);
1128 if (off[1]) off[1] = getInt(off[1]);
1129 return off;
1130 }
1131
1132 function extendAnimateSetting(animate) {
1133 if (Object.prototype.toString.call(animate) === "[object Array]") {
1134 return {
1135 show: animate,
1136 hide: animate
1137 };
1138 } else {
1139 return animate;
1140 }
1141 }
1142
1143 function warn(msg) {
1144 if (window.console) {
1145 console.log("(!) Float Menu: " + msg);
1146 }
1147 }
1148
1149 function getInt(val) {
1150 return parseInt(val, 10);
1151 }
1152
1153
1154 }(jQuery));
1155
1156
1157 function scrollToTop() {
1158 jQuery('body,html').animate({
1159 scrollTop: 0
1160 }, 777);
1161 }
1162
1163 function scrollToBottom() {
1164 jQuery("html, body").animate({scrollTop: jQuery(document).height()}, 777);
1165 }
1166
1167 function pageprint() {
1168 window.print();
1169 }
1170
1171 function smoothscroll(section) {
1172 jQuery('html, body').animate({
1173 scrollTop: jQuery(section).offset().top,
1174 }, 777);
1175 }
1176
1177 function goBack() {
1178 window.history.back();
1179 }
1180
1181 function goForward() {
1182 window.history.forward();
1183 }