define(function(require){var DecorillaView=require("DecorillaView");var Modal=require("Modal-ren");return DecorillaView.extend({defaults:{roomTypeId:0,bannerText:null,launchUrl:null,lastPageNum:0,samplesUrl:null,},initialize:function(options){this.options=$.extend({},this.defaults,options||{});this.dec_reg_from_page_key=$('body').data('dec_reg_from_page_key');$('.btn-room-samples').on('click',$.proxy(this.handleRoomSamplesClick,this));$('body').on('click','.featured-sample-container',$.proxy(this.handleSampleClick,this));$('body').on('click','.thumb-container',$.proxy(this.handleThumbClick,this));$('body').on('click','.portfolio-piece',$.proxy(this.handlePieceClick,this));$('body').on('click','.btn-phase',$.proxy(this.handlePhaseClick,this));_this=this;$(document).ready(function(){var page=1;var loading=!1;var lastPage=_this.options.lastPageNum;var triggerPoint=700;function loadMoreContent(){if(loading)return;loading=!0;$('.ajax-loader').show();page++;$.ajax({url:_this.options.samplesUrl,data:{page:page},success:function(response){var newContent=$(response).find('.after-top-hero').html();if(newContent.trim()!==''){$('.after-top-hero').append(newContent)} if(page>=lastPage){$(window).off('scroll')} loading=!1;$('.ajax-loader').hide()},error:function(){loading=!1;$('.ajax-loader').hide()}})} $(window).scroll(function(){var scrollPosition=$(window).scrollTop()+$(window).height();var triggerPosition=$(document).height()-triggerPoint;if(scrollPosition>triggerPosition&&!loading){loadMoreContent()}})})},handleRoomSamplesClick:function(evt){var $btn=$(evt.currentTarget);$('.room-title').html($btn.html());$('.vr-row,.sample-row,.testimonial-row,.navigation-row').addClass('d-none');$('.loading-row').removeClass('d-none')},handlePhaseClick:function(evt){evt.preventDefault();var $btn=$(evt.currentTarget);if($btn.hasClass('active')){return} var $samplesRow=$btn.parents('.sample-row');$samplesRow.find('.btn').removeClass('active');$btn.addClass('active');var targetClass=$btn.data('target');var $thumbRow=$samplesRow.next('.thumb-row');$thumbRow.find('.thumb-container').addClass('hidden');$thumbRow.find('.'+targetClass).removeClass('hidden');$thumbRow.find('.'+targetClass).first().click()},handleThumbClick:function(evt){var $btn=$(evt.currentTarget);if($btn.hasClass('active')){return} const $renderImage=$('#'+$btn.data('target'));const $renderImageContainer=$renderImage.parents('.featured-sample-container');$renderImageContainer.find('.featured-sample').hide();$renderImage.show();$btn.parents('.thumb-row').find('.thumb-container.active').removeClass('active');$btn.addClass('active');$renderImageContainer.data('index',$btn.data('index'))},handlePieceClick:function(evt){const $btn=$(evt.currentTarget);let remoteUrl='/project/sampleFlyerRenaissance/'+$btn.data('id')+'/type/portfolio';if(this.dec_reg_from_page_key){remoteUrl=`${remoteUrl}/dec_reg_from_page_key/${this.dec_reg_from_page_key}`} this.modal=new Modal({id:"p",remoteUrl:remoteUrl,buttons:[],modalDialogClass:"modal-xl modal-dialog-centered"})},handleSampleClick:function(evt){const $btn=$(evt.currentTarget);let remoteUrl='/project/sampleFlyerRenaissance/'+$btn.data('project-id')+'/room/'+$btn.data('room-id')+'/image/'+$btn.data('index');if(this.dec_reg_from_page_key){remoteUrl=`${remoteUrl}/dec_reg_from_page_key/${this.dec_reg_from_page_key}`} this.modal=new Modal({id:"p",remoteUrl:remoteUrl,buttons:[],modalDialogClass:"modal-xl modal-dialog-centered"})}});return SamplesView})