t_culture1_2/modules/space/show.html.erb

228 lines
7.7 KiB
Plaintext
Raw Permalink Normal View History

2023-03-26 01:43:40 +00:00
<article class="s-space show-space">
<h3 class="s-space__apartment-name">{{floor-title}}</h3>
<div class="s-space__apartment-layout">
{{floor-layout}}
</div>
<!-- <div class="s-space__floor-img-small">
<img class="img-btn" src="{{floor-frontend-image-thumb}}" alt="{{image-alt}}">
</div>
<div class="s-space__floor-img-large">
<img src="{{floor-frontend-image}}" alt="{{image-alt}}">
</div>
-->
<div class="s-space__back-btn-wrap">
<a href="{{building-back-link}}" class="s-space__back-btn btn btn-primary"><i class="fa fa-arrow-left"></i></a>
</div>
</article>
<div id="space-for-ad-banner"></div>
{{style_label}}
<script>
(function() {
var layout = $(".s-space__apartment-layout").eq(-1)
var canvas = layout.find("#full-layout-canvas");
var layoutImage =layout.find("#layout-image");
var cover = canvas.eq(-1).find(".image-cover");
var pxToDeduct = (Modernizr.touch ? 157 : 257);
var windowHeight = ($(window).height() - pxToDeduct);
var coverImageHeight = (parseInt(windowHeight));
var tmpImg = new Image();
var $box = $('.selection-box');
var $pin = $('<a class="s-space__pin-link" href="#"><div class="pin"></div><div class="pulse"></div></a>');
var $slideshow = null;
var $closeBtn = $('<div class="s-space__close-btn btn-close"><i class="fa fa-times"></i></div>');
var floorId = "{{floor-id}}";
var pageId = "{{page-id}}";
var spaceForAdBanner = layout.parents('.s-space.show-space').next('#space-for-ad-banner');
var loading = $("div.loading-cover");
var $controlBtn = null;
var $controlIcon = null;
var $collapse = null;
var active_color = '{{hover_color}}' || '#e84c3d';
var map_color = '{{bg_color}}' || '#00a8f3';
var block_color = '{{block_color}}' || 'rgba(0,0,0,0.4)';
canvas.css('height','');
cover.css('height','');
cover.css('width','');
layoutImage.css('height','');
layoutImage.css('width','100%');
tmpImg.src = layoutImage.attr('src') ;
spaceForAdBanner.hide()
$('.selection-box-btn-holder').remove();
$.ajax({
url: "/xhr/spaces/get_floor_units",
data: {floor_id : floorId, page_id : pageId },
dataType: 'JSON'
}).done(function(data) {
$box.each(function(i) {
var id = $(this).data('unit-id');
var obj = data.units.filter(function(x) {
return x.id == id;
});
var temp = $pin.clone();
temp.attr('href', obj[0].url);
if (obj[0].url == "#") {
temp.find('.pulse').remove();
}
var text = $(this).find('.selection-box-label')
text.append('<div class="anchor"></div>')
temp.prepend('<i class="fa fa-map-marker"></i>')
temp.prepend(text)
temp.find('.fa-map-marker').css('color',map_color)
$(this).on('mouseover',function(){
$(this).css('background-color',block_color)
})
$(this).on('mouseleave',function(){
var pin_link = $(this).find('.s-space__pin-link')
if (!pin_link.is(':focus')){
$(this).find('.selection-box-label').removeClass('active')
inactive_map(pin_link)
}
})
temp.on('focus',function(){
$(this).parents('.selection-box.overlay').find('.selection-box-label').addClass('active')
active_map(this)
})
temp.on('mouseover',function(){
$(this).parents('.selection-box.overlay').find('.selection-box-label').addClass('active')
active_map(this)
})
temp.on('blur',function(){
$(this).parents('.selection-box.overlay').find('.selection-box-label').removeClass('active')
inactive_map(this)
})
temp.on('mouseleave',function(){
if (!$(this).is(':focus')){
$(this).parents('.selection-box.overlay').find('.selection-box-label').removeClass('active')
inactive_map(this)
}
})
//temp.prepend($(this).find('.selection-box-label.absolute-center'))
$(this).append(temp);
});
canvas.find(".s-space__pin-link").on("click",pinLinkClickHandler);
});
var pinLinkClickHandler = function(){
var el = $(this);
if(el.attr("href") != "#"){
loading.removeClass("loading-hide");
$.ajax({
url : el.attr("href"),
dataType : "html",
type : "get"
}).done(function(data){
var template = $($(data).find('#main-content').html())
template.find('.s-space__back-btn-wrap').hide()
createAdbanner(template);
spaceForAdBanner.show()
$closeBtn
.on('click', destroyAdbanner)
.prependTo(template);
});
}
else{
destroyAdbanner()
}
return false;
};
function createAdbanner(data) {
spaceForAdBanner.html(data);
$closeBtn.removeClass('active');
imageLoad(function(){
setTimeout(function(){
loading.addClass("loading-hide");
},1000);
});
$slideshow = data.find('.cycle-slideshow');
$slideshow.cycle();
$controlBtn = data.find('.w-ad-banner__btn');
$controlIcon = $controlBtn.find('i');
$collapse = data.find('.w-ad-banner__collpase');
$(document).on('keyup.adbanner', function(e) {
if (e.keyCode === 37) {
$slideshow.cycle('prev');
} else if (e.keyCode === 39) {
$slideshow.cycle('next');
} else if (e.keyCode === 27) {
destroyAdbanner();
}
});
$controlBtn.on('click', function(e) {
if ($slideshow.hasClass('cycle-paused')) {
$slideshow.cycle('resume');
$controlIcon.attr('class', 'fa fa-pause');
} else {
$slideshow.cycle('pause');
$controlIcon.attr('class', 'fa fa-play');
}
});
// collapse cycle pager and close button
$collapse.on('click', function(e) {
var $this = $(this);
console.log($this.parents('.w-ad-banner.s-showcase').find('.w-ad-banner__wrap.cycle-slideshow'))
if ($this.hasClass('active')) {
$this
.removeClass('active')
.find('.fa')
.removeClass('fa-chevron-up')
.addClass('fa-chevron-down');
$this.parents('.w-ad-banner.s-showcase').find('.w-ad-banner__wrap.cycle-slideshow').show();
} else {
$this
.addClass('active')
.find('.fa')
.removeClass('fa-chevron-down')
.addClass('fa-chevron-up');
$this.parents('.w-ad-banner.s-showcase').find('.w-ad-banner__wrap.cycle-slideshow').hide();
}
$this.parents('.w-ad-banner__pager-wrap.w-ad-banner__page--active').toggleClass('active');
});
}
var imageLoad = function(fn){
var images = spaceForAdBanner.find("img.w-ad-banner__image");
images_loaded = 0;
images.each(function(){
var img = new Image();
img.src = $(this).attr("src");
img.onload = function(){
images_loaded++;
if(typeof fn == "function" && images_loaded == images.length){
fn.call();
}
};
});
};
function destroyAdbanner() {
if ($slideshow){
$slideshow.cycle('destroy');
}
$closeBtn.remove();
spaceForAdBanner
.children()
.remove()
.end()
.hide();
$(document).off('keyup.adbanner');
}
function active_map(ele){
$(ele).find('.fa-map-marker').css('color',active_color)
$(ele).parents('.selection-box.overlay').eq(0).css('background-color',block_color)
}
function inactive_map(ele){
$(ele).find('.fa-map-marker').css('color',map_color)
$(ele).parents('.selection-box.overlay').eq(0).css('background-color','')
}
}());
</script>