mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 20:43:25 +00:00
Fix JS code style
This commit is contained in:
@@ -1,82 +1,82 @@
|
||||
var p4 = p4 || {};
|
||||
|
||||
$(document).ready(function(){
|
||||
$('input.input-button').hover(
|
||||
function(){$(this).addClass('hover');},
|
||||
function(){$(this).removeClass('hover');}
|
||||
);
|
||||
$('input.input-button').hover(
|
||||
function(){$(this).addClass('hover');},
|
||||
function(){$(this).removeClass('hover');}
|
||||
);
|
||||
|
||||
var locale = $.cookie('locale');
|
||||
var locale = $.cookie('locale');
|
||||
|
||||
var jq_date = p4.lng = typeof locale !== "undefined" ? locale.split('_').reverse().pop() : 'en';
|
||||
var jq_date = p4.lng = typeof locale !== "undefined" ? locale.split('_').reverse().pop() : 'en';
|
||||
|
||||
if(jq_date == 'en')
|
||||
{
|
||||
jq_date = 'en-GB';
|
||||
}
|
||||
if(jq_date == 'en')
|
||||
{
|
||||
jq_date = 'en-GB';
|
||||
}
|
||||
|
||||
$.datepicker.setDefaults({showMonthAfterYear: false});
|
||||
$.datepicker.setDefaults($.datepicker.regional[jq_date]);
|
||||
$.datepicker.setDefaults({showMonthAfterYear: false});
|
||||
$.datepicker.setDefaults($.datepicker.regional[jq_date]);
|
||||
|
||||
$('a.infoDialog,div.infoDialog').live('click',function(event){
|
||||
console.log("click");
|
||||
infoDialog($(this));
|
||||
});
|
||||
$('a.infoDialog,div.infoDialog').live('click',function(event){
|
||||
console.log("click");
|
||||
infoDialog($(this));
|
||||
});
|
||||
|
||||
var cache = $('#mainMenu .helpcontextmenu');
|
||||
$('.context-menu-item',cache).hover(function(){$(this).addClass('context-menu-item-hover');},function(){$(this).removeClass('context-menu-item-hover');});
|
||||
var cache = $('#mainMenu .helpcontextmenu');
|
||||
$('.context-menu-item',cache).hover(function(){$(this).addClass('context-menu-item-hover');},function(){$(this).removeClass('context-menu-item-hover');});
|
||||
|
||||
$('#help-trigger').contextMenu('#mainMenu .helpcontextmenu',{openEvt:'click',dropDown:true,theme:'vista', dropDown:true,
|
||||
showTransition:'slideDown',
|
||||
hideTransition:'hide',
|
||||
shadow:false
|
||||
});
|
||||
$('#help-trigger').contextMenu('#mainMenu .helpcontextmenu',{openEvt:'click',dropDown:true,theme:'vista', dropDown:true,
|
||||
showTransition:'slideDown',
|
||||
hideTransition:'hide',
|
||||
shadow:false
|
||||
});
|
||||
|
||||
$('#notification_trigger').bind('mousedown',function(event){
|
||||
event.stopPropagation();
|
||||
var box = $('#notification_box');
|
||||
if($(this).hasClass('open'))
|
||||
{
|
||||
box.hide();
|
||||
$(this).removeClass('open');
|
||||
clear_notifications();
|
||||
}
|
||||
else
|
||||
{
|
||||
box.show();
|
||||
$('#notification_trigger').bind('mousedown',function(event){
|
||||
event.stopPropagation();
|
||||
var box = $('#notification_box');
|
||||
if($(this).hasClass('open'))
|
||||
{
|
||||
box.hide();
|
||||
$(this).removeClass('open');
|
||||
clear_notifications();
|
||||
}
|
||||
else
|
||||
{
|
||||
box.show();
|
||||
|
||||
fix_notification_height();
|
||||
fix_notification_height();
|
||||
|
||||
$(this).addClass('open');
|
||||
read_notifications();
|
||||
}
|
||||
});
|
||||
$(this).addClass('open');
|
||||
read_notifications();
|
||||
}
|
||||
});
|
||||
|
||||
$(this).bind('mousedown',function(){
|
||||
var not_trigger = $('#notification_trigger');
|
||||
if(not_trigger.hasClass('open'))
|
||||
not_trigger.trigger('click');
|
||||
});
|
||||
$('#notification_box').bind('mousedown',function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
$(this).bind('mousedown',function(){
|
||||
var not_trigger = $('#notification_trigger');
|
||||
if(not_trigger.hasClass('open'))
|
||||
not_trigger.trigger('click');
|
||||
});
|
||||
$('#notification_box').bind('mousedown',function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
$('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');});
|
||||
$('#notification_box div.notification').live('mouseout',function(){$(this).removeClass('hover');});
|
||||
$('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');});
|
||||
$('#notification_box div.notification').live('mouseout',function(){$(this).removeClass('hover');});
|
||||
|
||||
|
||||
|
||||
$(this).bind('mousedown',function(){
|
||||
var box = $('#notification_box');
|
||||
if($('#notification_trigger').hasClass('open'))
|
||||
{
|
||||
box.hide();
|
||||
$('#notification_trigger').removeClass('open');
|
||||
clear_notifications();
|
||||
}
|
||||
});
|
||||
$(this).bind('mousedown',function(){
|
||||
var box = $('#notification_box');
|
||||
if($('#notification_trigger').hasClass('open'))
|
||||
{
|
||||
box.hide();
|
||||
$('#notification_trigger').removeClass('open');
|
||||
clear_notifications();
|
||||
}
|
||||
});
|
||||
|
||||
set_notif_position();
|
||||
set_notif_position();
|
||||
|
||||
|
||||
});
|
||||
@@ -84,149 +84,149 @@ $(document).ready(function(){
|
||||
|
||||
function login(what)
|
||||
{
|
||||
if (confirm(language.confirmRedirectAuth)) {
|
||||
if(what != undefined)
|
||||
{
|
||||
EcrireCookie('last_act',what,null,'/');
|
||||
}
|
||||
self.location.replace('/login/?postlog=1');
|
||||
}
|
||||
return false;
|
||||
if (confirm(language.confirmRedirectAuth)) {
|
||||
if(what != undefined)
|
||||
{
|
||||
EcrireCookie('last_act',what,null,'/');
|
||||
}
|
||||
self.location.replace('/login/?postlog=1');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function EcrireCookie(nom, valeur)
|
||||
{
|
||||
var argv=EcrireCookie.arguments;
|
||||
var argc=EcrireCookie.arguments.length;
|
||||
var expires=(argc > 2) ? argv[2] : null;
|
||||
var path=(argc > 3) ? argv[3] : null;
|
||||
var domain=(argc > 4) ? argv[4] : null;
|
||||
var secure=(argc > 5) ? argv[5] : false;
|
||||
var cook = nom+"="+escape(valeur)+
|
||||
((expires===null) ? "" : ("; expires="+expires.toGMTString()))+
|
||||
((path===null) ? "" : ("; path="+path))+
|
||||
((domain===null) ? "" : ("; domain="+domain))+
|
||||
((secure===true) ? "; secure" : "");
|
||||
document.cookie = cook;
|
||||
var argv=EcrireCookie.arguments;
|
||||
var argc=EcrireCookie.arguments.length;
|
||||
var expires=(argc > 2) ? argv[2] : null;
|
||||
var path=(argc > 3) ? argv[3] : null;
|
||||
var domain=(argc > 4) ? argv[4] : null;
|
||||
var secure=(argc > 5) ? argv[5] : false;
|
||||
var cook = nom+"="+escape(valeur)+
|
||||
((expires===null) ? "" : ("; expires="+expires.toGMTString()))+
|
||||
((path===null) ? "" : ("; path="+path))+
|
||||
((domain===null) ? "" : ("; domain="+domain))+
|
||||
((secure===true) ? "; secure" : "");
|
||||
document.cookie = cook;
|
||||
}
|
||||
|
||||
function fix_notification_height()
|
||||
{
|
||||
var box = $('#notification_box');
|
||||
var not = $('.notification',box);
|
||||
var n = not.length;
|
||||
var not_t = $('.notification_title',box);
|
||||
var n_t = not_t.length;
|
||||
var box = $('#notification_box');
|
||||
var not = $('.notification',box);
|
||||
var n = not.length;
|
||||
var not_t = $('.notification_title',box);
|
||||
var n_t = not_t.length;
|
||||
|
||||
h = not.outerHeight() * n + not_t.outerHeight() * n_t;
|
||||
h = h > 350 ? 350 : h;
|
||||
h = not.outerHeight() * n + not_t.outerHeight() * n_t;
|
||||
h = h > 350 ? 350 : h;
|
||||
|
||||
box.stop().animate({height:h});
|
||||
box.stop().animate({height:h});
|
||||
}
|
||||
|
||||
function set_notif_position()
|
||||
{
|
||||
var trigger = $('#notification_trigger');
|
||||
if(trigger.length === 0)
|
||||
return;
|
||||
$('#notification_box').css({
|
||||
'left':Math.round(trigger.offset().left - 1)
|
||||
});
|
||||
var trigger = $('#notification_trigger');
|
||||
if(trigger.length === 0)
|
||||
return;
|
||||
$('#notification_box').css({
|
||||
'left':Math.round(trigger.offset().left - 1)
|
||||
});
|
||||
}
|
||||
$(window).bind('resize', function(){
|
||||
set_notif_position();
|
||||
set_notif_position();
|
||||
});
|
||||
|
||||
|
||||
function print_notifications(page)
|
||||
{
|
||||
|
||||
page = parseInt(page);
|
||||
var buttons = {};
|
||||
page = parseInt(page);
|
||||
var buttons = {};
|
||||
|
||||
buttons[language.fermer] = function(){
|
||||
$('#notifications-dialog').dialog('close');
|
||||
};
|
||||
buttons[language.fermer] = function(){
|
||||
$('#notifications-dialog').dialog('close');
|
||||
};
|
||||
|
||||
if($('#notifications-dialog').length === 0)
|
||||
$('body').append('<div id="notifications-dialog" class="loading"></div>');
|
||||
if($('#notifications-dialog').length === 0)
|
||||
$('body').append('<div id="notifications-dialog" class="loading"></div>');
|
||||
|
||||
$('#notifications-dialog')
|
||||
.dialog({
|
||||
title:language.notifications,
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
width:500,
|
||||
height:400,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
},
|
||||
close:function(event,ui)
|
||||
{
|
||||
$('#notifications-dialog').dialog('destroy').remove();
|
||||
}
|
||||
}).dialog('option','buttons',buttons)
|
||||
.dialog('open');
|
||||
$('#notifications-dialog')
|
||||
.dialog({
|
||||
title:language.notifications,
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
width:500,
|
||||
height:400,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
},
|
||||
close:function(event,ui)
|
||||
{
|
||||
$('#notifications-dialog').dialog('destroy').remove();
|
||||
}
|
||||
}).dialog('option','buttons',buttons)
|
||||
.dialog('open');
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/user/notifications/",
|
||||
dataType : 'json',
|
||||
data: {
|
||||
page:page
|
||||
},
|
||||
error: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
},
|
||||
timeout: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
},
|
||||
success: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
var cont = $('#notifications-dialog');
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/user/notifications/",
|
||||
dataType : 'json',
|
||||
data: {
|
||||
page:page
|
||||
},
|
||||
error: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
},
|
||||
timeout: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
},
|
||||
success: function(data){
|
||||
$('#notifications-dialog').removeClass('loading');
|
||||
var cont = $('#notifications-dialog');
|
||||
|
||||
if(page === 0)
|
||||
cont.empty();
|
||||
else
|
||||
$('.notification_next',cont).remove();
|
||||
if(page === 0)
|
||||
cont.empty();
|
||||
else
|
||||
$('.notification_next',cont).remove();
|
||||
|
||||
for (i in data.notifications)
|
||||
{
|
||||
var id = 'notif_date_'+i;
|
||||
var date_cont = $('#'+id);
|
||||
if(date_cont.length === 0)
|
||||
{
|
||||
cont.append('<div id="'+id+'"><div class="notification_title">'+data.notifications[i].display+'</div></div>');
|
||||
date_cont = $('#'+id);
|
||||
}
|
||||
for (i in data.notifications)
|
||||
{
|
||||
var id = 'notif_date_'+i;
|
||||
var date_cont = $('#'+id);
|
||||
if(date_cont.length === 0)
|
||||
{
|
||||
cont.append('<div id="'+id+'"><div class="notification_title">'+data.notifications[i].display+'</div></div>');
|
||||
date_cont = $('#'+id);
|
||||
}
|
||||
|
||||
for (j in data.notifications[i].notifications)
|
||||
{
|
||||
var loc_dat = data.notifications[i].notifications[j];
|
||||
var html = '<div style="position:relative;" id="notification_'+loc_dat.id+'" class="notification">'+
|
||||
'<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'+
|
||||
loc_dat.icon+
|
||||
'</td><td>'+
|
||||
'<div style="position:relative;" class="'+loc_dat.classname+'">'+
|
||||
loc_dat.text+' <span class="time">'+loc_dat.time+'</span></div>'+
|
||||
'</td></tr></table>'+
|
||||
'</div>';
|
||||
date_cont.append(html);
|
||||
}
|
||||
}
|
||||
for (j in data.notifications[i].notifications)
|
||||
{
|
||||
var loc_dat = data.notifications[i].notifications[j];
|
||||
var html = '<div style="position:relative;" id="notification_'+loc_dat.id+'" class="notification">'+
|
||||
'<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'+
|
||||
loc_dat.icon+
|
||||
'</td><td>'+
|
||||
'<div style="position:relative;" class="'+loc_dat.classname+'">'+
|
||||
loc_dat.text+' <span class="time">'+loc_dat.time+'</span></div>'+
|
||||
'</td></tr></table>'+
|
||||
'</div>';
|
||||
date_cont.append(html);
|
||||
}
|
||||
}
|
||||
|
||||
var next_ln = $.trim(data.next);
|
||||
var next_ln = $.trim(data.next);
|
||||
|
||||
if(next_ln !== '')
|
||||
{
|
||||
cont.append('<div class="notification_next">'+next_ln+'</div>');
|
||||
}
|
||||
if(next_ln !== '')
|
||||
{
|
||||
cont.append('<div class="notification_next">'+next_ln+'</div>');
|
||||
}
|
||||
|
||||
// '<div style="position:relative;" id="notification_'.$row['id'].'" class="notification '.($row['unread'] == '1' ? 'unread':'').'">'.
|
||||
// '<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'.
|
||||
@@ -238,40 +238,40 @@ function print_notifications(page)
|
||||
// '</div>'
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function read_notifications()
|
||||
{
|
||||
var notifications = [];
|
||||
var notifications = [];
|
||||
|
||||
$('#notification_box .unread').each(function(){
|
||||
notifications.push($(this).attr('id').split('_').pop());
|
||||
});
|
||||
$('#notification_box .unread').each(function(){
|
||||
notifications.push($(this).attr('id').split('_').pop());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user/notifications/read/",
|
||||
data: {
|
||||
notifications:notifications.join('_')
|
||||
},
|
||||
success: function(data){
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/user/notifications/read/",
|
||||
data: {
|
||||
notifications:notifications.join('_')
|
||||
},
|
||||
success: function(data){
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clear_notifications()
|
||||
{
|
||||
var unread = $('#notification_box .unread');
|
||||
var unread = $('#notification_box .unread');
|
||||
|
||||
if(unread.length === 0)
|
||||
return;
|
||||
if(unread.length === 0)
|
||||
return;
|
||||
|
||||
unread.removeClass('unread');
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
unread.removeClass('unread');
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
}
|
||||
|
||||
|
||||
@@ -283,254 +283,254 @@ function clear_notifications()
|
||||
function getMyRss(renew)
|
||||
{
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/prodFeedBack.php",
|
||||
dataType: 'json',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/prodFeedBack.php",
|
||||
dataType: 'json',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function setPref(name,value)
|
||||
{
|
||||
if(jQuery.data['pref_'+name] && jQuery.data['pref_'+name].abort)
|
||||
{
|
||||
jQuery.data['pref_'+name].abort();
|
||||
jQuery.data['pref_'+name] = false;
|
||||
}
|
||||
if(jQuery.data['pref_'+name] && jQuery.data['pref_'+name].abort)
|
||||
{
|
||||
jQuery.data['pref_'+name].abort();
|
||||
jQuery.data['pref_'+name] = false;
|
||||
}
|
||||
|
||||
jQuery.data['pref_'+name] = $.ajax({
|
||||
type: "POST",
|
||||
url: "/user/preferences/",
|
||||
data: {
|
||||
prop:name,
|
||||
value:value
|
||||
},
|
||||
dataType:'json',
|
||||
timeout: function(){
|
||||
jQuery.data['pref_'+name] = false;
|
||||
},
|
||||
error: function(){
|
||||
jQuery.data['pref_'+name] = false;
|
||||
},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
jQuery.data['pref_'+name] = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
jQuery.data['pref_'+name] = $.ajax({
|
||||
type: "POST",
|
||||
url: "/user/preferences/",
|
||||
data: {
|
||||
prop:name,
|
||||
value:value
|
||||
},
|
||||
dataType:'json',
|
||||
timeout: function(){
|
||||
jQuery.data['pref_'+name] = false;
|
||||
},
|
||||
error: function(){
|
||||
jQuery.data['pref_'+name] = false;
|
||||
},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
jQuery.data['pref_'+name] = false;
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function infoDialog(el)
|
||||
{
|
||||
|
||||
$("#DIALOG").attr('title','')
|
||||
.empty()
|
||||
.append(el.attr('infos'))
|
||||
.dialog({
|
||||
$("#DIALOG").attr('title','')
|
||||
.empty()
|
||||
.append(el.attr('infos'))
|
||||
.dialog({
|
||||
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:600,
|
||||
height:400,
|
||||
modal:true,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open').css({'overflow-x':'auto','overflow-y':'auto'});
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:600,
|
||||
height:400,
|
||||
modal:true,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open').css({'overflow-x':'auto','overflow-y':'auto'});
|
||||
}
|
||||
function manageSession(data, showMessages)
|
||||
{
|
||||
if(typeof(showMessages) == "undefined")
|
||||
showMessages = false;
|
||||
if(typeof(showMessages) == "undefined")
|
||||
showMessages = false;
|
||||
|
||||
if(data.status == 'disconnected' || data.status == 'session')
|
||||
{
|
||||
disconnected();
|
||||
return false;
|
||||
}
|
||||
if(showMessages)
|
||||
{
|
||||
var box = $('#notification_box');
|
||||
box.empty().append(data.notifications);
|
||||
if(data.status == 'disconnected' || data.status == 'session')
|
||||
{
|
||||
disconnected();
|
||||
return false;
|
||||
}
|
||||
if(showMessages)
|
||||
{
|
||||
var box = $('#notification_box');
|
||||
box.empty().append(data.notifications);
|
||||
|
||||
if(box.is(':visible'))
|
||||
fix_notification_height();
|
||||
if(box.is(':visible'))
|
||||
fix_notification_height();
|
||||
|
||||
if($('.notification.unread',box).length > 0)
|
||||
{
|
||||
var trigger = $('#notification_trigger') ;
|
||||
$('.counter',trigger)
|
||||
.empty()
|
||||
.append($('.notification.unread',box).length);
|
||||
$('.counter',trigger).css('visibility','visible');
|
||||
if($('.notification.unread',box).length > 0)
|
||||
{
|
||||
var trigger = $('#notification_trigger') ;
|
||||
$('.counter',trigger)
|
||||
.empty()
|
||||
.append($('.notification.unread',box).length);
|
||||
$('.counter',trigger).css('visibility','visible');
|
||||
|
||||
}
|
||||
else
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
}
|
||||
else
|
||||
$('#notification_trigger .counter').css('visibility','hidden').empty();
|
||||
|
||||
if(data.changed.length > 0)
|
||||
{
|
||||
var current_open = $('.SSTT.ui-state-active');
|
||||
var current_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false;
|
||||
if(data.changed.length > 0)
|
||||
{
|
||||
var current_open = $('.SSTT.ui-state-active');
|
||||
var current_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false;
|
||||
|
||||
var main_open = false;
|
||||
for(var i=0; i!=data.changed.length; i++)
|
||||
{
|
||||
var sstt = $('#SSTT_'+data.changed[i]);
|
||||
if(sstt.size() === 0)
|
||||
var main_open = false;
|
||||
for(var i=0; i!=data.changed.length; i++)
|
||||
{
|
||||
if(main_open === false)
|
||||
{
|
||||
$('#baskets .bloc').animate({'top':30}, function(){$('#baskets .alert_datas_changed:first').show()});
|
||||
main_open = true;
|
||||
}
|
||||
var sstt = $('#SSTT_'+data.changed[i]);
|
||||
if(sstt.size() === 0)
|
||||
{
|
||||
if(main_open === false)
|
||||
{
|
||||
$('#baskets .bloc').animate({'top':30}, function(){$('#baskets .alert_datas_changed:first').show()});
|
||||
main_open = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!sstt.hasClass('active'))
|
||||
sstt.addClass('unread');
|
||||
else
|
||||
{
|
||||
$('.alert_datas_changed', $('#SSTT_content_'+data.changed[i])).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!sstt.hasClass('active'))
|
||||
sstt.addClass('unread');
|
||||
else
|
||||
{
|
||||
$('.alert_datas_changed', $('#SSTT_content_'+data.changed[i])).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if('' !== $.trim(data.message))
|
||||
{
|
||||
if($('#MESSAGE').length === 0)
|
||||
$('body').append('<div id="#MESSAGE"></div>');
|
||||
$('#MESSAGE')
|
||||
.empty()
|
||||
.append(data.message+'<div style="margin:20px;"><input type="checkbox" class="dialog_remove" />'+language.hideMessage+'</div>')
|
||||
.attr('title','Global Message')
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
close:function()
|
||||
{
|
||||
if($('.dialog_remove:checked',$(this)).length > 0)
|
||||
setTemporaryPref('message',0);
|
||||
}
|
||||
})
|
||||
.dialog('open');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if('' !== $.trim(data.message))
|
||||
{
|
||||
if($('#MESSAGE').length === 0)
|
||||
$('body').append('<div id="#MESSAGE"></div>');
|
||||
$('#MESSAGE')
|
||||
.empty()
|
||||
.append(data.message+'<div style="margin:20px;"><input type="checkbox" class="dialog_remove" />'+language.hideMessage+'</div>')
|
||||
.attr('title','Global Message')
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
close:function()
|
||||
{
|
||||
if($('.dialog_remove:checked',$(this)).length > 0)
|
||||
setTemporaryPref('message',0);
|
||||
}
|
||||
})
|
||||
.dialog('open');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function disconnected()
|
||||
{
|
||||
showModal('disconnected',{title:'Disconnection'});
|
||||
showModal('disconnected',{title:'Disconnection'});
|
||||
}
|
||||
|
||||
function showModal(cas, options){
|
||||
|
||||
var content = '';
|
||||
var callback = null;
|
||||
var button = {
|
||||
"OK": function(e)
|
||||
{
|
||||
hideOverlay(3);
|
||||
$(this).dialog("close");
|
||||
return;
|
||||
}};
|
||||
var escape = true;
|
||||
var onClose = function(){};
|
||||
var content = '';
|
||||
var callback = null;
|
||||
var button = {
|
||||
"OK": function(e)
|
||||
{
|
||||
hideOverlay(3);
|
||||
$(this).dialog("close");
|
||||
return;
|
||||
}};
|
||||
var escape = true;
|
||||
var onClose = function(){};
|
||||
|
||||
switch (cas) {
|
||||
case 'timeout':
|
||||
content = language.serverTimeout;
|
||||
break;
|
||||
case 'error':
|
||||
content = language.serverError;
|
||||
break;
|
||||
case 'disconnected':
|
||||
content = language.serverDisconnected;
|
||||
escape=false;
|
||||
callback = function(e){ self.location.replace(self.location.href)};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (cas) {
|
||||
case 'timeout':
|
||||
content = language.serverTimeout;
|
||||
break;
|
||||
case 'error':
|
||||
content = language.serverError;
|
||||
break;
|
||||
case 'disconnected':
|
||||
content = language.serverDisconnected;
|
||||
escape=false;
|
||||
callback = function(e){ self.location.replace(self.location.href)};
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
p4.Alerts(options.title, content, callback);
|
||||
p4.Alerts(options.title, content, callback);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
function showOverlay(n,appendto,callback, zIndex){
|
||||
|
||||
var div ="OVERLAY";
|
||||
if(typeof(n)!="undefined")
|
||||
div+=n;
|
||||
if($('#'+div).length === 0)
|
||||
{
|
||||
if(typeof(appendto)=='undefined')
|
||||
appendto = 'body';
|
||||
$(appendto).append('<div id="'+div+'" style="display:none;"> </div>');
|
||||
}
|
||||
var div ="OVERLAY";
|
||||
if(typeof(n)!="undefined")
|
||||
div+=n;
|
||||
if($('#'+div).length === 0)
|
||||
{
|
||||
if(typeof(appendto)=='undefined')
|
||||
appendto = 'body';
|
||||
$(appendto).append('<div id="'+div+'" style="display:none;"> </div>');
|
||||
}
|
||||
|
||||
var css = {
|
||||
display: 'block',
|
||||
opacity: 0,
|
||||
right:0,
|
||||
bottom:0,
|
||||
position:'absolute',
|
||||
top:0,
|
||||
zIndex:zIndex,
|
||||
left:0
|
||||
};
|
||||
var css = {
|
||||
display: 'block',
|
||||
opacity: 0,
|
||||
right:0,
|
||||
bottom:0,
|
||||
position:'absolute',
|
||||
top:0,
|
||||
zIndex:zIndex,
|
||||
left:0
|
||||
};
|
||||
|
||||
if(parseInt(zIndex) > 0)
|
||||
css['zIndex'] = parseInt(zIndex);
|
||||
if(parseInt(zIndex) > 0)
|
||||
css['zIndex'] = parseInt(zIndex);
|
||||
|
||||
if(typeof(callback) != 'function')
|
||||
callback = function(){};
|
||||
$('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();});
|
||||
if ($.browser.msie && $.browser.version == '6.0') {
|
||||
$('select').css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
}
|
||||
if(typeof(callback) != 'function')
|
||||
callback = function(){};
|
||||
$('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();});
|
||||
if ($.browser.msie && $.browser.version == '6.0') {
|
||||
$('select').css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function hideDwnl(){
|
||||
hideOverlay(2);
|
||||
$('#MODALDL').css({
|
||||
'display': 'none'
|
||||
});
|
||||
hideOverlay(2);
|
||||
$('#MODALDL').css({
|
||||
'display': 'none'
|
||||
});
|
||||
}
|
||||
|
||||
function hideOverlay(n){
|
||||
if ($.browser.msie && $.browser.version == '6.0') {
|
||||
$('select').css({
|
||||
visibility: 'visible'
|
||||
});
|
||||
}
|
||||
var div = "OVERLAY";
|
||||
if(typeof(n)!="undefined")
|
||||
div+=n;
|
||||
$('#'+div).hide().remove();
|
||||
if ($.browser.msie && $.browser.version == '6.0') {
|
||||
$('select').css({
|
||||
visibility: 'visible'
|
||||
});
|
||||
}
|
||||
var div = "OVERLAY";
|
||||
if(typeof(n)!="undefined")
|
||||
div+=n;
|
||||
$('#'+div).hide().remove();
|
||||
}
|
||||
|
||||
|
@@ -1,249 +1,249 @@
|
||||
(function( $ ){
|
||||
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'zoomable' : false,
|
||||
'display_full_screen' : false
|
||||
};
|
||||
return this.each(function() {
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'zoomable' : false,
|
||||
'display_full_screen' : false
|
||||
};
|
||||
return this.each(function() {
|
||||
|
||||
var $this = $(this), data = $(this).data('image_enhance');
|
||||
var $this = $(this), data = $(this).data('image_enhance');
|
||||
|
||||
if ( ! data )
|
||||
{
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
if ( ! data )
|
||||
{
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
|
||||
var wrapper = $('.thumb_wrapper', $(this));
|
||||
var $image =$('img', $this);
|
||||
var wrapper = $('.thumb_wrapper', $(this));
|
||||
var $image =$('img', $this);
|
||||
|
||||
wrapper.css('position','relative');
|
||||
wrapper.css('position','relative');
|
||||
|
||||
reset_position($this);
|
||||
reset_position($this);
|
||||
|
||||
if(settings.display_full_screen)
|
||||
{
|
||||
$image.parent()
|
||||
.append('<div class="image_enhance_titlebar" style="display:none;">\n\
|
||||
if(settings.display_full_screen)
|
||||
{
|
||||
$image.parent()
|
||||
.append('<div class="image_enhance_titlebar" style="display:none;">\n\
|
||||
<div class="image_enhance_title_options"><span class="full"><img src="/skins/icons/fullscreen.gif" /></span></div>\n\
|
||||
<div class="image_enhance_title_bg"></div></div>');
|
||||
|
||||
var $titlebar = $('.image_enhance_titlebar',$this);
|
||||
var $titlebar = $('.image_enhance_titlebar',$this);
|
||||
|
||||
$('.image_enhance_title_bg',$titlebar).css('opacity',0.5);
|
||||
$('.image_enhance_title_bg',$titlebar).css('opacity',0.5);
|
||||
|
||||
$image.parent()
|
||||
.bind('mouseover.image_enhance', function(){
|
||||
$titlebar.stop().show().animate({
|
||||
'height':28
|
||||
}, 150);
|
||||
})
|
||||
.bind('mouseout.image_enhance', function(){
|
||||
$titlebar.stop().animate({
|
||||
'height':0
|
||||
}, 150, function(){
|
||||
$titlebar.hide()
|
||||
});
|
||||
});
|
||||
$image.parent()
|
||||
.bind('mouseover.image_enhance', function(){
|
||||
$titlebar.stop().show().animate({
|
||||
'height':28
|
||||
}, 150);
|
||||
})
|
||||
.bind('mouseout.image_enhance', function(){
|
||||
$titlebar.stop().animate({
|
||||
'height':0
|
||||
}, 150, function(){
|
||||
$titlebar.hide()
|
||||
});
|
||||
});
|
||||
|
||||
$('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function(){
|
||||
$('body').append('<div class="image_enhance_theatre">\n\
|
||||
$('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function(){
|
||||
$('body').append('<div class="image_enhance_theatre">\n\
|
||||
\n\
|
||||
<div class="image_enhance_theatre_closer_wrapper"><span class="closer">close</span></div>\n\
|
||||
<img style="width:'+image_width+'px;height:'+image_height+'" src="'+$image.attr('src')+'"/>\n\
|
||||
</div>');
|
||||
|
||||
var $theatre = $('.image_enhance_theatre');
|
||||
var $theatre_img = $('img', $theatre);
|
||||
$(window).bind('resize.image_enhance dblclick.image_enhance',function(event){
|
||||
var $theatre = $('.image_enhance_theatre');
|
||||
var $theatre_img = $('img', $theatre);
|
||||
$(window).bind('resize.image_enhance dblclick.image_enhance',function(event){
|
||||
|
||||
if(event.type == 'dblclick')
|
||||
{
|
||||
$theatre_img.removeClass('zoomed');
|
||||
if(event.type == 'dblclick')
|
||||
{
|
||||
$theatre_img.removeClass('zoomed');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($theatre_img.hasClass('zoomed'))
|
||||
return;
|
||||
}
|
||||
var datas = calculate_sizes($(this).width(), $(this).height(), image_width, image_height, 80);
|
||||
|
||||
$theatre_img.width(datas.width).height(datas.height).css('top',datas.top).css('left',datas.left);
|
||||
})
|
||||
$(window).trigger('resize.image_enhance');
|
||||
$('.closer', $theatre).bind('click.image_enhance', function(){
|
||||
$theatre.remove();
|
||||
});
|
||||
|
||||
if(typeof $theatre.disableSelection !== 'function' && window.console)
|
||||
console.error('enhanced image require jquery UI\'s disableSelection');
|
||||
$('img', $theatre).disableSelection();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
if(settings.zoomable)
|
||||
{
|
||||
if(typeof $image.draggable !== 'function' && window.console)
|
||||
console.error('zoomable require jquery UI\'s draggable');
|
||||
|
||||
if($image.attr('ondragstart'))
|
||||
{
|
||||
$image.removeAttr('ondragstart');
|
||||
}
|
||||
$image.draggable();
|
||||
$image.css({
|
||||
'max-width':'none',
|
||||
'max-height':'none'
|
||||
});
|
||||
|
||||
var image_width = parseInt($('input[name="width"]', $this).val());
|
||||
var image_height = parseInt($('input[name="height"]', $this).val());
|
||||
var ratio = image_width / image_height;
|
||||
|
||||
$this.bind('mousewheel',function(event, delta){
|
||||
$image.addClass('zoomed');
|
||||
if(delta > 0)
|
||||
{
|
||||
event.stopPropagation();
|
||||
zoomPreview(true, ratio, $image, $(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
event.stopPropagation();
|
||||
zoomPreview(false, ratio, $image, $(this));
|
||||
}
|
||||
return false;
|
||||
}).bind('dblclick', function(event){
|
||||
reset_position($this);
|
||||
});
|
||||
}
|
||||
|
||||
$(this).data('image_enhance', {
|
||||
width:image_width,
|
||||
height:image_height
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
if($theatre_img.hasClass('zoomed'))
|
||||
return;
|
||||
}
|
||||
var datas = calculate_sizes($(this).width(), $(this).height(), image_width, image_height, 80);
|
||||
|
||||
$theatre_img.width(datas.width).height(datas.height).css('top',datas.top).css('left',datas.left);
|
||||
})
|
||||
$(window).trigger('resize.image_enhance');
|
||||
$('.closer', $theatre).bind('click.image_enhance', function(){
|
||||
$theatre.remove();
|
||||
});
|
||||
|
||||
if(typeof $theatre.disableSelection !== 'function' && window.console)
|
||||
console.error('enhanced image require jquery UI\'s disableSelection');
|
||||
$('img', $theatre).disableSelection();
|
||||
});
|
||||
}
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('image_enhance', null);
|
||||
$('.image_enhance_titlebar, .image_enhance_theatre',this).remove();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function zoomPreview(bool, ratio, $img, $container)
|
||||
{
|
||||
if($img.length === 0)
|
||||
return;
|
||||
|
||||
if(settings.zoomable)
|
||||
{
|
||||
if(typeof $image.draggable !== 'function' && window.console)
|
||||
console.error('zoomable require jquery UI\'s draggable');
|
||||
var t1 = parseInt($img.css('top'));
|
||||
var l1 = parseInt($img.css('left'));
|
||||
var w1 = $img.width();
|
||||
var h1 = $img.height();
|
||||
|
||||
if($image.attr('ondragstart'))
|
||||
{
|
||||
$image.removeAttr('ondragstart');
|
||||
var w2,t2;
|
||||
|
||||
if(bool)
|
||||
{
|
||||
if((w1 * 1.08) < 32767) {
|
||||
w2 = w1 * 1.08;
|
||||
} else {
|
||||
w2 = w1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((w1 / 1.08) > 20) {
|
||||
w2 = w1 / 1.08;
|
||||
} else {
|
||||
w2 = w1;
|
||||
}
|
||||
$image.draggable();
|
||||
$image.css({
|
||||
'max-width':'none',
|
||||
'max-height':'none'
|
||||
});
|
||||
|
||||
var image_width = parseInt($('input[name="width"]', $this).val());
|
||||
var image_height = parseInt($('input[name="height"]', $this).val());
|
||||
var ratio = image_width / image_height;
|
||||
|
||||
$this.bind('mousewheel',function(event, delta){
|
||||
$image.addClass('zoomed');
|
||||
if(delta > 0)
|
||||
{
|
||||
event.stopPropagation();
|
||||
zoomPreview(true, ratio, $image, $(this));
|
||||
}
|
||||
else
|
||||
{
|
||||
event.stopPropagation();
|
||||
zoomPreview(false, ratio, $image, $(this));
|
||||
}
|
||||
return false;
|
||||
}).bind('dblclick', function(event){
|
||||
reset_position($this);
|
||||
});
|
||||
}
|
||||
|
||||
$(this).data('image_enhance', {
|
||||
width:image_width,
|
||||
height:image_height
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('image_enhance', null);
|
||||
$('.image_enhance_titlebar, .image_enhance_theatre',this).remove();
|
||||
});
|
||||
var datas = $(this).data('image_enhance');
|
||||
|
||||
h2 = Math.round(w2 / ratio);
|
||||
w2 = Math.round(w2);
|
||||
|
||||
t2 = Math.round(t1 - (h2 - h1) / 2)+'px';
|
||||
var l2 = Math.round(l1 - (w2 - w1) / 2)+'px';
|
||||
|
||||
var wPreview = $container.width()/2;
|
||||
var hPreview = $container.height()/2;
|
||||
|
||||
var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview);
|
||||
var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview);
|
||||
|
||||
$img.css({
|
||||
left: nl,
|
||||
top: nt
|
||||
}).width(w2).height(h2);
|
||||
}
|
||||
};
|
||||
|
||||
function zoomPreview(bool, ratio, $img, $container)
|
||||
{
|
||||
if($img.length === 0)
|
||||
return;
|
||||
|
||||
var t1 = parseInt($img.css('top'));
|
||||
var l1 = parseInt($img.css('left'));
|
||||
var w1 = $img.width();
|
||||
var h1 = $img.height();
|
||||
|
||||
var w2,t2;
|
||||
|
||||
if(bool)
|
||||
function calculate_sizes(window_width, window_height,image_width, image_height, border)
|
||||
{
|
||||
if((w1 * 1.08) < 32767) {
|
||||
w2 = w1 * 1.08;
|
||||
} else {
|
||||
w2 = w1;
|
||||
}
|
||||
if(typeof border !== 'number')
|
||||
border = 0;
|
||||
|
||||
var width, height;
|
||||
var ratio_display = window_width / window_height;
|
||||
var ratio_image = image_width / image_height;
|
||||
|
||||
if(ratio_image > ratio_display)
|
||||
{
|
||||
width = window_width - border;
|
||||
height = Math.round(width / ratio_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
height = window_height - border;
|
||||
width = Math.round(height * ratio_image);
|
||||
}
|
||||
|
||||
var top = Math.round((window_height - height) / 2);
|
||||
var left = Math.round((window_width - width )/2);
|
||||
|
||||
return {
|
||||
top:top,
|
||||
left:left,
|
||||
width:width,
|
||||
height:height
|
||||
};
|
||||
}
|
||||
else
|
||||
|
||||
function reset_position($this)
|
||||
{
|
||||
if((w1 / 1.08) > 20) {
|
||||
w2 = w1 / 1.08;
|
||||
} else {
|
||||
w2 = w1;
|
||||
}
|
||||
var display_width = $this.width();
|
||||
var display_height = $this.height();
|
||||
var image_width = parseInt($('input[name="width"]', $this).val());
|
||||
var image_height = parseInt($('input[name="height"]', $this).val());
|
||||
|
||||
var datas = calculate_sizes(display_width, display_height, image_width, image_height);
|
||||
var $image =$('img', $this);
|
||||
|
||||
var top = Math.round((display_height - datas.height) / 2)+'px';
|
||||
var left = Math.round((display_width - datas.width) / 2)+'px';
|
||||
|
||||
$image.width(datas.width).height(datas.height).css({top:top, left:left});
|
||||
return;
|
||||
}
|
||||
|
||||
var datas = $(this).data('image_enhance');
|
||||
$.fn.image_enhance = function(method) {
|
||||
|
||||
h2 = Math.round(w2 / ratio);
|
||||
w2 = Math.round(w2);
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.image_enhance' );
|
||||
}
|
||||
|
||||
t2 = Math.round(t1 - (h2 - h1) / 2)+'px';
|
||||
var l2 = Math.round(l1 - (w2 - w1) / 2)+'px';
|
||||
|
||||
var wPreview = $container.width()/2;
|
||||
var hPreview = $container.height()/2;
|
||||
|
||||
var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview);
|
||||
var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview);
|
||||
|
||||
$img.css({
|
||||
left: nl,
|
||||
top: nt
|
||||
}).width(w2).height(h2);
|
||||
}
|
||||
|
||||
function calculate_sizes(window_width, window_height,image_width, image_height, border)
|
||||
{
|
||||
if(typeof border !== 'number')
|
||||
border = 0;
|
||||
|
||||
var width, height;
|
||||
var ratio_display = window_width / window_height;
|
||||
var ratio_image = image_width / image_height;
|
||||
|
||||
if(ratio_image > ratio_display)
|
||||
{
|
||||
width = window_width - border;
|
||||
height = Math.round(width / ratio_image);
|
||||
}
|
||||
else
|
||||
{
|
||||
height = window_height - border;
|
||||
width = Math.round(height * ratio_image);
|
||||
}
|
||||
|
||||
var top = Math.round((window_height - height) / 2);
|
||||
var left = Math.round((window_width - width )/2);
|
||||
|
||||
return {
|
||||
top:top,
|
||||
left:left,
|
||||
width:width,
|
||||
height:height
|
||||
};
|
||||
}
|
||||
|
||||
function reset_position($this)
|
||||
{
|
||||
var display_width = $this.width();
|
||||
var display_height = $this.height();
|
||||
var image_width = parseInt($('input[name="width"]', $this).val());
|
||||
var image_height = parseInt($('input[name="height"]', $this).val());
|
||||
|
||||
var datas = calculate_sizes(display_width, display_height, image_width, image_height);
|
||||
var $image =$('img', $this);
|
||||
|
||||
var top = Math.round((display_height - datas.height) / 2)+'px';
|
||||
var left = Math.round((display_width - datas.width) / 2)+'px';
|
||||
|
||||
$image.width(datas.width).height(datas.height).css({top:top, left:left});
|
||||
return;
|
||||
}
|
||||
|
||||
$.fn.image_enhance = function(method) {
|
||||
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.image_enhance' );
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
})( jQuery );
|
||||
|
@@ -2,25 +2,25 @@
|
||||
|
||||
function is_ctrl_key(event)
|
||||
{
|
||||
if(event.altKey)
|
||||
return true;
|
||||
if(event.ctrlKey)
|
||||
return true;
|
||||
if(event.metaKey) // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '17') // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '224') // apple key mozilla
|
||||
return true;
|
||||
if(event.keyCode == '91') // apple key safari
|
||||
return true;
|
||||
if(event.altKey)
|
||||
return true;
|
||||
if(event.ctrlKey)
|
||||
return true;
|
||||
if(event.metaKey) // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '17') // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '224') // apple key mozilla
|
||||
return true;
|
||||
if(event.keyCode == '91') // apple key safari
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_shift_key(event)
|
||||
{
|
||||
if(event.shiftKey)
|
||||
return true;
|
||||
return false;
|
||||
if(event.shiftKey)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@@ -1,144 +1,144 @@
|
||||
(function($){
|
||||
$.fn.nicoslider = function(options)
|
||||
{
|
||||
var defaults = {
|
||||
start : 0,
|
||||
color : '#F6F2F1',
|
||||
sliderHeight : false
|
||||
};
|
||||
$.fn.nicoslider = function(options)
|
||||
{
|
||||
var defaults = {
|
||||
start : 0,
|
||||
color : '#F6F2F1',
|
||||
sliderHeight : false
|
||||
};
|
||||
|
||||
var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options);
|
||||
var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options);
|
||||
|
||||
return this.each(function(){
|
||||
new nicoslide(this, opts);
|
||||
});
|
||||
};
|
||||
return this.each(function(){
|
||||
new nicoslide(this, opts);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
var nicoslide = function(slider, o)
|
||||
{
|
||||
var $slider = $(slider);
|
||||
var nicoslide = function(slider, o)
|
||||
{
|
||||
var $slider = $(slider);
|
||||
|
||||
$sliderWidth = $slider.parent().innerWidth();
|
||||
$sliderWidth = $slider.parent().innerWidth();
|
||||
|
||||
$sliderCss = {
|
||||
'width':$sliderWidth,
|
||||
'background-color':o.color
|
||||
};
|
||||
$sliderCss = {
|
||||
'width':$sliderWidth,
|
||||
'background-color':o.color
|
||||
};
|
||||
|
||||
$slider.css($sliderCss);
|
||||
$slider.css($sliderCss);
|
||||
|
||||
var ul = $slider.find("ul");
|
||||
var ulWidth = 0;
|
||||
var liHeight = 0;
|
||||
var ul = $slider.find("ul");
|
||||
var ulWidth = 0;
|
||||
var liHeight = 0;
|
||||
|
||||
$slider.find("li").each(function(){
|
||||
ulWidth += $(this).width() + 5;
|
||||
ulWidth += parseInt($(this).css("padding-left"));
|
||||
ulWidth += parseInt($(this).css("padding-right"));
|
||||
ulWidth += parseInt($(this).css("margin-left"));
|
||||
ulWidth += parseInt($(this).css("margin-right"));
|
||||
liHeight = Math.max(liHeight,$(this).outerHeight());
|
||||
});
|
||||
//5 % of slider width
|
||||
$scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05"));
|
||||
//min 30 px;
|
||||
if($scrollWidth < 30)
|
||||
{
|
||||
$scrollWidth = 30;
|
||||
}
|
||||
$slider.find("li").each(function(){
|
||||
ulWidth += $(this).width() + 5;
|
||||
ulWidth += parseInt($(this).css("padding-left"));
|
||||
ulWidth += parseInt($(this).css("padding-right"));
|
||||
ulWidth += parseInt($(this).css("margin-left"));
|
||||
ulWidth += parseInt($(this).css("margin-right"));
|
||||
liHeight = Math.max(liHeight,$(this).outerHeight());
|
||||
});
|
||||
//5 % of slider width
|
||||
$scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05"));
|
||||
//min 30 px;
|
||||
if($scrollWidth < 30)
|
||||
{
|
||||
$scrollWidth = 30;
|
||||
}
|
||||
|
||||
var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth ));
|
||||
var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth ));
|
||||
|
||||
if(ulWidth > $wrapperWidth)
|
||||
{
|
||||
ul.wrapAll("<div class='wrapper'></div>");
|
||||
$wrapper = $slider.find(".wrapper");
|
||||
$ulHeight = ul.height();
|
||||
$wrapper.width($wrapperWidth);
|
||||
$wrapper.height($ulHeight);
|
||||
if(ulWidth > $wrapperWidth)
|
||||
{
|
||||
ul.wrapAll("<div class='wrapper'></div>");
|
||||
$wrapper = $slider.find(".wrapper");
|
||||
$ulHeight = ul.height();
|
||||
$wrapper.width($wrapperWidth);
|
||||
$wrapper.height($ulHeight);
|
||||
|
||||
$wrapperCss= {
|
||||
'overflow':'hidden',
|
||||
'float':'left',
|
||||
'position':'relative'
|
||||
};
|
||||
$wrapperCss= {
|
||||
'overflow':'hidden',
|
||||
'float':'left',
|
||||
'position':'relative'
|
||||
};
|
||||
|
||||
$wrapper.css($wrapperCss);
|
||||
ul.css('position', 'absolute');
|
||||
ul.width(ulWidth);
|
||||
$slider.prepend("<div class='scrollleft'></div>");
|
||||
$slider.append("<div class='scrollright'></div>");
|
||||
$wrapper.css($wrapperCss);
|
||||
ul.css('position', 'absolute');
|
||||
ul.width(ulWidth);
|
||||
$slider.prepend("<div class='scrollleft'></div>");
|
||||
$slider.append("<div class='scrollright'></div>");
|
||||
|
||||
var rightScroll = $slider.find(".scrollright");
|
||||
var leftScroll = $slider.find(".scrollleft");
|
||||
var rightScroll = $slider.find(".scrollright");
|
||||
var leftScroll = $slider.find(".scrollleft");
|
||||
|
||||
rightScroll.append("<div class='rb'>></div>");
|
||||
leftScroll.append("<div class='lb'><</div>");
|
||||
rightScroll.append("<div class='rb'>></div>");
|
||||
leftScroll.append("<div class='lb'><</div>");
|
||||
|
||||
$("div.rb").css('float', 'right');
|
||||
$("div.rb").css('float', 'right');
|
||||
|
||||
rightCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'right',
|
||||
'background-color' : o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
rightCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'right',
|
||||
'background-color' : o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
|
||||
leftCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'left',
|
||||
'background-color' : o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
leftCss = {
|
||||
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
|
||||
'height' : liHeight + 5,
|
||||
'float' : 'left',
|
||||
'background-color' : o.color,
|
||||
'cursor': 'pointer',
|
||||
' user-select': 'none'
|
||||
};
|
||||
|
||||
leftScroll.css(leftCss);
|
||||
rightScroll.css(rightCss);
|
||||
leftScroll.css(leftCss);
|
||||
rightScroll.css(rightCss);
|
||||
|
||||
var rightScrollWidth = rightScroll.width();
|
||||
var leftScrollWidth = leftScroll.width();
|
||||
var scrollXpos = 0;
|
||||
var scrollStepSpeed = 40;
|
||||
var speed = 8;
|
||||
var shift = o.start;
|
||||
var rightScrollWidth = rightScroll.width();
|
||||
var leftScrollWidth = leftScroll.width();
|
||||
var scrollXpos = 0;
|
||||
var scrollStepSpeed = 40;
|
||||
var speed = 8;
|
||||
var shift = o.start;
|
||||
|
||||
|
||||
//scroll a droite
|
||||
rightScroll.bind("click", function(e){
|
||||
var x = e.pageX - ($(this).offset().left);
|
||||
scrollXpos = Math.round((x / rightScrollWidth) * scrollStepSpeed);
|
||||
shift += (scrollXpos * speed);
|
||||
//scroll a droite
|
||||
rightScroll.bind("click", function(e){
|
||||
var x = e.pageX - ($(this).offset().left);
|
||||
scrollXpos = Math.round((x / rightScrollWidth) * scrollStepSpeed);
|
||||
shift += (scrollXpos * speed);
|
||||
|
||||
if(shift > (ulWidth - $wrapperWidth) + 50)
|
||||
{
|
||||
shift = (ulWidth - $wrapperWidth) + 50;
|
||||
}
|
||||
ul.animate({
|
||||
left: -shift
|
||||
}, 1);
|
||||
});
|
||||
if(shift > (ulWidth - $wrapperWidth) + 50)
|
||||
{
|
||||
shift = (ulWidth - $wrapperWidth) + 50;
|
||||
}
|
||||
ul.animate({
|
||||
left: -shift
|
||||
}, 1);
|
||||
});
|
||||
|
||||
//scroll a gauche
|
||||
leftScroll.bind("click", function(e){
|
||||
var x = $(this).innerWidth() - (e.pageX - $(this).offset().left);
|
||||
//scroll a gauche
|
||||
leftScroll.bind("click", function(e){
|
||||
var x = $(this).innerWidth() - (e.pageX - $(this).offset().left);
|
||||
|
||||
scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed);
|
||||
shift -= (scrollXpos * speed);
|
||||
scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed);
|
||||
shift -= (scrollXpos * speed);
|
||||
|
||||
if(shift < 0)
|
||||
{
|
||||
shift = 0;
|
||||
}
|
||||
if(shift < 0)
|
||||
{
|
||||
shift = 0;
|
||||
}
|
||||
|
||||
ul.animate({
|
||||
left: -shift
|
||||
}, 1);
|
||||
ul.animate({
|
||||
left: -shift
|
||||
}, 1);
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
@@ -1,17 +1,17 @@
|
||||
$(document).ready(function(){
|
||||
$('#tabs').tabs();
|
||||
$('input.input-button').hover(
|
||||
function(){parent.$(this).addClass('hover');},
|
||||
function(){parent.$(this).removeClass('hover');}
|
||||
);
|
||||
$(this).bind('keydown',function(event){
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case 27:
|
||||
parent.hideDwnl();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
$('#tabs').tabs();
|
||||
$('input.input-button').hover(
|
||||
function(){parent.$(this).addClass('hover');},
|
||||
function(){parent.$(this).removeClass('hover');}
|
||||
);
|
||||
$(this).bind('keydown',function(event){
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case 27:
|
||||
parent.hideDwnl();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@@ -3,480 +3,480 @@ prevAjaxrunning = false;
|
||||
p4.slideShow = false;
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#PREVIEWIMGDESC').tabs();
|
||||
$('#PREVIEWIMGDESC').tabs();
|
||||
});
|
||||
|
||||
|
||||
function getNewVideoToken(lst, obj)
|
||||
{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../prod/records/renew-url/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
lst: lst
|
||||
},
|
||||
success: function(data){
|
||||
if(!data[lst])
|
||||
return;
|
||||
obj.unload();
|
||||
obj.setClip({url:data[lst]});
|
||||
obj.play();
|
||||
return;
|
||||
}
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../prod/records/renew-url/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
lst: lst
|
||||
},
|
||||
success: function(data){
|
||||
if(!data[lst])
|
||||
return;
|
||||
obj.unload();
|
||||
obj.setClip({url:data[lst]});
|
||||
obj.play();
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function openPreview(env, pos, contId, reload){
|
||||
|
||||
if (contId == undefined)
|
||||
contId = '';
|
||||
var roll = 0;
|
||||
var justOpen = false;
|
||||
if (contId == undefined)
|
||||
contId = '';
|
||||
var roll = 0;
|
||||
var justOpen = false;
|
||||
|
||||
if (!p4.preview.open) {
|
||||
showOverlay();
|
||||
if (!p4.preview.open) {
|
||||
showOverlay();
|
||||
|
||||
$('#PREVIEWIMGCONT').disableSelection();
|
||||
$('#PREVIEWIMGCONT').disableSelection();
|
||||
|
||||
justOpen = true;
|
||||
justOpen = true;
|
||||
|
||||
if (!$.browser.msie) {
|
||||
$('#PREVIEWBOX').css({
|
||||
'display': 'block',
|
||||
'opacity': 0
|
||||
}).fadeTo(500, 1);
|
||||
}else
|
||||
{
|
||||
$('#PREVIEWBOX').css({
|
||||
'display': 'block',
|
||||
'opacity': 1
|
||||
});
|
||||
}
|
||||
p4.preview.open = true;
|
||||
p4.preview.nCurrent = 5;
|
||||
$('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty();
|
||||
resizePreview();
|
||||
if(env == 'BASK')
|
||||
roll = 1;
|
||||
if (!$.browser.msie) {
|
||||
$('#PREVIEWBOX').css({
|
||||
'display': 'block',
|
||||
'opacity': 0
|
||||
}).fadeTo(500, 1);
|
||||
}else
|
||||
{
|
||||
$('#PREVIEWBOX').css({
|
||||
'display': 'block',
|
||||
'opacity': 1
|
||||
});
|
||||
}
|
||||
p4.preview.open = true;
|
||||
p4.preview.nCurrent = 5;
|
||||
$('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty();
|
||||
resizePreview();
|
||||
if(env == 'BASK')
|
||||
roll = 1;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(reload === true)
|
||||
roll = 1;
|
||||
if(reload === true)
|
||||
roll = 1;
|
||||
|
||||
|
||||
$('#tooltip').css({
|
||||
'display': 'none'
|
||||
});
|
||||
$('#tooltip').css({
|
||||
'display': 'none'
|
||||
});
|
||||
|
||||
$('#PREVIEWIMGCONT').empty();
|
||||
$('#PREVIEWIMGCONT').empty();
|
||||
|
||||
var options_serial = p4.tot_options;
|
||||
var query = p4.tot_query;
|
||||
var options_serial = p4.tot_options;
|
||||
var query = p4.tot_query;
|
||||
|
||||
prevAjax = $.ajax({
|
||||
type: "POST",
|
||||
url: "../prod/records/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
env: env,
|
||||
pos: pos,
|
||||
cont: contId,
|
||||
roll: roll,
|
||||
options_serial:options_serial,
|
||||
query:query
|
||||
},
|
||||
beforeSend: function(){
|
||||
if (prevAjaxrunning)
|
||||
prevAjax.abort();
|
||||
if(env == 'RESULT')
|
||||
$('#current_result_n').empty().append(parseInt(pos)+1);
|
||||
prevAjaxrunning = true;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading');
|
||||
},
|
||||
error: function(data){
|
||||
prevAjaxrunning = false;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
posAsk = null;
|
||||
},
|
||||
timeout: function(){
|
||||
prevAjaxrunning = false;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
posAsk = null;
|
||||
},
|
||||
success: function(data){
|
||||
cancelPreview();
|
||||
prevAjaxrunning = false;
|
||||
posAsk = null;
|
||||
prevAjax = $.ajax({
|
||||
type: "POST",
|
||||
url: "../prod/records/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
env: env,
|
||||
pos: pos,
|
||||
cont: contId,
|
||||
roll: roll,
|
||||
options_serial:options_serial,
|
||||
query:query
|
||||
},
|
||||
beforeSend: function(){
|
||||
if (prevAjaxrunning)
|
||||
prevAjax.abort();
|
||||
if(env == 'RESULT')
|
||||
$('#current_result_n').empty().append(parseInt(pos)+1);
|
||||
prevAjaxrunning = true;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading');
|
||||
},
|
||||
error: function(data){
|
||||
prevAjaxrunning = false;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
posAsk = null;
|
||||
},
|
||||
timeout: function(){
|
||||
prevAjaxrunning = false;
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
posAsk = null;
|
||||
},
|
||||
success: function(data){
|
||||
cancelPreview();
|
||||
prevAjaxrunning = false;
|
||||
posAsk = null;
|
||||
|
||||
if(data.error)
|
||||
{
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
alert(data.error);
|
||||
if(justOpen)
|
||||
closePreview();
|
||||
return;
|
||||
}
|
||||
posAsk = data.pos - 1;
|
||||
if(data.error)
|
||||
{
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
alert(data.error);
|
||||
if(justOpen)
|
||||
closePreview();
|
||||
return;
|
||||
}
|
||||
posAsk = data.pos - 1;
|
||||
|
||||
$('#PREVIEWIMGCONT').empty().append(data.html_preview);
|
||||
$('#PREVIEWIMGCONT .thumb_wrapper')
|
||||
.width('100%').height('100%').image_enhance({zoomable:true});
|
||||
$('#PREVIEWIMGCONT').empty().append(data.html_preview);
|
||||
$('#PREVIEWIMGCONT .thumb_wrapper')
|
||||
.width('100%').height('100%').image_enhance({zoomable:true});
|
||||
|
||||
$('#PREVIEWIMGDESCINNER').empty().append(data.desc);
|
||||
$('#HISTORICOPS').empty().append(data.history);
|
||||
$('#popularity').empty().append(data.popularity);
|
||||
$('#PREVIEWIMGDESCINNER').empty().append(data.desc);
|
||||
$('#HISTORICOPS').empty().append(data.history);
|
||||
$('#popularity').empty().append(data.popularity);
|
||||
|
||||
if($('#popularity .bitly_link').length>0)
|
||||
{
|
||||
if($('#popularity .bitly_link').length>0)
|
||||
{
|
||||
|
||||
BitlyCB.statsResponse = function(data) {
|
||||
var result = data.results;
|
||||
if( $( '#popularity .bitly_link_' + result.userHash ).length > 0 )
|
||||
{
|
||||
$( '#popularity .bitly_link_' + result.userHash ).append( ' (' + result.clicks + ' clicks)');
|
||||
}
|
||||
};
|
||||
BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse');
|
||||
}
|
||||
BitlyCB.statsResponse = function(data) {
|
||||
var result = data.results;
|
||||
if( $( '#popularity .bitly_link_' + result.userHash ).length > 0 )
|
||||
{
|
||||
$( '#popularity .bitly_link_' + result.userHash ).append( ' (' + result.clicks + ' clicks)');
|
||||
}
|
||||
};
|
||||
BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse');
|
||||
}
|
||||
|
||||
p4.preview.current = {};
|
||||
p4.preview.current.width = parseInt($('#PREVIEWIMGCONT input[name=width]').val());
|
||||
p4.preview.current.height = parseInt($('#PREVIEWIMGCONT input[name=height]').val());
|
||||
p4.preview.current.tot = data.tot;
|
||||
p4.preview.current.pos = data.pos;
|
||||
p4.preview.current = {};
|
||||
p4.preview.current.width = parseInt($('#PREVIEWIMGCONT input[name=width]').val());
|
||||
p4.preview.current.height = parseInt($('#PREVIEWIMGCONT input[name=height]').val());
|
||||
p4.preview.current.tot = data.tot;
|
||||
p4.preview.current.pos = data.pos;
|
||||
|
||||
if($('#PREVIEWBOX img.record.zoomable').length > 0)
|
||||
{
|
||||
$('#PREVIEWBOX img.record.zoomable').draggable();
|
||||
}
|
||||
if($('#PREVIEWBOX img.record.zoomable').length > 0)
|
||||
{
|
||||
$('#PREVIEWBOX img.record.zoomable').draggable();
|
||||
}
|
||||
|
||||
setTitle(data.title);
|
||||
setPreview();
|
||||
setTitle(data.title);
|
||||
setPreview();
|
||||
|
||||
if(env != 'RESULT')
|
||||
{
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!justOpen)
|
||||
{
|
||||
$('#PREVIEWCURRENT li.selected').removeClass('selected');
|
||||
$('#PREVIEWCURRENTCONT li.current'+pos).addClass('selected');
|
||||
}
|
||||
if(justOpen || ($('#PREVIEWCURRENTCONT li.current'+pos).length === 0) || ($('#PREVIEWCURRENTCONT li:last')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]) || ($('#PREVIEWCURRENTCONT li:first')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]))
|
||||
{
|
||||
getAnswerTrain(pos, data.tools, query,options_serial);
|
||||
}
|
||||
if(env != 'RESULT')
|
||||
{
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!justOpen)
|
||||
{
|
||||
$('#PREVIEWCURRENT li.selected').removeClass('selected');
|
||||
$('#PREVIEWCURRENTCONT li.current'+pos).addClass('selected');
|
||||
}
|
||||
if(justOpen || ($('#PREVIEWCURRENTCONT li.current'+pos).length === 0) || ($('#PREVIEWCURRENTCONT li:last')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]) || ($('#PREVIEWCURRENTCONT li:first')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]))
|
||||
{
|
||||
getAnswerTrain(pos, data.tools, query,options_serial);
|
||||
}
|
||||
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
}
|
||||
if(env == 'REG' && $('#PREVIEWCURRENT').html() === '')
|
||||
{
|
||||
getRegTrain(contId,pos,data.tools);
|
||||
}
|
||||
setOthers(data.others);
|
||||
setTools(data.tools);
|
||||
$('#tooltip').css({
|
||||
'display': 'none'
|
||||
});
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
if(!justOpen || (p4.preview.mode != env))
|
||||
resizePreview();
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
}
|
||||
if(env == 'REG' && $('#PREVIEWCURRENT').html() === '')
|
||||
{
|
||||
getRegTrain(contId,pos,data.tools);
|
||||
}
|
||||
setOthers(data.others);
|
||||
setTools(data.tools);
|
||||
$('#tooltip').css({
|
||||
'display': 'none'
|
||||
});
|
||||
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
|
||||
if(!justOpen || (p4.preview.mode != env))
|
||||
resizePreview();
|
||||
|
||||
p4.preview.mode = env;
|
||||
$('#EDIT_query').focus();
|
||||
p4.preview.mode = env;
|
||||
$('#EDIT_query').focus();
|
||||
|
||||
$('#PREVIEWOTHERSINNER .otherBaskToolTip').tooltip();
|
||||
$('#PREVIEWOTHERSINNER .otherBaskToolTip').tooltip();
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function zoomPreview(bool){
|
||||
|
||||
var el = $('#PREVIEWIMGCONT img.record');
|
||||
var el = $('#PREVIEWIMGCONT img.record');
|
||||
|
||||
if(el.length === 0)
|
||||
return;
|
||||
if(el.length === 0)
|
||||
return;
|
||||
|
||||
var t1 = parseInt(el.css('top'));
|
||||
var l1 = parseInt(el.css('left'));
|
||||
var w1 = el.width();
|
||||
var h1 = el.height();
|
||||
var t1 = parseInt(el.css('top'));
|
||||
var l1 = parseInt(el.css('left'));
|
||||
var w1 = el.width();
|
||||
var h1 = el.height();
|
||||
|
||||
var w2,t2;
|
||||
var w2,t2;
|
||||
|
||||
if(bool)
|
||||
{
|
||||
if(w1 * 1.08 < 32767)
|
||||
w2 = w1 * 1.08;
|
||||
else
|
||||
w2 = w1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(w1 / 1.08 > 20)
|
||||
w2 = w1 / 1.08;
|
||||
else
|
||||
w2 = w1;
|
||||
}
|
||||
if(bool)
|
||||
{
|
||||
if(w1 * 1.08 < 32767)
|
||||
w2 = w1 * 1.08;
|
||||
else
|
||||
w2 = w1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(w1 / 1.08 > 20)
|
||||
w2 = w1 / 1.08;
|
||||
else
|
||||
w2 = w1;
|
||||
}
|
||||
|
||||
var ratio = p4.preview.current.width / p4.preview.current.height;
|
||||
h2 = Math.round(w2 / ratio);
|
||||
w2 = Math.round(w2);
|
||||
var ratio = p4.preview.current.width / p4.preview.current.height;
|
||||
h2 = Math.round(w2 / ratio);
|
||||
w2 = Math.round(w2);
|
||||
|
||||
t2 = Math.round(t1 - (h2 - h1) / 2)+'px';
|
||||
var l2 = Math.round(l1 - (w2 - w1) / 2)+'px';
|
||||
t2 = Math.round(t1 - (h2 - h1) / 2)+'px';
|
||||
var l2 = Math.round(l1 - (w2 - w1) / 2)+'px';
|
||||
|
||||
var wPreview = $('#PREVIEWIMGCONT').width()/2;
|
||||
var hPreview = $('#PREVIEWIMGCONT').height()/2;
|
||||
var wPreview = $('#PREVIEWIMGCONT').width()/2;
|
||||
var hPreview = $('#PREVIEWIMGCONT').height()/2;
|
||||
|
||||
var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview);
|
||||
var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview);
|
||||
var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview);
|
||||
var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview);
|
||||
|
||||
el.css({
|
||||
left: nl,
|
||||
top: nt
|
||||
}).width(w2).height(h2);
|
||||
el.css({
|
||||
left: nl,
|
||||
top: nt
|
||||
}).width(w2).height(h2);
|
||||
}
|
||||
|
||||
function getAnswerTrain(pos, tools, query,options_serial)
|
||||
{
|
||||
$('#PREVIEWCURRENTCONT').fadeOut('fast');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/query/answer-train/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
pos:pos,
|
||||
$('#PREVIEWCURRENTCONT').fadeOut('fast');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/query/answer-train/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
pos:pos,
|
||||
options_serial:options_serial,
|
||||
query:query
|
||||
},
|
||||
success: function(data){
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
setTools(tools);
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
success: function(data){
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
setTools(tools);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getRegTrain(contId,pos,tools)
|
||||
{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/query/reg-train/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
cont:contId,
|
||||
pos:pos
|
||||
},
|
||||
success: function(data){
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
if(typeof(tools) != 'undefined')
|
||||
setTools(tools);
|
||||
return;
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/query/reg-train/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
cont:contId,
|
||||
pos:pos
|
||||
},
|
||||
success: function(data){
|
||||
setCurrent(data.current);
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
if(typeof(tools) != 'undefined')
|
||||
setTools(tools);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function bounce(sbid, term, field){
|
||||
doThesSearch('T', sbid, term, field);
|
||||
closePreview();
|
||||
doThesSearch('T', sbid, term, field);
|
||||
closePreview();
|
||||
}
|
||||
|
||||
function setTitle(title){
|
||||
$('#SPANTITLE').empty().append(title);
|
||||
$('#SPANTITLE').empty().append(title);
|
||||
}
|
||||
|
||||
function cancelPreview(){
|
||||
$('#PREVIEWIMGDESCINNER').empty();
|
||||
$('#PREVIEWIMGCONT').empty();
|
||||
p4.preview.current = false;
|
||||
$('#PREVIEWIMGDESCINNER').empty();
|
||||
$('#PREVIEWIMGCONT').empty();
|
||||
p4.preview.current = false;
|
||||
}
|
||||
|
||||
|
||||
function startSlide(){
|
||||
if (!p4.slideShow) {
|
||||
p4.slideShow = true;
|
||||
}
|
||||
if (p4.slideShowCancel) {
|
||||
p4.slideShowCancel = false;
|
||||
p4.slideShow = false;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
if(!p4.preview.open)
|
||||
{
|
||||
p4.slideShowCancel = false;
|
||||
p4.slideShow = false;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
if (p4.slideShow) {
|
||||
$('#start_slide').hide();
|
||||
$('#stop_slide').show();
|
||||
getNext();
|
||||
setTimeout("startSlide()", 3000);
|
||||
}
|
||||
if (!p4.slideShow) {
|
||||
p4.slideShow = true;
|
||||
}
|
||||
if (p4.slideShowCancel) {
|
||||
p4.slideShowCancel = false;
|
||||
p4.slideShow = false;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
if(!p4.preview.open)
|
||||
{
|
||||
p4.slideShowCancel = false;
|
||||
p4.slideShow = false;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
if (p4.slideShow) {
|
||||
$('#start_slide').hide();
|
||||
$('#stop_slide').show();
|
||||
getNext();
|
||||
setTimeout("startSlide()", 3000);
|
||||
}
|
||||
}
|
||||
|
||||
function stopSlide(){
|
||||
p4.slideShowCancel = true;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
p4.slideShowCancel = true;
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
|
||||
//var posAsk = null;
|
||||
|
||||
function getNext(){
|
||||
if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0)
|
||||
$('#PREVIEWCURRENTCONT li img:first').trigger("click");
|
||||
else {
|
||||
if (p4.preview.mode == 'RESULT') {
|
||||
posAsk = parseInt(p4.preview.current.pos) + 1;
|
||||
posAsk = (posAsk > parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk;
|
||||
openPreview('RESULT', posAsk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$('#PREVIEWCURRENT li.selected').is(':last-child'))
|
||||
$('#PREVIEWCURRENT li.selected').next().children('img').trigger("click");
|
||||
else
|
||||
$('#PREVIEWCURRENT li:first-child').children('img').trigger("click");
|
||||
}
|
||||
if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0)
|
||||
$('#PREVIEWCURRENTCONT li img:first').trigger("click");
|
||||
else {
|
||||
if (p4.preview.mode == 'RESULT') {
|
||||
posAsk = parseInt(p4.preview.current.pos) + 1;
|
||||
posAsk = (posAsk > parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk;
|
||||
openPreview('RESULT', posAsk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$('#PREVIEWCURRENT li.selected').is(':last-child'))
|
||||
$('#PREVIEWCURRENT li.selected').next().children('img').trigger("click");
|
||||
else
|
||||
$('#PREVIEWCURRENT li:first-child').children('img').trigger("click");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
function reloadPreview(){
|
||||
$('#PREVIEWCURRENT li.selected img').trigger("click");
|
||||
$('#PREVIEWCURRENT li.selected img').trigger("click");
|
||||
}
|
||||
|
||||
function getPrevious(){
|
||||
if (p4.preview.mode == 'RESULT')
|
||||
{
|
||||
posAsk = parseInt(p4.preview.current.pos) - 1;
|
||||
posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk;
|
||||
openPreview('RESULT', posAsk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$('#PREVIEWCURRENT li.selected').is(':first-child'))
|
||||
$('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click");
|
||||
else
|
||||
$('#PREVIEWCURRENT li:last-child').children('img').trigger("click");
|
||||
}
|
||||
if (p4.preview.mode == 'RESULT')
|
||||
{
|
||||
posAsk = parseInt(p4.preview.current.pos) - 1;
|
||||
posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk;
|
||||
openPreview('RESULT', posAsk);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$('#PREVIEWCURRENT li.selected').is(':first-child'))
|
||||
$('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click");
|
||||
else
|
||||
$('#PREVIEWCURRENT li:last-child').children('img').trigger("click");
|
||||
}
|
||||
}
|
||||
|
||||
function setOthers(others){
|
||||
|
||||
$('#PREVIEWOTHERSINNER').empty();
|
||||
if (others !== '') {
|
||||
$('#PREVIEWOTHERSINNER').append(others);
|
||||
$('#PREVIEWOTHERSINNER').empty();
|
||||
if (others !== '') {
|
||||
$('#PREVIEWOTHERSINNER').append(others);
|
||||
|
||||
$('#PREVIEWOTHERS table.otherRegToolTip').tooltip();
|
||||
}
|
||||
$('#PREVIEWOTHERS table.otherRegToolTip').tooltip();
|
||||
}
|
||||
}
|
||||
|
||||
function setTools(tools){
|
||||
$('#PREVIEWTOOL').empty().append(tools);
|
||||
if(!p4.slideShowCancel && p4.slideShow)
|
||||
{
|
||||
$('#start_slide').hide();
|
||||
$('#stop_slide').show();
|
||||
}else
|
||||
{
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
$('#PREVIEWTOOL').empty().append(tools);
|
||||
if(!p4.slideShowCancel && p4.slideShow)
|
||||
{
|
||||
$('#start_slide').hide();
|
||||
$('#stop_slide').show();
|
||||
}else
|
||||
{
|
||||
$('#start_slide').show();
|
||||
$('#stop_slide').hide();
|
||||
}
|
||||
}
|
||||
|
||||
function setCurrent(current){
|
||||
if (current !== '') {
|
||||
var el = $('#PREVIEWCURRENT');
|
||||
el.removeClass('loading').empty().append(current);
|
||||
if (current !== '') {
|
||||
var el = $('#PREVIEWCURRENT');
|
||||
el.removeClass('loading').empty().append(current);
|
||||
|
||||
$('ul',el).width($('li',el).length * 80);
|
||||
$('img.prevRegToolTip',el).tooltip();
|
||||
$.each($('img.openPreview'), function(i, el){
|
||||
var jsopt = $(el).attr('jsargs').split('|');
|
||||
$(el).removeAttr('jsargs');
|
||||
$(el).removeClass('openPreview');
|
||||
$(el).bind('click', function(){
|
||||
viewCurrent($(this).parent());
|
||||
openPreview(jsopt[0], jsopt[1], jsopt[2]);
|
||||
});
|
||||
});
|
||||
}
|
||||
$('ul',el).width($('li',el).length * 80);
|
||||
$('img.prevRegToolTip',el).tooltip();
|
||||
$.each($('img.openPreview'), function(i, el){
|
||||
var jsopt = $(el).attr('jsargs').split('|');
|
||||
$(el).removeAttr('jsargs');
|
||||
$(el).removeClass('openPreview');
|
||||
$(el).bind('click', function(){
|
||||
viewCurrent($(this).parent());
|
||||
openPreview(jsopt[0], jsopt[1], jsopt[2]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function viewCurrent(el){
|
||||
if (el.length === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
$('#PREVIEWCURRENT li.selected').removeClass('selected');
|
||||
el.addClass('selected');
|
||||
$('#PREVIEWCURRENTCONT').animate({'scrollLeft':($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width()/2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))});
|
||||
return;
|
||||
if (el.length === 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
$('#PREVIEWCURRENT li.selected').removeClass('selected');
|
||||
el.addClass('selected');
|
||||
$('#PREVIEWCURRENTCONT').animate({'scrollLeft':($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width()/2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))});
|
||||
return;
|
||||
}
|
||||
|
||||
function setPreview(){
|
||||
if (!p4.preview.current)
|
||||
return;
|
||||
if (!p4.preview.current)
|
||||
return;
|
||||
|
||||
var zoomable = $('img.record.zoomable');
|
||||
if(zoomable.length > 0 && zoomable.hasClass('zoomed'))
|
||||
return;
|
||||
var zoomable = $('img.record.zoomable');
|
||||
if(zoomable.length > 0 && zoomable.hasClass('zoomed'))
|
||||
return;
|
||||
|
||||
var h = parseInt(p4.preview.current.height);
|
||||
var w = parseInt(p4.preview.current.width);
|
||||
var h = parseInt(p4.preview.current.height);
|
||||
var w = parseInt(p4.preview.current.width);
|
||||
// if(p4.preview.current.type == 'video')
|
||||
// {
|
||||
// var h = parseInt(p4.preview.current.flashcontent.height);
|
||||
// var w = parseInt(p4.preview.current.flashcontent.width);
|
||||
// }
|
||||
var t=20;
|
||||
var de = 0;
|
||||
var t=20;
|
||||
var de = 0;
|
||||
|
||||
var margX = 0;
|
||||
var margY = 0;
|
||||
var margX = 0;
|
||||
var margY = 0;
|
||||
|
||||
if($('#PREVIEWIMGCONT .record_audio').length > 0)
|
||||
{
|
||||
margY = 100;
|
||||
de = 60;
|
||||
}
|
||||
if($('#PREVIEWIMGCONT .record_audio').length > 0)
|
||||
{
|
||||
margY = 100;
|
||||
de = 60;
|
||||
}
|
||||
|
||||
|
||||
// if(p4.preview.current.type != 'flash')
|
||||
// {
|
||||
var ratioP = w / h;
|
||||
var ratioD = parseInt(p4.preview.width) / parseInt(p4.preview.height);
|
||||
var ratioP = w / h;
|
||||
var ratioD = parseInt(p4.preview.width) / parseInt(p4.preview.height);
|
||||
|
||||
if (ratioD > ratioP) {
|
||||
//je regle la hauteur d'abord
|
||||
if ((parseInt(h) + margY) > parseInt(p4.preview.height)) {
|
||||
h = Math.round(parseInt(p4.preview.height) - margY);
|
||||
w = Math.round(h * ratioP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((parseInt(w) + margX) > parseInt(p4.preview.width)) {
|
||||
w = Math.round(parseInt(p4.preview.width) - margX);
|
||||
h = Math.round(w / ratioP);
|
||||
}
|
||||
}
|
||||
if (ratioD > ratioP) {
|
||||
//je regle la hauteur d'abord
|
||||
if ((parseInt(h) + margY) > parseInt(p4.preview.height)) {
|
||||
h = Math.round(parseInt(p4.preview.height) - margY);
|
||||
w = Math.round(h * ratioP);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ((parseInt(w) + margX) > parseInt(p4.preview.width)) {
|
||||
w = Math.round(parseInt(p4.preview.width) - margX);
|
||||
h = Math.round(w / ratioP);
|
||||
}
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
@@ -484,42 +484,42 @@ function setPreview(){
|
||||
// h = Math.round(parseInt(p4.preview.height) - margY);
|
||||
// w = Math.round(parseInt(p4.preview.width) - margX);
|
||||
// }
|
||||
t = Math.round((parseInt(p4.preview.height) - h - de) / 2);
|
||||
var l = Math.round((parseInt(p4.preview.width) - w) / 2);
|
||||
$('#PREVIEWIMGCONT .record').css({
|
||||
width: w,
|
||||
height: h,
|
||||
top: t,
|
||||
left: l
|
||||
}).attr('width',w).attr('height',h);
|
||||
t = Math.round((parseInt(p4.preview.height) - h - de) / 2);
|
||||
var l = Math.round((parseInt(p4.preview.width) - w) / 2);
|
||||
$('#PREVIEWIMGCONT .record').css({
|
||||
width: w,
|
||||
height: h,
|
||||
top: t,
|
||||
left: l
|
||||
}).attr('width',w).attr('height',h);
|
||||
}
|
||||
|
||||
function classicMode(){
|
||||
$('#PREVIEWCURRENTCONT').animate({'scrollLeft' : ($('#PREVIEWCURRENT li.selected').position().left - 160)});
|
||||
p4.currentViewMode = 'classic';
|
||||
$('#PREVIEWCURRENTCONT').animate({'scrollLeft' : ($('#PREVIEWCURRENT li.selected').position().left - 160)});
|
||||
p4.currentViewMode = 'classic';
|
||||
}
|
||||
|
||||
function doudouMode(){
|
||||
$('#PREVIEWCURRENT li').removeClass('see-all');
|
||||
$('#PREVIEWCURRENT ul').width('auto');
|
||||
$('#PREVIEWCURRENTCONT').css({
|
||||
'overflow-x': 'hidden'
|
||||
});
|
||||
p4.currentViewMode = 'enhance';
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
$('#PREVIEWCURRENT li').removeClass('see-all');
|
||||
$('#PREVIEWCURRENT ul').width('auto');
|
||||
$('#PREVIEWCURRENTCONT').css({
|
||||
'overflow-x': 'hidden'
|
||||
});
|
||||
p4.currentViewMode = 'enhance';
|
||||
viewCurrent($('#PREVIEWCURRENT li.selected'));
|
||||
}
|
||||
|
||||
function closePreview(){
|
||||
p4.preview.open = false;
|
||||
hideOverlay();
|
||||
p4.preview.open = false;
|
||||
hideOverlay();
|
||||
|
||||
$('#PREVIEWBOX').fadeTo(500, 0);
|
||||
$('#PREVIEWBOX').queue(function(){
|
||||
$(this).css({
|
||||
'display': 'none'
|
||||
});
|
||||
cancelPreview();
|
||||
$(this).dequeue();
|
||||
});
|
||||
$('#PREVIEWBOX').fadeTo(500, 0);
|
||||
$('#PREVIEWBOX').queue(function(){
|
||||
$(this).css({
|
||||
'display': 'none'
|
||||
});
|
||||
cancelPreview();
|
||||
$(this).dequeue();
|
||||
});
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -6,278 +6,278 @@
|
||||
|
||||
(function( window ) {
|
||||
|
||||
var Selectable = function($container, options) {
|
||||
var Selectable = function($container, options) {
|
||||
|
||||
var defaults = {
|
||||
allow_multiple : false,
|
||||
selector : '',
|
||||
callbackSelection : null,
|
||||
selectStart : null,
|
||||
selectStop : null,
|
||||
limit : null
|
||||
var defaults = {
|
||||
allow_multiple : false,
|
||||
selector : '',
|
||||
callbackSelection : null,
|
||||
selectStart : null,
|
||||
selectStop : null,
|
||||
limit : null
|
||||
},
|
||||
options = (typeof options == 'object') ? options : {};
|
||||
|
||||
var $this = this;
|
||||
|
||||
if($container.data('selectionnable'))
|
||||
{
|
||||
/* this container is already selectionnable */
|
||||
if(window.console)
|
||||
{
|
||||
console.error('Trying to apply new selection to existing one');
|
||||
}
|
||||
|
||||
return $container.data('selectionnable');
|
||||
}
|
||||
|
||||
this.$container = $container;
|
||||
this.options = jQuery.extend(defaults, options);
|
||||
this.datas = new Array();
|
||||
|
||||
this.$container.data('selectionnable', this);
|
||||
this.$container.addClass('selectionnable');
|
||||
|
||||
jQuery(this.options.selector, this.$container)
|
||||
.live('click', function(event){
|
||||
|
||||
if(typeof $this.options.selectStart === 'function')
|
||||
{
|
||||
$this.options.selectStart(jQuery.extend(jQuery.Event('selectStart'), event), $this);
|
||||
}
|
||||
|
||||
var $that = jQuery(this);
|
||||
|
||||
var k = get_value($that, $this);
|
||||
|
||||
if(is_shift_key(event) && jQuery('.last_selected', this.$container).filter($this.options.selector).length != 0)
|
||||
{
|
||||
var lst = jQuery($this.options.selector, this.$container);
|
||||
|
||||
var index1 = jQuery.inArray( jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst );
|
||||
var index2 = jQuery.inArray( $that[0], lst );
|
||||
|
||||
if(index2<index1)
|
||||
{
|
||||
var tmp = index1;
|
||||
index1 = (index2 - 1) < 0 ? index2 : (index2 - 1);
|
||||
index2 = tmp;
|
||||
}
|
||||
|
||||
var stopped = false;
|
||||
|
||||
if(index2 != -1 && index1 != -1)
|
||||
{
|
||||
var exp = $this.options.selector + ':gt(' + index1 + '):lt(' + (index2-index1) + ')';
|
||||
|
||||
$.each(jQuery(exp, this.$container),function(i,n){
|
||||
if(!jQuery(n).hasClass('selected') && stopped === false)
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
var k = get_value(jQuery(n), $this);
|
||||
$this.push(k);
|
||||
jQuery(n).addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
stopped = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if($this.has(k) === false && stopped === false)
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
$this.push(k);
|
||||
$that.addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_ctrl_key(event))
|
||||
{
|
||||
$this.empty().push(k);
|
||||
jQuery('.selected', this.$container).filter($this.options.selector).removeClass('selected');
|
||||
$that.addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this.has(k) === true)
|
||||
{
|
||||
$this.remove(k);
|
||||
$that.removeClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
$this.push(k);
|
||||
$that.addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jQuery('.last_selected', this.$container).removeClass('last_selected');
|
||||
$that.addClass('last_selected');
|
||||
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
$this.options.selectStop(jQuery.extend(jQuery.Event('selectStop'), event), $this);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
function get_value(element, Selectable)
|
||||
{
|
||||
if(typeof Selectable.options.callbackSelection === 'function')
|
||||
{
|
||||
return Selectable.options.callbackSelection(jQuery(element));
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery('input[name="id"]', jQuery(element)).val();
|
||||
}
|
||||
}
|
||||
|
||||
function is_ctrl_key(event)
|
||||
{
|
||||
if(event.altKey)
|
||||
return true;
|
||||
if(event.ctrlKey)
|
||||
return true;
|
||||
if(event.metaKey) // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '17') // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '224') // apple key mozilla
|
||||
return true;
|
||||
if(event.keyCode == '91') // apple key safari
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_shift_key(event)
|
||||
{
|
||||
if(event.shiftKey)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Selectable.prototype = {
|
||||
push : function(element){
|
||||
if(this.options.allow_multiple === true || !this.has(element))
|
||||
{
|
||||
this.datas.push(element);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
options = (typeof options == 'object') ? options : {};
|
||||
|
||||
var $this = this;
|
||||
|
||||
if($container.data('selectionnable'))
|
||||
{
|
||||
/* this container is already selectionnable */
|
||||
if(window.console)
|
||||
{
|
||||
console.error('Trying to apply new selection to existing one');
|
||||
}
|
||||
|
||||
return $container.data('selectionnable');
|
||||
}
|
||||
|
||||
this.$container = $container;
|
||||
this.options = jQuery.extend(defaults, options);
|
||||
this.datas = new Array();
|
||||
|
||||
this.$container.data('selectionnable', this);
|
||||
this.$container.addClass('selectionnable');
|
||||
|
||||
jQuery(this.options.selector, this.$container)
|
||||
.live('click', function(event){
|
||||
|
||||
if(typeof $this.options.selectStart === 'function')
|
||||
{
|
||||
$this.options.selectStart(jQuery.extend(jQuery.Event('selectStart'), event), $this);
|
||||
}
|
||||
|
||||
var $that = jQuery(this);
|
||||
|
||||
var k = get_value($that, $this);
|
||||
|
||||
if(is_shift_key(event) && jQuery('.last_selected', this.$container).filter($this.options.selector).length != 0)
|
||||
{
|
||||
var lst = jQuery($this.options.selector, this.$container);
|
||||
|
||||
var index1 = jQuery.inArray( jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst );
|
||||
var index2 = jQuery.inArray( $that[0], lst );
|
||||
|
||||
if(index2<index1)
|
||||
{
|
||||
var tmp = index1;
|
||||
index1 = (index2 - 1) < 0 ? index2 : (index2 - 1);
|
||||
index2 = tmp;
|
||||
}
|
||||
|
||||
var stopped = false;
|
||||
|
||||
if(index2 != -1 && index1 != -1)
|
||||
{
|
||||
var exp = $this.options.selector + ':gt(' + index1 + '):lt(' + (index2-index1) + ')';
|
||||
|
||||
$.each(jQuery(exp, this.$container),function(i,n){
|
||||
if(!jQuery(n).hasClass('selected') && stopped === false)
|
||||
hasReachLimit : function() {
|
||||
if(this.options.limit !== null && this.options.limit <= this.datas.length)
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
var k = get_value(jQuery(n), $this);
|
||||
$this.push(k);
|
||||
jQuery(n).addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
stopped = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
},
|
||||
remove : function(element){
|
||||
this.datas = jQuery.grep(this.datas, function(n){
|
||||
return(n !== element);
|
||||
});
|
||||
|
||||
if($this.has(k) === false && stopped === false)
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
$this.push(k);
|
||||
$that.addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_ctrl_key(event))
|
||||
{
|
||||
$this.empty().push(k);
|
||||
jQuery('.selected', this.$container).filter($this.options.selector).removeClass('selected');
|
||||
$that.addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this.has(k) === true)
|
||||
{
|
||||
$this.remove(k);
|
||||
$that.removeClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$this.hasReachLimit())
|
||||
return this;
|
||||
},
|
||||
has : function(element){
|
||||
|
||||
return jQuery.inArray(element,this.datas) >= 0;
|
||||
},
|
||||
get : function(){
|
||||
|
||||
return this.datas;
|
||||
},
|
||||
empty : function(){
|
||||
var $this = this;
|
||||
this.datas = new Array();
|
||||
|
||||
jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected');
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
$this.push(k);
|
||||
$that.addClass('selected');
|
||||
$this.options.selectStop(jQuery.Event('selectStop'), $this);
|
||||
}
|
||||
else
|
||||
|
||||
return this;
|
||||
},
|
||||
length : function(){
|
||||
|
||||
return this.datas.length;
|
||||
},
|
||||
size : function(){
|
||||
|
||||
return this.datas.length;
|
||||
},
|
||||
serialize : function(separator){
|
||||
|
||||
separator = separator || ';';
|
||||
|
||||
return this.datas.join(separator);
|
||||
},
|
||||
selectAll : function(){
|
||||
this.select('*');
|
||||
|
||||
return this;
|
||||
},
|
||||
select : function(selector){
|
||||
var $this = this,
|
||||
stopped = false;
|
||||
|
||||
jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function(){
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
$this.push(get_value(this, $this));
|
||||
$(this).addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stopped === false)
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
}
|
||||
stopped = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
$this.options.selectStop(jQuery.Event('selectStop'), $this);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jQuery('.last_selected', this.$container).removeClass('last_selected');
|
||||
$that.addClass('last_selected');
|
||||
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
$this.options.selectStop(jQuery.extend(jQuery.Event('selectStop'), event), $this);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
function get_value(element, Selectable)
|
||||
{
|
||||
if(typeof Selectable.options.callbackSelection === 'function')
|
||||
{
|
||||
return Selectable.options.callbackSelection(jQuery(element));
|
||||
}
|
||||
else
|
||||
{
|
||||
return jQuery('input[name="id"]', jQuery(element)).val();
|
||||
}
|
||||
}
|
||||
|
||||
function is_ctrl_key(event)
|
||||
{
|
||||
if(event.altKey)
|
||||
return true;
|
||||
if(event.ctrlKey)
|
||||
return true;
|
||||
if(event.metaKey) // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '17') // apple key opera
|
||||
return true;
|
||||
if(event.keyCode == '224') // apple key mozilla
|
||||
return true;
|
||||
if(event.keyCode == '91') // apple key safari
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function is_shift_key(event)
|
||||
{
|
||||
if(event.shiftKey)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Selectable.prototype = {
|
||||
push : function(element){
|
||||
if(this.options.allow_multiple === true || !this.has(element))
|
||||
{
|
||||
this.datas.push(element);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
hasReachLimit : function() {
|
||||
if(this.options.limit !== null && this.options.limit <= this.datas.length)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
remove : function(element){
|
||||
this.datas = jQuery.grep(this.datas, function(n){
|
||||
return(n !== element);
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
has : function(element){
|
||||
|
||||
return jQuery.inArray(element,this.datas) >= 0;
|
||||
},
|
||||
get : function(){
|
||||
|
||||
return this.datas;
|
||||
},
|
||||
empty : function(){
|
||||
var $this = this;
|
||||
this.datas = new Array();
|
||||
|
||||
jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected');
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
$this.options.selectStop(jQuery.Event('selectStop'), $this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
length : function(){
|
||||
|
||||
return this.datas.length;
|
||||
},
|
||||
size : function(){
|
||||
|
||||
return this.datas.length;
|
||||
},
|
||||
serialize : function(separator){
|
||||
|
||||
separator = separator || ';';
|
||||
|
||||
return this.datas.join(separator);
|
||||
},
|
||||
selectAll : function(){
|
||||
this.select('*');
|
||||
|
||||
return this;
|
||||
},
|
||||
select : function(selector){
|
||||
var $this = this,
|
||||
stopped = false;
|
||||
|
||||
jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function(){
|
||||
if(!$this.hasReachLimit())
|
||||
{
|
||||
$this.push(get_value(this, $this));
|
||||
$(this).addClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stopped === false)
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
}
|
||||
stopped = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(typeof $this.options.selectStop === 'function')
|
||||
{
|
||||
$this.options.selectStop(jQuery.Event('selectStop'), $this);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
window.Selectable = Selectable;
|
||||
})(window);
|
||||
window.Selectable = Selectable;
|
||||
})(window);
|
||||
|
@@ -2,284 +2,284 @@ var p4 = p4 || {};
|
||||
|
||||
(function( window, p4, $ ) {
|
||||
|
||||
var Lists = function() {
|
||||
|
||||
};
|
||||
|
||||
var List = function (id) {
|
||||
|
||||
if(parseInt(id) <= 0)
|
||||
{
|
||||
throw 'Invalid list id';
|
||||
var Lists = function() {
|
||||
|
||||
};
|
||||
|
||||
var List = function (id) {
|
||||
|
||||
if(parseInt(id) <= 0)
|
||||
{
|
||||
throw 'Invalid list id';
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
};
|
||||
|
||||
Lists.prototype = {
|
||||
create : function(name, callback){
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/',
|
||||
dataType: 'json',
|
||||
data: {name : name},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
var list = new List(data.list_id);
|
||||
callback(list);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
get : function(callback, type) {
|
||||
|
||||
var $this = this;
|
||||
type = typeof type === 'undefined' ? 'json' : type;
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/prod/lists/all/',
|
||||
dataType: type,
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(type == 'json')
|
||||
{
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback(data.result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
};
|
||||
|
||||
Lists.prototype = {
|
||||
create : function(name, callback){
|
||||
|
||||
var $this = this;
|
||||
List.prototype = {
|
||||
addUsers : function(arrayUsers, callback) {
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/',
|
||||
dataType: 'json',
|
||||
data: {name : name},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
if(!arrayUsers instanceof Array)
|
||||
{
|
||||
var list = new List(data.list_id);
|
||||
callback(list);
|
||||
throw 'addUsers takes array as argument';
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
|
||||
var $this = this;
|
||||
var data = {usr_ids : $(arrayUsers).toArray()};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + $this.id + '/add/',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
addUser : function(usr_id, callback) {
|
||||
this.addUsers([usr_id], callback);
|
||||
},
|
||||
remove : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/delete/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
update : function(name, callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/update/',
|
||||
dataType: 'json',
|
||||
data: { name : name },
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
removeUser : function(usr_id, callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/remove/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
shareWith : function(usr_id, role, callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/share/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {role : role},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
unshareWith : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/unshare/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
get : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/prod/lists/list/' + this.id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
get : function(callback, type) {
|
||||
|
||||
var $this = this;
|
||||
type = typeof type === 'undefined' ? 'json' : type;
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/prod/lists/all/',
|
||||
dataType: type,
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(type == 'json')
|
||||
{
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback(data.result);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
List.prototype = {
|
||||
addUsers : function(arrayUsers, callback) {
|
||||
|
||||
if(!arrayUsers instanceof Array)
|
||||
{
|
||||
throw 'addUsers takes array as argument';
|
||||
}
|
||||
|
||||
var $this = this;
|
||||
var data = {usr_ids : $(arrayUsers).toArray()};
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + $this.id + '/add/',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
addUser : function(usr_id, callback) {
|
||||
this.addUsers([usr_id], callback);
|
||||
},
|
||||
remove : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/delete/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
update : function(name, callback) {
|
||||
|
||||
var $this = this;
|
||||
p4.Lists = new Lists();
|
||||
document.List = List;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/update/',
|
||||
dataType: 'json',
|
||||
data: { name : name },
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
removeUser : function(usr_id, callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/remove/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
shareWith : function(usr_id, role, callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/share/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {role : role},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
unshareWith : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '/prod/lists/list/' + this.id + '/unshare/' + usr_id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
get : function(callback) {
|
||||
|
||||
var $this = this;
|
||||
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: '/prod/lists/list/' + this.id + '/',
|
||||
dataType: 'json',
|
||||
data: {},
|
||||
success: function(data){
|
||||
if(data.success)
|
||||
{
|
||||
humane.info(data.message);
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
callback($this, data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
humane.error(data.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
p4.Lists = new Lists();
|
||||
document.List = List;
|
||||
|
||||
})(document, p4, jQuery);
|
||||
})(document, p4, jQuery);
|
||||
|
@@ -1,115 +1,115 @@
|
||||
(function( $ ){
|
||||
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'url' : '/admin/tests/pathurl/path/'
|
||||
};
|
||||
return this.each(function() {
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'url' : '/admin/tests/pathurl/path/'
|
||||
};
|
||||
return this.each(function() {
|
||||
|
||||
var $this = $(this), data = $(this).data('path_file_tests');
|
||||
var $this = $(this), data = $(this).data('path_file_tests');
|
||||
|
||||
if ( ! data )
|
||||
{
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
$this.data('path_file_tests', {});
|
||||
|
||||
$this.after('<img class="loader" style="visibility:hidden;" src="/skins/icons/loader-black.gif"/>');
|
||||
$this.after('<img class="reload" src="/skins/icons/reload.png"/>');
|
||||
$this.after('<img class="status" src="/skins/icons/delete.png"/>');
|
||||
|
||||
|
||||
$this.bind('keyup blur', function(){
|
||||
var el_loader = $this.nextAll('.loader');
|
||||
var el_status = $this.nextAll('.status');
|
||||
|
||||
if($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function')
|
||||
$this.data('ajax_path_test').abort();
|
||||
|
||||
if(!$this.hasClass('test_executable') && !$this.hasClass('test_writeable') && !$this.hasClass('test_readable'))
|
||||
return;
|
||||
|
||||
|
||||
if(!$this.hasClass('required') && $.trim($this.val()) === '')
|
||||
{
|
||||
el_status.css('visibility', 'hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
var ajax = $.ajax({
|
||||
dataType: 'json',
|
||||
type: "GET",
|
||||
url: settings.url,
|
||||
data: {
|
||||
path : $this.val()
|
||||
},
|
||||
beforeSend:function(){
|
||||
el_loader.css('visibility', 'visible');
|
||||
},
|
||||
success: function(data){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
if($this.hasClass('required'))
|
||||
if ( ! data )
|
||||
{
|
||||
$this.addClass('field_error');
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
$this.data('path_file_tests', {});
|
||||
|
||||
$this.after('<img class="loader" style="visibility:hidden;" src="/skins/icons/loader-black.gif"/>');
|
||||
$this.after('<img class="reload" src="/skins/icons/reload.png"/>');
|
||||
$this.after('<img class="status" src="/skins/icons/delete.png"/>');
|
||||
|
||||
|
||||
$this.bind('keyup blur', function(){
|
||||
var el_loader = $this.nextAll('.loader');
|
||||
var el_status = $this.nextAll('.status');
|
||||
|
||||
if($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function')
|
||||
$this.data('ajax_path_test').abort();
|
||||
|
||||
if(!$this.hasClass('test_executable') && !$this.hasClass('test_writeable') && !$this.hasClass('test_readable'))
|
||||
return;
|
||||
|
||||
|
||||
if(!$this.hasClass('required') && $.trim($this.val()) === '')
|
||||
{
|
||||
el_status.css('visibility', 'hidden');
|
||||
return;
|
||||
}
|
||||
|
||||
var ajax = $.ajax({
|
||||
dataType: 'json',
|
||||
type: "GET",
|
||||
url: settings.url,
|
||||
data: {
|
||||
path : $this.val()
|
||||
},
|
||||
beforeSend:function(){
|
||||
el_loader.css('visibility', 'visible');
|
||||
},
|
||||
success: function(data){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
if($this.hasClass('required'))
|
||||
{
|
||||
$this.addClass('field_error');
|
||||
}
|
||||
if($this.hasClass('test_executable') && (data.executable === false || data.file !== true))
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
if($this.hasClass('test_writeable') && data.writeable === false)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
if($this.hasClass('test_readable') && data.readable === false)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
el_status.attr('src','/skins/icons/ok.png').css('visibility', 'visible');
|
||||
$this.removeClass('field_error');
|
||||
return;
|
||||
},
|
||||
timeout:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
},
|
||||
error:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
}
|
||||
});
|
||||
$this.data('ajax_path_test', ajax);
|
||||
});
|
||||
|
||||
$this.trigger('keyup');
|
||||
|
||||
$this.nextAll('.reload').bind('click', function(){
|
||||
$this.trigger('keyup');
|
||||
});
|
||||
}
|
||||
if($this.hasClass('test_executable') && (data.executable === false || data.file !== true))
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
if($this.hasClass('test_writeable') && data.writeable === false)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
if($this.hasClass('test_readable') && data.readable === false)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
return;
|
||||
}
|
||||
el_status.attr('src','/skins/icons/ok.png').css('visibility', 'visible');
|
||||
$this.removeClass('field_error');
|
||||
return;
|
||||
},
|
||||
timeout:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
},
|
||||
error:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible');
|
||||
}
|
||||
});
|
||||
$this.data('ajax_path_test', ajax);
|
||||
});
|
||||
|
||||
$this.trigger('keyup');
|
||||
|
||||
$this.nextAll('.reload').bind('click', function(){
|
||||
$this.trigger('keyup');
|
||||
});
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('path_file_tests', null);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('path_file_tests', null);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$.fn.path_file_test = function(method) {
|
||||
$.fn.path_file_test = function(method) {
|
||||
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.path_file_test' );
|
||||
}
|
||||
};
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.path_file_test' );
|
||||
}
|
||||
};
|
||||
})( jQuery );
|
||||
|
||||
|
||||
@@ -117,121 +117,121 @@
|
||||
|
||||
(function( $ ){
|
||||
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'url' : '/admin/tests/pathurl/url/'
|
||||
};
|
||||
return this.each(function() {
|
||||
var methods = {
|
||||
init : function( options ) {
|
||||
var settings = {
|
||||
'url' : '/admin/tests/pathurl/url/'
|
||||
};
|
||||
return this.each(function() {
|
||||
|
||||
var $this = $(this), data = $(this).data('url_tests');
|
||||
var $this = $(this), data = $(this).data('url_tests');
|
||||
|
||||
if ( ! data )
|
||||
{
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
$this.data('url_tests', {});
|
||||
|
||||
$this.after('<img class="loader" style="visibility:hidden;" src="/skins/icons/loader-black.gif"/>');
|
||||
$this.after('<img class="reload" src="/skins/icons/reload.png"/>');
|
||||
$this.after('<img class="status" src="/skins/icons/delete.png"/>');
|
||||
|
||||
$this.bind('keyup blur', function(){
|
||||
var el_loader = $(this).nextAll('.loader');
|
||||
var el_status = $(this).nextAll('.status');
|
||||
|
||||
var listable = $this.hasClass('listable');
|
||||
var required = $this.hasClass('required');
|
||||
var same_domain = $this.hasClass('same_domain');
|
||||
|
||||
var value = $.trim($this.val());
|
||||
|
||||
if(!required && value === '')
|
||||
{
|
||||
el_status.attr('src','/skins/icons/ok.png');
|
||||
return;
|
||||
}
|
||||
if(required && value === '')
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
return;
|
||||
}
|
||||
if(same_domain && value.substring(0,1) != '/')
|
||||
{
|
||||
value = '/'+value;
|
||||
}
|
||||
if(same_domain)
|
||||
{
|
||||
value = location.protocol+'//'+location.hostname+value;
|
||||
}
|
||||
|
||||
if($this.data('ajax_url_test') && typeof $this.data('ajax_url_test').abort == 'function')
|
||||
$this.data('ajax_url_test').abort();
|
||||
|
||||
var ajax = $.ajax({
|
||||
type: "GET",
|
||||
url: settings.url,
|
||||
dataType:'json',
|
||||
data: {
|
||||
url : value
|
||||
},
|
||||
beforeSend:function(){
|
||||
el_loader.css('visibility', 'visible');
|
||||
},
|
||||
success: function(datas){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
if(datas.code === 404)
|
||||
if ( ! data )
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
return;
|
||||
if ( options ) {
|
||||
$.extend( settings, options );
|
||||
}
|
||||
$this.data('url_tests', {});
|
||||
|
||||
$this.after('<img class="loader" style="visibility:hidden;" src="/skins/icons/loader-black.gif"/>');
|
||||
$this.after('<img class="reload" src="/skins/icons/reload.png"/>');
|
||||
$this.after('<img class="status" src="/skins/icons/delete.png"/>');
|
||||
|
||||
$this.bind('keyup blur', function(){
|
||||
var el_loader = $(this).nextAll('.loader');
|
||||
var el_status = $(this).nextAll('.status');
|
||||
|
||||
var listable = $this.hasClass('listable');
|
||||
var required = $this.hasClass('required');
|
||||
var same_domain = $this.hasClass('same_domain');
|
||||
|
||||
var value = $.trim($this.val());
|
||||
|
||||
if(!required && value === '')
|
||||
{
|
||||
el_status.attr('src','/skins/icons/ok.png');
|
||||
return;
|
||||
}
|
||||
if(required && value === '')
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
return;
|
||||
}
|
||||
if(same_domain && value.substring(0,1) != '/')
|
||||
{
|
||||
value = '/'+value;
|
||||
}
|
||||
if(same_domain)
|
||||
{
|
||||
value = location.protocol+'//'+location.hostname+value;
|
||||
}
|
||||
|
||||
if($this.data('ajax_url_test') && typeof $this.data('ajax_url_test').abort == 'function')
|
||||
$this.data('ajax_url_test').abort();
|
||||
|
||||
var ajax = $.ajax({
|
||||
type: "GET",
|
||||
url: settings.url,
|
||||
dataType:'json',
|
||||
data: {
|
||||
url : value
|
||||
},
|
||||
beforeSend:function(){
|
||||
el_loader.css('visibility', 'visible');
|
||||
},
|
||||
success: function(datas){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
if(datas.code === 404)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
return;
|
||||
}
|
||||
if(!listable && datas.code === 403)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/ok.png');
|
||||
}
|
||||
else
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
}
|
||||
return;
|
||||
},
|
||||
timeout:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
},
|
||||
error:function(datas){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
}
|
||||
});
|
||||
$this.data('ajax_url_test', ajax);
|
||||
});
|
||||
|
||||
$this.trigger('keyup');
|
||||
$this.nextAll('.reload').bind('click', function(){
|
||||
$this.trigger('keyup');
|
||||
});
|
||||
}
|
||||
if(!listable && datas.code === 403)
|
||||
{
|
||||
el_status.attr('src','/skins/icons/ok.png');
|
||||
}
|
||||
else
|
||||
{
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
}
|
||||
return;
|
||||
},
|
||||
timeout:function(){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
},
|
||||
error:function(datas){
|
||||
el_loader.css('visibility', 'hidden');
|
||||
el_status.attr('src','/skins/icons/delete.png');
|
||||
}
|
||||
});
|
||||
$this.data('ajax_url_test', ajax);
|
||||
});
|
||||
|
||||
$this.trigger('keyup');
|
||||
$this.nextAll('.reload').bind('click', function(){
|
||||
$this.trigger('keyup');
|
||||
});
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('url_tests', null);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
destroy : function( ) {
|
||||
return this.each(function() {
|
||||
$(this).data('url_tests', null);
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
$.fn.url_test = function(method) {
|
||||
$.fn.url_test = function(method) {
|
||||
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.url_test' );
|
||||
}
|
||||
};
|
||||
if ( methods[method] ) {
|
||||
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
$.error( 'Method ' + method + ' does not exist on jQuery.url_test' );
|
||||
}
|
||||
};
|
||||
})( jQuery );
|
||||
|
||||
|
||||
|
@@ -20,8 +20,8 @@ define([
|
||||
"apps/admin/fields/views/fieldError",
|
||||
"apps/admin/fields/errors/errorManager"
|
||||
], function(
|
||||
$, _, Backbone, i18n, FieldsCollection, VocabulariesCollection,
|
||||
DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) {
|
||||
$, _, Backbone, i18n, FieldsCollection, VocabulariesCollection,
|
||||
DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) {
|
||||
var initialize = function() {
|
||||
AdminFieldApp = {
|
||||
$window : $(window),
|
||||
@@ -66,16 +66,16 @@ define([
|
||||
|
||||
// load all collections
|
||||
$.when.apply($, [
|
||||
AdminFieldApp.fieldsCollection.fetch(),
|
||||
AdminFieldApp.vocabularyCollection.fetch(),
|
||||
AdminFieldApp.dcFieldsCollection.fetch(),
|
||||
$.ajax({
|
||||
url: '/available-languages',
|
||||
success: function(languages) {
|
||||
AdminFieldApp.languages = languages;
|
||||
}
|
||||
})
|
||||
]).done(
|
||||
AdminFieldApp.fieldsCollection.fetch(),
|
||||
AdminFieldApp.vocabularyCollection.fetch(),
|
||||
AdminFieldApp.dcFieldsCollection.fetch(),
|
||||
$.ajax({
|
||||
url: '/available-languages',
|
||||
success: function(languages) {
|
||||
AdminFieldApp.languages = languages;
|
||||
}
|
||||
})
|
||||
]).done(
|
||||
function() {
|
||||
// register views
|
||||
AdminFieldApp.saveView = new SaveView({
|
||||
|
@@ -138,15 +138,15 @@ define([
|
||||
AdminFieldApp.fieldsCollection.add(field);
|
||||
_.last(AdminFieldApp.fieldListView.itemViews).clickAction().animate();
|
||||
|
||||
new AlertView({alert: "info", message: i18n.t("created_success", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: [field.get("name")]
|
||||
})
|
||||
new AlertView({alert: "info", message: i18n.t("created_success", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: [field.get("name")]
|
||||
})
|
||||
}).render();
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
new AlertView({
|
||||
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")}
|
||||
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")}
|
||||
).render();
|
||||
|
||||
self.toggleCreateFormAction();
|
||||
|
@@ -38,5 +38,5 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
return DcFieldsView;
|
||||
return DcFieldsView;
|
||||
});
|
||||
|
@@ -207,7 +207,7 @@ define([
|
||||
},
|
||||
// select temView by index in itemList
|
||||
_selectModelView: function(index) {
|
||||
// select previous or next itemview
|
||||
// select previous or next itemview
|
||||
if (index >= 0) {
|
||||
AdminFieldApp.fieldListView.itemViews[index].select().animate().click();
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ define([
|
||||
|
||||
// highlight view if edit view model match current view model
|
||||
if (AdminFieldApp.fieldEditView
|
||||
&& AdminFieldApp.fieldEditView.model.get("id") === this.model.get("id")) {
|
||||
&& AdminFieldApp.fieldEditView.model.get("id") === this.model.get("id")) {
|
||||
this.select();
|
||||
}
|
||||
|
||||
|
@@ -38,19 +38,19 @@ define([
|
||||
if (this._isModelDesync()) {
|
||||
this._loadingState(true);
|
||||
$.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function(m){
|
||||
return m.destroy({
|
||||
success: function(model, response) {
|
||||
AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){
|
||||
return model.get("id") !== m.get("id");
|
||||
});
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
new AlertView({
|
||||
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
|
||||
}).render();
|
||||
}
|
||||
});
|
||||
})).done(
|
||||
return m.destroy({
|
||||
success: function(model, response) {
|
||||
AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){
|
||||
return model.get("id") !== m.get("id");
|
||||
});
|
||||
},
|
||||
error: function(xhr, textStatus, errorThrown) {
|
||||
new AlertView({
|
||||
alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")
|
||||
}).render();
|
||||
}
|
||||
});
|
||||
})).done(
|
||||
function() {
|
||||
AdminFieldApp.fieldsCollection.save({
|
||||
success: function(fields) {
|
||||
@@ -69,8 +69,8 @@ define([
|
||||
}).render();
|
||||
}
|
||||
}).done(function() {
|
||||
self._loadingState(false);
|
||||
});
|
||||
self._loadingState(false);
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ require([
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
new LoginForm({
|
||||
new LoginForm({
|
||||
el : $("form[name=loginForm]"),
|
||||
rules: [{
|
||||
name: "login",
|
||||
|
@@ -36,9 +36,9 @@ define([
|
||||
} else {
|
||||
return i18n.t(
|
||||
options.length === 1 ? "one_collection_selected": "collections_selected", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: [options.length]
|
||||
}) + ' <b class="caret"></b>';
|
||||
postProcess: "sprintf",
|
||||
sprintf: [options.length]
|
||||
}) + ' <b class="caret"></b>';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -19,7 +19,7 @@ require([
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
new LoginForm({
|
||||
new LoginForm({
|
||||
el : $("form[name=loginForm]"),
|
||||
rules: [{
|
||||
name: "login",
|
||||
|
@@ -19,7 +19,7 @@ require([
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
new LoginForm({
|
||||
new LoginForm({
|
||||
el : $("form[name=loginForm]"),
|
||||
rules: [{
|
||||
name: "login",
|
||||
|
@@ -17,9 +17,9 @@ require([
|
||||
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
new LoginForm({
|
||||
new LoginForm({
|
||||
el : $("form[name=loginForm]"),
|
||||
rules: [{
|
||||
name: "login",
|
||||
|
@@ -14,8 +14,8 @@ require([
|
||||
"common/forms/views/formType/passwordSetter"
|
||||
], function($, i18n, Common, RenewPassword) {
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
Common.initialize();
|
||||
|
||||
|
@@ -18,97 +18,97 @@ require([
|
||||
var fieldsConfiguration = [];
|
||||
|
||||
$.when.apply($, [
|
||||
$.ajax({
|
||||
url: '/login/registration-fields/',
|
||||
success: function(config) {
|
||||
fieldsConfiguration = config;
|
||||
}
|
||||
})
|
||||
]).done(function(){
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
Common.initialize();
|
||||
|
||||
var rules = [{
|
||||
name: "email",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "email",
|
||||
rules: "valid_email",
|
||||
message: i18n.t("validation_email")
|
||||
},{
|
||||
name: "password[password]",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "password[password]",
|
||||
rules: "min_length[5]",
|
||||
message: i18n.t("validation_length_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["5"]
|
||||
})
|
||||
},{
|
||||
name: "password[confirm]",
|
||||
rules: "matches[password[password]]",
|
||||
message: i18n.t("password_match")
|
||||
},{
|
||||
name: "accept-tou",
|
||||
rules: "required",
|
||||
message: i18n.t("accept_tou"),
|
||||
type: "checkbox"
|
||||
},{
|
||||
name: "collections[]",
|
||||
rules: "min_length[1]",
|
||||
message: i18n.t("validation_choice_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["1"]
|
||||
}),
|
||||
type: "multiple"
|
||||
}];
|
||||
|
||||
_.each(fieldsConfiguration, function(field) {
|
||||
if (field.required) {
|
||||
var rule = {
|
||||
"name": field.name,
|
||||
"rules": "required",
|
||||
"message": i18n.t("validation_blank")
|
||||
};
|
||||
|
||||
rules.push(rule);
|
||||
$.ajax({
|
||||
url: '/login/registration-fields/',
|
||||
success: function(config) {
|
||||
fieldsConfiguration = config;
|
||||
}
|
||||
});
|
||||
})
|
||||
]).done(function(){
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
Common.initialize();
|
||||
|
||||
var $form = $("form[name=registerForm]");
|
||||
var rules = [{
|
||||
name: "email",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "email",
|
||||
rules: "valid_email",
|
||||
message: i18n.t("validation_email")
|
||||
},{
|
||||
name: "password[password]",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "password[password]",
|
||||
rules: "min_length[5]",
|
||||
message: i18n.t("validation_length_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["5"]
|
||||
})
|
||||
},{
|
||||
name: "password[confirm]",
|
||||
rules: "matches[password[password]]",
|
||||
message: i18n.t("password_match")
|
||||
},{
|
||||
name: "accept-tou",
|
||||
rules: "required",
|
||||
message: i18n.t("accept_tou"),
|
||||
type: "checkbox"
|
||||
},{
|
||||
name: "collections[]",
|
||||
rules: "min_length[1]",
|
||||
message: i18n.t("validation_choice_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["1"]
|
||||
}),
|
||||
type: "multiple"
|
||||
}];
|
||||
|
||||
new RegisterForm({
|
||||
el : $form,
|
||||
rules: rules
|
||||
});
|
||||
_.each(fieldsConfiguration, function(field) {
|
||||
if (field.required) {
|
||||
var rule = {
|
||||
"name": field.name,
|
||||
"rules": "required",
|
||||
"message": i18n.t("validation_blank")
|
||||
};
|
||||
|
||||
var geocompleter = geonames.init($("#geonameid"), {
|
||||
"server": $form.data("geonames-server-adress"),
|
||||
"limit": 40,
|
||||
"init-input": false,
|
||||
"onInit": function(input, autoinput) {
|
||||
// Set default name to geonameid-completer
|
||||
autoinput.prop("name", "geonameid-completer");
|
||||
}
|
||||
});
|
||||
rules.push(rule);
|
||||
}
|
||||
});
|
||||
|
||||
// Positioning menu below input
|
||||
geocompleter.geocompleter("autocompleter", "option", "position", {
|
||||
"of": geocompleter.closest(".input-table"),
|
||||
"my": "left top",
|
||||
"at": "left bottom"
|
||||
});
|
||||
var $form = $("form[name=registerForm]");
|
||||
|
||||
// On open menu calculate max-width
|
||||
geocompleter.geocompleter("autocompleter", "on", "autocompleteopen", function(event, ui) {
|
||||
$(this).autocomplete("widget").css("min-width", geocompleter.closest(".input-table").outerWidth());
|
||||
new RegisterForm({
|
||||
el : $form,
|
||||
rules: rules
|
||||
});
|
||||
|
||||
var geocompleter = geonames.init($("#geonameid"), {
|
||||
"server": $form.data("geonames-server-adress"),
|
||||
"limit": 40,
|
||||
"init-input": false,
|
||||
"onInit": function(input, autoinput) {
|
||||
// Set default name to geonameid-completer
|
||||
autoinput.prop("name", "geonameid-completer");
|
||||
}
|
||||
});
|
||||
|
||||
// Positioning menu below input
|
||||
geocompleter.geocompleter("autocompleter", "option", "position", {
|
||||
"of": geocompleter.closest(".input-table"),
|
||||
"my": "left top",
|
||||
"at": "left bottom"
|
||||
});
|
||||
|
||||
// On open menu calculate max-width
|
||||
geocompleter.geocompleter("autocompleter", "on", "autocompleteopen", function(event, ui) {
|
||||
$(this).autocomplete("widget").css("min-width", geocompleter.closest(".input-table").outerWidth());
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -19,71 +19,71 @@ require([
|
||||
var fieldsConfiguration = [];
|
||||
|
||||
$.when.apply($, [
|
||||
$.ajax({
|
||||
url: '/login/registration-fields/',
|
||||
success: function(config) {
|
||||
fieldsConfiguration = config;
|
||||
}
|
||||
})
|
||||
]).done(function(){
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
var rules = [{
|
||||
name: "email",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "email",
|
||||
rules: "valid_email",
|
||||
message: i18n.t("validation_email")
|
||||
},{
|
||||
name: "password",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "password",
|
||||
rules: "min_length[5]",
|
||||
message: i18n.t("validation_length_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["5"]
|
||||
})
|
||||
},{
|
||||
name: "passwordConfirm",
|
||||
rules: "matches[password]",
|
||||
message: i18n.t("password_match")
|
||||
},{
|
||||
name: "accept-tou",
|
||||
rules: "required",
|
||||
message: i18n.t("accept_tou"),
|
||||
type: "checkbox"
|
||||
},{
|
||||
name: "collections[]",
|
||||
rules: "min_length[1]",
|
||||
message: i18n.t("validation_choice_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["1"]
|
||||
}),
|
||||
type: "multiple"
|
||||
}];
|
||||
|
||||
_.each(fieldsConfiguration, function(field) {
|
||||
if (field.required) {
|
||||
var rule = {
|
||||
"name": field.name,
|
||||
"rules": "required",
|
||||
"message": i18n.t("validation_blank")
|
||||
};
|
||||
|
||||
rules.push(rule);
|
||||
$.ajax({
|
||||
url: '/login/registration-fields/',
|
||||
success: function(config) {
|
||||
fieldsConfiguration = config;
|
||||
}
|
||||
});
|
||||
})
|
||||
]).done(function(){
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
var rules = [{
|
||||
name: "email",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "email",
|
||||
rules: "valid_email",
|
||||
message: i18n.t("validation_email")
|
||||
},{
|
||||
name: "password",
|
||||
rules: "required",
|
||||
message: i18n.t("validation_blank")
|
||||
},{
|
||||
name: "password",
|
||||
rules: "min_length[5]",
|
||||
message: i18n.t("validation_length_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["5"]
|
||||
})
|
||||
},{
|
||||
name: "passwordConfirm",
|
||||
rules: "matches[password]",
|
||||
message: i18n.t("password_match")
|
||||
},{
|
||||
name: "accept-tou",
|
||||
rules: "required",
|
||||
message: i18n.t("accept_tou"),
|
||||
type: "checkbox"
|
||||
},{
|
||||
name: "collections[]",
|
||||
rules: "min_length[1]",
|
||||
message: i18n.t("validation_choice_min", {
|
||||
postProcess: "sprintf",
|
||||
sprintf: ["1"]
|
||||
}),
|
||||
type: "multiple"
|
||||
}];
|
||||
|
||||
new RegisterForm({
|
||||
el : $("form[name=registerForm]"),
|
||||
rules: rules
|
||||
_.each(fieldsConfiguration, function(field) {
|
||||
if (field.required) {
|
||||
var rule = {
|
||||
"name": field.name,
|
||||
"rules": "required",
|
||||
"message": i18n.t("validation_blank")
|
||||
};
|
||||
|
||||
rules.push(rule);
|
||||
}
|
||||
});
|
||||
|
||||
new RegisterForm({
|
||||
el : $("form[name=registerForm]"),
|
||||
rules: rules
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -14,8 +14,8 @@ require([
|
||||
"common/forms/views/form"
|
||||
], function($, i18n, Common, RenewEmail) {
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
Common.initialize();
|
||||
|
||||
|
@@ -14,8 +14,8 @@ require([
|
||||
"common/forms/views/formType/passwordSetter"
|
||||
], function($, i18n, Common, RenewPassword) {
|
||||
i18n.init({
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
resGetPath: Common.languagePath,
|
||||
useLocalStorage: true
|
||||
}, function() {
|
||||
Common.initialize();
|
||||
|
||||
|
@@ -55,7 +55,7 @@ define([
|
||||
return this;
|
||||
},
|
||||
reset: function() {
|
||||
this.$el.empty();
|
||||
this.$el.empty();
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -17,9 +17,9 @@ define([
|
||||
], function($, _, i18n, Backbone, bootstrap, FormView) {
|
||||
var PasswordSetterForm = FormView.extend({
|
||||
events: function(){
|
||||
return _.extend({},FormView.prototype.events,{
|
||||
'keyup input[type=password]' : 'onPasswordKeyup'
|
||||
});
|
||||
return _.extend({},FormView.prototype.events,{
|
||||
'keyup input[type=password]' : 'onPasswordKeyup'
|
||||
});
|
||||
},
|
||||
onPasswordKeyup : function(event) {
|
||||
var input = $(event.target);
|
||||
|
@@ -32,7 +32,7 @@ define([
|
||||
ModalView,
|
||||
SaveView,
|
||||
DcFieldView
|
||||
) {
|
||||
) {
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
@@ -176,14 +176,14 @@ define([
|
||||
describe("DcField Views", function() {
|
||||
beforeEach(function() {
|
||||
this.collection = new DcFieldCollection([{
|
||||
"label": "Contributor",
|
||||
"definition": "An entity responsible for making contributions to the resource.",
|
||||
"URI": "http://dublincore.org/documents/dces/#contributor"
|
||||
}, {
|
||||
"label": "Coverage",
|
||||
"definition": "The spatial or temporal topic of the resource, the spatial applicability of the resource,\n or the jurisdiction under which the resource\n is relevant.",
|
||||
"URI": "http://dublincore.org/documents/dces/#coverage"
|
||||
}
|
||||
"label": "Contributor",
|
||||
"definition": "An entity responsible for making contributions to the resource.",
|
||||
"URI": "http://dublincore.org/documents/dces/#contributor"
|
||||
}, {
|
||||
"label": "Coverage",
|
||||
"definition": "The spatial or temporal topic of the resource, the spatial applicability of the resource,\n or the jurisdiction under which the resource\n is relevant.",
|
||||
"URI": "http://dublincore.org/documents/dces/#coverage"
|
||||
}
|
||||
]);
|
||||
|
||||
var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"});
|
||||
@@ -236,7 +236,7 @@ define([
|
||||
});
|
||||
|
||||
it("should not render an error message if provided tag is empty", function() {
|
||||
var view = this.view.render();
|
||||
var view = this.view.render();
|
||||
|
||||
view.$('input#tag').val("").blur();
|
||||
|
||||
|
@@ -12,7 +12,7 @@ define([
|
||||
FormView,
|
||||
InputView,
|
||||
ErrorView
|
||||
) {
|
||||
) {
|
||||
var expect = chai.expect;
|
||||
var assert = chai.assert;
|
||||
var should = chai.should();
|
||||
|
@@ -52,11 +52,11 @@ $(document).ready(function() {
|
||||
saveBtn.show();
|
||||
// wrapp current calback in an input
|
||||
input
|
||||
.empty()
|
||||
.wrapInner(''
|
||||
+ '<input value = "'+inputVal+'"'
|
||||
+ ' name="oauth_callback" size="50" type="text"/>'
|
||||
);
|
||||
.empty()
|
||||
.wrapInner(''
|
||||
+ '<input value = "'+inputVal+'"'
|
||||
+ ' name="oauth_callback" size="50" type="text"/>'
|
||||
);
|
||||
|
||||
$(".url_callback").die();
|
||||
|
||||
@@ -71,9 +71,9 @@ $(document).ready(function() {
|
||||
data :{callback : callback},
|
||||
success : function(data) {
|
||||
if(data.success) {
|
||||
input.empty().append(callback);
|
||||
input.empty().append(callback);
|
||||
} else {
|
||||
input.empty().append(inputVal);
|
||||
input.empty().append(inputVal);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -1,507 +1,507 @@
|
||||
function ini_edit_usrs(){
|
||||
$('.users_col.options').bind('click', function(event){
|
||||
$('#users_check_uncheck').remove();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
check_uncheck_menu($('input[name="right"]', $(this)).val(),$('input[name="sbas_id"]', $(this)).val(), $(this));
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).unbind('click.usersoptions').bind('click.usersoptions', function(event){
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
|
||||
$('table.hoverable tr').hover(
|
||||
function(){
|
||||
$(this).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass('hovered');
|
||||
}
|
||||
);
|
||||
|
||||
$('table.hoverable td').hover(
|
||||
function(){
|
||||
var attr = $('input:first', this).attr('name');
|
||||
var right = attr ? attr.split('_').shift() : false;
|
||||
if(right)
|
||||
$('td.case_right_'+right).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
var attr = $('input:first', this).attr('name');
|
||||
var right = attr ? attr.split('_').shift() : false;
|
||||
if(right)
|
||||
$('td.hovered').removeClass('hovered');
|
||||
}
|
||||
);
|
||||
|
||||
function user_click_box(event, element, status)
|
||||
{
|
||||
var newclass, newvalue, boxes;
|
||||
|
||||
var $element = $(element);
|
||||
|
||||
if($element.hasClass('right_access'))
|
||||
{
|
||||
var base_id = $element.find('input').attr('name').split('_').pop();
|
||||
boxes = $('div.base_'+base_id+':not(:first)');
|
||||
}
|
||||
|
||||
if((typeof status !== 'undefined' && status == 'checked') || (typeof status === 'undefined' && (($element.hasClass('mixed') === true) || ($element.hasClass('unchecked') === true))))
|
||||
{
|
||||
newclass = 'checked';
|
||||
newvalue = '1';
|
||||
|
||||
if(boxes)
|
||||
boxes.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
newvalue = '0';
|
||||
|
||||
if(boxes)
|
||||
boxes.hide();
|
||||
}
|
||||
|
||||
$element.find('input').val(newvalue);
|
||||
$element.removeClass('mixed checked unchecked').addClass(newclass);
|
||||
}
|
||||
|
||||
$('#users_rights_form div.switch_right').bind('click', function(event){
|
||||
user_click_box(event, $(this));
|
||||
});
|
||||
$('#right-ajax button.users_rights_valid').bind('click', function(){
|
||||
var datas = {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
values:$('#users_rights_form').serialize(),
|
||||
template:$('#users_rights_form select[name="template"]').val(),
|
||||
user_infos:$('#user_infos_form').serialize()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/apply/',
|
||||
dataType:'json',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
if(!data.error)
|
||||
$('a.zone_editusers').trigger('click');
|
||||
else
|
||||
alert(data.message);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#right-ajax .users_rights_cancel').bind('click', function(){
|
||||
var $this = $(this);
|
||||
$('#right-ajax').empty().addClass('loading').parent().show();
|
||||
$('#right').hide();
|
||||
$.get($this.attr('href'), function(data) {
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
$('.users_col.options').bind('click', function(event){
|
||||
$('#users_check_uncheck').remove();
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
check_uncheck_menu($('input[name="right"]', $(this)).val(),$('input[name="sbas_id"]', $(this)).val(), $(this));
|
||||
return false;
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
$(document).unbind('click.usersoptions').bind('click.usersoptions', function(event){
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
|
||||
var time_buttons = {
|
||||
'Ok':function(){
|
||||
save_time();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#time_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#time_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:time_buttons,
|
||||
modal:true
|
||||
});
|
||||
var quota_buttons = {
|
||||
'Ok':function(){
|
||||
save_quotas();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#quotas_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#quotas_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:quota_buttons,
|
||||
modal:true
|
||||
});
|
||||
$('table.hoverable tr').hover(
|
||||
function(){
|
||||
$(this).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass('hovered');
|
||||
}
|
||||
);
|
||||
|
||||
var masks_buttons = {
|
||||
'Ok':function(){
|
||||
save_masks();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#masks_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#masks_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:masks_buttons,
|
||||
width:900,
|
||||
height:300,
|
||||
modal:true
|
||||
});
|
||||
$('#users_rights_form .time_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="time_base_id"]').val();
|
||||
if ('undefined' !== typeof base_id) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#time_dialog');
|
||||
$('table.hoverable td').hover(
|
||||
function(){
|
||||
var attr = $('input:first', this).attr('name');
|
||||
var right = attr ? attr.split('_').shift() : false;
|
||||
if(right)
|
||||
$('td.case_right_'+right).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
var attr = $('input:first', this).attr('name');
|
||||
var right = attr ? attr.split('_').shift() : false;
|
||||
if(right)
|
||||
$('td.hovered').removeClass('hovered');
|
||||
}
|
||||
);
|
||||
|
||||
if (dialog.data("ui-dialog")) {
|
||||
dialog.html(data).dialog('open');
|
||||
}
|
||||
function user_click_box(event, element, status)
|
||||
{
|
||||
var newclass, newvalue, boxes;
|
||||
|
||||
$('div.switch_time', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
var $element = $(element);
|
||||
|
||||
boxes = $(this).closest('form').find('input.datepicker');
|
||||
|
||||
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var sbas_id = $(this).find('input[name="time_sbas_id"]').val();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/sbas/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
sbas_id:sbas_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#time_dialog');
|
||||
|
||||
dialog.html(data);
|
||||
dialog.dialog('open');
|
||||
|
||||
$('div.switch_time', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
|
||||
boxes = $(this).closest('form').find('input.datepicker');
|
||||
|
||||
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#users_rights_form .quota_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="quota_base_id"]').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/quotas/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#quotas_dialog');
|
||||
|
||||
if (dialog.data("ui-dialog")) {
|
||||
dialog.html(data).dialog('open');
|
||||
if($element.hasClass('right_access'))
|
||||
{
|
||||
var base_id = $element.find('input').attr('name').split('_').pop();
|
||||
boxes = $('div.base_'+base_id+':not(:first)');
|
||||
}
|
||||
|
||||
$('div.switch_quota', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
|
||||
boxes = $(this).closest('form').find('input:text');
|
||||
|
||||
if(($(this).hasClass('mixed')===true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
if((typeof status !== 'undefined' && status == 'checked') || (typeof status === 'undefined' && (($element.hasClass('mixed') === true) || ($element.hasClass('unchecked') === true))))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newvalue = '1';
|
||||
|
||||
if(boxes)
|
||||
boxes.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
newvalue = '0';
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
if(boxes)
|
||||
boxes.hide();
|
||||
}
|
||||
|
||||
$('#users_rights_form .masks_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="masks_base_id"]').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/masks/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
$('#masks_dialog').html(data).dialog('open');
|
||||
|
||||
$('.switch_masks').bind('click', function(){
|
||||
var currentclass, newclass;
|
||||
|
||||
var bit = $(this).find('input[name="bit"]').val();
|
||||
currentclass = 'unchecked';
|
||||
if($(this).hasClass('mixed'))
|
||||
{
|
||||
currentclass = 'mixed';
|
||||
}
|
||||
if($(this).hasClass('checked'))
|
||||
{
|
||||
currentclass = 'checked';
|
||||
}
|
||||
switch(currentclass)
|
||||
{
|
||||
case 'mixed':
|
||||
default:
|
||||
$('.bitnum_'+bit).removeClass('mixed checked unchecked').addClass('checked')
|
||||
break;
|
||||
case 'unchecked':
|
||||
$(this).removeClass('mixed checked unchecked').addClass('checked')
|
||||
break;
|
||||
case 'checked':
|
||||
if($('.checked.bitnum_'+bit).length == 2)
|
||||
{
|
||||
$(this).removeClass('mixed checked unchecked').addClass('unchecked')
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("admin::user:mask: vous devez cocher au moins une case pour chaque status");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var left = $('.bitnum_'+bit+'.bit_left');
|
||||
var right = $('.bitnum_'+bit+'.bit_right');
|
||||
|
||||
var maskform = $('#masks_dialog form');
|
||||
var vand_and = $('input[name="vand_and"]', maskform);
|
||||
var vand_or = $('input[name="vand_or"]', maskform);
|
||||
var vxor_and = $('input[name="vxor_and"]', maskform);
|
||||
var vxor_or = $('input[name="vxor_or"]', maskform);
|
||||
|
||||
var newbit_vand_and = newbit_vand_or = newbit_vxor_and = newbit_vxor_or = 0;
|
||||
|
||||
if( left.length === 1 && right.length === 1 )
|
||||
{
|
||||
if(left.hasClass('checked') && right.hasClass('unchecked') )
|
||||
{
|
||||
newbit_vand_and = "1";
|
||||
newbit_vand_or = "1";
|
||||
}
|
||||
else if( left.hasClass('unchecked') && right.hasClass('checked') )
|
||||
{
|
||||
newbit_vand_and = "1";
|
||||
newbit_vand_or = "1";
|
||||
newbit_vxor_and = "1";
|
||||
newbit_vxor_or = "1";
|
||||
}
|
||||
vand_and.val( vand_and.val().substr(0, 31 - bit) + newbit_vand_and + vand_and.val().substr(31 + 1 - bit) );
|
||||
vand_or.val ( vand_or.val().substr( 0, 31 - bit) + newbit_vand_or + vand_or.val().substr( 31 + 1 - bit) );
|
||||
vxor_and.val( vxor_and.val().substr(0, 31 - bit) + newbit_vxor_and + vxor_and.val().substr(31 + 1 - bit) );
|
||||
vxor_or.val ( vxor_or.val().substr( 0, 31 - bit) + newbit_vxor_or + vxor_and.val().substr(31 + 1 - bit) );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function save_masks()
|
||||
{
|
||||
var cont = $('#masks_dialog');
|
||||
|
||||
var maskform = $('#masks_dialog form');
|
||||
var base_id = $('input[name="base_id"]', maskform).val();
|
||||
var users = $('input[name="users"]', maskform).val();
|
||||
var vand_and = $('input[name="vand_and"]', maskform).val();
|
||||
var vand_or = $('input[name="vand_or"]', maskform).val();
|
||||
var vxor_and = $('input[name="vxor_and"]', maskform).val();
|
||||
var vxor_or = $('input[name="vxor_or"]', maskform).val();
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/masks/apply/',
|
||||
data: {
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
vand_and:vand_and,
|
||||
vand_or:vand_or,
|
||||
vxor_and:vxor_and,
|
||||
vxor_or:vxor_or
|
||||
},
|
||||
success: function(data){
|
||||
$('#masks_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function save_quotas()
|
||||
{
|
||||
var cont = $('#quotas_dialog');
|
||||
var base_id = $('input[name="base_id"]', cont).val();
|
||||
var users = $('input[name="users"]', cont).val();
|
||||
var droits = $('input[name="droits"]', cont).val();
|
||||
var restes = $('input[name="restes"]', cont).val();
|
||||
|
||||
var switch_quota = $('.switch_quota', cont);
|
||||
|
||||
if(switch_quota.hasClass('mixed'))
|
||||
return;
|
||||
|
||||
var quota = 0;
|
||||
|
||||
if(switch_quota.hasClass('checked'))
|
||||
quota = 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/quotas/apply/',
|
||||
data: {
|
||||
act:"APPLYQUOTAS",
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
quota:quota,
|
||||
droits:droits,
|
||||
restes:restes
|
||||
},
|
||||
success: function(data){
|
||||
$('#quotas_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save_time()
|
||||
{
|
||||
var cont = $('#time_dialog');
|
||||
var dmin = $('input[name="dmin"]', cont).val();
|
||||
var dmax = $('input[name="dmax"]', cont).val();
|
||||
var users = $('input[name="users"]', cont).val();
|
||||
var base_id = $('input[name="base_id"]', cont).val();
|
||||
var sbas_id = $('input[name="sbas_id"]', cont).val();
|
||||
|
||||
var switch_time = $('.switch_time', cont);
|
||||
|
||||
if(switch_time.hasClass('mixed'))
|
||||
return;
|
||||
|
||||
var limit = 0;
|
||||
|
||||
if(switch_time.hasClass('checked'))
|
||||
limit = 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/apply/',
|
||||
data: {
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
sbas_id:sbas_id,
|
||||
limit:limit,
|
||||
dmin:dmin,
|
||||
dmax:dmax
|
||||
},
|
||||
success: function(data){
|
||||
$('#time_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check_uncheck_menu(right, sbas_id, el)
|
||||
{
|
||||
var top = el.offset().top ;
|
||||
var left = el.offset().left + 16;
|
||||
$('body').append('<div id="users_check_uncheck" style="position:absolute;top:'+top+'px;left:'+left+'px;">'+
|
||||
'<div class="checker" >'+
|
||||
language.check_all+
|
||||
'<input type="hidden" name="sbas_id" value="'+sbas_id+'"/>'+
|
||||
'<input type="hidden" name="right" value="'+right+'"/>'+
|
||||
'</div>'+
|
||||
'<div class="unchecker">'+
|
||||
language.uncheck_all+
|
||||
'<input type="hidden" name="sbas_id" value="'+sbas_id+'"/>'+
|
||||
'<input type="hidden" name="right" value="'+right+'"/>'+
|
||||
'</div></div>');
|
||||
|
||||
$('#users_check_uncheck div').hover(
|
||||
function(){
|
||||
$(this).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass('hovered');
|
||||
}
|
||||
);
|
||||
$('#users_check_uncheck div.checker').bind('click',function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
users_check(true, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val());
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
$('#users_check_uncheck div.unchecker').bind('click',function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
users_check(false, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val());
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
|
||||
}
|
||||
function users_check(bool, sbas_id, right)
|
||||
{
|
||||
var newclass;
|
||||
if(bool)
|
||||
{
|
||||
newclass="checked";
|
||||
$element.find('input').val(newvalue);
|
||||
$element.removeClass('mixed checked unchecked').addClass(newclass);
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass="unchecked";
|
||||
}
|
||||
$('.inside_sbas_'+sbas_id+'.'+right+':visible').each(function(i,n){
|
||||
user_click_box(null, $(n), newclass);
|
||||
|
||||
$('#users_rights_form div.switch_right').bind('click', function(event){
|
||||
user_click_box(event, $(this));
|
||||
});
|
||||
}
|
||||
$('#right-ajax button.users_rights_valid').bind('click', function(){
|
||||
var datas = {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
values:$('#users_rights_form').serialize(),
|
||||
template:$('#users_rights_form select[name="template"]').val(),
|
||||
user_infos:$('#user_infos_form').serialize()
|
||||
};
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/apply/',
|
||||
dataType:'json',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
if(!data.error)
|
||||
$('a.zone_editusers').trigger('click');
|
||||
else
|
||||
alert(data.message);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#right-ajax .users_rights_cancel').bind('click', function(){
|
||||
var $this = $(this);
|
||||
$('#right-ajax').empty().addClass('loading').parent().show();
|
||||
$('#right').hide();
|
||||
$.get($this.attr('href'), function(data) {
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
var time_buttons = {
|
||||
'Ok':function(){
|
||||
save_time();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#time_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#time_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:time_buttons,
|
||||
modal:true
|
||||
});
|
||||
var quota_buttons = {
|
||||
'Ok':function(){
|
||||
save_quotas();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#quotas_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#quotas_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:quota_buttons,
|
||||
modal:true
|
||||
});
|
||||
|
||||
var masks_buttons = {
|
||||
'Ok':function(){
|
||||
save_masks();
|
||||
},
|
||||
'Cancel':function(){
|
||||
$('#masks_dialog').dialog('close');
|
||||
}
|
||||
};
|
||||
$('#masks_dialog').dialog({
|
||||
resizable:false,
|
||||
autoOpen:false,
|
||||
draggable:false,
|
||||
buttons:masks_buttons,
|
||||
width:900,
|
||||
height:300,
|
||||
modal:true
|
||||
});
|
||||
$('#users_rights_form .time_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="time_base_id"]').val();
|
||||
if ('undefined' !== typeof base_id) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#time_dialog');
|
||||
|
||||
if (dialog.data("ui-dialog")) {
|
||||
dialog.html(data).dialog('open');
|
||||
}
|
||||
|
||||
$('div.switch_time', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
|
||||
boxes = $(this).closest('form').find('input.datepicker');
|
||||
|
||||
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var sbas_id = $(this).find('input[name="time_sbas_id"]').val();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/sbas/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
sbas_id:sbas_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#time_dialog');
|
||||
|
||||
dialog.html(data);
|
||||
dialog.dialog('open');
|
||||
|
||||
$('div.switch_time', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
|
||||
boxes = $(this).closest('form').find('input.datepicker');
|
||||
|
||||
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#users_rights_form .quota_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="quota_base_id"]').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/quotas/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
var dialog = $('#quotas_dialog');
|
||||
|
||||
if (dialog.data("ui-dialog")) {
|
||||
dialog.html(data).dialog('open');
|
||||
}
|
||||
|
||||
$('div.switch_quota', dialog).bind('click', function(event){
|
||||
var newclass, boxes;
|
||||
|
||||
boxes = $(this).closest('form').find('input:text');
|
||||
|
||||
if(($(this).hasClass('mixed')===true) || ($(this).hasClass('unchecked') === true))
|
||||
{
|
||||
newclass = 'checked';
|
||||
boxes.removeAttr('readonly');
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass = 'unchecked';
|
||||
boxes.attr('readonly','readonly');
|
||||
}
|
||||
|
||||
$(this).removeClass('mixed checked unchecked').addClass(newclass);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#users_rights_form .masks_trigger').bind('click', function(){
|
||||
var base_id = $(this).find('input[name="masks_base_id"]').val();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/masks/',
|
||||
data: {
|
||||
users:$('#users_rights_form input[name="users"]').val(),
|
||||
base_id:base_id
|
||||
},
|
||||
success: function(data){
|
||||
$('#masks_dialog').html(data).dialog('open');
|
||||
|
||||
$('.switch_masks').bind('click', function(){
|
||||
var currentclass, newclass;
|
||||
|
||||
var bit = $(this).find('input[name="bit"]').val();
|
||||
currentclass = 'unchecked';
|
||||
if($(this).hasClass('mixed'))
|
||||
{
|
||||
currentclass = 'mixed';
|
||||
}
|
||||
if($(this).hasClass('checked'))
|
||||
{
|
||||
currentclass = 'checked';
|
||||
}
|
||||
switch(currentclass)
|
||||
{
|
||||
case 'mixed':
|
||||
default:
|
||||
$('.bitnum_'+bit).removeClass('mixed checked unchecked').addClass('checked')
|
||||
break;
|
||||
case 'unchecked':
|
||||
$(this).removeClass('mixed checked unchecked').addClass('checked')
|
||||
break;
|
||||
case 'checked':
|
||||
if($('.checked.bitnum_'+bit).length == 2)
|
||||
{
|
||||
$(this).removeClass('mixed checked unchecked').addClass('unchecked')
|
||||
}
|
||||
else
|
||||
{
|
||||
alert("admin::user:mask: vous devez cocher au moins une case pour chaque status");
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
var left = $('.bitnum_'+bit+'.bit_left');
|
||||
var right = $('.bitnum_'+bit+'.bit_right');
|
||||
|
||||
var maskform = $('#masks_dialog form');
|
||||
var vand_and = $('input[name="vand_and"]', maskform);
|
||||
var vand_or = $('input[name="vand_or"]', maskform);
|
||||
var vxor_and = $('input[name="vxor_and"]', maskform);
|
||||
var vxor_or = $('input[name="vxor_or"]', maskform);
|
||||
|
||||
var newbit_vand_and = newbit_vand_or = newbit_vxor_and = newbit_vxor_or = 0;
|
||||
|
||||
if( left.length === 1 && right.length === 1 )
|
||||
{
|
||||
if(left.hasClass('checked') && right.hasClass('unchecked') )
|
||||
{
|
||||
newbit_vand_and = "1";
|
||||
newbit_vand_or = "1";
|
||||
}
|
||||
else if( left.hasClass('unchecked') && right.hasClass('checked') )
|
||||
{
|
||||
newbit_vand_and = "1";
|
||||
newbit_vand_or = "1";
|
||||
newbit_vxor_and = "1";
|
||||
newbit_vxor_or = "1";
|
||||
}
|
||||
vand_and.val( vand_and.val().substr(0, 31 - bit) + newbit_vand_and + vand_and.val().substr(31 + 1 - bit) );
|
||||
vand_or.val ( vand_or.val().substr( 0, 31 - bit) + newbit_vand_or + vand_or.val().substr( 31 + 1 - bit) );
|
||||
vxor_and.val( vxor_and.val().substr(0, 31 - bit) + newbit_vxor_and + vxor_and.val().substr(31 + 1 - bit) );
|
||||
vxor_or.val ( vxor_or.val().substr( 0, 31 - bit) + newbit_vxor_or + vxor_and.val().substr(31 + 1 - bit) );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function save_masks()
|
||||
{
|
||||
var cont = $('#masks_dialog');
|
||||
|
||||
var maskform = $('#masks_dialog form');
|
||||
var base_id = $('input[name="base_id"]', maskform).val();
|
||||
var users = $('input[name="users"]', maskform).val();
|
||||
var vand_and = $('input[name="vand_and"]', maskform).val();
|
||||
var vand_or = $('input[name="vand_or"]', maskform).val();
|
||||
var vxor_and = $('input[name="vxor_and"]', maskform).val();
|
||||
var vxor_or = $('input[name="vxor_or"]', maskform).val();
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/masks/apply/',
|
||||
data: {
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
vand_and:vand_and,
|
||||
vand_or:vand_or,
|
||||
vxor_and:vxor_and,
|
||||
vxor_or:vxor_or
|
||||
},
|
||||
success: function(data){
|
||||
$('#masks_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function save_quotas()
|
||||
{
|
||||
var cont = $('#quotas_dialog');
|
||||
var base_id = $('input[name="base_id"]', cont).val();
|
||||
var users = $('input[name="users"]', cont).val();
|
||||
var droits = $('input[name="droits"]', cont).val();
|
||||
var restes = $('input[name="restes"]', cont).val();
|
||||
|
||||
var switch_quota = $('.switch_quota', cont);
|
||||
|
||||
if(switch_quota.hasClass('mixed'))
|
||||
return;
|
||||
|
||||
var quota = 0;
|
||||
|
||||
if(switch_quota.hasClass('checked'))
|
||||
quota = 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/quotas/apply/',
|
||||
data: {
|
||||
act:"APPLYQUOTAS",
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
quota:quota,
|
||||
droits:droits,
|
||||
restes:restes
|
||||
},
|
||||
success: function(data){
|
||||
$('#quotas_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function save_time()
|
||||
{
|
||||
var cont = $('#time_dialog');
|
||||
var dmin = $('input[name="dmin"]', cont).val();
|
||||
var dmax = $('input[name="dmax"]', cont).val();
|
||||
var users = $('input[name="users"]', cont).val();
|
||||
var base_id = $('input[name="base_id"]', cont).val();
|
||||
var sbas_id = $('input[name="sbas_id"]', cont).val();
|
||||
|
||||
var switch_time = $('.switch_time', cont);
|
||||
|
||||
if(switch_time.hasClass('mixed'))
|
||||
return;
|
||||
|
||||
var limit = 0;
|
||||
|
||||
if(switch_time.hasClass('checked'))
|
||||
limit = 1;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/time/apply/',
|
||||
data: {
|
||||
users:users,
|
||||
base_id:base_id,
|
||||
sbas_id:sbas_id,
|
||||
limit:limit,
|
||||
dmin:dmin,
|
||||
dmax:dmax
|
||||
},
|
||||
success: function(data){
|
||||
$('#time_dialog').dialog('close');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function check_uncheck_menu(right, sbas_id, el)
|
||||
{
|
||||
var top = el.offset().top ;
|
||||
var left = el.offset().left + 16;
|
||||
$('body').append('<div id="users_check_uncheck" style="position:absolute;top:'+top+'px;left:'+left+'px;">'+
|
||||
'<div class="checker" >'+
|
||||
language.check_all+
|
||||
'<input type="hidden" name="sbas_id" value="'+sbas_id+'"/>'+
|
||||
'<input type="hidden" name="right" value="'+right+'"/>'+
|
||||
'</div>'+
|
||||
'<div class="unchecker">'+
|
||||
language.uncheck_all+
|
||||
'<input type="hidden" name="sbas_id" value="'+sbas_id+'"/>'+
|
||||
'<input type="hidden" name="right" value="'+right+'"/>'+
|
||||
'</div></div>');
|
||||
|
||||
$('#users_check_uncheck div').hover(
|
||||
function(){
|
||||
$(this).addClass('hovered');
|
||||
},
|
||||
function(){
|
||||
$(this).removeClass('hovered');
|
||||
}
|
||||
);
|
||||
$('#users_check_uncheck div.checker').bind('click',function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
users_check(true, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val());
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
$('#users_check_uncheck div.unchecker').bind('click',function(event){
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
users_check(false, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val());
|
||||
$('#users_check_uncheck').remove();
|
||||
});
|
||||
|
||||
}
|
||||
function users_check(bool, sbas_id, right)
|
||||
{
|
||||
var newclass;
|
||||
if(bool)
|
||||
{
|
||||
newclass="checked";
|
||||
}
|
||||
else
|
||||
{
|
||||
newclass="unchecked";
|
||||
}
|
||||
$('.inside_sbas_'+sbas_id+'.'+right+':visible').each(function(i,n){
|
||||
user_click_box(null, $(n), newclass);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -6,387 +6,387 @@
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
function users_select_this(n,k)
|
||||
{
|
||||
|
||||
if(p4.users.sel.length >= 800)
|
||||
function users_select_this(n,k)
|
||||
{
|
||||
alert(language.max_record_selected);
|
||||
return false;
|
||||
}
|
||||
p4.users.sel.push(k);
|
||||
$(n).addClass('selected');
|
||||
return true;
|
||||
}
|
||||
|
||||
$('#users th.sortable').live('click', function(){
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
var sort = $('input', $this).val();
|
||||
|
||||
if((sort == $('#users_page_form input[name="srt"]').val())
|
||||
&& ($('#users_page_form input[name="ord"]').val() == 'asc'))
|
||||
{
|
||||
var ord = 'desc';
|
||||
}
|
||||
else
|
||||
{
|
||||
var ord = 'asc';
|
||||
}
|
||||
|
||||
$('#users_page_form input[name="srt"]').val(sort);
|
||||
$('#users_page_form input[name="ord"]').val(ord);
|
||||
|
||||
$('#users_page_form').trigger('submit');
|
||||
}).live('mouseover', function(){$(this).addClass('hover');})
|
||||
.live('mouseout', function(){$(this).removeClass('hover');});
|
||||
|
||||
var buttons = {};
|
||||
buttons[language.create_user] = function(){
|
||||
check_new_user(false);
|
||||
};
|
||||
buttons[language.annuler] = function(){
|
||||
$('#user_add_dialog').dialog('close')
|
||||
};
|
||||
|
||||
$('#user_add_dialog').dialog({
|
||||
buttons:buttons,
|
||||
modal:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:500
|
||||
|
||||
}).dialog('close');
|
||||
|
||||
var buttons = {};
|
||||
buttons[language.create_template] = function(){
|
||||
check_new_user(true);
|
||||
};
|
||||
buttons[language.annuler] = function(){
|
||||
$('#template_add_dialog').dialog('close');
|
||||
};
|
||||
|
||||
$('#template_add_dialog').dialog({
|
||||
buttons:buttons,
|
||||
modal:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:500
|
||||
|
||||
}).dialog('close');
|
||||
|
||||
|
||||
function check_new_user(is_template)
|
||||
{
|
||||
var container = is_template ? $('#template_add_dialog') : $('#user_add_dialog');
|
||||
$('#new_user_loader').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/create/',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
act:'CREATENEWUSER',
|
||||
value:$('input[name="value"]', container).val(),
|
||||
send_credentials: $('input[name="send_credentials"]', container).is(':checked') ? 1 : 0,
|
||||
validate_mail: $('input[name="validate_mail"]', container).is(':checked') ? 1 : 0,
|
||||
template:is_template ? '1':'0'
|
||||
},
|
||||
success: function(data){
|
||||
$('.new_user_loader', container).hide();
|
||||
if(!data.error)
|
||||
if(p4.users.sel.length >= 800)
|
||||
{
|
||||
if (container.data("ui-dialog")) {
|
||||
container.dialog('close');
|
||||
}
|
||||
$('input[name="value"]', container).val('');
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
alert(language.max_record_selected);
|
||||
return false;
|
||||
}
|
||||
p4.users.sel.push(k);
|
||||
$(n).addClass('selected');
|
||||
return true;
|
||||
}
|
||||
|
||||
$('#users th.sortable').live('click', function(){
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
var sort = $('input', $this).val();
|
||||
|
||||
if((sort == $('#users_page_form input[name="srt"]').val())
|
||||
&& ($('#users_page_form input[name="ord"]').val() == 'asc'))
|
||||
{
|
||||
var ord = 'desc';
|
||||
}
|
||||
else
|
||||
{
|
||||
var ord = 'asc';
|
||||
}
|
||||
|
||||
$('#users_page_form input[name="srt"]').val(sort);
|
||||
$('#users_page_form input[name="ord"]').val(ord);
|
||||
|
||||
$('#users_page_form').trigger('submit');
|
||||
}).live('mouseover', function(){$(this).addClass('hover');})
|
||||
.live('mouseout', function(){$(this).removeClass('hover');});
|
||||
|
||||
var buttons = {};
|
||||
buttons[language.create_user] = function(){
|
||||
check_new_user(false);
|
||||
};
|
||||
buttons[language.annuler] = function(){
|
||||
$('#user_add_dialog').dialog('close')
|
||||
};
|
||||
|
||||
$('#user_add_dialog').dialog({
|
||||
buttons:buttons,
|
||||
modal:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:500
|
||||
|
||||
}).dialog('close');
|
||||
|
||||
var buttons = {};
|
||||
buttons[language.create_template] = function(){
|
||||
check_new_user(true);
|
||||
};
|
||||
buttons[language.annuler] = function(){
|
||||
$('#template_add_dialog').dialog('close');
|
||||
};
|
||||
|
||||
$('#template_add_dialog').dialog({
|
||||
buttons:buttons,
|
||||
modal:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
width:500
|
||||
|
||||
}).dialog('close');
|
||||
|
||||
|
||||
function check_new_user(is_template)
|
||||
{
|
||||
var container = is_template ? $('#template_add_dialog') : $('#user_add_dialog');
|
||||
$('#new_user_loader').show();
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/create/',
|
||||
dataType : 'json',
|
||||
data: {
|
||||
act:'CREATENEWUSER',
|
||||
value:$('input[name="value"]', container).val(),
|
||||
send_credentials: $('input[name="send_credentials"]', container).is(':checked') ? 1 : 0,
|
||||
validate_mail: $('input[name="validate_mail"]', container).is(':checked') ? 1 : 0,
|
||||
template:is_template ? '1':'0'
|
||||
},
|
||||
success: function(data){
|
||||
$('.new_user_loader', container).hide();
|
||||
if(!data.error)
|
||||
{
|
||||
if (container.data("ui-dialog")) {
|
||||
container.dialog('close');
|
||||
}
|
||||
$('input[name="value"]', container).val('');
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/',
|
||||
data: {
|
||||
users : data.data
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(data.message);
|
||||
}
|
||||
|
||||
},
|
||||
error:function()
|
||||
{
|
||||
alert(language.serverError);
|
||||
},
|
||||
timeout:function()
|
||||
{
|
||||
alert(language.serverTimeout);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('#users_page .user_adder').live('click', function(){
|
||||
if ($('#user_add_dialog').data("ui-dialog")) {
|
||||
$('#user_add_dialog').dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
$('#users_page .template_adder').live('click', function(){
|
||||
if ($('#template_add_dialog').data("ui-dialog")) {
|
||||
$('#template_add_dialog').dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
$('#users_page_form').live('submit', function(){
|
||||
var datas = $('#users_page_form').serializeArray();
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/search/',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').empty().html(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_search').live('submit', function(){
|
||||
var datas = $('#users_page_search').serializeArray();
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/search/',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').empty().html(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_form .pager').live('click', function(){
|
||||
var form = $('#users_page_form');
|
||||
|
||||
var current_page = parseInt($('input[name="page"]', form).val());
|
||||
var perPage = parseInt($('select[name="per_page"]', form).val());
|
||||
current_page = isNaN(current_page) ? 1 : current_page;
|
||||
|
||||
var offset_start = 0;
|
||||
|
||||
if($(this).hasClass('prev'))
|
||||
{
|
||||
offset_start = (current_page-2) * perPage;
|
||||
}
|
||||
if($(this).hasClass('first'))
|
||||
{
|
||||
offset_start = 0;
|
||||
}
|
||||
if($(this).hasClass('next'))
|
||||
{
|
||||
offset_start = current_page * perPage;
|
||||
}
|
||||
if($(this).hasClass('last'))
|
||||
{
|
||||
offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage))* perPage;
|
||||
}
|
||||
|
||||
$('input[name="offset_start"]', form).val(offset_start);
|
||||
});
|
||||
|
||||
$('#users tbody tr, #users tbody td').live('dblclick', function(evt){
|
||||
$('#users_page_form .user_modifier').trigger('click');
|
||||
});
|
||||
|
||||
$('#users tbody tr, #users tbody td').live('click', function(evt){
|
||||
if(evt.stopPropagation)
|
||||
evt.stopPropagation();
|
||||
evt.cancelBubble = true;
|
||||
evt.preventDefault();
|
||||
var el = $(this).closest('tr');
|
||||
var cont = $('#users');
|
||||
|
||||
var k = el.attr('id').split('_').pop();
|
||||
|
||||
if(is_shift_key(evt) && $('tr.last_selected', cont).length!=0)
|
||||
{
|
||||
var lst = $('tr', cont);
|
||||
var index1 = $.inArray($('tr.last_selected', cont)[0],lst);
|
||||
var index2 = $.inArray($(el)[0],lst);
|
||||
if(index2<index1)
|
||||
{
|
||||
var tmp = index1;
|
||||
index1=(index2-1)<0?index2:(index2-1);
|
||||
index2=tmp;
|
||||
}
|
||||
|
||||
var stopped = false;
|
||||
if(index2 != -1 && index1 != -1)
|
||||
{
|
||||
var exp = 'tr:gt('+index1+'):lt('+(index2-index1)+')';
|
||||
$.each($(exp, cont),function(i,n){
|
||||
|
||||
if(!$(n).hasClass('selected'))
|
||||
{
|
||||
|
||||
if(!users_select_this(n,$(n).attr('id').split('_').pop()))
|
||||
{
|
||||
stopped = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(!stopped && $.inArray(k,p4.users.sel)<0)
|
||||
{
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_ctrl_key(evt))
|
||||
{
|
||||
if($.inArray(k,p4.users.sel)<0)
|
||||
{
|
||||
p4.users.sel = new Array();
|
||||
$('tr', cont).removeClass('selected');
|
||||
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($.inArray(k,p4.users.sel)>=0)
|
||||
{
|
||||
p4.users.sel = $.grep(p4.users.sel,function(n){
|
||||
return(n!=k);
|
||||
});
|
||||
$(el).removeClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$('.last_selected', cont).removeClass('last_selected');
|
||||
$(el).addClass('last_selected');
|
||||
}).live('mousedown', function(evt){
|
||||
|
||||
if(evt.stopPropagation)
|
||||
evt.stopPropagation();
|
||||
evt.cancelBubble = true;
|
||||
evt.preventDefault();
|
||||
});
|
||||
|
||||
$('#users_apply_template').live('submit', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var $this = $(this);
|
||||
var template = $('select[name="template_chooser"]', $this).val();
|
||||
|
||||
if(template === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
|
||||
$.ajax({
|
||||
type: $this.attr('method'),
|
||||
url: $this.attr('action'),
|
||||
data: {
|
||||
users : users,
|
||||
template : template
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_form .user_modifier').live('click', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/',
|
||||
data: {
|
||||
users : data.data
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(data.message);
|
||||
}
|
||||
|
||||
},
|
||||
error:function()
|
||||
{
|
||||
alert(language.serverError);
|
||||
},
|
||||
timeout:function()
|
||||
{
|
||||
alert(language.serverTimeout);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
$('#users_page .user_adder').live('click', function(){
|
||||
if ($('#user_add_dialog').data("ui-dialog")) {
|
||||
$('#user_add_dialog').dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
$('#users_page .template_adder').live('click', function(){
|
||||
if ($('#template_add_dialog').data("ui-dialog")) {
|
||||
$('#template_add_dialog').dialog('open');
|
||||
}
|
||||
});
|
||||
|
||||
$('#users_page_form').live('submit', function(){
|
||||
var datas = $('#users_page_form').serializeArray();
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/search/',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').empty().html(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_search').live('submit', function(){
|
||||
var datas = $('#users_page_search').serializeArray();
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/search/',
|
||||
data: datas,
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').empty().html(data);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_form .pager').live('click', function(){
|
||||
var form = $('#users_page_form');
|
||||
|
||||
var current_page = parseInt($('input[name="page"]', form).val());
|
||||
var perPage = parseInt($('select[name="per_page"]', form).val());
|
||||
current_page = isNaN(current_page) ? 1 : current_page;
|
||||
|
||||
var offset_start = 0;
|
||||
|
||||
if($(this).hasClass('prev'))
|
||||
{
|
||||
offset_start = (current_page-2) * perPage;
|
||||
}
|
||||
if($(this).hasClass('first'))
|
||||
{
|
||||
offset_start = 0;
|
||||
}
|
||||
if($(this).hasClass('next'))
|
||||
{
|
||||
offset_start = current_page * perPage;
|
||||
}
|
||||
if($(this).hasClass('last'))
|
||||
{
|
||||
offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage))* perPage;
|
||||
}
|
||||
|
||||
$('input[name="offset_start"]', form).val(offset_start);
|
||||
});
|
||||
|
||||
$('#users tbody tr, #users tbody td').live('dblclick', function(evt){
|
||||
$('#users_page_form .user_modifier').trigger('click');
|
||||
});
|
||||
|
||||
$('#users tbody tr, #users tbody td').live('click', function(evt){
|
||||
if(evt.stopPropagation)
|
||||
evt.stopPropagation();
|
||||
evt.cancelBubble = true;
|
||||
evt.preventDefault();
|
||||
var el = $(this).closest('tr');
|
||||
var cont = $('#users');
|
||||
|
||||
var k = el.attr('id').split('_').pop();
|
||||
|
||||
if(is_shift_key(evt) && $('tr.last_selected', cont).length!=0)
|
||||
{
|
||||
var lst = $('tr', cont);
|
||||
var index1 = $.inArray($('tr.last_selected', cont)[0],lst);
|
||||
var index2 = $.inArray($(el)[0],lst);
|
||||
if(index2<index1)
|
||||
{
|
||||
var tmp = index1;
|
||||
index1=(index2-1)<0?index2:(index2-1);
|
||||
index2=tmp;
|
||||
}
|
||||
|
||||
var stopped = false;
|
||||
if(index2 != -1 && index1 != -1)
|
||||
{
|
||||
var exp = 'tr:gt('+index1+'):lt('+(index2-index1)+')';
|
||||
$.each($(exp, cont),function(i,n){
|
||||
|
||||
if(!$(n).hasClass('selected'))
|
||||
{
|
||||
|
||||
if(!users_select_this(n,$(n).attr('id').split('_').pop()))
|
||||
{
|
||||
stopped = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if(!stopped && $.inArray(k,p4.users.sel)<0)
|
||||
{
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!is_ctrl_key(evt))
|
||||
{
|
||||
if($.inArray(k,p4.users.sel)<0)
|
||||
|
||||
$('#users_page_form .user_deleter').live('click', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
p4.users.sel = new Array();
|
||||
$('tr', cont).removeClass('selected');
|
||||
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($.inArray(k,p4.users.sel)>=0)
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/delete/',
|
||||
data: {
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('#users_page .invite_modifier, #users_page .autoregister_modifier').live('click', function(){
|
||||
var users = $(this).next('input').val();
|
||||
|
||||
if($.trim(users) === '')
|
||||
{
|
||||
p4.users.sel = $.grep(p4.users.sel,function(n){
|
||||
return(n!=k);
|
||||
});
|
||||
$(el).removeClass('selected');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!users_select_this(el,k))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$('.last_selected', cont).removeClass('last_selected');
|
||||
$(el).addClass('last_selected');
|
||||
}).live('mousedown', function(evt){
|
||||
|
||||
if(evt.stopPropagation)
|
||||
evt.stopPropagation();
|
||||
evt.cancelBubble = true;
|
||||
evt.preventDefault();
|
||||
});
|
||||
|
||||
$('#users_apply_template').live('submit', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var $this = $(this);
|
||||
var template = $('select[name="template_chooser"]', $this).val();
|
||||
|
||||
if(template === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
|
||||
$.ajax({
|
||||
type: $this.attr('method'),
|
||||
url: $this.attr('action'),
|
||||
data: {
|
||||
users : users,
|
||||
template : template
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/',
|
||||
data: {
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#users_page_form .user_modifier').live('click', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/',
|
||||
data: {
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$('#users_page_form .user_deleter').live('click', function(){
|
||||
var users = p4.users.sel.join(';');
|
||||
if(users === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/delete/',
|
||||
data: {
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
$('#users_page .invite_modifier, #users_page .autoregister_modifier').live('click', function(){
|
||||
var users = $(this).next('input').val();
|
||||
|
||||
if($.trim(users) === '')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$('#right-ajax').empty().addClass('loading');
|
||||
p4.users.sel = [];
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../admin/users/rights/',
|
||||
data: {
|
||||
users : users
|
||||
},
|
||||
success: function(data){
|
||||
$('#right-ajax').removeClass('loading').html(data);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
})
|
||||
})
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,127 +1,127 @@
|
||||
$(document).ready(function(){
|
||||
if(typeof validator_loaded === 'boolean')
|
||||
return;
|
||||
if(typeof validator_loaded === 'boolean')
|
||||
return;
|
||||
|
||||
|
||||
|
||||
$('.confirm_report').live('click',function(){
|
||||
var $this = $(this);
|
||||
$('.confirm_report').live('click',function(){
|
||||
var $this = $(this);
|
||||
|
||||
$('.loader', $this).css({
|
||||
visibility:'visible'
|
||||
$('.loader', $this).css({
|
||||
visibility:'visible'
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_RELEASE/" + $('#basket_validation_id').val() + "/",
|
||||
dataType: 'json',
|
||||
error: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
},
|
||||
timeout: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
},
|
||||
success: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
if (data.datas) {
|
||||
alert(data.datas);
|
||||
}
|
||||
if (!data.error) {
|
||||
releasable = false;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_RELEASE/" + $('#basket_validation_id').val() + "/",
|
||||
dataType: 'json',
|
||||
error: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
},
|
||||
timeout: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
},
|
||||
success: function(data) {
|
||||
$('.loader', $this).css({
|
||||
visibility: 'hidden'
|
||||
});
|
||||
if (data.datas) {
|
||||
alert(data.datas);
|
||||
}
|
||||
if (!data.error) {
|
||||
releasable = false;
|
||||
}
|
||||
$('.agreement_radio').live('vmousedown', function(){
|
||||
var sselcont_id = $(this).attr('for').split('_').pop();
|
||||
var agreement = $('#' + $(this).attr('for')).val() == 'yes' ? '1' : '-1';
|
||||
|
||||
$.mobile.loading();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
agreement : agreement
|
||||
},
|
||||
error: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
timeout: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
success: function(datas){
|
||||
if(!datas.error)
|
||||
{
|
||||
if(agreement == '1')
|
||||
$('.valid_choice_'+sselcont_id).removeClass('disagree').addClass('agree');
|
||||
else
|
||||
$('.valid_choice_'+sselcont_id).removeClass('agree').addClass('disagree');
|
||||
$.mobile.loading();
|
||||
if(datas.error)
|
||||
{
|
||||
alert(datas.datas);
|
||||
return;
|
||||
}
|
||||
|
||||
releasable = datas.release;
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(datas.datas);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
||||
$('.note_area_validate').live('click', function(){
|
||||
var sselcont_id = $(this).closest('form').find('input[name="sselcont_id"]').val();
|
||||
|
||||
$.mobile.loading();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_NOTE/"+sselcont_id+"/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
note : $('#note_form_'+sselcont_id).find('textarea').val()
|
||||
},
|
||||
error: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
timeout: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
success: function(datas){
|
||||
$.mobile.loading();
|
||||
if(datas.error)
|
||||
{
|
||||
alert(datas.datas);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#notes_'+sselcont_id).empty().append(datas.datas);
|
||||
window.history.back();
|
||||
return;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
validator_loaded = true;
|
||||
});
|
||||
|
||||
$('.agreement_radio').live('vmousedown', function(){
|
||||
var sselcont_id = $(this).attr('for').split('_').pop();
|
||||
var agreement = $('#' + $(this).attr('for')).val() == 'yes' ? '1' : '-1';
|
||||
|
||||
$.mobile.loading();
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
agreement : agreement
|
||||
},
|
||||
error: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
timeout: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
success: function(datas){
|
||||
if(!datas.error)
|
||||
{
|
||||
if(agreement == '1')
|
||||
$('.valid_choice_'+sselcont_id).removeClass('disagree').addClass('agree');
|
||||
else
|
||||
$('.valid_choice_'+sselcont_id).removeClass('agree').addClass('disagree');
|
||||
$.mobile.loading();
|
||||
if(datas.error)
|
||||
{
|
||||
alert(datas.datas);
|
||||
return;
|
||||
}
|
||||
|
||||
releasable = datas.release;
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(datas.datas);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
|
||||
});
|
||||
$('.note_area_validate').live('click', function(){
|
||||
var sselcont_id = $(this).closest('form').find('input[name="sselcont_id"]').val();
|
||||
|
||||
$.mobile.loading();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/lightbox/ajax/SET_NOTE/"+sselcont_id+"/",
|
||||
dataType: 'json',
|
||||
data: {
|
||||
note : $('#note_form_'+sselcont_id).find('textarea').val()
|
||||
},
|
||||
error: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
timeout: function(datas){
|
||||
alert('error');
|
||||
$.mobile.loading();
|
||||
},
|
||||
success: function(datas){
|
||||
$.mobile.loading();
|
||||
if(datas.error)
|
||||
{
|
||||
alert(datas.datas);
|
||||
return;
|
||||
}
|
||||
|
||||
$('#notes_'+sselcont_id).empty().append(datas.datas);
|
||||
window.history.back();
|
||||
return;
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
validator_loaded = true;
|
||||
});
|
@@ -1,245 +1,245 @@
|
||||
;
|
||||
(function(document){
|
||||
|
||||
/*****************
|
||||
* Canva Object
|
||||
*****************/
|
||||
var Canva = function(domCanva){
|
||||
this.domCanva = domCanva;
|
||||
};
|
||||
|
||||
Canva.prototype = {
|
||||
resize : function(elementDomNode){
|
||||
var w = elementDomNode.getWidth();
|
||||
var maxH = elementDomNode.getHeight();
|
||||
|
||||
if ('' !== elementDomNode.getAspectRatio()) {
|
||||
var ratio = parseFloat(elementDomNode.getAspectRatio());
|
||||
|
||||
var h = Math.round(w * (1 / ratio));
|
||||
|
||||
if (h > maxH) {
|
||||
var h = maxH;
|
||||
var w = Math.round(h * ratio);
|
||||
}
|
||||
} else {
|
||||
var h = maxH;
|
||||
}
|
||||
|
||||
this.domCanva.setAttribute("width", w);
|
||||
this.domCanva.setAttribute("height", h);
|
||||
|
||||
return this;
|
||||
},
|
||||
getContext2d : function(){
|
||||
|
||||
if (undefined === this.domCanva.getContext)
|
||||
{
|
||||
return G_vmlCanvasManager
|
||||
.initElement(this.domCanva)
|
||||
.getContext("2d");
|
||||
}
|
||||
|
||||
return this.domCanva.getContext('2d');
|
||||
},
|
||||
extractImage : function(){
|
||||
return this.domCanva.toDataURL("image/png");
|
||||
},
|
||||
reset : function(){
|
||||
var context = this.getContext2d();
|
||||
var w = this.getWidth();
|
||||
var h = this.getHeight();
|
||||
|
||||
context.save();
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
context.clearRect(0, 0, w, h);
|
||||
context.restore();
|
||||
|
||||
return this;
|
||||
},
|
||||
copy : function(elementDomNode){
|
||||
var context = this.getContext2d();
|
||||
|
||||
context.drawImage(
|
||||
elementDomNode.getDomElement()
|
||||
, 0
|
||||
, 0
|
||||
, this.getWidth()
|
||||
, this.getHeight()
|
||||
);
|
||||
|
||||
return this;
|
||||
},
|
||||
getDomElement : function(){
|
||||
return this.domCanva;
|
||||
},
|
||||
getHeight : function(){
|
||||
return this.domCanva.offsetHeight;
|
||||
},
|
||||
getWidth : function(){
|
||||
return this.domCanva.offsetWidth;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/******************
|
||||
* Image Object
|
||||
******************/
|
||||
var Image = function(domElement){
|
||||
this.domElement = domElement;
|
||||
};
|
||||
|
||||
Image.prototype = {
|
||||
getDomElement : function(){
|
||||
return this.domElement;
|
||||
},
|
||||
getHeight : function(){
|
||||
return this.domElement.offsetHeight;
|
||||
},
|
||||
getWidth : function(){
|
||||
return this.domElement.offsetWidth;
|
||||
}
|
||||
};
|
||||
|
||||
/******************
|
||||
* Video Object inherits from Image object
|
||||
******************/
|
||||
|
||||
var Video = function(domElement){
|
||||
Image.call(this, domElement);
|
||||
this.aspectRatio = domElement.getAttribute('data-ratio');
|
||||
};
|
||||
|
||||
Video.prototype = new Image();
|
||||
Video.prototype.constructor = Video;
|
||||
Video.prototype.getCurrentTime = function(){
|
||||
return Math.floor(this.domElement.currentTime);
|
||||
};
|
||||
Video.prototype.getAspectRatio = function(){
|
||||
return this.aspectRatio;
|
||||
};
|
||||
|
||||
/******************
|
||||
* Cache Object
|
||||
******************/
|
||||
var Store = function(){
|
||||
this.datas = {};
|
||||
};
|
||||
|
||||
Store.prototype = {
|
||||
set : function(id, item){
|
||||
this.datas[id] = item;
|
||||
return this;
|
||||
},
|
||||
get : function(id){
|
||||
if(!this.datas[id]){
|
||||
throw 'Unknown ID';
|
||||
}
|
||||
return this.datas[id];
|
||||
},
|
||||
remove : function(id) {
|
||||
delete this.datas[id];
|
||||
},
|
||||
getLength : function(){
|
||||
var count = 0;
|
||||
for (var k in this.datas){
|
||||
if (this.datas.hasOwnProperty(k)){
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
/******************
|
||||
* Screenshot Object
|
||||
******************/
|
||||
var ScreenShot = function(id, canva, video){
|
||||
|
||||
var date = new Date();
|
||||
|
||||
canva.resize(video);
|
||||
canva.copy(video);
|
||||
|
||||
this.id = id;
|
||||
this.timestamp = date.getTime();
|
||||
this.dataURI = canva.extractImage();
|
||||
this.videoTime = video.getCurrentTime();
|
||||
};
|
||||
|
||||
ScreenShot.prototype = {
|
||||
getId:function(){
|
||||
return this.id;
|
||||
},
|
||||
getDataURI: function(){
|
||||
return this.dataURI;
|
||||
},
|
||||
getTimeStamp: function(){
|
||||
return this.timestamp;
|
||||
},
|
||||
getVideoTime : function(){
|
||||
return this.videoTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* THUMB EDITOR
|
||||
*/
|
||||
var ThumbEditor = function(videoId, canvaId){
|
||||
|
||||
var domElement = document.getElementById(videoId);
|
||||
|
||||
if (null !== domElement) {
|
||||
var editorVideo = new Video(domElement);
|
||||
}
|
||||
var store = new Store();
|
||||
|
||||
function getCanva(){
|
||||
return document.getElementById(canvaId);
|
||||
}
|
||||
|
||||
return {
|
||||
isSupported : function () {
|
||||
var elem = document.createElement('canvas');
|
||||
|
||||
return !! document.getElementById(videoId) && document.getElementById(canvaId)
|
||||
&& !! elem.getContext && !! elem.getContext('2d');
|
||||
},
|
||||
screenshot : function(){
|
||||
var screenshot = new ScreenShot(
|
||||
store.getLength() + 1,
|
||||
new Canva(getCanva()),
|
||||
editorVideo
|
||||
);
|
||||
|
||||
store.set(screenshot.getId(), screenshot);
|
||||
|
||||
return screenshot;
|
||||
},
|
||||
store : store,
|
||||
copy: function(elementDomNode){
|
||||
var element = new Image(elementDomNode);
|
||||
var editorCanva = new Canva(getCanva());
|
||||
editorCanva
|
||||
.reset()
|
||||
.resize(editorVideo)
|
||||
.copy(element);
|
||||
},
|
||||
getCanvaImage : function(){
|
||||
var canva = new Canva(getCanva());
|
||||
return canva.extractImage();
|
||||
},
|
||||
resetCanva : function(){
|
||||
var editorCanva = new Canva(getCanva());
|
||||
editorCanva.reset();
|
||||
},
|
||||
getNbScreenshot : function(){
|
||||
return store.getLength();
|
||||
}
|
||||
/*****************
|
||||
* Canva Object
|
||||
*****************/
|
||||
var Canva = function(domCanva){
|
||||
this.domCanva = domCanva;
|
||||
};
|
||||
};
|
||||
|
||||
document.THUMB_EDITOR = ThumbEditor;
|
||||
Canva.prototype = {
|
||||
resize : function(elementDomNode){
|
||||
var w = elementDomNode.getWidth();
|
||||
var maxH = elementDomNode.getHeight();
|
||||
|
||||
if ('' !== elementDomNode.getAspectRatio()) {
|
||||
var ratio = parseFloat(elementDomNode.getAspectRatio());
|
||||
|
||||
var h = Math.round(w * (1 / ratio));
|
||||
|
||||
if (h > maxH) {
|
||||
var h = maxH;
|
||||
var w = Math.round(h * ratio);
|
||||
}
|
||||
} else {
|
||||
var h = maxH;
|
||||
}
|
||||
|
||||
this.domCanva.setAttribute("width", w);
|
||||
this.domCanva.setAttribute("height", h);
|
||||
|
||||
return this;
|
||||
},
|
||||
getContext2d : function(){
|
||||
|
||||
if (undefined === this.domCanva.getContext)
|
||||
{
|
||||
return G_vmlCanvasManager
|
||||
.initElement(this.domCanva)
|
||||
.getContext("2d");
|
||||
}
|
||||
|
||||
return this.domCanva.getContext('2d');
|
||||
},
|
||||
extractImage : function(){
|
||||
return this.domCanva.toDataURL("image/png");
|
||||
},
|
||||
reset : function(){
|
||||
var context = this.getContext2d();
|
||||
var w = this.getWidth();
|
||||
var h = this.getHeight();
|
||||
|
||||
context.save();
|
||||
context.setTransform(1, 0, 0, 1, 0, 0);
|
||||
context.clearRect(0, 0, w, h);
|
||||
context.restore();
|
||||
|
||||
return this;
|
||||
},
|
||||
copy : function(elementDomNode){
|
||||
var context = this.getContext2d();
|
||||
|
||||
context.drawImage(
|
||||
elementDomNode.getDomElement()
|
||||
, 0
|
||||
, 0
|
||||
, this.getWidth()
|
||||
, this.getHeight()
|
||||
);
|
||||
|
||||
return this;
|
||||
},
|
||||
getDomElement : function(){
|
||||
return this.domCanva;
|
||||
},
|
||||
getHeight : function(){
|
||||
return this.domCanva.offsetHeight;
|
||||
},
|
||||
getWidth : function(){
|
||||
return this.domCanva.offsetWidth;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/******************
|
||||
* Image Object
|
||||
******************/
|
||||
var Image = function(domElement){
|
||||
this.domElement = domElement;
|
||||
};
|
||||
|
||||
Image.prototype = {
|
||||
getDomElement : function(){
|
||||
return this.domElement;
|
||||
},
|
||||
getHeight : function(){
|
||||
return this.domElement.offsetHeight;
|
||||
},
|
||||
getWidth : function(){
|
||||
return this.domElement.offsetWidth;
|
||||
}
|
||||
};
|
||||
|
||||
/******************
|
||||
* Video Object inherits from Image object
|
||||
******************/
|
||||
|
||||
var Video = function(domElement){
|
||||
Image.call(this, domElement);
|
||||
this.aspectRatio = domElement.getAttribute('data-ratio');
|
||||
};
|
||||
|
||||
Video.prototype = new Image();
|
||||
Video.prototype.constructor = Video;
|
||||
Video.prototype.getCurrentTime = function(){
|
||||
return Math.floor(this.domElement.currentTime);
|
||||
};
|
||||
Video.prototype.getAspectRatio = function(){
|
||||
return this.aspectRatio;
|
||||
};
|
||||
|
||||
/******************
|
||||
* Cache Object
|
||||
******************/
|
||||
var Store = function(){
|
||||
this.datas = {};
|
||||
};
|
||||
|
||||
Store.prototype = {
|
||||
set : function(id, item){
|
||||
this.datas[id] = item;
|
||||
return this;
|
||||
},
|
||||
get : function(id){
|
||||
if(!this.datas[id]){
|
||||
throw 'Unknown ID';
|
||||
}
|
||||
return this.datas[id];
|
||||
},
|
||||
remove : function(id) {
|
||||
delete this.datas[id];
|
||||
},
|
||||
getLength : function(){
|
||||
var count = 0;
|
||||
for (var k in this.datas){
|
||||
if (this.datas.hasOwnProperty(k)){
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
/******************
|
||||
* Screenshot Object
|
||||
******************/
|
||||
var ScreenShot = function(id, canva, video){
|
||||
|
||||
var date = new Date();
|
||||
|
||||
canva.resize(video);
|
||||
canva.copy(video);
|
||||
|
||||
this.id = id;
|
||||
this.timestamp = date.getTime();
|
||||
this.dataURI = canva.extractImage();
|
||||
this.videoTime = video.getCurrentTime();
|
||||
};
|
||||
|
||||
ScreenShot.prototype = {
|
||||
getId:function(){
|
||||
return this.id;
|
||||
},
|
||||
getDataURI: function(){
|
||||
return this.dataURI;
|
||||
},
|
||||
getTimeStamp: function(){
|
||||
return this.timestamp;
|
||||
},
|
||||
getVideoTime : function(){
|
||||
return this.videoTime;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* THUMB EDITOR
|
||||
*/
|
||||
var ThumbEditor = function(videoId, canvaId){
|
||||
|
||||
var domElement = document.getElementById(videoId);
|
||||
|
||||
if (null !== domElement) {
|
||||
var editorVideo = new Video(domElement);
|
||||
}
|
||||
var store = new Store();
|
||||
|
||||
function getCanva(){
|
||||
return document.getElementById(canvaId);
|
||||
}
|
||||
|
||||
return {
|
||||
isSupported : function () {
|
||||
var elem = document.createElement('canvas');
|
||||
|
||||
return !! document.getElementById(videoId) && document.getElementById(canvaId)
|
||||
&& !! elem.getContext && !! elem.getContext('2d');
|
||||
},
|
||||
screenshot : function(){
|
||||
var screenshot = new ScreenShot(
|
||||
store.getLength() + 1,
|
||||
new Canva(getCanva()),
|
||||
editorVideo
|
||||
);
|
||||
|
||||
store.set(screenshot.getId(), screenshot);
|
||||
|
||||
return screenshot;
|
||||
},
|
||||
store : store,
|
||||
copy: function(elementDomNode){
|
||||
var element = new Image(elementDomNode);
|
||||
var editorCanva = new Canva(getCanva());
|
||||
editorCanva
|
||||
.reset()
|
||||
.resize(editorVideo)
|
||||
.copy(element);
|
||||
},
|
||||
getCanvaImage : function(){
|
||||
var canva = new Canva(getCanva());
|
||||
return canva.extractImage();
|
||||
},
|
||||
resetCanva : function(){
|
||||
var editorCanva = new Canva(getCanva());
|
||||
editorCanva.reset();
|
||||
},
|
||||
getNbScreenshot : function(){
|
||||
return store.getLength();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
document.THUMB_EDITOR = ThumbEditor;
|
||||
|
||||
})(document);
|
||||
|
||||
|
@@ -2,63 +2,63 @@ var p4 = p4 || {};
|
||||
|
||||
(function(p4){
|
||||
|
||||
function create_dialog()
|
||||
{
|
||||
if($('#p4_alerts').length === 0)
|
||||
function create_dialog()
|
||||
{
|
||||
$('body').append('<div id="p4_alerts"></div>');
|
||||
if($('#p4_alerts').length === 0)
|
||||
{
|
||||
$('body').append('<div id="p4_alerts"></div>');
|
||||
}
|
||||
|
||||
return $('#p4_alerts');
|
||||
}
|
||||
|
||||
return $('#p4_alerts');
|
||||
}
|
||||
|
||||
function alert(title, message, callback)
|
||||
{
|
||||
var dialog = create_dialog();
|
||||
|
||||
var button = new Object();
|
||||
|
||||
button['Ok'] = function(){
|
||||
if(typeof callback === 'function')
|
||||
callback();
|
||||
else
|
||||
dialog.dialog('close');
|
||||
};
|
||||
|
||||
if (dialog.data('ui-dialog')) {
|
||||
dialog.dialog('destroy');
|
||||
}
|
||||
|
||||
dialog.attr('title',title)
|
||||
.empty()
|
||||
.append(message)
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
buttons : button,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
dialog.bind( "dialogclose", function(event, ui) {callback();});
|
||||
}
|
||||
else
|
||||
function alert(title, message, callback)
|
||||
{
|
||||
var dialog = create_dialog();
|
||||
|
||||
var button = new Object();
|
||||
|
||||
button['Ok'] = function(){
|
||||
if(typeof callback === 'function')
|
||||
callback();
|
||||
else
|
||||
dialog.dialog('close');
|
||||
};
|
||||
|
||||
if (dialog.data('ui-dialog')) {
|
||||
dialog.dialog('destroy');
|
||||
}
|
||||
|
||||
dialog.attr('title',title)
|
||||
.empty()
|
||||
.append(message)
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
buttons : button,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
|
||||
if(typeof callback === 'function')
|
||||
{
|
||||
dialog.bind( "dialogclose", function(event, ui) {callback();});
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
p4.Alerts = alert;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
p4.Alerts = alert;
|
||||
|
||||
|
||||
return;
|
||||
}(p4));
|
||||
|
@@ -4,284 +4,284 @@ var p4 = p4 || {};
|
||||
;
|
||||
(function(p4, $){
|
||||
|
||||
function getLevel (level) {
|
||||
function getLevel (level) {
|
||||
|
||||
level = parseInt(level);
|
||||
level = parseInt(level);
|
||||
|
||||
if(isNaN(level) || level < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(isNaN(level) || level < 1)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return level;
|
||||
};
|
||||
|
||||
function getId (level)
|
||||
{
|
||||
return 'DIALOG' + getLevel(level);
|
||||
};
|
||||
|
||||
function addButtons(buttons, dialog)
|
||||
{
|
||||
if(dialog.options.closeButton === true)
|
||||
{
|
||||
buttons[language.fermer] = function() {
|
||||
dialog.Close();
|
||||
};
|
||||
}
|
||||
if(dialog.options.cancelButton === true)
|
||||
{
|
||||
buttons[language.annuler] = function() {
|
||||
dialog.Close();
|
||||
};
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
var phraseaDialog = function (options, level) {
|
||||
|
||||
var createDialog = function(level) {
|
||||
|
||||
var $dialog = $('#' + getId(level));
|
||||
|
||||
if($dialog.length > 0)
|
||||
{
|
||||
throw 'Dialog already exists at this level';
|
||||
}
|
||||
|
||||
$dialog = $('<div style="display:none;" id="' + getId(level) + '"></div>');
|
||||
$('body').append($dialog);
|
||||
|
||||
return $dialog;
|
||||
return level;
|
||||
};
|
||||
|
||||
var defaults = {
|
||||
size : 'Medium',
|
||||
buttons : {},
|
||||
loading : true,
|
||||
title : '',
|
||||
closeOnEscape : true,
|
||||
confirmExit:false,
|
||||
closeCallback:false,
|
||||
closeButton:false,
|
||||
cancelButton:false
|
||||
},
|
||||
options = typeof options === 'object' ? options : {},
|
||||
width,
|
||||
height,
|
||||
$dialog,
|
||||
$this = this;
|
||||
|
||||
this.closing = false;
|
||||
|
||||
this.options = $.extend(defaults, options);
|
||||
|
||||
this.level = getLevel(level);
|
||||
|
||||
this.options.buttons = addButtons(this.options.buttons, this);
|
||||
|
||||
switch(this.options.size)
|
||||
function getId (level)
|
||||
{
|
||||
case 'Full':
|
||||
height = bodySize.y - 30;
|
||||
width = bodySize.x - 30 ;
|
||||
break;
|
||||
case 'Medium':
|
||||
width = Math.min(bodySize.x - 30, 730);
|
||||
height = Math.min(bodySize.y - 30, 520);
|
||||
break;
|
||||
default:
|
||||
case 'Small':
|
||||
width = Math.min(bodySize.x - 30, 420);
|
||||
height = Math.min(bodySize.y - 30, 300);
|
||||
break;
|
||||
case 'Alert':
|
||||
width = Math.min(bodySize.x - 30, 300);
|
||||
height = Math.min(bodySize.y - 30, 150);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* 3 avaailable dimensions :
|
||||
*
|
||||
* - Full | Full size ()
|
||||
* - Medium | 420 x 450
|
||||
* - Small | 730 x 480
|
||||
*
|
||||
**/
|
||||
this.$dialog = createDialog(this.level),
|
||||
zIndex = Math.min(this.level * 5000 + 5000, 32767);
|
||||
|
||||
var CloseCallback = function() {
|
||||
if(typeof $this.options.closeCallback === 'function')
|
||||
{
|
||||
$this.options.closeCallback($this.$dialog);
|
||||
}
|
||||
|
||||
if($this.closing === false)
|
||||
{
|
||||
$this.closing = true;
|
||||
$this.Close();
|
||||
}
|
||||
return 'DIALOG' + getLevel(level);
|
||||
};
|
||||
|
||||
if (this.$dialog.data('ui-dialog')) {
|
||||
this.$dialog.dialog('destroy');
|
||||
function addButtons(buttons, dialog)
|
||||
{
|
||||
if(dialog.options.closeButton === true)
|
||||
{
|
||||
buttons[language.fermer] = function() {
|
||||
dialog.Close();
|
||||
};
|
||||
}
|
||||
if(dialog.options.cancelButton === true)
|
||||
{
|
||||
buttons[language.annuler] = function() {
|
||||
dialog.Close();
|
||||
};
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
this.$dialog.attr('title', this.options.title)
|
||||
.empty()
|
||||
.dialog({
|
||||
buttons:this.options.buttons,
|
||||
draggable:false,
|
||||
resizable:false,
|
||||
closeOnEscape:this.options.closeOnEscape,
|
||||
modal:true,
|
||||
width:width,
|
||||
height:height,
|
||||
open: function() {
|
||||
$(this).dialog("widget").css("z-index", zIndex);
|
||||
},
|
||||
close:CloseCallback
|
||||
})
|
||||
.dialog('open').addClass('dialog-' + this.options.size);
|
||||
var phraseaDialog = function (options, level) {
|
||||
|
||||
if(this.options.loading === true)
|
||||
{
|
||||
this.$dialog.addClass('loading');
|
||||
}
|
||||
var createDialog = function(level) {
|
||||
|
||||
if(this.options.size === 'Full')
|
||||
{
|
||||
var $this = this;
|
||||
$(window).unbind('resize.DIALOG' + getLevel(level))
|
||||
.bind('resize.DIALOG' + getLevel(level), function(){
|
||||
if ($this.$dialog.data("ui-dialog")) {
|
||||
$this.$dialog.dialog('option', {
|
||||
width : bodySize.x - 30,
|
||||
height : bodySize.y - 30
|
||||
var $dialog = $('#' + getId(level));
|
||||
|
||||
if($dialog.length > 0)
|
||||
{
|
||||
throw 'Dialog already exists at this level';
|
||||
}
|
||||
|
||||
$dialog = $('<div style="display:none;" id="' + getId(level) + '"></div>');
|
||||
$('body').append($dialog);
|
||||
|
||||
return $dialog;
|
||||
};
|
||||
|
||||
var defaults = {
|
||||
size : 'Medium',
|
||||
buttons : {},
|
||||
loading : true,
|
||||
title : '',
|
||||
closeOnEscape : true,
|
||||
confirmExit:false,
|
||||
closeCallback:false,
|
||||
closeButton:false,
|
||||
cancelButton:false
|
||||
},
|
||||
options = typeof options === 'object' ? options : {},
|
||||
width,
|
||||
height,
|
||||
$dialog,
|
||||
$this = this;
|
||||
|
||||
this.closing = false;
|
||||
|
||||
this.options = $.extend(defaults, options);
|
||||
|
||||
this.level = getLevel(level);
|
||||
|
||||
this.options.buttons = addButtons(this.options.buttons, this);
|
||||
|
||||
switch(this.options.size)
|
||||
{
|
||||
case 'Full':
|
||||
height = bodySize.y - 30;
|
||||
width = bodySize.x - 30 ;
|
||||
break;
|
||||
case 'Medium':
|
||||
width = Math.min(bodySize.x - 30, 730);
|
||||
height = Math.min(bodySize.y - 30, 520);
|
||||
break;
|
||||
default:
|
||||
case 'Small':
|
||||
width = Math.min(bodySize.x - 30, 420);
|
||||
height = Math.min(bodySize.y - 30, 300);
|
||||
break;
|
||||
case 'Alert':
|
||||
width = Math.min(bodySize.x - 30, 300);
|
||||
height = Math.min(bodySize.y - 30, 150);
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
* 3 avaailable dimensions :
|
||||
*
|
||||
* - Full | Full size ()
|
||||
* - Medium | 420 x 450
|
||||
* - Small | 730 x 480
|
||||
*
|
||||
**/
|
||||
this.$dialog = createDialog(this.level),
|
||||
zIndex = Math.min(this.level * 5000 + 5000, 32767);
|
||||
|
||||
var CloseCallback = function() {
|
||||
if(typeof $this.options.closeCallback === 'function')
|
||||
{
|
||||
$this.options.closeCallback($this.$dialog);
|
||||
}
|
||||
|
||||
if($this.closing === false)
|
||||
{
|
||||
$this.closing = true;
|
||||
$this.Close();
|
||||
}
|
||||
};
|
||||
|
||||
if (this.$dialog.data('ui-dialog')) {
|
||||
this.$dialog.dialog('destroy');
|
||||
}
|
||||
|
||||
this.$dialog.attr('title', this.options.title)
|
||||
.empty()
|
||||
.dialog({
|
||||
buttons:this.options.buttons,
|
||||
draggable:false,
|
||||
resizable:false,
|
||||
closeOnEscape:this.options.closeOnEscape,
|
||||
modal:true,
|
||||
width:width,
|
||||
height:height,
|
||||
open: function() {
|
||||
$(this).dialog("widget").css("z-index", zIndex);
|
||||
},
|
||||
close:CloseCallback
|
||||
})
|
||||
.dialog('open').addClass('dialog-' + this.options.size);
|
||||
|
||||
if(this.options.loading === true)
|
||||
{
|
||||
this.$dialog.addClass('loading');
|
||||
}
|
||||
|
||||
if(this.options.size === 'Full')
|
||||
{
|
||||
var $this = this;
|
||||
$(window).unbind('resize.DIALOG' + getLevel(level))
|
||||
.bind('resize.DIALOG' + getLevel(level), function(){
|
||||
if ($this.$dialog.data("ui-dialog")) {
|
||||
$this.$dialog.dialog('option', {
|
||||
width : bodySize.x - 30,
|
||||
height : bodySize.y - 30
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
phraseaDialog.prototype = {
|
||||
Close : function() {
|
||||
p4.Dialog.Close(this.level);
|
||||
},
|
||||
setContent : function (content) {
|
||||
this.$dialog.removeClass('loading').empty().append(content);
|
||||
},
|
||||
getId : function () {
|
||||
return this.$dialog.attr('id');
|
||||
},
|
||||
load : function(url, method, params) {
|
||||
var $this = this;
|
||||
this.loader = {
|
||||
url : url,
|
||||
method : typeof method === 'undefined' ? 'GET' : method,
|
||||
params : typeof params === 'undefined' ? {} : params
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: this.loader.method,
|
||||
url: this.loader.url,
|
||||
dataType: 'html',
|
||||
data : this.loader.params,
|
||||
beforeSend:function(){
|
||||
},
|
||||
success: function(data){
|
||||
$this.setContent(data);
|
||||
return;
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
}
|
||||
});
|
||||
},
|
||||
refresh : function() {
|
||||
if(typeof this.loader === 'undefined')
|
||||
{
|
||||
throw 'Nothing to refresh';
|
||||
}
|
||||
this.load(this.loader.url, this.loader.method, this.loader.params);
|
||||
},
|
||||
getDomElement : function () {
|
||||
return this.$dialog;
|
||||
},
|
||||
getOption : function (optionName) {
|
||||
if (this.$dialog.data("ui-dialog")) {
|
||||
return this.$dialog.dialog('option', optionName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
setOption : function (optionName, optionValue) {
|
||||
if(optionName === 'buttons')
|
||||
{
|
||||
optionValue = addButtons(optionValue, this);
|
||||
}
|
||||
if (this.$dialog.data("ui-dialog")) {
|
||||
this.$dialog.dialog('option', optionName, optionValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
};
|
||||
var Dialog = function () {
|
||||
this.currentStack = {};
|
||||
};
|
||||
|
||||
phraseaDialog.prototype = {
|
||||
Close : function() {
|
||||
p4.Dialog.Close(this.level);
|
||||
},
|
||||
setContent : function (content) {
|
||||
this.$dialog.removeClass('loading').empty().append(content);
|
||||
},
|
||||
getId : function () {
|
||||
return this.$dialog.attr('id');
|
||||
},
|
||||
load : function(url, method, params) {
|
||||
var $this = this;
|
||||
this.loader = {
|
||||
url : url,
|
||||
method : typeof method === 'undefined' ? 'GET' : method,
|
||||
params : typeof params === 'undefined' ? {} : params
|
||||
};
|
||||
Dialog.prototype = {
|
||||
Create : function(options, level) {
|
||||
|
||||
$.ajax({
|
||||
type: this.loader.method,
|
||||
url: this.loader.url,
|
||||
dataType: 'html',
|
||||
data : this.loader.params,
|
||||
beforeSend:function(){
|
||||
if(this.get(level) instanceof phraseaDialog)
|
||||
{
|
||||
this.get(level).Close();
|
||||
}
|
||||
|
||||
$dialog = new phraseaDialog(options, level);
|
||||
|
||||
this.currentStack[$dialog.getId()] = $dialog;
|
||||
|
||||
return $dialog;
|
||||
},
|
||||
success: function(data){
|
||||
$this.setContent(data);
|
||||
return;
|
||||
get : function (level) {
|
||||
|
||||
var id = getId(level);
|
||||
|
||||
if(id in this.currentStack)
|
||||
{
|
||||
return this.currentStack[id];
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
error: function(){
|
||||
return;
|
||||
},
|
||||
timeout: function(){
|
||||
return;
|
||||
Close : function (level) {
|
||||
|
||||
$(window).unbind('resize.DIALOG' + getLevel(level));
|
||||
|
||||
this.get(level).closing = true;
|
||||
var dialog = this.get(level).getDomElement();
|
||||
if (dialog.data('ui-dialog')) {
|
||||
dialog.dialog('close').dialog('destroy');
|
||||
}
|
||||
dialog.remove();
|
||||
|
||||
var id = this.get(level).getId();
|
||||
|
||||
if(id in this.currentStack)
|
||||
{
|
||||
delete this.currentStack.id;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
refresh : function() {
|
||||
if(typeof this.loader === 'undefined')
|
||||
{
|
||||
throw 'Nothing to refresh';
|
||||
}
|
||||
this.load(this.loader.url, this.loader.method, this.loader.params);
|
||||
},
|
||||
getDomElement : function () {
|
||||
return this.$dialog;
|
||||
},
|
||||
getOption : function (optionName) {
|
||||
if (this.$dialog.data("ui-dialog")) {
|
||||
return this.$dialog.dialog('option', optionName);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
setOption : function (optionName, optionValue) {
|
||||
if(optionName === 'buttons')
|
||||
{
|
||||
optionValue = addButtons(optionValue, this);
|
||||
}
|
||||
if (this.$dialog.data("ui-dialog")) {
|
||||
this.$dialog.dialog('option', optionName, optionValue);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var Dialog = function () {
|
||||
this.currentStack = {};
|
||||
};
|
||||
p4.Dialog = new Dialog();
|
||||
|
||||
Dialog.prototype = {
|
||||
Create : function(options, level) {
|
||||
|
||||
if(this.get(level) instanceof phraseaDialog)
|
||||
{
|
||||
this.get(level).Close();
|
||||
}
|
||||
|
||||
$dialog = new phraseaDialog(options, level);
|
||||
|
||||
this.currentStack[$dialog.getId()] = $dialog;
|
||||
|
||||
return $dialog;
|
||||
},
|
||||
get : function (level) {
|
||||
|
||||
var id = getId(level);
|
||||
|
||||
if(id in this.currentStack)
|
||||
{
|
||||
return this.currentStack[id];
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
Close : function (level) {
|
||||
|
||||
$(window).unbind('resize.DIALOG' + getLevel(level));
|
||||
|
||||
this.get(level).closing = true;
|
||||
var dialog = this.get(level).getDomElement();
|
||||
if (dialog.data('ui-dialog')) {
|
||||
dialog.dialog('close').dialog('destroy');
|
||||
}
|
||||
dialog.remove();
|
||||
|
||||
var id = this.get(level).getId();
|
||||
|
||||
if(id in this.currentStack)
|
||||
{
|
||||
delete this.currentStack.id;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
p4.Dialog = new Dialog();
|
||||
|
||||
}(p4, jQuery));
|
||||
}(p4, jQuery));
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -2,23 +2,23 @@ var p4 = p4 || {};
|
||||
|
||||
(function(p4, window){
|
||||
|
||||
p4.Results = {
|
||||
p4.Results = {
|
||||
'Selection':new Selectable($('#answers'), {
|
||||
selector : '.IMGT',
|
||||
limit:800,
|
||||
selectStart:function(event, selection){
|
||||
$('#answercontextwrap table:visible').hide();
|
||||
},
|
||||
selectStop:function(event, selection){
|
||||
viewNbSelect();
|
||||
},
|
||||
callbackSelection:function(element){
|
||||
var elements = $(element).attr('id').split('_');
|
||||
selector : '.IMGT',
|
||||
limit:800,
|
||||
selectStart:function(event, selection){
|
||||
$('#answercontextwrap table:visible').hide();
|
||||
},
|
||||
selectStop:function(event, selection){
|
||||
viewNbSelect();
|
||||
},
|
||||
callbackSelection:function(element){
|
||||
var elements = $(element).attr('id').split('_');
|
||||
|
||||
return elements.slice(elements.length - 2 ,elements.length).join('_');
|
||||
}
|
||||
return elements.slice(elements.length - 2 ,elements.length).join('_');
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
return;
|
||||
return;
|
||||
}(p4, window));
|
||||
|
@@ -98,20 +98,20 @@ var p4 = p4 || {};
|
||||
var texte = '<p>' + language.confirmRemoveReg + '</p><div><input type="checkbox" onchange="toggleRemoveReg(this);"/>' + language.hideMessage + '</div>';
|
||||
$('body').append('<div id="DIALOG-baskets"></div>');
|
||||
$("#DIALOG-baskets").attr('title', language.removeTitle)
|
||||
.empty()
|
||||
.append(texte)
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
draggable: false,
|
||||
modal: true,
|
||||
buttons: buttons,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
.empty()
|
||||
.append(texte)
|
||||
.dialog({
|
||||
autoOpen: false,
|
||||
closeOnEscape: true,
|
||||
resizable: false,
|
||||
draggable: false,
|
||||
modal: true,
|
||||
buttons: buttons,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,11 +145,11 @@ var p4 = p4 || {};
|
||||
if (selectedItemIndex === 0 && carouselItemLength > 1) {
|
||||
// click next item
|
||||
selectedItem.next().find("img").trigger("click");
|
||||
// item is last item and list has at least 2 items
|
||||
// item is last item and list has at least 2 items
|
||||
} else if (carouselItemLength > 1 && selectedItemIndex === (carouselItemLength - 1)) {
|
||||
// click previous item
|
||||
selectedItem.prev().find("img").trigger("click");
|
||||
// Basket is empty
|
||||
// Basket is empty
|
||||
} else if (carouselItemLength > 1) {
|
||||
// click next item
|
||||
selectedItem.next().find("img").trigger("click");
|
||||
@@ -236,24 +236,24 @@ var p4 = p4 || {};
|
||||
}
|
||||
|
||||
$(".SSTT, .content", cache)
|
||||
.droppable({
|
||||
scope: 'objects',
|
||||
hoverClass: 'baskDrop',
|
||||
tolerance: 'pointer',
|
||||
accept: function(elem) {
|
||||
if ($(elem).hasClass('CHIM')) {
|
||||
if ($(elem).closest('.content').prev()[0] === $(this)[0]) {
|
||||
return false;
|
||||
.droppable({
|
||||
scope: 'objects',
|
||||
hoverClass: 'baskDrop',
|
||||
tolerance: 'pointer',
|
||||
accept: function(elem) {
|
||||
if ($(elem).hasClass('CHIM')) {
|
||||
if ($(elem).closest('.content').prev()[0] === $(this)[0]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($(elem).hasClass('grouping') || $(elem).parent()[0] === $(this)[0])
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
drop: function(event, ui) {
|
||||
dropOnBask(event, ui.draggable, $(this));
|
||||
}
|
||||
if ($(elem).hasClass('grouping') || $(elem).parent()[0] === $(this)[0])
|
||||
return false;
|
||||
return true;
|
||||
},
|
||||
drop: function(event, ui) {
|
||||
dropOnBask(event, ui.draggable, $(this));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if ($('#basketcontextwrap').length === 0)
|
||||
$('body').append('<div id="basketcontextwrap"></div>');
|
||||
@@ -312,8 +312,8 @@ var p4 = p4 || {};
|
||||
$('a.WorkZoneElementRemover', dest).bind('mousedown', function(event) {
|
||||
return false;
|
||||
}).bind('click', function(event) {
|
||||
return WorkZoneElementRemover($(this), false);
|
||||
});
|
||||
return WorkZoneElementRemover($(this), false);
|
||||
});
|
||||
|
||||
dest.droppable({
|
||||
accept: function(elem) {
|
||||
@@ -339,10 +339,10 @@ var p4 = p4 || {};
|
||||
dest.find('.CHIM').draggable({
|
||||
helper: function() {
|
||||
$('body').append('<div id="dragDropCursor" ' +
|
||||
'style="position:absolute;z-index:9999;background:red;' +
|
||||
'-moz-border-radius:8px;-webkit-border-radius:8px;">' +
|
||||
'<div style="padding:2px 5px;font-weight:bold;">' +
|
||||
p4.WorkZone.Selection.length() + '</div></div>');
|
||||
'style="position:absolute;z-index:9999;background:red;' +
|
||||
'-moz-border-radius:8px;-webkit-border-radius:8px;">' +
|
||||
'<div style="padding:2px 5px;font-weight:bold;">' +
|
||||
p4.WorkZone.Selection.length() + '</div></div>');
|
||||
return $('#dragDropCursor');
|
||||
},
|
||||
scope: "objects",
|
||||
@@ -356,7 +356,7 @@ var p4 = p4 || {};
|
||||
start: function(event, ui) {
|
||||
var baskets = $('#baskets');
|
||||
baskets.append('<div class="top-scroller"></div>' +
|
||||
'<div class="bottom-scroller"></div>');
|
||||
'<div class="bottom-scroller"></div>');
|
||||
$('.bottom-scroller', baskets).bind('mousemove', function() {
|
||||
$('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop() + 30);
|
||||
});
|
||||
@@ -366,8 +366,8 @@ var p4 = p4 || {};
|
||||
},
|
||||
stop: function() {
|
||||
$('#baskets').find('.top-scroller, .bottom-scroller')
|
||||
.unbind()
|
||||
.remove();
|
||||
.unbind()
|
||||
.remove();
|
||||
},
|
||||
drag: function(event, ui) {
|
||||
if (is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping'))
|
||||
@@ -572,13 +572,13 @@ var p4 = p4 || {};
|
||||
|
||||
frame.data('openwidth', frame.width());
|
||||
frame.animate({width: 100},
|
||||
300,
|
||||
'linear',
|
||||
function() {
|
||||
answerSizer();
|
||||
linearize();
|
||||
$('#answers').trigger('resize');
|
||||
});
|
||||
300,
|
||||
'linear',
|
||||
function() {
|
||||
answerSizer();
|
||||
linearize();
|
||||
$('#answers').trigger('resize');
|
||||
});
|
||||
frame.addClass('closed');
|
||||
$('.escamote', frame).hide();
|
||||
$('li.ui-tabs-selected', frame).removeClass('ui-tabs-selected');
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -428,7 +428,7 @@ function afterSearch()
|
||||
$('.rollover-gif-hover',this).hide();
|
||||
$('.rollover-gif-out',this).show();
|
||||
}
|
||||
);
|
||||
);
|
||||
viewNbSelect();
|
||||
$('#answers div.IMGT').draggable({
|
||||
helper : function(){
|
||||
@@ -464,7 +464,7 @@ function initAnswerForm(){
|
||||
searchForm.unbind('submit').bind('submit',function(){
|
||||
|
||||
var $this = $(this),
|
||||
method = $this.attr('method') ? $this.attr('method') : 'POST';
|
||||
method = $this.attr('method') ? $this.attr('method') : 'POST';
|
||||
|
||||
answAjax = $.ajax({
|
||||
type: method,
|
||||
@@ -750,7 +750,7 @@ function toHex(N) {
|
||||
N=Math.min(N,255);
|
||||
N=Math.round(N);
|
||||
return "0123456789ABCDEF".charAt((N-N%16)/16)
|
||||
+ "0123456789ABCDEF".charAt(N%16);
|
||||
+ "0123456789ABCDEF".charAt(N%16);
|
||||
}
|
||||
function hsl2rgb(h, s, l) {
|
||||
var m1, m2, hue;
|
||||
@@ -917,10 +917,10 @@ $(document).ready(function(){
|
||||
$('style[title=color_selection]').empty();
|
||||
|
||||
var datas = '.diapo.selected,#reorder_box .diapo.selected, #EDIT_ALL .diapo.selected, .list.selected, .list.selected .diapo' +
|
||||
'{'+
|
||||
' COLOR: #'+back_hex+';'+
|
||||
' BACKGROUND-COLOR: #'+hex+';'+
|
||||
'}';
|
||||
'{'+
|
||||
' COLOR: #'+back_hex+';'+
|
||||
' BACKGROUND-COLOR: #'+hex+';'+
|
||||
'}';
|
||||
$('style[title=color_selection]').empty().text(datas);
|
||||
}
|
||||
});
|
||||
@@ -1022,22 +1022,22 @@ $(document).ready(function(){
|
||||
$("#DIALOG").dialog('destroy');
|
||||
}
|
||||
$("#DIALOG").attr('title',data.titre)
|
||||
.empty()
|
||||
.append(data.texte)
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
buttons:buttons,
|
||||
width:650,
|
||||
height:250,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
.empty()
|
||||
.append(data.texte)
|
||||
.dialog({
|
||||
autoOpen:false,
|
||||
closeOnEscape:true,
|
||||
resizable:false,
|
||||
draggable:false,
|
||||
modal:true,
|
||||
buttons:buttons,
|
||||
width:650,
|
||||
height:250,
|
||||
overlay: {
|
||||
backgroundColor: '#000',
|
||||
opacity: 0.7
|
||||
}
|
||||
}).dialog('open');
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1053,8 +1053,8 @@ $(document).ready(function(){
|
||||
$('#history-queries ul li').live('mouseover',function(){
|
||||
$(this).addClass('hover');
|
||||
}).live('mouseout',function(){
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
|
||||
startThesaurus();
|
||||
checkFilters();
|
||||
@@ -1094,15 +1094,15 @@ $(document).ready(function(){
|
||||
|
||||
|
||||
$('#idFrameC').stop().animate({
|
||||
width : nwidth
|
||||
},
|
||||
300,
|
||||
'linear',
|
||||
function(){
|
||||
answerSizer();
|
||||
linearize();
|
||||
saveWindows();
|
||||
});
|
||||
width : nwidth
|
||||
},
|
||||
300,
|
||||
'linear',
|
||||
function(){
|
||||
answerSizer();
|
||||
linearize();
|
||||
saveWindows();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1163,17 +1163,17 @@ $(document).ready(function(){
|
||||
$('.tools .answer_selector').bind('click',function(){
|
||||
selector($(this));
|
||||
}).bind('mouseover',function(event){
|
||||
if(is_ctrl_key(event))
|
||||
{
|
||||
$(this).addClass('add_selector');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(is_ctrl_key(event))
|
||||
{
|
||||
$(this).addClass('add_selector');
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).removeClass('add_selector');
|
||||
}
|
||||
}).bind('mouseout',function(){
|
||||
$(this).removeClass('add_selector');
|
||||
}
|
||||
}).bind('mouseout',function(){
|
||||
$(this).removeClass('add_selector');
|
||||
});
|
||||
});
|
||||
|
||||
getLanguage();
|
||||
|
||||
@@ -1233,27 +1233,27 @@ $(document).ready(function(){
|
||||
if(p4.preview.open)
|
||||
{
|
||||
if (($('#dialog_dwnl:visible').length === 0 && $('#DIALOG1').length === 0 && $('#DIALOG2').length === 0)) {
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case 39:
|
||||
getNext();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
case 37:
|
||||
getPrevious();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
case 27://escape
|
||||
closePreview();
|
||||
break;
|
||||
case 32:
|
||||
if(p4.slideShow)
|
||||
stopSlide();
|
||||
else
|
||||
startSlide();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
}
|
||||
switch(event.keyCode)
|
||||
{
|
||||
case 39:
|
||||
getNext();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
case 37:
|
||||
getPrevious();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
case 27://escape
|
||||
closePreview();
|
||||
break;
|
||||
case 32:
|
||||
if(p4.slideShow)
|
||||
stopSlide();
|
||||
else
|
||||
startSlide();
|
||||
cancelKey = shortCut = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1411,8 +1411,8 @@ $(document).ready(function(){
|
||||
$('#EDIT_query').bind('focus',function(){
|
||||
$(this).addClass('focused');
|
||||
}).bind('blur',function(){
|
||||
$(this).removeClass('focused');
|
||||
});
|
||||
$(this).removeClass('focused');
|
||||
});
|
||||
|
||||
$('.basketTips').tooltip({
|
||||
delay: 200
|
||||
@@ -1716,7 +1716,7 @@ function toolREFACTOR(datas){
|
||||
dialog.setContent(data);
|
||||
return;
|
||||
}
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@@ -2071,8 +2071,8 @@ function activeIcons()
|
||||
}
|
||||
|
||||
/**
|
||||
* if works, then the object is not empty
|
||||
*/
|
||||
* if works, then the object is not empty
|
||||
*/
|
||||
for(i in value)
|
||||
{
|
||||
return chgCollThis(value);
|
||||
@@ -2098,7 +2098,7 @@ function activeIcons()
|
||||
}
|
||||
} else {
|
||||
if ($this.hasClass('basket_element')) {
|
||||
params.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop();
|
||||
params.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop();
|
||||
} else {
|
||||
if ($this.hasClass('story_window')) {
|
||||
if (p4.WorkZone.Selection.length() > 0) {
|
||||
@@ -2388,21 +2388,21 @@ function printThis(value)
|
||||
$("#DIALOG").dialog('destroy');
|
||||
}
|
||||
$('#DIALOG').attr('title', language.print)
|
||||
.empty().addClass('loading')
|
||||
.dialog({
|
||||
resizable:false,
|
||||
closeOnEscape:true,
|
||||
modal:true,
|
||||
width:'800',
|
||||
height:'500',
|
||||
open: function(event, ui) {
|
||||
$(this).dialog("widget").css("z-index", "1999");
|
||||
},
|
||||
close: function(event, ui) {
|
||||
$(this).dialog("widget").css("z-index", "auto");
|
||||
}
|
||||
})
|
||||
.dialog('open');
|
||||
.empty().addClass('loading')
|
||||
.dialog({
|
||||
resizable:false,
|
||||
closeOnEscape:true,
|
||||
modal:true,
|
||||
width:'800',
|
||||
height:'500',
|
||||
open: function(event, ui) {
|
||||
$(this).dialog("widget").css("z-index", "1999");
|
||||
},
|
||||
close: function(event, ui) {
|
||||
$(this).dialog("widget").css("z-index", "auto");
|
||||
}
|
||||
})
|
||||
.dialog('open');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
@@ -2413,7 +2413,7 @@ function printThis(value)
|
||||
},
|
||||
success: function(data){
|
||||
$('#DIALOG').removeClass('loading').empty()
|
||||
.append(data);
|
||||
.append(data);
|
||||
return;
|
||||
}
|
||||
});
|
||||
@@ -2432,7 +2432,7 @@ function downloadThis(datas)
|
||||
|
||||
$('.close_button', dialog.getDomElement()).bind('click',function(){
|
||||
dialog.Close();
|
||||
});
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -2581,8 +2581,8 @@ function doDelete(lst)
|
||||
|
||||
$.each(data,function(i,n){
|
||||
var imgt = $('#IMGT_'+n),
|
||||
chim = $('.CHIM_'+n),
|
||||
stories = $('.STORY_'+n);
|
||||
chim = $('.CHIM_'+n),
|
||||
stories = $('.STORY_'+n);
|
||||
$('.doc_infos', imgt).remove();
|
||||
imgt.unbind("click").removeAttr("ondblclick").removeClass("selected").removeClass("IMGT").find("img").unbind();
|
||||
|
||||
@@ -3053,10 +3053,10 @@ function set_up_feed_box(data)
|
||||
$(this).addClass('selected');
|
||||
$('input[name="feed_id"]', $form).val($('input', this).val());
|
||||
}).hover(function(){
|
||||
$(this).addClass('hover');
|
||||
},function(){
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
$(this).addClass('hover');
|
||||
},function(){
|
||||
$(this).removeClass('hover');
|
||||
});
|
||||
|
||||
$form.bind('submit', function(){
|
||||
return false;
|
||||
|
@@ -8,11 +8,11 @@ function publicator_reload_publicator()
|
||||
|
||||
function init_publicator(datas)
|
||||
{
|
||||
var dialog = p4.Dialog.Create({
|
||||
size:'Full',
|
||||
title:'Bridge',
|
||||
loading: false
|
||||
});
|
||||
var dialog = p4.Dialog.Create({
|
||||
size:'Full',
|
||||
title:'Bridge',
|
||||
loading: false
|
||||
});
|
||||
|
||||
dialog.load('/prod/bridge/manager/', 'POST', datas);
|
||||
}
|
||||
|
@@ -101,8 +101,8 @@ function bindEvents() {
|
||||
},
|
||||
text: false
|
||||
}).unbind("click").bind("click", function () {
|
||||
showMenu();
|
||||
});
|
||||
showMenu();
|
||||
});
|
||||
|
||||
$("#liste_dash").find("em").unbind("click").bind("click", function () {
|
||||
id = $(this).attr('id').substr(3);
|
||||
|
@@ -1,108 +1,108 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sprintf function for javascript
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// sprintf function for javascript
|
||||
function sprintf()
|
||||
{
|
||||
if (!arguments || arguments.length < 1 || !RegExp)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
str = arguments[0];
|
||||
while((newstr = str.replace("\n", "\x01")) != str)
|
||||
str = newstr;
|
||||
// var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
|
||||
var re = new RegExp("^([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)$", "m");
|
||||
re["$*"] = true;
|
||||
var a = b = [], numSubstitutions = 0, numMatches = 0;
|
||||
a = re.exec(str);
|
||||
while (a)
|
||||
{
|
||||
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
|
||||
var pPrecision = a[5], pType = a[6], rightPart = a[7]; numMatches++;
|
||||
|
||||
// alert("str:"+str + "\nl:"+leftpart + "\nr:"+rightPart);
|
||||
|
||||
if (pType == '%')
|
||||
{
|
||||
subst = '%';
|
||||
}
|
||||
else
|
||||
{
|
||||
numSubstitutions++;
|
||||
if (numSubstitutions >= arguments.length)
|
||||
{
|
||||
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\n' + 'for the number of substitution parameters in string (' + numSubstitutions + ' so far).');
|
||||
}
|
||||
var param = arguments[numSubstitutions];
|
||||
var pad = '';
|
||||
if (pPad && pPad.substr(0,1) == "'")
|
||||
{
|
||||
pad = leftpart.substr(1,1);
|
||||
}
|
||||
else if (pPad)
|
||||
{
|
||||
pad = pPad;
|
||||
}
|
||||
var justifyRight = true;
|
||||
if (pJustify && pJustify === "-")
|
||||
justifyRight = false;
|
||||
var minLength = -1;
|
||||
if (pMinLength)
|
||||
minLength = parseInt(pMinLength);
|
||||
var precision = -1;
|
||||
if (pPrecision && pType == 'f')
|
||||
{
|
||||
precision = parseInt(pPrecision.substring(1));
|
||||
}
|
||||
var subst = param;
|
||||
switch (pType)
|
||||
{
|
||||
case 'b':
|
||||
subst = parseInt(param).toString(2);
|
||||
break;
|
||||
case 'c':
|
||||
subst = String.fromCharCode(parseInt(param));
|
||||
break;
|
||||
case 'd':
|
||||
subst = parseInt(param)? parseInt(param) : 0;
|
||||
break;
|
||||
case 'u':
|
||||
subst = Math.abs(param);
|
||||
break;
|
||||
case 'f':
|
||||
subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision) : parseFloat(param);
|
||||
break;
|
||||
case 'o':
|
||||
subst = parseInt(param).toString(8);
|
||||
break;
|
||||
case 's':
|
||||
subst = param;
|
||||
break;
|
||||
case 'x':
|
||||
subst = ('' + parseInt(param).toString(16)).toLowerCase();
|
||||
break;
|
||||
case 'X':
|
||||
subst = ('' + parseInt(param).toString(16)).toUpperCase();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var padLeft = minLength - subst.toString().length;
|
||||
var padding;
|
||||
if (padLeft > 0)
|
||||
{
|
||||
var arrTmp = new Array(padLeft+1);
|
||||
padding = arrTmp.join(pad?pad:" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
padding = "";
|
||||
}
|
||||
}
|
||||
str = leftpart + padding + subst + rightPart;
|
||||
{
|
||||
if (!arguments || arguments.length < 1 || !RegExp)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
str = arguments[0];
|
||||
while((newstr = str.replace("\n", "\x01")) != str)
|
||||
str = newstr;
|
||||
// var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
|
||||
var re = new RegExp("^([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)$", "m");
|
||||
re["$*"] = true;
|
||||
var a = b = [], numSubstitutions = 0, numMatches = 0;
|
||||
a = re.exec(str);
|
||||
}
|
||||
while((newstr = str.replace("\x01", "\n")) != str)
|
||||
str = newstr;
|
||||
return(str);
|
||||
}
|
||||
while (a)
|
||||
{
|
||||
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
|
||||
var pPrecision = a[5], pType = a[6], rightPart = a[7]; numMatches++;
|
||||
|
||||
// alert("str:"+str + "\nl:"+leftpart + "\nr:"+rightPart);
|
||||
|
||||
if (pType == '%')
|
||||
{
|
||||
subst = '%';
|
||||
}
|
||||
else
|
||||
{
|
||||
numSubstitutions++;
|
||||
if (numSubstitutions >= arguments.length)
|
||||
{
|
||||
alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\n' + 'for the number of substitution parameters in string (' + numSubstitutions + ' so far).');
|
||||
}
|
||||
var param = arguments[numSubstitutions];
|
||||
var pad = '';
|
||||
if (pPad && pPad.substr(0,1) == "'")
|
||||
{
|
||||
pad = leftpart.substr(1,1);
|
||||
}
|
||||
else if (pPad)
|
||||
{
|
||||
pad = pPad;
|
||||
}
|
||||
var justifyRight = true;
|
||||
if (pJustify && pJustify === "-")
|
||||
justifyRight = false;
|
||||
var minLength = -1;
|
||||
if (pMinLength)
|
||||
minLength = parseInt(pMinLength);
|
||||
var precision = -1;
|
||||
if (pPrecision && pType == 'f')
|
||||
{
|
||||
precision = parseInt(pPrecision.substring(1));
|
||||
}
|
||||
var subst = param;
|
||||
switch (pType)
|
||||
{
|
||||
case 'b':
|
||||
subst = parseInt(param).toString(2);
|
||||
break;
|
||||
case 'c':
|
||||
subst = String.fromCharCode(parseInt(param));
|
||||
break;
|
||||
case 'd':
|
||||
subst = parseInt(param)? parseInt(param) : 0;
|
||||
break;
|
||||
case 'u':
|
||||
subst = Math.abs(param);
|
||||
break;
|
||||
case 'f':
|
||||
subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision) : parseFloat(param);
|
||||
break;
|
||||
case 'o':
|
||||
subst = parseInt(param).toString(8);
|
||||
break;
|
||||
case 's':
|
||||
subst = param;
|
||||
break;
|
||||
case 'x':
|
||||
subst = ('' + parseInt(param).toString(16)).toLowerCase();
|
||||
break;
|
||||
case 'X':
|
||||
subst = ('' + parseInt(param).toString(16)).toUpperCase();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
var padLeft = minLength - subst.toString().length;
|
||||
var padding;
|
||||
if (padLeft > 0)
|
||||
{
|
||||
var arrTmp = new Array(padLeft+1);
|
||||
padding = arrTmp.join(pad?pad:" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
padding = "";
|
||||
}
|
||||
}
|
||||
str = leftpart + padding + subst + rightPart;
|
||||
a = re.exec(str);
|
||||
}
|
||||
while((newstr = str.replace("\x01", "\n")) != str)
|
||||
str = newstr;
|
||||
return(str);
|
||||
}
|
||||
|
@@ -1,422 +1,422 @@
|
||||
|
||||
function loadXMLDoc(url, post_parms, asxml)
|
||||
{
|
||||
if(typeof(asxml)=="undefined")
|
||||
asxml = false;
|
||||
out = null;
|
||||
xmlhttp = null;
|
||||
// code for Mozilla, etc.
|
||||
if (window.XMLHttpRequest)
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
if (xmlhttp)
|
||||
{
|
||||
// xmlhttp.onreadystatechange=state_Change
|
||||
if(post_parms)
|
||||
{
|
||||
xmlhttp.open("POST", url, false);
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
xmlhttp.send(post_parms);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlhttp.open("GET", url, false);
|
||||
xmlhttp.send(null);
|
||||
}
|
||||
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
|
||||
}
|
||||
return(out);
|
||||
if(typeof(asxml)=="undefined")
|
||||
asxml = false;
|
||||
out = null;
|
||||
xmlhttp = null;
|
||||
// code for Mozilla, etc.
|
||||
if (window.XMLHttpRequest)
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
if (xmlhttp)
|
||||
{
|
||||
// xmlhttp.onreadystatechange=state_Change
|
||||
if(post_parms)
|
||||
{
|
||||
xmlhttp.open("POST", url, false);
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
xmlhttp.send(post_parms);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlhttp.open("GET", url, false);
|
||||
xmlhttp.send(null);
|
||||
}
|
||||
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
|
||||
}
|
||||
return(out);
|
||||
}
|
||||
|
||||
|
||||
function showFound2(term, lterm, branch, depth)
|
||||
{
|
||||
var c;
|
||||
var ret = 0;
|
||||
var thb = branch.firstChild.nextSibling.nextSibling;
|
||||
// branch est un <DIV ID="THE_xxx">
|
||||
|
||||
if(thb)
|
||||
{
|
||||
for(c=thb.firstChild; c; c=c.nextSibling) // THE, les SY ou les TA
|
||||
{
|
||||
if(c.nodeName=="DIV")
|
||||
ret += showFound2(term, lterm, c, depth+1); // on descend uniquement les THE_yyy
|
||||
}
|
||||
}
|
||||
var c;
|
||||
var ret = 0;
|
||||
var thb = branch.firstChild.nextSibling.nextSibling;
|
||||
// branch est un <DIV ID="THE_xxx">
|
||||
|
||||
if(thb)
|
||||
{
|
||||
for(c=thb.firstChild; c; c=c.nextSibling) // THE, les SY ou les TA
|
||||
{
|
||||
if(c.nodeName=="DIV")
|
||||
ret += showFound2(term, lterm, c, depth+1); // on descend uniquement les THE_yyy
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(branch.firstChild.nextSibling.nodeValue.substr(0, lterm)==term)
|
||||
{
|
||||
ret = 1;
|
||||
if(branch.firstChild.nextSibling.nodeValue.substr(0, lterm)==term)
|
||||
{
|
||||
ret = 1;
|
||||
// alert(branch.firstChild.nextSibling.nodeValue + " : " + thb.id);
|
||||
}
|
||||
}
|
||||
|
||||
// if(ret > 0)
|
||||
// if(ret > 0)
|
||||
// if(depth > 0)
|
||||
// {
|
||||
if(ret > 0)
|
||||
{
|
||||
//eventObj.Src0.innerHTML = "+";
|
||||
thb.className = "OB";
|
||||
}
|
||||
else
|
||||
{
|
||||
//eventObj.Src0.innerHTML = "+";
|
||||
thb.className = "ob";
|
||||
}
|
||||
if(ret > 0)
|
||||
{
|
||||
//eventObj.Src0.innerHTML = "+";
|
||||
thb.className = "OB";
|
||||
}
|
||||
else
|
||||
{
|
||||
//eventObj.Src0.innerHTML = "+";
|
||||
thb.className = "ob";
|
||||
}
|
||||
// }
|
||||
/*
|
||||
if(depth == 0)
|
||||
{
|
||||
document.getElementById("WT1").style.visibility="hidden";
|
||||
if(document.forms["fTh"].textT1.value!=term)
|
||||
{
|
||||
// oups! le mot a changé durant le traitement, on recommence
|
||||
evt_kup_T1();
|
||||
}
|
||||
}
|
||||
*/
|
||||
return(ret);
|
||||
/*
|
||||
if(depth == 0)
|
||||
{
|
||||
document.getElementById("WT1").style.visibility="hidden";
|
||||
if(document.forms["fTh"].textT1.value!=term)
|
||||
{
|
||||
// oups! le mot a changé durant le traitement, on recommence
|
||||
evt_kup_T1();
|
||||
}
|
||||
}
|
||||
*/
|
||||
return(ret);
|
||||
}
|
||||
|
||||
function showAll(branch, depth)
|
||||
{
|
||||
depth = parseInt(depth);
|
||||
var c;
|
||||
for(c=branch.firstChild; c; c=c.nextSibling)
|
||||
{
|
||||
if(c.nodeType==1 && c.nodeName=="DIV") // 1=XML_ELEMENT_NODE
|
||||
showAll(c, depth+1);
|
||||
}
|
||||
depth = parseInt(depth);
|
||||
var c;
|
||||
for(c=branch.firstChild; c; c=c.nextSibling)
|
||||
{
|
||||
if(c.nodeType==1 && c.nodeName=="DIV") // 1=XML_ELEMENT_NODE
|
||||
showAll(c, depth+1);
|
||||
}
|
||||
|
||||
if(depth > 0)
|
||||
branch.style.display = "";
|
||||
if(depth > 0)
|
||||
branch.style.display = "";
|
||||
|
||||
if(depth===0)
|
||||
{
|
||||
document.getElementById("WT1").style.visibility="hidden";
|
||||
if(document.forms["fTh"].textT1.value!=="")
|
||||
{
|
||||
// oups! le mot a changé durant le traitement, on recommence
|
||||
evt_kup_T1();
|
||||
}
|
||||
}
|
||||
if(depth===0)
|
||||
{
|
||||
document.getElementById("WT1").style.visibility="hidden";
|
||||
if(document.forms["fTh"].textT1.value!=="")
|
||||
{
|
||||
// oups! le mot a changé durant le traitement, on recommence
|
||||
evt_kup_T1();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function scanTerms(inputName, zTerm, showhide)
|
||||
{
|
||||
showhide = !!showhide;
|
||||
var lTerm = zTerm.length;
|
||||
var zTable = document.getElementById("L"+inputName);
|
||||
var zTr = zTable.childNodes; // TR's
|
||||
var l = zTr.length;
|
||||
var found = null;
|
||||
for(var i=0; i<l; i++)
|
||||
{
|
||||
showhide = !!showhide;
|
||||
var lTerm = zTerm.length;
|
||||
var zTable = document.getElementById("L"+inputName);
|
||||
var zTr = zTable.childNodes; // TR's
|
||||
var l = zTr.length;
|
||||
var found = null;
|
||||
for(var i=0; i<l; i++)
|
||||
{
|
||||
// if(renum)
|
||||
// zTr[i].id = inputName+"_"+i
|
||||
var t = zTr[i].firstChild.firstChild.nodeValue;
|
||||
var t = zTr[i].firstChild.firstChild.nodeValue;
|
||||
// alert(i+" "+t);
|
||||
if(zTerm == t)
|
||||
found = zTr[i];
|
||||
if(zTerm == t)
|
||||
found = zTr[i];
|
||||
|
||||
if(showhide === true)
|
||||
{
|
||||
if(lTerm==0 || (t.substr(0, lTerm)==zTerm))
|
||||
zTr[i].style.display = "";
|
||||
else
|
||||
zTr[i].style.display = "none";
|
||||
}
|
||||
else
|
||||
{
|
||||
zTr[i].style.display = "";
|
||||
}
|
||||
}
|
||||
return(found);
|
||||
if(showhide === true)
|
||||
{
|
||||
if(lTerm==0 || (t.substr(0, lTerm)==zTerm))
|
||||
zTr[i].style.display = "";
|
||||
else
|
||||
zTr[i].style.display = "none";
|
||||
}
|
||||
else
|
||||
{
|
||||
zTr[i].style.display = "";
|
||||
}
|
||||
}
|
||||
return(found);
|
||||
}
|
||||
|
||||
function addTerm(inputName, zTerm, oldid) // inputName = "TS"|"TA"|"SY"
|
||||
{
|
||||
if(typeof(zTerm)=="undefined") // si pas de terme en argument, prendre dans la zone de saisie
|
||||
zTerm = document.forms["fTh"]["text"+inputName].value;
|
||||
if(typeof(zTerm)=="undefined") // si pas de terme en argument, prendre dans la zone de saisie
|
||||
zTerm = document.forms["fTh"]["text"+inputName].value;
|
||||
// alert(zTerm);
|
||||
// on cherche si le zTerm existe déjà
|
||||
// on cherche si le zTerm existe déjà
|
||||
// var parent_id = selectedThesaurusItem.getAttribute("id");
|
||||
// alert("parent_id = " + parent_id);
|
||||
|
||||
// found = scanTerms(inputName, true, false); // renuméroter et tout afficher
|
||||
var found = scanTerms(inputName, zTerm, false); // tout afficher
|
||||
if(!found)
|
||||
{
|
||||
// on cherche la div "thb" si elle existe
|
||||
var thb, thRef;
|
||||
for(thb=selectedThesaurusItem.firstChild; thb; thb=thb.nextSibling)
|
||||
{
|
||||
if(thb.nodeType==1 && thb.tagName=="DIV" && thb.id.substr(0,4)=="THB_")
|
||||
break;
|
||||
}
|
||||
if(!thb)
|
||||
{
|
||||
// on ajoute le premier fils ...
|
||||
// ... on crée le +/- en face du terme
|
||||
selectedThesaurusItem.firstChild.className = "tri";
|
||||
selectedThesaurusItem.firstChild.id = "THP_" + selectedThesaurusItem.id.substr(4);
|
||||
selectedThesaurusItem.firstChild.innerHTML = "-";
|
||||
// selectedThesaurusItem.nextid = "0";
|
||||
selectedThesaurusItem.setAttribute("nextid", "0");
|
||||
// ... on crée la div "THB"
|
||||
thb = selectedThesaurusItem.appendChild(document.createElement("DIV"));
|
||||
thb.className = "ob";
|
||||
thb.id = "THB_" + selectedThesaurusItem.id.substr(4);
|
||||
}
|
||||
|
||||
if(inputName=="TS") // on ajoute un terme spécifique
|
||||
{
|
||||
// un id pour le nouveau terme
|
||||
var nextid = parseInt(selectedThesaurusItem.getAttribute("nextid"));
|
||||
// selectedThesaurusItem.nextid = "" + (nextid+1);
|
||||
selectedThesaurusItem.setAttribute("nextid", "" + (nextid+1));
|
||||
// found = scanTerms(inputName, true, false); // renuméroter et tout afficher
|
||||
var found = scanTerms(inputName, zTerm, false); // tout afficher
|
||||
if(!found)
|
||||
{
|
||||
// on cherche la div "thb" si elle existe
|
||||
var thb, thRef;
|
||||
for(thb=selectedThesaurusItem.firstChild; thb; thb=thb.nextSibling)
|
||||
{
|
||||
if(thb.nodeType==1 && thb.tagName=="DIV" && thb.id.substr(0,4)=="THB_")
|
||||
break;
|
||||
}
|
||||
if(!thb)
|
||||
{
|
||||
// on ajoute le premier fils ...
|
||||
// ... on crée le +/- en face du terme
|
||||
selectedThesaurusItem.firstChild.className = "tri";
|
||||
selectedThesaurusItem.firstChild.id = "THP_" + selectedThesaurusItem.id.substr(4);
|
||||
selectedThesaurusItem.firstChild.innerHTML = "-";
|
||||
// selectedThesaurusItem.nextid = "0";
|
||||
selectedThesaurusItem.setAttribute("nextid", "0");
|
||||
// ... on crée la div "THB"
|
||||
thb = selectedThesaurusItem.appendChild(document.createElement("DIV"));
|
||||
thb.className = "ob";
|
||||
thb.id = "THB_" + selectedThesaurusItem.id.substr(4);
|
||||
}
|
||||
|
||||
// on ajoute le nouveau terme dans le thb : on crée une nouvelle div
|
||||
var div = document.createElement("DIV");
|
||||
div.className = "s_";
|
||||
if(selectedThesaurusItem.id == "THE_")
|
||||
div.id = "THE_" + nextid;
|
||||
else
|
||||
div.id = selectedThesaurusItem.id + "." + nextid;
|
||||
if(typeof(oldid)=="undefined")
|
||||
{
|
||||
// div.oldid = "?"; // permettra de repérer les nouveaux termes
|
||||
div.setAttribute("oldid", "?"); // permettra de repérer les nouveaux termes
|
||||
}
|
||||
else
|
||||
{
|
||||
// div.oldid = oldid; // le terme a provient des termes candidats
|
||||
div.setAttribute("oldid", oldid); // le terme a provient des termes candidats
|
||||
}
|
||||
div.setAttribute("lng", "");
|
||||
var u = div.appendChild(document.createElement("U"));
|
||||
//u.appendChild(document.createEntityReference("nbsp"));
|
||||
u.innerHTML = " ";
|
||||
div.appendChild(document.createTextNode(zTerm));
|
||||
thRef = thb.appendChild(div);
|
||||
}
|
||||
else // inputName="TA"|"SY" : on ajoute un terme associé ou un synonyme
|
||||
{
|
||||
var p = document.createElement("P");
|
||||
p.className = inputName.toLowerCase(); // ta ou sy
|
||||
p.appendChild(document.createTextNode(zTerm));
|
||||
thRef = thb.appendChild(p);
|
||||
nextid = document.getElementById("L"+inputName).nextid++;
|
||||
}
|
||||
if(inputName=="TS") // on ajoute un terme spécifique
|
||||
{
|
||||
// un id pour le nouveau terme
|
||||
var nextid = parseInt(selectedThesaurusItem.getAttribute("nextid"));
|
||||
// selectedThesaurusItem.nextid = "" + (nextid+1);
|
||||
selectedThesaurusItem.setAttribute("nextid", "" + (nextid+1));
|
||||
|
||||
// on ajoute aussi à la liste des termes
|
||||
tr = appendTerm(inputName, zTerm, nextid);
|
||||
// on scroll la liste pour montrer le nouveau terme, et on le selectionne
|
||||
tr.scrollIntoView(false);
|
||||
myGUI.select(tr);
|
||||
// on ajoute le nouveau terme dans le thb : on crée une nouvelle div
|
||||
var div = document.createElement("DIV");
|
||||
div.className = "s_";
|
||||
if(selectedThesaurusItem.id == "THE_")
|
||||
div.id = "THE_" + nextid;
|
||||
else
|
||||
div.id = selectedThesaurusItem.id + "." + nextid;
|
||||
if(typeof(oldid)=="undefined")
|
||||
{
|
||||
// div.oldid = "?"; // permettra de repérer les nouveaux termes
|
||||
div.setAttribute("oldid", "?"); // permettra de repérer les nouveaux termes
|
||||
}
|
||||
else
|
||||
{
|
||||
// div.oldid = oldid; // le terme a provient des termes candidats
|
||||
div.setAttribute("oldid", oldid); // le terme a provient des termes candidats
|
||||
}
|
||||
div.setAttribute("lng", "");
|
||||
var u = div.appendChild(document.createElement("U"));
|
||||
//u.appendChild(document.createEntityReference("nbsp"));
|
||||
u.innerHTML = " ";
|
||||
div.appendChild(document.createTextNode(zTerm));
|
||||
thRef = thb.appendChild(div);
|
||||
}
|
||||
else // inputName="TA"|"SY" : on ajoute un terme associé ou un synonyme
|
||||
{
|
||||
var p = document.createElement("P");
|
||||
p.className = inputName.toLowerCase(); // ta ou sy
|
||||
p.appendChild(document.createTextNode(zTerm));
|
||||
thRef = thb.appendChild(p);
|
||||
nextid = document.getElementById("L"+inputName).nextid++;
|
||||
}
|
||||
|
||||
tr.thRef = thRef; // lien du nouveau terme de la liste vers le thesaurus
|
||||
// on ajoute aussi à la liste des termes
|
||||
tr = appendTerm(inputName, zTerm, nextid);
|
||||
// on scroll la liste pour montrer le nouveau terme, et on le selectionne
|
||||
tr.scrollIntoView(false);
|
||||
myGUI.select(tr);
|
||||
|
||||
document.forms["fTh"]["text"+inputName].value = "";
|
||||
tr.thRef = thRef; // lien du nouveau terme de la liste vers le thesaurus
|
||||
|
||||
termChanged = true;
|
||||
|
||||
dirty();
|
||||
}
|
||||
document.forms["fTh"]["text"+inputName].value = "";
|
||||
|
||||
termChanged = true;
|
||||
|
||||
dirty();
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// alert("Le terme associé '"+newterm+"' existe déjà.");
|
||||
// alert("Le terme associé '"+newterm+"' existe déjà.");
|
||||
// }
|
||||
evt_kup(inputName);
|
||||
evt_kup(inputName);
|
||||
}
|
||||
|
||||
function dirty()
|
||||
{
|
||||
thesaurusChanged = true;
|
||||
document.getElementById("saveButton").style.display = "";
|
||||
thesaurusChanged = true;
|
||||
document.getElementById("saveButton").style.display = "";
|
||||
}
|
||||
/*
|
||||
function delTerm(inputName, zTerm) // inputName = "TS"|"TA"|"SY"
|
||||
{
|
||||
if(typeof(zTerm)=="undefined")
|
||||
zTerm = document.forms["fTh"]["text"+inputName].value;
|
||||
function delTerm(inputName, zTerm) // inputName = "TS"|"TA"|"SY"
|
||||
{
|
||||
if(typeof(zTerm)=="undefined")
|
||||
zTerm = document.forms["fTh"]["text"+inputName].value;
|
||||
|
||||
// on cherche si le zTerm existe déjà
|
||||
// zTr = scanTerms(inputName, true, false); // renuméroter et tout afficher
|
||||
var zTr = scanTerms(inputName, zTerm, false); // tout afficher
|
||||
if(zTr)
|
||||
{
|
||||
// si on a supprimé un terme spécifique, on vérifie s'il en reste
|
||||
var thb = zTr.thRef.parentNode;
|
||||
|
||||
if(inputName == "TS")
|
||||
{
|
||||
// on deplace du thesaurus vers les candidats (refuse), pour le champ special '(deleted)'
|
||||
var deleted=null
|
||||
var thb_deleted;
|
||||
// on cherche la branche de 'deleted' dans les cterms
|
||||
for(c=document.getElementById("CTERMS").firstChild; c && !deleted; c=c.nextSibling)
|
||||
{
|
||||
if(c.nodeType==1 && c.field && c.field=="(deleted)")
|
||||
deleted = c;
|
||||
}
|
||||
// si elle n'existe pas on la cree
|
||||
if(!deleted)
|
||||
{
|
||||
var zid = document.getElementById("CTERMS").nextid;
|
||||
document.getElementById("CTERMS").setAttribute("nextid", parseInt(zid)+1);
|
||||
|
||||
// on cree le grp
|
||||
deleted = document.getElementById("CTERMS").appendChild(document.createElement("DIV"));
|
||||
deleted.name = "CTERMSGRP";
|
||||
deleted.className = "s_ R_";
|
||||
deleted.id = "C"+zid;
|
||||
deleted.setAttribute("nextid", "0");
|
||||
deleted.setAttribute("field", "(deleted)");
|
||||
|
||||
var u = deleted.appendChild(document.createElement("U"));
|
||||
u.className = "tri";
|
||||
u.id = "THP_C"+zid;
|
||||
u.innerText = "+ ";
|
||||
|
||||
deleted.appendChild(document.createTextNode("(deleted)"));
|
||||
|
||||
thb_deleted = deleted.appendChild(document.createElement("DIV"));
|
||||
thb_deleted.className = "ob";
|
||||
thb_deleted.id = "THB_C"+zid;
|
||||
}
|
||||
else
|
||||
{
|
||||
zid = deleted.id.substr(1);
|
||||
thb_deleted = document.getElementById("THB_C" + zid);
|
||||
}
|
||||
// on cherche si le zTerm existe déjà
|
||||
// zTr = scanTerms(inputName, true, false); // renuméroter et tout afficher
|
||||
var zTr = scanTerms(inputName, zTerm, false); // tout afficher
|
||||
if(zTr)
|
||||
{
|
||||
// si on a supprimé un terme spécifique, on vérifie s'il en reste
|
||||
var thb = zTr.thRef.parentNode;
|
||||
|
||||
// var d = thb_deleted.appendChild(document.createElement("DIV") );
|
||||
// d.className = "s_ R_";
|
||||
// d.id = "TCE_R" + zid + "." + deleted.nextid;
|
||||
// d.appendChild(zTr.thRef.firstChild.nextSibling.cloneNode(false) );
|
||||
// d.setAttribute("oldid", zTr.thRef.oldid ? zTr.thRef.oldid : zTr.thRef.id.substr(4) );
|
||||
|
||||
// deleted.setAttribute("nextid", parseInt(deleted.getAttribute("nextid")+1) );
|
||||
if(inputName == "TS")
|
||||
{
|
||||
// on deplace du thesaurus vers les candidats (refuse), pour le champ special '(deleted)'
|
||||
var deleted=null
|
||||
var thb_deleted;
|
||||
// on cherche la branche de 'deleted' dans les cterms
|
||||
for(c=document.getElementById("CTERMS").firstChild; c && !deleted; c=c.nextSibling)
|
||||
{
|
||||
if(c.nodeType==1 && c.field && c.field=="(deleted)")
|
||||
deleted = c;
|
||||
}
|
||||
// si elle n'existe pas on la cree
|
||||
if(!deleted)
|
||||
{
|
||||
var zid = document.getElementById("CTERMS").nextid;
|
||||
document.getElementById("CTERMS").setAttribute("nextid", parseInt(zid)+1);
|
||||
|
||||
deleteBranch(zTr.thRef, thb_deleted);
|
||||
}
|
||||
thb.removeChild(zTr.thRef); // supprime le node du thesaurus
|
||||
if(!thb.firstChild)
|
||||
{
|
||||
// plus de ts : on nettoie
|
||||
var the = thb.parentNode;
|
||||
the.removeChild(thb); // supprime thb
|
||||
var u = the.firstChild;
|
||||
u.innerHTML = " " // vire le +/-
|
||||
u.className = "";
|
||||
}
|
||||
// on cree le grp
|
||||
deleted = document.getElementById("CTERMS").appendChild(document.createElement("DIV"));
|
||||
deleted.name = "CTERMSGRP";
|
||||
deleted.className = "s_ R_";
|
||||
deleted.id = "C"+zid;
|
||||
deleted.setAttribute("nextid", "0");
|
||||
deleted.setAttribute("field", "(deleted)");
|
||||
|
||||
// on supprime aussi de la liste des termes
|
||||
zTr.parentNode.removeChild(zTr);
|
||||
document.forms["fTh"]["text"+inputName].value = "";
|
||||
var u = deleted.appendChild(document.createElement("U"));
|
||||
u.className = "tri";
|
||||
u.id = "THP_C"+zid;
|
||||
u.innerText = "+ ";
|
||||
|
||||
termChanged = true;
|
||||
|
||||
dirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
// alert("Le terme associé '"+newterm+"' n' existe pas.");
|
||||
}
|
||||
evt_kup(inputName);
|
||||
}
|
||||
*/
|
||||
deleted.appendChild(document.createTextNode("(deleted)"));
|
||||
|
||||
thb_deleted = deleted.appendChild(document.createElement("DIV"));
|
||||
thb_deleted.className = "ob";
|
||||
thb_deleted.id = "THB_C"+zid;
|
||||
}
|
||||
else
|
||||
{
|
||||
zid = deleted.id.substr(1);
|
||||
thb_deleted = document.getElementById("THB_C" + zid);
|
||||
}
|
||||
|
||||
// var d = thb_deleted.appendChild(document.createElement("DIV") );
|
||||
// d.className = "s_ R_";
|
||||
// d.id = "TCE_R" + zid + "." + deleted.nextid;
|
||||
// d.appendChild(zTr.thRef.firstChild.nextSibling.cloneNode(false) );
|
||||
// d.setAttribute("oldid", zTr.thRef.oldid ? zTr.thRef.oldid : zTr.thRef.id.substr(4) );
|
||||
|
||||
// deleted.setAttribute("nextid", parseInt(deleted.getAttribute("nextid")+1) );
|
||||
|
||||
deleteBranch(zTr.thRef, thb_deleted);
|
||||
}
|
||||
thb.removeChild(zTr.thRef); // supprime le node du thesaurus
|
||||
if(!thb.firstChild)
|
||||
{
|
||||
// plus de ts : on nettoie
|
||||
var the = thb.parentNode;
|
||||
the.removeChild(thb); // supprime thb
|
||||
var u = the.firstChild;
|
||||
u.innerHTML = " " // vire le +/-
|
||||
u.className = "";
|
||||
}
|
||||
|
||||
// on supprime aussi de la liste des termes
|
||||
zTr.parentNode.removeChild(zTr);
|
||||
document.forms["fTh"]["text"+inputName].value = "";
|
||||
|
||||
termChanged = true;
|
||||
|
||||
dirty();
|
||||
}
|
||||
else
|
||||
{
|
||||
// alert("Le terme associé '"+newterm+"' n' existe pas.");
|
||||
}
|
||||
evt_kup(inputName);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// supprime un terme et tous ses fils (deplace la branche dans '(deleted)' )
|
||||
function deleteBranch(the, thb_deleted)
|
||||
{
|
||||
newdel = thb_deleted.appendChild(the.cloneNode(true));
|
||||
deleteBranch0(newdel, "R"+thb_deleted.parentNode.id.substr(1));
|
||||
}
|
||||
// supprime un terme et tous ses fils (deplace la branche dans '(deleted)' )
|
||||
function deleteBranch(the, thb_deleted)
|
||||
{
|
||||
newdel = thb_deleted.appendChild(the.cloneNode(true));
|
||||
deleteBranch0(newdel, "R"+thb_deleted.parentNode.id.substr(1));
|
||||
}
|
||||
|
||||
function deleteBranch0(node, pfxid)
|
||||
{
|
||||
if(node.id && node.id.substr(0,2)=="TH")
|
||||
{
|
||||
oldid = node.oldid ? node.oldid : node.id.substr(4);
|
||||
if(node.id.substr(0,4)=="THE_")
|
||||
{
|
||||
node.id = "TCE_" + pfxid + "_" + oldid;
|
||||
node.className = "s_ R_";
|
||||
node.setAttribute("oldid", oldid);
|
||||
}
|
||||
else // THB_ ou THP_
|
||||
{
|
||||
node.id = node.id.substr(0,4) + pfxid + "_" + oldid;
|
||||
}
|
||||
}
|
||||
for(var node=node.firstChild; node; node=node.nextSibling)
|
||||
{
|
||||
deleteBranch0(node, pfxid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
function deleteBranch0(node, pfxid)
|
||||
{
|
||||
if(node.id && node.id.substr(0,2)=="TH")
|
||||
{
|
||||
oldid = node.oldid ? node.oldid : node.id.substr(4);
|
||||
if(node.id.substr(0,4)=="THE_")
|
||||
{
|
||||
node.id = "TCE_" + pfxid + "_" + oldid;
|
||||
node.className = "s_ R_";
|
||||
node.setAttribute("oldid", oldid);
|
||||
}
|
||||
else // THB_ ou THP_
|
||||
{
|
||||
node.id = node.id.substr(0,4) + pfxid + "_" + oldid;
|
||||
}
|
||||
}
|
||||
for(var node=node.firstChild; node; node=node.nextSibling)
|
||||
{
|
||||
deleteBranch0(node, pfxid);
|
||||
}
|
||||
}
|
||||
*/
|
||||
// supprime un terme et tous ses fils (deplace 'e plat') dans '(deleted)'
|
||||
function deleteBranch(the, thb_deleted)
|
||||
{
|
||||
if(the.id.substr(0,4)=="THE_")
|
||||
{
|
||||
var d = thb_deleted.appendChild(document.createElement("DIV") );
|
||||
d.className = "s_ R_";
|
||||
d.id = "TCE_R" + (thb_deleted.parentNode.id.substr(1)) + "." + (thb_deleted.parentNode.getAttribute("nextid"));
|
||||
thb_deleted.parentNode.setAttribute("nextid", parseInt(thb_deleted.parentNode.getAttribute("nextid")+1) );
|
||||
d.appendChild(the.firstChild.nextSibling.cloneNode(false) );
|
||||
d.setAttribute("oldid", the.oldid ? the.oldid : the.id.substr(4) );
|
||||
if(the.firstChild.nextSibling.nextSibling)
|
||||
{
|
||||
for(var the=the.firstChild.nextSibling.nextSibling.firstChild; the; the=the.nextSibling)
|
||||
{
|
||||
deleteBranch(the, thb_deleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(the.id.substr(0,4)=="THE_")
|
||||
{
|
||||
var d = thb_deleted.appendChild(document.createElement("DIV") );
|
||||
d.className = "s_ R_";
|
||||
d.id = "TCE_R" + (thb_deleted.parentNode.id.substr(1)) + "." + (thb_deleted.parentNode.getAttribute("nextid"));
|
||||
thb_deleted.parentNode.setAttribute("nextid", parseInt(thb_deleted.parentNode.getAttribute("nextid")+1) );
|
||||
d.appendChild(the.firstChild.nextSibling.cloneNode(false) );
|
||||
d.setAttribute("oldid", the.oldid ? the.oldid : the.id.substr(4) );
|
||||
if(the.firstChild.nextSibling.nextSibling)
|
||||
{
|
||||
for(var the=the.firstChild.nextSibling.nextSibling.firstChild; the; the=the.nextSibling)
|
||||
{
|
||||
deleteBranch(the, thb_deleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function alertNode(n, msg)
|
||||
{
|
||||
if(typeof(msg)=="undefined")
|
||||
msg = "";
|
||||
if(n)
|
||||
{
|
||||
if(n.nodeType==1)
|
||||
{
|
||||
alert(msg + " : <"+n.nodeName+" id='"+n.id+"'>");
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(msg + " : nodeType="+n.nodeType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(msg + " : NULL");
|
||||
}
|
||||
if(typeof(msg)=="undefined")
|
||||
msg = "";
|
||||
if(n)
|
||||
{
|
||||
if(n.nodeType==1)
|
||||
{
|
||||
alert(msg + " : <"+n.nodeName+" id='"+n.id+"'>");
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(msg + " : nodeType="+n.nodeType);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(msg + " : NULL");
|
||||
}
|
||||
}
|
||||
|
||||
function appendTerm(inputName, new_term, id)
|
||||
{
|
||||
var tr = document.createElement("TR");
|
||||
tr.id = inputName + "_"+id;
|
||||
tr.className = "s_";
|
||||
var td = tr.appendChild(document.createElement("TD"));
|
||||
td.appendChild(document.createTextNode(new_term));
|
||||
td = tr.appendChild(document.createElement("TD"));
|
||||
td.innerHTML = "<img id='"+inputName+"f_"+id+"' src='./images/noflag.gif' />";
|
||||
td = tr.appendChild(document.createElement("TD"));
|
||||
td.appendChild(document.createTextNode(" "));
|
||||
var tr = document.createElement("TR");
|
||||
tr.id = inputName + "_"+id;
|
||||
tr.className = "s_";
|
||||
var td = tr.appendChild(document.createElement("TD"));
|
||||
td.appendChild(document.createTextNode(new_term));
|
||||
td = tr.appendChild(document.createElement("TD"));
|
||||
td.innerHTML = "<img id='"+inputName+"f_"+id+"' src='./images/noflag.gif' />";
|
||||
td = tr.appendChild(document.createElement("TD"));
|
||||
td.appendChild(document.createTextNode(" "));
|
||||
|
||||
var zTable = document.getElementById("L"+inputName);
|
||||
return(zTable.appendChild(tr));
|
||||
var zTable = document.getElementById("L"+inputName);
|
||||
return(zTable.appendChild(tr));
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,31 +1,31 @@
|
||||
|
||||
function loadXMLDoc(url, post_parms, asxml)
|
||||
{
|
||||
if(typeof(asxml)=="undefined")
|
||||
asxml = false;
|
||||
out = null;
|
||||
xmlhttp = null;
|
||||
// code for Mozilla, etc.
|
||||
if (window.XMLHttpRequest)
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
|
||||
if (xmlhttp)
|
||||
{
|
||||
// xmlhttp.onreadystatechange=state_Change
|
||||
if(post_parms)
|
||||
{
|
||||
xmlhttp.open("POST", url, false);
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
xmlhttp.send(post_parms);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlhttp.open("GET", url, false);
|
||||
xmlhttp.send(null);
|
||||
}
|
||||
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
|
||||
}
|
||||
return(out);
|
||||
if(typeof(asxml)=="undefined")
|
||||
asxml = false;
|
||||
out = null;
|
||||
xmlhttp = null;
|
||||
// code for Mozilla, etc.
|
||||
if (window.XMLHttpRequest)
|
||||
xmlhttp=new XMLHttpRequest();
|
||||
else if (window.ActiveXObject)
|
||||
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
||||
|
||||
if (xmlhttp)
|
||||
{
|
||||
// xmlhttp.onreadystatechange=state_Change
|
||||
if(post_parms)
|
||||
{
|
||||
xmlhttp.open("POST", url, false);
|
||||
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
|
||||
xmlhttp.send(post_parms);
|
||||
}
|
||||
else
|
||||
{
|
||||
xmlhttp.open("GET", url, false);
|
||||
xmlhttp.send(null);
|
||||
}
|
||||
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
|
||||
}
|
||||
return(out);
|
||||
}
|
||||
|
Reference in New Issue
Block a user