diff --git a/Lib/EcmaScript.NET.modified.dll b/Lib/EcmaScript.NET.modified.dll new file mode 100644 index 0000000..d89fc10 Binary files /dev/null and b/Lib/EcmaScript.NET.modified.dll differ diff --git a/Lib/Yahoo.Yui.Compressor.dll b/Lib/Yahoo.Yui.Compressor.dll new file mode 100644 index 0000000..e749f18 Binary files /dev/null and b/Lib/Yahoo.Yui.Compressor.dll differ diff --git a/Lib/compressjs.targets b/Lib/compressjs.targets new file mode 100644 index 0000000..bf86963 --- /dev/null +++ b/Lib/compressjs.targets @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Configuration/EnableSearchWithLucene.cs b/Src/VideoGameQuotes.Web/Configuration/EnableSearchWithLucene.cs index 1483afb..399d96d 100644 --- a/Src/VideoGameQuotes.Web/Configuration/EnableSearchWithLucene.cs +++ b/Src/VideoGameQuotes.Web/Configuration/EnableSearchWithLucene.cs @@ -43,7 +43,7 @@ namespace VideoGameQuotes.Web.Configuration { .Configure() .AddPolicy("UpdateSearchIndexPolicy") .AddCallHandler() - .AddMatchingRule(); + .AddMatchingRule(new QuoteUpdatedMatchingRule()); } #region lucene-related factories @@ -61,7 +61,7 @@ namespace VideoGameQuotes.Web.Configuration { } #endregion - public class QuoteUpdatedMatchingRule : IMatchingRule { + private class QuoteUpdatedMatchingRule : IMatchingRule { private static readonly MethodBase saveMethod = typeof(IRepository).GetMethod("Save", new[] { typeof(Quote) }); public bool Matches(MethodBase member) { diff --git a/Src/VideoGameQuotes.Web/Models/ContactModel.cs b/Src/VideoGameQuotes.Web/Models/ContactModel.cs index b63a92a..a15fb00 100644 --- a/Src/VideoGameQuotes.Web/Models/ContactModel.cs +++ b/Src/VideoGameQuotes.Web/Models/ContactModel.cs @@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations; using Portoa.Validation.DataAnnotations; namespace VideoGameQuotes.Web.Models { - public class ContactModel { + public class ContactModel : ICaptchaModel { [Required] public string Name { get; set; } [Email] diff --git a/Src/VideoGameQuotes.Web/Models/EditQuoteModel.cs b/Src/VideoGameQuotes.Web/Models/EditQuoteModel.cs new file mode 100644 index 0000000..f87cac6 --- /dev/null +++ b/Src/VideoGameQuotes.Web/Models/EditQuoteModel.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Linq; +using VideoGameQuotes.Api; + +namespace VideoGameQuotes.Web.Models { + public class EditQuoteModel : EditQuoteModelBase { + public EditQuoteModel(Quote quote) { + QuoteId = quote.Id; + Flags = quote.Flags.ToList(); + QuoteText = quote.Text; + CategoryIds = quote.Categories.Select(category => category.Id).ToList(); + GameId = quote.Game.Id; + ActionName = "Edit"; + } + + public int QuoteId { get; set; } + public List Flags { get; set; } + } +} \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Models/EditQuoteModelBase.cs b/Src/VideoGameQuotes.Web/Models/EditQuoteModelBase.cs index 26250f2..01e4c6c 100644 --- a/Src/VideoGameQuotes.Web/Models/EditQuoteModelBase.cs +++ b/Src/VideoGameQuotes.Web/Models/EditQuoteModelBase.cs @@ -5,31 +5,9 @@ using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web.Mvc; using JetBrains.Annotations; -using Portoa.Validation.DataAnnotations; using VideoGameQuotes.Api; namespace VideoGameQuotes.Web.Models { - - public class SubmitQuoteModel : EditQuoteModelBase { - public string CaptchaAnswer { get; set; } - public string HashedCaptchaAnswer { get; set; } - public string UnhashedCaptchaAnswer { get; set; } - } - - public class EditQuoteModel : EditQuoteModelBase { - public EditQuoteModel(Quote quote) { - QuoteId = quote.Id; - Flags = quote.Flags.ToList(); - QuoteText = quote.Text; - CategoryIds = quote.Categories.Select(category => category.Id).ToList(); - GameId = quote.Game.Id; - ActionName = "Edit"; - } - - public int QuoteId { get; set; } - public List Flags { get; set; } - } - public abstract class EditQuoteModelBase { protected EditQuoteModelBase() { ControllerName = "quote"; diff --git a/Src/VideoGameQuotes.Web/Models/ICaptchaModel.cs b/Src/VideoGameQuotes.Web/Models/ICaptchaModel.cs new file mode 100644 index 0000000..86242e2 --- /dev/null +++ b/Src/VideoGameQuotes.Web/Models/ICaptchaModel.cs @@ -0,0 +1,7 @@ +namespace VideoGameQuotes.Web.Models { + public interface ICaptchaModel { + string CaptchaAnswer { get; set; } + string HashedCaptchaAnswer { get; set; } + string UnhashedCaptchaAnswer { get; set; } + } +} \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Models/SubmitQuoteModel.cs b/Src/VideoGameQuotes.Web/Models/SubmitQuoteModel.cs new file mode 100644 index 0000000..986ddc2 --- /dev/null +++ b/Src/VideoGameQuotes.Web/Models/SubmitQuoteModel.cs @@ -0,0 +1,7 @@ +namespace VideoGameQuotes.Web.Models { + public class SubmitQuoteModel : EditQuoteModelBase, ICaptchaModel { + public string CaptchaAnswer { get; set; } + public string HashedCaptchaAnswer { get; set; } + public string UnhashedCaptchaAnswer { get; set; } + } +} \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj b/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj index 124f139..08cb2c3 100644 --- a/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj +++ b/Src/VideoGameQuotes.Web/VideoGameQuotes.Web.csproj @@ -97,6 +97,9 @@ + + + @@ -144,27 +147,36 @@ Always - - - - - - + + + + + + - + - + - - + + - - - - + + + + + + + + + + + + + @@ -177,7 +189,9 @@ + + @@ -221,10 +235,7 @@ - + diff --git a/Src/VideoGameQuotes.Web/Views/Home/Contact.aspx b/Src/VideoGameQuotes.Web/Views/Home/Contact.aspx index 6240850..ced1d78 100644 --- a/Src/VideoGameQuotes.Web/Views/Home/Contact.aspx +++ b/Src/VideoGameQuotes.Web/Views/Home/Contact.aspx @@ -44,27 +44,5 @@ - + <% Html.RenderPartial("CaptchaJavaScript", Model); %> \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Quote/DefaultBrowse.aspx b/Src/VideoGameQuotes.Web/Views/Quote/DefaultBrowse.aspx index 3870d5d..0c950ae 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/DefaultBrowse.aspx +++ b/Src/VideoGameQuotes.Web/Views/Quote/DefaultBrowse.aspx @@ -22,5 +22,5 @@ - + diff --git a/Src/VideoGameQuotes.Web/Views/Quote/Edit.aspx b/Src/VideoGameQuotes.Web/Views/Quote/Edit.aspx index ee7bf18..5e2a6f9 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/Edit.aspx +++ b/Src/VideoGameQuotes.Web/Views/Quote/Edit.aspx @@ -7,5 +7,5 @@ <% Html.RenderPartial("EditQuoteForm", Model); %> - + <% Html.RenderPartial("QuoteFormJavaScript"); %> \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Quote/QuoteFormJavaScript.ascx b/Src/VideoGameQuotes.Web/Views/Quote/QuoteFormJavaScript.ascx new file mode 100644 index 0000000..fae6501 --- /dev/null +++ b/Src/VideoGameQuotes.Web/Views/Quote/QuoteFormJavaScript.ascx @@ -0,0 +1,2 @@ +<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> + \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Quote/Submit.aspx b/Src/VideoGameQuotes.Web/Views/Quote/Submit.aspx index 32f82b1..8a5a617 100644 --- a/Src/VideoGameQuotes.Web/Views/Quote/Submit.aspx +++ b/Src/VideoGameQuotes.Web/Views/Quote/Submit.aspx @@ -7,29 +7,6 @@ <% Html.RenderPartial("EditQuoteForm", Model); %> - - + <% Html.RenderPartial("QuoteFormJavaScript"); %> + <% Html.RenderPartial("CaptchaJavaScript", Model); %> \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Shared/CaptchaJavaScript.ascx b/Src/VideoGameQuotes.Web/Views/Shared/CaptchaJavaScript.ascx new file mode 100644 index 0000000..4dbf6ec --- /dev/null +++ b/Src/VideoGameQuotes.Web/Views/Shared/CaptchaJavaScript.ascx @@ -0,0 +1,25 @@ +<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> + \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/Views/Shared/Site.Master b/Src/VideoGameQuotes.Web/Views/Shared/Site.Master index 5f31762..bad7533 100644 --- a/Src/VideoGameQuotes.Web/Views/Shared/Site.Master +++ b/Src/VideoGameQuotes.Web/Views/Shared/Site.Master @@ -6,7 +6,7 @@ Video Game Quotes :: <asp:ContentPlaceHolder ID="TitleContent" runat="server" /> - + @@ -47,7 +47,7 @@ - + diff --git a/Src/VideoGameQuotes.Web/media/css/global.css b/Src/VideoGameQuotes.Web/media/css/vgquotes.css similarity index 94% rename from Src/VideoGameQuotes.Web/media/css/global.css rename to Src/VideoGameQuotes.Web/media/css/vgquotes.css index 2319a95..61fcc26 100644 --- a/Src/VideoGameQuotes.Web/media/css/global.css +++ b/Src/VideoGameQuotes.Web/media/css/vgquotes.css @@ -143,7 +143,7 @@ ul.menu { padding: 0; list-style: none; } -ul.menu li { +.menu li { margin: 0; padding: 0; } diff --git a/Src/VideoGameQuotes.Web/media/images/error.pdn b/Src/VideoGameQuotes.Web/media/images/error.pdn new file mode 100644 index 0000000..c30d50c Binary files /dev/null and b/Src/VideoGameQuotes.Web/media/images/error.pdn differ diff --git a/Src/VideoGameQuotes.Web/media/images/vgquotes.pdn b/Src/VideoGameQuotes.Web/media/images/vgquotes.pdn new file mode 100644 index 0000000..7c65236 Binary files /dev/null and b/Src/VideoGameQuotes.Web/media/images/vgquotes.pdn differ diff --git a/Src/VideoGameQuotes.Web/media/js/browse.compressed.js b/Src/VideoGameQuotes.Web/media/js/browse.compressed.js new file mode 100644 index 0000000..664263b --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/browse.compressed.js @@ -0,0 +1 @@ +(function(c,a,b){c(document).ready(function(){var i=c("#browse-default-menu");var k=c("#browse-default-container");var f=c("#browse-default-content");var d={game:[],system:[],publisher:[],category:[]};var e=function(l,n){var m=c("
    "),o=c("
  1. ");c.each(l,function(){m.append(o.clone().append(n(this)))});f.append(m)};var j=function(m,l){return function(){var o=function(){i.hide();k.show();e(d[m],l)};if(d[m].length===0){var n=c(this);c.ajax("/api/"+m+"/all",{data:{sort:"alphabetical"},success:function(r,p,q){if(r.Error!==null){alert(r.Error);return}d[m]=r.Data.records;o()},beforeSend:function(){n.toggleClass("loading-icon")},complete:function(){n.toggleClass("loading-icon")}})}else{o()}return false}};var h=function(m){var l=c("");return function(n,o){return l.clone().attr("href","/browse/"+m+"/"+n.Id).text(n.Name)}};var g=function(){var l=c("");return function(m,n){return l.clone().attr({href:"/browse/system/"+m.Id,title:m.Name}).text(m.Abbreviation)}}();c("#show-default-menu").click(function(){f.empty();k.hide();i.show();return false});c("#browse-game").click(j("game",h("game")));c("#browse-system").click(j("system",g));c("#browse-category").click(j("category",h("category")));c("#browse-publisher").click(j("publisher",h("publisher")))})}(jQuery,window)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/jquery.center.js b/Src/VideoGameQuotes.Web/media/js/jquery.center.js new file mode 100644 index 0000000..f12b70c --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/jquery.center.js @@ -0,0 +1,8 @@ +(function($){ + $.fn.center = function() { + var fixed = this.css("position") === "fixed"; + this.css("top", ($(window).height() - this.height()) / 2 + (fixed ? 0 : $(window).scrollTop()) + "px"); + this.css("left", ($(window).width() - this.width()) / 2 + (fixed ? 0 : $(window).scrollLeft()) + "px"); + return this; + }; +}(jQuery)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/jquery.cookie.js b/Src/VideoGameQuotes.Web/media/js/jquery.cookie.js new file mode 100644 index 0000000..8307b46 --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/jquery.cookie.js @@ -0,0 +1,52 @@ +(function($, window){ + /** + * Cookie plugin + * + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + */ + $.cookie = function(name, value, options) { + if (typeof value != 'undefined') { // name and value given, set cookie + options = options || {}; + if (value === null) { + value = ''; + options.expires = -1; + } + var expires = ''; + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { + var date; + if (typeof options.expires == 'number') { + date = new Date(); + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); + } else { + date = options.expires; + } + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE + } + // CAUTION: Needed to parenthesize options.path and options.domain + // in the following expressions, otherwise they evaluate to undefined + // in the packed version for some reason... + var path = options.path ? '; path=' + (options.path) : ''; + var domain = options.domain ? '; domain=' + (options.domain) : ''; + var secure = options.secure ? '; secure' : ''; + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); + } else { // only name given, get cookie + var cookieValue = null; + if (document.cookie && document.cookie != '') { + var cookies = document.cookie.split(';'); + for (var i = 0; i < cookies.length; i++) { + var cookie = $.trim(cookies[i]); + // Does this cookie string begin with the name we want? + if (cookie.substring(0, name.length + 1) == (name + '=')) { + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); + break; + } + } + } + return cookieValue; + } + }; + +}(jQuery, window)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/jquery.modelerrors.js b/Src/VideoGameQuotes.Web/media/js/jquery.modelerrors.js new file mode 100644 index 0000000..3ebf2d2 --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/jquery.modelerrors.js @@ -0,0 +1,39 @@ +(function($){ + $.fn.applyModelErrors = function(errorMessage, errorData) { + var $this = this; + + if (errorMessage !== null) { + $this.find(".error-summary").first().text(errorMessage).show(); + } + + $.each(errorData, function(inputFieldName, value) { + var $input = $this.find("input[name='" + inputFieldName + "']"); + if ($input.length > 1) { + $input = $("#" + inputFieldName); + } + + if ($input.length === 1) { + if ($input[0].localName === "INPUT") { + $input.addClass("input-validation-error"); + } + + $("") + .addClass("field-validation-error") + .append($("").addClass("error-icon")) + .append($("").text(value)) + .insertAfter($input); + } + }); + + return this; + }; + + $.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)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/jquery.refresh.js b/Src/VideoGameQuotes.Web/media/js/jquery.refresh.js new file mode 100644 index 0000000..8de7829 --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/jquery.refresh.js @@ -0,0 +1,32 @@ +/** + * (c) 2010 Tommy Montgomery + * http://tommymontgomery.com/stuff/snippets/javascript/javascript-refresh + * Licensed under WTFPL: http://sam.zoy.org/wtfpl/COPYING + */ +(function($, window){ + var refreshCookie = "jquery.refresh.fragment"; + + var refresh = function() { + var url = window.location.href; + var fragmentPosition = url.lastIndexOf("#"); + if (fragmentPosition >= 0) { + if (fragmentPosition !== url.length - 1) { + $.cookie(refreshCookie, url.substring(fragmentPosition + 1)); //store the fragment in a cookie + } + url = url.substring(0, fragmentPosition); + } + + window.location.href = url; + }; + + var applyFragmentFromCookie = function() { + var fragment = $.cookie(refreshCookie); + if (fragment !== null) { + window.location.href += "#" + fragment; + $.cookie(refreshCookie, null); //delete cookie + } + }; + + $(document).ready(applyFragmentFromCookie); + $.refresh = refresh; +}(jQuery, window)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/quoteform.compressed.js b/Src/VideoGameQuotes.Web/media/js/quoteform.compressed.js new file mode 100644 index 0000000..a17db6e --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/quoteform.compressed.js @@ -0,0 +1 @@ +(function(g,e,i){var d=function(k){return function(){g("#create-"+k+"-form").find("input[type='text']").val("").end().find("input[type='checkbox']").removeAttr("checked").end().find("> .edit-mode").val(0).end().find("> fieldset > legend").text("Create new "+k).end().clearModelErrors().toggle();g("#"+k+"-select").toggle();return false}};var a=function(n,p,k,q,o){var m=n.find("tr:last");if(m.find("td").length===o){m=g("");n.append(m)}var l=g("").append(g("").attr({type:"checkbox",name:p,value:k,id:p+"_"+k,checked:"checked"})).append(g("").attr({href:"#",title:"submit"}).addClass("submit-icon").click(p);var m=g("").attr({href:"#",title:"cancel"}).addClass("cancel-icon");var o=g("").attr({id:"new-category-name",type:"text"}).bind("keyup",function(t){console.log(t.which);if(t.which===13){t.preventDefault();p.call(g(this).siblings(".submit-icon").get(0))}else{if(t.which===27){t.preventDefault();m.click()}}});if(s!==i){q=r.find("input[value='"+s+"']").parent();q.children().hide();m.click(function(){o.remove();n.remove();m.remove();q.children().show();return false});o.val(q.find("label").text());q.append(o).append(n).append(m);o.select();return}var l=r.find("tr:last");q=g("");if(l.find("td").length===5){l=g("");r.append(l)}l.append(q);o.val("Category name");m.click(function(){q.remove();return false});q.append(o).append(n).append(m);o.select()};g("#create-category-link").click(function(){k.call(this);return false});g(".edit-category-link").click(function(){var l=g(this).siblings("input[name='CategoryIds']").val();k.call(this,l);return false});g(".delete-category-link").click(function(){var m=g(this).siblings("input[name='CategoryIds']").val();var l=g(this);g.ajax("/category/delete",{type:"POST",data:{id:m},beforeSend:function(){l.toggleClass("delete-icon loading-icon")},success:function(n){if(n.Error!==null){alert(n.Error);return}g("#category-checkbox-table").find("input[value='"+m+"']").parent().empty()},complete:function(){l.toggleClass("delete-icon loading-icon")}});return false})};var j=function(){g(".dismiss-flag-link").click(function(){var l=g(this);var k=l.parents(".quote-flag");var n=k.find(".quote-flag-id").val();var m=g("#quote-id").val();g.ajax("/dismiss-flag",{type:"POST",data:{quoteId:m,flagId:n},success:function(o,p,q){if(o.Error!==null){alert(o.Error);return}k.remove()}});return false})};(function(){g(document).ready(function(){h();f();b();c();j()})}())}(jQuery,window)); \ No newline at end of file diff --git a/Src/VideoGameQuotes.Web/media/js/vgquotes.compressed.js b/Src/VideoGameQuotes.Web/media/js/vgquotes.compressed.js new file mode 100644 index 0000000..d42fa93 --- /dev/null +++ b/Src/VideoGameQuotes.Web/media/js/vgquotes.compressed.js @@ -0,0 +1 @@ +(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;f1){g=a("#"+f)}if(g.length===1){if(g[0].localName==="INPUT"){g.addClass("input-validation-error")}a("").addClass("field-validation-error").append(a("").addClass("error-icon")).append(a("").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("")[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("
    ").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("").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("").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("").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("");var n=[[1,"Inaccurate"],[2,"Duplicate"],[3,"Spam"],[4,"Fake"],[0,"Other"]];for(var h=0;h";o.append(e(l))}var m=e("
    ").addClass("dialog flag-dialog");var k=e("").attr({href:"#",title:"submit"}).addClass("button-link").append(e("").addClass("submit-icon")).append(e("").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("").attr({href:"#",title:"cancel"}).addClass("button-link").append(e("").addClass("cancel-icon")).append(e("").text("Cancel")).click(function(){e.vgquotes.closeDialog(m);return false});m.append(e("

    ").addClass("label").text("Flag as:")).append(e("").append(o)).append(e("

    ").addClass("label").text("Comment")).append(e("