tmont
25172d14a3
* renamed css file * removed copypaste code for js includes * added pdn files * changed unused images/javascript build type from Content to None
1 line
6.9 KiB
JavaScript
1 line
6.9 KiB
JavaScript
(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(e,c,a){e.vgquotes=function(){var h=function(j,i){return function(k){if(typeof(k)==="undefined"||typeof(k.Error)==="undefined"||k.Error!==null){i.call(null,null);return}i.call(null,k.Data.records[0])}};return{parseDate:function(i){return new Date(parseInt(i.substr(6)))},formatDate:function(i){return i.getFullYear()+"-"+(i.getMonth()+1)+"-"+i.getDate()},parseAndFormatDate:function(i){return e.vgquotes.formatDate(e.vgquotes.parseDate(i))},ajaxErrorHandler:function(i){alert("An error occurred ("+i.status+")")},preload:function(i){e.each(i,function(){e("<img/>")[0].src=this})},loadingGif:"/media/images/loading.gif",getResourceById:function(j,i,k){i=i.toString();e.ajax("/api/"+j+"/"+i,{type:"GET",success:h(j,k),error:h(j,k)})},createDialog:function(i){e("body").append(e("<div/>").attr("id","modal-background")).append(i);i.center()},closeDialog:function(i){e("#modal-background").remove();i.remove()}}}();var b=function(){var h=function(){var i=e.trim(e("#search-query").val());if(i.length>0){c.location="/search/"+i}return false};e(document).ready(function(){e("#search-query").keypress(function(i){if(i.which===13){h()}});e("#search-submit").click(h)})};var g=function(){var h=false;e(".vote-for, .vote-against").live("click",function(){if(h){alert("Please wait for the current vote to process before voting again");return false}h=true;var l=e(this);var n=l.parents(".quote-container");var k=l.hasClass("vote-for")?1:0;var i=n.find("input.quote-id").val();var m=n.find(".quote-score");var j=m.text();e.ajax("/vote",{type:"POST",data:{QuoteId:i,Direction:k},beforeSend:function(){m.empty().append(e("<img/>").attr({src:e.vgquotes.loadingGif,title:"submitting your vote"+String.fromCharCode(8230)}))},success:function(o,p,q){if(o.Error!==null){c.alert(o.Error);return}j=o.Data.score;m.attr("title","+"+o.Data.upVotes+", -"+o.Data.downVotes);l.remove();if(k===1){if(n.find(".vote-against").length===0){e("<span/>").addClass("vote-against").attr("title","I hate this quote").text(String.fromCharCode(9660)).appendTo(n.find(".vote-container:last"))}}else{if(n.find(".vote-for").length===0){e("<span/>").addClass("vote-for").attr("title","I like this quote").text(String.fromCharCode(9650)).appendTo(n.find(".vote-container:first"))}}},complete:function(){h=false;var o=m.find("img");if(o.length){o.remove()}m.text(j)}});return false})};var f=function(){e("a.quote-flag-icon").click(function(){if(e(".flag-dialog").length>0){return false}var p=e(this).parents(".quote-container");var j=p.find("input.quote-id").val();var o=e("<tr/>");var n=[[1,"Inaccurate"],[2,"Duplicate"],[3,"Spam"],[4,"Fake"],[0,"Other"]];for(var h=0;h<n.length;h++){var l='<td><input type="radio" name="flagType" value="'+n[h][0]+'" id="flag-type-'+n[h][0]+'"/><label for="flag-type-'+n[h][0]+'">'+n[h][1]+"</label></td>";o.append(e(l))}var m=e("<div/>").addClass("dialog flag-dialog");var k=e("<a/>").attr({href:"#",title:"submit"}).addClass("button-link").append(e("<span/>").addClass("submit-icon")).append(e("<span/>").text("Submit")).click(function(){var i=e(this).find(".submit-icon");i.toggleClass("submit-icon loading-icon");e.ajax("/flag",{type:"POST",data:{QuoteId:j,Comment:m.find("textarea").val(),FlagType:m.find("input[name='flagType']:checked").val()},success:function(r,s,t){if(r.Error!==null){alert(r.Error);return}e.vgquotes.closeDialog(m)},complete:function(){i.toggleClass("submit-icon loading-icon")}});return false});var q=e("<a/>").attr({href:"#",title:"cancel"}).addClass("button-link").append(e("<span/>").addClass("cancel-icon")).append(e("<span/>").text("Cancel")).click(function(){e.vgquotes.closeDialog(m);return false});m.append(e("<p/>").addClass("label").text("Flag as:")).append(e("<table/>").append(o)).append(e("<p/>").addClass("label").text("Comment")).append(e("<textarea/>")).append(e("<div/>").addClass("submit-container").append(k).append(q));m.find("#flag-type-0").attr("checked","checked");e.vgquotes.createDialog(m);return false})};var d=function(){var h=function(){var i=e("#login-dialog");if(i.length>0){e.vgquotes.closeDialog(i);return false}var j=e("<input/>").attr({type:"text",id:"login-username"});var m=e("<input/>").attr({type:"password",id:"login-password"});var l=e("<input/>").attr("type","submit").css("display","none");var k=e("<form/>").attr({method:"post",action:"/login"}).submit(function(){e.ajax("/login",{type:"POST",data:{username:j.val(),password:m.val()},success:function(n,o,p){if(n.Error!==null){alert(n.Error);return}e.refresh()}});return false});i=e("<div/>").addClass("dialog").attr("id","login-dialog");k.append(j).append(m).append(l);i.append(k);e.vgquotes.createDialog(i);j.focus();return false};e(document).ready(function(){e("#login-link").click(h)})};(function(){d();b();e(document).ready(function(){e.vgquotes.preload([e.vgquotes.loadingGif]);f();g();e("body").ajaxError(function(k,h,j,i){e.vgquotes.ajaxErrorHandler.call(this,h)});e("#search-query").focus();e(document).keyup(function(h){if(h.keyCode===27){e.vgquotes.closeDialog(e(".dialog"))}})})}())}(jQuery,window)); |