Sha256: 221e1dce15f6da1b6fab8e4be9080a95b56e955f95f169f53df7aff0e6260bc1

Contents?: true

Size: 1 KB

Versions: 70

Compression:

Stored size: 1 KB

Contents

module RubyApp

  module Elements

    module Navigation
      require 'ruby_app/element'

      class PageLink < RubyApp::Element

        class ClickedEvent < RubyApp::Element::Event

          attr_reader :page

          def initialize(data)
            super(data)
            @page = eval(data['page'])
          end

          def to_hash
            super.merge('page' => @page)
          end

        end

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

        attr_accessor :page

        def initialize(page = nil)
          super()
          @page = page
        end

        def current_page?
          page == RubyApp::Session.pages.last.class
        end

        protected

          def on_event(event)
            on_clicked(event) if event.is_a?(RubyApp::Elements::Navigation::PageLink::ClickedEvent)
            super(event)
          end

          def on_clicked(event)
            RubyApp::Session.pages.push(event.page.new)
            event.refresh
          end

      end

    end

  end

end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
RubyApp-0.0.91 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.90 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.89 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.88 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.87 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.86 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.85 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.84 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.83 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.82 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.81 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.80 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.79 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.78 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.77 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.76 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.75 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.74 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.73 lib/ruby_app/elements/navigation/page_link.rb
RubyApp-0.0.72 lib/ruby_app/elements/navigation/page_link.rb