This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Contains general scripts that may be used in any page. | |
* If this file starts to get large it can be split into page-specific files. */ | |
/* The following code is the Garber-Irish implementation, a way to run relevant JavaScript on page-load | |
* based on the MVC action that produced the page. It's an unobtrusive approach, which means that the | |
* code to call the relevant JavaScript functions is all here instead of being hardcoded into the HTML. | |
* All this code needs from the page is data-controller and data-action attributes on the body tag. | |
* Since JavaScript is case-sensitive, the controller and action names we use here must be an exact match. | |
* http://viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Utility | |
{ | |
public class AvailableAttribute : Attribute | |
{ | |
public AvailableAttribute(bool available) { this.Available = available; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
using System.Linq.Expressions; | |
namespace Web.Extensions | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net; | |
using System.Web.Mvc; | |
using System.Web.Routing; | |
namespace Web.Filters | |
{ | |
/// <summary> | |
/// Check whether the application is marked as offline in the config file. | |
/// If so, and the user does not have the override permission, throw an exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
using System.Web.Mvc; | |
/* Based on the ModelStateToTempDataAttribute class from MVCContrib */ | |
namespace Web.Filters | |
{ | |
/// <summary> | |
/// When a RedirectResult or RedirectToRouteResult is returned from an action, anything in the ViewData.ModelState dictionary will be copied into TempData. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ELMAH - Error Logging Modules and Handlers for ASP.NET | |
Copyright (c) 2004-9 Atif Aziz. All rights reserved. | |
Author(s): | |
Atif Aziz, http://www.raboof.com | |
Phil Haacked, http://haacked.com | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Disable caching globally, for all Ajax requests | |
$.ajaxSetup ({ | |
cache: false | |
}); | |
// Make an Ajax request with caching explicitly disabled | |
$.ajax({ | |
type: "GET", | |
cache: false, | |
url: "http://example.com/GetSomeData" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function formatDate (d,f){return f.replace(/{(.+?)(?::(.*?))?}/g,function(v,c,p){for(v=d["get"+c]()+/h/.test(c)+"";v.length<p;v=0+v);return v})} | |
// Formats the date as a string e.g. "24/08/2013 17:04" | |
var formattedDate = formatDate(parsedDate, "{Date:2}/{Month:2}/{FullYear} {Hours:2}:{Minutes:2}"); | |
//Instead of using classical format specifiers like "YYYY", "MM", "HH", "mm" etc. | |
//this function uses the Date instance getters like getFullYear, getMonth, etc. | |
//with support for zero-padding. | |
//For example, instead of: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function dateTimeReviver (key, value) { | |
var a; | |
if (typeof value === 'string') { | |
a = /\/Date\((\d*)\)\//.exec(value); | |
if (a) { | |
return new Date(+a[1]); | |
} | |
} | |
return value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If using Unobtrusive Validation then that library initialised the Validate plugin | |
// on our behalf, so we missed the chance to set invalidHandler. Even if we were to | |
// set invalidHandler now via the settings object it would have no effect, due to the | |
// way that Validate works internally. Instead, we can do the following: | |
$("#MyForm").bind("invalid-form.validate", function () { | |
// Do something useful e.g. display the Validation Summary in a popup dialog | |
$("div.ValSummary").dialog({ | |
title: "Information", | |
modal: true, | |
resizable: false, |