vgquotes/Src/VideoGameQuotes.Web/media/js/vgquotes.compressed.js

1 line
7.3 KiB
JavaScript
Raw Normal View History

2011-03-04 08:20:37 +00:00
(function(b,a){b.cookie=function(m,c,e){if(typeof c!="undefined"){e=e||{};if(c===null){c="";e.expires=-1}var d="";if(e.expires&&(typeof e.expires=="number"||e.expires.toUTCString)){var h;if(typeof e.expires=="number"){h=new Date();h.setTime(h.getTime()+(e.expires*24*60*60*1000))}else{h=e.expires}d="; expires="+h.toUTCString()}var j=e.path?"; path="+(e.path):"";var l=e.domain?"; domain="+(e.domain):"";var o=e.secure?"; secure":"";document.cookie=[m,"=",encodeURIComponent(c),d,j,l,o].join("")}else{var n=null;if(document.cookie&&document.cookie!=""){var k=document.cookie.split(";");for(var f=0;f<k.length;f++){var g=b.trim(k[f]);if(g.substring(0,m.length+1)==(m+"=")){n=decodeURIComponent(g.substring(m.length+1));break}}}return n}}}(jQuery,window));(function(a){a.fn.center=function(){var b=this.css("position")==="fixed";this.css("top",(a(window).height()-this.height())/2+(b?0:a(window).scrollTop())+"px");this.css("left",(a(window).width()-this.width())/2+(b?0:a(window).scrollLeft())+"px");return this}}(jQuery));(function(a){a.fn.applyModelErrors=function(b,c){var d=this;if(b!==null){d.find(".error-summary").first().text(b).show()}a.each(c,function(f,e){var g=d.find("input[name='"+f+"']");if(g.length>1){g=a("#"+f)}if(g.length===1){if(g[0].localName==="INPUT"){g.addClass("input-validation-error")}a("<span/>").addClass("field-validation-error").append(a("<span/>").addClass("error-icon")).append(a("<span/>").text(e)).insertAfter(g)}});return this};a.fn.clearModelErrors=function(){this.find(".field-validation-error").remove().end().find(".input-validation-error").removeClass("input-validation-error").end().find(".error-summary").empty().hide();return this}}(jQuery));(function(e,c){var a="jquery.refresh.fragment";var d=function(){var g=c.location.href;var f=g.lastIndexOf("#");if(f>=0){if(f!==g.length-1){e.cookie(a,g.substring(f+1))}g=g.substring(0,f)}c.location.href=g};var b=function(){var f=e.cookie(a);if(f!==null){c.location.href+="#"+f;e.cookie(a,null)}};e(document).ready(b);e.refresh=d}(jQuery,window));(function(f,d,a){f.vgquotes=function(){var i=function(k,j){return function(l){if(typeof(l)==="undefined"||typeof(l.Error)==="undefined"||l.Error!==null){j.call(null,null);return}j.call(null,l.Data.records[0])}};return{parseDate:function(j){return new Date(parseInt(j.substr(6)))},formatDate:function(j){return j.getFullYear()+"-"+(j.getMonth()+1)+"-"+j.getDate()},parseAndFormatDate:function(j){return f.vgquotes.formatDate(f.vgquotes.parseDate(j))},ajaxErrorHandler:function(j){alert("An error occurred ("+j.status+")")},preload:function(j){f.each(j,function(){f("<img/>")[0].src=this})},loadingGif:"/media/images/loading.gif",getResourceById:function(k,j,l){j=j.toString();f.ajax("/api/"+k+"/"+j,{type:"GET",success:i(k,l),error:i(k,l)})},createDialog:function(j){f("body").append(f("<div/>").attr("id","modal-background")).append(j);j.center()},closeDialog:function(j){f("#modal-background").remove();j.remove()}}}();var b=function(){var i=function(){var j=f.trim(f("#search-query").val());if(j.length>0){d.location="/search/"+j}return false};f(document).ready(function(){f("#search-query").keypress(function(j){if(j.which===13){i()}});f("#search-submit").click(i)})};var h=function(){var i=false;f(".vote-for, .vote-against").live("click",function(){if(i){alert("Please wait for the current vote to process before voting again");return false}i=true;var m=f(this);var o=m.parents(".quote-container");var l=m.hasClass("vote-for")?1:0;var j=o.find("input.quote-id").val();var n=o.find(".quote-score");var k=n.text();f.ajax("/vote",{type:"POST",data:{QuoteId:j,Direction:l},beforeSend:function(){n.empty().append(f("<img/>").attr({src:f.vgquotes.loadingGif,title:"submitting your vote"+String.fromCharCode(8230)}))},success:function(p,q,r){if(p.Error!==null){d.alert(p.Error);return}k=p.Data.score;n.attr("title","+"+p.Data.upVotes+", -"+p.Data.downVotes);m.remove();if(l===1){if(o.find(".vote-against").length===0){f("<span/>").addClass("vote-against").attr("title","I hate this quote").text(String.fromCharCode(9660)).appendTo(o.find(".vote-container:last"))}}el