Module: ActionView::Helpers::JavaScriptMacrosHelper
- Defined in:
- lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb
Instance Method Summary collapse
- #active_scaffold_in_place_editor_js(field_id, options = {}) ⇒ Object
-
#active_scaffold_inplace_edit_2(record, column, options = {}) ⇒ Object
Allow in_place_editor to pass along nested information so the update_column can call refresh_record properly.
- #check_for_choices(options) ⇒ Object
- #field_for_inplace_editing(record, options, column) ⇒ Object
- #form_for_inplace_display(record, column, id_string, in_place_editor_options, options) ⇒ Object
- #format_inplace_edit_column(record, column) ⇒ Object
- #html_for_inplace_display(display_text, id_string, in_place_editor_options) ⇒ Object
-
#in_place_editor(field_id, options = {}) ⇒ Object
Fix html_escape issues with url_for.
Instance Method Details
#active_scaffold_in_place_editor_js(field_id, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 40 def active_scaffold_in_place_editor_js(field_id, = {}) function = "new Ajax.InPlaceEditor(" function << "'#{field_id}', " function << "'#{url_for(options[:url])}'" = {} ['cancelText'] = %('#{options[:cancel_text]}') if [:cancel_text] ['okText'] = %('#{options[:save_text]}') if [:save_text] ['loadingText'] = %('#{options[:loading_text]}') if [:loading_text] ['savingText'] = %('#{options[:saving_text]}') if [:saving_text] ['rows'] = [:rows] if [:rows] ['htmlResponse'] = [:html_response] if .has_key?(:html_response) ['cols'] = [:cols] if [:cols] ['size'] = [:size] if [:size] ['externalControl'] = "'#{options[:external_control]}'" if [:external_control] ['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if [:load_text_url] ['ajaxOptions'] = [:options] if [:options] ['evalScripts'] = [:script] if [:script] ['callback'] = "function(form) { return #{options[:with]} }" if [:with] ['clickToEditText'] = %('#{options[:click_to_edit_text]}') if [:click_to_edit_text] function << (', ' + ()) unless .empty? function << ')' javascript_tag(function) end |
#active_scaffold_inplace_edit_2(record, column, options = {}) ⇒ Object
Allow in_place_editor to pass along nested information so the update_column can call refresh_record properly.
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 84 def active_scaffold_inplace_edit_2(record, column, = {}) formatted_column = [:formatted_column] || format_inplace_edit_column(record, column) = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s} = {:tag => "span", :id => element_cell_id(), :class => "in_place_editor_field"} = {:url => {:controller => params_for[:controller], :action => "update_column", :eid => params[:eid], :parent_model => params[:parent_model], :column => column.name, :id => record.id.to_s}, :click_to_edit_text => as_(:click_to_edit), :cancel_text => as_(:cancel), :loading_text => as_(:loading), :save_text => as_(:update), :saving_text => as_(:saving), :script => true}.merge(column.) html = html_for_inplace_display(formatted_column, [:id], ) html << form_for_inplace_display(record, column, [:id], , ) end |
#check_for_choices(options) ⇒ Object
99 100 101 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 99 def check_for_choices() raise ArgumentError, "Missing choices for select! Specify options[:choices] for in_place_select" if [:choices].nil? end |
#field_for_inplace_editing(record, options, column) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 134 def field_for_inplace_editing(record, , column) input_type = column.list_ui [:class] = "inplace_#{input_type}" htm_opts = {:class => [:class] } case input_type when :textarea text_area_tag('value', record.send(column.name), ) when :select select_tag('value', (.delete(:choices), record.send(column.name)), .merge(htm_opts)) # when :date_select # calendar_date_select( :record, column.name, options) else text_field_tag('value', record.send(column.name), ) end end |
#form_for_inplace_display(record, column, id_string, in_place_editor_options, options) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 112 def form_for_inplace_display(record, column, id_string, , ) retval = "" [:url] ||= {} [:url][:action] ||= "set_record_#{column.name}" [:url][:id] ||= record.id = [:saving_text] || as_(:saving_) retval << form_remote_tag(:url => [:url], :method => [:http_method] || :post, :loading => "$('#{id_string}_form').hide(); $('loader_#{id_string}').show();", :complete => "$('loader_#{id_string}').hide();", :html => {:class => "in_place_editor_form", :id => "#{id_string}_form", :style => "display:none" } ) retval << field_for_inplace_editing(record, , column ) retval << content_tag(:br) if [:br] retval << submit_tag(as_(:ok), :class => "inplace_submit") retval << link_to_function( "Cancel", "$('#{id_string}_form').hide();$('#{id_string}').show() ", {:class => "inplace_cancel" }) retval << "</form>" # #FIXME 2008-01-14 (EJM) Level=0 - Use AS's spinner # retval << invisible_loader( loader_message, "loader_#{id_string}", "inplace_loader") retval << content_tag(:br) end |
#format_inplace_edit_column(record, column) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 31 def format_inplace_edit_column(record,column) value = record.send(column.name) if column.list_ui == :checkbox active_scaffold_column_checkbox(column, record) else clean_column_value(format_value(value)) end end |
#html_for_inplace_display(display_text, id_string, in_place_editor_options) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 103 def html_for_inplace_display(display_text, id_string, ) content_tag(:span, display_text, :onclick => "Element.hide(this);$('#{id_string}_form').show();", :onmouseover => visual_effect(:highlight, id_string), :title => [:click_to_edit_text], :id => id_string, :class => "inplace_span") end |
#in_place_editor(field_id, options = {}) ⇒ Object
Fix html_escape issues with url_for.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/lib/extensions/java_script_macros_helper.rb', line 5 def in_place_editor(field_id, = {}) function = "new Ajax.InPlaceEditor(" function << "'#{field_id}', " function << "'#{url_for(options[:url])}'".gsub("&", "&") = {} ['cancelText'] = %('#{options[:cancel_text]}') if [:cancel_text] ['okText'] = %('#{options[:save_text]}') if [:save_text] ['loadingText'] = %('#{options[:loading_text]}') if [:loading_text] ['savingText'] = %('#{options[:saving_text]}') if [:saving_text] ['rows'] = [:rows] if [:rows] ['cols'] = [:cols] if [:cols] ['size'] = [:size] if [:size] ['externalControl'] = "'#{options[:external_control]}'" if [:external_control] ['loadTextURL'] = "'#{url_for(options[:load_text_url])}'" if [:load_text_url] ['ajaxOptions'] = [:options] if [:options] ['evalScripts'] = [:script] if [:script] ['callback'] = "function(form) { return #{options[:with]} }" if [:with] ['clickToEditText'] = %('#{options[:click_to_edit_text]}') if [:click_to_edit_text] function << (', ' + ()) unless .empty? function << ')' javascript_tag(function) end |