").append(b.parseHTML(e)).find(i):e)}).complete(r&&function(e,t){s.each(r,o||[e.responseText,t,e])}),this},b.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){b.fn[t]=function(e){return this.on(t,e)}}),b.each(["get","post"],function(e,n){b[n]=function(e,r,i,o){return b.isFunction(r)&&(o=o||i,i=r,r=t),b.ajax({url:e,type:n,dataType:o,data:r,success:i})}}),b.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:yn,type:"GET",isLocal:Nn.test(mn[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Dn,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":e.String,"text html":!0,"text json":b.parseJSON,"text xml":b.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?Mn(Mn(e,b.ajaxSettings),t):Mn(b.ajaxSettings,e)},ajaxPrefilter:Hn(An),ajaxTransport:Hn(jn),ajax:function(e,n){"object"==typeof e&&(n=e,e=t),n=n||{};var r,i,o,a,s,u,l,c,p=b.ajaxSetup({},n),f=p.context||p,d=p.context&&(f.nodeType||f.jquery)?b(f):b.event,h=b.Deferred(),g=b.Callbacks("once memory"),m=p.statusCode||{},y={},v={},x=0,T="canceled",N={readyState:0,getResponseHeader:function(e){var t;if(2===x){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return 2===x?a:null},setRequestHeader:function(e,t){var n=e.toLowerCase();return x||(e=v[n]=v[n]||e,y[e]=t),this},overrideMimeType:function(e){return x||(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(2>x)for(t in e)m[t]=[m[t],e[t]];else N.always(e[N.status]);return this},abort:function(e){var t=e||T;return l&&l.abort(t),k(0,t),this}};if(h.promise(N).complete=g.add,N.success=N.done,N.error=N.fail,p.url=((e||p.url||yn)+"").replace(xn,"").replace(kn,mn[1]+"//"),p.type=n.method||n.type||p.method||p.type,p.dataTypes=b.trim(p.dataType||"*").toLowerCase().match(w)||[""],null==p.crossDomain&&(r=En.exec(p.url.toLowerCase()),p.crossDomain=!(!r||r[1]===mn[1]&&r[2]===mn[2]&&(r[3]||("http:"===r[1]?80:443))==(mn[3]||("http:"===mn[1]?80:443)))),p.data&&p.processData&&"string"!=typeof p.data&&(p.data=b.param(p.data,p.traditional)),qn(An,p,n,N),2===x)return N;u=p.global,u&&0===b.active++&&b.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Cn.test(p.type),o=p.url,p.hasContent||(p.data&&(o=p.url+=(bn.test(o)?"&":"?")+p.data,delete p.data),p.cache===!1&&(p.url=wn.test(o)?o.replace(wn,"$1_="+vn++):o+(bn.test(o)?"&":"?")+"_="+vn++)),p.ifModified&&(b.lastModified[o]&&N.setRequestHeader("If-Modified-Since",b.lastModified[o]),b.etag[o]&&N.setRequestHeader("If-None-Match",b.etag[o])),(p.data&&p.hasContent&&p.contentType!==!1||n.contentType)&&N.setRequestHeader("Content-Type",p.contentType),N.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Dn+"; q=0.01":""):p.accepts["*"]);for(i in p.headers)N.setRequestHeader(i,p.headers[i]);if(p.beforeSend&&(p.beforeSend.call(f,N,p)===!1||2===x))return N.abort();T="abort";for(i in{success:1,error:1,complete:1})N[i](p[i]);if(l=qn(jn,p,n,N)){N.readyState=1,u&&d.trigger("ajaxSend",[N,p]),p.async&&p.timeout>0&&(s=setTimeout(function(){N.abort("timeout")},p.timeout));try{x=1,l.send(y,k)}catch(C){if(!(2>x))throw C;k(-1,C)}}else k(-1,"No Transport");function k(e,n,r,i){var c,y,v,w,T,C=n;2!==x&&(x=2,s&&clearTimeout(s),l=t,a=i||"",N.readyState=e>0?4:0,r&&(w=_n(p,N,r)),e>=200&&300>e||304===e?(p.ifModified&&(T=N.getResponseHeader("Last-Modified"),T&&(b.lastModified[o]=T),T=N.getResponseHeader("etag"),T&&(b.etag[o]=T)),204===e?(c=!0,C="nocontent"):304===e?(c=!0,C="notmodified"):(c=Fn(p,w),C=c.state,y=c.data,v=c.error,c=!v)):(v=C,(e||!C)&&(C="error",0>e&&(e=0))),N.status=e,N.statusText=(n||C)+"",c?h.resolveWith(f,[y,C,N]):h.rejectWith(f,[N,C,v]),N.statusCode(m),m=t,u&&d.trigger(c?"ajaxSuccess":"ajaxError",[N,p,c?y:v]),g.fireWith(f,[N,C]),u&&(d.trigger("ajaxComplete",[N,p]),--b.active||b.event.trigger("ajaxStop")))}return N},getScript:function(e,n){return b.get(e,t,n,"script")},getJSON:function(e,t,n){return b.get(e,t,n,"json")}});function _n(e,n,r){var i,o,a,s,u=e.contents,l=e.dataTypes,c=e.responseFields;for(s in c)s in r&&(n[c[s]]=r[s]);while("*"===l[0])l.shift(),o===t&&(o=e.mimeType||n.getResponseHeader("Content-Type"));if(o)for(s in u)if(u[s]&&u[s].test(o)){l.unshift(s);break}if(l[0]in r)a=l[0];else{for(s in r){if(!l[0]||e.converters[s+" "+l[0]]){a=s;break}i||(i=s)}a=a||i}return a?(a!==l[0]&&l.unshift(a),r[a]):t}function Fn(e,t){var n,r,i,o,a={},s=0,u=e.dataTypes.slice(),l=u[0];if(e.dataFilter&&(t=e.dataFilter(t,e.dataType)),u[1])for(i in e.converters)a[i.toLowerCase()]=e.converters[i];for(;r=u[++s];)if("*"!==r){if("*"!==l&&l!==r){if(i=a[l+" "+r]||a["* "+r],!i)for(n in a)if(o=n.split(" "),o[1]===r&&(i=a[l+" "+o[0]]||a["* "+o[0]])){i===!0?i=a[n]:a[n]!==!0&&(r=o[0],u.splice(s--,0,r));break}if(i!==!0)if(i&&e["throws"])t=i(t);else try{t=i(t)}catch(c){return{state:"parsererror",error:i?c:"No conversion from "+l+" to "+r}}}l=r}return{state:"success",data:t}}b.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(e){return b.globalEval(e),e}}}),b.ajaxPrefilter("script",function(e){e.cache===t&&(e.cache=!1),e.crossDomain&&(e.type="GET",e.global=!1)}),b.ajaxTransport("script",function(e){if(e.crossDomain){var n,r=o.head||b("head")[0]||o.documentElement;return{send:function(t,i){n=o.createElement("script"),n.async=!0,e.scriptCharset&&(n.charset=e.scriptCharset),n.src=e.url,n.onload=n.onreadystatechange=function(e,t){(t||!n.readyState||/loaded|complete/.test(n.readyState))&&(n.onload=n.onreadystatechange=null,n.parentNode&&n.parentNode.removeChild(n),n=null,t||i(200,"success"))},r.insertBefore(n,r.firstChild)},abort:function(){n&&n.onload(t,!0)}}}});var On=[],Bn=/(=)\?(?=&|$)|\?\?/;b.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=On.pop()||b.expando+"_"+vn++;return this[e]=!0,e}}),b.ajaxPrefilter("json jsonp",function(n,r,i){var o,a,s,u=n.jsonp!==!1&&(Bn.test(n.url)?"url":"string"==typeof n.data&&!(n.contentType||"").indexOf("application/x-www-form-urlencoded")&&Bn.test(n.data)&&"data");return u||"jsonp"===n.dataTypes[0]?(o=n.jsonpCallback=b.isFunction(n.jsonpCallback)?n.jsonpCallback():n.jsonpCallback,u?n[u]=n[u].replace(Bn,"$1"+o):n.jsonp!==!1&&(n.url+=(bn.test(n.url)?"&":"?")+n.jsonp+"="+o),n.converters["script json"]=function(){return s||b.error(o+" was not called"),s[0]},n.dataTypes[0]="json",a=e[o],e[o]=function(){s=arguments},i.always(function(){e[o]=a,n[o]&&(n.jsonpCallback=r.jsonpCallback,On.push(o)),s&&b.isFunction(a)&&a(s[0]),s=a=t}),"script"):t});var Pn,Rn,Wn=0,$n=e.ActiveXObject&&function(){var e;for(e in Pn)Pn[e](t,!0)};function In(){try{return new e.XMLHttpRequest}catch(t){}}function zn(){try{return new e.ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}b.ajaxSettings.xhr=e.ActiveXObject?function(){return!this.isLocal&&In()||zn()}:In,Rn=b.ajaxSettings.xhr(),b.support.cors=!!Rn&&"withCredentials"in Rn,Rn=b.support.ajax=!!Rn,Rn&&b.ajaxTransport(function(n){if(!n.crossDomain||b.support.cors){var r;return{send:function(i,o){var a,s,u=n.xhr();if(n.username?u.open(n.type,n.url,n.async,n.username,n.password):u.open(n.type,n.url,n.async),n.xhrFields)for(s in n.xhrFields)u[s]=n.xhrFields[s];n.mimeType&&u.overrideMimeType&&u.overrideMimeType(n.mimeType),n.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest");try{for(s in i)u.setRequestHeader(s,i[s])}catch(l){}u.send(n.hasContent&&n.data||null),r=function(e,i){var s,l,c,p;try{if(r&&(i||4===u.readyState))if(r=t,a&&(u.onreadystatechange=b.noop,$n&&delete Pn[a]),i)4!==u.readyState&&u.abort();else{p={},s=u.status,l=u.getAllResponseHeaders(),"string"==typeof u.responseText&&(p.text=u.responseText);try{c=u.statusText}catch(f){c=""}s||!n.isLocal||n.crossDomain?1223===s&&(s=204):s=p.text?200:404}}catch(d){i||o(-1,d)}p&&o(s,c,p,l)},n.async?4===u.readyState?setTimeout(r):(a=++Wn,$n&&(Pn||(Pn={},b(e).unload($n)),Pn[a]=r),u.onreadystatechange=r):r()},abort:function(){r&&r(t,!0)}}}});var Xn,Un,Vn=/^(?:toggle|show|hide)$/,Yn=RegExp("^(?:([+-])=|)("+x+")([a-z%]*)$","i"),Jn=/queueHooks$/,Gn=[nr],Qn={"*":[function(e,t){var n,r,i=this.createTween(e,t),o=Yn.exec(t),a=i.cur(),s=+a||0,u=1,l=20;if(o){if(n=+o[2],r=o[3]||(b.cssNumber[e]?"":"px"),"px"!==r&&s){s=b.css(i.elem,e,!0)||n||1;do u=u||".5",s/=u,b.style(i.elem,e,s+r);while(u!==(u=i.cur()/a)&&1!==u&&--l)}i.unit=r,i.start=s,i.end=o[1]?s+(o[1]+1)*n:n}return i}]};function Kn(){return setTimeout(function(){Xn=t}),Xn=b.now()}function Zn(e,t){b.each(t,function(t,n){var r=(Qn[t]||[]).concat(Qn["*"]),i=0,o=r.length;for(;o>i;i++)if(r[i].call(e,t,n))return})}function er(e,t,n){var r,i,o=0,a=Gn.length,s=b.Deferred().always(function(){delete u.elem}),u=function(){if(i)return!1;var t=Xn||Kn(),n=Math.max(0,l.startTime+l.duration-t),r=n/l.duration||0,o=1-r,a=0,u=l.tweens.length;for(;u>a;a++)l.tweens[a].run(o);return s.notifyWith(e,[l,o,n]),1>o&&u?n:(s.resolveWith(e,[l]),!1)},l=s.promise({elem:e,props:b.extend({},t),opts:b.extend(!0,{specialEasing:{}},n),originalProperties:t,originalOptions:n,startTime:Xn||Kn(),duration:n.duration,tweens:[],createTween:function(t,n){var r=b.Tween(e,l.opts,t,n,l.opts.specialEasing[t]||l.opts.easing);return l.tweens.push(r),r},stop:function(t){var n=0,r=t?l.tweens.length:0;if(i)return this;for(i=!0;r>n;n++)l.tweens[n].run(1);return t?s.resolveWith(e,[l,t]):s.rejectWith(e,[l,t]),this}}),c=l.props;for(tr(c,l.opts.specialEasing);a>o;o++)if(r=Gn[o].call(l,e,c,l.opts))return r;return Zn(l,c),b.isFunction(l.opts.start)&&l.opts.start.call(e,l),b.fx.timer(b.extend(u,{elem:e,anim:l,queue:l.opts.queue})),l.progress(l.opts.progress).done(l.opts.done,l.opts.complete).fail(l.opts.fail).always(l.opts.always)}function tr(e,t){var n,r,i,o,a;for(i in e)if(r=b.camelCase(i),o=t[r],n=e[i],b.isArray(n)&&(o=n[1],n=e[i]=n[0]),i!==r&&(e[r]=n,delete e[i]),a=b.cssHooks[r],a&&"expand"in a){n=a.expand(n),delete e[r];for(i in n)i in e||(e[i]=n[i],t[i]=o)}else t[r]=o}b.Animation=b.extend(er,{tweener:function(e,t){b.isFunction(e)?(t=e,e=["*"]):e=e.split(" ");var n,r=0,i=e.length;for(;i>r;r++)n=e[r],Qn[n]=Qn[n]||[],Qn[n].unshift(t)},prefilter:function(e,t){t?Gn.unshift(e):Gn.push(e)}});function nr(e,t,n){var r,i,o,a,s,u,l,c,p,f=this,d=e.style,h={},g=[],m=e.nodeType&&nn(e);n.queue||(c=b._queueHooks(e,"fx"),null==c.unqueued&&(c.unqueued=0,p=c.empty.fire,c.empty.fire=function(){c.unqueued||p()}),c.unqueued++,f.always(function(){f.always(function(){c.unqueued--,b.queue(e,"fx").length||c.empty.fire()})})),1===e.nodeType&&("height"in t||"width"in t)&&(n.overflow=[d.overflow,d.overflowX,d.overflowY],"inline"===b.css(e,"display")&&"none"===b.css(e,"float")&&(b.support.inlineBlockNeedsLayout&&"inline"!==un(e.nodeName)?d.zoom=1:d.display="inline-block")),n.overflow&&(d.overflow="hidden",b.support.shrinkWrapBlocks||f.always(function(){d.overflow=n.overflow[0],d.overflowX=n.overflow[1],d.overflowY=n.overflow[2]}));for(i in t)if(a=t[i],Vn.exec(a)){if(delete t[i],u=u||"toggle"===a,a===(m?"hide":"show"))continue;g.push(i)}if(o=g.length){s=b._data(e,"fxshow")||b._data(e,"fxshow",{}),"hidden"in s&&(m=s.hidden),u&&(s.hidden=!m),m?b(e).show():f.done(function(){b(e).hide()}),f.done(function(){var t;b._removeData(e,"fxshow");for(t in h)b.style(e,t,h[t])});for(i=0;o>i;i++)r=g[i],l=f.createTween(r,m?s[r]:0),h[r]=s[r]||b.style(e,r),r in s||(s[r]=l.start,m&&(l.end=l.start,l.start="width"===r||"height"===r?1:0))}}function rr(e,t,n,r,i){return new rr.prototype.init(e,t,n,r,i)}b.Tween=rr,rr.prototype={constructor:rr,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||"swing",this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(b.cssNumber[n]?"":"px")},cur:function(){var e=rr.propHooks[this.prop];return e&&e.get?e.get(this):rr.propHooks._default.get(this)},run:function(e){var t,n=rr.propHooks[this.prop];return this.pos=t=this.options.duration?b.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):rr.propHooks._default.set(this),this}},rr.prototype.init.prototype=rr.prototype,rr.propHooks={_default:{get:function(e){var t;return null==e.elem[e.prop]||e.elem.style&&null!=e.elem.style[e.prop]?(t=b.css(e.elem,e.prop,""),t&&"auto"!==t?t:0):e.elem[e.prop]},set:function(e){b.fx.step[e.prop]?b.fx.step[e.prop](e):e.elem.style&&(null!=e.elem.style[b.cssProps[e.prop]]||b.cssHooks[e.prop])?b.style(e.elem,e.prop,e.now+e.unit):e.elem[e.prop]=e.now}}},rr.propHooks.scrollTop=rr.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},b.each(["toggle","show","hide"],function(e,t){var n=b.fn[t];b.fn[t]=function(e,r,i){return null==e||"boolean"==typeof e?n.apply(this,arguments):this.animate(ir(t,!0),e,r,i)}}),b.fn.extend({fadeTo:function(e,t,n,r){return this.filter(nn).css("opacity",0).show().end().animate({opacity:t},e,n,r)},animate:function(e,t,n,r){var i=b.isEmptyObject(e),o=b.speed(t,n,r),a=function(){var t=er(this,b.extend({},e),o);a.finish=function(){t.stop(!0)},(i||b._data(this,"finish"))&&t.stop(!0)};return a.finish=a,i||o.queue===!1?this.each(a):this.queue(o.queue,a)},stop:function(e,n,r){var i=function(e){var t=e.stop;delete e.stop,t(r)};return"string"!=typeof e&&(r=n,n=e,e=t),n&&e!==!1&&this.queue(e||"fx",[]),this.each(function(){var t=!0,n=null!=e&&e+"queueHooks",o=b.timers,a=b._data(this);if(n)a[n]&&a[n].stop&&i(a[n]);else for(n in a)a[n]&&a[n].stop&&Jn.test(n)&&i(a[n]);for(n=o.length;n--;)o[n].elem!==this||null!=e&&o[n].queue!==e||(o[n].anim.stop(r),t=!1,o.splice(n,1));(t||!r)&&b.dequeue(this,e)})},finish:function(e){return e!==!1&&(e=e||"fx"),this.each(function(){var t,n=b._data(this),r=n[e+"queue"],i=n[e+"queueHooks"],o=b.timers,a=r?r.length:0;for(n.finish=!0,b.queue(this,e,[]),i&&i.cur&&i.cur.finish&&i.cur.finish.call(this),t=o.length;t--;)o[t].elem===this&&o[t].queue===e&&(o[t].anim.stop(!0),o.splice(t,1));for(t=0;a>t;t++)r[t]&&r[t].finish&&r[t].finish.call(this);delete n.finish})}});function ir(e,t){var n,r={height:e},i=0;for(t=t?1:0;4>i;i+=2-t)n=Zt[i],r["margin"+n]=r["padding"+n]=e;return t&&(r.opacity=r.width=e),r}b.each({slideDown:ir("show"),slideUp:ir("hide"),slideToggle:ir("toggle"),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(e,t){b.fn[e]=function(e,n,r){return this.animate(t,e,n,r)}}),b.speed=function(e,t,n){var r=e&&"object"==typeof e?b.extend({},e):{complete:n||!n&&t||b.isFunction(e)&&e,duration:e,easing:n&&t||t&&!b.isFunction(t)&&t};return r.duration=b.fx.off?0:"number"==typeof r.duration?r.duration:r.duration in b.fx.speeds?b.fx.speeds[r.duration]:b.fx.speeds._default,(null==r.queue||r.queue===!0)&&(r.queue="fx"),r.old=r.complete,r.complete=function(){b.isFunction(r.old)&&r.old.call(this),r.queue&&b.dequeue(this,r.queue)},r},b.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2}},b.timers=[],b.fx=rr.prototype.init,b.fx.tick=function(){var e,n=b.timers,r=0;for(Xn=b.now();n.length>r;r++)e=n[r],e()||n[r]!==e||n.splice(r--,1);n.length||b.fx.stop(),Xn=t},b.fx.timer=function(e){e()&&b.timers.push(e)&&b.fx.start()},b.fx.interval=13,b.fx.start=function(){Un||(Un=setInterval(b.fx.tick,b.fx.interval))},b.fx.stop=function(){clearInterval(Un),Un=null},b.fx.speeds={slow:600,fast:200,_default:400},b.fx.step={},b.expr&&b.expr.filters&&(b.expr.filters.animated=function(e){return b.grep(b.timers,function(t){return e===t.elem}).length}),b.fn.offset=function(e){if(arguments.length)return e===t?this:this.each(function(t){b.offset.setOffset(this,e,t)});var n,r,o={top:0,left:0},a=this[0],s=a&&a.ownerDocument;if(s)return n=s.documentElement,b.contains(n,a)?(typeof a.getBoundingClientRect!==i&&(o=a.getBoundingClientRect()),r=or(s),{top:o.top+(r.pageYOffset||n.scrollTop)-(n.clientTop||0),left:o.left+(r.pageXOffset||n.scrollLeft)-(n.clientLeft||0)}):o},b.offset={setOffset:function(e,t,n){var r=b.css(e,"position");"static"===r&&(e.style.position="relative");var i=b(e),o=i.offset(),a=b.css(e,"top"),s=b.css(e,"left"),u=("absolute"===r||"fixed"===r)&&b.inArray("auto",[a,s])>-1,l={},c={},p,f;u?(c=i.position(),p=c.top,f=c.left):(p=parseFloat(a)||0,f=parseFloat(s)||0),b.isFunction(t)&&(t=t.call(e,n,o)),null!=t.top&&(l.top=t.top-o.top+p),null!=t.left&&(l.left=t.left-o.left+f),"using"in t?t.using.call(e,l):i.css(l)}},b.fn.extend({position:function(){if(this[0]){var e,t,n={top:0,left:0},r=this[0];return"fixed"===b.css(r,"position")?t=r.getBoundingClientRect():(e=this.offsetParent(),t=this.offset(),b.nodeName(e[0],"html")||(n=e.offset()),n.top+=b.css(e[0],"borderTopWidth",!0),n.left+=b.css(e[0],"borderLeftWidth",!0)),{top:t.top-n.top-b.css(r,"marginTop",!0),left:t.left-n.left-b.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent||o.documentElement;while(e&&!b.nodeName(e,"html")&&"static"===b.css(e,"position"))e=e.offsetParent;return e||o.documentElement})}}),b.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(e,n){var r=/Y/.test(n);b.fn[e]=function(i){return b.access(this,function(e,i,o){var a=or(e);return o===t?a?n in a?a[n]:a.document.documentElement[i]:e[i]:(a?a.scrollTo(r?b(a).scrollLeft():o,r?o:b(a).scrollTop()):e[i]=o,t)},e,i,arguments.length,null)}});function or(e){return b.isWindow(e)?e:9===e.nodeType?e.defaultView||e.parentWindow:!1}b.each({Height:"height",Width:"width"},function(e,n){b.each({padding:"inner"+e,content:n,"":"outer"+e},function(r,i){b.fn[i]=function(i,o){var a=arguments.length&&(r||"boolean"!=typeof i),s=r||(i===!0||o===!0?"margin":"border");return b.access(this,function(n,r,i){var o;return b.isWindow(n)?n.document.documentElement["client"+e]:9===n.nodeType?(o=n.documentElement,Math.max(n.body["scroll"+e],o["scroll"+e],n.body["offset"+e],o["offset"+e],o["client"+e])):i===t?b.css(n,r,s):b.style(n,r,i,s)},n,a?i:t,a,null)}})}),e.jQuery=e.$=b,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return b})})(window);
/*! H5F
* https://github.com/ryanseddon/H5F/
* Copyright (c) Ryan Seddon | Licensed MIT */
(function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof module&&module.exports?module.exports=t():e.H5F=t()})(this,function(){var e,t,a,i,n,r,l,s,o,u,d,c,v,p,f,m,b,h,g,y,w,C,N,A,E,$,x=document,k=x.createElement("input"),q=/^[a-zA-Z0-9.!#$%&'*+-\/=?\^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/,M=/[a-z][\-\.+a-z]*:\/\//i,L=/^(input|select|textarea)$/i;return r=function(e,t){var a=!e.nodeType||!1,i={validClass:"valid",invalidClass:"error",requiredClass:"required",placeholderClass:"placeholder",onSubmit:Function.prototype,onInvalid:Function.prototype};if("object"==typeof t)for(var r in i)t[r]===void 0&&(t[r]=i[r]);if(n=t||i,a)for(var s=0,o=e.length;o>s;s++)l(e[s]);else l(e)},l=function(a){var i,r=a.elements,l=r.length,c=!!a.attributes.novalidate;if(g(a,"invalid",o,!0),g(a,"blur",o,!0),g(a,"input",o,!0),g(a,"keyup",o,!0),g(a,"focus",o,!0),g(a,"change",o,!0),g(a,"click",u,!0),g(a,"submit",function(i){return e=!0,t||c||a.checkValidity()?(n.onSubmit.call(a,i),void 0):(w(i),void 0)},!1),!v())for(a.checkValidity=function(){return d(a)};l--;)i=!!r[l].attributes.required,"fieldset"!==r[l].nodeName.toLowerCase()&&s(r[l])},s=function(e){var t=e,a=h(t),n={type:t.getAttribute("type"),pattern:t.getAttribute("pattern"),placeholder:t.getAttribute("placeholder")},r=/^(email|url)$/i,l=/^(input|keyup)$/i,s=r.test(n.type)?n.type:n.pattern?n.pattern:!1,o=p(t,s),u=m(t,"step"),v=m(t,"min"),b=m(t,"max"),g=!(""===t.validationMessage||void 0===t.validationMessage);t.checkValidity=function(){return d.call(this,t)},t.setCustomValidity=function(e){c.call(t,e)},t.validity={valueMissing:a,patternMismatch:o,rangeUnderflow:v,rangeOverflow:b,stepMismatch:u,customError:g,valid:!(a||o||u||v||b||g)},n.placeholder&&!l.test(i)&&f(t)},o=function(e){var t=C(e)||e,a=/^(input|keyup|focusin|focus|change)$/i,r=/^(submit|image|button|reset)$/i,l=/^(checkbox|radio)$/i,u=!0;!L.test(t.nodeName)||r.test(t.type)||r.test(t.nodeName)||(i=e.type,v()||s(t),t.validity.valid&&(""!==t.value||l.test(t.type))||t.value!==t.getAttribute("placeholder")&&t.validity.valid?(A(t,[n.invalidClass,n.requiredClass]),N(t,n.validClass)):a.test(i)?t.validity.valueMissing&&A(t,[n.requiredClass,n.invalidClass,n.validClass]):t.validity.valueMissing?(A(t,[n.invalidClass,n.validClass]),N(t,n.requiredClass)):t.validity.valid||(A(t,[n.validClass,n.requiredClass]),N(t,n.invalidClass)),"input"===i&&u&&(y(t.form,"keyup",o,!0),u=!1))},d=function(t){var a,i,r,l,s,u=!1;if("form"===t.nodeName.toLowerCase()){a=t.elements;for(var d=0,c=a.length;c>d;d++)i=a[d],r=!!i.attributes.disabled,l=!!i.attributes.required,s=!!i.attributes.pattern,"fieldset"!==i.nodeName.toLowerCase()&&!r&&(l||s&&l)&&(o(i),i.validity.valid||u||(e&&i.focus(),u=!0,n.onInvalid.call(t,i)));return!u}return o(t),t.validity.valid},c=function(e){var t=this;t.validationMessage=e},u=function(e){var a=C(e);a.attributes.formnovalidate&&"submit"===a.type&&(t=!0)},v=function(){return E(k,"validity")&&E(k,"checkValidity")},p=function(e,t){if("email"===t)return!q.test(e.value);if("url"===t)return!M.test(e.value);if(t){var i=e.getAttribute("placeholder"),n=e.value;return a=RegExp("^(?:"+t+")$"),n===i?!1:""===n?!1:!a.test(e.value)}return!1},f=function(e){var t={placeholder:e.getAttribute("placeholder")},a=/^(focus|focusin|submit)$/i,r=/^(input|textarea)$/i,l=/^password$/i,s=!!("placeholder"in k);s||!r.test(e.nodeName)||l.test(e.type)||(""!==e.value||a.test(i)?e.value===t.placeholder&&a.test(i)&&(e.value="",A(e,n.placeholderClass)):(e.value=t.placeholder,g(e.form,"submit",function(){i="submit",f(e)},!0),N(e,n.placeholderClass)))},m=function(e,t){var a=parseInt(e.getAttribute("min"),10)||0,i=parseInt(e.getAttribute("max"),10)||!1,n=parseInt(e.getAttribute("step"),10)||1,r=parseInt(e.value,10),l=(r-a)%n;return h(e)||isNaN(r)?"number"===e.getAttribute("type")?!0:!1:"step"===t?e.getAttribute("step")?0!==l:!1:"min"===t?e.getAttribute("min")?a>r:!1:"max"===t?e.getAttribute("max")?r>i:!1:void 0},b=function(e){var t=!!e.attributes.required;return t?h(e):!1},h=function(e){var t=e.getAttribute("placeholder"),a=/^(checkbox|radio)$/i,i=!!e.attributes.required;return!(!i||""!==e.value&&e.value!==t&&(!a.test(e.type)||$(e)))},g=function(e,t,a,i){E(window,"addEventListener")?e.addEventListener(t,a,i):E(window,"attachEvent")&&window.event!==void 0&&("blur"===t?t="focusout":"focus"===t&&(t="focusin"),e.attachEvent("on"+t,a))},y=function(e,t,a,i){E(window,"removeEventListener")?e.removeEventListener(t,a,i):E(window,"detachEvent")&&window.event!==void 0&&e.detachEvent("on"+t,a)},w=function(e){e=e||window.event,e.stopPropagation&&e.preventDefault?(e.stopPropagation(),e.preventDefault()):(e.cancelBubble=!0,e.returnValue=!1)},C=function(e){return e=e||window.event,e.target||e.srcElement},N=function(e,t){var a;e.className?(a=RegExp("(^|\\s)"+t+"(\\s|$)"),a.test(e.className)||(e.className+=" "+t)):e.className=t},A=function(e,t){var a,i,n="object"==typeof t?t.length:1,r=n;if(e.className)if(e.className===t)e.className="";else for(;n--;)a=RegExp("(^|\\s)"+(r>1?t[n]:t)+"(\\s|$)"),i=e.className.match(a),i&&3===i.length&&(e.className=e.className.replace(a,i[1]&&i[2]?" ":""))},E=function(e,t){var a=typeof e[t],i=RegExp("^function|object$","i");return!!(i.test(a)&&e[t]||"unknown"===a)},$=function(e){for(var t=document.getElementsByName(e.name),a=0;t.length>a;a++)if(t[a].checked)return!0;return!1},{setup:r}});
// postMessage is used to send and receive messages when using iframe
var XD=function(){var e,d,b=1,c,a=this;return{postMessage:function(f,h,g){if(!h){return}g=g||parent;if(a.postMessage){g.postMessage(f,h.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))}else{if(h){g.location=h.replace(/#.*$/,"")+"#"+(+new Date)+(b++)+"&"+f}}}}}();
function preloadImage(url){
var img=new Image();
img.src=url;
}
if(typeof preload_images != "undefined"){
for(var i in preload_images){
preloadImage(preload_images[i]);
}
}
function managePersonIdCodeInputFor(operator_id, containerId, inputId) {
var c = $(containerId);
var inp = $(inputId);
if (!c || !inp) { return; }
inp.val('');
if (typeof(operator_based_person_id_code_settings) != 'undefined') {
var opt = operator_based_person_id_code_settings[operator_id] || operator_based_person_id_code_settings['0'];
if (opt && opt['required']) {
inp.attr('required', 'required');
if (opt['pattern']) {
inp.attr('pattern', opt['pattern']);
} else {
inp.removeAttr('pattern');
inp.removeClass('pattern');
}
c.show();
} else {
c.hide();
inp.removeAttr('required');
inp.removeClass('required');
inp.removeAttr('pattern');
inp.removeClass('pattern');
}
} else {
c.hide();
inp.removeAttr('required');
inp.removeClass('required');
inp.removeAttr('pattern');
inp.removeClass('pattern');
}
}
function managePersonIdCodeInput(operator_id) {
if(typeof(operator_id) == 'undefined'){
operator_id = $('select#payment_operator_id').val();
}
managePersonIdCodeInputFor(operator_id, "#person-idcode-input", "#person-idcode-input-field");
}
function manageTocCheckboxInputFor(operator_id, containerId, inputId, labelId) {
var c = $(containerId);
var inp = $(inputId);
var lab = $(labelId);
if (!c || !inp) { return; }
if (typeof(toc_checkbox_settings) != 'undefined') {
var opt = toc_checkbox_settings[operator_id] || toc_checkbox_settings['0'];
if (opt && opt['required']) {
inp.attr('required', 'required');
lab.html(opt['label']);
c.show();
} else {
c.hide();
inp.removeAttr('required');
}
} else {
c.hide();
inp.removeAttr('required');
}
}
function manageTocCheckboxInput(operator_id) {
if(typeof(operator_id) == 'undefined'){
operator_id = $('select#payment_operator_id').val();
}
manageTocCheckboxInputFor(operator_id, '#toc-checkbox', '#toc-checkbox-field', '#toc-checkbox-label')
}
function manageMsisdnInputForOperator(operator_id){
if(typeof(operator_id) == 'undefined'){
operator_id = $('select#payment_operator_id').val();
}
if (typeof(operator_msisdn_input_settings) != 'undefined') {
var opt = operator_msisdn_input_settings[operator_id];
var inp = $('#payment_phone_number');
if(opt && opt['hide_msisdn_input'] == true && inp){
$('#nr').hide();
$('#nr-alt').hide();
$('#enter-phone-number').hide();
inp.hide();
inp.val('');
inp.removeAttr('required');
inp.removeClass('required');
inp.removeAttr('pattern');
inp.removeClass('pattern');
}else if(inp && operator_id){
$('#nr').show();
$('#nr-alt').show();
$('#enter-phone-number').show();
inp.show();
inp.attr('required', 'true');
if(opt && opt['pattern']){
inp.attr('pattern', opt['pattern']);
}
}
}
}
function updateCreditsAmount(operator_id){
if(typeof(operator_id) == 'undefined'){
operator_id = $('select#payment_operator_id').val();
}
if(typeof(operator_based_credits) != 'undefined'){
$(".credit_amount_holder").html(typeof operator_based_credits[operator_id] == 'undefined' ? operator_based_credits["0"] : operator_based_credits[operator_id]);
}
if(typeof(operator_based_prices) != 'undefined'){
$(".total_amount_holder").html(typeof operator_based_prices[operator_id] == 'undefined' ? operator_based_prices["0"] : operator_based_prices[operator_id]);
}
}
function updateCreditsAmountMultiple(){
var operator_el = $('select#payment_operator_id');
var operator_id;
if(operator_el.length == 0){
operator_id = 'avg';
} else {
operator_id = operator_el.val();
}
managePersonIdCodeInputFor(operator_id, "#person-idcode-input-change", "#person-idcode-input-field-change");
manageTocCheckboxInputFor(operator_id, "#toc-checkbox-change", "#toc-checkbox-field-change", "#toc-checkbox-label-change");
if(typeof operator_based_credits_multiple == 'undefined'){
return;
}
// if we have dropdown instead of a list
var is_select = $("select#payment_tariffclass_set_id").length > 0;
for(var tc_id in operator_based_credits_multiple){
if(operator_based_credits_multiple[tc_id] && operator_based_credits_multiple[tc_id][operator_id] || operator_based_credits_multiple[tc_id]["0"]){
if(is_select){
var new_option = price_template.replace("%price%",operator_based_prices_multiple[tc_id][operator_id] || operator_based_prices_multiple[tc_id]["0"])
new_option = new_option.replace("%credits%",operator_based_credits_multiple[tc_id][operator_id] || operator_based_credits_multiple[tc_id]["0"])
$("#select_tc_id_"+tc_id).attr("disabled", false);
$("#select_tc_id_"+tc_id).html(new_option);
}
else {
$('#tc_id_credits_'+tc_id).html(operator_based_credits_multiple[tc_id][operator_id] || operator_based_credits_multiple[tc_id]["0"]);
$('#tc_id_price_'+tc_id).html(operator_based_prices_multiple[tc_id][operator_id] || operator_based_prices_multiple[tc_id]["0"]);
var li_el = $("#option_tc_id_"+tc_id);
if(li_el.length != 0){
li_el.show();
}
}
}
else {
if(is_select){
// remove option
var select = $("#select_tc_id_"+tc_id);
var selected = select.attr("selected") || select.parent().val() == tc_id;
select.attr("disabled", true);
if(selected){
preselect_tariffclass();
$("#select_tc_id_"+tc_id).attr("selected", false);
}
}
else {
var li_el = $("#option_tc_id_"+tc_id);
if(li_el.length != 0){
var radio = $("#payment_tariffclass_set_id_"+tc_id);
var selected = radio.attr('checked') || $("input[name='payment[tariffclass_set_id]']").filter(":checked").val() == tc_id;
li_el.hide();
if(selected){
preselect_tariffclass();
radio.attr('checked', false);
}
}
}
}
}
if (is_select){ // Select highest pricepoint
$('.payment-select select option:enabled:last').attr('selected', 'selected');
} else { // update iframe size in case there were new pricepoints/ some were hid
setTimeout("resize(getHeight())",100);
}
}
function payment_complete(status) {
jQuery('#loader').hide();
jQuery('#pin').addClass('hidden');
jQuery('#payment_status').show();
statusMessage.unlock();
if(status == 'completed' || status == 'ok'){
jQuery("#dcb-operator").show();
}
if (typeof win8_in_app_enabled == 'undefined' || !win8_in_app_enabled) {
jQuery("#pb-back-to-merchant").show();
} else {
if(jQuery("#pb-price-fallback").length == 0 && !win8_in_app_enabled){
jQuery("#pb-back-to-merchant").show();
} else {
jQuery("#pb-back-to-merchant").hide();
jQuery("#pb-price-fallback").show();
}
}
jQuery("#purchase, .price-block").hide();
jQuery("#close").unbind("click", open_close_notification);
jQuery("#close").bind("click", close_widget);
// Bind redirect for close button if back to merchant button is visible
if (jQuery("#payment-complete").is(":visible")) {
jQuery("#close").bind("click", click_back_to_merchant_button);
}
jQuery('body').addClass('payment-complete');
payment_complete_action(status);
wa.trackSuccessfulPayment();
}
function payment_complete_action(status){
setHourlyCookie('last_completed_payemnt', payment_id, 1);
var el = document.getElementById('payment-complete');
status = ((status == 'completed' || status == 'ok') ? 'completed' : 'failed');
if(android_inapp){
if(status == 'failed') {
Android.onCancel();
}
else {
Android.onPayment(); // TODO requires payment object
}
}
if(typeof el == 'object' && el != null && el.rel){
if(typeof brand_name != 'undefined' && brand_name == 'PayPal'){
status = (status == 'completed' ? "0" : "1");
}
el.rel = el.rel.replace("STATUS", status);
}
if(typeof auto_redirect_time != 'undefined'){
setTimeout(function(){
document.getElementById('payment-complete').click();
},1000*auto_redirect_time);
}
}
var click_back_to_merchant_button = function() {
jQuery("#payment-complete").click();
};
jQuery('#payment-complete').on('click', function() {
var target = jQuery(this).attr('rel');
if (jQuery(this).attr('data-fcb') == '' && target.length == 1) {
goBack();
return false;
}
if (jQuery(this).attr('data-fcb') == '' && target.length > 11) {
window.location = target;
return false;
} else {
if(window.self === window.top){ // if we are not in an iframe
window.location = target || jQuery(this).attr('data-fcb');
} else {
send("fmpUrl:" + target || jQuery(this).attr('data-fcb'));
}
return false;
}
});
// FOLLOWING FUNCTIONS WERE TAKEN FROM PAYMENT.JS CURRENTLY ITS NOT KNOWN WHICH ONE OF THESE ARE STILL IN USE
// make sure these dont already exist somewhere? if they do then change function names
function setHourlyCookie(name,value,hours) {
if (hours) {
var date = new Date();
date.setTime(date.getTime()+(hours*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function getHourlyCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function goBack() { // call it only if widget was not started in an iframe
var l = getHourlyCookie('widget_history');
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ // Because IE is different
l = l+1;
}
if (l<=1) {
window.close();
}
else {
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
document.location = getHourlyCookie('widget_referrer');
}
else {
window.history.go("-"+(window.history.length-l+1));
}
}
}
/* end Widget back to merchant button ----------------------------------------------------
*/
// Enable or disable widget action buttons to prevent multiple requests
// resulting from users spamming the "OK" button
function disableWidgetActionButtons(){
$('#pb-check-pin, #buy .button, .msisdn-submit')
.prop('disabled', true)
.addClass('btn-disabled');
}
function enableWidgetActionButtons(){
$('#pb-check-pin, #buy .button, .msisdn-submit')
.prop('disabled', false)
.removeClass('btn-disabled');
}
// JQuery URL Parser
// Written by Mark Perkins, mark@allmarkedup.com
// License: http://unlicense.org/ (i.e. do what you want with it!)
jQuery.url = function()
{
var segments = {};
var parsed = {};
/**
* Options object. Only the URI and strictMode values can be changed via the setters below.
*/
var options = {
url : window.location, // default URI is the page in which the script is running
strictMode: false, // 'loose' parsing by default
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], // keys available to query
q: {
name: "queryKey",
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
},
parser: {
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs
}
};
/**
* Deals with the parsing of the URI according to the regex above.
* Written by Steven Levithan - see credits at top.
*/
var parseUri = function()
{
str = decodeURI( options.url );
var m = options.parser[ options.strictMode ? "strict" : "loose" ].exec( str );
var uri = {};
var i = 14;
while ( i-- ) {
uri[ options.key[i] ] = m[i] || "";
}
uri[ options.q.name ] = {};
uri[ options.key[12] ].replace( options.q.parser, function ( $0, $1, $2 ) {
if ($1) {
uri[options.q.name][$1] = $2;
}
});
return uri;
};
/**
* Returns the value of the passed in key from the parsed URI.
*
* @param string key The key whose value is required
*/
var key = function( key )
{
if ( jQuery.isEmptyObject(parsed) )
{
setUp(); // if the URI has not been parsed yet then do this first...
}
if ( key == "base" )
{
if ( parsed.port !== null && parsed.port !== "" )
{
return parsed.protocol+"://"+parsed.host+":"+parsed.port+"/";
}
else
{
return parsed.protocol+"://"+parsed.host+"/";
}
}
return ( parsed[key] === "" ) ? null : parsed[key];
};
/**
* Returns the value of the required query string parameter.
*
* @param string item The parameter whose value is required
*/
var param = function( item )
{
if ( jQuery.isEmptyObject(parsed) )
{
setUp(); // if the URI has not been parsed yet then do this first...
}
return ( parsed.queryKey[item] === null ) ? null : parsed.queryKey[item];
};
/**
* 'Constructor' (not really!) function.
* Called whenever the URI changes to kick off re-parsing of the URI and splitting it up into segments.
*/
var setUp = function()
{
parsed = parseUri();
getSegments();
};
/**
* Splits up the body of the URI into segments (i.e. sections delimited by '/')
*/
var getSegments = function()
{
var p = parsed.path;
segments = []; // clear out segments array
segments = parsed.path.length == 1 ? {} : ( p.charAt( p.length - 1 ) == "/" ? p.substring( 1, p.length - 1 ) : path = p.substring( 1 ) ).split("/");
};
return {
/**
* Sets the parsing mode - either strict or loose. Set to loose by default.
*
* @param string mode The mode to set the parser to. Anything apart from a value of 'strict' will set it to loose!
*/
setMode : function( mode )
{
options.strictMode = mode == "strict" ? true : false;
return this;
},
/**
* Sets URI to parse if you don't want to to parse the current page's URI.
* Calling the function with no value for newUri resets it to the current page's URI.
*
* @param string newUri The URI to parse.
*/
setUrl : function( newUri )
{
options.url = newUri === undefined ? window.location : newUri;
setUp();
return this;
},
/**
* Returns the value of the specified URI segment. Segments are numbered from 1 to the number of segments.
* For example the URI http://test.com/about/company/ segment(1) would return 'about'.
*
* If no integer is passed into the function it returns the number of segments in the URI.
*
* @param int pos The position of the segment to return. Can be empty.
*/
segment : function( pos )
{
if ( jQuery.isEmptyObject(parsed) )
{
setUp(); // if the URI has not been parsed yet then do this first...
}
if ( pos === undefined )
{
return segments.length;
}
return ( segments[pos] === "" || segments[pos] === undefined ) ? null : segments[pos];
},
attr : key, // provides public access to private 'key' function - see above
param : param // provides public access to private 'param' function - see above
};
}();
// Allows to edit the status message as well as lock it
// to prevent content updates from polls
var StatusMessageHandler = function() {
var statusMessageLocked = false;
var self = this;
// set the info message in widget
// type can be either nil or error
this.set = function(str, type) {
type = typeof type == 'undefined' ? null : type;
if(self.isLocked() === false){
var statusElement = jQuery('#payment_status');
jQuery('#payment_status').html(str);
if(type == 'error') {
statusElement.addClass('msg-error');
} else {
statusElement.removeClass('msg-error');
}
if(type == 'success') {
statusElement.addClass('msg-ok');
} else {
statusElement.removeClass('msg-ok');
}
}
if(in_iframe) {
hideSmsButton();
}
};
this.lock = function() {
statusMessageLocked = true;
};
this.unlock = function() {
statusMessageLocked = false;
};
this.show = function() {
jQuery("#payment_status").show();
};
this.isLocked = function() {
return statusMessageLocked;
};
function hideSmsButton() {
$('#send-sms-btn').hide();
}
};
var statusMessage = new StatusMessageHandler();
jQuery('#subscription-completed').show();
var MultipartUI = function () {
'use strict';
var _this = this;
/**
* Sets step in the multipart bar
*
* @param {Number} stepNumber Step number to set
*
* @return {Number} step number, if step was set
* @return {Boolean} false, if step was not set
*/
this.setStep = function (stepNumber) {
var bubbles = jQuery('.multipart-bubble'),
activeBubbleClass = 'multipart-bubble--active';
if (bubbles && bubbles[stepNumber]) {
bubbles.removeClass(activeBubbleClass);
jQuery(bubbles[stepNumber]).addClass(activeBubbleClass);
return true;
} else {
return false;
}
};
/**
* Hides the bells and whistles pertaining to the multipart flow
*/
this.hideMultipartUI = function () {
var multipartBar = jQuery('.multipart-progress-bar');
multipartBar.hide();
_this.hideStepName();
};
/**
* Updates the amount of purchased credits"
*/
this.setPurchasedCredits = function (amount) {
jQuery('.complete-msg .credit_amount_holder').text(amount);
jQuery('.credits-bought').text(amount);
};
/**
* Updates the currency paid for the credits
*/
this.setPaidAmount = function (amount) {
jQuery('.complete-msg .total_amount_holder').text(amount);
jQuery('.confirmed-amount').text(amount);
};
/**
* Updates the step name (grey text below multipart bar)
*/
this.setStepName = function (stepName) {
jQuery('.multipart-step-name').text(stepName);
};
/**
* Hides the step name
*/
this.hideStepName = function () {
jQuery('.multipart-step-name').hide();
};
};
var mpui = new MultipartUI();
$(document).ready(function () {
enableWidgetActionButtons();
jQuery = $;
jQuery('#send-sms-btn').on('click', function () {
jQuery("#payment-status").show();
jQuery(".payment-help").show();
});
var oneclick_iframe = $('#oneclick_iframe');
if (oneclick_iframe.length > 0 && oneclick_iframe.attr('data-aasm_status') === 'price_set') {
jQuery('#loader').show();
setTimeout(function() {
window.location.href = oneclick_iframe.attr('data-continue_url');
}, 10000);
oneclick_iframe.one('load', function() {
setTimeout(function() {
window.location.href = oneclick_iframe.attr('data-continue_url');
}, 4000);
});
oneclick_iframe.one('error', function() {
setTimeout(function() {
window.location.href = oneclick_iframe.attr('data-continue_url');
}, 4000);
});
}
// Hide browser chrome
window.scrollTo(0, 1);
});
jQuery('select#payment_operator_id').change(function () {
var operator_id = jQuery(this).val();
updateCreditsAmount(operator_id);
managePersonIdCodeInput(operator_id);
manageTocCheckboxInput(operator_id);
manageMsisdnInputForOperator(operator_id);
});
function checkPinToc () {
var pin_toc_checkbox_checked = true;
var pin_toc_checkbox_field = $("#pin-toc-checkbox-field");
var pin_toc_checkbox_field_play_pl = $('#pin-toc-checkbox-field-play-pl');
if (pin_toc_checkbox_field.length && !pin_toc_checkbox_field.prop("checked")) {
pin_toc_checkbox_checked = false;
var alert_text = pin_toc_checkbox_field.attr("data-validation_error");
alert(alert_text);
} else if (pin_toc_checkbox_field_play_pl.length) {
if (!pin_toc_checkbox_field_play_pl.prop("checked")) {
var play_alert = document.getElementById("pin-toc-checkbox-field-play-pl").getAttribute("data_validation_error_play");
document.getElementById("pin-toc-checkbox-field-play-pl").setCustomValidity(play_alert);
return false;
}
}
return pin_toc_checkbox_checked;
}
jQuery('#oneclick_confirm_button').on('click', function () {
checkPinToc();
});
$('#pb-pin-input').on('keypress',function(event) {
var pin = jQuery('#pin input').val();
if(event.which === 13) {
if (pin) {
validatePin(event);
}
}
});
jQuery('#pb-check-pin').on('click', function (event) {
validatePin(event);
});
function validatePin(event) {
event.preventDefault();
var pin = jQuery('#pin input').val();
var validation_error = $("#pin input").attr("data-validation_error");
var validation_error_permanent = $("#pin input").attr("data-validation_error_permanent");
var validation_error_incorrect = $("#pin input").attr("data-validation_error_incorrect");
var pattern = $("#pin input").attr("pattern");
var regexp = new RegExp(pattern);
var pin_toc_checkbox_checked = checkPinToc();
if (regexp.test(pin)) {
if (pin_toc_checkbox_checked) {
// Disable "OK" button on the PIN screen to avoid double requests
disableWidgetActionButtons();
jQuery.post('/mobile_payments/pin/'+ window.payment_id, { pin: pin }, function (data) {
if (data == 'ok' || data == 'failed') {
jQuery('#payment_status').removeClass('msg-error');
statusMessage.set(data.content);
jQuery('#pin').addClass('hidden');
jQuery('#country-terms').addClass('hidden');
startPaymentFlow();
} else if (data == 'pin-failed') {
statusMessage.set(validation_error_permanent, 'error');
jQuery('#pin').addClass('hidden');
jQuery('#country-terms').addClass('hidden');
startPaymentFlow();
} else if (data == 'pending') {
checkPinAsync(1);
} else if (data == 'duplicate-request') {
// no op
// callback will be handled by the original request
} else {
// Enable "OK" button on the PIN screen for retry
enableWidgetActionButtons();
jQuery('#payment_status').addClass('msg-error');
jQuery("#payment_status").html(validation_error);
}
})
.fail(function () {
enableWidgetActionButtons();
});
}
} else {
jQuery('#payment_status').addClass('msg-error');
jQuery("#payment_status").html(validation_error_incorrect);
}
}
function checkPinAsync(multiplier) {
var validation_error = $("#pin input").attr("data-validation_error");
disableWidgetActionButtons();
jQuery('#loader').show();
jQuery.get('/mobile_payments/pin_status/'+ window.payment_id, function (data) {
if (data == 'pending') {
setTimeout(function () {
checkPinAsync(multiplier + 1);
}, 1000 * multiplier);
} else if (data == 'ok' || data == 'failed' || data == 'pin-failed') {
startPaymentFlow();
} else {
jQuery('#payment_status').removeClass('hidden');
jQuery('#payment_status').addClass('msg-error');
jQuery("#payment_status").html(validation_error);
enableWidgetActionButtons();
jQuery('#loader').hide();
}
});
}
updateCreditsAmount();
managePersonIdCodeInput();
manageTocCheckboxInput();
function startPaymentFlow(public_id, multiplier) {
window.payment_id = window.payment_id || public_id;
multiplier = multiplier || 1;
jQuery.getJSON('/mobile_payments/status/' + window.payment_id, {}, function (data) {
if (data.status == "pending") {
multiplier++;
jQuery("#payment_status").show();
statusMessage.set(data.content);
}
if (data.next && data.next.action == 'redirect' && data.next.url) {
window.location = data.next.url;
}
// Handle multipart UI
if (data && data.multipart) {
mpui.setStep(data.multipart.succeeded_parts);
if (data.multipart.succeeded_credit_amount) {
mpui.setPurchasedCredits(data.multipart.succeeded_credit_amount);
}
if (data.multipart.succeeded_cost) {
mpui.setPaidAmount(data.multipart.succeeded_cost);
}
if (data.multipart.step_name) {
mpui.setStepName(data.multipart.step_name);
}
}
setPbStatus(data);
if (data.complete && data.status != 'waiting_for_pin'
&& (jQuery('#payment-complete').attr('data-fcb') != '' || jQuery('#payment-complete').length && jQuery('#payment-complete').attr('rel').length > 11)) {
//let the widget button host know of successful payment
send("fmpId:" + data.pid);
window.setTimeout(function () {
jQuery('#pb-back-to-merchant').show(0, function () {
setTimeout("resize(getHeight())", 100);
payment_complete(data.status);
});
}, 1000);
}
//make back to merchant btn appear for mobile devices refresh
if (data.status === 'completed' && data.complete === true) {
jQuery('#pin').addClass('hidden');
if (typeof rescueFlow !== 'undefined') rescueFlow.terminate();
jQuery('#country-terms').addClass('hidden');
jQuery('#loader').hide();
statusMessage.set(data.content);
jQuery('.complete-msg').show();
mpui.hideMultipartUI();
jQuery('.hide-on-complete').hide();
if (jQuery('.v-whitelabel').length === 0 && jQuery('.v-web').length > 0) {
jQuery('.sandbox').hide();
jQuery('#caption').hide();
}
jQuery("#payment_status").addClass('msg-ok');
if (data.data) {
window.callback_data = data.data;
}
payment_complete(data.status);
}
if (data.simplified_status == 'failed' || data.simplified_status == 'cancelled') {
jQuery("#payment_status").show();
statusMessage.set(data.content);
jQuery("#payment_status").addClass('msg-error');
if (jQuery("#pb-price-fallback").length == 0) {
jQuery("#pb-back-to-merchant").show();
} else {
jQuery("#pb-back-to-merchant").hide();
jQuery("#pb-price-fallback").show();
}
payment_complete(data.simplified_status);
}
if (typeof rescueFlow !== 'undefined') {
rescueFlow.update(data);
}
if (data.status != 'waiting_for_pin' && !data.complete) {
setTimeout(function () {
startPaymentFlow(public_id, multiplier);
}, data.timeout * multiplier);
}
});
}
function setPbStatus(data) {
if (data.content !== false) {
var content = data.content;
if (!data.complete) {
if (data.content.length > 0) {
statusMessage.set(content);
}
} else {
jQuery("#subscription-status").show();
var insert_pin = $("#insert-pin");
if (insert_pin.length) {
insert_pin.hide();
}
var pin_toc = $("#pin-toc");
if (pin_toc.length) {
pin_toc.hide();
}
if (data.status == 'completed') {
statusMessage.unlock();
jQuery('#payment-status-box').hide();
jQuery('#pb-multipart-progress').hide();
jQuery('#tiny-total').hide();
jQuery('#pb-completed').show();
jQuery('#subscription-completed').show();
jQuery('#ok-tick').show();
jQuery('#next-payment-date').show();
setTimeout("resize(getHeight())", 100);
} else if (data.status != 'waiting_for_pin') {
jQuery('#payment_status').hide();
jQuery('#payment-status-box').hide();
jQuery('#pb-error').show();
jQuery('#subscription-error').show();
if (jQuery("#pb-price-fallback").length == 0) {
jQuery("#pb-back-to-merchant").show();
} else {
jQuery("#pb-back-to-merchant").hide();
jQuery("#pb-price-fallback").show();
}
setTimeout("resize(getHeight())", 100);
}
}
}
if (data.status == 'do_sent')
setLoading('pb-init');
if (data.status == 'do_failed')
setFailed('pb-init');
if (data.status == 'waiting_for_pin') {
statusMessage.set(data.content);
if (statusMessage.isLocked() === false) {
jQuery('#payment_status').removeClass('msg-error');
jQuery('#payment_status').addClass('msg');
}
jQuery('#payment-flow').show();
jQuery('#pin').removeClass('hidden');
jQuery('#country-terms').removeClass('hidden');
setTimeout("resize(getHeight())", 100);
}
if (data.status == 'waiting_for_mo') {
jQuery('.return-tip').show();
setLoading('pb-reply');
}
if (data.status == 'mo_received') {
jQuery('.return-tip').hide();
setLoading('pb-confirmation');
}
if (data.status == 'mt_sent') {
setLoading('pb-result');
}
}
function setLoading(selector) {
jQuery('#payment-status-box').show();
jQuery('#payment-status').html(jQuery('span#' + selector + ' .' + 'loading').text());
setTimeout("resize(getHeight())", 100);
}
function setFailed(selector) {
jQuery('span#' + selector).addClass('failed').children('.loaded').hide();
jQuery('.supported-carriers').hide();
if (jQuery("#pb-price-fallback").length == 0) {
jQuery("#pb-back-to-merchant").show();
} else {
jQuery("#pb-back-to-merchant").hide();
jQuery("#pb-price-fallback").show();
}
setTimeout("resize(getHeight())", 100);
}
if (typeof win8_in_app_enabled == 'undefined') {
win8_in_app_enabled = false;
}
;
var RescueCodeFlow = function() {
this.update = function(data) {
if ((data.simplified_status === 'pending') && (data.show_rescue_code === true)) {
showInputs();
}
};
var showInputs = function() {
jQuery('.rescue-code-entry').show();
jQuery('.rescue-code-entry input').removeAttr('disabled');
};
var hideInputs = function() {
jQuery('.rescue-code-entry').hide();
jQuery('.rescue-code-entry input').attr('disabled', 'disabled');
};
this.terminate = function() {
hideInputs();
};
};
'use strict';
var LogoSwapper = function() {
var logoFrames = [];
var visibleFrame = 0;
var operatorLogos = document.getElementById('operators');
this.init = function() {
if (operatorLogos === null) {
// No logos to show
} else if (operatorLogos.querySelectorAll('img').length === 0) {
// text based operator logos
} else if (typeof(operatorLogos.querySelectorAll('li')) === 'undefined') {
justShowLogos();
} else {
var liItems = operatorLogos.querySelectorAll('li');
if (liItems.length > 0) {
if (typeof(window.getComputedStyle) !== 'undefined') {
splitLogosToFrames();
packageLogosToFrames();
fadeLogosIn();
/* starts the cycle of fadein/fadeout if more than 1 frame */
} else {
justShowLogos();
}
}
}
};
var justShowLogos = function() {
var images = operatorLogos.querySelectorAll('img');
for (var i = 0; i < images.length; i++) {
images[i].className = 'operator_logo';
}
};
// Private methods
var splitLogosToFrames = function() {
var ul = operatorLogos.querySelectorAll('ul');
var contentMaxWidth = ul[0].offsetWidth;
var domImages = document.querySelectorAll('.operator_logo');
var currentFrameWidth = 0;
var currentFrame = [];
for (var i = 0; i < domImages.length; i++) {
var img = domImages[i];
var logoWidth = img.width;
var logoMargins = parseInt(getComputedStyle(img, null).getPropertyValue('margin-right')) +
parseInt(getComputedStyle(img, null).getPropertyValue('margin-left'));
var logoBoxWidth = logoWidth + logoMargins;
if ((currentFrameWidth + logoBoxWidth) < contentMaxWidth) {
currentFrame.push(img);
currentFrameWidth += logoBoxWidth;
} else {
logoFrames.push(currentFrame);
currentFrameWidth = 0;
currentFrame = [];
currentFrame.push(img);
currentFrameWidth += logoBoxWidth;
}
}
if (currentFrame.length > 0) {
logoFrames.push(currentFrame);
}
};
var packageLogosToFrames = function() {
/* move all images to div containers (frames) */
for (var i in logoFrames) {
if (logoFrames.hasOwnProperty(i)) {
var div = document.createElement('div');
div.className = 'hidden';
for (var j in logoFrames[i]) {
if (logoFrames[i].hasOwnProperty(j)) {
div.appendChild(logoFrames[i][j]);
}
}
operatorLogos.appendChild(div);
}
}
/* remove unused nodes */
var ul = operatorLogos.querySelectorAll('ul');
while (ul[0].firstChild) {
ul[0].removeChild(ul[0].firstChild);
}
operatorLogos.removeChild(ul[0]);
/* show all images (parents are hidden) */
var images = operatorLogos.querySelectorAll('img');
for (var img = 0; img < images.length; img++) {
images[img].className = 'operator_logo';
}
};
var fadeOutOperatorLogos = function() {
var operators = document.getElementById('operators');
var frames = operators.querySelectorAll('div');
var frame = frames[visibleFrame];
var opacity = 1;
frame.style.opacity = opacity;
var fadeOutTimer = setInterval(function() {
if (frame.style.opacity <= 0.1) {
clearInterval(fadeOutTimer);
frame.style.display = 'none';
setTimeout(function() {
fadeLogosIn();
}, 500);
if ((visibleFrame + 1) >= logoFrames.length) {
visibleFrame = 0;
} else {
visibleFrame++;
}
}
frame.style.opacity = opacity;
opacity -= frame.style.opacity * 0.1;
}, 10);
};
var fadeLogosIn = function() {
var operators = document.getElementById('operators');
var frames = operators.querySelectorAll('div');
var frame = frames[visibleFrame];
if (typeof(frame) !== 'undefined') {
var opacity = 0.1;
frame.style.opacity = opacity;
frame.style.display = 'block';
var fadeInTimer = setInterval(function() {
if (frame.style.opacity >= 1) {
clearInterval(fadeInTimer);
if (logoFrames.length > 1) {
setTimeout(function() {
fadeOutOperatorLogos();
}, 3000);
}
}
frame.style.opacity = opacity;
opacity += frame.style.opacity * 0.1;
}, 10);
}
};
};
var ls = new LogoSwapper();
ls.init();
var WidgetUI = function() {
'use strict';
var _this = this;
H5F.setup(document.getElementsByTagName('form'), {
validClass: 'valid',
invalidClass: 'invalid'
});
this.showLoader = function() {
$('#loader').show();
};
this.hideLoader = function() {
$('#loader').hide();
};
/**
* Adds legal-text-expanded class to the legal texts
*/
this.showLegalTexts = function() {
var e = document.getElementById('legal-text');
var classNameToAdd = ' legal-text-expanded';
if (e.className.indexOf(classNameToAdd.trim()) === -1) {
e.className += classNameToAdd;
}
};
/**
* Animate scrolling to the bottom of the page
*/
this.scrollToBottom = function() {
window.scrollBy(0, 5);
if (notBottomYet()) {
setTimeout(_this.scrollToBottom, 10);
}
};
/**
* Returns ture if the scroll is not at its maximum
*
* @returns {boolean} true if page is not at the bottom
*/
var notBottomYet = function() {
return getDocHeight() !== getScrollY() + window.innerHeight;
};
/**
* Inspired by
* http://jsfiddle.net/W75mP/
*
* @returns {Number} Value of vertical scroll on page in pixels
*
*/
var getScrollY = function() {
var yScroll = 0;
if (typeof(window.pageYOffset) === 'number') {
//Netscape compliant
yScroll = window.pageYOffset;
} else if (document.body && document.body.scrollTop) {
//DOM compliant
yScroll = document.body.scrollTop;
} else if (document.documentElement && document.documentElement.scrollTop) {
//IE6 standards compliant mode
yScroll = document.documentElement.scrollTop;
}
return yScroll;
};
/**
* Inspired by
* http://james.padolsey.com/javascript/get-document-height-cross-browser/
*
* @returns {number} Document height in pixels
*/
var getDocHeight = function() {
var D = document;
return Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
};
/**
* Opens rescue code form and places the cursor on the rescue code entry input
*/
var openRescueForm = function() {
toggleHelp();
var rescueInput = document.querySelector('#rescue-form input');
rescueInput.focus();
};
/**
* Binds the rescue form opening to .js-open-rescue-entry elements
*/
var bindRescueFormLinks = function() {
var links = document.querySelectorAll('.js-open-rescue-entry');
for(var i=0; i < links.length; i ++) {
links[i].addEventListener('click', openRescueForm);
}
};
/**
* Constructor method
*/
var init = function() {
bindRescueFormLinks();
};
init();
};
var widgetUI = new WidgetUI();
var $phoneInputField = $('#payment_phone_number'),
$phoneInputRepeat = $("#nr-alt"),
$form = $('form');
/**
* Force reload of the page when iOS back button is pressed
*/
$(window).bind("pageshow", function(event) {
if (event.originalEvent.persisted) {
enableWidgetActionButtons();
window.location.reload();
}
});
// Fix submit button for Safari
$('#payment_operator_id, #payment_phone_number').change(function() {
enableWidgetActionButtons();
});
$phoneInputField.on('keydown', function() {
enableWidgetActionButtons();
});
$form.on('submit', function(e) {
// For fixing the bug where Safari doesn't allow DOM modifications it's
// necessary to submit form with a delay after showing the loader animation
e.preventDefault();
applyLoadingVisuals();
$form.off('submit');
var thisForm = $(this);
setTimeout(function() {
$(thisForm).submit();
}, 10);
});
function applyLoadingVisuals() {
if ($(".field").is(":visible")) {
if ($(".field:visible.valid").length > 0 && $("#payment_operator_id").val() !== "") {
widgetUI.showLoader();
}
} else {
widgetUI.showLoader();
}
// Disable "OK" button to avoid double requests
disableWidgetActionButtons();
}
resize(getHeight());
var in_iframe = true;
if (top === self) { // not in iframe
in_iframe = false;
}
$(document).ready(function() {
var legalTexts = document.getElementById('legal-text');
if (legalTexts !== null) {
legalTexts.onclick = function() {
widgetUI.showLegalTexts();
setTimeout(widgetUI.scrollToBottom, 100);
};
}
if (!in_iframe && !win8_inapp && !android_inapp) {
$("#close").hide();
}
});
// custom validation for inputs
$('#payment_operator_id').bind('invalid', function(e) {
var error = $(this).attr("data-validation")
e.target.setCustomValidity("");
if (!e.target.validity.valid) {
e.target.setCustomValidity(error);
}
}).bind('blur', function(e) {
var target = e.target || e.srcElement;
try {
target.checkValidity();
} catch (e) {
// check validity failed
}
;
});
// prevent iframe jump
$('a[href="#"]').bind('click', function(e) {
e.preventDefault();
});
/*------------------------------------------
=resize font for country calling code
-------------------------------------------*/
//repeat purchase view
$(function() {
var nralt = $phoneInputRepeat.length
if (nralt == 1) {
var length = $phoneInputRepeat.text().length
if (length >= 4) {
$phoneInputRepeat.addClass('resize-font');
}
}
});
//phone number view
$(function() {
var nr = $("#nr").length
if (nr == 1) {
var length = $("#nr").text().length
if (length == 3) {
$("#nr").addClass('resize-font01');
} else if (length == 4) {
$("#nr").addClass('resize-font02');
}
}
});
/*------------------------------------------
=tcs
-------------------------------------------*/
//preselect tariffclass
function preselect_tariffclass() {
var tcs, assign;
var payment_options = $('.payment-option:visible');
if (payment_options.length > 0) {
tcs = payment_options.children().filter(":input");
assign = function(value) {
tcs.val([value]);
};
}
else {
// assume its dropdown
tcs = $("#payment_tariffclass_set_id").children().filter(":enabled");
assign = function(value) {
tcs.parent().val(value);
setTimeout(function() {
$('.payment-select select, .operator-select select').trigger('update');
}, 10);
};
}
var count = tcs.length;
if (count == 1) {
var value = tcs[0].value;
}
else if (count > 1) {
var value = tcs[count - 2].value;
}
else {
// no tariffclasses found
return;
}
assign(value);
}
$(function() {
preselect_tariffclass();
});
/*------------------------------------------
=amount select
-------------------------------------------*/
$(".payment-option").click(function() {
$(".payment-option").removeClass("selected");
$(this).addClass("selected");
});
$form.on("submit", function() {
var errors = $(this).data("errors") || [],
self = this;
$.each(errors, function(k, v) {
$.each(v, function() {
$(self).append($('
').val(this))
});
});
$(".loader").fadeIn(200);
});
/*------------------------------------------
=language/country change
-------------------------------------------*/
$(document).ready(function() {
$('#payment_country_code, #payment_set_locale').on('change', function() {
widgetUI.showLoader();
$(this).parents('form').submit();
});
$('#lang .change-language').on('click', function() {
widgetUI.showLoader();
$(this).parents('form').submit();
});
});
/*------------------------------------------
=operator select
-------------------------------------------*/
$("#payment_operator_id").on("change", function() {
$(this).closest(".row").nextAll(".row.hidden").fadeIn(600);
$("#payment-phone-number").focus();
updateCreditsAmount();
managePersonIdCodeInput();
manageTocCheckboxInput();
manageMsisdnInputForOperator();
// GA operator selection event
wa.sendEvent({
action: 'click',
label: 'Network selected'
})});
/*------------------------------------------
=help toggle
-------------------------------------------*/
var toggleHelp = function() {
// hide help button
var help_button = $("#help, .help-link");
help_button.addClass('hidden');
// show close help
var close_help_button = $("#help-close, .close-help-link");
close_help_button.removeClass('hidden');
// show help content
var content = $("#help-content");
var toggleContent = $("#main, .toggle-with-help");
var link = $("#help");
var hiding_buttons = $("#country, #close");
if (content.hasClass('hidden')) {
// Show help section, hide everything else
if (android_inapp) {
hiding_buttons.addClass('hidden');
}
toggleContent.hide();
toggleContent.addClass('hidden');
content.fadeIn().removeClass('hidden');
close_help_button.removeClass('hidden');
help_button.addClass('hidden');
$('.dockbar-hidden').removeClass('hidden'); // Dockbar has only to be shown on help page
setTimeout(function() {
resize(getHeight() + 10);
}, 100);
} else {
// Hide help section, show everything else
content.hide();
if (android_inapp) {
hiding_buttons.removeClass('hidden');
}
content.addClass('hidden');
toggleContent.fadeIn().removeClass('hidden');
close_help_button.addClass('hidden');
help_button.removeClass('hidden');
$('.dockbar-hidden').addClass('hidden');
setTimeout(function() {
resize(getHeight());
}, 100);
}
return false;
};
$("#help, #help-close, .help-link, .close-help-link").on("click", toggleHelp);
/*------------------------------------------
=payment messages
-------------------------------------------*/
$("#payment-complete").on("submit", function() {
if (win8_in_app_enabled) {
window.external.notify(JSON.stringify({
method: "close",
data: [
{key: "btm_url", value: this.action},
{key: "status", value: window.payment.status()}
]
}));
return false;
}
})
$(".errors").on("payment-error", function(e, message) {
if (!$(".error:contains(" + message + ")").length) {
$('
�"+message+"
').appendTo(this);
}
}).on("click", ".error .close", function() {
$(this).closest(".error").fadeOut(function() {
$(this).remove();
return false;
});
});
$("[required][data-validation-error]").on("invalid", function() {
var errors = $(this).closest("form").data("errors") || {};
errors[this.name] = errors[this.name] || [];
errors[this.name].push(this.value);
$(this).closest("form").data("errors", errors);
$.event.trigger("payment-error", $(this).data("validation_error"));
return false;
});
$("#payment-phone-number").on("payment-error", function() {
$(this).val("");
});
/*------------------------------------------
=navigation
-------------------------------------------*/
var close_widget = function() {
if (win8_in_app_enabled) {
window.external.notify(JSON.stringify({
method: "close",
data: [
{key: "btm_url", value: this.action},
{key: "status", value: (window.payment && window.payment.status() || "cancelled")}
]
}));
} else if (android_inapp) {
Android.onCancel();
}
wa.sendEvent({
action: 'click',
label: 'Close confirmation clicked'
});
send("close");
return false;
};
var open_close_notification = function() {
$("#close-notification").show();
$("#close-notification-overlay").show();
wa.sendEvent({
action: 'click',
label: 'Close button clicked'
});
};
$("#close-widget").bind("click", close_widget);
$("#close, .cancel-payment-button").bind("click", open_close_notification);
// Send GA event when user decided not to close the widget
$("#close-notification-hide, #close-notification-overlay").on("click", function() {
$("#close-notification").fadeOut("fast");
$("#close-notification-overlay").hide();
wa.sendEvent({
action: 'click',
label: 'Decided not to close'
});
});
$(".prev a").on("click", function() {
widgetUI.showLoader();
$("#goback").submit();
});
$("#change-nr").on("click", function() {
$("#phone-nr").addClass('hidden');
$("#phone-nr-change").removeClass('hidden');
resize(getHeight());
wa.sendEvent({
action: 'click',
label: 'Change number'
})
});
/*------------------------------------------
=resize colorbox
-------------------------------------------*/
function getHeight() {
var height = $("body").height();
height = height + 75; // extra padding
height = Math.max(height, 380); // min-height
height = Math.min(height, 700); // max-height
return height;
}
function resize(height) {
send("resize:" + height);
}
function resizewidget(size) {
send("resizewidget:" + size);
}
function showAllLogos() {
jQuery("ul", "#operators").find("img").each(function() {
jQuery(this).show();
});
}
/*------------------------------------------
=force reload, related to -> @page.has_to_force_reload_on_history_back?
-------------------------------------------*/
if ($("#refresh-on-render").val() == "1") {
force_refresh();
}
// user comes back with browser "Back"
if ($("#buy_button").length > 0 && payment_id == getHourlyCookie('last_completed_payemnt')) {
force_refresh();
}
function force_refresh() {
window.location.reload();
var init_text = $("#init_text").html();
$("body").html(init_text);
}
$('#buy_button').bind('click', function(e) {
$("#refresh-on-render").val("1");
});
/*------------------------------------------
=resize widget if service type payment profile has resize parameter
-------------------------------------------*/
$(function() {
$("#buy_button, .msisdn-submit").on('click', function() {
if (typeof(widget_resize) != 'undefined') {
var operator_selected = $("#payment_operator_id").find("option:selected").val() || "0";
if (operator_selected in widget_resize) {
if (widget_resize[operator_selected]["affects_width"]) {
resizewidget(widget_resize[operator_selected]["resize"]);
} else {
resize(widget_resize[operator_selected]["resize"]);
}
}
}
});
//resize back to normal
if (typeof(widget_resize) != 'undefined' && $("#payment_status").is(":visible")) {
resizewidget('595');
resize(getHeight());
}
});
// Brazil area code correction
if (typeof(correctBrazilAreaCode) != 'undefined' && correctBrazilAreaCode) {
$phoneInputField.blur(function() {
var no = $(this).val();
var extraDigit = 9; //mobile phone numbers in the certain cities/states have an extra digit (9) after the area code
var extraDigitPosition = 2;
if (!no.match(/\d{2}9\d{8}/) && no.length == 10) {
var correctedNumber = no.substr(0, extraDigitPosition) + extraDigit + no.substr(extraDigitPosition);
$(this).val(correctedNumber);
}
});
}
manageMsisdnInputForOperator();
/**
* Here we deal with older browsers that don't support certain features by adding no-XXX classes to body tag.
* A bit like modernizr, but only with the stuff we need
*/
'use strict';
(function() {
/**
* Checks whether element has a class applied
*
* @param {object} el element to perform the check on
* @param {string} className class name to check
* @returns {boolean} true/false
*/
var hasClass = function(el, className) {
return el.className.indexOf(className) > -1;
};
/**
* Adds a class to the body
*
* @param {string} className class name to add
*/
var addBodyClass = function(className) {
var body = document.body;
if (!hasClass(body, className)) {
body.className = body.className + ' ' + className;
}
};
/**
* Adds a no-{feature} class to body
*
* @param {string} feature name to be added to body tag
*/
var setUnSupported = function(feature) {
addBodyClass('no-' + feature);
};
/**
* Checks whether gradients are supported
*
* @returns {boolean}
*/
var isGradientSupported = function() {
var mElem = document.createElement('modern'),
mStyle = mElem.style;
mStyle.backgroundImage = 'linear-gradient(left top, #9f9, white)';
mStyle.backgroundImage = '-webkit-linear-gradient(left top, #9f9, white)';
return (mStyle.backgroundImage.indexOf('gradient') > -1);
};
if (!isGradientSupported()) {
setUnSupported('gradient');
}
}());
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-2408470-16', 'auto');
ga('require', 'ecommerce');
ga('send', 'pageview');
var WidgetAnalytics = function() {
'use strict';
if (typeof ga === 'undefined') {
throw 'Google Analytics is not initialized';
}
var _this = this;
/**
* Sends an event to Google Analytics
*
* @param {Object} opts Options for the event
*
* @example
*
* _this.sendEvent({
* category: 'outbound',
* action: 'click',
* label: 'https://example.com',
* nonInteraction: false
* });
*
*/
this.sendEvent = function(opts) {
var flow_type = typeof opts.category === 'undefined' ? payment_flow_type : opts.category,
action = typeof opts.action === 'undefined' ? null : opts.action,
label = typeof opts.label === 'undefined' ? null : opts.label,
nonInteraction = typeof opts.nonInteraction === 'undefined' ? false : opts.nonInteraction;
var trackingParams = {
hitType: 'event',
eventCategory: payment_type,
eventAction: action,
eventLabel: label,
nonInteraction: nonInteraction,
dimension1: isInIframe,
dimension2: purchase_type,
dimension3: flow_type
};
ga('send', trackingParams);
};
/**
* Determines whether the page is in an iframe
*
* @returns {boolean}
*/
this.isInIframe = function() {
return window !== window.top;
};
const isInIframe = _this.isInIframe() ? 'in_iframe' : 'not_in_iframe';
/**
* Sends an event to Google Analytics about the fact whether widget was
* loaded inside an iframe or not
*/
this.trackIsInIframe = function() {
_this.sendEvent({
action: 'load',
label: 'widget opened'
});
};
/**
* Returns a formatted error message to log to analytics from a given exception object
*
* @param {object} err Exception object to generate the message from
* @returns {string} A formatted string for the log
*/
this.formatError = function(err) {
return err.message + ' (' + err.filename + ':' + err.lineno + ')';
};
/**
* Given an exception object tracks JS errors to Google Analytics
*
* @param {object} err Exception object to generate the message from
*/
this.trackError = function(err) {
_this.sendEvent({
category: 'Errors',
action: 'WebWidget',
label: _this.formatError(err),
nonInteraction: true
});
};
/**
* Tracks successful payment to Google Analytics. Called on completed payment screen.
*/
this.trackPayment = function() {
if(fortumoWidget) {
ga('ecommerce:addTransaction', {
'id': fortumoWidget.transaction.id,
'affiliation': fortumoWidget.transaction.provider,
'revenue': fortumoWidget.transaction.enduser_cost,
'tax': fortumoWidget.transaction.vat,
'country': fortumoWidget.transaction.country
});
ga('ecommerce:addItem', {
'id': fortumoWidget.transaction.id,
'sku': fortumoWidget.transaction.sku_code,
'category': fortumoWidget.transaction.provider,
'name': fortumoWidget.transaction.credit_name,
'price': fortumoWidget.transaction.unit_price,
'quantity': fortumoWidget.transaction.amount
});
ga('ecommerce:send');
}
};
/**
* Tracks the conversion for iFrame integrations
*/
this.trackIframeConversion = function() {
_this.sendEvent({
action: 'load',
label: 'Payment completed',
});
};
/**
* This function is triggered upon a successful payments.
* It calls all actions that should be performed at that point
*/
this.trackSuccessfulPayment = function() {
_this.trackPayment();
_this.trackIframeConversion();
};
};
var wa = new WidgetAnalytics();
window.addEventListener('load', function() {
if (fortumoWidget && fortumoWidget.step === 'new') {
wa.trackIsInIframe();
}
});
window.addEventListener('error', function(err) {
wa.trackError(err);
})
// Send GA event when buy button is clicked
$("#buy_button").bind("click", function() {
wa.sendEvent({
action: 'click',
label: 'Buy button clicked'
})
})
// Send GA event when msisdn input field loses focus (msisdn entered)
$phoneInputField.focusout(function() {
wa.sendEvent({
action: 'enter',
label: 'MSISDN entered'
})
})
// send GA event when msisdn enter button is clicked
$(".msisdn-submit").bind("click", function() {
wa.sendEvent({
action: 'click',
label: 'Pay'
})
})
// Send GA event when PIN is entered
$("#pin").focusout(function() {
wa.sendEvent({
action: 'enter',
label: 'PIN entered'
})
})
// Send GA event when pin button is clicked
$("#pb-check-pin").bind("click", function() {
wa.sendEvent({
action: 'click',
label: 'PIN submit'
})
})
// Send GA event when 'help & support' is clicked
$(".help-link").bind("click", function() {
wa.sendEvent({
action: 'click',
label: 'Help opened'
})
})
;