1"use strict"; 2 3$(function () { 4 5 /* Variables */ 6 fac.document = $(document); 7 fac.window = $(window); 8 fac.body = $("body"); 9 fac.container = $("#container_"); 10 fac.lang = fac.html.attr("lang"); 11 fac.home = $("head > link[rel=home]").attr("href"); 12 fac.main_theme_url = $('html').data('main-theme-url') || (fac.home + "wordpress/wp-content/themes/midori2018/"); 13 14 /* HTML classes */ 15 fac.html.addClass("fac-dom-loaded"); 16 17 /* Start */ 18 fac.scroller = new fac.Scroller("a, area"); 19 fac.main = new fac.Main({min_width:599}); 20 21 fac.product_categories_switcher = new fac.Switcher(".c-product-categories > section", "> h1", "> ul", {set_height:true}); 22 fac.product_categories_switcher.start(); 23 24 // .c-sub-nav 25 (function () { 26 27 var target = $("#sub-nav_"); 28 29 if (target.length === 0) return; 30 31 var accordion = new fac.Switcher(target, "> h1", "> .container", {set_height:true}); 32 accordion.start(); 33 34 fac.main.addContentSizeEvent( 35 "c-sub-nav", 36 function () { 37 accordion.disable(); 38 }, 39 function () { 40 accordion.enable(); 41 } 42 ); 43 44 })(); 45 46 // .c-news-pickup-list 47 (function () { 48 var targets = $(".c-news-pickup-list"); 49 var options = { 50 transition : "slide", 51 direction : "vertical", 52 duration : 0.7, 53 delay : 6.0, 54 easing : "cubic-bezier(0.645, 0.045, 0.355, 1)", 55 drag : false, 56 loop : true, 57 auto : true 58 }; 59 targets.each(function () { 60 var target = $(this); 61 var gallery = new fac.Gallery(target.find("> ul"), options); 62 gallery.start(); 63 }); 64 })(); 65 66 // Responsive 67 fac.main.addContentSizeEvent( 68 "general", 69 function () { 70 fac.scroller.setOffset(-55); 71 }, 72 function () { 73 fac.scroller.setOffset(-45); 74 } 75 ); 76 77}); 78 79//shuffle 80$.fn.shuffle = function() { 81 82 var elements = this.get(); 83 84 var shuffled = 85 $.map(elements, function() { 86 var random = Math.floor(Math.random() * elements.length); 87 var element = $(elements[random]).clone(true)[0]; 88 elements.splice(random, 1); 89 return element; 90 }); 91 92 this.each(function (i) { 93 $(this).replaceWith($(shuffled[i])); 94 }); 95 96 return $(shuffled); 97}; 98 99 100/************************ 101 fac 102 require:jQuery1.7+ 103 ************************/ 104 105if (typeof fac === "undefined") var fac = function() {}; 106 107(function () { 108 109 var u = window.navigator.userAgent.toLowerCase(); 110 var has_mobile = u.indexOf("mobile") > -1; 111 112 fac.is_windows = u.indexOf("windows") > -1; 113 fac.is_windows_mobile = fac.is_windows && u.indexOf("phone") > -1; 114 fac.is_windows_tablet = fac.is_windows && u.indexOf("touch") > -1; 115 fac.is_macintosh = u.indexOf("macintosh") > -1 && !("ontouchend" in document); 116 fac.is_iphone = u.indexOf("iphone") > -1; 117 fac.is_ipod = u.indexOf("ipod") > -1; 118 fac.is_ipad = u.indexOf("ipad") > -1 || u.indexOf("macintosh") > -1 && "ontouchend" in document; 119 fac.is_ios = fac.is_iphone || fac.is_ipod || fac.is_ipad || u.indexOf("macintosh") > -1 && "ontouchend" in document; 120 fac.is_android = u.indexOf("android") > -1; 121 fac.is_android_mobile = fac.is_android && has_mobile; 122 fac.is_android_tablet = fac.is_android && !has_mobile; 123 fac.is_firefox = u.indexOf("firefox") > -1; 124 fac.is_firefox_mobile = fac.is_firefox && has_mobile; 125 fac.is_firefox_tablet = fac.is_firefox && u.indexOf("tablet") > -1; 126 fac.is_blackberry = u.indexOf("blackberry") > -1; 127 fac.is_kindle = u.indexOf("kindle") > -1; 128 fac.is_silk = u.indexOf("silk") > -1; 129 fac.is_playbook = u.indexOf("playbook") > -1; 130 fac.is_ie = u.indexOf("msie") > -1 || u.indexOf("trident") > -1; 131 fac.is_ie6 = fac.is_ie && (/msie [6.]/i).test(u); 132 fac.is_ie7 = fac.is_ie && !fac.is_ie6 && (/msie [7.]/).test(u); 133 fac.is_ie8 = fac.is_ie && !fac.is_ie7 && (/msie [8.]/).test(u); 134 fac.is_ie9 = fac.is_ie && !fac.is_ie8 && (/msie [9.]/).test(u); 135 fac.is_ie7u = fac.is_ie7 || fac.is_ie6; 136 fac.is_ie8u = fac.is_ie8 || fac.is_ie7 || fac.is_ie6; 137 fac.is_edge = u.indexOf("edge") > -1; 138 fac.is_webkit = u.indexOf("applewebkit") > -1; 139 fac.is_chrome = u.indexOf("chrome") > -1; 140 fac.is_safari = !fac.is_chrome && u.indexOf("safari") > -1; 141 fac.is_android_browser = fac.is_android && !fac.is_chrome && u.indexOf("linux; u;") > -1; 142 143 fac.is_mobile = fac.is_iphone || fac.is_android_mobile || fac.is_windows_mobile || fac.is_ipod || fac.is_firefox_mobile || fac.is_blackberry; 144 fac.is_tablet = fac.is_ipad || fac.is_android_tablet || fac.is_windows_tablet || fac.is_kindle || fac.is_firefox_tablet || fac.is_silk || fac.is_playbook; 145 fac.is_smartdevice = fac.is_mobile || fac.is_tablet; 146 fac.is_touchscreen = ("ontouchend" in window); 147 148})(); 149 150fac.html = jQuery("html"); 151 152fac.events = { 153 click : "click", 154 mouseover : "mouseover", 155 mouseout : "mouseout", 156 mousedown : !fac.is_smartdevice ? "mousedown touchstart" : "touchstart", 157 mouseup : !fac.is_smartdevice ? "mouseup touchend" : "touchend", 158 mousemove : !fac.is_smartdevice ? "mousemove touchmove" : "touchmove", 159 mousewheel : "onwheel" in document ? "wheel" : "onmousewheel" in document ? "mousewheel" : "DOMMouseScroll" 160}; 161 162fac.easing = { 163 linear : "cubic-bezier(0.0, 0.0, 1.0, 1.0)", 164 easeInSine : "cubic-bezier(0.47, 0, 0.745, 0.715)", 165 easeOutSine : "cubic-bezier(0.39, 0.575, 0.565, 1)", 166 easeInOutSine : "cubic-bezier(0.445, 0.05, 0.55, 0.95)", 167 easeInQuad : "cubic-bezier(0.55, 0.085, 0.68, 0.53)", 168 easeOutQuad : "cubic-bezier(0.25, 0.46, 0.45, 0.94)",
169 easeInOutQuad : "cubic-bezier(0.455, 0.03, 0.515, 0.955)", 170 easeInCubic : "cubic-bezier(0.55, 0.055, 0.675, 0.19)", 171 easeOutCubic : "cubic-bezier(0.215, 0.61, 0.355, 1)", 172 easeInOutCubic : "cubic-bezier(0.645, 0.045, 0.355, 1)", 173 easeInQuart : "cubic-bezier(0.895, 0.03, 0.685, 0.22)", 174 easeOutQuart : "cubic-bezier(0.165, 0.84, 0.44, 1)", 175 easeInOutQuart : "cubic-bezier(0.77, 0, 0.175, 1)", 176 easeInQuint : "cubic-bezier(0.755, 0.05, 0.855, 0.06)", 177 easeOutQuint : "cubic-bezier(0.23, 1, 0.32, 1)", 178 easeInOutQuint : "cubic-bezier(0.86, 0, 0.07, 1)", 179 easeInExpo : "cubic-bezier(0.95, 0.05, 0.795, 0.035)", 180 easeOutExpo : "cubic-bezier(0.19, 1, 0.22, 1)", 181 easeInOutExpo : "cubic-bezier(1, 0, 0, 1)", 182 easeInCirc : "cubic-bezier(0.6, 0.04, 0.98, 0.335)", 183 easeOutCirc : "cubic-bezier(0.075, 0.82, 0.165, 1)", 184 easeInOutCirc : "cubic-bezier(0.785, 0.135, 0.15, 0.86)", 185 easeInBack : "cubic-bezier(0.6, -0.28, 0.735, 0.045)", 186 easeOutBack : "cubic-bezier(0.175, 0.885, 0.32, 1.275)", 187 easeInOutBack : "cubic-bezier(0.68, -0.55, 0.265, 1.55)" 188}; 189 190fac.html.addClass(["fac-js-enabled", "fac-initial"]); 191if (fac.is_smartdevice) fac.html.addClass("fac-is-smartdevice"); 192$(window).on("load", function () { fac.html.addClass("fac-loaded"); }); 193 194if (fac.is_tablet) { 195 $('meta[name="viewport"]').attr({content:"width=1180"}); 196} 197 198 199 200/************************ 201 fac.Main 202 ************************/ 203 204fac.Main = function (options) { 205 //console.log("fac.Main(" + [options] + ")"); 206 207 this.initialize(options); 208}; 209 210fac.Main.onContentFull = "onContentFull"; 211fac.Main.onContentSmall = "onContentSmall"; 212 213fac.Main.prototype = { 214 215 self : null, 216 header : null, 217 footer : null, 218 nav : null, 219 header_visible : null, 220 221 min_width : null, 222 is_first : null, 223 is_content_full : null, 224 225 initialize : function (options) { 226 //console.log("fac.Main.initialize(" + [options] + ")"); 227 228 this.self = $(this); 229 this.header = $("#header_"); 230 this.footer = $("#footer_"); 231 232 if (this.header.length > 0) { 233 this.nav = new fac.Main.Nav(this.header, this.footer); 234 this.header_visible = new fac.Visible(fac.body, {border:0, over_class:"fac-header-hidden", class_target:fac.html}); 235 this.header_visible.start(); 236 } 237 238 if (this.footer.length > 0) { 239 this.footer_visible = new fac.Visible("#footer_ > nav", {offset:-30, visible_class:"fac-footer-shown", class_target:fac.html}); 240 this.footer_visible.start(); 241 } 242 243 this.min_width = options.min_width !== void 0 ? options.min_width : 0; 244 this.is_first = true; 245 this.is_content_full = false; 246 247 fac.window.on("resize orientationchange", this.onResize.bind(this)); 248 this.onResize(); 249 250 this.is_first = false; 251 }, 252 253 setInitial : function () { 254 //console.log("fac.Main.setInitial (" + [] + ")"); 255 256 fac.html.addClass("fac-initial"); 257 258 setTimeout(function () { 259 fac.html.removeClass("fac-initial"); 260 }, 500); 261 }, 262 263 setContentFull : function () { 264 //console.log("fac.Main.setContentFull (" + [] + ")"); 265 266 this.header_visible.setOffset(this.header.outerHeight() - 56); 267 268 if (!this.is_first && this.is_content_full) return; 269 270 this.is_content_full = true; 271 272 this.setInitial(); 273 if (this.nav) this.nav.onContentFull(); 274 275 this.self.trigger(fac.Main.onContentFull); 276 }, 277 278 setContentSmall : function () { 279 //console.log("fac.Main.setContentSmall (" + [] + ")"); 280 281 if (!this.is_first && !this.is_content_full) return; 282 283 this.is_content_full = false; 284 285 this.setInitial(); 286 this.header_visible.setOffset(45); 287 if (this.nav) this.nav.onContentSmall(); 288 289 this.self.trigger(fac.Main.onContentSmall); 290 }, 291 292 addContentSizeEvent : function (event_id, content_full_function, content_small_function) { 293 //console.log("fac.Main.addContentSizeEvent (" + [event_id, content_full_function, content_small_function] + ")"); 294 295 this.self 296 .on(fac.Main.onContentFull + "." + event_id, content_full_function) 297 .on(fac.Main.onContentSmall + "." + event_id, content_small_function); 298 299 if (this.is_content_full) { 300 content_full_function(); 301 } 302 else { 303 content_small_function(); 304 } 305 }, 306 307 removeContentSizeEvent : function (event_id) { 308 //console.log("fac.Main.removeContentSizeEvent (" + [event_id] + ")"); 309 310 this.self 311 .off(fac.Main.onContentFull + "." + event_id) 312 .off(fac.Main.onContentSmall + "." + event_id); 313 }, 314 315 triggerContentSizeEvent : function () { 316 //console.log("fac.Main.triggerContentSizeEvent (" + [] + ")"); 317 318 if (this.is_content_full) { 319 this.self.trigger(fac.Main.onContentFull); 320 } 321 else { 322 this.self.trigger(fac.Main.onContentSmall); 323 } 324 }, 325 326 isContentFull : function () { 327 //console.log("fac.Main.isContentFull (" + [] + ")"); 328 329 return this.is_content_full; 330 }, 331 332 isContentSmall : function () { 333 //console.log("fac.Main.isContentSmall (" + [] + ")"); 334 335 return !this.is_content_full; 336 }, 337 338 //Events 339 340 onResize : function () { 341 //console.log("fac.Main.onResize (" + [] + ")"); 342 343 var area_width = parseInt(fac.body.css("max-width")); 344 area_width = !isNaN(area_width) ? area_width : fac.window.width(); 345 var area_height = fac.window.height(); 346 347 if (area_width === this.min_width) { 348 this.setContentSmall(); 349 } 350 else { 351 this.setContentFull(); 352 } 353 354 if (this.nav) this.nav.onResize(area_height); 355 } 356 357}; 358 359/* fac.Main.Nav */ 360 361fac.Main.Nav = function (header) { 362 //console.log("fac.Main.Nav(" + [header] + ")"); 363 364 this.initialize(header); 365};
366 367fac.Main.Nav.ON_SHOW = "onShow"; 368fac.Main.Nav.ON_HIDE = "onHide"; 369 370fac.Main.Nav.prototype = { 371 372 self : null, 373 374 header : null, 375 nav : null, 376 button : null, 377 sub_switcher : null, 378 trap_scrolling : null, 379 380 is_nav_shown : null, 381 382 initialize : function (header) { 383 //console.log("fac.Main.Nav.initialize(" + [header] + ")"); 384 385 var p = this; 386 387 this.self = $(this); 388 this.header = header; 389 this.nav = this.header.find("> nav"); 390 this.button = this.nav.find("> h1").on("click", this.toggleNav.bind(this)); 391 392 var nav_container = 393 $('<div class="container"></div>') 394 .appendTo(this.nav); 395 396 this.nav.find("> ul") 397 .appendTo(nav_container); 398 399 this.sub_switcher = new fac.Switcher(nav_container.find("> .main > li > a + *").parent(), "> a", "> a + *", {prevent_click:true}); 400 401 this.trap_scrolling = new fac.TrapScrolling(nav_container); 402 this.trap_scrolling.start(); 403 404 this.is_nav_shown = false; 405 }, 406 407 toggleNav : function () { 408 //console.log("fac.Main.Nav.toggleNav(" + [] + ")"); 409 410 if (this.is_nav_shown) { 411 this.hideNav(); 412 } 413 else { 414 this.showNav(); 415 } 416 }, 417 418 showNav : function () { 419 //console.log("fac.Main.Nav.showNav(" + [] + ")"); 420 421 this.is_nav_shown = true; 422 423 fac.html.addClass("fac-nav-show"); 424 425 this.trap_scrolling.start(); 426 427 this.self.trigger(fac.Main.Nav.ON_SHOW); 428 }, 429 430 hideNav : function () { 431 //console.log("fac.Main.Nav.hideNav(" + [] + ")"); 432 433 this.is_nav_shown = false; 434 435 fac.html.removeClass("fac-nav-show"); 436 437 this.trap_scrolling.stop(); 438 439 this.self.trigger(fac.Main.Nav.ON_HIDE); 440 }, 441 442 //Events 443 444 onResize : function (area_height) { 445 //console.log("fac.Main.Nav.onResize (" + [area_height] + ")"); 446 447 }, 448 449 onContentFull : function () { 450 //console.log("fac.Main.Nav.onContentFull (" + [] + ")"); 451 452 this.sub_switcher.enable(); 453 this.hideNav(); 454 }, 455 456 onContentSmall : function () { 457 //console.log("fac.Main.Nav.onContentSmall (" + [] + ")"); 458 459 this.sub_switcher.disable(); 460 } 461 462}; 463 464 465 466/************************ 467 fac.ShopInfoNav 468 ************************/ 469 470fac.ShopInfoNav = function (container) { 471 //console.log("fac.ShopInfoNav(" + [container] + ")"); 472 473 this.initialize(container); 474}; 475 476fac.ShopInfoNav.NAME = "fac-shopinfo-nav"; 477fac.ShopInfoNav.ON_READY = "onReady"; 478fac.ShopInfoNav.ON_SEARCH = "onSearch"; 479fac.ShopInfoNav.LOADER_INSTANCE = null; 480fac.ShopInfoNav.IS_API_ERADY = false; 481fac.ShopInfoNav.BOUNDS_ZOOM_MIN = 5; 482fac.ShopInfoNav.BOUNDS_ZOOM_MAX = 18; 483 484fac.ShopInfoNav.LoadAPI = function (instance) { 485 if (fac.ShopInfoNav.IS_API_ERADY) { 486 return; 487 } 488 489 fac.ShopInfoNav.LOADER_INSTANCE = instance; 490 491 var api_key = $("html").data("googlemaps-api-key"); 492 493 var script = document.createElement("script"); 494 script.async = true; 495 script.src = "https://maps.googleapis.com/maps/api/js?loading=async&libraries=marker&callback=fac.ShopInfoNav.OnAPIReady&key=" + api_key; 496 document.head.appendChild(script); 497}; 498 499fac.ShopInfoNav.OnAPIReady = function () { 500 fac.ShopInfoNav.IS_API_ERADY = true; 501 502 fac.ShopInfoNav.LOADER_INSTANCE.generateMap(); 503}; 504 505fac.ShopInfoNav.prototype = { 506 507 self : null, 508 container : null, 509 map : null, 510 511 data : null, 512 googlemaps : null, 513 markers : null, 514 infos : null, 515 infowindow : null, 516 users_marker : null, 517 prefectures : null, 518 search_text : null, 519 is_ready : null, 520 is_data_ready : null, 521 522 initialize : function (container) { 523 //console.log("fac.ShopInfoNav.initialize(" + [container] + ")"); 524 525 var p = this; 526 527 this.self = $(this); 528 this.container = $(container); 529 this.map = this.container.find("> .map"); 530 this.markers = {}; 531 this.infos = []; 532 this.is_ready = false; 533 this.is_data_ready = false; 534 535 var search_form = this.container.find("> .search"); 536 this.prefectures = this.container.find("> .prefectures > select"); 537 this.search_text = search_form.find("> .text"); 538 var search_submit = search_form.find("> .submit"); 539 var near_by = search_form.find("> .near-by"); 540 541 this.prefectures.on("change." + fac.ShopInfoNav.NAME, function () { 542 p.search_text 543 .val($(this).val()) 544 .submit(); 545 }); 546 547 search_form.on("submit." + fac.ShopInfoNav.NAME, function () { 548 549 p.search(p.search_text.val()); 550 551 return false; 552 }); 553 554 near_by.on("click", this.moveToUsersLocation.bind(this)); 555 }, 556 557 start : function (search_text) { 558 if (fac.ShopInfoNav.IS_API_ERADY) { 559 this.checkReady(); 560 } 561 else { 562 fac.ShopInfoNav.LoadAPI(this); 563 } 564 565 var domData = []; 566 $("#list li[id^='shop-'], #shopinfo-data-list li[id^='shop-']").each(function () { 567 var el = $(this); 568 domData.push({ 569 id : parseInt(el.attr("id").replace("shop-", ""), 10), 570 title : el.data("title"), 571 lat : el.data("lat"), 572 lng : el.data("lng"), 573 prefecture : el.data("prefecture"), 574 address : el.data("address"), 575 phone : el.data("phone"), 576 url : el.data("url") 577 }); 578 }); 579 this.checkReady(undefined, domData); 580 }, 581 582 checkReady : function (event, data) { 583 if (data !== void 0) { 584 this.data = data; 585 this.is_data_ready = true; 586 } 587 588 if (fac.ShopInfoNav.IS_API_ERADY && this.is_data_ready) { 589 this.ready(); 590 } 591 }, 592 593 ready : function () { 594 //console.log("fac.ShopInfoNav.ready(" + [] + ")"); 595 596 this.is_ready = true; 597 598 this.generateMarkers(this.data); 599 600 this.self.trigger(fac.ShopInfoNav.ON_READY); 601 }, 602 603 generateMap : function () { 604 var p = this; 605 606 var mapId = $('html').data('googlemaps-map-id') || 'DEMO_MAP_ID'; 607 var options = { 608 zoom : 12, 609 center : new google.maps.LatLng(35.6477406, 139.711474), 610 mapTypeId : google.maps.MapTypeId.ROADMAP, 611 mapTypeControl : false, 612 gestureHandling : "cooperative", 613 zoomControl : true, 614 mapId : mapId, 615 zoomControlOptions : { 616 position : google.maps.ControlPosition.TOP_LEFT 617 }, 618 streetViewControlOptions: { 619 position : google.maps.ControlPosition.TOP_LEFT 620 } 621 }; 622 623 this.googlemaps = new google.maps.Map(this.map.get(0), options); 624 625 this.googlemaps.initialZoom = true; 626 627 google.maps.event.addListener(this.googlemaps, "zoom_changed", function() { 628 var zoomChangeBoundsListener = 629 google.maps.event.addListener(p.googlemaps, "bounds_changed", function() { 630 var zoom = this.getZoom(); 631 if (this.initialZoom === true) { 632 if (zoom > fac.ShopInfoNav.BOUNDS_ZOOM_MAX) { 633 this.setZoom(fac.ShopInfoNav.BOUNDS_ZOOM_MAX); 634 this.initialZoom = false; 635 } 636 else if (zoom < fac.ShopInfoNav.BOUNDS_ZOOM_MIN) { 637 this.setZoom(fac.ShopInfoNav.BOUNDS_ZOOM_MIN); 638 this.initialZoom = false; 639 } 640 } 641 google.maps.event.removeListener(zoomChangeBoundsListener); 642 }); 643 }); 644 645 this.checkReady(); 646 }, 647 648 generateMarkers : function (data) { 649 //console.log("fac.ShopInfoNav.generateMarkers(" + [data] + ")"); 650 651 var img = new Image(90, 53); 652 img.src = fac.main_theme_url + "shopinfo/images/marker_normal.png"; 653 654 for (var i = 0; i < data.length; i++) { 655 var datum = data[i]; 656 var marker = this.generateMarker(datum, img.cloneNode()); 657 this.markers[datum.id] = marker; 658 } 659 660 this.self.trigger(fac.ShopInfoNav.ON_SEARCH, [this.search_text.val(), data]); 661 }, 662 663 generateMarker : function (datum, imgEl) { 664 //console.log("fac.ShopInfoNav.generateMarker(" + [datum, imgEl] + ")"); 665 666 var marker = new google.maps.marker.AdvancedMarkerElement({ 667 map : this.googlemaps, 668 title : datum.title, 669 position : new google.maps.LatLng(datum.lat, datum.lng), 670 content : imgEl 671 }); 672 marker.addListener("gmp-click", this.showInfoWindow.bind(this, datum, marker)); 673 674 return marker; 675 }, 676 677 showInfoWindow : function (datum, marker) { 678 //console.log("fac.ShopInfoNav.showInfoWindow(" + [datum, marker] + ")"); 679 680 if(this.infowindow) this.infowindow.close(); 681
682 var container = $('<div></div>') 683 var content = $('<div class="info-content"><strong>' + datum.title + '</strong></div>').appendTo(container); 684 var info = []; 685 var address = (datum.prefecture || "") + (datum.address || ""); 686 var map = '<a class="map c-link" href="https://maps.google.com/maps?ll=' + datum.lat + ',' + datum.lng + '&q=' + encodeURI(datum.title) + '&z=13" target="_blank">å°å³</a>'; 687 if (address) info.push(address); 688 if (datum.phone) info.push("TEL. " + datum.phone); 689 if (datum.url) { 690 info.push(map + '<a class="hp c-link" href="' + datum.url + '" target="_blank">WEBãµã¤ã</a>'); 691 } 692 else { 693 info.push(map); 694 } 695 696 $('<p></p>') 697 .append(info.join("<br>")) 698 .appendTo(content); 699 700 this.infowindow = new google.maps.InfoWindow({content:container.html()}); 701 this.infowindow.open(this.googlemaps, marker); 702 }, 703 704 search : function (text) { 705 //console.log("fac.ShopInfoNav.search(" + [text] + ")"); 706 707 text = text !== void 0 ? text : ""; 708 709 this.search_text.val(text); 710 711 var endpoint = text.length > 0 ? "/search/" + text : "/all"; 712 713 var data = new fac.ShopInfoData(endpoint); 714 $(data).on(fac.ShopInfoData.ON_LOADED, this.setMarkers.bind(this)); 715 716 if (this.is_ready) { 717 data.start(); 718 } 719 else { 720 this.self 721 .off(fac.ShopInfoNav.ON_READY + ".search") 722 .on(fac.ShopInfoNav.ON_READY + ".search", data.start.bind(data)); 723 } 724 }, 725 726 clearSearch : function () { 727 //console.log("fac.ShopInfoNav.clearSearch(" + [] + ")"); 728 729 this.search(""); 730 this.prefectures.val(""); 731 732 this.container.removeClass("not-found"); 733 }, 734 735 setMarkers : function (event, data) { 736 //console.log("fac.ShopInfoNav.setMarkers(" + [] + ")"); 737 738 this.hideAllMarkers(); 739 740 if (data.length > 0) { 741 742 this.container.removeClass("not-found"); 743 744 var bounds = new google.maps.LatLngBounds(); 745 746 for (var i = 0; i < data.length; i++) { 747 var datum = data[i]; 748 var marker = this.markers[datum.id]; 749 marker.map = this.googlemaps; 750 bounds.extend(marker.position); 751 } 752 753 if (this.search_text.val() !== "") { 754 this.googlemaps.fitBounds(bounds, 30); 755 } 756 757 this.self.trigger(fac.ShopInfoNav.ON_SEARCH, [this.search_text.val(), data]); 758 } 759 else { 760 761 this.googlemaps.panTo(new google.maps.LatLng(37.6477406, 139.711474)); 762 this.googlemaps.setZoom(fac.ShopInfoNav.BOUNDS_ZOOM_MIN); 763 764 this.container.addClass("not-found"); 765 766 this.self.trigger(fac.ShopInfoNav.ON_SEARCH, [this.search_text.val(), []]); 767 } 768 }, 769 770 showAllMarkers : function () { 771 //console.log("fac.ShopInfoNav.showAllMarkers(" + [] + ")"); 772 773 this.clearSearch(); 774 775 for (var id in this.markers) { 776 if (this.markers.hasOwnProperty(id)) { 777 var marker = this.markers[id]; 778 marker.map = this.googlemaps; 779 } 780 } 781 }, 782 783 hideAllMarkers : function () { 784 //console.log("fac.ShopInfoNav.hideAllMarkers(" + [] + ")"); 785 786 if(this.infowindow) this.infowindow.close(); 787 788 for (var id in this.markers) { 789 if (this.markers.hasOwnProperty(id)) { 790 var marker = this.markers[id]; 791 marker.map = null; 792 } 793 } 794 }, 795 796 moveToUsersLocation : function () { 797 //console.log("fac.ShopInfoNav.moveToUsersLocation(" + [] + ")"); 798 799 var p = this; 800 801 navigator.geolocation.getCurrentPosition( 802 function(position) { 803 804 p.showAllMarkers(); 805 806 var googlemaps = p.googlemaps; 807 var markers = p.markers; 808 var lat = position.coords.latitude; 809 var lng = position.coords.longitude; 810 var latlng = new google.maps.LatLng(lat, lng); 811 812 if (p.users_marker) p.users_marker.map = null; 813 p.users_marker = new google.maps.marker.AdvancedMarkerElement({ 814 map : googlemaps, 815 position : latlng 816 }); 817 818 var R = 6371; 819 var distances = []; 820 var closest = -1; 821 for (var id in markers) { 822 if (markers.hasOwnProperty(id)) { 823 var marker = markers[id]; 824 var pos = marker.position; 825 var mlat = (typeof pos.lat === "function") ? pos.lat() : pos.lat; 826 var mlng = (typeof pos.lng === "function") ? pos.lng() : pos.lng; 827 var dLat = rad(mlat - lat); 828 var dLng = rad(mlng - lng); 829 var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.
829cos(rad(lat)) * Math.cos(rad(lat)) * Math.sin(dLng / 2) * Math.sin(dLng / 2); 830 var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); 831 var d = R * c; 832 833 distances[id] = d; 834 if (closest === -1 || d < distances[closest]) { 835 closest = id; 836 } 837 } 838 } 839 840 var bounds = new google.maps.LatLngBounds(); 841 bounds.extend(latlng); 842 bounds.extend(markers[closest].position); 843 googlemaps.fitBounds(bounds, 80); 844 }, 845 function(error) { 846 847 switch(error.code) { 848 case 1: // PERMISSION_DENIED 849 console.log("ä½ç½®æ å ±ã®å©ç¨ã許å¯ããã¦ãã¾ãã"); 850 break; 851 case 2: // POSITION_UNAVAILABLE 852 console.log("ç¾å¨ä½ç½®ãåå¾ã§ãã¾ããã§ãã"); 853 break; 854 case 3: // TIMEOUT 855 console.log("ã¿ã¤ã ã¢ã¦ãã«ãªãã¾ãã"); 856 break; 857 default: 858 console.log("ãã®ä»ã®ã¨ã©ã¼(ã¨ã©ã¼ã³ã¼ã:" + error.code + ")"); 859 break; 860 } 861 } 862 ); 863 864 function rad(x) {return x * Math.PI / 180;} 865 866 return false; 867 } 868 869}; 870 871 872 873/************************ 874 fac.ShopInfoData 875 ************************/ 876 877fac.ShopInfoData = function (endpoint) { 878 //console.log("fac.ShopInfoData(" + [endpoint] + ")"); 879 880 this.initialize(endpoint); 881}; 882 883fac.ShopInfoData.ON_LOADED = "onLoaded"; 884 885fac.ShopInfoData.prototype = { 886 887 self : null, 888 endpoint : null, 889 890 initialize : function (endpoint) { 891 //console.log("fac.ShopInfoData.initialize(" + [endpoint] + ")"); 892 893 this.self = $(this); 894 this.endpoint = endpoint; 895 }, 896 897 start : function () { 898 //console.log("fac.ShopInfoData.start(" + [] + ")"); 899 900 var json = fac.home + "wp-json/shopinfo" + this.endpoint; 901 902 $.getJSON(json) 903 .done(this.loaded.bind(this)) 904 .fail(this.error.bind(this)); 905 }, 906 907 loaded : function (data) { 908 //console.log("fac.ShopInfoData.loaded(" + [] + ")"); 909 910 this.self.trigger(fac.ShopInfoData.ON_LOADED, [data]); 911 }, 912 913 error : function (jqXHR, textStatus, errorThrown) { 914 //console.log("fac.ShopInfoData.error(" + [] + ")"); 915 916 console.error("æ å ±ã®åå¾ã«å¤±æãã¾ãã", jqXHR.status, textStatus); 917 } 918 919}; 920 921 922 923/************************ 924 fac.Switcher 925 ************************/ 926 927fac.Switcher = function (containers, button_selector, content_selector, options) { 928 //console.log("fac.Switcher (" + [containers, button_selector, content_selector, options] + ")"); 929 930 this.initialize(containers, button_selector, content_selector, options); 931}; 932 933fac.Switcher.NAME = "fac-switcher"; 934fac.Switcher.ON_SHOW = "OnShow"; 935fac.Switcher.ON_SHOW_ALL = "OnShowAll"; 936fac.Switcher.ON_HIDE = "OnHide"; 937fac.Switcher.ON_HIDE_ALL = "OnHideAll"; 938 939fac.Switcher.prototype = { 940 941 env : { 942 $ : null, 943 }, 944 945 options : { 946 single : false, 947 set_height : false, 948 prevent_click : false, 949 duration : 0.5 950 }, 951 952 status : { 953 first : true, 954 single : null 955 }, 956 957 self : null, 958 containers : null, 959 button_selector : null, 960 content_selector : null, 961 items : null, 962 963 initialize : function (containers, button_selector, content_selector, options) { 964 //console.log("fac.Switcher.initialize (" + [containers, button_selector, content_selector, options] + ")"); 965 966 this.env.$ = 967 options && options.jquery ? options.jquery : 968 this.env.$ ? this.env.$ : 969 fac.$ ? fac.$ : 970 jQuery ? jQuery : 971 $; 972 973 var $ = this.env.$; 974 975 if (!$.fn || !$.fn.jquery) { 976 console.warn("jQuery required"); 977 return; 978 } 979 980 this.self = $(this); 981 982 //Options 983 this.options = $.extend({}, this.options, options); 984 985 //Elements 986 this.containers = $(containers); 987 this.button_selector = button_selector; 988 this.content_selector = content_selector; 989 this.items = []; 990 991 //Status 992 this.status = $.extend({}, this.status); 993 this.status.single = this.options.single; 994 995 for (var i = 0; i < this.containers.length; i++) { 996 997 var container = this.containers.eq(i); 998 var button = this.button_selector !== "" ? container.find(this.button_selector) : container; 999 var content = this.content_selector !== "" ? container.find(this.content_selector) : container; 1000 1001 if (button.length === 0) return; 1002 1003 var item = new fac.Switcher.Item(this, this.items.length, container, button, content); 1004 1005 this.items.push(item); 1006 } 1007 }, 1008 1009 start : function () { 1010 //console.log("fac.Switcher.start (" + [] + ")"); 1011 1012 this.hideAll(); 1013 this.status.first = false; 1014 }, 1015 1016 //Public 1017 1018 show : function (index) { 1019 //console.log("fac.Switcher.show (" + [index] + ")"); 1020 1021 if (isNaN(index)) { 1022 1023 index = this.getIndexByElement(index); 1024 1025 } 1026 1027 var item = this.items[index]; 1028 1029 if (!item) return false; 1030 1031 item.startShow(); 1032 1033 if (this.status.single) { 1034 1035 for (var i = 0; i < this.items.length; i++) { 1036 1037 if (i !== index) this.items[i].startHide(); 1038 1039 } 1040 1041 } 1042 1043 //Trigger 1044 this.self.trigger(fac.Switcher.ON_SHOW, [index]); 1045 if (this.isAllShown()) this.self.trigger(fac.Switcher.ON_SHOW_ALL, [index]); 1046 1047 return false; 1048 }, 1049 1050 showAll : function () { 1051 //console.log("fac.Switcher.showAll (" + [] + ")"); 1052 1053 for (var i = 0; i < this.items.length; i++) { 1054 1055 this.show(i);
1056 1057 } 1058 1059 return false; 1060 }, 1061 1062 hide : function (index) { 1063 //console.log("fac.Switcher.hide (" + [index] + ")"); 1064 1065 var item = this.items[index]; 1066 1067 if (!item) return false; 1068 1069 item.startHide(); 1070 1071 //Trigger 1072 this.self.trigger(fac.Switcher.ON_HIDE, [index]); 1073 if (this.isAllHidden()) this.self.trigger(fac.Switcher.ON_HIDE_ALL, [index]); 1074 1075 return false; 1076 }, 1077 1078 hideAll : function () { 1079 //console.log("fac.Switcher.hideAll (" + [] + ")"); 1080 1081 for (var i = 0; i < this.items.length; i++) { 1082 1083 this.hide(i); 1084 1085 } 1086 1087 return false; 1088 }, 1089 1090 enable : function () { 1091 //console.log("fac.Switcher.enable (" + [] + ")"); 1092 1093 for (var i = 0; i < this.items.length; i++) { 1094 1095 var item = this.items[i]; 1096 item.enable(); 1097 1098 } 1099 1100 this.start(); 1101 1102 return false; 1103 }, 1104 1105 disable : function () { 1106 //console.log("fac.Switcher.disable (" + [] + ")"); 1107 1108 for (var i = 0; i < this.items.length; i++) { 1109 1110 var item = this.items[i]; 1111 item.disable(); 1112 1113 } 1114 1115 return false; 1116 }, 1117 1118 isAllShown : function () { 1119 //console.log("fac.Switcher.isAllShown (" + [] + ")"); 1120 1121 var is_all_shown = true; 1122 1123 for (var i = 0; i < this.items.length; i++) { 1124 1125 var item = this.items[i]; 1126 if (!item.status.shown) { 1127 is_all_shown = false; 1128 break; 1129 } 1130 } 1131 1132 return is_all_shown; 1133 }, 1134 1135 isAllHidden : function () { 1136 //console.log("fac.Switcher.isAllHidden (" + [] + ")"); 1137 1138 var is_all_hidden = true; 1139 1140 for (var i = 0; i < this.items.length; i++) { 1141 1142 var item = this.items[i]; 1143 if (item.status.shown) { 1144 is_all_hidden = false; 1145 break; 1146 } 1147 } 1148 1149 return is_all_hidden; 1150 }, 1151 1152 getIndexByElement : function (element) { 1153 //console.log("fac.Switcher.getIndexByElement (" + [element] + ")"); 1154 1155 var $ = this.env.$; 1156 1157 element = $(element); 1158 1159 for (var i = 0; i < this.items.length; i++) { 1160 1161 var item = this.items[i]; 1162 1163 if (element.get(0) === item.container.get(0)) return i; 1164 1165 } 1166 1167 return null; 1168 } 1169 1170}; 1171 1172/* fac.Switcher.Item */ 1173 1174fac.Switcher.Item = function (parent, index, container, button, content) { 1175 //console.log("fac.Switcher.Item (" + [parent, index, container, button, content] + ")"); 1176 1177 this.initialize(parent, index, container, button, content); 1178}; 1179 1180fac.Switcher.Item.prototype = { 1181 1182 status : { 1183 shown : true, 1184 enabled : false 1185 }, 1186 1187 parent : null, 1188 index : null, 1189 container : null, 1190 button : null, 1191 content : null, 1192 1193 button_click : null, 1194 timeout : null, 1195 1196 initialize : function (parent, index, container, button, content) { 1197 //console.log("fac.Switcher.Item.initialize (" + [parent, index, container, button, content] + ")"); 1198 1199 this.parent = parent; 1200 this.index = index; 1201 this.container = container; 1202 this.button = button; 1203 this.content = content; 1204 1205 this.button_click = new fac.FastClick(this.button, {prevent_click:this.parent.options.prevent_click}); 1206 $(this.button_click).on(fac.FastClick.ON_CLICK, this.toggle.bind(this)); 1207 1208 //Status 1209 this.status = $.extend({}, this.status); 1210 1211 this.enable(); 1212 }, 1213 1214 //Public 1215 1216 toggle : function () { 1217 //console.log("fac.Switcher.Item.toggle (" + [] + ")"); 1218 1219 if (this.status.shown) this.hide(); 1220 else this.show(); 1221 1222 return false; 1223 }, 1224 1225 show : function () { 1226 //console.log("fac.Switcher.Item.show (" + [] + ")"); 1227 1228 if (this.status.shown) return; 1229 1230 this.parent.show(this.index); 1231 1232 return false; 1233 }, 1234 1235 hide : function () { 1236 //console.log("fac.Switcher.Item.hide (" + [] + ")"); 1237 1238 if (!this.status.shown) return; 1239 1240 this.parent.hide(this.index); 1241 1242 return false; 1243 }, 1244 1245 enable : function () { 1246 //console.log("fac.Switcher.Item.enable (" + [] + ")"); 1247 1248 if (this.status.enabled) return; 1249 1250 this.status.enabled = true; 1251 this.status.shown = true; 1252 1253 this.button_click.enable(); 1254 1255 this.container.addClass(fac.Switcher.NAME); 1256 if (this.parent.options.set_height) { 1257 this.container.addClass(fac.Switcher.NAME + "--height"); 1258 } 1259 this.button.addClass(fac.Switcher.NAME + "-button"); 1260 this.content.addClass(fac.Switcher.NAME + "-content"); 1261 }, 1262 1263 disable : function () { 1264 //console.log("fac.Switcher.Item.disable (" + [] + ")"); 1265 1266 if (!this.status.enabled) return; 1267 1268 this.status.enabled = false; 1269 1270 this.startHide(); 1271 this.button_click.disable(); 1272 1273 this.container.removeClass(fac.Switcher.NAME); 1274 this.container.removeClass(fac.Switcher.NAME + "--height"); 1275 this.button.removeClass(fac.Switcher.NAME + "-button"); 1276 this.content.removeClass(fac.Switcher.NAME + "-content"); 1277 1278 if (this.parent.options.set_height) { 1279 1280 this.content.css({height:""}); 1281 1282 } 1283 }, 1284 1285 //Private 1286 1287 startShow : function () { 1288 //console.log("fac.Switcher.Item.startShow (" + [] + ")"); 1289 1290 this.status.shown = true; 1291 1292 this.container.addClass(fac.Switcher.NAME + "-show"); 1293 1294 if (this.parent.options.set_height) { 1295 1296 clearTimeout(this.timeout); 1297 1298 var p = this; 1299 var height = this.getHeight(); 1300 var delay = parseFloat(this.content.css("transition-duration")) + parseFloat(this.content.css("transition-delay")); // use seconds 1301 1302 this.content.css({height:height}); 1303 this.timeout = setTimeout(function () { 1304 p.content.css({height:"auto"}); 1305 }, delay * 1000); 1306 } 1307 }, 1308 1309 startHide : function () { 1310 //console.log("fac.Switcher.Item.startHide (" + [] + ")"); 1311 1312 this.status.shown = false; 1313 1314 this.container.removeClass(fac.Switcher.NAME + "-show"); 1315 1316 if (this.parent.options.set_height && !this.parent.status.first) { 1317 1318 clearTimeout(this.timeout); 1319 1320 var p = this; 1321 var height = this.getHeight(); 1322 1323 this.content.css({height:height}); 1324 this.timeout = setTimeout(function () { 1325 p.content.css({height:""}); 1326 }, 20); 1327 1328 } 1329 }, 1330 1331 getHeight : function () { 1332 //console.log("fac.Switcher.Item.getHeight (" + [] + ")"); 1333 1334 var clone = this.content.clone().insertBefore(this.content).css({height:"auto"}); 1335 var height = clone.height(); 1336 1337 clone.remove(); 1338 1339 return height; 1340 } 1341 1342}; 1343 1344 1345 1346/************************ 1347 fac.Visible 1348 ex) 1349 new fac.Visible(selector, {border:3/4, offset:-100, over_class:"over", visible_class:"visible", hidden_class:"hidden", class_target:"html", onece:true}); 1350 ************************/ 1351 1352if (typeof fac === "undefined") var fac = function() {}; 1353 1354fac.Visible = function (selector, options) { 1355 //console.log("fac.Visible(" + [selector, options] + ")"); 1356 1357 this.initialize(selector, options); 1358}; 1359 1360fac.Visible.NAME = "fac-visible"; 1361fac.Visible.INCREMENT = 0; 1362fac.Visible.ON_VISIBLE = "onVisible"; 1363fac.Visible.ON_HIDDEN = "onHidden"; 1364fac.Visible.ON_OVER = "onOver"; 1365fac.Visible.ON_BELOW = "onBelow"; 1366fac.Visible.ON_COLLIDE = "onCollide"; 1367fac.Visible.ON_APART = "onApart"; 1368fac.Visible.ON_ALL_VISIBLE = "onAllVisible"; 1369fac.Visible.ON_ALL_HIDDEN = "onAllHidden"; 1370fac.Visible.ON_ALL_OVER = "onAllOver"; 1371fac.Visible.ON_ALL_BELOW = "onAllBelow"; 1372fac.Visible.ON_ALL_COLLIDE = "onAllCollide"; 1373fac.Visible.ON_ALL_APART = "onAllApart"; 1374 1375fac.Visible.prototype = { 1376 1377 env : { 1378 $ : null, 1379 window : null 1380 }, 1381 1382 events : { 1383 resize : null, 1384 rotationchange : null, 1385 load : null, 1386 scroll : null 1387 }, 1388 1389 options : { 1390 items : null, 1391 offset : 0, 1392 auto : true, 1393 onece : false, 1394 group : false, 1395 full_visible : false, 1396 border : void 0, 1397 class_target : void 0, 1398 visible_class : null, 1399 hidden_class : null, 1400 over_class : null, 1401 collide_class : null, 1402 apart_class : null, 1403 do_visible : null, 1404 do_over : null, 1405 do_collide : null 1406 }, 1407 1408 status : { 1409 auto : null, 1410 all_visible : null, 1411 all_over : null, 1412 all_collide : null, 1413 window_height : null, 1414 scroll_top : null 1415 }, 1416 1417 id : null, 1418 self : null, 1419 check_all_visible : function () {}, 1420 check_all_over : function () {}, 1421 check_all_collide : function () {}, 1422 1423 initialize : function (selector, options) { 1424 //console.log("fac.Visible.initialize(" + [selector, options] + ")"); 1425 1426 this.env.$ = 1427 options && options.jquery ? options.jquery : 1428 this.env.$ ? this.env.$ : 1429 fac.$ ? fac.$ : 1430 jQuery ? jQuery : 1431 $; 1432 1433 if (!this.env.$.fn || !this.env.$.fn.jquery) { 1434 console.warn("jQuery required"); 1435 return; 1436 } 1437 1438 1439 var $ = this.env.$; 1440 var targets = $(selector); 1441 1442 this.id = "." + fac.Visible.NAME + "-" + fac.Visible.INCREMENT++; 1443 this.self = $(this); 1444 1445 //Env 1446 this.env.window = this.env.window ? this.env.window : fac.window ? fac.window : $(window); 1447 1448 //Events 1449 this.events = $.extend({}, this.events); 1450 1451 this.events.resize = this.events.resize ? this.events.resize : "resize"; 1452 this.events.orientationchange = this.events.orientationchange ? this.events.orientationchange : "orientationchange"; 1453 this.events.load = this.events.load ? this.events.load : "load"; 1454 this.events.scroll = this.events.scroll ? this.events.scroll : "scroll"; 1455 1456 //Options 1457 this.options = $.extend({}, this.options, options); 1458 1459 this.options.items = []; 1460 this.options.class_target = this.options.class_target !== void 0 ? $(this.options.class_target) : void 0; 1461 if (this.options.border !== void 0) { 1462 this.options.visible_class = this.options.visible_class || ""; 1463 this.options.hidden_class = this.options.hidden_class || ""; 1464 this.options.over_class = this.options.over_class !== null ? this.options.over_class : fac.Visible.NAME; 1465 this.options.collide_class = this.options.collide_class || ""; 1466 this.options.apart_class = this.options.apart_class || ""; 1467 } 1468 else { 1469 this.options.visible_class = this.options.visible_class !== null ? this.options.visible_class : fac.Visible.NAME; 1470 this.options.hidden_class = this.options.hidden_class || ""; 1471 this.options.over_class = this.options.over_class || ""; 1472 } 1473 this.options.do_visible = this.options.visible_class || this.options.hidden_class; 1474 this.options.do_over = this.options.over_class; 1475 this.options.do_collide = this.options.collide_class || this.options.apart_class; 1476 1477 //Status 1478 this.status = $.extend({}, this.status); 1479 this.status.window_height = this.env.window.height(); 1480 this.status.scroll_top = this.env.window.scrollTop(); 1481 1482 //Elements 1483 for (var i = 0; i < targets.length; i++) { 1484 1485 var target = targets.eq(i); 1486 var item = new fac.Visible.Item(this, target); 1487 1488 this.options.items.push(item); 1489 } 1490 1491 1492 if (this.options.group) { 1493 if (this.options.do_visible) this.check_all_visible = this.checkAllVisible; 1494 if (this.options.do_over) this.check_all_over = this.checkAllOver; 1495 if (this.options.do_collide) this.check_all_collide = this.checkAllCollide; 1496 } 1497 }, 1498 1499 //Public Methods 1500 1501 start : function () { 1502 //console.log("fac.Visible.start (" + [] + ")"); 1503 1504 for (var i = 0; i < this.options.items.length; i++) { 1505 1506 var item = this.options.items[i]; 1507 item.start(); 1508 } 1509 1510 this.setAuto(this.options.auto); 1511 this.update(); 1512 }, 1513 1514 setOffset : function (value) { 1515 //console.log("fac.Visible.setOffset (" + [value] + ")"); 1516 1517 this.options.offset = value; 1518 }, 1519 1520 setAuto : function (value) { 1521 //console.log("fac.Visible.setAuto (" + [value] + ")"); 1522 1523 this.status.auto = Boolean(value); 1524 1525 if (this.status.auto) { 1526 1527 this.env.window 1528 .on(this.getEventName([ 1529 this.events.resize, 1530 this.events.orientationchange, 1531 this.events.load, 1532 this.events.scroll, 1533 ]), this.update.bind(this)); 1534 1535 } 1536 else { 1537 1538 this.env.window 1539 .off(this.getID()); 1540 1541 } 1542 }, 1543 1544 update : function () { 1545 //console.log("fac.Visible.update(" + [] + ")"); 1546 1547 this.status.window_height = window.innerHeight; 1548 this.status.scroll_top = this.env.window.scrollTop(); 1549 1550 for (var i = 0; i < this.options.items.length; i++) { 1551 var item = this.options.items[i]; 1552 item.update(this.status.scroll_top, this.status.window_height); 1553 } 1554 1555 this.check_all_visible(); 1556 this.check_all_over(); 1557 this.check_all_collide(); 1558 1559 for (var i = 0; i < this.options.items.length; i++) { 1560 1561 var item = this.options.items[i]; 1562 1563 if (!this.options.class_target && this.options.group) { 1564 1565 if (this.status.all_visible) { 1566 item.setVisibleClass(); 1567 } 1568 else { 1569 item.setHiddenClass(); 1570 } 1571 1572 if (this.status.all_over) { 1573 item.setOverClass(); 1574 } 1575 else { 1576 item.setBelowClass(); 1577 } 1578 1579 if (this.status.all_collide) { 1580 item.setCollideClass(); 1581 } 1582 else { 1583 item.setApartClass(); 1584 } 1585 1586 } 1587 } 1588 }, 1589 1590 destroy : function () { 1591 //console.log("fac.Visible.destroy (" + [] + ")"); 1592 1593 this.setAuto(false); 1594 1595 this.status.all_visible = false; 1596 this.status.all_over = false; 1597 this.status.all_collide = false; 1598 1599 if (this.options.class_target) { 1600 this.options.class_target 1601 .removeClass([ 1602 this.options.visible_class, 1603 this.options.hidden_class, 1604 this.options.over_class, 1605 this.options.collide_class, 1606 this.options.apart_class 1607 ]); 1608 } 1609 1610 for (var i = 0; i < this.options.items.length; i++) { 1611 var item = this.options.items[i]; 1612 item.destroy(); 1613 } 1614 }, 1615 1616 getOffset : function () { 1617 //console.log("fac.Visible.getOffset (" + [] + ")"); 1618 1619 if ($.isFunction(this.options.offset)) { 1620 return this.options.offset(); 1621 } 1622 else if (!isNaN(this.options.offset)) { 1623 return this.options.offset; 1624 } 1625 else if ($(this.options.offset).length > 0) { 1626 return -$(this.options.offset).outerHeight(); 1627 } 1628 1629 return 0; 1630 }, 1631 1632 getID : function (suffix) { 1633 //console.log("fac.Visible.getID (" + [suffix] + ")"); 1634 1635 suffix = suffix !== void 0 ? suffix : ""; 1636 1637 var id = this.id + suffix; 1638 1639 return id; 1640 }, 1641
1642 getEventName : function (name, suffix) { 1643 //console.log("fac.Visible.getEventName (" + [name, suffix] + ")"); 1644 1645 name = $.isArray(name) ? name.join(" ") : name; 1646 name = (name.trim() + " ").replace(/ /g, this.getID(suffix) + " "); 1647 1648 return name; 1649 }, 1650 1651 //Visible 1652 checkAllVisible : function () { 1653 //console.log("fac.Visible.checkAllVisible(" + [] + ")"); 1654 1655 var is_all_visible = true; 1656 1657 for (var i = 0; i < this.options.items.length; i++) { 1658 1659 var item = this.options.items[i]; 1660 1661 if (is_all_visible) { 1662 var visible = item.status.visible; 1663 if (!visible) is_all_visible = false; 1664 } 1665 1666 } 1667 1668 if (is_all_visible) { 1669 this.allVisible(); 1670 } 1671 else { 1672 this.allHidden(); 1673 } 1674 }, 1675 1676 allVisible : function () { 1677 //console.log("fac.Visible.allVisible (" + [] + ")"); 1678 1679 if (this.status.all_visible === true) return; 1680 if (this.options.onece) this.check_all_visible = function () {}; 1681 if (this.options.class_target) this.setAllVisibleClass(); 1682 1683 this.status.all_visible = true; 1684 1685 this.self.trigger(fac.Visible.ON_ALL_VISIBLE, [this]); 1686 }, 1687 1688 allHidden : function () { 1689 //console.log("fac.Visible.allHidden (" + [] + ")"); 1690 1691 if (this.status.all_visible === false) return; 1692 if (this.options.class_target) this.setAllHiddenClass(); 1693 1694 this.status.all_visible = false; 1695 1696 this.self.trigger(fac.Visible.ON_ALL_HIDDEN, [this]); 1697 }, 1698 1699 setAllVisibleClass : function () { 1700 //console.log("fac.Visible.setAllVisibleClass(" + [] + ")"); 1701 1702 this.options.class_target 1703 .removeClass(this.options.hidden_class) 1704 .addClass(this.options.visible_class); 1705 }, 1706 1707 setAllHiddenClass : function () { 1708 //console.log("fac.Visible.setAllHiddenClass(" + [] + ")"); 1709 1710 this.options.class_target 1711 .removeClass(this.options.visible_class) 1712 .addClass(this.options.hidden_class); 1713 }, 1714 1715 //Over 1716 checkAllOver : function () { 1717 //console.log("fac.Visible.checkAllOver(" + [] + ")"); 1718 1719 var is_all_over = true; 1720 1721 for (var i = 0; i < this.options.items.length; i++) { 1722 1723 var item = this.options.items[i]; 1724 1725 if (is_all_over) { 1726 var is_over = item.status.over; 1727 if (!is_over) is_all_over = false; 1728 } 1729 1730 } 1731 1732 if (is_all_over) { 1733 this.allOver(); 1734 } 1735 else { 1736 this.allBelow(); 1737 } 1738 }, 1739 1740 allOver : function () { 1741 //console.log("fac.Visible.Item.allOver(" + [] + ")"); 1742 1743 if (this.status.all_over === true) return; 1744 if (this.options.onece) this.check_all_visible = function () {}; 1745 if (this.options.class_target) this.setAllOverClass(); 1746 1747 this.status.all_over = true; 1748 1749 this.self.trigger(fac.Visible.ON_ALL_OVER, [this]); 1750 }, 1751 1752 allBelow : function () { 1753 //console.log("fac.Visible.Item.allBelow(" + [] + ")"); 1754 1755 if (this.status.all_over === false) return; 1756 if (this.options.class_target) this.setAllBelowClass(); 1757 1758 this.status.all_over = false; 1759 1760 this.self.trigger(fac.Visible.ON_ALL_BELOW, [this]); 1761 }, 1762 1763 setAllOverClass : function () { 1764 //console.log("fac.Visible.setAllOverClass(" + [] + ")"); 1765 1766 this.options.class_target 1767 .addClass(this.options.over_class); 1768 }, 1769 1770 setAllBelowClass : function () { 1771 //console.log("fac.Visible.setAllBelowClass(" + [] + ")"); 1772 1773 this.options.class_target 1774 .removeClass(this.options.over_class); 1775 }, 1776 1777 //Collide 1778 checkAllCollide : function () { 1779 //console.log("fac.Visible.checkAllCollide(" + [] + ")"); 1780 1781 var is_all_collide = true; 1782 1783 for (var i = 0; i < this.options.items.length; i++) { 1784 1785 var item = this.options.items[i]; 1786 1787 if (is_all_collide) { 1788 var is_collide = item.status.collide; 1789 if (!is_collide) is_all_collide = false; 1790 } 1791 1792 } 1793 1794 if (is_all_collide) { 1795 this.allCollide(); 1796 } 1797 else { 1798 this.allApart(); 1799 } 1800 }, 1801 1802 allCollide : function () { 1803 //console.log("fac.Visible.Item.allCollide(" + [] + ")"); 1804 1805 if (this.status.all_collide === true) return; 1806 if (this.options.onece) this.check_all_collide = function () {}; 1807 if (this.options.class_target) this.setAllCollideClass(); 1808 1809 this.status.all_collide = true; 1810 1811 this.self.trigger(fac.Visible.ON_ALL_COLLIDE, [this]); 1812 }, 1813 1814 allApart : function () { 1815 //console.log("fac.Visible.Item.allApart(" + [] + ")"); 1816 1817 if (this.status.all_collide === false) return; 1818 if (this.options.class_target) this.setAllApartClass(); 1819 1820 this.status.all_collide = false; 1821 1822 this.self.trigger(fac.Visible.ON_ALL_APART, [this]); 1823 }, 1824 1825 setAllCollideClass : function () { 1826 //console.log("fac.Visible.setAllCollideClass(" + [] + ")"); 1827 1828 this.options.class_target 1829 .removeClass(this.options.apart_class) 1830 .addClass(this.options.collide_class); 1831 }, 1832 1833 setAllApartClass : function () { 1834 //console.log("fac.Visible.setAllApartClass(" + [] + ")"); 1835 1836 this.options.class_target 1837 .removeClass(this.options.collide_class) 1838 .addClass(this.options.apart_class); 1839 } 1840 1841}; 1842 1843/* fac.Visible.Item */ 1844 1845fac.Visible.Item = function (parent, target, options) { 1846 //console.log("fac.Visible.Item(" + [parent, target, options] + ")"); 1847 1848 this.initialize(parent, target, options); 1849}; 1850 1851fac.Visible.Item.prototype = { 1852 1853 parent : null, 1854 target : null, 1855 class_target : null, 1856 1857 status : { 1858 top : null, 1859 height : null, 1860 visible : null, 1861 over : null, 1862 collide : null, 1863 }, 1864 1865 is_visible : null, 1866 is_over : null, 1867 is_collide : null, 1868 check_visible : function () {}, 1869 check_over : function () {}, 1870 check_collide : function () {}, 1871 1872 initialize : function (parent, target, options) { 1873 //console.log("fac.Visible.Item.initialize(" + [parent, target, options] + ")"); 1874 1875 var $ = parent.env.$; 1876 1877 this.parent = parent; 1878 this.target = $(target); 1879 this.class_target = this.parent.options.class_target || this.target; 1880 this.status = $.extend({}, this.status); 1881 1882 if (this.parent.options.do_visible) this.check_visible = this.checkVisible; 1883 if (this.parent.options.do_over) this.check_over = this.checkOver; 1884 if (this.parent.options.do_collide) this.check_collide = this.checkCollide; 1885 1886 this.is_visible = this.parent.options.full_visible ? this.isVisibleFull : this.isVisibleParti
1886al; 1887 this.is_over = this.parent.options.full_visible ? this.isOverFull : this.isOverPartial; 1888 this.is_collide = this.isCollide; 1889 }, 1890 1891 start : function () { 1892 //console.log("fac.Visible.Item.start(" + [scroll_top, window_height] + ")"); 1893 1894 this.setStatus(); 1895 this.update(); 1896 }, 1897 1898 update : function (scroll_top, window_height) { 1899 //console.log("fac.Visible.Item.update(" + [scroll_top, window_height] + ")"); 1900 1901 this.setStatus(); 1902 this.check_visible(scroll_top, window_height); 1903 this.check_over(scroll_top, window_height); 1904 this.check_collide(scroll_top, window_height); 1905 }, 1906 1907 setStatus: function () { 1908 //console.log("fac.Visible.Item.setStatus(" + [] + ")"); 1909 1910 this.status.top = this.target.offset().top + this.parent.getOffset(); 1911 this.status.height = this.target.outerHeight(); 1912 }, 1913 1914 destroy : function () { 1915 //console.log("fac.Visible.Item.destroy(" + [] + ")"); 1916 1917 this.status.visible = 1918 this.status.over = 1919 this.status.collide = null; 1920 1921 this.class_target 1922 .removeClass([ 1923 this.parent.options.visible_class, 1924 this.parent.options.hidden_class, 1925 this.parent.options.over_class, 1926 this.parent.options.collide_class, 1927 this.parent.options.apart_class 1928 ]); 1929 }, 1930 1931 //Visible 1932 checkVisible : function (scroll_top, window_height) { 1933 //console.log("fac.Visible.Item.checkVisible(" + [scroll_top, window_center] + ")"); 1934 1935 var is_visible = this.is_visible(scroll_top, window_height); 1936 1937 if (is_visible) { 1938 this.visible(); 1939 } 1940 else { 1941 this.hidden(); 1942 } 1943 }, 1944 1945 isVisiblePartial : function (scroll_top, window_height) { 1946 //console.log("fac.Visible.Item.isVisiblePartial(" + [scroll_top, window_height] + ")"); 1947 1948 var item_top = this.status.top; 1949 var item_bottom = this.status.top + this.status.height; 1950 var over_top = item_top > scroll_top + window_height; 1951 var over_bottom = item_bottom < scroll_top; 1952 var is_visible = !over_top && !over_bottom; 1953 1954 return is_visible; 1955 }, 1956 1957 isVisibleFull : function (scroll_top, window_height) { 1958 //console.log("fac.Visible.Item.isVisibleFull(" + [scroll_top, window_height] + ")"); 1959 1960 var item_top = this.status.top; 1961 var item_bottom = this.status.top + this.status.height; 1962 var over_top = item_top + this.status.height > scroll_top + window_height; 1963 var over_bottom = item_bottom - this.status.height < scroll_top; 1964 var is_visible = !over_top && !over_bottom; 1965 1966 return is_visible; 1967 }, 1968 1969 visible : function () { 1970 //console.log("fac.Visible.Item.visible(" + [] + ")"); 1971 1972 if (this.status.visible === true) return; 1973 if (this.parent.options.onece && !this.parent.options.group) this.check_visible = function () {}; 1974 if (!this.parent.options.group) this.setVisibleClass(); 1975 1976 this.status.visible = true; 1977 1978 this.parent.self.trigger(fac.Visible.ON_VISIBLE, [this]); 1979 }, 1980 1981 hidden : function () { 1982 //console.log("fac.Visible.Item.hidden(" + [] + ")"); 1983 1984 if (this.status.visible === false) return; 1985 if (!this.parent.options.group) this.setHiddenClass(); 1986 1987 this.status.visible = false; 1988 1989 this.parent.self.trigger(fac.Visible.ON_HIDDEN, [this]); 1990 }, 1991 1992 setVisibleClass : function () { 1993 //console.log("fac.Visible.Item.setVisibleClass(" + [] + ")"); 1994 1995 this.class_target 1996 .removeClass(this.parent.options.hidden_class) 1997 .addClass(this.parent.options.visible_class); 1998 }, 1999 2000 setHiddenClass : function () { 2001 //console.log("fac.Visible.Item.setHiddenClass(" + [] + ")"); 2002 2003 this.class_target 2004 .removeClass(this.parent.options.visible_class) 2005 .addClass(this.parent.options.hidden_class); 2006 }, 2007 2008 //Over 2009 checkOver : function (scroll_top, window_height) { 2010 //console.log("fac.Visible.Item.checkOver(" + [scroll_top, window_height] + ")"); 2011 2012 var is_over = this.is_over(scroll_top, window_height); 2013 2014 if (is_over) { 2015 this.over(); 2016 } 2017 else { 2018 this.below(); 2019 } 2020 }, 2021 2022 isOverPartial : function (scroll_top, window_height) { 2023 //console.log("fac.Visible.Item.isOverPartial(" + [scroll_top, window_height] + ")"); 2024 2025 var window_center = window_height * this.parent.options.border; 2026 var is_over = scroll_top + window_center > this.status.top; 2027 2028 return is_over; 2029 }, 2030 2031 isOverFull : function (scroll_top, window_height) { 2032 //console.log("fac.Visible.Item.isOverFull(" + [scroll_top, window_height] + ")"); 2033 2034 var window_center = window_height * this.parent.options.border; 2035 var item_bottom = this.status.top + this.status.height; 2036 var is_over = scroll_top + window_center > item_bottom; 2037 2038 return is_over; 2039 }, 2040 2041 over : function () { 2042 //console.log("fac.Visible.Item.over(" + [] + ")"); 2043 2044 if (this.status.over === true) return; 2045 if (this.parent.options.onece) this.check_over = function () {}; 2046 if (!this.parent.options.group) this.setOverClass(); 2047 2048 this.status.over = true; 2049 2050 this.parent.self.trigger(fac.Visible.ON_OVER, [this]); 2051 }, 2052 2053 below : function () { 2054 //console.log("fac.Visible.Item.below(" + [] + ")"); 2055 2056 if (this.status.over === false) return; 2057 if (!this.parent.options.group) this.setBelowClass(); 2058 2059 this.status.over = false; 2060 2061 this.parent.self.trigger(fac.Visible.ON_BELOW, [this]); 2062 }, 2063 2064 setOverClass : function () { 2065 //console.log("fac.Visible.Item.setOverClass(" + [] + ")"); 2066 2067 this.class_target 2068 .addClass(this.parent.options.over_class); 2069 }, 2070 2071 setBelowClass : function () { 2072 //console.log("fac.Visible.Item.setBelowClass(" + [] + ")"); 2073 2074 this.class_target 2075 .removeClass(this.parent.options.over_class); 2076 }, 2077 2078 //Collide 2079 checkCollide : function (scroll_top, window_height) { 2080 //console.log("fac.Visible.Item.checkCollide(" + [scroll_top, window_height] + ")"); 2081 2082 var is_collide = this.isCollide(scroll_top, window_height); 2083 2084 if (is_collide) { 2085 this.collide(); 2086 } 2087 else { 2088 this.apart(); 2089 } 2090 }, 2091 2092 isCollide : function (scroll_top, window_height) { 2093 //console.log("fac.Visible.Item.isCollide(" + [scroll_top, window_height] + ")"); 2094 2095 var item_top = this.status.top; 2096 var item_bottom = this.status.top + this.status.height; 2097 var border = scroll_top + window_height * this.parent.options.border; 2098 var inner_top = border >= item_top; 2099 var inner_bottom = border <= item_bottom; 2100 var is_collide = inner_top && inner_bottom; 2101 2102 return is_collide; 2103 }, 2104 2105 collide : function () { 2106 //console.log("fac.Visible.Item.collide(" + [] + ")"); 2107 2108 if (this.status.collide === true) return; 2109 if (this.parent.options.onece) this.check_collide = function () {}; 2110 if (!this.parent.options.group) this.setCollideClass(); 2111 2112 this.status.collide = true; 2113 2114 this.parent.self.trigger(fac.Visible.ON_COLLIDE, [this]); 2115 }, 2116 2117 apart : function () {
2118 //console.log("fac.Visible.Item.apart(" + [] + ")"); 2119 2120 if (this.status.collide === false) return; 2121 if (!this.parent.options.group) this.setApartClass(); 2122 2123 this.status.collide = false; 2124 2125 this.parent.self.trigger(fac.Visible.ON_APART, [this]); 2126 }, 2127 2128 setCollideClass : function () { 2129 //console.log("fac.Visible.Item.setCollideClass(" + [] + ")"); 2130 2131 this.class_target 2132 .removeClass(this.parent.options.apart_class) 2133 .addClass(this.parent.options.collide_class); 2134 }, 2135 2136 setApartClass : function () { 2137 //console.log("fac.Visible.Item.setApartClass(" + [] + ")"); 2138 2139 this.class_target 2140 .removeClass(this.parent.options.collide_class) 2141 .addClass(this.parent.options.apart_class); 2142 } 2143 2144}; 2145 2146 2147 2148/************************ 2149 fac.More 2150 ************************/ 2151 2152fac.More = function (target, options) { 2153 //console.log("fac.More(" + [target, options] + ")"); 2154 2155 this.initialize(target, options); 2156}; 2157 2158fac.More.NAME = "fac-more"; 2159fac.More.NAME_REGEXP = new RegExp("\\b" + fac.More.NAME + "-\\S+", "g"); 2160 2161fac.More.prototype = { 2162 2163 target : null, 2164 button : null, 2165 switcher : null, 2166 2167 options : { 2168 element : null, 2169 elements_num : null, 2170 more_text : "ãã£ã¨è¦ã", 2171 less_text : "éãã", 2172 }, 2173 2174 status : { 2175 mode : "height", 2176 height : null, 2177 scroll_height : null, 2178 over : false 2179 }, 2180 2181 timeout : null, 2182 2183 initialize : function (target, options) { 2184 //console.log("fac.More.initialize(" + [target, options] + ")"); 2185 2186 var p = this; 2187 2188 this.target = 2189 $(target).eq(0) 2190 .addClass(fac.More.NAME); 2191 2192 //Options 2193 this.options = $.extend({}, this.options, options); 2194 2195 //Status 2196 this.status = $.extend({}, this.status); 2197 if (this.options.elements_num !== null) { 2198 this.status.mode = "elements"; 2199 this.options.element = this.options.element !== null ? this.target.find(this.options.element) : this.target.find("> *"); 2200 this.options.elements_num = parseInt(this.options.elements_num); 2201 } 2202 2203 2204 var switcher_options = {}; 2205 2206 switch (this.status.mode) { 2207 2208 case "height" : 2209 var height = this.target.height(); 2210 var scroll_height = this.target[0].scrollHeight; 2211 this.status.over = scroll_height > height; 2212 switcher_options = {set_height:true}; 2213 break; 2214 2215 case "elements" : 2216 this.status.over = this.options.element.length > this.options.elements_num; 2217 switcher_options = {}; 2218 break; 2219 2220 } 2221 2222 var elements = $(); 2223 this.options.element.each(function (index) { 2224 if (index >= p.options.elements_num) { 2225 elements = elements.add(this); 2226 } 2227 }); 2228 elements.addClass(fac.More.NAME + "-item"); 2229 2230 2231 if (this.status.over) { 2232 2233 this.target.addClass(fac.More.NAME + "-" + this.status.mode); 2234 2235 this.button = 2236 $('<button></button>') 2237 .addClass(fac.More.NAME + "-button") 2238 .text(this.options.more_text) 2239 .appendTo(this.target); 2240 2241 this.switcher = new fac.Switcher(this.target, "." + fac.More.NAME + "-button", "", switcher_options); 2242 $(this.switcher) 2243 .on(fac.Switcher.ON_SHOW, function (event, index) { p.show(index); }) 2244 .on(fac.Switcher.ON_HIDE, function (event, index) { p.hide(index); }); 2245 this.switcher.start(); 2246 2247 } 2248 else { 2249 2250 this.target.removeClass(fac.More.NAME); 2251 2252 } 2253 }, 2254 2255 //Public 2256 2257 destroy : function () { 2258 //console.log("fac.More.destroy(" + [] + ")"); 2259 2260 clearTimeout(this.timeout); 2261 2262 if (this.status.over) { 2263 2264 this.target 2265 .removeClass(fac.More.NAME) 2266 .removeClass(this.removeMyClasses); 2267 2268 this.options.element 2269 .removeClass(this.removeMyClasses); 2270 2271 this.button.remove(); 2272 2273 $(this.switcher) 2274 .off(fac.Switcher.ON_SHOW) 2275 .off(fac.Switcher.ON_HIDE); 2276 2277 for (var i = 0; i < this.switcher.items.length; i++) { 2278 2279 var container = this.switcher.items[i].container; 2280 container.css({height:""}); 2281 2282 } 2283 2284 } 2285 }, 2286 2287 show : function (index) { 2288 //console.log("fac.More.show(" + [index] + ")"); 2289 2290 var p = this; 2291 var item = this.switcher.items[index]; 2292 var container = item.container; 2293 var button = item.button; 2294 2295 container.addClass(fac.More.NAME + "-show"); 2296 button.text(this.options.less_text); 2297 2298 switch (this.status.mode) { 2299 2300 case "height" : 2301 2302 break; 2303 2304 case "elements" : 2305 2306 clearTimeout(this.timeout); 2307 2308 var from_height = this.target.height(); 2309 2310 this.options.element.removeClass(fac.More.NAME + "-hidden"); 2311 2312 var to_height = this.target.height(); 2313 var delay = parseFloat(container.css("transition-duration")) + parseFloat(container.css("transition-delay")); // use seconds 2314 2315 container.css({height:from_height}); 2316 this.timeout = setTimeout(function () { 2317 container.css({height:to_height}); 2318 p.timeout = setTimeout(function () { 2319 container.css({height:""}); 2320 }, delay * 1000); 2321 }, 20); 2322 2323 break; 2324 2325 } 2326 }, 2327 2328 hide : function (index) { 2329 //console.log("fac.More.hide(" + [index] + ")"); 2330 2331 var p = this; 2332 var item = this.switcher.items[index]; 2333 var container = item.container; 2334 var button = item.button; 2335 2336 container.removeClass(fac.More.NAME + "-show"); 2337 button.text(this.options.more_text); 2338 2339 switch (this.status.mode) { 2340 2341 case "height" : 2342 2343 break; 2344 2345 case "elements" : 2346 2347 clearTimeout(this.timeout); 2348 2349 var from_height = this.target.height(); 2350 var hidden_elements = this.options.element.filter("." + fac.More.NAME + "-item"); 2351 2352 hidden_elements.addClass(fac.More.NAME + "-hidden"); 2353 2354 var to_height = this.target.height(); 2355 var delay = parseFloat(container.css("transition-duration")) + parseFloat(container.css("transition-delay")); // use seconds 2356 2357 hidden_elements.removeClass(fac.More.NAME + "-hidden"); 2358 2359 container.css({height:from_height}); 2360 this.timeout = setTimeout(function () { 2361 container.css({height:to_height}); 2362 p.timeout = setTimeout(function () { 2363 container.css({height:""}); 2364 hidden_elements.addClass(fac.More.NAME + "-hidden"); 2365 }, delay * 1000); 2366 }, 20); 2367 2368 if (!this.switcher.status.first) { 2369 var window_height = window.innerHeight; 2370 var scroll_to = hidden_elements.first().offset().top - window_height + button.outerHeight() + window_height / 4; 2371 fac.scroller.scrollTo(scroll_to, null, {easing:"easeOutExpo"}); 2372 } 2373 2374 break; 2375 2376 } 2377 }, 2378 2379 //Private 2380
2381 removeMyClasses : function (index, class_name) { 2382 //console.log("fac.Gallery.removeMyClasses (" + [index, class_name] + ")"); 2383 2384 var remove_class = (class_name.match(fac.More.NAME_REGEXP) || []).join(' '); 2385 2386 return remove_class; 2387 }, 2388 2389}; 2390 2391 2392 2393/************************ 2394 fac.Gallery 2395 Version: 2.2.2 2396 ex) 2397 var gallery = new fac.Gallery(selector, {transition:"none", duration:0.8, delay:3.0, easing:"cubic-bezier(0.645, 0.045, 0.355, 1)", loop:"auto", auto:false, rapid:true, nav:true, dummies:0}); 2398 gallery.start(); 2399 ************************/ 2400 2401fac.Gallery = function (selector, options) { 2402 //console.log("fac.Gallery (" + [selector, options] + ")"); 2403 2404 this.initialize(selector, options); 2405}; 2406 2407fac.Gallery.NAME = "fac-gallery"; 2408fac.Gallery.NAME_REGEXP = new RegExp("\\b" + fac.Gallery.NAME + "-\\S+", "g"); 2409fac.Gallery.INCREMENT = 0; 2410fac.Gallery.ON_SELECT = "onSelect"; 2411fac.Gallery.ON_SELECTED = "onSelected"; 2412fac.Gallery.ON_OVER_SELECT = "onOverSelect"; 2413fac.Gallery.ON_OVER_SLIDE = "onOverSlide"; 2414fac.Gallery.ON_PREVIOUS = "onPrevious"; 2415fac.Gallery.ON_NEXT = "onNext"; 2416fac.Gallery.ON_DRAGGED = "onDragged"; 2417 2418fac.Gallery.prototype = { 2419 2420 env : { 2421 $ : null, 2422 document : null, 2423 window : null, 2424 }, 2425 2426 events : { 2427 click : null, 2428 mousedown : null, 2429 touchstart : null, 2430 touchend : null, 2431 touchmove : null, 2432 resize : null, 2433 orientationchange : null 2434 }, 2435 2436 options : { 2437 transition : "none", 2438 select : 1, 2439 min : null, 2440 max : null, 2441 duration : 0.8, 2442 duration_flick : null, 2443 delay : 3.0, 2444 easing : "cubic-bezier(0.645, 0.045, 0.355, 1)", 2445 loop : "auto", 2446 auto : false, 2447 rapid : true, 2448 nav : true, 2449 drag : "auto", 2450 start_drag_on : 20, 2451 start_slide_on : 30, 2452 lock_slide_on : 20, 2453 items_in_group : 1, 2454 dummies : 0, 2455 pad : true, 2456 set_item_size : false, 2457 element_list : null, 2458 element_items : null, 2459 direction : "horizontal" 2460 }, 2461 2462 status : { 2463 select : null, 2464 last_select : null, 2465 min : null, 2466 max : null, 2467 selecting : null, 2468 draggable : null, 2469 dragging : null, 2470 dragged : null, 2471 slide_locked : null, 2472 pane_size : null, 2473 list_size : null, 2474 backward_end : null, 2475 forward_end : null, 2476 reversed : null, 2477 over : null, 2478 start_page_pos : null, 2479 start_pos : null, 2480 relative_pos : null, 2481 }, 2482 2483 property : { 2484 size : null, 2485 size_caps : null, 2486 axis : null, 2487 axis_cross : null, 2488 pos : null, 2489 }, 2490 2491 id : null, 2492 self : null, 2493 container : null, 2494 slider : null, 2495 element_list : null, 2496 element_items : null, 2497 element_items_all : null, 2498 element_groups : null, 2499 nav : null, 2500 nav_items : null, 2501 panes : null, 2502 delay_timeout : null, 2503 2504 initialize : function (selector, options) { 2505 //console.log("fac.Gallery.initialize (" + [selector, options] + ")"); 2506 2507 this.env.$ = 2508 options && options.jquery ? options.jquery : 2509 this.env.$ ? this.env.$ : 2510 fac.$ ? fac.$ : 2511 jQuery ? jQuery : 2512 $; 2513 2514 if (!this.env.$.fn || !this.env.$.fn.jquery) { 2515 console.warn("jQuery required"); 2516 return; 2517 } 2518 2519 2520 var i,num; 2521 var p = this; 2522 var $ = this.env.$; 2523 var target = $(selector); 2524 2525 this.id = "." + fac.Gallery.NAME + "-" + fac.Gallery.INCREMENT++; 2526 this.self = $(this); 2527 2528 //Env 2529 this.env.document = this.env.document ? this.env.document : fac.document ? fac.document : $(document); 2530 this.env.window = this.env.window ? this.env.window : fac.window ? fac.window : $(window); 2531 2532 //Events 2533 this.events = $.extend({}, this.events); 2534 2535 this.events.click = this.events.click ? this.events.click : fac.events ? fac.events.click : "click"; 2536 this.events.mousedown = this.events.mousedown ? this.events.mousedown : !fac.is_smartdevice ? "mousedown touchstart" : "touchstart"; 2537 this.events.touchstart = this.events.touchstart ? this.events.touchstart : "touchstart"; 2538 this.events.touchend = this.events.touchend ? this.events.touchend : "touchend"; 2539 this.events.touchmove = this.events.touchmove ? this.events.touchmove : "touchmove"; 2540 this.events.resize = this.events.resize ? this.events.resize : "resize"; 2541 this.events.orientationchange = this.events.orientationchange ? this.events.orientationchange : "orientationchange"; 2542 2543 //Options 2544 this.options = $.extend({}, this.options, options); 2545 2546 switch (this.options.transition) { 2547 2548 case "slide" : 2549 break; 2550 2551 case "none" : 2552 default : 2553 this.options.drag = false; 2554 this.options.dummies = 0; 2555 break; 2556 2557 } 2558 2559 this.options.duration_flick = this.options.duration_flick !== null ? this.options.duration_flick : this.options.duration / 2; 2560 this.options.items_in_group = Math.max(this.options.items_in_group, 1); 2561 this.options.element_list = target; 2562 this.options.element_items = this.options.element_list.find("> *"); 2563 if (this.options.loop === "auto") { 2564 this.options.loop = this.options.element_items.length > this.options.items_in_group ? true : false; 2565 } 2566 if (this.options.drag === "auto") { 2567 this.options.drag = ("ontouchend" in window); 2568 } 2569 this.options.dummies = this.options.loop ? (this.options.dummies || 0) * this.options.items_in_group : 0; 2570 2571 //Elements 2572 this.container = 2573 $('<div></div>') 2574 .addClass(fac.Gallery.NAME) 2575 .addClass(fac.Gallery.NAME + "-transition-" + this.options.transition) 2576 .addClass(fac.Gallery.NAME + "-initialize") 2577 .insertAfter(target); 2578 2579 if (this.options.transition === "slide") { 2580 this.container 2581 .addClass(fac.Gallery.NAME + "-direction-" + this.options.direction); 2582 } 2583 2584 this.slider = 2585 $('<div></div>') 2586 .addClass(fac.Gallery.NAME + "-slider") 2587 .appendTo(this.container); 2588 2589 this.element_list = 2590 this.options.element_list 2591 .addClass(fac.Gallery.NAME + "-list") 2592 .appendTo(this.slider); 2593 2594 this.element_items = 2595 this.options.element_items 2596 .addClass(fac.Gallery.NAME + "-item"); 2597 2598 this.element_items_all = this.element_items; 2599 this.element_groups = []; 2600 2601 this.nav = 2602 $('<div></div>') 2603 .addClass(fac.Gallery.NAME + "-nav") 2604 .appendTo(this.container); 2605 2606 this.panes = []; 2607 2608 //Status 2609 this.status = $.extend({}, this.status); 2610 this.status.min = this.options.min !== null ? this.options.min : 0; 2611 this.status.min = Math.max(0, this.status.min); 2612 this.status.max = this.options.max !== null ? this.options.max : Math.ceil(this.element_items.length / this.options.items_in_group) - 1; 2613 this.status.max = Math.max(0, this.status.max); 2614 this.status.reversed = this.element_list.css("flex-direction").indexOf("-reverse") !== -1; 2615 2616 //Property 2617 this.property = $.extend({}, this.property); 2618 2619 switch (this.options.direction) { 2620 2621 case "vertical" : 2622 this.property.size = "height"; 2623 this.property.size_caps = "Height"; 2624 this.property.axis = "Y"; 2625 this.property.axis_cross = "X"; 2626 this.property.pos = "top"; 2627 break; 2628 2629 case "hrizontal" : 2630 default : 2631 this.property.size = "width"; 2632 this.property.size_caps = "Width"; 2633 this.property.axis = "X"; 2634 this.property.axis_cross = "Y"; 2635 this.property.pos = "left"; 2636 break; 2637 2638 } 2639 2640 2641 if (this.status.max < 1) this.container.addClass(fac.Gallery.NAME + "-less"); 2642 2643 2644 //Item 2645 this.element_items 2646 .each(function (index) { 2647 2648 var pane = new fac.Gallery.Pane(p, $(this)); 2649 p.panes.push(pane); 2650 2651 }); 2652 2653 //Padding 2654 if (this.options.pad) { 2655 2656 var tagname = this.element_items.prop("tagName"); 2657 var remainder = this.element_items.length % this.options.items_in_group; 2658 var pad_num = remainder > 0 ? this.options.items_in_group - remainder : 0; 2659 2660 for (i = this.element_items.length; i < this.element_items.length + pad_num; i++) { 2661 2662 num = i + 1; 2663 2664 var pad = 2665 $('<' + tagname + '></' + tagname + '>') 2666 .addClass(fac.Gallery.NAME + "-item") 2667 .addClass(fac.Gallery.NAME + "-pad") 2668 .appendTo(this.element_list); 2669 2670 this.element_items_all = 2671 this.element_items_all 2672 .add(pad); 2673 } 2674 2675 } 2676 2677 //Group 2678 for (i = 0; i < this.element_items_all.length; i++) { 2679 2680 num = Math.floor(i / this.options.items_in_group) + 1; 2681 2682 this.element_items_all.eq(i) 2683 .addClass(fac.Gallery.NAME + "-group-" + num); 2684 2685 } 2686 2687 //Nav 2688 if (this.options.nav) { 2689 2690 $('<button></button>') 2691 .addClass(fac.Gallery.NAME + "-previous") 2692 .text("<") 2693 .appendTo(this.nav) 2694 .on(this.getEventName(this.events.mousedown), function (event) {return;}) 2695 .on(this.getEventName(this.events.click), this.previous.bind(this, void 0)); 2696 2697 var nav_list = 2698 $('<ol></ol>') 2699 .appendTo(this.nav); 2700 2701 $('<button></button>') 2702 .addClass(fac.Gallery.NAME + "-next") 2703 .text(">") 2704 .appendTo(this.nav) 2705 .on(this.getEventName(this.events.mousedown), function (event) {return;}) 2706 .on(this.getEventName(this.events.click), this.next.bind(this, void 0)); 2707 2708 for (i = 0; i <= this.status.max; i++) { 2709 2710 $('<li></li>') 2711 .text(i) 2712 .appendTo(nav_list) 2713 .on(this.getEventName(this.events.click), this.select.bind(this, i, void 0, void 0, void 0)); 2714 2715 } 2716 2717 this.nav_items = 2718 nav_list.find("> li"); 2719 } 2720 2721 switch (this.options.transition) { 2722 2723 case "slide" : 2724 2725 //Dummies 2726 var new_element_all = this.element_items_all; 2727 2728 for (i = 0; i < this.options.dummies; i++) { 2729 2730 num = i + 1; 2731 2732 //backward 2733 var backward = 2734 this.element_items_all.eq(this.element_items_all.length - i - 1).clone() 2735 .addClass(fac.Gallery.NAME + "-dummy") 2736 .prependTo(this.element_list); 2737 2738 //forward 2739 var forward = 2740 this.element_items_all.eq(i % this.element_items_all.length).clone() 2741 .addClass(fac.Gallery.NAME + "-dummy") 2742 .appendTo(this.element_list); 2743 2744 new_element_all = 2745 new_element_all 2746 .add(backward) 2747 .add(forward); 2748 2749 } 2750 2751 this.element_items_all = new_element_all; 2752 2753 var area_size = this.element_items_all.length * 100 / this.options.items_in_group; 2754 var dummy_offset = (-100 * this.options.dummies / this.options.items_in_group) + "%"; 2755 var property = {position:"relative"}; 2756 property[this.property.size] = area_size + "%"; 2757 property[this.property.pos] = dummy_offset; 2758 this.element_list.css(property); 2759 2760 break; 2761 2762 } 2763 2764 //Set item size 2765 if (this.options.set_item_size) { 2766 var item_size = 100 / this.element_items_all.length; 2767 this.element_items_all.css(this.property.size, item_size + "%"); 2768 } 2769 }, 2770 2771 //Public Methods 2772 2773 start : function () { 2774 //console.log("fac.Gallery.start (" + [] + ")"); 2775 2776 //Events 2777 this.setDraggable(this.options.drag); 2778 2779 this.env.window 2780 .on(this.getEventName([this.events.resize, this.events.orientationchange]), this.resize.bind(this)); 2781 this.resize(); 2782 2783 //Start 2784 this.status.select = this.options.select; 2785 this.select(this.options.select - 1, 0); 2786 }, 2787 2788 destroy : function () { 2789 //console.log("fac.Gallery.destroy (" + [] + ")"); 2790 2791 clearTimeout(this.delay_timeout); 2792 2793 //Remove Events 2794 this.env.window 2795 .off(this.getID()); 2796 2797 this.env.document 2798 .off(this.getID("-drag")); 2799 2800 this.container 2801 .off(this.getID("-draggable")); 2802 2803 this.element_list 2804 .off(this.getID("-draggable")); 2805 2806 //Remove Elements 2807 this.element_items_all.filter("." + fac.Gallery.NAME + "-dummy") 2808 .remove(); 2809 2810 this.element_items_all.filter("." + fac.Gallery.NAME + "-pad") 2811 .remove(); 2812 2813 //Remove Classes 2814 this.element_items_all
2815 .removeClass(this.removeMyClasses); 2816 2817 this.element_list 2818 .removeClass(this.removeMyClasses); 2819 2820 //Restore 2821 var css = {position:"", transform:"", transition:""}; 2822 css[this.property.size] = ""; 2823 css[this.property.pos] = ""; 2824 2825 this.element_list 2826 .css(css) 2827 .insertAfter(this.container); 2828 2829 this.container 2830 .remove(); 2831 }, 2832 2833 setDraggable : function (bool) { 2834 //console.log("fac.Gallery.setDraggable (" + [bool] + ")"); 2835 2836 this.status.draggable = Boolean(bool); 2837 2838 if (this.status.draggable) { 2839 2840 this.container 2841 .on(this.getEventName(this.events.touchstart, "-draggable"), this.areaPress.bind(this)) 2842 .on(this.getEventName(this.events.click, "-draggable"), this.areaClick.bind(this)); 2843 2844 this.element_list 2845 .on(this.getEventName(this.events.touchstart, "-draggable"), this.areaPress.bind(this)) 2846 .on(this.getEventName(this.events.click, "-draggable"), this.areaClick.bind(this)); 2847 } 2848 else { 2849 2850 this.container 2851 .off(this.getID("-draggable")); 2852 2853 this.element_list 2854 .off(this.getID("-draggable")); 2855 } 2856 }, 2857 2858 next : function (is_rapid) { 2859 //console.log("fac.Gallery.next (" + [is_rapid] + ")"); 2860 2861 var original_index = this.status.select + 1; 2862 2863 this.select(original_index, null, true, null, is_rapid); 2864 2865 this.self.trigger(fac.Gallery.ON_NEXT, [this.status.select, true, original_index]); 2866 2867 return false; 2868 }, 2869 2870 previous : function (is_rapid) { 2871 //console.log("fac.Gallery.previous (" + [is_rapid] + ")"); 2872 2873 var original_index = this.status.select - 1; 2874 2875 this.select(original_index, null, false, null, is_rapid); 2876 2877 this.self.trigger(fac.Gallery.ON_PREVIOUS, [this.status.select, false, original_index]); 2878 2879 return false; 2880 }, 2881 2882 select : function (index, duration, is_forward, is_force, is_rapid) { 2883 //console.log("fac.Gallery.select (" + [index, duration, is_forward, is_force, is_rapid] + ")"); 2884 2885 var rapid = typeof is_rapid === "boolean" ? is_rapid : this.options.rapid; 2886 2887 if (!rapid && this.status.selecting) return; 2888 2889 var min = this.status.min; 2890 var max = this.status.max; 2891 var next_index = this.normalizeIndex(index); 2892 2893 is_forward = 2894 typeof is_forward === "boolean" ? is_forward : 2895 next_index > this.status.select ? true : false; 2896 2897 if ((!is_forward && index < min) || (is_forward && index > max)) { 2898 this.self.trigger(fac.Gallery.ON_OVER_SELECT, [next_index, is_forward]); 2899 } 2900 2901 if (!is_force && next_index == this.status.select) return; 2902 2903 duration = typeof duration === "number" ? duration : this.options.duration; 2904 2905 //Container 2906 this.container 2907 .addClass(fac.Gallery.NAME + "-selecting") 2908 .removeClass(fac.Gallery.NAME + "-first") 2909 .removeClass(fac.Gallery.NAME + "-last"); 2910 2911 if (duration === 0) { 2912 this.container 2913 .addClass(fac.Gallery.NAME + "-instant"); 2914 } 2915 2916 if (next_index === min) { 2917 this.container 2918 .addClass(fac.Gallery.NAME + "-first"); 2919 } 2920 2921 if (next_index === max) { 2922 this.container 2923 .addClass(fac.Gallery.NAME + "-last"); 2924 } 2925 2926 //Item 2927 var last_group = this.container.hasClass(fac.Gallery.NAME + "-initialize") ? -1 : this.status.reversed ? max - this.status.select + 1 : this.status.select + 1; 2928 var last_items = this.element_items_all.filter("." + fac.Gallery.NAME + "-group-" + last_group); 2929 2930 var next_group = this.status.reversed ? max - next_index + 1 : next_index + 1; 2931 var next_items = this.element_items_all.filter("." + fac.Gallery.NAME + "-group-" + next_group); 2932 2933 this.element_items_all 2934 .removeClass(fac.Gallery.NAME + "-selected") 2935 .removeClass(fac.Gallery.NAME + "-last-selected"); 2936 2937 next_items.addClass(fac.Gallery.NAME + "-selected"); 2938 last_items.addClass(fac.Gallery.NAME + "-last-selected"); 2939 2940 //Nav 2941 if (this.options.nav) { 2942 2943 this.nav_items 2944 .removeClass(fac.Gallery.NAME + "-selected") 2945 .eq(next_index) 2946 .addClass(fac.Gallery.NAME + "-selected"); 2947 2948 } 2949 2950 2951 this.status.last_select = this.status.select; 2952 this.status.select = next_index; 2953 this.status.selecting = true; 2954 2955 this.self.trigger(fac.Gallery.ON_SELECT, [this.status.select, is_forward, this.status.last_select]); 2956 2957 //Transition 2958 switch (this.options.transition) { 2959 2960 case "slide" : 2961 2962 if (!is_force && this.options.loop && this.options.dummies > 0) { 2963 var is_first = !is_forward && next_index === max; 2964 var is_last = is_forward && next_index === min; 2965 next_index = 2966 is_first ? min - 1 : 2967 is_last ? max + 1 : 2968 next_index; 2969 } 2970 2971 var position = this.getPositionByIndex(next_index); 2972 var easing = is_force ? "cubic-bezier(0.215, 0.61, 0.355, 1)" : this.options.easing; 2973 2974 this.element_list 2975 .css({transform:"translate" + this.property.axis + "(" + position + "%)", transition:"transform " + duration + "s " + easing}); 2976 2977 break; 2978 2979 case "none" : 2980 default : 2981 2982 break; 2983 2984 } 2985 2986 clearTimeout(this.delay_timeout); 2987 this.delay_timeout = setTimeout(this.selectEnd.bind(this), duration * 1000); 2988 }, 2989 2990 //Private Methods 2991 2992 selectEnd : function () { 2993 //console.log("fac.Gallery.selectEnd (" + [] + ")"); 2994 2995 clearTimeout(this.delay_timeout); 2996 this.status.selecting = false; 2997 2998 this.container 2999 .removeClass(fac.Gallery.NAME + "-initialize") 3000 .removeClass(fac.Gallery.NAME + "-instant") 3001 .removeClass(fac.Gallery.NAME + "-selecting"); 3002 3003 switch (this.options.transition) { 3004 3005 case "slide" : 3006 3007 var position = this.getPositionByIndex(this.status.select); 3008 3009 this.element_list 3010 .css({transform:"translate" + this.property.axis + "(" + position + "%)", transition:""}); 3011 3012 break; 3013 3014 } 3015 3016 3017 this.self.trigger(fac.Gallery.ON_SELECTED, [this.status.select]); 3018 3019 3020 if (this.options.auto) this.delay_timeout = setTimeout(this.next.bind(this, void 0), this.options.delay * 1000); 3021 }, 3022 3023 normalizeIndex : function (index) { 3024 //console.log("fac.Gallery.normalizeIndex (" + [index] + ")"); 3025 3026 index = index === -0 ? 0 : index; 3027 3028 var min = this.status.min; 3029 var max = this.status.max; 3030 3031 if (this.options.loop) { 3032 index = index % (max + 1); 3033 if (index < min) index = max + (index - min) + 1; 3034 if (index > max) index = min + (index - max) - 1; 3035 } 3036 else { 3037 if (index < min) index = min; 3038 if (index > max) index = max; 3039 } 3040 3041 return index; 3042 }, 3043 3044 setSizes : function () { 3045 //console.log("fac.Gallery.setSizes (" + [] + ")"); 3046 3047 this.status.pane_size = this.container["outer" + this.property.size_caps](); 3048 this.status.list_size = this.status.pane_size * (this.status.max + 1); 3049 this.status.backward_end = 0; 3050 this.status.forward_end = -this.status.list_size + this.status.pane_size; 3051 }, 3052 3053 getPosition : function () { 3054 //console.log("fac.Gallery.getPosition (" + [] + ")"); 3055 3056 var position = this.element_list.position()[this.property.pos] + (this.status.pane_size * (this.options.dummies / this.options.items_in_group)); 3057 3058 return position; 3059 }, 3060 3061 getPositionByIndex : function (index) { 3062 //console.log("fac.Gallery.getPositionByIndex (" + [index] + ")"); 3063 3064 var position = -(index * this.options.items_in_group) * (100 / this.element_items_all.length); 3065 3066 return position; 3067 }, 3068 3069 getID : function (suffix) { 3070 //console.log("fac.Gallery.getID (" + [suffix] + ")"); 3071 3072 suffix = typeof suffix !== void 0 ? suffix : ""; 3073 3074 var id = this.id + suffix; 3075 3076 return id; 3077 }, 3078
3079 getEventName : function (name, suffix) { 3080 //console.log("fac.Gallery.getEventName (" + [name, suffix] + ")"); 3081 3082 var $ = this.env.$; 3083 3084 name = $.isArray(name) ? name.join(" ") : name; 3085 name = (name.trim() + " ").replace(/ /g, this.getID(suffix) + " "); 3086 3087 return name; 3088 }, 3089 3090 removeMyClasses : function (index, class_name) { 3091 //console.log("fac.Gallery.removeMyClasses (" + [index, class_name] + ")"); 3092 3093 var remove_class = (class_name.match(fac.Gallery.NAME_REGEXP) || []).join(" "); 3094 3095 return remove_class; 3096 }, 3097 3098 //Events 3099 3100 resize : function () { 3101 //console.log("fac.Gallery.resize (" + [] + ")"); 3102 3103 this.setSizes(); 3104 }, 3105 3106 areaPress : function (event) { 3107 //console.log("fac.Gallery.areaPress (" + [event] + ")"); 3108 3109 if (!this.options.rapid && this.status.selecting) return; 3110 3111 clearTimeout(this.delay_timeout); 3112 3113 this.setSizes(); 3114 this.setDraggable(false); 3115 3116 this.status.dragged = false; 3117 this.status.over = ""; 3118 this.status.start_page_pos = event.originalEvent.touches ? event.originalEvent.touches[0]["page" + this.property.axis] : event["page" + this.property.axis]; 3119 this.status.start_pos = this.getPosition(); 3120 this.status.start_page_pos_cross = event.originalEvent.touches ? event.originalEvent.touches[0]["page" + this.property.axis_cross] : event["page" + this.property.axis_cross]; 3121 this.status.relative_pos = 0; 3122 3123 this.env.document 3124 .on(this.getEventName(this.events.touchmove, "-drag"), this.areaDrag.bind(this)) 3125 .on(this.getEventName(this.events.touchend, "-drag"), this.areaRelease.bind(this)); 3126 }, 3127 3128 areaDrag : function (event) { 3129 //console.log("fac.Gallery.areaDrag (" + [event] + ")"); 3130 3131 3132 if (this.status.slide_locked) return; 3133 3134 3135 this.status.dragged = true; 3136 this.status.over = ""; 3137 3138 var page_pos = event.touches ? event.touches[0]["page" + this.property.axis] : event["page" + this.property.axis]; 3139 var page_pos_cross = event.touches ? event.touches[0]["page" + this.property.axis_cross] : event["page" + this.property.axis_cross]; 3140 var relative_pos = page_pos - this.status.start_page_pos; 3141 var relative_pos_cross = page_pos_cross - this.status.start_page_pos_cross; 3142 3143 if (!this.status.dragging && (Math.abs(relative_pos) > this.options.start_drag_on)) { 3144 this.status.dragging = true; 3145 } 3146 3147 if (!this.status.dragging && (Math.abs(relative_pos_cross) > this.options.lock_slide_on)) { 3148 this.status.dragged = false; 3149 this.status.slide_locked = true; 3150 return; 3151 } 3152 3153 if (this.status.dragging) { 3154 3155 var to_pos = this.status.start_pos + relative_pos; 3156 3157 if (to_pos > this.status.backward_end + this.options.start_slide_on) { 3158 this.status.over = "backward"; 3159 if (this.options.loop && this.options.dummies > 0) { 3160 while (to_pos >= this.status.backward_end) { 3161 to_pos -= this.status.list_size; 3162 } 3163 } 3164 else { 3165 to_pos -= (to_pos - this.status.backward_end) / 2; 3166 } 3167 } 3168 else if (to_pos < this.status.forward_end - this.options.start_slide_on) { 3169 this.status.over = "forward"; 3170 if (this.options.loop && this.options.dummies > 0) { 3171 while (to_pos <= this.status.forward_end) { 3172 to_pos += this.status.list_size; 3173 } 3174 } 3175 else { 3176 to_pos -= (to_pos - this.status.forward_end) / 2; 3177 } 3178 } 3179 3180 this.container 3181 .addClass(fac.Gallery.NAME + "-dragging"); 3182 3183 this.element_list 3184 .css({transform:"translate" + this.property.axis + "(" + Math.round(to_pos) + "px)", transition:"none"}); 3185 3186 this.status.relative_pos = relative_pos; 3187 3188 event.originalEvent.preventDefault(); 3189 return false; 3190 } 3191 }, 3192 3193 areaRelease : function (event) { 3194 //console.log("fac.Gallery.areaRelease (" + [event] + ")"); 3195 3196 var p = this; 3197 3198 this.status.dragging = false; 3199 this.status.slide_locked = false; 3200 3201 this.container 3202 .removeClass(fac.Gallery.NAME + "-dragging"); 3203 3204 this.env.document 3205 .off(this.getID("-drag")); 3206 3207 this.setDraggable(true); 3208 3209 3210 if (!this.status.dragged) return; 3211 3212 3213 var relative_pos = this.status.relative_pos; 3214 var to_pos = this.status.start_pos + relative_pos; 3215 3216 var index; 3217 var duration = this.options.duration_flick; 3218 var is_forward = relative_pos <= 0; 3219 var is_force = true; 3220 3221 if (Math.abs(relative_pos) > this.options.start_slide_on) { 3222 3223 var min = this.status.min; 3224 var max = this.status.max; 3225 var method = is_forward ? Math.ceil : Math.floor; 3226 3227 index = method(-to_pos / this.status.pane_size); 3228 3229 if (this.options.loop && this.options.dummies === 0) { 3230 if (index < min) index = min; 3231 if (index > max) index = max; 3232 } 3233 } 3234 else { 3235 index = this.status.select; 3236 } 3237 3238 this.select(index, duration, is_forward, is_force); 3239 3240 this.self.trigger(fac.Gallery.ON_DRAGGED, [index, is_forward]); 3241 3242 if (this.status.over !== "") { 3243 this.self.trigger(fac.Gallery.ON_OVER_SLIDE, [index, is_forward]); 3244 } 3245 3246 if (this.status.dragged) { 3247 event.originalEvent.preventDefault(); 3248 return false; 3249 } 3250 }, 3251 3252 areaClick : function (event) { 3253 //console.log("fac.Gallery.areaClick (" + [event] + ")"); 3254 3255 if (this.status.dragged) { 3256 event.originalEvent.preventDefault(); 3257 return false; 3258 } 3259 } 3260 3261}; 3262 3263/* fac.Gallery.Pane */ 3264 3265fac.Gallery.Pane = function (parent, target, options) { 3266 //console.log("fac.Gallery.Pane (" + [parent, target, options] + ")"); 3267 3268 this.initialize(parent, target, options); 3269}; 3270 3271fac.Gallery.Pane.prototype = { 3272 3273 parent : null, 3274 target : null, 3275 3276 initialize : function (parent, target, options) { 3277 //console.log("fac.Gallery.Pane.initialize (" + [parent, target, options] + ")"); 3278 3279 this.parent = parent; 3280 this.target = target; 3281 } 3282 3283}; 3284 3285 3286 3287/************************ 3288 fac.Popups 3289 requires: fac.Gallery 3290 ex) 3291 var popups = new fac.Popups("a.popup", {type:"image|html|youtube|gallery|clone", class:"popup", preload:false, gallery_options:{}}); 3292 popups.start(); 3293 ************************/ 3294 3295if (typeof fac === "undefined") var fac = function() {}; 3296 3297fac.Popups = function (selector, options) { 3298 //console.log("fac.Popups(" + [selector, options] + ")"); 3299 3300 this.initialize(selector, options); 3301}; 3302 3303fac.Popups.NAME = "fac-popups"; 3304fac.Popups.IMAGE_REGEX = /(\.gif|\.jpg|\.jpeg|\.png)(\?[^?#]*)?(#[^?#]*)?$/i; 3305fac.Popups.HTML_REGEX = /(\.html|\.htm|\.php|\/)(\?[^?#]*)?(#[^?#]*)?$/i; 3306fac.Popups.YOUTUBE_REGEX = /\/watch\?v=([-\w]{11})$/i; 3307fac.Popups.ON_READY = "onReady"; 3308fac.Popups.ON_SHOW = "onShow"; 3309fac.Popups.ON_HIDE = "onHide"; 3310 3311fac.Popups.IsImage = function (source) { 3312 //console.log("fac.Popups.IsImage(" + [source] + ")"); 3313 3314 var bool = fac.Popups.IMAGE_REGEX.test(source); 3315 3316 return bool; 3317}; 3318 3319fac.Popups.IsHtml = function (source) { 3320 //console.log("fac.Popups.IsHtml(" + [source] + ")"); 3321 3322 var bool = fac.Popups.HTML_REGEX.test(source); 3323 3324 return bool; 3325}; 3326 3327fac.Popups.IsYoutube = function (source) { 3328 //console.log("fac.Popups.IsYoutube(" + [source] + ")"); 3329 3330 var bool = fac.Popups.YOUTUBE_REGEX.test(source); 3331 3332 return bool; 3333}; 3334 3335fac.Popups.prototype = { 3336 3337 env : { 3338 $ : null, 3339 html : null, 3340 click : null 3341 }, 3342 3343 options : { 3344 type : "auto", 3345 preload : false, 3346 class : "", 3347 show_event : "click." + fac.Popups.NAME, 3348 hide_event : "click." + fac.Popups.NAME, 3349 change_cloned_tag : null, 3350 gallery_options : {} 3351 }, 3352 3353 status : { 3354 is_shown : false 3355 }, 3356 3357 self : null, 3358 buttons : null, 3359 popup : null, 3360 3361 items : null, 3362 trap_scrolling : null, 3363 3364 initialize : function (selector, options) { 3365 //console.log("fac.Popups.initialize(" + [selector, options] + ")"); 3366 3367 this.env.$ = 3368 options && options.jquery ? options.jquery : 3369 this.env.$ ? this.env.$ : 3370 fac.$ ? fac.$ : 3371 jQuery ? jQuery : 3372 $; 3373 3374 if (!this.env.$.fn || !this.env.$.fn.jquery) { 3375 console.warn("jQuery required"); 3376 return; 3377 } 3378 3379 3380 var $ = this.env.$; 3381 3382 this.self = $(this); 3383 this.buttons = $(selector); 3384 this.items = []; 3385 3386 //Env 3387 this.env.html = this.env.html ? this.env.html : fac.html ? fac.html : $("html"); 3388 this.env.click = this.env.click ? this.env.click : fac.events ? fac.events.click : "click"; 3389 3390 //Options 3391 this.options = $.extend({}, this.options, options); 3392 3393 //Status 3394 this.status = $.extend({}, this.status); 3395 3396 //Gallery 3397 var base = 3398 $('<ul></ul>') 3399 .appendTo("body"); 3400 3401 for (var i = 0; i < this.buttons.length; i++) { 3402 3403 var button = this.buttons.eq(i); 3404 var container = 3405 $('<li></li>') 3406 .appendTo(base); 3407 3408 //Type 3409 var type = this.options.type; 3410 var source = button.attr("href") || fac.Popups.NAME + "-" + i; 3411 3412 if (type === "auto") { 3413 type = 3414 fac.Popups.IsImage(source) ? "image" :
3415 fac.Popups.IsHtml(source) ? "html" : 3416 fac.Popups.IsYoutube(source) ? "youtube" : 3417 "clone"; 3418 } 3419 3420 //Button 3421 if (type !== "clone") { 3422 if (this.options.show_event === this.options.hide_event) { 3423 button 3424 .on("click." + fac.Popups.NAME, this.toggle.bind(this, i)); 3425 } 3426 else { 3427 button 3428 .on(this.options.show_event, this.show.bind(this, i)) 3429 .on(this.options.hide_event, this.hide.bind(this, i)); 3430 } 3431 } 3432 3433 //Item 3434 var item; 3435 3436 switch (type) { 3437 3438 case "image" : 3439 item = new fac.Popups.Image(this, source, container, this.options); 3440 break; 3441 3442 case "html" : 3443 item = new fac.Popups.Iframe(this, source, container, this.options); 3444 break; 3445 3446 case "youtube" : 3447 item = new fac.Popups.Youtube(this, source, container, this.options); 3448 break; 3449 3450 case "clone" : 3451 default : 3452 item = new fac.Popups.Clone(this, button, container, this.options); 3453 break; 3454 3455 } 3456 3457 this.items.push(item); 3458 3459 } 3460 3461 this.gallery = new fac.Gallery(base, this.options.gallery_options); 3462 3463 //Popup 3464 this.popup = 3465 this.gallery.container 3466 .addClass(fac.Popups.NAME) 3467 .addClass(this.options.class); 3468 3469 }, 3470 3471 //Public Methods 3472 3473 start : function () { 3474 //console.log("fac.Popups.start(" + [] + ")"); 3475 3476 var $ = this.env.$; 3477 3478 //Gallery 3479 for (var i = 0; i < this.items.length; i++) { 3480 3481 var item = this.items[i]; 3482 item.start(); 3483 3484 } 3485 3486 this.gallery.start(); 3487 3488 //Popup 3489 var background = 3490 $('<div></div>') 3491 .addClass(fac.Popups.NAME + "-background") 3492 .on(this.env.click, this.hide.bind(this)) 3493 .appendTo(this.popup); 3494 3495 var board = 3496 this.gallery.slider 3497 .addClass(fac.Popups.NAME + "-board"); 3498 3499 var button_close = 3500 $('<button></button>') 3501 .addClass(fac.Popups.NAME + "-close") 3502 .text("éãã") 3503 .on(this.env.click, this.hide.bind(this)) 3504 .appendTo(board); 3505 3506 this.trap_scrolling = new fac.TrapScrolling(board); 3507 this.trap_scrolling.start(); 3508 }, 3509 3510 toggle : function (select) { 3511 //console.log("fac.Popups.toggle(" + [select] + ")"); 3512 3513 if (this.status.is_shown) this.hide() 3514 else this.show(select); 3515 3516 return false; 3517 }, 3518 3519 show : function (select) { 3520 //console.log("fac.Popups.show(" + [select] + ")"); 3521 3522 if (this.status.is_shown) return false; 3523 3524 select = typeof select === "number" ? select : this.gallery.status.select; 3525 3526 this.gallery.select(select, 0, null, true); 3527 3528 var item = this.items[this.gallery.status.select]; 3529 3530 this.status.is_shown = true; 3531 3532 this.popup.addClass(fac.Popups.NAME + "-show"); 3533 3534 if (item.is_loaded && item.is_ready) { 3535 this.showContent(); 3536 } 3537 else { 3538 item.self 3539 .off(fac.Popups.ON_READY) 3540 .on(fac.Popups.ON_READY, this.showContent.bind(this)); 3541 item.load(); 3542 } 3543 3544 return false; 3545 }, 3546 3547 hide : function () { 3548 //console.log("fac.Popups.hide(" + [] + ")"); 3549 3550 if (!this.status.is_shown) return; 3551 3552 var item = this.items[this.gallery.status.select]; 3553 3554 this.status.is_shown = false; 3555 3556 this.env.html.removeClass(fac.Popups.NAME + "-show"); 3557 this.popup.removeClass(fac.Popups.NAME + "-show"); 3558 this.gallery.element_items.removeClass(fac.Gallery.NAME + "-selected"); 3559 3560 item.self.off(fac.Popups.ON_READY); 3561 item.hide(); 3562 3563 this.self.trigger(fac.Popups.ON_HIDE, [this]); 3564 3565 return false; 3566 }, 3567 3568 destroy : function () { 3569 //console.log("fac.Popups.destroy(" + [] + ")"); 3570 3571 this.hide(); 3572 this.trap_scrolling.stop(); 3573 3574 this.popup.remove(); 3575 3576 this.buttons.off("." + fac.Popups.NAME); 3577 }, 3578 3579 //Private Methods 3580 3581 showContent : function () { 3582 //console.log("fac.Popups.showContent(" + [] + ")"); 3583 3584 var item = this.items[this.gallery.status.select]; 3585 3586 item.show(); 3587 3588 this.env.html.addClass(fac.Popups.NAME + "-show"); 3589 3590 this.self.trigger(fac.Popups.ON_SHOW, [this]); 3591 3592 return false; 3593 } 3594 3595}; 3596 3597// fac.Popups.Clone 3598 3599fac.Popups.Clone = function (parent, button, container, options) { 3600 //console.log("fac.Popups.Clone(" + [parent, element, container, options] + ")"); 3601 3602 this.initialize(parent, button, container, options); 3603}; 3604 3605fac.Popups.Clone.prototype = { 3606 3607 self : null, 3608 parent : null, 3609 button : null, 3610 container : null, 3611 options : null, 3612 content : null, 3613 3614 is_loaded : null, 3615 is_ready : null, 3616 3617 initialize : function (parent, button, container, options) { 3618 //console.log("fac.Popups.Clone.initialize(" + [parent, button, container, options] + ")"); 3619 3620 var $ = parent.env.$; 3621 3622 this.self = $(this); 3623 this.parent = parent; 3624 this.button = button; 3625 this.container = container; 3626 this.options = options; 3627 }, 3628 3629 start : function () { 3630 //console.log("fac.Popups.Clone.start(" + [] + ")"); 3631 3632 this.is_loaded = false; 3633 this.is_ready = false; 3634 3635 if (this.options.preload) this.load(); 3636 3637 this.hide(); 3638 }, 3639 3640 load : function () { 3641 //console.log("fac.Popups.Clone.load(" + [] + ")"); 3642 3643 if (this.is_loaded) return; 3644 3645 var $ = this.parent.env.$; 3646 3647 this.is_loaded = true; 3648 3649 this.ready(); 3650 }, 3651 3652 ready : function () { 3653 //console.log("fac.Popups.Clone.ready(" + [] + ")"); 3654 3655 var p = this; 3656 3657 this.is_ready = true; 3658 3659 this.content = 3660 this.button.clone(true) 3661 .off("." + fac.Popups.NAME) 3662 .appendTo(this.container); 3663 3664 if (this.options.change_cloned_tag !== null) { 3665 3666 var new_content; 3667 var attributes = this.content.get(0).attributes; 3668 3669 if (this.options.change_cloned_tag === "") { 3670 new_content = 3671 this.container 3672 .append(this.content.find("> *")); 3673 } 3674 else { 3675 new_content = 3676 $("<" + this.options.change_cloned_tag + "></" + this.options.change_cloned_tag + ">") 3677 .append(this.content.find("> *")) 3678 .insertAfter(this.content); 3679 } 3680 3681 this.content.remove(); 3682 this.content = new_content; 3683 3684 for (var i = 0; i < attributes.length; i++) { 3685 var name = attributes[i].name; 3686 var value = attributes[i].value; 3687 if(name === "class") { 3688 this.content.addClass(value); 3689 } 3690 else { 3691 this.content.attr(name, value); 3692 } 3693 } 3694 3695 } 3696 3697 if (this.content.attr("id") !== void 0) { 3698 this.content.attr({id:fac.Popups.NAME + "-" + this.content.attr("id")}); 3699 } 3700 3701 this.content.find("*[for]").each(function () { 3702 var for_element = $(this); 3703 var id = for_element.attr("for"); 3704 var new_id = fac.Popups.NAME + "-" + id; 3705 var input_element = p.content.find("#" + id); 3706 for_element.attr({for:new_id}); 3707 input_element.attr({id:new_id}); 3708 }); 3709 3710 this.self.trigger(fac.Popups.ON_READY); 3711 }, 3712 3713 show : function () { 3714 //console.log("fac.Popups.Clone.show(" + [] + ")"); 3715 3716 }, 3717 3718 hide : function () { 3719 //console.log("fac.Popups.Clone.hide(" + [] + ")"); 3720 3721 } 3722 3723}; 3724 3725// fac.Popups.Image 3726 3727fac.Popups.Image = function (parent, source, container, options) { 3728 //console.log("fac.Popups.Image(" + [parent, source, container, options] + ")"); 3729 3730 this.initialize(parent, source, container, options); 3731}; 3732 3733fac.Popups.Image.prototype = { 3734 3735 self : null, 3736 parent : null, 3737 source : null, 3738 container : null, 3739 options : null, 3740 content : null, 3741 3742 is_loaded : null, 3743 is_ready : null, 3744 3745 initialize : function (parent, source, container, options) { 3746 //console.log("fac.Popups.Image.initialize(" + [parent, source, container, options] + ")"); 3747 3748 var $ = parent.env.$; 3749 3750 this.self = $(this); 3751 this.parent = parent;
3752 this.source = source; 3753 this.container = container; 3754 this.options = options; 3755 }, 3756 3757 start : function () { 3758 //console.log("fac.Popups.Image.start(" + [] + ")"); 3759 3760 this.is_loaded = false; 3761 this.is_ready = false; 3762 3763 if (this.options.preload) this.load(); 3764 3765 this.hide(); 3766 }, 3767 3768 load : function () { 3769 //console.log("fac.Popups.Image.load(" + [] + ")"); 3770 3771 if (this.is_loaded) return; 3772 3773 var $ = this.parent.env.$; 3774 3775 this.is_loaded = true; 3776 3777 this.content = 3778 $('<img />') 3779 .attr({src:this.source}) 3780 .appendTo(this.container) 3781 .on("load", this.ready.bind(this)); 3782 }, 3783 3784 ready : function () { 3785 //console.log("fac.Popups.Image.ready(" + [] + ")"); 3786 3787 this.is_ready = true; 3788 3789 this.self.trigger(fac.Popups.ON_READY); 3790 }, 3791 3792 show : function () { 3793 //console.log("fac.Popups.Image.show(" + [] + ")"); 3794 3795 }, 3796 3797 hide : function () { 3798 //console.log("fac.Popups.Image.hide(" + [] + ")"); 3799 3800 } 3801 3802}; 3803 3804// fac.Popups.Iframe 3805 3806fac.Popups.Iframe = function (parent, source, container, options) { 3807 //console.log("fac.Popups.Iframe(" + [parent, source, container, options] + ")"); 3808 3809 this.initialize(parent, source, container, options); 3810}; 3811 3812fac.Popups.Iframe.prototype = { 3813 3814 self : null, 3815 parent : null, 3816 source : null, 3817 container : null, 3818 options : null, 3819 content : null, 3820 3821 is_loaded : null, 3822 is_ready : null, 3823 3824 initialize : function (parent, source, container, options) { 3825 //console.log("fac.Popups.Iframe.initialize(" + [parent, source, container, options] + ")"); 3826 3827 var $ = parent.env.$; 3828 3829 this.self = $(this); 3830 this.parent = parent; 3831 this.source = source; 3832 this.container = container; 3833 this.options = options; 3834 }, 3835 3836 start : function () { 3837 //console.log("fac.Popups.Iframe.start(" + [] + ")"); 3838 3839 this.is_loaded = false; 3840 this.is_ready = false; 3841 3842 if (this.options.preload) this.load(); 3843 3844 this.hide(); 3845 }, 3846 3847 load : function () { 3848 //console.log("fac.Popups.Iframe.load(" + [] + ")"); 3849 3850 if (this.is_loaded) return; 3851 3852 var $ = this.parent.env.$; 3853 3854 this.is_loaded = true; 3855 3856 this.content = 3857 $('<iframe></iframe>') 3858 .attr({src:this.source, frameborder:0}) 3859 .appendTo(this.container) 3860 .load(this.ready.bind(this)); 3861 }, 3862 3863 ready : function () { 3864 //console.log("fac.Popups.Iframe.onReady(" + [] + ")"); 3865 3866 this.is_ready = true; 3867 3868 this.self.trigger(fac.Popups.ON_READY); 3869 }, 3870 3871 show : function () { 3872 //console.log("fac.Popups.Iframe.show(" + [] + ")"); 3873 3874 if (this.content) this.content.css({visibility:"visible"}); 3875 }, 3876 3877 hide : function () { 3878 //console.log("fac.Popups.Iframe.hide(" + [] + ")"); 3879 3880 if (this.content) this.content.css({visibility:"hidden"}); 3881 } 3882 3883}; 3884 3885// fac.Popups.Youtube 3886 3887fac.Popups.Youtube = function (parent, source, container, options) { 3888 //console.log("fac.Popups.Youtube(" + [parent, source, container, options] + ")"); 3889 3890 this.initialize(parent, source, container, options); 3891}; 3892 3893fac.Popups.Youtube.prototype = { 3894 3895 self : null, 3896 parent : null, 3897 source : null, 3898 container : null, 3899 options : null, 3900 content : null, 3901 youtube_api : null, 3902 3903 is_loaded : null, 3904 is_ready : null, 3905 3906 initialize : function (parent, source, container, options) { 3907 //console.log("fac.Popups.Youtube.initialize(" + [parent, source, container, options] + ")"); 3908 3909 var $ = parent.env.$; 3910 3911 this.self = $(this); 3912 this.parent = parent; 3913 this.source = source; 3914 this.container = container; 3915 this.options = options; 3916 }, 3917 3918 start : function () { 3919 //console.log("fac.Popups.Youtube.start(" + [] + ")"); 3920 3921 this.is_loaded = false; 3922 this.is_ready = false; 3923 3924 if (this.options.preload) this.load(); 3925 3926 this.hide(); 3927 }, 3928 3929 load : function () { 3930 //console.log("fac.Popups.Youtube.load(" + [] + ")"); 3931 3932 if (this.is_loaded) return; 3933 3934 var $ = this.parent.env.$; 3935 3936 this.is_loaded = true; 3937 3938 var video_id = this.source.match(fac.Popups.YOUTUBE_REGEX)[1]; 3939 3940 this.content = 3941 $('<iframe></iframe>') 3942 .attr({src:"//www.youtube.com/embed/" + video_id + "?rel=0&showinfo=0&autoplay=1&enablejsapi=1", allowfullscreen:"allowfullscreen"}) 3943 .appendTo(this.container); 3944 3945 this.youtube_api = this.content[0].contentWindow; 3946 3947 this.ready(); 3948 }, 3949 3950 ready : function () { 3951 //console.log("fac.Popups.Youtube.onReady(" + [] + ")"); 3952 3953 this.is_ready = true; 3954 3955 this.self.trigger(fac.Popups.ON_READY); 3956 }, 3957 3958 show : function () { 3959 //console.log("fac.Popups.Youtube.show(" + [] + ")"); 3960 3961 if (this.youtube_api) this.youtube_api.postMessage('{"event":"command","func":"playVideo","args":""}', '*'); 3962 3963 if (this.content) this.content.css({visibility:"visible"}); 3964 }, 3965 3966 hide : function () { 3967 //console.log("fac.Popups.Youtube.hide(" + [] + ")"); 3968 3969 if (this.youtube_api) this.youtube_api.postMessage('{"event":"command","func":"pauseVideo","args":""}', '*'); 3970 3971 if (this.content) this.content.css({visibility:"hidden"}); 3972 } 3973 3974}; 3975 3976 3977 3978/************************ 3979 fac.Scroller 3980ex) 3981var scroller = new fac.Scroller("a, area", {duration:1000, easing:"easeInOutCubic", initial:true, offset:0}); 3982************************/ 3983 3984if (typeof fac === "undefined") var fac = function() {}; 3985 3986fac.Scroller = function (targets, options) { 3987 //console.log("fac.Scroller(" + [targets, options] + ")"); 3988 3989 this.initialize(targets, options); 3990}; 3991 3992fac.Scroller.ParseURL = function (url) { 3993 //console.log("fac.Scroller.ParseURL(" + [url] + ")"); 3994 3995 var parsed = document.createElement("a"); 3996 parsed.href = url; 3997 3998 if (parsed.host === "") { 3999 parsed.href = parsed.href; 4000 } 4001 4002 return parsed; 4003};
4004 4005fac.Scroller.GetIsSameHref = function (href) { 4006 //console.log("fac.Scroller.GetIsSameHref(" + [href] + ")"); 4007 4008 var href_parsed = fac.Scroller.ParseURL(href); 4009 var location_parsed = fac.Scroller.LOCATION_PARSED; 4010 4011 var is_same_protocol = href_parsed.protocol === location_parsed.protocol; 4012 var is_same_hostname = href_parsed.hostname === location_parsed.hostname; 4013 var is_same_pathname = href_parsed.pathname === location_parsed.pathname; 4014 var is_same_file = href_parsed.file === location_parsed.file; 4015 var is_same_search = href_parsed.search === location_parsed.search; 4016 var is_same_hash = href_parsed.hash === location_parsed.hash; 4017 4018 var same = { 4019 protocol : is_same_protocol, 4020 hostname : is_same_hostname, 4021 pathname : is_same_pathname, 4022 file : is_same_file, 4023 search : is_same_search, 4024 hash : is_same_hash 4025 }; 4026 4027 return same; 4028}; 4029 4030fac.Scroller.IsSameHref = function (href) { 4031 //console.log("fac.Scroller.IsSameHref(" + [href] + ")"); 4032 4033 var same = fac.Scroller.GetIsSameHref(href); 4034 var is_same = same.protocol && same.hostname && same.pathname && same.file && same.search; 4035 4036 return is_same; 4037}; 4038 4039fac.Scroller.GetTargetByHref = function (href) { 4040 //console.log("fac.Scroller.GetTargetByHref(" + [href] + ")"); 4041 4042 var $ = 4043 fac.$ ? fac.$ : 4044 jQuery ? jQuery : 4045 $; 4046 4047 var is_same = fac.Scroller.IsSameHref(href); 4048 4049 if (is_same) { 4050 4051 var href_parsed = fac.Scroller.ParseURL(href); 4052 var name = href_parsed.hash.replace(/[.=#]/g, ""); 4053 4054 if (name === "") { 4055 return $(); 4056 } 4057 4058 try { 4059 var target = $("#" + name); 4060 target = 4061 target.length > 0 ? target : 4062 name ? $('[name=' + name +']') : 4063 $(); 4064 4065 return target; 4066 } 4067 catch (error) { 4068 4069 console.warn(error); 4070 4071 return $(); 4072 } 4073 4074 } 4075 4076 return $(); 4077}; 4078 4079fac.Scroller.NAME = "fac-scroller"; 4080fac.Scroller.LOCATION_PARSED = fac.Scroller.ParseURL(location.href); 4081 4082fac.Scroller.prototype = { 4083 4084 env : { 4085 $ : null, 4086 document : null, 4087 window : null, 4088 body : null, 4089 click : null, 4090 mousedown : null, 4091 mousewheel : null, 4092 touchstart : null 4093 }, 4094 4095 options : { 4096 duration : 800, 4097 easing : "easeInOutCubic", 4098 offset : 0, 4099 hash : "", 4100 initial : true, 4101 history : true 4102 }, 4103 4104 targets : null, 4105 scroller : null, 4106 interval : null, 4107 4108 initialize : function (targets, options) { 4109 //console.log("fac.Scroller.initialize(" + [targets, options] + ")"); 4110 4111 this.env.$ = 4112 options && options.jquery ? options.jquery : 4113 this.env.$ ? this.env.$ : 4114 fac.$ ? fac.$ : 4115 jQuery ? jQuery : 4116 $; 4117 4118 if (!this.env.$.fn || !this.env.$.fn.jquery) { 4119 console.warn("jQuery required"); 4120 return; 4121 } 4122 4123 4124 var $ = this.env.$; 4125 4126 //Env 4127 this.env.document = this.env.document ? this.env.document : fac.document ? fac.document : $(document); 4128 this.env.window = this.env.window ? this.env.window : fac.window ? fac.window : $(window); 4129 this.env.body = this.env.body ? this.env.body : fac.body ? fac.body : $("body"); 4130 this.env.click = "click." + fac.Scroller.NAME; 4131 this.env.mousedown = "mousedown." + fac.Scroller.NAME; 4132 this.env.mousewheel = "mousewheel." + fac.Scroller.NAME; 4133 this.env.touchstart = "touchstart." + fac.Scroller.NAME; 4134 4135 //Options 4136 this.options = $.extend({}, this.options, options); 4137 4138 this.scroller = $('html,body'); 4139 4140 this.targets = $(targets); 4141 4142 for (var i = 0; i < this.targets.length; i++) { 4143 4144 this.add(this.targets.eq(i)); 4145 4146 } 4147 4148 this.initialScroll(fac.Scroller.LOCATION_PARSED.hash); 4149 }, 4150 4151 initialScroll : function (hash) { 4152 //console.log("fac.Scroller.initialScroll(" + [hash] + ")"); 4153 4154 var is_reloaded = window.name === window.location.href; 4155 4156 window.name = window.location.href; 4157 4158 if (!this.options.initial || is_reloaded || hash.indexOf("#") !== 0) return; 4159 4160 var target; 4161 4162 try { 4163 target = $(hash); 4164 } 4165 catch (error) { 4166 target = $(); 4167 } 4168 4169 if (target.length === 0) return; 4170 4171 var p = this; 4172 var delay = 10; 4173 var stayed = 0;
4174 var elapsed = 0; 4175 4176 function check () { 4177 4178 var scroll_top = p.env.window.scrollTop(); 4179 var target_top = p.getNormalizedScrollTop(target.offset().top); 4180 4181 p.scroller.scrollTop(target_top); 4182 4183 if (scroll_top === target_top) { 4184 stayed += delay; 4185 if (stayed >= 1000) { 4186 p.stop(); 4187 } 4188 } 4189 else { 4190 stayed = 0; 4191 } 4192 4193 elapsed += delay; 4194 if (elapsed >= 1500) { 4195 p.stop(); 4196 } 4197 } 4198 4199 this.env.document 4200 .on(this.env.mousedown + " " + this.env.mousewheel + " " + this.env.touchstart, function () { 4201 p.stop(); 4202 }); 4203 4204 this.env.window 4205 .on("beforeunload." + fac.Scroller.NAME, function () { 4206 history.replaceState("", document.title, window.location.pathname); 4207 }); 4208 4209 this.interval = setInterval(check, delay); 4210 }, 4211 4212 //Methods 4213 4214 scrollByHref : function (href, duration, options) { 4215 //console.log("fac.Scroller.scrollByHref(" + [href, duration, options] + ")"); 4216 4217 var target = fac.Scroller.GetTargetByHref(href); 4218 4219 if (!target || target.length <= 0) return; 4220 4221 options = $.extend({}, options); 4222 options.hash = target.attr("id"); 4223 4224 this.scrollTo(target.offset().top, duration, options); 4225 4226 return false; 4227 }, 4228 4229 scrollToElement : function (element, duration, options) { 4230 //console.log("fac.Scroller.scrollToElement(" + [href, duration, options] + ")"); 4231 4232 var target = $(element); 4233 4234 if (!target || target.length <= 0) return; 4235 4236 this.scrollTo(target.offset().top, duration, options); 4237 4238 return false; 4239 }, 4240 4241 scrollTo : function (scroll_top, duration, options) { 4242 //console.log("fac.Scroller.scrollTo(" + [scroll_top, duration, options] + ")"); 4243 4244 var $ = this.env.$; 4245 4246 options = $.extend({}, this.options, options); 4247 4248 scroll_top = this.getNormalizedScrollTop(scroll_top, options.offset); 4249 duration = typeof duration === "number" ? duration : this.options.duration; 4250 4251 this.stop(); 4252 4253 this.env.document 4254 .off("." + fac.Scroller.NAME) 4255 .on(this.env.mousewheel + " " + this.env.touchstart, this.stop.bind(this)); 4256 4257 this.scroller.animate({scrollTop:scroll_top}, {queue:fac.Scroller.NAME, duration:duration, easing:this.options.easing, complete:this.scrolled.bind(this, options)}); 4258 this.scroller.dequeue(fac.Scroller.NAME); 4259 }, 4260 4261 scrolled : function (options) { 4262 //console.log("fac.Scroller.scrolled(" + [options] + ")"); 4263 4264 this.env.document.off("." + fac.Scroller.NAME); 4265 4266 var hash = options.hash; 4267 var callback = options.callback; 4268 if (hash !== void 0 && hash !== "" && hash !== null) { 4269 if (this.options.histrory) { 4270 history.pushState(null, null, "#" + hash); 4271 } 4272 else { 4273 history.replaceState(null, null, "#" + hash); 4274 } 4275 } 4276 4277 if (typeof callback === "function") { 4278 callback(); 4279 } 4280 }, 4281 4282 stop : function () { 4283 //console.log("fac.Scroller.stop(" + [] + ")"); 4284 4285 clearInterval(this.interval); 4286 this.scroller.stop(fac.Scroller.NAME); 4287 this.env.window.off("." + fac.Scroller.NAME); 4288 this.env.document.off("." + fac.Scroller.NAME); 4289 }, 4290 4291 add : function (anchor) { 4292 //console.log("fac.Scroller.add(" + [anchor] + ")"); 4293 4294 var $ = this.env.$; 4295 var anchor = $(anchor); 4296 var win = anchor.attr("target"); 4297 4298 if (win !== void 0 && win !== "_self") return; 4299 4300 var href = anchor.attr("href"); 4301 var target = fac.Scroller.GetTargetByHref(href); 4302 4303 if (target.length <= 0) return; 4304 4305 var data = {}; 4306 data[fac.Scroller.NAME + "-target"] = target; 4307 4308 anchor.data(data); 4309 4310 this.enable(anchor); 4311 }, 4312 4313 remove : function (anchor) { 4314 //console.log("fac.Scroller.remove(" + [anchor] + ")"); 4315 4316 var $ = this.env.$; 4317 4318 var anchor = $(anchor); 4319 this.disable(anchor); 4320 anchor.removeData(fac.Scroller.NAME + "-target"); 4321 }, 4322 4323 enable : function (targets) { 4324 //console.log("fac.Scroller.enable(" + [targets] + ")"); 4325 4326 var p = this; 4327 var $ = this.env.$; 4328 4329 targets.each(function () { 4330 4331 var anchor = $(this); 4332 var target = anchor.data(fac.Scroller.NAME + "-target"); 4333 4334 if (!target) return; 4335 4336 anchor 4337 .off(p.env.click) 4338 .on(p.env.click, p.anchorClick.bind(p, anchor)); 4339 4340 }); 4341 }, 4342 4343 disable : function (targets) { 4344 //console.log("fac.Scroller.disable(" + [targets] + ")"); 4345 4346 var p = this; 4347 var $ = this.env.$; 4348 4349 targets.each(function () { 4350 4351 var anchor = $(this); 4352 var target = anchor.data(fac.Scroller.NAME + "-target"); 4353 4354 if (!target) return; 4355 4356 anchor.off(p.env.click); 4357 4358 }); 4359 }, 4360 4361 destroy : function () { 4362 //console.log("fac.Scroller.destroy(" + [] + ")"); 4363 4364 this.stop(); 4365 this.targets.off("." + fac.Scroller.NAME); 4366 this.env.window.off("." + fac.Scroller.NAME); 4367 4368 this.targets = null; 4369 this.scroller = null; 4370 }, 4371 4372 getNormalizedScrollTop : function (scroll_top, offset) { 4373 //console.log("fac.Scroller.getNormalizedScrollTop(" + [scroll_top, offset] + ")"); 4374 4375 var min = 0; 4376 var max = this.env.body.get(0).scrollHeight - window.innerHeight; 4377 var offset = this.getOffset(offset); 4378 4379 scroll_top = Math.round(Math.max(Math.min(scroll_top + offset, max), min)); 4380 4381 return scroll_top; 4382 }, 4383 4384 getOffset : function (offset) { 4385 //console.log("fac.Scroller.getOffset(" + [offset] + ")"); 4386 4387 offset = offset !== void 0 ? offset : this.options.offset; 4388 4389 var offset_num = 0; 4390 4391 switch (typeof offset) { 4392 4393 case "number" : 4394 offset_num = offset; 4395 break; 4396 4397 case "function" : 4398 offset_num = offset(); 4399 break; 4400 4401 case "string" : 4402 case "object" : 4403 var offset_target = $(offset); 4404 if (offset_target.length > 0) { 4405 offset_num = -offset_target.outerHeight() + 1; 4406 } 4407 break; 4408 4409 } 4410 4411 offset_num = !isNaN(offset_num) ? offset_num : 0; 4412 4413 return offset_num; 4414 }, 4415 4416 setOptions : function (options) { 4417 //console.log("fac.Scroller.setOptions(" + [options] + ")"); 4418 4419 this.options = $.extend({}, this.options, options); 4420 }, 4421 4422 setOffset : function (offset) { 4423 //console.log("fac.Scroller.setOffset(" + [offset] + ")"); 4424 4425 this.setOptions({offset:offset}); 4426 }, 4427 4428 //Events 4429 4430 anchorClick : function (anchor) { 4431 //console.log("fac.Scroller.anchorClick(" + [anchor] + ")"); 4432 4433 var href = anchor.attr("href"); 4434 4435 this.scrollByHref(href); 4436 4437 event.preventDefault(); 4438 } 4439 4440}; 4441 4442 4443 4444/************************ 4445 fac.FastClick 4446 ex) 4447 var fast_click = new fac.FastClick("a.fast-click", {prevent_click:true}); 4448 $(fast_click).on(fac.FastClick.ON_CLICK, function () { console.log("fac.FastClick"); })); 4449 ************************/ 4450 4451if (typeof fac === "undefined") var fac = function() {}; 4452 4453fac.FastClick = function (target, options) { 4454 //console.log("fac.FastClick(" + [target, options] + ")"); 4455 4456 this.initialize(target, options); 4457}; 4458 4459fac.FastClick.NAME = "fac-fast-click"; 4460fac.FastClick.INCREMENT = 0; 4461fac.FastClick.ON_CLICK = "onClick"; 4462 4463fac.FastClick.prototype = { 4464 4465 env : { 4466 $ : null, 4467 window : null 4468 }, 4469 4470 events : { 4471 click : null, 4472 mousedown : null, 4473 mouseup : null, 4474 mousemove : null, 4475 dragend : null 4476 }, 4477 4478 options : { 4479 threshold : 2, 4480 prevent_default : false, 4481 prevent_click : false 4482 }, 4483 4484 status : { 4485 mousemove_count : 0 4486 }, 4487 4488 id : null, 4489 self : null, 4490 target : null, 4491 4492 initialize : function (target, options) { 4493 //console.log("fac.FastClick.initialize(" + [target, options] + ")"); 4494 4495 this.env.$ = 4496 options && options.jquery ? options.jquery : 4497 this.env.$ ? this.env.$ : 4498 fac.$ ? fac.$ : 4499 jQuery ? jQuery : 4500 $; 4501 4502 if (!this.env.$.fn || !this.env.$.fn.jquery) { 4503 console.warn("jQuery required"); 4504 return; 4505 } 4506 4507 var $ = this.env.$; 4508 4509 this.id = "." + fac.FastClick.NAME + "-" + fac.FastClick.INCREMENT++; 4510 this.self = $(this); 4511 this.target = $(target); 4512 4513 //Env 4514 this.env.window = this.env.window ? this.env.window : fac.window ? fac.window : $(window); 4515 4516 //Events 4517 this.events.click = this.events.click ? this.events.click : fac.events ? fac.events.click : "click"; 4518 this.events.mousedown = this.events.mousedown ? this.events.mousedown : !fac.is_smartdevice ? "mousedown touchstart" : "touchstart"; 4519 this.events.mouseup = this.events.mouseup ? this.events.mouseup : !fac.is_smartdevice ? "mouseup touchend" : "touchend"; 4520 this.events.mousemove = this.events.mousemove ? this.events.mousemove : !fac.is_smartdevice ? "mousemove touchmove" : "touchmove"; 4521 this.events.dragend = this.events.dragend ? this.events.dragend : "dragend"; 4522 4523 //Options 4524 this.options = $.extend({}, this.options, options); 4525 4526 4527 this.enable(); 4528 }, 4529 4530 //Public Methods 4531 4532 enable : function () { 4533 //console.log("fac.FastClick.enable(" + [] + ")"); 4534 4535 this.target 4536 .off(this.getID()) 4537 .on(this.getEventName(this.events.mousedown), this.mousedown.bind(this)); 4538 4539 if (this.options.prevent_click) { 4540 this.target.on(this.getEventName(this.events.click), function (event) { event.preventDefault(); return false; }); 4541 } 4542 }, 4543 4544 disable : function () { 4545 //console.log("fac.FastClick.disable(" + [] + ")"); 4546 4547 this.env.window.off(this.getID()); 4548 this.target.off(this.getID()); 4549 }, 4550 4551 getID : function (suffix) { 4552 //console.log("fac.FastClick.getID (" + [suffix] + ")"); 4553 4554 suffix = suffix !== void 0 ? suffix : ""; 4555 4556 var id = this.id + suffix; 4557 4558 return id; 4559 }, 4560
4561 getEventName : function (name, suffix) { 4562 //console.log("fac.FastClick.getEventName (" + [name, suffix] + ")"); 4563 4564 var $ = this.env.$; 4565 4566 name = $.isArray(name) ? name.join(" ") : name; 4567 name = (name.trim() + " ").replace(/ /g, this.getID(suffix) + " "); 4568 4569 return name; 4570 }, 4571 4572 //Events 4573 4574 mousedown : function (event) { 4575 //console.log("fac.FastClick.mousedown(" + [event] + ")"); 4576 4577 this.status.mousemove_count = 0; 4578 4579 this.env.window 4580 .off(this.getID()) 4581 .on(this.getEventName(this.events.mousemove), this.mousemove.bind(this)) 4582 .on(this.getEventName([this.events.mouseup, this.events.dragend]), this.mouseup.bind(this)); 4583 4584 if (this.options.prevent_default) { 4585 event.preventDefault(); 4586 return false; 4587 } 4588 }, 4589 4590 mouseup : function (event) { 4591 //console.log("fac.FastClick.mouseup(" + [event] + ")"); 4592 4593 this.env.window.off(this.getID()); 4594 4595 if (this.status.mousemove_count < this.options.threshold) { 4596 4597 this.self.trigger(fac.FastClick.ON_CLICK); 4598 4599 } 4600 4601 event.preventDefault(); 4602 return false; 4603 }, 4604 4605 mousemove : function () { 4606 //console.log("fac.FastClick.mousemove(" + [] + ")"); 4607 4608 this.status.mousemove_count++; 4609 } 4610 4611}; 4612 4613 4614 4615/************************ 4616 fac.TrapScrolling 4617 ************************/ 4618 4619fac.TrapScrolling = function (target) { 4620 //console.log("fac.TrapScrolling (" + [target] + ")"); 4621 4622 this.initialize(target); 4623}; 4624 4625fac.TrapScrolling.NAME = "fac-trap-scrolling"; 4626 4627fac.TrapScrolling.prototype = { 4628 4629 target : null, 4630 4631 initialize : function (target) { 4632 //console.log("fac.TrapScrolling.initialize(" + [target] + ")"); 4633 4634 this.target = $(target).addClass(fac.TrapScrolling.NAME); 4635 }, 4636 4637 start : function () { 4638 //console.log("fac.TrapScrolling.start(" + [] + ")"); 4639 4640 this.target.on("scroll." + fac.TrapScrolling.NAME, this.checkScroll.bind(this)); 4641 4642 this.checkScroll(); 4643 }, 4644 4645 stop : function () { 4646 //console.log("fac.TrapScrolling.stop(" + [] + ")"); 4647 4648 this.target.off("scroll." + fac.TrapScrolling.NAME); 4649 }, 4650 4651 checkScroll : function () { 4652 //console.log("fac.TrapScrolling.checkScroll (" + [] + ")"); 4653 4654 var scroll_top = this.target.scrollTop(); 4655 var scroll_max = this.target[0].scrollHeight - this.target[0].offsetHeight; 4656 4657 if (scroll_max <= 1) return; 4658 4659 if (scroll_top === 0) { 4660 this.target.scrollTop(1); 4661 } 4662 else if (scroll_top === scroll_max) { 4663 this.target.scrollTop(scroll_max - 1); 4664 } 4665 } 4666 4667}; 4668 4669 4670 4671/************************ 4672 fac.log 4673 ************************/ 4674 4675fac.log = function () { 4676 //console.log.apply(this, arguments); 4677 4678 if (!fac.log.console) { 4679 fac.log.console = document.createElement('textarea'); 4680 fac.log.console.id = fac.log.NAME; 4681 fac.log.console.value = "::Log::"; 4682 fac.log.console.setAttribute( 4683 "style", 4684 "width:" + fac.log.WIDTH + "; height:" + fac.log.HEIGHT + "; position:fixed; _position:absolute; left:0; top:0; z-index:100000; background:#fff; border:1px solid #000; color:#000; font-size:12px; text-align:left; overflow:auto;" 4685 ); 4686 document.body.appendChild(fac.log.console); 4687 } 4688 4689 var text = fac.log.console.value + "\n" + arguments[0]; 4690 4691 for (var i = 1; i < arguments.length; i++) { 4692 text += ", " + arguments[i]; 4693 } 4694 4695 fac.log.console.value = text; 4696 4697 if (fac.log.AUTO_SCROLL) fac.log.console.scrollTop = fac.log.console.scrollHeight; 4698 4699}; 4700 4701fac.log.console = null; 4702fac.log.NAME = "fac-console-log"; 4703fac.log.WIDTH = "300px"; 4704fac.log.HEIGHT = "20em"; 4705fac.log.AUTO_SCROLL = true; 4706 4707 4708 4709/* 4710 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ 4711 * 4712 * Uses the built in easing capabilities added In jQuery 1.1 4713 * to offer multiple easing options 4714 * 4715 * TERMS OF USE - jQuery Easing 4716 * 4717 * Open source under the BSD License. 4718 * 4719 * Copyright © 2008 George McGinley Smith 4720 * All rights reserved. 4721 * 4722 * Redistribution and use in source and binary forms, with or without modification, 4723 * are permitted provided that the following conditions are met: 4724 * 4725 * Redistributions of source code must retain the above copyright notice, this list of 4726 * conditions and the following disclaimer. 4727 * Redistributions in binary form must reproduce the above copyright notice, this list 4728 * of conditions and the following disclaimer in the documentation and/or other materials 4729 * provided with the distribution. 4730 * 4731 * Neither the name of the author nor the names of contributors may be used to endorse 4732 * or promote products derived from this software without specific prior written permission. 4733 * 4734 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 4735 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 4736 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 4737 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
vendor: 4,083 bytes, lines 4738-4749
4738 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 4739 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 4740 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 4741 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4742 * OF THE POSSIBILITY OF SUCH DAMAGE. 4743 * 4744*/ 4745// t: current time, b: begInnIng value, c: change In value, d: duration 4746jQuery.easing['jswing']=jQuery.easing['swing'];jQuery.extend(jQuery.easing,{def:'easeOutQuad',swing:function(x,t,b,c,d){return jQuery.easing[jQuery.easing.def](x,t,b,c,d)},easeInQuad:function(x,t,b,c,d){return c*(t/=d)*t+b},easeOutQuad:function(x,t,b,c,d){return-c*(t/=d)*(t-2)+b},easeInOutQuad:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b},easeInCubic:function(x,t,b,c,d){return c*(t/=d)*t*t+b},easeOutCubic:function(x,t,b,c,d){return c*((t=t/d-1)*t*t+1)+b},easeInOutCubic:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t+b;return c/2*((t-=2)*t*t+2)+b},easeInQuart:function(x,t,b,c,d){return c*(t/=d)*t*t*t+b},easeOutQuart:function(x,t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b},easeInOutQuart:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b},easeInQuint:function(x,t,b,c,d){return c*(t/=d)*t*t*t*t+b},easeOutQuint:function(x,t,b,c,d){return c*((t=t/d-1)*t*t*t*t+1)+b},easeInOutQuint:function(x,t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t*t+b;return c/2*((t-=2)*t*t*t*t+2)+b},easeInSine:function(x,t,b,c,d){return-c*Math.cos(t/d*(Math.PI/2))+c+b},easeOutSine:function(x,t,b,c,d){return c*Math.sin(t/d*(Math.PI/2))+b},easeInOutSine:function(x,t,b,c,d){return-c/2*(Math.cos(Math.PI*t/d)-1)+b},easeInExpo:function(x,t,b,c,d){return(t==0)?b:c*Math.pow(2,10*(t/d-1))+b},easeOutExpo:function(x,t,b,c,d){return(t==d)?b+c:c*(-Math.pow(2,-10*t/d)+1)+b},easeInOutExpo:function(x,t,b,c,d){if(t==0)return b;if(t==d)return b+c;if((t/=d/2)<1)return c/2*Math.pow(2,10*(t-1))+b;return c/2*(-Math.pow(2,-10*--t)+2)+b},easeInCirc:function(x,t,b,c,d){return-c*(Math.sqrt(1-(t/=d)*t)-1)+b},easeOutCirc:function(x,t,b,c,d){return c*Math.sqrt(1-(t=t/d-1)*t)+b},easeInOutCirc:function(x,t,b,c,d){if((t/=d/2)<1)return-c/2*(Math.sqrt(1-t*t)-1)+b;return c/2*(Math.sqrt(1-(t-=2)*t)+1)+b},easeInElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},easeOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},easeInOutElastic:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},easeInBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},easeOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},easeInOutBack:function(x,t,b,c,d,s){if(s==undefined)s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},easeInBounce:function(x,t,b,c,d){return c-jQuery.easing.easeOutBounce(x,d-t,0,c,d)+b},easeOutBounce:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},easeInOutBounce:function(x,t,b,c,d){if(t<d/2)return jQuery.easing.easeInBounce(x,t*2,0,c,d)*.5+b;return jQuery.easing.easeOutBounce(x,t*2-d,0,c,d)*.5+c*.5+b}}); 4747 4748/* 4749 *
vendor: 4,449 bytes, lines 4750-4791
4750 * TERMS OF USE - EASING EQUATIONS 4751 * 4752 * Open source under the BSD License. 4753 * 4754 * Copyright © 2001 Robert Penner 4755 * All rights reserved. 4756 * 4757 * Redistribution and use in source and binary forms, with or without modification, 4758 * are permitted provided that the following conditions are met: 4759 * 4760 * Redistributions of source code must retain the above copyright notice, this list of 4761 * conditions and the following disclaimer. 4762 * Redistributions in binary form must reproduce the above copyright notice, this list 4763 * of conditions and the following disclaimer in the documentation and/or other materials 4764 * provided with the distribution. 4765 * 4766 * Neither the name of the author nor the names of contributors may be used to endorse 4767 * or promote products derived from this software without specific prior written permission. 4768 * 4769 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 4770 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 4771 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 4772 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 4773 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 4774 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 4775 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 4776 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 4777 * OF THE POSSIBILITY OF SUCH DAMAGE. 4778 * 4779 */ 4780 4781 4782 4783/*! 4784 * jQuery Mousewheel 3.1.13 4785 * 4786 * Copyright 2015 jQuery Foundation and other contributors 4787 * Released under the MIT license. 4788 * http://jquery.org/license 4789 */ 4790!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); 4791
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.