included entree and entree#notice entree#index in ajax history nav
This commit is contained in:
+1054
-40
File diff suppressed because it is too large
Load Diff
+1152
-37
File diff suppressed because it is too large
Load Diff
@@ -1 +1,71 @@
|
||||
canvas#corpus-map{position:absolute;-webkit-box-sizing:border-box;box-sizing:border-box;top:0;left:0;z-index:0}canvas#corpus-map.de-activated{background-color:#f4f4f4}div.node-popup{z-index:10;position:absolute;-webkit-box-sizing:content-box;box-sizing:content-box;width:300px;min-height:30px;top:60%;left:30%;pointer-events:none}div.node-popup .inner{padding:1em;outline:red solid 1px;background-color:#fff}div.node-popup:before{content:"";position:absolute;width:60px;height:0;border-top:1px solid red}div.node-popup[pos=bottom-right]{-webkit-transform:translateY(42px) translateX(42px);transform:translateY(42px) translateX(42px)}div.node-popup[pos=bottom-right]:before{top:-1px;left:-61px;-webkit-transform-origin:bottom right;transform-origin:bottom right;-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg)}div.node-popup[pos=bottom-left]{-webkit-transform:translateX(-100%) translateY(42px) translateX(-42px);transform:translateX(-100%) translateY(42px) translateX(-42px)}div.node-popup[pos=bottom-left]:before{top:calc(100% +1px);left:100%;-webkit-transform-origin:top left;transform-origin:top left;-webkit-transform:rotateZ(-45deg);transform:rotateZ(-45deg)}div.node-popup[pos=top-left]{-webkit-transform:translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px);transform:translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px)}div.node-popup[pos=top-left]:before{bottom:0;left:100%;-webkit-transform-origin:top left;transform-origin:top left;-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg)}div.node-popup[pos=top-right]{-webkit-transform:translateY(-100%) translateY(-42px) translateX(42px);transform:translateY(-100%) translateY(-42px) translateX(42px)}div.node-popup[pos=top-right]:before{top:calc(100% + 1px);left:-61px;-webkit-transform-origin:top right;transform-origin:top right;-webkit-transform:rotateZ(-45deg);transform:rotateZ(-45deg)}
|
||||
canvas#corpus-map {
|
||||
position: absolute;
|
||||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 0; }
|
||||
canvas#corpus-map.de-activated {
|
||||
background-color: #f4f4f4; }
|
||||
|
||||
div.node-popup {
|
||||
z-index: 10;
|
||||
position: absolute;
|
||||
-webkit-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
width: 300px;
|
||||
min-height: 30px;
|
||||
pointer-events: none;
|
||||
top: 60%;
|
||||
left: 30%;
|
||||
pointer-events: none; }
|
||||
div.node-popup .inner {
|
||||
padding: 1em;
|
||||
outline: 1px solid red;
|
||||
background-color: white; }
|
||||
div.node-popup:before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 60px;
|
||||
height: 0;
|
||||
border-top: 1px solid red; }
|
||||
div.node-popup[pos="bottom-right"] {
|
||||
-webkit-transform: translateY(42px) translateX(42px);
|
||||
transform: translateY(42px) translateX(42px); }
|
||||
div.node-popup[pos="bottom-right"]:before {
|
||||
top: -1px;
|
||||
left: -61px;
|
||||
-webkit-transform-origin: bottom right;
|
||||
transform-origin: bottom right;
|
||||
-webkit-transform: rotateZ(45deg);
|
||||
transform: rotateZ(45deg); }
|
||||
div.node-popup[pos="bottom-left"] {
|
||||
-webkit-transform: translateX(-100%) translateY(42px) translateX(-42px);
|
||||
transform: translateX(-100%) translateY(42px) translateX(-42px); }
|
||||
div.node-popup[pos="bottom-left"]:before {
|
||||
top: calc(100% +1px);
|
||||
left: 100%;
|
||||
-webkit-transform-origin: top left;
|
||||
transform-origin: top left;
|
||||
-webkit-transform: rotateZ(-45deg);
|
||||
transform: rotateZ(-45deg); }
|
||||
div.node-popup[pos="top-left"] {
|
||||
-webkit-transform: translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px);
|
||||
transform: translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px); }
|
||||
div.node-popup[pos="top-left"]:before {
|
||||
bottom: 0;
|
||||
left: 100%;
|
||||
-webkit-transform-origin: top left;
|
||||
transform-origin: top left;
|
||||
-webkit-transform: rotateZ(45deg);
|
||||
transform: rotateZ(45deg); }
|
||||
div.node-popup[pos="top-right"] {
|
||||
-webkit-transform: translateY(-100%) translateY(-42px) translateX(42px);
|
||||
transform: translateY(-100%) translateY(-42px) translateX(42px); }
|
||||
div.node-popup[pos="top-right"]:before {
|
||||
top: calc(100% + 1px);
|
||||
left: -61px;
|
||||
-webkit-transform-origin: top right;
|
||||
transform-origin: top right;
|
||||
-webkit-transform: rotateZ(-45deg);
|
||||
transform: rotateZ(-45deg); }
|
||||
|
||||
@@ -139,6 +139,7 @@
|
||||
initArtilesLink();
|
||||
initNodePopup();
|
||||
initEvents();
|
||||
checkPreOpenedEntry();
|
||||
startAnime();
|
||||
};
|
||||
|
||||
@@ -654,6 +655,26 @@
|
||||
// | __|_ _| |_ _ _ ___ ___ ___
|
||||
// | _|| ' \ _| '_/ -_) -_|_-<
|
||||
// |___|_||_\__|_| \___\___/__/
|
||||
// TODO : this functionn is not clear as it should be called toggleEntry
|
||||
function openEntree(tid, bubbling){
|
||||
//var $link = $('a.term-link[tid="'+tid+'"]');
|
||||
var $link = _$entrees_block_termlinks.filter('[tid="'+tid+'"]');
|
||||
var $li = $link.parents('li');
|
||||
var sys_path = $link.attr('data-drupal-link-system-path');
|
||||
var url = $link.attr('href');
|
||||
if(!$li.is('.opened')){
|
||||
_$entrees_block_termlinks.parents('li').removeClass('opened');
|
||||
$li.addClass('opened');
|
||||
filterEntree(tid);
|
||||
if(bubbling){
|
||||
_$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
|
||||
}
|
||||
}else if(bubbling){
|
||||
$li.removeClass('opened');
|
||||
scrambleCollection();
|
||||
_$body.trigger({'type':'close_entree', 'tid':tid});
|
||||
}
|
||||
};
|
||||
function filterEntree(t){
|
||||
shutDownArticles();
|
||||
|
||||
@@ -792,6 +813,7 @@
|
||||
// | _|\ V / -_) ' \ _(_-<
|
||||
// |___|\_/\___|_||_\__/__/
|
||||
function initEvents(){
|
||||
console.log('Corpus, initEvents');
|
||||
_$canvas
|
||||
.on('mousemove', function(event) {
|
||||
event.preventDefault();
|
||||
@@ -836,22 +858,33 @@
|
||||
})
|
||||
.on('audio-node-closed', function(e){
|
||||
closeNode();
|
||||
})
|
||||
.on('open-entree', function(e){
|
||||
openEntree(e.tid);
|
||||
})
|
||||
.on('close-all-entree', function(e){
|
||||
closeAllEntries();
|
||||
});
|
||||
|
||||
_$entrees_block_termlinks.on('click', function(event) {
|
||||
console.log('_$entrees_block_termlinks click', this);
|
||||
event.preventDefault();
|
||||
var tid = $(this).attr('tid');
|
||||
var $li = $(this).parents('li');
|
||||
if(!$li.is('.opened')){
|
||||
_$entrees_block_termlinks.parents('li').removeClass('opened');
|
||||
$li.addClass('opened');
|
||||
filterEntree(tid);
|
||||
_$body.trigger({'type':'open_entree', 'tid':tid});
|
||||
}else{
|
||||
$li.removeClass('opened');
|
||||
scrambleCollection();
|
||||
_$body.trigger({'type':'close_entree', 'tid':tid});
|
||||
}
|
||||
openEntree($(this).attr('tid'), true);
|
||||
// var $link = $(this);
|
||||
// var tid = $link.attr('tid');
|
||||
// var $li = $link.parents('li');
|
||||
// var sys_path = $link.attr('data-drupal-link-system-path');
|
||||
// var url = $link.attr('href');
|
||||
// if(!$li.is('.opened')){
|
||||
// _$entrees_block_termlinks.parents('li').removeClass('opened');
|
||||
// $li.addClass('opened');
|
||||
// openEntree(tid);
|
||||
// _$body.trigger({'type':'open_entree', 'tid':tid, 'url':url, 'sys_path':sys_path});
|
||||
// }else{
|
||||
// $li.removeClass('opened');
|
||||
// scrambleCollection();
|
||||
// _$body.trigger({'type':'close_entree', 'tid':tid});
|
||||
// }
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -866,9 +899,28 @@
|
||||
})
|
||||
.on('search-closed', function(e){
|
||||
scrambleCollection();
|
||||
})
|
||||
.on('new-content-not-entree-ajax-loaded', function(e){
|
||||
// close all entries only if entry already opened
|
||||
if(_$entrees_block_termlinks.parents('li.opened').length){
|
||||
_$entrees_block_termlinks.parents('li').removeClass('opened');
|
||||
scrambleCollection();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
function checkPreOpenedEntry(){
|
||||
_$entrees_block.find('li.entree').each(function(index, el) {
|
||||
var $li = $(this);
|
||||
if($('a.is-active', $li).length){
|
||||
$li.addClass('opened');
|
||||
filterEntree($li.attr('tid'));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// _ _ _ ___ _ _
|
||||
// | \| |___ __| |___| _ \___ _ __| | | |_ __
|
||||
// | .` / _ \/ _` / -_) _/ _ \ '_ \ |_| | '_ \
|
||||
|
||||
+108
-3
@@ -1,4 +1,109 @@
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
(function($,Drupal,drupalSettings){var settings=drupalSettings.edlp_search;var _$body=$('body');var _$container;var _$form;function init(){initEvents();initAjax();};function initEvents(){$('body').on('new-content-ajax-loaded',initAjax).on('edlp_search_search_form-col-closed',onSearchClosed);};function initAjax(){_$form=$('#edlp-search-form:not(.ajax-enabled)');if(!_$form.length)return false;_$form=$('#edlp-search-form:not(.ajax-enabled)').on('submit',onSubmitForm).addClass('ajax-enabled');_$container=_$form.parents('.row');if(!_$container.length){_$container=_$form.parent();}};function onSubmitForm(e){e.preventDefault();var args={};args.keys=$('input[type="search"]',this).val();args.entries=[];$('input[type="checkbox"]:checked','#edit-entries').each(function(index,el){args.entries.push($(this).val());});args.langues=$('input[name="langues"]',this).val();args.genres=$('input[name="genres"]',this).val();loadResults(args);return false;};function loadResults(args){_$form.addClass('ajax-loading');_$body.addClass('ajax-loading');$('[theme="edlp_search_results"]',_$container).addClass('ajax-loading');var path=window.location.origin+drupalSettings.path.baseUrl+settings.results_ajax_url;$.getJSON(path,args).done(function(data){onResultsLoaded(data);}).fail(function(jqxhr,textStatus,error){onResultsLoadFail(jqxhr,textStatus,error);});};function onResultsLoaded(data){_$form.removeClass('ajax-loading');_$body.removeClass('ajax-loading');$prev_results=$('[theme="edlp_search_results"]',_$container);if($prev_results.length){$prev_results.replaceWith(data.rendered);}else{_$container.append(data.rendered);}
|
||||
_$body.trigger({'type':'search-results-loaded','results':data.results_nids});};function onResultsLoadFail(jqxhr,textStatus,error){void 0;};function onSearchClosed(e){$('div[theme="edlp_search_results"]').remove();_$body.trigger({'type':'search-closed'});}
|
||||
init();})(jQuery,Drupal,drupalSettings);
|
||||
var settings = drupalSettings.edlp_search;
|
||||
var _$body = $('body');
|
||||
var _$container;
|
||||
var _$form;
|
||||
|
||||
function init(){
|
||||
// console.log('EdlpSearch Init', settings);
|
||||
initEvents();
|
||||
initAjax();
|
||||
};
|
||||
|
||||
function initEvents(){
|
||||
$('body')
|
||||
.on('new-content-ajax-loaded', initAjax)
|
||||
.on('edlp_search_search_form-col-closed', onSearchClosed);
|
||||
};
|
||||
|
||||
function initAjax(){
|
||||
_$form = $('#edlp-search-form:not(.ajax-enabled)');
|
||||
if(!_$form.length) return false;
|
||||
|
||||
//console.log('EdlpSearch initAjaxForm()');
|
||||
_$form = $('#edlp-search-form:not(.ajax-enabled)')
|
||||
.on('submit', onSubmitForm)
|
||||
.addClass('ajax-enabled');
|
||||
_$container = _$form.parents('.row');
|
||||
if(!_$container.length){
|
||||
_$container = _$form.parent();
|
||||
}
|
||||
};
|
||||
|
||||
function onSubmitForm(e){
|
||||
e.preventDefault();
|
||||
// console.log('onSubmitForm',e);
|
||||
var args = {};
|
||||
|
||||
// search for key words
|
||||
args.keys = $('input[type="search"]', this).val();
|
||||
|
||||
// entries filter
|
||||
args.entries = [];
|
||||
$('input[type="checkbox"]:checked', '#edit-entries').each(function(index, el) {
|
||||
args.entries.push($(this).val());
|
||||
});
|
||||
|
||||
// langues
|
||||
args.langues = $('input[name="langues"]', this).val();
|
||||
|
||||
// genres
|
||||
args.genres = $('input[name="genres"]', this).val();
|
||||
|
||||
//console.log('EdlpSearch onSubmitForm() : args',args);
|
||||
|
||||
loadResults(args);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
function loadResults(args){
|
||||
//console.log('EdlpSearch loadResults() : args', args);
|
||||
_$form.addClass('ajax-loading');
|
||||
_$body.addClass('ajax-loading');
|
||||
$('[theme="edlp_search_results"]', _$container).addClass('ajax-loading');
|
||||
var path = window.location.origin + drupalSettings.path.baseUrl +settings.results_ajax_url;
|
||||
$.getJSON(path, args)
|
||||
.done(function(data){
|
||||
onResultsLoaded(data);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onResultsLoadFail(jqxhr, textStatus, error);
|
||||
});
|
||||
};
|
||||
|
||||
function onResultsLoaded(data){
|
||||
// console.log('EdlpSearch onResultsLoaded()', data);
|
||||
_$form.removeClass('ajax-loading');
|
||||
_$body.removeClass('ajax-loading');
|
||||
|
||||
// insert results col
|
||||
$prev_results = $('[theme="edlp_search_results"]', _$container);
|
||||
if($prev_results.length){
|
||||
$prev_results.replaceWith(data.rendered);
|
||||
}else{
|
||||
_$container.append(data.rendered);
|
||||
}
|
||||
|
||||
// trigger event
|
||||
_$body.trigger({
|
||||
'type':'search-results-loaded',
|
||||
'results':data.results_nids
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
function onResultsLoadFail(jqxhr, textStatus, error){
|
||||
console.warn('EdlpSearch : search results ajax load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
function onSearchClosed(e){
|
||||
// console.log('Edlp Search onSearchClosed()');
|
||||
$('div[theme="edlp_search_results"]').remove();
|
||||
// trigger event
|
||||
_$body.trigger({'type':'search-closed'});
|
||||
}
|
||||
|
||||
init();
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
+407
-9
@@ -1,10 +1,408 @@
|
||||
(function ($, Drupal, drupalSettings) {
|
||||
|
||||
(function($,Drupal,drupalSettings){var _settings=drupalSettings.edlp_studio;var $composer;function init(){initEvents();initStudio();};function initEvents(){$('body').on('new-audio-cartel-loaded',initAjaxChutierLinks).on('new-content-ajax-loaded',initStudio).on('all-modal-closed',initStudio);};function initStudio(){if($('#studio-ui').length){$composer=$('.composition_ui .composer','#studio-ui');initAjaxChutierLinks();initAjaxCompoLinks();initDragAndDropUI();$('body').trigger({'type':'studio-initialized'});}else{$('body').trigger({'type':'studio-not-active'});}}
|
||||
function initAjaxChutierLinks(){$('.chutier-ajax-link:not(.ajax-enabled)').addClass('ajax-enabled').on('click',onClickChutierAjaxLink);};function onClickChutierAjaxLink(e){e.preventDefault();addRemoveToChutier($(this));return false;};function addRemoveToChutier($link){var ajax_path=$link.attr('data-drupal-link-system-path');var path=window.location.origin+drupalSettings.path.baseUrl+ajax_path;$link.addClass('ajax-loading');$.getJSON(path,{}).done(function(data){onActionToChutierDone($link,data);}).fail(function(jqxhr,textStatus,error){onErrorActionToChutier(jqxhr,textStatus,error,$link);});};function onActionToChutierDone($link,data){$('body').trigger({'type':'chutier-action-done','action_done':data.action_done,'new_action':data.action_done=='add'?'remove':'add','target_id':$link.attr('target_id'),});$link.replaceWith(data.new_link);initAjaxChutierLinks();updateStudioChutier();};function onErrorActionToChutier(jqxhr,textStatus,error,$link){void 0;};function initAjaxCompoLinks(){$('.new-composition-link:not(.ajax-enabled)').on('click',onClickNewCompoLink).addClass('ajax-enabled');$('.composition-link:not(.ajax-enabled)').on('click',onClickCompoLink).addClass('ajax-enabled');$('.delete-composition-link:not(.ajax-enabled)').on('click',onClickDeleteCompoLink).addClass('ajax-enabled');};function onClickCompoLink(e){e.preventDefault();openCompo($(this));return false;};function openCompo($link){var cid=$link.attr('cid');var ajax_path=_settings.open_compo_ajax_url+'/'+cid;var path=window.location.origin+Drupal.url(ajax_path);$link.addClass('ajax-loading');$composer.addClass('ajax-loading');$.getJSON(path,{}).done(function(data){onOpenCompoDone(data,$link);}).fail(function(jqxhr,textStatus,error){onErrorOpenCompo(jqxhr,textStatus,error,$link);});};function onOpenCompoDone(data,$link){$('.composition-link').removeClass('is-active');$link.removeClass('ajax-loading').addClass('is-active');if($('.composition',$composer).length){$('.composition',$composer).replaceWith(data.compo);}else{$('header',$composer).after(data.compo);}
|
||||
$composer.removeClass('ajax-loading');initDragAndDropUI();$('body').trigger({'type':'on-studio-compo-opened'});};function onErrorOpenCompo(jqxhr,textStatus,error,$link){$link.removeClass('ajax-loading');void 0;};function onClickNewCompoLink(e){e.preventDefault();setInputForNewCompoName($(this));return false;};function setInputForNewCompoName($link){var $form=$('<form>').addClass('new-compo-form').append($('<input>').attr('type','text').attr('placeholder','new name')).append($('<button>').attr('type','submit').html('+')).submit(function(e){onNewCompoFormSubmit(e,$link,$(this));});$link.after($form).addClass('folded');$form.children('input[type="text"]').focus();};function onNewCompoFormSubmit(e,$link,$form){var name=$('input[type="text"]',$form).val();if(name!=''){$form.addClass('ajax-loading').children('*').attr('disabled','disabled');createNewCompo(name,$link,$form);}
|
||||
e.preventDefault();};function createNewCompo(name,$link,$form){var ajax_path=$link.attr('data-drupal-link-system-path');var path=window.location.origin+drupalSettings.path.baseUrl+ajax_path;$.getJSON(path,{'new_name':name}).done(function(data){onCreateCompoDone(data,$link,$form);}).fail(function(jqxhr,textStatus,error){onErrorCreateCompo(jqxhr,textStatus,error,$link);});};function onCreateCompoDone(data,$link,$form){var $new_link=$(data.new_link);var $delete_link=$(data.delete_link);$link.removeClass('folded').parents('li').before($('<li>').append($new_link).append($delete_link));$form.remove();initAjaxCompoLinks();openCompo($new_link);};function onErrorCreateCompo(jqxhr,textStatus,error,$link){void 0;};function onClickDeleteCompoLink(e){e.preventDefault();deleteCompo($(this));return false;};function deleteCompo($link){var ajax_path=$link.attr('data-drupal-link-system-path');var path=window.location.origin+Drupal.url(ajax_path);$link.parents('li').addClass('ajax-loading');$.getJSON(path,{}).done(function(data){onDeleteCompoDone(data,$link);}).fail(function(jqxhr,textStatus,error){onErrorDeleteCompo(jqxhr,textStatus,error,$link);});};function onDeleteCompoDone(data,$link,$form){if(data.status=="ok"){$link.parents('li').remove();if($('.composition-link').length){openCompo($('.composition-link').eq(0));}else{$('.composition',$composer).html();}}else{void 0;}};function onErrorDeleteCompo(jqxhr,textStatus,error,$link){$link.parents('li').removeClass('ajax-loading');void 0;};function updateStudioChutier(){$studioChutier=$('#studio-ui .chutier_ui');if($studioChutier.length){var ajax_path=_settings.chutier_ui_ajax;var path=window.location.origin+drupalSettings.path.baseUrl+ajax_path;$studioChutier.addClass('loading');$.getJSON(path,{}).done(function(data){onLoadedChutier($studioChutier,data);}).fail(function(jqxhr,textStatus,error){onLoadChutierError(jqxhr,textStatus,error,$studioChutier);});}};function onLoadedChutier($studioChutier,data){$studioChutier.replaceWith(data.rendered);initAjaxChutierLinks();setChutierDraggable();$('body').trigger({'type':'on-studio-chutier-updated'});}
|
||||
function onLoadChutierError(jqxhr,textStatus,error,$studioChutier){void 0;$studioChutier.removeClass('loading');}
|
||||
function initDragAndDropUI(){if(!$('.composition_ui .composer .composition .field--name-documents').length){$field_documents=$('<div>').addClass('field').addClass('field--name-documents').appendTo('.composition_ui .composer .composition');}else{$field_documents=$('.composition_ui .composer .composition .field--name-documents');$('.field__item',$field_documents).each(function(i){$(this).prepend($('<span>').addClass('handler'));});}
|
||||
var $remove_zone=$('<div>').addClass('remove-drop-zone').appendTo('.composition_ui .composer .composition').droppable({tolerance:'pointer',over:function(e,ui){ui.draggable.addClass('ready-to-remove');},out:function(e,ui){ui.draggable.removeClass('ready-to-remove');},drop:function(e,ui){ui.draggable.remove();}});$field_documents.sortable({revert:false,handle:".handler",receive:function(e,ui){$('.field__item',this).attr('style','');},update:function(e,ui){onOrderChanged(e,ui);},connectWith:$remove_zone,});setChutierDraggable();};function setChutierDraggable(){$('.chutier_ui .item-list li>div').draggable({containment:$('#studio-ui'),scroll:false,helper:function(e){return $('<div>').addClass('field__item').append($('<article>').addClass('node').append($('<h2>').addClass('node-title').append($('.audio-link',this).clone().removeClass('ajax-enable')))).prepend($('<span>').addClass('handler'));},cursorAt:{bottom:10,left:10},zIndex:999,revert:true,revertDuration:0,connectToSortable:$('.composition_ui .composer .composition .field--name-documents'),});}
|
||||
function onOrderChanged(e,ui){var cid=$(e.target).parents('.composition').attr('cid');var documents={};$('a',e.target).each(function(i){documents[i]=$(this).attr('nid');});recordCompoList(cid,documents);};function recordCompoList(cid,docs){var ajax_path=_settings.save_compo_ajax_url+'/'+cid;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{documents:docs}).done(function(data){onRecordCompoDone(data);}).fail(function(jqxhr,textStatus,error){onErrorRecordCompo(jqxhr,textStatus,error);});$('body').trigger({'type':'on-studio-compo-updated'});}
|
||||
function onRecordCompoDone(data){if(data.status=="ok"){}else{void 0;}};function onErrorRecordCompo(jqxhr,textStatus,error){void 0;};init();})(jQuery,Drupal,drupalSettings);
|
||||
var _settings = drupalSettings.edlp_studio;
|
||||
var $composer;
|
||||
|
||||
// audio play is handled by edlp_theme
|
||||
|
||||
function init(){
|
||||
// console.log('Studio Init');
|
||||
initEvents();
|
||||
initStudio();
|
||||
};
|
||||
|
||||
function initEvents(){
|
||||
$('body')
|
||||
.on('new-audio-cartel-loaded', initAjaxChutierLinks)
|
||||
.on('new-content-ajax-loaded', initStudio)
|
||||
.on('all-modal-closed', initStudio);
|
||||
};
|
||||
|
||||
function initStudio(){
|
||||
if($('#studio-ui').length){
|
||||
$composer = $('.composition_ui .composer', '#studio-ui');
|
||||
initAjaxChutierLinks();
|
||||
initAjaxCompoLinks();
|
||||
initDragAndDropUI();
|
||||
$('body').trigger({'type':'studio-initialized'});
|
||||
}else{
|
||||
$('body').trigger({'type':'studio-not-active'});
|
||||
}
|
||||
}
|
||||
|
||||
// ___ _ _ _ _ _ _ _ _ _
|
||||
// / __| |_ _ _| |_(_)___ _ _ | \| |___ __| |___ | | (_)_ _ | |__ ___
|
||||
// | (__| ' \ || | _| / -_) '_| | .` / _ \/ _` / -_) | |__| | ' \| / /(_-<
|
||||
// \___|_||_\_,_|\__|_\___|_| |_|\_\___/\__,_\___| |____|_|_||_|_\_\/__/
|
||||
function initAjaxChutierLinks(){
|
||||
//console.log('studio initAjaxChutierLinks');
|
||||
$('.chutier-ajax-link:not(.ajax-enabled)')
|
||||
.addClass('ajax-enabled')
|
||||
.on('click', onClickChutierAjaxLink);
|
||||
};
|
||||
function onClickChutierAjaxLink(e){
|
||||
//console.log('studio onClickAjaxLink chutier');
|
||||
e.preventDefault();
|
||||
addRemoveToChutier($(this));
|
||||
return false;
|
||||
};
|
||||
function addRemoveToChutier($link){
|
||||
// var ajax_path = 'edlp_studio/ajax/chutier/add/'+id; // + '/' +cid;
|
||||
var ajax_path = $link.attr('data-drupal-link-system-path');
|
||||
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||
$link.addClass('ajax-loading');
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onActionToChutierDone($link, data);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onErrorActionToChutier(jqxhr, textStatus, error, $link);
|
||||
});
|
||||
};
|
||||
function onActionToChutierDone($link, data){
|
||||
//console.log('onActionToChutierDone',data);
|
||||
$('body').trigger({
|
||||
'type':'chutier-action-done',
|
||||
'action_done':data.action_done,
|
||||
'new_action':data.action_done == 'add' ? 'remove' : 'add',
|
||||
'target_id':$link.attr('target_id'),
|
||||
});
|
||||
$link.replaceWith(data.new_link);
|
||||
initAjaxChutierLinks();
|
||||
// reload Studio chutier_ui's documents list
|
||||
updateStudioChutier();
|
||||
};
|
||||
function onErrorActionToChutier(jqxhr, textStatus, error, $link){
|
||||
console.warn('action to chuttier load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
// ___ _ _ _
|
||||
// / __|___ _ __ _ __ ___ __(_) |_(_)___ _ _ ___
|
||||
// | (__/ _ \ ' \| '_ \/ _ (_-< | _| / _ \ ' \(_-<
|
||||
// \___\___/_|_|_| .__/\___/__/_|\__|_\___/_||_/__/
|
||||
// |_|
|
||||
function initAjaxCompoLinks(){
|
||||
//console.log('studio initAjaxCompoLinks');
|
||||
$('.new-composition-link:not(.ajax-enabled)')
|
||||
.on('click', onClickNewCompoLink)
|
||||
.addClass('ajax-enabled');
|
||||
$('.composition-link:not(.ajax-enabled)')
|
||||
.on('click', onClickCompoLink)
|
||||
.addClass('ajax-enabled');
|
||||
$('.delete-composition-link:not(.ajax-enabled)')
|
||||
.on('click', onClickDeleteCompoLink)
|
||||
.addClass('ajax-enabled');
|
||||
};
|
||||
|
||||
// ___ ___
|
||||
// / _ \ _ __ ___ _ _ / __|___ _ __ _ __ ___
|
||||
// | (_) | '_ \/ -_) ' \ | (__/ _ \ ' \| '_ \/ _ \
|
||||
// \___/| .__/\___|_||_| \___\___/_|_|_| .__/\___/
|
||||
// |_| |_|
|
||||
function onClickCompoLink(e){
|
||||
e.preventDefault();
|
||||
//console.log('onClickCompoLink');
|
||||
openCompo($(this));
|
||||
return false;
|
||||
};
|
||||
function openCompo($link){
|
||||
var cid = $link.attr('cid');
|
||||
var ajax_path = _settings.open_compo_ajax_url+'/'+cid;
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
$link.addClass('ajax-loading');
|
||||
$composer.addClass('ajax-loading');
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onOpenCompoDone(data, $link);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onErrorOpenCompo(jqxhr, textStatus, error, $link);
|
||||
});
|
||||
};
|
||||
function onOpenCompoDone(data, $link){
|
||||
//console.log('onActionToCompoDone',data);
|
||||
$('.composition-link').removeClass('is-active');
|
||||
$link.removeClass('ajax-loading').addClass('is-active');
|
||||
if($('.composition', $composer).length){
|
||||
$('.composition', $composer).replaceWith(data.compo);
|
||||
}else{
|
||||
$('header', $composer).after(data.compo);
|
||||
}
|
||||
$composer.removeClass('ajax-loading');
|
||||
initDragAndDropUI();
|
||||
$('body').trigger({
|
||||
'type':'on-studio-compo-opened'
|
||||
});
|
||||
};
|
||||
function onErrorOpenCompo(jqxhr, textStatus, error, $link){
|
||||
$link.removeClass('ajax-loading');
|
||||
console.warn('open compo load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
// _ _ _____ __ __ __ ___ _ __ _ __ ___
|
||||
// | ' \/ -_) V V / / _/ _ \ ' \| '_ \/ _ \
|
||||
// |_||_\___|\_/\_/ \__\___/_|_|_| .__/\___/
|
||||
// |_|
|
||||
function onClickNewCompoLink(e){
|
||||
e.preventDefault();
|
||||
setInputForNewCompoName($(this));
|
||||
return false;
|
||||
};
|
||||
function setInputForNewCompoName($link){
|
||||
var $form = $('<form>').addClass('new-compo-form')
|
||||
.append($('<input>').attr('type', 'text').attr('placeholder', 'new name'))
|
||||
.append($('<button>').attr('type', 'submit').html('+'))
|
||||
.submit(function(e){
|
||||
onNewCompoFormSubmit(e, $link, $(this));
|
||||
});
|
||||
|
||||
$link
|
||||
.after($form)
|
||||
.addClass('folded');
|
||||
$form.children('input[type="text"]').focus();
|
||||
};
|
||||
function onNewCompoFormSubmit(e, $link, $form){
|
||||
var name = $('input[type="text"]',$form).val();
|
||||
//console.log('onNewCompoFormSubmit', name);
|
||||
if(name != ''){
|
||||
$form.addClass('ajax-loading').children('*').attr('disabled', 'disabled');
|
||||
createNewCompo(name, $link, $form);
|
||||
}
|
||||
e.preventDefault();
|
||||
};
|
||||
function createNewCompo(name,$link, $form){
|
||||
var ajax_path = $link.attr('data-drupal-link-system-path');
|
||||
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||
// $link.addClass('ajax-loading');
|
||||
$.getJSON(path, {
|
||||
'new_name':name
|
||||
})
|
||||
.done(function(data){
|
||||
onCreateCompoDone(data, $link, $form);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onErrorCreateCompo(jqxhr, textStatus, error, $link);
|
||||
});
|
||||
};
|
||||
function onCreateCompoDone(data, $link, $form){
|
||||
//console.log('onActionToCompoDone',data);
|
||||
var $new_link = $(data.new_link);
|
||||
var $delete_link = $(data.delete_link);
|
||||
$link
|
||||
.removeClass('folded')
|
||||
.parents('li')
|
||||
.before($('<li>').append($new_link).append($delete_link));
|
||||
$form.remove();
|
||||
// open new composition to composer
|
||||
initAjaxCompoLinks();
|
||||
openCompo($new_link);
|
||||
};
|
||||
function onErrorCreateCompo(jqxhr, textStatus, error, $link){
|
||||
console.warn('action to compo load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
// ___ _ _
|
||||
// | \ ___| |___| |_ ___ __ ___ _ __ _ __ ___
|
||||
// | |) / -_) / -_) _/ -_) / _/ _ \ ' \| '_ \/ _ \
|
||||
// |___/\___|_\___|\__\___| \__\___/_|_|_| .__/\___/
|
||||
// |_|
|
||||
function onClickDeleteCompoLink(e){
|
||||
e.preventDefault();
|
||||
// TODO: confirm compo deletion
|
||||
deleteCompo($(this));
|
||||
return false;
|
||||
};
|
||||
function deleteCompo($link){
|
||||
var ajax_path = $link.attr('data-drupal-link-system-path');
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
$link.parents('li').addClass('ajax-loading');
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onDeleteCompoDone(data, $link);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onErrorDeleteCompo(jqxhr, textStatus, error, $link);
|
||||
});
|
||||
};
|
||||
function onDeleteCompoDone(data, $link, $form){
|
||||
//console.log('onDeleteCompoDone',data);
|
||||
if(data.status == "ok"){
|
||||
$link.parents('li').remove();
|
||||
//console.log("$('.composition-link').length", $('.composition-link').length);
|
||||
if($('.composition-link').length){
|
||||
openCompo($('.composition-link').eq(0));
|
||||
}else{
|
||||
$('.composition', $composer).html();
|
||||
}
|
||||
}else{
|
||||
console.warn(data.message);
|
||||
}
|
||||
};
|
||||
function onErrorDeleteCompo(jqxhr, textStatus, error, $link){
|
||||
$link.parents('li').removeClass('ajax-loading');
|
||||
console.warn('delete compo load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
// ___ _ _ _ _
|
||||
// / __| |_ _ _ __| (_)___ ___ _ _(_)
|
||||
// \__ \ _| || / _` | / _ \___| || | |
|
||||
// |___/\__|\_,_\__,_|_\___/ \_,_|_|
|
||||
// this seems dirty
|
||||
function updateStudioChutier(){
|
||||
$studioChutier = $('#studio-ui .chutier_ui');
|
||||
if($studioChutier.length){
|
||||
var ajax_path = _settings.chutier_ui_ajax;
|
||||
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||
$studioChutier.addClass('loading');
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onLoadedChutier($studioChutier, data);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onLoadChutierError(jqxhr, textStatus, error, $studioChutier);
|
||||
});
|
||||
}
|
||||
};
|
||||
function onLoadedChutier($studioChutier, data){
|
||||
$studioChutier.replaceWith(data.rendered);
|
||||
initAjaxChutierLinks();
|
||||
// set chutier element draggable again
|
||||
setChutierDraggable();
|
||||
$('body').trigger({
|
||||
'type':'on-studio-chutier-updated'
|
||||
});
|
||||
}
|
||||
function onLoadChutierError(jqxhr, textStatus, error, $studioChutier){
|
||||
console.warn('Chutier load failed', jqxhr.responseText);
|
||||
$studioChutier.removeClass('loading');
|
||||
|
||||
}
|
||||
|
||||
// ___ __ ___ _ _ ___
|
||||
// | \ _ _ __ _ __ _ / _|___ | \ _ _ ___ _ __ | | | |_ _|
|
||||
// | |) | '_/ _` / _` | > _|_ _| | |) | '_/ _ \ '_ \ | |_| || |
|
||||
// |___/|_| \__,_\__, | \_____| |___/|_| \___/ .__/ \___/|___|
|
||||
// |___/ |_|
|
||||
function initDragAndDropUI(){
|
||||
// check if field--name-documents exists
|
||||
if (!$('.composition_ui .composer .composition .field--name-documents').length) {
|
||||
// if not create it
|
||||
$field_documents = $('<div>')
|
||||
.addClass('field').addClass('field--name-documents')
|
||||
.appendTo('.composition_ui .composer .composition');
|
||||
}else{
|
||||
// add real dom square element to handle sorting
|
||||
$field_documents = $('.composition_ui .composer .composition .field--name-documents'); $('.field__item', $field_documents).each(function(i){
|
||||
$(this).prepend($('<span>').addClass('handler'));
|
||||
});
|
||||
}
|
||||
|
||||
// create remove dropzone
|
||||
var $remove_zone = $('<div>').addClass('remove-drop-zone')
|
||||
.appendTo('.composition_ui .composer .composition')
|
||||
.droppable({
|
||||
tolerance:'pointer',
|
||||
// scope:'composition_ui',
|
||||
over:function(e,ui){
|
||||
// console.log('on over remove : ui', ui);
|
||||
ui.draggable.addClass('ready-to-remove');
|
||||
},
|
||||
out:function(e,ui){
|
||||
// console.log('on over remove : ui', ui);
|
||||
ui.draggable.removeClass('ready-to-remove');
|
||||
},
|
||||
drop:function(e,ui){
|
||||
// console.log('on drop remove : ui', ui);
|
||||
ui.draggable.remove();
|
||||
// onOrderChanged(ui);
|
||||
}
|
||||
});
|
||||
|
||||
// create sortable
|
||||
$field_documents.sortable({
|
||||
revert:false,
|
||||
handle: ".handler",
|
||||
receive:function(e, ui){
|
||||
$('.field__item', this).attr('style', '');
|
||||
// TODO: trigger event to enable new audiolink player
|
||||
},
|
||||
update:function(e, ui){
|
||||
onOrderChanged(e, ui);
|
||||
},
|
||||
connectWith : $remove_zone,
|
||||
});
|
||||
|
||||
// set chutier element draggable
|
||||
setChutierDraggable();
|
||||
|
||||
};
|
||||
function setChutierDraggable(){
|
||||
$('.chutier_ui .item-list li>div').draggable({
|
||||
containment:$('#studio-ui'),
|
||||
scroll:false,
|
||||
helper:function(e){
|
||||
// we reproduce here the irem structure of destination sortable elements
|
||||
// var $audio_link = $('.audio-link',this);
|
||||
return $('<div>').addClass('field__item')
|
||||
.append(
|
||||
$('<article>').addClass('node').append(
|
||||
$('<h2>').addClass('node-title').append(
|
||||
// $('<a>')
|
||||
// .attr('nid', $audio_link.attr('nid'))
|
||||
// .html($audio_link.html())
|
||||
$('.audio-link',this).clone().removeClass('ajax-enable')
|
||||
)
|
||||
)
|
||||
)
|
||||
.prepend($('<span>').addClass('handler'));
|
||||
},
|
||||
// cursor:'grab',
|
||||
cursorAt:{bottom:10,left:10},
|
||||
zIndex:999,
|
||||
revert:true,
|
||||
revertDuration:0,
|
||||
connectToSortable:$('.composition_ui .composer .composition .field--name-documents'),
|
||||
});
|
||||
}
|
||||
function onOrderChanged(e, ui){
|
||||
//console.log('onOrderChanged : e', e);
|
||||
var cid = $(e.target).parents('.composition').attr('cid');
|
||||
var documents = {};
|
||||
$('a', e.target).each(function(i) {
|
||||
// console.log(this);
|
||||
documents[i] = $(this).attr('nid');
|
||||
});
|
||||
// console.log(documents);
|
||||
recordCompoList(cid, documents);
|
||||
};
|
||||
function recordCompoList(cid, docs){
|
||||
//console.log('recordCompoList '+cid, docs);
|
||||
var ajax_path = _settings.save_compo_ajax_url+'/'+cid;
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
//console.log('path', path);
|
||||
$.getJSON(path, {
|
||||
documents:docs
|
||||
})
|
||||
.done(function(data){
|
||||
onRecordCompoDone(data);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onErrorRecordCompo(jqxhr, textStatus, error);
|
||||
});
|
||||
$('body').trigger({
|
||||
'type':'on-studio-compo-updated'
|
||||
});
|
||||
}
|
||||
function onRecordCompoDone(data){
|
||||
//console.log('onDeleteCompoDone',data);
|
||||
if(data.status == "ok"){
|
||||
}else{
|
||||
console.warn(data.message);
|
||||
}
|
||||
};
|
||||
function onErrorRecordCompo(jqxhr, textStatus, error){
|
||||
console.warn('record compo failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
init();
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
@@ -4,6 +4,7 @@ if(edlp.redirect){
|
||||
console.log('history redirect');
|
||||
window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
|
||||
window.localStorage.setItem('edlp_origin_url', window.location.pathname);
|
||||
window.localStorage.setItem('edlp_origin_hash', window.location.hash);
|
||||
// redirect to home
|
||||
window.location.replace(window.location.origin);
|
||||
}else{
|
||||
|
||||
+168
-66
@@ -5,6 +5,7 @@ console.log('EDLP THEME MAIN.js');
|
||||
var _ajax_settings = drupalSettings.edlp_ajax;
|
||||
var _$body = $('body');
|
||||
var _is_front = _$body.is('.path-frontpage');
|
||||
var _corpus_ready = false;
|
||||
var _$corpus_canvas;
|
||||
var _$row = $('main[role="main"]>.layout-content>.row');
|
||||
var _$ajaxLinks;
|
||||
@@ -19,6 +20,8 @@ console.log('EDLP THEME MAIN.js');
|
||||
function init(){
|
||||
console.log("EdlpTheme init()");
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
initHistory();
|
||||
|
||||
if(!drupalSettings.path.isFront)
|
||||
@@ -29,7 +32,6 @@ console.log('EDLP THEME MAIN.js');
|
||||
_audioPlayer = new AudioPlayer();
|
||||
_compoPlayer = new CompoPlayer();
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
// if (_$body.is('.path-productions')) initProductions();
|
||||
// if(_$body.is('.path-frontpage')) initHome();
|
||||
@@ -59,7 +61,31 @@ console.log('EDLP THEME MAIN.js');
|
||||
_compoPlayer.newCompo();
|
||||
})
|
||||
.on('search-results-loaded', initAjaxLinks)
|
||||
.on('open_entree', closeAllModals)
|
||||
// do not close index or notice modale on entree click
|
||||
.on('open_entree', function(e){
|
||||
console.log('on_open_entree : e', e);
|
||||
closeAllModals();
|
||||
|
||||
// add body class for currently loaded content
|
||||
// var body_classes = [
|
||||
// 'path-'+sys_path.replace(/\//g, '-'),
|
||||
// 'entity-type-'+data.entity_type,
|
||||
// 'bundle-'+data.bundle,
|
||||
// 'view-mode-'+data.view_mode
|
||||
// ];
|
||||
_$body.removeClass();//.addClass(body_classes.join(' '));
|
||||
|
||||
// record new history state
|
||||
if(typeof e.url != 'undefined'){
|
||||
// var state = {
|
||||
// ajax_path:null,
|
||||
// sys_path:null,
|
||||
// entree_tid:e.tid
|
||||
// };
|
||||
var state = getSysPathState(e.sys_path);
|
||||
history.pushState(state, null, e.url);
|
||||
}
|
||||
})
|
||||
.on('close_entree', backToFrontPage);
|
||||
}
|
||||
|
||||
@@ -84,44 +110,56 @@ console.log('EDLP THEME MAIN.js');
|
||||
// / _ \ | / _` \ \ /
|
||||
// /_/ \_\/ \__,_/_\_\
|
||||
// |__/
|
||||
function parseAjaxSysPath(sys_path, view_mode){
|
||||
// console.log('Theme : parseAjaxSysPath', sys_path);
|
||||
var ajax_path = sys_path;
|
||||
function getSysPathState(sys_path, view_mode){
|
||||
// console.log('Theme : getSysPathState', sys_path);
|
||||
var state = {
|
||||
'sys_path':sys_path,
|
||||
'ajax_path': sys_path
|
||||
};
|
||||
|
||||
// convert node link to edlp_ajax_node module links
|
||||
var node_match = ajax_path.match(/^\/?(node\/\d+)$/g);
|
||||
var term_match = ajax_path.match(/^\/?(taxonomy\/term\/\d+)$/g);
|
||||
var node_match = state.ajax_path.match(/^\/?(node\/(\d+))$/i);
|
||||
console.log('node_match', node_match);
|
||||
var term_match = state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);
|
||||
console.log('term_match', term_match);
|
||||
if(node_match){
|
||||
ajax_path = _ajax_settings.entityjson_path+'/'+node_match[0];
|
||||
state.ajax_path = _ajax_settings.entityjson_path+'/'+node_match[1];
|
||||
state.node_nid = node_match[2];
|
||||
// check for viewmode attribute
|
||||
if(view_mode){
|
||||
ajax_path += '/'+view_mode;
|
||||
state.ajax_path += '/'+view_mode;
|
||||
}
|
||||
}else if(term_match){
|
||||
ajax_path = _ajax_settings.entityjson_path+'/'+term_match[0];
|
||||
ajax_path = ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
|
||||
// terms are always entrees, there's no other vocabulary links in front
|
||||
state.ajax_path = _ajax_settings.entityjson_path+'/'+term_match[1];
|
||||
state.ajax_path = state.ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
|
||||
state.entree_tid = term_match[2];
|
||||
// check for viewmode attribute
|
||||
if(view_mode){
|
||||
ajax_path += '/'+view_mode;
|
||||
state.ajax_path += '/'+view_mode;
|
||||
state.view_mode = view_mode;
|
||||
}else{
|
||||
state.ajax_path = null;
|
||||
}
|
||||
}else{
|
||||
// convert other link to ajax
|
||||
// TODO: we assume that other links (no node, no term) are all from own modules (e.g. productions) !! may not be true !!
|
||||
ajax_path += '/ajax'
|
||||
state.ajax_path += '/ajax'
|
||||
}
|
||||
return ajax_path;
|
||||
return state;
|
||||
};
|
||||
function ajaxLoadContent(url, sys_path, ajax_path, selector){
|
||||
console.log('ajaxLoadContent : url', url);
|
||||
// function ajaxLoadContent(url, sys_path, ajax_path, selector){
|
||||
function ajaxLoadContent(state){
|
||||
console.log('ajaxLoadContent : url', state.url);
|
||||
_$body.addClass('ajax-loading');
|
||||
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
var path = window.location.origin + Drupal.url(state.ajax_path);
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onAjaxLoaded(data, url, ajax_path, sys_path, selector);
|
||||
onAjaxLoaded(data, state);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onAjaxLoadError(jqxhr, textStatus, error, sys_path);
|
||||
onAjaxLoadError(jqxhr, textStatus, error, state.sys_path);
|
||||
});
|
||||
};
|
||||
function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
|
||||
@@ -129,22 +167,18 @@ console.log('EDLP THEME MAIN.js');
|
||||
$('.ajax-loading').removeClass('ajax-loading');
|
||||
_$body.removeClass('ajax-loading');
|
||||
};
|
||||
function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
|
||||
console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path);
|
||||
// function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
|
||||
function onAjaxLoaded(data, state){
|
||||
console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
|
||||
|
||||
// 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)
|
||||
_$row.removeAttr('style').html(data.rendered);
|
||||
|
||||
// add close btn
|
||||
if(sys_path != 'productions'){
|
||||
addCloseBtnToCols();
|
||||
}
|
||||
|
||||
// add body class for currently loaded content
|
||||
var body_classes = [
|
||||
'path-'+sys_path.replace(/\//g, '-'),
|
||||
'path-'+state.sys_path.replace(/\//g, '-'),
|
||||
'entity-type-'+data.entity_type,
|
||||
'bundle-'+data.bundle,
|
||||
'view-mode-'+data.view_mode
|
||||
@@ -152,8 +186,9 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.removeClass().addClass(body_classes.join(' '));
|
||||
|
||||
// id node add a generic path-node class to body
|
||||
m = sys_path.match(/^\/?(node\/\d+)$/g);
|
||||
if(m)
|
||||
// m = state.sys_path.match(/^\/?(node\/\d+)$/g);
|
||||
// if(m)
|
||||
if(state.node_nid)
|
||||
_$body.addClass('path-edlp-node');
|
||||
|
||||
// handle clicked link classes
|
||||
@@ -161,10 +196,14 @@ console.log('EDLP THEME MAIN.js');
|
||||
$('.is-active').removeClass('is-active');
|
||||
$('.is-active-trail').removeClass('is-active-trail');
|
||||
|
||||
if(typeof selector != 'undefined'){
|
||||
$('a[selector="'+selector+'"]').addClass('is-active');
|
||||
if(typeof state.selector != 'undefined'){
|
||||
// in case of entree link (actualy, selector is used only for entries links)
|
||||
console.log('selector', state.selector);
|
||||
$('a[selector="'+state.selector+'"]').addClass('is-active');
|
||||
}else{
|
||||
$('a[data-drupal-link-system-path="'+sys_path+'"]').addClass('is-active');
|
||||
$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');
|
||||
// as new content is not related to entree, we trigger close entree
|
||||
_$body.trigger({'type':'new-content-not-entree-ajax-loaded'});
|
||||
}
|
||||
|
||||
// if bundle page (productions) activate production links
|
||||
@@ -190,13 +229,17 @@ console.log('EDLP THEME MAIN.js');
|
||||
|
||||
// initScrollbars();
|
||||
|
||||
if(sys_path == "productions")
|
||||
if(state.sys_path == "productions"){
|
||||
initProductions();
|
||||
}else{
|
||||
addCloseBtnToCols();
|
||||
}
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
// trigger other modules behaviours
|
||||
_$body.trigger({'type':'new-content-ajax-loaded'});
|
||||
|
||||
// and call druapl behaviours
|
||||
Drupal.attachBehaviors(_$row[0]);
|
||||
|
||||
@@ -204,16 +247,17 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.removeClass('ajax-loading');
|
||||
|
||||
|
||||
var state = {
|
||||
ajax_path:ajax_path,
|
||||
sys_path:sys_path,
|
||||
};
|
||||
// url is null means that we are loading content on popState event
|
||||
// so we don't record the state again
|
||||
if(url){
|
||||
if(state.url){
|
||||
// var state = {
|
||||
// ajax_path:ajax_path,
|
||||
// sys_path:sys_path,
|
||||
// };
|
||||
// console.log('url:'+url+' ; state',state);
|
||||
// console.log(window.location);
|
||||
// we can not pushestate with absolute url
|
||||
history.pushState(state, null, url);
|
||||
history.pushState(state, null, state.url);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -253,41 +297,73 @@ console.log('EDLP THEME MAIN.js');
|
||||
window.addEventListener('popstate', onHistoryPopState);
|
||||
};
|
||||
function initFirstLoad(){
|
||||
console.log('theme : initFirstLoad()', window.location);
|
||||
console.log(document.cookie);
|
||||
var url = window.location.pathname;
|
||||
// var origin_path = getCookie('edlp_origin_path');
|
||||
// console.log('origin_path', origin_path);
|
||||
console.log('theme : initFirstLoad()');
|
||||
|
||||
var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
|
||||
console.log('origin_sys_path', origin_sys_path);
|
||||
var origin_url = window.localStorage.getItem('edlp_origin_url');
|
||||
console.log('origin_url', origin_url);
|
||||
if(origin_sys_path){
|
||||
var origin_url = window.localStorage.getItem('edlp_origin_url');
|
||||
// origin_hash is used as viewmode for taxonomy term entrees load (index or notice)
|
||||
var origin_hash = window.localStorage.getItem('edlp_origin_hash');
|
||||
var view_mode = origin_hash.replace('#', '');
|
||||
if(view_mode){
|
||||
var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
|
||||
var selector = $link.attr('selector') || null;
|
||||
if(selector){
|
||||
// in case of entree link (actualy, selector is used only for entries links)
|
||||
if(_corpus_ready){
|
||||
_$corpus_canvas.trigger({
|
||||
type:'open-entree',
|
||||
tid:$link.attr('tid')
|
||||
});
|
||||
}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)
|
||||
// but what if corpus ready before onAjaxLoaded
|
||||
$('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create history state
|
||||
var state = {
|
||||
ajax_path: parseAjaxSysPath(origin_sys_path),
|
||||
sys_path: origin_sys_path,
|
||||
};
|
||||
console.log('state', state);
|
||||
var state = getSysPathState(origin_sys_path, view_mode);
|
||||
|
||||
// only if not entree path
|
||||
if(state.ajax_path){
|
||||
// load content through ajax
|
||||
// ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
|
||||
ajaxLoadContent(state);
|
||||
}
|
||||
|
||||
// TODO what about entree alone (without notice or index)
|
||||
if(state.entree_tid){
|
||||
openEntree(state.entree_tid);
|
||||
}
|
||||
|
||||
// record history state
|
||||
history.replaceState(state, null, origin_url);
|
||||
// load content through ajax
|
||||
ajaxLoadContent(null, state.sys_path, state.ajax_path);
|
||||
history.replaceState(state, null, origin_url+origin_hash);
|
||||
|
||||
// reset the storage
|
||||
window.localStorage.removeItem("edlp_origin_path");
|
||||
window.localStorage.removeItem("edlp_origin_url");
|
||||
|
||||
}else{
|
||||
history.replaceState({home:true}, null, url);
|
||||
history.replaceState({home:true}, null, window.location.pathname);
|
||||
_$body.attr('booted', 'booted');
|
||||
}
|
||||
};
|
||||
function onHistoryPopState(e){
|
||||
//console.log('onPopState',e);
|
||||
console.log('onPopState',e.state);
|
||||
if(e.state.home){
|
||||
backToFrontPage();
|
||||
}else{
|
||||
ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
|
||||
if(e.state.entree_tid){
|
||||
openEntree(e.state.entree_tid);
|
||||
}
|
||||
if(e.state.ajax_path){
|
||||
e.state.url = null;
|
||||
// ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
|
||||
ajaxLoadContent(e.state);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -338,7 +414,6 @@ console.log('EDLP THEME MAIN.js');
|
||||
}
|
||||
|
||||
// other links
|
||||
var url = $(this).attr('href');
|
||||
var sys_path = $(this).attr('data-drupal-link-system-path');
|
||||
|
||||
// front page
|
||||
@@ -349,15 +424,21 @@ console.log('EDLP THEME MAIN.js');
|
||||
}
|
||||
|
||||
var view_mode = $link.attr('viewmode');
|
||||
var ajax_path = parseAjaxSysPath(sys_path, view_mode);
|
||||
var state = getSysPathState(sys_path, view_mode);
|
||||
state.url = $(this).attr('href');
|
||||
|
||||
$link.addClass('ajax-loading');
|
||||
|
||||
if($link.is('[selector]')){
|
||||
var selector = $link.attr('selector');
|
||||
if(view_mode){
|
||||
state.url += "#"+view_mode;
|
||||
}
|
||||
|
||||
ajaxLoadContent(url, sys_path, ajax_path, selector);
|
||||
if($link.is('[selector]')){
|
||||
state.selector = $link.attr('selector');
|
||||
}
|
||||
|
||||
$link.addClass('ajax-loading');
|
||||
// ajaxLoadContent(url, sys_path, state.ajax_path, selector);
|
||||
ajaxLoadContent(state);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -368,6 +449,7 @@ console.log('EDLP THEME MAIN.js');
|
||||
// |_|
|
||||
function onCorpusMapReady(e){
|
||||
//console.log('theme : onCorpusReady', e);
|
||||
_corpus_ready = true;
|
||||
_$corpus_canvas = $('canvas#corpus-map');
|
||||
_$corpus_canvas
|
||||
.on('corpus-cliked-on-map', function(e) {
|
||||
@@ -386,6 +468,25 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.attr('corpus-map', 'ready');
|
||||
}
|
||||
|
||||
function openEntree(tid){
|
||||
if(tid){
|
||||
closeAllModals();
|
||||
|
||||
_$body.removeClass();//.addClass(body_classes.join(' '));
|
||||
|
||||
// open entree
|
||||
if(_corpus_ready){
|
||||
_$corpus_canvas.trigger({
|
||||
type:'open-entree',
|
||||
tid:tid
|
||||
});
|
||||
}else{
|
||||
// else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
|
||||
$('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// _ _ _
|
||||
// /_\ _ _ __| (_)___
|
||||
// / _ \ || / _` | / _ \
|
||||
@@ -981,7 +1082,8 @@ console.log('EDLP THEME MAIN.js');
|
||||
// assume we are going back to front page
|
||||
$('body').removeClass().addClass('path-frontpage');
|
||||
$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
|
||||
|
||||
// TODO: close entrees
|
||||
_$corpus_canvas.trigger({'type':'close-all-entree'});
|
||||
}
|
||||
|
||||
function initHome(){
|
||||
|
||||
@@ -4,6 +4,7 @@ if(edlp.redirect){
|
||||
console.log('history redirect');
|
||||
window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, ''));
|
||||
window.localStorage.setItem('edlp_origin_url', window.location.pathname);
|
||||
window.localStorage.setItem('edlp_origin_hash', window.location.hash);
|
||||
// redirect to home
|
||||
window.location.replace(window.location.origin);
|
||||
}else{
|
||||
|
||||
@@ -5,6 +5,7 @@ console.log('EDLP THEME MAIN.js');
|
||||
var _ajax_settings = drupalSettings.edlp_ajax;
|
||||
var _$body = $('body');
|
||||
var _is_front = _$body.is('.path-frontpage');
|
||||
var _corpus_ready = false;
|
||||
var _$corpus_canvas;
|
||||
var _$row = $('main[role="main"]>.layout-content>.row');
|
||||
var _$ajaxLinks;
|
||||
@@ -19,6 +20,8 @@ console.log('EDLP THEME MAIN.js');
|
||||
function init(){
|
||||
console.log("EdlpTheme init()");
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
initHistory();
|
||||
|
||||
if(!drupalSettings.path.isFront)
|
||||
@@ -29,7 +32,6 @@ console.log('EDLP THEME MAIN.js');
|
||||
_audioPlayer = new AudioPlayer();
|
||||
_compoPlayer = new CompoPlayer();
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
// if (_$body.is('.path-productions')) initProductions();
|
||||
// if(_$body.is('.path-frontpage')) initHome();
|
||||
@@ -59,7 +61,31 @@ console.log('EDLP THEME MAIN.js');
|
||||
_compoPlayer.newCompo();
|
||||
})
|
||||
.on('search-results-loaded', initAjaxLinks)
|
||||
.on('open_entree', closeAllModals)
|
||||
// do not close index or notice modale on entree click
|
||||
.on('open_entree', function(e){
|
||||
console.log('on_open_entree : e', e);
|
||||
closeAllModals();
|
||||
|
||||
// add body class for currently loaded content
|
||||
// var body_classes = [
|
||||
// 'path-'+sys_path.replace(/\//g, '-'),
|
||||
// 'entity-type-'+data.entity_type,
|
||||
// 'bundle-'+data.bundle,
|
||||
// 'view-mode-'+data.view_mode
|
||||
// ];
|
||||
_$body.removeClass();//.addClass(body_classes.join(' '));
|
||||
|
||||
// record new history state
|
||||
if(typeof e.url != 'undefined'){
|
||||
// var state = {
|
||||
// ajax_path:null,
|
||||
// sys_path:null,
|
||||
// entree_tid:e.tid
|
||||
// };
|
||||
var state = getSysPathState(e.sys_path);
|
||||
history.pushState(state, null, e.url);
|
||||
}
|
||||
})
|
||||
.on('close_entree', backToFrontPage);
|
||||
}
|
||||
|
||||
@@ -84,44 +110,56 @@ console.log('EDLP THEME MAIN.js');
|
||||
// / _ \ | / _` \ \ /
|
||||
// /_/ \_\/ \__,_/_\_\
|
||||
// |__/
|
||||
function parseAjaxSysPath(sys_path, view_mode){
|
||||
// console.log('Theme : parseAjaxSysPath', sys_path);
|
||||
var ajax_path = sys_path;
|
||||
function getSysPathState(sys_path, view_mode){
|
||||
// console.log('Theme : getSysPathState', sys_path);
|
||||
var state = {
|
||||
'sys_path':sys_path,
|
||||
'ajax_path': sys_path
|
||||
};
|
||||
|
||||
// convert node link to edlp_ajax_node module links
|
||||
var node_match = ajax_path.match(/^\/?(node\/\d+)$/g);
|
||||
var term_match = ajax_path.match(/^\/?(taxonomy\/term\/\d+)$/g);
|
||||
var node_match = state.ajax_path.match(/^\/?(node\/(\d+))$/i);
|
||||
console.log('node_match', node_match);
|
||||
var term_match = state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);
|
||||
console.log('term_match', term_match);
|
||||
if(node_match){
|
||||
ajax_path = _ajax_settings.entityjson_path+'/'+node_match[0];
|
||||
state.ajax_path = _ajax_settings.entityjson_path+'/'+node_match[1];
|
||||
state.node_nid = node_match[2];
|
||||
// check for viewmode attribute
|
||||
if(view_mode){
|
||||
ajax_path += '/'+view_mode;
|
||||
state.ajax_path += '/'+view_mode;
|
||||
}
|
||||
}else if(term_match){
|
||||
ajax_path = _ajax_settings.entityjson_path+'/'+term_match[0];
|
||||
ajax_path = ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
|
||||
// terms are always entrees, there's no other vocabulary links in front
|
||||
state.ajax_path = _ajax_settings.entityjson_path+'/'+term_match[1];
|
||||
state.ajax_path = state.ajax_path.replace(/taxonomy\/term/, 'taxonomy_term');
|
||||
state.entree_tid = term_match[2];
|
||||
// check for viewmode attribute
|
||||
if(view_mode){
|
||||
ajax_path += '/'+view_mode;
|
||||
state.ajax_path += '/'+view_mode;
|
||||
state.view_mode = view_mode;
|
||||
}else{
|
||||
state.ajax_path = null;
|
||||
}
|
||||
}else{
|
||||
// convert other link to ajax
|
||||
// TODO: we assume that other links (no node, no term) are all from own modules (e.g. productions) !! may not be true !!
|
||||
ajax_path += '/ajax'
|
||||
state.ajax_path += '/ajax'
|
||||
}
|
||||
return ajax_path;
|
||||
return state;
|
||||
};
|
||||
function ajaxLoadContent(url, sys_path, ajax_path, selector){
|
||||
console.log('ajaxLoadContent : url', url);
|
||||
// function ajaxLoadContent(url, sys_path, ajax_path, selector){
|
||||
function ajaxLoadContent(state){
|
||||
console.log('ajaxLoadContent : url', state.url);
|
||||
_$body.addClass('ajax-loading');
|
||||
|
||||
var path = window.location.origin + Drupal.url(ajax_path);
|
||||
var path = window.location.origin + Drupal.url(state.ajax_path);
|
||||
$.getJSON(path, {})
|
||||
.done(function(data){
|
||||
onAjaxLoaded(data, url, ajax_path, sys_path, selector);
|
||||
onAjaxLoaded(data, state);
|
||||
})
|
||||
.fail(function(jqxhr, textStatus, error){
|
||||
onAjaxLoadError(jqxhr, textStatus, error, sys_path);
|
||||
onAjaxLoadError(jqxhr, textStatus, error, state.sys_path);
|
||||
});
|
||||
};
|
||||
function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
|
||||
@@ -129,22 +167,18 @@ console.log('EDLP THEME MAIN.js');
|
||||
$('.ajax-loading').removeClass('ajax-loading');
|
||||
_$body.removeClass('ajax-loading');
|
||||
};
|
||||
function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
|
||||
console.log('ajax loaded url:'+url+' ajax_path:'+ajax_path+' sys_path:'+sys_path);
|
||||
// function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
|
||||
function onAjaxLoaded(data, state){
|
||||
console.log('ajax loaded url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
|
||||
|
||||
// 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)
|
||||
_$row.removeAttr('style').html(data.rendered);
|
||||
|
||||
// add close btn
|
||||
if(sys_path != 'productions'){
|
||||
addCloseBtnToCols();
|
||||
}
|
||||
|
||||
// add body class for currently loaded content
|
||||
var body_classes = [
|
||||
'path-'+sys_path.replace(/\//g, '-'),
|
||||
'path-'+state.sys_path.replace(/\//g, '-'),
|
||||
'entity-type-'+data.entity_type,
|
||||
'bundle-'+data.bundle,
|
||||
'view-mode-'+data.view_mode
|
||||
@@ -152,8 +186,9 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.removeClass().addClass(body_classes.join(' '));
|
||||
|
||||
// id node add a generic path-node class to body
|
||||
m = sys_path.match(/^\/?(node\/\d+)$/g);
|
||||
if(m)
|
||||
// m = state.sys_path.match(/^\/?(node\/\d+)$/g);
|
||||
// if(m)
|
||||
if(state.node_nid)
|
||||
_$body.addClass('path-edlp-node');
|
||||
|
||||
// handle clicked link classes
|
||||
@@ -161,10 +196,14 @@ console.log('EDLP THEME MAIN.js');
|
||||
$('.is-active').removeClass('is-active');
|
||||
$('.is-active-trail').removeClass('is-active-trail');
|
||||
|
||||
if(typeof selector != 'undefined'){
|
||||
$('a[selector="'+selector+'"]').addClass('is-active');
|
||||
if(typeof state.selector != 'undefined'){
|
||||
// in case of entree link (actualy, selector is used only for entries links)
|
||||
console.log('selector', state.selector);
|
||||
$('a[selector="'+state.selector+'"]').addClass('is-active');
|
||||
}else{
|
||||
$('a[data-drupal-link-system-path="'+sys_path+'"]').addClass('is-active');
|
||||
$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');
|
||||
// as new content is not related to entree, we trigger close entree
|
||||
_$body.trigger({'type':'new-content-not-entree-ajax-loaded'});
|
||||
}
|
||||
|
||||
// if bundle page (productions) activate production links
|
||||
@@ -190,13 +229,17 @@ console.log('EDLP THEME MAIN.js');
|
||||
|
||||
// initScrollbars();
|
||||
|
||||
if(sys_path == "productions")
|
||||
if(state.sys_path == "productions"){
|
||||
initProductions();
|
||||
}else{
|
||||
addCloseBtnToCols();
|
||||
}
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
// trigger other modules behaviours
|
||||
_$body.trigger({'type':'new-content-ajax-loaded'});
|
||||
|
||||
// and call druapl behaviours
|
||||
Drupal.attachBehaviors(_$row[0]);
|
||||
|
||||
@@ -204,16 +247,17 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.removeClass('ajax-loading');
|
||||
|
||||
|
||||
var state = {
|
||||
ajax_path:ajax_path,
|
||||
sys_path:sys_path,
|
||||
};
|
||||
// url is null means that we are loading content on popState event
|
||||
// so we don't record the state again
|
||||
if(url){
|
||||
if(state.url){
|
||||
// var state = {
|
||||
// ajax_path:ajax_path,
|
||||
// sys_path:sys_path,
|
||||
// };
|
||||
// console.log('url:'+url+' ; state',state);
|
||||
// console.log(window.location);
|
||||
// we can not pushestate with absolute url
|
||||
history.pushState(state, null, url);
|
||||
history.pushState(state, null, state.url);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -253,41 +297,73 @@ console.log('EDLP THEME MAIN.js');
|
||||
window.addEventListener('popstate', onHistoryPopState);
|
||||
};
|
||||
function initFirstLoad(){
|
||||
console.log('theme : initFirstLoad()', window.location);
|
||||
console.log(document.cookie);
|
||||
var url = window.location.pathname;
|
||||
// var origin_path = getCookie('edlp_origin_path');
|
||||
// console.log('origin_path', origin_path);
|
||||
console.log('theme : initFirstLoad()');
|
||||
|
||||
var origin_sys_path = window.localStorage.getItem('edlp_origin_path');
|
||||
console.log('origin_sys_path', origin_sys_path);
|
||||
var origin_url = window.localStorage.getItem('edlp_origin_url');
|
||||
console.log('origin_url', origin_url);
|
||||
if(origin_sys_path){
|
||||
var origin_url = window.localStorage.getItem('edlp_origin_url');
|
||||
// origin_hash is used as viewmode for taxonomy term entrees load (index or notice)
|
||||
var origin_hash = window.localStorage.getItem('edlp_origin_hash');
|
||||
var view_mode = origin_hash.replace('#', '');
|
||||
if(view_mode){
|
||||
var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
|
||||
var selector = $link.attr('selector') || null;
|
||||
if(selector){
|
||||
// in case of entree link (actualy, selector is used only for entries links)
|
||||
if(_corpus_ready){
|
||||
_$corpus_canvas.trigger({
|
||||
type:'open-entree',
|
||||
tid:$link.attr('tid')
|
||||
});
|
||||
}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)
|
||||
// but what if corpus ready before onAjaxLoaded
|
||||
$('li.entree[tid="'+$link.attr('tid')+'"] a.term-link').addClass('is-active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// create history state
|
||||
var state = {
|
||||
ajax_path: parseAjaxSysPath(origin_sys_path),
|
||||
sys_path: origin_sys_path,
|
||||
};
|
||||
console.log('state', state);
|
||||
var state = getSysPathState(origin_sys_path, view_mode);
|
||||
|
||||
// only if not entree path
|
||||
if(state.ajax_path){
|
||||
// load content through ajax
|
||||
// ajaxLoadContent(null, state.sys_path, state.ajax_path, selector);
|
||||
ajaxLoadContent(state);
|
||||
}
|
||||
|
||||
// TODO what about entree alone (without notice or index)
|
||||
if(state.entree_tid){
|
||||
openEntree(state.entree_tid);
|
||||
}
|
||||
|
||||
// record history state
|
||||
history.replaceState(state, null, origin_url);
|
||||
// load content through ajax
|
||||
ajaxLoadContent(null, state.sys_path, state.ajax_path);
|
||||
history.replaceState(state, null, origin_url+origin_hash);
|
||||
|
||||
// reset the storage
|
||||
window.localStorage.removeItem("edlp_origin_path");
|
||||
window.localStorage.removeItem("edlp_origin_url");
|
||||
|
||||
}else{
|
||||
history.replaceState({home:true}, null, url);
|
||||
history.replaceState({home:true}, null, window.location.pathname);
|
||||
_$body.attr('booted', 'booted');
|
||||
}
|
||||
};
|
||||
function onHistoryPopState(e){
|
||||
//console.log('onPopState',e);
|
||||
console.log('onPopState',e.state);
|
||||
if(e.state.home){
|
||||
backToFrontPage();
|
||||
}else{
|
||||
ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
|
||||
if(e.state.entree_tid){
|
||||
openEntree(e.state.entree_tid);
|
||||
}
|
||||
if(e.state.ajax_path){
|
||||
e.state.url = null;
|
||||
// ajaxLoadContent(null, e.state.sys_path, e.state.ajax_path)
|
||||
ajaxLoadContent(e.state);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -338,7 +414,6 @@ console.log('EDLP THEME MAIN.js');
|
||||
}
|
||||
|
||||
// other links
|
||||
var url = $(this).attr('href');
|
||||
var sys_path = $(this).attr('data-drupal-link-system-path');
|
||||
|
||||
// front page
|
||||
@@ -349,15 +424,21 @@ console.log('EDLP THEME MAIN.js');
|
||||
}
|
||||
|
||||
var view_mode = $link.attr('viewmode');
|
||||
var ajax_path = parseAjaxSysPath(sys_path, view_mode);
|
||||
var state = getSysPathState(sys_path, view_mode);
|
||||
state.url = $(this).attr('href');
|
||||
|
||||
$link.addClass('ajax-loading');
|
||||
|
||||
if($link.is('[selector]')){
|
||||
var selector = $link.attr('selector');
|
||||
if(view_mode){
|
||||
state.url += "#"+view_mode;
|
||||
}
|
||||
|
||||
ajaxLoadContent(url, sys_path, ajax_path, selector);
|
||||
if($link.is('[selector]')){
|
||||
state.selector = $link.attr('selector');
|
||||
}
|
||||
|
||||
$link.addClass('ajax-loading');
|
||||
// ajaxLoadContent(url, sys_path, state.ajax_path, selector);
|
||||
ajaxLoadContent(state);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -368,6 +449,7 @@ console.log('EDLP THEME MAIN.js');
|
||||
// |_|
|
||||
function onCorpusMapReady(e){
|
||||
//console.log('theme : onCorpusReady', e);
|
||||
_corpus_ready = true;
|
||||
_$corpus_canvas = $('canvas#corpus-map');
|
||||
_$corpus_canvas
|
||||
.on('corpus-cliked-on-map', function(e) {
|
||||
@@ -386,6 +468,25 @@ console.log('EDLP THEME MAIN.js');
|
||||
_$body.attr('corpus-map', 'ready');
|
||||
}
|
||||
|
||||
function openEntree(tid){
|
||||
if(tid){
|
||||
closeAllModals();
|
||||
|
||||
_$body.removeClass();//.addClass(body_classes.join(' '));
|
||||
|
||||
// open entree
|
||||
if(_corpus_ready){
|
||||
_$corpus_canvas.trigger({
|
||||
type:'open-entree',
|
||||
tid:tid
|
||||
});
|
||||
}else{
|
||||
// else : EdlpCorpus will check when ready if entry item (notice or index) is already .is-active
|
||||
$('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// _ _ _
|
||||
// /_\ _ _ __| (_)___
|
||||
// / _ \ || / _` | / _ \
|
||||
@@ -981,7 +1082,8 @@ console.log('EDLP THEME MAIN.js');
|
||||
// assume we are going back to front page
|
||||
$('body').removeClass().addClass('path-frontpage');
|
||||
$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
|
||||
|
||||
// TODO: close entrees
|
||||
_$corpus_canvas.trigger({'type':'close-all-entree'});
|
||||
}
|
||||
|
||||
function initHome(){
|
||||
|
||||
Reference in New Issue
Block a user