Browse Source

replace pjax with turbolinks

pull/1/head
Nicolae Claudius 12 years ago
parent
commit
593b6c1a42
  1. 2
      Gemfile
  2. 5
      Gemfile.lock
  3. 3
      app/assets/javascripts/application.js.coffee
  4. 30
      app/assets/javascripts/components/behaviors.js.coffee
  5. 6
      app/views/layouts/admin.html.erb
  6. 6
      app/views/layouts/errors.html.erb
  7. 6
      app/views/layouts/home.html.erb
  8. 6
      app/views/layouts/public.html.erb
  9. 6
      app/views/layouts/users.html.erb
  10. 2
      app/views/shared/_bottom.html.erb
  11. 2
      app/views/shared/_navigation.html.erb
  12. 2
      app/views/shared/navigation/_users.html.erb
  13. 2
      app/views/users/shared/_links.erb
  14. 2
      vendor/assets/javascripts/slides.js

2
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

5
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)!

3
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

30
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)

6
app/views/layouts/admin.html.erb

@ -18,10 +18,8 @@
<body class="users">
<div class="container" id="main">
<div data-pjax-container="true">
<%= flash_display 'flash' %>
<%= yield %>
</div>
<%= flash_display 'flash' %>
<%= yield %>
</div>
<div class="container">

6
app/views/layouts/errors.html.erb

@ -15,10 +15,8 @@
<%= render 'shared/public_top' %>
<div class="container" id="main">
<div data-pjax-container="true">
<%= flash_display 'flash' %>
<%= yield %>
</div>
<%= flash_display 'flash' %>
<%= yield %>
</div>
<div class="container">

6
app/views/layouts/home.html.erb

@ -4,10 +4,8 @@
<%= render 'shared/navigation' %>
<div id="main">
<div data-pjax-container="true">
<%= flash_display 'flash' %>
<%= yield %>
</div>
<%= flash_display 'flash' %>
<%= yield %>
</div>
<div class="container">

6
app/views/layouts/public.html.erb

@ -4,10 +4,8 @@
<%= render 'shared/navigation' %>
<div class="container" id="main">
<div data-pjax-container="true">
<%= flash_display 'flash' %>
<%= yield %>
</div>
<%= flash_display 'flash' %>
<%= yield %>
</div>
<div class="container">

6
app/views/layouts/users.html.erb

@ -19,10 +19,8 @@
<%= render 'shared/navigation' %>
<div class="container" id="main">
<div data-pjax-container="true">
<%= flash_display 'flash' %>
<%= yield %>
</div>
<%= flash_display 'flash' %>
<%= yield %>
</div>
<div class="container">

2
app/views/shared/_bottom.html.erb

@ -4,7 +4,7 @@
<%= switch_user_select %>
</p>
<% 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') %>

2
app/views/shared/_navigation.html.erb

@ -1,6 +1,6 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container pjax-nav">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>

2
app/views/shared/navigation/_users.html.erb

@ -27,7 +27,7 @@
<%= n.item '', link: edit_user_registration_path, html: { rel: 'tooltip', title: "IP: #{client_remote_ip}" } do %>
<i class="icon-cog"></i> Settings
<% end %>
<%= n.item '', link: destroy_user_session_path, link_html: { data: { :'skip-pjax' => true } } do %>
<%= n.item '', link: destroy_user_session_path do %>
<i class="icon-off"></i> Sign out
<% end %>
<% end %>

2
app/views/users/shared/_links.erb

@ -1,5 +1,5 @@
<br />
<% semantic_navigation :devise_nav, html: { class: 'nav nav-tabs pjax-nav' } do |n| %>
<% semantic_navigation :devise_nav, html: { class: 'nav nav-tabs' } do |n| %>
<%= n.item "Sign in", link: new_session_path(resource_name) %>
<%= n.item "Sign up", link: new_registration_path(resource_name) %>
<%= n.item "Forgot your password?", link: new_password_path(resource_name) %>

2
vendor/assets/javascripts/slides.js vendored

@ -717,7 +717,7 @@
this.slides.each(
$.proxy(function(index, element) {
$("<li><a href='#" + index + "' class='slidesNavigation slidesPaginationItem' data-slidesindex=" + index + " data-skip-pjax=true> " + ( index + 1 ) + "</a></li>").appendTo(this.pagination);
$("<li><a href='#" + index + "' class='slidesNavigation slidesPaginationItem' data-slidesindex=" + index + " data-no-turbolink=true> " + ( index + 1 ) + "</a></li>").appendTo(this.pagination);
},this)
);

Loading…
Cancel
Save