Sha256: 5d1745690def2bd13c9efd0691d15c983a97fdf9332cbbd8e8fcb8b222812274

Contents?: true

Size: 1.35 KB

Versions: 41

Compression:

Stored size: 1.35 KB

Contents

module Redcar
  module HtmlController
    include Redcar::Observable

    # Reload the index page
    def reload_index
      notify_listeners(:reload_index)
    end

    # Override this to return a message if the user should be prompted
    # before closing the tab.
    def ask_before_closing
      nil
    end

    # Override this to run code right before the tab is closed.
    def close
      nil
    end

    # Call execute with a string of javascript to execute the script
    # in the context of the browser widget.
    def execute(script)
      notify_listeners(:execute_script, script)
    end

    def javascript_controller_actions
      methods = self.methods - Object.methods
      <<-JS
        <script type="text/javascript">
          function makeController (methods) {
            var controller = {};
            methods.map(function (method) {
              var jsMethod = method.replace(/_(.)/g, function () {
                    return arguments[1].toUpperCase();
                  });
              controller[jsMethod] = function () {
                var args = Array.prototype.slice.call(arguments);
                return JSON.parse(rubyCall.apply(this, [method].concat(args)));
              };
            });
            return controller;
          }
          Controller = makeController(#{methods.inspect});
        </script>
      JS
    end
  end
end

Version data entries

41 entries across 41 versions & 2 rubygems

Version Path
redcar-0.13 plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.5dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.4dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.3dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.2dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.1dev plugins/html_view/lib/html_controller.rb
redcar-0.12.1 plugins/html_view/lib/html_controller.rb
redcar-dev-0.13.0dev plugins/html_view/lib/html_controller.rb
redcar-0.12 plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.27dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.26dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.25dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.24dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.23dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.22dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.21dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.20dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.19dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.18dev plugins/html_view/lib/html_controller.rb
redcar-dev-0.12.17dev plugins/html_view/lib/html_controller.rb