pretty inline outfit form live

This commit is contained in:
Emi Matchu 2011-02-09 19:29:31 -05:00
parent fd5663c9e8
commit d1daa6b772
2 changed files with 19 additions and 35 deletions

View file

@ -14,14 +14,14 @@
%form#pet-state-form %form#pet-state-form
Gender/Emotions: Gender/Emotions:
%ul %ul
#save-outfit-wrapper.saving-outfit #save-outfit-wrapper
%button#save-outfit Save outfit %button#save-outfit Save outfit
%button#save-outfit-not-signed-in Log in to save outfit %button#save-outfit-not-signed-in Log in to save outfit
%button#save-current-outfit Save &quot;<span>current outfit</span>&quot; %button#save-current-outfit Save &quot;<span>current outfit</span>&quot;
%button#save-outfit-copy Save a copy %button#save-outfit-copy Save a copy
%form#save-outfit-form %form#save-outfit-form
.outfit-star .outfit-star
%input#new-outfit-name{:type => 'text', :placeholder => 'Outfit name'} %input#save-outfit-name{:type => 'text', :placeholder => 'Outfit name'}
%button#save-outfit-finish{:type => 'submit'} Save %button#save-outfit-finish{:type => 'submit'} Save
%button#save-outfit-cancel{:type => 'button'} Cancel %button#save-outfit-cancel{:type => 'button'} Cancel
#preview #preview

View file

@ -8,18 +8,6 @@
}); });
})(); })();
(function () {
var controlOverlay = $('<div/>', {'class': 'control-overlay'});
$.fn.disableControl = function () {
this.prepend(controlOverlay.clone()).stop().fadeTo('slow', .35);
}
$.fn.enableControl = function () {
this.stop().fadeTo('fast', 1).children('div.control-overlay').remove();
}
})();
$.fn.notify = function () { $.fn.notify = function () {
this.stop(true, true).show('slow').delay(5000).hide('fast'); this.stop(true, true).show('slow').delay(5000).hide('fast');
} }
@ -456,9 +444,8 @@ View.Hash = function (wardrobe) {
View.Outfits = function (wardrobe) { View.Outfits = function (wardrobe) {
var controls = $('#pet-type-form, #pet-state-form, #preview-swf, #preview-search-form'), var controls = $('#pet-type-form, #pet-state-form, #preview-swf, #preview-search-form'),
new_outfit_el = $('#new-outfit'), new_outfit_form_el = $('#save-outfit-form'),
new_outfit_form_el = $('#new-outfit-form'), new_outfit_name_el = $('#save-outfit-name'),
new_outfit_name_el = $('#new-outfit-name'),
outfits_el = $('#preview-outfits'), outfits_el = $('#preview-outfits'),
outfits_list_el = outfits_el.children('ul'), outfits_list_el = outfits_el.children('ul'),
outfit_not_found_el = $('#outfit-not-found'), outfit_not_found_el = $('#outfit-not-found'),
@ -501,37 +488,32 @@ View.Outfits = function (wardrobe) {
/* Nav */ /* Nav */
function showCloset() { function showCloset() {
controls.enableControl('fast');
navigateTo(''); navigateTo('');
} }
function showOutfits() { function showOutfits() {
wardrobe.user.loadOutfits(); wardrobe.user.loadOutfits();
controls.enableControl('fast');
navigateTo('viewing-outfits'); navigateTo('viewing-outfits');
} }
function showSavingOutfit() { function showNewOutfitForm() {
controls.disableControl('slow'); new_outfit_name_el.val('');
navigateTo('viewing-saving-outfit'); new_outfit_form_el.removeClass('starred').stopLoading();
save_outfit_wrapper_el.addClass('saving-outfit');
new_outfit_name_el.focus(); new_outfit_name_el.focus();
} }
function hideNewOutfitForm() {
save_outfit_wrapper_el.removeClass('saving-outfit');
}
$('#preview-sidebar-nav-outfits').click(navLinkTo(showOutfits)); $('#preview-sidebar-nav-outfits').click(navLinkTo(showOutfits));
$('#preview-sidebar-nav-closet').click(navLinkTo(showCloset)); $('#preview-sidebar-nav-closet').click(navLinkTo(showCloset));
$('#preview-sidebar-nav-cancel-save').click(function (e) { $('#save-outfit, #save-outfit-copy').click(showNewOutfitForm);
e.preventDefault();
controls.enableControl('fast');
sidebar_el.attr('class', previously_viewing);
});
$('#save-outfit, #save-outfit-copy').click(function () { $('#save-outfit-cancel').click(hideNewOutfitForm);
new_outfit_name_el.val('');
new_outfit_el.removeClass('starred').show();
showSavingOutfit();
});
$('#save-outfit-not-signed-in').click(function () { $('#save-outfit-not-signed-in').click(function () {
window.location.replace($('#userbar a').attr('href')); window.location.replace($('#userbar a').attr('href'));
@ -653,11 +635,12 @@ View.Outfits = function (wardrobe) {
new_outfit_form_el.submit(function (e) { new_outfit_form_el.submit(function (e) {
e.preventDefault(); e.preventDefault();
wardrobe.outfit.create({starred: new_outfit_el.hasClass('starred'), name: new_outfit_name_el.val()}); new_outfit_form_el.outfitLoading();
wardrobe.outfit.create({starred: new_outfit_form_el.hasClass('starred'), name: new_outfit_name_el.val()});
}); });
new_outfit_el.find('div.outfit-star').click(function () { new_outfit_form_el.find('div.outfit-star').click(function () {
new_outfit_el.toggleClass('starred'); new_outfit_form_el.toggleClass('starred');
}); });
var SAVE_ERRORS = { var SAVE_ERRORS = {
@ -678,6 +661,7 @@ View.Outfits = function (wardrobe) {
wardrobe.outfit.bind('createSuccess', function (outfit) { wardrobe.outfit.bind('createSuccess', function (outfit) {
wardrobe.user.addOutfit(outfit); wardrobe.user.addOutfit(outfit);
showOutfits(); showOutfits();
hideNewOutfitForm();
}); });
wardrobe.outfit.bind('updateSuccess', function (outfit) { wardrobe.outfit.bind('updateSuccess', function (outfit) {