refactoring (gulp and libraries) + some fixing

This commit is contained in:
Bachir Soussi Chiadmi
2018-04-04 12:58:58 +02:00
parent c8f54cb9f1
commit 6263b674b8
31 changed files with 13519 additions and 150 deletions
@@ -18,22 +18,21 @@
function init(){
// console.log("EdlpTheme init()");
// redirect all no-front pages to front with right url ajax load
initHistory();
_$body.on('corpus-map-ready', onCorpusMapReady);
if(!drupalSettings.path.isFront)
return;
initEvents();
_audioPlayer = new AudioPlayer();
_compoPlayer = new CompoPlayer();
initAjaxLinks();
if (_$body.is('.path-productions')) initProductions();
if(_$body.is('.path-frontpage')) initHome();
// if (_$body.is('.path-productions')) initProductions();
// if(_$body.is('.path-frontpage')) initHome();
// initScrollbars();
initEvents();
};
// ___ _
@@ -41,7 +40,8 @@
// | _|\ V / -_) ' \ _(_-<
// |___|\_/\___|_||_\__/__/
function initEvents(){
$('body')
_$body
.on('corpus-map-ready', onCorpusMapReady)
.on('on-studio-chutier-updated', initAjaxLinks)
.on('studio-initialized', function(e){
_compoPlayer.newCompo();
@@ -118,32 +118,18 @@
var path = window.location.origin + Drupal.url(ajax_path);
$.getJSON(path, {})
.done(function(data){
onAjaxLoaded(data, sys_path, selector);
onAjaxLoaded(data, url, ajax_path, sys_path, selector);
})
.fail(function(jqxhr, textStatus, error){
onAjaxLoadError(jqxhr, textStatus, error, sys_path);
});
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){
// console.log('url:'+url+' ; state',state);
// we can not pushestate with absolute url
history.pushState(state, null, url);
}
};
function onAjaxLoadError(jqxhr, textStatus, error, sys_path){
console.warn('ajaxlink load failed for '+sys_path+' : '+error, jqxhr.responseText);
$('.ajax-loading').removeClass('ajax-loading');
_$body.removeClass('ajax-loading');
};
function onAjaxLoaded(data, sys_path, selector){
function onAjaxLoaded(data, url, ajax_path, sys_path, selector){
// console.log('ajax loaded : data', data);
// reset all style may been added by other pages (like masonry for productions)
@@ -217,6 +203,18 @@
_$body.attr('booted', 'booted');
_$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){
// console.log('url:'+url+' ; state',state);
// we can not pushestate with absolute url
history.pushState(state, null, url);
}
};
function addCloseBtnToCols(){
@@ -304,10 +302,8 @@
.add('a', '.productions-subtree')
.add('a', '.productions-parent')
// .add('a.index-link, a.notice-link', '#block-edlpentreesblock')
// .addClass('use-ajax')
.addClass('ajax-link');
Drupal.ajax.bindAjaxLinks('#block-footer.menu--footer');
_$ajaxLinks = $('.ajax-link:not(.ajax-enabled)')
.each(function(i,e){
var $this = $(this);
@@ -464,7 +460,6 @@
this.$previous.on('click', this.playPrevious.bind(this));
this.$playpause.on('click', this.togglePlayPause.bind(this));
this.$next.on('click', this.playNext.bind(this));
// TODO: previous and next btns
},
openDocument(node, caller){
// console.log('AudioPlayer openDocument', node);
@@ -796,7 +791,7 @@
this.refresh();
this.active = true; // TODO: set active false
this.active = true;
// this.newCompo();
}
},
@@ -1069,7 +1064,6 @@
d.setTime(d.getTime() + 24*60*60*1000*days);
document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString();
}
function deleteCookie(name) { setCookie(name, '', -1); }
init();