mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 15:03:25 +00:00
Push & Feedback templates
This commit is contained in:
@@ -60,23 +60,115 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#PushBox form[name="FeedBackForm"]').bind('submit', function(){
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: $this.attr('method'),
|
||||
url: $this.attr('action'),
|
||||
dataType: 'json',
|
||||
data: $this.serializeArray(),
|
||||
beforeSend:function(){
|
||||
|
||||
},
|
||||
success: function(data){
|
||||
|
||||
return;
|
||||
},
|
||||
error: function(){
|
||||
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.FeedbackSend', this.container).bind('click', function(){
|
||||
if($('.badges .badge', $container).length === 0)
|
||||
{
|
||||
alert(language.FeedBackNoUsersSelected);
|
||||
return;
|
||||
}
|
||||
|
||||
if($('#FeedBackSendDialog').length == 0)
|
||||
{
|
||||
$('body').append('<div id="FeedBackSendDialog" style="display:none;"></div>');
|
||||
}
|
||||
|
||||
var $dialog = $('#FeedBackSendDialog');
|
||||
|
||||
$dialog.addClass('loading').dialog({
|
||||
buttons:{},
|
||||
draggable:false,
|
||||
resizable:false,
|
||||
modal:true,
|
||||
closeOnEscape:true,
|
||||
width:300,
|
||||
height:400
|
||||
}).dialog( "moveToTop" );
|
||||
|
||||
var $FeedBackForm = $('form[name="FeedBackForm"]', $container);
|
||||
|
||||
var buttons = {};
|
||||
|
||||
buttons[language.cancel] = function(){
|
||||
$dialog.dialog('destroy');
|
||||
$dialog.remove();
|
||||
};
|
||||
buttons[language.send] = function(){
|
||||
$dialog.dialog('destroy');
|
||||
$dialog.remove();
|
||||
|
||||
$('#PushBox form[name="FeedBackForm"]').trigger('submit');
|
||||
|
||||
$('input[name="name"]', $FeedBackForm).val($('input[name="name"]', $dialog).val());
|
||||
$('textarea[name="message"]', $FeedBackForm).val($('textarea[name="message"]', $dialog).val());
|
||||
};
|
||||
|
||||
var callback = function(rendered){
|
||||
|
||||
$('input[name="name"]', rendered).val($('input[name="name"]', $FeedBackForm).val());
|
||||
$('textarea[name="message"]', rendered).val($('textarea[name="message"]', $FeedBackForm).val());
|
||||
|
||||
$dialog.dialog('option', 'buttons', buttons).removeClass('loading').empty().append(rendered);
|
||||
};
|
||||
|
||||
p4.Mustache.Render('Feedback-SendForm', { language:language }, callback);
|
||||
}).button();
|
||||
|
||||
$('.user_content .badges', this.container).disableSelection();
|
||||
|
||||
$('.user_content .badges .badge .toggle', this.container).live('click', function(event){
|
||||
var $this = $(this);
|
||||
$this.toggleClass('status_off status_on');
|
||||
$this.find('input').val($this.hasClass('status_on') ? '1' : '0');
|
||||
return;
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.general_togglers .general_toggler', this.container).bind('click', function(){
|
||||
console.log('togglers');
|
||||
var feature = $(this).attr('feature');
|
||||
var badges = $('.user_content .badge.selected .status_off.toggle_' + feature, this.container);
|
||||
if(badges.length == 0)
|
||||
|
||||
var $badges = $('.user_content .badge.selected', this.container);
|
||||
|
||||
var toggles = $('.status_off.toggle_' + feature, $badges);
|
||||
|
||||
if(toggles.length == 0)
|
||||
{
|
||||
var toggles = $('.status_on.toggle_' + feature, $badges);
|
||||
}
|
||||
if(toggles.length == 0)
|
||||
{
|
||||
humane.info('No user selected');
|
||||
}
|
||||
badges.trigger('click');
|
||||
toggles.trigger('click');
|
||||
return false;
|
||||
});
|
||||
|
||||
@@ -86,6 +178,12 @@
|
||||
return;
|
||||
});
|
||||
|
||||
$('.list_manager', this.container).bind('click', function(){
|
||||
$('#PushBox').hide();
|
||||
$('#ListManager').show();
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.options button', this.container).button();
|
||||
|
||||
$('form.list_saver', this.container).bind('submit', function(){
|
||||
@@ -221,6 +319,58 @@
|
||||
this.list = null;
|
||||
this.container = $container;
|
||||
|
||||
$('.back_link', this.container).bind('click', function(){
|
||||
$('#PushBox').show();
|
||||
$('#ListManager').hide();
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$('a.user_adder', this.container).bind('click', function(){
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: $this.attr('href'),
|
||||
dataType: 'html',
|
||||
beforeSend:function(){
|
||||
if($('#user_adder_dialog').length == 0)
|
||||
{
|
||||
$('body').append('<div id="user_adder_dialog" style="display:none;"></div>');
|
||||
}
|
||||
$('#user_adder_dialog').addClass('loading').empty().dialog({
|
||||
buttons:{},
|
||||
draggable:false,
|
||||
resizable:false,
|
||||
closeOnEscape:true,
|
||||
modal:true,
|
||||
width:'400',
|
||||
height:'400'
|
||||
}).dialog( "moveToTop" );
|
||||
},
|
||||
success: function(data){
|
||||
$('#user_adder_dialog').removeClass('loading').empty().append(data);
|
||||
return;
|
||||
},
|
||||
error: function(){
|
||||
$('#user_adder_dialog').dialog('destroy');
|
||||
$('#user_adder_dialog').remove();
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
$('#user_adder_dialog').dialog('destroy');
|
||||
$('#user_adder_dialog').remove();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
var initLeft = function() {
|
||||
$('a.list_refresh', $container).bind('click', function(event){
|
||||
|
||||
@@ -373,58 +523,88 @@
|
||||
|
||||
var initRight = function(){
|
||||
|
||||
$('.editor input[name="list-add-user"]', this.container).autocomplete({
|
||||
minLength: 2,
|
||||
source: function( request, response ) {
|
||||
$.ajax({
|
||||
url: '/prod/push/search-user/',
|
||||
dataType: "json",
|
||||
data: {
|
||||
query: request.term
|
||||
},
|
||||
success: function( data ) {
|
||||
response( data );
|
||||
}
|
||||
});
|
||||
var $container = this.container;
|
||||
|
||||
$('form[name="list-editor-search"]', this.container).bind('submit', function(){
|
||||
|
||||
var $this = $(this);
|
||||
var dest = $('.list-editor-results', $container);
|
||||
|
||||
$.ajax({
|
||||
url: $this.attr('action'),
|
||||
type: $this.attr('method'),
|
||||
dataType: "html",
|
||||
data: $this.serializeArray(),
|
||||
beforeSend : function () {
|
||||
dest.empty().addClass('loading');
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
if(ui.item.type == 'USER')
|
||||
{
|
||||
var callback = function(list, datas) {
|
||||
if($.inArray(ui.item.usr_id, datas.result) >= 0)
|
||||
{
|
||||
p4.Mustache.Render('List-Badge', ui.item, p4.ListManager.appendBadge);
|
||||
}
|
||||
$('.counter.current, .list.selected .counter', $('#ListManager')).each(function(){
|
||||
$(this).text(parseInt($(this).text()) + datas.result.length);
|
||||
});
|
||||
console.log('increment counter');
|
||||
}
|
||||
p4.ListManager.getList().addUser(ui.item.usr_id, callback);
|
||||
}
|
||||
return false;
|
||||
success: function( datas ) {
|
||||
|
||||
dest.empty().removeClass('loading').append(datas);
|
||||
}
|
||||
})
|
||||
.data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
|
||||
var autocompleter = $('.editor input[name="list-add-user"]', this.container);
|
||||
|
||||
autocompleter.addClass('loading');
|
||||
|
||||
var callback = function(datas){
|
||||
$(datas).data( "item.autocomplete", item ).appendTo( ul );
|
||||
autocompleter.data( "autocomplete" ).menu.refresh();
|
||||
autocompleter.data('autocomplete')._resizeMenu();
|
||||
autocompleter.removeClass('loading');
|
||||
};
|
||||
|
||||
if(item.type == 'USER')
|
||||
{
|
||||
var datas = p4.Mustache.Render('List-User-Item', item, callback);
|
||||
}
|
||||
|
||||
return;
|
||||
};
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('form[name="list-editor-search"] select', this.container).bind('change', function(){
|
||||
$(this).closest('form').trigger('submit');
|
||||
});
|
||||
|
||||
|
||||
|
||||
//
|
||||
// $('.editor input[name="list-add-user"]', this.container).autocomplete({
|
||||
// minLength: 2,
|
||||
// source: function( request, response ) {
|
||||
// $.ajax({
|
||||
// url: '/prod/push/search-user/',
|
||||
// dataType: "json",
|
||||
// data: {
|
||||
// query: request.term
|
||||
// },
|
||||
// success: function( data ) {
|
||||
// response( data );
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// select: function( event, ui ) {
|
||||
// if(ui.item.type == 'USER')
|
||||
// {
|
||||
// var callback = function(list, datas) {
|
||||
// if($.inArray(ui.item.usr_id, datas.result) >= 0)
|
||||
// {
|
||||
// p4.Mustache.Render('List-Badge', ui.item, p4.ListManager.appendBadge);
|
||||
// }
|
||||
// $('.counter.current, .list.selected .counter', $('#ListManager')).each(function(){
|
||||
// $(this).text(parseInt($(this).text()) + datas.result.length);
|
||||
// });
|
||||
// console.log('increment counter');
|
||||
// }
|
||||
// p4.ListManager.getList().addUser(ui.item.usr_id, callback);
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// })
|
||||
// .data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
//
|
||||
// var autocompleter = $('.editor input[name="list-add-user"]', this.container);
|
||||
//
|
||||
// autocompleter.addClass('loading');
|
||||
//
|
||||
// var callback = function(datas){
|
||||
// $(datas).data( "item.autocomplete", item ).appendTo( ul );
|
||||
// autocompleter.data( "autocomplete" ).menu.refresh();
|
||||
// autocompleter.data('autocomplete')._resizeMenu();
|
||||
// autocompleter.removeClass('loading');
|
||||
// };
|
||||
//
|
||||
// if(item.type == 'USER')
|
||||
// {
|
||||
// var datas = p4.Mustache.Render('List-User-Item', item, callback);
|
||||
// }
|
||||
//
|
||||
// return;
|
||||
// };
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user