1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050 |
- ;(function($) {
- var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,
- selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
- ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
- loadingTimer, loadingFrame = 1,
- titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
- isIE6 = $.browser.msie && $.browser.version < 7 && !window.XMLHttpRequest,
-
- _abort = function() {
- loading.hide();
- imgPreloader.onerror = imgPreloader.onload = null;
- if (ajaxLoader) {
- ajaxLoader.abort();
- }
- tmp.empty();
- },
- _error = function() {
- if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
- loading.hide();
- busy = false;
- return;
- }
- selectedOpts.titleShow = false;
- selectedOpts.width = 'auto';
- selectedOpts.height = 'auto';
- tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );
- _process_inline();
- },
- _start = function() {
- var obj = selectedArray[ selectedIndex ],
- href,
- type,
- title,
- str,
- emb,
- ret;
- _abort();
- selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
- ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);
- if (ret === false) {
- busy = false;
- return;
- } else if (typeof ret == 'object') {
- selectedOpts = $.extend(selectedOpts, ret);
- }
- title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';
- if (obj.nodeName && !selectedOpts.orig) {
- selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
- }
- if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
- title = selectedOpts.orig.attr('alt');
- }
- href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
- if ((/^(?:javascript)/i).test(href) || href == '#') {
- href = null;
- }
- if (selectedOpts.type) {
- type = selectedOpts.type;
- if (!href) {
- href = selectedOpts.content;
- }
- } else if (selectedOpts.content) {
- type = 'html';
- } else if (href) {
- if (href.match(imgRegExp)) {
- type = 'image';
- } else if (href.match(swfRegExp)) {
- type = 'swf';
- } else if ($(obj).hasClass("iframe")) {
- type = 'iframe';
- } else if (href.indexOf("#") === 0) {
- type = 'inline';
- } else {
- type = 'ajax';
- }
- }
- if (!type) {
- _error();
- return;
- }
- if (type == 'inline') {
- obj = href.substr(href.indexOf("#"));
- type = $(obj).length > 0 ? 'inline' : 'ajax';
- }
- selectedOpts.type = type;
- selectedOpts.href = href;
- selectedOpts.title = title;
- if (selectedOpts.autoDimensions) {
- if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
- selectedOpts.width = 'auto';
- selectedOpts.height = 'auto';
- } else {
- selectedOpts.autoDimensions = false;
- }
- }
- if (selectedOpts.modal) {
- selectedOpts.overlayShow = true;
- selectedOpts.hideOnOverlayClick = false;
- selectedOpts.hideOnContentClick = false;
- selectedOpts.enableEscapeButton = false;
- selectedOpts.showCloseButton = false;
- }
- selectedOpts.padding = parseInt(selectedOpts.padding, 10);
- selectedOpts.margin = parseInt(selectedOpts.margin, 10);
- tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
- $('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
- $(this).replaceWith(content.children());
- });
- switch (type) {
- case 'html' :
- tmp.html( selectedOpts.content );
- _process_inline();
- break;
- case 'inline' :
- if ( $(obj).parent().is('#fancybox-content') === true) {
- busy = false;
- return;
- }
- $('<div class="fancybox-inline-tmp" />')
- .hide()
- .insertBefore( $(obj) )
- .bind('fancybox-cleanup', function() {
- $(this).replaceWith(content.children());
- }).bind('fancybox-cancel', function() {
- $(this).replaceWith(tmp.children());
- });
- $(obj).appendTo(tmp);
- _process_inline();
- break;
- case 'image':
- busy = false;
- $.fancybox.showActivity();
- imgPreloader = new Image();
- imgPreloader.onerror = function() {
- _error();
- };
- imgPreloader.onload = function() {
- busy = true;
- imgPreloader.onerror = imgPreloader.onload = null;
- _process_image();
- };
- imgPreloader.src = href;
- break;
- case 'swf':
- selectedOpts.scrolling = 'no';
- str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
- emb = '';
- $.each(selectedOpts.swf, function(name, val) {
- str += '<param name="' + name + '" value="' + val + '"></param>';
- emb += ' ' + name + '="' + val + '"';
- });
- str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
- tmp.html(str);
- _process_inline();
- break;
- case 'ajax':
- busy = false;
- $.fancybox.showActivity();
- selectedOpts.ajax.win = selectedOpts.ajax.success;
- ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
- url : href,
- data : selectedOpts.ajax.data || {},
- error : function(XMLHttpRequest, textStatus, errorThrown) {
- if ( XMLHttpRequest.status > 0 ) {
- _error();
- }
- },
- success : function(data, textStatus, XMLHttpRequest) {
- var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
- if (o.status == 200) {
- if ( typeof selectedOpts.ajax.win == 'function' ) {
- ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);
- if (ret === false) {
- loading.hide();
- return;
- } else if (typeof ret == 'string' || typeof ret == 'object') {
- data = ret;
- }
- }
- tmp.html( data );
- _process_inline();
- }
- }
- }));
- break;
- case 'iframe':
- _show();
- break;
- }
- },
- _process_inline = function() {
- var
- w = selectedOpts.width,
- h = selectedOpts.height;
- if (w.toString().indexOf('%') > -1) {
- w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
- } else {
- w = w == 'auto' ? 'auto' : w + 'px';
- }
- if (h.toString().indexOf('%') > -1) {
- h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
- } else {
- h = h == 'auto' ? 'auto' : h + 'px';
- }
- tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
- selectedOpts.width = tmp.width();
- selectedOpts.height = tmp.height();
- _show();
- },
- _process_image = function() {
- selectedOpts.width = imgPreloader.width;
- selectedOpts.height = imgPreloader.height;
- $("<img />").attr({
- 'id' : 'fancybox-img',
- 'src' : imgPreloader.src,
- 'alt' : selectedOpts.title
- }).appendTo( tmp );
- _show();
- },
- _show = function() {
- var pos, equal;
- loading.hide();
- if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
- $.event.trigger('fancybox-cancel');
- busy = false;
- return;
- }
- busy = true;
- $(content.add( overlay )).unbind();
- $(window).unbind("resize.fb scroll.fb");
- $(document).unbind('keydown.fb');
- if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
- wrap.css('height', wrap.height());
- }
- currentArray = selectedArray;
- currentIndex = selectedIndex;
- currentOpts = selectedOpts;
- if (currentOpts.overlayShow) {
- overlay.css({
- 'background-color' : currentOpts.overlayColor,
- 'opacity' : currentOpts.overlayOpacity,
- 'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
- 'height' : $(document).height()
- });
- if (!overlay.is(':visible')) {
- if (isIE6) {
- $('select:not(#fancybox-tmp select)').filter(function() {
- return this.style.visibility !== 'hidden';
- }).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
- this.style.visibility = 'inherit';
- });
- }
- overlay.show();
- }
- } else {
- overlay.hide();
- }
- final_pos = _get_zoom_to();
- _process_title();
- if (wrap.is(":visible")) {
- $( close.add( nav_left ).add( nav_right ) ).hide();
- pos = wrap.position(),
- start_pos = {
- top : pos.top,
- left : pos.left,
- width : wrap.width(),
- height : wrap.height()
- };
- equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
- content.fadeTo(currentOpts.changeFade, 0.3, function() {
- var finish_resizing = function() {
- content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
- };
- $.event.trigger('fancybox-change');
- content
- .empty()
- .removeAttr('filter')
- .css({
- 'border-width' : currentOpts.padding,
- 'width' : final_pos.width - currentOpts.padding * 2,
- 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
- });
- if (equal) {
- finish_resizing();
- } else {
- fx.prop = 0;
- $(fx).animate({prop: 1}, {
- duration : currentOpts.changeSpeed,
- easing : currentOpts.easingChange,
- step : _draw,
- complete : finish_resizing
- });
- }
- });
- return;
- }
- wrap.removeAttr("style");
- content.css('border-width', currentOpts.padding);
- if (currentOpts.transitionIn == 'elastic') {
- start_pos = _get_zoom_from();
- content.html( tmp.contents() );
- wrap.show();
- if (currentOpts.opacity) {
- final_pos.opacity = 0;
- }
- fx.prop = 0;
- $(fx).animate({prop: 1}, {
- duration : currentOpts.speedIn,
- easing : currentOpts.easingIn,
- step : _draw,
- complete : _finish
- });
- return;
- }
- if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
- title.show();
- }
- content
- .css({
- 'width' : final_pos.width - currentOpts.padding * 2,
- 'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
- })
- .html( tmp.contents() );
- wrap
- .css(final_pos)
- .fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
- },
- _format_title = function(title) {
- if (title && title.length) {
- if (currentOpts.titlePosition == 'float') {
- return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
- }
- return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
- }
- return false;
- },
- _process_title = function() {
- titleStr = currentOpts.title || '';
- titleHeight = 0;
- title
- .empty()
- .removeAttr('style')
- .removeClass();
- if (currentOpts.titleShow === false) {
- title.hide();
- return;
- }
- titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
- if (!titleStr || titleStr === '') {
- title.hide();
- return;
- }
- title
- .addClass('fancybox-title-' + currentOpts.titlePosition)
- .html( titleStr )
- .appendTo( 'body' )
- .show();
- switch (currentOpts.titlePosition) {
- case 'inside':
- title
- .css({
- 'width' : final_pos.width - (currentOpts.padding * 2),
- 'marginLeft' : currentOpts.padding,
- 'marginRight' : currentOpts.padding
- });
- titleHeight = title.outerHeight(true);
- title.appendTo( outer );
- final_pos.height += titleHeight;
- break;
- case 'over':
- title
- .css({
- 'marginLeft' : currentOpts.padding,
- 'width' : final_pos.width - (currentOpts.padding * 2),
- 'bottom' : currentOpts.padding
- })
- .appendTo( outer );
- break;
- case 'float':
- title
- .css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
- .appendTo( wrap );
- break;
- default:
- title
- .css({
- 'width' : final_pos.width - (currentOpts.padding * 2),
- 'paddingLeft' : currentOpts.padding,
- 'paddingRight' : currentOpts.padding
- })
- .appendTo( wrap );
- break;
- }
- title.hide();
- },
- _set_navigation = function() {
- if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
- $(document).bind('keydown.fb', function(e) {
- if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
- e.preventDefault();
- $.fancybox.close();
- } else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
- e.preventDefault();
- $.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
- }
- });
- }
- if (!currentOpts.showNavArrows) {
- nav_left.hide();
- nav_right.hide();
- return;
- }
- if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
- nav_left.show();
- }
- if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
- nav_right.show();
- }
- },
- _finish = function () {
- if (!$.support.opacity) {
- content.get(0).style.removeAttribute('filter');
- wrap.get(0).style.removeAttribute('filter');
- }
- if (selectedOpts.autoDimensions) {
- content.css('height', 'auto');
- }
- wrap.css('height', 'auto');
- if (titleStr && titleStr.length) {
- title.show();
- }
- if (currentOpts.showCloseButton) {
- close.show();
- }
- _set_navigation();
-
- if (currentOpts.hideOnContentClick) {
- content.bind('click', $.fancybox.close);
- }
- if (currentOpts.hideOnOverlayClick) {
- overlay.bind('click', $.fancybox.close);
- }
- $(window).bind("resize.fb", $.fancybox.resize);
- if (currentOpts.centerOnScroll) {
- $(window).bind("scroll.fb", $.fancybox.center);
- }
- if (currentOpts.type == 'iframe') {
- $('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
- }
- wrap.show();
- busy = false;
- $.fancybox.center();
- currentOpts.onComplete(currentArray, currentIndex, currentOpts);
- _preload_images();
- },
- _preload_images = function() {
- var href,
- objNext;
- if ((currentArray.length -1) > currentIndex) {
- href = currentArray[ currentIndex + 1 ].href;
- if (typeof href !== 'undefined' && href.match(imgRegExp)) {
- objNext = new Image();
- objNext.src = href;
- }
- }
- if (currentIndex > 0) {
- href = currentArray[ currentIndex - 1 ].href;
- if (typeof href !== 'undefined' && href.match(imgRegExp)) {
- objNext = new Image();
- objNext.src = href;
- }
- }
- },
- _draw = function(pos) {
- var dim = {
- width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
- height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),
- top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
- left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
- };
- if (typeof final_pos.opacity !== 'undefined') {
- dim.opacity = pos < 0.5 ? 0.5 : pos;
- }
- wrap.css(dim);
- content.css({
- 'width' : dim.width - currentOpts.padding * 2,
- 'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
- });
- },
- _get_viewport = function() {
- return [
- $(window).width() - (currentOpts.margin * 2),
- $(window).height() - (currentOpts.margin * 2),
- $(document).scrollLeft() + currentOpts.margin,
- $(document).scrollTop() + currentOpts.margin
- ];
- },
- _get_zoom_to = function () {
- var view = _get_viewport(),
- to = {},
- resize = currentOpts.autoScale,
- double_padding = currentOpts.padding * 2,
- ratio;
- if (currentOpts.width.toString().indexOf('%') > -1) {
- to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
- } else {
- to.width = currentOpts.width + double_padding;
- }
- if (currentOpts.height.toString().indexOf('%') > -1) {
- to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
- } else {
- to.height = currentOpts.height + double_padding;
- }
- if (resize && (to.width > view[0] || to.height > view[1])) {
- if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
- ratio = (currentOpts.width ) / (currentOpts.height );
- if ((to.width ) > view[0]) {
- to.width = view[0];
- to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
- }
- if ((to.height) > view[1]) {
- to.height = view[1];
- to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
- }
- } else {
- to.width = Math.min(to.width, view[0]);
- to.height = Math.min(to.height, view[1]);
- }
- }
- to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
- to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);
- return to;
- },
- _get_obj_pos = function(obj) {
- var pos = obj.offset();
- pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
- pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;
- pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
- pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;
- pos.width = obj.width();
- pos.height = obj.height();
- return pos;
- },
- _get_zoom_from = function() {
- var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
- from = {},
- pos,
- view;
- if (orig && orig.length) {
- pos = _get_obj_pos(orig);
- from = {
- width : pos.width + (currentOpts.padding * 2),
- height : pos.height + (currentOpts.padding * 2),
- top : pos.top - currentOpts.padding - 20,
- left : pos.left - currentOpts.padding - 20
- };
- } else {
- view = _get_viewport();
- from = {
- width : currentOpts.padding * 2,
- height : currentOpts.padding * 2,
- top : parseInt(view[3] + view[1] * 0.5, 10),
- left : parseInt(view[2] + view[0] * 0.5, 10)
- };
- }
- return from;
- },
- _animate_loading = function() {
- if (!loading.is(':visible')){
- clearInterval(loadingTimer);
- return;
- }
- $('div', loading).css('top', (loadingFrame * -40) + 'px');
- loadingFrame = (loadingFrame + 1) % 12;
- };
-
- $.fn.fancybox = function(options) {
- if (!$(this).length) {
- return this;
- }
- $(this)
- .data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
- .unbind('click.fb')
- .bind('click.fb', function(e) {
- e.preventDefault();
- if (busy) {
- return;
- }
- busy = true;
- $(this).blur();
- selectedArray = [];
- selectedIndex = 0;
- var rel = $(this).attr('rel') || '';
- if (!rel || rel == '' || rel === 'nofollow') {
- selectedArray.push(this);
- } else {
- selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
- selectedIndex = selectedArray.index( this );
- }
- _start();
- return;
- });
- return this;
- };
- $.fancybox = function(obj) {
- var opts;
- if (busy) {
- return;
- }
- busy = true;
- opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
- selectedArray = [];
- selectedIndex = parseInt(opts.index, 10) || 0;
- if ($.isArray(obj)) {
- for (var i = 0, j = obj.length; i < j; i++) {
- if (typeof obj[i] == 'object') {
- $(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
- } else {
- obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
- }
- }
- selectedArray = jQuery.merge(selectedArray, obj);
- } else {
- if (typeof obj == 'object') {
- $(obj).data('fancybox', $.extend({}, opts, obj));
- } else {
- obj = $({}).data('fancybox', $.extend({content : obj}, opts));
- }
- selectedArray.push(obj);
- }
- if (selectedIndex > selectedArray.length || selectedIndex < 0) {
- selectedIndex = 0;
- }
- _start();
- };
- $.fancybox.showActivity = function() {
- clearInterval(loadingTimer);
- loading.show();
- loadingTimer = setInterval(_animate_loading, 66);
- };
- $.fancybox.hideActivity = function() {
- loading.hide();
- };
- $.fancybox.next = function() {
- return $.fancybox.pos( currentIndex + 1);
- };
- $.fancybox.prev = function() {
- return $.fancybox.pos( currentIndex - 1);
- };
- $.fancybox.pos = function(pos) {
- if (busy) {
- return;
- }
- pos = parseInt(pos);
- selectedArray = currentArray;
- if (pos > -1 && pos < currentArray.length) {
- selectedIndex = pos;
- _start();
- } else if (currentOpts.cyclic && currentArray.length > 1) {
- selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
- _start();
- }
- return;
- };
- $.fancybox.cancel = function() {
- if (busy) {
- return;
- }
- busy = true;
- $.event.trigger('fancybox-cancel');
- _abort();
- selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
- busy = false;
- };
-
- $.fancybox.close = function() {
- if (busy || wrap.is(':hidden')) {
- return;
- }
- busy = true;
- if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
- busy = false;
- return;
- }
- _abort();
- $(close.add( nav_left ).add( nav_right )).hide();
- $(content.add( overlay )).unbind();
- $(window).unbind("resize.fb scroll.fb");
- $(document).unbind('keydown.fb');
- content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');
- if (currentOpts.titlePosition !== 'inside') {
- title.empty();
- }
- wrap.stop();
- function _cleanup() {
- overlay.fadeOut('fast');
- title.empty().hide();
- wrap.hide();
- $.event.trigger('fancybox-cleanup');
- content.empty();
- currentOpts.onClosed(currentArray, currentIndex, currentOpts);
- currentArray = selectedOpts = [];
- currentIndex = selectedIndex = 0;
- currentOpts = selectedOpts = {};
- busy = false;
- }
- if (currentOpts.transitionOut == 'elastic') {
- start_pos = _get_zoom_from();
- var pos = wrap.position();
- final_pos = {
- top : pos.top ,
- left : pos.left,
- width : wrap.width(),
- height : wrap.height()
- };
- if (currentOpts.opacity) {
- final_pos.opacity = 1;
- }
- title.empty().hide();
- fx.prop = 1;
- $(fx).animate({ prop: 0 }, {
- duration : currentOpts.speedOut,
- easing : currentOpts.easingOut,
- step : _draw,
- complete : _cleanup
- });
- } else {
- wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
- }
- };
- $.fancybox.resize = function() {
- if (overlay.is(':visible')) {
- overlay.css('height', $(document).height());
- }
- $.fancybox.center(true);
- };
- $.fancybox.center = function() {
- var view, align;
- if (busy) {
- return;
- }
- align = arguments[0] === true ? 1 : 0;
- view = _get_viewport();
- if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
- return;
- }
- wrap
- .stop()
- .animate({
- 'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
- 'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
- }, typeof arguments[0] == 'number' ? arguments[0] : 200);
- };
- $.fancybox.init = function() {
- if ($("#fancybox-wrap").length) {
- return;
- }
- $('body').append(
- tmp = $('<div id="fancybox-tmp"></div>'),
- loading = $('<div id="fancybox-loading"><div></div></div>'),
- overlay = $('<div id="fancybox-overlay"></div>'),
- wrap = $('<div id="fancybox-wrap"></div>')
- );
- outer = $('<div id="fancybox-outer"></div>')
- .append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
- .appendTo( wrap );
- outer.append(
- content = $('<div id="fancybox-content"></div>'),
- close = $('<a id="fancybox-close"></a>'),
- title = $('<div id="fancybox-title"></div>'),
- nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
- nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
- );
- close.click($.fancybox.close);
- loading.click($.fancybox.cancel);
- nav_left.click(function(e) {
- e.preventDefault();
- $.fancybox.prev();
- });
- nav_right.click(function(e) {
- e.preventDefault();
- $.fancybox.next();
- });
- if ($.fn.mousewheel) {
- wrap.bind('mousewheel.fb', function(e, delta) {
- if (busy) {
- e.preventDefault();
- } else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
- e.preventDefault();
- $.fancybox[ delta > 0 ? 'prev' : 'next']();
- }
- });
- }
- if (!$.support.opacity) {
- wrap.addClass('fancybox-ie');
- }
- if (isIE6) {
- loading.addClass('fancybox-ie6');
- wrap.addClass('fancybox-ie6');
- $('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
- }
- };
- $.fn.fancybox.defaults = {
- padding : 10,
- margin : 40,
- opacity : false,
- modal : false,
- cyclic : false,
- scrolling : 'auto',
- width : 560,
- height : 340,
- autoScale : true,
- autoDimensions : true,
- centerOnScroll : false,
- ajax : {},
- swf : { wmode: 'transparent' },
- hideOnOverlayClick : true,
- hideOnContentClick : false,
- overlayShow : true,
- overlayOpacity : 0.7,
- overlayColor : '#777',
- titleShow : true,
- titlePosition : 'float',
- titleFormat : null,
- titleFromAlt : false,
- transitionIn : 'fade',
- transitionOut : 'fade',
- speedIn : 300,
- speedOut : 300,
- changeSpeed : 300,
- changeFade : 'fast',
- easingIn : 'swing',
- easingOut : 'swing',
- showCloseButton : true,
- showNavArrows : true,
- enableEscapeButton : true,
- enableKeyboardNav : true,
- onStart : function(){},
- onCancel : function(){},
- onComplete : function(){},
- onCleanup : function(){},
- onClosed : function(){},
- onError : function(){}
- };
- $(document).ready(function() {
- $.fancybox.init();
- });
- })(jQuery);
- (function($) {
- function Countdown() {
- this.regional = [];
- this.regional[''] = {
-
- labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
-
- labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
- compactLabels: ['y', 'm', 'w', 'd'],
- whichLabels: null,
- digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
- timeSeparator: ':',
- isRTL: false
- };
- this._defaults = {
- until: null,
-
-
- since: null,
-
-
- timezone: null,
-
- serverSync: null,
- format: 'dHMS',
-
- layout: '',
- compact: false,
- significant: 0,
- description: '',
- expiryUrl: '',
- expiryText: '',
- alwaysExpire: false,
- onExpiry: null,
-
- onTick: null,
-
-
- tickInterval: 1
- };
- $.extend(this._defaults, this.regional['']);
- this._serverSyncs = [];
- var now = (typeof Date.now == 'function' ? Date.now :
- function() { return new Date().getTime(); });
- var perfAvail = (window.performance && typeof window.performance.now == 'function');
-
- function timerCallBack(timestamp) {
- var drawStart = (timestamp < 1e12 ?
- (perfAvail ? (performance.now() + performance.timing.navigationStart) : now()) :
-
- timestamp || now());
- if (drawStart - animationStartTime >= 1000) {
- plugin._updateTargets();
- animationStartTime = drawStart;
- }
- requestAnimationFrame(timerCallBack);
- }
- var requestAnimationFrame = window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
-
- var animationStartTime = 0;
- if (!requestAnimationFrame || $.noRequestAnimationFrame) {
- $.noRequestAnimationFrame = null;
- setInterval(function() { plugin._updateTargets(); }, 980);
- }
- else {
- animationStartTime = window.animationStartTime ||
- window.webkitAnimationStartTime || window.mozAnimationStartTime ||
- window.oAnimationStartTime || window.msAnimationStartTime || now();
- requestAnimationFrame(timerCallBack);
- }
- }
- var Y = 0;
- var O = 1;
- var W = 2;
- var D = 3;
- var H = 4;
- var M = 5;
- var S = 6;
- $.extend(Countdown.prototype, {
-
- markerClassName: 'hasCountdown',
-
- propertyName: 'countdown',
-
- _rtlClass: 'countdown_rtl',
-
- _sectionClass: 'countdown_section',
-
- _amountClass: 'countdown_amount',
-
- _rowClass: 'countdown_row',
-
- _holdingClass: 'countdown_holding',
-
- _showClass: 'countdown_show',
-
- _descrClass: 'countdown_descr',
-
- _timerTargets: [],
-
-
- setDefaults: function(options) {
- this._resetExtraLabels(this._defaults, options);
- $.extend(this._defaults, options || {});
- },
-
- UTCDate: function(tz, year, month, day, hours, mins, secs, ms) {
- if (typeof year == 'object' && year.constructor == Date) {
- ms = year.getMilliseconds();
- secs = year.getSeconds();
- mins = year.getMinutes();
- hours = year.getHours();
- day = year.getDate();
- month = year.getMonth();
- year = year.getFullYear();
- }
- var d = new Date();
- d.setUTCFullYear(year);
- d.setUTCDate(1);
- d.setUTCMonth(month || 0);
- d.setUTCDate(day || 1);
- d.setUTCHours(hours || 0);
- d.setUTCMinutes((mins || 0) - (Math.abs(tz) < 30 ? tz * 60 : tz));
- d.setUTCSeconds(secs || 0);
- d.setUTCMilliseconds(ms || 0);
- return d;
- },
-
- periodsToSeconds: function(periods) {
- return periods[0] * 31557600 + periods[1] * 2629800 + periods[2] * 604800 +
- periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
- },
-
- _attachPlugin: function(target, options) {
- target = $(target);
- if (target.hasClass(this.markerClassName)) {
- return;
- }
- var inst = {options: $.extend({}, this._defaults), _periods: [0, 0, 0, 0, 0, 0, 0]};
- target.addClass(this.markerClassName).data(this.propertyName, inst);
- this._optionPlugin(target, options);
- },
-
- _addTarget: function(target) {
- if (!this._hasTarget(target)) {
- this._timerTargets.push(target);
- }
- },
-
- _hasTarget: function(target) {
- return ($.inArray(target, this._timerTargets) > -1);
- },
-
- _removeTarget: function(target) {
- this._timerTargets = $.map(this._timerTargets,
- function(value) { return (value == target ? null : value); });
- },
-
- _updateTargets: function() {
- for (var i = this._timerTargets.length - 1; i >= 0; i--) {
- this._updateCountdown(this._timerTargets[i]);
- }
- },
-
- _optionPlugin: function(target, options, value) {
- target = $(target);
- var inst = target.data(this.propertyName);
- if (!options || (typeof options == 'string' && value == null)) {
- var name = options;
- options = (inst || {}).options;
- return (options && name ? options[name] : options);
- }
- if (!target.hasClass(this.markerClassName)) {
- return;
- }
- options = options || {};
- if (typeof options == 'string') {
- var name = options;
- options = {};
- options[name] = value;
- }
- if (options.layout) {
- options.layout = options.layout.replace(/</g, '<').replace(/>/g, '>');
- }
- this._resetExtraLabels(inst.options, options);
- var timezoneChanged = (inst.options.timezone != options.timezone);
- $.extend(inst.options, options);
- this._adjustSettings(target, inst,
- options.until != null || options.since != null || timezoneChanged);
- var now = new Date();
- if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
- this._addTarget(target[0]);
- }
- this._updateCountdown(target, inst);
- },
-
- _updateCountdown: function(target, inst) {
- var $target = $(target);
- inst = inst || $target.data(this.propertyName);
- if (!inst) {
- return;
- }
- $target.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
- if ($.isFunction(inst.options.onTick)) {
- var periods = inst._hold != 'lap' ? inst._periods :
- this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
- if (inst.options.tickInterval == 1 ||
- this.periodsToSeconds(periods) % inst.options.tickInterval == 0) {
- inst.options.onTick.apply(target, [periods]);
- }
- }
- var expired = inst._hold != 'pause' &&
- (inst._since ? inst._now.getTime() < inst._since.getTime() :
- inst._now.getTime() >= inst._until.getTime());
- if (expired && !inst._expiring) {
- inst._expiring = true;
- if (this._hasTarget(target) || inst.options.alwaysExpire) {
- this._removeTarget(target);
- if ($.isFunction(inst.options.onExpiry)) {
- inst.options.onExpiry.apply(target, []);
- }
- if (inst.options.expiryText) {
- var layout = inst.options.layout;
- inst.options.layout = inst.options.expiryText;
- this._updateCountdown(target, inst);
- inst.options.layout = layout;
- }
- if (inst.options.expiryUrl) {
- window.location = inst.options.expiryUrl;
- }
- }
- inst._expiring = false;
- }
- else if (inst._hold == 'pause') {
- this._removeTarget(target);
- }
- $target.data(this.propertyName, inst);
- },
-
- _resetExtraLabels: function(base, options) {
- var changingLabels = false;
- for (var n in options) {
- if (n != 'whichLabels' && n.match(/[Ll]abels/)) {
- changingLabels = true;
- break;
- }
- }
- if (changingLabels) {
- for (var n in base) {
- if (n.match(/[Ll]abels[02-9]|compactLabels1/)) {
- base[n] = null;
- }
- }
- }
- },
-
-
- _adjustSettings: function(target, inst, recalc) {
- var now;
- var serverOffset = 0;
- var serverEntry = null;
- for (var i = 0; i < this._serverSyncs.length; i++) {
- if (this._serverSyncs[i][0] == inst.options.serverSync) {
- serverEntry = this._serverSyncs[i][1];
- break;
- }
- }
- if (serverEntry != null) {
- serverOffset = (inst.options.serverSync ? serverEntry : 0);
- now = new Date();
- }
- else {
- var serverResult = ($.isFunction(inst.options.serverSync) ?
- inst.options.serverSync.apply(target, []) : null);
- now = new Date();
- serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
- this._serverSyncs.push([inst.options.serverSync, serverOffset]);
- }
- var timezone = inst.options.timezone;
- timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
- if (recalc || (!recalc && inst._until == null && inst._since == null)) {
- inst._since = inst.options.since;
- if (inst._since != null) {
- inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
- if (inst._since && serverOffset) {
- inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
- }
- }
- inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
- if (serverOffset) {
- inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
- }
- }
- inst._show = this._determineShow(inst);
- },
-
- _destroyPlugin: function(target) {
- target = $(target);
- if (!target.hasClass(this.markerClassName)) {
- return;
- }
- this._removeTarget(target[0]);
- target.removeClass(this.markerClassName).empty().removeData(this.propertyName);
- },
-
- _pausePlugin: function(target) {
- this._hold(target, 'pause');
- },
-
- _lapPlugin: function(target) {
- this._hold(target, 'lap');
- },
-
- _resumePlugin: function(target) {
- this._hold(target, null);
- },
-
- _hold: function(target, hold) {
- var inst = $.data(target, this.propertyName);
- if (inst) {
- if (inst._hold == 'pause' && !hold) {
- inst._periods = inst._savePeriods;
- var sign = (inst._since ? '-' : '+');
- inst[inst._since ? '_since' : '_until'] =
- this._determineTime(sign + inst._periods[0] + 'y' +
- sign + inst._periods[1] + 'o' + sign + inst._periods[2] + 'w' +
- sign + inst._periods[3] + 'd' + sign + inst._periods[4] + 'h' +
- sign + inst._periods[5] + 'm' + sign + inst._periods[6] + 's');
- this._addTarget(target);
- }
- inst._hold = hold;
- inst._savePeriods = (hold == 'pause' ? inst._periods : null);
- $.data(target, this.propertyName, inst);
- this._updateCountdown(target, inst);
- }
- },
-
- _getTimesPlugin: function(target) {
- var inst = $.data(target, this.propertyName);
- return (!inst ? null : (inst._hold == 'pause' ? inst._savePeriods : (!inst._hold ? inst._periods :
- this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()))));
- },
-
- _determineTime: function(setting, defaultTime) {
- var offsetNumeric = function(offset) {
- var time = new Date();
- time.setTime(time.getTime() + offset * 1000);
- return time;
- };
- var offsetString = function(offset) {
- offset = offset.toLowerCase();
- var time = new Date();
- var year = time.getFullYear();
- var month = time.getMonth();
- var day = time.getDate();
- var hour = time.getHours();
- var minute = time.getMinutes();
- var second = time.getSeconds();
- var pattern = /([+-]?[0-9]+)\s*(s|m|h|d|w|o|y)?/g;
- var matches = pattern.exec(offset);
- while (matches) {
- switch (matches[2] || 's') {
- case 's': second += parseInt(matches[1], 10); break;
- case 'm': minute += parseInt(matches[1], 10); break;
- case 'h': hour += parseInt(matches[1], 10); break;
- case 'd': day += parseInt(matches[1], 10); break;
- case 'w': day += parseInt(matches[1], 10) * 7; break;
- case 'o':
- month += parseInt(matches[1], 10);
- day = Math.min(day, plugin._getDaysInMonth(year, month));
- break;
- case 'y':
- year += parseInt(matches[1], 10);
- day = Math.min(day, plugin._getDaysInMonth(year, month));
- break;
- }
- matches = pattern.exec(offset);
- }
- return new Date(year, month, day, hour, minute, second, 0);
- };
- var time = (setting == null ? defaultTime :
- (typeof setting == 'string' ? offsetString(setting) :
- (typeof setting == 'number' ? offsetNumeric(setting) : setting)));
- if (time) time.setMilliseconds(0);
- return time;
- },
-
- _getDaysInMonth: function(year, month) {
- return 32 - new Date(year, month, 32).getDate();
- },
-
- _normalLabels: function(num) {
- return num;
- },
-
- _generateHTML: function(inst) {
- var self = this;
-
- inst._periods = (inst._hold ? inst._periods :
- this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
-
- var shownNonZero = false;
- var showCount = 0;
- var sigCount = inst.options.significant;
- var show = $.extend({}, inst._show);
- for (var period = Y; period <= S; period++) {
- shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
- show[period] = (inst._show[period] == '?' && !shownNonZero ? null : inst._show[period]);
- showCount += (show[period] ? 1 : 0);
- sigCount -= (inst._periods[period] > 0 ? 1 : 0);
- }
- var showSignificant = [false, false, false, false, false, false, false];
- for (var period = S; period >= Y; period--) {
- if (inst._show[period]) {
- if (inst._periods[period]) {
- showSignificant[period] = true;
- }
- else {
- showSignificant[period] = sigCount > 0;
- sigCount--;
- }
- }
- }
- var labels = (inst.options.compact ? inst.options.compactLabels : inst.options.labels);
- var whichLabels = inst.options.whichLabels || this._normalLabels;
- var showCompact = function(period) {
- var labelsNum = inst.options['compactLabels' + whichLabels(inst._periods[period])];
- return (show[period] ? self._translateDigits(inst, inst._periods[period]) +
- (labelsNum ? labelsNum[period] : labels[period]) + ' ' : '');
- };
- var showFull = function(period) {
- var labelsNum = inst.options['labels' + whichLabels(inst._periods[period])];
- return ((!inst.options.significant && show[period]) ||
- (inst.options.significant && showSignificant[period]) ?
- '<span class="' + plugin._sectionClass + '">' +
- '<span class="' + plugin._amountClass + '">' +
- self._translateDigits(inst, inst._periods[period]) + '</span><br/>' +
- (labelsNum ? labelsNum[period] : labels[period]) + '</span>' : '');
- };
- return (inst.options.layout ? this._buildLayout(inst, show, inst.options.layout,
- inst.options.compact, inst.options.significant, showSignificant) :
- ((inst.options.compact ?
- '<span class="' + this._rowClass + ' ' + this._amountClass +
- (inst._hold ? ' ' + this._holdingClass : '') + '">' +
- showCompact(Y) + showCompact(O) + showCompact(W) + showCompact(D) +
- (show[H] ? this._minDigits(inst, inst._periods[H], 2) : '') +
- (show[M] ? (show[H] ? inst.options.timeSeparator : '') +
- this._minDigits(inst, inst._periods[M], 2) : '') +
- (show[S] ? (show[H] || show[M] ? inst.options.timeSeparator : '') +
- this._minDigits(inst, inst._periods[S], 2) : '') :
-
- '<span class="' + this._rowClass + ' ' + this._showClass + (inst.options.significant || showCount) +
- (inst._hold ? ' ' + this._holdingClass : '') + '">' +
- showFull(Y) + showFull(O) + showFull(W) + showFull(D) +
- showFull(H) + showFull(M) + showFull(S)) + '</span>' +
- (inst.options.description ? '<span class="' + this._rowClass + ' ' + this._descrClass + '">' +
- inst.options.description + '</span>' : '')));
- },
-
- _buildLayout: function(inst, show, layout, compact, significant, showSignificant) {
- var labels = inst.options[compact ? 'compactLabels' : 'labels'];
- var whichLabels = inst.options.whichLabels || this._normalLabels;
- var labelFor = function(index) {
- return (inst.options[(compact ? 'compactLabels' : 'labels') +
- whichLabels(inst._periods[index])] || labels)[index];
- };
- var digit = function(value, position) {
- return inst.options.digits[Math.floor(value / position) % 10];
- };
- var subs = {desc: inst.options.description, sep: inst.options.timeSeparator,
- yl: labelFor(Y), yn: this._minDigits(inst, inst._periods[Y], 1),
- ynn: this._minDigits(inst, inst._periods[Y], 2),
- ynnn: this._minDigits(inst, inst._periods[Y], 3), y1: digit(inst._periods[Y], 1),
- y10: digit(inst._periods[Y], 10), y100: digit(inst._periods[Y], 100),
- y1000: digit(inst._periods[Y], 1000),
- ol: labelFor(O), on: this._minDigits(inst, inst._periods[O], 1),
- onn: this._minDigits(inst, inst._periods[O], 2),
- onnn: this._minDigits(inst, inst._periods[O], 3), o1: digit(inst._periods[O], 1),
- o10: digit(inst._periods[O], 10), o100: digit(inst._periods[O], 100),
- o1000: digit(inst._periods[O], 1000),
- wl: labelFor(W), wn: this._minDigits(inst, inst._periods[W], 1),
- wnn: this._minDigits(inst, inst._periods[W], 2),
- wnnn: this._minDigits(inst, inst._periods[W], 3), w1: digit(inst._periods[W], 1),
- w10: digit(inst._periods[W], 10), w100: digit(inst._periods[W], 100),
- w1000: digit(inst._periods[W], 1000),
- dl: labelFor(D), dn: this._minDigits(inst, inst._periods[D], 1),
- dnn: this._minDigits(inst, inst._periods[D], 2),
- dnnn: this._minDigits(inst, inst._periods[D], 3), d1: digit(inst._periods[D], 1),
- d10: digit(inst._periods[D], 10), d100: digit(inst._periods[D], 100),
- d1000: digit(inst._periods[D], 1000),
- hl: labelFor(H), hn: this._minDigits(inst, inst._periods[H], 1),
- hnn: this._minDigits(inst, inst._periods[H], 2),
- hnnn: this._minDigits(inst, inst._periods[H], 3), h1: digit(inst._periods[H], 1),
- h10: digit(inst._periods[H], 10), h100: digit(inst._periods[H], 100),
- h1000: digit(inst._periods[H], 1000),
- ml: labelFor(M), mn: this._minDigits(inst, inst._periods[M], 1),
- mnn: this._minDigits(inst, inst._periods[M], 2),
- mnnn: this._minDigits(inst, inst._periods[M], 3), m1: digit(inst._periods[M], 1),
- m10: digit(inst._periods[M], 10), m100: digit(inst._periods[M], 100),
- m1000: digit(inst._periods[M], 1000),
- sl: labelFor(S), sn: this._minDigits(inst, inst._periods[S], 1),
- snn: this._minDigits(inst, inst._periods[S], 2),
- snnn: this._minDigits(inst, inst._periods[S], 3), s1: digit(inst._periods[S], 1),
- s10: digit(inst._periods[S], 10), s100: digit(inst._periods[S], 100),
- s1000: digit(inst._periods[S], 1000)};
- var html = layout;
-
- for (var i = Y; i <= S; i++) {
- var period = 'yowdhms'.charAt(i);
- var re = new RegExp('\\{' + period + '<\\}([\\s\\S]*)\\{' + period + '>\\}', 'g');
- html = html.replace(re, ((!significant && show[i]) ||
- (significant && showSignificant[i]) ? '$1' : ''));
- }
-
- $.each(subs, function(n, v) {
- var re = new RegExp('\\{' + n + '\\}', 'g');
- html = html.replace(re, v);
- });
- return html;
- },
-
- _minDigits: function(inst, value, len) {
- value = '' + value;
- if (value.length >= len) {
- return this._translateDigits(inst, value);
- }
- value = '0000000000' + value;
- return this._translateDigits(inst, value.substr(value.length - len));
- },
-
- _translateDigits: function(inst, value) {
- return ('' + value).replace(/[0-9]/g, function(digit) {
- return inst.options.digits[digit];
- });
- },
-
- _determineShow: function(inst) {
- var format = inst.options.format;
- var show = [];
- show[Y] = (format.match('y') ? '?' : (format.match('Y') ? '!' : null));
- show[O] = (format.match('o') ? '?' : (format.match('O') ? '!' : null));
- show[W] = (format.match('w') ? '?' : (format.match('W') ? '!' : null));
- show[D] = (format.match('d') ? '?' : (format.match('D') ? '!' : null));
- show[H] = (format.match('h') ? '?' : (format.match('H') ? '!' : null));
- show[M] = (format.match('m') ? '?' : (format.match('M') ? '!' : null));
- show[S] = (format.match('s') ? '?' : (format.match('S') ? '!' : null));
- return show;
- },
-
-
- _calculatePeriods: function(inst, show, significant, now) {
-
- inst._now = now;
- inst._now.setMilliseconds(0);
- var until = new Date(inst._now.getTime());
- if (inst._since) {
- if (now.getTime() < inst._since.getTime()) {
- inst._now = now = until;
- }
- else {
- now = inst._since;
- }
- }
- else {
- until.setTime(inst._until.getTime());
- if (now.getTime() > inst._until.getTime()) {
- inst._now = now = until;
- }
- }
-
- var periods = [0, 0, 0, 0, 0, 0, 0];
- if (show[Y] || show[O]) {
-
- var lastNow = plugin._getDaysInMonth(now.getFullYear(), now.getMonth());
- var lastUntil = plugin._getDaysInMonth(until.getFullYear(), until.getMonth());
- var sameDay = (until.getDate() == now.getDate() ||
- (until.getDate() >= Math.min(lastNow, lastUntil) &&
- now.getDate() >= Math.min(lastNow, lastUntil)));
- var getSecs = function(date) {
- return (date.getHours() * 60 + date.getMinutes()) * 60 + date.getSeconds();
- };
- var months = Math.max(0,
- (until.getFullYear() - now.getFullYear()) * 12 + until.getMonth() - now.getMonth() +
- ((until.getDate() < now.getDate() && !sameDay) ||
- (sameDay && getSecs(until) < getSecs(now)) ? -1 : 0));
- periods[Y] = (show[Y] ? Math.floor(months / 12) : 0);
- periods[O] = (show[O] ? months - periods[Y] * 12 : 0);
-
- now = new Date(now.getTime());
- var wasLastDay = (now.getDate() == lastNow);
- var lastDay = plugin._getDaysInMonth(now.getFullYear() + periods[Y],
- now.getMonth() + periods[O]);
- if (now.getDate() > lastDay) {
- now.setDate(lastDay);
- }
- now.setFullYear(now.getFullYear() + periods[Y]);
- now.setMonth(now.getMonth() + periods[O]);
- if (wasLastDay) {
- now.setDate(lastDay);
- }
- }
- var diff = Math.floor((until.getTime() - now.getTime()) / 1000);
- var extractPeriod = function(period, numSecs) {
- periods[period] = (show[period] ? Math.floor(diff / numSecs) : 0);
- diff -= periods[period] * numSecs;
- };
- extractPeriod(W, 604800);
- extractPeriod(D, 86400);
- extractPeriod(H, 3600);
- extractPeriod(M, 60);
- extractPeriod(S, 1);
- if (diff > 0 && !inst._since) {
- var multiplier = [1, 12, 4.3482, 7, 24, 60, 60];
- var lastShown = S;
- var max = 1;
- for (var period = S; period >= Y; period--) {
- if (show[period]) {
- if (periods[lastShown] >= max) {
- periods[lastShown] = 0;
- diff = 1;
- }
- if (diff > 0) {
- periods[period]++;
- diff = 0;
- lastShown = period;
- max = 1;
- }
- }
- max *= multiplier[period];
- }
- }
- if (significant) {
- for (var period = Y; period <= S; period++) {
- if (significant && periods[period]) {
- significant--;
- }
- else if (!significant) {
- periods[period] = 0;
- }
- }
- }
- return periods;
- }
- });
- var getters = ['getTimes'];
- function isNotChained(command, otherArgs) {
- if (command == 'option' && (otherArgs.length == 0 ||
- (otherArgs.length == 1 && typeof otherArgs[0] == 'string'))) {
- return true;
- }
- return $.inArray(command, getters) > -1;
- }
- $.fn.countdown = function(options) {
- var otherArgs = Array.prototype.slice.call(arguments, 1);
- if (isNotChained(options, otherArgs)) {
- return plugin['_' + options + 'Plugin'].
- apply(plugin, [this[0]].concat(otherArgs));
- }
- return this.each(function() {
- if (typeof options == 'string') {
- if (!plugin['_' + options + 'Plugin']) {
- throw 'Unknown command: ' + options;
- }
- plugin['_' + options + 'Plugin'].
- apply(plugin, [this].concat(otherArgs));
- }
- else {
- plugin._attachPlugin(this, options || {});
- }
- });
- };
- var plugin = $.countdown = new Countdown();
- })(jQuery);
- eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))
|