auto load article on audio open if map's articl filter is on

This commit is contained in:
2018-04-17 15:59:51 +02:00
parent a3a4e3922c
commit 29ad08648f
4 changed files with 80 additions and 50 deletions
@@ -127,6 +127,7 @@
// check for viewmode attribute
if(view_mode){
state.ajax_path += '/'+view_mode;
state.view_mode = view_mode;
}
}else if(term_match){
// terms are always entrees, there's no other vocabulary links in front
@@ -148,7 +149,7 @@
return state;
};
function ajaxLoadContent(state){
console.log('ajaxLoadContent : url', state.url);
console.log('ajaxLoadContent : state', state);
_$body.addClass('ajax-loading');
var path = window.location.origin + Drupal.url(state.ajax_path);
@@ -166,7 +167,7 @@
_$body.removeClass('ajax-loading');
};
function onAjaxLoaded(data, state){
console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
console.log('ajax loaded : state', state);
// console.log(data);
// reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
@@ -200,7 +201,7 @@
// handle clicked link classes
$('.ajax-loading').removeClass('ajax-loading');
$('.is-active').removeClass('is-active');
$('.ajax-link.is-active').removeClass('is-active');
$('.is-active-trail').removeClass('is-active-trail');
if(typeof state.selector != 'undefined'){
@@ -302,11 +303,9 @@
};
function initAudioLinksInContent(){
// console.log('initAudioLinksInContent');
_$row.find('a.audio-link')
.on('mouseover', function(event) {
event.preventDefault();
// console.log('onmouseover audio-link');
if(_corpus_ready){
_$corpus_canvas.trigger({
type:'mouseover-audio-link',
@@ -316,7 +315,6 @@
})
.on('mouseout', function(event) {
event.preventDefault();
// console.log('onmouseout audio-link');
if(_corpus_ready){
_$corpus_canvas.trigger({
type:'mouseout-audio-link',
@@ -570,6 +568,7 @@
}
var view_mode = $link.attr('viewmode');
var state = getSysPathState(sys_path, view_mode);
state.url = $(this).attr('href');
@@ -588,7 +587,6 @@
return false;
};
// ___
// / __|___ _ _ _ __ _ _ ___
// | (__/ _ \ '_| '_ \ || (_-<
@@ -607,6 +605,7 @@
//console.log('theme : corpus-cliked-on-node', e);
_audioPlayer
.emmit('stop-shuffle')
.setAutoOpenArticle(e.article)
.openDocument(e.target_node);
});
@@ -678,6 +677,9 @@
this.historic = [];
this.shuffle_is_active = false;
// artciles
this.auto_open_article = false;
// object events
this.event_handlers = {
'audio-open-document':[],
@@ -821,7 +823,8 @@
// debugger;
this.audio.pause();
// don't close player if article or transcript is open
if(!_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)){
if(!(_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)
&& (_$body.is('.view-mode-article') || _$body.is('.view-mode-transcript')))){
this.timeOutToHide();
}
},
@@ -865,11 +868,19 @@
this.$cartel.html(data.rendered).removeClass('loading');
_$body.trigger({'type':'new-audio-cartel-loaded'});
initAjaxLinks();
if(this.auto_open_article){
this.$cartel.find('a.link-article').trigger('click');
this.auto_open_article = false;
}
},
onNodeLoadFail(jqxhr, textStatus, error){
console.warn('AudioPlayer node load failed', jqxhr.responseText);
this.$cartel.removeClass('loading').html('');
},
setAutoOpenArticle(art){
this.auto_open_article = art;
return this;
},
// global
show(){
this.$container.addClass('visible');
@@ -1317,7 +1328,6 @@
});
};
// ___ _ _ _
// | __|_ _ _ _ ___ __ _(_)__| |_ _ _ ___ _ __ ___ _ _| |_
// | _|| ' \| '_/ -_) _` | (_-< _| '_/ -_) ' \/ -_) ' \ _|
@@ -127,6 +127,7 @@
// check for viewmode attribute
if(view_mode){
state.ajax_path += '/'+view_mode;
state.view_mode = view_mode;
}
}else if(term_match){
// terms are always entrees, there's no other vocabulary links in front
@@ -148,7 +149,7 @@
return state;
};
function ajaxLoadContent(state){
console.log('ajaxLoadContent : url', state.url);
console.log('ajaxLoadContent : state', state);
_$body.addClass('ajax-loading');
var path = window.location.origin + Drupal.url(state.ajax_path);
@@ -166,7 +167,7 @@
_$body.removeClass('ajax-loading');
};
function onAjaxLoaded(data, state){
console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
console.log('ajax loaded : state', state);
// console.log(data);
// reset all style may been added by other pages (like masonry for productions)
// and replace all content with newly loaded
@@ -200,7 +201,7 @@
// handle clicked link classes
$('.ajax-loading').removeClass('ajax-loading');
$('.is-active').removeClass('is-active');
$('.ajax-link.is-active').removeClass('is-active');
$('.is-active-trail').removeClass('is-active-trail');
if(typeof state.selector != 'undefined'){
@@ -302,11 +303,9 @@
};
function initAudioLinksInContent(){
// console.log('initAudioLinksInContent');
_$row.find('a.audio-link')
.on('mouseover', function(event) {
event.preventDefault();
// console.log('onmouseover audio-link');
if(_corpus_ready){
_$corpus_canvas.trigger({
type:'mouseover-audio-link',
@@ -316,7 +315,6 @@
})
.on('mouseout', function(event) {
event.preventDefault();
// console.log('onmouseout audio-link');
if(_corpus_ready){
_$corpus_canvas.trigger({
type:'mouseout-audio-link',
@@ -570,6 +568,7 @@
}
var view_mode = $link.attr('viewmode');
var state = getSysPathState(sys_path, view_mode);
state.url = $(this).attr('href');
@@ -588,7 +587,6 @@
return false;
};
// ___
// / __|___ _ _ _ __ _ _ ___
// | (__/ _ \ '_| '_ \ || (_-<
@@ -607,6 +605,7 @@
//console.log('theme : corpus-cliked-on-node', e);
_audioPlayer
.emmit('stop-shuffle')
.setAutoOpenArticle(e.article)
.openDocument(e.target_node);
});
@@ -678,6 +677,9 @@
this.historic = [];
this.shuffle_is_active = false;
// artciles
this.auto_open_article = false;
// object events
this.event_handlers = {
'audio-open-document':[],
@@ -821,7 +823,8 @@
// debugger;
this.audio.pause();
// don't close player if article or transcript is open
if(!_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)){
if(!(_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)
&& (_$body.is('.view-mode-article') || _$body.is('.view-mode-transcript')))){
this.timeOutToHide();
}
},
@@ -865,11 +868,19 @@
this.$cartel.html(data.rendered).removeClass('loading');
_$body.trigger({'type':'new-audio-cartel-loaded'});
initAjaxLinks();
if(this.auto_open_article){
this.$cartel.find('a.link-article').trigger('click');
this.auto_open_article = false;
}
},
onNodeLoadFail(jqxhr, textStatus, error){
console.warn('AudioPlayer node load failed', jqxhr.responseText);
this.$cartel.removeClass('loading').html('');
},
setAutoOpenArticle(art){
this.auto_open_article = art;
return this;
},
// global
show(){
this.$container.addClass('visible');
@@ -1317,7 +1328,6 @@
});
};
// ___ _ _ _
// | __|_ _ _ _ ___ __ _(_)__| |_ _ _ ___ _ __ ___ _ _| |_
// | _|| ' \| '_/ -_) _` | (_-< _| '_/ -_) ' \/ -_) ' \ _|