|
@@ -163,7 +163,7 @@
|
|
};
|
|
};
|
|
function onAjaxLoaded(data, state){
|
|
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 url:'+state.url+' ajax_path:'+state.ajax_path+' sys_path:'+state.sys_path);
|
|
-
|
|
|
|
|
|
+ // console.log(data);
|
|
// reset all style may been added by other pages (like masonry for productions)
|
|
// reset all style may been added by other pages (like masonry for productions)
|
|
// and replace all content with newly loaded
|
|
// and replace all content with newly loaded
|
|
// TODO: build a system to replace or append contents (like studio + search)
|
|
// TODO: build a system to replace or append contents (like studio + search)
|
|
@@ -228,6 +228,28 @@
|
|
addCloseModalBtnToCols();
|
|
addCloseModalBtnToCols();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // update the language switcher block if it comes in the response
|
|
|
|
+ if(typeof data.translations_links != 'undefined'){
|
|
|
|
+ console.log('state',state);
|
|
|
|
+ var lang_code = drupalSettings.path.currentLanguage;
|
|
|
|
+ var $links = $(data.translations_links);
|
|
|
|
+ // set active link
|
|
|
|
+ $links.find('li[hreflang="'+lang_code+'"]').addClass('is-active').find('a').addClass('is-active');
|
|
|
|
+
|
|
|
|
+ if(state.view_mode){
|
|
|
|
+ $links.find('a').each(function(i,e){
|
|
|
|
+ var $a = $(this);
|
|
|
|
+ $a.attr('href', $a.attr('href')+'#'+state.view_mode);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // if(state.selector){
|
|
|
|
+ // $links.find('a').attr('selector', state.selector);
|
|
|
|
+ // }
|
|
|
|
+
|
|
|
|
+ $('ul','.block.language-switcher-language-url').replaceWith($links);
|
|
|
|
+ }
|
|
|
|
+
|
|
initAjaxLinks();
|
|
initAjaxLinks();
|
|
|
|
|
|
// trigger other modules behaviours
|
|
// trigger other modules behaviours
|
|
@@ -281,6 +303,34 @@
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ // _ _ ___ _ _
|
|
|
|
+ // /_\ (_)__ ___ __ | _ ) |___ __| |__ ___
|
|
|
|
+ // / _ \ | / _` \ \ / | _ \ / _ \/ _| / /(_-<
|
|
|
|
+ // /_/ \_\/ \__,_/_\_\ |___/_\___/\__|_\_\/__/
|
|
|
|
+ // |__/
|
|
|
|
+ // NOT USED (YET)
|
|
|
|
+ function refreshAllBlocks(){
|
|
|
|
+ var path = window.location.origin + Drupal.url(_ajax_settings.blocksjson_path);
|
|
|
|
+ $.getJSON(path, {})
|
|
|
|
+ .done(function(data){
|
|
|
|
+ onAjaxBlockLoaded(data);
|
|
|
|
+ })
|
|
|
|
+ .fail(function(jqxhr, textStatus, error){
|
|
|
|
+ onAjaxBlockLoadError(jqxhr, textStatus, error);
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+ function onAjaxBlockLoadError(jqxhr, textStatus, error){
|
|
|
|
+ console.warn('ajax block load failed: '+error, jqxhr.responseText);
|
|
|
|
+ };
|
|
|
|
+ function onAjaxBlockLoaded(data){
|
|
|
|
+ console.log('onAjaxBlockLoaded', data);
|
|
|
|
+ // TODO: update each blocks (exepted language switcher)
|
|
|
|
+ for (var blockname in data.blocks) {
|
|
|
|
+ var block = data.blocks[blockname];
|
|
|
|
+ console.log(blockname, block);
|
|
|
|
+ $(block.id).replaceWith(block.rendered);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
// _ _ _ _
|
|
// _ _ _ _
|
|
// | || (_)__| |_ ___ _ _ _ _
|
|
// | || (_)__| |_ ___ _ _ _ _
|
|
// | __ | (_-< _/ _ \ '_| || |
|
|
// | __ | (_-< _/ _ \ '_| || |
|
|
@@ -300,6 +350,7 @@
|
|
var origin_hash = window.localStorage.getItem('edlp_origin_hash');
|
|
var origin_hash = window.localStorage.getItem('edlp_origin_hash');
|
|
var view_mode = origin_hash.replace('#', '');
|
|
var view_mode = origin_hash.replace('#', '');
|
|
if(view_mode){
|
|
if(view_mode){
|
|
|
|
+ // TODO first load with index or notice do not activate the right link (activate all)
|
|
var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
|
|
var $link = $('[href="'+origin_url+'"][viewmode="'+view_mode+'"]');
|
|
var selector = $link.attr('selector') || null;
|
|
var selector = $link.attr('selector') || null;
|
|
if(selector){
|
|
if(selector){
|
|
@@ -371,7 +422,7 @@
|
|
|
|
|
|
$('a.site-name', '#block-edlptheme-branding')
|
|
$('a.site-name', '#block-edlptheme-branding')
|
|
.add('a', '#block-mainnavigation')
|
|
.add('a', '#block-mainnavigation')
|
|
- .add('a', '.block.language-switcher-language-url')
|
|
|
|
|
|
+ // .add('a', '.block.language-switcher-language-url')
|
|
.add('a', '#block-footer.menu--footer')
|
|
.add('a', '#block-footer.menu--footer')
|
|
.add('a', '#block-productions')
|
|
.add('a', '#block-productions')
|
|
.add('a', 'article.node:not(.node--type-enregistrement) h2.node-title')
|
|
.add('a', 'article.node:not(.node--type-enregistrement) h2.node-title')
|
|
@@ -409,10 +460,14 @@
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if($link.is('.language-link')){
|
|
|
|
- // TODO load all blocks translated ... :/
|
|
|
|
- // then let load the content
|
|
|
|
- }
|
|
|
|
|
|
+ // NOT USED (YET)
|
|
|
|
+ // if($link.is('.language-link')){
|
|
|
|
+ // TODO: change global site current language
|
|
|
|
+ // load all blocks translated (exepted language switcher) ... :/
|
|
|
|
+ // refreshAllBlocks();
|
|
|
|
+ // TODO: use a promise to initAjaxLinks again after blocks updated
|
|
|
|
+ // then let load the content
|
|
|
|
+ // }
|
|
|
|
|
|
// other links
|
|
// other links
|
|
var sys_path = $(this).attr('data-drupal-link-system-path');
|
|
var sys_path = $(this).attr('data-drupal-link-system-path');
|
|
@@ -443,6 +498,7 @@
|
|
return false;
|
|
return false;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+
|
|
// ___
|
|
// ___
|
|
// / __|___ _ _ _ __ _ _ ___
|
|
// / __|___ _ _ _ __ _ _ ___
|
|
// | (__/ _ \ '_| '_ \ || (_-<
|
|
// | (__/ _ \ '_| '_ \ || (_-<
|