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