update
- added materio_user.module (add permission to view the profile page) - materio_serach_api.pages : limit actu items for anonymous - materio_search_api_ajax.pages & materio_flag.pages : redirect to real page if current page not corresponding on ajax request (solve the view mode block visibility on user edit profile page) - materio_flag : added edit lists functionalities ++ get_list_page_title func Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
@@ -81,10 +81,10 @@ MaterioSearchApiAjax = function(){
|
||||
$.event.trigger('loading-content');
|
||||
_isloadingresults = true;
|
||||
$('#materio-search-api-search-form').addClass('loading');
|
||||
|
||||
// trace('window.location.href',window.location.href);
|
||||
// TODO: record ajax path in a variable from materio_search_api_ajax_init
|
||||
$.getJSON(Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys,
|
||||
{'types':types},
|
||||
{'types':types,'current_path':document.location.href},
|
||||
function(json){
|
||||
trace('json', json);
|
||||
$.event.trigger('loaded-content');
|
||||
@@ -99,8 +99,12 @@ MaterioSearchApiAjax = function(){
|
||||
label : 'filters : '+ stringTypes.join(' ,'),
|
||||
value : json.count
|
||||
});
|
||||
|
||||
changeContent(json);
|
||||
if(json.redirect){
|
||||
window.location = json.redirect;
|
||||
}else{
|
||||
changeContent(json);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -129,7 +133,7 @@ MaterioSearchApiAjax = function(){
|
||||
|
||||
if(json.return){
|
||||
$.event.trigger('loaded-content');
|
||||
$('.inner-content',_$content).html(json.return);
|
||||
$('.inner-content',_$content).html(json.return).find('ul.pager').hide();
|
||||
triggerContentChanged();
|
||||
}else{
|
||||
trace('no results');
|
||||
@@ -162,57 +166,54 @@ MaterioSearchApiAjax = function(){
|
||||
};
|
||||
|
||||
function onLoadScrollerPager(event){
|
||||
if (isExplore())
|
||||
loadNextResultsPage(event.href);
|
||||
if(!_isloadingresults){
|
||||
if (isExplore())
|
||||
loadNextResultsPage(event.href);
|
||||
|
||||
if(isActuality())
|
||||
loadNextActualityPage(event.href);
|
||||
if(isActuality())
|
||||
loadNextActualityPage(event.href);
|
||||
}
|
||||
};
|
||||
|
||||
function loadNextResultsPage(href){
|
||||
// trace('loadNextResultsPage');
|
||||
if(!_isloadingresults){
|
||||
var keys = href.match(/explore\/([^\/|\?]+)/);
|
||||
var page = href.match(/\?page=([0-9]+)/);
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys[1]+'/'+page[1];
|
||||
|
||||
loadNextPage(url, $('.materiobase-results', _$content), '.search-results');
|
||||
}
|
||||
var keys = href.match(/explore\/([^\/|\?]+)/);
|
||||
var page = href.match(/\?page=([0-9]+)/);
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/search/'+keys[1]+'/'+page[1];
|
||||
|
||||
loadNextPage(url, $('.materiobase-results', _$content), '.search-results');
|
||||
};
|
||||
|
||||
function loadNextActualityPage(href){
|
||||
// trace('loadNextActualityPage');
|
||||
if(!_isloadingresults){
|
||||
var page = href.match(/\?page=([0-9]+)/);
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
|
||||
var page = href.match(/\?page=([0-9]+)/);
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materio_search_api_ajax/actuality/'+page[1];
|
||||
|
||||
loadNextPage(url, $('.materiobase-actuality', _$content), '.actuality-items');
|
||||
}
|
||||
loadNextPage(url, $('.materiobase-actuality', _$content), '.actuality-items');
|
||||
};
|
||||
|
||||
function loadNextPage(url, $container, target){
|
||||
trace('loadNextPage');
|
||||
trace('MaterioSearchApiAjax :: loadNextPage()');
|
||||
_isloadingresults = true;
|
||||
$container.addClass('loading');
|
||||
$.getJSON(url, function(json){
|
||||
trace('json', json);
|
||||
_isloadingresults = false;
|
||||
$container.removeClass('loading');
|
||||
addNextpage(json, target);
|
||||
// addNextpageItemByItem($(json.return), target);
|
||||
});
|
||||
};
|
||||
|
||||
function addNextpage(json, container_class){
|
||||
var $newcontent = $(json.return),
|
||||
$newitems = $(container_class, $newcontent).children('article').addClass('just-added'),
|
||||
$newitems = $(container_class, $newcontent).children('article'), //.addClass('just-added'),
|
||||
$newpager = $('ul.pager', $newcontent);
|
||||
|
||||
|
||||
$(container_class, _$content).append($newitems);
|
||||
$('ul.pager', _$content).replaceWith($newpager.hide());
|
||||
|
||||
// TODO: animation, this should be on theme side
|
||||
$(container_class, _$content).children('.just-added').each(function(i){
|
||||
// $(this).delay(5000*i).removeClass('just-added');
|
||||
var $this = $(this);
|
||||
setTimeout(function(){
|
||||
$this.removeClass('just-added');
|
||||
@@ -223,38 +224,66 @@ MaterioSearchApiAjax = function(){
|
||||
type : 'resultscompleted',
|
||||
container : $(container_class, _$content)
|
||||
});
|
||||
_isloadingresults = false;
|
||||
};
|
||||
|
||||
// TEST not used
|
||||
function addNextpageItemByItem($newcontent, container_class){
|
||||
trace('MaterioSearchApiAjax :: addNextpageItemByItem()');
|
||||
$('ul.pager', _$content).remove();
|
||||
$(container_class, _$content).append($(container_class, $newcontent).children('article').eq(0));
|
||||
|
||||
if($(container_class, $newcontent).children('article').length){
|
||||
setTimeout(function(){
|
||||
addNextpageItemByItem($newcontent, container_class);
|
||||
}, 200);
|
||||
}else{
|
||||
_isloadingresults = false;
|
||||
$('ul.pager', _$content).replaceWith($('ul.pager', $newcontent).hide());
|
||||
$.event.trigger({
|
||||
type : 'resultscompleted',
|
||||
container : $(container_class, _$content)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* viewmode
|
||||
*/
|
||||
function initViewMode(){
|
||||
$('.viewmode-link').click(function(event){
|
||||
event.preventDefault();
|
||||
changeViewMode($(this).attr('rel'), $(this));
|
||||
|
||||
if(!$(this).is('.active'))
|
||||
changeViewMode($(this).attr('rel'), $(this));
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
function changeViewMode(vm, $btn){
|
||||
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
|
||||
trace('viewmode json', json);
|
||||
if (json.statut == "saved"){
|
||||
|
||||
// google analytics
|
||||
$.event.trigger({
|
||||
type : "record-stat",
|
||||
categorie : 'Viewmode',
|
||||
action : vm,
|
||||
label : isActuality() ? 'Actualities' : 'Search results'
|
||||
});
|
||||
if(!_isloadingresults){
|
||||
_isloadingresults = true;
|
||||
$.getJSON(Drupal.settings.basePath+'materio_search_api_ajax/viewmode/change/'+vm, function(json){
|
||||
trace('viewmode json', json);
|
||||
_isloadingresults = false;
|
||||
if (json.statut == "saved"){
|
||||
|
||||
// google analytics
|
||||
$.event.trigger({
|
||||
type : "record-stat",
|
||||
categorie : 'Viewmode',
|
||||
action : vm,
|
||||
label : isActuality() ? 'Actualities' : 'Search results'
|
||||
});
|
||||
|
||||
$.event.trigger('view-mode-changed');
|
||||
$('.viewmode-link, .viewmode-link i').removeClass('active');
|
||||
$btn.addClass('active').find('i').addClass('active');
|
||||
}
|
||||
|
||||
});
|
||||
$.event.trigger('view-mode-changed');
|
||||
$('.viewmode-link, .viewmode-link i').removeClass('active');
|
||||
$btn.addClass('active').find('i').addClass('active');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function onViewModeChanged(event){
|
||||
|
||||
Reference in New Issue
Block a user