tracks/app/views/contexts/edit.js.erb
2014-08-13 15:33:32 +02:00

25 lines
No EOL
764 B
Text

<%- object_name = unique_object_name_for("edit_context_#{@context.id}") %>
var <%=object_name%> = {
animate: function() {
<%=object_name%>.replace_context_with_edit_form();
},
replace_context_with_edit_form: function() {
$('div#<%=dom_id(@context)%>').fadeOut(250, function() {
<%=object_name%>.show_edit_form();
<%=object_name%>.set_focus();
});
},
show_edit_form: function() {
$('div#<%=dom_id(@context, 'edit')%>').html(<%=object_name%>.html_for_edit_form());
$('div#<%=dom_id(@context, 'edit')%>').fadeIn(500);
},
set_focus: function() {
$('input.context-name').focus();
},
html_for_edit_form: function() {
return "<%= js_render('context_form', {}, @context) %>";
}
};
<%= object_name %>.animate();