Sha256: 2c5b67931e2f9077ef572680045e74697defcd02f09b0d58bdae06ad3e9e4451

Contents?: true

Size: 681 Bytes

Versions: 45

Compression:

Stored size: 681 Bytes

Contents

module Volt
  # The URLTracker is responsible for updating the url when
  # a param changes, or updating the url model/params when
  # the browser url changes.
  class UrlTracker
    def initialize(page)
      @page = page

      if Volt.client?
        that = self

        # Setup popstate on the dom ready event.  Prevents an extra
        # popstate trigger
        `
          window.addEventListener("popstate", function(e) {
            that.$url_updated();
            return true;
          });
        `
      end
    end

    def url_updated(first_call = false)
      @page.url.parse(`document.location.href`)
      @page.url.update! unless first_call
    end
  end
end

Version data entries

45 entries across 45 versions & 1 rubygems

Version Path
volt-0.9.4.pre3 lib/volt/page/url_tracker.rb
volt-0.9.4.pre2 lib/volt/page/url_tracker.rb
volt-0.9.4.pre1 lib/volt/page/url_tracker.rb
volt-0.9.3 lib/volt/page/url_tracker.rb
volt-0.9.3.pre6 lib/volt/page/url_tracker.rb
volt-0.9.3.pre5 lib/volt/page/url_tracker.rb
volt-0.9.3.pre4 lib/volt/page/url_tracker.rb
volt-0.9.3.pre3 lib/volt/page/url_tracker.rb
volt-0.9.3.pre2 lib/volt/page/url_tracker.rb
volt-0.9.3.pre1 lib/volt/page/url_tracker.rb
volt-0.9.2 lib/volt/page/url_tracker.rb
volt-0.9.1 lib/volt/page/url_tracker.rb
volt-0.9.1.pre5 lib/volt/page/url_tracker.rb
volt-0.9.1.pre4 lib/volt/page/url_tracker.rb
volt-0.9.1.pre3 lib/volt/page/url_tracker.rb
volt-0.9.1.pre2 lib/volt/page/url_tracker.rb
volt-0.9.1.pre1 lib/volt/page/url_tracker.rb
volt-0.9.0 lib/volt/page/url_tracker.rb
volt-0.9.0.pre7 lib/volt/page/url_tracker.rb
volt-0.9.0.pre6 lib/volt/page/url_tracker.rb