/app/Resources/assets/es6/mobile-engine.js
JavaScript | 811 lines | 735 code | 66 blank | 10 comment | 124 complexity | 670208784f575305d7802ccdc41acf61 MD5 | raw file
Possible License(s): Apache-2.0
- var infoBubbleWidth = 250;
- var infoBubbles = [];
- _.templateSettings = {
- evaluate: /\{%(.+?)%\}/g,
- interpolate: /\{\{(.+?)\}\}/g,
- escape: /\{\{-(.+?)\}\}/g
- };
- function formatNumber (num) {
- return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1 ");
- }
- function formatKNumber (num) {
- if(num < 10000) {
- return formatNumber(num);
- }
- return (num / 1000).toString() + 'k';
- }
- function formatDate(chaine) {
- var toDate = chaine.split('-');
- return toDate[2]+'/'+toDate[1]+'/'+toDate[0];
- }
- function modal_msg(msg, autohide) {
- $('#modalMsg .modal-body p').html(msg);
- if(autohide) {
- $('#modalMsg').addClass('autohide');
- } else {
- $('#modalMsg').removeClass('autohide');
- }
- $('#modalMsg').modal('show');
- }
- function getIBItemHtml(result, divData) {
- var etiquette = '';
- var libelle = result.get('bien').get('libelle');
- if (result.get('bien').get('source') == 2) {
- etiquette = 'neuf';
- if (result.get('bien').get('programme')) {
- libelle = result.get('bien').get('programme').libelle;
- }
- }
- if (result.get('bien').get('residence')) {
- etiquette = 'résidence gérée';
- }
- if (result.get('bien').get('source') == 4) {
- etiquette = 'Terrain à bâtir';
- }
- if (result.get('bien').get('type_bien') != 'Parking/Box' && result.get('bien').get('type_bien') != 'Terrain' ) {
- libelle = result.get('bien').get('type_bien');
- if (result.get('bien').get('nb_piece') > 0) {
- libelle = libelle.concat(result.get('bien').get('nb_piece')+' pièce')
- }
- if (result.get('bien').get('nb_piece') > 1) {
- libelle = libelle.concat('s');
- }
- if (result.get('bien').get('surface') > 0) {
- libelle = libelle.concat('de '+result.get('bien').get('surface')+' m²');
- }
- } else {
- libelle = result.get('bien').get('type_bien');
- }
- return _.template($('#infobubble_content_item').html())({result: result, etiquette: etiquette, libelle: libelle, divData: divData });
- }
- function getIBMultipleItemHtml(quartier) {
- content = quartier.map((point, index) => {
- return getIBItemHtml(point, 'data-index="'+(index)+'" data-annonce-id="'+quartier[index].get('bien').get('reference')+'"');
- }).join('');
- return _.template($('#infobubble_content_quartier').html())({quartier: quartier, items: content});
- }
- $.fn.nodoubletapzoom = function() {
- if (/iphone|ipad/i.test(navigator.userAgent)) {
- $(this).bind('touchstart', function preventZoom(e) {
- var t2 = e.timeStamp, t1 = $(this).data('lastTouch') || t2, dt = t2 - t1, fingers = e.originalEvent.touches.length;
- $(this).data('lastTouch', t2);
- if (!dt || dt > 500 || fingers > 1) return;
- e.preventDefault();
- $(this).trigger('click');
- });
- }
- };
- var HtmlInput = Backbone.Model.extend({
- defaults: {
- id: '',
- libelle: '',
- value: null,
- isActive: true,
- isChecked: false
- },
- reinitialize: function() {
- this.set('isChecked', false);
- }
- });
- var HtmlInputCollection = Backbone.Collection.extend({
- model: HtmlInput
- });
- var CriteriaSelector = Backbone.Model.extend({
- defaults: {
- id: '',
- value: null,
- inputType: '',
- isActive: true,
- inputChoices: []
- },
- initialize: function(data) {
- this.set('inputChoices', new HtmlInputCollection(data.inputChoices));
- }
- });
- var Criteria = Backbone.Model.extend({
- defaults: {
- name: '',
- libelle: '',
- value: null,
- units: '',
- selector: '',
- isDisplayed: true,
- isChecked: false,
- isActive: true,
- inputType: '',
- step: null,
- inputChoices: []
- },
- initialize: function(data) {
- this.set('inputChoices', new HtmlInputCollection(data.inputChoices));
- this.on('change:isActive', function(model) {
- if(!model.get('isActive') && model.get('inputType') == 'checkbox') {
- this.reinitialize();
- }
- }, this);
- this.get('inputChoices').on('change', function(model) {
- this.updateValue();
- }, this);
- },
- add: function(attribute, value) {
- var aAttribute = _.clone(this.get(attribute));
- aAttribute.push(value);
- this.set(attribute, aAttribute);
- },
- remove: function(attribute, value) {
- var arrAttr = this.get(attribute);
- this.set(attribute, _.without(arrAttr, value));
- },
- reinitialize: function() {
- switch(this.get('inputType')){
- case 'checkbox':
- this.set('isChecked', false);
- break;
- case 'changer':
- this.set('isActive', false);
- break;
- case 'hidden':
- if ( typeof this.get('value') == 'number' ) {
- this.set('value', 0);
- } else {
- this.set('value', '');
- }
- this.set('isActive', false);
- break;
- case 'radio':
- if(this.get('name') == 'anciennete'){
- this.set('value', '0');
- }
- break;
- case 'multiple-checkbox':
- this.get('inputChoices').each(function(choice) {
- choice.reinitialize();
- });
- break;
- }
- },
- serialize: function(mode) {
- if( this.get('isDisplayed') && !_.contains(['', null], this.get('value')) ) {
- var retour;
- switch(this.get('inputType')) {
- case 'checkbox':
- if(this.get('isActive') && this.get('isChecked')) {
- retour = this.get('name') + '=' + this.get('value');
- }
- break;
- case 'multiple-checkbox':
- if(this.get('isActive')) {
- switch(mode) {
- case SERIALIZE_FOR_URL:
- case SERIALIZE_FOR_ALERT:
- retour = this.get('inputChoices').where({isChecked: true}).map(inputChoice => {
- return this.get('name') + "[]=" + inputChoice.get('value');
- }).join('&');
- break;
- default:
- retour = this.get('name') + '=' + this.get('value');
- break;
- }
- }
- break;
- case 'location':
- if(this.get('isActive')) {
- switch(mode) {
- case SERIALIZE_FOR_URL:
- if(this.get('value').length == 1 && this.get('value')[0] == masterFilters.get('initialCriterias').get('location_id').get('value')) {
- return null;
- }
- case SERIALIZE_FOR_ALERT:
- retour = this.get('value').map((locId) => {
- return "locationsId[]=" + locId ;
- }).join('&');
- break;
- case SERIALIZE_FOR_MAP_ZONE:
- retour = '';
- break;
- default:
- retour = this.get('name') + '=' + this.get('value');
- break;
- }
- }
- break;
- case 'hidden':
- if(this.get('isActive')) {
- switch(mode) {
- case SERIALIZE_FOR_URL:
- switch(this.get('name')) {
- case 'nb_p':
- retour = this.get('value').map(piece => {
- return "nb_p[]=" + piece;
- }).join('&');
- break;
- default:
- retour = this.get('name') + '=' + this.get('value');
- break;
- }
- break;
- case SERIALIZE_FOR_MAP_ZONE:
- if(_.indexOf(['latitude', 'longitude', 'distance'], this.get('name')) == -1 ){
- retour = this.get('name') + '=' + this.get('value');
- }
- break;
- default:
- retour = this.get('name') + '=' + this.get('value');
- break;
- }
- }
- break;
- default:
- if(this.get('isActive') && _.indexOf(['min_piece', 'max_piece'], this.get('name')) == -1 ) {
- switch(mode) {
- case SERIALIZE_FOR_URL:
- if(_.indexOf(masterFilters.get('initialCriterias').pluck('name'), this.get('name')) > -1) {
- if(this.get('value') == masterFilters.get('initialCriterias').get(this.get('name')).get('value')) {
- return null;
- }
- }
- break;
- }
- retour = this.get('name') + '=' + this.get('value');
- }
- break;
- }
- if(retour != "anciennete=0") {
- return retour;
- }
- }
- return null;
- },
- updateValue: function() {
- var criteriaValue = this.get('inputChoices').where({isChecked: true}).map(inputChoice => {
- return inputChoice.get('value');
- }).join(',');
- this.set('value', criteriaValue);
- }
- });
- var CriteriaCollection = Backbone.Collection.extend({
- model: Criteria,
- modelId: function(attrs) {
- return attrs.name ;
- }
- });
- var Filter = Backbone.Model.extend({
- defaults: {
- id: '',
- libelle: '',
- picto: '',
- value : '',
- desc: '',
- isActive: true,
- criteriaSelector: null,
- criterias : []
- },
- initialize: function(data) {
- if(data.criteriaSelector) {
- this.set('criteriaSelector', new CriteriaSelector(data.criteriaSelector));
- }
- this.set('criterias', new CriteriaCollection(data.criterias));
- this.updateValue();
- this.on('change:isActive', model => {
- if(!model.get('isActive')) {
- this.reinitialize();
- }
- })
- this.get('criterias').on('change', this.updateValue.bind(this))
- if(data.criteriaSelector) {
- this.get('criteriaSelector').on('change:value', (model, value) => {
- this.get('criterias').forEach(criteria => {
- if(model.get('inputType') === 'exploded-radio') {
- criteria.set('isActive', (criteria.get('selector') == value));
- } else {
- criteria.set('isActive', false);
- if(model.get('inputType') === 'radio') {
- criteria.set('isDisplayed', (criteria.get('selector') == value));
- }
- }
- });
- });
- }
- },
- reinitialize: function() {
- this.get('criterias').forEach(criteria => {
- criteria.reinitialize();
- });
- },
- updateValue: function() {
- var filterValues = [], c_name = null, c_val_min = null, c_val_lib = null;
- this.get('criterias').forEach(criteria => {
- switch(criteria.get('inputType')) {
- case 'radio':
- filterValues.push(criteria.get('inputChoices').findWhere({value: criteria.get('value')}).get('libelle'));
- break;
- case 'checkbox':
- if(criteria.get('isActive') && criteria.get('isChecked')) {
- filterValues.push(criteria.get('libelle'));
- }
- break;
- case 'multiple-checkbox': {
- let filterValue = criteria.get('inputChoices').where({isChecked: true}).map(inputChoice => {
- return inputChoice.get('libelle');
- }).join(' - ');
- filterValues.push((filterValue != '' ? filterValue : this.get('emptyLib')));
- break;
- }
- case 'changer':
- if(criteria.get('isActive')) {
- if(criteria.get('name').indexOf('min') === 0) {
- c_name = criteria.get('name').replace('min_', '');
- c_val_min = criteria.get('value');
- c_val_lib = formatKNumber(criteria.get('value')) + ' ' + criteria.get('units');
- filterValues.push( c_val_lib + ' min.' );
- } else if(criteria.get('name').indexOf('max') === 0) {
- if(c_name == criteria.get('name').replace('max_', '')) {
- if ( c_val_min == criteria.get('value') ) {
- filterValues[filterValues.length - 1] = formatKNumber(criteria.get('value')) + ' ' + criteria.get('units');
- } else {
- filterValues[filterValues.length - 1] = c_val_lib + ' > ' + formatKNumber(criteria.get('value')) + ' ' + criteria.get('units');
- }
- c_name = c_val_min = c_val_lib = null;
- } else {
- filterValues.push( formatKNumber(criteria.get('value')) + ' ' + criteria.get('units') + ' max.' );
- }
- } else {
- filterValues.push( formatKNumber(criteria.get('value')) + ' ' + criteria.get('units') );
- }
- }
- break;
- case 'location': {
- let filterValue = criteria.get('valuelib').join(' - ');
- if(filterValue == '') {
- filterValue = 'France';
- }
- filterValues.push( filterValue );
- break;
- }
- }
- });
- this.set('value', ( filterValues.length > 0 ? filterValues.join(' - ') : this.get('emptyLib')) );
- },
- serialize: function(mode) {
- var param = [];
- this.get('criterias').each(function(criteria) {
- var paramString = criteria.serialize(mode);
- if(paramString) {
- param.push(paramString);
- }
- });
- return param.join('&');
- }
- });
- var FilterCollection = Backbone.Collection.extend({
- model: Filter
- });
- var MasterFilters = Backbone.Model.extend({
- defaults: {
- id: '',
- libelle: '',
- initialCriterias: {},
- mainFilters: {},
- otherFilters: {},
- pageNumber: 1,
- pageSize: 12,
- mapPageSize: 300,
- sortField: 'prix',
- sortOrder: 'asc'
- },
- initialize: function(data) {
- this.set('initialCriterias', new CriteriaCollection(data.initialCriterias));
- this.set('mainFilters', new FilterCollection(data.mainFilters));
- this.set('otherFilters', new FilterCollection(data.otherFilters));
- this.setSort($('#resultats-tri').val());
- this.updateNbFilters();
- this.get('mainFilters').on('change', function(model) {
- this.updateFiltersState();
- if(model.get('id') == 'projet') {
- this.updateBudgetValues();
- }
- this.resetPage();
- }, this);
- this.get('otherFilters').on('change', function(model) {
- this.updateFiltersState();
- this.resetPage();
- this.updateNbFilters();
- }, this);
- $('.row').on('click', '.container-offer', function (e) {
- e.stopPropagation();
- $(this).find('.offer-link').get(0).click();
- });
- },
- serialize: function(mode, extra) {
- var param = [];
- this.get('mainFilters').each(function(filter){
- var paramString = filter.serialize(mode);
- if(paramString) {
- param.push(paramString);
- }
- });
- this.get('otherFilters').each(function(filter){
- var paramString = filter.serialize(mode);
- if(paramString) {
- param.push(paramString);
- }
- });
- if(extra) {
- _.each(extra, function(value, key){
- param.push(key + '=' + value);
- })
- }
- switch(mode) {
- case SERIALIZE_FOR_MAP:
- case SERIALIZE_FOR_MAP_ZONE:
- param.push('withPartners=1');
- param.push('pageNumber=1');
- param.push('pageSize=' + this.get('mapPageSize'));
- break;
- case SERIALIZE_FOR_URL:
- if(this.get('pageNumber') > 1) {
- param.push('page=' + this.get('pageNumber'));
- }
- if(this.get('sortField') != 'prix' || this.get('sortOrder') != 'asc') {
- param.push('order=' + this.get('sortField') + ' ' + this.get('sortOrder'));
- }
- break;
- case SERIALIZE_FOR_ALERT:
- break;
- case SERIALIZE_DEFAULT:
- default:
- param.push('withPartners=1');
- param.push('pageNumber=' + this.get('pageNumber'));
- param.push('pageSize=' + this.get('pageSize'));
- param.push('sortField=' + this.get('sortField'));
- param.push('sortOrder=' + this.get('sortOrder'));
- break;
- }
- return param.join('&');
- },
- setSort: function(inputVal) {
- if(!inputVal) {
- return;
- }
- var data = inputVal.split('|');
- this.set('sortField', data[0]);
- this.set('sortOrder', data[1]);
- },
- resetPage: function() {
- this.set('pageNumber', 1);
- },
- updateFiltersState: function() {
- var checkedTypes = masterFilters.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('value').split(',');
- if( _.intersection(['', 'Appartement', 'Maison/Villa', 'Loft/Atelier/Surface', 'Immeuble'], checkedTypes).length == 0) {
- // Terrain, Parking/Box, Local ou Bureaux
- if( _.indexOf(['Terrain', 'Parking/Box', 'Terrain,Parking/Box'], this.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('value')) != -1 ) {
- this.get('otherFilters').get('pieces').set('isActive', false);
- this.get('otherFilters').get('equipement').set('isActive', false);
- this.get('otherFilters').get('autre').get('criterias').get('mobilite_reduite').set('isActive', false);
- } else {
- this.get('otherFilters').get('pieces').set('isActive', true);
- this.get('otherFilters').get('equipement').set('isActive', true);
- this.get('otherFilters').get('autre').get('criterias').get('mobilite_reduite').set('isActive', true);
- }
- this.get('otherFilters').get('defiscalisation').set('isActive', false);
- } else {
- this.get('otherFilters').get('pieces').set('isActive', true);
- this.get('otherFilters').get('equipement').set('isActive', true);
- this.get('otherFilters').get('defiscalisation').set('isActive', true);
- this.get('otherFilters').get('autre').get('criterias').get('mobilite_reduite').set('isActive', true);
- }
- if(this.get('mainFilters').get('projet').get('criterias').get('type_commercialisation').get('value') == 'Vente') {
- this.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('inputChoices').get('terrain').set('isActive', true);
- this.get('otherFilters').get('budget').get('criteriaSelector').set('isActive', true);
- if(this.get('mainFilters').get('categories').get('criterias').get('anciennete').get('value') == '1') {
- this.get('otherFilters').get('autre').get('criterias').get('bbc').set('isActive', false);
- var fiscalCrit = this.get('otherFilters').get('defiscalisation').get('criterias');
- fiscalCrit.get('scellier').set('isActive', false);
- fiscalCrit.get('lmnp').set('isActive', false);
- fiscalCrit.get('censi').set('isActive', false);
- fiscalCrit.get('tva_reduite').set('isActive', false);
- this.get('otherFilters').get('disponibilite').set('isActive', false);
- } else {
- if( _.intersection(['', 'Appartement', 'Maison/Villa', 'Loft/Atelier/Surface'], checkedTypes).length > 0 ) {
- this.get('otherFilters').get('autre').get('criterias').get('bbc').set('isActive', true);
- var fiscalCrit = this.get('otherFilters').get('defiscalisation').get('criterias');
- fiscalCrit.get('scellier').set('isActive', true);
- fiscalCrit.get('lmnp').set('isActive', true);
- fiscalCrit.get('censi').set('isActive', true);
- fiscalCrit.get('tva_reduite').set('isActive', true);
- this.get('otherFilters').get('disponibilite').set('isActive', true);
- } else {
- this.get('otherFilters').get('autre').get('criterias').get('bbc').set('isActive', false);
- var fiscalCrit = this.get('otherFilters').get('defiscalisation').get('criterias');
- fiscalCrit.get('scellier').set('isActive', false);
- fiscalCrit.get('lmnp').set('isActive', false);
- fiscalCrit.get('censi').set('isActive', false);
- fiscalCrit.get('tva_reduite').set('isActive', false);
- if( _.indexOf(['Terrain'], this.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('value')) != -1 ) {
- this.get('otherFilters').get('disponibilite').set('isActive', true);
- } else {
- this.get('otherFilters').get('disponibilite').set('isActive', false);
- }
- }
- }
- } else {
- this.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('inputChoices').get('terrain').set('isChecked', false);
- this.get('mainFilters').get('types_bien').get('criterias').get('types_bien').get('inputChoices').get('terrain').set('isActive', false);
- this.get('otherFilters').get('budget').get('criteriaSelector').set('value', 'global');
- this.get('otherFilters').get('budget').get('criteriaSelector').set('isActive', false);
- this.get('otherFilters').get('autre').get('criterias').get('bbc').set('isActive', false);
- var fiscalCrit = this.get('otherFilters').get('defiscalisation').get('criterias');
- fiscalCrit.get('scellier').set('isActive', false);
- fiscalCrit.get('lmnp').set('isActive', false);
- fiscalCrit.get('censi').set('isActive', false);
- fiscalCrit.get('tva_reduite').set('isActive', false);
- if(this.get('mainFilters').get('categories').get('criterias').get('anciennete').get('value') == '1') {
- this.get('otherFilters').get('disponibilite').set('isActive', false);
- } else {
- this.get('otherFilters').get('disponibilite').set('isActive', true);
- }
- }
- },
- updateBudgetValues: function () {
- var typeCom = this.get('mainFilters').get('projet').get('criterias').get('type_commercialisation').get('value');
- var minBudget = this.get('otherFilters').get('budget').get('criterias').get('min_budget');
- minBudget.set('value', minBudget.get('default'+typeCom));
- minBudget.set('step', minBudget.get('step'+typeCom));
- minBudget.reinitialize();
- var maxBudget = this.get('otherFilters').get('budget').get('criterias').get('max_budget');
- maxBudget.set('value', maxBudget.get('default'+typeCom));
- maxBudget.set('step', maxBudget.get('step'+typeCom));
- maxBudget.reinitialize();
- },
- updateNbFilters: function () {
- var nb = this.get('otherFilters').length - ( this.get('otherFilters').where({value: '(vide)'}).length + this.get('otherFilters').where({value: 'Tous'}).length );
- if(nb > 0) {
- $('.nb-filters').html('<span>' + nb + '</span>');
- } else {
- $('.nb-filters').html('');
- }
- }
- });
- // Recherche
- var Pagination = Backbone.Model.extend({
- });
- var Bien = Backbone.Model.extend({
- });
- var Result = Backbone.Model.extend({
- defaults: {
- bien: null,
- center_x: '',
- center_y : '',
- polygone: '',
- c_prix_min: 0,
- distance: 0,
- p_nb_piece_min: 0,
- p_nb_lots: 0
- },
- initialize: function(data) {
- this.set('bien', new Bien(data[0]) );
- this.unset(0);
- }
- });
- var ResultCollection = Backbone.Collection.extend({
- model: Result
- });
- var SearchResult = Backbone.Model.extend({
- defaults: {
- searchUrl: '',
- isLoaded: false,
- lastMode: SERIALIZE_DEFAULT,
- historyAction: 'replace',
- locationChanged: false,
- pagination: {},
- count: 0,
- results: [],
- alentourNeufIds: [],
- pushNeufIds: [],
- enlargeType: '',
- resultMapListPseudoView: false,
- },
- initialize: function(searchUrl){
- this.set('searchUrl', searchUrl);
- this.on("sync", function(_this){
- _this.set('isLoaded', true);
- window.searchResults = _this;
- switch(Backbone.history.getFragment()){
- case 'map':
- // if (!_this.resultMapListPseudoView) {
- // let resultMapListPseudoView = new ResultMapListPseudoView({model: _this})
- // _this.resultMapListPseudoView = resultMapListPseudoView
- // _this.resultMapListPseudoView.render();
- // }
- window.currentMapManager.initMap();
- //$.cookie("mapDefault", 1, { path: '/' });
- //localStorage.setItem('mapDefault', 1);
- break;
- case '':
- case 'list':
- var resultListPseudoView = new ResultListPseudoView({model: _this});
- resultListPseudoView.render();
- var paginationPseudoView = new PaginationPseudoView({model: _this.get('pagination')});
- paginationPseudoView.render();
- switch(searchResults.get('historyAction')) {
- case 'push':
- Backbone.history.history.pushState({type: 'push', serializedFilters: JSON.stringify(masterFilters)}, 'maj_url', "?" + masterFilters.serialize(SERIALIZE_FOR_URL) + '#list');
- break;
- case 'replace':
- Backbone.history.history.replaceState({type: 'replace', serializedFilters: JSON.stringify(masterFilters)}, 'maj_url', "?" + masterFilters.serialize(SERIALIZE_FOR_URL) + '#list');
- break;
- }
- if(_this.get('locationChanged')) {
- $('#search-infos').css('display', 'none');
- $('.search-metadata .search-label h1').html(_this.get('title'));
- }
- $('a.ajax_new_searches').attr('data-name', AlertManager.getAlerteName());
- break;
- }
- _this.switchLoader(true);
- });
- this.on("error", function(_this){
- modal_msg("Une erreur est survenue lors du chargement des données.<br><br>Veuillez nous excuser pour la gêne occasionnée");
- _this.switchLoader(true);
- });
- this.on("change:searchUrl", function(_this) {
- _this.set('isLoaded', false);
- _this.fetch();
- _this.switchLoader(false);
- $('body').animate({scrollTop: 0});
- var xitiBudgetMax = xitiPiecesMin = xitiSurfaceMin = '';
- var xitiLocalisation = '';
- var xitiAncienete = 'Tous';
- var xitiTypeCommercialisation = 'Louer';
- if (masterFilters.get('mainFilters').get('projet').get('criterias').get('type_commercialisation').get('value') == 'Vente') {
- xitiTypeCommercialisation = 'Acheter';
- }
- if (masterFilters.get('mainFilters').get('categories').get('criterias').get('anciennete').get('value') == 1) {
- xitiAncienete = 'Ancien';
- } else if (masterFilters.get('mainFilters').get('categories').get('criterias').get('anciennete').get('value') == 2) {
- xitiAncienete = 'Neuf';
- }
- if (masterFilters.get('otherFilters').get('budget').get('criteriaSelector').get('isActive')) {
- xitiBudgetMax = masterFilters.get('otherFilters').get('budget').get('criterias').get('max_budget').get('value');
- }
- if (masterFilters.get('otherFilters').get('pieces').get('isActive')) {
- xitiPiecesMin = masterFilters.get('otherFilters').get('pieces').get('criterias').get('min_piece').get('value');
- }
- if (masterFilters.get('otherFilters').get('surface').get('isActive')) {
- xitiSurfaceMin = masterFilters.get('otherFilters').get('surface').get('criterias').get('min_surface').get('value');
- }
- tc_events_5(this,'10',{'label':tc_vars["xiti_xtpage"],'xtmed_s2':'12','xtmed_type':'P','x1':xitiSurfaceMin,'x16':xitiLocalisation,'x17':xitiTypeCommercialisation,'x18':xitiPiecesMin,'x19':xitiBudgetMax,'x20':xitiAncienete});
- sessionStorage.setItem('masterFilters', JSON.stringify(masterFilters));
- popinMkt();
- });
- },
- url: function() {
- return this.get('searchUrl');
- },
- parse: function (response) {
- response.pagination = new Pagination(response.pagination);
- response.results = new ResultCollection(response.results);
- return response;
- },
- switchLoader: function (display) {
- if(display) {
- $('.loader').removeClass('active');
- $('body').removeClass('loading');
- } else {
- $('.loader').addClass('active');
- $('body').addClass('loading');
- }
- },
- reload: function(serialize_mode, extra, historyAction) {
- if(!historyAction) {
- historyAction = 'replace';
- }
- this.set('historyAction', historyAction);
- this.set('lastMode', serialize_mode);
- this.set('searchUrl', urlSearchAPI + "?" + masterFilters.serialize(serialize_mode, extra));
- }
- });
- var Favori = Backbone.Model.extend({
- defaults: {
- id: 0,
- native_id: '',
- reference : '',
- type: ''
- }
- });
- var FavoriCollection = Backbone.Collection.extend({
- model: Favori
- });
- var Favoris = Backbone.Model.extend({
- defaults: {
- favIds: [],
- favoris: []
- },
- url: '/mon-compte/mes-favoris.json?type=bien',
- initialize: function() {
- this.reload();
- },
- parse: function (response) {
- this.set('favoris', new FavoriCollection(response));
- var favIds = [];
- _.each(response, function(fav){
- favIds.push(fav.reference);
- });
- this.set('favIds', favIds);
- },
- reload: function() {
- if($('header a.loginAction').hasClass('logged')) {
- this.fetch();
- }
- }
- });
- // Display the popin marketing on page loaded
- $(function(){
- popinMkt();
- });