MediaWiki:Common.js: Difference between revisions

No edit summary
No edit summary
Line 8: Line 8:
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
   })();
   })();
!function ($) {  "use strict"; // jshint ;_; /* AFFIX CLASS DEFINITION  * ====================== */  var Affix = function (element, options) {    this.options = $.extend({}, $.fn.affix.defaults, options)    this.$window = $(window)      .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))      .on('click.affix.data-api',  $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))    this.$element = $(element)    this.checkPosition()  }  Affix.prototype.checkPosition = function () {    if (!this.$element.is(':visible')) return    var scrollHeight = $(document).height()      , scrollTop = this.$window.scrollTop()      , position = this.$element.offset()      , offset = this.options.offset      , offsetBottom = offset.bottom      , offsetTop = offset.top      , reset = 'affix affix-top affix-bottom'      , affix    if (typeof offset != 'object') offsetBottom = offsetTop = offset    if (typeof offsetTop == 'function') offsetTop = offset.top()    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()    affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?      false    : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?      'bottom' : offsetTop != null && scrollTop <= offsetTop ?      'top'    : false    if (this.affixed === affix) return    this.affixed = affix    this.unpin = affix == 'bottom' ? position.top - scrollTop : null    this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))  } /* AFFIX PLUGIN DEFINITION  * ======================= */  var old = $.fn.affix  $.fn.affix = function (option) {    return this.each(function () {      var $this = $(this)        , data = $this.data('affix')        , options = typeof option == 'object' && option      if (!data) $this.data('affix', (data = new Affix(this, options)))      if (typeof option == 'string') data[option]()    })  }  $.fn.affix.Constructor = Affix  $.fn.affix.defaults = {    offset: 0  } /* AFFIX NO CONFLICT  * ================= */  $.fn.affix.noConflict = function () {    $.fn.affix = old    return this  } /* AFFIX DATA-API  * ============== */  $(window).on('load', function () {    $('[data-spy="affix"]').each(function () {      var $spy = $(this)        , data = $spy.data()      data.offset = data.offset || {}      data.offsetBottom && (data.offset.bottom = data.offsetBottom)      data.offsetTop && (data.offset.top = data.offsetTop)      $spy.affix(data)    })  })}(window.jQuery);

Revision as of 15:14, 12 January 2013

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-28926290-18']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

!function ($) {  "use strict"; // jshint ;_; /* AFFIX CLASS DEFINITION  * ====================== */  var Affix = function (element, options) {    this.options = $.extend({}, $.fn.affix.defaults, options)    this.$window = $(window)      .on('scroll.affix.data-api', $.proxy(this.checkPosition, this))      .on('click.affix.data-api',  $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))    this.$element = $(element)    this.checkPosition()  }  Affix.prototype.checkPosition = function () {    if (!this.$element.is(':visible')) return    var scrollHeight = $(document).height()      , scrollTop = this.$window.scrollTop()      , position = this.$element.offset()      , offset = this.options.offset      , offsetBottom = offset.bottom      , offsetTop = offset.top      , reset = 'affix affix-top affix-bottom'      , affix    if (typeof offset != 'object') offsetBottom = offsetTop = offset    if (typeof offsetTop == 'function') offsetTop = offset.top()    if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()    affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?      false    : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?      'bottom' : offsetTop != null && scrollTop <= offsetTop ?      'top'    : false    if (this.affixed === affix) return    this.affixed = affix    this.unpin = affix == 'bottom' ? position.top - scrollTop : null    this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))  } /* AFFIX PLUGIN DEFINITION  * ======================= */  var old = $.fn.affix  $.fn.affix = function (option) {    return this.each(function () {      var $this = $(this)        , data = $this.data('affix')        , options = typeof option == 'object' && option      if (!data) $this.data('affix', (data = new Affix(this, options)))      if (typeof option == 'string') data[option]()    })  }  $.fn.affix.Constructor = Affix  $.fn.affix.defaults = {    offset: 0  } /* AFFIX NO CONFLICT  * ================= */  $.fn.affix.noConflict = function () {    $.fn.affix = old    return this  } /* AFFIX DATA-API  * ============== */  $(window).on('load', function () {    $('[data-spy="affix"]').each(function () {      var $spy = $(this)        , data = $spy.data()      data.offset = data.offset || {}      data.offsetBottom && (data.offset.bottom = data.offsetBottom)      data.offsetTop && (data.offset.top = data.offsetTop)      $spy.affix(data)    })  })}(window.jQuery);
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Need wiki hosting?

Do you need a wiki for your Minecraft mod/gaming wiki? We'll host it for free! Contact us.

Other wikis

Indie-game wikis
Powered by Indie Wikis