Permalink
Browse files

settings forms are always shown;

  • Loading branch information...
1 parent 33a414f commit 41a43dc08cd257b968000386af9cf5eabe82dd97 Alex Kravets committed Jul 30, 2012
View
@@ -1 +1,2 @@
.DS_Store
+pkg
@@ -1,7 +1,3 @@
-<div class="value <%= setting.type %>">
- <%= setting.value %>
-</div>
-
<div class="form">
<%= semantic_form_for setting,
:method => :put,
@@ -21,9 +21,7 @@ def update
end
column "" do |s|
- link_to("Edit", "#", :class => "member_link edit_setting_link", "data-setting-id" => s.id) +
- link_to("Update", "#", :class => "member_link update_setting_link", "data-setting-id" => s.id) +
- link_to("Delete", admin_setting_path(s), :class => "member_link", :method => :delete, :confirm => "Are you sure?")
+ link_to("Update", "#", :class => "member_link update_setting_link", "data-setting-id" => s.id)
end
end
@@ -1,33 +1,31 @@
#= require jquery.form
$ ->
+ show_update_btn = (el) ->
+ $(el).closest('tr').find('.update_setting_link').show()
+
+ hide_update_btn = (el) ->
+ $(el).closest('tr').find('.update_setting_link').hide()
+
+ $('#settings .form form input, textarea').change ->
+ show_update_btn(this)
+
+ $('#settings .form form input, textarea').keypress ->
+ show_update_btn(this)
+
$('#settings .form form').submit ->
false
- $('.edit_setting_link').click (e) ->
- e.preventDefault()
- id = $(this).attr "data-setting-id"
- setting = $("#setting_#{id}")
- setting.find(".value").hide()
- setting.find(".form").show()
- setting.find(".update_setting_link").show()
- $(this).hide()
-
$('.update_setting_link').click (e) ->
e.preventDefault()
btn = $(this)
id = btn.attr "data-setting-id"
setting = $("#setting_#{id}")
- setting.find(".form").hide()
- # submit form, should use jquery form for file submissions
form = setting.find(".form form")
form.submit =>
form.ajaxSubmit
success: (value) =>
- setting.find('.value').html(value)
- setting.find(".value").show()
- setting.find(".edit_setting_link").show()
btn.hide()
false
form.submit()
@@ -4,11 +4,12 @@
.update_setting_link { display: none; }
tr td .form {
- display:none;
+ //display:none;
.label { display:none; }
.file .label { display:inline; }
.inputs { margin-bottom:0; }
input[type="text"], textarea { width:90%; }
+ textarea { height:100px; }
}
}

0 comments on commit 41a43dc

Please sign in to comment.