2011-02-15 00:14:24 +00:00
|
|
|
|
(function($, window, undefined){
|
2011-02-28 07:31:07 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2011-02-23 01:30:53 +00:00
|
|
|
|
$.fn.center = function() {
|
2011-02-28 00:38:47 +00:00
|
|
|
|
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");
|
2011-02-15 01:18:23 +00:00
|
|
|
|
return this;
|
2011-02-17 20:55:47 +00:00
|
|
|
|
};
|
2011-02-28 00:38:47 +00:00
|
|
|
|
|
2011-02-23 01:30:53 +00:00
|
|
|
|
$.fn.applyModelErrors = function(errorMessage, errorData) {
|
|
|
|
|
var $this = this;
|
|
|
|
|
|
|
|
|
|
if (errorMessage !== null) {
|
2011-02-24 20:28:35 +00:00
|
|
|
|
$this.find(".error-summary").first().text(errorMessage).show();
|
2011-02-23 01:30:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$.each(errorData, function(inputFieldName, value) {
|
|
|
|
|
var $input = $this.find("input[name='" + inputFieldName + "']");
|
|
|
|
|
if ($input.length > 1) {
|
|
|
|
|
$input = $("#" + inputFieldName);
|
|
|
|
|
}
|
2011-02-24 20:28:35 +00:00
|
|
|
|
|
|
|
|
|
if ($input.length === 1) {
|
|
|
|
|
if ($input[0].localName === "INPUT") {
|
|
|
|
|
$input.addClass("input-validation-error");
|
|
|
|
|
}
|
2011-02-23 01:30:53 +00:00
|
|
|
|
|
|
|
|
|
$("<span/>")
|
2011-02-28 07:27:38 +00:00
|
|
|
|
.addClass("field-validation-error")
|
|
|
|
|
.append($("<span/>").addClass("error-icon"))
|
|
|
|
|
.append($("<span/>").text(value))
|
2011-02-23 01:30:53 +00:00
|
|
|
|
.insertAfter($input);
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-02-24 21:00:22 +00:00
|
|
|
|
|
|
|
|
|
return this;
|
2011-02-23 01:30:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$.fn.clearModelErrors = function() {
|
|
|
|
|
this
|
2011-02-28 06:17:49 +00:00
|
|
|
|
.find(".field-validation-error").remove().end()
|
|
|
|
|
.find(".input-validation-error").removeClass("input-validation-error").end()
|
|
|
|
|
.find(".error-summary").empty().hide();
|
2011-02-24 21:00:22 +00:00
|
|
|
|
|
|
|
|
|
return this;
|
2011-02-23 01:30:53 +00:00
|
|
|
|
};
|
|
|
|
|
|
2011-02-23 09:19:32 +00:00
|
|
|
|
$.vgquotes = function() {
|
2011-02-24 20:28:35 +00:00
|
|
|
|
var ajaxCallback = function(type, callback) {
|
|
|
|
|
return function(data) {
|
|
|
|
|
if (typeof(data) === "undefined" || typeof(data.Error) === "undefined" || data.Error !== null) {
|
|
|
|
|
callback.call(null, null);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-28 06:17:49 +00:00
|
|
|
|
callback.call(null, data.Data.records[0]);
|
2011-02-24 20:28:35 +00:00
|
|
|
|
};
|
2011-02-23 09:19:32 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
refresh: function() { },
|
2011-02-23 21:53:51 +00:00
|
|
|
|
parseDate: function(jsonDate) { return new Date(parseInt(jsonDate.substr(6))); },
|
|
|
|
|
formatDate: function(date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); },
|
|
|
|
|
parseAndFormatDate: function(jsonDate) { return $.vgquotes.formatDate($.vgquotes.parseDate(jsonDate)); },
|
2011-02-23 09:19:32 +00:00
|
|
|
|
ajaxErrorHandler: function(xhr) {
|
2011-02-24 20:28:35 +00:00
|
|
|
|
alert("An error occurred (" + xhr.status + ")");
|
2011-02-23 09:19:32 +00:00
|
|
|
|
},
|
|
|
|
|
preload: function(images) {
|
|
|
|
|
$.each(images, function() {
|
|
|
|
|
$('<img/>')[0].src = this;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
loadingGif: "/media/images/loading.gif",
|
2011-02-23 21:53:51 +00:00
|
|
|
|
getResourceById: function(type, id, callback) {
|
2011-02-23 09:19:32 +00:00
|
|
|
|
id = id.toString();
|
2011-02-24 20:28:35 +00:00
|
|
|
|
$.ajax("/api/" + type + "/" + id, {
|
|
|
|
|
type: "GET",
|
|
|
|
|
success: ajaxCallback(type, callback),
|
|
|
|
|
error: ajaxCallback(type, callback)
|
2011-02-23 09:19:32 +00:00
|
|
|
|
});
|
2011-02-28 00:38:47 +00:00
|
|
|
|
},
|
|
|
|
|
createDialog: function($dialog) {
|
|
|
|
|
$("body")
|
|
|
|
|
.append($("<div/>").attr("id", "modal-background"))
|
|
|
|
|
.append($dialog);
|
|
|
|
|
|
|
|
|
|
$dialog.center();
|
|
|
|
|
},
|
|
|
|
|
closeDialog: function($dialog) {
|
|
|
|
|
$("#modal-background").remove();
|
|
|
|
|
$dialog.remove();
|
2011-02-23 09:19:32 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}();
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
(function(){
|
|
|
|
|
var refreshCookie = "vgquotes.refreshFragment";
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
window.location.href = url;
|
|
|
|
|
};
|
2011-02-17 07:52:56 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var applyFragmentFromCookie = function() {
|
|
|
|
|
var fragment = $.cookie(refreshCookie);
|
|
|
|
|
if (fragment !== null) {
|
|
|
|
|
window.location.href += "#" + fragment;
|
|
|
|
|
$.cookie(refreshCookie, null); //delete cookie
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).ready(applyFragmentFromCookie);
|
|
|
|
|
$.vgquotes.refresh = refresh;
|
|
|
|
|
}());
|
2011-02-17 07:52:56 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var setupSearch = function() {
|
|
|
|
|
var submitSearch = function() {
|
|
|
|
|
var searchQuery = $.trim($("#search-query").val());
|
|
|
|
|
if (searchQuery.length > 0) {
|
|
|
|
|
window.location = "/search/" + searchQuery;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2011-02-17 07:52:56 +00:00
|
|
|
|
$("#search-query").keypress(function(e) {
|
|
|
|
|
if (e.which === 13) {
|
|
|
|
|
submitSearch();
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-02-17 05:30:31 +00:00
|
|
|
|
|
2011-02-17 07:52:56 +00:00
|
|
|
|
$("#search-submit").click(submitSearch);
|
2011-02-19 09:41:09 +00:00
|
|
|
|
});
|
|
|
|
|
};
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var setupVoting = function() {
|
2011-02-15 00:14:24 +00:00
|
|
|
|
var voting = false;
|
|
|
|
|
$(".vote-for, .vote-against").live("click", function() {
|
|
|
|
|
if (voting) {
|
|
|
|
|
alert("Please wait for the current vote to process before voting again");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
voting = true;
|
|
|
|
|
var $votingLink = $(this);
|
|
|
|
|
var $container = $votingLink.parents(".quote-container");
|
|
|
|
|
var direction = $votingLink.hasClass("vote-for") ? 1 : 0;
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var quoteId = $container.find("input.quote-id").val();
|
2011-02-23 01:30:53 +00:00
|
|
|
|
var $score = $container.find(".quote-score");
|
|
|
|
|
var score = $score.text();
|
|
|
|
|
|
2011-02-15 00:14:24 +00:00
|
|
|
|
$.ajax("/vote", {
|
|
|
|
|
type: "POST",
|
2011-02-23 01:30:53 +00:00
|
|
|
|
data: { QuoteId: quoteId, Direction: direction },
|
|
|
|
|
beforeSend: function() {
|
2011-02-23 09:19:32 +00:00
|
|
|
|
$score.empty().append($("<img/>").attr({ src: $.vgquotes.loadingGif, title: "submitting your vote" + String.fromCharCode(0x2026) }));
|
2011-02-15 00:14:24 +00:00
|
|
|
|
},
|
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
|
if (data.Error !== null) {
|
2011-02-23 01:30:53 +00:00
|
|
|
|
window.alert(data.Error);
|
2011-02-15 00:14:24 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 09:19:32 +00:00
|
|
|
|
score = data.Data.score;
|
2011-02-23 01:30:53 +00:00
|
|
|
|
$score.attr("title", "+" + data.Data.upVotes + ", -" + data.Data.downVotes);
|
2011-02-15 00:14:24 +00:00
|
|
|
|
|
|
|
|
|
//remove the voting arrow, and add the other one if needed
|
|
|
|
|
$votingLink.remove();
|
|
|
|
|
if (direction === 1) {
|
|
|
|
|
if ($container.find(".vote-against").length === 0) {
|
|
|
|
|
$("<span/>")
|
|
|
|
|
.addClass("vote-against")
|
|
|
|
|
.attr("title", "I hate this quote")
|
|
|
|
|
.text(String.fromCharCode(0x25BC))
|
|
|
|
|
.appendTo($container.find(".vote-container:last"));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if ($container.find(".vote-for").length === 0) {
|
|
|
|
|
$("<span/>")
|
|
|
|
|
.addClass("vote-for")
|
|
|
|
|
.attr("title", "I like this quote")
|
|
|
|
|
.text(String.fromCharCode(0x25B2))
|
|
|
|
|
.appendTo($container.find(".vote-container:first"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2011-02-23 01:30:53 +00:00
|
|
|
|
complete: function() {
|
|
|
|
|
voting = false;
|
|
|
|
|
var $img = $score.find("img");
|
|
|
|
|
if ($img.length) {
|
|
|
|
|
$img.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$score.text(score);
|
|
|
|
|
}
|
2011-02-15 00:14:24 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2011-02-19 09:41:09 +00:00
|
|
|
|
};
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
var setupFlagLink = function() {
|
2011-02-28 07:27:38 +00:00
|
|
|
|
$("a.quote-flag-icon").click(function() {
|
2011-02-28 00:38:47 +00:00
|
|
|
|
if ($(".flag-dialog").length > 0) {
|
2011-02-15 01:18:23 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-02-28 00:38:47 +00:00
|
|
|
|
|
2011-02-28 07:27:38 +00:00
|
|
|
|
var $container = $(this).parents(".quote-container");
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var quoteId = $container.find("input.quote-id").val();
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
|
|
|
|
var $row = $("<tr/>");
|
|
|
|
|
var flagTypes = [ [1, "Inaccurate"], [2, "Duplicate"], [3, "Spam"], [4, "Fake"], [0, "Other"] ];
|
|
|
|
|
for (var i = 0; i < flagTypes.length; i++) {
|
|
|
|
|
var html = "<td><input type=\"radio\" name=\"flagType\" value=\""
|
|
|
|
|
+ flagTypes[i][0] + "\" id=\"flag-type-" +flagTypes[i][0] + "\"/>"
|
|
|
|
|
+ "<label for=\"flag-type-" + flagTypes[i][0] + "\">" + flagTypes[i][1] + "</label></td>";
|
|
|
|
|
|
|
|
|
|
$row.append($(html));
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
var $dialog = $("<div/>").addClass("dialog flag-dialog");
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
var $submit = $("<a/>")
|
|
|
|
|
.attr({ href: "#", title: "submit" })
|
2011-02-28 07:27:38 +00:00
|
|
|
|
.addClass("button-link")
|
|
|
|
|
.append($("<span/>").addClass("submit-icon"))
|
|
|
|
|
.append($("<span/>").text("Submit"))
|
2011-02-15 01:18:23 +00:00
|
|
|
|
.click(function() {
|
2011-02-28 07:27:38 +00:00
|
|
|
|
var $icon = $(this).find(".submit-icon");
|
|
|
|
|
$icon.toggleClass("submit-icon loading-icon");
|
2011-02-28 00:38:47 +00:00
|
|
|
|
|
|
|
|
|
$.ajax("/flag", {
|
2011-02-15 01:18:23 +00:00
|
|
|
|
type: "POST",
|
|
|
|
|
data: { QuoteId: quoteId, Comment: $dialog.find("textarea").val(), FlagType: $dialog.find("input[name='flagType']:checked").val() },
|
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
|
if (data.Error !== null) {
|
|
|
|
|
alert(data.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-02-28 00:38:47 +00:00
|
|
|
|
|
|
|
|
|
$.vgquotes.closeDialog($dialog);
|
|
|
|
|
},
|
|
|
|
|
|
2011-02-28 07:27:38 +00:00
|
|
|
|
complete: function() { $icon.toggleClass("submit-icon loading-icon"); }
|
2011-02-15 01:18:23 +00:00
|
|
|
|
});
|
2011-02-28 00:38:47 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
2011-02-15 01:18:23 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
var $cancel = $("<a/>")
|
|
|
|
|
.attr({ href: "#", title: "cancel" })
|
2011-02-28 07:27:38 +00:00
|
|
|
|
.addClass("button-link")
|
|
|
|
|
.append($("<span/>").addClass("cancel-icon"))
|
|
|
|
|
.append($("<span/>").text("Cancel"))
|
2011-02-28 00:38:47 +00:00
|
|
|
|
.click(function() { $.vgquotes.closeDialog($dialog); return false; });
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
|
|
|
|
$dialog
|
2011-02-28 00:38:47 +00:00
|
|
|
|
.append($("<p/>").addClass("label").text("Flag as:"))
|
2011-02-15 01:18:23 +00:00
|
|
|
|
.append($("<table/>").append($row))
|
2011-02-28 00:38:47 +00:00
|
|
|
|
.append($("<p/>").addClass("label").text("Comment"))
|
2011-02-15 01:18:23 +00:00
|
|
|
|
.append($("<textarea/>"))
|
2011-02-28 00:38:47 +00:00
|
|
|
|
.append($("<div/>").addClass("submit-container").append($submit).append($cancel));
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
|
|
|
|
//"other" should be checked by default
|
|
|
|
|
$dialog.find("#flag-type-0").attr("checked", "checked");
|
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
$.vgquotes.createDialog($dialog);
|
2011-02-15 01:18:23 +00:00
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
2011-02-19 09:41:09 +00:00
|
|
|
|
};
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var setupLogin = function() {
|
|
|
|
|
var showLoginForm = function() {
|
|
|
|
|
var $dialog = $("#login-dialog");
|
|
|
|
|
if ($dialog.length > 0) {
|
2011-02-28 00:38:47 +00:00
|
|
|
|
$.vgquotes.closeDialog($dialog);
|
2011-02-19 09:41:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
var $usernameInput = $("<input/>").attr({ type: "text", id: "login-username" });
|
|
|
|
|
var $passwordInput = $("<input/>").attr({ type: "password", id: "login-password" });
|
|
|
|
|
var $submit = $("<input/>").attr("type", "submit").css("display", "none");
|
|
|
|
|
|
|
|
|
|
var $form = $("<form/>").attr({ method: "post", action: "/login" }).submit(function() {
|
|
|
|
|
$.ajax("/login", {
|
|
|
|
|
type: "POST",
|
|
|
|
|
data: { username: $usernameInput.val(), password: $passwordInput.val() },
|
|
|
|
|
success: function(data, status, $xhr) {
|
|
|
|
|
if (data.Error !== null) {
|
|
|
|
|
alert(data.Error);
|
|
|
|
|
return;
|
2011-02-17 20:55:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
$.vgquotes.refresh();
|
|
|
|
|
}
|
2011-02-17 20:55:47 +00:00
|
|
|
|
});
|
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
$dialog = $("<div/>").addClass("dialog").attr("id", "login-dialog");
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
$form.append($usernameInput).append($passwordInput).append($submit);
|
|
|
|
|
$dialog.append($form);
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-28 00:38:47 +00:00
|
|
|
|
$.vgquotes.createDialog($dialog);
|
2011-02-19 09:41:09 +00:00
|
|
|
|
$usernameInput.focus();
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
return false;
|
|
|
|
|
};
|
2011-02-17 20:55:47 +00:00
|
|
|
|
|
2011-02-19 09:41:09 +00:00
|
|
|
|
$(document).ready(function() {
|
2011-02-17 20:55:47 +00:00
|
|
|
|
$("#login-link").click(showLoginForm);
|
2011-02-19 09:41:09 +00:00
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
(function(){
|
|
|
|
|
setupLogin();
|
|
|
|
|
setupSearch();
|
|
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2011-02-23 09:19:32 +00:00
|
|
|
|
$.vgquotes.preload([$.vgquotes.loadingGif]);
|
2011-02-28 00:38:47 +00:00
|
|
|
|
setupFlagLink();
|
2011-02-19 09:41:09 +00:00
|
|
|
|
setupVoting();
|
|
|
|
|
|
2011-02-23 01:30:53 +00:00
|
|
|
|
$("body").ajaxError(function(e, xhr, options, error){
|
|
|
|
|
$.vgquotes.ajaxErrorHandler.call(this, xhr);
|
|
|
|
|
});
|
2011-02-24 21:00:22 +00:00
|
|
|
|
|
|
|
|
|
$("#search-query").focus();
|
2011-02-28 00:38:47 +00:00
|
|
|
|
$(document).keyup(function(e) {
|
|
|
|
|
if (e.keyCode === 27) {
|
|
|
|
|
$.vgquotes.closeDialog($(".dialog"));
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-02-19 09:41:09 +00:00
|
|
|
|
});
|
|
|
|
|
}());
|
|
|
|
|
|
2011-02-15 00:14:24 +00:00
|
|
|
|
}(jQuery, window));
|