* compressed javascript

* renamed css file
* removed copypaste code for js includes
* added pdn files
* changed unused images/javascript build type from Content to None
This commit is contained in:
tmont 2011-03-01 00:11:17 +00:00
parent 26352fb745
commit 25172d14a3
29 changed files with 290 additions and 222 deletions

Binary file not shown.

Binary file not shown.

52
Lib/compressjs.targets Normal file
View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="CompressorTask" AssemblyFile="Yahoo.Yui.Compressor.dll" />
<ItemGroup>
<Core Include="media\js\jquery.cookie.js" />
<Core Include="media\js\jquery.center.js" />
<Core Include="media\js\jquery.modelerrors.js" />
<Core Include="media\js\jquery.refresh.js" />
<Core Include="media\js\vgquotes.js" />
</ItemGroup>
<ItemGroup>
<QuoteForm Include="media\js\quoteform.js" />
</ItemGroup>
<ItemGroup>
<Browse Include="media\js\browse.js" />
</ItemGroup>
<Target Name="ConcatenateAndCompressJavaScript">
<CompressorTask
JavaScriptFiles="@(Core)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="False"
DisableOptimizations="Nope"
DeleteJavaScriptFiles="False"
JavaScriptOutputFile="..\VideoGameQuotes.Web\media\js\vgquotes.compressed.js"
LoggingType="ALittleBit"
/>
<CompressorTask
JavaScriptFiles="@(QuoteForm)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="False"
DisableOptimizations="Nope"
DeleteJavaScriptFiles="False"
JavaScriptOutputFile="..\VideoGameQuotes.Web\media\js\quoteform.compressed.js"
LoggingType="ALittleBit"
/>
<CompressorTask
JavaScriptFiles="@(Browse)"
ObfuscateJavaScript="True"
PreserveAllSemicolons="False"
DisableOptimizations="Nope"
DeleteJavaScriptFiles="False"
JavaScriptOutputFile="..\VideoGameQuotes.Web\media\js\browse.compressed.js"
LoggingType="ALittleBit"
/>
</Target>
</Project>

View File

@ -43,7 +43,7 @@ namespace VideoGameQuotes.Web.Configuration {
.Configure<Interception>() .Configure<Interception>()
.AddPolicy("UpdateSearchIndexPolicy") .AddPolicy("UpdateSearchIndexPolicy")
.AddCallHandler<UpdateSearchIndexCallHandler>() .AddCallHandler<UpdateSearchIndexCallHandler>()
.AddMatchingRule<QuoteUpdatedMatchingRule>(); .AddMatchingRule(new QuoteUpdatedMatchingRule());
} }
#region lucene-related factories #region lucene-related factories
@ -61,7 +61,7 @@ namespace VideoGameQuotes.Web.Configuration {
} }
#endregion #endregion
public class QuoteUpdatedMatchingRule : IMatchingRule { private class QuoteUpdatedMatchingRule : IMatchingRule {
private static readonly MethodBase saveMethod = typeof(IRepository<Quote, int>).GetMethod("Save", new[] { typeof(Quote) }); private static readonly MethodBase saveMethod = typeof(IRepository<Quote, int>).GetMethod("Save", new[] { typeof(Quote) });
public bool Matches(MethodBase member) { public bool Matches(MethodBase member) {

View File

@ -2,7 +2,7 @@ using System.ComponentModel.DataAnnotations;
using Portoa.Validation.DataAnnotations; using Portoa.Validation.DataAnnotations;
namespace VideoGameQuotes.Web.Models { namespace VideoGameQuotes.Web.Models {
public class ContactModel { public class ContactModel : ICaptchaModel {
[Required] [Required]
public string Name { get; set; } public string Name { get; set; }
[Email] [Email]

View File

@ -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<QuoteFlag> Flags { get; set; }
}
}

View File

@ -5,31 +5,9 @@ using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Web.Mvc; using System.Web.Mvc;
using JetBrains.Annotations; using JetBrains.Annotations;
using Portoa.Validation.DataAnnotations;
using VideoGameQuotes.Api; using VideoGameQuotes.Api;
namespace VideoGameQuotes.Web.Models { 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<QuoteFlag> Flags { get; set; }
}
public abstract class EditQuoteModelBase { public abstract class EditQuoteModelBase {
protected EditQuoteModelBase() { protected EditQuoteModelBase() {
ControllerName = "quote"; ControllerName = "quote";

View File

@ -0,0 +1,7 @@
namespace VideoGameQuotes.Web.Models {
public interface ICaptchaModel {
string CaptchaAnswer { get; set; }
string HashedCaptchaAnswer { get; set; }
string UnhashedCaptchaAnswer { get; set; }
}
}

View File

@ -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; }
}
}

View File

@ -97,6 +97,9 @@
<Compile Include="Models\EditCategoryModel.cs" /> <Compile Include="Models\EditCategoryModel.cs" />
<Compile Include="Models\EditGameModel.cs" /> <Compile Include="Models\EditGameModel.cs" />
<Compile Include="Models\EditPublisherModel.cs" /> <Compile Include="Models\EditPublisherModel.cs" />
<Compile Include="Models\EditQuoteModel.cs" />
<Compile Include="Models\ICaptchaModel.cs" />
<Compile Include="Models\SubmitQuoteModel.cs" />
<Compile Include="Search\QuoteDocumentHandler.cs" /> <Compile Include="Search\QuoteDocumentHandler.cs" />
<Compile Include="Search\SearchService.cs" /> <Compile Include="Search\SearchService.cs" />
<Compile Include="Services\CategoryService.cs" /> <Compile Include="Services\CategoryService.cs" />
@ -144,27 +147,36 @@
<Content Include="hibernate.cfg.xml"> <Content Include="hibernate.cfg.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="media\css\global.css" /> <Content Include="media\css\vgquotes.css" />
<Content Include="media\images\accept.png" /> <None Include="media\images\accept.png" />
<Content Include="media\images\add.png" /> <None Include="media\images\add.png" />
<Content Include="media\images\cancel.png" /> <None Include="media\images\cancel.png" />
<Content Include="media\images\delete.png" /> <None Include="media\images\delete.png" />
<Content Include="media\images\error.png" /> <None Include="media\images\error.png" />
<Content Include="media\images\external.png" /> <Content Include="media\images\external.png" />
<Content Include="media\images\favicon.png" /> <Content Include="media\images\favicon.png" />
<Content Include="media\images\flag_red.png" /> <None Include="media\images\flag_red.png" />
<Content Include="media\images\forbidden.png" /> <Content Include="media\images\forbidden.png" />
<Content Include="media\images\link.png" /> <None Include="media\images\link.png" />
<Content Include="media\images\loading.gif" /> <Content Include="media\images\loading.gif" />
<Content Include="media\images\notfound.png" /> <Content Include="media\images\notfound.png" />
<Content Include="media\images\pencil.png" /> <None Include="media\images\pencil.png" />
<Content Include="media\images\search.png" /> <None Include="media\images\search.png" />
<Content Include="media\images\sprite.png" /> <Content Include="media\images\sprite.png" />
<Content Include="media\images\unknown.png" /> <Content Include="media\images\unknown.png" />
<Content Include="media\images\vgquotes.png" /> <None Include="media\images\vgquotes.png" />
<Content Include="media\js\browse.js" /> <None Include="media\images\error.pdn" />
<Content Include="media\js\quoteform.js" /> <None Include="media\images\vgquotes.pdn" />
<Content Include="media\js\vgquotes.js" /> <None Include="media\js\browse.js" />
<None Include="media\js\jquery.center.js" />
<None Include="media\js\jquery.cookie.js" />
<None Include="media\js\jquery.modelerrors.js" />
<None Include="media\js\jquery.refresh.js" />
<None Include="media\js\quoteform.js" />
<None Include="media\js\vgquotes.js" />
<Content Include="media\js\browse.compressed.js" />
<Content Include="media\js\quoteform.compressed.js" />
<Content Include="media\js\vgquotes.compressed.js" />
<Content Include="Views\Admin\Create.aspx" /> <Content Include="Views\Admin\Create.aspx" />
<Content Include="Views\Admin\CreateAdminSuccess.aspx" /> <Content Include="Views\Admin\CreateAdminSuccess.aspx" />
<Content Include="Views\Admin\FlaggedQuote.ascx" /> <Content Include="Views\Admin\FlaggedQuote.ascx" />
@ -177,7 +189,9 @@
<Content Include="Views\Home\About.aspx" /> <Content Include="Views\Home\About.aspx" />
<Content Include="Views\Home\Contact.aspx" /> <Content Include="Views\Home\Contact.aspx" />
<Content Include="Views\Home\ContactSuccess.aspx" /> <Content Include="Views\Home\ContactSuccess.aspx" />
<Content Include="Views\Shared\CaptchaJavaScript.ascx" />
<Content Include="Views\Quote\PagingMenu.ascx" /> <Content Include="Views\Quote\PagingMenu.ascx" />
<Content Include="Views\Quote\QuoteFormJavaScript.ascx" />
<Content Include="Views\Quote\QuoteOfTheDay.ascx" /> <Content Include="Views\Quote\QuoteOfTheDay.ascx" />
<Content Include="Views\Shared\BadPaging.aspx" /> <Content Include="Views\Shared\BadPaging.aspx" />
<Content Include="Views\Quote\Best.aspx" /> <Content Include="Views\Quote\Best.aspx" />
@ -221,10 +235,7 @@
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <Import Project="..\..\Lib\compressjs.targets" />
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target> -->
<Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> <Target Name="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" /> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(ProjectDir)" />
</Target> </Target>

View File

@ -44,27 +44,5 @@
</asp:Content> </asp:Content>
<asp:Content ContentPlaceHolderID="DeferrableScripts" runat="server"> <asp:Content ContentPlaceHolderID="DeferrableScripts" runat="server">
<script type="text/javascript">//<![CDATA[ <% Html.RenderPartial("CaptchaJavaScript", Model); %>
$(document).ready(function() {
$("#captcha-question").click(function() {
if ($("#captcha-dialog").length) {
$("#captcha-dialog").remove();
} else {
$("<div/>")
.attr("id", "captcha-dialog")
.addClass("dialog")
.css({ top: "20px" })
.append(
$("<span>The answer is: <strong></strong></span>")
.css({ "white-space": "nowrap" })
.find("strong")
.text("<%= Model.UnhashedCaptchaAnswer %>")
.end()
).insertAfter($("#captcha-question"));
}
return false;
});
});
//]]></script>
</asp:Content> </asp:Content>

View File

@ -22,5 +22,5 @@
</asp:Content> </asp:Content>
<asp:Content ContentPlaceHolderID="DeferrableScripts" runat="server"> <asp:Content ContentPlaceHolderID="DeferrableScripts" runat="server">
<script type="text/javascript" src="/media/js/browse.js"></script> <script type="text/javascript" src="/media/js/browse.compressed.js"></script>
</asp:Content> </asp:Content>

View File

@ -7,5 +7,5 @@
<% Html.RenderPartial("EditQuoteForm", Model); %> <% Html.RenderPartial("EditQuoteForm", Model); %>
</asp:Content> </asp:Content>
<asp:Content runat="server" ID="DeferrableScripts" ContentPlaceHolderID="DeferrableScripts"> <asp:Content runat="server" ID="DeferrableScripts" ContentPlaceHolderID="DeferrableScripts">
<script type="text/javascript" src="/media/js/quoteform.js"></script> <% Html.RenderPartial("QuoteFormJavaScript"); %>
</asp:Content> </asp:Content>

View File

@ -0,0 +1,2 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<script type="text/javascript" src="/media/js/quoteform.compressed.js"></script>

View File

@ -7,29 +7,6 @@
<% Html.RenderPartial("EditQuoteForm", Model); %> <% Html.RenderPartial("EditQuoteForm", Model); %>
</asp:Content> </asp:Content>
<asp:Content runat="server" ID="DeferrableScripts" ContentPlaceHolderID="DeferrableScripts"> <asp:Content runat="server" ID="DeferrableScripts" ContentPlaceHolderID="DeferrableScripts">
<script type="text/javascript" src="/media/js/quoteform.js"></script> <% Html.RenderPartial("QuoteFormJavaScript"); %>
<script type="text/javascript">//<![CDATA[ <% Html.RenderPartial("CaptchaJavaScript", Model); %>
$(document).ready(function() {
$("#captcha-question").click(function() {
if ($("#captcha-dialog").length) {
$("#captcha-dialog").remove();
$(this).text("[click for correct answer]");
} else {
$("<div/>")
.attr("id", "captcha-dialog")
.addClass("dialog")
.css({ top: "20px" })
.append(
$("<span/>")
.css("white-space", "nowrap")
.text("<%= Model.UnhashedCaptchaAnswer %>")
).insertAfter($("#captcha-question"));
$(this).text("[click to hide]");
}
return false;
});
});
//]]></script>
</asp:Content> </asp:Content>

View File

@ -0,0 +1,25 @@
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<VideoGameQuotes.Web.Models.ICaptchaModel>" %>
<script type="text/javascript">//<![CDATA[
$(document).ready(function() {
$("#captcha-question").click(function() {
if ($("#captcha-dialog").length) {
$("#captcha-dialog").remove();
$(this).text("[click for correct answer]");
} else {
$("<div/>")
.attr("id", "captcha-dialog")
.addClass("dialog")
.css({ top: "20px" })
.append(
$("<span/>")
.css("white-space", "nowrap")
.text("<%= Model.UnhashedCaptchaAnswer %>")
).insertAfter($("#captcha-question"));
$(this).text("[click to hide]");
}
return false;
});
});
//]]></script>

View File

@ -6,7 +6,7 @@
<head> <head>
<title>Video Game Quotes :: <asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title> <title>Video Game Quotes :: <asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="/media/css/global.css" /> <link rel="stylesheet" type="text/css" href="/media/css/vgquotes.css" />
<link rel="shortcut icon" type="image/png" href="/media/images/favicon.png" /> <link rel="shortcut icon" type="image/png" href="/media/images/favicon.png" />
</head> </head>
@ -47,7 +47,7 @@
</div> </div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>
<script type="text/javascript" src="/media/js/vgquotes.js"></script> <script type="text/javascript" src="/media/js/vgquotes.compressed.js"></script>
<asp:ContentPlaceHolder ID="DeferrableScripts" runat="server" /> <asp:ContentPlaceHolder ID="DeferrableScripts" runat="server" />
</body> </body>
</html> </html>

View File

@ -143,7 +143,7 @@ ul.menu {
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
ul.menu li { .menu li {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }

Binary file not shown.

Binary file not shown.

View File

@ -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("<ol/>"),o=c("<li/>");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("<a/>");return function(n,o){return l.clone().attr("href","/browse/"+m+"/"+n.Id).text(n.Name)}};var g=function(){var l=c("<a/>");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));

View File

@ -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));

View File

@ -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));

View File

@ -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");
}
$("<span/>")
.addClass("field-validation-error")
.append($("<span/>").addClass("error-icon"))
.append($("<span/>").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));

View File

@ -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));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,100 +1,4 @@
(function($, window, undefined){ (function($, window, undefined){
/**
* 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;
}
};
$.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;
};
$.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");
}
$("<span/>")
.addClass("field-validation-error")
.append($("<span/>").addClass("error-icon"))
.append($("<span/>").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;
};
$.vgquotes = function() { $.vgquotes = function() {
var ajaxCallback = function(type, callback) { var ajaxCallback = function(type, callback) {
return function(data) { return function(data) {
@ -108,7 +12,6 @@
}; };
return { return {
refresh: function() { },
parseDate: function(jsonDate) { return new Date(parseInt(jsonDate.substr(6))); }, parseDate: function(jsonDate) { return new Date(parseInt(jsonDate.substr(6))); },
formatDate: function(date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); }, formatDate: function(date) { return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate(); },
parseAndFormatDate: function(jsonDate) { return $.vgquotes.formatDate($.vgquotes.parseDate(jsonDate)); }, parseAndFormatDate: function(jsonDate) { return $.vgquotes.formatDate($.vgquotes.parseDate(jsonDate)); },
@ -143,34 +46,6 @@
}; };
}(); }();
(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);
}
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);
$.vgquotes.refresh = refresh;
}());
var setupSearch = function() { var setupSearch = function() {
var submitSearch = function() { var submitSearch = function() {
var searchQuery = $.trim($("#search-query").val()); var searchQuery = $.trim($("#search-query").val());
@ -352,7 +227,7 @@
return; return;
} }
$.vgquotes.refresh(); $.refresh();
} }
}); });

View File

@ -16,6 +16,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{4C702D70-7D2E-410D-A3C6-50598863E102}" Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{4C702D70-7D2E-410D-A3C6-50598863E102}"
ProjectSection(SolutionItems) = preProject ProjectSection(SolutionItems) = preProject
Lib\Antlr3.Runtime.dll = Lib\Antlr3.Runtime.dll Lib\Antlr3.Runtime.dll = Lib\Antlr3.Runtime.dll
Lib\compressjs.targets = Lib\compressjs.targets
Lib\EcmaScript.NET.modified.dll = Lib\EcmaScript.NET.modified.dll
Lib\Iesi.Collections.dll = Lib\Iesi.Collections.dll Lib\Iesi.Collections.dll = Lib\Iesi.Collections.dll
Lib\Iesi.Collections.xml = Lib\Iesi.Collections.xml Lib\Iesi.Collections.xml = Lib\Iesi.Collections.xml
Lib\LinFu.DynamicProxy.dll = Lib\LinFu.DynamicProxy.dll Lib\LinFu.DynamicProxy.dll = Lib\LinFu.DynamicProxy.dll
@ -52,6 +54,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{4C702D70-7D2
Lib\Portoa.xml = Lib\Portoa.xml Lib\Portoa.xml = Lib\Portoa.xml
Lib\Remotion.Data.Linq.dll = Lib\Remotion.Data.Linq.dll Lib\Remotion.Data.Linq.dll = Lib\Remotion.Data.Linq.dll
Lib\UnityGenerics.dll = Lib\UnityGenerics.dll Lib\UnityGenerics.dll = Lib\UnityGenerics.dll
Lib\Yahoo.Yui.Compressor.dll = Lib\Yahoo.Yui.Compressor.dll
EndProjectSection EndProjectSection
EndProject EndProject
Global Global