lib/sugar/actionview.rb in krasivotokak-sugar-0.0.10 vs lib/sugar/actionview.rb in krasivotokak-sugar-0.0.11
- old
+ new
@@ -76,20 +76,20 @@
end
def button_to_delete(something)
button_to(t('.delete'),
polymorphic_path(something),
- :class => 'ajax delete',
+ :class => 'delete',
:method => :delete,
:confirm => t('sure'))
end
def image_button_to_delete(something)
image_to('icons/delete.png',
t('.delete'),
polymorphic_path(something),
- :class => 'ajax delete',
+ :class => 'delete',
:method => :delete,
:confirm => t('sure'))
end
def link_to_delete(something)
@@ -98,7 +98,24 @@
:title => t('.delete')),
polymorphic_path(something),
:class => 'ajax delete')
end
end
+
+ def default_new_link_options
+ @default_new_link_options ||= {
+ :image => 'icons/add.png',
+ :alt => t('.add'),
+ :title => t('.add')
+ }
+ end
+
+ def link_to_new(options = {})
+ options = default_new_link_options.merge(options || {})
+ url = options.has_key?(:url) ? options.delete(:url) : {:action => 'new'}
+ link_to(image_tag(options.delete(:image),
+ options),
+ url)
+ end
+
end