|
@@ -56,6 +56,11 @@
|
|
// initEvents();
|
|
// initEvents();
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
|
|
+ // __ __ _ _ _
|
|
|
|
+ // | \/ |___| |__(_) |___
|
|
|
|
+ // | |\/| / _ \ '_ \ | / -_)
|
|
|
|
+ // |_| |_\___/_.__/_|_\___|
|
|
function initHomeMobile(){
|
|
function initHomeMobile(){
|
|
$('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
|
|
$('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
|
|
.addClass('closed');
|
|
.addClass('closed');
|
|
@@ -64,19 +69,16 @@
|
|
$('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
|
|
$('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
|
|
.on('click', onClickHomeMobileIndex);
|
|
.on('click', onClickHomeMobileIndex);
|
|
};
|
|
};
|
|
-
|
|
|
|
function onClickHomeMobileNotice(e){
|
|
function onClickHomeMobileNotice(e){
|
|
// console.log('onClickHomeMobileNotice');
|
|
// console.log('onClickHomeMobileNotice');
|
|
// var $part = $(this).parent();//parents('.taxonomy-term');
|
|
// var $part = $(this).parent();//parents('.taxonomy-term');
|
|
toggleEntreeOpening($(this).parent(), 'notice');
|
|
toggleEntreeOpening($(this).parent(), 'notice');
|
|
};
|
|
};
|
|
-
|
|
|
|
function onClickHomeMobileIndex(e){
|
|
function onClickHomeMobileIndex(e){
|
|
// console.log('onClickHomeMobileIndex');
|
|
// console.log('onClickHomeMobileIndex');
|
|
// var $part = $(this).parent();//parents('.taxonomy-term');
|
|
// var $part = $(this).parent();//parents('.taxonomy-term');
|
|
toggleEntreeOpening($(this).parent(), 'index');
|
|
toggleEntreeOpening($(this).parent(), 'index');
|
|
};
|
|
};
|
|
-
|
|
|
|
function toggleEntreeOpening($e, part){
|
|
function toggleEntreeOpening($e, part){
|
|
$e.toggleClass('closed')
|
|
$e.toggleClass('closed')
|
|
.parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
|
|
.parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
|
|
@@ -521,6 +523,7 @@
|
|
};
|
|
};
|
|
function initFirstLoad(){
|
|
function initFirstLoad(){
|
|
console.log('theme : initFirstLoad()');
|
|
console.log('theme : initFirstLoad()');
|
|
|
|
+ console.log('window.location', window.location);
|
|
|
|
|
|
// var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
|
|
// var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
|
|
var edlp_origin = JSON.parse(window.localStorage.getItem('edlp_origin'));
|
|
var edlp_origin = JSON.parse(window.localStorage.getItem('edlp_origin'));
|
|
@@ -529,81 +532,87 @@
|
|
if(edlp_origin != null && edlp_origin.sys_path){
|
|
if(edlp_origin != null && edlp_origin.sys_path){
|
|
// hash is used as viewmode for taxonomy term entrees load (index or notice)
|
|
// hash is used as viewmode for taxonomy term entrees load (index or notice)
|
|
// and for audio contents (article|transcript)
|
|
// and for audio contents (article|transcript)
|
|
- var view_mode = edlp_origin.hash.replace('#', '');
|
|
|
|
-
|
|
|
|
- // create history state
|
|
|
|
- var state = getSysPathState(edlp_origin.sys_path, view_mode);
|
|
|
|
-
|
|
|
|
- // open entree tray in case of entree index|notice
|
|
|
|
- // (index or notice will be opened with ajaxLoadContent)
|
|
|
|
- // refactorized with new infos from edlp_origin
|
|
|
|
- // if(view_mode){
|
|
|
|
- if(edlp_origin.entity_type == "taxonomy_term"
|
|
|
|
- && edlp_origin.entity_bundle == "entrees"
|
|
|
|
- && view_mode){
|
|
|
|
- // var $link = $('[href="'+edlp_origin.url+'"][viewmode="'+view_mode+'"]');
|
|
|
|
- // var selector = $link.attr('selector') || null;
|
|
|
|
-
|
|
|
|
- // record the selector in the state for actions after ajaxContentLoaded
|
|
|
|
- state.selector = 'entree-'+view_mode+'-link-'+edlp_origin.entity_id; // entree-index-link-125
|
|
|
|
- // if(selector){
|
|
|
|
- // in case of entree link (actualy, selector is used only for entries links)
|
|
|
|
- // TODO: use a promise
|
|
|
|
- // TODO: but what if corpus ready before onAjaxLoaded >> use a promise !!
|
|
|
|
- if(_corpus_ready){
|
|
|
|
- _$corpus_canvas.trigger({
|
|
|
|
- type:'open-entree',
|
|
|
|
- // tid:$link.attr('tid')
|
|
|
|
- tid:edlp_origin.entity_id
|
|
|
|
- });
|
|
|
|
|
|
+ var hash = edlp_origin.hash.replace('#', '');
|
|
|
|
+
|
|
|
|
+ // if hash is random, RandomPlayer will be started when playlist sent by corpus.js
|
|
|
|
+ if(hash != "random"){
|
|
|
|
+ // create history state
|
|
|
|
+ var state = getSysPathState(edlp_origin.sys_path, hash);
|
|
|
|
+
|
|
|
|
+ // open entree tray in case of entree index|notice
|
|
|
|
+ // (index or notice will be opened with ajaxLoadContent)
|
|
|
|
+ // refactorized with new infos from edlp_origin
|
|
|
|
+ // if(hash){
|
|
|
|
+ if(edlp_origin.entity_type == "taxonomy_term"
|
|
|
|
+ && edlp_origin.entity_bundle == "entrees"
|
|
|
|
+ && hash){
|
|
|
|
+ // var $link = $('[href="'+edlp_origin.url+'"][viewmode="'+hash+'"]');
|
|
|
|
+ // var selector = $link.attr('selector') || null;
|
|
|
|
+
|
|
|
|
+ // record the selector in the state for actions after ajaxContentLoaded
|
|
|
|
+ state.selector = 'entree-'+hash+'-link-'+edlp_origin.entity_id; // entree-index-link-125
|
|
|
|
+ // if(selector){
|
|
|
|
+ // in case of entree link (actualy, selector is used only for entries links)
|
|
|
|
+ // TODO: use a promise
|
|
|
|
+ // TODO: but what if corpus ready before onAjaxLoaded >> use a promise !!
|
|
|
|
+ if(_corpus_ready){
|
|
|
|
+ _$corpus_canvas.trigger({
|
|
|
|
+ type:'open-entree',
|
|
|
|
+ // tid:$link.attr('tid')
|
|
|
|
+ tid:edlp_origin.entity_id
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
|
|
|
|
+ // .is-active class is added by onAjaxLoaded() (when content is loaded)
|
|
|
|
+ // $('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
|
|
|
|
+ $('li.entree[tid="'+edlp_origin.entity_id+'"] a.term-link').addClass('is-active');
|
|
|
|
+ }
|
|
|
|
+ // }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // check if audio link
|
|
|
|
+ // only if not random link
|
|
|
|
+ if(edlp_origin.audio_url){
|
|
|
|
+ var node = {
|
|
|
|
+ nid:edlp_origin.entity_id,
|
|
|
|
+ audio_url:edlp_origin.audio_url
|
|
|
|
+ };
|
|
|
|
+ _audioPlayer.openDocument(node, 'history_first_load');
|
|
|
|
+ if(hash == ""){
|
|
|
|
+ // if audio only record in state
|
|
|
|
+ state.audio = true;
|
|
|
|
+ state.node = node;
|
|
|
|
+ // we don't laod ajax content so we boot the home
|
|
|
|
+ _$body.attr('booted', 'booted');
|
|
}else{
|
|
}else{
|
|
- // else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
|
|
|
|
- // .is-active class is added by onAjaxLoaded() (when content is loaded)
|
|
|
|
- // $('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
|
|
|
|
- $('li.entree[tid="'+edlp_origin.entity_id+'"] a.term-link').addClass('is-active');
|
|
|
|
|
|
+ // ajax load content for audio only if article or transcript
|
|
|
|
+ ajaxLoadContent(state);
|
|
}
|
|
}
|
|
- // }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // check if audio link
|
|
|
|
- if(edlp_origin.audio_url){
|
|
|
|
- var node = {
|
|
|
|
- nid:edlp_origin.entity_id,
|
|
|
|
- audio_url:edlp_origin.audio_url
|
|
|
|
- };
|
|
|
|
- _audioPlayer.openDocument(node, 'history_first_load');
|
|
|
|
- if(view_mode == ""){
|
|
|
|
- // if audio only record in state
|
|
|
|
- state.audio = true;
|
|
|
|
- state.node = node;
|
|
|
|
- // we don't laod ajax content so we boot the home
|
|
|
|
- _$body.attr('booted', 'booted');
|
|
|
|
- }else{
|
|
|
|
- // ajax load content for audio only if article or transcript
|
|
|
|
|
|
+ }
|
|
|
|
+ // only if not entree path
|
|
|
|
+ // only if not audio (without article or transcript) path
|
|
|
|
+ else if(state.ajax_path){
|
|
|
|
+ // load content through ajax
|
|
|
|
+ // ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
|
|
ajaxLoadContent(state);
|
|
ajaxLoadContent(state);
|
|
}
|
|
}
|
|
- }
|
|
|
|
- // only if not entree path
|
|
|
|
- // only if not audio (without article or transcript) path
|
|
|
|
- else if(state.ajax_path){
|
|
|
|
- // load content through ajax
|
|
|
|
- // ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
|
|
|
|
- ajaxLoadContent(state);
|
|
|
|
- }
|
|
|
|
|
|
|
|
- if(state.entree_tid){
|
|
|
|
- openEntree(state.entree_tid);
|
|
|
|
|
|
+ if(state.entree_tid){
|
|
|
|
+ openEntree(state.entree_tid);
|
|
|
|
+ }
|
|
|
|
+ // record history state
|
|
|
|
+ history.replaceState(state, null, edlp_origin.url+edlp_origin.hash);
|
|
}
|
|
}
|
|
|
|
|
|
- // record history state
|
|
|
|
- history.replaceState(state, null, edlp_origin.url+edlp_origin.hash);
|
|
|
|
-
|
|
|
|
// reset the storage
|
|
// reset the storage
|
|
window.localStorage.removeItem("edlp_origin");
|
|
window.localStorage.removeItem("edlp_origin");
|
|
// window.localStorage.removeItem("edlp_origin_url");
|
|
// window.localStorage.removeItem("edlp_origin_url");
|
|
|
|
|
|
}else{
|
|
}else{
|
|
- history.replaceState({home:true}, null, window.location.pathname);
|
|
|
|
|
|
+ // if(window.location.hash == "#random"){
|
|
|
|
+ //
|
|
|
|
+ // }
|
|
|
|
+ history.replaceState({home:true}, null, window.location.pathname+window.location.hash);
|
|
// initHome();
|
|
// initHome();
|
|
initGrid();
|
|
initGrid();
|
|
_$body.attr('booted', 'booted');
|
|
_$body.attr('booted', 'booted');
|
|
@@ -893,11 +902,10 @@
|
|
this.$next.on('click', this.playNext.bind(this));
|
|
this.$next.on('click', this.playNext.bind(this));
|
|
},
|
|
},
|
|
openDocument(node, caller, historic_index){
|
|
openDocument(node, caller, historic_index){
|
|
- // console.log('AudioPlayer openDocument', node);
|
|
|
|
|
|
+ console.log('AudioPlayer openDocument', node, caller);
|
|
if(typeof node == 'undefined'
|
|
if(typeof node == 'undefined'
|
|
|| typeof node.nid == 'undefined'
|
|
|| typeof node.nid == 'undefined'
|
|
- || typeof node.audio_url == 'undfined'
|
|
|
|
- || typeof node.document_url == 'undfined'){
|
|
|
|
|
|
+ || typeof node.audio_url == 'undefined'){
|
|
console.warn('AudioPlayer openDocument() node is malformed', node);
|
|
console.warn('AudioPlayer openDocument() node is malformed', node);
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
@@ -910,18 +918,23 @@
|
|
|
|
|
|
// add the document opening to history to be able to share and play audio from any where
|
|
// add the document opening to history to be able to share and play audio from any where
|
|
if(caller != "history_first_load"){
|
|
if(caller != "history_first_load"){
|
|
- var state = {
|
|
|
|
- audio:true,
|
|
|
|
- node:{
|
|
|
|
- nid:node.nid,
|
|
|
|
- audio_url:node.audio_url,
|
|
|
|
- document_url:node.document_url,
|
|
|
|
- title:node.title || null,
|
|
|
|
- },
|
|
|
|
- historic_index : this.currentHistoricIndex,
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- history.pushState(state, null, node.document_url);
|
|
|
|
|
|
+ if(typeof node.document_url == 'undefined'){
|
|
|
|
+ console.warn("AudioPlayer openDocument missing document_url, can't push state to history", caller, node);
|
|
|
|
+ }else{
|
|
|
|
+ var state = {
|
|
|
|
+ audio:true,
|
|
|
|
+ node:{
|
|
|
|
+ nid:node.nid,
|
|
|
|
+ audio_url:node.audio_url,
|
|
|
|
+ document_url:node.document_url,
|
|
|
|
+ title:node.title || null,
|
|
|
|
+ },
|
|
|
|
+ historic_index : this.currentHistoricIndex,
|
|
|
|
+ };
|
|
|
|
+ // console.log('AudioPlayer pushstate', state);
|
|
|
|
+ var url = node.document_url + (caller == 'random' ? '#random' : '');
|
|
|
|
+ history.pushState(state, null, url);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}else{
|
|
}else{
|
|
// if the call commes from popstate, we update the current position of index
|
|
// if the call commes from popstate, we update the current position of index
|
|
@@ -1043,12 +1056,14 @@
|
|
if(this.currentHistoricIndex > 0){
|
|
if(this.currentHistoricIndex > 0){
|
|
this.currentHistoricIndex -= 1;
|
|
this.currentHistoricIndex -= 1;
|
|
this.launch();
|
|
this.launch();
|
|
|
|
+ // TODO: update history state
|
|
}
|
|
}
|
|
},
|
|
},
|
|
playNext(){
|
|
playNext(){
|
|
if(this.currentHistoricIndex < this.historic.length-1){
|
|
if(this.currentHistoricIndex < this.historic.length-1){
|
|
this.currentHistoricIndex += 1;
|
|
this.currentHistoricIndex += 1;
|
|
this.launch();
|
|
this.launch();
|
|
|
|
+ // TODO: update history state
|
|
}else{
|
|
}else{
|
|
this.emmit('audio-play-next');
|
|
this.emmit('audio-play-next');
|
|
}
|
|
}
|
|
@@ -1167,6 +1182,10 @@
|
|
console.info('AudioPlayer hide() : _$corpus_canvas does not exists');
|
|
console.info('AudioPlayer hide() : _$corpus_canvas does not exists');
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ deActivateRandom(){
|
|
|
|
+ this.shuffle_is_active = false;
|
|
|
|
+ this.showHideNextBtn();
|
|
|
|
+ },
|
|
// object events
|
|
// object events
|
|
on(event_name, handler){
|
|
on(event_name, handler){
|
|
if(typeof this.event_handlers[event_name] == 'undefined'){
|
|
if(typeof this.event_handlers[event_name] == 'undefined'){
|
|
@@ -1202,7 +1221,8 @@
|
|
function RandomPlayer(playlist){
|
|
function RandomPlayer(playlist){
|
|
this.active = false;
|
|
this.active = false;
|
|
this.playlist = playlist;
|
|
this.playlist = playlist;
|
|
- this.$btn = $('<a>').html('Shuffle').addClass('random-player-btn');
|
|
|
|
|
|
+ this.path = drupalSettings.path.baseUrl+drupalSettings.path.pathPrefix+'#random'
|
|
|
|
+ this.$btn = $('<a>').html('Shuffle').attr('href',this.path).addClass('random-player-btn');
|
|
this.init();
|
|
this.init();
|
|
};
|
|
};
|
|
RandomPlayer.prototype = {
|
|
RandomPlayer.prototype = {
|
|
@@ -1229,6 +1249,12 @@
|
|
|
|
|
|
_$corpus_canvas
|
|
_$corpus_canvas
|
|
.on('update-random-playlist', this.updatePlaylist.bind(this));
|
|
.on('update-random-playlist', this.updatePlaylist.bind(this));
|
|
|
|
+
|
|
|
|
+ // provide a link to auto start random player
|
|
|
|
+ if(window.location.hash == '#random'){
|
|
|
|
+ this.start();
|
|
|
|
+ // window.location.hash = '';
|
|
|
|
+ }
|
|
},
|
|
},
|
|
updatePlaylist(e){
|
|
updatePlaylist(e){
|
|
// debugger;
|
|
// debugger;
|
|
@@ -1248,11 +1274,13 @@
|
|
//console.log('RandomPlayer, this.shuffledPlaylist', this.shuffledPlaylist);
|
|
//console.log('RandomPlayer, this.shuffledPlaylist', this.shuffledPlaylist);
|
|
},
|
|
},
|
|
toggleActive(e){
|
|
toggleActive(e){
|
|
|
|
+ e.preventDefault();
|
|
if (this.active) {
|
|
if (this.active) {
|
|
this.stop();
|
|
this.stop();
|
|
}else{
|
|
}else{
|
|
this.start();
|
|
this.start();
|
|
}
|
|
}
|
|
|
|
+ return false;
|
|
},
|
|
},
|
|
start(){
|
|
start(){
|
|
this.active = _audioPlayer.shuffle_is_active = true;
|
|
this.active = _audioPlayer.shuffle_is_active = true;
|
|
@@ -1266,10 +1294,14 @@
|
|
}
|
|
}
|
|
},
|
|
},
|
|
stop(){
|
|
stop(){
|
|
- this.active = _audioPlayer.shuffle_is_active = false;
|
|
|
|
|
|
+ this.active = false;
|
|
this.$btn.removeClass('is-active');
|
|
this.$btn.removeClass('is-active');
|
|
// stop audio player
|
|
// stop audio player
|
|
// _audioPlayer.stop();
|
|
// _audioPlayer.stop();
|
|
|
|
+ // remove hash
|
|
|
|
+ history.replaceState(history.state, null, window.location.pathname);
|
|
|
|
+ // tell to AudioPlayer to deactivate netx btn
|
|
|
|
+ _audioPlayer.deActivateRandom();
|
|
if(typeof _paq !== 'undefined'){
|
|
if(typeof _paq !== 'undefined'){
|
|
// trackEvent(category, action, [name], [value])
|
|
// trackEvent(category, action, [name], [value])
|
|
_paq.push(['trackEvent', 'RandomPlayer', 'stop']);
|
|
_paq.push(['trackEvent', 'RandomPlayer', 'stop']);
|
|
@@ -1278,7 +1310,7 @@
|
|
next(){
|
|
next(){
|
|
console.log('RandomPlayer next', this.active, this.shuffledPlaylist.length);
|
|
console.log('RandomPlayer next', this.active, this.shuffledPlaylist.length);
|
|
if(this.active && this.shuffledPlaylist.length > 0)
|
|
if(this.active && this.shuffledPlaylist.length > 0)
|
|
- _audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0]);
|
|
|
|
|
|
+ _audioPlayer.openDocument(this.shuffledPlaylist.splice(0,1)[0], 'random');
|
|
},
|
|
},
|
|
onAudioPlayNext(){
|
|
onAudioPlayNext(){
|
|
console.log('RandomPlayer : onAudioPlayNext()');
|
|
console.log('RandomPlayer : onAudioPlayNext()');
|
|
@@ -1576,7 +1608,7 @@
|
|
};
|
|
};
|
|
|
|
|
|
function checkGridBlockHeight(){
|
|
function checkGridBlockHeight(){
|
|
- console.log('checkGridBlockHeight');
|
|
|
|
|
|
+ // console.log('checkGridBlockHeight');
|
|
var $r_h = _$row.height();
|
|
var $r_h = _$row.height();
|
|
var $this;
|
|
var $this;
|
|
// console.log($r_h);
|
|
// console.log($r_h);
|
|
@@ -1596,14 +1628,14 @@
|
|
};
|
|
};
|
|
|
|
|
|
function checkGridBlockVisible(){
|
|
function checkGridBlockVisible(){
|
|
- console.log('checkGridBlockVisible');
|
|
|
|
|
|
+ // console.log('checkGridBlockVisible');
|
|
var $r_h = _$row.height();
|
|
var $r_h = _$row.height();
|
|
var $this,pos;
|
|
var $this,pos;
|
|
$('.grid .col', _$row).each(function(i,e){
|
|
$('.grid .col', _$row).each(function(i,e){
|
|
// $(this).on('load',function(event){
|
|
// $(this).on('load',function(event){
|
|
$this = $(this);
|
|
$this = $(this);
|
|
pos = $this.position();
|
|
pos = $this.position();
|
|
- console.log(pos.top, $this.height(), pos.top+$this.height(), $r_h, $this);
|
|
|
|
|
|
+ // console.log(pos.top, $this.height(), pos.top+$this.height(), $r_h, $this);
|
|
if(pos.top+$this.height() <= $r_h){
|
|
if(pos.top+$this.height() <= $r_h){
|
|
$this.removeClass('offfield');
|
|
$this.removeClass('offfield');
|
|
}else{
|
|
}else{
|