var loading = false; var userProfiles = { skip: 0, element: '', id: '', type: '', parentDiv: '', profilesLoaded: [], hideTimer: null, loadIndexUsers: function(parentDiv, element, id, type, skip) { this.loadUsers(parentDiv, element, id, type, skip, true); }, initTipTip: function() { $('.withTooltipVW').tipTip({ delay:100, maxWidth: '213px', minWidth: '213px', content: true, keepAlive: true, activation: 'click' }); }, loadUsers: function(parentDiv, element, id, type, skip, index) { var _this = this; _this.element = element; _this.id = id; _this.type = type; _this.parentDiv = parentDiv; $.ajax({ url: '/ajax/visitedwishing/moreusers/' + element + '/' + id + '/' + type + '/' + skip, type: 'POST', success: function(data, textStatus, jqXHR){ if(!data.result) return; if(data.result.profiles && data.result.profiles.users) { _this.drawProfiles(data.result.profiles.users, data.result.profiles.skip, index); } else { var profileDiv = $('.userProfiles'); profileDiv.empty(); } } }); }, drawProfiles : function(profiles, skip, index) { this.profilesLoaded = []; var profileDiv = $('.userProfiles'); profileDiv.empty(); $('#userProfileTpl').template('userProfileItem'); for(i in profiles) { this.profilesLoaded.push(profiles[i]); profileDiv.append($.tmpl('userProfileItem', profiles[i])); } $('#userProfileMoreLinkTpl').template('userProfileMoreLink'); if(skip >= 0) { var item = { element : this.element, id : this.id, type : this.type, skip : skip, index : index } profileDiv.append($.tmpl('userProfileMoreLink', item)); } $('.fullInfo').empty(); }, profileOver : function(userId) { if(this.profilesLoaded.length <= 0) return; var profile = null; for(i in this.profilesLoaded) { if(this.profilesLoaded[i].id == userId) { profile = this.profilesLoaded[i]; break; } } if(profile == null) return; $('.vwUsersTooltip_list .userpic').css('opacity','0.5'); $('.upicSm_' + userId).css('opacity','1'); $('#userProfileFullInfoTpl').template('userProfileFullInfo'); $('.fullInfo').empty().append($.tmpl('userProfileFullInfo', profile)); }, resetFullInfo : function() { } } function setVWStatus(element, id, type, sender) { if(loading) return; loading = true; var infoBlockOffsetTop = sender.offset().top + 35; var infoBlockOffsetLeft = sender.offset().left - 170; var toggle_after_ajax = element === 'Destination' && sender.attr('id').indexOf('_act') !== -1; var sender_toggled; if (sender.attr('id').indexOf('_act') == -1) { sender_toggled = $('#' + sender.attr('id') + '_act'); } else { sender_toggled = $('#' + sender.attr('id').replace('_act','')); } if (!toggle_after_ajax) { sender.hide(); sender_toggled.show(); } $.ajax({ url: '/ajax/setvwstatus', type: 'get', data: {type: type, element: element, id: id, ajax: true}, success: function(data) { loading = false; var el_id = sender.attr('id').split('_')[0]; if (data.saveResult.status == 'success') { if (toggle_after_ajax) { sender.hide(); sender_toggled.show(); } $(document).trigger('wvChange', [id, sender.parents('[data-id]'), data.saveResult]); $('.'+ type +'Counter'+id).each(function() {$(this).html(data.saveResult[type+'Counter']);}) } if (!data.saveResult.html) { return; } if($('#vw_mess')) { $('#vw_mess').remove(); } $('body').append( '