Sha256: 064ab1a1dccabc5c3c9ddcaf3a4dcd252782a30aba0a2a89d93442b32f72178f

Contents?: true

Size: 1.26 KB

Versions: 14

Compression:

Stored size: 1.26 KB

Contents

var History = window.History;
var ajaxed = true;

$.ajaxSetup({
  dataType: "html"
});

function ajax_complete_defaults(data){
  $("#main").removeClass('ajax-loader');
  $("#main").html(data);
  $('title').html($("#content_for_title").html());
  $("meta[name='description']").attr("content",$("#content_for_page_description").html());
  $("meta[name='keywords']").attr("content",$("#content_for_keywords").html());
  $('#sidebar').html($("#content_for_sidebar").html());
  $("#content_for_gallery").appendTo('#main');
  $('#slideshow').html($("#content_for_slideshow").html());
  bind_functions("#main");
}

$(document).ready(function (){
  $("a[data-remote]").live('ajax:before', function() {
    $("#main").addClass('ajax-loader');
  });

  $("a[data-remote]").live('ajax:complete', function(status, xhr) {
    ajaxed = true;
    History.pushState(null,'',$(this).attr('href'));
    ajax_complete_defaults(xhr.responseText);
  });

  $(window).bind('statechange',function(){
    if (ajaxed === false ) {
      var url = History.getState().url.replace(History.getRootUrl(),'');
      $.ajax({
        url: url,
        success: [function(data) {History.pushState(null,'',url)},function(data) {ajax_complete_defaults(data);}] 
      });
    } else {
      ajaxed = false;
    }
  });

});

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
sbdevcore-0.3.10 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.9 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.8 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.7 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.6 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.5 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.4 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.3 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.2 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.3.0 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.2.26 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.2.25 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.2.24 app/assets/javascripts/sbdev-ajax.js
sbdevcore-0.2.23 app/assets/javascripts/sbdev-ajax.js