fix masonry on productions and home

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-28 12:54:27 +02:00
parent f4ad71e57a
commit 9b45cbb77c
7 changed files with 176 additions and 147 deletions
@@ -18,6 +18,9 @@
}; };
function initAjax(){ function initAjax(){
_$form = $('#edlp-search-form:not(.ajax-enabled)');
if(!_$form.length) return false;
console.log('EdlpSearch initAjaxForm()'); console.log('EdlpSearch initAjaxForm()');
_$form = $('#edlp-search-form:not(.ajax-enabled)') _$form = $('#edlp-search-form:not(.ajax-enabled)')
.on('submit', onSubmitForm) .on('submit', onSubmitForm)
@@ -186,9 +186,10 @@
console.log('ajax link loaded : data', data); console.log('ajax link loaded : data', data);
_$body.removeClass('ajax-loading'); _$body.removeClass('ajax-loading');
// replace all content with newly loaded // reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
// TODO: build a system to replace or append contents (like studio + search) // TODO: build a system to replace or append contents (like studio + search)
_$row.html(data.rendered); _$row.removeAttr('style').html(data.rendered);
// add close btn // add close btn
if(sys_path != 'procuction'){ if(sys_path != 'procuction'){
@@ -228,9 +229,9 @@
initAjaxLinks(); initAjaxLinks();
// trigger other modules behaviours
_$body.trigger({'type':'new-content-ajax-loaded'}); _$body.trigger({'type':'new-content-ajax-loaded'});
// and call druapl behaviours
// call behaviours
Drupal.attachBehaviors(_$row[0]); Drupal.attachBehaviors(_$row[0]);
}; };
@@ -799,28 +800,36 @@
showHideControls(){ showHideControls(){
// console.log('CompoPlayer showHideNextBtn(), playing:'+this.playing+', paused:'+this.paused); // console.log('CompoPlayer showHideNextBtn(), playing:'+this.playing+', paused:'+this.paused);
// global playing // global playing
if(this.playing && !this.paused){ if(this.$controls){
this.$controls.addClass('is-playing'); if(this.playing && !this.paused){
}else{ this.$controls.addClass('is-playing');
this.$controls.removeClass('is-playing'); }else{
this.$controls.removeClass('is-playing');
}
} }
// playpause // playpause
if(this.playlist.length > 0){ if(this.$playpause){
this.$playpause.addClass('is-active'); if(this.playlist.length > 0){
}else{ this.$playpause.addClass('is-active');
this.$playpause.removeClass('is-active'); }else{
this.$playpause.removeClass('is-active');
}
} }
// next // next
if(this.playing && this.playlist.length > 1 && this.current_index < this.playlist.length -1){ if(this.$next){
this.$next.addClass('is-active'); if(this.playing && this.playlist.length > 1 && this.current_index < this.playlist.length -1){
}else{ this.$next.addClass('is-active');
this.$next.removeClass('is-active'); }else{
this.$next.removeClass('is-active');
}
} }
// previous // previous
if(this.playing && this.playlist.length > 1 && this.current_index > 0){ if(this.$previous){
this.$previous.addClass('is-active'); if(this.playing && this.playlist.length > 1 && this.current_index > 0){
}else{ this.$previous.addClass('is-active');
this.$previous.removeClass('is-active'); }else{
this.$previous.removeClass('is-active');
}
} }
return this; return this;
}, },
@@ -859,51 +868,6 @@
}; };
// _ _
// | || |___ _ __ ___
// | __ / _ \ ' \/ -_)
// |_||_\___/_|_|_\___|
function initHome(){
addCloseBtnToCols();
console.log('theme : initProductions');
var $grid = $('.row', _$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2'
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
}
// ___ _ _ _
// | _ \_ _ ___ __| |_ _ __| |_(_)___ _ _ ___
// | _/ '_/ _ \/ _` | || / _| _| / _ \ ' \(_-<
// |_| |_| \___/\__,_|\_,_\__|\__|_\___/_||_/__/
function initProductions(){
console.log('theme : initProductions');
var $grid = $('.row', _$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2'
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
// var $grid = $('.row', _$row).imagesLoaded( function() {
// // init Masonry after all images have loaded
// $grid.masonry({
// itemSelector:'.col',
// columnWidth:'.col-2'
// });
// });
};
// ___ _ ___ // ___ _ ___
// | __| _ ___ _ _| |_| _ \__ _ __ _ ___ // | __| _ ___ _ _| |_| _ \__ _ __ _ ___
// | _| '_/ _ \ ' \ _| _/ _` / _` / -_) // | _| '_/ _ \ ' \ _| _/ _` / _` / -_)
@@ -917,6 +881,51 @@
} }
function initHome(){
addCloseBtnToCols();
console.log('theme : initHome');
// console.log('theme : initProductions');
var $grid = $('.grid',_$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2',
horizontalOrder: true,
containerStyle: null,
// disable initial layout
initLayout: false,
});
// bind event
// $grid.masonry( 'on', 'layoutComplete', function() {
// console.log('layout is complete');
// });
$grid.imagesLoaded(function(){
$grid.masonry();
});
}
// ___ _ _ _
// | _ \_ _ ___ __| |_ _ __| |_(_)___ _ _ ___
// | _/ '_/ _ \/ _` | || / _| _| / _ \ ' \(_-<
// |_| |_| \___/\__,_|\_,_\__|\__|_\___/_||_/__/
function initProductions(){
// console.log('theme : initProductions');
var $grid = $('.grid',_$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2',
horizontalOrder: true,
containerStyle: null,
// disable initial layout
initLayout: false,
});
// bind event
// $grid.masonry( 'on', 'layoutComplete', function() {
// console.log('layout is complete');
// });
$grid.imagesLoaded(function(){
$grid.masonry();
});
};
// __ __ _ _ // __ __ _ _
// | \/ |___ __| |__ _| |___ // | \/ |___ __| |__ _| |___
// | |\/| / _ \/ _` / _` | (_-< // | |\/| / _ \/ _` / _` | (_-<
@@ -2144,7 +2144,8 @@ body.path-agenda main .col > .wrapper {
text-transform: uppercase; } text-transform: uppercase; }
body.path-frontpage .layout-content .row, body.path-productions .layout-content .row { body.path-frontpage .layout-content .row, body.path-productions .layout-content .row {
white-space: normal; } white-space: normal;
min-height: 100%; }
body.path-frontpage .layout-content .row .col, body.path-productions .layout-content .row .col { body.path-frontpage .layout-content .row .col, body.path-productions .layout-content .row .col {
height: auto; } height: auto; }
body.path-frontpage .layout-content .row .col.col-2:last-child, body.path-productions .layout-content .row .col.col-2:last-child { body.path-frontpage .layout-content .row .col.col-2:last-child, body.path-productions .layout-content .row .col.col-2:last-child {
@@ -186,9 +186,10 @@
console.log('ajax link loaded : data', data); console.log('ajax link loaded : data', data);
_$body.removeClass('ajax-loading'); _$body.removeClass('ajax-loading');
// replace all content with newly loaded // reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
// TODO: build a system to replace or append contents (like studio + search) // TODO: build a system to replace or append contents (like studio + search)
_$row.html(data.rendered); _$row.removeAttr('style').html(data.rendered);
// add close btn // add close btn
if(sys_path != 'procuction'){ if(sys_path != 'procuction'){
@@ -228,9 +229,9 @@
initAjaxLinks(); initAjaxLinks();
// trigger other modules behaviours
_$body.trigger({'type':'new-content-ajax-loaded'}); _$body.trigger({'type':'new-content-ajax-loaded'});
// and call druapl behaviours
// call behaviours
Drupal.attachBehaviors(_$row[0]); Drupal.attachBehaviors(_$row[0]);
}; };
@@ -799,28 +800,36 @@
showHideControls(){ showHideControls(){
// console.log('CompoPlayer showHideNextBtn(), playing:'+this.playing+', paused:'+this.paused); // console.log('CompoPlayer showHideNextBtn(), playing:'+this.playing+', paused:'+this.paused);
// global playing // global playing
if(this.playing && !this.paused){ if(this.$controls){
this.$controls.addClass('is-playing'); if(this.playing && !this.paused){
}else{ this.$controls.addClass('is-playing');
this.$controls.removeClass('is-playing'); }else{
this.$controls.removeClass('is-playing');
}
} }
// playpause // playpause
if(this.playlist.length > 0){ if(this.$playpause){
this.$playpause.addClass('is-active'); if(this.playlist.length > 0){
}else{ this.$playpause.addClass('is-active');
this.$playpause.removeClass('is-active'); }else{
this.$playpause.removeClass('is-active');
}
} }
// next // next
if(this.playing && this.playlist.length > 1 && this.current_index < this.playlist.length -1){ if(this.$next){
this.$next.addClass('is-active'); if(this.playing && this.playlist.length > 1 && this.current_index < this.playlist.length -1){
}else{ this.$next.addClass('is-active');
this.$next.removeClass('is-active'); }else{
this.$next.removeClass('is-active');
}
} }
// previous // previous
if(this.playing && this.playlist.length > 1 && this.current_index > 0){ if(this.$previous){
this.$previous.addClass('is-active'); if(this.playing && this.playlist.length > 1 && this.current_index > 0){
}else{ this.$previous.addClass('is-active');
this.$previous.removeClass('is-active'); }else{
this.$previous.removeClass('is-active');
}
} }
return this; return this;
}, },
@@ -859,51 +868,6 @@
}; };
// _ _
// | || |___ _ __ ___
// | __ / _ \ ' \/ -_)
// |_||_\___/_|_|_\___|
function initHome(){
addCloseBtnToCols();
console.log('theme : initProductions');
var $grid = $('.row', _$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2'
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
}
// ___ _ _ _
// | _ \_ _ ___ __| |_ _ __| |_(_)___ _ _ ___
// | _/ '_/ _ \/ _` | || / _| _| / _ \ ' \(_-<
// |_| |_| \___/\__,_|\_,_\__|\__|_\___/_||_/__/
function initProductions(){
console.log('theme : initProductions');
var $grid = $('.row', _$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2'
});
// layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
// var $grid = $('.row', _$row).imagesLoaded( function() {
// // init Masonry after all images have loaded
// $grid.masonry({
// itemSelector:'.col',
// columnWidth:'.col-2'
// });
// });
};
// ___ _ ___ // ___ _ ___
// | __| _ ___ _ _| |_| _ \__ _ __ _ ___ // | __| _ ___ _ _| |_| _ \__ _ __ _ ___
// | _| '_/ _ \ ' \ _| _/ _` / _` / -_) // | _| '_/ _ \ ' \ _| _/ _` / _` / -_)
@@ -917,6 +881,51 @@
} }
function initHome(){
addCloseBtnToCols();
console.log('theme : initHome');
// console.log('theme : initProductions');
var $grid = $('.grid',_$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2',
horizontalOrder: true,
containerStyle: null,
// disable initial layout
initLayout: false,
});
// bind event
// $grid.masonry( 'on', 'layoutComplete', function() {
// console.log('layout is complete');
// });
$grid.imagesLoaded(function(){
$grid.masonry();
});
}
// ___ _ _ _
// | _ \_ _ ___ __| |_ _ __| |_(_)___ _ _ ___
// | _/ '_/ _ \/ _` | || / _| _| / _ \ ' \(_-<
// |_| |_| \___/\__,_|\_,_\__|\__|_\___/_||_/__/
function initProductions(){
// console.log('theme : initProductions');
var $grid = $('.grid',_$row).masonry({
itemSelector:'.col',
columnWidth:'.col-2',
horizontalOrder: true,
containerStyle: null,
// disable initial layout
initLayout: false,
});
// bind event
// $grid.masonry( 'on', 'layoutComplete', function() {
// console.log('layout is complete');
// });
$grid.imagesLoaded(function(){
$grid.masonry();
});
};
// __ __ _ _ // __ __ _ _
// | \/ |___ __| |__ _| |___ // | \/ |___ __| |__ _| |___
// | |\/| / _ \/ _` / _` | (_-< // | |\/| / _ \/ _` / _` | (_-<
@@ -1043,6 +1043,7 @@ body.path-agenda main .col{
body.path-frontpage, body.path-productions{ body.path-frontpage, body.path-productions{
.layout-content .row{ .layout-content .row{
white-space: normal; white-space: normal;
min-height: 100%;
.col{ .col{
height:auto; height:auto;
&.col-2:last-child{ &.col-2:last-child{
@@ -15,17 +15,21 @@
</div> </div>
</div> </div>
#} #}
{% for node in nodes %} <div class="grid">
<div class="col col-{{ node.cols }}">
{% for node in nodes %}
<div class="col col-{{ node.cols }}">
<div class="wrapper">
{{ node.build }}
</div>
</div>
{% endfor %}
<div class="agenda col col-2">
<div class="wrapper"> <div class="wrapper">
{{ node.build }} {{ agenda }}
</div> </div>
</div> </div>
{% endfor %}
<div class="agenda col col-2">
<div class="wrapper">
{{ agenda }}
</div>
</div> </div>
@@ -1,7 +1,9 @@
{% for node in nodes %} <div class="grid">
<div class="col col-{{ node.cols }}"> {% for node in nodes %}
<div class="wrapper"> <div class="col col-{{ node.cols }}">
{{ node.build }} <div class="wrapper">
{{ node.build }}
</div>
</div> </div>
</div> {% endfor %}
{% endfor %} </div>