Skip to content

Instantly share code, notes, and snippets.

View JumboLove's full-sized avatar

David Witt JumboLove

View GitHub Profile
@JumboLove
JumboLove / cookie-utilities
Created August 28, 2013 18:27
jQuery Cookie Utilities
@JumboLove
JumboLove / append-param
Created August 28, 2013 18:22
Append param to URL
// appends the parameter with the given name and
// value to the given url and returns the changed url
appendParamToURL: function(url, name, value) {
var c = "?";
if (url.indexOf(c) != -1) {
c = "&";
}
return url + c + name + "=" + encodeURIComponent(value);
}
@JumboLove
JumboLove / disable-autocomplete
Created August 28, 2013 18:20
Disable autocomplete
// disables browser auto completion for the given element
disableAutoComplete: function(selector) {
jQuery(selector).attr("autocomplete", "off");
}
@JumboLove
JumboLove / inventory
Created August 28, 2013 18:17
Product Inventory
var inventory = Product.getAvailabilityModel().getInventoryRecord().ATS.value;
@JumboLove
JumboLove / isml-json
Created July 9, 2013 19:22
ISML JSON Template
<isscript>
var data = {};
data.success = pdict.GeneralError == null ? true : false;
data.result = {
lineItemId: pdict.GiftCertificateLineItem.UUID,
amount: pdict.GiftCertificateLineItem.baseValue
};
data.errors = {};
</isscript>
<isprint value="${JSON.stringify( data )}" encoding="off"/>
@JumboLove
JumboLove / buttons
Created July 9, 2013 17:48
Increment/Decrement Button
<input type="text" name="${FormLi.quantity.htmlName}" size="2" maxlength="6" value="<isprint value="${lineItem.quantity}"/>" data-pid="${lineItem.productID}" class="inputbox quantityinput positivenumber" />
<iscomment>Plus and Minus button functionality</iscomment>
<isif condition="${lineItem.quantity > 0}">
<button class="plus quantitybtn" data-pid="${lineItem.productID}">Plus</button>
<button class="minus quantitybtn" data-pid="${lineItem.productID}">Minus</button>
</isif>
@JumboLove
JumboLove / hover-table
Created July 5, 2013 14:36
Hover table effect
jQuery(document).ready(function(){
hovertable();
});
function hovertable(){
jQuery("table.hovertable").delegate('td','mouseover mouseleave', function(e) {
if (e.type == 'mouseover') {
jQuery(this).addClass("hover");
jQuery(this).parent().addClass("hover-row");
jQuery(this).parents("table").find("colgroup").eq(jQuery(this).index()).addClass("hover-column");
@JumboLove
JumboLove / update-minicart
Created July 2, 2013 18:16
Update mini cart with data
//Show updated mini-cart using data returned from the add to cart submission
function updateMiniCart(data){
jQuery.ajax({
type: 'POST',
url: serverData.showMiniCartUrl,
data: {lineItemId: data.result.lineItemId},
cache: false,
success: function(html){
app.minicart.show(html);
},
@JumboLove
JumboLove / get-url-param
Created June 25, 2013 15:52
Get the URL parameter specified
function urlParam(key){
var result = new RegExp(key + "=([^&]*)", "i").exec(window.location.search);
return result && result[1] || "";
}
@JumboLove
JumboLove / strip-html
Created June 17, 2013 14:04
Remove HTML from a string
function getShortDescription(product : Product) {
var description : String = product.getLongDescription().toString();
var htmlTest : RegExp = new RegExp("(<([^>]+)>)", "ig");
description = description.replace(htmlTest, "");
return description;
}