Sha256: 0906122ae1a36ef3625b6bab79c2d46abeb383757072db82d80edff945dd9d82

Contents?: true

Size: 1.78 KB

Versions: 80

Compression:

Stored size: 1.78 KB

Contents

var CabooseRets = function() {};
  
CabooseRets.search_params = {
  uri: window.location.pathname,
  property_type: "residential",
  params: false
};
      
CabooseRets.save_search = function(uri, property_type, params)
{  
  $.ajax({
    url: '/saved-searches',
    type: 'post',
    data: CabooseRets.search_params,
    success: function(resp) {
      caboose_modal_url(resp.redirect);
    }
  });
};

CabooseRets.get_save_property = function(mls_acct, el)
{
  $.ajax({
    url: '/saved-properties/' + mls_acct + '/status',
    type: 'get',
    success: function(resp) {
      if (resp.saved == true) el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9733;</span> Saved");
      else                    el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9734;</span> Save Listing");            
    }
  });
}

CabooseRets.toggle_save_property = function(mls_acct, el)
{
  $.ajax({
    url: '/saved-properties/' + mls_acct + '/toggle',
    type: 'get',
    success: function(resp) {
      if (resp.saved == true) el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9733;</span> Saved");
      else                    el.html("<span style='color: #e5cd58; font-size: 2em;'>&#9734;</span> Save Listing");            
    }
  });
}

$(document).ready(function() {
  caboose_modal('login');            
  caboose_modal('saved_searches_button');
  
  $('#save_search').click(function(e) {
    e.preventDefault();
    CabooseRets.save_search();
  });

  $('.toggle_save_property').click(function(e) {
    e.preventDefault();
    var mls_acct = $(e.target).data('mls_acct');
    CabooseRets.toggle_save_property(mls_acct, $(e.target));    
  });
    
  $('.toggle_save_property').each(function(i, el) {
    var mls_acct = $(el).data('mls_acct');
    CabooseRets.get_save_property(mls_acct, $(el));
  });
    
});

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
caboose-rets-0.1.18 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.17 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.16 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.15 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.14 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.13 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.12 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.11 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.10 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.9 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.8 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.7 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.6 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.5 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.4 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.3 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.2 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.1.1 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.0.87 app/assets/javascripts/caboose_rets/caboose_rets.js
caboose-rets-0.0.86 app/assets/javascripts/caboose_rets/caboose_rets.js