1jQuery( document ).ready( function() { 2 3 // Video Previews Manager 4 (function videosPreviewsManager() { 5 var videosPreviewsXhrs = {}; 6 var videosPreviewsBuffer = {}; 7 8 jQuery( '.video-with-trailer' ).each( function( index, value ) { 9 var $videoPreview = jQuery( this ).find( '.video-preview' ); 10 var postId = jQuery( this ).data( 'post-id' ); 11 var $videoDebounceBar = jQuery( this ).find( '.video-debounce-bar' ); 12 var $videoImg = jQuery( this ).find( '.video-img' ); 13 var $videoName = jQuery( this ).find( '.video-name' ); 14 var $videoDuration = jQuery( this ).find( '.video-duration' ); 15 16 videosPreviewsBuffer[postId] = false; 17 18 // On mouseenter event. 19 jQuery( value ).on( 'mouseenter', function( event ) { 20 if ( ! $videoImg.hasClass( 'loaded' ) ) { 21 return; 22 } 23 24 $videoDebounceBar.addClass( 'video-debounce-bar--wait' ); 25 // $videoName.addClass( 'video-name--hidden' ); 26 // $videoDuration.addClass( 'video-duration--hidden' ); 27 videosPreviewsBuffer[postId] = true; 28 setTimeout( function() { 29 if ( ! videosPreviewsBuffer[postId] ) { 30 return; 31 } 32 jQuery.ajax({ 33 beforeSend: function( xhr ) { 34 videosPreviewsXhrs[postId] = xhr; 35 }, 36 method: 'POST', 37 url: ftt_ajax_var.url, 38 dataType: 'json', 39 data: { 40 action: 'ftt_load_video_preview', 41 nonce: ftt_ajax_var.nonce, 42 post_id: postId 43 } 44 }) 45 .done( function( response ) { 46 var $canvas, canvasId; 47 if ( ! ( videosPreviewsBuffer[postId] && response.success && '' !== response.data ) ) { 48 return; 49 } 50 // Add the Model Preview in the DOM directly. 51 // The Model Preview wrapper is z-indexed 50. 52 $videoPreview.html( response.data ).show( function() { 53 // Hide the Model Image to reveal the preview. 54 // Model Image is z-indexed 100. 55 if ( videosPreviewsBuffer[postId] ) { 56 $videoImg.addClass( 'video-img--hidden' ); 57 } 58 }); 59 }); // End of Ajax call. 60 }, 250 ); // End of settimeout 61 }); // End of mouseenter event. 62 63 // On mouseleave event. 64 jQuery( value ).on( 'mouseleave', function( event ) { 65 videosPreviewsBuffer[postId] = false; 66 $videoImg.removeClass( 'video-img--hidden' ); 67 // $videoName.removeClass( 'video-name--hidden' ); 68 // $videoDuration.removeClass( 'video-duration--hidden' ); 69 $videoDebounceBar.removeClass( 'video-debounce-bar--wait' ); 70 71 setTimeout( function() { 72 $videoPreview.html( '' ); 73 }, 200 ); 74 75 // Abort current postId xhr if exists. 76 if ( videosPreviewsXhrs[postId] ) { 77 videosPreviewsXhrs[postId].abort(); 78 delete( videosPreviewsXhrs[postId] ); 79 } 80 }); // End of mouseleave event. 81 82 }); // End of each. 83 })(); // End of Models Previews Manager IFEE. 84 85 //Multithumbs 86 var changeThumb = null; 87 var stopped = false; 88 jQuery('body').on('mouseenter', '.thumbs-rotation', function(e){ 89 var $this = jQuery(this); 90 stopped = false; 91 if( $this.data('thumbs') != undefined ){ 92 var dataThumbs = $this.data('thumbs'); 93 var thumbs = dataThumbs.split(','); 94 var nbThumbs = thumbs.length; 95 var i = 1; 96 changeThumb = null; 97 clearTimeout(changeThumb); 98 changeThumb = function() { 99 if( stopped == false ){ 100 $this.find('img').attr('srcset', thumbs[i - 1]); 101 if (i <= nbThumbs ) { 102 setTimeout(changeThumb, 700); 103 if( i == nbThumbs){ 104 i = 1; 105 }else{ 106 i++; 107 } 108 } 109 } 110 }; 111 changeThumb(); 112 } 113 }).on('mouseleave', '.thumbs-rotation', function(e){ 114 stopped = true; 115 changeThumb = null; 116 var highestTimeoutId = setTimeout(";"); 117 for (var i = 0 ; i < highestTimeoutId ; i++) { 118 clearTimeout(i); 119 } 120 var $blockImg = jQuery(this).find('img'); 121 var defaultThumb = $blockImg.attr('src'); 122 $blockImg.attr('srcset', defaultThumb); 123 }); 124 125 // Open search form 126 jQuery( '.header-search-mobile' ).click( function() { 127 if ( jQuery( window ).width() <= 767.98 ) { 128 jQuery( '.header-search' ).slideToggle( 200 ); 129 } 130 if ( jQuery( window ).width() >= 768 ) { 131 jQuery( '.header-search' ).animate({ width: 'toggle' }, 200 ); 132 jQuery( '.search-field' ).focus(); 133 } 134 }); 135 // Move search form 136 // if ( jQuery( window ).width() <= 767.98 ) { 137 // jQuery( '.header-search-form' ).appendTo( '#wrapper-navbar' ); 138 // } 139 // if ( jQuery( window ).width() >= 768 ) { 140 // jQuery( '.header-search-form' ).prependTo( '.search-nav' ); 141 // } 142 // jQuery( window ).resize( function() { 143 // if ( jQuery( window ).width() <= 767.98 ) { 144 // jQuery( '.header-search-form' ).appendTo( '#wrapper-navbar' ); 145 // } 146 // if ( jQuery( window ).width() >= 768 ) { 147 // jQuery( '.header-search-form' ).prependTo( '.search-nav' ); 148 // } 149 // }); 150 jQuery('.header-search').insertAfter('.logo-search'); 151 152 // Load videojs 153 if(jQuery('#ftt-video').length > 0 && !ftt_ajax_var.ctpl_installed){ 154 var playerOptions = { 155 controlBar: { 156 children: [ 157 'playToggle', 158 'progressControl', 159 'durationDisplay', 160 'volumePanel', 161 'qualitySelector', 162 'fullscreenToggle', 163 ], 164 }, 165 }; 166 videojs('ftt-video', playerOptions); 167 } 168 169 // Close inplayer advertising 170 jQuery('body').on('click', '.happy-inside-player .close-text', function(e) { 171 jQuery(this).parent('.happy-inside-player').hide(); 172 }); 173 174 /** Tabs **/ 175 jQuery('.tab-link').on('click', function(e) { 176 var tabId = jQuery(this).data('tab-id'); 177 // Show/Hide Tabs 178 jQuery('#' + tabId).show().siblings().hide(); 179 // Change/remove current tab to active 180 jQuery(this).addClass('active').siblings().removeClass('active'); 181 e.preventDefault(); 182 }); 183 184 // Replace all SVG images with inline SVG 185 jQuery( 'img[src$=".svg"]' ).each( function() { 186 var $img = jQuery( this ); 187 var imgURL = $img.attr( 'src' ); 188 var attributes = $img.prop( 'attributes' ); 189 var id = $img.parent( 'a' ).attr( 'id' ); 190 191 jQuery.get( imgURL, function( data ) { 192 193 // Get the SVG tag, ignore the rest 194 var $svg = jQuery( data ).find( 'svg' ); 195
196 // Remove any invalid XML tags 197 $svg = $svg.removeAttr( 'xmlns:a' ); 198 199 // Loop through IMG attributes and apply on SVG 200 jQuery.each( attributes, function() { 201 $svg.attr( this.name, this.value ); 202 }); 203 204 // Replace IMG with SVG 205 $img.replaceWith( $svg ); 206 207 if ( 'wps-logo-link' === id ) { 208 jQuery( '#' + id ).addClass( 'show-logo' ); 209 } 210 }, 'xml' ); 211 }); 212 213 /** IIFE Set Post views with ajax request for cache compatibility */ 214 (function(){ 215 var is_post = jQuery('body.single-post').length > 0; 216 if( !is_post ) return; 217 var post_id = jQuery('article.post').attr('id').replace('post-', ''); 218 jQuery.ajax({ 219 type: 'post', 220 url: ftt_ajax_var.url, 221 dataType: 'json', 222 data: { 223 action: 'post-views', 224 nonce: ftt_ajax_var.nonce, 225 post_id: post_id 226 } 227 }) 228 .done(function(doneData){ 229 // console.log(doneData); 230 }) 231 .fail(function(errorData){ 232 console.error(errorData); 233 }) 234 .always(function(alwaysData){ 235 //get post views & rating data 236 jQuery.ajax({ 237 type: 'post', 238 url: ftt_ajax_var.url, 239 dataType: 'json', 240 data: { 241 action: 'get-post-data', 242 nonce: ftt_ajax_var.nonce, 243 post_id: post_id 244 } 245 }) 246 .done(function(doneData){ 247 if(doneData.views) { 248 jQuery("#video-views span.views-number").text(doneData.views); 249 } 250 if(doneData.likes) { 251 jQuery(".likes_count").text(doneData.likes); 252 } 253 if(doneData.dislikes) { 254 jQuery(".dislikes_count").text(doneData.dislikes); 255 } 256 if(doneData.rating) { 257 jQuery(".percentage").text(doneData.rating); 258 jQuery(".rating-bar-meter").css('width', doneData.rating); 259 } 260 }) 261 .fail(function(errorData){ 262 console.error(errorData); 263 }) 264 .always(function(){ 265 // always stuff 266 }) 267 }); 268 })(); 269 270 /** Post like **/ 271 jQuery(".post-like a").on('click', function(e){ 272 e.preventDefault(); 273 274 var heart = jQuery(this); 275 var post_id = heart.data("post_id"); 276 var post_like = heart.data("post_like"); 277 278 jQuery.ajax({ 279 type: "post", 280 url: ftt_ajax_var.url, 281 dataType : "json", 282 data: "action=post-like&nonce=" + ftt_ajax_var.nonce + "&post_like=" + post_like + "&post_id=" + post_id, 283 success : function(data, textStatus, jqXHR){ 284 if(data.alreadyrate !== true) { 285 jQuery(".rating-bar-meter").removeClass("not-rated-yet"); 286 /*jQuery(".rating").text(Math.floor(data.pourcentage) + "%"); 287 jQuery(".rating").show();*/ 288 289 jQuery(".rating-result .percentage").text(Math.floor(data.percentage) + "%"); 290 jQuery(".rating-result .percentage").show(); 291 292 jQuery(".likes .likes_count").text(data.likes); 293 jQuery(".likes .dislikes_count").text(data.dislikes); 294 295 jQuery(".post-like").text(data.button); 296 297 if( data.nbrates > 0 ){ 298 jQuery(".rating-bar-meter").animate({ 299 width: data.progressbar + "%", 300 }, "fast", function() { 301 // Animation complete. 302 }); 303 } 304 } 305 } 306 }); 307 return false; 308 }); 309 310 // Video share toggle 311 jQuery('#show-sharing-buttons').click(function(e){ 312 e.preventDefault(); 313 jQuery('.video-share-box').slideToggle('fast'); 314 if (jQuery('.video-share-box').css('display') == 'block') { 315 jQuery(this).addClass('active'); 316 }else{ 317 jQuery(this).removeClass('active'); 318 } 319 }); 320 321 // Copy video share url to clipboard 322 jQuery("#clickme").click(function() { 323 var textToCopy = jQuery("#copyme").val(); 324 jQuery(this) 325 .parent() 326 .children("#temptext") 327 .val(textToCopy); 328 jQuery(this) 329 .parent() 330 .children("#temptext") 331 .select(); 332 document.execCommand("copy"); 333 jQuery(this) 334 .replaceWith('<span id="clickme"><i class="fa fa-check"></i> Copied</span>'); 335 }); 336}); 337 338// Menu mobile
339var forEach = function( t, o, r ) { 340 if ( '[object Object]' === Object.prototype.toString.call( t ) ) { 341 for ( var c in t ) { 342 Object.prototype.hasOwnProperty.call( t, c ) && o.call( r, t[c], c, t ); 343 } 344 } else { 345 for ( var e = 0, l = t.length; l > e; e++ ) { 346 o.call( r, t[e], e, t ); 347 } 348 } 349}; 350var hamburgers = document.querySelectorAll( '.hamburger' ); 351if ( hamburgers.length > 0 ) { 352 forEach( hamburgers, function( hamburger ) { 353 hamburger.addEventListener( 'click', function() { 354 this.classList.toggle( 'is-active' ); 355 }, false ); 356 }); 357} 358 359/** LOGIN / REGISTER POPUP */ 360function ftt_open_login_dialog(href){ 361 362 jQuery('#wpst-user-modal .modal-dialog').removeClass('registration-complete'); 363 364 var modal_dialog = jQuery('#wpst-user-modal .modal-dialog'); 365 modal_dialog.attr('data-active-tab', ''); 366 367 switch(href){ 368 369 case '#wpst-register': 370 modal_dialog.attr('data-active-tab', '#wpst-register'); 371 break; 372 373 case '#wpst-login': 374 default: 375 modal_dialog.attr('data-active-tab', '#wpst-login'); 376 break; 377 } 378 379 jQuery('#wpst-user-modal').modal('show'); 380} 381 382function ftt_close_login_dialog(){ 383 384 jQuery('#wpst-user-modal').modal('hide'); 385} 386 387jQuery(function($){ 388 389 "use strict"; 390 /*************************** 391 ** LOGIN / REGISTER DIALOG 392 ***************************/ 393 394 // Open login/register modal 395 $('[href="#wpst-login"], [href="#wpst-register"]').click(function(e){ 396 397 e.preventDefault(); 398 399 ftt_open_login_dialog( $(this).attr('href') ); 400 401 }); 402 403 // Switch forms login/register 404 $('.modal-footer a, a[href="#wpst-reset-password"]').click(function(e){ 405 e.preventDefault(); 406 $('#wpst-user-modal .modal-dialog').attr('data-active-tab', $(this).attr('href')); 407 }); 408 409 // Post login form 410 $('#ftt_login_form').on('submit', function(e){ 411 412 e.preventDefault(); 413 414 var button = $(this).find('button'); 415 button.button('loading'); 416 417 $.post(ftt_ajax_var.url, $('#ftt_login_form').serialize(), function(data){ 418 419 var obj = $.parseJSON(data); 420 421 $('.wpst-login .wpst-errors').html(obj.message); 422 423 if(obj.error == false){ 424 $('#wpst-user-modal .modal-dialog').addClass('loading'); 425 window.location.reload(true); 426 button.hide(); 427 } 428 429 button.button('reset'); 430 }); 431 432 }); 433 434 435 // Post register form 436 $('#ftt_registration_form').on('submit', function(e){ 437 438 e.preventDefault(); 439 440 var button = $(this).find('button'); 441 button.button('loading'); 442 443 $.post(ftt_ajax_var.url, $('#ftt_registration_form').serialize(), function(data){ 444 445 var obj = $.parseJSON(data); 446 447 $('.wpst-register .wpst-errors').html(obj.message); 448 449 if(obj.error == false){ 450 $('#wpst-user-modal .modal-dialog').addClass('registration-complete'); 451 // window.location.reload(true); 452 button.hide(); 453 } 454 455 button.button('reset'); 456 457 }); 458 459 }); 460 461 462 // Reset Password 463 $('#ftt_reset_password_form').on('submit', function(e){ 464 465 e.preventDefault(); 466 467 var button = $(this).find('button'); 468 button.button('loading'); 469 470 $.post(ftt_ajax_var.url, $('#ftt_reset_password_form').serialize(), function(data){ 471 472 var obj = $.parseJSON(data); 473 474 $('.wpst-reset-password .wpst-errors').html(obj.message); 475 476 // if(obj.error == false){ 477 // $('#wpst-user-modal .modal-dialog').addClass('loading'); 478 // $('#wpst-user-modal').modal('hide'); 479 // } 480 481 button.button('reset'); 482 }); 483 484 }); 485 486 if(window.location.hash == '#login'){ 487 ftt_open_login_dialog('#wpst-login'); 488 } 489 490}); 491 492/********************/ 493/** Bootstrap modal */ 494/********************/ 495/*! 496 * Bootstrap v3.3.7 (http://getbootstrap.com) 497 * Copyright 2011-2017 Twitter, Inc. 498 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 499 */ 500 501/*! 502 * Generated using the Bootstrap Customizer (http://getbootstrap.com/docs/3.3/customize/?id=2df80e69d208c504c2a17d0146de73bb) 503 * Config saved to config.json and https://gist.github.com/2df80e69d208c504c2a17d0146de73bb 504 */ 505if (typeof jQuery === 'undefined') { 506 throw new Error('Bootstrap\'s JavaScript requires jQuery') 507} 508+function ($) { 509 'use strict'; 510 var version = $.fn.jquery.split(' ')[0].split('.') 511 if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1) || (version[0] > 3)) { 512 throw new Error('Bootstrap\'s JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4') 513 } 514}(jQuery); 515 516/* ======================================================================== 517 * Bootstrap: button.js v3.3.7 518 * http://getbootstrap.com/javascript/#buttons 519 * ======================================================================== 520 * Copyright 2011-2016 Twitter, Inc. 521 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 522 * ======================================================================== */ 523 524 525+function ($) { 526 'use strict'; 527 528 // BUTTON PUBLIC CLASS DEFINITION 529 // ============================== 530 531 var Button = function (element, options) { 532 this.$element = $(element) 533 this.options = $.extend({}, Button.DEFAULTS, options) 534 this.isLoading = false 535 } 536 537 Button.VERSION = '3.3.7' 538 539 Button.DEFAULTS = { 540 loadingText: 'loading...' 541 } 542 543 Button.prototype.setState = function (state) { 544 var d = 'disabled' 545 var $el = this.$element 546 var val = $el.is('input') ? 'val' : 'html' 547 var data = $el.data() 548 549 state += 'Text' 550 551 if (data.resetText == null) $el.data('resetText', $el[val]()) 552 553 // push to event loop to allow forms to submit 554 setTimeout($.proxy(function () { 555 $el[val](data[state] == null ? this.options[state] : data[state]) 556 557 if (state == 'loadingText') { 558 this.isLoading = true 559 $el.addClass(d).attr(d, d).prop(d, true) 560 } else if (this.isLoading) { 561 this.isLoading = false 562 $el.removeClass(d).removeAttr(d).prop(d, false) 563 } 564 }, this), 0) 565 } 566 567 Button.prototype.toggle = function () { 568 var changed = true 569 var $parent = this.$element.closest('[data-toggle="buttons"]') 570 571 if ($parent.length) { 572 var $input = this.$element.find('input') 573 if ($input.prop('type') == 'radio') { 574 if ($input.prop('checked')) changed = false 575 $parent.find('.active').removeClass('active') 576 this.$element.addClass('active') 577 } else if ($input.prop('type') == 'checkbox') { 578 if (($input.prop('checked')) !== this.$element.hasClass('active')) changed = false 579 this.$element.toggleClass('active') 580 } 581 $input.prop('checked', this.$element.hasClass('active')) 582 if (changed) $input.trigger('change') 583 } else { 584 this.$element.attr('aria-pressed', !this.$element.hasClass('active')) 585 this.$element.toggleClass('active') 586 } 587 } 588 589
vendor: 5,786 bytes, lines 590-794
590 // BUTTON PLUGIN DEFINITION 591 // ======================== 592 593 function Plugin(option) { 594 return this.each(function () { 595 var $this = $(this) 596 var data = $this.data('bs.button') 597 var options = typeof option == 'object' && option 598 599 if (!data) $this.data('bs.button', (data = new Button(this, options))) 600 601 if (option == 'toggle') data.toggle() 602 else if (option) data.setState(option) 603 }) 604 } 605 606 var old = $.fn.button 607 608 $.fn.button = Plugin 609 $.fn.button.Constructor = Button 610 611 612 // BUTTON NO CONFLICT 613 // ================== 614 615 $.fn.button.noConflict = function () { 616 $.fn.button = old 617 return this 618 } 619 620 621 // BUTTON DATA-API 622 // =============== 623 624 $(document) 625 .on('click.bs.button.data-api', '[data-toggle^="button"]', function (e) { 626 var $btn = $(e.target).closest('.btn') 627 Plugin.call($btn, 'toggle') 628 if (!($(e.target).is('input[type="radio"], input[type="checkbox"]'))) { 629 // Prevent double click on radios, and the double selections (so cancellation) on checkboxes 630 e.preventDefault() 631 // The target component still receive the focus 632 if ($btn.is('input,button')) $btn.trigger('focus') 633 else $btn.find('input:visible,button:visible').first().trigger('focus') 634 } 635 }) 636 .on('focus.bs.button.data-api blur.bs.button.data-api', '[data-toggle^="button"]', function (e) { 637 $(e.target).closest('.btn').toggleClass('focus', /^focus(in)?$/.test(e.type)) 638 }) 639 640}(jQuery); 641 642/* ======================================================================== 643 * Bootstrap: modal.js v3.3.7 644 * http://getbootstrap.com/javascript/#modals 645 * ======================================================================== 646 * Copyright 2011-2016 Twitter, Inc. 647 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) 648 * ======================================================================== */ 649 650 651+function ($) { 652 'use strict'; 653 654 // MODAL CLASS DEFINITION 655 // ====================== 656 657 var Modal = function (element, options) { 658 this.options = options 659 this.$body = $(document.body) 660 this.$element = $(element) 661 this.$dialog = this.$element.find('.modal-dialog') 662 this.$backdrop = null 663 this.isShown = null 664 this.originalBodyPad = null 665 this.scrollbarWidth = 0 666 this.ignoreBackdropClick = false 667 668 if (this.options.remote) { 669 this.$element 670 .find('.modal-content') 671 .load(this.options.remote, $.proxy(function () { 672 this.$element.trigger('loaded.bs.modal') 673 }, this)) 674 } 675 } 676 677 Modal.VERSION = '3.3.7' 678 679 Modal.TRANSITION_DURATION = 300 680 Modal.BACKDROP_TRANSITION_DURATION = 150 681 682 Modal.DEFAULTS = { 683 backdrop: true, 684 keyboard: true, 685 show: true 686 } 687 688 Modal.prototype.toggle = function (_relatedTarget) { 689 return this.isShown ? this.hide() : this.show(_relatedTarget) 690 } 691 692 Modal.prototype.show = function (_relatedTarget) { 693 var that = this 694 var e = $.Event('show.bs.modal', { relatedTarget: _relatedTarget }) 695 696 this.$element.trigger(e) 697 698 if (this.isShown || e.isDefaultPrevented()) return 699 700 this.isShown = true 701 702 this.checkScrollbar() 703 this.setScrollbar() 704 this.$body.addClass('modal-open') 705 706 this.escape() 707 this.resize() 708 709 this.$element.on('click.dismiss.bs.modal', '[data-dismiss="modal"]', $.proxy(this.hide, this)) 710 711 this.$dialog.on('mousedown.dismiss.bs.modal', function () { 712 that.$element.one('mouseup.dismiss.bs.modal', function (e) { 713 if ($(e.target).is(that.$element)) that.ignoreBackdropClick = true 714 }) 715 }) 716 717 this.backdrop(function () { 718 var transition = $.support.transition && that.$element.hasClass('fade') 719 720 if (!that.$element.parent().length) { 721 that.$element.appendTo(that.$body) // don't move modals dom position 722 } 723 724 that.$element 725 .show() 726 .scrollTop(0) 727 728 that.adjustDialog() 729 730 if (transition) { 731 that.$element[0].offsetWidth // force reflow 732 } 733 734 that.$element.addClass('in') 735 736 that.enforceFocus() 737 738 var e = $.Event('shown.bs.modal', { relatedTarget: _relatedTarget }) 739 740 transition ? 741 that.$dialog // wait for modal to slide in 742 .one('bsTransitionEnd', function () { 743 that.$element.trigger('focus').trigger(e) 744 }) 745 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 746 that.$element.trigger('focus').trigger(e) 747 }) 748 } 749 750 Modal.prototype.hide = function (e) { 751 if (e) e.preventDefault() 752 753 e = $.Event('hide.bs.modal') 754 755 this.$element.trigger(e) 756 757 if (!this.isShown || e.isDefaultPrevented()) return 758 759 this.isShown = false 760 761 this.escape() 762 this.resize() 763 764 $(document).off('focusin.bs.modal') 765 766 this.$element 767 .removeClass('in') 768 .off('click.dismiss.bs.modal') 769 .off('mouseup.dismiss.bs.modal') 770 771 this.$dialog.off('mousedown.dismiss.bs.modal') 772 773 $.support.transition && this.$element.hasClass('fade') ? 774 this.$element 775 .one('bsTransitionEnd', $.proxy(this.hideModal, this)) 776 .emulateTransitionEnd(Modal.TRANSITION_DURATION) : 777 this.hideModal() 778 } 779 780 Modal.prototype.enforceFocus = function () { 781 $(document) 782 .off('focusin.bs.modal') // guard against infinite focus loop 783 .on('focusin.bs.modal', $.proxy(function (e) { 784 if (document !== e.target && 785 this.$element[0] !== e.target && 786 !this.$element.has(e.target).length) { 787 this.$element.trigger('focus') 788 } 789 }, this)) 790 } 791 792 Modal.prototype.escape = function () { 793 if (this.isShown && this.options.keyboard) { 794 this.$element.on('keydown.dismiss.bs.modal', $.proxy(function (e) {
vendor: 5,699 bytes, lines 795-980
795 e.which == 27 && this.hide() 796 }, this)) 797 } else if (!this.isShown) { 798 this.$element.off('keydown.dismiss.bs.modal') 799 } 800 } 801 802 Modal.prototype.resize = function () { 803 if (this.isShown) { 804 $(window).on('resize.bs.modal', $.proxy(this.handleUpdate, this)) 805 } else { 806 $(window).off('resize.bs.modal') 807 } 808 } 809 810 Modal.prototype.hideModal = function () { 811 var that = this 812 this.$element.hide() 813 this.backdrop(function () { 814 that.$body.removeClass('modal-open') 815 that.resetAdjustments() 816 that.resetScrollbar() 817 that.$element.trigger('hidden.bs.modal') 818 }) 819 } 820 821 Modal.prototype.removeBackdrop = function () { 822 this.$backdrop && this.$backdrop.remove() 823 this.$backdrop = null 824 } 825 826 Modal.prototype.backdrop = function (callback) { 827 var that = this 828 var animate = this.$element.hasClass('fade') ? 'fade' : '' 829 830 if (this.isShown && this.options.backdrop) { 831 var doAnimate = $.support.transition && animate 832 833 this.$backdrop = $(document.createElement('div')) 834 .addClass('modal-backdrop ' + animate) 835 .appendTo(this.$body) 836 837 this.$element.on('click.dismiss.bs.modal', $.proxy(function (e) { 838 if (this.ignoreBackdropClick) { 839 this.ignoreBackdropClick = false 840 return 841 } 842 if (e.target !== e.currentTarget) return 843 this.options.backdrop == 'static' 844 ? this.$element[0].focus() 845 : this.hide() 846 }, this)) 847 848 if (doAnimate) this.$backdrop[0].offsetWidth // force reflow 849 850 this.$backdrop.addClass('in') 851 852 if (!callback) return 853 854 doAnimate ? 855 this.$backdrop 856 .one('bsTransitionEnd', callback) 857 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 858 callback() 859 860 } else if (!this.isShown && this.$backdrop) { 861 this.$backdrop.removeClass('in') 862 863 var callbackRemove = function () { 864 that.removeBackdrop() 865 callback && callback() 866 } 867 $.support.transition && this.$element.hasClass('fade') ? 868 this.$backdrop 869 .one('bsTransitionEnd', callbackRemove) 870 .emulateTransitionEnd(Modal.BACKDROP_TRANSITION_DURATION) : 871 callbackRemove() 872 873 } else if (callback) { 874 callback() 875 } 876 } 877 878 // these following methods are used to handle overflowing modals 879 880 Modal.prototype.handleUpdate = function () { 881 this.adjustDialog() 882 } 883 884 Modal.prototype.adjustDialog = function () { 885 var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight 886 887 this.$element.css({ 888 paddingLeft: !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '', 889 paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : '' 890 }) 891 } 892 893 Modal.prototype.resetAdjustments = function () { 894 this.$element.css({ 895 paddingLeft: '', 896 paddingRight: '' 897 }) 898 } 899 900 Modal.prototype.checkScrollbar = function () { 901 var fullWindowWidth = window.innerWidth 902 if (!fullWindowWidth) { // workaround for missing window.innerWidth in IE8 903 var documentElementRect = document.documentElement.getBoundingClientRect() 904 fullWindowWidth = documentElementRect.right - Math.abs(documentElementRect.left) 905 } 906 this.bodyIsOverflowing = document.body.clientWidth < fullWindowWidth 907 this.scrollbarWidth = this.measureScrollbar() 908 } 909 910 Modal.prototype.setScrollbar = function () { 911 var bodyPad = parseInt((this.$body.css('padding-right') || 0), 10) 912 this.originalBodyPad = document.body.style.paddingRight || '' 913 if (this.bodyIsOverflowing) this.$body.css('padding-right', bodyPad + this.scrollbarWidth) 914 } 915 916 Modal.prototype.resetScrollbar = function () { 917 this.$body.css('padding-right', this.originalBodyPad) 918 } 919 920 Modal.prototype.measureScrollbar = function () { // thx walsh 921 var scrollDiv = document.createElement('div') 922 scrollDiv.className = 'modal-scrollbar-measure' 923 this.$body.append(scrollDiv) 924 var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth 925 this.$body[0].removeChild(scrollDiv) 926 return scrollbarWidth 927 } 928 929 930 // MODAL PLUGIN DEFINITION 931 // ======================= 932 933 function Plugin(option, _relatedTarget) { 934 return this.each(function () { 935 var $this = $(this) 936 var data = $this.data('bs.modal') 937 var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option) 938 939 if (!data) $this.data('bs.modal', (data = new Modal(this, options))) 940 if (typeof option == 'string') data[option](_relatedTarget) 941 else if (options.show) data.show(_relatedTarget) 942 }) 943 } 944 945 var old = $.fn.modal 946 947 $.fn.modal = Plugin 948 $.fn.modal.Constructor = Modal 949 950 951 // MODAL NO CONFLICT 952 // ================= 953 954 $.fn.modal.noConflict = function () { 955 $.fn.modal = old 956 return this 957 } 958 959 960 // MODAL DATA-API 961 // ============== 962 963 $(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) { 964 var $this = $(this) 965 var href = $this.attr('href') 966 var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) // strip for ie7 967 var option = $target.data('bs.modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data()) 968 969 if ($this.is('a')) e.preventDefault() 970 971 $target.one('show.bs.modal', function (showEvent) { 972 if (showEvent.isDefaultPrevented()) return // only register focus restorer if modal will actually get shown 973 $target.one('hidden.bs.modal', function () { 974 $this.is(':visible') && $this.trigger('focus') 975 }) 976 }) 977 Plugin.call($target, option, this) 978 }) 979 980}(jQuery);
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.