Skip to content

Commit

Permalink
Removed dependence on prototype_legacy_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Tillman committed Nov 29, 2011
1 parent 5bc0ec8 commit ab7f936
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 795 deletions.
9 changes: 5 additions & 4 deletions app/helpers/admin/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ def link_to_confirm(user)

#----------------------------------------------------------------------------
def link_to_delete(user)
link_to_remote(t(:yes_button),
:method => :delete,
:url => admin_user_path(user),
:before => visual_effect(:highlight, dom_id(user), :startcolor => "#ffe4e1")
link_to(t(:yes_button),
admin_user_path(user),
:method => :delete,
:remote => true,
:onclick => visual_effect(:highlight, dom_id(user), :startcolor => "#ffe4e1")
)
end

Expand Down
60 changes: 31 additions & 29 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def tabs(tabs = nil)
if tabs
@current_tab ||= tabs.first[:text] # Select first tab by default.
tabs.each { |tab| tab[:active] = (@current_tab == tab[:text] || @current_tab == tab[:url][:controller]) }
else
else
raise FatFreeCRM::MissingSettings, "Tab settings are missing, please run <b>rake crm:setup</b> command."
end
end
Expand All @@ -48,9 +48,10 @@ def show_flash(options = { :sticky => false })
#----------------------------------------------------------------------------
def subtitle(id, hidden = true, text = id.to_s.split("_").last.capitalize)
content_tag("div",
link_to_remote("<small>#{ hidden ? "&#9658;" : "&#9660;" }</small> #{text}".html_safe,
:url => url_for(:controller => :home, :action => :toggle, :id => id),
:before => "crm.flip_subtitle(this)"
link_to("<small>#{ hidden ? "&#9658;" : "&#9660;" }</small> #{text}".html_safe,
url_for(:controller => :home, :action => :toggle, :id => id),
:remote => true,
:onclick => "crm.flip_subtitle(this)"
), :class => "subtitle")
end

Expand Down Expand Up @@ -93,12 +94,12 @@ def rating_select(name, options = {})
def link_to_inline(id, url, options = {})
text = options[:text] || t(id, :default => id.to_s.titleize)
text = (arrow_for(id) + text) unless options[:plain]
related = (options[:related] ? "+'&related=#{options[:related]}'" : '')
related = (options[:related] ? "&related=#{options[:related]}" : '')

link_to_remote(text,
:url => url,
:method => :get,
:with => "'cancel='+Element.visible('#{id}')#{related}"
link_to(text,
url +'?cancel=false'+ related,
:remote => true,
:onclick => "this.href = this.href.replace(/cancel=(true|false)/,'cancel='+ Element.visible('#{id}'));"
)
end

Expand All @@ -110,20 +111,21 @@ def arrow_for(id)
#----------------------------------------------------------------------------
def link_to_edit(model, params = {})
name = model.class.name.underscore.downcase
link_to_remote(t(:edit),
:url => params[:url] || send(:"edit_#{name}_path", model),
:method => :get,
:with => "'previous='+crm.find_form('edit_#{name}')"
link_to(t(:edit),
params[:url] || send(:"edit_#{name}_path", model),
:remote => true,
:onclick => "this.href += '?previous='+ crm.find_form('edit_#{name}');"
)
end

#----------------------------------------------------------------------------
def link_to_delete(model, params = {})
name = model.class.name.underscore.downcase
link_to_remote(t(:delete) + "!",
:url => params[:url] || url_for(model),
link_to(t(:delete) + "!",
params[:url] || url_for(model),
:method => :delete,
:before => visual_effect(:highlight, dom_id(model), :startcolor => "#ffe4e1")
:remote => true,
:onclick => visual_effect(:highlight, dom_id(model), :startcolor => "#ffe4e1")
)
end

Expand All @@ -133,30 +135,30 @@ def link_to_discard(model)
current_url = (request.xhr? ? request.referer : request.fullpath)
parent, parent_id = current_url.scan(%r|/(\w+)/(\d+)|).flatten

link_to_remote(t(:discard),
:url => url_for(:controller => parent, :action => :discard, :id => parent_id),
:method => :post,
:with => "'attachment=#{model.class.name}&attachment_id=#{model.id}'",
:before => visual_effect(:highlight, dom_id(model), :startcolor => "#ffe4e1")
link_to(t(:discard),
url_for(:controller => parent, :action => :discard, :id => parent_id, :attachment => model.class.name, :attachment_id => model.id),
:method => :post,
:remote => true,
:onclick => visual_effect(:highlight, dom_id(model), :startcolor => "#ffe4e1")
)
end

#----------------------------------------------------------------------------
def link_to_cancel(url, params = {})
link_to_remote(t(:cancel),
:url => params[:url] || url,
:method => :get,
:with => "'cancel=true'"
link_to(t(:cancel),
(params[:url] || url) + '?cancel=true',
:remote => true
)
end

#----------------------------------------------------------------------------
def link_to_close(url)
content_tag("div", "x",
:class => "close", :title => t(:close_form),
content_tag(:div,
link_to("x", url + '?cancel=true', :remote => true),
:class => "close",
:title => t(:close_form),
:onmouseover => "this.style.background='lightsalmon'",
:onmouseout => "this.style.background='lightblue'",
:onclick => remote_function(:url => url, :method => :get, :with => "'cancel=true'")
:onmouseout => "this.style.background='lightblue'"
)
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/comments/_edit.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
%div{:style => "padding:6px 0px 0px 40px;"}
= f.submit t(:save_note)
#{t :or}
= link_to_remote(t(:cancel), :url => edit_comment_path("#{class_name}_id" => commentable), :method => :get, :with => "'cancel=true'")
= link_to(t(:cancel), edit_comment_path("#{class_name}_id" => commentable) + '?cancel=true', :remote => true)
2 changes: 1 addition & 1 deletion app/views/comments/_new.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
%div{:style => "padding:6px 0px 0px 40px;"}
= f.submit t(:add_note), :id => "#{id_prefix}_comment_submit"
#{t :or}
= link_to_remote(t(:cancel), :url => new_comment_path("#{class_name}_id" => commentable), :method => :get, :with => "'cancel=true'")
= link_to(t(:cancel), new_comment_path("#{class_name}_id" => commentable) + '?cancel=true', :remote => true)
%div{ {:id => "#{id_prefix}_ask"}.merge(hidden_if(false))}
= text_field_tag :post_new_note, t(:add_note_help), :onclick => remote_function(:url => new_comment_path("#{class_name}_id" => commentable), :method => :get), :id => "#{id_prefix}_post_new_note"

2 changes: 1 addition & 1 deletion app/views/users/_avatar.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
%small.cool{:style => "float:right"}== #{t :gravatar_help} #{link_to(t(:here), "http://en.gravatar.com", :"data-popup" => true)}.
= f.submit t(:upload_picture), :onclick => "this.disabled = true"
#{t :or}
= link_to_remote(t(:use_gravatar), :url => upload_avatar_user_path(@user), :method => :put, :with => "'gravatar=1'")
= link_to(t(:use_gravatar), upload_avatar_user_path(@user) + '?gravatar=1', :method => :put, :remote => true)
#{t :or}
= link_to_cancel avatar_user_path(@user)
%br
14 changes: 0 additions & 14 deletions vendor/plugins/prototype_legacy_helper/README.rdoc

This file was deleted.

12 changes: 0 additions & 12 deletions vendor/plugins/prototype_legacy_helper/Rakefile

This file was deleted.

1 change: 0 additions & 1 deletion vendor/plugins/prototype_legacy_helper/init.rb

This file was deleted.

Loading

0 comments on commit ab7f936

Please sign in to comment.