Sha256: 74592d2e06666a38a4a0c232d1f73fb15e082bd0d0e22c72d6f996cf51567388

Contents?: true

Size: 1.95 KB

Versions: 5

Compression:

Stored size: 1.95 KB

Contents

require 'rubygems'
require 'bundler/setup'

require 'ruby-event'

module RubyApp

  module Elements

    module Mobile
      require 'ruby_app/element'

      class Document < RubyApp::Element

        class LoadedEvent < RubyApp::Element::Event

          def initialize(data)
            super(data)
          end

        end

        template_path(:all, File.dirname(__FILE__))

        attr_reader :metadata
        attr_reader :links
        attr_reader :stylesheets
        attr_reader :scripts

        attr_reader :pages

        event :loaded

        def initialize
          super

          @metadata = {}
          @links = {}
          @stylesheets = []
          @scripts = []

          @pages = []

          @metadata.merge!('viewport' => 'width=device-width, initial-scale=1')

          @stylesheets.push('http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css')

          @scripts.push('http://code.jquery.com/jquery-1.8.3.min.js')
          @scripts.push('http://code.jquery.com/ui/1.9.2/jquery-ui.min.js')
          @scripts.push('/ruby_app/resources/elements/mobile/document/jquery.ui.touch-punch.min.js')
          @scripts.push('/ruby_app/resources/elements/mobile/document/fastclick.js')
          @scripts.push('/ruby_app/resources/elements/mobile/document/document.js')
          @scripts.push('http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.js')

        end

        def page
          return @pages.last
        end

        def show(event, url = '/')
          RubyApp::Session.documents.push(self)
          event.go(url)
        end

        def hide(event, url = '/')
          RubyApp::Session.documents.pop
          event.go(url)
        end

        protected

          def on_event(event)
            on_loaded(event) if event.is_a?(RubyApp::Elements::Mobile::Document::LoadedEvent)
            super(event)
          end

          def on_loaded(event)
            loaded(event)
          end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
RubyApp-0.6.58 lib/ruby_app/elements/mobile/document.rb
RubyApp-0.6.57 lib/ruby_app/elements/mobile/document.rb
RubyApp-0.6.53 lib/ruby_app/elements/mobile/document.rb
RubyApp-0.6.52 lib/ruby_app/elements/mobile/document.rb
RubyApp-0.6.51 lib/ruby_app/elements/mobile/document.rb