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
module TextLengthHelper | |
def text_length(string, max_length) | |
return string if string.length <= max_length | |
string[0..(max_length - 1)] + "..." | |
end | |
end |
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
$('#alt_shipping_address').click(function() { | |
if( $(this).is(':checked')) { | |
$(".shippingContainer").show(); | |
} else { | |
$(".shippingContainer").hide(); | |
} | |
}); |
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
# simple mobile check which covers all devices. | |
def is_mobile? | |
request.user_agent =~ /Mobile|webOS/ | |
end | |
# more advanced mobile check, you can exclude devices. | |
def is_mobile? | |
request.env["HTTP_USER_AGENT"][/(iPhone|iPad|iPod|BlackBerry|Android)/] | |
end |
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
$(".showMoreIntroText").click(function(){ | |
$(".hiddenIntroText").slideToggle(); | |
$(this).text($(this).text() == "Read more..." ? "Read less..." : "Read more..."); | |
}); |
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
$('input#radio').change(function(){ | |
$("input#amountInput").focus(); | |
}); |
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( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) { | |
// code here | |
} else { | |
// code here | |
} |
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
$("body").keydown(function(e){ | |
if (e.keyCode == 69) { | |
$('.editLink').toggle(); | |
} | |
}); |
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
def to_param | |
"#{id}-#{title.parameterize}" | |
end |
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
// paste this in your chrome's console | |
for(var x in localStorage)console.log(x+"="+((localStorage[x].length * 2)/1024/1024).toFixed(2)+" MB"); |
OlderNewer