Diferencia entre revisiones de «MediaWiki:Common.js»

De Bioeticawiki
 
(No se muestra una edición intermedia de otro usuario)
Línea 29: Línea 29:
}
}


/*jshint smarttabs:true, loopfunc:true,forin:false*/
// BEGIN Main Page carousel code
/*global mw, $, importScript */
// TODO: make autodate an option in the CiteTemplate object, not a preference
/*!
 
jCarousel - v0.3.0 - 2013-11-22
// Global object
http://sorgalla.com/jcarousel
// TODO:
Copyright (c) 2013 Jan Sorgalla; Licensed MIT
// * Remove this once the page is moved to a module 'ext.gadget.refToolbarDialogs' depending on 'ext.gadget.refToolbarBase'
if (typeof CiteTB === 'undefined') {
Permission is hereby granted, free of charge, to any person obtaining a copy
  var CiteTB = {
of this software and associated documentation files (the "Software"), to deal
    "Templates" : {}, // All templates
in the Software without restriction, including without limitation the rights
    "Options" : {}, // Global options
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    "UserOptions" : {}, // User options
copies of the Software, and to permit persons to whom the Software is
    "DefaultOptions" : {}, // Script defaults
furnished to do so, subject to the following conditions:
    "ErrorChecks" : {} // Error check functions
  };
The above copyright notice and this permission notice shall be included in
}
all copies or substantial portions of the Software.
 
*/
// Only execute on edit, unless it is a user JS/CSS page
(function(t){"use strict";var i=t.jCarousel={};i.version="0.3.0";var s=/^([+\-]=)?(.+)$/;i.parseTarget=function(t){var i=!1,e="object"!=typeof t?s.exec(t):null;return e?(t=parseInt(e[2],10)||0,e[1]&&(i=!0,"-="===e[1]&&(t*=-1))):"object"!=typeof t&&(t=parseInt(t,10)||0),{target:t,relative:i}},i.detectCarousel=function(t){for(var i;t.length>0;){if(i=t.filter("[data-jcarousel]"),i.length>0)return i;if(i=t.find("[data-jcarousel]"),i.length>0)return i;t=t.parent()}return null},i.base=function(s){return{version:i.version,_options:{},_element:null,_carousel:null,_init:t.noop,_create:t.noop,_destroy:t.noop,_reload:t.noop,create:function(){return this._element.attr("data-"+s.toLowerCase(),!0).data(s,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(s).removeAttr("data-"+s.toLowerCase()),this)},reload:function(t){return!1===this._trigger("reload")?this:(t&&this.options(t),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(i,s){if(0===arguments.length)return t.extend({},this._options);if("string"==typeof i){if(s===void 0)return this._options[i]===void 0?null:this._options[i];this._options[i]=s}else this._options=t.extend({},this._options,i);return this},carousel:function(){return this._carousel||(this._carousel=i.detectCarousel(this.options("carousel")||this._element),this._carousel||t.error('Could not detect carousel for plugin "'+s+'"')),this._carousel},_trigger:function(i,e,r){var n,o=!1;return r=[this].concat(r||[]),(e||this._element).each(function(){n=t.Event((s+":"+i).toLowerCase()),t(this).trigger(n,r),n.isDefaultPrevented()&&(o=!0)}),!o}}},i.plugin=function(s,e){var r=t[s]=function(i,s){this._element=t(i),this.options(s),this._init(),this.create()};return r.fn=r.prototype=t.extend({},i.base(s),e),t.fn[s]=function(i){var e=Array.prototype.slice.call(arguments,1),n=this;return"string"==typeof i?this.each(function(){var r=t(this).data(s);if(!r)return t.error("Cannot call methods on "+s+" prior to initialization; "+'attempted to call method "'+i+'"');if(!t.isFunction(r[i])||"_"===i.charAt(0))return t.error('No such method "'+i+'" for '+s+" instance");var o=r[i].apply(r,e);return o!==r&&o!==void 0?(n=o,!1):void 0}):this.each(function(){var e=t(this).data(s);e instanceof r?e.reload(i):new r(this,i)}),n},r}})(jQuery),function(t,i){"use strict";var s=function(t){return parseFloat(t)||0};t.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,underflow:!1,relative:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,transitions:!1,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this},_create:function(){this._reload(),t(i).on("resize.jcarousel",this.onWindowResize)},_destroy:function(){t(i).off("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),null==this.vertical&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),null==this.rtl&&(this.rtl=function(i){if("rtl"===(""+i.attr("dir")).toLowerCase())return!0;var s=!1;return i.parents("[dir]").each(function(){return/rtl/i.test(t(this).attr("dir"))?(s=!0,!1):void 0}),s}(this._element)),this.lt=this.vertical?"top":"left",this.relative="relative"===this.list().css("position"),this._list=null,this._items=null;var i=this._target&&this.index(this._target)>=0?this._target:this.closest();this.circular="circular"===this.options("wrap"),this.underflow=!1;var s={left:0,top:0};return i.length>0&&(this._prepare(i),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.underflow=this._fullyvisible.length>=this.items().length,this.circular=this.circular&&!this.underflow,s[this.lt]=this._position(i)+"px"),this.move(s),this},list:function(){if(null===this._list){var i=this.options("list");this._list=t.isFunction(i)?i.call(this):this._element.find(i)}return this._list},items:function(){if(null===this._items){var i=this.options("items");this._items=(t.isFunction(i)?i.call(this):this.list().find(i)).not("[data-jcarousel-clone]")}return this._items},index:function(t){return this.items().index(t)},closest:function(){var i,e=this,r=this.list().position()[this.lt],n=t(),o=!1,l=this.vertical?"bottom":this.rtl&&!this.relative?"left":"right";return this.rtl&&this.relative&&!this.vertical&&(r+=this.list().width()-this.clipping()),this.items().each(function(){if(n=t(this),o)return!1;var a=e.dimension(n);if(r+=a,r>=0){if(i=a-s(n.css("margin-"+l)),!(0>=Math.abs(r)-a+i/2))return!1;o=!0}}),n},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var t=this.options("wrap"),i=this.items().length-1;return i>=0&&(t&&"first"!==t||i>this.index(this._last)||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var t=this.options("wrap");return this.items().length>0&&(t&&"last"!==t||this.index(this._first)>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(t){return t["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(i,s,e){if(this.animating)return this;if(!1===this._trigger("scroll",null,[i,s]))return this;t.isFunction(s)&&(e=s,s=!0);var r=t.jCarousel.parseTarget(i);if(r.relative){var n,o,l,a,h,u,c,f,d=this.items().length-1,_=Math.abs(r.target),p=this.options("wrap");if(r.target>0){var v=this.index(this._last);if(v>=d&&this.tail)this.inTail?"both"===p||"last"===p?this._scroll(0,s,e):t.isFunction(e)&&e.call(this,!1):this._scrollTail(s,e);else if(n=this.index(this._target),this.underflow&&n===d&&("circular"===p||"both"===p||"last"===p)||!this.underflow&&v===d&&("both"===p||"last"===p))this._scroll(0,s,e);else if(l=n+_,this.circular&&l>d){for(f=d,h=this.items().get(-1);l>f++;)h=this.items().eq(0),u=this._visible.index(h)>=0,u&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(h),u||(c={},c[this.lt]=this.dimension(h),this.moveBy(c)),this._items=null;this._scroll(h,s,e)}else this._scroll(Math.min(l,d),s,e)}else if(this.inTail)this._scroll(Math.max(this.index(this._first)-_+1,0),s,e);else if(o=this.index(this._first),n=this.index(this._target),a=this.underflow?n:o,l=a-_,0>=a&&(this.underflow&&"circular"===p||"both"===p||"first"===p))this._scroll(d,s,e);else if(this.circular&&0>l){for(f=l,h=this.items().get(0);0>f++;){h=this.items().eq(-1),u=this._visible.index(h)>=0,u&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(h),this._items=null;var g=this.dimension(h);c={},c[this.lt]=-g,this.moveBy(c)}this._scroll(h,s,e)}else this._scroll(Math.max(l,0),s,e)}else this._scroll(r.target,s,e);return this._trigger("scrollend"),this},moveBy:function(t,i){var e=this.list().position(),r=1,n=0;return this.rtl&&!this.vertical&&(r=-1,this.relative&&(n=this.list().width()-this.clipping())),t.left&&(t.left=e.left+n+s(t.left)*r+"px"),t.top&&(t.top=e.top+n+s(t.top)*r+"px"),this.move(t,i)},move:function(i,s){s=s||{};var e=this.options("transitions"),r=!!e,n=!!e.transforms,o=!!e.transforms3d,l=s.duration||0,a=this.list();if(!r&&l>0)return a.animate(i,s),void 0;var h=s.complete||t.noop,u={};if(r){var c=a.css(["transitionDuration","transitionTimingFunction","transitionProperty"]),f=h;h=function(){t(this).css(c),f.call(this)},u={transitionDuration:(l>0?l/1e3:0)+"s",transitionTimingFunction:e.easing||s.easing,transitionProperty:l>0?function(){return n||o?"all":i.left?"left":"top"}():"none",transform:"none"}}o?u.transform="translate3d("+(i.left||0)+","+(i.top||0)+",0)":n?u.transform="translate("+(i.left||0)+","+(i.top||0)+")":t.extend(u,i),r&&l>0&&a.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",h),a.css(u),0>=l&&a.each(function(){h.call(this)})},_scroll:function(i,s,e){if(this.animating)return t.isFunction(e)&&e.call(this,!1),this;if("object"!=typeof i?i=this.items().eq(i):i.jquery===void 0&&(i=t(i)),0===i.length)return t.isFunction(e)&&e.call(this,!1),this;this.inTail=!1,this._prepare(i);var r=this._position(i),n=this.list().position()[this.lt];if(r===n)return t.isFunction(e)&&e.call(this,!1),this;var o={};return o[this.lt]=r+"px",this._animate(o,s,e),this},_scrollTail:function(i,s){if(this.animating||!this.tail)return t.isFunction(s)&&s.call(this,!1),this;var e=this.list().position()[this.lt];this.rtl&&this.relative&&!this.vertical&&(e+=this.list().width()-this.clipping()),this.rtl&&!this.vertical?e+=this.tail:e-=this.tail,this.inTail=!0;var r={};return r[this.lt]=e+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(r,i,s),this},_animate:function(i,s,e){if(e=e||t.noop,!1===this._trigger("animate"))return e.call(this,!1),this;this.animating=!0;var r=this.options("animation"),n=t.proxy(function(){this.animating=!1;var t=this.list().find("[data-jcarousel-clone]");t.length>0&&(t.remove(),this._reload()),this._trigger("animateend"),e.call(this,!0)},this),o="object"==typeof r?t.extend({},r):{duration:r},l=o.complete||t.noop;return s===!1?o.duration=0:t.fx.speeds[o.duration]!==void 0&&(o.duration=t.fx.speeds[o.duration]),o.complete=function(){n(),l.call(this)},this.move(i,o),this},_prepare:function(i){var e,r,n,o,l=this.index(i),a=l,h=this.dimension(i),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=this.options("center"),d={target:i,first:i,last:i,visible:i,fullyvisible:u>=h?i:t()};if(f&&(h/=2,u/=2),u>h)for(;;){if(e=this.items().eq(++a),0===e.length){if(!this.circular)break;if(e=this.items().eq(0),i.get(0)===e.get(0))break;if(r=this._visible.index(e)>=0,r&&e.after(e.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(e),!r){var _={};_[this.lt]=this.dimension(e),this.moveBy(_)}this._items=null}if(o=this.dimension(e),0===o)break;if(h+=o,d.last=e,d.visible=d.visible.add(e),n=s(e.css("margin-"+c)),u>=h-n&&(d.fullyvisible=d.fullyvisible.add(e)),h>=u)break}if(!this.circular&&!f&&u>h)for(a=l;;){if(0>--a)break;if(e=this.items().eq(a),0===e.length)break;if(o=this.dimension(e),0===o)break;if(h+=o,d.first=e,d.visible=d.visible.add(e),n=s(e.css("margin-"+c)),u>=h-n&&(d.fullyvisible=d.fullyvisible.add(e)),h>=u)break}return this._update(d),this.tail=0,f||"circular"===this.options("wrap")||"custom"===this.options("wrap")||this.index(d.last)!==this.items().length-1||(h-=s(d.last.css("margin-"+c)),h>u&&(this.tail=h-u)),this},_position:function(t){var i=this._first,s=i.position()[this.lt],e=this.options("center"),r=e?this.clipping()/2-this.dimension(i)/2:0;return this.rtl&&!this.vertical?(s-=this.relative?this.list().width()-this.dimension(i):this.clipping()-this.dimension(i),s+=r):s-=r,!e&&(this.index(t)>this.index(i)||this.inTail)&&this.tail?(s=this.rtl&&!this.vertical?s-this.tail:s+this.tail,this.inTail=!0):this.inTail=!1,-s},_update:function(i){var s,e=this,r={target:this._target||t(),first:this._first||t(),last:this._last||t(),visible:this._visible||t(),fullyvisible:this._fullyvisible||t()},n=this.index(i.first||r.first)<this.index(r.first),o=function(s){var o=[],l=[];i[s].each(function(){0>r[s].index(this)&&o.push(this)}),r[s].each(function(){0>i[s].index(this)&&l.push(this)}),n?o=o.reverse():l=l.reverse(),e._trigger(s+"in",t(o)),e._trigger(s+"out",t(l)),e["_"+s]=i[s]};for(s in i)o(s);return this}})}(jQuery,window),function(t){"use strict";t.jcarousel.fn.scrollIntoView=function(i,s,e){var r,n=t.jCarousel.parseTarget(i),o=this.index(this._fullyvisible.first()),l=this.index(this._fullyvisible.last());if(r=n.relative?0>n.target?Math.max(0,o+n.target):l+n.target:"object"!=typeof n.target?n.target:this.index(n.target),o>r)return this.scroll(r,s,e);if(r>=o&&l>=r)return t.isFunction(e)&&e.call(this,!1),this;for(var a,h=this.items(),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=0;;){if(a=h.eq(r),0===a.length)break;if(f+=this.dimension(a),f>=u){var d=parseFloat(a.css("margin-"+c))||0;f-d!==u&&r++;break}if(0>=r)break;r--}return this.scroll(r,s,e)}}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click",method:"scroll"},_active:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onEvent=t.proxy(function(i){i.preventDefault();var s=this.options("method");t.isFunction(s)?s.call(this):this.carousel().jcarousel(this.options("method"),this.options("target"))},this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend jcarousel:scrollend",this.onReload),this._element.on(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.off(".jcarouselcontrol",this.onEvent),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend jcarousel:scrollend",this.onReload)},_reload:function(){var i,s=t.jCarousel.parseTarget(this.options("target")),e=this.carousel();if(s.relative)i=e.jcarousel(s.target>0?"hasNext":"hasPrev");else{var r="object"!=typeof s.target?e.jcarousel("items").eq(s.target):s.target;i=e.jcarousel("target").index(r)>=0}return this._active!==i&&(this._trigger(i?"active":"inactive"),this._active=i),this}})}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(t){return'<a href="#'+t+'">'+t+"</a>"},event:"click",method:"scroll"},_pages:{},_items:{},_currentPage:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onScroll=t.proxy(this._update,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend",this.onReload).on("jcarousel:scrollend",this.onScroll),this._reload()},_destroy:function(){this._clear(),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend",this.onReload).off("jcarousel:scrollend",this.onScroll)},_reload:function(){var i=this.options("perPage");if(this._pages={},this._items={},t.isFunction(i)&&(i=i.call(this)),null==i)this._pages=this._calculatePages();else for(var s,e=parseInt(i,10)||0,r=this.carousel().jcarousel("items"),n=1,o=0;;){if(s=r.eq(o++),0===s.length)break;this._pages[n]=this._pages[n]?this._pages[n].add(s):s,0===o%e&&n++}this._clear();var l=this,a=this.carousel().data("jcarousel"),h=this._element,u=this.options("item");t.each(this._pages,function(i,s){var e=l._items[i]=t(u.call(l,i,s));e.on(l.options("event")+".jcarouselpagination",t.proxy(function(){var t=s.eq(0);if(a.circular){var e=a.index(a.target()),r=a.index(t);parseFloat(i)>parseFloat(l._currentPage)?e>r&&(t="+="+(a.items().length-e+r)):r>e&&(t="-="+(e+(a.items().length-r)))}a[this.options("method")](t)},l)),h.append(e)}),this._update()},_update:function(){var i,s=this.carousel().jcarousel("target");t.each(this._pages,function(t,e){return e.each(function(){return s.is(this)?(i=t,!1):void 0}),i?!1:void 0}),this._currentPage!==i&&(this._trigger("inactive",this._items[this._currentPage]),this._trigger("active",this._items[i])),this._currentPage=i},items:function(){return this._items},_clear:function(){this._element.empty(),this._currentPage=null},_calculatePages:function(){for(var t,i=this.carousel().data("jcarousel"),s=i.items(),e=i.clipping(),r=0,n=0,o=1,l={};;){if(t=s.eq(n++),0===t.length)break;l[o]=l[o]?l[o].add(t):t,r+=i.dimension(t),r>=e&&(o++,r=0)}return l}})}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0},_timer:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onAnimateEnd=t.proxy(this.start,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy),this.options("autostart")&&this.start()},_destroy:function(){this.stop(),this.carousel().off("jcarousel:destroy",this.onDestroy)},start:function(){return this.stop(),this.carousel().one("jcarousel:animateend",this.onAnimateEnd),this._timer=setTimeout(t.proxy(function(){this.carousel().jcarousel("scroll",this.options("target"))},this),this.options("interval")),this},stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().off("jcarousel:animateend",this.onAnimateEnd),this}})}(jQuery);
// TODO: Remove tests already done by [[MediaWiki:Gadget-refToolbar.js]]
$(function() {
if (
    $('.jcarousel')
( mw.config.get('wgAction') === 'edit' || mw.config.get('wgAction') === 'submit' ) &&
        .on('jcarousel:create jcarousel:reload', function() {
( ( mw.config.get('wgNamespaceNumber') !== 2 && mw.config.get('wgNamespaceNumber') !== 4 ) ||
            var element = $(this),
( mw.config.get('wgPageName').indexOf('.js') === -1 && mw.config.get('wgPageName').indexOf('.css') === -1 ) )
                width = element.innerWidth();
) {
            // This shows 1 item at a time.
 
            // Divide `width` to the number of items you want to display,
// TODO: Move this to [[MediaWiki:Gadget-refToolbarDialogs.css]] and add it to the definition of module 'ext.gadget.refToolbarDialogs'
            // eg. `width = width / 3` to display 3 items at a time.
mw.util.addCSS(".cite-form-td {"+
            element.jcarousel('items').css('width', width + 'px');
"height: 0 !important;"+
        })
"padding: 0.1em !important;"+
        .jcarousel({
"}")
            // Configuration goes here
 
            wrap: 'both',
// Default options, these mainly exist so the script won't break if a new option is added
            animation: 1200,
CiteTB.DefaultOptions = {
            center: true
  "date format" : "<year>-<zmonth>-<zdate>",
        })
  "autodate fields" : [],
        .jcarouselAutoscroll({
  "months" : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
            interval: 10000,
  "modal" : true,
            target: '+=1',
  "autoparse" : false,
            autostart: true
  "expandtemplates": false
        });
};
 
    $('.jcarousel-control-prev')
// Get an option - user settings override global which override defaults
        .on('jcarouselcontrol:active', function() {
CiteTB.getOption = function(opt) {
            $(this).removeClass('inactive');
  if (CiteTB.UserOptions[opt] !== undefined) {
        })
    return CiteTB.UserOptions[opt];
        .on('jcarouselcontrol:inactive', function() {
  } else if (CiteTB.Options[opt] !== undefined) {
            $(this).addClass('inactive');
    return CiteTB.Options[opt];
        })
  }
        .jcarouselControl({
  return CiteTB.DefaultOptions[opt];
            target: '-=1'
};
        });
 
CiteTB.init = function() {
    $('.jcarousel-control-next')
  /* Main stuff, build the actual toolbar structure
        .on('jcarouselcontrol:active', function() {
  * 1. get the template list, make the dropdown list and set up the template dialog boxes
            $(this).removeClass('inactive');
  * 2. actually build the toolbar:
        })
  *    * A section for cites
        .on('jcarouselcontrol:inactive', function() {
  *    ** dropdown for the templates (previously defined)
            $(this).addClass('inactive');
  *    ** button for named refs with a dialog box
        })
  *    ** button for errorcheck
        .jcarouselControl({
  * 3. add the whole thing to the main toolbar
            target: '+=1'
  */
        });
 
  if (typeof $('div[rel=cites]')[0] !== 'undefined') { // Mystery IE bug workaround
    $('.jcarousel-pagination')
    return;
        .on('jcarouselpagination:active', 'a', function() {
  }
            $(this).addClass('active');
  $('head').trigger('reftoolbarbase');
        })
  var $target = $('#wpTextbox1');
        .on('jcarouselpagination:inactive', 'a', function() {
  var temlist = {};
            $(this).removeClass('active');
  for (var t in CiteTB.Templates) {
        })
    var tem = CiteTB.Templates[t];
        .jcarouselPagination();
    var sform = CiteTB.escStr(tem.shortform);
    var actionobj = {
      type: 'dialog',
      module: 'cite-dialog-'+sform
    };
    var dialogobj = {};
    dialogobj['cite-dialog-'+sform] = {
      resizeme: false,
      titleMsg: 'cite-dialog-'+sform,  
      id: 'citetoolbar-'+sform,
      init: function() {},  
      html: tem.getInitial(),  
      dialog: {
        width:675,
        open: function() {  
          $(this).html(CiteTB.getOpenTemplate().getForm());
          /** @param {jQuery.Event} e */
          $('.cite-prev-parse').bind( 'click', function ( e ) {
            e.preventDefault();
            CiteTB.prevParseClick();
          });
        },
        buttons: {
          'cite-form-submit': function() {
            var ref = CiteTB.getRef(false, true);
            $(this).dialog( 'close' );
            $.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
              type: 'encapsulate',
              options: {
                post: ref
              }
            }, $(this) );
          },
          'cite-form-showhide': CiteTB.showHideExtra,
          'cite-refpreview': function() {  
            var ref = CiteTB.getRef(false, false);
            var template = CiteTB.getOpenTemplate();
            var div = $("#citetoolbar-"+CiteTB.escStr(template.shortform));
            div.find('.cite-preview-label').show();
            div.find('.cite-ref-preview').text(ref).show();
            if (CiteTB.getOption('autoparse')) {
              CiteTB.prevParseClick();
            } else {
              div.find('.cite-prev-parse').show();
              div.find('.cite-prev-parsed-label').hide();
              div.find('.cite-preview-parsed').html('');
            }       
          },
          'wikieditor-toolbar-tool-link-cancel': function() {
            $(this).dialog( 'close' );
          },
          'cite-form-reset': function() {
            CiteTB.resetForm();
          }
        }
      }
    };
    $target.wikiEditor('addDialog', dialogobj);
    //if (!CiteTB.getOption('modal')) {
      //$('#citetoolbar-'+sform).dialog('option', 'modal', false);
    //}
    temlist[sform] = {label: tem.templatename, action: actionobj }; 
  }
 
  var refsection =  {
    'sections': {
      'cites': {
        type: 'toolbar',  
        labelMsg: 'cite-section-label',
        groups: {  
          'template': {
            tools: {
              'template': {
                type: 'select',
                labelMsg: 'cite-template-list',
                list: temlist
              }
            }
          },
          'namedrefs': {
            labelMsg: 'cite-named-refs-label',
            tools: {
              'nrefs': {
                type: 'button',
                action: {
                  type: 'dialog',
                  module: 'cite-toolbar-namedrefs'
                },
                icon: '//upload.wikimedia.org/wikipedia/commons/thumb/b/be/Nuvola_clipboard_lined.svg/22px-Nuvola_clipboard_lined.svg.png',
                section: 'cites',
                group: 'namedrefs',
                labelMsg: 'cite-named-refs-button'
              }
            }
          },
          'errorcheck': {
            labelMsg: 'cite-errorcheck-label',
            tools: {
              'echeck': {
                type: 'button',
                action: {
                  type: 'dialog',
                  module: 'cite-toolbar-errorcheck'         
                },
                icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a3/Nuvola_apps_korganizer-NO.png/22px-Nuvola_apps_korganizer-NO.png',
                section: 'cites',
                group: 'errorcheck',
                labelMsg: 'cite-errorcheck-button'
              }
            }
          }
        }
      }
    }
  };
 
  var defaultdialogs = {  
    'cite-toolbar-errorcheck': {
      titleMsg: 'cite-errorcheck-label',
      id: 'citetoolbar-errorcheck',
      resizeme: false,
      init: function() {},
      html: '<div id="cite-namedref-loading">'+
        '<img src="//upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'+
        '&nbsp;'+mw.usability.getMsg('cite-loading')+'</div>',
      dialog: {
        width:550,
        open: function() {
          CiteTB.loadRefs();
        },
        buttons: {
          'cite-errorcheck-submit': function() {
            var errorchecks = $("input[name='cite-err-test']:checked");
            var errors = [];
            for (var i=0; i<errorchecks.length; i++) {
              errors = errors.concat(CiteTB.ErrorChecks[$(errorchecks[i]).val()].run());
            }
            CiteTB.displayErrors(errors);
            $(this).dialog( 'close' );                     
          },
          'wikieditor-toolbar-tool-link-cancel': function() {
            $(this).dialog( 'close' );
          }
        }
      }
    },
    'cite-toolbar-namedrefs': {
      titleMsg: 'cite-named-refs-title',
      resizeme: false,
      id: 'citetoolbar-namedrefs',
      html: '<div id="cite-namedref-loading">'+
        '<img src="//upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />'+
        '&nbsp;'+mw.usability.getMsg('cite-loading')+'</div>',
      init: function() {},
      dialog: {
        width: 550,
        open: function() {  
          CiteTB.loadRefs();
        },
        buttons: {
          'cite-form-submit': function() {
            var refname = $("#cite-namedref-select").val();
            if (refname === '') {
              return;
            }
            $(this).dialog( 'close' );
            $.wikiEditor.modules.toolbar.fn.doAction( $(this).data( 'context' ), {
              type: 'encapsulate',
              options: {
                post: CiteTB.getNamedRef(refname, true)
              }
            }, $(this) );
          },
          'wikieditor-toolbar-tool-link-cancel': function() {
            $(this).dialog( 'close' );
          }                 
        }
      }     
    }
  };
 
  $target.wikiEditor('addDialog', defaultdialogs);
  $('#citetoolbar-namedrefs').unbind('dialogopen');
  if (!CiteTB.getOption('modal')) {
    //$('#citetoolbar-namedrefs').dialog('option', 'modal', false);
    //$('#citetoolbar-errorcheck').dialog('option', 'modal', false);
    mw.util.addCSS(".ui-widget-overlay {"+
    "display:none !important;"+
    "}")
  }
  $target.wikiEditor('addToToolbar', refsection);
};
 
// Load local data - messages, cite templates, etc.
$(document).ready( function() {
  switch( mw.config.get('wgUserLanguage') ) {
    case 'de': // German
      importScript('MediaWiki:RefToolbarMessages-de.js');
      break;
    default: // English
      importScript('MediaWiki:RefToolbarMessages-en.js');
  }
});
});
 
   
// Setup the main object
// END Main Page carousel code
CiteTB.mainRefList = [];
CiteTB.refsLoaded = false;
 
// REF FUNCTIONS
// Actually assemble a ref from user input
CiteTB.getRef = function(inneronly, forinsert) {
  var i;
  var template = CiteTB.getOpenTemplate();
  var templatename = template.templatename;
  var res = '';
  var refobj = {'shorttag':false};
  if (!inneronly) {
    var group = $('#cite-'+CiteTB.escStr(template.shortform)+'-group').val();
    var refname = $('#cite-'+CiteTB.escStr(template.shortform)+'-name').val();
    res += '<ref';
    if (refname) {
      refname = $.trim(refname);
      res+=' name='+CiteTB.getQuotedString(refname);
      refobj.refname = refname;
    }
    if (group) {
      group = $.trim(group);
      res+=' group='+CiteTB.getQuotedString(group);
      refobj.refgroup = group;
    }
    res+='>';
  }
  var content ='{{'+templatename;
  for( g in template.incrementables ) {
  group = template.incrementables[g];
  for (i=1; i<=group.val; i++) {
for (j=0; j<group.fields.length; j++) {
  var fieldname = group.fields[j].field;
  var fieldid = fieldname.replace('<N>', i.toString());
  var field = $('#cite-'+CiteTB.escStr(template.shortform)+'-'+fieldid).val();
  if (field) {
  content+='|'+fieldid+'=';
  content+= $.trim(field);
  }
  }
  }
  }
  for( i=0; i<template.basic.length; i++ ) {
  if (template.basic[i].increment_group) {
  continue;
  }
    var fieldname = template.basic[i].field;
    var field = $('#cite-'+CiteTB.escStr(template.shortform)+'-'+fieldname).val();
    if (field) {
      content+='|'+fieldname+'=';
      content+= $.trim(field);
    }
  }
  if ($('#cite-form-status').val() !== 'closed') {
    for( i=0; i<template.extra.length; i++ ) {
      if (template.extra[i].increment_group) {
        continue;
      }
      var fieldname = template.extra[i].field;
      var field = $('#cite-'+CiteTB.escStr(template.shortform)+'-'+fieldname).val();
      if (field) {
        content+='|'+fieldname+'=';
        content+= $.trim(field);
      }
    }
  }
  content+= '}}';
  res+=content;
  refobj.content = content;
  if (!inneronly) {
    res+= '</ref>';
  }
  if (forinsert) {
    CiteTB.mainRefList.push(refobj);
  }
  return res;
};
 
// Make a reference to a named ref
CiteTB.getNamedRef = function(refname, forinsert) {
  if (forinsert) {
    CiteTB.mainRefList.push( {'shorttag':true, 'refname':refname} );
  }
  return '<ref name='+CiteTB.getQuotedString(refname)+' />'; 
};
 
// Function to load the ref list
CiteTB.loadRefs = function() {
  if (CiteTB.refsLoaded) {
    return;
  }
  CiteTB.getPageText(CiteTB.loadRefsInternal);
};
 
// Function that actually loads the list from the page text
CiteTB.loadRefsInternal = function(text) {
  // What this does:            extract first name/group                                    extract second name/group                                          shorttag  inner content
  var refsregex = /< *ref(?: +(name|group) *= *(?:"([^"]*?)"|'([^']*?)'|([^ '"\/\>]*?)) *)? *(?: +(name|group) *= *(?:"([^"]*?)"|'([^']*?)'|([^ '"\/\>]*?)) *)? *(?:\/ *>|>((?:.|\n)*?)< *\/ *ref *>)/gim;
  // This should work regardless of the quoting used for names/groups and for linebreaks in the inner content  
  while (true) {
    var ref = refsregex.exec(text);
    if (ref === null) {
      break;
    }
    var refobj = {};
    if (ref[9]) { // Content + short tag check
      //alert('"'+ref[9]+'"');
      refobj.content = ref[9];
      refobj.shorttag = false;
    } else {
      refobj.shorttag = true;
    }
    if (ref[1] !== '') { // First name/group
      if (ref[2]) {
        refobj['ref'+ref[1]] = ref[2];
      } else if (ref[3]) {
        refobj['ref'+ref[1]] = ref[3];
      } else {
        refobj['ref'+ref[1]] = ref[4];
      }
    }
    if (ref[5] !== '') { // Second name/group
      if (ref[6]) {
        refobj['ref'+ref[5]] = ref[6];
      } else if (ref[7]) {
        refobj['ref'+ref[5]] = ref[7];
      } else {
        refobj['ref'+ref[5]] = ref[8];
      }
    }
    CiteTB.mainRefList.push(refobj);
  }
  CiteTB.refsLoaded = true;
  CiteTB.setupErrorCheck();
  CiteTB.setupNamedRefs();
};
 
// AJAX FUNCTIONS
// Parse some wikitext and hand it off to a callback function
CiteTB.parse = function(text, callback) {
  $.post( mw.util.wikiScript( 'api' ),
    {action:'parse', title:mw.config.get('wgPageName'), text:text, prop:'text', format:'json'},
    function(data) {
      var html = data.parse.text['*'];
      callback(html);
    },
    'json'
  ); 
};
 
// Use the API to expand templates on some text
CiteTB.expandtemplates = function(text, callback) {
  $.post( mw.util.wikiScript( 'api' ),
    {action:'expandtemplates', title:mw.config.get('wgPageName'), text:text, format:'json'},
    function(data) {
      var restext = data.expandtemplates['*'];
      callback(restext);
    },
    'json'
  );
};
 
// Function to get the page text
CiteTB.getPageText = function(callback) {
  var section = $("input[name='wpSection']").val();
  if ( section !== '' ) {
    var postdata = {action:'query', prop:'revisions', rvprop:'content', pageids:mw.config.get('wgArticleId'), format:'json'};
    if (CiteTB.getOption('expandtemplates')) {
      postdata.rvexpandtemplates = '1';
    }
    $.get( mw.util.wikiScript( 'api' ),
      postdata,
      function(data) {
        var pagetext = data.query.pages[mw.config.get('wgArticleId').toString()].revisions[0]['*'];
        callback(pagetext);
      },
      'json'
    );
  } else {
    if (CiteTB.getOption('expandtemplates')) {
      CiteTB.expandtemplates($('#wpTextbox1').wikiEditor('getContents').text(), callback);
    } else {
      callback($('#wpTextbox1').wikiEditor('getContents').text());
    }
  }
};
 
// Autofill a template from an ID (ISBN, DOI, PMID, URL)
CiteTB.initAutofill = function() {
  var elemid = $(this).attr('id');
  var res = /^cite\-auto\-(.*?)\-(.*)\-(.*)$/.exec(elemid);
  var tem = res[1];
  var field = res[2];
  var autotype = res[3];
  var id = $('#cite-'+tem+'-'+field).val();
  if (!id) {
    return false;
  }
  var url = '//tools.wmflabs.org/reftoolbar/lookup.php?';
  url+=autotype+'='+encodeURIComponent(id);
  url+='&template='+encodeURIComponent(tem);
  var s = document.createElement('script');
  s.setAttribute('src', url);
  s.setAttribute('type', 'text/javascript');
  document.getElementsByTagName('head')[0].appendChild(s);
  return false;
};
 
// Callback for autofill
//TODO: Autofill the URL, at least for DOI
CiteTB.autoFill = function(data, template, type) {
  var cl = 'cite-'+template+'-';
  var i,j, coauthors;
  $('.'+cl+'title').val(data.title);
  // Fill in authors
  if (data.authors && data.authors.length > 0) {
  if ($('.'+cl+'last-incr-1').length != 0) {
var classes = $('.'+cl+'last-incr-1').eq(0).attr('class').split(/\s+/);
var group = false;
var patt = /cite-[^-]*?-incr-(.*)/
for (var c=0; c<classes.length; c++) {
if (patt.exec(classes[c])) {
group = patt.exec(classes[c])[1];
break;
}
}
$('.'+cl+'last-incr-1').val(data.authors[0][0])
$('.'+cl+'first-incr-1').val(data.authors[0][1])
elemid = '#cite-incr-'+template+'-'+group;
for (var i=2; i<data.authors.length+1; i++) {
$(elemid).click();
$('.'+cl+'last-incr-'+i.toString()).val(data.authors[i-1][0])
$('.'+cl+'first-incr-'+i.toString()).val(data.authors[i-1][1])
}
  } else if ($('.'+cl+'author-incr-1').length != 0) {
var classes = $('.'+cl+'author-incr-1').eq(0).attr('class').split(/\s+/);
var group = false;
var patt = /cite-[^-]*?-incr-(.*)/
for (var c=0; c<classes.length; c++) {
if (patt.exec(classes[c])) {
group = patt.exec(classes[c])[1];
break;
}
}
$('.'+cl+'author-incr-1').val(data.authors[0].join(', '))
elemid = '#cite-incr-'+template+'-'+group;
for (var i=2; i<data.authors.length+1; i++) {
$(elemid).click();
$('.'+cl+'author-incr-'+i.toString()).val(data.authors[i-1].join(', '))
}
  } else if ($('.'+cl+'last1').length != 0) {
for(i=0; data.authors && i<data.authors.length; i++) {
  if ($('.'+cl+'last'+(i+1)).length) {
$('.'+cl+'last'+(i+1)).val(data.authors[i][0]);
$('.'+cl+'first'+(i+1)).val(data.authors[i][1]);
  } else {
coauthors = [];
for(j=i; j<data.authors.length; j++) {
  coauthors.push(data.authors[j].join(', '));
}
$('.'+cl+'coauthors').val(coauthors.join('; '));
break;
  }
}
  } else if($('.'+cl+'author1').length !== 0) {
for(i=0; data.authors && i<data.authors.length; i++) {
  if ($('.'+cl+'author'+(i+1)).length) {
$('.'+cl+'author'+(i+1)).val(data.authors[i].join(', '));
  } else {
coauthors = [];
for(j=i; j<data.authors.length; j++) {
  coauthors.push(data.authors[j].join(', '));
}
$('.'+cl+'coauthors').val(coauthors.join('; '));
break;
  }
}
  } else {
var authors = [];
for(i=0; data.authors && i<data.authors.length; i++) {
  authors.push(data.authors[i].join(', '));
}
$('.'+cl+'authors').val(authors.join('; '));
  }
  }
 
  if (type === 'pmid' || type === 'doi') {
    if (data.date && (data.fulldate || !$('.'+cl+'month').length)) {
      var DT = new Date(data.date);
      var useday = /\d{4}-\d{2}-\d{2}/.test(data.date);
      var usemonth = /\d{4}-\d{2}/.test(data.date);
      $('.'+cl+'date').val(CiteTB.formatDate(DT, useday, usemonth));
    } else if (!data.fulldate && $('.'+cl+'month').length && $('.'+cl+'year').length) {
      if (data.month) { // lookup.php sets month to false if it isn't provided
        $('.'+cl+'month').val( CiteTB.getOption('months')[parseInt(data.month)-1] );
      }
      $('.'+cl+'year').val(data.year);
    } else {
      $('.'+cl+'date').val(data.date);
    }
    $('.'+cl+'journal').val(data.journal);
    $('.'+cl+'volume').val(data.volume);
    $('.'+cl+'issue').val(data.issue);
    $('.'+cl+'pages').val(data.pages);
  } else if (type === 'isbn') {
    $('.'+cl+'publisher').val(data.publisher);
    $('.'+cl+'location').val(data.location);
    $('.'+cl+'year').val(data.year);
    $('.'+cl+'edition').val(data.edition);
  } else if (type === 'url') {
    if (data.date) {
    var DT = new Date(data.date);
      var useday = /\d{4}-\d{2}-\d{2}/.test(data.date);
      var usemonth = /\d{4}-\d{2}/.test(data.date);
      $('.'+cl+'date').val(CiteTB.formatDate(DT, useday, usemonth));
    }
    $('.'+cl+'journal').val(data.journal);
    $('.'+cl+'volume').val(data.volume);
    $('.'+cl+'issue').val(data.issue);
    $('.'+cl+'pages').val(data.pages);
    $('.'+cl+'publisher').val(data.publisher);
    $('.'+cl+'edition').val(data.edition);
    $('.'+cl+'isbn').val(data.isbn);
    $('.'+cl+'issn').val(data.issn);
    $('.'+cl+'doi').val(data.doi);
    // "en-US" isn't a valid value for the language parameter
    if (data.language && data.language !== 'en-US' && data.language !== 'en-GB') {
    $('.'+cl+'language').val(data.language);
    }
    $('.'+cl+'chapter').val(data.chapter);
  }
};
 
// FORM DIALOG FUNCTIONS
// Add new incrementable fields
CiteTB.incrementFields = function() {
template = CiteTB.getOpenTemplate();
var currentrow = $(this).parents('tr')[0];
$(this).prev().css('width', '100%')
$(this).detach();
var elemid = $(this).attr('id');
var res = /^cite\-incr\-(.*?)\-(.*)$/.exec(elemid);
group = res[2];
increments = template.incrementables[group];
fields = increments.fields;
incrval = increments.val+1;
template.incrementables[group].val += 1;
trs = template.makeFormInner(fields, false);
trs.reverse();
for (var i=0; i<trs.length; i++) {
$(currentrow).after(trs[i]);
}
};
 
// fill the accessdate param with the current date
CiteTB.fillAccessdate = function() {
  var elemid = $(this).attr('id');
  var res = /^cite\-date\-(.*?)\-(.*)$/.exec(elemid);
  var id = res[1];
  var field = res[2];
  var DT = new Date();
  var datestr = CiteTB.formatDate(DT);
  $('#cite-'+id+'-'+field).val(datestr);
  return false;
};
 
CiteTB.formatDate = function(DT, useday, usemonth) {
  if (typeof useday == "undefined") {
    useday = true;
  }
  if (typeof usemonth == "undefined") {
    usemonth = true;
  }
  var datestr = CiteTB.getOption('date format');
  var zmonth = '';
  var month = DT.getUTCMonth()+1;
  if (month < 10) {
    zmonth = "0"+month.toString();
  } else {
    zmonth = month.toString();
  }
  month = month.toString();
  var zdate = '';
  var date = DT.getUTCDate();
  if (date < 10) {
    zdate = "0"+date.toString();
  } else {
    zdate = date.toString();
  }
  date = date.toString();
  if (useday) {
    datestr = datestr.replace('<date>', date);
    datestr = datestr.replace('<zdate>', zdate);
  } else {
    datestr = datestr.replace('<date>', '');
    datestr = datestr.replace('<zdate>', '');
  }
  if (usemonth) {
    datestr = datestr.replace('<month>', month);
    datestr = datestr.replace('<zmonth>', zmonth);
    datestr = datestr.replace('<monthname>', CiteTB.getOption('months')[DT.getUTCMonth()]);
  } else {
    datestr = datestr.replace('<month>', '');
    datestr = datestr.replace('<zmonth>', '');
    datestr = datestr.replace('<monthname>', '');
  } 
  datestr = datestr.replace('<year>', DT.getUTCFullYear().toString());
  return datestr.replace(/^[ \/\-\,\.]*(.*?)[ \/\-\,\.]*$/g, "$1"); // Cleanup any dangling spaces or connectors that might result from omitting date/month
};
 
// Function called after the ref list is loaded, to actually set the contents of the named ref dialog
// Until the list is loaded, its just a "Loading" placeholder
CiteTB.setupNamedRefs = function() {
  var names = [], i;
  for( i=0; i<CiteTB.mainRefList.length; i++) {
    if (!CiteTB.mainRefList[i].shorttag && CiteTB.mainRefList[i].refname) {
      names.push(CiteTB.mainRefList[i]);
    }
  }
  var stuff = $('<div>');
  $('#citetoolbar-namedrefs').html( stuff );
  if (names.length === 0) {
    stuff.html(mw.usability.getMsg('cite-no-namedrefs'));
  } else {
    stuff.html(mw.usability.getMsg('cite-namedrefs-intro'));
    var select = $('<select id="cite-namedref-select">');
    select.append($('<option value="" />').text(mw.usability.getMsg('cite-named-refs-dropdown')));
    for(i=0; i<names.length; i++) {
      select.append($('<option />').text(names[i].refname));
    }
    stuff.after(select);
    select.before('<br />');     
    var prevlabel = $('<div id="cite-nref-preview-label" style="display:none;" />').html(mw.usability.getMsg('cite-raw-preview'));
    select.after(prevlabel);
    prevlabel.before("<br /><br />");
    prevlabel.after('<div id="cite-namedref-preview" style="padding:0.5em; font-size:110%" />');
    var parselabel = $('<span id="cite-parsed-label" style="display:none;" />').html(mw.usability.getMsg('cite-parsed-label'));
    $('#cite-namedref-preview').after(parselabel);
    parselabel.after('<div id="cite-namedref-parsed" style="padding-bottom:0.5em; font-size:110%" />');
    var link = $('<a href="#" id="cite-nref-parse" style="margin:0 1em 0 1em; display:none; color:darkblue" />');
    link.html(mw.usability.getMsg('cite-form-parse'));
    $('#cite-namedref-parsed').after(link);
   
    $("#cite-namedref-select").bind( 'change', CiteTB.namedRefSelectClick);
    $('#cite-nref-parse').bind( 'click', CiteTB.nrefParseClick);
  }     
};
 
// Function to get the errorcheck form HTML
CiteTB.setupErrorCheck = function() {
  var form = $('<div id="cite-errorcheck-heading" />').html(mw.usability.getMsg('cite-errorcheck-heading'));
  var ul = $("<ul id='cite-errcheck-list' />");
  var test;
  for (var t in CiteTB.ErrorChecks) {
    test = CiteTB.ErrorChecks[t];
    ul.append(test.getRow());
  }
  form.append(ul);
  $('#citetoolbar-errorcheck').html(form);
};
 
// Callback function for parsed preview
CiteTB.fillNrefPreview = function(parsed) {
  $('#cite-parsed-label').show();
  $('#cite-namedref-parsed').html(parsed);
};
 
// Click handler for the named-ref parsed preview
CiteTB.nrefParseClick = function() {
  var choice = $("#cite-namedref-select").val();
  if (choice === '') {
    $('#cite-parsed-label').hide();
    $('#cite-namedref-parsed').text('');
    return false;
  }
  $('#cite-nref-parse').hide();
  for( var i=0; i<CiteTB.mainRefList.length; i++) {
    if (!CiteTB.mainRefList[i].shorttag && CiteTB.mainRefList[i].refname == choice) {
      CiteTB.parse(CiteTB.mainRefList[i].content, CiteTB.fillNrefPreview);
      return false;
    }
  } 
};
 
// Click handler for the named-ref dropdown
CiteTB.lastnamedrefchoice = '';
CiteTB.namedRefSelectClick = function() {
  var choice = $("#cite-namedref-select").val();
  if (CiteTB.lastnamedrefchoice == choice) {
    return;
  }
  CiteTB.lastnamedrefchoice = choice;
  $('#cite-parsed-label').hide();
  $('#cite-namedref-parsed').text('');
  if (choice === '') {
    $('#cite-nref-preview-label').hide();
    $('#cite-namedref-preview').text('');
    $('#cite-nref-parse').hide();
    return;
  }
  for( var i=0; i<CiteTB.mainRefList.length; i++) {
    if (!CiteTB.mainRefList[i].shorttag && CiteTB.mainRefList[i].refname == choice) {
      $('#cite-nref-preview-label').show();
      $('#cite-namedref-preview').text(CiteTB.mainRefList[i].content);
      if (CiteTB.getOption('autoparse')) {
        CiteTB.nrefParseClick();
      } else {
        $('#cite-nref-parse').show();
      }
    }
  }
};
 
// callback function for parsed preview
CiteTB.fillTemplatePreview = function(text) {
  var template = CiteTB.getOpenTemplate();
  var div = $("#citetoolbar-"+CiteTB.escStr(template.shortform));
  div.find('.cite-prev-parsed-label').show();
  div.find('.cite-preview-parsed').html(text);
};
 
// Click handler for template parsed preview
CiteTB.prevParseClick = function() {
  var ref = CiteTB.getRef(true, false);
  var template = CiteTB.getOpenTemplate();
  var div = $("#citetoolbar-"+CiteTB.escStr(template.shortform));
  div.find('.cite-prev-parse').hide();
  CiteTB.parse(ref, CiteTB.fillTemplatePreview);
};
 
// Show/hide the extra fields in the dialog box
CiteTB.showHideExtra = function() {
  var template = CiteTB.getOpenTemplate();
  var div = $("#citetoolbar-"+CiteTB.escStr(template.shortform));
  var setting = div.find(".cite-form-status").val();
  if ( setting === 'closed' ) {
    div.find(".cite-form-status").val('open');
    div.find('.cite-extra-fields').show(1, function() {
      // jQuery adds "display:block", which screws things up
      div.find('.cite-extra-fields').attr('style', 'width:100%; background-color:transparent;');
    });
  } else {
    div.find(".cite-form-status").val('closed');
    div.find('.cite-extra-fields').hide();
  }
};
 
// Resets form fields and previews
// Resets form fields and previews
CiteTB.resetForm = function() {
  var template = CiteTB.getOpenTemplate();
  var div = $("#citetoolbar-"+CiteTB.escStr(template.shortform));
  div.html(template.getForm());
};
 
// STRING UTILITY FUNCTIONS
// Returns a string quoted as necessary for name/group attributes
CiteTB.getQuotedString = function(s) {
  var sq = /\'/.test(s); // single quotes
  var dq = /\"/.test(s); // double quotes
  if (!sq && !dq) { // Always quotes for non-latin alphabet
    return '"'+s+'"';
  } else if (!dq) { // Can use double quotes
    return '"'+s+'"';
  } else if (!sq) { // Can use single quotes
    return "'"+s+"'";
  } else { // Has double and single quotes
    s = s.replace(/\"/g, '\'');
    return '"'+s+'"';
  }
};
 
// Fix up strings for output - capitalize first char, replace underscores with spaces
CiteTB.fixStr = function(s) {
  s = s.slice(0,1).toUpperCase() + s.slice(1);
  s = s.replace('_',' ');
  return s;
};
 
// Escape spaces and quotes for use in HTML classes/ids
CiteTB.escStr = function(s) {
  return s.replace(' ', '-').replace("'", "\'").replace('"', '\"');
};
 
// MISC FUNCTIONS
// Determine which template form is open, and get the template object for it
CiteTB.getOpenTemplate = function() {
  var dialogs = $(".ui-dialog-content.ui-widget-content:visible");
  var templatename = $(dialogs[0]).find(".cite-template").val();
  return CiteTB.Templates[templatename];
};
 
// Display the report for the error checks
CiteTB.displayErrors = function(errors) {
  $('#cite-err-report').remove();
  var table = $('<table id="cite-err-report" style="width:100%; border:1px solid #A9A9A9; background-color:#FFEFD5; padding:0.25em; margin-top:0.5em" />');
  $('#editpage-copywarn').before(table);
  var tr;
  var tr1 = $('<tr style="width:100%" />');
  var th1 = $('<th style="width:60%; font-size:110%" />').html(mw.usability.getMsg('cite-err-report-heading'));
  var th2 = $('<th style="text-align:right; width:40%" />');
  var im = $('<img />').attr('src', '//upload.wikimedia.org/wikipedia/commons/thumb/5/55/Gtk-stop.svg/20px-Gtk-stop.svg.png');
  im.attr('alt', mw.usability.getMsg('cite-err-report-close')).attr('title', mw.usability.getMsg('cite-err-report-close'));
  var ad = $('<a id="cite-err-check-close" />').attr('href', '#');
  ad.append(im);
  th2.append(ad);
  tr1.append(th1).append(th2);
  table.append(tr1);
  $('#cite-err-check-close').bind('click', function() {  $('#cite-err-report').remove(); });
  if (errors.length === 0) {
    tr = $('<tr style="width:100%;" />');
    var td = $('<td style="text-align:center; margin:1.5px;" />').html(mw.usability.getMsg('cite-err-report-empty'));
    tr.append(td);
    table.append(tr);
   
    return;
  }
  for(var e in errors) {
    var err = errors[e];
    tr = $('<tr style="width:100%;" />');
    var td1 = $('<td style="border: 1px solid black; margin:1.5px; width:60%" />').html(err.err);
    var td2 = $('<td style="border: 1px solid black; margin:1.5px; width:40%" />').html(mw.usability.getMsg(err.msg));
    tr.append(td1).append(td2);
    table.append(tr);
  }
};
 
} // End of code loaded only on edit

Revisión actual del 11:07 17 oct 2018

/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
//Edición
if ( $.inArray(mw.config.get('wgAction'), ['edit', 'submit'] ) > -1) {
    /** Fix edit summary prompt for undo  ******************************************
     *  Fixes the fact that the undo function combined with the "no edit summary prompter"
     *  causes problems if leaving the edit summary unchanged.
     *  Added by [[User:Deskana]], code by [[User:Tra]].
     *  See also [[bugzilla:8912]].
     */
    $(document).ready( function () {
        if (document.location.search.indexOf("undo=") != -1 && document.getElementsByName('wpAutoSummary')[0]) {
            document.getElementsByName('wpAutoSummary')[0].value = '1';
        }
    });
 
    /**
     * Caracteres especiales (edittools)
     * Crea (y coloca) el ''combobox'' que permite seleccionar un conjunto determinado de
     * caracteres especiales bajo la caja de edición.
     * Funciona en conjunto con [[MediaWiki:Edittools]] y [[MediaWiki:Edittools.js]].
     * Basado en [[commons:MediaWiki:Edittools.js]].
     */
     importScript('MediaWiki:Edittools.javascript');
 
    //Seguimiento
} else if (mw.config.get('wgPageName') == 'Especial:Seguimiento') {
    mw.loader.load( mw.config.get('wgServer') + mw.config.get('wgScript') +
        '?title=MediaWiki:Common.js/seguimiento.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
}

// BEGIN Main Page carousel code
 
/*!
jCarousel - v0.3.0 - 2013-11-22
http://sorgalla.com/jcarousel
Copyright (c) 2013 Jan Sorgalla; Licensed MIT
 
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
 
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
*/
(function(t){"use strict";var i=t.jCarousel={};i.version="0.3.0";var s=/^([+\-]=)?(.+)$/;i.parseTarget=function(t){var i=!1,e="object"!=typeof t?s.exec(t):null;return e?(t=parseInt(e[2],10)||0,e[1]&&(i=!0,"-="===e[1]&&(t*=-1))):"object"!=typeof t&&(t=parseInt(t,10)||0),{target:t,relative:i}},i.detectCarousel=function(t){for(var i;t.length>0;){if(i=t.filter("[data-jcarousel]"),i.length>0)return i;if(i=t.find("[data-jcarousel]"),i.length>0)return i;t=t.parent()}return null},i.base=function(s){return{version:i.version,_options:{},_element:null,_carousel:null,_init:t.noop,_create:t.noop,_destroy:t.noop,_reload:t.noop,create:function(){return this._element.attr("data-"+s.toLowerCase(),!0).data(s,this),!1===this._trigger("create")?this:(this._create(),this._trigger("createend"),this)},destroy:function(){return!1===this._trigger("destroy")?this:(this._destroy(),this._trigger("destroyend"),this._element.removeData(s).removeAttr("data-"+s.toLowerCase()),this)},reload:function(t){return!1===this._trigger("reload")?this:(t&&this.options(t),this._reload(),this._trigger("reloadend"),this)},element:function(){return this._element},options:function(i,s){if(0===arguments.length)return t.extend({},this._options);if("string"==typeof i){if(s===void 0)return this._options[i]===void 0?null:this._options[i];this._options[i]=s}else this._options=t.extend({},this._options,i);return this},carousel:function(){return this._carousel||(this._carousel=i.detectCarousel(this.options("carousel")||this._element),this._carousel||t.error('Could not detect carousel for plugin "'+s+'"')),this._carousel},_trigger:function(i,e,r){var n,o=!1;return r=[this].concat(r||[]),(e||this._element).each(function(){n=t.Event((s+":"+i).toLowerCase()),t(this).trigger(n,r),n.isDefaultPrevented()&&(o=!0)}),!o}}},i.plugin=function(s,e){var r=t[s]=function(i,s){this._element=t(i),this.options(s),this._init(),this.create()};return r.fn=r.prototype=t.extend({},i.base(s),e),t.fn[s]=function(i){var e=Array.prototype.slice.call(arguments,1),n=this;return"string"==typeof i?this.each(function(){var r=t(this).data(s);if(!r)return t.error("Cannot call methods on "+s+" prior to initialization; "+'attempted to call method "'+i+'"');if(!t.isFunction(r[i])||"_"===i.charAt(0))return t.error('No such method "'+i+'" for '+s+" instance");var o=r[i].apply(r,e);return o!==r&&o!==void 0?(n=o,!1):void 0}):this.each(function(){var e=t(this).data(s);e instanceof r?e.reload(i):new r(this,i)}),n},r}})(jQuery),function(t,i){"use strict";var s=function(t){return parseFloat(t)||0};t.jCarousel.plugin("jcarousel",{animating:!1,tail:0,inTail:!1,resizeTimer:null,lt:null,vertical:!1,rtl:!1,circular:!1,underflow:!1,relative:!1,_options:{list:function(){return this.element().children().eq(0)},items:function(){return this.list().children()},animation:400,transitions:!1,wrap:null,vertical:null,rtl:null,center:!1},_list:null,_items:null,_target:null,_first:null,_last:null,_visible:null,_fullyvisible:null,_init:function(){var t=this;return this.onWindowResize=function(){t.resizeTimer&&clearTimeout(t.resizeTimer),t.resizeTimer=setTimeout(function(){t.reload()},100)},this},_create:function(){this._reload(),t(i).on("resize.jcarousel",this.onWindowResize)},_destroy:function(){t(i).off("resize.jcarousel",this.onWindowResize)},_reload:function(){this.vertical=this.options("vertical"),null==this.vertical&&(this.vertical=this.list().height()>this.list().width()),this.rtl=this.options("rtl"),null==this.rtl&&(this.rtl=function(i){if("rtl"===(""+i.attr("dir")).toLowerCase())return!0;var s=!1;return i.parents("[dir]").each(function(){return/rtl/i.test(t(this).attr("dir"))?(s=!0,!1):void 0}),s}(this._element)),this.lt=this.vertical?"top":"left",this.relative="relative"===this.list().css("position"),this._list=null,this._items=null;var i=this._target&&this.index(this._target)>=0?this._target:this.closest();this.circular="circular"===this.options("wrap"),this.underflow=!1;var s={left:0,top:0};return i.length>0&&(this._prepare(i),this.list().find("[data-jcarousel-clone]").remove(),this._items=null,this.underflow=this._fullyvisible.length>=this.items().length,this.circular=this.circular&&!this.underflow,s[this.lt]=this._position(i)+"px"),this.move(s),this},list:function(){if(null===this._list){var i=this.options("list");this._list=t.isFunction(i)?i.call(this):this._element.find(i)}return this._list},items:function(){if(null===this._items){var i=this.options("items");this._items=(t.isFunction(i)?i.call(this):this.list().find(i)).not("[data-jcarousel-clone]")}return this._items},index:function(t){return this.items().index(t)},closest:function(){var i,e=this,r=this.list().position()[this.lt],n=t(),o=!1,l=this.vertical?"bottom":this.rtl&&!this.relative?"left":"right";return this.rtl&&this.relative&&!this.vertical&&(r+=this.list().width()-this.clipping()),this.items().each(function(){if(n=t(this),o)return!1;var a=e.dimension(n);if(r+=a,r>=0){if(i=a-s(n.css("margin-"+l)),!(0>=Math.abs(r)-a+i/2))return!1;o=!0}}),n},target:function(){return this._target},first:function(){return this._first},last:function(){return this._last},visible:function(){return this._visible},fullyvisible:function(){return this._fullyvisible},hasNext:function(){if(!1===this._trigger("hasnext"))return!0;var t=this.options("wrap"),i=this.items().length-1;return i>=0&&(t&&"first"!==t||i>this.index(this._last)||this.tail&&!this.inTail)?!0:!1},hasPrev:function(){if(!1===this._trigger("hasprev"))return!0;var t=this.options("wrap");return this.items().length>0&&(t&&"last"!==t||this.index(this._first)>0||this.tail&&this.inTail)?!0:!1},clipping:function(){return this._element["inner"+(this.vertical?"Height":"Width")]()},dimension:function(t){return t["outer"+(this.vertical?"Height":"Width")](!0)},scroll:function(i,s,e){if(this.animating)return this;if(!1===this._trigger("scroll",null,[i,s]))return this;t.isFunction(s)&&(e=s,s=!0);var r=t.jCarousel.parseTarget(i);if(r.relative){var n,o,l,a,h,u,c,f,d=this.items().length-1,_=Math.abs(r.target),p=this.options("wrap");if(r.target>0){var v=this.index(this._last);if(v>=d&&this.tail)this.inTail?"both"===p||"last"===p?this._scroll(0,s,e):t.isFunction(e)&&e.call(this,!1):this._scrollTail(s,e);else if(n=this.index(this._target),this.underflow&&n===d&&("circular"===p||"both"===p||"last"===p)||!this.underflow&&v===d&&("both"===p||"last"===p))this._scroll(0,s,e);else if(l=n+_,this.circular&&l>d){for(f=d,h=this.items().get(-1);l>f++;)h=this.items().eq(0),u=this._visible.index(h)>=0,u&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(h),u||(c={},c[this.lt]=this.dimension(h),this.moveBy(c)),this._items=null;this._scroll(h,s,e)}else this._scroll(Math.min(l,d),s,e)}else if(this.inTail)this._scroll(Math.max(this.index(this._first)-_+1,0),s,e);else if(o=this.index(this._first),n=this.index(this._target),a=this.underflow?n:o,l=a-_,0>=a&&(this.underflow&&"circular"===p||"both"===p||"first"===p))this._scroll(d,s,e);else if(this.circular&&0>l){for(f=l,h=this.items().get(0);0>f++;){h=this.items().eq(-1),u=this._visible.index(h)>=0,u&&h.after(h.clone(!0).attr("data-jcarousel-clone",!0)),this.list().prepend(h),this._items=null;var g=this.dimension(h);c={},c[this.lt]=-g,this.moveBy(c)}this._scroll(h,s,e)}else this._scroll(Math.max(l,0),s,e)}else this._scroll(r.target,s,e);return this._trigger("scrollend"),this},moveBy:function(t,i){var e=this.list().position(),r=1,n=0;return this.rtl&&!this.vertical&&(r=-1,this.relative&&(n=this.list().width()-this.clipping())),t.left&&(t.left=e.left+n+s(t.left)*r+"px"),t.top&&(t.top=e.top+n+s(t.top)*r+"px"),this.move(t,i)},move:function(i,s){s=s||{};var e=this.options("transitions"),r=!!e,n=!!e.transforms,o=!!e.transforms3d,l=s.duration||0,a=this.list();if(!r&&l>0)return a.animate(i,s),void 0;var h=s.complete||t.noop,u={};if(r){var c=a.css(["transitionDuration","transitionTimingFunction","transitionProperty"]),f=h;h=function(){t(this).css(c),f.call(this)},u={transitionDuration:(l>0?l/1e3:0)+"s",transitionTimingFunction:e.easing||s.easing,transitionProperty:l>0?function(){return n||o?"all":i.left?"left":"top"}():"none",transform:"none"}}o?u.transform="translate3d("+(i.left||0)+","+(i.top||0)+",0)":n?u.transform="translate("+(i.left||0)+","+(i.top||0)+")":t.extend(u,i),r&&l>0&&a.one("transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",h),a.css(u),0>=l&&a.each(function(){h.call(this)})},_scroll:function(i,s,e){if(this.animating)return t.isFunction(e)&&e.call(this,!1),this;if("object"!=typeof i?i=this.items().eq(i):i.jquery===void 0&&(i=t(i)),0===i.length)return t.isFunction(e)&&e.call(this,!1),this;this.inTail=!1,this._prepare(i);var r=this._position(i),n=this.list().position()[this.lt];if(r===n)return t.isFunction(e)&&e.call(this,!1),this;var o={};return o[this.lt]=r+"px",this._animate(o,s,e),this},_scrollTail:function(i,s){if(this.animating||!this.tail)return t.isFunction(s)&&s.call(this,!1),this;var e=this.list().position()[this.lt];this.rtl&&this.relative&&!this.vertical&&(e+=this.list().width()-this.clipping()),this.rtl&&!this.vertical?e+=this.tail:e-=this.tail,this.inTail=!0;var r={};return r[this.lt]=e+"px",this._update({target:this._target.next(),fullyvisible:this._fullyvisible.slice(1).add(this._visible.last())}),this._animate(r,i,s),this},_animate:function(i,s,e){if(e=e||t.noop,!1===this._trigger("animate"))return e.call(this,!1),this;this.animating=!0;var r=this.options("animation"),n=t.proxy(function(){this.animating=!1;var t=this.list().find("[data-jcarousel-clone]");t.length>0&&(t.remove(),this._reload()),this._trigger("animateend"),e.call(this,!0)},this),o="object"==typeof r?t.extend({},r):{duration:r},l=o.complete||t.noop;return s===!1?o.duration=0:t.fx.speeds[o.duration]!==void 0&&(o.duration=t.fx.speeds[o.duration]),o.complete=function(){n(),l.call(this)},this.move(i,o),this},_prepare:function(i){var e,r,n,o,l=this.index(i),a=l,h=this.dimension(i),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=this.options("center"),d={target:i,first:i,last:i,visible:i,fullyvisible:u>=h?i:t()};if(f&&(h/=2,u/=2),u>h)for(;;){if(e=this.items().eq(++a),0===e.length){if(!this.circular)break;if(e=this.items().eq(0),i.get(0)===e.get(0))break;if(r=this._visible.index(e)>=0,r&&e.after(e.clone(!0).attr("data-jcarousel-clone",!0)),this.list().append(e),!r){var _={};_[this.lt]=this.dimension(e),this.moveBy(_)}this._items=null}if(o=this.dimension(e),0===o)break;if(h+=o,d.last=e,d.visible=d.visible.add(e),n=s(e.css("margin-"+c)),u>=h-n&&(d.fullyvisible=d.fullyvisible.add(e)),h>=u)break}if(!this.circular&&!f&&u>h)for(a=l;;){if(0>--a)break;if(e=this.items().eq(a),0===e.length)break;if(o=this.dimension(e),0===o)break;if(h+=o,d.first=e,d.visible=d.visible.add(e),n=s(e.css("margin-"+c)),u>=h-n&&(d.fullyvisible=d.fullyvisible.add(e)),h>=u)break}return this._update(d),this.tail=0,f||"circular"===this.options("wrap")||"custom"===this.options("wrap")||this.index(d.last)!==this.items().length-1||(h-=s(d.last.css("margin-"+c)),h>u&&(this.tail=h-u)),this},_position:function(t){var i=this._first,s=i.position()[this.lt],e=this.options("center"),r=e?this.clipping()/2-this.dimension(i)/2:0;return this.rtl&&!this.vertical?(s-=this.relative?this.list().width()-this.dimension(i):this.clipping()-this.dimension(i),s+=r):s-=r,!e&&(this.index(t)>this.index(i)||this.inTail)&&this.tail?(s=this.rtl&&!this.vertical?s-this.tail:s+this.tail,this.inTail=!0):this.inTail=!1,-s},_update:function(i){var s,e=this,r={target:this._target||t(),first:this._first||t(),last:this._last||t(),visible:this._visible||t(),fullyvisible:this._fullyvisible||t()},n=this.index(i.first||r.first)<this.index(r.first),o=function(s){var o=[],l=[];i[s].each(function(){0>r[s].index(this)&&o.push(this)}),r[s].each(function(){0>i[s].index(this)&&l.push(this)}),n?o=o.reverse():l=l.reverse(),e._trigger(s+"in",t(o)),e._trigger(s+"out",t(l)),e["_"+s]=i[s]};for(s in i)o(s);return this}})}(jQuery,window),function(t){"use strict";t.jcarousel.fn.scrollIntoView=function(i,s,e){var r,n=t.jCarousel.parseTarget(i),o=this.index(this._fullyvisible.first()),l=this.index(this._fullyvisible.last());if(r=n.relative?0>n.target?Math.max(0,o+n.target):l+n.target:"object"!=typeof n.target?n.target:this.index(n.target),o>r)return this.scroll(r,s,e);if(r>=o&&l>=r)return t.isFunction(e)&&e.call(this,!1),this;for(var a,h=this.items(),u=this.clipping(),c=this.vertical?"bottom":this.rtl?"left":"right",f=0;;){if(a=h.eq(r),0===a.length)break;if(f+=this.dimension(a),f>=u){var d=parseFloat(a.css("margin-"+c))||0;f-d!==u&&r++;break}if(0>=r)break;r--}return this.scroll(r,s,e)}}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselControl",{_options:{target:"+=1",event:"click",method:"scroll"},_active:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onEvent=t.proxy(function(i){i.preventDefault();var s=this.options("method");t.isFunction(s)?s.call(this):this.carousel().jcarousel(this.options("method"),this.options("target"))},this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend jcarousel:scrollend",this.onReload),this._element.on(this.options("event")+".jcarouselcontrol",this.onEvent),this._reload()},_destroy:function(){this._element.off(".jcarouselcontrol",this.onEvent),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend jcarousel:scrollend",this.onReload)},_reload:function(){var i,s=t.jCarousel.parseTarget(this.options("target")),e=this.carousel();if(s.relative)i=e.jcarousel(s.target>0?"hasNext":"hasPrev");else{var r="object"!=typeof s.target?e.jcarousel("items").eq(s.target):s.target;i=e.jcarousel("target").index(r)>=0}return this._active!==i&&(this._trigger(i?"active":"inactive"),this._active=i),this}})}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselPagination",{_options:{perPage:null,item:function(t){return'<a href="#'+t+'">'+t+"</a>"},event:"click",method:"scroll"},_pages:{},_items:{},_currentPage:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onReload=t.proxy(this._reload,this),this.onScroll=t.proxy(this._update,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy).on("jcarousel:reloadend",this.onReload).on("jcarousel:scrollend",this.onScroll),this._reload()},_destroy:function(){this._clear(),this.carousel().off("jcarousel:destroy",this.onDestroy).off("jcarousel:reloadend",this.onReload).off("jcarousel:scrollend",this.onScroll)},_reload:function(){var i=this.options("perPage");if(this._pages={},this._items={},t.isFunction(i)&&(i=i.call(this)),null==i)this._pages=this._calculatePages();else for(var s,e=parseInt(i,10)||0,r=this.carousel().jcarousel("items"),n=1,o=0;;){if(s=r.eq(o++),0===s.length)break;this._pages[n]=this._pages[n]?this._pages[n].add(s):s,0===o%e&&n++}this._clear();var l=this,a=this.carousel().data("jcarousel"),h=this._element,u=this.options("item");t.each(this._pages,function(i,s){var e=l._items[i]=t(u.call(l,i,s));e.on(l.options("event")+".jcarouselpagination",t.proxy(function(){var t=s.eq(0);if(a.circular){var e=a.index(a.target()),r=a.index(t);parseFloat(i)>parseFloat(l._currentPage)?e>r&&(t="+="+(a.items().length-e+r)):r>e&&(t="-="+(e+(a.items().length-r)))}a[this.options("method")](t)},l)),h.append(e)}),this._update()},_update:function(){var i,s=this.carousel().jcarousel("target");t.each(this._pages,function(t,e){return e.each(function(){return s.is(this)?(i=t,!1):void 0}),i?!1:void 0}),this._currentPage!==i&&(this._trigger("inactive",this._items[this._currentPage]),this._trigger("active",this._items[i])),this._currentPage=i},items:function(){return this._items},_clear:function(){this._element.empty(),this._currentPage=null},_calculatePages:function(){for(var t,i=this.carousel().data("jcarousel"),s=i.items(),e=i.clipping(),r=0,n=0,o=1,l={};;){if(t=s.eq(n++),0===t.length)break;l[o]=l[o]?l[o].add(t):t,r+=i.dimension(t),r>=e&&(o++,r=0)}return l}})}(jQuery),function(t){"use strict";t.jCarousel.plugin("jcarouselAutoscroll",{_options:{target:"+=1",interval:3e3,autostart:!0},_timer:null,_init:function(){this.onDestroy=t.proxy(function(){this._destroy(),this.carousel().one("jcarousel:createend",t.proxy(this._create,this))},this),this.onAnimateEnd=t.proxy(this.start,this)},_create:function(){this.carousel().one("jcarousel:destroy",this.onDestroy),this.options("autostart")&&this.start()},_destroy:function(){this.stop(),this.carousel().off("jcarousel:destroy",this.onDestroy)},start:function(){return this.stop(),this.carousel().one("jcarousel:animateend",this.onAnimateEnd),this._timer=setTimeout(t.proxy(function(){this.carousel().jcarousel("scroll",this.options("target"))},this),this.options("interval")),this},stop:function(){return this._timer&&(this._timer=clearTimeout(this._timer)),this.carousel().off("jcarousel:animateend",this.onAnimateEnd),this}})}(jQuery);
$(function() {
    $('.jcarousel')
        .on('jcarousel:create jcarousel:reload', function() {
            var element = $(this),
                width = element.innerWidth();
            // This shows 1 item at a time.
            // Divide `width` to the number of items you want to display,
            // eg. `width = width / 3` to display 3 items at a time.
            element.jcarousel('items').css('width', width + 'px');
        })
        .jcarousel({
            // Configuration goes here
            wrap: 'both',
            animation: 1200,
            center: true
        })
        .jcarouselAutoscroll({
            interval: 10000,
            target: '+=1',
            autostart: true
        });
 
    $('.jcarousel-control-prev')
        .on('jcarouselcontrol:active', function() {
            $(this).removeClass('inactive');
        })
        .on('jcarouselcontrol:inactive', function() {
            $(this).addClass('inactive');
        })
        .jcarouselControl({
            target: '-=1'
        });
 
    $('.jcarousel-control-next')
        .on('jcarouselcontrol:active', function() {
            $(this).removeClass('inactive');
        })
        .on('jcarouselcontrol:inactive', function() {
            $(this).addClass('inactive');
        })
        .jcarouselControl({
            target: '+=1'
        });
 
    $('.jcarousel-pagination')
        .on('jcarouselpagination:active', 'a', function() {
            $(this).addClass('active');
        })
        .on('jcarouselpagination:inactive', 'a', function() {
            $(this).removeClass('active');
        })
        .jcarouselPagination();
});
 
// END Main Page carousel code