Commit 23c37c50 authored by Martin Markech's avatar Martin Markech
Browse files

add ajaxified index

parent 3ac7c982
if (history && history.pushState) {
$(document).ready(function(){
$('#news_index').on("click", ".pagination a[href]", function() {
$("html,body").animate({ 'scrollTop': 0 }, 600, function(){
$("html,body").animate({ 'scrollTop': 0 }, 0);
});
$.getScript(this.href);
history.pushState(null,"",this.href);
return false;
});
$(window).bind("popstate", function() {
$.getScript(location.href);
});
});
}
$(document).ready(function(){
$('#news_index').html("<%= escape_javascript( render :partial => "refinery/news/items/index", :formats => [:html] ) %>");
});
......@@ -14,6 +14,11 @@ module Refinery
plugin.url = proc { Refinery::Core::Engine.routes.url_helpers.news_admin_items_path }
end
end
config.to_prepare do
require 'refinerycms-pages'
Refinery::PagesController.send :include, Refinery::News::Extensions::PagesController
end
config.after_initialize do
Refinery.register_engine(Refinery::News)
......
module Refinery
module News
module Extensions
module PagesController
def self.included(base)
base.class_eval do
around_filter :wrap_home_action, :only => :home
def wrap_home_action
# this is only for fragment caching to create 1 cache file version for first page
params[:page].blank? ? params[:page] = 1 : params[:page]
if request.xhr?
respond_to do |format|
format.js { render :partial=> "/refinery/news/items/index"}
end
else
home
end
end
end
end
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment