function updateOutfitLayerAction(action) { $("#o-outfit-save-popup *").remove(); // position and show popup $("#o-outfit-save-popup").vCenter(); $("#o-outfit-save-popup").css("left", (($("body").width() / 2) - ($("#o-outfit-save-popup").width() / 2) + "px")); $("#o-outfit-save-popup").show(); // show overlay overlayShow(); params = "action=" + action; if( action == "edit" ) { params = params + "&editOutfitId=" + editOutfitId; } updateHTML('updateOutfitLayer',params,'GET','#o-outfit-save-popup'); }; function loadOutfitAction(params) { if(!theStage.isDirty()) { // remove the ManageLayer, and make sure to show the tab that was closed $("#o-manage-view-back a").click(); // reset to non changed outfit theStage.makeClean(); // 1. Update the Stage with new Outfit $("#o-the-stage").droppableDestroy(); updateHTML('loadOutfitStage',params,'GET','#o-leftcolumn'); // 2. update the Outfit Information updateHTML('loadOutfitTags',params,'GET','#o-tags-area'); // 3. Update the Tag Information updateHTML('loadOutfitInfo',params,'GET','#o-your-outfit-area'); } else { confirmLoad(params); } }; function removeFromClosetAction(id,type) { $("#o-delete-loading").vCenter(); $("#o-delete-loading").show(); overlayShow(); if( type == "item" ) { params = "productVariantId=" + id + "&name=" + $("#o-detail-closet .o-detail-hdr-name").html(); updateHTML('removeItemFromCloset',params,'GET','#o-closet-other-area'); } else { if( theStage.getOutfitId() == id ) { confirmDelete(id,type); return true; } params = "outfitId=" + id + "&name=" + $("#o-detail-outfits .o-detail-hdr-name").html(); updateHTML('removeOutfitFromCloset',params,'GET','#o-closet-other-area'); } }; function confirmDelete(id,type) { if(confirm("This outfit is currently on the stage. To continue and delete this outfit Click OK")) { theStage.reset(); createNewOutfit(); removeFromClosetAction(id,type); } else { $("#o-delete-loading").hide(); overlayHide(); } }; function changeSortAction(sort,type) { params = "sortBy=" + sort; if( type == "item" ) { $("#o-my-closet").remove(); updateHTML('showCloset',params,'GET','#o-closet-other-area'); } else { $("#o-my-outfits").remove(); updateHTML('showOutfits',params,'GET','#o-closet-other-area'); } }; function confirmLoad(params) { if( confirm("Your Outfit has not been saved since the last update. Click OK to continue without saving.") ) { theStage.makeClean(); loadOutfitAction(params); } }; function confirmNew() { if( confirm("Your Outfit has not been saved since the last update. Click OK to continue without saving.") ) { theStage.makeClean(); createNewOutfit(); } }; function actionManageTable(params) { updateHTML('manageTable',params,'GET','#o-manage-outfit-table-container'); }; function pageUnload() { saveOutfitAction('N','N'); }; /* functions for publishing, saving, and updating outfits */ /* ------------------------------------------ */ function saveOutfitAction(toDB,pub) { var params = ""; //outfit name, and outfit Id if( (toDB == 'N') || (pub == 'Y') ) { tempName = $("#o-stage-outfit-name").html(); } else { tempName = $("input#input-OutfitName").val(); } tempName = tempName.replace(/\/g,">"); params = params + "outfitId=" + theStage.getOutfitId(); params = params + "&outfitName=" + tempName; // this need to be set dependingon where saving data to. params = params + "&commitToDb=" + toDB; // if we are doing set the publish flag params = params + "&publish=" + pub; // outfit tags var tagIds = new Array(); if( (toDB == 'N') || (pub == 'Y') ) { $("#o-tags-listing-container ul li").each(function(i) { tagIds[i] = $(this).attr("id"); }); } else { $("#save-outfit-tag-area input[@checked]").each(function(i) { tagIds[i] = $(this).val(); }); } // tags to params tagIds_string = "&tagIds="; for( x = 0; x < tagIds.length; x++) { tagIds_string = tagIds_string + tagIds[x] + ((x != (tagIds.length - 1)) ? "," : ""); } // get the outfit var z_index = new Array(); var x_position = new Array(); var y_position = new Array(); var item_id = new Array(); var variant_id = new Array(); $(".o-stage-image").each(function(i) { z_index[i] = $(this).css("z-index"); x_position[i] = $(this).css("left").split("px")[0]; y_position[i] = $(this).css("top").split("px")[0]; item_id[i] = $(this).attr("id"); variant_id[i] = $(this).attr("name"); }); // add the z_index params z_index_string = "&z_orders="; for( x = 0; x < z_index.length; x++) { z_index_string = z_index_string + z_index[x] + ((x != (z_index.length - 1)) ? "," : ""); } // add the x_position params x_position_string = "&x_positions="; for( x = 0; x < x_position.length; x++) { x_position_string = x_position_string + x_position[x] + ((x != (x_position.length - 1)) ? "," : ""); } // add the y_position params y_position_string = "&y_positions="; for( x = 0; x < y_position.length; x++) { y_position_string = y_position_string + y_position[x] + ((x != (y_position.length - 1)) ? "," : ""); } // add the item_id params item_id_string = "&outfitItemIds="; for( x = 0; x < item_id.length; x++) { item_id_string = item_id_string + item_id[x] + ((x != (item_id.length - 1)) ? "," : ""); } // add the variant_id params variant_id_string = "&variantIds="; for( x = 0; x < item_id.length; x++) { variant_id_string = variant_id_string + variant_id[x] + ((x != (variant_id.length - 1)) ? "," : ""); } params = params + tagIds_string + z_index_string + x_position_string + y_position_string + item_id_string + variant_id_string; // remove old dropable events and add stage back $("#o-the-stage").droppableDestroy(); if( pub == 'Y') { updateHTML('publishOutfit',params,'GET','#o-results-popup-content'); } else { updateHTML('saveOutfit',params,'GET','#o-outfit-save-popup'); } }; function updateOutfitAction(toDB) { var params = ""; //outfit name, and outfit Id params = params + "outfitId=" + $("#o-detail-outfits-img").attr("name"); params = params + "&outfitName=" + $("input#input-OutfitName").val(); // this need to be set dependingon where saving data to. params = params + "&commitToDb=" + toDB; // outfit tags var tagIds = new Array(); $("#save-outfit-tag-area input[@type=checkbox][@checked]").each(function(i) { tagIds[i] = $(this).val(); }); // tags to params tagIds_string = "&tagIds="; for( x = 0; x < tagIds.length; x++) { tagIds_string = tagIds_string + tagIds[x] + ((x != (tagIds.length - 1)) ? "," : ""); } params = params + tagIds_string; updateHTML('updateOutfit',params,'GET','#o-outfit-save-popup'); }; /* -------------------------------------------- */ /* Functions for processing results of save, edit, publish */ /* ------------------------------------ */ function publishResultsAction(publishedCount) { // close the loading popup $("#o-publish-loading").hide(); // reset the outfit to clean because just got saved. theStage.makeClean(); // 1. Update the published Count $("#o-pub-outfit-count").html(publishedCount); // 2. Reload the outfits tab so that new info available for detail view outfitterTabs.tabRemove("tabOutfits"); outfitterTabs.showTab(outfitterTabs.getCurrentTab()) // 3. Add confirmation message. addMessageResultsPopup(); }; function saveResultsAction(outfitId) { // close the save layer $("#update-progress-layer").hide(); // reset the outfit because we just saved theStage.makeClean(); // check for redirect if(theStage.needRedirect()) { outfitId = theStage.getRedirectId(); if( theStage.getRedirectId() == -1 ) { createNewOutfit(); addMessageResultsPopup(); updateLayerClose(); theStage.redirectOff(); return; } } theStage.redirectOff(); // 1. Start reloading area with correct outfitId loadOutfitAction("outfitId=" + outfitId); // 2. Reload the outfits tab so that new info available for detail view outfitterTabs.tabRemove("tabOutfits"); outfitterTabs.showTab(outfitterTabs.getCurrentTab()) // 3. Add Results message if successful addMessageResultsPopup(); // 4. close the layer updateLayerClose(); }; function updateResultsAction() { // close the save layer $("#update-progress-layer").hide(); // 1. Reload the outfits tab so that new info available for detail view outfitterTabs.tabRemove("tabOutfits"); outfitterTabs.showTab(outfitterTabs.getCurrentTab()) // 2. Add the results message if successful addMessageResultsPopup(); // 2. Close the popup updateLayerClose(); }; /* ----------------------------------------------- */ /* functions to add outfits and items to basket */ /* ------------------------------------------- */ function addItemsToBasketAction(params) { // params should equal comma seperated list of product variants params = "variantIds=" + params; window.location = commands.get("addOutfitItemsToCart") + "?" + params; }; function addOutfitToBasketAction(params) { // params should be outfitId params = "outfitId=" + params; window.location = commands.get("addOutfitItemsToCart") + "?" + params; }; /* --------------------------------------- */ /* MESSAGES */ function updateMessageLeftNavAction() { params = "&noactivate=1"; updateHTML('updateMessageleftnav',params,'GET','#o-messages-left'); }; function messagesNavAction(name) { resetMessagePages(); params = "page=" + $("#o-messages-left li[class=active]").attr("id"); updateHTML('showMessagesFromNav',params,'GET','#o-messages-right'); }; function messagesPagnationAction(pageNo) { params = "page=" + $("#o-messages-left li[class=active]").attr("id"); params = params + "&pageNo=" + pageNo + "&sortValue=" + messagesSort.getActiveField() + "&sortToggle=" + messagesSort.getFieldState(messagesSort.getActiveField()); updateHTML('updateMessagesPagable',params,'GET','#o-messages-pagable'); $(".o-message-pagnation select").val(pageNo); }; function viewMessageAction(id) { params = "messageId=" + id + "&pageId=viewMessage"; updateHTML('messageAction',params,'GET','#o-messages-right'); }; function composeMessageAction() { params = "pageId=composeMessage"; updateHTML('messageAction',params,'GET','#o-messages-right'); }; function messageActionOther(type,messageId) { params = "pageId=" + type +"&messageId=" + messageId; if( type == "deleteMessage") { updateHTML('deleteMessage',params,'GET','#o-messages-right'); } else if( type == "deleteMultipleMessages") { pageNo = $(".o-message-pagnation select").eq(0).val(); params = "page=" + $("#o-messages-left li[class=active]").attr("id"); params = params + "&pageNo=" + pageNo + "&sortValue=" + messagesSort.getActiveField() + "&sortToggle=" + messagesSort.getFieldState(messagesSort.getActiveField()) + "&messageIds=" + messageId; updateHTML('deleteMultipleMessages',params,'GET','#o-messages-pagable'); } else { updateHTML('messageAction',params,'GET','#o-messages-right'); } }; function sendMessageAction(type) { params = "pageId=" + type + "&recipients=" + $("#recipients").val() + "&subject=" + $("#subject").val() + "&message=" + $("#message").val() + "&userId=" + $("#userId").val(); updateHTML('sendMessage',params,'POST','#o-messages-right'); }; function friendRequestAction(obj) { params = "screenName=" + $(obj).attr("name").split("#")[0] + "&userId=" + $(obj).attr("name").split("#")[1] + "&pageId=" + $(obj).attr("name").split("#")[2] + "&messageId=" + $(obj).attr("name").split("#")[3]; updateHTML('friendRequest',params,'POST','#o-messages-right'); }; function blockUserAction(obj) { params = "screenName=" + $(obj).attr("name").split("#")[0] + "&userId=" + $(obj).attr("name").split("#")[1] + "&pageId=" + $(obj).attr("name").split("#")[2] + "&messageId=" + $(obj).attr("name").split("#")[3]; updateHTML('blockUser',params,'POST','#o-messages-right'); }; function deleteRelationshipAction(ids) { pageNo = $(".o-message-pagnation select").eq(0).val(); params = "page=" + $("#o-messages-left li[class=active]").attr("id"); params = params + "&pageNo=" + pageNo + "&sortValue=" + messagesSort.getActiveField() + "&sortToggle=" + messagesSort.getFieldState(messagesSort.getActiveField()) + "&relationshipIds=" + ids; updateHTML('deleteRelationship',params,'POST','#o-messages-pagable'); }; /* ------------------ */