From 593b6c1a42ee46371ddef33c2939952fb18fc893 Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Fri, 5 Oct 2012 19:13:30 +0300 Subject: [PATCH] replace pjax with turbolinks --- Gemfile | 2 +- Gemfile.lock | 5 ++-- app/assets/javascripts/application.js.coffee | 3 +- .../components/behaviors.js.coffee | 30 ++++++------------- app/views/layouts/admin.html.erb | 6 ++-- app/views/layouts/errors.html.erb | 6 ++-- app/views/layouts/home.html.erb | 6 ++-- app/views/layouts/public.html.erb | 6 ++-- app/views/layouts/users.html.erb | 6 ++-- app/views/shared/_bottom.html.erb | 2 +- app/views/shared/_navigation.html.erb | 2 +- app/views/shared/navigation/_users.html.erb | 2 +- app/views/users/shared/_links.erb | 2 +- vendor/assets/javascripts/slides.js | 2 +- 14 files changed, 28 insertions(+), 52 deletions(-) diff --git a/Gemfile b/Gemfile index 66c4f35..daa9a27 100644 --- a/Gemfile +++ b/Gemfile @@ -47,7 +47,7 @@ gem 'dalli', '~> 1.1.3' gem 'active_scaffold', '~> 3.2.16' # git: 'https://github.com/activescaffold/active_scaffold.git' # path: '/home/clyfe/dev/active_scaffold' -gem 'pjax_rails', '~> 0.2.0' +gem 'turbolinks', '~> 0.5.1' # gem 'foreigner' ? group :development do diff --git a/Gemfile.lock b/Gemfile.lock index d3fb342..8f4a00a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -172,8 +172,6 @@ GEM activesupport (>= 3.0.0) nokogiri (1.5.5) orm_adapter (0.4.0) - pjax_rails (0.2.2) - jquery-rails polyamorous (0.5.0) activerecord (~> 3.0) polyglot (0.3.3) @@ -294,6 +292,7 @@ GEM treetop (1.4.10) polyglot polyglot (>= 0.3.1) + turbolinks (0.5.1) tzinfo (0.3.33) uglifier (1.3.0) execjs (>= 0.3.0) @@ -335,7 +334,6 @@ DEPENDENCIES mysql2 navigasmic (~> 0.5.6)! nilify_blanks (~> 1.0.0) - pjax_rails (~> 0.2.0) quiet_assets (~> 1.0.1) rails (= 3.2.8) rails-backbone (~> 0.7.0) @@ -354,6 +352,7 @@ DEPENDENCIES squeel (~> 1.0.0) switch_user (~> 0.6.0) therubyracer + turbolinks (~> 0.5.1) uglifier (>= 1.0.3) userstamp (~> 2.0.2)! validates_hostname (~> 1.0.0)! diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee index 778b9ce..f89a71c 100644 --- a/app/assets/javascripts/application.js.coffee +++ b/app/assets/javascripts/application.js.coffee @@ -7,8 +7,7 @@ #= require jquery #= require jquery-ui #= require jquery_ujs -#= require jquery.pjax -#= require pjax/page_triggers +#= require turbolinks #= require slides #= require bootstrap #= require active_scaffold diff --git a/app/assets/javascripts/components/behaviors.js.coffee b/app/assets/javascripts/components/behaviors.js.coffee index 23a600d..fac7489 100644 --- a/app/assets/javascripts/components/behaviors.js.coffee +++ b/app/assets/javascripts/components/behaviors.js.coffee @@ -1,24 +1,12 @@ $ -> $(document).popover(selector: '[rel=popover]') $(document).tooltip(selector: '[rel=tooltip]') - - pjaxContainer = '[data-pjax-container]' - $pjaxContainer = $(pjaxContainer) - $pjaxContainerParent = $(pjaxContainer).parent() - $body = $('body') - fixLayout = -> - if $pjaxContainer.find('.container').length > 0 - $pjaxContainerParent.removeClass 'container' - else - $pjaxContainerParent.addClass 'container' - if $body.has('.page-home-section').length > 0 - $body.addClass('with-home-section') - else - $body.removeClass('with-home-section') - fixLayout() - - $('.pjax-nav a:not([data-remote]):not([data-behavior]):not([data-skip-pjax])').pjax(pjaxContainer) - $pjaxContainer.on 'pjax:success', (event, data, status, xhr, options) -> - $('.pjax-nav').find('li.active').removeClass 'active' - $(".pjax-nav a[href=\"#{window.location.pathname}\"]").parents('li').addClass 'active' - fixLayout() + + # fix for Turbolinks with Bootstrap + # https://github.com/rails/turbolinks/issues/16 + proto = $.fn.dropdown.Constructor.prototype + toggle = '[data-toggle=dropdown]' + $(document) + .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', (e) -> e.stopPropagation()) + .on('click.dropdown.data-api touchstart.dropdown.data-api', toggle, proto.toggle) + .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]', proto.keydown) diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb index c18ff7e..cde4cbe 100644 --- a/app/views/layouts/admin.html.erb +++ b/app/views/layouts/admin.html.erb @@ -18,10 +18,8 @@
-
- <%= flash_display 'flash' %> - <%= yield %> -
+ <%= flash_display 'flash' %> + <%= yield %>
diff --git a/app/views/layouts/errors.html.erb b/app/views/layouts/errors.html.erb index bbb7d46..f844a77 100644 --- a/app/views/layouts/errors.html.erb +++ b/app/views/layouts/errors.html.erb @@ -15,10 +15,8 @@ <%= render 'shared/public_top' %>
-
- <%= flash_display 'flash' %> - <%= yield %> -
+ <%= flash_display 'flash' %> + <%= yield %>
diff --git a/app/views/layouts/home.html.erb b/app/views/layouts/home.html.erb index 6f270c7..e110bdc 100644 --- a/app/views/layouts/home.html.erb +++ b/app/views/layouts/home.html.erb @@ -4,10 +4,8 @@ <%= render 'shared/navigation' %>
-
- <%= flash_display 'flash' %> - <%= yield %> -
+ <%= flash_display 'flash' %> + <%= yield %>
diff --git a/app/views/layouts/public.html.erb b/app/views/layouts/public.html.erb index f89e80d..127dc09 100644 --- a/app/views/layouts/public.html.erb +++ b/app/views/layouts/public.html.erb @@ -4,10 +4,8 @@ <%= render 'shared/navigation' %>
-
- <%= flash_display 'flash' %> - <%= yield %> -
+ <%= flash_display 'flash' %> + <%= yield %>
diff --git a/app/views/layouts/users.html.erb b/app/views/layouts/users.html.erb index 17c525f..9b9961f 100644 --- a/app/views/layouts/users.html.erb +++ b/app/views/layouts/users.html.erb @@ -19,10 +19,8 @@ <%= render 'shared/navigation' %>
-
- <%= flash_display 'flash' %> - <%= yield %> -
+ <%= flash_display 'flash' %> + <%= yield %>
diff --git a/app/views/shared/_bottom.html.erb b/app/views/shared/_bottom.html.erb index fc92b33..b0781a7 100644 --- a/app/views/shared/_bottom.html.erb +++ b/app/views/shared/_bottom.html.erb @@ -4,7 +4,7 @@ <%= switch_user_select %>

- <% semantic_navigation :footer_nav, html: { class: 'nav nav-pills pjax-nav' } do |n| %> + <% semantic_navigation :footer_nav, html: { class: 'nav nav-pills' } do |n| %> <%= n.item "Terms & Conditions", link: page_path('terms') %> <%= n.item "Privacy Policy", link: page_path('privacy') %> <%= n.item "Contact", link: page_path('contact') %> diff --git a/app/views/shared/_navigation.html.erb b/app/views/shared/_navigation.html.erb index 0f1ddc5..9c40205 100644 --- a/app/views/shared/_navigation.html.erb +++ b/app/views/shared/_navigation.html.erb @@ -1,6 +1,6 @@