// Initialize Outfitter
$(function() {
updateHTML('loadOutfitStage','','GET','#o-leftcolumn');
setupOutfitterActionButtons();
});
function setupOutfitterClosetImages() {
// remove function for old sort, re-add the function
$("#sortItem").unbind("change").change( function() {
changeSortAction( $("#sortItem").val(),'item');
});
// setup the dragables
$("#o-my-closet .o-closet-image").each(function() {
setupItemDraggable(this);
});
// setup the detail view
$("#o-my-closet .o-my-closet-image-container").hover(
function() {
$(".btn-item-info").remove();
html = '
'
$(this).append( html );
addDetailEventItem( $(".btn-item-info",this).eq(0) );
},
function() { $(".btn-item-info", this).remove(); }
);
};
function addDetailEventItem(obj) {
$(obj).unbind("click").click( function() {
imgObj = $(".o-closet-image",$(obj).parent()).eq(0);
// bind the close event
$("#o-detail-closet .back").unbind("click").click( function() { updateDetailView("#o-my-closet .o-detail-view","#o-my-closet .o-my-closet-container"); });
// 1. Change the name of to correct item.
$("#o-detail-closet .o-detail-hdr-name").html( $(imgObj).attr("alt") );
$("#o-detail-closet .o-detail-hdr-name").attr("name", $(imgObj).attr("name") );
// 2. Change Size, color, price
$("#o-my-closet-items li").each(function() {
if( $("span",this).eq(0).html() == $(imgObj).attr("name") )
{
// this is the swatch imag
$("#o-detail-closet .o-detail-view-icon-container img").eq(0).attr("alt", $("span",this).eq(6).html());
$("#o-detail-closet .o-detail-view-icon-container img").eq(0).attr("src", $("span",this).eq(3).html().split(",")[2]);
// this is the size size and price
$("#o-detail-closet .icon-size").html( $("span",this).eq(7).html() );
$("#o-detail-closet #o-detail-closet-view-price").html("Price: $" + $("span",this).eq(2).html());
// this is the large image
$("#o-detail-closet-img").attr("alt", $(imgObj).attr("alt") );
$("#o-detail-closet-img").attr("src", $("span",this).eq(3).html().split(",")[1] );
$("#o-detail-closet-img").attr("name", $(imgObj).attr("name") );
// bind make image draggable.
setupItemDraggable( $("#o-detail-closet-img") );
// get the link to product page, only if the product is not out of stock.
productURL = "/catalog/product.jsp?productId=" + $("span",this).eq(8).html() + "&boutique=1";
$("#o-detail-closet .o-detail-closet-info a").eq(1).attr("href",productURL);
if( $("span",this).eq(4).html() == "O" )
{
$("#o-detail-closet .o-detail-closet-info a").eq(1).hide();
$("#widget-pdetail-divider").hide();
}
else
{
$("#o-detail-closet .o-detail-closet-info a").eq(1).show();
$("#widget-pdetail-divider").show();
}
// setup the add to basket
$("#o-detail-closet .btn-o-detail-add-item").unbind("click").click(function() { addItemsToBasketAction( $(imgObj).attr("name") ); });
}
});
// show the updated layer.
updateDetailView("#o-my-closet .o-my-closet-container","#o-my-closet .o-detail-view");
// remove old events, attach new events for remove
$("#o-detail-closet .o-detail-closet-info a").eq(0).unbind("click").click(function() {
removeFromClosetAction( $(imgObj).attr("name"),"item" );
});
});
};
function updateDetailView(obj1, obj2) {
$(obj1).hide();
$(obj2).show();
};
function setupOutfitterOutfitImages() {
// remove function for old sort, re-add the function
$("#sortOutfit").unbind( "change" );
$("#sortOutfit").change( function() {
changeSortAction( $("#sortOutfit").val(),'outfit');
});
$("#o-my-outfits .o-closet-image").hover(
function() { $(this).addClass("o-closet-image-hover"); },
function() { $(this).removeClass("o-closet-image-hover"); }
);
// setup the dragables
$("#o-my-outfits .o-closet-image").each( function() {
setupOutfitDraggable( this );
});
// setup the detail view
$("#o-my-outfits .o-my-closet-image-container").hover(
function() {
$(".btn-outfit-info").remove();
html = '
'
$(this).append( html );
addDetailEventOutfit( $(".btn-outfit-info",this).eq(0) );
},
function() { $(".btn-outfit-info", this).remove(); }
);
};
function addDetailEventOutfit(obj) {
$(obj).unbind("click").click( function() {
imgObj = $(".o-closet-image",$(obj).parent()).eq(0);
// bind the close event
$("#o-detail-outfits .back").unbind("click").click( function() { updateDetailView("#o-my-outfits .o-detail-view","#o-my-outfits .o-my-closet-container"); });
// 1. Change the name of to correct item.
$("#o-detail-outfits .o-detail-hdr-name").html( $(imgObj).attr("alt") );
$("#o-detail-outfits .o-detail-hdr-name").attr("name", $(imgObj).attr("id") );
// 2. Change image, change view, change dates
$("#o-my-closet-outfits li").each(function() {
if( $("span",this).eq(1).html() == $(imgObj).attr("name") )
{
// this is the large image
$("#o-detail-full-name").html( $("span",this).eq(0).html() );
$("#o-detail-outfits-img").attr("alt", $(imgObj).attr("alt") );
$("#o-detail-outfits-img").attr("src", $("span",this).eq(2).html().split(",")[2] );
$("#o-detail-outfits-img").attr("name", $(imgObj).attr("name") );
// setup the draggable.
setupOutfitDraggable( $("#o-detail-outfits-img") );
// change number of views
$("#o-detail-outfits-view-count").html( $("span",this).eq(6).html() );
// change the dates
$("#o-detail-outfits-created").html( $("span",this).eq(3).html() );
$("#o-detail-outfits-updated").html( $("span",this).eq(4).html() );
$("#o-detail-outfits-published").html( $("span",this).eq(5).html() );
}
});
// show the updated layer.
updateDetailView("#o-my-outfits .o-my-closet-container","#o-my-outfits .o-detail-view");
// setup the add to basket
$("#o-detail-outfits .btn-o-detail-add-item").unbind("click").click(function() { addOutfitToBasketAction( $(imgObj).attr("name") ); });
// setup the edit outfit action
$("#o-detail-outfits .o-detail-closet-info a").eq(1).unbind("click").click(function() {
if( $(imgObj).attr("name") != theStage.getOutfitId() )
{
editOutfitId = $(imgObj).attr("name");
updateOutfitLayerAction('edit');
}
else
{ updateOutfitLayerAction('save'); }
});
// attach event for remove
$("#o-detail-outfits .o-detail-closet-info a").eq(0).unbind("click").click(function() {
removeFromClosetAction( $(imgObj).attr("name"),"outfit" );
});
// attach event for share with friend.
$("#o-detail-outfits .o-detail-closet-info a").eq(2).unbind("click").click(function() {
shareOutfitWithFriend( $("#o-detail-outfits-img").attr("name") );
});
});
};
function loadClosetImages(s,e) {
// clear closet for next set of images
$("#o-my-closet #o-my-closet-images *").remove();
$("#o-my-closet-items li").each( function(i) {
style = (((i+1) % 3) == 0) ? "margin-right: 0px;" : " ";
vId = $("span", this).eq(0).html();
image = $("span", this).eq(3).html().split(",")[0];
name = $("span", this).eq(5).html();
name = fixHTMLtext(name);
htmlTxt = '
' +
'

' +
'
';
$("#o-my-closet #o-my-closet-images").append(htmlTxt);
});
$("#o-closet-loading-msg").hide();
setupOutfitterClosetImages();
};
function loadOutfitImages(s,e) {
// clear closet for next set of images
$("#o-my-outfits #o-my-closet-images *").remove();
$("#o-my-closet-outfits li").each(function(i) {
style = (((i+1) % 3) == 0) ? "margin-right: 0px;" : " ";
outfitName = $("span", this).eq(7).html();
outfitId = $("span", this).eq(1).html();
image = $("span", this).eq(2).html().split(",")[0];
htmlTxt = '' +
'

' +
'
';
$("#o-my-outfits #o-my-closet-images").append(htmlTxt);
});
$("#o-closet-loading-msg").hide();
setupOutfitterOutfitImages();
};
function setupOutfitterActionButtons() {
// unbind events first
$("div#o-action-buttons img").eq(0).unbind("click").click( function() {
if( (theStage.getOutfitId() != -1) )
{
$("#o-results-popup").hide();
$("#o-publish-loading").vCenter();
$("#o-publish-loading").show();
overlayShow();
saveOutfitAction('Y','Y');
}
else
{ alert("Please save your outfit first."); }
});
$("div#o-action-buttons img").eq(1).unbind("click").click( function() { shareOutfitWithFriend(theStage.getOutfitId()); });
$("div#o-action-buttons img").eq(2).unbind("click").click( function() {
params = "";
$(".o-stage-image").each(function() { params = params + $(this).attr("name") + ","; });
params = params.substring(0,params.length-1);
addItemsToBasketAction(params);
});
};
function setupOutfitterClosetButtons() {
$(".manage-closet-link").eq(0).unbind("click").click( function() { outfitterManageLayer.openManage("wardrobe"); shrinkPage(); });
};
function setupOutfitterOutfitButtons() {
$(".manage-outfits-link").eq(0).unbind("click").click( function() { outfitterManageLayer.openManage("outfits"); shrinkPage(); });
};
function setupOutfitterTabs(id) {
//Add the tab events
$("#o-tab-area img").each(function(i) {
if( $(this).attr("name") == id)
{
$(this).attr("id",outfitterTabs.getActiveTabId());
$(this).attr("src",outfitterTabs.getTabImageOn( $(this).attr("name") ));
outfitterTabs.showTab( $(this).attr("name") );
if( $(this).attr("name") == "tabMessages" )
{ shrinkPage(); }
}
$(this).unbind("click").click( function() {
if( $(this).attr("name") != outfitterTabs.getCurrentTab() )
{
unShrinkPage();
// remove the old active tab
$("img#active-tab").attr("src",outfitterTabs.getTabImageOff( outfitterTabs.getCurrentTab() ));
$("img#active-tab").attr("id","");
// setup new active tab
$(this).attr("id",outfitterTabs.getActiveTabId());
$(this).attr("src",outfitterTabs.getTabImageOn( $(this).attr("name") ));
outfitterTabs.showTab( $(this).attr("name") );
if( $(this).attr("name") == "tabMessages" )
{ shrinkPage(); }
}
});
});
};
function clickTab(id) { $("#o-tab-area img").eq(id).click(); };
function checkClosetInstructions() {
if( closetMessage == 0 )
{
//if there are no items on the stage then show instructions
if( $(".o-stage-image").size() == 0 )
{
$("#o-empty-stage-directions").show("slow");
setTimeout( function() { $("#o-empty-stage-directions").fadeOut("slow"); }, 3000);
}
closetMessage = 1;
}
};
function setupOutfitTagsBrowse() {
$("#o-tags-nav img").eq(0).unbind("click").click( function() { yourTagsBrowse('prev'); });
$("#o-tags-nav img").eq(1).unbind("click").click( function() { yourTagsBrowse('next'); });
if( $("#o-tags-listing-container").height() >= $("#o-tags-listing-container ul").eq(0).height() )
{ $("#o-tags-nav img.next-btn").hide(); }
$("#o-tags-nav img.prev-btn").hide();
// find what the top (last showing element id is when at top of list
runningTotal = 0;
$("#o-tags-listing-container ul li").each(function(i) {
runningTotal = runningTotal + $(this).height();
if( runningTotal <= outfitTagHeight )
{ outfitTagElCurrentE = i; }
});
outfitTagElCurrentS = 0;
};
function yourTagsBrowse(action) {
if( action == "prev")
{
outfitTagElCurrentS--;
outfitTagElCurrentE--;
topValue = parseInt($("#o-tags-listing-container ul").eq(0).css("margin-top").split("px")[0]) + outfitTagPrevH;
outfitTagPrevH = $("#o-tags-listing-container ul li").eq(outfitTagElCurrentE).height();
$("#o-tags-listing-container ul").eq(0).css("margin-top", topValue +"px");
$("#o-tags-nav img.next-btn").show();
if( outfitTagElCurrentS == 0 )
{ $("#o-tags-nav img.prev-btn").hide(); }
}
else if(action = "next")
{
outfitTagElCurrentS++;
outfitTagElCurrentE++;
outfitTagPrevH = $("#o-tags-listing-container ul li").eq(outfitTagElCurrentE).height();
topValue = parseInt($("#o-tags-listing-container ul").eq(0).css("margin-top").split("px")[0]) - outfitTagPrevH;
$("#o-tags-listing-container ul").eq(0).css("margin-top", topValue +"px");
$("#o-tags-nav img.prev-btn").show();
if( outfitTagElCurrentE == ( $("#o-tags-listing-container ul li").size() - 1 ))
{ $("#o-tags-nav img.next-btn").hide(); }
}
else
{ alert("error Action not know"); }
};
function setupOutfitTags() {
$("#o-tags-links a").unbind("click").click( function() { updateOutfitLayerAction('save'); });
};
function addYourOutfitTotals() {
newTotal = 0;
$(".your-outfit-item-price span").each(function () { newTotal = newTotal + parseFloat($(this).html()); });
$("#o-your-outfit-total span").html(newTotal.toFixed(2));
};
function stagePopupButton(state,obj) {
if(state == "show")
{
locT = parseInt($(obj).css("top").split("px")[0]) + 20;
locL = parseInt($(obj).css("left").split("px")[0]) + 20;
zIndex = $(obj).css("z-index") + 1;
$("#btn-stage-popup").css("top",locT + "px");
$("#btn-stage-popup").css("left",locL + "px");
$("#btn-stage-popup").css("z-index",zIndex);
$("#btn-stage-popup").show();
$("#btn-stage-popup").unbind("click").click( function() { showStagePopup(obj); });
}
else
{ $("#btn-stage-popup").hide(); }
};
function showStagePopup(obj) {
//position the popup
var pos = findPos(obj);
locL = pos[0] + 20;
locT = pos[1] + 20;
$("#o-stage-item-popup").css("top",locT + "px");
$("#o-stage-item-popup").css("left",locL + "px");
// find info for this popup
vID = $(obj).attr("name");
name = $("tr[name="+vID+"] td").eq(0).html();
$("#o-stage-item-popup .itemName").html( name );
price = $("tr[name="+vID+"] td").eq(2).html();
$("#o-stage-item-popup .itemPrice").html( price );
// view other colors
productURL = "/catalog/product.jsp?productId=" + $("#your-outfit-browse-table tr[name="+vID+"]").attr("productId") + "&boutique=1";
$("#o-stage-item-popup .itemViewOtherColors a").attr("href",productURL);
//attach events for the popup
$("#o-stage-item-popup .btn-close-stage-popup").unbind("click").click(function() {
$("#o-stage-item-popup").hide();
$(".o-stage-image").draggableEnable();
});
// move to front, back
$("li", $("#stage-item-popup-movement ul").eq(0)).eq(0).unbind("click").click(function() { $(obj).css("z-index", stageZ.getFront()); $("#o-stage-item-popup .btn-close-stage-popup").click(); });
$("li", $("#stage-item-popup-movement ul").eq(0)).eq(1).unbind("click").click(function() { $(obj).css("z-index", stageZ.getBack()); $("#o-stage-item-popup .btn-close-stage-popup").click(); });
// move forward, backward
$("li", $("#stage-item-popup-movement ul").eq(1)).eq(0).unbind("click").click(function() { stageZ.forward(obj); $("#o-stage-item-popup .btn-close-stage-popup").click(); });
$("li", $("#stage-item-popup-movement ul").eq(1)).eq(1).unbind("click").click(function() { stageZ.backward(obj); $("#o-stage-item-popup .btn-close-stage-popup").click(); });
// removeItem
$("#stage-item-popup-actions img").eq(0).unbind("click").click(function() {
$(".btn-close-stage-popup").click();
removeItemYourOutfit($(obj).attr("id"),$(obj).attr("name"));
stagePopupButton("hide",'');
});
// add to basket
$("#stage-item-popup-actions img").eq(1).unbind("click").click(function() {
params = $(obj).attr("name");
addItemsToBasketAction(params);
});
$("#o-stage-item-popup").show();
$(".o-stage-image").draggableDisable();
};
function setupManageLayer(type) {
$("#o-manage-loading2").hide();
$("#o-manage-view-back a").unbind("click").click( function() {
// 1. close the manage layer, reload tab if needed
removeManagelayer();
unShrinkPage();
outfitterTabs.showTab( outfitterTabs.getCurrentTab() );
});
$("#o-manage-outfit-table-hdr > span > span.sortable").unbind("click").click(function() {
// run the sort
params = "type=" + type + "&sortBy=" + $(this).html() + "&sortToggle=" + outfitterManageLayer.getSortToggle();
actionManageTable(params);
// show hdr as active
$("#o-manage-outfit-table-hdr > span").removeClass("o-manage-active-hdr");
$("#o-manage-outfit-table-hdr > span").addClass("o-manage-inactive-hdr");
$(this).parent().removeClass("o-manage-inactive-hdr");
$(this).parent().addClass("o-manage-active-hdr");
});
};
/* Function to setup teh manage table area */
/* ----------------------------- */
function confirmRemoveManage(type,id) {
if(confirm("This outfit is currently on the stage. To continue and delete this outfit Click OK"))
{
//theStage.reset();
createNewOutfit();
outfitterManageLayer.removeObject( type, id );
}
};
function manageLayerTableSetup( type ) {
$("#o-manage-loading").hide();
//setup the remove button
$(".btn-manage-remove").unbind("click").click(function() {
id = $(this).parent().parent().attr("id");
if(type == "outfits")
{
if( theStage.getOutfitId() == id )
{
confirmRemoveManage(type, id );
return true;
}
}
outfitterManageLayer.removeObject( type, id);
});
// update the item / outfit count / update published count.
$("#o-manage-count").html( $("#o-manage-outfit-table-container tr").size() );
// setup the image hovers (click);
$(".manage-image-icon").unbind("hover").each(function() {
$(this).hover(
function(ev) {
// if not showing show, if showing remove
htmlTxt = ""
$("body").append(htmlTxt);
$(".manage-image-hover").css("left", parseInt(getMouseCoord(ev)[0] + 35) +"px");
$(".manage-image-hover").css("top", getMouseCoord(ev)[1]+"px");
}, function() {
$(".manage-image-hover").remove();
});
});
// setup the load function
if( type == "outfits" )
{
$(".manage-load-outfit").unbind("click").click( function() {
params = "outfitId=" + $(this).parent().parent().attr("id");
loadOutfitAction(params);
});
}
};
/* ------------------------------------ */
/* function for email a friend */
/* --------------------------- */
function shareOutfitWithFriend(outfitId) {
//set the href witht the correct outfitId;
if(outfitId != -1)
{
emailURL = "/catalog/email_a_friend.jsp?outfitId=" + outfitId;
myCurrentPopupWindow = window.open(emailURL,'emailFriend','location=0,status=0,menubar=0,toolbar=0,resizable=0,width=600,height=550');
}
else
{ alert("Please save your outfit first."); }
};
/* ---------------------------- */
/* function for checking and removing the manage layer on screen */
/* ----------------------------- */
function removeManagelayer() {
// make sure the layer exists
if(outfitterManageLayer.isDirty())
{ outfitterTabs.tabRemove(outfitterTabs.getCurrentTab()); }
outfitterManageLayer.removeManage();
};
/* ----------------------------- */
/* Functions for settup up draggables to stage */
/* -------------------------------------------- */
function setupOutfitDraggable(obj) {
$(obj).draggableDestroy().draggable({
helper: 'clone',
zIndex: 30000,
start: function(e,ui) {
setupStageDroppable();
if($.browser.msie)
{
if (typeof document.body.style.maxHeight == "undefined")
{ $(".o-closet-sort").hide(); }
}
$("#o-tab-area").css("z-index","-1");
},
drag: function(e,ui) { $(".btn-outfits-info").remove(); },
stop: function(e,ui) { $(".o-closet-sort").show();
$("#o-tab-area").css("z-index","3");
}
});
};
function setupItemDraggable(obj) {
$(obj).draggableDestroy().draggable({
helper: 'clone',
zIndex: 30000,
start: function(e,ui) {
setupStageDroppable();
if($.browser.msie)
{
if (typeof document.body.style.maxHeight == "undefined")
{ $(".o-closet-sort").hide(); }
}
$("#o-tab-area").css("z-index","-1");
},
drag: function(e,ui) { $(".btn-item-info").remove(); },
stop: function(e,ui) { $(".o-closet-sort").show();
$("#o-tab-area").css("z-index","3");
}
});
};
/* --------------------------------------------- */
/* Functions for page overlay (black/grey overlay) */
/* -------------------------- */
function overlayShow() {
$("#o-overlay").css("height", $("#container").height() + "px" );
$("#o-overlay").show();
hideSelect();
};
function overlayHide() {
$("#o-overlay").hide();
showSelect();
};
/* ---------------------------- */
/* function to hide selectBoxs for IE6 */
/* --------------------------------------- */
function hideSelect() {
if ( !(typeof document.body.style.maxHeight != "undefined") )
{ $("select").css("visibility","hidden");}
};
function showSelect() {
if ( !(typeof document.body.style.maxHeight != "undefined") )
{ $("select").css("visibility","visible");}
};
/* -------------------------------- */
/* Function to close the results popup, function to setup Results Popup, funciton to add message to popup */
/* ---------------------------------- */
function closeResultsPopup() {
$("#o-results-popup-content *").remove();
$("#o-results-popup-content").html("");
$("#o-results-popup-content-sub *").remove();
$("#o-results-popup-content-sub").html("");
$("#o-results-popup").hide();
overlayHide();
};
function setupResultsPopup() {
//setup the publish button
$("#widget-savePostRunway").unbind("click").click(function() { $("#btn-o-post-to-community").click(); });
$("#widget-savePostRunway").attr("href","javascript:void(0)");
$("#o-results-close-btn").unbind("click").click( function() { closeResultsPopup(); });
$("#o-results-popup").vCenter();
$("#o-results-popup").show();
overlayShow();
};
function addMessageResultsPopup() {
message1 = "";
message2 = "";
if( $("#results-key").size() > 0 )
{
message1 = $("div#results-key").html();
$("div#results-key").remove();
}
if( $("#results-sub-key").size() > 0 )
{
message2 = $("#results-sub-key").html();
$("#results-sub-key").remove();
}
$("#o-results-popup-content *").remove();
$("#o-results-popup-content-sub *").remove();
$("#o-results-popup-content").append(message1);
$("#o-results-popup-content-sub").append(message2);
setupResultsPopup();
};
/* --------------------------------- */
/* Report Innappropriate Behavior function */
/* ----------------------------------------- */
function reportBehavior() {
URL = "/outfitter/email_abuse.jsp";
if( ( $(".o-message-details-actions").size() > 0) && ( outfitterTabs.getCurrentTab() == "tabMessages") )
{ URL = URL + "?type=message&messageId=" + $(".o-message-details-actions").eq(0).attr("id"); }
myCurrentPopupWindow = window.open(URL,'reportBehavior','location=0,status=0,menubar=0,toolbar=0,resizable=0,width=500,height=475')
};
/* ------------------------------------------- */
/* Function to setup, "Create New Outfit", "Save Outfit", and Edit Outfit Links */
/* -------------------------------------- */
function setupOutfitterStageButtons() {
$("div#o-stage-btns img").eq(0).unbind("click").click(function() { createNewOutfit() });
$("div#o-stage-btns img").eq(1).unbind("click").click(function() { updateOutfitLayerAction('save'); });
$("span#o-stage-outfit-editname").unbind("click").click(function() { updateOutfitLayerAction('save'); });
};
/* ---------------------------------- */
/* Function that fires when doing a "new Outfit" */
/* ----------------------------- */
function createNewOutfit() {
if(!theStage.isDirty())
{
// clear all areas
clearAllNoReload();
theStage.reset();
stageZ.reset();
}
else
{ confirmNew(); }
};
/* ----------------------------- */
/* Functions for clear boutique areas */
/* ---------------------------------------- */
function clearAllNoReload() {
clearStage();
clearYourOutfit();
clearTags();
};
function clearStage() {
$("#btn-stage-popup").hide();
$("#o-the-stage .o-stage-image").each( function() {
$(this).draggableDestroy();
$(this).remove();
});
};
function clearTags() {
// clear old tags
$("#o-tags-listing-container ul *").remove();
$("#o-tags-nav img").show();
setupOutfitTagsBrowse();
};
function clearYourOutfit() {
// clear old your-oufit data
$("#your-outfit-browse-table tr").remove();
// reset stuff
setupYourOutfitBrowse();
setupYourOutfitRemove();
addYourOutfitTotals();
};
/* ---------------------------------- */
/* functions for updateLayer events, and setup of the Update Layer */
/* ------------------------------------ */
function cancelAndCloseUpdateLayer() {
updateLayerClose();
theStage.redirectOff();
overlayHide();
};
function updateLayerClose() {
$("#o-outfit-save-popup *").remove();
$("#o-outfit-save-popup").hide();
};
function suggestTag() {
URL = "/outfitter/email_suggest_tag.jsp";
myCurrentPopupWindow = window.open(URL,'suggestTag','location=0,status=0,menubar=0,toolbar=0,resizable=0,width=500,height=300');
};
function setupUpdateLayer(action) {
// show this layer if previously hid, hide the saving layer if previusly showing
$("#o-outfit-save-popup").show();
$("#update-progress-layer").hide();
//events for canceling, [x] image or cancel
$("#o-outfit-save-popup .btn-close-stage-popup").unbind("click").click( function() { cancelAndCloseUpdateLayer(); });
$("#o-save-btn-cancel").unbind("click").click(function() { cancelAndCloseUpdateLayer(); });
//attach event for suggest a tag
$("#o-suggest-a-tag").unbind("click").click(function() { suggestTag(); });
// attach events for navigation of tags
// 1. Determin if need to show the buttons
if( $("#save-outfit-tag-area table").eq(0).height() > saveTagHeight )
{ $("#save-outfit-tag-area .next-btn").show(); }
runningTotal = 0;
saveTagElCurrentS = 0;
saveTagElCurrentE = 0;
$("#save-outfit-tag-area table tr").each(function(i) {
runningTotal = runningTotal + $("td",this).eq(0).height();
if( $.browser.safari )
{ runningTotal = runningTotal + 6; }
if( runningTotal <= saveTagHeight )
{ saveTagElCurrentE = i; }
});
// add the events to the buttons for navigating tags
$("#save-outfit-tag-area .next-btn").unbind("click").click(function() {
saveTagElCurrentS++;
saveTagElCurrentE++;
saveTagPrevH = $("td", $("#save-outfit-tag-area table tr").eq(saveTagElCurrentE)).height();
newTop = parseInt( $("#save-outfit-tag-area table").css("top").split("px")[0] ) - saveTagPrevH;
$("#save-outfit-tag-area table").css("top", newTop + "px");
$("#save-outfit-tag-area .prev-btn").show();
if( saveTagElCurrentE == ( $("#save-outfit-tag-area table tr").size() - 1) )
{ $("#save-outfit-tag-area .next-btn").hide(); }
});
$("#save-outfit-tag-area .prev-btn").unbind("click").click(function() {
saveTagElCurrentS--;
saveTagElCurrentE--;
newTop = parseInt( $("#save-outfit-tag-area table").css("top").split("px")[0] ) + saveTagPrevH;
saveTagPrevH = $("td", $("#save-outfit-tag-area table tr").eq(saveTagElCurrentE)).height();
$("#save-outfit-tag-area table").css("top", newTop + "px");
$("#save-outfit-tag-area .next-btn").show();
if( saveTagElCurrentS == 0 )
{ $("#save-outfit-tag-area .prev-btn").hide(); }
});
// attach action specific events
if(action == "save" || action == "results")
{
// Prepopulate the Outfit Name if needed
if( $("#input-OutfitName").val() == "" )
{ $("#input-OutfitName").val( $("#o-stage-outfit-name").html() ); }
//load the tags that are already on the outfit
$("#o-tags-listing-container ul li").each(function() {
$("#save-outfit-tag-area input[@value=" + $(this).attr("id") + "]").attr("checked","true");
});
$("#o-save-btn-save").unbind("click").click(function() {
// Hide the save layer
$("#o-outfit-save-popup").hide();
// show the working layer
$("#update-progress-layer").vCenter();
$("#update-progress-layer").show();
// 3. Now run the command to save outfit
saveOutfitAction('Y','N');
});
}
else if(action == "edit")
{
// 1. update outfit name so that we send the correct name
$("input#input-OutfitName").val( $("#o-detail-full-name").html() );
$("#o-save-btn-save").unbind("click").click(function() {
// Hide the save layer
$("#o-outfit-save-popup").hide();
// show the working layer
$("#update-progress-layer").vCenter();
$("#update-progress-layer").show();
// run the update
updateOutfitAction('Y');
});
}
};
/* ------------------------------------------------ */
/* function that runs when you drop image on stage */
/* --------------------------------------- */
function setupOutfitterStageImages() {
// remove old dragables, reset stage item count
theStage.clearItems();
stageZ.reset();
$(".o-stage-image").each(function() {
// add the item to the count of items
theStage.addItem();
// remove and add the new event, add the draggable event
$(this).draggableDestroy().draggable({
containment: 'parent',
start: function(e,ui) { stagePopupButton("hide",''); },
stop: function(e,ui) { stagePopupButton("show",ui.draggable.element); theStage.makeDirty(); }
});
// setup the z-index stuff
stageZ.addObjectZ( parseInt($(this).css("z-index")) );
// setup the hover
$(this).unbind("hover").hover(
function() { stagePopupButton("show",this); },
function() { stagePopupButton("hide",this); }
);
});
$("#btn-stage-popup").mouseover( function() { $(this).show(); });
};
/* ------------------------------------------- */
/* Function that sets up the stage as a droppable area */
/* -------------------------------------- */
function setupStageDroppable() {
$("#o-the-stage").droppableDestroy().droppable({
accept: ".o-closet-image, #o-detail-closet-img, #o-detail-outfits-img",
tolerance: "fit",
activeClass: 'o-stage-drop-zone',
hoverClass: 'o-stage-hover',
drop: function(ev,ui) {
$("#o-stage-item-popup .btn-close-stage-popup").click();
elem = ui.draggable.element;
if( $(elem).attr("title") == "item" )
{
// cant put more then 10 things on stage
if ( theStage.getItemCount() < 10 )
{
$("#o-my-closet-items li").each(function() {
if( $("span",this).eq(0).html() == $(elem).attr("name") )
{
addToYourOutfit($("span",this).eq(8).html() ,$(elem).attr("name"), -1, $("span",this).eq(2).html(),$("span",this).eq(5).html(), $("span",this).eq(4).html() );
addToStage($(elem).attr("name"),-1,$(elem).attr("alt"),0,0,$("span",this).eq(3).html().split(",")[3]);
}
});
}
else
{ alert("You cannot have more than 10 items in an Outfit"); }
}
else if( $(elem).attr("title") == "outfit" )
{
params = "outfitId=" + $(elem).attr("name");
loadOutfitAction(params);
doFireclick(1);
}
else
{ alert("unknown object dropped");}
//Destory Droppable after dropping obj
$("#o-the-stage").droppableDestroy();
}
});
};
/* -------------------------------- */
/* Function that fires if you drop an item on the stage */
/* ------------------------------------------- */
function addToStage(vId,itemId,name,x,y,image) {
z = stageZ.getFront();
$("#o-the-stage-loading").show();
name = fixHTMLtext(name);
newImage = '
';
$("#o-the-stage").append(newImage);
// re-add the events to stage.
setupOutfitterStageImages();
// update Z-index info
stageZ.addObjectZ(z);
// update stage variables
theStage.makeDirty();
// hide the "loading" div
$("#o-the-stage-loading").hide();
};
/* ---------------------------------------- */
/* Functions for -your outfit area- */
/* ---------------------------------------------------- */
function removeItemYourOutfit(id,vId) {
// 1. remove from "your Outfit list" via removing the row
$("#your-outfit-browse-table tr[@id=" + id + "][@name=" + vId + "]").eq(0).remove();
// 2. remove the item from stage via id and variant
$(".o-stage-image[@id=" + id + "][@name=" + vId + "]").eq(0).draggableDestroy();
$(".o-stage-image[@id=" + id + "][@name=" + vId + "]").eq(0).remove();
// 3. reset the first item to have class = first
$("td", $("#your-outfit-browse-table tr").eq(0)).addClass("first");
// reset nav
setupYourOutfitBrowse();
addYourOutfitTotals();
theStage.makeDirty();
theStage.removeItem();
};
function addToYourOutfit(pId, vId, itemId, price, name, inventory) {
newRow = "";
firstStyle = "";
inventoryString = " "
if ( inventory == "O" )
{ inventoryString = '
'; }
if( $("#your-outfit-browse-table tr").size() == 0 )
{ firstStyle = "first"; }
newRow = '' +
'| ' + name + ' | ' +
' | ' +
'$' + price +' | ' +
'' + inventoryString + ' | ' +
' | ' +
'
';
$("#your-outfit-browse-table table").append(newRow);
setupYourOutfitBrowse();
addYourOutfitTotals();
setupYourOutfitRemove();
};
function setupYourOutfitBrowse() {
//remove old events, add the events
$("#o-your-outfit-area .prev-btn").unbind("click").click( function() { yourOutfitBrowse('prev'); });
$("#o-your-outfit-area .next-btn").unbind("click").click( function() { yourOutfitBrowse('next'); });
//initial the table to top
if ( $.browser.safari)
{ $("#your-outfit-browse-table").css("margin-top", "-1px"); }
else
{ $("#your-outfit-browse-table").css("margin-top", "0px"); }
// setup default state
if( $("#o-your-outfit-area").height() >= $("#your-outfit-browse-table").height() )
{ $("#o-your-outfit-area img.next-btn").hide(); }
else
{ $("#o-your-outfit-area img.next-btn").show(); }
$("#o-your-outfit-area img.prev-btn").hide();
runningTotal = 0;
$("#your-outfit-browse-table tr").each(function(i) {
runningTotal = runningTotal + $("td", this).eq(0).height();
if( runningTotal <= outfitInfoHeight )
{ outfitInfoElCurrentE = i; }
});
outfitInfoElCurrentS = 0;
if( (outfitInfoElCurrentE + 1) == $("#your-outfit-browse-table tr").size() )
{ $("#o-your-outfit-area img.next-btn").hide(); }
//show the total if more then one item
if( $("#your-outfit-browse-table tr").size() > 0 )
{ $("#o-your-outfit-total").show(); }
else
{ $("#o-your-outfit-total").hide(); }
};
function yourOutfitBrowse(action) {
if(action == "prev")
{
outfitInfoElCurrentS--;
outfitInfoElCurrentE--;
topValue = parseInt( $("#your-outfit-browse-table").css("margin-top").split("px")[0] ) + outfitInfoPrevH;
outfitInfoPrevH = $("td", $("#your-outfit-browse-table tr").eq(outfitInfoElCurrentE)).eq(0).height() + 1;
$("#your-outfit-browse-table").css("margin-top", topValue + "px");
$("#o-your-outfit-area img.next-btn").show();
if( outfitInfoElCurrentS == 0 )
{ $("#o-your-outfit-area img.prev-btn").hide(); }
}
else if(action == "next")
{
outfitInfoElCurrentS++;
outfitInfoElCurrentE++;
outfitInfoPrevH = $("td", $("#your-outfit-browse-table tr").eq(outfitInfoElCurrentE)).eq(0).height() + 1;
topValue = parseInt( $("#your-outfit-browse-table").css("margin-top").split("px")[0] ) - outfitInfoPrevH;
$("#your-outfit-browse-table").css("margin-top", topValue + "px");
$("#o-your-outfit-area img.prev-btn").show();
if(outfitInfoElCurrentE == ( $("#your-outfit-browse-table tr").size() - 1) )
{ $("#o-your-outfit-area img.next-btn").hide(); }
}
else
{ alert("action value: " + action + " not defined"); }
};
function setupYourOutfitRemove() {
$(".o-your-outfit-remove").each(function() {
$(this).unbind("click").click( function() {
id = $(this).parent().parent().attr("id");
vId = $(this).parent().parent().attr("name");
removeItemYourOutfit(id,vId)
});
});
};
/* ------------------------------------------------- */
/* Funciton gets me absoulte position of something on the screen */
/* ------------------------- */
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
/* --------------------------- */
/* MESSAGING */
/* Function to control the menu navigation */
function setupMessageNav() {
$("#o-messages-left li").unbind("click").click(function() {
$("#o-messages-left li").removeClass("active");
$(this).addClass("active");
messagesNavAction();
});
$("#composeMessage").unbind("click").click(function() {
$("#o-messages-left li").removeClass("active");
composeMessageAction();
});
};
/* --------------------------- */
/* Function to control the pagnation */
oldTotalMessagePages = 0;
function resetMessagePages() {
oldTotalMessagePages = 0;
}
function setupMessagePagenation(cur,total,unreadItems,totalItems,type) {
// stuff to update left nav
if( type == "inbox" )
{ $("#o-messages-left #inbox").html("Inbox (" + unreadItems + " unread, " + totalItems +" total)"); }
else if( type == "blocked")
{ $("#o-messages-left #blocked").html("Blocked Users ("+ totalItems +")"); }
else if( type == "friends")
{ $("#o-messages-left #friends").html("My Friends ("+ totalItems +")"); }
// setup the dropdown box
if( total != oldTotalMessagePages )
{
oldTotalMessagePages = total;
for( x = 1; x <= total; x++)
{
newOption = '';
$(".o-message-pagnation select").append(newOption);
}
}
// next / previous pages
$(".o-message-pagnation span").each( function() {
$("img", this).unbind("click").each(function(i) {
$(this).click(function() {
if( $(this).attr("class") == "m-first" )
{ page = 1; }
else if( $(this).attr("class") == "m-prev" )
{ page = parseInt($("select", $(this).parent()).val()) - 1; }
else if( $(this).attr("class") == "m-next" )
{ page = parseInt($("select", $(this).parent()).val()) + 1; }
else if( $(this).attr("class") == "m-last" )
{ page = total; }
messagesPagnationAction(page);
});
});
});
// logic for next / prev
if( cur == 1 )
{
$(".m-prev").hide();
$(".m-first").hide();
}
else
{
$(".m-prev").show();
$(".m-first").show();
}
if( cur == total )
{
$(".m-next").hide();
$(".m-last").hide();
}
else
{
$(".m-next").show();
$(".m-last").show();
}
// select the current page in the dropdown.
$(".o-message-pagnation select option[@value=" + cur).attr("selected","true");
// change on select drop-down
$(".o-message-pagnation select").unbind("change").change(function() {
messagesPagnationAction($(this).val());
});
// change on selecting a different sort.
lastItem = $("#o-message-sort .sortable").size() - 1;
$("#o-message-sort .sortable").each(function(i) {
$(this).unbind("click").click( function() {
$("#o-message-sort").removeClass("o-message-sort-bg-last");
$("#o-message-sort").addClass("o-message-sort-bg-notlast");
$("#o-message-sort .sortable").each(function() { $(this).parent().attr("class","o-message-tbl-hdr-inactive") });
$(this).parent().attr("class","o-message-tbl-hdr-active");
messagesSort.changeFieldState( $(this).attr("id") );
messagesPagnationAction(1);
if( i == lastItem )
{
$("#o-message-sort").removeClass("o-message-sort-bg-notlast")
$("#o-message-sort").addClass("o-message-sort-bg-last");
}
});
});
// if not items then hide pagnation.
if( total == 0 )
{
$(".o-message-pagnation span").hide();
$(".o-message-pagnation #deleteMesssages").hide();
}
};
/* -------------------------------- */
/* function to setup message inbox / message actions */
function setupMessageInbox() {
// setup the view messages link
$(".aMessage").unbind("click").click(function() {
$("#o-messages-left li").removeClass("active");
viewMessageAction( $(this).attr("id") );
});
//setup the delete messages button
$("#deleteMesssages").unbind("click").click(function() {
messageIds = "";
$(".message-delete-checkbox[@checked]").each(function() {
messageIds = messageIds + $(this).attr("name") + ",";
});
if(messageIds == "")
{ $(".o-messages-main-page-error").html("Please select the message(s) you would like to delete."); }
else
{ messageActionOther("deleteMultipleMessages",messageIds); }
});
};
function setupUserList(type) {
//setup the delete selected button
$("#deleteMesssages").unbind("click").click(function() {
ids = "";
$(".message-delete-checkbox[@checked]").each(function() {
ids = ids + $(this).attr("name") + ",";
});
if(ids == "")
{
if(type == "friends")
{ $(".o-messages-main-page-error").html("Please select the friend(s) you would like to delete."); }
else
{ $(".o-messages-main-page-error").html("Please select the user(s) you would like to unblock."); }
}
else
{ deleteRelationshipAction(ids); }
});
};
function setupViewMessage(type) {
$(".o-message-details-actions").each(function() {
$("img",this).unbind("click").each(function(i) {
$(this).click(function() {
if( (i == 0) && (type != "banned")) // reply
{ messageActionOther("replyMessage", $(".o-message-details-actions").eq(0).attr("id")); }
else if(i == 1) // forward
{ messageActionOther("forwardMessage", $(".o-message-details-actions").eq(0).attr("id")); }
else // delete
{ messageActionOther("deleteMessage", $(".o-message-details-actions").eq(0).attr("id")); }
});
});
});
$("#friend-request-link").unbind("click").click(function() {
friendRequestAction(this);
});
$("#block-user-link").unbind("click").click(function() {
blockUserAction(this);
});
if( type == "banned" )
{ $(".o-message-details-actions img").eq(0).hide(); }
};
function backToInbox() {
resetMessagePages();
$("#o-messages-left li").eq(0).click();
};
function setupFriendSelector() {
// setup the friend selector functionality
$("#friend-selector-add").unbind("click").click(function() {
selectedValues = "";
$("#friend-selector option[@selected]").each(function() { selectedValues = selectedValues + "," + $(this).val(); });
if( $("#recipients").val() != "" )
{ $("#recipients").val($("#recipients").val() + "," + selectedValues.substring(1)); }
else
{ $("#recipients").val( selectedValues.substring(1) ); }
});
};
function setupMessageActions(pageId) {
$("#o-messages-send").unbind("click").click( function() { sendMessageAction(pageId); });
$("#o-messages-cancel").unbind("click").click( function() {
if( pageId == "composeMessage")
{ backToInbox(); }
else
{ viewMessageAction( $(this).attr("name") ); }
});
// if no friends don't show friend selector.
if( $("#friend-selector option").size() == 0 )
{ $("#o-messages-action-info-right").hide(); }
};
function setupMessageConfirmation() {
$("#o-message-back-to-inbox").unbind("click").click(function() { backToInbox(); });
};
/* ------------------------------ */
function shrinkPage() {
$("#o-action-buttons").hide();
$("#o-your-outfit-area").hide();
$("#o-tags-area").hide();
$("#outfitter-content-area").css("height","680px");
};
function unShrinkPage() {
$("#outfitter-content-area").css("height","828px");
$("#o-action-buttons").show();
$("#o-your-outfit-area").show();
$("#o-tags-area").show();
};
/* ---------------------------------------- */
function doFireclick(id) {
if(id == 1)
{
var params = new Object();
params.outfitter = "outfits";
my_fc_rpt(params, null);
}
};