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:
File diff suppressed because one or more lines are too long
@@ -51,7 +51,7 @@ MaterioFlag = function(){
|
||||
|
||||
var name = $this.attr('class').match(/flag_lists_[^_]+_[0-9]+/);
|
||||
// trace('MaterioFlag :: name', name);
|
||||
$('<span class="preview">open preview</span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
||||
$('<span class="preview"><i class="icon-eye-open"></i></span>').attr('name', name).insertAfter($this).bind('click', onClickShowPreview);
|
||||
});
|
||||
|
||||
// preview block
|
||||
@@ -113,6 +113,10 @@ MaterioFlag = function(){
|
||||
$('a.flag-lists-create:not(.ajax-processed)', container)
|
||||
.bind('click', onClickCreatLink)
|
||||
.addClass('ajax-processed');
|
||||
|
||||
$('a.edit-list:not(.ajax-processed)', container)
|
||||
.bind('click', onCLickEditList)
|
||||
.addClass('ajax-processed');
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -158,9 +162,13 @@ MaterioFlag = function(){
|
||||
|
||||
$.event.trigger('loading-content');
|
||||
|
||||
$.getJSON(url, function(json){
|
||||
$.getJSON(url, {'current_path':document.location.href},function(json){
|
||||
trace('MaterioFlag :: json', json);
|
||||
changeContent(json);
|
||||
if(json.redirect){
|
||||
window.location = json.redirect;
|
||||
}else{
|
||||
changeContent(json);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@@ -214,7 +222,7 @@ MaterioFlag = function(){
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/createlist/form/'+type[0];
|
||||
|
||||
$.getJSON(url, function(json){
|
||||
trace('MaterioFlag :: json', json);
|
||||
trace('MaterioFlag :: creat list : json', json);
|
||||
showCreateListForm(json, $link);
|
||||
});
|
||||
return false;
|
||||
@@ -358,6 +366,142 @@ MaterioFlag = function(){
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* onCLickEditList(event)
|
||||
*/
|
||||
function onCLickEditList(event){
|
||||
// TODO: empécher le double formulaire
|
||||
event.preventDefault();
|
||||
var $link = $(event.currentTarget);
|
||||
var lid = $link.attr('href').match(/[^\/]*$/);
|
||||
var type = 'materiau'; // this is cheap
|
||||
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlistform/'+type+'/'+lid[0];
|
||||
|
||||
$.getJSON(url, function(json){
|
||||
trace('MaterioFlag :: editlist : json', json);
|
||||
showEditListForm(json, $link);
|
||||
});
|
||||
return false;
|
||||
};
|
||||
|
||||
function showEditListForm(json, $link){
|
||||
|
||||
// google analytics
|
||||
$.event.trigger({
|
||||
type:"record-stat",
|
||||
categorie:"flagLists",
|
||||
action: 'show edit form'
|
||||
});
|
||||
|
||||
var $modal = $('<div id="modal" class="modal"/>').appendTo('body');
|
||||
$modal
|
||||
.css({
|
||||
position:'absolute',
|
||||
top:'40%', left:'50%',
|
||||
marginLeft:'-150px', width:'300px',
|
||||
zIndex:"99999"
|
||||
})
|
||||
.append(json.return)
|
||||
.find('input[type="submit"]', '#materio-flag-edit-list-form').bind('click', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
var $form = $(this).parents('form');
|
||||
var title = $form.find('input[name*="flag-lists-title"]').val();
|
||||
var fid = $form.find('input[name*="fid"]').val();
|
||||
var name = $form.find('input[name*="name"]').val();
|
||||
|
||||
switch($(this).attr('name')){
|
||||
case 'cancel':
|
||||
trace('MaterioFlag :: cancel',event);
|
||||
$(this).parents('#modal').remove();
|
||||
|
||||
// google analytics
|
||||
var action = 'cancel edit form';
|
||||
|
||||
break;
|
||||
case 'save':
|
||||
trace('MaterioFlag :: create',event);
|
||||
|
||||
// google analytics
|
||||
var action = "submit edit form";
|
||||
|
||||
editList($modal, fid, name, title);
|
||||
break;
|
||||
case 'delete':
|
||||
trace('MaterioFlag :: delete',event);
|
||||
|
||||
if(confirm('Do you realy want to delete the folder '+title+'?')){
|
||||
var action = "submit delete form";
|
||||
deleteList($modal, fid);
|
||||
}else{
|
||||
var action = "cancel delete form";
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// google analytics
|
||||
$.event.trigger({
|
||||
type:"record-stat",
|
||||
categorie:"flagLists",
|
||||
action: action
|
||||
});
|
||||
|
||||
return false;
|
||||
})
|
||||
.parents('form').find('input[type="text"]').focus();
|
||||
// TODO: esc keypressed close the form
|
||||
};
|
||||
|
||||
function editList($modal, fid, name, title){
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/editlist/'+fid+'/'+name+'/'+title;
|
||||
$.getJSON(url, function(data) {
|
||||
if (data.error) {
|
||||
// trace(data.error);
|
||||
if(data.message)
|
||||
alert(data.message);
|
||||
}
|
||||
else {
|
||||
trace('MaterioFlag :: saved list : data', data);
|
||||
|
||||
$.event.trigger({
|
||||
type : 'list-edited',
|
||||
name : data.listname,
|
||||
title : data.title,
|
||||
});
|
||||
|
||||
refreshBlocks();
|
||||
refreshNodeLinks();
|
||||
|
||||
$modal.remove();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function deleteList($modal, fid){
|
||||
// prompt('are you sure ?');
|
||||
var url = Drupal.settings.basePath+Drupal.settings.pathPrefix+'materioflag/deletelist/'+fid;
|
||||
$.getJSON(url, function(data) {
|
||||
if (data.error) {
|
||||
// trace(data.error);
|
||||
if(data.message)
|
||||
alert(data.message);
|
||||
}
|
||||
else {
|
||||
trace('MaterioFlag :: deleted list : data', data);
|
||||
|
||||
refreshBlocks();
|
||||
refreshNodeLinks();
|
||||
// TODO: if the deleted list was the current displayed list ??
|
||||
$modal.remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function onInitScrollerPager(event){
|
||||
// trace('MaterioFlag :: MaterioFlag :: onInitScrollerPager');
|
||||
if (isList()){
|
||||
|
File diff suppressed because one or more lines are too long
@@ -5,7 +5,10 @@
|
||||
MaterioPageTitle = function(){
|
||||
|
||||
function init(){
|
||||
$(document).bind('materio-page-title-refresh-block', onRefreshBlock);
|
||||
$(document)
|
||||
.bind('materio-page-title-refresh-block', onRefreshBlock)
|
||||
.bind('list-edited', onListEdited);
|
||||
|
||||
};
|
||||
|
||||
function onRefreshBlock(event){
|
||||
@@ -19,6 +22,16 @@ MaterioPageTitle = function(){
|
||||
$('#block-materio-page-title-materio-page-title h1').html(event.title);
|
||||
};
|
||||
|
||||
function onListEdited(event){
|
||||
trace('MaterioPageTitle :: onListEdited', event);
|
||||
|
||||
// this is for refreshing page title when list title was just edited AND this list is the cirreunt list
|
||||
if($("#materio-page-title ."+event.name).length)
|
||||
$('a.open-list.'+event.name).eq(0).trigger('click');
|
||||
|
||||
};
|
||||
|
||||
|
||||
init();
|
||||
};
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
@@ -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