|
@@ -69,8 +69,7 @@ edlp_vars = {
|
|
|
var $this = $(this);
|
|
|
|
|
|
// avoid already ajaxified links
|
|
|
- if($this.is('.ajax-enable'))
|
|
|
- return;
|
|
|
+ if($this.is('.ajax-enable')) return;
|
|
|
|
|
|
var sys_path = $this.attr('data-drupal-link-system-path');
|
|
|
if(sys_path){
|
|
@@ -93,36 +92,59 @@ edlp_vars = {
|
|
|
|
|
|
var sys_path = $(this).attr('data-drupal-link-system-path');
|
|
|
if(sys_path == '<front>'){
|
|
|
- closeAllModals();
|
|
|
+ backToFrontPage();
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- var path = window.location.origin + drupalSettings.path.baseUrl + sys_path +'/ajax';
|
|
|
- closeAllModals();
|
|
|
+ var path = window.location.origin + drupalSettings.path.baseUrl + sys_path;
|
|
|
_$body.addClass('ajax-loading');
|
|
|
$link.addClass('ajax-loading');
|
|
|
- $.getJSON(path, {}, function(data){
|
|
|
- onAjaxLinkLoaded(data, $link, sys_path);
|
|
|
- });
|
|
|
+ // $.getJSON(path, {}, function(data){
|
|
|
+ // onAjaxLinkLoaded(data, $link, sys_path);
|
|
|
+ // });
|
|
|
+ $.getJSON(path+'/ajax', {})
|
|
|
+ .done(function(data){
|
|
|
+ onAjaxLinkLoaded(data, $link, sys_path);
|
|
|
+ })
|
|
|
+ .fail(function(jqxhr, textStatus, error){
|
|
|
+ onAjaxLinkLoadError(jqxhr, textStatus, error, $link, sys_path);
|
|
|
+ });
|
|
|
|
|
|
return false;
|
|
|
};
|
|
|
|
|
|
+ function onAjaxLinkLoadError(jqxhr, textStatus, error, $link, sys_path){
|
|
|
+ console.warn('fail : error', jqxhr.responseText);
|
|
|
+ $link.removeClass('ajax-loading');
|
|
|
+ _$body.removeClass('ajax-loading');
|
|
|
+ };
|
|
|
+
|
|
|
function onAjaxLinkLoaded(data, $link, sys_path){
|
|
|
- console.log('ajax link loaded');
|
|
|
- _$content_container.html(data.rendered);
|
|
|
+ console.log('ajax link loaded : data', data);
|
|
|
_$body.removeClass('ajax-loading');
|
|
|
+
|
|
|
+ // replace all content with newly loaded
|
|
|
+ _$content_container.html(data.rendered);
|
|
|
+
|
|
|
// add body class for currently loaded content
|
|
|
_$body.removeClass().addClass('path-'+sys_path.replace(/\//g, '-'));
|
|
|
-
|
|
|
// id node add a generic path-node class to body
|
|
|
m = sys_path.match(/^\/?(edlp\/node\/\d+)$/g);
|
|
|
- if(m){
|
|
|
+ if(m)
|
|
|
_$body.addClass('path-edlp-node');
|
|
|
- }
|
|
|
+
|
|
|
+ // handle clicked link classes
|
|
|
_$ajaxLinks.removeClass('is-active');
|
|
|
$link.removeClass('ajax-loading').addClass('is-active');
|
|
|
|
|
|
+ // if block attached (eg : from edlp_productions module)
|
|
|
+ if(typeof data.block != 'undefined'){
|
|
|
+ // if block not already added
|
|
|
+ if(!$('#'+data.block.id, '.region-'+data.block.region).length){
|
|
|
+ $('.region-'+data.block.region).append(data.block.rendered);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
initScrollbars();
|
|
|
|
|
|
if(sys_path == "productions")
|
|
@@ -142,7 +164,7 @@ edlp_vars = {
|
|
|
_$corpus_map = $('canvas#corpus-map');
|
|
|
_$corpus_map.on('corpus-cliked-on-map', function(e) {
|
|
|
console.log('theme : corpus-cliked-on-map');
|
|
|
- closeAllModals();
|
|
|
+ backToFrontPage();
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -170,6 +192,20 @@ edlp_vars = {
|
|
|
// });
|
|
|
};
|
|
|
|
|
|
+
|
|
|
+ // ___ _ ___
|
|
|
+ // | __| _ ___ _ _| |_| _ \__ _ __ _ ___
|
|
|
+ // | _| '_/ _ \ ' \ _| _/ _` / _` / -_)
|
|
|
+ // |_||_| \___/_||_\__|_| \__,_\__, \___|
|
|
|
+ // |___/
|
|
|
+ function backToFrontPage(){
|
|
|
+ closeAllModals();
|
|
|
+ // assume we are going back to front page
|
|
|
+ $('body').removeClass().addClass('path-frontpage');
|
|
|
+ $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
// __ __ _ _
|
|
|
// | \/ |___ __| |__ _| |___
|
|
|
// | |\/| / _ \/ _` / _` | (_-<
|
|
@@ -179,8 +215,6 @@ edlp_vars = {
|
|
|
// TODO: animate the remove
|
|
|
_$content_container.html('');
|
|
|
_$ajaxLinks.removeClass('is-active');
|
|
|
- $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
|
|
|
-
|
|
|
};
|
|
|
|
|
|
init();
|