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:
@@ -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()){
|
||||
|
||||
Reference in New Issue
Block a user