Skip to content

Instantly share code, notes, and snippets.

@AaronLayton
AaronLayton / gist:9351598
Created March 4, 2014 17:38
MVC Obfuscate emails
#### Helper
```csharp
@helper obfuscateEmail( string email , string text)
{
<a href="/contact/@email.Replace("@",":").Replace(".","+")">@text</a>
}
```
#### Usage
```html
@AaronLayton
AaronLayton / script.js
Created June 10, 2014 09:44
Bootstrap hover dropdowns
// This will add the 'open' class on hover to all dropdowns if the user is on a wide screen
// and then remove the 'open' class when you mouse out
$('.dropdown').hover(function () {
if ($(window).width() >= 768) {
$(this).toggleClass('open');
}
}, function () {
$(this).removeClass('open');
});
/*=============================================================
e.g. <div class="scrollhere"></div>
<a data-scroll="scrollhere" href="#"></a>
TODO Detect whether class or id without indication
Allow class="js-scroll-{element}" to initiate
==============================================================*/
@AaronLayton
AaronLayton / test.js
Created October 17, 2014 15:06
CRBug
Add the following to a snippet in DevTools
Save it
Close DevTools
Open DevTools
Snippet not saved
@AaronLayton
AaronLayton / designer.html
Last active August 29, 2015 14:10
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
var MaterialEffect = {
self: null,
modalContent: null,
baseClass: "material-box",
openClass: "material-box--show",
contentClass: "material-box__content",
init: function(){
self = $("<div />").addClass(baseClass);
modalContent = $(contentClass, self);
@AaronLayton
AaronLayton / index.js
Created March 31, 2015 14:35
ScrollToElementNew
function ScrollToElement(elmID, scrollOffset) {
if (!scrollOffset) scrollOffset = 0;
$('html,body').animate({ scrollTop: $(elmID).offset().top - scrollOffset }, 'slow');
}
function ScrollToElementNew(options, callback) {
var defaults = {
speed: 400,
var data = {
url: url,
data: data,
success: function(data) {
if (data.error) {
if (data.error.message.indexOf("Please log in") != -1) {
$('.quick-account-login a:eq(0)').trigger('click');
} else {
alert(data.error.message);
}
@helper NumberToWords(int number){
// http://stackoverflow.com/questions/2729752/converting-numbers-in-to-words-c-sharp
if (number == 0){
<text>zero</text>
}
if (number < 0){
<text>minus @NumberToWords(Math.Abs(number))</text>
}
@AaronLayton
AaronLayton / tile-cascade.less
Created May 18, 2015 09:34
Tile Cascade mixin (Less)
.tile-cascade( @interval: 60ms, @delay: 0ms ) {
& > * {
&:first-child {
transition-delay: (@interval * 1) + @delay !important;
}
&:nth-child(2) {
transition-delay: @interval * 2 + @delay !important;