Module: SecretSauce::Helpers::UiFormHelper
- Defined in:
- lib/jquery/secret_sauce/helpers/ui_form_helper.rb
Defined Under Namespace
Classes: UiFormBuilder
Instance Method Summary collapse
- #error_messages_for(*params) ⇒ Object
-
#ui_button_pane(&block) ⇒ Object
render a button pane.
-
#ui_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
builds a form within a ui_static_dialog using UiFormBuilder in this case we are using a custom version of form_for instead of the original to wrap jquery-ui components inside of the form.
-
#ui_static_dialog(options = {}, &block) ⇒ Object
renders a jquery-ui templated static dialog box (cannot be resized or moved, appears on base z-index) to be used for things like forms.
-
#ui_static_dialog_tags(options = {}) ⇒ Object
flat tags for static dialog.
-
#ui_submit_tag(value = "Save changes", options = {}) ⇒ Object
render a submit tag themed with jquery ui.
Instance Method Details
#error_messages_for(*params) ⇒ Object
111 112 113 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 111 def (*params) render :partial => "shared/ui_form_error_messages", :locals => {:messages => super(*params)} end |
#ui_button_pane(&block) ⇒ Object
render a button pane
94 95 96 97 98 99 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 94 def (&block) body = capture(&block) concat("<div class='ui-dialog-buttonpane ui-widget-content ui-helper-clearfix'>") body concat("</div>") end |
#ui_form_for(record_or_name_or_array, *args, &proc) ⇒ Object
builds a form within a ui_static_dialog using UiFormBuilder in this case we are using a custom version of form_for instead of the original to wrap jquery-ui components inside of the form
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 47 def ui_form_for(record_or_name_or_array, *args, &proc) raise ArgumentError, "Missing block" unless block_given? if params[:layout] == "dialog" return form_for(record_or_name_or_array, *args, &proc) else = args. [:builder] = UiFormBuilder if ![:submit] [:submit] = {:value => "Save Changes", :options => {}} else [:submit][:value] = "Save Changes" if ![:submit][:value] [:submit][:options] = {} if ![:submit][:options] end case record_or_name_or_array when String, Symbol object_name = record_or_name_or_array when Array object = record_or_name_or_array.last object_name = ActionController::RecordIdentifier.singular_class_name(object) (record_or_name_or_array, ) args.unshift object else object = record_or_name_or_array object_name = ActionController::RecordIdentifier.singular_class_name(object) ([object], ) args.unshift object end concat("<div id='#{object_name}_form_container'>") concat(form_tag(.delete(:url) || {}, .delete(:html) || {})) concat(([:dialog_options])) fields_for(object_name, *(args << ), &proc) concat(%Q{ </div> <div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"> #{ui_submit_tag(@ui_form_submit[0], @ui_form_submit[1]) if @ui_form_submit} </div> </div> </div> </form> </div>}) end end |
#ui_static_dialog(options = {}, &block) ⇒ Object
renders a jquery-ui templated static dialog box (cannot be resized or moved, appears on base z-index) to be used for things like forms
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 19 def ui_static_dialog(={}, &block) body = capture(&block) concat(()) body concat(%q{ </div> </div> </div> }) end |
#ui_static_dialog_tags(options = {}) ⇒ Object
flat tags for static dialog
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 31 def (={}) [:width] = 100 unless [:width] [:height] = 100 unless [:height] [:title] = "Dialog" unless [:title] [:parent] = '' unless [:parent] [:style] = "width: #{[:width]}px;" if [:center] [:parent] = "width: 100%;" [:style] << " margin-left: auto; margin-right: auto;" end render :partial => 'shared/ui_static_dialog', :locals => end |
#ui_submit_tag(value = "Save changes", options = {}) ⇒ Object
render a submit tag themed with jquery ui
102 103 104 105 106 107 108 109 |
# File 'lib/jquery/secret_sauce/helpers/ui_form_helper.rb', line 102 def ui_submit_tag(value = "Save changes", = {}) if [:class] [:class] << " ui-state-default ui-corner-all" else [:class] = "ui-state-default ui-corner-all" end submit_tag(value, ) end |