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