;(function($){ 'use strict'; $.fn.tawcvs_variation_swatches_form=function (){ return this.each(function(){ var $form=$(this), clicked=null, selected=[]; $form .addClass('swatches-support') .on('click', '.swatch', function(e){ e.preventDefault(); var $el=$(this), $select=$el.closest('.value').find('select'), attribute_name=$select.data('attribute_name')||$select.attr('name'), value=$el.data('value'); $select.trigger('focusin'); if(! $select.find('option[value="' + value + '"]').length){ $el.siblings('.swatch').removeClass('selected'); $select.val('').change(); $form.trigger('tawcvs_no_matching_variations', [$el]); return; } clicked=attribute_name; if(selected.indexOf(attribute_name)===-1){ selected.push(attribute_name); } if($el.hasClass('selected')){ $select.val(''); $el.removeClass('selected'); delete selected[selected.indexOf(attribute_name)]; }else{ $el.addClass('selected').siblings('.selected').removeClass('selected'); $select.val(value); } $select.change(); }) .on('click', '.reset_variations', function (){ $(this).closest('.variations_form').find('.swatch.selected').removeClass('selected'); selected=[]; }) .on('tawcvs_no_matching_variations', function(){ window.alert(wc_add_to_cart_variation_params.i18n_no_matching_variations_text); }); }); }; $(function (){ $('.variations_form').tawcvs_variation_swatches_form(); $(document.body).trigger('tawcvs_initialized'); }); })(jQuery); ;(function(){ "use strict"; function setup($){ $.fn._fadeIn=$.fn.fadeIn; var noOp=$.noop||function(){}; var msie=/MSIE/.test(navigator.userAgent); var ie6=/MSIE 6.0/.test(navigator.userAgent)&&! /MSIE 8.0/.test(navigator.userAgent); var mode=document.documentMode||0; var setExpr=$.isFunction(document.createElement('div').style.setExpression); $.ow_vote_blockUI=function(opts){ install(window, opts); }; $.ow_vote_unblockUI=function(opts){ remove(window, opts); }; $.growlUI=function(title, message, timeout, onClose){ var $m=$('
'); if(title) $m.append('

'+title+'

'); if(message) $m.append('

'+message+'

'); if(timeout===undefined) timeout=3000; var callBlock=function(opts){ opts=opts||{}; $.ow_vote_blockUI({ message: $m, fadeIn:typeof opts.fadeIn!=='undefined' ? opts.fadeIn:700, fadeOut: typeof opts.fadeOut!=='undefined' ? opts.fadeOut:1000, timeout: typeof opts.timeout!=='undefined' ? opts.timeout:timeout, centerY: false, showOverlay: false, onUnblock: onClose, css: $.ow_vote_blockUI.defaults.growlCSS }); }; callBlock(); var nonmousedOpacity=$m.css('opacity'); $m.mouseover(function(){ callBlock({ fadeIn: 0, timeout: 30000 }); var displayBlock=$('.blockMsg'); displayBlock.stop(); displayBlock.fadeTo(300, 1); }).mouseout(function(){ $('.blockMsg').fadeOut(1000); }); }; $.fn.ow_vote_block=function(opts){ if(this[0]===window){ $.ow_vote_blockUI(opts); return this; } var fullOpts=$.extend({}, $.ow_vote_blockUI.defaults, opts||{}); this.each(function(){ var $el=$(this); if(fullOpts.ignoreIfBlocked&&$el.data('ow_vote_blockUI.isBlocked')) return; $el.ow_vote_unblock({ fadeOut: 0 }); }); return this.each(function(){ if($.css(this,'position')=='static'){ this.style.position='relative'; $(this).data('ow_vote_blockUI.static', true); } this.style.zoom=1; install(this, opts); }); }; $.fn.ow_vote_unblock=function(opts){ if(this[0]===window){ $.ow_vote_unblockUI(opts); return this; } return this.each(function(){ remove(this, opts); }); }; $.ow_vote_blockUI.version=2.70; $.ow_vote_blockUI.defaults={ message: '

Please wait...

', title: null, draggable: true, theme: false, css: { padding: 0, margin: 0, width: '30%', top: '40%', left: '35%', textAlign: 'center', color: '#000', border: '3px solid #aaa', backgroundColor:'#fff', cursor: 'wait' }, themedCSS: { width: '30%', top: '40%', left: '35%' }, overlayCSS: { backgroundColor: '#000', opacity: 0.6, cursor: 'wait' }, cursorReset: 'default', growlCSS: { width: '350px', top: '10px', left: '', right: '10px', border: 'none', padding: '5px', opacity: 0.6, cursor: 'default', color: '#fff', backgroundColor: '#000', '-webkit-border-radius':'10px', '-moz-border-radius': '10px', 'border-radius': '10px' }, iframeSrc: /^https/i.test(window.location.href||'') ? 'javascript:false':'about:blank', forceIframe: false, baseZ: 1000, centerX: true, centerY: true, allowBodyStretch: true, bindEvents: true, constrainTabKey: true, fadeIn: 200, fadeOut: 400, timeout: 0, showOverlay: true, focusInput: true, focusableElements: ':input:enabled:visible', onBlock: null, onUnblock: null, onOverlayClick: null, quirksmodeOffsetHack: 4, blockMsgClass: 'blockMsg', ignoreIfBlocked: false }; var pageBlock=null; var pageBlockEls=[]; function install(el, opts){ var css, themedCSS; var full=(el==window); var msg=(opts&&opts.message!==undefined ? opts.message:undefined); opts=$.extend({}, $.ow_vote_blockUI.defaults, opts||{}); if(opts.ignoreIfBlocked&&$(el).data('ow_vote_blockUI.isBlocked')) return; opts.overlayCSS=$.extend({}, $.ow_vote_blockUI.defaults.overlayCSS, opts.overlayCSS||{}); css=$.extend({}, $.ow_vote_blockUI.defaults.css, opts.css||{}); if(opts.onOverlayClick) opts.overlayCSS.cursor='pointer'; themedCSS=$.extend({}, $.ow_vote_blockUI.defaults.themedCSS, opts.themedCSS||{}); msg=msg===undefined ? opts.message:msg; if(full&&pageBlock) remove(window, {fadeOut:0}); if(msg&&typeof msg!='string'&&(msg.parentNode||msg.jquery)){ var node=msg.jquery ? msg[0]:msg; var data={}; $(el).data('ow_vote_blockUI.history', data); data.el=node; data.parent=node.parentNode; data.display=node.style.display; data.position=node.style.position; if(data.parent) data.parent.removeChild(node); } $(el).data('ow_vote_blockUI.onUnblock', opts.onUnblock); var z=opts.baseZ; var lyr1, lyr2, lyr3, s; if(msie||opts.forceIframe) lyr1=$(''); else lyr1=$(''); if(opts.theme) lyr2=$(''); else lyr2=$(''); if(opts.theme&&full){ s=''; } else if(opts.theme){ s=''; } else if(full){ s=''; }else{ s=''; } lyr3=$(s); if(msg){ if(opts.theme){ lyr3.css(themedCSS); lyr3.addClass('ui-widget-content'); } else lyr3.css(css); } if(!opts.theme ) lyr2.css(opts.overlayCSS); lyr2.css('position', full ? 'fixed':'absolute'); if(msie||opts.forceIframe) lyr1.css('opacity',0.0); var layers=[lyr1,lyr2,lyr3], $par=full ? $('body'):$(el); $.each(layers, function(){ this.appendTo($par); }); if(opts.theme&&opts.draggable&&$.fn.draggable){ lyr3.draggable({ handle: '.ui-dialog-titlebar', cancel: 'li' }); } var expr=setExpr&&(!$.support.boxModel||$('object,embed', full ? null:el).length > 0); if(ie6||expr){ if(full&&opts.allowBodyStretch&&$.support.boxModel) $('html,body').css('height','100%'); if((ie6||!$.support.boxModel)&&!full){ var t=sz(el,'borderTopWidth'), l=sz(el,'borderLeftWidth'); var fixT=t ? '(0 - '+t+')':0; var fixL=l ? '(0 - '+l+')':0; } $.each(layers, function(i,o){ var s=o[0].style; s.position='absolute'; if(i < 2){ if(full) s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.support.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"'); else s.setExpression('height','this.parentNode.offsetHeight + "px"'); if(full) s.setExpression('width','jQuery.support.boxModel&&document.documentElement.clientWidth||document.body.clientWidth + "px"'); else s.setExpression('width','this.parentNode.offsetWidth + "px"'); if(fixL) s.setExpression('left', fixL); if(fixT) s.setExpression('top', fixT); } else if(opts.centerY){ if(full) s.setExpression('top','(document.documentElement.clientHeight||document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah=document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + "px"'); s.marginTop=0; } else if(!opts.centerY&&full){ var top=(opts.css&&opts.css.top) ? parseInt(opts.css.top, 10):0; var expression='((document.documentElement.scrollTop ? document.documentElement.scrollTop:document.body.scrollTop) + '+top+') + "px"'; s.setExpression('top',expression); }}); } if(msg){ if(opts.theme) lyr3.find('.ui-widget-content').append(msg); else lyr3.append(msg); if(msg.jquery||msg.nodeType) $(msg).show(); } if((msie||opts.forceIframe)&&opts.showOverlay) lyr1.show(); if(opts.fadeIn){ var cb=opts.onBlock ? opts.onBlock:noOp; var cb1=(opts.showOverlay&&!msg) ? cb:noOp; var cb2=msg ? cb:noOp; if(opts.showOverlay) lyr2._fadeIn(opts.fadeIn, cb1); if(msg) lyr3._fadeIn(opts.fadeIn, cb2); }else{ if(opts.showOverlay) lyr2.show(); if(msg) lyr3.show(); if(opts.onBlock) opts.onBlock.bind(lyr3)(); } bind(1, el, opts); if(full){ pageBlock=lyr3[0]; pageBlockEls=$(opts.focusableElements,pageBlock); if(opts.focusInput) setTimeout(focus, 20); } else center(lyr3[0], opts.centerX, opts.centerY); if(opts.timeout){ var to=setTimeout(function(){ if(full) $.ow_vote_unblockUI(opts); else $(el).ow_vote_unblock(opts); }, opts.timeout); $(el).data('ow_vote_blockUI.timeout', to); }} function remove(el, opts){ var count; var full=(el==window); var $el=$(el); var data=$el.data('ow_vote_blockUI.history'); var to=$el.data('ow_vote_blockUI.timeout'); if(to){ clearTimeout(to); $el.removeData('ow_vote_blockUI.timeout'); } opts=$.extend({}, $.ow_vote_blockUI.defaults, opts||{}); bind(0, el, opts); if(opts.onUnblock===null){ opts.onUnblock=$el.data('ow_vote_blockUI.onUnblock'); $el.removeData('ow_vote_blockUI.onUnblock'); } var els; if(full) els=$('body').children().filter('.ow_vote_blockUI').add('body > .ow_vote_blockUI'); else els=$el.find('>.ow_vote_blockUI'); if(opts.cursorReset){ if(els.length > 1) els[1].style.cursor=opts.cursorReset; if(els.length > 2) els[2].style.cursor=opts.cursorReset; } if(full) pageBlock=pageBlockEls=null; if(opts.fadeOut){ count=els.length; els.stop().fadeOut(opts.fadeOut, function(){ if(--count===0) reset(els,data,opts,el); }); } else reset(els, data, opts, el); } function reset(els,data,opts,el){ var $el=$(el); if($el.data('ow_vote_blockUI.isBlocked')) return; els.each(function(i,o){ if(this.parentNode) this.parentNode.removeChild(this); }); if(data&&data.el){ data.el.style.display=data.display; data.el.style.position=data.position; data.el.style.cursor='default'; if(data.parent) data.parent.appendChild(data.el); $el.removeData('ow_vote_blockUI.history'); } if($el.data('ow_vote_blockUI.static')){ $el.css('position', 'static'); } if(typeof opts.onUnblock=='function') opts.onUnblock(el,opts); var body=$(document.body), w=body.width(), cssW=body[0].style.width; body.width(w-1).width(w); body[0].style.width=cssW; } function bind(b, el, opts){ var full=el==window, $el=$(el); if(!b&&(full&&!pageBlock||!full&&!$el.data('ow_vote_blockUI.isBlocked'))) return; $el.data('ow_vote_blockUI.isBlocked', b); if(!full||!opts.bindEvents||(b&&!opts.showOverlay)) return; var events='mousedown mouseup keydown keypress keyup touchstart touchend touchmove'; if(b) $(document).bind(events, opts, handler); else $(document).unbind(events, handler); } function handler(e){ if(e.type==='keydown'&&e.keyCode&&e.keyCode==9){ if(pageBlock&&e.data.constrainTabKey){ var els=pageBlockEls; var fwd = !e.shiftKey&&e.target===els[els.length-1]; var back=e.shiftKey&&e.target===els[0]; if(fwd||back){ setTimeout(function(){focus(back);},10); return false; }} } var opts=e.data; var target=$(e.target); if(target.hasClass('blockOverlay')&&opts.onOverlayClick) opts.onOverlayClick(e); if(target.parents('div.' + opts.blockMsgClass).length > 0) return true; return target.parents().children().filter('div.ow_vote_blockUI').length===0; } function focus(back){ if(!pageBlockEls) return; var e=pageBlockEls[back===true ? pageBlockEls.length-1:0]; if(e) e.focus(); } function center(el, x, y){ var p=el.parentNode, s=el.style; var l=((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth'); var t=((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth'); if(x) s.left=l > 0 ? (l+'px'):'0'; if(y) s.top=t > 0 ? (t+'px'):'0'; } function sz(el, p){ return parseInt($.css(el,p),10)||0; }} if(typeof define==='function'&&define.amd&&define.amd.jQuery){ define(['jquery'], setup); }else{ setup(jQuery); }})(); (function($){ $.ow_vote_prettyPhoto={version: '3.1.5'}; $.fn.ow_vote_prettyPhoto=function(pp_settings){ pp_settings=jQuery.extend({ hook: 'rel', animation_speed: 'fast', ajaxcallback: function(){}, slideshow: 5000, autoplay_slideshow: false, opacity: 0.80, show_title: true, allow_resize: true, allow_expand: true, default_width: 500, default_height: 344, counter_separator_label: '/', theme: 'pp_default', horizontal_padding: 20, hideflash: false, wmode: 'opaque', autoplay: true, modal: false, deeplinking: true, overlay_gallery: true, overlay_gallery_max: 30, keyboard_shortcuts: true, changepicturecallback: function(){}, callback: function(){}, ie6_fallback: true, markup: '
\
 
\
\
\
\
\
\
\
\
\
\
\
\ Expand \
\ next \ previous \
\
\
\
\ Previous \

0/0

\ Next \
\

\
{pp_social}
\ Close \
\
\
\
\
\
\
\
\
\
\
\
\
', gallery_markup: '', image_markup: '', flash_markup: '', quicktime_markup: '', iframe_markup: '', inline_markup: '
{content}
', custom_markup: '', social_tools: '
Tweet
' }, pp_settings); var matchedObjects=this, percentBased=false, pp_dimensions, pp_open, pp_contentHeight, pp_contentWidth, pp_containerHeight, pp_containerWidth, windowHeight=$(window).height(), windowWidth=$(window).width(), pp_slideshow; doresize=true, scroll_pos=_get_scroll(); $(window).unbind('resize.prettyphoto').bind('resize.prettyphoto',function(){ _center_overlay(); _resize_overlay(); }); if(pp_settings.keyboard_shortcuts){ $(document).unbind('keydown.prettyphoto').bind('keydown.prettyphoto',function(e){ if(typeof $pp_pic_holder!='undefined'){ if($pp_pic_holder.is(':visible')){ switch(e.keyCode){ case 37: $.ow_vote_prettyPhoto.changePage('previous'); e.preventDefault(); break; case 39: $.ow_vote_prettyPhoto.changePage('next'); e.preventDefault(); break; case 27: if(!settings.modal) $.ow_vote_prettyPhoto.close(); e.preventDefault(); break; };}; };}); }; $.ow_vote_prettyPhoto.initialize=function(){ settings=pp_settings; if(settings.theme=='pp_default') settings.horizontal_padding=16; theRel=$(this).attr(settings.hook); galleryRegExp=/\[(?:.*)\]/; isSet=(galleryRegExp.exec(theRel)) ? true:false; pp_images=(isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel)!=-1) return $(n).attr('href'); }):$.makeArray($(this).attr('href')); pp_titles=(isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel)!=-1) return ($(n).find('img').attr('data-pretty-alt')) ? $(n).find('img').attr('data-pretty-alt'):""; }):$.makeArray($(this).find('img').attr('data-pretty-alt')); pp_descriptions=(isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel)!=-1) return ($(n).attr('data-pretty-title')) ? $(n).attr('data-pretty-title'):""; }):$.makeArray($(this).attr('data-pretty-title')); vote_contestant_id=(isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel)!=-1) return ($(n).attr('data-vote-id')) ? $(n).attr('data-vote-id'):""; }):$.makeArray($(this).attr('data-vote-id')); vote_term_id=(isSet) ? jQuery.map(matchedObjects, function(n, i){ if($(n).attr(settings.hook).indexOf(theRel)!=-1) return ($(n).attr('data-term-id')) ? $(n).attr('data-term-id'):""; }):$.makeArray($(this).attr('data-term-id')); if(pp_images.length > settings.overlay_gallery_max) settings.overlay_gallery=false; set_position=jQuery.inArray($(this).attr('href'), pp_images); rel_index=(isSet) ? set_position:$("a["+settings.hook+"^='"+theRel+"']").index($(this)); _build_overlay(this); if(settings.allow_resize) $(window).bind('scroll.prettyphoto',function(){ _center_overlay(); }); $.ow_vote_prettyPhoto.open(); return false; } $.ow_vote_prettyPhoto.open=function(event){ if(typeof settings=="undefined"){ settings=pp_settings; pp_images=$.makeArray(arguments[0]); pp_titles=(arguments[1]) ? $.makeArray(arguments[1]):$.makeArray(""); pp_descriptions=(arguments[2]) ? $.makeArray(arguments[2]):$.makeArray(""); isSet=(pp_images.length > 1) ? true:false; set_position=(arguments[3])? arguments[3]: 0; _build_overlay(event.target); } if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','hidden'); _checkPosition($(pp_images).size()); $('.pp_loaderIcon').show(); if(settings.deeplinking) setHashtag(); if(settings.social_tools){ facebook_like_link=settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); $pp_pic_holder.find('.pp_social').html(facebook_like_link); } if($ppt.is(':hidden')) $ppt.css('opacity',0).show(); $pp_overlay.show().fadeTo(settings.animation_speed,settings.opacity); $pp_pic_holder.find('.currentTextHolder').text((set_position+1) + settings.counter_separator_label + $(pp_images).size()); if(typeof pp_descriptions[set_position]!='undefined'&&pp_descriptions[set_position]!=""){ $pp_pic_holder.find('.pp_description').show().html(unescape(pp_descriptions[set_position])); }else{ $pp_pic_holder.find('.pp_description').hide(); } movie_width=(parseFloat(getParam('width',pp_images[set_position]))) ? getParam('width',pp_images[set_position]):settings.default_width.toString(); movie_height=(parseFloat(getParam('height',pp_images[set_position]))) ? getParam('height',pp_images[set_position]):settings.default_height.toString(); percentBased=false; if(movie_height.indexOf('%')!=-1){ movie_height=parseFloat(($(window).height() * parseFloat(movie_height) / 100) - 150); percentBased=true; } if(movie_width.indexOf('%')!=-1){ movie_width=parseFloat(($(window).width() * parseFloat(movie_width) / 100) - 150); percentBased=true; } $pp_pic_holder.fadeIn(function(){ (settings.show_title&&pp_titles[set_position]!=""&&typeof pp_titles[set_position]!="undefined") ? $ppt.html(unescape(pp_titles[set_position])):$ppt.html(' '); imgPreloader=""; skipInjection=false; switch(_getFileType(pp_images[set_position])){ case 'image': imgPreloader=new Image(); nextImage=new Image(); if(isSet&&set_position < $(pp_images).size() -1) nextImage.src=pp_images[set_position + 1]; prevImage=new Image(); if(isSet&&pp_images[set_position - 1]) prevImage.src=pp_images[set_position - 1]; $pp_pic_holder.find('#pp_full_res')[0].innerHTML=settings.image_markup.replace(/{path}/g,pp_images[set_position]); imgPreloader.onload=function(){ pp_dimensions=_fitToViewport(imgPreloader.width,imgPreloader.height); _showContent(set_position); }; imgPreloader.onerror=function(){ alert('Image cannot be loaded. Make sure the path is correct and image exist.'); $.ow_vote_prettyPhoto.close(); }; imgPreloader.src=pp_images[set_position]; break; case 'youtube': pp_dimensions=_fitToViewport(movie_width,movie_height); movie_id=getParam('v',pp_images[set_position]); if(movie_id==""){ movie_id=pp_images[set_position].split('youtu.be/'); movie_id=movie_id[1]; if(movie_id.indexOf('?') > 0) movie_id=movie_id.substr(0,movie_id.indexOf('?')); if(movie_id.indexOf('&') > 0) movie_id=movie_id.substr(0,movie_id.indexOf('&')); } movie='http://www.youtube.com/embed/'+movie_id; (getParam('rel',pp_images[set_position])) ? movie+="?rel="+getParam('rel',pp_images[set_position]):movie+="?rel=1"; if(settings.autoplay) movie +="&autoplay=1"; toInject=settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie); break; case 'vimeo': pp_dimensions=_fitToViewport(movie_width,movie_height); movie_id=pp_images[set_position]; var regExp=/http(s?):\/\/(www\.)?vimeo.com\/(\d+)/; var match=movie_id.match(regExp); movie='http://player.vimeo.com/video/'+ match[3] +'?title=0&byline=0&portrait=0'; if(settings.autoplay) movie +="&autoplay=1;"; vimeo_width=pp_dimensions['width'] + '/embed/?moog_width='+ pp_dimensions['width']; toInject=settings.iframe_markup.replace(/{width}/g,vimeo_width).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,movie); break; case 'quicktime': pp_dimensions=_fitToViewport(movie_width,movie_height); pp_dimensions['height']+=15; pp_dimensions['contentHeight']+=15; pp_dimensions['containerHeight']+=15; toInject=settings.quicktime_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,pp_images[set_position]).replace(/{autoplay}/g,settings.autoplay); break; case 'flash': pp_dimensions=_fitToViewport(movie_width,movie_height); flash_vars=pp_images[set_position]; flash_vars=flash_vars.substring(pp_images[set_position].indexOf('flashvars') + 10,pp_images[set_position].length); filename=pp_images[set_position]; filename=filename.substring(0,filename.indexOf('?')); toInject=settings.flash_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars); break; case 'iframe': pp_dimensions=_fitToViewport(movie_width,movie_height); frame_url=pp_images[set_position]; frame_url=frame_url.substr(0,frame_url.indexOf('iframe')-1); toInject=settings.iframe_markup.replace(/{width}/g,pp_dimensions['width']).replace(/{height}/g,pp_dimensions['height']).replace(/{path}/g,frame_url); break; case 'ajax': doresize=false; pp_dimensions=_fitToViewport(movie_width,movie_height); doresize=true; skipInjection=true; $.get(pp_images[set_position],function(responseHTML){ toInject=settings.inline_markup.replace(/{content}/g,responseHTML); $pp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject; _showContent(set_position); }); break; case 'custom': pp_dimensions=_fitToViewport(movie_width,movie_height); toInject=settings.custom_markup; break; case 'inline': myClone=$(pp_images[set_position]).clone().append('
').css({'width':settings.default_width}).wrapInner('
').appendTo($('body')).show(); doresize=false; pp_dimensions=_fitToViewport($(myClone).width(),$(myClone).height()); doresize=true; $(myClone).remove(); toInject=settings.inline_markup.replace(/{content}/g,$(pp_images[set_position]).html()); break; }; if(!imgPreloader&&!skipInjection){ $pp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject; _showContent(set_position); };}); return false; }; $.ow_vote_prettyPhoto.changePage=function(direction){ currentGalleryPage=0; if(direction=='previous'){ set_position--; if(set_position < 0) set_position=$(pp_images).size()-1; }else if(direction=='next'){ set_position++; if(set_position > $(pp_images).size()-1) set_position=0; }else{ set_position=direction; }; rel_index=set_position; if(!doresize) doresize=true; if(settings.allow_expand){ $('.pp_contract').removeClass('pp_contract').addClass('pp_expand'); } _hideContent(function(){ $.ow_vote_prettyPhoto.open(); }); }; $.ow_vote_prettyPhoto.changeGalleryPage=function(direction){ if(direction=='next'){ currentGalleryPage ++; if(currentGalleryPage > totalPage) currentGalleryPage=0; }else if(direction=='previous'){ currentGalleryPage --; if(currentGalleryPage < 0) currentGalleryPage=totalPage; }else{ currentGalleryPage=direction; }; slide_speed=(direction=='next'||direction=='previous') ? settings.animation_speed:0; slide_to=currentGalleryPage * (itemsPerPage * itemWidth); $pp_gallery.find('ul').animate({left:-slide_to},slide_speed); }; $.ow_vote_prettyPhoto.startSlideshow=function(){ if(typeof pp_slideshow=='undefined'){ $pp_pic_holder.find('.pp_play').unbind('click').removeClass('pp_play').addClass('pp_pause').click(function(){ $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); pp_slideshow=setInterval($.ow_vote_prettyPhoto.startSlideshow,settings.slideshow); }else{ $.ow_vote_prettyPhoto.changePage('next'); };} $.ow_vote_prettyPhoto.stopSlideshow=function(){ $pp_pic_holder.find('.pp_pause').unbind('click').removeClass('pp_pause').addClass('pp_play').click(function(){ $.ow_vote_prettyPhoto.startSlideshow(); return false; }); clearInterval(pp_slideshow); pp_slideshow=undefined; } $.ow_vote_prettyPhoto.close=function(){ if($pp_overlay.is(":animated")) return; $.ow_vote_prettyPhoto.stopSlideshow(); $pp_pic_holder.stop().find('object,embed').css('visibility','hidden'); $('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animation_speed,function(){ $(this).remove(); }); $pp_overlay.fadeOut(settings.animation_speed, function(){ if(settings.hideflash) $('object,embed,iframe[src*=youtube],iframe[src*=vimeo]').css('visibility','visible'); $(this).remove(); $(window).unbind('scroll.prettyphoto'); clearHashtag(); settings.callback(); doresize=true; pp_open=false; delete settings; }); }; function _showContent(set_position){ $('.pp_loaderIcon').hide(); projectedTop=scroll_pos['scrollTop'] + ((windowHeight/2) - (pp_dimensions['containerHeight']/2)); if(projectedTop < 0) projectedTop=0; $ppt.fadeTo(settings.animation_speed,1); $pp_pic_holder.find('.pp_content') .animate({ height:pp_dimensions['contentHeight'], width:pp_dimensions['contentWidth'] },settings.animation_speed); $pp_pic_holder.animate({ 'top': projectedTop, 'left': ((windowWidth/2) - (pp_dimensions['containerWidth']/2) < 0) ? 0:(windowWidth/2) - (pp_dimensions['containerWidth']/2), width:pp_dimensions['containerWidth'] },settings.animation_speed,function(){ $pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(pp_dimensions['height']).width(pp_dimensions['width']); $pp_pic_holder.find('.pp_fade').fadeIn(settings.animation_speed); if(isSet&&_getFileType(pp_images[set_position])=="image"){ $pp_pic_holder.find('.pp_hoverContainer').show(); }else{ $pp_pic_holder.find('.pp_hoverContainer').hide(); } if(settings.allow_expand){ if(pp_dimensions['resized']){ $('a.pp_expand,a.pp_contract').show(); }else{ $('a.pp_expand').hide(); }} if(settings.autoplay_slideshow&&!pp_slideshow&&!pp_open) $.ow_vote_prettyPhoto.startSlideshow(); if(typeof vote_contestant_id!=='undefined'){ settings.changepicturecallback(vote_contestant_id[set_position],vote_term_id[set_position]); } pp_open=true; }); _insert_gallery(); pp_settings.ajaxcallback(); }; function _hideContent(callback){ $pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden'); $pp_pic_holder.find('.pp_fade').fadeOut(settings.animation_speed,function(){ $('.pp_loaderIcon').show(); callback(); }); }; function _checkPosition(setCount){ (setCount > 1) ? $('.pp_nav').show():$('.pp_nav').hide(); }; function _fitToViewport(width,height){ resized=false; _getDimensions(width,height); imageWidth=width, imageHeight=height; if(((pp_containerWidth > windowWidth)||(pp_containerHeight > windowHeight))&&doresize&&settings.allow_resize&&!percentBased){ resized=true, fitting=false; while (!fitting){ if((pp_containerWidth > windowWidth)){ imageWidth=(windowWidth - 200); imageHeight=(height/width) * imageWidth; }else if((pp_containerHeight > windowHeight)){ imageHeight=(windowHeight - 200); imageWidth=(width/height) * imageHeight; }else{ fitting=true; }; pp_containerHeight=imageHeight, pp_containerWidth=imageWidth; }; if((pp_containerWidth > windowWidth)||(pp_containerHeight > windowHeight)){ _fitToViewport(pp_containerWidth,pp_containerHeight) }; _getDimensions(imageWidth,imageHeight); }; return { width:Math.floor(imageWidth), height:Math.floor(imageHeight), containerHeight:Math.floor(pp_containerHeight), containerWidth:Math.floor(pp_containerWidth) + (settings.horizontal_padding * 2), contentHeight:Math.floor(pp_contentHeight), contentWidth:Math.floor(pp_contentWidth), resized:resized };}; function _getDimensions(width,height){ width=parseFloat(width); height=parseFloat(height); $pp_details=$pp_pic_holder.find('.pp_details'); $pp_details.width(width); detailsHeight=parseFloat($pp_details.css('marginTop')) + parseFloat($pp_details.css('marginBottom')); $pp_details=$pp_details.clone().addClass(settings.theme).width(width).appendTo($('body')).css({ 'position':'absolute', 'top':-10000 }); detailsHeight +=$pp_details.height(); detailsHeight=(detailsHeight <=34) ? 36:detailsHeight; $pp_details.remove(); $pp_title=$pp_pic_holder.find('.ppt'); $pp_title.width(width); titleHeight=parseFloat($pp_title.css('marginTop')) + parseFloat($pp_title.css('marginBottom')); $pp_title=$pp_title.clone().appendTo($('body')).css({ 'position':'absolute', 'top':-10000 }); titleHeight +=$pp_title.height(); $pp_title.remove(); pp_contentHeight=height + detailsHeight; pp_contentWidth=width; pp_containerHeight=pp_contentHeight + titleHeight + $pp_pic_holder.find('.pp_top').height() + $pp_pic_holder.find('.pp_bottom').height(); pp_containerWidth=width; } function _getFileType(itemSrc){ if(itemSrc.match(/youtube\.com\/watch/i)||itemSrc.match(/youtu\.be/i)){ return 'youtube'; }else if(itemSrc.match(/vimeo\.com/i)){ return 'vimeo'; }else if(itemSrc.match(/\b.mov\b/i)){ return 'quicktime'; }else if(itemSrc.match(/\b.swf\b/i)){ return 'flash'; }else if(itemSrc.match(/\biframe=true\b/i)){ return 'iframe'; }else if(itemSrc.match(/\bajax=true\b/i)){ return 'ajax'; }else if(itemSrc.match(/\bcustom=true\b/i)){ return 'custom'; }else if(itemSrc.substr(0,1)=='#'){ return 'inline'; }else{ return 'image'; };}; function _center_overlay(){ if(doresize&&typeof $pp_pic_holder!='undefined'){ scroll_pos=_get_scroll(); contentHeight=$pp_pic_holder.height(), contentwidth=$pp_pic_holder.width(); projectedTop=(windowHeight/2) + scroll_pos['scrollTop'] - (contentHeight/2); if(projectedTop < 0) projectedTop=0; if(contentHeight > windowHeight) return; $pp_pic_holder.css({ 'top': projectedTop, 'left': (windowWidth/2) + scroll_pos['scrollLeft'] - (contentwidth/2) }); };}; function _get_scroll(){ if(self.pageYOffset){ return {scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset};}else if(document.documentElement&&document.documentElement.scrollTop){ return {scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};}else if(document.body){ return {scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft};}; }; function _resize_overlay(){ windowHeight=$(window).height(), windowWidth=$(window).width(); if(typeof $pp_overlay!="undefined") $pp_overlay.height($(document).height()).width(windowWidth); }; function _insert_gallery(){ if(isSet&&settings.overlay_gallery&&_getFileType(pp_images[set_position])=="image"){ itemWidth=52+5; navWidth=(settings.theme=="facebook"||settings.theme=="pp_default") ? 50:30; itemsPerPage=Math.floor((pp_dimensions['containerWidth'] - 100 - navWidth) / itemWidth); itemsPerPage=(itemsPerPage < pp_images.length) ? itemsPerPage:pp_images.length; totalPage=Math.ceil(pp_images.length / itemsPerPage) - 1; if(totalPage==0){ navWidth=0; $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').hide(); }else{ $pp_gallery.find('.pp_arrow_next,.pp_arrow_previous').show(); }; galleryWidth=itemsPerPage * itemWidth; fullGalleryWidth=pp_images.length * itemWidth; $pp_gallery .css('margin-left',-((galleryWidth/2) + (navWidth/2))) .find('div:first').width(galleryWidth+5) .find('ul').width(fullGalleryWidth) .find('li.selected').removeClass('selected'); goToPage=(Math.floor(set_position/itemsPerPage) < totalPage) ? Math.floor(set_position/itemsPerPage):totalPage; $.ow_vote_prettyPhoto.changeGalleryPage(goToPage); $pp_gallery_li.filter(':eq('+set_position+')').addClass('selected'); }else{ $pp_pic_holder.find('.pp_content').unbind('mouseenter mouseleave'); }} function _build_overlay(caller){ if(settings.social_tools) facebook_like_link=settings.social_tools.replace('{location_href}', encodeURIComponent(location.href)); settings.markup=settings.markup.replace('{pp_social}',''); $('body').append(settings.markup); $pp_pic_holder=$('.pp_pic_holder') , $ppt=$('.ppt'), $pp_overlay=$('div.pp_overlay'); if(isSet&&settings.overlay_gallery){ currentGalleryPage=0; toInject=""; for (var i=0; i < pp_images.length; i++){ if(!pp_images[i].match(/\b(jpg|jpeg|png|gif)\b/gi)){ classname='default'; img_src=''; }else{ classname=''; img_src=pp_images[i]; } toInject +="
  • "; }; toInject=settings.gallery_markup.replace(/{gallery}/g,toInject); $pp_pic_holder.find('#pp_full_res').after(toInject); $pp_gallery=$('.pp_pic_holder .pp_gallery'), $pp_gallery_li=$pp_gallery.find('li'); $pp_gallery.find('.pp_arrow_next').click(function(){ $.ow_vote_prettyPhoto.changeGalleryPage('next'); $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); $pp_gallery.find('.pp_arrow_previous').click(function(){ $.ow_vote_prettyPhoto.changeGalleryPage('previous'); $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); $pp_pic_holder.find('.pp_content').hover(function(){ $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeIn(); }, function(){ $pp_pic_holder.find('.pp_gallery:not(.disabled)').fadeOut(); }); itemWidth=52+5; $pp_gallery_li.each(function(i){ $(this) .find('a') .click(function(){ $.ow_vote_prettyPhoto.changePage(i); $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); }); }; if(settings.slideshow){ $pp_pic_holder.find('.pp_nav').prepend('Play') $pp_pic_holder.find('.pp_nav .pp_play').click(function(){ $.ow_vote_prettyPhoto.startSlideshow(); return false; }); } $pp_pic_holder.attr('class','pp_pic_holder ' + settings.theme); $pp_overlay .css({ 'opacity':0, 'height':$(document).height(), 'width':$(window).width() }) .bind('click',function(){ if(!settings.modal) $.ow_vote_prettyPhoto.close(); }); $('a.pp_close').bind('click',function(){ $.ow_vote_prettyPhoto.close(); return false; }); if(settings.allow_expand){ $('a.pp_expand').bind('click',function(e){ if($(this).hasClass('pp_expand')){ $(this).removeClass('pp_expand').addClass('pp_contract'); doresize=false; }else{ $(this).removeClass('pp_contract').addClass('pp_expand'); doresize=true; }; _hideContent(function(){ $.ow_vote_prettyPhoto.open(); }); return false; }); } $pp_pic_holder.find('.pp_previous, .pp_nav .pp_arrow_previous').bind('click',function(){ $.ow_vote_prettyPhoto.changePage('previous'); $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); $pp_pic_holder.find('.pp_next, .pp_nav .pp_arrow_next').bind('click',function(){ $.ow_vote_prettyPhoto.changePage('next'); $.ow_vote_prettyPhoto.stopSlideshow(); return false; }); _center_overlay(); }; if(!pp_alreadyInitialized&&getHashtag()){ pp_alreadyInitialized=true; hashIndex=getHashtag(); hashRel=hashIndex; hashIndex=hashIndex.substring(hashIndex.indexOf('/')+1,hashIndex.length-1); hashRel=hashRel.substring(0,hashRel.indexOf('/')); setTimeout(function(){ $("a["+pp_settings.hook+"^='"+hashRel+"']:eq("+hashIndex+")").trigger('click'); },50); } return this.unbind('click.prettyphoto').bind('click.prettyphoto',$.ow_vote_prettyPhoto.initialize); }; function getHashtag(){ var url=location.href; hashtag=(url.indexOf('#ow_vote_prettyPhoto')!==-1) ? decodeURI(url.substring(url.indexOf('#ow_vote_prettyPhoto')+1,url.length)):false; return hashtag; }; function setHashtag(){ if(typeof theRel=='undefined') return; location.hash=theRel + '/'+rel_index+'/'; }; function clearHashtag(){ if(location.href.indexOf('#ow_vote_prettyPhoto')!==-1) location.hash="ow_vote_prettyPhoto"; } function getParam(name,url){ name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS="[\\?&]"+name+"=([^&#]*)"; var regex=new RegExp(regexS); var results=regex.exec(url); return(results==null) ? "":results[1]; }})(jQuery); var pp_alreadyInitialized=false; (function (window, document, $, undefined){ "use strict"; var H=$("html"), W=$(window), D=$(document), F=$.ow_vote_fancybox=function (){ F.open.apply(this, arguments); }, IE=navigator.userAgent.match(/msie/i), didUpdate=null, isTouch=document.createTouch!==undefined, isQuery=function(obj){ return obj&&obj.hasOwnProperty&&obj instanceof $; }, isString=function(str){ return str&&$.type(str)==="string"; }, isPercentage=function(str){ return isString(str)&&str.indexOf('%') > 0; }, isScrollable=function(el){ return (el&&!(el.style.overflow&&el.style.overflow==='hidden')&&((el.clientWidth&&el.scrollWidth > el.clientWidth)||(el.clientHeight&&el.scrollHeight > el.clientHeight))); }, getScalar=function(orig, dim){ var value=parseInt(orig, 10)||0; if(dim&&isPercentage(orig)){ value=F.getViewport()[ dim ] / 100 * value; } return Math.ceil(value); }, getValue=function(value, dim){ return getScalar(value, dim) + 'px'; }; $.extend(F, { version: '2.1.5', defaults: { padding:15, margin:20, width:800, height:600, minWidth:100, minHeight:100, maxWidth:9999, maxHeight:9999, pixelRatio: 1, autoSize:true, autoHeight:false, autoWidth:false, autoResize:true, autoCenter:!isTouch, fitToView:true, aspectRatio:false, topRatio:0.5, leftRatio:0.5, scrolling:'auto', // 'auto', 'yes' or 'no' wrapCSS:'', arrows:true, closeBtn:true, closeClick:false, nextClick:false, mouseWheel:true, autoPlay:false, playSpeed:3000, preload:3, modal:false, loop:true, ajax:{ dataType:'html', headers:{ 'X-fancyBox': true }}, iframe:{ scrolling:'auto', preload:true }, swf:{ wmode: 'transparent', allowfullscreen:'true', allowscriptaccess:'always' }, keys:{ next:{ 13:'left', 34:'up', 39:'left', 40:'up' }, prev:{ 8:'right', 33:'down', 37:'right', 38:'down' }, close:[27], play:[32], toggle:[70] }, direction:{ next:'left', prev:'right' }, scrollOutside:true, index:0, type:null, href:null, content:null, title:null, tpl: { wrap:'
    ', image:'', iframe:'', error:'

    The requested content cannot be loaded.
    Please try again later.

    ', closeBtn:'', next:'', prev:'' }, openEffect:'fade', // 'elastic', 'fade' or 'none' openSpeed:250, openEasing:'swing', openOpacity:true, openMethod:'zoomIn', closeEffect:'fade', // 'elastic', 'fade' or 'none' closeSpeed:250, closeEasing:'swing', closeOpacity:true, closeMethod:'zoomOut', nextEffect:'elastic', // 'elastic', 'fade' or 'none' nextSpeed:250, nextEasing:'swing', nextMethod:'changeIn', prevEffect:'elastic', // 'elastic', 'fade' or 'none' prevSpeed:250, prevEasing:'swing', prevMethod:'changeOut', helpers:{ overlay:true, title:true }, onCancel:$.noop, beforeLoad:$.noop, afterLoad:$.noop, beforeShow:$.noop, afterShow:$.noop, beforeChange:$.noop, beforeClose:$.noop, afterClose:$.noop }, group:{}, opts:{}, previous:null, coming:null, current:null, isActive:false, isOpen:false, isOpened:false, wrap:null, skin:null, outer:null, inner:null, player:{ timer:null, isActive:false }, ajaxLoad:null, imgPreload:null, transitions:{}, helpers:{}, open: function (group, opts){ if(!group){ return; } if(!$.isPlainObject(opts)){ opts={};} if(false===F.close(true)){ return; } if(!$.isArray(group)){ group=isQuery(group) ? $(group).get():[group]; } $.each(group, function(i, element){ var obj={}, href, title, content, type, rez, hrefParts, selector; if($.type(element)==="object"){ if(element.nodeType){ element=$(element); } if(isQuery(element)){ obj={ href:element.data('ow_vote_fancybox-href')||element.attr('href'), title:element.data('ow_vote_fancybox-title')||element.attr('title'), isDom:true, element:element }; if($.metadata){ $.extend(true, obj, element.metadata()); }}else{ obj=element; }} href=opts.href||obj.href||(isString(element) ? element:null); title=opts.title!==undefined ? opts.title:obj.title||''; content=opts.content||obj.content; type=content ? 'html':(opts.type||obj.type); if(!type&&obj.isDom){ type=element.data('ow_vote_fancybox-type'); if(!type){ rez=element.prop('class').match(/ow_vote_fancybox\.(\w+)/); type=rez ? rez[1]:null; }} if(isString(href)){ if(!type){ if(F.isImage(href)){ type='image'; }else if(F.isSWF(href)){ type='swf'; }else if(href.charAt(0)==='#'){ type='inline'; }else if(isString(element)){ type='html'; content=element; }} if(type==='ajax'){ hrefParts=href.split(/\s+/, 2); href=hrefParts.shift(); selector=hrefParts.shift(); }} if(!content){ if(type==='inline'){ if(href){ content=$(isString(href) ? href.replace(/.*(?=#[^\s]+$)/, ''):href); }else if(obj.isDom){ content=element; }}else if(type==='html'){ content=href; }else if(!type&&!href&&obj.isDom){ type='inline'; content=element; }} $.extend(obj, { href:href, type:type, content:content, title:title, selector:selector }); group[ i ]=obj; }); F.opts=$.extend(true, {}, F.defaults, opts); if(opts.keys!==undefined){ F.opts.keys=opts.keys ? $.extend({}, F.defaults.keys, opts.keys):false; } F.group=group; return F._start(F.opts.index); }, cancel: function (){ var coming=F.coming; if(!coming||false===F.trigger('onCancel')){ return; } F.hideLoading(); if(F.ajaxLoad){ F.ajaxLoad.abort(); } F.ajaxLoad=null; if(F.imgPreload){ F.imgPreload.onload=F.imgPreload.onerror=null; } if(coming.wrap){ coming.wrap.stop(true, true).trigger('onReset').remove(); } F.coming=null; if(!F.current){ F._afterZoomOut(coming); }}, close: function (event){ F.cancel(); if(false===F.trigger('beforeClose')){ return; } F.unbindEvents(); if(!F.isActive){ return; } if(!F.isOpen||event===true){ $('.ow_vote_fancybox-wrap').stop(true).trigger('onReset').remove(); F._afterZoomOut(); }else{ F.isOpen=F.isOpened=false; F.isClosing=true; $('.ow_vote_fancybox-item, .ow_vote_fancybox-nav').remove(); F.wrap.stop(true, true).removeClass('ow_vote_fancybox-opened'); F.transitions[ F.current.closeMethod ](); }}, play: function(action){ var clear=function (){ clearTimeout(F.player.timer); }, set=function (){ clear(); if(F.current&&F.player.isActive){ F.player.timer=setTimeout(F.next, F.current.playSpeed); }}, stop=function (){ clear(); D.unbind('.player'); F.player.isActive=false; F.trigger('onPlayEnd'); }, start=function (){ if(F.current&&(F.current.loop||F.current.index < F.group.length - 1)){ F.player.isActive=true; D.bind({ 'onCancel.player beforeClose.player':stop, 'onUpdate.player':set, 'beforeLoad.player':clear }); set(); F.trigger('onPlayStart'); }}; if(action===true||(!F.player.isActive&&action!==false)){ start(); }else{ stop(); }}, next: function(direction){ var current=F.current; if(current){ if(!isString(direction)){ direction=current.direction.next; } F.jumpto(current.index + 1, direction, 'next'); }}, prev: function(direction){ var current=F.current; if(current){ if(!isString(direction)){ direction=current.direction.prev; } F.jumpto(current.index - 1, direction, 'prev'); }}, jumpto: function(index, direction, router){ var current=F.current; if(!current){ return; } index=getScalar(index); F.direction=direction||current.direction[ (index >=current.index ? 'next':'prev') ]; F.router=router||'jumpto'; if(current.loop){ if(index < 0){ index=current.group.length + (index % current.group.length); } index=index % current.group.length; } if(current.group[ index ]!==undefined){ F.cancel(); F._start(index); }}, reposition: function (e, onlyAbsolute){ var current=F.current, wrap=current ? current.wrap:null, pos; if(wrap){ pos=F._getPosition(onlyAbsolute); if(e&&e.type==='scroll'){ delete pos.position; wrap.stop(true, true).animate(pos, 200); }else{ wrap.css(pos); current.pos=$.extend({}, current.dim, pos); }} }, update: function (e){ var type=(e&&e.type), anyway = !type||type==='orientationchange'; if(anyway){ clearTimeout(didUpdate); didUpdate=null; } if(!F.isOpen||didUpdate){ return; } didUpdate=setTimeout(function(){ var current=F.current; if(!current||F.isClosing){ return; } F.wrap.removeClass('ow_vote_fancybox-tmp'); if(anyway||type==='load'||(type==='resize'&¤t.autoResize)){ F._setDimension(); } if(!(type==='scroll'&¤t.canShrink)){ F.reposition(e); } F.trigger('onUpdate'); didUpdate=null; }, (anyway&&!isTouch ? 0:300)); }, toggle: function(action){ if(F.isOpen){ F.current.fitToView=$.type(action)==="boolean" ? action:!F.current.fitToView; if(isTouch){ F.wrap.removeAttr('style').addClass('ow_vote_fancybox-tmp'); F.trigger('onUpdate'); } F.update(); }}, hideLoading: function (){ D.unbind('.loading'); $('#ow_vote_fancybox-loading').remove(); }, showLoading: function (){ var el, viewport; F.hideLoading(); el=$('
    ').click(F.cancel).appendTo('body'); D.bind('keydown.loading', function(e){ if((e.which||e.keyCode)===27){ e.preventDefault(); F.cancel(); }}); if(!F.defaults.fixed){ viewport=F.getViewport(); el.css({ position:'absolute', top:(viewport.h * 0.5) + viewport.y, left:(viewport.w * 0.5) + viewport.x }); }}, getViewport: function (){ var locked=(F.current&&F.current.locked)||false, rez={ x: W.scrollLeft(), y: W.scrollTop() }; if(locked){ rez.w=locked[0].clientWidth; rez.h=locked[0].clientHeight; }else{ rez.w=isTouch&&window.innerWidth ? window.innerWidth:W.width(); rez.h=isTouch&&window.innerHeight ? window.innerHeight:W.height(); } return rez; }, unbindEvents: function (){ if(F.wrap&&isQuery(F.wrap)){ F.wrap.unbind('.fb'); } D.unbind('.fb'); W.unbind('.fb'); }, bindEvents: function (){ var current=F.current, keys; if(!current){ return; } W.bind('orientationchange.fb' + (isTouch ? '':' resize.fb') + (current.autoCenter&&!current.locked ? ' scroll.fb':''), F.update); keys=current.keys; if(keys){ D.bind('keydown.fb', function (e){ var code=e.which||e.keyCode, target=e.target||e.srcElement; if(code===27&&F.coming){ return false; } if(!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.metaKey&&!(target&&(target.type||$(target).is('[contenteditable]')))){ $.each(keys, function(i, val){ if(current.group.length > 1&&val[ code ]!==undefined){ F[ i ](val[ code ]); e.preventDefault(); return false; } if($.inArray(code, val) > -1){ F[ i ] (); e.preventDefault(); return false; }}); }}); } if($.fn.mousewheel&¤t.mouseWheel){ F.wrap.bind('mousewheel.fb', function (e, delta, deltaX, deltaY){ var target=e.target||null, parent=$(target), canScroll=false; while (parent.length){ if(canScroll||parent.is('.ow_vote_fancybox-skin')||parent.is('.ow_vote_fancybox-wrap')){ break; } canScroll=isScrollable(parent[0]); parent=$(parent).parent(); } if(delta!==0&&!canScroll){ if(F.group.length > 1&&!current.canShrink){ if(deltaY > 0||deltaX > 0){ F.prev(deltaY > 0 ? 'down':'left'); }else if(deltaY < 0||deltaX < 0){ F.next(deltaY < 0 ? 'up':'right'); } e.preventDefault(); }} }); }}, trigger: function (event, o){ var ret, obj=o||F.coming||F.current; if(!obj){ return; } if($.isFunction(obj[event])){ ret=obj[event].apply(obj, Array.prototype.slice.call(arguments, 1)); } if(ret===false){ return false; } if(obj.helpers){ $.each(obj.helpers, function (helper, opts){ if(opts&&F.helpers[helper]&&$.isFunction(F.helpers[helper][event])){ F.helpers[helper][event]($.extend(true, {}, F.helpers[helper].defaults, opts), obj); }}); } D.trigger(event); }, isImage: function (str){ return isString(str)&&str.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg)((\?|#).*)?$)/i); }, isSWF: function (str){ return isString(str)&&str.match(/\.(swf)((\?|#).*)?$/i); }, _start: function (index){ var coming={}, obj, href, type, margin, padding; index=getScalar(index); obj=F.group[ index ]||null; if(!obj){ return false; } coming=$.extend(true, {}, F.opts, obj); margin=coming.margin; padding=coming.padding; if($.type(margin)==='number'){ coming.margin=[margin, margin, margin, margin]; } if($.type(padding)==='number'){ coming.padding=[padding, padding, padding, padding]; } if(coming.modal){ $.extend(true, coming, { closeBtn:false, closeClick:false, nextClick:false, arrows:false, mouseWheel:false, keys:null, helpers: { overlay:{ closeClick:false }} }); } if(coming.autoSize){ coming.autoWidth=coming.autoHeight=true; } if(coming.width==='auto'){ coming.autoWidth=true; } if(coming.height==='auto'){ coming.autoHeight=true; } /* * Add reference to the group, so it`s possible to access from callbacks, example: * afterLoad:function(){ * this.title='Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title:''); * } */ coming.group=F.group; coming.index=index; F.coming=coming; if(false===F.trigger('beforeLoad')){ F.coming=null; return; } type=coming.type; href=coming.href; if(!type){ F.coming=null; if(F.current&&F.router&&F.router!=='jumpto'){ F.current.index=index; return F[ F.router ](F.direction); } return false; } F.isActive=true; if(type==='image'||type==='swf'){ coming.autoHeight=coming.autoWidth=false; coming.scrolling='visible'; } if(type==='image'){ coming.aspectRatio=true; } if(type==='iframe'&&isTouch){ coming.scrolling='scroll'; } coming.wrap=$(coming.tpl.wrap).addClass('ow_vote_fancybox-' + (isTouch ? 'mobile':'desktop') + ' ow_vote_fancybox-type-' + type + ' ow_vote_fancybox-tmp ' + coming.wrapCSS).appendTo(coming.parent||'body'); $.extend(coming, { skin:$('.ow_vote_fancybox-skin', coming.wrap), outer:$('.ow_vote_fancybox-outer', coming.wrap), inner:$('.ow_vote_fancybox-inner', coming.wrap) }); $.each(["Top", "Right", "Bottom", "Left"], function(i, v){ coming.skin.css('padding' + v, getValue(coming.padding[ i ])); }); F.trigger('onReady'); if(type==='inline'||type==='html'){ if(!coming.content||!coming.content.length){ return F._error('content'); }}else if(!href){ return F._error('href'); } if(type==='image'){ F._loadImage(); }else if(type==='ajax'){ F._loadAjax(); }else if(type==='iframe'){ F._loadIframe(); }else{ F._afterLoad(); }}, _error: function(type){ $.extend(F.coming, { type:'html', autoWidth:true, autoHeight:true, minWidth:0, minHeight:0, scrolling:'no', hasError:type, content:F.coming.tpl.error }); F._afterLoad(); }, _loadImage: function (){ var img=F.imgPreload=new Image(); img.onload=function (){ this.onload=this.onerror=null; F.coming.width=this.width / F.opts.pixelRatio; F.coming.height=this.height / F.opts.pixelRatio; F._afterLoad(); }; img.onerror=function (){ this.onload=this.onerror=null; F._error('image'); }; img.src=F.coming.href; if(img.complete!==true){ F.showLoading(); }}, _loadAjax: function (){ var coming=F.coming; F.showLoading(); F.ajaxLoad=$.ajax($.extend({}, coming.ajax, { url: coming.href, error: function (jqXHR, textStatus){ if(F.coming&&textStatus!=='abort'){ F._error('ajax', jqXHR); }else{ F.hideLoading(); }}, success: function (data, textStatus){ if(textStatus==='success'){ coming.content=data; F._afterLoad(); }} })); }, _loadIframe: function(){ var coming=F.coming, iframe=$(coming.tpl.iframe.replace(/\{rnd\}/g, new Date().getTime())) .attr('scrolling', isTouch ? 'auto':coming.iframe.scrolling) .attr('src', coming.href); $(coming.wrap).bind('onReset', function (){ try { $(this).find('iframe').hide().attr('src', '//about:blank').end().empty(); } catch (e){}}); if(coming.iframe.preload){ F.showLoading(); iframe.one('load', function(){ $(this).data('ready', 1); if(!isTouch){ $(this).bind('load.fb', F.update); } $(this).parents('.ow_vote_fancybox-wrap').width('100%').removeClass('ow_vote_fancybox-tmp').show(); F._afterLoad(); }); } coming.content=iframe.appendTo(coming.inner); if(!coming.iframe.preload){ F._afterLoad(); }}, _preloadImages: function(){ var group=F.group, current=F.current, len=group.length, cnt=current.preload ? Math.min(current.preload, len - 1):0, item, i; for (i=1; i <=cnt; i +=1){ item=group[ (current.index + i) % len ]; if(item.type==='image'&&item.href){ new Image().src=item.href; }} }, _afterLoad: function (){ var coming=F.coming, previous=F.current, placeholder='ow_vote_fancybox-placeholder', current, content, type, scrolling, href, embed; F.hideLoading(); if(!coming||F.isActive===false){ return; } if(false===F.trigger('afterLoad', coming, previous)){ coming.wrap.stop(true).trigger('onReset').remove(); F.coming=null; return; } if(previous){ F.trigger('beforeChange', previous); previous.wrap.stop(true).removeClass('ow_vote_fancybox-opened') .find('.ow_vote_fancybox-item, .ow_vote_fancybox-nav') .remove(); } F.unbindEvents(); current=coming; content=coming.content; type=coming.type; scrolling=coming.scrolling; $.extend(F, { wrap:current.wrap, skin:current.skin, outer:current.outer, inner:current.inner, current:current, previous:previous }); href=current.href; switch (type){ case 'inline': case 'ajax': case 'html': if(current.selector){ content=$('
    ').html(content).find(current.selector); }else if(isQuery(content)){ if(!content.data(placeholder)){ content.data(placeholder, $('
    ').insertAfter(content).hide()); } content=content.show().detach(); current.wrap.bind('onReset', function (){ if($(this).find(content).length){ content.hide().replaceAll(content.data(placeholder)).data(placeholder, false); }}); } break; case 'image': content=current.tpl.image.replace('{href}', href); break; case 'swf': content=''; embed=''; $.each(current.swf, function(name, val){ content +=''; embed +=' ' + name + '="' + val + '"'; }); content +=''; break; } if(!(isQuery(content)&&content.parent().is(current.inner))){ current.inner.append(content); } F.trigger('beforeShow'); current.inner.css('overflow', scrolling==='yes' ? 'scroll':(scrolling==='no' ? 'hidden':scrolling)); F._setDimension(); F.reposition(); F.isOpen=false; F.coming=null; F.bindEvents(); if(!F.isOpened){ $('.ow_vote_fancybox-wrap').not(current.wrap).stop(true).trigger('onReset').remove(); }else if(previous.prevMethod){ F.transitions[ previous.prevMethod ](); } F.transitions[ F.isOpened ? current.nextMethod:current.openMethod ](); F._preloadImages(); }, _setDimension: function (){ var viewport=F.getViewport(), steps=0, canShrink=false, canExpand=false, wrap=F.wrap, skin=F.skin, inner=F.inner, current=F.current, width=current.width, height=current.height, minWidth=current.minWidth, minHeight=current.minHeight, maxWidth=current.maxWidth, maxHeight=current.maxHeight, scrolling=current.scrolling, scrollOut=current.scrollOutside ? current.scrollbarWidth:0, margin=current.margin, wMargin=getScalar(margin[1] + margin[3]), hMargin=getScalar(margin[0] + margin[2]), wPadding, hPadding, wSpace, hSpace, origWidth, origHeight, origMaxWidth, origMaxHeight, ratio, width_, height_, maxWidth_, maxHeight_, iframe, body; wrap.add(skin).add(inner).width('auto').height('auto').removeClass('ow_vote_fancybox-tmp'); wPadding=getScalar(skin.outerWidth(true) - skin.width()); hPadding=getScalar(skin.outerHeight(true) - skin.height()); wSpace=wMargin + wPadding; hSpace=hMargin + hPadding; origWidth=isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100:width; origHeight=isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100:height; if(current.type==='iframe'){ iframe=current.content; if(current.autoHeight&&iframe.data('ready')===1){ try { if(iframe[0].contentWindow.document.location){ inner.width(origWidth).height(9999); body=iframe.contents().find('body'); if(scrollOut){ body.css('overflow-x', 'hidden'); } origHeight=body.outerHeight(true); }} catch (e){}} }else if(current.autoWidth||current.autoHeight){ inner.addClass('ow_vote_fancybox-tmp'); if(!current.autoWidth){ inner.width(origWidth); } if(!current.autoHeight){ inner.height(origHeight); } if(current.autoWidth){ origWidth=inner.width(); } if(current.autoHeight){ origHeight=inner.height(); } inner.removeClass('ow_vote_fancybox-tmp'); } width=getScalar(origWidth); height=getScalar(origHeight); ratio=origWidth / origHeight; minWidth=getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace:minWidth); maxWidth=getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace:maxWidth); minHeight=getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace:minHeight); maxHeight=getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace:maxHeight); origMaxWidth=maxWidth; origMaxHeight=maxHeight; if(current.fitToView){ maxWidth=Math.min(viewport.w - wSpace, maxWidth); maxHeight=Math.min(viewport.h - hSpace, maxHeight); } maxWidth_=viewport.w - wMargin; maxHeight_=viewport.h - hMargin; if(current.aspectRatio){ if(width > maxWidth){ width=maxWidth; height=getScalar(width / ratio); } if(height > maxHeight){ height=maxHeight; width=getScalar(height * ratio); } if(width < minWidth){ width=minWidth; height=getScalar(width / ratio); } if(height < minHeight){ height=minHeight; width=getScalar(height * ratio); }}else{ width=Math.max(minWidth, Math.min(width, maxWidth)); if(current.autoHeight&¤t.type!=='iframe'){ inner.width(width); height=inner.height(); } height=Math.max(minHeight, Math.min(height, maxHeight)); } if(current.fitToView){ inner.width(width).height(height); wrap.width(width + wPadding); width_=wrap.width(); height_=wrap.height(); if(current.aspectRatio){ while ((width_ > maxWidth_||height_ > maxHeight_)&&width > minWidth&&height > minHeight){ if(steps++ > 19){ break; } height=Math.max(minHeight, Math.min(maxHeight, height - 10)); width=getScalar(height * ratio); if(width < minWidth){ width=minWidth; height=getScalar(width / ratio); } if(width > maxWidth){ width=maxWidth; height=getScalar(width / ratio); } inner.width(width).height(height); wrap.width(width + wPadding); width_=wrap.width(); height_=wrap.height(); }}else{ width=Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_))); height=Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_))); }} if(scrollOut&&scrolling==='auto'&&height < origHeight&&(width + wPadding + scrollOut) < maxWidth_){ width +=scrollOut; } inner.width(width).height(height); wrap.width(width + wPadding); width_=wrap.width(); height_=wrap.height(); canShrink=(width_ > maxWidth_||height_ > maxHeight_)&&width > minWidth&&height > minHeight; canExpand=current.aspectRatio ? (width < origMaxWidth&&height < origMaxHeight&&width < origWidth&&height < origHeight):((width < origMaxWidth||height < origMaxHeight)&&(width < origWidth||height < origHeight)); $.extend(current, { dim:{ width:getValue(width_), height:getValue(height_) }, origWidth:origWidth, origHeight:origHeight, canShrink:canShrink, canExpand:canExpand, wPadding:wPadding, hPadding:hPadding, wrapSpace:height_ - skin.outerHeight(true), skinSpace:skin.height() - height }); if(!iframe&¤t.autoHeight&&height > minHeight&&height < maxHeight&&!canExpand){ inner.height('auto'); }}, _getPosition: function (onlyAbsolute){ var current=F.current, viewport=F.getViewport(), margin=current.margin, width=F.wrap.width() + margin[1] + margin[3], height=F.wrap.height() + margin[0] + margin[2], rez={ position: 'absolute', top:margin[0], left:margin[3] }; if(current.autoCenter&¤t.fixed&&!onlyAbsolute&&height <=viewport.h&&width <=viewport.w){ rez.position='fixed'; }else if(!current.locked){ rez.top +=viewport.y; rez.left +=viewport.x; } rez.top=getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio))); rez.left=getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio))); return rez; }, _afterZoomIn: function (){ var current=F.current; if(!current){ return; } F.isOpen=F.isOpened=true; F.wrap.css('overflow', 'visible').addClass('ow_vote_fancybox-opened'); F.update(); if(current.closeClick||(current.nextClick&&F.group.length > 1)){ F.inner.css('cursor', 'pointer').bind('click.fb', function(e){ if(!$(e.target).is('a')&&!$(e.target).parent().is('a')){ e.preventDefault(); F[ current.closeClick ? 'close':'next' ](); }}); } if(current.closeBtn){ $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e){ e.preventDefault(); F.close(); }); } if(current.arrows&&F.group.length > 1){ if(current.loop||current.index > 0){ $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev); } if(current.loop||current.index < F.group.length - 1){ $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next); }} F.trigger('afterShow'); if(!current.loop&¤t.index===current.group.length - 1){ F.play(false); }else if(F.opts.autoPlay&&!F.player.isActive){ F.opts.autoPlay=false; F.play(); }}, _afterZoomOut: function(obj){ obj=obj||F.current; $('.ow_vote_fancybox-wrap').trigger('onReset').remove(); $.extend(F, { group:{}, opts:{}, router:false, current:null, isActive:false, isOpened:false, isOpen:false, isClosing:false, wrap:null, skin:null, outer:null, inner:null }); F.trigger('afterClose', obj); }}); F.transitions={ getOrigPosition: function (){ var current=F.current, element=current.element, orig=current.orig, pos={}, width=50, height=50, hPadding=current.hPadding, wPadding=current.wPadding, viewport=F.getViewport(); if(!orig&¤t.isDom&&element.is(':visible')){ orig=element.find('img:first'); if(!orig.length){ orig=element; }} if(isQuery(orig)){ pos=orig.offset(); if(orig.is('img')){ width=orig.outerWidth(); height=orig.outerHeight(); }}else{ pos.top=viewport.y + (viewport.h - height) * current.topRatio; pos.left=viewport.x + (viewport.w - width) * current.leftRatio; } if(F.wrap.css('position')==='fixed'||current.locked){ pos.top -=viewport.y; pos.left -=viewport.x; } pos={ top:getValue(pos.top - hPadding * current.topRatio), left:getValue(pos.left - wPadding * current.leftRatio), width:getValue(width + wPadding), height:getValue(height + hPadding) }; return pos; }, step: function (now, fx){ var ratio, padding, value, prop=fx.prop, current=F.current, wrapSpace=current.wrapSpace, skinSpace=current.skinSpace; if(prop==='width'||prop==='height'){ ratio=fx.end===fx.start ? 1:(now - fx.start) / (fx.end - fx.start); if(F.isClosing){ ratio=1 - ratio; } padding=prop==='width' ? current.wPadding:current.hPadding; value=now - padding; F.skin[ prop ](getScalar(prop==='width' ? value:value - (wrapSpace * ratio))); F.inner[ prop ](getScalar(prop==='width' ? value:value - (wrapSpace * ratio) - (skinSpace * ratio))); }}, zoomIn: function (){ var current=F.current, startPos=current.pos, effect=current.openEffect, elastic=effect==='elastic', endPos=$.extend({opacity:1}, startPos); delete endPos.position; if(elastic){ startPos=this.getOrigPosition(); if(current.openOpacity){ startPos.opacity=0.1; }}else if(effect==='fade'){ startPos.opacity=0.1; } F.wrap.css(startPos).animate(endPos, { duration:effect==='none' ? 0:current.openSpeed, easing:current.openEasing, step:elastic ? this.step:null, complete:F._afterZoomIn }); }, zoomOut: function (){ var current=F.current, effect=current.closeEffect, elastic=effect==='elastic', endPos={opacity:0.1}; if(elastic){ endPos=this.getOrigPosition(); if(current.closeOpacity){ endPos.opacity=0.1; }} F.wrap.animate(endPos, { duration:effect==='none' ? 0:current.closeSpeed, easing:current.closeEasing, step:elastic ? this.step:null, complete:F._afterZoomOut }); }, changeIn: function (){ var current=F.current, effect=current.nextEffect, startPos=current.pos, endPos={ opacity:1 }, direction=F.direction, distance=200, field; startPos.opacity=0.1; if(effect==='elastic'){ field=direction==='down'||direction==='up' ? 'top':'left'; if(direction==='down'||direction==='right'){ startPos[ field ]=getValue(getScalar(startPos[ field ]) - distance); endPos[ field ]='+=' + distance + 'px'; }else{ startPos[ field ]=getValue(getScalar(startPos[ field ]) + distance); endPos[ field ]='-=' + distance + 'px'; }} if(effect==='none'){ F._afterZoomIn(); }else{ F.wrap.css(startPos).animate(endPos, { duration:current.nextSpeed, easing:current.nextEasing, complete:F._afterZoomIn }); }}, changeOut: function (){ var previous=F.previous, effect=previous.prevEffect, endPos={ opacity:0.1 }, direction=F.direction, distance=200; if(effect==='elastic'){ endPos[ direction==='down'||direction==='up' ? 'top':'left' ]=(direction==='up'||direction==='left' ? '-':'+') + '=' + distance + 'px'; } previous.wrap.animate(endPos, { duration:effect==='none' ? 0:previous.prevSpeed, easing:previous.prevEasing, complete:function (){ $(this).trigger('onReset').remove(); }}); }}; F.helpers.overlay={ defaults:{ closeClick:true, speedOut:200, showEarly:true, css:{}, locked:!isTouch, fixed:true }, overlay:null, fixed:false, el:$('html'), create:function(opts){ opts=$.extend({}, this.defaults, opts); if(this.overlay){ this.close(); } this.overlay=$('
    ').appendTo(F.coming ? F.coming.parent:opts.parent); this.fixed=false; if(opts.fixed&&F.defaults.fixed){ this.overlay.addClass('ow_vote_fancybox-overlay-fixed'); this.fixed=true; }}, open:function(opts){ var that=this; opts=$.extend({}, this.defaults, opts); if(this.overlay){ this.overlay.unbind('.overlay').width('auto').height('auto'); }else{ this.create(opts); } if(!this.fixed){ W.bind('resize.overlay', $.proxy(this.update, this)); this.update(); } if(opts.closeClick){ this.overlay.bind('click.overlay', function(e){ if($(e.target).hasClass('ow_vote_fancybox-overlay')){ if(F.isActive){ F.close(); }else{ that.close(); } return false; }}); } this.overlay.css(opts.css).show(); }, close:function(){ var scrollV, scrollH; W.unbind('resize.overlay'); if(this.el.hasClass('ow_vote_fancybox-lock')){ $('.ow_vote_fancybox-margin').removeClass('ow_vote_fancybox-margin'); scrollV=W.scrollTop(); scrollH=W.scrollLeft(); this.el.removeClass('ow_vote_fancybox-lock'); W.scrollTop(scrollV).scrollLeft(scrollH); } $('.ow_vote_fancybox-overlay').remove().hide(); $.extend(this, { overlay:null, fixed:false }); }, update:function (){ var width='100%', offsetWidth; this.overlay.width(width).height('100%'); if(IE){ offsetWidth=Math.max(document.documentElement.offsetWidth, document.body.offsetWidth); if(D.width() > offsetWidth){ width=D.width(); }}else if(D.width() > W.width()){ width=D.width(); } this.overlay.width(width).height(D.height()); }, onReady:function (opts, obj){ var overlay=this.overlay; $('.ow_vote_fancybox-overlay').stop(true, true); if(!overlay){ this.create(opts); } if(opts.locked&&this.fixed&&obj.fixed){ if(!overlay){ this.margin=D.height() > W.height() ? $('html').css('margin-right').replace("px", ""):false; } obj.locked=this.overlay.append(obj.wrap); obj.fixed=false; } if(opts.showEarly===true){ this.beforeShow.apply(this, arguments); }}, beforeShow:function(opts, obj){ var scrollV, scrollH; if(obj.locked){ if(this.margin!==false){ $('*').filter(function(){ return ($(this).css('position')==='fixed'&&!$(this).hasClass("ow_vote_fancybox-overlay")&&!$(this).hasClass("ow_vote_fancybox-wrap")); }).addClass('ow_vote_fancybox-margin'); this.el.addClass('ow_vote_fancybox-margin'); } scrollV=W.scrollTop(); scrollH=W.scrollLeft(); this.el.addClass('ow_vote_fancybox-lock'); W.scrollTop(scrollV).scrollLeft(scrollH); } this.open(opts); }, onUpdate:function(){ if(!this.fixed){ this.update(); }}, afterClose: function (opts){ if(this.overlay&&!F.coming){ this.overlay.fadeOut(opts.speedOut, $.proxy(this.close, this)); }} }; F.helpers.title={ defaults:{ type:'float', // 'float', 'inside', 'outside' or 'over', position:'bottom' // 'top' or 'bottom' }, beforeShow: function (opts){ var current=F.current, text=current.title, type=opts.type, title, target; if($.isFunction(text)){ text=text.call(current.element, current); } if(!isString(text)||$.trim(text)===''){ return; } title=$('
    ' + text + '
    '); switch (type){ case 'inside': target=F.skin; break; case 'outside': target=F.wrap; break; case 'over': target=F.inner; break; default: // 'float' target=F.skin; title.appendTo('body'); if(IE){ title.width(title.width()); } title.wrapInner(''); F.current.margin[2] +=Math.abs(getScalar(title.css('margin-bottom'))); break; } title[ (opts.position==='top' ? 'prependTo':'appendTo') ](target); }}; $.fn.ow_vote_fancybox=function (options){ var index, that=$(this), selector=this.selector||'', run=function(e){ var what=$(this).blur(), idx=index, relType, relVal; if(!(e.ctrlKey||e.altKey||e.shiftKey||e.metaKey)&&!what.is('.ow_vote_fancybox-wrap')){ relType=options.groupAttr||'data-ow_vote_fancybox-group'; relVal=what.attr(relType); if(!relVal){ relType='rel'; relVal=what.get(0)[ relType ]; } if(relVal&&relVal!==''&&relVal!=='nofollow'){ what=selector.length ? $(selector):that; what=what.filter('[' + relType + '="' + relVal + '"]'); idx=what.index(this); } options.index=idx; if(F.open(what, options)!==false){ e.preventDefault(); }} }; options=options||{}; index=options.index||0; if(!selector||options.live===false){ that.unbind('click.fb-start').bind('click.fb-start', run); }else{ D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.ow_vote_fancybox-item, .ow_vote_fancybox-nav')", 'click.fb-start', run); } this.filter('[data-ow_vote_fancybox-start=1]').trigger('click'); return this; }; D.ready(function(){ var w1, w2; if($.scrollbarWidth===undefined){ $.scrollbarWidth=function(){ var parent=$('
    ').appendTo('body'), child=parent.children(), width=child.innerWidth() - child.height(99).innerWidth(); parent.remove(); return width; };} if($.support.fixedPosition===undefined){ $.support.fixedPosition=(function(){ var elem=$('
    ').appendTo('body'), fixed=(elem[0].offsetTop===20||elem[0].offsetTop===15); elem.remove(); return fixed; }()); } $.extend(F.defaults, { scrollbarWidth:$.scrollbarWidth(), fixed:$.support.fixedPosition, parent:$('body') }); w1=$(window).width(); H.addClass('ow_vote_fancybox-lock-test'); w2=$(window).width(); H.removeClass('ow_vote_fancybox-lock-test'); $("").appendTo("head"); }); }(window, document, jQuery)); (function(factory){ if(typeof define==="function"&&define.amd){ define(["jquery"], factory); }else{ factory(jQuery); }}(function($){ $.extend($.fn, { ow_vote_validate: function(options){ if(!this.length){ if(options&&options.debug&&window.console){ console.warn("Nothing selected, can't validate, returning nothing."); } return; } var vote_validator=$.data(this[ 0 ], "vote_validator"); if(vote_validator){ return vote_validator; } this.attr("noow_vote_validate", "noow_vote_validate"); vote_validator=new $.vote_validator(options, this[ 0 ]); $.data(this[ 0 ], "vote_validator", vote_validator); if(vote_validator.settings.onsubmit){ this.ow_vote_validateDelegate(":submit", "click", function(event){ if(vote_validator.settings.submitHandler){ vote_validator.submitButton=event.target; } if($(event.target).hasClass("cancel")){ vote_validator.cancelSubmit=true; } if($(event.target).attr("formnoow_vote_validate")!==undefined){ vote_validator.cancelSubmit=true; }}); this.submit(function(event){ if(vote_validator.settings.debug){ event.preventDefault(); } function handle(){ var hidden, result; if(vote_validator.settings.submitHandler){ if(vote_validator.submitButton){ hidden=$("") .attr("name", vote_validator.submitButton.name) .val($(vote_validator.submitButton).val()) .appendTo(vote_validator.currentForm); } result=vote_validator.settings.submitHandler.call(vote_validator, vote_validator.currentForm, event); if(vote_validator.submitButton){ hidden.remove(); } if(result!==undefined){ return result; } return false; } return true; } if(vote_validator.cancelSubmit){ vote_validator.cancelSubmit=false; return handle(); } if(vote_validator.form()){ if(vote_validator.pendingRequest){ vote_validator.formSubmitted=true; return false; } return handle(); }else{ vote_validator.focusInvalid(); return false; }}); } return vote_validator; }, ow_vote_valid: function(){ var ow_vote_valid, vote_validator; if($(this[ 0 ]).is("form")){ ow_vote_valid=this.ow_vote_validate().form(); }else{ ow_vote_valid=true; vote_validator=$(this[ 0 ].form).ow_vote_validate(); this.each(function(){ ow_vote_valid=vote_validator.element(this)&&ow_vote_valid; }); } return ow_vote_valid; }, ow_vote_removeAttrs: function(attributes){ var result={}, $element=this; $.each(attributes.split(/\s/), function(index, value){ result[ value ]=$element.attr(value); $element.removeAttr(value); }); return result; }, ow_vote_rules: function(command, argument){ var element=this[ 0 ], settings, staticRules, existingRules, data, param, filtered; if(element===undefined){ return; } if(command){ settings=$.data(element.form, "vote_validator").settings; staticRules=settings.ow_vote_rules; existingRules=$.vote_validator.staticRules(element); switch(command){ case "add": $.extend(existingRules, $.vote_validator.normalizeRule(argument)); delete existingRules.ow_vote_messages; staticRules[ element.name ]=existingRules; if(argument.ow_vote_messages){ settings.ow_vote_messages[ element.name ]=$.extend(settings.ow_vote_messages[ element.name ], argument.ow_vote_messages); } break; case "remove": if(!argument){ delete staticRules[ element.name ]; return existingRules; } filtered={}; $.each(argument.split(/\s/), function(index, method){ filtered[ method ]=existingRules[ method ]; delete existingRules[ method ]; if(method==="required"){ $(element).removeAttr("aria-required"); }}); return filtered; }} data=$.vote_validator.normalizeRules($.extend({}, $.vote_validator.classRules(element), $.vote_validator.attributeRules(element), $.vote_validator.dataRules(element), $.vote_validator.staticRules(element) ), element); if(data.required){ param=data.required; delete data.required; data=$.extend({ required: param }, data); $(element).attr("aria-required", "true"); } if(data.remote){ param=data.remote; delete data.remote; data=$.extend(data, { remote: param }); } return data; }}); $.extend($.expr[ ":" ], { blank: function(a){ return !$.trim("" + $(a).val()); }, filled: function(a){ return !!$.trim("" + $(a).val()); }, unchecked: function(a){ return !$(a).prop("checked"); }}); $.vote_validator=function(options, form){ this.settings=$.extend(true, {}, $.vote_validator.defaults, options); this.currentForm=form; this.init(); }; $.vote_validator.format=function(source, params){ if(arguments.length===1){ return function(){ var args=$.makeArray(arguments); args.unshift(source); return $.vote_validator.format.apply(this, args); };} if(arguments.length > 2&¶ms.constructor!==Array){ params=$.makeArray(arguments).slice(1); } if(params.constructor!==Array){ params=[ params ]; } $.each(params, function(i, n){ source=source.replace(new RegExp("\\{" + i + "\\}", "g"), function(){ return n; }); }); return source; }; $.extend($.vote_validator, { defaults: { ow_vote_messages: {}, groups: {}, ow_vote_rules: {}, errorClass: "error", validClass: "ow_vote_valid", errorElement: "label", focusCleanup: false, focusInvalid: true, errorContainer: $([]), errorLabelContainer: $([]), onsubmit: true, ignore: ":hidden", ignoreTitle: false, onfocusin: function(element){ this.lastActive=element; if(this.settings.focusCleanup){ if(this.settings.unhighlight){ this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.validClass); } this.hideThese(this.errorsFor(element)); }}, onfocusout: function(element){ if(!this.checkable(element)&&(element.name in this.submitted||!this.optional(element))){ this.element(element); }}, onkeyup: function(element, event){ if(event.which===9&&this.elementValue(element)===""){ return; }else if(element.name in this.submitted||element===this.lastElement){ this.element(element); }}, onclick: function(element){ if(element.name in this.submitted){ this.element(element); }else if(element.parentNode.name in this.submitted){ this.element(element.parentNode); }}, highlight: function(element, errorClass, validClass){ if(element.type==="radio"){ this.findByName(element.name).addClass(errorClass).removeClass(validClass); }else{ $(element).addClass(errorClass).removeClass(validClass); }}, unhighlight: function(element, errorClass, validClass){ if(element.type==="radio"){ this.findByName(element.name).removeClass(errorClass).addClass(validClass); }else{ $(element).removeClass(errorClass).addClass(validClass); }} }, setDefaults: function(settings){ $.extend($.vote_validator.defaults, settings); }, ow_vote_messages: { required: "This field is required", remote: "Please fix this field.", email: "Please enter a valid email address.", url: "Please enter a valid URL.", date: "Please enter a valid date.", dateISO: "Please enter a valid date(ISO).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", maxlength: $.vote_validator.format("Please enter no more than {0} characters."), minlength: $.vote_validator.format("Please enter at least {0} characters."), rangelength: $.vote_validator.format("Please enter a value between {0} and {1} characters long."), range: $.vote_validator.format("Please enter a value between {0} and {1}."), max: $.vote_validator.format("Please enter a value less than or equal to {0}."), min: $.vote_validator.format("Please enter a value greater than or equal to {0}.") }, autoCreateRanges: false, prototype: { init: function(){ this.labelContainer=$(this.settings.errorLabelContainer); this.errorContext=this.labelContainer.length&&this.labelContainer||$(this.currentForm); this.containers=$(this.settings.errorContainer).add(this.settings.errorLabelContainer); this.submitted={}; this.valueCache={}; this.pendingRequest=0; this.pending={}; this.invalid={}; this.reset(); var groups=(this.groups={}), ow_vote_rules; $.each(this.settings.groups, function(key, value){ if(typeof value==="string"){ value=value.split(/\s/); } $.each(value, function(index, name){ groups[ name ]=key; }); }); ow_vote_rules=this.settings.ow_vote_rules; $.each(ow_vote_rules, function(key, value){ ow_vote_rules[ key ]=$.vote_validator.normalizeRule(value); }); function delegate(event){ var vote_validator=$.data(this[ 0 ].form, "vote_validator"), eventType="on" + event.type.replace(/^ow_vote_validate/, ""), settings=vote_validator.settings; if(settings[ eventType ]&&!this.is(settings.ignore)){ settings[ eventType ].call(vote_validator, this[ 0 ], event); }} $(this.currentForm) .ow_vote_validateDelegate(":text, [type='password'], [type='file'], select, textarea, " + "[type='number'], [type='search'] ,[type='tel'], [type='url'], " + "[type='email'], [type='datetime'], [type='date'], [type='month'], " + "[type='week'], [type='time'], [type='datetime-local'], " + "[type='range'], [type='color'], [type='radio'], [type='checkbox']", "focusin focusout keyup", delegate) .ow_vote_validateDelegate("select, option, [type='radio'], [type='checkbox']", "click", delegate); if(this.settings.invalidHandler){ $(this.currentForm).bind("invalid-form.ow_vote_validate", this.settings.invalidHandler); } $(this.currentForm).find("[required], [data-rule-required], .required").attr("aria-required", "true"); }, form: function(){ this.checkForm(); $.extend(this.submitted, this.errorMap); this.invalid=$.extend({}, this.errorMap); if(!this.ow_vote_valid()){ $(this.currentForm).triggerHandler("invalid-form", [ this ]); } this.showErrors(); return this.ow_vote_valid(); }, checkForm: function(){ this.prepareForm(); for(var i=0, elements=(this.currentElements=this.elements()); elements[ i ]; i++){ this.check(elements[ i ]); } return this.ow_vote_valid(); }, element: function(element){ var cleanElement=this.clean(element), checkElement=this.validationTargetFor(cleanElement), result=true; this.lastElement=checkElement; if(checkElement===undefined){ delete this.invalid[ cleanElement.name ]; }else{ this.prepareElement(checkElement); this.currentElements=$(checkElement); result=this.check(checkElement)!==false; if(result){ delete this.invalid[ checkElement.name ]; }else{ this.invalid[ checkElement.name ]=true; }} $(element).attr("aria-invalid", !result); if(!this.numberOfInvalids()){ this.toHide=this.toHide.add(this.containers); } this.showErrors(); return result; }, showErrors: function(errors){ if(errors){ $.extend(this.errorMap, errors); this.errorList=[]; for(var name in errors){ this.errorList.push({ message: errors[ name ], element: this.findByName(name)[ 0 ] }); } this.successList=$.grep(this.successList, function(element){ return !(element.name in errors); }); } if(this.settings.showErrors){ this.settings.showErrors.call(this, this.errorMap, this.errorList); }else{ this.defaultShowErrors(); }}, resetForm: function(){ if($.fn.resetForm){ $(this.currentForm).resetForm(); } this.submitted={}; this.lastElement=null; this.prepareForm(); this.hideErrors(); this.elements() .removeClass(this.settings.errorClass) .removeData("previousValue") .removeAttr("aria-invalid"); }, numberOfInvalids: function(){ return this.objectLength(this.invalid); }, objectLength: function(obj){ var count=0, i; for(i in obj){ count++; } return count; }, hideErrors: function(){ this.hideThese(this.toHide); }, hideThese: function(errors){ errors.not(this.containers).text(""); this.addWrapper(errors).hide(); }, ow_vote_valid: function(){ return this.size()===0; }, size: function(){ return this.errorList.length; }, focusInvalid: function(){ if(this.settings.focusInvalid){ try { $(this.findLastActive()||this.errorList.length&&this.errorList[ 0 ].element||[]) .filter(":visible") .focus() .trigger("focusin"); } catch(e){ }} }, findLastActive: function(){ var lastActive=this.lastActive; return lastActive&&$.grep(this.errorList, function(n){ return n.element.name===lastActive.name; }).length===1&&lastActive; }, elements: function(){ var vote_validator=this, ow_vote_rulesCache={}; return $(this.currentForm) .find("input, select, textarea") .not(":submit, :reset, :image, [disabled], [readonly]") .not(this.settings.ignore) .filter(function(){ if(!this.name&&vote_validator.settings.debug&&window.console){ console.error("%o has no name assigned", this); } if(this.name in ow_vote_rulesCache||!vote_validator.objectLength($(this).ow_vote_rules())){ return false; } ow_vote_rulesCache[ this.name ]=true; return true; }); }, clean: function(selector){ return $(selector)[ 0 ]; }, errors: function(){ var errorClass=this.settings.errorClass.split(" ").join("."); return $(this.settings.errorElement + "." + errorClass, this.errorContext); }, reset: function(){ this.successList=[]; this.errorList=[]; this.errorMap={}; this.toShow=$([]); this.toHide=$([]); this.currentElements=$([]); }, prepareForm: function(){ this.reset(); this.toHide=this.errors().add(this.containers); }, prepareElement: function(element){ this.reset(); this.toHide=this.errorsFor(element); }, elementValue: function(element){ var val, $element=$(element), type=element.type; if(type==="radio"||type==="checkbox"){ return $("input[name='" + element.name + "']:checked").val(); }else if(type==="number"&&typeof element.validity!=="undefined"){ return element.validity.badInput ? false:$element.val(); } val=$element.val(); if(typeof val==="string"){ return val.replace(/\r/g, ""); } return val; }, check: function(element){ element=this.validationTargetFor(this.clean(element)); var ow_vote_rules=$(element).ow_vote_rules(), ow_vote_rulesCount=$.map(ow_vote_rules, function(n, i){ return i; }).length, dependencyMismatch=false, val=this.elementValue(element), result, method, rule; for(method in ow_vote_rules){ rule={ method: method, parameters: ow_vote_rules[ method ] }; try { result=$.vote_validator.methods[ method ].call(this, val, element, rule.parameters); if(result==="dependency-mismatch"&&ow_vote_rulesCount===1){ dependencyMismatch=true; continue; } dependencyMismatch=false; if(result==="pending"){ this.toHide=this.toHide.not(this.errorsFor(element)); return; } if(!result){ this.formatAndAdd(element, rule); return false; }} catch(e){ if(this.settings.debug&&window.console){ console.log("Exception occurred when checking element " + element.id + ", check the '" + rule.method + "' method.", e); } throw e; }} if(dependencyMismatch){ return; } if(this.objectLength(ow_vote_rules)){ this.successList.push(element); } return true; }, customDataMessage: function(element, method){ return $(element).data("msg" + method.charAt(0).toUpperCase() + method.substring(1).toLowerCase())||$(element).data("msg"); }, customMessage: function(name, method){ var m=this.settings.ow_vote_messages[ name ]; return m&&(m.constructor===String ? m:m[ method ]); }, findDefined: function(){ for(var i=0; i < arguments.length; i++){ if(arguments[ i ]!==undefined){ return arguments[ i ]; }} return undefined; }, defaultMessage: function(element, method){ return this.findDefined(this.customMessage(element.name, method), this.customDataMessage(element, method), !this.settings.ignoreTitle&&element.title||undefined, $.vote_validator.ow_vote_messages[ method ], "Warning: No message defined for " + element.name + "" ); }, formatAndAdd: function(element, rule){ var message=this.defaultMessage(element, rule.method), theregex=/\$?\{(\d+)\}/g; if(typeof message==="function"){ message=message.call(this, rule.parameters, element); }else if(theregex.test(message)){ message=$.vote_validator.format(message.replace(theregex, "{$1}"), rule.parameters); } this.errorList.push({ message: message, element: element, method: rule.method }); this.errorMap[ element.name ]=message; this.submitted[ element.name ]=message; }, addWrapper: function(toToggle){ if(this.settings.wrapper){ toToggle=toToggle.add(toToggle.parent(this.settings.wrapper)); } return toToggle; }, defaultShowErrors: function(){ var i, elements, error; for(i=0; this.errorList[ i ]; i++){ error=this.errorList[ i ]; if(this.settings.highlight){ this.settings.highlight.call(this, error.element, this.settings.errorClass, this.settings.validClass); } this.showLabel(error.element, error.message); } if(this.errorList.length){ this.toShow=this.toShow.add(this.containers); } if(this.settings.success){ for(i=0; this.successList[ i ]; i++){ this.showLabel(this.successList[ i ]); }} if(this.settings.unhighlight){ for(i=0, elements=this.validElements(); elements[ i ]; i++){ this.settings.unhighlight.call(this, elements[ i ], this.settings.errorClass, this.settings.validClass); }} this.toHide=this.toHide.not(this.toShow); this.hideErrors(); this.addWrapper(this.toShow).show(); }, validElements: function(){ return this.currentElements.not(this.invalidElements()); }, invalidElements: function(){ return $(this.errorList).map(function(){ return this.element; }); }, showLabel: function(element, message){ var place, group, errorID, error=this.errorsFor(element), elementID=this.idOrName(element), describedBy=$(element).attr("aria-describedby"); if(error.length){ error.removeClass(this.settings.validClass).addClass(this.settings.errorClass); error.html(message); }else{ error=$("<" + this.settings.errorElement + ">") .attr("id", elementID + "-error") .addClass(this.settings.errorClass) .html(message||""); place=error; if(this.settings.wrapper){ place=error.hide().show().wrap("<" + this.settings.wrapper + "/>").parent(); } if(this.labelContainer.length){ this.labelContainer.append(place); }else if(this.settings.errorPlacement){ this.settings.errorPlacement(place, $(element)); }else{ place.insertAfter(element); } if(error.is("label")){ error.attr("for", elementID); }else if(error.parents("label[for='" + elementID + "']").length===0){ errorID=error.attr("id").replace(/(:|\.|\[|\])/g, "\\$1"); if(!describedBy){ describedBy=errorID; }else if(!describedBy.match(new RegExp("\\b" + errorID + "\\b"))){ describedBy +=" " + errorID; } $(element).attr("aria-describedby", describedBy); group=this.groups[ element.name ]; if(group){ $.each(this.groups, function(name, testgroup){ if(testgroup===group){ $("[name='" + name + "']", this.currentForm) .attr("aria-describedby", error.attr("id")); }}); }} } if(!message&&this.settings.success){ error.text(""); if(typeof this.settings.success==="string"){ error.addClass(this.settings.success); }else{ this.settings.success(error, element); }} this.toShow=this.toShow.add(error); }, errorsFor: function(element){ var name=this.idOrName(element), describer=$(element).attr("aria-describedby"), selector="label[for='" + name + "'], label[for='" + name + "'] *"; if(describer){ selector=selector + ", #" + describer.replace(/\s+/g, ", #"); } return this .errors() .filter(selector); }, idOrName: function(element){ return this.groups[ element.name ]||(this.checkable(element) ? element.name:element.id||element.name); }, validationTargetFor: function(element){ if(this.checkable(element)){ element=this.findByName(element.name); } return $(element).not(this.settings.ignore)[ 0 ]; }, checkable: function(element){ return(/radio|checkbox/i).test(element.type); }, findByName: function(name){ return $(this.currentForm).find("[name='" + name + "']"); }, getLength: function(value, element){ switch(element.nodeName.toLowerCase()){ case "select": return $("option:selected", element).length; case "input": if(this.checkable(element)){ return this.findByName(element.name).filter(":checked").length; }} return value.length; }, depend: function(param, element){ return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element):true; }, dependTypes: { "boolean": function(param){ return param; }, "string": function(param, element){ return !!$(param, element.form).length; }, "function": function(param, element){ return param(element); }}, optional: function(element){ var val=this.elementValue(element); return !$.vote_validator.methods.required.call(this, val, element)&&"dependency-mismatch"; }, startRequest: function(element){ if(!this.pending[ element.name ]){ this.pendingRequest++; this.pending[ element.name ]=true; }}, stopRequest: function(element, ow_vote_valid){ this.pendingRequest--; if(this.pendingRequest < 0){ this.pendingRequest=0; } delete this.pending[ element.name ]; if(ow_vote_valid&&this.pendingRequest===0&&this.formSubmitted&&this.form()){ $(this.currentForm).submit(); this.formSubmitted=false; }else if(!ow_vote_valid&&this.pendingRequest===0&&this.formSubmitted){ $(this.currentForm).triggerHandler("invalid-form", [ this ]); this.formSubmitted=false; }}, previousValue: function(element){ return $.data(element, "previousValue")||$.data(element, "previousValue", { old: null, ow_vote_valid: true, message: this.defaultMessage(element, "remote") }); }}, classRuleSettings: { required: { required: true }, email: { email: true }, url: { url: true }, date: { date: true }, dateISO: { dateISO: true }, number: { number: true }, digits: { digits: true }, creditcard: { creditcard: true }}, addClassRules: function(className, ow_vote_rules){ if(className.constructor===String){ this.classRuleSettings[ className ]=ow_vote_rules; }else{ $.extend(this.classRuleSettings, className); }}, classRules: function(element){ var ow_vote_rules={}, classes=$(element).attr("class"); if(classes){ $.each(classes.split(" "), function(){ if(this in $.vote_validator.classRuleSettings){ $.extend(ow_vote_rules, $.vote_validator.classRuleSettings[ this ]); }}); } return ow_vote_rules; }, attributeRules: function(element){ var ow_vote_rules={}, $element=$(element), type=element.getAttribute("type"), method, value; for(method in $.vote_validator.methods){ if(method==="required"){ value=element.getAttribute(method); if(value===""){ value=true; } value = !!value; }else{ value=$element.attr(method); } if(/min|max/.test(method)&&(type===null||/number|range|text/.test(type))){ value=Number(value); } if(value||value===0){ ow_vote_rules[ method ]=value; }else if(type===method&&type!=="range"){ ow_vote_rules[ method ]=true; }} if(ow_vote_rules.maxlength&&/-1|2147483647|524288/.test(ow_vote_rules.maxlength)){ delete ow_vote_rules.maxlength; } return ow_vote_rules; }, dataRules: function(element){ var method, value, ow_vote_rules={}, $element=$(element); for(method in $.vote_validator.methods){ value=$element.data("rule" + method.charAt(0).toUpperCase() + method.substring(1).toLowerCase()); if(value!==undefined){ ow_vote_rules[ method ]=value; }} return ow_vote_rules; }, staticRules: function(element){ var ow_vote_rules={}, vote_validator=$.data(element.form, "vote_validator"); if(vote_validator.settings.ow_vote_rules){ ow_vote_rules=$.vote_validator.normalizeRule(vote_validator.settings.ow_vote_rules[ element.name ])||{};} return ow_vote_rules; }, normalizeRules: function(ow_vote_rules, element){ $.each(ow_vote_rules, function(prop, val){ if(val===false){ delete ow_vote_rules[ prop ]; return; } if(val.param||val.depends){ var keepRule=true; switch(typeof val.depends){ case "string": keepRule = !!$(val.depends, element.form).length; break; case "function": keepRule=val.depends.call(element, element); break; } if(keepRule){ ow_vote_rules[ prop ]=val.param!==undefined ? val.param:true; }else{ delete ow_vote_rules[ prop ]; }} }); $.each(ow_vote_rules, function(rule, parameter){ ow_vote_rules[ rule ]=$.isFunction(parameter) ? parameter(element):parameter; }); $.each([ "minlength", "maxlength" ], function(){ if(ow_vote_rules[ this ]){ ow_vote_rules[ this ]=Number(ow_vote_rules[ this ]); }}); $.each([ "rangelength", "range" ], function(){ var parts; if(ow_vote_rules[ this ]){ if($.isArray(ow_vote_rules[ this ])){ ow_vote_rules[ this ]=[ Number(ow_vote_rules[ this ][ 0 ]), Number(ow_vote_rules[ this ][ 1 ]) ]; }else if(typeof ow_vote_rules[ this ]==="string"){ parts=ow_vote_rules[ this ].replace(/[\[\]]/g, "").split(/[\s,]+/); ow_vote_rules[ this ]=[ Number(parts[ 0 ]), Number(parts[ 1 ]) ]; }} }); if($.vote_validator.autoCreateRanges){ if(ow_vote_rules.min!=null&&ow_vote_rules.max!=null){ ow_vote_rules.range=[ ow_vote_rules.min, ow_vote_rules.max ]; delete ow_vote_rules.min; delete ow_vote_rules.max; } if(ow_vote_rules.minlength!=null&&ow_vote_rules.maxlength!=null){ ow_vote_rules.rangelength=[ ow_vote_rules.minlength, ow_vote_rules.maxlength ]; delete ow_vote_rules.minlength; delete ow_vote_rules.maxlength; }} return ow_vote_rules; }, normalizeRule: function(data){ if(typeof data==="string"){ var transformed={}; $.each(data.split(/\s/), function(){ transformed[ this ]=true; }); data=transformed; } return data; }, addMethod: function(name, method, message){ $.vote_validator.methods[ name ]=method; $.vote_validator.ow_vote_messages[ name ]=message!==undefined ? message:$.vote_validator.ow_vote_messages[ name ]; if(method.length < 3){ $.vote_validator.addClassRules(name, $.vote_validator.normalizeRule(name)); }}, methods: { required: function(value, element, param){ if(!this.depend(param, element)){ return "dependency-mismatch"; } if(element.nodeName.toLowerCase()==="select"){ var val=$(element).val(); return val&&val.length > 0; } if(this.checkable(element)){ return this.getLength(value, element) > 0; } return $.trim(value).length > 0; }, email: function(value, element){ return this.optional(element)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value); }, url: function(value, element){ return this.optional(element)||/^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(value); }, date: function(value, element){ return this.optional(element)||!/Invalid|NaN/.test(new Date(value).toString()); }, dateISO: function(value, element){ return this.optional(element)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value); }, number: function(value, element){ return this.optional(element)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value); }, digits: function(value, element){ return this.optional(element)||/^\d+$/.test(value); }, creditcard: function(value, element){ if(this.optional(element)){ return "dependency-mismatch"; } if(/[^0-9 \-]+/.test(value)){ return false; } var nCheck=0, nDigit=0, bEven=false, n, cDigit; value=value.replace(/\D/g, ""); if(value.length < 13||value.length > 19){ return false; } for(n=value.length - 1; n >=0; n--){ cDigit=value.charAt(n); nDigit=parseInt(cDigit, 10); if(bEven){ if(( nDigit *=2) > 9){ nDigit -=9; }} nCheck +=nDigit; bEven = !bEven; } return(nCheck % 10)===0; }, minlength: function(value, element, param){ var length=$.isArray(value) ? value.length:this.getLength(value, element); return this.optional(element)||length >=param; }, maxlength: function(value, element, param){ var length=$.isArray(value) ? value.length:this.getLength(value, element); return this.optional(element)||length <=param; }, rangelength: function(value, element, param){ var length=$.isArray(value) ? value.length:this.getLength(value, element); return this.optional(element)||(length >=param[ 0 ]&&length <=param[ 1 ]); }, min: function(value, element, param){ return this.optional(element)||value >=param; }, max: function(value, element, param){ return this.optional(element)||value <=param; }, range: function(value, element, param){ return this.optional(element)||(value >=param[ 0 ]&&value <=param[ 1 ]); }, equalTo: function(value, element, param){ var target=$(param); if(this.settings.onfocusout){ target.unbind(".ow_vote_validate-equalTo").bind("blur.ow_vote_validate-equalTo", function(){ $(element).ow_vote_valid(); }); } return value===target.val(); }, remote: function(value, element, param){ if(this.optional(element)){ return "dependency-mismatch"; } var previous=this.previousValue(element), vote_validator, data; if(!this.settings.ow_vote_messages[ element.name ]){ this.settings.ow_vote_messages[ element.name ]={};} previous.originalMessage=this.settings.ow_vote_messages[ element.name ].remote; this.settings.ow_vote_messages[ element.name ].remote=previous.message; param=typeof param==="string"&&{ url: param }||param; if(previous.old===value){ return previous.ow_vote_valid; } previous.old=value; vote_validator=this; this.startRequest(element); data={}; data[ element.name ]=value; $.ajax($.extend(true, { url: param, mode: "abort", port: "ow_vote_validate" + element.name, dataType: "json", data: data, context: vote_validator.currentForm, success: function(response){ var ow_vote_valid=response===true||response==="true", errors, message, submitted; vote_validator.settings.ow_vote_messages[ element.name ].remote=previous.originalMessage; if(ow_vote_valid){ submitted=vote_validator.formSubmitted; vote_validator.prepareElement(element); vote_validator.formSubmitted=submitted; vote_validator.successList.push(element); delete vote_validator.invalid[ element.name ]; vote_validator.showErrors(); }else{ errors={}; message=response||vote_validator.defaultMessage(element, "remote"); errors[ element.name ]=previous.message=$.isFunction(message) ? message(value):message; vote_validator.invalid[ element.name ]=true; vote_validator.showErrors(errors); } previous.ow_vote_valid=ow_vote_valid; vote_validator.stopRequest(element, ow_vote_valid); }}, param)); return "pending"; }} }); $.format=function deprecated(){ throw "$.format has been deprecated. Please use $.vote_validator.format instead."; }; var pendingRequests={}, ajax; if($.ajaxPrefilter){ $.ajaxPrefilter(function(settings, _, xhr){ var port=settings.port; if(settings.mode==="abort"){ if(pendingRequests[port]){ pendingRequests[port].abort(); } pendingRequests[port]=xhr; }}); }else{ ajax=$.ajax; $.ajax=function(settings){ var mode=("mode" in settings ? settings:$.ajaxSettings).mode, port=("port" in settings ? settings:$.ajaxSettings).port; if(mode==="abort"){ if(pendingRequests[port]){ pendingRequests[port].abort(); } pendingRequests[port]=ajax.apply(this, arguments); return pendingRequests[port]; } return ajax.apply(this, arguments); };} $.extend($.fn, { ow_vote_validateDelegate: function(delegate, type, handler){ return this.bind(type, function(event){ var target=$(event.target); if(target.is(delegate)){ return handler.apply(target, arguments); }}); }}); })); (function ($){ "use strict"; var is_supported_browser = !!window.File, fileSizeToBytes, formatter=$.vote_validator.format; fileSizeToBytes=(function (){ var units=["B", "KB", "MB", "GB", "TB"]; return function (size, unit){ var index_of_unit=units.indexOf(unit), coverted_size; if(index_of_unit===-1){ coverted_size=false; }else{ while (index_of_unit > 0){ size *=1024; index_of_unit -=1; } coverted_size=size; } return coverted_size; };}()); $.vote_validator.addMethod("fileType", function (value, element, params){ var files, types=params.types||["text"], is_valid=false; if(!is_supported_browser||this.optional(element)){ is_valid=true; }else{ files=element.files; if(files.length < 1){ is_valid=false; }else{ $.each(types, function (key, value){ is_valid=is_valid||files[0].type.indexOf(value)!==-1; }); }} return is_valid; }, function (params, element){ return formatter( "File must be one of the following types: {0}.", params.types.join(",") ); } ); $.vote_validator.addMethod("minFileSize", function (value, element, params){ var files, unit=params.unit||"KB", size=params.size||100, min_file_size=fileSizeToBytes(size, unit), is_valid=false; if(!is_supported_browser||this.optional(element)){ is_valid=true; }else{ files=element.files; if(files.length < 1){ is_valid=false; }else{ is_valid=files[0].size >=min_file_size; }} return is_valid; }, function (params, element){ return formatter( "File must be at least {0}{1} large.", [params.size||100, params.unit||"KB"] ); } ); $.vote_validator.addMethod("maxFileSize", function (value, element, params){ var files, unit=params.unit||"KB", size=params.size||100, max_file_size=fileSizeToBytes(size, unit), is_valid=false; if(!is_supported_browser||this.optional(element)){ is_valid=true; }else{ files=element.files; if(files.length < 1){ is_valid=false; }else{ is_valid=files[0].size <=max_file_size; }} return is_valid; }, function (params, element){ return formatter( "File cannot be larger than {0}{1}.", [params.size||100, params.unit||"KB"] ); } ); }(jQuery)); jQuery(document).ready(function(){ var vote_fb_appid=jQuery('#vote_fb_appid').val(); if(vote_fb_appid!=null){ window.fbAsyncInit=function(){ FB.init({ appId:vote_fb_appid, status:true, cookie:false, xfbml:true, version:'v2.5', oauth:true, }); }; (function(d, s, id){ var js, fjs=d.getElementsByTagName(s)[0]; if(d.getElementById(id)) return; js=d.createElement(s); js.id=id; js.src="//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); } var vote_fb_image=jQuery('#vote_fb_image').val(); jQuery('.ow_voting_facebook_login').append(''); jQuery('.FB_login_button').find('img').attr('src', vote_fb_image); jQuery('#wp-admin-bar-logout').on('click', function (){ jQuery('body').append(''); }); }); function statusChangeCallback(response,flag){ if(flag==1){ FB.api('/me', {fields: 'name,email'}, function(response){ jQuery.ajax({ type: 'POST', url: vote_path_local.votesajaxurl, data: { action:'ow_facebook_login', responses: response, email: response.email, }, success: function(response, textStatus, XMLHttpRequest){ jQuery.ow_vote_fancybox('

    Your account has been created and you will be now logged in

    ', { 'width':300, 'height':150, 'maxWidth': 300, 'maxHeight': 150, 'minWidth': 200, 'minHeight': 80 } ); setTimeout(function(){ location.reload(); }, 2000); }, error: function(MLHttpRequest, textStatus, errorThrown){ alert(errorThrown); }}); }); }} function fb_login(){ FB.login(function(response){ if(response.authResponse){ console.log('Welcome! Fetching your information.... '); access_token=response.authResponse.accessToken; user_id=response.authResponse.userID; FB.api('/me', {fields: 'name,email'}, function(response){ console.log(response); jQuery.ajax({ type: 'POST', url: vote_path_local.votesajaxurl, data: { action:'ow_facebook_login', responses: response, email: response.email, }, success: function(response, textStatus, XMLHttpRequest){ jQuery.ow_vote_fancybox('

    Your account has been created and you will be now logged in

    ', { 'width':300, 'height':150, 'maxWidth': 300, 'maxHeight': 150, 'minWidth': 200, 'minHeight': 80 } ); setTimeout(function(){ location.reload(); }, 2000); }, error: function(MLHttpRequest, textStatus, errorThrown){ alert(errorThrown); }}); }); }else{ console.log('User cancelled login or did not fully authorize.'); }}, { scope: 'publish_actions,email' }); } function checkLoginState(){ FB.getLoginStatus(function(response){ if(response.status==='connected'||response.status==='not_authorized'){ statusChangeCallback(response,1); }else{ FB.login(function(response){ if(response.authResponse){ statusChangeCallback(response,1); }}); }}); } function voting_save_twemail_session(){ jQuery.ow_vote_prettyPhoto.close(); jQuery(".error_empty").remove(); setTimeout(function(){ jQuery.fn.ow_vote_prettyPhoto({social_tools: false, deeplinking: false, show_title: false, default_width: '350', theme:'pp_kalypso'}); jQuery.ow_vote_prettyPhoto.open('#twitter_register_panel'); jQuery('.ow_tabs_register_content').show(); jQuery('.forgot-panel').show(); }, 300); jQuery(".inner-container").addClass('forgot-panel_add'); } var ow_myWindow; var timer=setInterval(checktwitter_auth, 1000); function votes_twitter_authentication(){ jQuery.ajax({ type: 'POST', url: vote_path_local.votesajaxurl, data: { action:'ow_twitter_login', vote_tw_appid: jQuery('#vote_tw_appid').val(), vote_tw_secret: jQuery('#vote_tw_secret').val(), current_callback_url:jQuery('#current_callback_url').val(), }, success: function(response, textStatus, XMLHttpRequest){ if(response==1){ alert('Error connecting to Twitter! Try again later!'); }else{ ow_myWindow=window.open(response,null,"height=200,width=400,status=yes,toolbar=no,menubar=no,location=no"); }}, error: function(MLHttpRequest, textStatus, errorThrown){ alert(errorThrown); }}); } function checktwitter_auth(){ try { var url_opened=ow_myWindow.location.href; if(url_opened.indexOf('oauth_verifier')!=-1){ clearInterval(timer); ow_myWindow.close(); window.location.href=url_opened; }} catch (e){ }} var getCookies=function(){ var pairs=document.cookie.split(";"); var cookies={}; for (var i=0; iYour account has been created and you will be now logged in', { 'width':300, 'height':150, 'maxWidth': 300, 'maxHeight': 150, 'minWidth': 200, 'minHeight': 80 } ); setTimeout(function(){ location.reload(); }, 2000); }, error: function(MLHttpRequest, textStatus, errorThrown){ alert(errorThrown); }}); } var googleUser={}; var startApp=function(){ gapi.load('auth2', function(){ auth2=gapi.auth2.init({ client_id: document.getElementById('vote_gg_clientid').value, cookiepolicy: 'single_host_origin', }); attachSignin(document.getElementById('customBtn')); }); }; function attachSignin(element){ auth2.attachClickHandler(element, {}, function(googleUser){ onSignIn(googleUser); }, function(error){ alert(JSON.stringify(error, undefined, 2)); }); }; (function($){ $.fn.ow_vote_countDown=function (options){ config={}; $.extend(config, options); diffSecs=this.setCountDown(config); if(config.onComplete){ $.data($(this)[0], 'callback', config.onComplete); } if(config.omitWeeks){ $.data($(this)[0], 'omitWeeks', config.omitWeeks); } $('#' + $(this).attr('id') + ' .digit').html('
    '); $(this).votingdoCountDown($(this).attr('id'), diffSecs, 500); return this; }; $.fn.stopCountDown=function (){ clearTimeout($.data(this[0], 'timer')); }; $.fn.startCountDown=function (){ this.votingdoCountDown($(this).attr('id'),$.data(this[0], 'diffSecs'), 500); }; $.fn.setCountDown=function (options){ var targetTime=new Date(); if(options.targetDate){ targetTime=new Date(options.targetDate.month + '/' + options.targetDate.day + '/' + options.targetDate.year + ' ' + options.targetDate.hour + ':' + options.targetDate.min + ':' + options.targetDate.sec + (options.targetDate.utc ? ' UTC':'')); } else if(options.targetOffset){ targetTime.setFullYear(options.targetOffset.year + targetTime.getFullYear()); targetTime.setMonth(options.targetOffset.month + targetTime.getMonth()); targetTime.setDate(options.targetOffset.day + targetTime.getDate()); targetTime.setHours(options.targetOffset.hour + targetTime.getHours()); targetTime.setMinutes(options.targetOffset.min + targetTime.getMinutes()); targetTime.setSeconds(options.targetOffset.sec + targetTime.getSeconds()); } var nowTime=new Date(); if(options.currentDate){ var nowTime=new Date(options.currentDate.month + '/' + options.currentDate.day + '/' + options.currentDate.year + ' ' + options.currentDate.hour + ':' + options.currentDate.min + ':' + options.currentDate.sec + (options.currentDate.utc ? ' UTC':'')); }else if(options.currentOffset){ nowTime.setFullYear(options.currentOffset.year + nowTime.getFullYear()); nowTime.setMonth(options.currentOffset.month + nowTime.getMonth()); nowTime.setDate(options.currentOffset.day + nowTime.getDate()); nowTime.setHours(options.currentOffset.hour + nowTime.getHours()); nowTime.setMinutes(options.currentOffset.min + nowTime.getMinutes()); nowTime.setSeconds(options.currentOffset.sec + nowTime.getSeconds()); } diffSecs=Math.floor((targetTime.valueOf()-nowTime.valueOf())/1000); $.data(this[0], 'diffSecs', diffSecs); return diffSecs; }; $.fn.votingdoCountDown=function (id, diffSecs, duration){ $this=$('#' + id); if(diffSecs <=0){ diffSecs=0; if($.data($this[0], 'timer')){ clearTimeout($.data($this[0], 'timer')); }} secs=diffSecs % 60; mins=Math.floor(diffSecs/60)%60; hours=Math.floor(diffSecs/60/60)%24; if($.data($this[0], 'omitWeeks')==true){ days=Math.floor(diffSecs/60/60/24); weeks=Math.floor(diffSecs/60/60/24/7); }else{ days=Math.floor(diffSecs/60/60/24)%7; weeks=Math.floor(diffSecs/60/60/24/7); } $this.votingdashChangeTo(id, 'seconds_dash', secs, duration ? duration:800); $this.votingdashChangeTo(id, 'minutes_dash', mins, duration ? duration:1200); $this.votingdashChangeTo(id, 'hours_dash', hours, duration ? duration:1200); $this.votingdashChangeTo(id, 'days_dash', days, duration ? duration:1200); $this.votingdashChangeTo(id, 'weeks_dash', weeks, duration ? duration:1200); $.data($this[0], 'diffSecs', diffSecs); if(diffSecs > 0){ e=$this; t=setTimeout(function(){ e.votingdoCountDown(id, diffSecs-1) } , 1000); $.data(e[0], 'timer', t); } else if(cb=$.data($this[0], 'callback')){ $.data($this[0], 'callback')(); }}; $.fn.votingdashChangeTo=function(id, dash, n, duration){ $this=$('#' + id); for (var i=($this.find('.' + dash + ' .digit').length-1); i>=0; i--){ var d=n%10; n=(n - d) / 10; $this.digitChangeTo('#' + $this.attr('id') + ' .' + dash + ' .digit:eq('+i+')', d, duration); }}; $.fn.digitChangeTo=function (digit, n, duration){ if(!duration){ duration=800; } if($(digit + ' div.top').html()!=n + ''){ $(digit + ' div.top').css({'display': 'none'}); $(digit + ' div.top').html((n ? n:'0')).slideDown(duration); $(digit + ' div.bottom').animate({'height': ''}, duration, function(){ $(digit + ' div.bottom').html($(digit + ' div.top').html()); $(digit + ' div.bottom').css({'display': 'block', 'height': ''}); $(digit + ' div.top').hide().slideUp(10); }); }};})(jQuery); jQuery(document).ready(function(){ ow_votes_list_page_show_contest(); votes_countdown('.ow_countdown_dashboard'); ow_vote_sorting_filter(); ow_vote_show_contest_grid_function(); ow_vote_show_contest_list_function(); ow_vote_pagination_click_function(); ow_vote_pagination_change_function(); ow_vote_add_contestant_function(); ow_vote_submit_user_form(); ow_pretty_photo_gallery(); ow_vote_click_function(); ow_voting_load_more(); ow_voting_load_more_all(); ow_single_contestant_function(); ow_single_contestant_pretty(); owvideojs_initialize(); ow_success_message(); ow_terms_show(); function ow_terms_show(){ jQuery(document).on('click','.ow_terms',function(){ var cat_id=jQuery(this).data('id'); jQuery('#ow_terms_val_'+cat_id).toggle('250'); jQuery('#ow_hide_terms'+cat_id).show(); }); jQuery(document).on('click','.ow_hide_terms',function(){ var cat_id=jQuery(this).data('id'); jQuery('#ow_terms_val_'+cat_id).toggle('250'); jQuery('#ow_terms_'+cat_id).show(); }); } function copyToClipboard(elem){ var targetId="_hiddenCopyText_"; var isInput=elem.tagName==="INPUT"||elem.tagName==="TEXTAREA"; var origSelectionStart, origSelectionEnd; if(isInput){ target=elem; origSelectionStart=elem.selectionStart; origSelectionEnd=elem.selectionEnd; }else{ target=document.getElementById(targetId); if(!target){ var target=document.createElement("textarea"); target.style.position="absolute"; target.style.left="-9999px"; target.style.top="0"; target.id=targetId; document.body.appendChild(target); } target.textContent=elem.textContent; } var currentFocus=document.activeElement; target.focus(); target.setSelectionRange(0, target.value.length); var succeed; try { succeed=document.execCommand ("copy"); } catch(e){ succeed=false; } if(currentFocus&&typeof currentFocus.focus==="function"){ currentFocus.focus(); } if(isInput){ elem.setSelectionRange(origSelectionStart, origSelectionEnd); }else{ target.textContent=""; } return succeed; } var copiedurl=document.getElementById("ow_vote_share_url_copy"); if(copiedurl){ document.getElementById("ow_vote_share_url_copy").addEventListener("focus", function(){ copyToClipboard(document.getElementById("ow_vote_share_url_copy")); jQuery("#ow_vote_share_url_copy").select(); jQuery(".copied_message span").slideDown("slow"); setTimeout(function(){ jQuery(".copied_message span").slideUp("slow"); }, 3000); }); } var options={ url: vote_path_local.votesajaxurl + "?action=ow_render_search", getValue: "label", template: { type: "links", fields: { link: "link", iconSrc: "icon", }}, requestDelay: 500, list: { match: { enabled: true }, showAnimation: { type: "fade", time: 400, callback: function(){}}, hideAnimation: { type: "slide", time: 400, callback: function(){}} }}; jQuery(document).on('click','.single_contestant_pretty_video',function (e){ e.preventDefault(); var cont_id=jQuery(this).attr('data-vote-id'); var vote_type=jQuery(this).attr('data-vote-type'); var con_title=jQuery(this).attr('data-pretty-title'); jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'ow_display_video', pid:cont_id, vote_type:vote_type }, type: 'POST', success: function(result){ jQuery('.ow_single_video_music').html(result); jQuery('.ow_single_video_music .resp-video-center').prepend(''+vote_translation.close+''); jQuery('.ow_single_video_music').show(); jQuery('.ow_single_video_music .resp-video-center').append('

    '+con_title+'

    '); owvideojs_initialize(); }}); }); jQuery(document).on('click','.ow_video_music_close,.ow_single_video_music',function (e){ e.preventDefault(); if(e.target!==this) return; jQuery('.ow_single_video_music').html(""); jQuery('.ow_single_video_music').hide(); }); jQuery(document).on('submit','#ow_contestants_search',function(e){ e.preventDefault(); var contest_id=jQuery('#ow_search_input').val(); var insert_param=ow_insertParam('ow_search',contest_id); var url=document.URL; var shortUrl=url.substring(0,url.lastIndexOf("/page/")); window.location.href=shortUrl + '?' + insert_param; }); jQuery(document).on('change','#ow_tax_select',function(e){ var contest_id=jQuery(this).val(); var insert_param=ow_insertParam('ow_cont',contest_id); var url=document.URL; var shortUrl=url.substring(0,url.lastIndexOf("/page/")); window.location.href=shortUrl + '?' + insert_param; }); jQuery(document).on('change','#ow_sort_select',function(e){ var ow_sort=jQuery(this).val(); if(ow_sort!=='Sort'){ var insert_param=ow_insertParam('ow_sort',ow_sort); var url=document.URL; var shortUrl=url.substring(0,url.lastIndexOf("/page/")); window.location.href=shortUrl + '?' + insert_param; }}); function ow_insertParam(key, value){ key=encodeURI(key); value=encodeURI(value); var kvp=document.location.search.substr(1).split('&'); var i=kvp.length; var x; while(i--){ x=kvp[i].split('='); if(x[0]==key){ x[1]=value; kvp[i]=x.join('='); break; }} if(i<0){kvp[kvp.length]=[key,value].join('=');} return kvp.join('&'); } function ow_preview_img(input){ if(input.files&&input.files[0]){ var reader=new FileReader(); reader.onload=function (e){ jQuery('#uploaded_img').attr('src', e.target.result); jQuery('#uploaded_img').show(); } reader.readAsDataURL(input.files[0]); }} jQuery(document).on('change','#ow_select_term',function(e){ var current_textarea=jQuery("textarea[name*='contestant-desc']");; var available_textarea=jQuery(current_textarea).attr('name'); var contest_id=jQuery(this).val(); jQuery('#contest-id').val(contest_id); jQuery('#contestantform').val(contest_id); jQuery('#contestantform').attr('name', 'contestantform' + contest_id); jQuery('#'+available_textarea).attr('name', 'contestant-desc' + contest_id); var cat_term=jQuery('option:selected', this).attr('data-val'); if(cat_term=="photo"){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_getterm', term_id:contest_id, }, type: 'POST', cache: false, success: function (resp){ var img_data=JSON.parse(resp); var custom_divs=img_data.custom_fields; jQuery('.custom_fields_cat_addcontest').html(''); jQuery('.custom_fields_cat_addcontest').html(custom_divs); jQuery('.date_picker').on('click', function (){ jQuery(this).owvotedatetimepicker('destroy').owvotedatetimepicker({format:'m-d-Y', step:10, timepicker: false,}).focus(); }); }}); }else{ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_getterm', term_id:contest_id, }, type: 'POST', cache: false, success: function (resp){ var img_data=JSON.parse(resp); var custom_divs=img_data.custom_fields; jQuery('.custom_fields_cat_addcontest').html(''); jQuery('.custom_fields_cat_addcontest').html(custom_divs); jQuery('.date_picker').on('click', function (){ jQuery(this).owvotedatetimepicker('destroy').owvotedatetimepicker({format:'m-d-Y', step:10, timepicker: false,}).focus(); }); if(img_data.imgenable=="on"){ jQuery('#ow_img_id').show(); if(img_data.imgrequired=="on"){ jQuery('.img_required_span').show(); add_contestant_validation_method("contestant-image",vote_translation.upload_message); jQuery("#contestant-image").change(function(){ ow_preview_img(this); }); }else{ jQuery('.img_required_span').hide(); }}else{ jQuery('#ow_img_id').hide(); }}, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }}); jQuery(document).on('click','.ow_tog',function(e){ e.preventDefault(); if(jQuery(".ow_vote_show_contestants .ow_vote_menu_links").is(':hidden')){ jQuery(".ow_vote_show_contestants .ow_vote_menu_links").attr("style", "display: block !important"); jQuery(".ow_tog a.togglehide span.ow_vote_icons").addClass('menu_open'); }else{ jQuery(".ow_vote_show_contestants .ow_vote_menu_links").attr("style", "display: none !important"); jQuery(".ow_vote_show_contestants .ow_tog a.togglehide span.ow_vote_icons").removeClass('menu_open'); } if(jQuery(".ow_vote_single_section .ow_vote_menu_links").is(':hidden')){ jQuery(".ow_vote_single_section .ow_vote_menu_links").attr("style", "display: block !important"); jQuery(".ow_tog a.togglehide span.ow_vote_icons").addClass('menu_open'); }else{ jQuery(".ow_vote_single_section .ow_vote_menu_links").attr("style", "display: none !important"); jQuery(".ow_vote_single_section .ow_tog a.togglehide span.ow_vote_icons").removeClass('menu_open'); }}); jQuery(document).on('click','.ow_tabs_register',function (e){ jQuery('.ow_tabs_login_content').hide(); jQuery('.ow_tabs_register_content').show(); jQuery('.forgot-panel').hide(); jQuery(".inner-container").removeClass('login-panel_add'); jQuery(".inner-container").removeClass('register-panel_add'); jQuery(".inner-container").removeClass('forgot-panel_add'); jQuery(".inner-container").addClass('register-panel_add'); jQuery(this).addClass('active'); jQuery('.ow_tabs_login').removeClass('active'); }); jQuery(document).on('click','.ow_tabs_login,.ow_tabs_already,.ow_votebutton',function (e){ jQuery('.ow_tabs_login_content').show(); jQuery('.ow_tabs_register_content').hide(); jQuery(".inner-container").removeClass('login-panel_add'); jQuery(".inner-container").removeClass('register-panel_add'); jQuery(".inner-container").removeClass('forgot-panel_add'); jQuery(".inner-container").addClass('login-panel_add'); jQuery('.ow_tabs_login').addClass('active'); jQuery('.ow_tabs_register').removeClass('active'); }); var window_width=jQuery(window).width(); if(window_width < 600){ ow_change_grid_list(window_width); } jQuery(window).resize(function (){ var window_width=jQuery(window).width(); ow_change_grid_list(window_width); }); function ow_change_grid_list(window_width){ if(window_width < 600){ jQuery(".ow_views_container").each(function(){ if(jQuery(this).hasClass('ow_video_contest')){ var ow_views_container=jQuery(this).attr('id'); var res=ow_views_container.split("ow_views_container_"); var term_id=res[1]; ow_show_contest_list(term_id); }else{ var ow_views_container=jQuery(this).attr('id'); var res=ow_views_container.split("ow_views_container_"); var term_id=res[1]; ow_show_contest_grid(term_id); } jQuery('li.ow_vote_float_right').hide(); }); }} jQuery(document).on({ mouseenter:function(){ var cont_id=jQuery(this).attr('data-vote-id'); var win_width=jQuery(window).width(); if(win_width > '450'){ var width=jQuery('#ow_image_responsive'+cont_id).width(); var height=jQuery('#ow_image_responsive'+cont_id).height(); jQuery('.ow_overlay_bg').css("width",width); jQuery('.ow_overlay_bg').css("height",height); }else{ var width=jQuery('#ow_image_responsive'+cont_id).data('mob'); var height='auto'; jQuery('.ow_vote_showcontent_view').css("width",width); jQuery('.ow_overlay_bg').css("width",width); jQuery('.ow_img_class').css("width",width); } jQuery('.ow_overlay_'+cont_id).css('opacity','1'); jQuery('.ow_overlay_'+cont_id).children().addClass('ow_overlay_bg_bottom_0',{duration:200}); },mouseleave:function(){ var cont_id=jQuery(this).attr('data-vote-id'); jQuery('.ow_overlay_'+cont_id).css('opacity','0'); jQuery('.ow_overlay_'+cont_id).children().removeClass('ow_overlay_bg_bottom_0',{duration:200}); }}, 'a.ow_hover_image'); AudioJS.setupAllWhenReady(); resize_window(); jQuery(window).resize(function(){ resize_window(); }); jQuery.extend(jQuery.vote_validator.ow_vote_messages, { required: vote_translation.required_message, remote: vote_translation.remote_message, email: vote_translation.email_message, url: vote_translation.url_message, date: vote_translation.date_message, dateISO: "Please enter a valid date(ISO).", number: "Please enter a valid number.", digits: "Please enter only digits.", creditcard: "Please enter a valid credit card number.", equalTo: "Please enter the same value again.", maxlength: jQuery.vote_validator.format("Please enter no more than {0} characters."), minlength: jQuery.vote_validator.format("Please enter at least {0} characters."), rangelength: jQuery.vote_validator.format("Please enter a value between {0} and {1} characters long."), range: jQuery.vote_validator.format("Please enter a value between {0} and {1}."), max: jQuery.vote_validator.format("Please enter a value less than or equal to {0}."), min: jQuery.vote_validator.format("Please enter a value greater than or equal to {0}.") }); }); function resize_window(){ var win_width=jQuery(window).width(); if(win_width <='450'){ var width=jQuery('.ow_overlay_bg').data('mob'); var height='auto'; if(width!==''){ jQuery('.ow_vote_showcontent_view').css("width",width); jQuery('.ow_overlay_bg').css("width",width); jQuery('.ow_img_class').css("width",width); }}else{ var widths=jQuery('.ow_vote_img_wdth').val(); jQuery('.ow_vote_showcontent_view').css("width",''); jQuery('.ow_overlay_bg').css("width",''); jQuery('.ow_img_class').css("width",widths); }} function ow_single_contestant_function(){ jQuery(document).on('click','.ow_share_click_expand',function(e){ if(jQuery('.ow_total_share_single').is(':hidden')){ jQuery('.ow_vote_share_shrink').addClass('active'); jQuery('.ow_total_share_single').show(); }else{ jQuery('.ow_vote_share_shrink').removeClass('active'); jQuery('.ow_total_share_single').hide(); }}); } function ow_single_contestant_pretty(){ jQuery('.single_contestant_pretty').ow_vote_prettyPhoto({ hook:'data-vote-gallery', markup: ow_pretty_photo_theme_markupp(), social_tools: false, deeplinking: false, show_title: true, theme:'pp_kalypso', changepicturecallback: function(ow_vote_id,ow_term_id){ var votes_counter=jQuery('.votes_count_single'+ow_vote_id).html(); var get_html_count="";var get_vote_btn=""; var ow_vote_button=jQuery('.ow_votes_btn_single'+ow_vote_id).html(); if(ow_vote_button!=undefined){ var get_vote_btn="
    "+ow_vote_button+'
    '; } if(votes_counter!=undefined){ var get_html_count="
    "+votes_counter+'
    '; } var get_html_pretty=jQuery('.ow_pretty_content_social'+ow_vote_id).html(); if(get_html_pretty!=undefined){ jQuery('.pp_social').html(get_html_count+get_vote_btn+get_html_pretty); jQuery('.pp_pic_holder').css('margin-top','20px'); jQuery('.pp_social').css('margin-right','20px'); ow_voting_add_contents_pretty(ow_vote_id); }} }); } function ow_vote_add_contestant_function(){ jQuery(document).on('click','.ow_vote_submit_entry',function(e){ var voter_submitter=jQuery('.voter_submitter').val(); if(voter_submitter==0){ jQuery.ow_vote_fancybox('

    Submitting Not Allowed

    '+ '
    Submitting Contestants Not Allowed for Voter
    ', { 'padding':0, 'width':500, 'height':280, 'maxWidth': 500, 'maxHeight': 280, 'minWidth': 350, 'minHeight': 220 }); return false; } var form_show_logged=jQuery(this).hasClass("ow_logged_in_enabled"); if(!form_show_logged){ var term_id=jQuery(this).attr('data-id'); var close_button_text=jQuery('.close_btn_text'+term_id).val(); var open_button_text=jQuery('.open_btn_text'+term_id).val(); var _self=jQuery(this); if(jQuery('.ow_form_add-contestants'+term_id).is(':visible')) jQuery('.ow_form_add-contestants'+term_id).slideToggle('slow', function(){ _self.html(open_button_text); }); else{ jQuery('.ow_contestants-success').hide(); jQuery('.ow_form_add-contestants'+term_id).slideToggle('slow', function(){ _self.html('X '+close_button_text); }); }}else{ ow_vote_ppOpen('#ow_vote_login_panel', '300',1); jQuery('.ow_tabs_login_content').show(); jQuery('.ow_tabs_register_content').hide(); jQuery('.ow_tabs_login').addClass('active'); }}); } function ow_vote_sorting_filter(){ jQuery('.ow_vote_filter_votes').change(function(){ var term_id=jQuery(this).attr('id'); var view=jQuery('.ow_vote_view_'+term_id).attr('data-view'); jQuery('#ow_filter_view'+term_id).val(view); jQuery('#ow_vote_select_filter'+term_id).submit(); }); } function ow_vote_show_contest_grid_function(){ jQuery(document).on('click','.ow_vote_grid_show_contest',function(e){ var term_id=jQuery(this).attr('data-id'); ow_show_contest_grid(term_id); }); } function ow_show_contest_grid(term_id){ var show_desc=jQuery('.ow_show_description'+term_id).val(); jQuery('.ow_vote_view_'+term_id).attr('data-view','grid'); jQuery('.ow_right_dynamic_content'+term_id).removeAttr('style'); jQuery('#list_show'+term_id).removeClass('ow_list_active'); jQuery('.ow_vote_view_'+term_id).removeClass('ow_vote_list'); jQuery('.ow_list_title'+term_id).hide(); jQuery('.custom_field_entry_'+term_id+'.list').html(''); jQuery('.custom_field_entry_'+term_id).removeClass('list'); var width_img=jQuery('.ow_vote_img_width'+term_id).val(); jQuery('.ow_right_dynamic_content'+term_id).css('width',width_img+'px'); jQuery('#grid_show'+term_id).addClass('ow_grid_active'); jQuery('.ow_vote_view_'+term_id).addClass('ow_vote_grid'); jQuery('.ow_grid_title'+term_id).show(); jQuery('.custom_field_entry_'+term_id).addClass('grid'); var post_ids=new Array(); jQuery('.custom_field_entry_'+term_id).each(function (index, value){ if(jQuery(this).children().length <=0){ post_id=jQuery(this).attr('data-post_id'); post_ids.push(post_id); }}); if(post_ids.length >=1){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_custom_fields', cat_id:term_id, post_idds:post_ids, ow_view:'grid' }, type: 'POST', cache: false, dataType: 'json', success: function(response){ if(response!==''){ jQuery('.custom_field_entry_'+term_id).each(function (index, value){ if(jQuery(this).children().length <=0){ post_id=jQuery(this).attr('data-post_id'); jQuery(this).html(response[post_id]); }}); }} }); } if(show_desc=='grid'||show_desc=='both') jQuery('.ow_show_desc_view_'+term_id).show(); else jQuery('.ow_show_desc_view_'+term_id).hide(); ow_render_title(term_id); AudioJS.setupAllWhenReady(); } function ow_render_title(term_id){ var title_alocation=jQuery('.ow_title_alocation_description'+term_id).val(); if(title_alocation=='on'){ var ow_image_contest=jQuery('.ow_image_contest'+term_id).val(); if(ow_image_contest=='photo'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ var check_content=jQuery(this).find('.ow_vote_title_content'+term_id).hasClass("ow_vote_title_added"+term_id); if(!check_content){ jQuery(this).find(".vote_left_sid"+term_id).before("
    "+jQuery(this).find('.ow_vote_title_content'+term_id).html()+"
    "); jQuery(this).find('.ow_vote_title_content'+term_id).hide(); jQuery(this).find('.ow_vote_title_content'+term_id).addClass('ow_vote_title_added'+term_id); }}); }}else{ var ow_image_contest=jQuery('.ow_image_contest'+term_id).val(); if(ow_image_contest=='video'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ var check_content=jQuery(this).find('.ow_vote_title_content'+term_id).hasClass("ow_vote_title_added"+term_id); if(!check_content){ jQuery(this).find(".video_contest_desc"+term_id).after("
    "+jQuery(this).find('.ow_vote_title_content'+term_id).html()+"
    "); jQuery(this).find('.ow_vote_title_content'+term_id).hide(); jQuery(this).find('.ow_vote_title_content'+term_id).addClass('ow_vote_title_added'+term_id); }}); }else if(ow_image_contest=='music'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ var check_content=jQuery(this).find('.ow_vote_title_content'+term_id).hasClass("ow_vote_title_added"+term_id); if(!check_content){ jQuery(this).find(".ow_msc_content"+term_id).after("
    "+jQuery(this).find('.ow_vote_title_content'+term_id).html()+"
    "); jQuery(this).find('.ow_vote_title_content'+term_id).hide(); jQuery(this).find('.ow_vote_title_content'+term_id).addClass('ow_vote_title_added'+term_id); }}); }} } function ow_vote_show_contest_list_function(){ jQuery(document).on('click','.ow_vote_list_show_contest',function(e){ var term_id=jQuery(this).attr('data-id'); ow_show_contest_list(term_id); ow_votes_list_page_show_contest(); }); } function ow_show_contest_list(term_id){ var show_desc=jQuery('.ow_show_description'+term_id).val(); jQuery('.ow_vote_view_'+term_id).attr('data-view','list'); jQuery('#grid_show'+term_id).removeClass('ow_grid_active'); jQuery('.ow_vote_view_'+term_id).removeClass('ow_vote_grid'); jQuery('.ow_grid_title'+term_id).hide(); jQuery('.custom_field_entry_'+term_id+'.grid').html(''); jQuery('.custom_field_entry_'+term_id).removeClass('grid'); jQuery('#list_show'+term_id).addClass('ow_list_active'); jQuery('.ow_right_dynamic_content'+term_id).css('width','auto'); jQuery('.ow_vote_view_'+term_id).addClass('ow_vote_list'); jQuery('.ow_list_title'+term_id).show(); jQuery('.custom_field_entry_'+term_id).addClass('list'); var post_ids=new Array(); jQuery('.custom_field_entry_'+term_id).each(function (index, value){ if(jQuery(this).children().length <=0){ post_id=jQuery(this).attr('data-post_id'); post_ids.push(post_id); }}); if(post_ids.length >=1){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_custom_fields', cat_id:term_id, post_idds:post_ids, ow_view:'list' }, type: 'POST', cache: false, dataType: 'json', success: function(response){ if(response!==''){ jQuery('.custom_field_entry_'+term_id).each(function (index, value){ if(jQuery(this).children().length <=0){ post_id=jQuery(this).attr('data-post_id'); jQuery(this).html(response[post_id]); }}); }} }); } if((show_desc=='list')||(show_desc=='both')) jQuery('.ow_show_desc_view_'+term_id).show(); else jQuery('.ow_show_desc_view_'+term_id).hide(); var title_alocation=jQuery('.ow_title_alocation_description'+term_id).val(); if(title_alocation=='on'){ var ow_image_contest=jQuery('.ow_image_contest'+term_id).val(); if(ow_image_contest=='photo'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ jQuery(this).find('.title_trnc_grid'+term_id).remove(); jQuery(this).find('.ow_vote_title_content'+term_id).show(); jQuery(this).find('.ow_vote_title_content'+term_id).removeClass('ow_vote_title_added'+term_id); }); }}else{ var ow_image_contest=jQuery('.ow_image_contest'+term_id).val(); if(ow_image_contest=='video'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ jQuery(this).find('.title_trnc_grid'+term_id).remove(); jQuery(this).find('.ow_vote_title_content'+term_id).show(); jQuery(this).find('.ow_vote_title_content'+term_id).removeClass('ow_vote_title_added'+term_id); }); }else if(ow_image_contest=='music'){ jQuery('.ow_vote_showcontent_'+term_id).each(function(){ jQuery(this).find('.title_trnc_grid'+term_id).remove(); jQuery(this).find('.ow_vote_title_content'+term_id).show(); jQuery(this).find('.ow_vote_title_content'+term_id).removeClass('ow_vote_title_added'+term_id); }); }} AudioJS.setupAllWhenReady(); } function ow_vote_pagination_click_function(){ jQuery(document).on('click', '.ow_votes-pagination a',function(e){ var all_contest_page=jQuery('#all_contest_page').val(); if(all_contest_page=="1"){ return; } e.preventDefault(); var term_id=jQuery(this).parent().attr('id'); var view=jQuery('.ow_vote_view_'+term_id).attr('data-view'); var link=jQuery(this).attr('href'); if(term_id=="profile"){ votes_display_profilescreen(link); jQuery('.ow_voting-profile').ow_vote_block({ message: '', overlayCSS: { backgroundColor: '#fff', opacity: 0.6 }}); jQuery('html,body').animate({ scrollTop: jQuery(".ow_voting-profile").offset().top}, 'slow'); return false; } jQuery('.ow_vote_view_'+term_id).ow_vote_block({ message: '', overlayCSS: { backgroundColor: '#fff', opacity: 0.6 }}); jQuery('.ow_vote_view_'+term_id).load(link+' .ow_contest-posts-container'+term_id,function(){ if(view=='list'){ ow_show_contest_list(term_id); ow_votes_list_page_show_contest(); }else{ ow_show_contest_grid(term_id); } ow_pretty_photo_gallery(); jQuery('.ow_vote_view_'+term_id).ow_vote_unblock(); jQuery('html,body').animate({ scrollTop: jQuery('.ow_vote_view_'+term_id).offset().top}, 'slow'); owvideojs_initialize(); jQuery(window).owllazyLoadXT(); }); resize_window(); }); } function votes_display_profilescreen(link){ jQuery('.ow_voting-profile').load(link+' .ow_voting-profile',function(){}); } function ow_vote_pagination_change_function(){ jQuery(document).on('change','.ow_votes-pagination select', function(e){ var all_contest_page=jQuery('#all_contest_page').val(); if(all_contest_page=="1"){ var url=jQuery(this).val(); window.location.href=url; return; } e.preventDefault(); var term_id=jQuery(this).attr('class'); var view=jQuery('.ow_vote_view_'+term_id).attr('data-view'); var link=jQuery(this).val(); if(term_id=="profile"){ votes_display_profilescreen(link); jQuery('.ow_voting-profile').ow_vote_block({ message: '', overlayCSS: { backgroundColor: '#fff', opacity: 0.6 }}); jQuery('html,body').animate({ scrollTop: jQuery(".ow_voting-profile").offset().top}, 'slow'); return false; } jQuery('.ow_vote_view_'+term_id).ow_vote_block({ message: '', overlayCSS: { backgroundColor: '#fff', opacity: 0.6 }}); jQuery('.ow_vote_view_'+term_id).load(link+' .ow_contest-posts-container'+term_id,function(){ if(view=='list'){ ow_show_contest_list(term_id); ow_votes_list_page_show_contest(); }else{ ow_show_contest_grid(term_id); } ow_pretty_photo_gallery(); jQuery('.ow_vote_view_'+term_id).ow_vote_unblock(); jQuery('html,body').animate({ scrollTop: jQuery('.ow_vote_view_'+term_id).offset().top}, 'slow'); owvideojs_initialize(); jQuery(window).owllazyLoadXT(); }); }); resize_window(); } function ow_votes_list_page_show_contest(){ jQuery('.ow_views_container').each(function(){ var term=jQuery(this).attr('id'); var term_id=term.split('ow_views_container_')[1]; var view=jQuery(this).attr('data-view'); if(view=="grid") ow_render_title(term_id); }); jQuery('.ow_vote_showcontent_view').each(function(){ var term_id=jQuery(this).attr('data-id'); var view=jQuery('.ow_vote_view_'+term_id).attr('data-view'); var show_desc=jQuery('.ow_show_description'+term_id).val(); if(view=='list'){ var main_div_width=parseInt(jQuery(this).width()); var image_width=parseInt(jQuery('.ow_vote_img_width'+term_id).val()); if(image_width==''){ image_width=parseInt(jQuery('.ow_vote_img_style'+term_id).width()); } var pixels=((image_width/main_div_width)*100)-100; pixels=Math.abs(pixels)-0.12; if(!isNaN(pixels)){ }}else{ var image_width=parseInt(jQuery('.ow_vote_img_width'+term_id).val()); if(image_width==''){ image_width=parseInt(jQuery('.ow_vote_img_style'+term_id).width()); } if(jQuery(this).hasClass("ow_video_get")){ image_width=jQuery(this).find('iframe').width(); if(jQuery.trim(image_width)==''){ image_width=jQuery('.ow_video_get').width(); }} if(!isNaN(image_width)){ jQuery(this).find('.ow_right_dynamic_content'+term_id).css('width',Math.abs(image_width)+'px'); }} if((show_desc==view)||(show_desc=='both')) jQuery('.ow_show_desc_view_'+term_id).show(); else jQuery('.ow_show_desc_view_'+term_id).hide(); }); } function add_contestant_validation(term_id,title_error_message){ jQuery('.ow_form_add-contestants'+term_id).ow_vote_validate({ ow_vote_rules: { 'contestant-title': "required", }, ow_vote_messages: { 'contestant-title': title_error_message, }}); } function add_contestant_validation_method(id_validate,message){ jQuery(document).ready(function(){ jQuery("#"+id_validate).ow_vote_rules("add", { required:true, ow_vote_messages:{ required:message }}); }); } function add_contestant_validation_method_file(id_validate,message,size=""){ jQuery(document).ready(function(){ if(size!=0){ jQuery("#"+id_validate).ow_vote_rules("add", { required:true, maxFileSize: { "unit": "MB", "size": size }, }); }else{ add_contestant_validation_method(id_validate,message) }}); } jQuery(document).on('change','.ow_checkbox_restrict', function(){ var thislinked=this.id; vote_restrict_extension(jQuery('.'+thislinked)[0]); return false; }); function vote_restrict_extension(thislinked){ var vote_id=jQuery(thislinked).attr('data-vote-id'); var ow_restriction_count=jQuery('#ow_restriction_count').val(); var checkbox_count=jQuery('.ow_checkbox_restrict:checked').size(); if(parseInt(checkbox_count)==parseInt(ow_restriction_count)){ jQuery('html,body').animate({ scrollTop: jQuery(".ow_restrict_description").offset().top}, 'slow'); } else if(parseInt(checkbox_count) > parseInt(ow_restriction_count)){ jQuery('#ow_restrict_'+vote_id).prop('checked', false); } var ow_restriction_count=jQuery('#ow_restriction_count').val(); var vote_cookie_count=jQuery('#vote_cookie_count').val(); var checkbox_count=jQuery('.ow_checkbox_restrict:checked').size(); var total_vote_count=parseInt(vote_cookie_count)+ parseInt(checkbox_count); if(vote_cookie_count >=ow_restriction_count||total_vote_count > ow_restriction_count){ jQuery.ow_vote_fancybox('

    Voting Not Allowed

    '+ '
    More than '+ow_restriction_count+' votes not allowed
    ', { 'padding':0, 'width':500, 'height':280, 'maxWidth': 500, 'maxHeight': 280, 'minWidth': 350, 'minHeight': 220 }); jQuery('.ow_button_all').hide(); return false; } else if(total_vote_count==ow_restriction_count){ jQuery('html,body').animate({ scrollTop: jQuery(".ow_restrict_description").offset().top}, 'slow'); jQuery('.ow_button_all').show(); } return false; } function ow_vote_click_function(){ jQuery(document).on('click','a.ow_votebutton', function(){ if(jQuery(this).hasClass('ow_vote_restriction')){ var vote_id=jQuery(this).attr('data-vote-id'); if(jQuery('#ow_restrict_'+vote_id)[0].checked===true){ jQuery('#ow_restrict_'+vote_id).prop('checked', false); }else{ jQuery('#ow_restrict_'+vote_id).prop('checked', true); } vote_restrict_extension(this); return false; } var voter_submitter=jQuery('.voter_submitter').val(); if(voter_submitter==1){ jQuery.ow_vote_fancybox('

    Voting Not Allowed

    '+ '
    Voting Not Allowed for Contestant Submitter
    ', { 'padding':0, 'width':500, 'height':280, 'maxWidth': 500, 'maxHeight': 280, 'minWidth': 350, 'minHeight': 220 }); return false; } var link_clicked=this; var form_show_logged=jQuery(this).hasClass("ow_logged_in_enabled"); var ow_voting_email=jQuery(this).hasClass("ow_voting_email"); var ow_voting_grab=jQuery(this).hasClass("ow_voting_grab"); var term_id=jQuery(link_clicked).attr('data-term-id'); var ow_contest_closed=jQuery('#ow_contest_closed_'+term_id).val(); if(ow_voting_email||ow_voting_grab){ if(form_show_logged&&ow_contest_closed!='start'){ ow_vote_ppOpen('#ow_vote_login_panel', '300',1); }else{ var term_id=jQuery(link_clicked).attr('data-term-id'); var vote_id=jQuery(link_clicked).attr('data-vote-id'); var ow_contest_closed=jQuery('#ow_contest_closed_'+term_id).val(); if(ow_contest_closed=='start'){ jQuery.ow_vote_fancybox('

    Processing...

    '+ '
    ', { 'padding':0, 'width':500, 'height':280, 'maxWidth': 500, 'maxHeight': 280, 'minWidth': 350, 'minHeight': 220 }); jQuery('.ow_vote_view_'+term_id).ow_vote_unblock(); jQuery('.ow_vote_fancybox_result').css("background","none"); jQuery('.ow_vote_fancybox_result_header').html('Restricted'); jQuery('.ow_vote_fancybox_result').html("
    "+jQuery('.ow_contest_closed_desc').val()+"
    "); var get_html_pretty=jQuery('.ow_fancy_content_social'+vote_id).html(); if(get_html_pretty!==undefined&&jQuery(get_html_pretty).length > 0){ jQuery('.ow_vote_fancybox_result').append(vote_translation.share_message); jQuery('.ow_vote_fancybox_result').append("
    "+get_html_pretty+"
    "); } return false; }else{ ow_vote_ppOpen('#ow_vote_email_panel', '300',1); window.link_btn=link_clicked; return false; }} } if(jQuery('.ow_captcha_voting').val()=='1'&&!form_show_logged){ jQuery.ow_vote_fancybox('

    Captcha Validation

    '+ '
    ', { 'padding':0, 'width':500, 'height':160, 'maxWidth': 500, 'maxHeight': 160, 'minWidth': 350, 'minHeight': 160 }); window.link_clicked=link_clicked; window.form_show_logged=form_show_logged; ow_captcha_voting=grecaptcha.render("ow_captcha_voting", { sitekey: jQuery('.vote_recapatcha_key').val(), theme: "light", callback :function(response){ if(response!=""){ jQuery('.ow_vote_fancybox-overlay').hide(); vote_button_function(window.link_clicked,window.form_show_logged); }else{ return false; }} }); }else{ vote_button_function(link_clicked,form_show_logged); }}); } function vote_button_function(link_clicked,form_show_logged){ if(!form_show_logged){ if(jQuery(link_clicked).hasClass('ow_buy_votes')){ ow_buy_votes_func(link_clicked); return false; } if(jQuery(link_clicked).hasClass('ow_buy_class')){ var ow_buy_class=1; }else{ var ow_buy_class=0; } var term_id=jQuery(link_clicked).attr('data-term-id'); var vote_id=jQuery(link_clicked).attr('data-vote-id'); var enc_term_id=jQuery(link_clicked).attr('data-enc-id'); var enc_vote_id=jQuery(link_clicked).attr('data-enc-pid'); var votes_count=jQuery(link_clicked).attr('data-vote-count'); var today=new Date(); var current_time=today.toUTCString(); var gmt_offset=today.getTimezoneOffset(); var cur_timeinfo=new Array(); jQuery('.ow_vote_view_'+term_id).ow_vote_block({ message: '', overlayCSS: { backgroundColor: '#fff', opacity: 0.1 }}); jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:(ow_buy_class==1)?'ow_save_votes_buy':'ow_save_votes', pid:enc_vote_id, termid: enc_term_id, current_time:current_time, gmt_offset:gmt_offset, votes_count:votes_count, ow_buy_class:ow_buy_class }, type: 'GET', cache: false, dataType: 'jsonp', beforeSend:function(){ jQuery.ow_vote_fancybox('

    Processing...

    '+ '
    ', { 'padding':0, 'width':500, 'height':280, 'maxWidth': 500, 'maxHeight': 280, 'minWidth': 350, 'minHeight': 220 }); }, success: function(result){ jQuery('.ow_vote_view_'+term_id).ow_vote_unblock(); if(result.success==1){ jQuery(link_clicked).addClass('ow_success'); jQuery('.ow_vote_count'+vote_id).text(result.votes); jQuery('.votes_count_single_count'+vote_id).text(result.votes); if(result.button_flag==1){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var voting_type=jQuery(this).attr('data-voting-type'); if(voting_type==0){ jQuery('.votr_btn_cont'+vote_id).text(vote_translation.voted); jQuery('.voter_btn_term'+term_id).text(vote_translation.voted); jQuery('.voter_a_btn_term'+term_id).each(function(){ var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ jQuery(this).addClass('ow_voting_green_button'); }else jQuery(this).addClass('ow_voting_grey_button'); }); }else if(voting_type==1||voting_type==2){ if(voting_type==1) jQuery('.votr_btn_cont'+vote_id).text(vote_translation.voted); var count_frequency=jQuery(this).attr('data-frequency-count'); var total_count_voted=jQuery(this).attr('data-current-user-votecount'); var total_count_votes=parseInt(total_count_voted) + parseInt(1); jQuery(this).attr('data-current-user-votecount',total_count_votes); var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ if(voting_type==1) jQuery(this).addClass('ow_voting_green_button'); } if(new_vote_id==vote_id){ jQuery(this).removeClass('ow_voting_grey_button'); }} }); }else if(result.button_flag==2){ if(result.frequency==1){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var voting_type=jQuery(this).attr('data-voting-type'); if(voting_type==0){ jQuery('.votr_btn_cont'+vote_id).text(vote_translation.voted); jQuery('.voter_btn_term'+term_id).text(vote_translation.voted); jQuery('.voter_a_btn_term'+term_id).each(function(){ var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ jQuery(this).addClass('ow_voting_green_button'); }else jQuery(this).addClass('ow_voting_grey_button'); }); }else if(voting_type==1||voting_type==2){ jQuery('.votr_btn_cont'+vote_id).text(vote_translation.voted); var count_frequency=jQuery(this).attr('data-frequency-count'); var total_count_voted=jQuery(this).attr('data-current-user-votecount'); var total_count_votes=parseInt(total_count_voted) + parseInt(1); jQuery(this).attr('data-current-user-votecount',total_count_votes); var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ if(voting_type==1) jQuery(this).addClass('ow_voting_green_button'); if(voting_type==2) jQuery(this).addClass('ow_voting_green_button'); } if(new_vote_id==vote_id){ jQuery(this).removeClass('ow_voting_grey_button'); }} }); } if(result.frequency==0){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var voting_type=jQuery(this).attr('data-voting-type'); if(voting_type==0){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ jQuery(this).addClass('ow_voting_green_button'); }else{ jQuery('.voter_btn_term'+term_id).text(vote_translation.voted); jQuery(this).addClass('ow_voting_grey_button'); }}); }}); } if(result.frequency==2){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var voting_type=jQuery(this).attr('data-voting-type'); if(voting_type==0){ jQuery('.voter_a_btn_term'+term_id).each(function(){ var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ jQuery(this).addClass('ow_voting_green_button'); }else{ jQuery('.voter_btn_term'+term_id).text(vote_translation.voted); jQuery(this).addClass('ow_voting_grey_button'); }}); } else if(voting_type==1||voting_type==2){ jQuery('.votr_btn_cont'+vote_id).text(vote_translation.voted); var count_frequency=jQuery(this).attr('data-frequency-count'); var total_count_voted=jQuery(this).attr('data-current-user-votecount'); var total_count_votes=parseInt(total_count_voted) + parseInt(1); jQuery(this).attr('data-current-user-votecount',total_count_votes); var new_vote_id=jQuery(this).attr('data-vote-id'); if(new_vote_id==vote_id){ if(voting_type==1) jQuery(this).addClass('ow_voting_green_button'); if(voting_type==2) jQuery(this).addClass('ow_voting_green_button'); } if(new_vote_id==vote_id){ jQuery(this).removeClass('ow_voting_grey_button'); }} }); }} if(ow_buy_class==1){ if(result.check_votable==true){ jQuery('.ow_buybutton_'+result.pid).removeClass('hide'); jQuery('.ow_buybutton_'+result.pid).show(); jQuery('.votr_btn_cont'+vote_id).text('Buy Votes'); jQuery('.ow_votebutton_'+result.pid).hide(); } if(result.freq_type=='cookie_traced'){ setTimeout(function(){ location.reload(); }, 2000); }} } var istotalcounter=document.getElementsByClassName('ow_total_counter'); if(istotalcounter.length > 0){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'owtotalvotes', }, type: 'GET', cache: false, success: function(result){ jQuery('.ow_total_counter').html(result); }}); } jQuery('.ow_vote_fancybox_result').css("background","none"); jQuery('.ow_vote_fancybox_result_header').html(result.msg); jQuery('.ow_vote_fancybox_result').html(result.msg_html); var get_html_pretty=jQuery('.ow_fancy_content_social'+vote_id).html(); if(get_html_pretty!==undefined&&jQuery(get_html_pretty).length > 0){ jQuery('.ow_vote_fancybox_result').append(vote_translation.share_message); jQuery('.ow_vote_fancybox_result').append("
    "+get_html_pretty+"
    "); }} }); return false; }else{ ow_vote_ppOpen('#ow_vote_login_panel', '300',1); }} function votes_countdown(el){ var countdown=jQuery(el); if(!countdown.length) return false; countdown.each(function(i, e){ var timer=jQuery(this).data('datetimer').split("-"); var currenttimer=jQuery(this).data('currenttimer').split("-"); jQuery(this).ow_vote_countDown({ omitWeeks: false, targetDate: { 'year': timer[0], 'month': timer[1], 'day': timer[2], 'hour': timer[3], 'min': timer[4], 'sec': timer[5] }, currentDate: { 'year': currenttimer[0], 'month': currenttimer[1], 'day': currenttimer[2], 'hour': currenttimer[3], 'min': currenttimer[4], 'sec': currenttimer[5] }, onComplete: function(){ }}); countdown.css('visibility','visible'); }); } function ow_vote_ppOpen(panel, width,flag){ jQuery(function(){ jQuery('.date_picker').on('click', function (){ jQuery(this).owvotedatetimepicker('destroy').owvotedatetimepicker({format:'m-d-Y', step:10, timepicker: false,}).focus(); }); }); if(panel=='#ow_vote_forgot_panel'){ jQuery('.forgot-panel').show(); jQuery(".inner-container").removeClass('login-panel_add'); jQuery(".inner-container").removeClass('register-panel_add'); jQuery(".inner-container").removeClass('forgot-panel_add'); jQuery(".inner-container").addClass('forgot-panel_add'); }else if(panel=='#ow_vote_login_panel'){ jQuery(".inner-container").removeClass('login-panel_add'); jQuery(".inner-container").removeClass('register-panel_add'); jQuery(".inner-container").removeClass('forgot-panel_add'); jQuery(".inner-container").addClass('login-panel_add'); }else if(panel=='#ow_vote_register_panel'){ jQuery(".inner-container").removeClass('login-panel_add'); jQuery(".inner-container").removeClass('register-panel_add'); jQuery(".inner-container").removeClass('forgot-panel_add'); jQuery(".inner-container").addClass('register-panel_add'); } jQuery(".error_empty").remove(); jQuery(".voting_success").remove(); if(jQuery('.pp_pic_holder').size() > 0){ jQuery.ow_vote_prettyPhoto.close(); } setTimeout(function(){ jQuery.fn.ow_vote_prettyPhoto({ social_tools: false, deeplinking: false, show_title: false, default_width: width, theme:'pp_kalypso login_prettyPhoto' }); jQuery.ow_vote_prettyPhoto.open(panel); if(jQuery('.ow_captcha_login').val()=='1'&&(panel=='#ow_vote_login_panel'||panel=='#ow_vote_register_panel')){ if(jQuery('.pp_content_container').length > 0){ setTimeout(function(){ jQuery('

    ').insertBefore('#pp_full_res #ow_sign_in'); }, 500); setTimeout(function(){ jQuery('

    ').insertBefore('#pp_full_res #signup'); }, 500); setTimeout(function(){ createRecaptcha(); }, 500); }else{ console.log(' }} if(panel=='#ow_vote_login_panel'&&jQuery('#vote_gg_clientid').length > 0){ setTimeout(function(){ if(jQuery('.login_prettyPhoto .voting_google_login #customBtn').length==0){ jQuery('.login_prettyPhoto .voting_google_login').append(' sign-in-with-google-dark'); startApp(); }}, 500); } if(jQuery('.ow_captcha_voting').val()=='1'&&panel=='#ow_vote_email_panel'){ if(jQuery('#ow_email_grab_id').length > 0){ setTimeout(function(){ jQuery('

    ').insertBefore('#pp_full_res #ow_email_grab_id'); }, 500); setTimeout(function(){ ow_email_grab_captcha=grecaptcha.render("ow_email_grab_captcha", { sitekey: jQuery('.vote_recapatcha_key').val(), theme: "light", callback:"emailgrab_captcha_callback" }); }, 500); }} }, 300); } function createRecaptcha(){ ow_sign_in_captcha=grecaptcha.render("ow_sign_in_captcha", { sitekey: jQuery('.vote_recapatcha_key').val(), theme: "light", callback:"captcha_callback" }); ow_sign_up_captcha=grecaptcha.render("ow_sign_up_captcha", { sitekey: jQuery('.vote_recapatcha_key').val(), theme: "light", callback:"captcha_callback" }); } var captcha_callback=function(response){ jQuery(".error_empty").remove(); }; var emailgrab_captcha_callback=function(response){ jQuery(".error_empty").remove(); jQuery('#pp_full_res #ow_email_grab_id').removeAttr('disabled',false); }; function ow_vote_submit_user_form(){ jQuery(document).on('submit','.zn_form_login',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize(); var get_reg_or_login=''; if(jQuery('.ow_captcha_login').val()=='1'){ if(jQuery(".inner-container").hasClass("login-panel_add")){ if(grecaptcha.getResponse(ow_sign_in_captcha)==""){ warning=true; }} if(jQuery(".inner-container").hasClass("register-panel_add")){ if(grecaptcha.getResponse(ow_sign_up_captcha)==""){ warning=true; }} } if(jQuery(".inner-container").hasClass("register-panel_add")){ get_reg_or_login='register'; jQuery('.required_vote_custom').filter(':visible').each(function(){ var type_bos=jQuery(this).attr('type'); var in_id=jQuery(this).attr('id'); if(type_bos=='checkbox'){ var in_idc=jQuery(this).attr('id'); if(jQuery('.reg_check_'+in_idc+':checked').length > 0){ jQuery('.'+in_idc).attr('style',''); }else{ jQuery('.'+in_idc).attr('style','color:red'); warning=true; }}else if(type_bos=='radio'){ var in_ids=jQuery(this).attr('id'); if(jQuery('.reg_radio_'+in_ids+':checked').length > 0){ jQuery('.'+in_ids).attr('style',''); }else{ jQuery('.'+in_ids).attr('style','color:red'); warning=true; }}else{ if(!jQuery(this).val()){ jQuery(this).attr('style','border:1px solid red;'); warning=true; }else{ jQuery(this).attr('style','border:none;'); }} }); }else{ get_reg_or_login='login'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); } if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("register-panel_add")){ if(grecaptcha.getResponse(ow_sign_up_captcha)==""){ jQuery(".m_title").after("

    Captcha Error

    "); }else{ jQuery(".m_title").after("

    Please Fill In The Required Fields Below.

    "); }} if(jQuery(".inner-container").hasClass("login-panel_add")){ if(grecaptcha.getResponse(ow_sign_in_captcha)==""){ jQuery(".m_title").after("

    Captcha Error

    "); }else{ jQuery(".m_title").after("

    Please Enter The Username and Password.

    "); }} button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery.post(vote_path_local.votesajaxurl, values, function(resp){ jQuery(".error_empty").remove(); var res=resp.split("~~"); var data=jQuery(document.createElement('div')).html(res[1]); if(get_reg_or_login=='login'){ if(res[0]==1){ data.find('a').attr('onClick','ow_vote_ppOpen(\'#ow_vote_forgot_panel\', \'300\');return false;'); jQuery('div.links', form).html(data); button.removeClass('zn_blocked'); }else{ if(jQuery('.zn_login_redirect', form).length > 0){ jQuery.ow_vote_prettyPhoto.close(); redirect=jQuery('.zn_login_redirect', form); href=redirect.val(); if(jQuery('.ow_open_login_form').val()==1){ jQuery('.ow_open_login_form').val('0'); if(jQuery('#contestant-title'+window.contest_id).val()==undefined){ window.location=href; }else{ jQuery('.ow_form_add-contestants'+window.contest_id).submit(); return true; }}else{ window.location=href; }} }}else{ if(res[0]==0){ button.addClass('zn_blocked'); var autologin_txt=""; if(jQuery('.vote_auto_login').val()=='on'){ autologin_txt="Your account has been created and you will be now logged in"; }else{ autologin_txt="Your account has been created.Now you can login to access the voting"; } jQuery.ow_vote_fancybox('

    '+autologin_txt+'

    ', { 'width':300, 'height':150, 'maxWidth': 300, 'maxHeight': 150, 'minWidth': 200, 'minHeight': 80 } ); if(jQuery('.ow_open_login_form').val()==1){ jQuery('.ow_open_login_form').val('0'); if(jQuery('#contestant-title'+window.contest_id).val()==undefined){ setTimeout(function(){ jQuery.ow_vote_prettyPhoto.close(); redirect=jQuery('.zn_login_redirect', form); href=redirect.val(); window.location=href; }, 2000); }else{ jQuery('.ow_form_add-contestants'+window.contest_id).submit(); return false; }}else{ setTimeout(function(){ jQuery.ow_vote_prettyPhoto.close(); redirect=jQuery('.zn_login_redirect', form); href=redirect.val(); window.location=href; }, 2000); }}else{ button.removeClass('zn_blocked'); jQuery.ow_vote_fancybox('

    '+res[1]+'

    ', { 'width':300, 'height':150, 'maxWidth': 300, 'maxHeight': 150, 'minWidth': 200, 'minHeight': 80 } ); }} return false; button.removeClass('zn_blocked'); }); }); jQuery(document).on('submit','.zn_form_lost_pass',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize()+'&ajax_login=true'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("forgot-panel_add")){ jQuery(".m_title").after("

    Please Enter The Username / Email.

    "); } button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery(".error_empty").remove(); jQuery.ajax({ url: form.attr('action'), data: values, type: 'POST', cache: false, success: function (resp){ var data=jQuery(document.createElement('div')).html(resp); jQuery('div.links', form).html(''); if(jQuery('#login_error', data).length){ var error=jQuery('#login_error', data); error.find('a').attr('onClick','ppOpen(\'#forgot_panel\', \'350\');return false;'); jQuery('div.links', form).html(error); } else if(jQuery('.message', data).length){ var message=jQuery('.message', data); jQuery('div.links', form).html(message); }else{ jQuery.prettyPhoto.close(); redirect=jQuery('.zn_login_redirect', form); href=redirect.val(); location.reload(true); } button.removeClass('zn_blocked'); }, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }); jQuery(document).on('submit','.zn_form_save_email',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize()+'&ajax_login=true&action=voting_save_twemail_session'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("forgot-panel_add")){ jQuery(".m_title").after("

    Please Enter The Email.

    "); } button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery(".error_empty").remove(); jQuery.ajax({ url: vote_path_local.votesajaxurl, data: values, type: 'POST', cache: false, success: function (resp){ if(resp==0){ jQuery(".m_title").after("

    Please Enter The Valid Email.

    "); button.removeClass('zn_blocked'); }else{ jQuery(".error_empty").remove(); votes_twitter_authentication(); }}, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }); jQuery(document).on('submit','.zn_email_verification',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize()+'&ajax_login=true&action=voting_email_verification'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("login-panel")){ jQuery(".m_title_email").after("

    Please Enter The Email.

    "); } button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery(".error_empty").remove(); jQuery.ajax({ url: vote_path_local.votesajaxurl, data: values, type: 'POST', cache: false, success: function (resp){ if(resp==0){ jQuery(".m_title_email").after("

    Please Enter The Valid Email.

    "); button.removeClass('zn_blocked'); }else{ jQuery(".error_empty").remove(); jQuery(".voting_success").remove(); jQuery(".ow_grab_email_send").after("

    Email Verification Code Sent Successfully

    "); }}, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }); jQuery(document).on('submit','.zn_email_verification_code',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize()+'&ajax_login=true&action=voting_email_code'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("login-panel")){ jQuery(".m_title_code").after("

    Please Enter Valid Code.

    "); } button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery(".error_empty").remove(); jQuery.ajax({ url: vote_path_local.votesajaxurl, data: values, type: 'POST', cache: false, success: function (resp){ if(resp==0){ jQuery(".m_title_code").after("

    Please Enter Valid Code.

    "); button.removeClass('zn_blocked'); }else{ jQuery(".error_empty").remove(); jQuery.ow_vote_prettyPhoto.close(); vote_button_function(window.link_btn,""); }}, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }); jQuery(document).on('submit','.zn_email_grab',function(event){ event.preventDefault(); var form=jQuery(this), warning=false, button=jQuery('.zn_sub_button',this), values=form.serialize()+'&ajax_login=true&action=ow_voting_grab_email'; jQuery('input',form).each(function(){ if(!jQuery(this).val()){ warning=true; }}); if(warning){ jQuery(".error_empty").remove(); if(jQuery(".inner-container").hasClass("login-panel")){ jQuery(".m_title").after("

    Please Enter Valid Email Address.

    "); } button.removeClass('zn_blocked'); return false; } if(button.hasClass('zn_blocked')){ return; } button.addClass('zn_blocked'); jQuery(".error_empty").remove(); jQuery.ajax({ url: vote_path_local.votesajaxurl, data: values, type: 'POST', cache: false, success: function (resp){ if(resp==0){ jQuery(".m_title").after("

    Please Enter Valid Email Address.

    "); button.removeClass('zn_blocked'); }else{ jQuery(".error_empty").remove(); jQuery.ow_vote_prettyPhoto.close(); vote_button_function(window.link_btn,""); jQuery(".ow_voting_verification").show(); }}, error: function (jqXHR , textStatus, errorThrown){ jQuery('div.links', form).html(errorThrown); }}); }); } function ow_pretty_photo_gallery(){ var vote_prettyphoto_disable=jQuery('.vote_prettyphoto_disable').val(); if(vote_prettyphoto_disable==1){ jQuery('a[data-vote-gallery^=ow_vote_prettyPhoto]').ow_vote_prettyPhoto({ hook:'data-vote-gallery', markup: ow_pretty_photo_theme_markupp(), social_tools: false, deeplinking: false, show_title: true, theme:'pp_kalypso', changepicturecallback: function(ow_vote_id,ow_term_id){ var get_html_pretty=jQuery('.ow_pretty_content_social'+ow_vote_id).html(); jQuery('.pp_social').html(get_html_pretty); ow_voting_add_contents_pretty(ow_vote_id); }}); }} function ow_voting_add_contents_pretty(votes_id){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_additional_fields_pretty', pid:votes_id }, type: 'POST', success: function(result){ if(result!=0) jQuery('.pp_mult_desc').html(jQuery(result)); }}); } function ow_pretty_photo_theme_markupp(){ window.markupp='
    \ \
    \
     
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \ Expand \
    \ next \ previous \
    \
    \
    \
    \ Previous \

    0/0

    \ Next \
    \

    \

    \ \ Close \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    \
    '; return window.markupp; } function confirm_delete_single(vote_id){ var r=confirm(jQuery('#confirm_delete_single').val()); if(r==true){ jQuery("#delete_contestants"+vote_id).submit(); return true; }else{ return false; }} function ow_voting_load_more(){ jQuery('.ow_load_more').click(function (){ var cat_id=this.id.split("_")[2]; var postperpage=jQuery('#ow_postperpage_'+cat_id).val(); var offset=jQuery('#ow_offset_'+cat_id).val(); var ow_category_options=jQuery('#ow_category_options_'+cat_id).val(); var show_cont_args=jQuery('#ow_show_cont_args_'+cat_id).val(); var global_options=jQuery('#ow_show_global_'+cat_id).val(); var view=jQuery('.ow_vote_view_'+cat_id).attr('data-view'); var ow_profile_screen=jQuery('#ow_profile_screen').val(); jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_more', cat_id:cat_id, postperpage:postperpage, category_option:ow_category_options, show_cont_args:show_cont_args, global_options:global_options, offset:offset, ow_view:view, ow_profile_screen:ow_profile_screen }, type: 'POST', cache: false, dataType: 'html', beforeSend:function(){ jQuery('.ow_jx_loader_'+cat_id).show(); }, success: function(response){ jQuery('.ow_jx_loader_'+cat_id).hide(); if(cat_id==0){ jQuery('.ow_contest-posts-container0').append(response); if(ow_profile_screen==undefined){ new GridScrollFx(document.getElementById('grid'), { viewportFactor:0.4 }); }}else{ jQuery('.ow_jx_response_'+cat_id).append(response); } jQuery('#ow_offset_'+cat_id).val(parseInt(offset)+parseInt(postperpage)); if(jQuery('#ow_load_stop_'+cat_id).val()==-1){ jQuery('#ow_load_'+cat_id).hide(); jQuery('.ow_all_contestloaded').delay(5000).fadeOut('slow'); } ow_pretty_photo_gallery(); if(view=='list'){ ow_show_contest_list(cat_id); ow_votes_list_page_show_contest(); }else{ ow_show_contest_grid(cat_id); } owvideojs_initialize(); jQuery(window).owllazyLoadXT(); resize_window(); }}); }); jQuery(function(){ var ow_infinite=jQuery('#ow_infinite').val(); if(ow_infinite==1){ var scrollFunction=function(){ jQuery('.ow_all_contestloaded').delay(5000).fadeOut('slow'); var mostOfTheWayDown=(jQuery(document).height() - jQuery('.ow_views_container').height()) * 1 / 3; if(jQuery(window).scrollTop() >=mostOfTheWayDown){ jQuery(window).unbind("scroll"); var obj=jQuery('.ow_views_container'); var cat_id=jQuery(obj).attr('id').split("ow_views_container_")[1]; var postperpage=jQuery('#ow_postperpage_'+cat_id).val(); var offset=jQuery('#ow_offset_'+cat_id).val(); var ow_category_options=jQuery('#ow_category_options_'+cat_id).val(); var show_cont_args=jQuery('#ow_show_cont_args_'+cat_id).val(); var global_options=jQuery('#ow_show_global_'+cat_id).val(); var view=jQuery('.ow_vote_view_'+cat_id).attr('data-view'); if(jQuery('#ow_load_stop_'+cat_id).val()!=-1){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_more', cat_id:cat_id, postperpage:postperpage, category_option:ow_category_options, show_cont_args:show_cont_args, global_options:global_options, ow_view:view, offset:offset }, type: 'POST', cache: false, dataType: 'html', beforeSend:function(){ jQuery('.ow_jx_loader_'+cat_id).show(); }, success: function(response){ jQuery('.ow_jx_loader_'+cat_id).hide(); jQuery('.ow_jx_response_'+cat_id).append(response); jQuery('#ow_offset_'+cat_id).val(parseInt(offset)+parseInt(postperpage)); jQuery(window).scroll(scrollFunction); ow_pretty_photo_gallery(); if(view=='list'){ ow_show_contest_list(cat_id); ow_votes_list_page_show_contest(); }else{ ow_show_contest_grid(cat_id); } owvideojs_initialize(); jQuery(window).owllazyLoadXT(); resize_window(); }}); }} }; jQuery(window).scroll(scrollFunction); }}); } function ow_voting_load_more_all(){ jQuery('.ow_load_more_all').click(function (){ var cat_id=this.id.split("_")[2]; var postperpage=jQuery('#ow_postperpage_'+cat_id).val(); var offset=jQuery('#ow_offset_'+cat_id).val(); var ow_category_options=jQuery('#ow_category_options_'+cat_id).val(); var show_cont_args=jQuery('#ow_show_cont_args_'+cat_id).val(); var global_options=jQuery('#ow_show_global_'+cat_id).val(); var view=jQuery('.ow_vote_view_'+cat_id).attr('data-view'); jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_more', cat_id:cat_id, ow_ajax_flag:1, postperpage:postperpage, category_option:ow_category_options, show_cont_args:show_cont_args, global_options:global_options, ow_view:view, offset:offset, ow_search:jQuery('#ow_search_input').val(), }, type: 'POST', cache: false, dataType: 'html', beforeSend:function(){ jQuery('.ow_jx_loader_'+cat_id).show(); }, success: function(response){ jQuery('.ow_jx_loader_'+cat_id).hide(); jQuery('.ow_contest-posts-container0').append(response); jQuery('#ow_offset_'+cat_id).val(parseInt(offset)+parseInt(postperpage)); if(jQuery('.ow_load_stop').val()==-1){ jQuery('.ow_load_more_all').hide(); jQuery('.ow_all_contestloaded').delay(5000).fadeOut('slow'); } owvideojs_initialize(); jQuery(window).owllazyLoadXT(); ow_single_contestant_pretty(); resize_window(); }}); }); jQuery(function(){ var ow_infinite=jQuery('#ow_infinite_all').val(); if(ow_infinite==1){ var scrollFunction=function(){ jQuery('.ow_all_contestloaded').delay(5000).fadeOut('slow'); var mostOfTheWayDown=(jQuery(document).height() - jQuery('.ow_views_container').height()) * 1 / 3; if(jQuery(window).scrollTop() >=mostOfTheWayDown){ jQuery(window).unbind("scroll"); var obj=jQuery('.ow_views_container'); var cat_id=jQuery('.ow_all_cat_id').val(); var postperpage=jQuery('#ow_postperpage_'+cat_id).val(); var offset=jQuery('#ow_offset_'+cat_id).val(); var ow_category_options=jQuery('#ow_category_options_'+cat_id).val(); var show_cont_args=jQuery('#ow_show_cont_args_'+cat_id).val(); var global_options=jQuery('#ow_show_global_'+cat_id).val(); var view=jQuery('.ow_vote_view_'+cat_id).attr('data-view'); if(jQuery('.ow_load_stop').val()!=-1){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'voting_load_more', cat_id:cat_id, postperpage:postperpage, category_option:ow_category_options, show_cont_args:show_cont_args, global_options:global_options, ow_view:view, offset:offset, ow_ajax_flag:1, ow_search:jQuery('#ow_search_input').val(), }, type: 'POST', cache: false, dataType: 'html', beforeSend:function(){ jQuery('.ow_jx_loader_'+cat_id).show(); }, success: function(response){ jQuery('.ow_jx_loader_'+cat_id).hide(); jQuery('.ow_contest-posts-container0').append(response); jQuery('#ow_offset_'+cat_id).val(parseInt(offset)+parseInt(postperpage)); setTimeout(function(){jQuery(window).scroll(scrollFunction)},1000); owvideojs_initialize(); jQuery(window).owllazyLoadXT(); ow_single_contestant_pretty(); resize_window(); }}); }} }; setTimeout(function(){ jQuery(window).scroll(scrollFunction)},1000 ); }}); } function owvideojs_initialize(){ jQuery(".video-js").each(function (videoIndex){ var videoId=jQuery(this).attr("id"); videojs(videoId).ready(function(){ this.on("play", function(e){ jQuery(".video-js").each(function (index){ if(videoIndex!==index){ this.player.pause(); }}); }); }); }); } function getUrlParameter(sParam){ var sPageURL=decodeURIComponent(window.location.search.substring(1)), sURLVariables=sPageURL.split('&'), sParameterName, i; for (i=0; i < sURLVariables.length; i++){ sParameterName=sURLVariables[i].split('='); if(sParameterName[0]===sParam){ return sParameterName[1]===undefined ? true:sParameterName[1]; }} } function ow_success_message(){ var ow_sucess_message=jQuery('#ow_sucess_message').val(); var ow_sucess_approve=jQuery('#ow_sucess_approve').val(); var social_share=""; var success=getUrlParameter('success'); if(ow_sucess_message!=undefined&&success!=undefined){ if(ow_sucess_approve!=undefined&&ow_sucess_approve!=0){ jQuery.ajax({ url: vote_path_local.votesajaxurl, data:{ action:'ow_social_share_icons', post_id:ow_sucess_approve, }, type: 'POST', cache: false, dataType: 'html', success: function(response){ jQuery.ow_vote_fancybox('

    Contestant Submission

    '+ '
    '+ow_sucess_message+'
    '+response+'
    ', { 'padding':0, 'width':500, 'height':340, 'maxWidth': 500, 'maxHeight': 340, 'minWidth': 350, 'minHeight': 190 }); }}); }else{ social_share=""; jQuery.ow_vote_fancybox('

    Contestant Submission

    '+ '
    '+ow_sucess_message+'
    '+social_share+'
    ', { 'padding':0, 'width':500, 'height':340, 'maxWidth': 500, 'maxHeight': 340, 'minWidth': 350, 'minHeight': 190 }); }} }; var all_play_list=[]; (function(window, undefined){ var document=window.document; (function(){var initializing=false, fnTest=/xyz/.test(function(){xyz;}) ? /\b_super\b/:/.*/; this.JRClass=function(){}; JRClass.extend=function(prop){ var _super=this.prototype; initializing=true; var prototype=new this(); initializing=false; for (var name in prop){ prototype[name]=typeof prop[name]=="function"&&typeof _super[name]=="function"&&fnTest.test(prop[name]) ? (function(name, fn){ return function(){ var tmp=this._super; this._super=_super[name]; var ret=fn.apply(this, arguments); this._super=tmp; return ret; };})(name, prop[name]):prop[name]; } function JRClass(){ if(!initializing&&this.init) this.init.apply(this, arguments); } JRClass.prototype=prototype; JRClass.constructor=JRClass; JRClass.extend=arguments.callee; return JRClass;};})(); var AudioJS=JRClass.extend({ init: function(element, setOptions){ if(typeof element=='string'){ this.audio=document.getElementById(element); }else{ this.audio=element; } this.audio.player=this; this.values={}; this.elements={}; this.options={ autoplay: false, preload: false, useBuiltInControls: false, controlsAtStart: true, controlsHiding: false, defaultVolume: 0.85, volumeBars: 6, playerFallbackOrder: ["html5", "links"] }; if(typeof AudioJS.options=="object"){ AudioJS.merge(this.options, AudioJS.options); } if(typeof setOptions=="object"){ AudioJS.merge(this.options, setOptions); } if(this.getPreloadAttribute()!==undefined){ this.options.preload=this.getPreloadAttribute(); } if(this.getAutoplayAttribute()!==undefined){ this.options.autoplay=this.getAutoplayAttribute(); } this.box=this.audio.parentNode; this.linksFallback=this.getLinksFallback(); this.hideLinksFallback(); this.each(this.options.playerFallbackOrder, function(playerType){ if(this[playerType+"Supported"]()){ this[playerType+"Init"](); return true; }}); this.activateElement(this, "player"); this.activateElement(this.box, "box"); }, behaviors: {}, newBehavior: function(name, activate, functions){ this.behaviors[name]=activate; this.extend(functions); }, activateElement: function(element, behavior){ if(typeof element=="string"){ element=document.getElementById(element); } this.behaviors[behavior].call(this, element); }, errors: [], warnings: [], warning: function(warning){ this.warnings.push(warning); this.log(warning); }, history: [], log: function(event){ if(!event){ return; } if(typeof event=="string"){ event={ type: event };} if(event.type){ this.history.push(event.type); } if(this.history.length >=50){ this.history.shift(); } try { console.log(event.type); } catch(e){ try { opera.postError(event.type); } catch(e){}} }, setLocalStorage: function(key, value){ if(!localStorage){ return; } try { localStorage[key]=value; } catch(e){ if(e.code==22||e.code==1014){ this.warning(AudioJS.warnings.localStorageFull); }} }, getPreloadAttribute: function(){ if(typeof this.audio.hasAttribute=="function"&&this.audio.hasAttribute("preload")){ var preload=this.audio.getAttribute("preload"); if(preload===""||preload==="true"){ return "auto"; } if(preload==="false"){ return "none"; } return preload; }}, getAutoplayAttribute: function(){ if(typeof this.audio.hasAttribute=="function"&&this.audio.hasAttribute("autoplay")){ var autoplay=this.audio.getAttribute("autoplay"); if(autoplay==="false"){ return false; } return true; }}, bufferedPercent: function(){ return (this.duration()) ? this.buffered()[1] / this.duration():0; }, each: function(arr, fn){ if(!arr||arr.length===0){ return; } for (var i=0,j=arr.length; i 0){ var newBufferEnd=(event.loaded / event.total) * this.duration(); if(newBufferEnd > this.values.bufferEnd){ this.values.bufferEnd=newBufferEnd; }} }, iOSInterface: function(){ if(AudioJS.iOSVersion() < 4){ this.forceTheSource(); } if(AudioJS.isIPad()){ this.buildAndActivateSpinner(); }}, androidInterface: function(){ this.forceTheSource(); _A_.addListener(this.audio, "click", function(){ this.play(); }); }, loadInterface: function(){ if(this.options.controlsAtStart){ this.showControlBars(); } this.positionControlBars(); }, buildAndActivateControlBar: function(){ jQuery('.audio-js').addClass('embeded_music'); this.controls=_A_.createElement("div", { className: "ajs-controls" }); this.box.appendChild(this.controls); this.activateElement(this.controls, "controlBar"); this.activateElement(this.controls, "mouseOverAudioReporter"); var get_image_feature=this.audio.getAttribute('datafeatured-img'); var check_css=false; if(get_image_feature!=''&&get_image_feature!=undefined){ this.featuredimageMeta=_A_.createElement("div", { className: "ow_msc_featureimage", innerHTML: '' }); this.controls.appendChild(this.featuredimageMeta); }else{ var check_css=jQuery(".audio-js-box").hasClass("hu-css"); } this.descriptionMeta=_A_.createElement("div", { className: "description", innerHTML: this.audio.getAttribute('data-description') }); this.controls.appendChild(this.descriptionMeta); this.playControl=_A_.createElement("div", { className: "ajs-play-control", innerHTML: "" }); this.controls.appendChild(this.playControl); this.activateElement(this.playControl, "playToggle"); if(check_css){ jQuery(".ajs-play-control").attr('style','left:20px;'); } this.progressControl=_A_.createElement("div", { className: "ajs-progress-control" }); this.controls.appendChild(this.progressControl); this.progressHolder=_A_.createElement("div", { className: "ajs-progress-holder" }); this.progressControl.appendChild(this.progressHolder); this.activateElement(this.progressHolder, "currentTimeScrubber"); this.loadProgressBar=_A_.createElement("div", { className: "ajs-load-progress" }); this.progressHolder.appendChild(this.loadProgressBar); this.activateElement(this.loadProgressBar, "loadProgressBar"); this.playProgressBar=_A_.createElement("div", { className: "ajs-play-progress" }); this.progressHolder.appendChild(this.playProgressBar); this.activateElement(this.playProgressBar, "playProgressBar"); this.timeControl=_A_.createElement("div", { className: "ajs-time-control" }); this.controls.appendChild(this.timeControl); this.currentTimeDisplay=_A_.createElement("span", { className: "ajs-current-time-display", innerHTML: "00:00" }); this.timeControl.appendChild(this.currentTimeDisplay); this.activateElement(this.currentTimeDisplay, "currentTimeDisplay"); this.timeSeparator=_A_.createElement("span", { innerHTML: " / " }); this.timeControl.appendChild(this.timeSeparator); this.durationDisplay=_A_.createElement("span", { className: "ajs-duration-display", innerHTML: "00:00" }); this.timeControl.appendChild(this.durationDisplay); this.activateElement(this.durationDisplay, "durationDisplay"); var bars=[]; while(bars.length < this.options.volumeBars){ bars.push(''); } this.volumeControl=_A_.createElement("div", { className: "ajs-volume-control", innerHTML: "
    " + bars.join('') + "
    " }); this.controls.appendChild(this.volumeControl); this.activateElement(this.volumeControl, "volumeScrubber"); this.volumeDisplay=this.volumeControl.children[0]; this.activateElement(this.volumeDisplay, "volumeDisplay"); }, buildAndActivateSpinner: function(){ this.spinner=_A_.createElement("div", {className: "ajs-spinner"}); this.box.appendChild(this.spinner); this.activateElement(this.spinner, "spinner"); }, addAudioListener: function(type, fn){ _A_.addListener(this.audio, type, fn.rEvtContext(this)); }, play: function(){ this.each(_A_.getAudioJSTags(), function(players){ players.pause(); }); this.audio.play(); return this; }, onPlay: function(fn){ this.addAudioListener("play", fn); return this; }, pause: function(){ this.audio.pause(); return this; }, onPause: function(fn){ this.addAudioListener("pause", fn); return this; }, paused: function(){ return this.audio.paused; }, currentTime: function(seconds){ if(seconds!==undefined){ try { this.audio.currentTime=seconds; } catch(e){ this.warning(AudioJS.warnings.audioNotReady); } this.values.currentTime=seconds; return this; } return this.audio.currentTime; }, onCurrentTimeUpdate: function(fn){ this.currentTimeListeners.push(fn); }, duration: function(){ return this.audio.duration; }, buffered: function(){ if(this.values.bufferStart===undefined){ this.values.bufferStart=0; this.values.bufferEnd=0; } if(this.audio.buffered&&this.audio.buffered.length > 0){ var newEnd=this.audio.buffered.end(0); if(newEnd > this.values.bufferEnd){ this.values.bufferEnd=newEnd; }} return [this.values.bufferStart, this.values.bufferEnd]; }, volume: function(percentAsDecimal){ if(percentAsDecimal!==undefined){ this.values.volume=Math.max(0, Math.min(1, parseFloat(percentAsDecimal))); this.audio.volume=this.values.volume; this.setLocalStorage("volume", this.values.volume); return this; } if(this.values.volume){ return this.values.volume; } return this.audio.volume; }, onVolumeChange: function(fn){ _A_.addListener(this.audio, 'volumechange', fn.rEvtContext(this)); }, width: function(width){ if(width!==undefined){ this.audio.width=width; this.box.style.width=width+"px"; this.triggerResizeListeners(); return this; } return this.audio.offsetWidth||this.audio.style.width||400; }, height: function(height){ if(height!==undefined){ this.audio.height=height; this.box.style.height=height+"px"; this.triggerResizeListeners(); return this; } return this.audio.offsetHeight; }, onError: function(fn){ this.addAudioListener("error", fn); return this; }, onEnded: function(fn){ this.addAudioListener("ended", fn); return this; }}); AudioJS.player.newBehavior("player", function(player){ this.onError(this.playerOnAudioError); this.onPlay(this.playerOnAudioPlay); this.onPlay(this.trackCurrentTime); this.onPause(this.playerOnAudioPause); this.onPause(this.stopTrackingCurrentTime); this.onEnded(this.playerOnAudioEnded); this.trackBuffered(); this.onBufferedUpdate(this.isBufferFull); },{ playerOnAudioError: function(event){ this.log(event); this.log(this.audio.error); }, playerOnAudioPlay: function(event){ this.hasPlayed=true; }, playerOnAudioPause: function(event){}, playerOnAudioEnded: function(event){ this.currentTime(0); this.pause(); }, trackBuffered: function(){ this.bufferedInterval=setInterval(this.triggerBufferedListeners.context(this), 500); }, stopTrackingBuffered: function(){ clearInterval(this.bufferedInterval); }, bufferedListeners: [], onBufferedUpdate: function(fn){ this.bufferedListeners.push(fn); }, triggerBufferedListeners: function(){ this.isBufferFull(); this.each(this.bufferedListeners, function(listener){ (listener.context(this))(); }); }, isBufferFull: function(){ if(this.bufferedPercent()==1){ this.stopTrackingBuffered(); }}, trackCurrentTime: function(){ if(this.currentTimeInterval){ clearInterval(this.currentTimeInterval); } this.currentTimeInterval=setInterval(this.triggerCurrentTimeListeners.context(this), 100); this.trackingCurrentTime=true; }, stopTrackingCurrentTime: function(){ clearInterval(this.currentTimeInterval); this.trackingCurrentTime=false; }, currentTimeListeners: [], triggerCurrentTimeListeners: function(late, newTime){ this.each(this.currentTimeListeners, function(listener){ (listener.context(this))(newTime||this.currentTime()); }); }, resizeListeners: [], onResize: function(fn){ this.resizeListeners.push(fn); }, triggerResizeListeners: function(){ this.each(this.resizeListeners, function(listener){ (listener.context(this))(); }); }} ); AudioJS.player.newBehavior("mouseOverAudioReporter", function(element){ _A_.addListener(element, "mousemove", this.mouseOverAudioReporterOnMouseMove.context(this)); _A_.addListener(element, "mouseout", this.mouseOverAudioReporterOnMouseOut.context(this)); },{ mouseOverAudioReporterOnMouseMove: function(){ this.showControlBars(); clearInterval(this.mouseMoveTimeout); this.mouseMoveTimeout=setTimeout(this.hideControlBars.context(this), 4000); }, mouseOverAudioReporterOnMouseOut: function(event){ var parent=event.relatedTarget; while (parent&&parent!==this.box){ parent=parent.parentNode; } if(parent!==this.box){ this.hideControlBars(); }} } ); AudioJS.player.newBehavior("box", function(element){ _A_.addClass(element, "ajs-paused"); this.activateElement(element, "mouseOverAudioReporter"); this.onPlay(this.boxOnAudioPlay); this.onPause(this.boxOnAudioPause); },{ boxOnAudioPlay: function(){ _A_.removeClass(this.box, "ajs-paused"); _A_.addClass(this.box, "ajs-playing"); }, boxOnAudioPause: function(){ _A_.removeClass(this.box, "ajs-playing"); _A_.addClass(this.box, "ajs-paused"); }} ); AudioJS.player.newBehavior("controlBar", function(element){ if(!this.controlBars){ this.controlBars=[]; this.onResize(this.positionControlBars); } this.controlBars.push(element); _A_.addListener(element, "mousemove", this.onControlBarsMouseMove.context(this)); _A_.addListener(element, "mouseout", this.onControlBarsMouseOut.context(this)); },{ showControlBars: function(){ if(!this.options.controlsAtStart&&!this.hasPlayed){ return; } this.each(this.controlBars, function(bar){ bar.style.display="block"; }); }, positionControlBars: function(){ this.updatePlayProgressBars(); this.updateLoadProgressBars(); }, hideControlBars: function(){ if(this.options.controlsHiding&&!this.mouseIsOverControls){ this.each(this.controlBars, function(bar){ bar.style.display="none"; }); }}, onControlBarsMouseMove: function(){ this.mouseIsOverControls=true; }, onControlBarsMouseOut: function(event){ this.mouseIsOverControls=false; }} ); AudioJS.player.newBehavior("playToggle", function(element){ if(!this.elements.playToggles){ this.elements.playToggles=[]; this.onPlay(this.playTogglesOnPlay); this.onPause(this.playTogglesOnPause); all_play_list.push(this); } this.elements.playToggles.push(element); _A_.addListener(element, "click", this.onPlayToggleClick.context(this)); },{ onPlayToggleClick: function(event){ if(this.paused()){ this.each(all_play_list, function(all_play){ all_play.pause(); }); this.play(); }else{ this.pause(); }}, playTogglesOnPlay: function(event){ this.each(this.elements.playToggles, function(toggle){ _A_.removeClass(toggle, "ajs-paused"); _A_.addClass(toggle, "ajs-playing"); }); }, playTogglesOnPause: function(event){ this.each(this.elements.playToggles, function(toggle){ _A_.removeClass(toggle, "ajs-playing"); _A_.addClass(toggle, "ajs-paused"); }); }} ); AudioJS.player.newBehavior("playButton", function(element){ _A_.addListener(element, "click", this.onPlayButtonClick.context(this)); },{ onPlayButtonClick: function(event){ this.play(); }} ); AudioJS.player.newBehavior("pauseButton", function(element){ _A_.addListener(element, "click", this.onPauseButtonClick.context(this)); },{ onPauseButtonClick: function(event){ this.pause(); }} ); AudioJS.player.newBehavior("playProgressBar", function(element){ if(!this.playProgressBars){ this.playProgressBars=[]; this.onCurrentTimeUpdate(this.updatePlayProgressBars); } this.playProgressBars.push(element); },{ updatePlayProgressBars: function(newTime){ var progress=(newTime!==undefined) ? newTime / this.duration():this.currentTime() / this.duration(); if(isNaN(progress)){ progress=0; } this.each(this.playProgressBars, function(bar){ if(bar.style){ bar.style.width=_A_.round(progress * 100, 2) + "%"; }}); }} ); AudioJS.player.newBehavior("loadProgressBar", function(element){ if(!this.loadProgressBars){ this.loadProgressBars=[]; } this.loadProgressBars.push(element); this.onBufferedUpdate(this.updateLoadProgressBars); },{ updateLoadProgressBars: function(){ this.each(this.loadProgressBars, function(bar){ if(bar.style){ bar.style.width=_A_.round(this.bufferedPercent() * 100, 2) + "%"; }}); }} ); AudioJS.player.newBehavior("currentTimeDisplay", function(element){ if(!this.currentTimeDisplays){ this.currentTimeDisplays=[]; this.onCurrentTimeUpdate(this.updateCurrentTimeDisplays); } this.currentTimeDisplays.push(element); },{ updateCurrentTimeDisplays: function(newTime){ if(!this.currentTimeDisplays){ return; } var time=(newTime) ? newTime:this.currentTime(); this.each(this.currentTimeDisplays, function(dis){ dis.innerHTML=_A_.formatTime(time); }); }} ); AudioJS.player.newBehavior("durationDisplay", function(element){ if(!this.durationDisplays){ this.durationDisplays=[]; this.onCurrentTimeUpdate(this.updateDurationDisplays); } this.durationDisplays.push(element); },{ updateDurationDisplays: function(){ if(!this.durationDisplays){ return; } this.each(this.durationDisplays, function(dis){ if(this.duration()){ dis.innerHTML=_A_.formatTime(this.duration()); }}); }} ); AudioJS.player.newBehavior("currentTimeScrubber", function(element){ _A_.addListener(element, "mousedown", this.onCurrentTimeScrubberMouseDown.rEvtContext(this)); },{ onCurrentTimeScrubberMouseDown: function(event, scrubber){ event.preventDefault(); this.currentScrubber=scrubber; this.stopTrackingCurrentTime(); this.audioWasPlaying = !this.paused(); this.pause(); _A_.blockTextSelection(); this.setCurrentTimeWithScrubber(event); _A_.addListener(document, "mousemove", this.onCurrentTimeScrubberMouseMove.rEvtContext(this)); _A_.addListener(document, "mouseup", this.onCurrentTimeScrubberMouseUp.rEvtContext(this)); }, onCurrentTimeScrubberMouseMove: function(event){ this.setCurrentTimeWithScrubber(event); }, onCurrentTimeScrubberMouseUp: function(event){ _A_.unblockTextSelection(); document.removeEventListener("mousemove", this.onCurrentTimeScrubberMouseMove, false); document.removeEventListener("mouseup", this.onCurrentTimeScrubberMouseUp, false); if(this.audioWasPlaying){ this.play(); this.trackCurrentTime(); }}, setCurrentTimeWithScrubber: function(event){ var newProgress=_A_.getRelativePosition(event.pageX, this.currentScrubber); var newTime=newProgress * this.duration(); this.triggerCurrentTimeListeners(0, newTime); if(newTime==this.duration()){ newTime=newTime - 0.1; } this.currentTime(newTime); }} ); AudioJS.player.newBehavior("volumeDisplay", function(element){ if(!this.volumeDisplays){ this.volumeDisplays=[]; this.onVolumeChange(this.updateVolumeDisplays); } this.volumeDisplays.push(element); this.updateVolumeDisplay(element); },{ updateVolumeDisplays: function(){ if(!this.volumeDisplays){ return; } this.each(this.volumeDisplays, function(dis){ this.updateVolumeDisplay(dis); }); }, updateVolumeDisplay: function(display){ var volNum=Math.ceil(this.volume() * this.options.volumeBars); this.each(display.children, function(child, num){ if(num < volNum){ _A_.addClass(child, "ajs-volume-level-on"); }else{ _A_.removeClass(child, "ajs-volume-level-on"); }}); }} ); AudioJS.player.newBehavior("volumeScrubber", function(element){ _A_.addListener(element, "mousedown", this.onVolumeScrubberMouseDown.rEvtContext(this)); },{ onVolumeScrubberMouseDown: function(event, scrubber){ _A_.blockTextSelection(); this.currentScrubber=scrubber; this.setVolumeWithScrubber(event); _A_.addListener(document, "mousemove", this.onVolumeScrubberMouseMove.rEvtContext(this)); _A_.addListener(document, "mouseup", this.onVolumeScrubberMouseUp.rEvtContext(this)); }, onVolumeScrubberMouseMove: function(event){ this.setVolumeWithScrubber(event); }, onVolumeScrubberMouseUp: function(event){ this.setVolumeWithScrubber(event); _A_.unblockTextSelection(); document.removeEventListener("mousemove", this.onVolumeScrubberMouseMove, false); document.removeEventListener("mouseup", this.onVolumeScrubberMouseUp, false); }, setVolumeWithScrubber: function(event){ var newVol=_A_.getRelativePosition(event.pageX, this.currentScrubber); this.volume(newVol); }} ); AudioJS.player.newBehavior("spinner", function(element){ if(!this.spinners){ this.spinners=[]; _A_.addListener(this.audio, "loadeddata", this.spinnersOnAudioLoadedData.context(this)); _A_.addListener(this.audio, "loadstart", this.spinnersOnAudioLoadStart.context(this)); _A_.addListener(this.audio, "seeking", this.spinnersOnAudioSeeking.context(this)); _A_.addListener(this.audio, "seeked", this.spinnersOnAudioSeeked.context(this)); _A_.addListener(this.audio, "canplay", this.spinnersOnAudioCanPlay.context(this)); _A_.addListener(this.audio, "canplaythrough", this.spinnersOnAudioCanPlayThrough.context(this)); _A_.addListener(this.audio, "waiting", this.spinnersOnAudioWaiting.context(this)); _A_.addListener(this.audio, "stalled", this.spinnersOnAudioStalled.context(this)); _A_.addListener(this.audio, "suspend", this.spinnersOnAudioSuspend.context(this)); _A_.addListener(this.audio, "playing", this.spinnersOnAudioPlaying.context(this)); _A_.addListener(this.audio, "timeupdate", this.spinnersOnAudioTimeUpdate.context(this)); } this.spinners.push(element); },{ showSpinners: function(){ this.each(this.spinners, function(spinner){ spinner.style.display="block"; }); clearInterval(this.spinnerInterval); this.spinnerInterval=setInterval(this.rotateSpinners.context(this), 100); }, hideSpinners: function(){ this.each(this.spinners, function(spinner){ spinner.style.display="none"; }); clearInterval(this.spinnerInterval); }, spinnersRotated: 0, rotateSpinners: function(){ }, spinnersOnAudioLoadedData: function(event){ this.hideSpinners(); }, spinnersOnAudioLoadStart: function(event){ this.showSpinners(); }, spinnersOnAudioSeeking: function(event){ }, spinnersOnAudioSeeked: function(event){ }, spinnersOnAudioCanPlay: function(event){ }, spinnersOnAudioCanPlayThrough: function(event){ this.hideSpinners(); }, spinnersOnAudioWaiting: function(event){ this.showSpinners(); }, spinnersOnAudioStalled: function(event){}, spinnersOnAudioSuspend: function(event){}, spinnersOnAudioPlaying: function(event){ this.hideSpinners(); }, spinnersOnAudioTimeUpdate: function(event){ if(this.spinner.style.display=="block"){ this.hideSpinners(); }} } ); AudioJS.extend({ addClass: function(element, classToAdd){ if((" "+element.className+" ").indexOf(" "+classToAdd+" ")==-1){ element.className=element.className==="" ? classToAdd:element.className + " " + classToAdd; }}, removeClass: function(element, classToRemove){ if(element.className.indexOf(classToRemove)==-1){ return; } var classNames=element.className.split(/\s+/); classNames.splice(classNames.lastIndexOf(classToRemove),1); element.className=classNames.join(" "); }, createElement: function(tagName, attributes){ return this.merge(document.createElement(tagName), attributes); }, blockTextSelection: function(){ document.body.focus(); document.onselectstart=function (){ return false; };}, unblockTextSelection: function(){ document.onselectstart=function (){ return true; };}, formatTime: function(secs){ var seconds=Math.round(secs); var minutes=Math.floor(seconds / 60); minutes=(minutes >=10) ? minutes:"0" + minutes; seconds=Math.floor(seconds % 60); seconds=(seconds >=10) ? seconds:"0" + seconds; return minutes + ":" + seconds; }, getRelativePosition: function(x, relativeElement){ return Math.max(0, Math.min(1, (x - this.findPosX(relativeElement)) / relativeElement.offsetWidth)); }, findPosX: function(obj){ var curleft=obj.offsetLeft; while(obj=obj.offsetParent){ curleft +=obj.offsetLeft; } return curleft; }, getComputedStyleValue: function(element, style){ return window.getComputedStyle(element, null).getPropertyValue(style); }, round: function(num, dec){ if(!dec){ dec=0; } return Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); }, addListener: function(element, type, handler){ if(element.addEventListener){ element.addEventListener(type, handler, false); }else if(element.attachEvent){ element.attachEvent("on"+type, handler); }}, removeListener: function(element, type, handler){ if(element.removeEventListener){ element.removeEventListener(type, handler, false); }else if(element.attachEvent){ element.detachEvent("on"+type, handler); }}, get: function(url, onSuccess){ if(typeof XMLHttpRequest=="undefined"){ XMLHttpRequest=function (){ try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e){} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (f){} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (g){} throw new Error("This browser does not support XMLHttpRequest."); };} var request=new XMLHttpRequest(); request.open("GET",url); request.onreadystatechange=function(){ if(request.readyState==4&&request.status==200){ onSuccess(request.responseText); }}.context(this); request.send(); }, trim: function(string){ return string.toString().replace(/^\s+/, "").replace(/\s+$/, ""); }, bindDOMReady: function(){ if(document.readyState==="complete"){ return AudioJS.onDOMReady(); } if(document.addEventListener){ document.addEventListener("DOMContentLoaded", AudioJS.DOMContentLoaded, false); window.addEventListener("load", AudioJS.onDOMReady, false); }else if(document.attachEvent){ document.attachEvent("onreadystatechange", AudioJS.DOMContentLoaded); window.attachEvent("onload", AudioJS.onDOMReady); }}, DOMContentLoaded: function(){ if(document.addEventListener){ document.removeEventListener("DOMContentLoaded", AudioJS.DOMContentLoaded, false); AudioJS.onDOMReady(); }else if(document.attachEvent){ if(document.readyState==="complete"){ document.detachEvent("onreadystatechange", AudioJS.DOMContentLoaded); AudioJS.onDOMReady(); }} }, DOMReadyList: [], addToDOMReady: function(fn){ if(AudioJS.DOMIsReady){ fn.call(document); }else{ AudioJS.DOMReadyList.push(fn); }}, DOMIsReady: false, onDOMReady: function(){ if(AudioJS.DOMIsReady){ return; } if(!document.body){ return setTimeout(AudioJS.onDOMReady, 13); } AudioJS.DOMIsReady=true; if(AudioJS.DOMReadyList){ for (var i=0; i", options: { disabled: false, create: null }, _createWidget: function(options, element){ element=$(element||this.defaultElement||this)[ 0 ]; this.element=$(element); this.uuid=widget_uuid++; this.eventNamespace="." + this.widgetName + this.uuid; this.bindings=$(); this.hoverable=$(); this.focusable=$(); if(element!==this){ $.data(element, this.widgetFullName, this); this._on(true, this.element, { remove: function(event){ if(event.target===element){ this.destroy(); }} }); this.document=$(element.style ? element.ownerDocument : element.document||element); this.window=$(this.document[0].defaultView||this.document[0].parentWindow); } this.options=$.widget.extend({}, this.options, this._getCreateOptions(), options); this._create(); this._trigger("create", null, this._getCreateEventData()); this._init(); }, _getCreateOptions: $.noop, _getCreateEventData: $.noop, _create: $.noop, _init: $.noop, destroy: function(){ this._destroy(); this.element .unbind(this.eventNamespace) .removeData(this.widgetFullName) .removeData($.camelCase(this.widgetFullName)); this.widget() .unbind(this.eventNamespace) .removeAttr("aria-disabled") .removeClass(this.widgetFullName + "-disabled " + "ui-state-disabled"); this.bindings.unbind(this.eventNamespace); this.hoverable.removeClass("ui-state-hover"); this.focusable.removeClass("ui-state-focus"); }, _destroy: $.noop, widget: function(){ return this.element; }, option: function(key, value){ var options=key, parts, curOption, i; if(arguments.length===0){ return $.widget.extend({}, this.options); } if(typeof key==="string"){ options={}; parts=key.split("."); key=parts.shift(); if(parts.length){ curOption=options[ key ]=$.widget.extend({}, this.options[ key ]); for(i=0; i < parts.length - 1; i++){ curOption[ parts[ i ] ]=curOption[ parts[ i ] ]||{}; curOption=curOption[ parts[ i ] ]; } key=parts.pop(); if(arguments.length===1){ return curOption[ key ]===undefined ? null:curOption[ key ]; } curOption[ key ]=value; }else{ if(arguments.length===1){ return this.options[ key ]===undefined ? null:this.options[ key ]; } options[ key ]=value; }} this._setOptions(options); return this; }, _setOptions: function(options){ var key; for(key in options){ this._setOption(key, options[ key ]); } return this; }, _setOption: function(key, value){ this.options[ key ]=value; if(key==="disabled"){ this.widget() .toggleClass(this.widgetFullName + "-disabled", !!value); if(value){ this.hoverable.removeClass("ui-state-hover"); this.focusable.removeClass("ui-state-focus"); }} return this; }, enable: function(){ return this._setOptions({ disabled: false }); }, disable: function(){ return this._setOptions({ disabled: true }); }, _on: function(suppressDisabledCheck, element, handlers){ var delegateElement, instance=this; if(typeof suppressDisabledCheck!=="boolean"){ handlers=element; element=suppressDisabledCheck; suppressDisabledCheck=false; } if(!handlers){ handlers=element; element=this.element; delegateElement=this.widget(); }else{ element=delegateElement=$(element); this.bindings=this.bindings.add(element); } $.each(handlers, function(event, handler){ function handlerProxy(){ if(!suppressDisabledCheck && (instance.options.disabled===true || $(this).hasClass("ui-state-disabled"))){ return; } return(typeof handler==="string" ? instance[ handler ]:handler) .apply(instance, arguments); } if(typeof handler!=="string"){ handlerProxy.guid=handler.guid = handler.guid||handlerProxy.guid||$.guid++; } var match=event.match(/^([\w:-]*)\s*(.*)$/), eventName=match[1] + instance.eventNamespace, selector=match[2]; if(selector){ delegateElement.delegate(selector, eventName, handlerProxy); }else{ element.bind(eventName, handlerProxy); }}); }, _off: function(element, eventName){ eventName=(eventName||"").split(" ").join(this.eventNamespace + " ") + this.eventNamespace; element.unbind(eventName).undelegate(eventName); this.bindings=$(this.bindings.not(element).get()); this.focusable=$(this.focusable.not(element).get()); this.hoverable=$(this.hoverable.not(element).get()); }, _delay: function(handler, delay){ function handlerProxy(){ return(typeof handler==="string" ? instance[ handler ]:handler) .apply(instance, arguments); } var instance=this; return setTimeout(handlerProxy, delay||0); }, _hoverable: function(element){ this.hoverable=this.hoverable.add(element); this._on(element, { mouseenter: function(event){ $(event.currentTarget).addClass("ui-state-hover"); }, mouseleave: function(event){ $(event.currentTarget).removeClass("ui-state-hover"); }}); }, _focusable: function(element){ this.focusable=this.focusable.add(element); this._on(element, { focusin: function(event){ $(event.currentTarget).addClass("ui-state-focus"); }, focusout: function(event){ $(event.currentTarget).removeClass("ui-state-focus"); }}); }, _trigger: function(type, event, data){ var prop, orig, callback=this.options[ type ]; data=data||{}; event=$.Event(event); event.type=(type===this.widgetEventPrefix ? type : this.widgetEventPrefix + type).toLowerCase(); event.target=this.element[ 0 ]; orig=event.originalEvent; if(orig){ for(prop in orig){ if(!(prop in event)){ event[ prop ]=orig[ prop ]; }} } this.element.trigger(event, data); return !($.isFunction(callback) && callback.apply(this.element[0], [ event ].concat(data))===false || event.isDefaultPrevented()); }}; $.each({ show: "fadeIn", hide: "fadeOut" }, function(method, defaultEffect){ $.Widget.prototype[ "_" + method ]=function(element, options, callback){ if(typeof options==="string"){ options={ effect: options };} var hasOptions, effectName = !options ? method : options===true||typeof options==="number" ? defaultEffect : options.effect||defaultEffect; options=options||{}; if(typeof options==="number"){ options={ duration: options };} hasOptions = !$.isEmptyObject(options); options.complete=callback; if(options.delay){ element.delay(options.delay); } if(hasOptions&&$.effects&&$.effects.effect[ effectName ]){ element[ method ](options); }else if(effectName!==method&&element[ effectName ]){ element[ effectName ](options.duration, options.easing, callback); }else{ element.queue(function(next){ $(this)[ method ](); if(callback){ callback.call(element[ 0 ]); } next(); }); }};}); var widget=$.widget; })); ;(function (factory){ 'use strict'; if(typeof define==='function'&&define.amd){ define([ 'jquery', 'jquery.ui.widget' ], factory); }else if(typeof exports==='object'){ factory( require('jquery'), require('./vendor/jquery.ui.widget') ); }else{ factory(window.jQuery); }}(function ($){ 'use strict'; $.support.fileInput = !(new RegExp( '(Android (1\\.[0156]|2\\.[01]))' + '|(Windows Phone (OS 7|8\\.0))|(XBLWP)|(ZuneWP)|(WPDesktop)' + '|(w(eb)?OSBrowser)|(webOS)' + '|(Kindle/(1\\.0|2\\.[05]|3\\.0))' ).test(window.navigator.userAgent) || $('').prop('disabled')); $.support.xhrFileUpload = !!(window.ProgressEvent&&window.FileReader); $.support.xhrFormDataFileUpload = !!window.FormData; $.support.blobSlice=window.Blob&&(Blob.prototype.slice || Blob.prototype.webkitSlice||Blob.prototype.mozSlice); function getDragHandler(type){ var isDragOver=type==='dragover'; return function (e){ e.dataTransfer=e.originalEvent&&e.originalEvent.dataTransfer; var dataTransfer=e.dataTransfer; if(dataTransfer&&$.inArray('Files', dataTransfer.types)!==-1 && this._trigger(type, $.Event(type, {delegatedEvent: e}) )!==false){ e.preventDefault(); if(isDragOver){ dataTransfer.dropEffect='copy'; }} };} $.widget('blueimp.fileupload', { options: { dropZone: $(document), pasteZone: undefined, fileInput: undefined, replaceFileInput: true, paramName: undefined, singleFileUploads: true, limitMultiFileUploads: undefined, limitMultiFileUploadSize: undefined, limitMultiFileUploadSizeOverhead: 512, sequentialUploads: false, limitConcurrentUploads: undefined, forceIframeTransport: false, redirect: undefined, redirectParamName: undefined, postMessage: undefined, multipart: true, maxChunkSize: undefined, uploadedBytes: undefined, recalculateProgress: true, progressInterval: 100, bitrateInterval: 500, autoUpload: true, messages: { uploadedBytes: 'Uploaded bytes exceed file size' }, i18n: function (message, context){ message=this.messages[message]||message.toString(); if(context){ $.each(context, function (key, value){ message=message.replace('{' + key + '}', value); }); } return message; }, formData: function (form){ return form.serializeArray(); }, add: function (e, data){ if(e.isDefaultPrevented()){ return false; } if(data.autoUpload||(data.autoUpload!==false && $(this).fileupload('option', 'autoUpload'))){ data.process().done(function (){ data.submit(); }); }}, processData: false, contentType: false, cache: false, timeout: 0 }, _specialOptions: [ 'fileInput', 'dropZone', 'pasteZone', 'multipart', 'forceIframeTransport' ], _blobSlice: $.support.blobSlice&&function (){ var slice=this.slice||this.webkitSlice||this.mozSlice; return slice.apply(this, arguments); }, _BitrateTimer: function (){ this.timestamp=((Date.now) ? Date.now():(new Date()).getTime()); this.loaded=0; this.bitrate=0; this.getBitrate=function (now, loaded, interval){ var timeDiff=now - this.timestamp; if(!this.bitrate||!interval||timeDiff > interval){ this.bitrate=(loaded - this.loaded) * (1000 / timeDiff) * 8; this.loaded=loaded; this.timestamp=now; } return this.bitrate; };}, _isXHRUpload: function (options){ return !options.forceIframeTransport && ((!options.multipart&&$.support.xhrFileUpload) || $.support.xhrFormDataFileUpload); }, _getFormData: function (options){ var formData; if($.type(options.formData)==='function'){ return options.formData(options.form); } if($.isArray(options.formData)){ return options.formData; } if($.type(options.formData)==='object'){ formData=[]; $.each(options.formData, function (name, value){ formData.push({name: name, value: value}); }); return formData; } return []; }, _getTotal: function (files){ var total=0; $.each(files, function (index, file){ total +=file.size||1; }); return total; }, _initProgressObject: function (obj){ var progress={ loaded: 0, total: 0, bitrate: 0 }; if(obj._progress){ $.extend(obj._progress, progress); }else{ obj._progress=progress; }}, _initResponseObject: function (obj){ var prop; if(obj._response){ for (prop in obj._response){ if(obj._response.hasOwnProperty(prop)){ delete obj._response[prop]; }} }else{ obj._response={};}}, _onProgress: function (e, data){ if(e.lengthComputable){ var now=((Date.now) ? Date.now():(new Date()).getTime()), loaded; if(data._time&&data.progressInterval && (now - data._time < data.progressInterval) && e.loaded!==e.total){ return; } data._time=now; loaded=Math.floor(e.loaded / e.total * (data.chunkSize||data._progress.total) ) + (data.uploadedBytes||0); this._progress.loaded +=(loaded - data._progress.loaded); this._progress.bitrate=this._bitrateTimer.getBitrate(now, this._progress.loaded, data.bitrateInterval ); data._progress.loaded=data.loaded=loaded; data._progress.bitrate=data.bitrate=data._bitrateTimer.getBitrate(now, loaded, data.bitrateInterval ); this._trigger('progress', $.Event('progress', {delegatedEvent: e}), data ); this._trigger('progressall', $.Event('progressall', {delegatedEvent: e}), this._progress ); }}, _initProgressListener: function (options){ var that=this, xhr=options.xhr ? options.xhr():$.ajaxSettings.xhr(); if(xhr.upload){ $(xhr.upload).bind('progress', function (e){ var oe=e.originalEvent; e.lengthComputable=oe.lengthComputable; e.loaded=oe.loaded; e.total=oe.total; that._onProgress(e, options); }); options.xhr=function (){ return xhr; };}}, _isInstanceOf: function (type, obj){ return Object.prototype.toString.call(obj)==='[object ' + type + ']'; }, _initXHRData: function (options){ var that=this, formData, file=options.files[0], multipart=options.multipart||!$.support.xhrFileUpload, paramName=$.type(options.paramName)==='array' ? options.paramName[0]:options.paramName; options.headers=$.extend({}, options.headers); if(options.contentRange){ options.headers['Content-Range']=options.contentRange; } if(!multipart||options.blob||!this._isInstanceOf('File', file)){ options.headers['Content-Disposition']='attachment; filename="' + encodeURI(file.name) + '"'; } if(!multipart){ options.contentType=file.type||'application/octet-stream'; options.data=options.blob||file; }else if($.support.xhrFormDataFileUpload){ if(options.postMessage){ formData=this._getFormData(options); if(options.blob){ formData.push({ name: paramName, value: options.blob }); }else{ $.each(options.files, function (index, file){ formData.push({ name: ($.type(options.paramName)==='array' && options.paramName[index])||paramName, value: file }); }); }}else{ if(that._isInstanceOf('FormData', options.formData)){ formData=options.formData; }else{ formData=new FormData(); $.each(this._getFormData(options), function (index, field){ formData.append(field.name, field.value); }); } if(options.blob){ formData.append(paramName, options.blob, file.name); }else{ $.each(options.files, function (index, file){ if(that._isInstanceOf('File', file) || that._isInstanceOf('Blob', file)){ formData.append(($.type(options.paramName)==='array' && options.paramName[index])||paramName, file, file.uploadName||file.name ); }}); }} options.data=formData; } options.blob=null; }, _initIframeSettings: function (options){ var targetHost=$('').prop('href', options.url).prop('host'); options.dataType='iframe ' + (options.dataType||''); options.formData=this._getFormData(options); if(options.redirect&&targetHost&&targetHost!==location.host){ options.formData.push({ name: options.redirectParamName||'redirect', value: options.redirect }); }}, _initDataSettings: function (options){ if(this._isXHRUpload(options)){ if(!this._chunkedUpload(options, true)){ if(!options.data){ this._initXHRData(options); } this._initProgressListener(options); } if(options.postMessage){ options.dataType='postmessage ' + (options.dataType||''); }}else{ this._initIframeSettings(options); }}, _getParamName: function (options){ var fileInput=$(options.fileInput), paramName=options.paramName; if(!paramName){ paramName=[]; fileInput.each(function (){ var input=$(this), name=input.prop('name')||'files[]', i=(input.prop('files')||[1]).length; while (i){ paramName.push(name); i -=1; }}); if(!paramName.length){ paramName=[fileInput.prop('name')||'files[]']; }}else if(!$.isArray(paramName)){ paramName=[paramName]; } return paramName; }, _initFormSettings: function (options){ if(!options.form||!options.form.length){ options.form=$(options.fileInput.prop('form')); if(!options.form.length){ options.form=$(this.options.fileInput.prop('form')); }} options.paramName=this._getParamName(options); if(!options.url){ options.url=options.form.prop('action')||location.href; } options.type=(options.type || ($.type(options.form.prop('method'))==='string' && options.form.prop('method'))||'' ).toUpperCase(); if(options.type!=='POST'&&options.type!=='PUT' && options.type!=='PATCH'){ options.type='POST'; } if(!options.formAcceptCharset){ options.formAcceptCharset=options.form.attr('accept-charset'); }}, _getAJAXSettings: function (data){ var options=$.extend({}, this.options, data); this._initFormSettings(options); this._initDataSettings(options); return options; }, _getDeferredState: function (deferred){ if(deferred.state){ return deferred.state(); } if(deferred.isResolved()){ return 'resolved'; } if(deferred.isRejected()){ return 'rejected'; } return 'pending'; }, _enhancePromise: function (promise){ promise.success=promise.done; promise.error=promise.fail; promise.complete=promise.always; return promise; }, _getXHRPromise: function (resolveOrReject, context, args){ var dfd=$.Deferred(), promise=dfd.promise(); context=context||this.options.context||promise; if(resolveOrReject===true){ dfd.resolveWith(context, args); }else if(resolveOrReject===false){ dfd.rejectWith(context, args); } promise.abort=dfd.promise; return this._enhancePromise(promise); }, _addConvenienceMethods: function (e, data){ var that=this, getPromise=function (args){ return $.Deferred().resolveWith(that, args).promise(); }; data.process=function (resolveFunc, rejectFunc){ if(resolveFunc||rejectFunc){ data._processQueue=this._processQueue = (this._processQueue||getPromise([this])).then(function (){ if(data.errorThrown){ return $.Deferred() .rejectWith(that, [data]).promise(); } return getPromise(arguments); } ).then(resolveFunc, rejectFunc); } return this._processQueue||getPromise([this]); }; data.submit=function (){ if(this.state()!=='pending'){ data.jqXHR=this.jqXHR = (that._trigger('submit', $.Event('submit', {delegatedEvent: e}), this )!==false)&&that._onSend(e, this); } return this.jqXHR||that._getXHRPromise(); }; data.abort=function (){ if(this.jqXHR){ return this.jqXHR.abort(); } this.errorThrown='abort'; that._trigger('fail', null, this); return that._getXHRPromise(false); }; data.state=function (){ if(this.jqXHR){ return that._getDeferredState(this.jqXHR); } if(this._processQueue){ return that._getDeferredState(this._processQueue); }}; data.processing=function (){ return !this.jqXHR&&this._processQueue&&that ._getDeferredState(this._processQueue)==='pending'; }; data.progress=function (){ return this._progress; }; data.response=function (){ return this._response; };}, _getUploadedBytes: function (jqXHR){ var range=jqXHR.getResponseHeader('Range'), parts=range&&range.split('-'), upperBytesPos=parts&&parts.length > 1 && parseInt(parts[1], 10); return upperBytesPos&&upperBytesPos + 1; }, _chunkedUpload: function (options, testOnly){ options.uploadedBytes=options.uploadedBytes||0; var that=this, file=options.files[0], fs=file.size, ub=options.uploadedBytes, mcs=options.maxChunkSize||fs, slice=this._blobSlice, dfd=$.Deferred(), promise=dfd.promise(), jqXHR, upload; if(!(this._isXHRUpload(options)&&slice&&(ub||mcs < fs)) || options.data){ return false; } if(testOnly){ return true; } if(ub >=fs){ file.error=options.i18n('uploadedBytes'); return this._getXHRPromise(false, options.context, [null, 'error', file.error] ); } upload=function (){ var o=$.extend({}, options), currentLoaded=o._progress.loaded; o.blob=slice.call(file, ub, ub + mcs, file.type ); o.chunkSize=o.blob.size; o.contentRange='bytes ' + ub + '-' + (ub + o.chunkSize - 1) + '/' + fs; that._initXHRData(o); that._initProgressListener(o); jqXHR=((that._trigger('chunksend', null, o)!==false&&$.ajax(o)) || that._getXHRPromise(false, o.context)) .done(function (result, textStatus, jqXHR){ ub=that._getUploadedBytes(jqXHR) || (ub + o.chunkSize); if(currentLoaded + o.chunkSize - o._progress.loaded){ that._onProgress($.Event('progress', { lengthComputable: true, loaded: ub - o.uploadedBytes, total: ub - o.uploadedBytes }), o); } options.uploadedBytes=o.uploadedBytes=ub; o.result=result; o.textStatus=textStatus; o.jqXHR=jqXHR; that._trigger('chunkdone', null, o); that._trigger('chunkalways', null, o); if(ub < fs){ upload(); }else{ dfd.resolveWith(o.context, [result, textStatus, jqXHR] ); }}) .fail(function (jqXHR, textStatus, errorThrown){ o.jqXHR=jqXHR; o.textStatus=textStatus; o.errorThrown=errorThrown; that._trigger('chunkfail', null, o); that._trigger('chunkalways', null, o); dfd.rejectWith(o.context, [jqXHR, textStatus, errorThrown] ); }); }; this._enhancePromise(promise); promise.abort=function (){ return jqXHR.abort(); }; upload(); return promise; }, _beforeSend: function (e, data){ if(this._active===0){ this._trigger('start'); this._bitrateTimer=new this._BitrateTimer(); this._progress.loaded=this._progress.total=0; this._progress.bitrate=0; } this._initResponseObject(data); this._initProgressObject(data); data._progress.loaded=data.loaded=data.uploadedBytes||0; data._progress.total=data.total=this._getTotal(data.files)||1; data._progress.bitrate=data.bitrate=0; this._active +=1; this._progress.loaded +=data.loaded; this._progress.total +=data.total; }, _onDone: function (result, textStatus, jqXHR, options){ var total=options._progress.total, response=options._response; if(options._progress.loaded < total){ this._onProgress($.Event('progress', { lengthComputable: true, loaded: total, total: total }), options); } response.result=options.result=result; response.textStatus=options.textStatus=textStatus; response.jqXHR=options.jqXHR=jqXHR; this._trigger('done', null, options); }, _onFail: function (jqXHR, textStatus, errorThrown, options){ var response=options._response; if(options.recalculateProgress){ this._progress.loaded -=options._progress.loaded; this._progress.total -=options._progress.total; } response.jqXHR=options.jqXHR=jqXHR; response.textStatus=options.textStatus=textStatus; response.errorThrown=options.errorThrown=errorThrown; this._trigger('fail', null, options); }, _onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options){ this._trigger('always', null, options); }, _onSend: function (e, data){ if(!data.submit){ this._addConvenienceMethods(e, data); } var that=this, jqXHR, aborted, slot, pipe, options=that._getAJAXSettings(data), send=function (){ that._sending +=1; options._bitrateTimer=new that._BitrateTimer(); jqXHR=jqXHR||( ((aborted||that._trigger('send', $.Event('send', {delegatedEvent: e}), options )===false) && that._getXHRPromise(false, options.context, aborted)) || that._chunkedUpload(options)||$.ajax(options) ).done(function (result, textStatus, jqXHR){ that._onDone(result, textStatus, jqXHR, options); }).fail(function (jqXHR, textStatus, errorThrown){ that._onFail(jqXHR, textStatus, errorThrown, options); }).always(function (jqXHRorResult, textStatus, jqXHRorError){ that._onAlways(jqXHRorResult, textStatus, jqXHRorError, options ); that._sending -=1; that._active -=1; if(options.limitConcurrentUploads && options.limitConcurrentUploads > that._sending){ var nextSlot=that._slots.shift(); while (nextSlot){ if(that._getDeferredState(nextSlot)==='pending'){ nextSlot.resolve(); break; } nextSlot=that._slots.shift(); }} if(that._active===0){ that._trigger('stop'); }}); return jqXHR; }; this._beforeSend(e, options); if(this.options.sequentialUploads || (this.options.limitConcurrentUploads && this.options.limitConcurrentUploads <=this._sending)){ if(this.options.limitConcurrentUploads > 1){ slot=$.Deferred(); this._slots.push(slot); pipe=slot.then(send); }else{ this._sequence=this._sequence.then(send, send); pipe=this._sequence; } pipe.abort=function (){ aborted=[undefined, 'abort', 'abort']; if(!jqXHR){ if(slot){ slot.rejectWith(options.context, aborted); } return send(); } return jqXHR.abort(); }; return this._enhancePromise(pipe); } return send(); }, _onAdd: function (e, data){ var that=this, result=true, options=$.extend({}, this.options, data), files=data.files, filesLength=files.length, limit=options.limitMultiFileUploads, limitSize=options.limitMultiFileUploadSize, overhead=options.limitMultiFileUploadSizeOverhead, batchSize=0, paramName=this._getParamName(options), paramNameSet, paramNameSlice, fileSet, i, j=0; if(!filesLength){ return false; } if(limitSize&&files[0].size===undefined){ limitSize=undefined; } if(!(options.singleFileUploads||limit||limitSize) || !this._isXHRUpload(options)){ fileSet=[files]; paramNameSet=[paramName]; }else if(!(options.singleFileUploads||limitSize)&&limit){ fileSet=[]; paramNameSet=[]; for (i=0; i < filesLength; i +=limit){ fileSet.push(files.slice(i, i + limit)); paramNameSlice=paramName.slice(i, i + limit); if(!paramNameSlice.length){ paramNameSlice=paramName; } paramNameSet.push(paramNameSlice); }}else if(!options.singleFileUploads&&limitSize){ fileSet=[]; paramNameSet=[]; for (i=0; i < filesLength; i=i + 1){ batchSize +=files[i].size + overhead; if(i + 1===filesLength || ((batchSize + files[i + 1].size + overhead) > limitSize) || (limit&&i + 1 - j >=limit)){ fileSet.push(files.slice(j, i + 1)); paramNameSlice=paramName.slice(j, i + 1); if(!paramNameSlice.length){ paramNameSlice=paramName; } paramNameSet.push(paramNameSlice); j=i + 1; batchSize=0; }} }else{ paramNameSet=paramName; } data.originalFiles=files; $.each(fileSet||files, function (index, element){ var newData=$.extend({}, data); newData.files=fileSet ? element:[element]; newData.paramName=paramNameSet[index]; that._initResponseObject(newData); that._initProgressObject(newData); that._addConvenienceMethods(e, newData); result=that._trigger('add', $.Event('add', {delegatedEvent: e}), newData ); return result; }); return result; }, _replaceFileInput: function (data){ var input=data.fileInput, inputClone=input.clone(true), restoreFocus=input.is(document.activeElement); data.fileInputClone=inputClone; $('
    ').append(inputClone)[0].reset(); input.after(inputClone).detach(); if(restoreFocus){ inputClone.focus(); } $.cleanData(input.unbind('remove')); this.options.fileInput=this.options.fileInput.map(function (i, el){ if(el===input[0]){ return inputClone[0]; } return el; }); if(input[0]===this.element[0]){ this.element=inputClone; }}, _handleFileTreeEntry: function (entry, path){ var that=this, dfd=$.Deferred(), errorHandler=function (e){ if(e&&!e.entry){ e.entry=entry; } dfd.resolve([e]); }, successHandler=function (entries){ that._handleFileTreeEntries(entries, path + entry.name + '/' ).done(function (files){ dfd.resolve(files); }).fail(errorHandler); }, readEntries=function (){ dirReader.readEntries(function (results){ if(!results.length){ successHandler(entries); }else{ entries=entries.concat(results); readEntries(); }}, errorHandler); }, dirReader, entries=[]; path=path||''; if(entry.isFile){ if(entry._file){ entry._file.relativePath=path; dfd.resolve(entry._file); }else{ entry.file(function (file){ file.relativePath=path; dfd.resolve(file); }, errorHandler); }}else if(entry.isDirectory){ dirReader=entry.createReader(); readEntries(); }else{ dfd.resolve([]); } return dfd.promise(); }, _handleFileTreeEntries: function (entries, path){ var that=this; return $.when.apply($, $.map(entries, function (entry){ return that._handleFileTreeEntry(entry, path); }) ).then(function (){ return Array.prototype.concat.apply([], arguments ); }); }, _getDroppedFiles: function (dataTransfer){ dataTransfer=dataTransfer||{}; var items=dataTransfer.items; if(items&&items.length&&(items[0].webkitGetAsEntry || items[0].getAsEntry)){ return this._handleFileTreeEntries($.map(items, function (item){ var entry; if(item.webkitGetAsEntry){ entry=item.webkitGetAsEntry(); if(entry){ entry._file=item.getAsFile(); } return entry; } return item.getAsEntry(); }) ); } return $.Deferred().resolve($.makeArray(dataTransfer.files) ).promise(); }, _getSingleFileInputFiles: function (fileInput){ fileInput=$(fileInput); var entries=fileInput.prop('webkitEntries') || fileInput.prop('entries'), files, value; if(entries&&entries.length){ return this._handleFileTreeEntries(entries); } files=$.makeArray(fileInput.prop('files')); if(!files.length){ value=fileInput.prop('value'); if(!value){ return $.Deferred().resolve([]).promise(); } files=[{name: value.replace(/^.*\\/, '')}]; }else if(files[0].name===undefined&&files[0].fileName){ $.each(files, function (index, file){ file.name=file.fileName; file.size=file.fileSize; }); } return $.Deferred().resolve(files).promise(); }, _getFileInputFiles: function (fileInput){ if(!(fileInput instanceof $)||fileInput.length===1){ return this._getSingleFileInputFiles(fileInput); } return $.when.apply($, $.map(fileInput, this._getSingleFileInputFiles) ).then(function (){ return Array.prototype.concat.apply([], arguments ); }); }, _onChange: function (e){ var that=this, data={ fileInput: $(e.target), form: $(e.target.form) }; this._getFileInputFiles(data.fileInput).always(function (files){ data.files=files; if(that.options.replaceFileInput){ that._replaceFileInput(data); } if(that._trigger('change', $.Event('change', {delegatedEvent: e}), data )!==false){ that._onAdd(e, data); }}); }, _onPaste: function (e){ var items=e.originalEvent&&e.originalEvent.clipboardData && e.originalEvent.clipboardData.items, data={files: []}; if(items&&items.length){ $.each(items, function (index, item){ var file=item.getAsFile&&item.getAsFile(); if(file){ data.files.push(file); }}); if(this._trigger('paste', $.Event('paste', {delegatedEvent: e}), data )!==false){ this._onAdd(e, data); }} }, _onDrop: function (e){ e.dataTransfer=e.originalEvent&&e.originalEvent.dataTransfer; var that=this, dataTransfer=e.dataTransfer, data={}; if(dataTransfer&&dataTransfer.files&&dataTransfer.files.length){ e.preventDefault(); this._getDroppedFiles(dataTransfer).always(function (files){ data.files=files; if(that._trigger('drop', $.Event('drop', {delegatedEvent: e}), data )!==false){ that._onAdd(e, data); }}); }}, _onDragOver: getDragHandler('dragover'), _onDragEnter: getDragHandler('dragenter'), _onDragLeave: getDragHandler('dragleave'), _initEventHandlers: function (){ if(this._isXHRUpload(this.options)){ this._on(this.options.dropZone, { dragover: this._onDragOver, drop: this._onDrop, dragenter: this._onDragEnter, dragleave: this._onDragLeave }); this._on(this.options.pasteZone, { paste: this._onPaste }); } if($.support.fileInput){ this._on(this.options.fileInput, { change: this._onChange }); }}, _destroyEventHandlers: function (){ this._off(this.options.dropZone, 'dragenter dragleave dragover drop'); this._off(this.options.pasteZone, 'paste'); this._off(this.options.fileInput, 'change'); }, _setOption: function (key, value){ var reinit=$.inArray(key, this._specialOptions)!==-1; if(reinit){ this._destroyEventHandlers(); } this._super(key, value); if(reinit){ this._initSpecialOptions(); this._initEventHandlers(); }}, _initSpecialOptions: function (){ var options=this.options; if(options.fileInput===undefined){ options.fileInput=this.element.is('input[type="file"]') ? this.element:this.element.find('input[type="file"]'); }else if(!(options.fileInput instanceof $)){ options.fileInput=$(options.fileInput); } if(!(options.dropZone instanceof $)){ options.dropZone=$(options.dropZone); } if(!(options.pasteZone instanceof $)){ options.pasteZone=$(options.pasteZone); }}, _getRegExp: function (str){ var parts=str.split('/'), modifiers=parts.pop(); parts.shift(); return new RegExp(parts.join('/'), modifiers); }, _isRegExpOption: function (key, value){ return key!=='url'&&$.type(value)==='string' && /^\/.*\/[igm]{0,3}$/.test(value); }, _initDataAttributes: function (){ var that=this, options=this.options, data=this.element.data(); $.each(this.element[0].attributes, function (index, attr){ var key=attr.name.toLowerCase(), value; if(/^data-/.test(key)){ key=key.slice(5).replace(/-[a-z]/g, function (str){ return str.charAt(1).toUpperCase(); }); value=data[key]; if(that._isRegExpOption(key, value)){ value=that._getRegExp(value); } options[key]=value; }} ); }, _create: function (){ this._initDataAttributes(); this._initSpecialOptions(); this._slots=[]; this._sequence=this._getXHRPromise(true); this._sending=this._active=0; this._initProgressObject(this); this._initEventHandlers(); }, active: function (){ return this._active; }, progress: function (){ return this._progress; }, add: function (data){ var that=this; if(!data||this.options.disabled){ return; } if(data.fileInput&&!data.files){ this._getFileInputFiles(data.fileInput).always(function (files){ data.files=files; that._onAdd(null, data); }); }else{ data.files=$.makeArray(data.files); this._onAdd(null, data); }}, send: function (data){ if(data&&!this.options.disabled){ if(data.fileInput&&!data.files){ var that=this, dfd=$.Deferred(), promise=dfd.promise(), jqXHR, aborted; promise.abort=function (){ aborted=true; if(jqXHR){ return jqXHR.abort(); } dfd.reject(null, 'abort', 'abort'); return promise; }; this._getFileInputFiles(data.fileInput).always(function (files){ if(aborted){ return; } if(!files.length){ dfd.reject(); return; } data.files=files; jqXHR=that._onSend(null, data); jqXHR.then(function (result, textStatus, jqXHR){ dfd.resolve(result, textStatus, jqXHR); }, function (jqXHR, textStatus, errorThrown){ dfd.reject(jqXHR, textStatus, errorThrown); } ); } ); return this._enhancePromise(promise); } data.files=$.makeArray(data.files); if(data.files.length){ return this._onSend(null, data); }} return this._getXHRPromise(false, data&&data.context); }}); })); ;(function (factory){ 'use strict'; if(typeof define==='function'&&define.amd){ define([ 'jquery', './jquery.fileupload' ], factory); }else if(typeof exports==='object'){ factory(require('jquery')); }else{ factory( window.jQuery ); }}(function ($){ 'use strict'; var originalAdd=$.blueimp.fileupload.prototype.options.add; $.widget('blueimp.fileupload', $.blueimp.fileupload, { options: { processQueue: [ ], add: function (e, data){ var $this=$(this); data.process(function (){ return $this.fileupload('process', data); }); originalAdd.call(this, e, data); }}, processActions: { }, _processFile: function (data, originalData){ var that=this, dfd=$.Deferred().resolveWith(that, [data]), chain=dfd.promise(); this._trigger('process', null, data); $.each(data.processQueue, function (i, settings){ var func=function (data){ if(originalData.errorThrown){ return $.Deferred() .rejectWith(that, [originalData]).promise(); } return that.processActions[settings.action].call(that, data, settings ); }; chain=chain.then(func, settings.always&&func); }); chain .done(function (){ that._trigger('processdone', null, data); that._trigger('processalways', null, data); }) .fail(function (){ that._trigger('processfail', null, data); that._trigger('processalways', null, data); }); return chain; }, _transformProcessQueue: function (options){ var processQueue=[]; $.each(options.processQueue, function (){ var settings={}, action=this.action, prefix=this.prefix===true ? action:this.prefix; $.each(this, function (key, value){ if($.type(value)==='string' && value.charAt(0)==='@'){ settings[key]=options[ value.slice(1)||(prefix ? prefix + key.charAt(0).toUpperCase() + key.slice(1):key) ]; }else{ settings[key]=value; }}); processQueue.push(settings); }); options.processQueue=processQueue; }, processing: function (){ return this._processing; }, process: function (data){ var that=this, options=$.extend({}, this.options, data); if(options.processQueue&&options.processQueue.length){ this._transformProcessQueue(options); if(this._processing===0){ this._trigger('processstart'); } $.each(data.files, function (index){ var opts=index ? $.extend({}, options):options, func=function (){ if(data.errorThrown){ return $.Deferred() .rejectWith(that, [data]).promise(); } return that._processFile(opts, data); }; opts.index=index; that._processing +=1; that._processingQueue=that._processingQueue.then(func, func) .always(function (){ that._processing -=1; if(that._processing===0){ that._trigger('processstop'); }}); }); } return this._processingQueue; }, _create: function (){ this._super(); this._processing=0; this._processingQueue=$.Deferred().resolveWith(this) .promise(); }}); })); ;(function (factory){ 'use strict'; if(typeof define==='function'&&define.amd){ define([ 'jquery', './jquery.fileupload-process' ], factory); }else if(typeof exports==='object'){ factory(require('jquery')); }else{ factory( window.jQuery ); }}(function ($){ 'use strict'; $.blueimp.fileupload.prototype.options.processQueue.push({ action: 'validate', always: true, acceptFileTypes: '@', maxFileSize: '@', minFileSize: '@', maxNumberOfFiles: '@', disabled: '@disableValidation' } ); $.widget('blueimp.fileupload', $.blueimp.fileupload, { options: { getNumberOfFiles: $.noop, messages: { maxNumberOfFiles: 'Maximum number of files exceeded', acceptFileTypes: 'File type not allowed', maxFileSize: 'File is too large', minFileSize: 'File is too small' }}, processActions: { validate: function (data, options){ if(options.disabled){ return data; } var dfd=$.Deferred(), settings=this.options, file=data.files[data.index], fileSize; if(options.minFileSize||options.maxFileSize){ fileSize=file.size; } if($.type(options.maxNumberOfFiles)==='number' && (settings.getNumberOfFiles()||0) + data.files.length > options.maxNumberOfFiles){ file.error=settings.i18n('maxNumberOfFiles'); }else if(options.acceptFileTypes && !(options.acceptFileTypes.test(file.type) || options.acceptFileTypes.test(file.name))){ file.error=settings.i18n('acceptFileTypes'); }else if(fileSize > options.maxFileSize){ file.error=settings.i18n('maxFileSize'); }else if($.type(fileSize)==='number' && fileSize < options.minFileSize){ file.error=settings.i18n('minFileSize'); }else{ delete file.error; } if(file.error||data.files.error){ data.files.error=true; dfd.rejectWith(this, [data]); }else{ dfd.resolveWith(this, [data]); } return dfd.promise(); }} }); })); (function ($){ 'use strict'; var default_options={ i18n: { ar: { months: [ "كانون الثاني", "شباط", "آذار", "نيسان", "مايو", "حزيران", "تموز", "آب", "أيلول", "تشرين الأول", "تشرين الثاني", "كانون الأول" ], dayOfWeek: [ "ن", "ث", "ع", "خ", "ج", "س", "ح" ] }, ro: { months: [ "ianuarie", "februarie", "martie", "aprilie", "mai", "iunie", "iulie", "august", "septembrie", "octombrie", "noiembrie", "decembrie" ], dayOfWeek: [ "l", "ma", "mi", "j", "v", "s", "d" ] }, id: { months: [ "Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember" ], dayOfWeek: [ "Sen", "Sel", "Rab", "Kam", "Jum", "Sab", "Min" ] }, bg: { months: [ "Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември" ], dayOfWeek: [ "Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб" ] }, fa: { months: [ 'فروردین', 'اردیبهشت', 'خرداد', 'تیر', 'مرداد', 'شهریور', 'مهر', 'آبان', 'آذر', 'دی', 'بهمن', 'اسفند' ], dayOfWeek: [ 'یکشنبه', 'دوشنبه', 'سه شنبه', 'چهارشنبه', 'پنجشنبه', 'جمعه', 'شنبه' ] }, ru: { months: [ 'Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь' ], dayOfWeek: [ "Вск", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб" ] }, uk: { months: [ 'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень' ], dayOfWeek: [ "Ндл", "Пнд", "Втр", "Срд", "Чтв", "Птн", "Сбт" ] }, en: { months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], dayOfWeek: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] }, el: { months: [ "Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος" ], dayOfWeek: [ "Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ" ] }, de: { months: [ 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ], dayOfWeek: [ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa" ] }, nl: { months: [ "januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus", "september", "oktober", "november", "december" ], dayOfWeek: [ "zo", "ma", "di", "wo", "do", "vr", "za" ] }, tr: { months: [ "Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık" ], dayOfWeek: [ "Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts" ] }, fr: { months: [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ], dayOfWeek: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ] }, es: { months: [ "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ], dayOfWeek: [ "Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb" ] }, th: { months: [ 'มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม', 'กันยายน', 'ตุลาคม', 'พฤศจิกายน', 'ธันวาคม' ], dayOfWeek: [ 'อา.', 'จ.', 'อ.', 'พ.', 'พฤ.', 'ศ.', 'ส.' ] }, pl: { months: [ "styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień" ], dayOfWeek: [ "nd", "pn", "wt", "śr", "cz", "pt", "sb" ] }, pt: { months: [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ], dayOfWeek: [ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab" ] }, ch: { months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayOfWeek: [ "日", "一", "二", "三", "四", "五", "六" ] }, se: { months: [ "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December" ], dayOfWeek: [ "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör" ] }, kr: { months: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월" ], dayOfWeek: [ "일", "월", "화", "수", "목", "금", "토" ] }, it: { months: [ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ], dayOfWeek: [ "Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab" ] }, da: { months: [ "January", "Februar", "Marts", "April", "Maj", "Juni", "July", "August", "September", "Oktober", "November", "December" ], dayOfWeek: [ "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør" ] }, no: { months: [ "Januar", "Februar", "Mars", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Desember" ], dayOfWeek: [ "Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør" ] }, ja: { months: [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ], dayOfWeek: [ "日", "月", "火", "水", "木", "金", "土" ] }, vi: { months: [ "Tháng 1", "Tháng 2", "Tháng 3", "Tháng 4", "Tháng 5", "Tháng 6", "Tháng 7", "Tháng 8", "Tháng 9", "Tháng 10", "Tháng 11", "Tháng 12" ], dayOfWeek: [ "CN", "T2", "T3", "T4", "T5", "T6", "T7" ] }, sl: { months: [ "Januar", "Februar", "Marec", "April", "Maj", "Junij", "Julij", "Avgust", "September", "Oktober", "November", "December" ], dayOfWeek: [ "Ned", "Pon", "Tor", "Sre", "Čet", "Pet", "Sob" ] }, cs: { months: [ "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec" ], dayOfWeek: [ "Ne", "Po", "Út", "St", "Čt", "Pá", "So" ] }, hu: { months: [ "Január", "Február", "Március", "Április", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December" ], dayOfWeek: [ "Va", "Hé", "Ke", "Sze", "Cs", "Pé", "Szo" ] }, az: { months: [ "Yanvar", "Fevral", "Mart", "Aprel", "May", "Iyun", "Iyul", "Avqust", "Sentyabr", "Oktyabr", "Noyabr", "Dekabr" ], dayOfWeek: [ "B", "Be", "Ça", "Ç", "Ca", "C", "Ş" ] }, bs: { months: [ "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar" ], dayOfWeek: [ "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub" ] }, ca: { months: [ "Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre" ], dayOfWeek: [ "Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds" ] }, 'en-GB': { months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], dayOfWeek: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] }, et: { //"Eesti" months: [ "Jaanuar", "Veebruar", "Märts", "Aprill", "Mai", "Juuni", "Juuli", "August", "September", "Oktoober", "November", "Detsember" ], dayOfWeek: [ "P", "E", "T", "K", "N", "R", "L" ] }, eu: { months: [ "Urtarrila", "Otsaila", "Martxoa", "Apirila", "Maiatza", "Ekaina", "Uztaila", "Abuztua", "Iraila", "Urria", "Azaroa", "Abendua" ], dayOfWeek: [ "Ig.", "Al.", "Ar.", "Az.", "Og.", "Or.", "La." ] }, fi: { months: [ "Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu" ], dayOfWeek: [ "Su", "Ma", "Ti", "Ke", "To", "Pe", "La" ] }, gl: { months: [ "Xan", "Feb", "Maz", "Abr", "Mai", "Xun", "Xul", "Ago", "Set", "Out", "Nov", "Dec" ], dayOfWeek: [ "Dom", "Lun", "Mar", "Mer", "Xov", "Ven", "Sab" ] }, hr: { months: [ "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac" ], dayOfWeek: [ "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub" ] }, ko: { months: [ "1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월" ], dayOfWeek: [ "일", "월", "화", "수", "목", "금", "토" ] }, lt: { months: [ "Sausio", "Vasario", "Kovo", "Balandžio", "Gegužės", "Birželio", "Liepos", "Rugpjūčio", "Rugsėjo", "Spalio", "Lapkričio", "Gruodžio" ], dayOfWeek: [ "Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš" ] }, lv: { months: [ "Janvāris", "Februāris", "Marts", "Aprīlis ", "Maijs", "Jūnijs", "Jūlijs", "Augusts", "Septembris", "Oktobris", "Novembris", "Decembris" ], dayOfWeek: [ "Sv", "Pr", "Ot", "Tr", "Ct", "Pk", "St" ] }, mk: { months: [ "јануари", "февруари", "март", "април", "мај", "јуни", "јули", "август", "септември", "октомври", "ноември", "декември" ], dayOfWeek: [ "нед", "пон", "вто", "сре", "чет", "пет", "саб" ] }, mn: { months: [ "1-р сар", "2-р сар", "3-р сар", "4-р сар", "5-р сар", "6-р сар", "7-р сар", "8-р сар", "9-р сар", "10-р сар", "11-р сар", "12-р сар" ], dayOfWeek: [ "Дав", "Мяг", "Лха", "Пүр", "Бсн", "Бям", "Ням" ] }, 'pt-BR': { months: [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ], dayOfWeek: [ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb" ] }, sk: { months: [ "Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December" ], dayOfWeek: [ "Ne", "Po", "Ut", "St", "Št", "Pi", "So" ] }, sq: { months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], dayOfWeek: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ] }, 'sr-YU': { months: [ "Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar" ], dayOfWeek: [ "Ned", "Pon", "Uto", "Sre", "čet", "Pet", "Sub" ] }, sr: { months: [ "јануар", "фебруар", "март", "април", "мај", "јун", "јул", "август", "септембар", "октобар", "новембар", "децембар" ], dayOfWeek: [ "нед", "пон", "уто", "сре", "чет", "пет", "суб" ] }, sv: { months: [ "Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December" ], dayOfWeek: [ "Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör" ] }, 'zh-TW': { months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayOfWeek: [ "日", "一", "二", "三", "四", "五", "六" ] }, zh: { months: [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月" ], dayOfWeek: [ "日", "一", "二", "三", "四", "五", "六" ] }, he: { months: [ 'ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר' ], dayOfWeek: [ 'א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת' ] }}, value: '', lang: 'en', format: 'Y/m/d H:i', formatTime: 'H:i', formatDate: 'Y/m/d', startDate: false, step: 60, monthChangeSpinner: true, closeOnDateSelect: false, closeOnWithoutClick: true, closeOnInputClick: true, timepicker: true, datepicker: true, weeks: false, defaultTime: false, defaultDate: false, minDate: false, maxDate: false, minTime: false, maxTime: false, allowTimes: [], opened: false, initTime: true, inline: false, theme: '', onSelectDate: function (){}, onSelectTime: function (){}, onChangeMonth: function (){}, onChangeYear: function (){}, onChangeDateTime: function (){}, onShow: function (){}, onClose: function (){}, onGenerate: function (){}, withoutCopyright: true, inverseButton: false, hours12: false, next: 'ow_voting_next', prev:'ow_voting_prev', dayOfWeekStart: 0, parentID: 'body', timeHeightInTimePicker: 25, timepickerScrollbar: true, todayButton: true, defaultSelect: true, scrollMonth: true, scrollTime: true, scrollInput: true, lazyInit: false, mask: false, validateOnBlur: true, allowBlank: true, yearStart: 1950, yearEnd: 2050, style: '', id: '', fixed: false, roundTime: 'round', className: '', weekends: [], disabledDates:[], yearOffset: 0, beforeShowDay: null, enterLikeTab: true }; if(!Array.prototype.indexOf){ Array.prototype.indexOf=function (obj, start){ var i, j; for (i=(start||0), j=this.length; i < j; i +=1){ if(this[i]===obj){ return i; }} return -1; };} Date.prototype.countDaysInMonth=function (){ return new Date(this.getFullYear(), this.getMonth() + 1, 0).getDate(); }; $.fn.ow_votingScroller=function (percent){ return this.each(function (){ var timeboxparent=$(this), pointerEventToXY=function (e){ var out={x: 0, y: 0}, touch; if(e.type==='touchstart'||e.type==='touchmove'||e.type==='touchend'||e.type==='touchcancel'){ touch=e.originalEvent.touches[0]||e.originalEvent.changedTouches[0]; out.x=touch.clientX; out.y=touch.clientY; }else if(e.type==='mousedown'||e.type==='mouseup'||e.type==='mousemove'||e.type==='mouseover'||e.type==='mouseout'||e.type==='mouseenter'||e.type==='mouseleave'){ out.x=e.clientX; out.y=e.clientY; } return out; }, move=0, timebox, parentHeight, height, scrollbar, scroller, maximumOffset=100, start=false, startY=0, startTop=0, h1=0, touchStart=false, startTopScroll=0, calcOffset=function (){}; if(percent==='hide'){ timeboxparent.find('.ow_voting_scrollbar').hide(); return; } if(!$(this).hasClass('ow_voting_scroller_box')){ timebox=timeboxparent.children().eq(0); parentHeight=timeboxparent[0].clientHeight; height=timebox[0].offsetHeight; scrollbar=$('
    '); scroller=$('
    '); scrollbar.append(scroller); timeboxparent.addClass('ow_voting_scroller_box').append(scrollbar); calcOffset=function calcOffset(event){ var offset=pointerEventToXY(event).y - startY + startTopScroll; if(offset < 0){ offset=0; } if(offset + scroller[0].offsetHeight > h1){ offset=h1 - scroller[0].offsetHeight; } timeboxparent.trigger('scroll_element.ow_voting_scroller', [maximumOffset ? offset / maximumOffset:0]); }; scroller .on('touchstart.ow_voting_scroller mousedown.ow_voting_scroller', function (event){ if(!parentHeight){ timeboxparent.trigger('resize_scroll.ow_voting_scroller', [percent]); } startY=pointerEventToXY(event).y; startTopScroll=parseInt(scroller.css('margin-top'), 10); h1=scrollbar[0].offsetHeight; if(event.type==='mousedown'){ if(document){ $(document.body).addClass('ow_voting_noselect'); } $([document.body, window]).on('mouseup.ow_voting_scroller', function arguments_callee(){ $([document.body, window]).off('mouseup.ow_voting_scroller', arguments_callee) .off('mousemove.ow_voting_scroller', calcOffset) .removeClass('ow_voting_noselect'); }); $(document.body).on('mousemove.ow_voting_scroller', calcOffset); }else{ touchStart=true; event.stopPropagation(); event.preventDefault(); }}) .on('touchmove', function (event){ if(touchStart){ event.preventDefault(); calcOffset(event); }}) .on('touchend touchcancel', function (event){ touchStart=false; startTopScroll=0; }); timeboxparent .on('scroll_element.ow_voting_scroller', function (event, percentage){ if(!parentHeight){ timeboxparent.trigger('resize_scroll.ow_voting_scroller', [percentage, true]); } percentage=percentage > 1 ? 1:(percentage < 0||isNaN(percentage)) ? 0:percentage; scroller.css('margin-top', maximumOffset * percentage); setTimeout(function (){ timebox.css('marginTop', -parseInt((timebox[0].offsetHeight - parentHeight) * percentage, 10)); }, 10); }) .on('resize_scroll.ow_voting_scroller', function (event, percentage, noTriggerScroll){ var percent, sh; parentHeight=timeboxparent[0].clientHeight; height=timebox[0].offsetHeight; percent=parentHeight / height; sh=percent * scrollbar[0].offsetHeight; if(percent > 1){ scroller.hide(); }else{ scroller.show(); scroller.css('height', parseInt(sh > 10 ? sh:10, 10)); maximumOffset=scrollbar[0].offsetHeight - scroller[0].offsetHeight; if(noTriggerScroll!==true){ timeboxparent.trigger('scroll_element.ow_voting_scroller', [percentage||Math.abs(parseInt(timebox.css('marginTop'), 10)) / (height - parentHeight)]); }} }); timeboxparent.on('mousewheel', function (event){ var top=Math.abs(parseInt(timebox.css('marginTop'), 10)); top=top - (event.deltaY * 20); if(top < 0){ top=0; } timeboxparent.trigger('scroll_element.ow_voting_scroller', [top / (height - parentHeight)]); event.stopPropagation(); return false; }); timeboxparent.on('touchstart', function (event){ start=pointerEventToXY(event); startTop=Math.abs(parseInt(timebox.css('marginTop'), 10)); }); timeboxparent.on('touchmove', function (event){ if(start){ event.preventDefault(); var coord=pointerEventToXY(event); timeboxparent.trigger('scroll_element.ow_voting_scroller', [(startTop - (coord.y - start.y)) / (height - parentHeight)]); }}); timeboxparent.on('touchend touchcancel', function (event){ start=false; startTop=0; }); } timeboxparent.trigger('resize_scroll.ow_voting_scroller', [percent]); }); }; $.fn.owvotedatetimepicker=function (opt){ var KEY0=48, KEY9=57, _KEY0=96, _KEY9=105, CTRLKEY=17, DEL=46, ENTER=13, ESC=27, BACKSPACE=8, ARROWLEFT=37, ARROWUP=38, ARROWRIGHT=39, ARROWDOWN=40, TAB=9, F5=116, AKEY=65, CKEY=67, VKEY=86, ZKEY=90, YKEY=89, ctrlDown=false, options=($.isPlainObject(opt)||!opt) ? $.extend(true, {}, default_options, opt):$.extend(true, {}, default_options), lazyInitTimer=0, createOWDateTimePicker, destroyOWDateTimePicker, _ow_voting_datetime, lazyInit=function (input){ input .on('open.ow_voting focusin.ow_voting mousedown.ow_voting', function initOnActionCallback(event){ if(input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||input.data('ow_voting_owvotedatetimepicker')){ return; } clearTimeout(lazyInitTimer); lazyInitTimer=setTimeout(function (){ if(!input.data('ow_voting_owvotedatetimepicker')){ createDateTimePicker(input); } input .off('open.ow_voting focusin.ow_voting mousedown.ow_voting', initOnActionCallback) .trigger('open.ow_voting'); }, 100); }); }; createOWDateTimePicker=function (input){ var owvotedatetimepicker=$('
    '), datepicker=$('
    '), mounth_picker=$('
    ' + '
    ' + '
    ' + '
    '), calendar=$('
    '), timepicker=$('
    '), timeboxparent=timepicker.find('.ow_voting_time_box').eq(0), timebox=$('
    '), monthselect=$('
    '), yearselect=$('
    '), triggerAfterOpen=false, XDSoft_datetime, xchangeTimer, timerclick, current_time_index, setPos, timer=0, timer1=0; mounth_picker .find('.ow_voting_month span') .after(monthselect); mounth_picker .find('.ow_voting_year span') .after(yearselect); mounth_picker .find('.ow_voting_month,.ow_voting_year') .on('mousedown.ow_voting', function (event){ var select=$(this).find('.ow_voting_select').eq(0), val=0, top=0, visible=select.is(':visible'), items, i; mounth_picker .find('.ow_voting_select') .hide(); if(_ow_voting_datetime.currentTime){ val=_ow_voting_datetime.currentTime[$(this).hasClass('ow_voting_month') ? 'getMonth':'getFullYear'](); } select[visible ? 'hide':'show'](); for (items=select.find('div.ow_voting_option'), i=0; i < items.length; i +=1){ if(items.eq(i).data('value')===val){ break; }else{ top +=items[0].offsetHeight; }} select.ow_votingScroller(top / (select.children()[0].offsetHeight - (select[0].clientHeight))); event.stopPropagation(); return false; }); mounth_picker .find('.ow_voting_select') .ow_votingScroller() .on('mousedown.ow_voting', function (event){ event.stopPropagation(); event.preventDefault(); }) .on('mousedown.ow_voting', '.ow_voting_option', function (event){ var year=_ow_voting_datetime.currentTime.getFullYear(); if(_ow_voting_datetime&&_ow_voting_datetime.currentTime){ _ow_voting_datetime.currentTime[$(this).parent().parent().hasClass('ow_voting_monthselect') ? 'setMonth':'setFullYear']($(this).data('value')); } $(this).parent().parent().hide(); owvotedatetimepicker.trigger('xchange.ow_voting'); if(options.onChangeMonth&&$.isFunction(options.onChangeMonth)){ options.onChangeMonth.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); } if(year!==_ow_voting_datetime.currentTime.getFullYear()&&$.isFunction(options.onChangeYear)){ options.onChangeYear.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); }}); owvotedatetimepicker.setOptions=function (_options){ options=$.extend(true, {}, options, _options); if(_options.allowTimes&&$.isArray(_options.allowTimes)&&_options.allowTimes.length){ options.allowTimes=$.extend(true, [], _options.allowTimes); } if(_options.weekends&&$.isArray(_options.weekends)&&_options.weekends.length){ options.weekends=$.extend(true, [], _options.weekends); } if(_options.disabledDates&&$.isArray(_options.disabledDates)&&_options.disabledDates.length){ options.disabledDates=$.extend(true, [], _options.disabledDates); } if((options.open||options.opened)&&(!options.inline)){ input.trigger('open.ow_voting'); } if(options.inline){ triggerAfterOpen=true; owvotedatetimepicker.addClass('ow_voting_inline'); input.after(owvotedatetimepicker).hide(); } if(options.inverseButton){ options.next='ow_voting_prev'; options.prev='ow_voting_next'; } if(options.datepicker){ datepicker.addClass('active'); }else{ datepicker.removeClass('active'); } if(options.timepicker){ timepicker.addClass('active'); }else{ timepicker.removeClass('active'); } if(options.value){ if(input&&input.val){ input.val(options.value); } _ow_voting_datetime.setCurrentTime(options.value); } if(isNaN(options.dayOfWeekStart)){ options.dayOfWeekStart=0; }else{ options.dayOfWeekStart=parseInt(options.dayOfWeekStart, 10) % 7; } if(!options.timepickerScrollbar){ timeboxparent.ow_votingScroller('hide'); } if(options.minDate&&/^-(.*)$/.test(options.minDate)){ options.minDate=_ow_voting_datetime.strToDateTime(options.minDate).dateFormat(options.formatDate); } if(options.maxDate&&/^\+(.*)$/.test(options.maxDate)){ options.maxDate=_ow_voting_datetime.strToDateTime(options.maxDate).dateFormat(options.formatDate); } mounth_picker .find('.ow_voting_today_button') .css('visibility', !options.todayButton ? 'hidden':'visible'); if(options.mask){ var e, getCaretPos=function (input){ try { if(document.selection&&document.selection.createRange){ var range=document.selection.createRange(); return range.getBookmark().charCodeAt(2) - 2; } if(input.setSelectionRange){ return input.selectionStart; }} catch (e){ return 0; }}, setCaretPos=function (node, pos){ node=(typeof node==="string"||node instanceof String) ? document.getElementById(node):node; if(!node){ return false; } if(node.createTextRange){ var textRange=node.createTextRange(); textRange.collapse(true); textRange.moveEnd('character', pos); textRange.moveStart('character', pos); textRange.select(); return true; } if(node.setSelectionRange){ node.setSelectionRange(pos, pos); return true; } return false; }, isValidValue=function (mask, value){ var reg=mask .replace(/([\[\]\/\{\}\(\)\-\.\+]{1})/g, '\\$1') .replace(/_/g, '{digit+}') .replace(/([0-9]{1})/g, '{digit$1}') .replace(/\{digit([0-9]{1})\}/g, '[0-$1_]{1}') .replace(/\{digit[\+]\}/g, '[0-9_]{1}'); return (new RegExp(reg)).test(value); }; input.off('keydown.ow_voting'); if(options.mask===true){ options.mask=options.format .replace(/Y/g, '9999') .replace(/F/g, '9999') .replace(/m/g, '19') .replace(/d/g, '39') .replace(/H/g, '29') .replace(/i/g, '59') .replace(/s/g, '59'); } if($.type(options.mask)==='string'){ if(!isValidValue(options.mask, input.val())){ input.val(options.mask.replace(/[0-9]/g, '_')); } input.on('keydown.ow_voting', function (event){ var val=this.value, key=event.which, pos, digit; if(((key >=KEY0&&key <=KEY9)||(key >=_KEY0&&key <=_KEY9))||(key===BACKSPACE||key===DEL)){ pos=getCaretPos(this); digit=(key!==BACKSPACE&&key!==DEL) ? String.fromCharCode((_KEY0 <=key&&key <=_KEY9) ? key - KEY0:key):'_'; if((key===BACKSPACE||key===DEL)&&pos){ pos -=1; digit='_'; } while (/[^0-9_]/.test(options.mask.substr(pos, 1))&&pos < options.mask.length&&pos > 0){ pos +=(key===BACKSPACE||key===DEL) ? -1:1; } val=val.substr(0, pos) + digit + val.substr(pos + 1); if($.trim(val)===''){ val=options.mask.replace(/[0-9]/g, '_'); }else{ if(pos===options.mask.length){ event.preventDefault(); return false; }} pos +=(key===BACKSPACE||key===DEL) ? 0:1; while (/[^0-9_]/.test(options.mask.substr(pos, 1))&&pos < options.mask.length&&pos > 0){ pos +=(key===BACKSPACE||key===DEL) ? -1:1; } if(isValidValue(options.mask, val)){ this.value=val; setCaretPos(this, pos); }else if($.trim(val)===''){ this.value=options.mask.replace(/[0-9]/g, '_'); }else{ input.trigger('error_input.ow_voting'); }}else{ if(([AKEY, CKEY, VKEY, ZKEY, YKEY].indexOf(key)!==-1&&ctrlDown)||[ESC, ARROWUP, ARROWDOWN, ARROWLEFT, ARROWRIGHT, F5, CTRLKEY, TAB, ENTER].indexOf(key)!==-1){ return true; }} event.preventDefault(); return false; }); }} if(options.validateOnBlur){ input .off('blur.ow_voting') .on('blur.ow_voting', function (){ if(options.allowBlank&&!$.trim($(this).val()).length){ $(this).val(null); owvotedatetimepicker.data('ow_voting_datetime').empty(); }else if(!Date.parseDate($(this).val(), options.format)){ $(this).val((_ow_voting_datetime.now()).dateFormat(options.format)); owvotedatetimepicker.data('ow_voting_datetime').setCurrentTime($(this).val()); }else{ owvotedatetimepicker.data('ow_voting_datetime').setCurrentTime($(this).val()); } owvotedatetimepicker.trigger('changedatetime.ow_voting'); }); } options.dayOfWeekStartPrev=(options.dayOfWeekStart===0) ? 6:options.dayOfWeekStart - 1; owvotedatetimepicker .trigger('xchange.ow_voting') .trigger('afterOpen.ow_voting'); }; owvotedatetimepicker .data('options', options) .on('mousedown.ow_voting', function (event){ event.stopPropagation(); event.preventDefault(); yearselect.hide(); monthselect.hide(); return false; }); timeboxparent.append(timebox); timeboxparent.ow_votingScroller(); owvotedatetimepicker.on('afterOpen.ow_voting', function (){ timeboxparent.ow_votingScroller(); }); owvotedatetimepicker .append(datepicker) .append(timepicker); datepicker .append(mounth_picker) .append(calendar); $(options.parentID) .append(owvotedatetimepicker); XDSoft_datetime=function (){ var _this=this; _this.now=function (norecursion){ var d=new Date(), date, time; if(!norecursion&&options.defaultDate){ date=_this.strToDate(options.defaultDate); d.setFullYear(date.getFullYear()); d.setMonth(date.getMonth()); d.setDate(date.getDate()); } if(options.yearOffset){ d.setFullYear(d.getFullYear() + options.yearOffset); } if(!norecursion&&options.defaultTime){ time=_this.strtotime(options.defaultTime); d.setHours(time.getHours()); d.setMinutes(time.getMinutes()); } return d; }; _this.isValidDate=function (d){ if(Object.prototype.toString.call(d)!=="[object Date]"){ return false; } return !isNaN(d.getTime()); }; _this.setCurrentTime=function (dTime){ _this.currentTime=(typeof dTime==='string') ? _this.strToDateTime(dTime):_this.isValidDate(dTime) ? dTime:_this.now(); owvotedatetimepicker.trigger('xchange.ow_voting'); }; _this.empty=function (){ _this.currentTime=null; }; _this.getCurrentTime=function (dTime){ return _this.currentTime; }; _this.nextMonth=function (){ var month=_this.currentTime.getMonth() + 1, year; if(month===12){ _this.currentTime.setFullYear(_this.currentTime.getFullYear() + 1); month=0; } year=_this.currentTime.getFullYear(); _this.currentTime.setDate(Math.min(new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(), _this.currentTime.getDate() ) ); _this.currentTime.setMonth(month); if(options.onChangeMonth&&$.isFunction(options.onChangeMonth)){ options.onChangeMonth.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); } if(year!==_this.currentTime.getFullYear()&&$.isFunction(options.onChangeYear)){ options.onChangeYear.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); } owvotedatetimepicker.trigger('xchange.ow_voting'); return month; }; _this.prevMonth=function (){ var month=_this.currentTime.getMonth() - 1; if(month===-1){ _this.currentTime.setFullYear(_this.currentTime.getFullYear() - 1); month=11; } _this.currentTime.setDate(Math.min(new Date(_this.currentTime.getFullYear(), month + 1, 0).getDate(), _this.currentTime.getDate() ) ); _this.currentTime.setMonth(month); if(options.onChangeMonth&&$.isFunction(options.onChangeMonth)){ options.onChangeMonth.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); } owvotedatetimepicker.trigger('xchange.ow_voting'); return month; }; _this.getWeekOfYear=function (datetime){ var onejan=new Date(datetime.getFullYear(), 0, 1); return Math.ceil((((datetime - onejan) / 86400000) + onejan.getDay() + 1) / 7); }; _this.strToDateTime=function (sDateTime){ var tmpDate=[], timeOffset, currentTime; if(sDateTime&&sDateTime instanceof Date&&_this.isValidDate(sDateTime)){ return sDateTime; } tmpDate=/^(\+|\-)(.*)$/.exec(sDateTime); if(tmpDate){ tmpDate[2]=Date.parseDate(tmpDate[2], options.formatDate); } if(tmpDate&&tmpDate[2]){ timeOffset=tmpDate[2].getTime() - (tmpDate[2].getTimezoneOffset()) * 60000; currentTime=new Date((_ow_voting_datetime.now()).getTime() + parseInt(tmpDate[1] + '1', 10) * timeOffset); }else{ currentTime=sDateTime ? Date.parseDate(sDateTime, options.format):_this.now(); } if(!_this.isValidDate(currentTime)){ currentTime=_this.now(); } return currentTime; }; _this.strToDate=function (sDate){ if(sDate&&sDate instanceof Date&&_this.isValidDate(sDate)){ return sDate; } var currentTime=sDate ? Date.parseDate(sDate, options.formatDate):_this.now(true); if(!_this.isValidDate(currentTime)){ currentTime=_this.now(true); } return currentTime; }; _this.strtotime=function (sTime){ if(sTime&&sTime instanceof Date&&_this.isValidDate(sTime)){ return sTime; } var currentTime=sTime ? Date.parseDate(sTime, options.formatTime):_this.now(true); if(!_this.isValidDate(currentTime)){ currentTime=_this.now(true); } return currentTime; }; _this.str=function (){ return _this.currentTime.dateFormat(options.format); }; _this.currentTime=this.now(); }; _ow_voting_datetime=new XDSoft_datetime(); mounth_picker .find('.ow_voting_today_button') .on('mousedown.ow_voting', function (){ owvotedatetimepicker.data('changed', true); _ow_voting_datetime.setCurrentTime(0); owvotedatetimepicker.trigger('afterOpen.ow_voting'); }).on('dblclick.ow_voting', function (){ input.val(_ow_voting_datetime.str()); owvotedatetimepicker.trigger('close.ow_voting'); }); mounth_picker .find('.ow_voting_prev,.ow_voting_next') .on('mousedown.ow_voting', function (){ var $this=$(this), timer=0, stop=false; (function arguments_callee1(v){ var month=_ow_voting_datetime.currentTime.getMonth(); if($this.hasClass(options.next)){ _ow_voting_datetime.nextMonth(); }else if($this.hasClass(options.prev)){ _ow_voting_datetime.prevMonth(); } if(options.monthChangeSpinner){ if(!stop){ timer=setTimeout(arguments_callee1, v||100); }} }(500)); $([document.body, window]).on('mouseup.ow_voting', function arguments_callee2(){ clearTimeout(timer); stop=true; $([document.body, window]).off('mouseup.ow_voting', arguments_callee2); }); }); timepicker .find('.ow_voting_prev,.ow_voting_next') .on('mousedown.ow_voting', function (){ var $this=$(this), timer=0, stop=false, period=110; (function arguments_callee4(v){ var pheight=timeboxparent[0].clientHeight, height=timebox[0].offsetHeight, top=Math.abs(parseInt(timebox.css('marginTop'), 10)); if($this.hasClass(options.next)&&(height - pheight) - options.timeHeightInTimePicker >=top){ timebox.css('marginTop', '-' + (top + options.timeHeightInTimePicker) + 'px'); }else if($this.hasClass(options.prev)&&top - options.timeHeightInTimePicker >=0){ timebox.css('marginTop', '-' + (top - options.timeHeightInTimePicker) + 'px'); } timeboxparent.trigger('scroll_element.ow_voting_scroller', [Math.abs(parseInt(timebox.css('marginTop'), 10) / (height - pheight))]); period=(period > 10) ? 10:period - 10; if(!stop){ timer=setTimeout(arguments_callee4, v||period); }}(500)); $([document.body, window]).on('mouseup.ow_voting', function arguments_callee5(){ clearTimeout(timer); stop=true; $([document.body, window]) .off('mouseup.ow_voting', arguments_callee5); }); }); xchangeTimer=0; owvotedatetimepicker .on('xchange.ow_voting', function (event){ clearTimeout(xchangeTimer); xchangeTimer=setTimeout(function (){ var table='', start=new Date(_ow_voting_datetime.currentTime.getFullYear(), _ow_voting_datetime.currentTime.getMonth(), 1, 12, 0, 0), i=0, j, today=_ow_voting_datetime.now(), maxDate=false, minDate=false, d, y, m, w, classes=[], customDateSettings, newRow=true, time='', h='', line_time; while (start.getDay()!==options.dayOfWeekStart){ start.setDate(start.getDate() - 1); } table +=''; if(options.weeks){ table +=''; } for (j=0; j < 7; j +=1){ table +=''; } table +=''; table +=''; if(options.maxDate!==false){ maxDate=_ow_voting_datetime.strToDate(options.maxDate); maxDate=_ow_voting_datetime.strToDateTime(options.maxDate); maxDate=new Date(maxDate.getFullYear(), maxDate.getMonth(), maxDate.getDate(), 23, 59, 59, 999); } if(options.minDate!==false){ minDate=_ow_voting_datetime.strToDate(options.minDate); minDate=_ow_voting_datetime.strToDateTime(options.minDate); minDate=new Date(minDate.getFullYear(), minDate.getMonth(), minDate.getDate()); } while (i < _ow_voting_datetime.currentTime.countDaysInMonth()||start.getDay()!==options.dayOfWeekStart||_ow_voting_datetime.currentTime.getMonth()===start.getMonth()){ classes=[]; i +=1; d=start.getDate(); y=start.getFullYear(); m=start.getMonth(); w=_ow_voting_datetime.getWeekOfYear(start); classes.push('ow_voting_date'); if(options.beforeShowDay&&$.isFunction(options.beforeShowDay.call)){ customDateSettings=options.beforeShowDay.call(owvotedatetimepicker, start); }else{ customDateSettings=null; } if((maxDate!==false&&start > maxDate)||(minDate!==false&&start < minDate)||(customDateSettings&&customDateSettings[0]===false)){ classes.push('ow_voting_disabled'); }else if(options.disabledDates.indexOf(start.dateFormat(options.formatDate))!==-1){ classes.push('ow_voting_disabled'); } if(customDateSettings&&customDateSettings[1]!==""){ classes.push(customDateSettings[1]); } if(_ow_voting_datetime.currentTime.getMonth()!==m){ classes.push('ow_voting_other_month'); } if((options.defaultSelect||owvotedatetimepicker.data('changed'))&&_ow_voting_datetime.currentTime.dateFormat(options.formatDate)===start.dateFormat(options.formatDate)){ classes.push('ow_voting_current'); } if(today.dateFormat(options.formatDate)===start.dateFormat(options.formatDate)){ classes.push('ow_voting_today'); } if(start.getDay()===0||start.getDay()===6||options.weekends.indexOf(start.dateFormat(options.formatDate))===-1){ classes.push('ow_voting_weekend'); } if(options.beforeShowDay&&$.isFunction(options.beforeShowDay)){ classes.push(options.beforeShowDay(start)); } if(newRow){ table +=''; newRow=false; if(options.weeks){ table +=''; }} table +=''; if(start.getDay()===options.dayOfWeekStartPrev){ table +=''; newRow=true; } start.setDate(d + 1); } table +='
    ' + options.i18n[options.lang].dayOfWeek[(j + options.dayOfWeekStart) % 7] + '
    ' + w + '' + '
    ' + d + '
    ' + '
    '; calendar.html(table); mounth_picker.find('.ow_voting_label span').eq(0).text(options.i18n[options.lang].months[_ow_voting_datetime.currentTime.getMonth()]); mounth_picker.find('.ow_voting_label span').eq(1).text(_ow_voting_datetime.currentTime.getFullYear()); time=''; h=''; m=''; line_time=function line_time(h, m){ var now=_ow_voting_datetime.now(); now.setHours(h); h=parseInt(now.getHours(), 10); now.setMinutes(m); m=parseInt(now.getMinutes(), 10); var optionDateTime=new Date(_ow_voting_datetime.currentTime) optionDateTime.setHours(h); optionDateTime.setMinutes(m); classes=[]; if((options.minDateTime!==false&&options.minDateTime > optionDateTime)||(options.maxTime!==false&&_ow_voting_datetime.strtotime(options.maxTime).getTime() < now.getTime())||(options.minTime!==false&&_ow_voting_datetime.strtotime(options.minTime).getTime() > now.getTime())){ classes.push('ow_voting_disabled'); } if((options.initTime||options.defaultSelect||owvotedatetimepicker.data('changed'))&&parseInt(_ow_voting_datetime.currentTime.getHours(), 10)===parseInt(h, 10)&&(options.step > 59||Math[options.roundTime](_ow_voting_datetime.currentTime.getMinutes() / options.step) * options.step===parseInt(m, 10))){ if(options.defaultSelect||owvotedatetimepicker.data('changed')){ classes.push('ow_voting_current'); }else if(options.initTime){ classes.push('ow_voting_init_time'); }} if(parseInt(today.getHours(), 10)===parseInt(h, 10)&&parseInt(today.getMinutes(), 10)===parseInt(m, 10)){ classes.push('ow_voting_today'); } time +='
    ' + now.dateFormat(options.formatTime) + '
    '; }; if(!options.allowTimes||!$.isArray(options.allowTimes)||!options.allowTimes.length){ for (i=0, j=0; i < (options.hours12 ? 12:24); i +=1){ for (j=0; j < 60; j +=options.step){ h=(i < 10 ? '0':'') + i; m=(j < 10 ? '0':'') + j; line_time(h, m); }} }else{ for (i=0; i < options.allowTimes.length; i +=1){ h=_ow_voting_datetime.strtotime(options.allowTimes[i]).getHours(); m=_ow_voting_datetime.strtotime(options.allowTimes[i]).getMinutes(); line_time(h, m); }} timebox.html(time); opt=''; i=0; for (i=parseInt(options.yearStart, 10) + options.yearOffset; i <=parseInt(options.yearEnd, 10) + options.yearOffset; i +=1){ opt +='
    ' + i + '
    '; } yearselect.children().eq(0) .html(opt); for (i=0, opt=''; i <=11; i +=1){ opt +='
    ' + options.i18n[options.lang].months[i] + '
    '; } monthselect.children().eq(0).html(opt); $(owvotedatetimepicker) .trigger('generate.ow_voting'); }, 10); event.stopPropagation(); }) .on('afterOpen.ow_voting', function (){ if(options.timepicker){ var classType, pheight, height, top; if(timebox.find('.ow_voting_current').length){ classType='.ow_voting_current'; }else if(timebox.find('.ow_voting_init_time').length){ classType='.ow_voting_init_time'; } if(classType){ pheight=timeboxparent[0].clientHeight; height=timebox[0].offsetHeight; top=timebox.find(classType).index() * options.timeHeightInTimePicker + 1; if((height - pheight) < top){ top=height - pheight; } timeboxparent.trigger('scroll_element.ow_voting_scroller', [parseInt(top, 10) / (height - pheight)]); }else{ timeboxparent.trigger('scroll_element.ow_voting_scroller', [0]); }} }); timerclick=0; calendar .on('click.ow_voting', 'td', function (xdevent){ xdevent.stopPropagation(); timerclick +=1; var $this=$(this), currentTime=_ow_voting_datetime.currentTime; if(currentTime===undefined||currentTime===null){ _ow_voting_datetime.currentTime=_ow_voting_datetime.now(); currentTime=_ow_voting_datetime.currentTime; } if($this.hasClass('ow_voting_disabled')){ return false; } currentTime.setDate(1); currentTime.setFullYear($this.data('year')); currentTime.setMonth($this.data('month')); currentTime.setDate($this.data('date')); owvotedatetimepicker.trigger('select.ow_voting', [currentTime]); input.val(_ow_voting_datetime.str()); if((timerclick > 1||(options.closeOnDateSelect===true||(options.closeOnDateSelect===0&&!options.timepicker)))&&!options.inline){ owvotedatetimepicker.trigger('close.ow_voting'); } if(options.onSelectDate&&$.isFunction(options.onSelectDate)){ options.onSelectDate.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input'), xdevent); } owvotedatetimepicker.data('changed', true); owvotedatetimepicker.trigger('xchange.ow_voting'); owvotedatetimepicker.trigger('changedatetime.ow_voting'); setTimeout(function (){ timerclick=0; }, 200); }); timebox .on('click.ow_voting', 'div', function (xdevent){ xdevent.stopPropagation(); var $this=$(this), currentTime=_ow_voting_datetime.currentTime; if(currentTime===undefined||currentTime===null){ _ow_voting_datetime.currentTime=_ow_voting_datetime.now(); currentTime=_ow_voting_datetime.currentTime; } if($this.hasClass('ow_voting_disabled')){ return false; } currentTime.setHours($this.data('hour')); currentTime.setMinutes($this.data('minute')); owvotedatetimepicker.trigger('select.ow_voting', [currentTime]); owvotedatetimepicker.data('input').val(_ow_voting_datetime.str()); if(!options.inline){ owvotedatetimepicker.trigger('close.ow_voting'); } if(options.onSelectTime&&$.isFunction(options.onSelectTime)){ options.onSelectTime.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input'), xdevent); } owvotedatetimepicker.data('changed', true); owvotedatetimepicker.trigger('xchange.ow_voting'); owvotedatetimepicker.trigger('changedatetime.ow_voting'); }); datepicker .on('mousewheel.ow_voting', function (event){ if(!options.scrollMonth){ return true; } if(event.deltaY < 0){ _ow_voting_datetime.nextMonth(); }else{ _ow_voting_datetime.prevMonth(); } return false; }); input .on('mousewheel.ow_voting', function (event){ if(!options.scrollInput){ return true; } if(!options.datepicker&&options.timepicker){ current_time_index=timebox.find('.ow_voting_current').length ? timebox.find('.ow_voting_current').eq(0).index():0; if(current_time_index + event.deltaY >=0&¤t_time_index + event.deltaY < timebox.children().length){ current_time_index +=event.deltaY; } if(timebox.children().eq(current_time_index).length){ timebox.children().eq(current_time_index).trigger('mousedown'); } return false; } if(options.datepicker&&!options.timepicker){ datepicker.trigger(event, [event.deltaY, event.deltaX, event.deltaY]); if(input.val){ input.val(_ow_voting_datetime.str()); } owvotedatetimepicker.trigger('changedatetime.ow_voting'); return false; }}); owvotedatetimepicker .on('changedatetime.ow_voting', function (event){ if(options.onChangeDateTime&&$.isFunction(options.onChangeDateTime)){ var $input=owvotedatetimepicker.data('input'); options.onChangeDateTime.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, $input, event); delete options.value; $input.trigger('change'); }}) .on('generate.ow_voting', function (){ if(options.onGenerate&&$.isFunction(options.onGenerate)){ options.onGenerate.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input')); } if(triggerAfterOpen){ owvotedatetimepicker.trigger('afterOpen.ow_voting'); triggerAfterOpen=false; }}) .on('click.ow_voting', function (xdevent){ xdevent.stopPropagation(); }); current_time_index=0; setPos=function (){ var offset=owvotedatetimepicker.data('input').offset(), top=offset.top + owvotedatetimepicker.data('input')[0].offsetHeight - 1, left=offset.left, position="absolute"; if(options.fixed){ top -=$(window).scrollTop(); left -=$(window).scrollLeft(); position="fixed"; }else{ if(top + owvotedatetimepicker[0].offsetHeight > $(window).height() + $(window).scrollTop()){ top=offset.top - owvotedatetimepicker[0].offsetHeight + 1; } if(top < 0){ top=0; } if(left + owvotedatetimepicker[0].offsetWidth > $(window).width()){ left=$(window).width() - owvotedatetimepicker[0].offsetWidth; }} owvotedatetimepicker.css({ left: left, top: top, position: position }); }; owvotedatetimepicker .on('open.ow_voting', function (event){ var onShow=true; if(options.onShow&&$.isFunction(options.onShow)){ onShow=options.onShow.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input'), event); } if(onShow!==false){ owvotedatetimepicker.show(); setPos(); $(window) .off('resize.ow_voting', setPos) .on('resize.ow_voting', setPos); if(options.closeOnWithoutClick){ $([document.body, window]).on('mousedown.ow_voting', function arguments_callee6(){ owvotedatetimepicker.trigger('close.ow_voting'); $([document.body, window]).off('mousedown.ow_voting', arguments_callee6); }); }} }) .on('close.ow_voting', function (event){ var onClose=true; mounth_picker .find('.ow_voting_month,.ow_voting_year') .find('.ow_voting_select') .hide(); if(options.onClose&&$.isFunction(options.onClose)){ onClose=options.onClose.call(owvotedatetimepicker, _ow_voting_datetime.currentTime, owvotedatetimepicker.data('input'), event); } if(onClose!==false&&!options.opened&&!options.inline){ owvotedatetimepicker.hide(); } event.stopPropagation(); }) .on('toggle.ow_voting', function (event){ if(owvotedatetimepicker.is(':visible')){ owvotedatetimepicker.trigger('close.ow_voting'); }else{ owvotedatetimepicker.trigger('open.ow_voting'); }}) .data('input', input); timer=0; timer1=0; owvotedatetimepicker.data('ow_voting_datetime', _ow_voting_datetime); owvotedatetimepicker.setOptions(options); function getCurrentValue(){ var ct=false, time; if(options.startDate){ ct=_ow_voting_datetime.strToDate(options.startDate); }else{ ct=options.value||((input&&input.val&&input.val()) ? input.val():''); if(ct){ ct=_ow_voting_datetime.strToDateTime(ct); }else if(options.defaultDate){ ct=_ow_voting_datetime.strToDate(options.defaultDate); if(options.defaultTime){ time=_ow_voting_datetime.strtotime(options.defaultTime); ct.setHours(time.getHours()); ct.setMinutes(time.getMinutes()); }} } if(ct&&_ow_voting_datetime.isValidDate(ct)){ owvotedatetimepicker.data('changed', true); }else{ ct=''; } return ct||0; } _ow_voting_datetime.setCurrentTime(getCurrentValue()); input .data('ow_voting_owvotedatetimepicker', owvotedatetimepicker) .on('open.ow_voting focusin.ow_voting mousedown.ow_voting', function (event){ if(input.is(':disabled')||input.is(':hidden')||!input.is(':visible')||(input.data('ow_voting_owvotedatetimepicker').is(':visible')&&options.closeOnInputClick)){ return; } clearTimeout(timer); timer=setTimeout(function (){ if(input.is(':disabled')||input.is(':hidden')||!input.is(':visible')){ return; } triggerAfterOpen=true; _ow_voting_datetime.setCurrentTime(getCurrentValue()); owvotedatetimepicker.trigger('open.ow_voting'); }, 100); }) .on('keydown.ow_voting', function (event){ var val=this.value, elementSelector, key=event.which; if([ENTER].indexOf(key)!==-1&&options.enterLikeTab){ elementSelector=$("input:visible,textarea:visible"); owvotedatetimepicker.trigger('close.ow_voting'); elementSelector.eq(elementSelector.index(this) + 1).focus(); return false; } if([TAB].indexOf(key)!==-1){ owvotedatetimepicker.trigger('close.ow_voting'); return true; }}); }; destroyOWDateTimePicker=function (input){ var owvotedatetimepicker=input.data('ow_voting_owvotedatetimepicker'); if(owvotedatetimepicker){ owvotedatetimepicker.data('ow_voting_datetime', null); owvotedatetimepicker.remove(); input .data('ow_voting_owvotedatetimepicker', null) .off('.ow_voting'); $(window).off('resize.ow_voting'); $([window, document.body]).off('mousedown.ow_voting'); if(input.unmousewheel){ input.unmousewheel(); }} }; $(document) .off('keydown.ow_votingctrl keyup.ow_votingctrl') .on('keydown.ow_votingctrl', function (e){ if(e.keyCode===CTRLKEY){ ctrlDown=true; }}) .on('keyup.ow_votingctrl', function (e){ if(e.keyCode===CTRLKEY){ ctrlDown=false; }}); return this.each(function (){ var owvotedatetimepicker=$(this).data('ow_voting_owvotedatetimepicker'); if(owvotedatetimepicker){ if($.type(opt)==='string'){ switch (opt){ case 'show': $(this).select().focus(); owvotedatetimepicker.trigger('open.ow_voting'); break; case 'hide': owvotedatetimepicker.trigger('close.ow_voting'); break; case 'toggle': owvotedatetimepicker.trigger('toggle.ow_voting'); break; case 'destroy': destroyOWDateTimePicker($(this)); break; case 'reset': this.value=this.defaultValue; if(!this.value||!owvotedatetimepicker.data('ow_voting_datetime').isValidDate(Date.parseDate(this.value, options.format))){ owvotedatetimepicker.data('changed', false); } owvotedatetimepicker.data('ow_voting_datetime').setCurrentTime(this.value); break; }}else{ owvotedatetimepicker .setOptions(opt); } return 0; } if($.type(opt)!=='string'){ if(!options.lazyInit||options.open||options.inline){ createOWDateTimePicker($(this)); }else{ lazyInit($(this)); }} }); }; $.fn.owvotedatetimepicker.defaults=default_options; }(jQuery)); (function (){ !function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.12",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b),d=c["offsetParent"in a.fn?"offsetParent":"parent"]();return d.length||(d=a("body")),parseInt(d.css("fontSize"),10)||parseInt(c.css("fontSize"),10)||16},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})}); Date.parseFunctions={count:0};Date.parseRegexes=[];Date.formatFunctions={count:0};Date.prototype.dateFormat=function(b){if(b=="unixtime"){return parseInt(this.getTime()/1000);}if(Date.formatFunctions[b]==null){Date.createNewFormat(b);}var a=Date.formatFunctions[b];return this[a]();};Date.createNewFormat=function(format){var funcName="format"+Date.formatFunctions.count++;Date.formatFunctions[format]=funcName;var code="Date.prototype."+funcName+"=function(){return ";var special=false;var ch="";for(var i=0;i 0){";var regex="";var special=false;var ch="";for(var i=0;i 0&&z > 0){\nvar doyDate=new Date(y,0);\ndoyDate.setDate(z);\nm=doyDate.getMonth();\nd=doyDate.getDate();\n}";code+="if(y > 0&&m >=0&&d > 0&&h >=0&&i >=0&&s >=0)\n{return new Date(y, m, d, h, i, s);}\nelse if(y > 0&&m >=0&&d > 0&&h >=0&&i >=0)\n{return new Date(y, m, d, h, i);}\nelse if(y > 0&&m >=0&&d > 0&&h >=0)\n{return new Date(y, m, d, h);}\nelse if(y > 0&&m >=0&&d > 0)\n{return new Date(y, m, d);}\nelse if(y > 0&&m >=0)\n{return new Date(y, m);}\nelse if(y > 0)\n{return new Date(y);}\n}return null;}";Date.parseRegexes[regexNum]=new RegExp("^"+regex+"$");eval(code);};Date.formatCodeToRegex=function(b,a){switch(b){case"D":return{g:0,c:null,s:"(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)"};case"j":case"d":return{g:1,c:"d=parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"l":return{g:0,c:null,s:"(?:"+Date.dayNames.join("|")+")"};case"S":return{g:0,c:null,s:"(?:st|nd|rd|th)"};case"w":return{g:0,c:null,s:"\\d"};case"z":return{g:1,c:"z=parseInt(results["+a+"], 10);\n",s:"(\\d{1,3})"};case"W":return{g:0,c:null,s:"(?:\\d{2})"};case"F":return{g:1,c:"m=parseInt(Date.monthNumbers[results["+a+"].substring(0, 3)], 10);\n",s:"("+Date.monthNames.join("|")+")"};case"M":return{g:1,c:"m=parseInt(Date.monthNumbers[results["+a+"]], 10);\n",s:"(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)"};case"n":case"m":return{g:1,c:"m=parseInt(results["+a+"], 10) - 1;\n",s:"(\\d{1,2})"};case"t":return{g:0,c:null,s:"\\d{1,2}"};case"L":return{g:0,c:null,s:"(?:1|0)"};case"Y":return{g:1,c:"y=parseInt(results["+a+"], 10);\n",s:"(\\d{4})"};case"y":return{g:1,c:"var ty=parseInt(results["+a+"], 10);\ny=ty > Date.y2kYear ? 1900 + ty:2000 + ty;\n",s:"(\\d{1,2})"};case"a":return{g:1,c:"if(results["+a+"]=='am'){\nif(h==12){ h=0; }\n}else{ if(h < 12){ h +=12; }}",s:"(am|pm)"};case"A":return{g:1,c:"if(results["+a+"]=='AM'){\nif(h==12){ h=0; }\n}else{ if(h < 12){ h +=12; }}",s:"(AM|PM)"};case"g":case"G":case"h":case"H":return{g:1,c:"h=parseInt(results["+a+"], 10);\n",s:"(\\d{1,2})"};case"i":return{g:1,c:"i=parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"s":return{g:1,c:"s=parseInt(results["+a+"], 10);\n",s:"(\\d{2})"};case"O":return{g:0,c:null,s:"[+-]\\d{4}"};case"T":return{g:0,c:null,s:"[A-Z]{3}"};case"Z":return{g:0,c:null,s:"[+-]\\d{1,5}"};default:return{g:0,c:null,s:String.escape(b)};}};Date.prototype.getTimezone=function(){return this.toString().replace(/^.*? ([A-Z]{3}) [0-9]{4}.*$/,"$1").replace(/^.*?\(([A-Z])[a-z]+ ([A-Z])[a-z]+ ([A-Z])[a-z]+\)$/,"$1$2$3");};Date.prototype.getGMTOffset=function(){return(this.getTimezoneOffset()>0?"-":"+")+String.leftPad(Math.floor(Math.abs(this.getTimezoneOffset())/60),2,"0")+String.leftPad(Math.abs(this.getTimezoneOffset())%60,2,"0");};Date.prototype.getDayOfYear=function(){var a=0;Date.daysInMonth[1]=this.isLeapYear()?29:28;for(var b=0;b',i=n.firstChild,n.setAttribute("style","display:none; position:absolute;"),d.body.appendChild(n));for(var a={},s=0;sx',t=e.firstChild.href}return t},Ge=function(t){if("string"==typeof t){var e=/^(\/?)([\s\S]*?)((?:\.{1,2}|[^\/]+?)(\.([^\.\/\?]+)))(?:[\/]*|[\?].*)$/i.exec(t);if(e)return e.pop().toLowerCase()}return""},Xe=function(t){var e=v.location,i=ze(t);return(":"===i.protocol?e.protocol:i.protocol)+i.host!==e.protocol+e.host},Ye=Object.freeze({parseUrl:ze,getAbsoluteURL:We,getFileExtension:Ge,isCrossOrigin:Xe}),$e=function(t){var e=Ke.call(t);return"[object Function]"===e||"function"==typeof t&&"[object RegExp]"!==e||"undefined"!=typeof window&&(t===window.setTimeout||t===window.alert||t===window.confirm||t===window.prompt)},Ke=Object.prototype.toString;"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Qe(t,e){return t(e={exports:{}},e.exports),e.exports}var Je=Qe(function(t,e){(e=t.exports=function(t){return t.replace(/^\s*|\s*$/g,"")}).left=function(t){return t.replace(/^\s*/,"")},e.right=function(t){return t.replace(/\s*$/,"")}}),Ze=(Je.left,Je.right,Function.prototype.toString),ti=/^\s*class\b/,ei=function(t){try{var e=Ze.call(t);return ti.test(e)}catch(t){return!1}},ii=Object.prototype.toString,ni="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag,ri=function(t){if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if("function"==typeof t&&!t.prototype)return!0;if(ni)return function(t){try{return!ei(t)&&(Ze.call(t),!0)}catch(t){return!1}}(t);if(ei(t))return!1;var e=ii.call(t);return"[object Function]"===e||"[object GeneratorFunction]"===e},ai=Object.prototype.toString,si=Object.prototype.hasOwnProperty,oi=function(t,e,i){if(!ri(e))throw new TypeError("iterator must be a function");var n;3<=arguments.length&&(n=i),"[object Array]"===ai.call(t)?function(t,e,i){for(var n=0,r=t.length;n=t?e.push(r):r.startTime===r.endTime&&r.startTime<=t&&r.startTime+.5>=t&&e.push(r)}if(o=!1,e.length!==this.activeCues_.length)o=!0;else for(var a=0;a","‎":"‎","‏":"‏"," ":" "},Pi={c:"span",i:"i",b:"b",u:"u",ruby:"ruby",rt:"rt",v:"span",lang:"span"},Ui={v:"title",lang:"lang"},xi={rt:"ruby"};function Ii(a,i){function t(){if(!i)return null;var t,e=i.match(/^([^<]*)(<[^>]*>?)?/);return t=e[1]?e[1]:e[2],i=i.substr(t.length),t}function e(t){return Oi[t]}function n(t){for(;f=t.match(/&(amp|lt|gt|lrm|rlm|nbsp);/);)t=t.replace(f[0],e);return t}function r(t,e){var i=Pi[t];if(!i)return null;var n=a.document.createElement(i);n.localName=i;var r=Ui[t];return r&&e&&(n[r]=e.trim()),n}for(var s,o,u,l=a.document.createElement("div"),c=l,h=[];null!==(s=t());)if("<"!==s[0])c.appendChild(a.document.createTextNode(n(s)));else{if("/"===s[1]){h.length&&h[h.length-1]===s.substr(2).replace(">","")&&(h.pop(),c=c.parentNode);continue}var d,p=Ci(s.substr(1,s.length-2));if(p){d=a.document.createProcessingInstruction("timestamp",p),c.appendChild(d);continue}var f=s.match(/^<([^.\s/0-9>]+)(\.[^\s\\>]+)?([^>\\]+)?(\\?)>?$/);if(!f)continue;if(!(d=r(f[1],f[3])))continue;if(o=c,xi[(u=d).localName]&&xi[u.localName]!==o.localName)continue;f[2]&&(d.className=f[2].substr(1).replace("."," ")),h.push(f[1]),c.appendChild(d),c=d}return l}var Di=[[1470,1470],[1472,1472],[1475,1475],[1478,1478],[1488,1514],[1520,1524],[1544,1544],[1547,1547],[1549,1549],[1563,1563],[1566,1610],[1645,1647],[1649,1749],[1765,1766],[1774,1775],[1786,1805],[1807,1808],[1810,1839],[1869,1957],[1969,1969],[1984,2026],[2036,2037],[2042,2042],[2048,2069],[2074,2074],[2084,2084],[2088,2088],[2096,2110],[2112,2136],[2142,2142],[2208,2208],[2210,2220],[8207,8207],[64285,64285],[64287,64296],[64298,64310],[64312,64316],[64318,64318],[64320,64321],[64323,64324],[64326,64449],[64467,64829],[64848,64911],[64914,64967],[65008,65020],[65136,65140],[65142,65276],[67584,67589],[67592,67592],[67594,67637],[67639,67640],[67644,67644],[67647,67669],[67671,67679],[67840,67867],[67872,67897],[67903,67903],[67968,68023],[68030,68031],[68096,68096],[68112,68115],[68117,68119],[68121,68147],[68160,68167],[68176,68184],[68192,68223],[68352,68405],[68416,68437],[68440,68466],[68472,68479],[68608,68680],[126464,126467],[126469,126495],[126497,126498],[126500,126500],[126503,126503],[126505,126514],[126516,126519],[126521,126521],[126523,126523],[126530,126530],[126535,126535],[126537,126537],[126539,126539],[126541,126543],[126545,126546],[126548,126548],[126551,126551],[126553,126553],[126555,126555],[126557,126557],[126559,126559],[126561,126562],[126564,126564],[126567,126570],[126572,126578],[126580,126583],[126585,126588],[126590,126590],[126592,126601],[126603,126619],[126625,126627],[126629,126633],[126635,126651],[1114109,1114109]];function Ri(t){for(var e=0;e=i[0]&&t<=i[1])return!0}return!1}function Mi(){}function Bi(t,e,i){Mi.call(this),this.cue=e,this.cueDiv=Ii(t,e.text);var n={color:"rgba(255, 255, 255, 1)",backgroundColor:"rgba(0, 0, 0, 0.8)",position:"relative",left:0,right:0,top:0,bottom:0,display:"inline",writingMode:""===e.vertical?"horizontal-tb":"lr"===e.vertical?"vertical-lr":"vertical-rl",unicodeBidi:"plaintext"};this.applyStyles(n,this.cueDiv),this.div=t.document.createElement("div"),n={direction:function(t){var e=[],i="";if(!t||!t.childNodes)return"ltr";function r(t,e){for(var i=e.childNodes.length-1;0<=i;i--)t.push(e.childNodes[i])}function a(t){if(!t||!t.length)return null;var e=t.pop(),i=e.textContent||e.innerText;if(i){var n=i.match(/^.*(\n|\r)/);return n?n[t.length=0]:i}return"ruby"===e.tagName?a(t):e.childNodes?(r(t,e),a(t)):void 0}for(r(e,t);i=a(e);)for(var n=0;nh&&(c=c<0?-1:1,c*=Math.ceil(h/l)*l),r<0&&(c+=""===n.vertical?o.height:o.width,a=a.reverse()),i.move(d,c)}else{var p=i.lineHeight/o.height*100;switch(n.lineAlign){case"middle":r-=p/2;break;case"end":r-=p}switch(n.vertical){case"":e.applyStyles({top:e.formatStyle(r,"%")});break;case"rl":e.applyStyles({left:e.formatStyle(r,"%")});break;case"lr":e.applyStyles({right:e.formatStyle(r,"%")})}a=["+y","-x","+x","-y"],i=new Ni(e)}var f=function(t,e){for(var i,n=new Ni(t),r=1,a=0;at.left&&this.topt.top},Ni.prototype.overlapsAny=function(t){for(var e=0;e=t.top&&this.bottom<=t.bottom&&this.left>=t.left&&this.right<=t.right},Ni.prototype.overlapsOppositeAxis=function(t,e){switch(e){case"+x":return this.leftt.right;case"+y":return this.topt.bottom}},Ni.prototype.intersectPercentage=function(t){return Math.max(0,Math.min(this.right,t.right)-Math.max(this.left,t.left))*Math.max(0,Math.min(this.bottom,t.bottom)-Math.max(this.top,t.top))/(this.height*this.width)},Ni.prototype.toCSSCompatValues=function(t){return{top:this.top-t.top,bottom:t.bottom-this.bottom,left:this.left-t.left,right:t.right-this.right,height:this.height,width:this.width}},Ni.getSimpleBoxPosition=function(t){var e=t.div?t.div.offsetHeight:t.tagName?t.offsetHeight:0,i=t.div?t.div.offsetWidth:t.tagName?t.offsetWidth:0,n=t.div?t.div.offsetTop:t.tagName?t.offsetTop:0;return{left:(t=t.div?t.div.getBoundingClientRect():t.tagName?t.getBoundingClientRect():t).left,right:t.right,top:t.top||n,height:t.height||e,bottom:t.bottom||n+(t.height||e),width:t.width||i}},Fi.StringDecoder=function(){return{decode:function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))}}},Fi.convertCueToDOMTree=function(t,e){return t&&e?Ii(t,e):null};Fi.processCues=function(n,r,t){if(!n||!r||!t)return null;for(;t.firstChild;)t.removeChild(t.firstChild);var a=n.document.createElement("div");if(a.style.position="absolute",a.style.left="0",a.style.right="0",a.style.top="0",a.style.bottom="0",a.style.margin="1.5%",t.appendChild(a),function(t){for(var e=0;e