"use strict"; //! Faiwer /** * Этот класс отвечает за блок филиалов в нижней части страницы */ (function($) { classes.AdressToggler = new $._class(); classes.AdressToggler.prototype = { _init: function( options ) { this._initConst(); $.deepExtend( this, options ); $( $.proxy( this, '_load' ) ); }, _initConst: function() { $.extend( this, { _get: { block: '#hcsbk_city_parent', tab: { block: [ 'block', '.holder' ], tab_link: [ 'tab.block', '.holder_tab', true ], contacts: [ 'block', '.content_contacts' ], schedule: [ 'block', '.content_schedule' ] }, tab_schedule_list: [ 'block', '.tab_schedule', true ], tab_contacts_list: [ 'block', '.tab_contacts', true ] }, url: 'process/citymanager/' } ); }, _load: function() { this.__factory(); this._observe(); }, _observe: function() { this.city = new SmartSelector( 'hcsbk_city_toggler', { parent_box: 'div.cities_list', width: 125, margin: 0, usetext: true, onchange: $.proxy( this, '_changeBranch' ) } ); this.tab.tab_link.click( $.proxy( this, '_chooseTab' ) ); }, _chooseTab: function( e ) { var item = e.currentTarget, link = item.__link ? item.__link : item.__link = e.currentTarget.className.match( /\l_(\w+)/ )[1]; $( [ this.tab.contacts, this.tab.schedule ] ).hide(); $( this.tab[ link ] ).show(); $( this.tab.tab_link ).addClass( 'toggler' ); $( item ).removeClass( 'toggler' ); }, _changeBranch: function( new_value ) { this.tab_schedule_list.hide(); this.tab_contacts_list.hide(); $( '#tab_contacts_' + new_value + ',#tab_schedule_' + new_value ).show(); this._setCity( new_value ); $.cookie( 'city[id]', new_value ); $.cookie( 'country[id]', 30 ); }, _setCity: function( branch_id ) { $._postJSON ( this.url + 'set', {branch_id: branch_id} ); } } } )( jQuery );