added animation to edlp loader, created edlp_ajax_node module
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
var _is_front = _$body.is('.path-frontpage');
|
||||
var _$corpus_map;
|
||||
var _$content_container = $('.layout-container>main>.layout-content');
|
||||
var _$ajaxLinks;
|
||||
|
||||
function init(){
|
||||
console.log("EdlpTheme init()");
|
||||
@@ -30,30 +31,59 @@
|
||||
// / _ \ | / _` \ \ /
|
||||
// /_/ \_\/ \__,_/_\_\
|
||||
// |__/
|
||||
|
||||
// TODO: add url hash nav
|
||||
// TODO: implement history.js
|
||||
function initAjaxLinks(){
|
||||
console.log('initAjaxLinks');
|
||||
$('a', '#block-mainnavigation').on('click', onClickAjaxLink);
|
||||
$('a', '#block-mainnavigation, #block-footer.menu--footer').addClass('ajax-link');
|
||||
|
||||
_$ajaxLinks = $('.ajax-link')
|
||||
.each(function(i,e){
|
||||
var $this = $(this);
|
||||
var sys_path = $this.attr('data-drupal-link-system-path');
|
||||
if(sys_path){
|
||||
// convert node link to edlp_ajax_node module links
|
||||
m = sys_path.match(/^\/?(node\/\d+)$/g);
|
||||
if(m) $this.attr('data-drupal-link-system-path', 'edlp/'+m[0]);
|
||||
}
|
||||
})
|
||||
.on('click', onClickAjaxLink);
|
||||
;
|
||||
};
|
||||
|
||||
function onClickAjaxLink(e){
|
||||
e.preventDefault();
|
||||
// TODO: drupal settings not defined on NOT front page
|
||||
var $link = $(this);
|
||||
|
||||
if($link.is('.is-active'))
|
||||
return false;
|
||||
|
||||
var sys_path = $(this).attr('data-drupal-link-system-path');
|
||||
if(sys_path == '<front>'){
|
||||
closeAllModals();
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: drupal settings not defined on NOT front page
|
||||
var path = window.location.origin + drupalSettings.basepath + sys_path +'/ajax';
|
||||
closeAllModals();
|
||||
_$body.addClass('ajax-loading');
|
||||
$link.addClass('ajax-loading');
|
||||
$.getJSON(path, {}, function(data){
|
||||
onAjaxLinkLoaded(data, sys_path);
|
||||
onAjaxLinkLoaded(data, $link, sys_path);
|
||||
});
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
function onAjaxLinkLoaded(data, sys_path){
|
||||
function onAjaxLinkLoaded(data, $link, sys_path){
|
||||
console.log('ajax link loaded : data', data);
|
||||
_$content_container.html(data.rendered);
|
||||
_$body.removeClass().addClass('path-'+sys_path);
|
||||
_$body.removeClass('ajax-loading');
|
||||
_$body.removeClass().addClass('path-'+sys_path);
|
||||
_$ajaxLinks.removeClass('is-active');
|
||||
$link.removeClass('ajax-loading').addClass('is-active');
|
||||
initScrollbars();
|
||||
};
|
||||
|
||||
@@ -72,6 +102,9 @@
|
||||
console.log('theme : closeAllModals');
|
||||
// TODO: animate the remove
|
||||
_$content_container.html('');
|
||||
_$ajaxLinks.removeClass('is-active');
|
||||
$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
|
||||
|
||||
};
|
||||
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user