Module: DevPanel::Panel

Defined in:
lib/devpanel/extension.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


4
5
6
# File 'lib/devpanel/extension.rb', line 4

def self.included(base)
  base.after_filter :dev_panel_output, :if => lambda { request.format.to_s == "text/html" && !(!!request.xhr?) }
end

Instance Method Details

#dev_panel_outputObject


8
9
10
# File 'lib/devpanel/extension.rb', line 8

def dev_panel_output
  self.response.body += panel
end

#hide_containerObject


35
36
37
# File 'lib/devpanel/extension.rb', line 35

def hide_container
  (Stats.show?) ? '' : '$jq("#devPanelContainer").toggle()'
end

#panelObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/devpanel/extension.rb', line 12

def panel
  <<-html_code
    <script>
    window.onload = function() {
      body = document.getElementsByTagName('body')[0]
      iframe = document.createElement('iframe')
      iframe.setAttribute('src', '__DevPanel/main')
      iframe.setAttribute('id', 'devPanel')
      iframe.setAttribute('style', 'width: 100%; border: none;')
      iframe.setAttribute('height', 50)
      body.insertBefore(iframe ,body.children[0])
    }

    window.resizeDevPanel = function(height) {
      element = document.getElementById('devPanel')
      console.log(height)
      element.setAttribute('height', height)
    }

    </script>
  html_code
end