Module: Typus::QuickEdit

Included in:
TypusController
Defined in:
lib/typus/quick_edit.rb

Instance Method Summary collapse

Instance Method Details

#quick_editObject



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
30
31
32
33
34
35
36
# File 'lib/typus/quick_edit.rb', line 5

def quick_edit

  render :text => '' and return unless session[:typus_user_id]

  links = [[ "Dashboard", admin_dashboard_path ]]
  links << [ params[:message], "/admin/#{params[:path]}" ] if params[:message] && params[:path]

  options = links.reverse.map do |link|
              "<li><a href=\"#{link.last}\">#{link.first}</a></li>"
            end

  content = <<-HTML
var links = '';
links += '<div id="quick_edit">';
links += '<ul>';
links += '#{options}';
links += '</ul>';
links += '</div>';
links += '<style type="text/css">';
links += '<!--';
links += '#quick_edit { font-size: 12px; font-family: sans-serif; position: absolute; top: 0px; right: 0px; margin: 10px; }';
links += '#quick_edit a { color: #FFF; font-weight: bold; text-decoration: none; }'
links += '#quick_edit ul { margin: 0; padding: 0; }';
links += '#quick_edit li { display: inline; background: #000; margin: 0 0 0 5px; padding: 3px 5px; }';
links += '-->';
links += '</style>';
document.write(links);
  HTML

  render :text => content

end