{:uriI"�file:///Users/YvesSi/Projects/better_frame/app/assets/javascripts/better_frame/better_frame.js?type=application/javascript&pipeline=self&id=0cdfc3561ec9dfe44d107c5e1733488a4803ebaa2e829a919dda2328b82169a9:ET:load_pathI"?/Users/YvesSi/Projects/better_frame/app/assets/javascripts;T:
filenameI"\/Users/YvesSi/Projects/better_frame/app/assets/javascripts/better_frame/better_frame.js;T:	nameI"better_frame/better_frame;T:logical_pathI"&better_frame/better_frame.self.js;T:content_typeI"application/javascript;T:sourceI"(function(){
  var baseURL = $("#app-content").data("baseurl");
  var railsURL = $("#app-content").data("railsurl");
  var railsPath = function() {
    var currentURL = window.location.toString();
    return currentURL.replace(baseURL, "");
  }
  var currentRailsPath = function() {
    return $("#rails-path").data("path");
  }

  function fill(url) {
    return $.ajax({url: url, type: "GET", xhrFields: { withCredentials: true }}).done(fillContent); }

  function fillContent(content) { $("#app-content").html(content); }

  function storeURLInHistory() {
    window.history.pushState(null, null, baseURL + currentRailsPath());
  }

  function handleLinks(event) {
    event.preventDefault();
    url_or_path = event.currentTarget.getAttribute("href");
    var expression = /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/;
    var url_regex = new RegExp(expression);
    if (!url_or_path.match(url_regex)) {
      url_or_path = railsURL + url_or_path;
    }
    console.log(url_or_path);
    fill(url_or_path).then(storeURLInHistory);
  }

  $(document).on("click", "#app-content a:not([target=\"_blank\"])", handleLinks);

  $(document).on("ajax:success", "#app-content form", function(e, data, status, xhr) {
    fillContent(data);
    storeURLInHistory();
  });

  window.onpopstate = function(event) {
    var currentURL = document.location.toString();
    fill(currentURL.replace(baseURL, railsURL));
  };

  // inital loading
  $(function() {
    fill(railsURL + railsPath()).then(storeURLInHistory);
  });
})(jQuery);
;T:
metadata{:dependencieso:Set:
@hash{
I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"jfile-digest:///Users/YvesSi/Projects/better_frame/app/assets/javascripts/better_frame/better_frame.js;TT:
requiredo;;{�:stubbedo;;{�:
linkso;;{�:charsetI"
utf-8;F:digest"%����ùX��k-'p��)�*�w�<�9(!)M�:lengthi:dependencies_digest"%0-�Q����+ݽ����}����x������:idI"E0cdfc3561ec9dfe44d107c5e1733488a4803ebaa2e829a919dda2328b82169a9;F:
mtimel+` �W