if @opportunity.valid? page[:create_opportunity_arrow].replace_html "►" page[:create_opportunity_title].replace_html t(:opportunities) page.visual_effect :toggle_blind, :create_opportunity, :duration => 0.3, :afterFinish => 'function(effect) {effect.element.update("")}' page.insert_html :top, :opportunities, :partial => "opportunity", :collection => [ @opportunity ] page[dom_id(@opportunity)].visual_effect :highlight, :duration => 1.5 if called_from_index_page? page << refresh_sidebar(:index, :filters) page[:paginate].replace_html :partial => "shared/paginate" elsif called_from_landing_page?("accounts") # Opportunity created on Account landing page: refresh Account summary. @account.reload page << refresh_sidebar_for(:accounts, :show, :summary) elsif called_from_landing_page?("campaigns") # Opportunity created on Campaign landing page: refresh Campaign summary. @campaign.reload page << refresh_sidebar_for(:campaigns, :show, :summary) else # Opportunity created on Contact landing page: refresh recent items list. page[:recently].replace :partial => "shared/recently" end page.call "crm.flick", :empty, :remove else page[:create_opportunity].replace_html :partial => "new" page.call "crm.init_chosen_fields" page.call "crm.create_or_select_account", request.referer =~ /\/accounts\// || @account.id.blank? page.call "crm.date_select_popup", "opportunity_closes_on" hook(:new_opportunity_rjs, self, :page => page) page[:create_opportunity].visual_effect :shake, :duration => 0.25, :distance => 6 page[:opportunity_name].focus end