Fix JS code style

This commit is contained in:
Romain Neutron
2013-11-11 11:25:52 +01:00
parent ea6b93b88a
commit dc5c12a592
52 changed files with 11500 additions and 11500 deletions

View File

@@ -1,82 +1,82 @@
var p4 = p4 || {}; var p4 = p4 || {};
$(document).ready(function(){ $(document).ready(function(){
$('input.input-button').hover( $('input.input-button').hover(
function(){$(this).addClass('hover');}, function(){$(this).addClass('hover');},
function(){$(this).removeClass('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') if(jq_date == 'en')
{ {
jq_date = 'en-GB'; jq_date = 'en-GB';
} }
$.datepicker.setDefaults({showMonthAfterYear: false}); $.datepicker.setDefaults({showMonthAfterYear: false});
$.datepicker.setDefaults($.datepicker.regional[jq_date]); $.datepicker.setDefaults($.datepicker.regional[jq_date]);
$('a.infoDialog,div.infoDialog').live('click',function(event){ $('a.infoDialog,div.infoDialog').live('click',function(event){
console.log("click"); console.log("click");
infoDialog($(this)); infoDialog($(this));
}); });
var cache = $('#mainMenu .helpcontextmenu'); var cache = $('#mainMenu .helpcontextmenu');
$('.context-menu-item',cache).hover(function(){$(this).addClass('context-menu-item-hover');},function(){$(this).removeClass('context-menu-item-hover');}); $('.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, $('#help-trigger').contextMenu('#mainMenu .helpcontextmenu',{openEvt:'click',dropDown:true,theme:'vista', dropDown:true,
showTransition:'slideDown', showTransition:'slideDown',
hideTransition:'hide', hideTransition:'hide',
shadow:false shadow:false
}); });
$('#notification_trigger').bind('mousedown',function(event){ $('#notification_trigger').bind('mousedown',function(event){
event.stopPropagation(); event.stopPropagation();
var box = $('#notification_box'); var box = $('#notification_box');
if($(this).hasClass('open')) if($(this).hasClass('open'))
{ {
box.hide(); box.hide();
$(this).removeClass('open'); $(this).removeClass('open');
clear_notifications(); clear_notifications();
} }
else else
{ {
box.show(); box.show();
fix_notification_height(); fix_notification_height();
$(this).addClass('open'); $(this).addClass('open');
read_notifications(); read_notifications();
} }
}); });
$(this).bind('mousedown',function(){ $(this).bind('mousedown',function(){
var not_trigger = $('#notification_trigger'); var not_trigger = $('#notification_trigger');
if(not_trigger.hasClass('open')) if(not_trigger.hasClass('open'))
not_trigger.trigger('click'); not_trigger.trigger('click');
}); });
$('#notification_box').bind('mousedown',function(event){ $('#notification_box').bind('mousedown',function(event){
event.stopPropagation(); event.stopPropagation();
}); });
$('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');}); $('#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('mouseout',function(){$(this).removeClass('hover');});
$(this).bind('mousedown',function(){ $(this).bind('mousedown',function(){
var box = $('#notification_box'); var box = $('#notification_box');
if($('#notification_trigger').hasClass('open')) if($('#notification_trigger').hasClass('open'))
{ {
box.hide(); box.hide();
$('#notification_trigger').removeClass('open'); $('#notification_trigger').removeClass('open');
clear_notifications(); clear_notifications();
} }
}); });
set_notif_position(); set_notif_position();
}); });
@@ -84,149 +84,149 @@ $(document).ready(function(){
function login(what) function login(what)
{ {
if (confirm(language.confirmRedirectAuth)) { if (confirm(language.confirmRedirectAuth)) {
if(what != undefined) if(what != undefined)
{ {
EcrireCookie('last_act',what,null,'/'); EcrireCookie('last_act',what,null,'/');
} }
self.location.replace('/login/?postlog=1'); self.location.replace('/login/?postlog=1');
} }
return false; return false;
} }
function EcrireCookie(nom, valeur) function EcrireCookie(nom, valeur)
{ {
var argv=EcrireCookie.arguments; var argv=EcrireCookie.arguments;
var argc=EcrireCookie.arguments.length; var argc=EcrireCookie.arguments.length;
var expires=(argc > 2) ? argv[2] : null; var expires=(argc > 2) ? argv[2] : null;
var path=(argc > 3) ? argv[3] : null; var path=(argc > 3) ? argv[3] : null;
var domain=(argc > 4) ? argv[4] : null; var domain=(argc > 4) ? argv[4] : null;
var secure=(argc > 5) ? argv[5] : false; var secure=(argc > 5) ? argv[5] : false;
var cook = nom+"="+escape(valeur)+ var cook = nom+"="+escape(valeur)+
((expires===null) ? "" : ("; expires="+expires.toGMTString()))+ ((expires===null) ? "" : ("; expires="+expires.toGMTString()))+
((path===null) ? "" : ("; path="+path))+ ((path===null) ? "" : ("; path="+path))+
((domain===null) ? "" : ("; domain="+domain))+ ((domain===null) ? "" : ("; domain="+domain))+
((secure===true) ? "; secure" : ""); ((secure===true) ? "; secure" : "");
document.cookie = cook; document.cookie = cook;
} }
function fix_notification_height() function fix_notification_height()
{ {
var box = $('#notification_box'); var box = $('#notification_box');
var not = $('.notification',box); var not = $('.notification',box);
var n = not.length; var n = not.length;
var not_t = $('.notification_title',box); var not_t = $('.notification_title',box);
var n_t = not_t.length; var n_t = not_t.length;
h = not.outerHeight() * n + not_t.outerHeight() * n_t; h = not.outerHeight() * n + not_t.outerHeight() * n_t;
h = h > 350 ? 350 : h; h = h > 350 ? 350 : h;
box.stop().animate({height:h}); box.stop().animate({height:h});
} }
function set_notif_position() function set_notif_position()
{ {
var trigger = $('#notification_trigger'); var trigger = $('#notification_trigger');
if(trigger.length === 0) if(trigger.length === 0)
return; return;
$('#notification_box').css({ $('#notification_box').css({
'left':Math.round(trigger.offset().left - 1) 'left':Math.round(trigger.offset().left - 1)
}); });
} }
$(window).bind('resize', function(){ $(window).bind('resize', function(){
set_notif_position(); set_notif_position();
}); });
function print_notifications(page) function print_notifications(page)
{ {
page = parseInt(page); page = parseInt(page);
var buttons = {}; var buttons = {};
buttons[language.fermer] = function(){ buttons[language.fermer] = function(){
$('#notifications-dialog').dialog('close'); $('#notifications-dialog').dialog('close');
}; };
if($('#notifications-dialog').length === 0) if($('#notifications-dialog').length === 0)
$('body').append('<div id="notifications-dialog" class="loading"></div>'); $('body').append('<div id="notifications-dialog" class="loading"></div>');
$('#notifications-dialog') $('#notifications-dialog')
.dialog({ .dialog({
title:language.notifications, title:language.notifications,
autoOpen:false, autoOpen:false,
closeOnEscape:true, closeOnEscape:true,
resizable:false, resizable:false,
draggable:false, draggable:false,
modal:true, modal:true,
width:500, width:500,
height:400, height:400,
overlay: { overlay: {
backgroundColor: '#000', backgroundColor: '#000',
opacity: 0.7 opacity: 0.7
}, },
close:function(event,ui) close:function(event,ui)
{ {
$('#notifications-dialog').dialog('destroy').remove(); $('#notifications-dialog').dialog('destroy').remove();
} }
}).dialog('option','buttons',buttons) }).dialog('option','buttons',buttons)
.dialog('open'); .dialog('open');
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/user/notifications/", url: "/user/notifications/",
dataType : 'json', dataType : 'json',
data: { data: {
page:page page:page
}, },
error: function(data){ error: function(data){
$('#notifications-dialog').removeClass('loading'); $('#notifications-dialog').removeClass('loading');
}, },
timeout: function(data){ timeout: function(data){
$('#notifications-dialog').removeClass('loading'); $('#notifications-dialog').removeClass('loading');
}, },
success: function(data){ success: function(data){
$('#notifications-dialog').removeClass('loading'); $('#notifications-dialog').removeClass('loading');
var cont = $('#notifications-dialog'); var cont = $('#notifications-dialog');
if(page === 0) if(page === 0)
cont.empty(); cont.empty();
else else
$('.notification_next',cont).remove(); $('.notification_next',cont).remove();
for (i in data.notifications) for (i in data.notifications)
{ {
var id = 'notif_date_'+i; var id = 'notif_date_'+i;
var date_cont = $('#'+id); var date_cont = $('#'+id);
if(date_cont.length === 0) if(date_cont.length === 0)
{ {
cont.append('<div id="'+id+'"><div class="notification_title">'+data.notifications[i].display+'</div></div>'); cont.append('<div id="'+id+'"><div class="notification_title">'+data.notifications[i].display+'</div></div>');
date_cont = $('#'+id); date_cont = $('#'+id);
} }
for (j in data.notifications[i].notifications) for (j in data.notifications[i].notifications)
{ {
var loc_dat = data.notifications[i].notifications[j]; var loc_dat = data.notifications[i].notifications[j];
var html = '<div style="position:relative;" id="notification_'+loc_dat.id+'" class="notification">'+ 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;">'+ '<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'+
loc_dat.icon+ loc_dat.icon+
'</td><td>'+ '</td><td>'+
'<div style="position:relative;" class="'+loc_dat.classname+'">'+ '<div style="position:relative;" class="'+loc_dat.classname+'">'+
loc_dat.text+' <span class="time">'+loc_dat.time+'</span></div>'+ loc_dat.text+' <span class="time">'+loc_dat.time+'</span></div>'+
'</td></tr></table>'+ '</td></tr></table>'+
'</div>'; '</div>';
date_cont.append(html); date_cont.append(html);
} }
} }
var next_ln = $.trim(data.next); var next_ln = $.trim(data.next);
if(next_ln !== '') if(next_ln !== '')
{ {
cont.append('<div class="notification_next">'+next_ln+'</div>'); cont.append('<div class="notification_next">'+next_ln+'</div>');
} }
// '<div style="position:relative;" id="notification_'.$row['id'].'" class="notification '.($row['unread'] == '1' ? 'unread':'').'">'. // '<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;">'. // '<table style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tr><td style="width:25px;">'.
@@ -238,40 +238,40 @@ function print_notifications(page)
// '</div>' // '</div>'
} }
}); });
} }
function read_notifications() function read_notifications()
{ {
var notifications = []; var notifications = [];
$('#notification_box .unread').each(function(){ $('#notification_box .unread').each(function(){
notifications.push($(this).attr('id').split('_').pop()); notifications.push($(this).attr('id').split('_').pop());
}); });
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/user/notifications/read/", url: "/user/notifications/read/",
data: { data: {
notifications:notifications.join('_') notifications:notifications.join('_')
}, },
success: function(data){ success: function(data){
$('#notification_trigger .counter').css('visibility','hidden').empty(); $('#notification_trigger .counter').css('visibility','hidden').empty();
} }
}); });
} }
function clear_notifications() function clear_notifications()
{ {
var unread = $('#notification_box .unread'); var unread = $('#notification_box .unread');
if(unread.length === 0) if(unread.length === 0)
return; return;
unread.removeClass('unread'); unread.removeClass('unread');
$('#notification_trigger .counter').css('visibility','hidden').empty(); $('#notification_trigger .counter').css('visibility','hidden').empty();
} }
@@ -283,254 +283,254 @@ function clear_notifications()
function getMyRss(renew) function getMyRss(renew)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/prod/prodFeedBack.php", url: "/prod/prodFeedBack.php",
dataType: 'json', dataType: 'json',
data: datas, data: datas,
success: function(data){ success: function(data){
} }
}); });
} }
function setPref(name,value) function setPref(name,value)
{ {
if(jQuery.data['pref_'+name] && jQuery.data['pref_'+name].abort) if(jQuery.data['pref_'+name] && jQuery.data['pref_'+name].abort)
{ {
jQuery.data['pref_'+name].abort(); jQuery.data['pref_'+name].abort();
jQuery.data['pref_'+name] = false; jQuery.data['pref_'+name] = false;
} }
jQuery.data['pref_'+name] = $.ajax({ jQuery.data['pref_'+name] = $.ajax({
type: "POST", type: "POST",
url: "/user/preferences/", url: "/user/preferences/",
data: { data: {
prop:name, prop:name,
value:value value:value
}, },
dataType:'json', dataType:'json',
timeout: function(){ timeout: function(){
jQuery.data['pref_'+name] = false; jQuery.data['pref_'+name] = false;
}, },
error: function(){ error: function(){
jQuery.data['pref_'+name] = false; jQuery.data['pref_'+name] = false;
}, },
success: function(data){ success: function(data){
if(data.success) if(data.success)
{ {
humane.info(data.message); humane.info(data.message);
} }
else else
{ {
humane.error(data.message); humane.error(data.message);
} }
jQuery.data['pref_'+name] = false; jQuery.data['pref_'+name] = false;
return; return;
} }
}); });
} }
function infoDialog(el) function infoDialog(el)
{ {
$("#DIALOG").attr('title','') $("#DIALOG").attr('title','')
.empty() .empty()
.append(el.attr('infos')) .append(el.attr('infos'))
.dialog({ .dialog({
autoOpen:false, autoOpen:false,
closeOnEscape:true, closeOnEscape:true,
resizable:false, resizable:false,
draggable:false, draggable:false,
width:600, width:600,
height:400, height:400,
modal:true, modal:true,
overlay: { overlay: {
backgroundColor: '#000', backgroundColor: '#000',
opacity: 0.7 opacity: 0.7
} }
}).dialog('open').css({'overflow-x':'auto','overflow-y':'auto'}); }).dialog('open').css({'overflow-x':'auto','overflow-y':'auto'});
} }
function manageSession(data, showMessages) function manageSession(data, showMessages)
{ {
if(typeof(showMessages) == "undefined") if(typeof(showMessages) == "undefined")
showMessages = false; showMessages = false;
if(data.status == 'disconnected' || data.status == 'session') if(data.status == 'disconnected' || data.status == 'session')
{ {
disconnected(); disconnected();
return false; return false;
} }
if(showMessages) if(showMessages)
{ {
var box = $('#notification_box'); var box = $('#notification_box');
box.empty().append(data.notifications); box.empty().append(data.notifications);
if(box.is(':visible')) if(box.is(':visible'))
fix_notification_height(); fix_notification_height();
if($('.notification.unread',box).length > 0) if($('.notification.unread',box).length > 0)
{ {
var trigger = $('#notification_trigger') ; var trigger = $('#notification_trigger') ;
$('.counter',trigger) $('.counter',trigger)
.empty() .empty()
.append($('.notification.unread',box).length); .append($('.notification.unread',box).length);
$('.counter',trigger).css('visibility','visible'); $('.counter',trigger).css('visibility','visible');
} }
else else
$('#notification_trigger .counter').css('visibility','hidden').empty(); $('#notification_trigger .counter').css('visibility','hidden').empty();
if(data.changed.length > 0) if(data.changed.length > 0)
{ {
var current_open = $('.SSTT.ui-state-active'); var current_open = $('.SSTT.ui-state-active');
var current_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false; var current_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false;
var main_open = false; var main_open = false;
for(var i=0; i!=data.changed.length; i++) for(var i=0; i!=data.changed.length; i++)
{
var sstt = $('#SSTT_'+data.changed[i]);
if(sstt.size() === 0)
{ {
if(main_open === false) var sstt = $('#SSTT_'+data.changed[i]);
{ if(sstt.size() === 0)
$('#baskets .bloc').animate({'top':30}, function(){$('#baskets .alert_datas_changed:first').show()}); {
main_open = true; 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('' !== $.trim(data.message))
if(!sstt.hasClass('active')) {
sstt.addClass('unread'); if($('#MESSAGE').length === 0)
else $('body').append('<div id="#MESSAGE"></div>');
{ $('#MESSAGE')
$('.alert_datas_changed', $('#SSTT_content_'+data.changed[i])).show(); .empty()
} .append(data.message+'<div style="margin:20px;"><input type="checkbox" class="dialog_remove" />'+language.hideMessage+'</div>')
} .attr('title','Global Message')
} .dialog({
} autoOpen:false,
if('' !== $.trim(data.message)) closeOnEscape:true,
{ resizable:false,
if($('#MESSAGE').length === 0) draggable:false,
$('body').append('<div id="#MESSAGE"></div>'); modal:true,
$('#MESSAGE') close:function()
.empty() {
.append(data.message+'<div style="margin:20px;"><input type="checkbox" class="dialog_remove" />'+language.hideMessage+'</div>') if($('.dialog_remove:checked',$(this)).length > 0)
.attr('title','Global Message') setTemporaryPref('message',0);
.dialog({ }
autoOpen:false, })
closeOnEscape:true, .dialog('open');
resizable:false, }
draggable:false, }
modal:true, return true;
close:function()
{
if($('.dialog_remove:checked',$(this)).length > 0)
setTemporaryPref('message',0);
}
})
.dialog('open');
}
}
return true;
} }
function disconnected() function disconnected()
{ {
showModal('disconnected',{title:'Disconnection'}); showModal('disconnected',{title:'Disconnection'});
} }
function showModal(cas, options){ function showModal(cas, options){
var content = ''; var content = '';
var callback = null; var callback = null;
var button = { var button = {
"OK": function(e) "OK": function(e)
{ {
hideOverlay(3); hideOverlay(3);
$(this).dialog("close"); $(this).dialog("close");
return; return;
}}; }};
var escape = true; var escape = true;
var onClose = function(){}; var onClose = function(){};
switch (cas) { switch (cas) {
case 'timeout': case 'timeout':
content = language.serverTimeout; content = language.serverTimeout;
break; break;
case 'error': case 'error':
content = language.serverError; content = language.serverError;
break; break;
case 'disconnected': case 'disconnected':
content = language.serverDisconnected; content = language.serverDisconnected;
escape=false; escape=false;
callback = function(e){ self.location.replace(self.location.href)}; callback = function(e){ self.location.replace(self.location.href)};
break; break;
default: default:
break; break;
} }
p4.Alerts(options.title, content, callback); p4.Alerts(options.title, content, callback);
return; return;
} }
function showOverlay(n,appendto,callback, zIndex){ function showOverlay(n,appendto,callback, zIndex){
var div ="OVERLAY"; var div ="OVERLAY";
if(typeof(n)!="undefined") if(typeof(n)!="undefined")
div+=n; div+=n;
if($('#'+div).length === 0) if($('#'+div).length === 0)
{ {
if(typeof(appendto)=='undefined') if(typeof(appendto)=='undefined')
appendto = 'body'; appendto = 'body';
$(appendto).append('<div id="'+div+'" style="display:none;">&nbsp;</div>'); $(appendto).append('<div id="'+div+'" style="display:none;">&nbsp;</div>');
} }
var css = { var css = {
display: 'block', display: 'block',
opacity: 0, opacity: 0,
right:0, right:0,
bottom:0, bottom:0,
position:'absolute', position:'absolute',
top:0, top:0,
zIndex:zIndex, zIndex:zIndex,
left:0 left:0
}; };
if(parseInt(zIndex) > 0) if(parseInt(zIndex) > 0)
css['zIndex'] = parseInt(zIndex); css['zIndex'] = parseInt(zIndex);
if(typeof(callback) != 'function') if(typeof(callback) != 'function')
callback = function(){}; callback = function(){};
$('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();}); $('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();});
if ($.browser.msie && $.browser.version == '6.0') { if ($.browser.msie && $.browser.version == '6.0') {
$('select').css({ $('select').css({
visibility: 'hidden' visibility: 'hidden'
}); });
} }
} }
function hideDwnl(){ function hideDwnl(){
hideOverlay(2); hideOverlay(2);
$('#MODALDL').css({ $('#MODALDL').css({
'display': 'none' 'display': 'none'
}); });
} }
function hideOverlay(n){ function hideOverlay(n){
if ($.browser.msie && $.browser.version == '6.0') { if ($.browser.msie && $.browser.version == '6.0') {
$('select').css({ $('select').css({
visibility: 'visible' visibility: 'visible'
}); });
} }
var div = "OVERLAY"; var div = "OVERLAY";
if(typeof(n)!="undefined") if(typeof(n)!="undefined")
div+=n; div+=n;
$('#'+div).hide().remove(); $('#'+div).hide().remove();
} }

View File

@@ -1,249 +1,249 @@
(function( $ ){ (function( $ ){
var methods = { var methods = {
init : function( options ) { init : function( options ) {
var settings = { var settings = {
'zoomable' : false, 'zoomable' : false,
'display_full_screen' : false 'display_full_screen' : false
}; };
return this.each(function() { return this.each(function() {
var $this = $(this), data = $(this).data('image_enhance'); var $this = $(this), data = $(this).data('image_enhance');
if ( ! data ) if ( ! data )
{ {
if ( options ) { if ( options ) {
$.extend( settings, options ); $.extend( settings, options );
} }
var wrapper = $('.thumb_wrapper', $(this)); var wrapper = $('.thumb_wrapper', $(this));
var $image =$('img', $this); var $image =$('img', $this);
wrapper.css('position','relative'); wrapper.css('position','relative');
reset_position($this); reset_position($this);
if(settings.display_full_screen) if(settings.display_full_screen)
{ {
$image.parent() $image.parent()
.append('<div class="image_enhance_titlebar" style="display:none;">\n\ .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_options"><span class="full"><img src="/skins/icons/fullscreen.gif" /></span></div>\n\
<div class="image_enhance_title_bg"></div></div>'); <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() $image.parent()
.bind('mouseover.image_enhance', function(){ .bind('mouseover.image_enhance', function(){
$titlebar.stop().show().animate({ $titlebar.stop().show().animate({
'height':28 'height':28
}, 150); }, 150);
}) })
.bind('mouseout.image_enhance', function(){ .bind('mouseout.image_enhance', function(){
$titlebar.stop().animate({ $titlebar.stop().animate({
'height':0 'height':0
}, 150, function(){ }, 150, function(){
$titlebar.hide() $titlebar.hide()
}); });
}); });
$('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function(){ $('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function(){
$('body').append('<div class="image_enhance_theatre">\n\ $('body').append('<div class="image_enhance_theatre">\n\
\n\ \n\
<div class="image_enhance_theatre_closer_wrapper"><span class="closer">close</span></div>\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\ <img style="width:'+image_width+'px;height:'+image_height+'" src="'+$image.attr('src')+'"/>\n\
</div>'); </div>');
var $theatre = $('.image_enhance_theatre'); var $theatre = $('.image_enhance_theatre');
var $theatre_img = $('img', $theatre); var $theatre_img = $('img', $theatre);
$(window).bind('resize.image_enhance dblclick.image_enhance',function(event){ $(window).bind('resize.image_enhance dblclick.image_enhance',function(event){
if(event.type == 'dblclick') if(event.type == 'dblclick')
{ {
$theatre_img.removeClass('zoomed'); $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) var t1 = parseInt($img.css('top'));
{ var l1 = parseInt($img.css('left'));
if(typeof $image.draggable !== 'function' && window.console) var w1 = $img.width();
console.error('zoomable require jquery UI\'s draggable'); var h1 = $img.height();
if($image.attr('ondragstart')) var w2,t2;
{
$image.removeAttr('ondragstart'); 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
});
} }
}); var datas = $(this).data('image_enhance');
},
destroy : function( ) { h2 = Math.round(w2 / ratio);
return this.each(function() { w2 = Math.round(w2);
$(this).data('image_enhance', null);
$('.image_enhance_titlebar, .image_enhance_theatre',this).remove(); 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) function calculate_sizes(window_width, window_height,image_width, image_height, border)
{
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)
{ {
if((w1 * 1.08) < 32767) { if(typeof border !== 'number')
w2 = w1 * 1.08; border = 0;
} else {
w2 = w1; 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) { var display_width = $this.width();
w2 = w1 / 1.08; var display_height = $this.height();
} else { var image_width = parseInt($('input[name="width"]', $this).val());
w2 = w1; 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); if ( methods[method] ) {
w2 = Math.round(w2); 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 ); })( jQuery );

View File

@@ -2,25 +2,25 @@
function is_ctrl_key(event) function is_ctrl_key(event)
{ {
if(event.altKey) if(event.altKey)
return true; return true;
if(event.ctrlKey) if(event.ctrlKey)
return true; return true;
if(event.metaKey) // apple key opera if(event.metaKey) // apple key opera
return true; return true;
if(event.keyCode == '17') // apple key opera if(event.keyCode == '17') // apple key opera
return true; return true;
if(event.keyCode == '224') // apple key mozilla if(event.keyCode == '224') // apple key mozilla
return true; return true;
if(event.keyCode == '91') // apple key safari if(event.keyCode == '91') // apple key safari
return true; return true;
return false; return false;
} }
function is_shift_key(event) function is_shift_key(event)
{ {
if(event.shiftKey) if(event.shiftKey)
return true; return true;
return false; return false;
} }

View File

@@ -1,144 +1,144 @@
(function($){ (function($){
$.fn.nicoslider = function(options) $.fn.nicoslider = function(options)
{ {
var defaults = { var defaults = {
start : 0, start : 0,
color : '#F6F2F1', color : '#F6F2F1',
sliderHeight : false sliderHeight : false
}; };
var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options); var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options);
return this.each(function(){ return this.each(function(){
new nicoslide(this, opts); new nicoslide(this, opts);
}); });
}; };
var nicoslide = function(slider, o) var nicoslide = function(slider, o)
{ {
var $slider = $(slider); var $slider = $(slider);
$sliderWidth = $slider.parent().innerWidth(); $sliderWidth = $slider.parent().innerWidth();
$sliderCss = { $sliderCss = {
'width':$sliderWidth, 'width':$sliderWidth,
'background-color':o.color 'background-color':o.color
}; };
$slider.css($sliderCss); $slider.css($sliderCss);
var ul = $slider.find("ul"); var ul = $slider.find("ul");
var ulWidth = 0; var ulWidth = 0;
var liHeight = 0; var liHeight = 0;
$slider.find("li").each(function(){ $slider.find("li").each(function(){
ulWidth += $(this).width() + 5; ulWidth += $(this).width() + 5;
ulWidth += parseInt($(this).css("padding-left")); ulWidth += parseInt($(this).css("padding-left"));
ulWidth += parseInt($(this).css("padding-right")); ulWidth += parseInt($(this).css("padding-right"));
ulWidth += parseInt($(this).css("margin-left")); ulWidth += parseInt($(this).css("margin-left"));
ulWidth += parseInt($(this).css("margin-right")); ulWidth += parseInt($(this).css("margin-right"));
liHeight = Math.max(liHeight,$(this).outerHeight()); liHeight = Math.max(liHeight,$(this).outerHeight());
}); });
//5 % of slider width //5 % of slider width
$scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05")); $scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05"));
//min 30 px; //min 30 px;
if($scrollWidth < 30) if($scrollWidth < 30)
{ {
$scrollWidth = 30; $scrollWidth = 30;
} }
var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth )); var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth ));
if(ulWidth > $wrapperWidth) if(ulWidth > $wrapperWidth)
{ {
ul.wrapAll("<div class='wrapper'></div>"); ul.wrapAll("<div class='wrapper'></div>");
$wrapper = $slider.find(".wrapper"); $wrapper = $slider.find(".wrapper");
$ulHeight = ul.height(); $ulHeight = ul.height();
$wrapper.width($wrapperWidth); $wrapper.width($wrapperWidth);
$wrapper.height($ulHeight); $wrapper.height($ulHeight);
$wrapperCss= { $wrapperCss= {
'overflow':'hidden', 'overflow':'hidden',
'float':'left', 'float':'left',
'position':'relative' 'position':'relative'
}; };
$wrapper.css($wrapperCss); $wrapper.css($wrapperCss);
ul.css('position', 'absolute'); ul.css('position', 'absolute');
ul.width(ulWidth); ul.width(ulWidth);
$slider.prepend("<div class='scrollleft'></div>"); $slider.prepend("<div class='scrollleft'></div>");
$slider.append("<div class='scrollright'></div>"); $slider.append("<div class='scrollright'></div>");
var rightScroll = $slider.find(".scrollright"); var rightScroll = $slider.find(".scrollright");
var leftScroll = $slider.find(".scrollleft"); var leftScroll = $slider.find(".scrollleft");
rightScroll.append("<div class='rb'>&gt;</div>"); rightScroll.append("<div class='rb'>&gt;</div>");
leftScroll.append("<div class='lb'>&lt;</div>"); leftScroll.append("<div class='lb'>&lt;</div>");
$("div.rb").css('float', 'right'); $("div.rb").css('float', 'right');
rightCss = { rightCss = {
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), 'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
'height' : liHeight + 5, 'height' : liHeight + 5,
'float' : 'right', 'float' : 'right',
'background-color' : o.color, 'background-color' : o.color,
'cursor': 'pointer', 'cursor': 'pointer',
' user-select': 'none' ' user-select': 'none'
}; };
leftCss = { leftCss = {
'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), 'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()),
'height' : liHeight + 5, 'height' : liHeight + 5,
'float' : 'left', 'float' : 'left',
'background-color' : o.color, 'background-color' : o.color,
'cursor': 'pointer', 'cursor': 'pointer',
' user-select': 'none' ' user-select': 'none'
}; };
leftScroll.css(leftCss); leftScroll.css(leftCss);
rightScroll.css(rightCss); rightScroll.css(rightCss);
var rightScrollWidth = rightScroll.width(); var rightScrollWidth = rightScroll.width();
var leftScrollWidth = leftScroll.width(); var leftScrollWidth = leftScroll.width();
var scrollXpos = 0; var scrollXpos = 0;
var scrollStepSpeed = 40; var scrollStepSpeed = 40;
var speed = 8; var speed = 8;
var shift = o.start; var shift = o.start;
//scroll a droite //scroll a droite
rightScroll.bind("click", function(e){ rightScroll.bind("click", function(e){
var x = e.pageX - ($(this).offset().left); var x = e.pageX - ($(this).offset().left);
scrollXpos = Math.round((x / rightScrollWidth) * scrollStepSpeed); scrollXpos = Math.round((x / rightScrollWidth) * scrollStepSpeed);
shift += (scrollXpos * speed); shift += (scrollXpos * speed);
if(shift > (ulWidth - $wrapperWidth) + 50) if(shift > (ulWidth - $wrapperWidth) + 50)
{ {
shift = (ulWidth - $wrapperWidth) + 50; shift = (ulWidth - $wrapperWidth) + 50;
} }
ul.animate({ ul.animate({
left: -shift left: -shift
}, 1); }, 1);
}); });
//scroll a gauche //scroll a gauche
leftScroll.bind("click", function(e){ leftScroll.bind("click", function(e){
var x = $(this).innerWidth() - (e.pageX - $(this).offset().left); var x = $(this).innerWidth() - (e.pageX - $(this).offset().left);
scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed); scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed);
shift -= (scrollXpos * speed); shift -= (scrollXpos * speed);
if(shift < 0) if(shift < 0)
{ {
shift = 0; shift = 0;
} }
ul.animate({ ul.animate({
left: -shift left: -shift
}, 1); }, 1);
}); });
} }
}; };
})(jQuery); })(jQuery);

View File

@@ -1,17 +1,17 @@
$(document).ready(function(){ $(document).ready(function(){
$('#tabs').tabs(); $('#tabs').tabs();
$('input.input-button').hover( $('input.input-button').hover(
function(){parent.$(this).addClass('hover');}, function(){parent.$(this).addClass('hover');},
function(){parent.$(this).removeClass('hover');} function(){parent.$(this).removeClass('hover');}
); );
$(this).bind('keydown',function(event){ $(this).bind('keydown',function(event){
switch(event.keyCode) switch(event.keyCode)
{ {
case 27: case 27:
parent.hideDwnl(); parent.hideDwnl();
break; break;
default: default:
break; break;
} }
}); });
}); });

View File

@@ -3,480 +3,480 @@ prevAjaxrunning = false;
p4.slideShow = false; p4.slideShow = false;
$(document).ready(function(){ $(document).ready(function(){
$('#PREVIEWIMGDESC').tabs(); $('#PREVIEWIMGDESC').tabs();
}); });
function getNewVideoToken(lst, obj) function getNewVideoToken(lst, obj)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "../prod/records/renew-url/", url: "../prod/records/renew-url/",
dataType: 'json', dataType: 'json',
data: { data: {
lst: lst lst: lst
}, },
success: function(data){ success: function(data){
if(!data[lst]) if(!data[lst])
return; return;
obj.unload(); obj.unload();
obj.setClip({url:data[lst]}); obj.setClip({url:data[lst]});
obj.play(); obj.play();
return; return;
} }
}); });
} }
function openPreview(env, pos, contId, reload){ function openPreview(env, pos, contId, reload){
if (contId == undefined) if (contId == undefined)
contId = ''; contId = '';
var roll = 0; var roll = 0;
var justOpen = false; var justOpen = false;
if (!p4.preview.open) { if (!p4.preview.open) {
showOverlay(); showOverlay();
$('#PREVIEWIMGCONT').disableSelection(); $('#PREVIEWIMGCONT').disableSelection();
justOpen = true; justOpen = true;
if (!$.browser.msie) { if (!$.browser.msie) {
$('#PREVIEWBOX').css({ $('#PREVIEWBOX').css({
'display': 'block', 'display': 'block',
'opacity': 0 'opacity': 0
}).fadeTo(500, 1); }).fadeTo(500, 1);
}else }else
{ {
$('#PREVIEWBOX').css({ $('#PREVIEWBOX').css({
'display': 'block', 'display': 'block',
'opacity': 1 'opacity': 1
}); });
} }
p4.preview.open = true; p4.preview.open = true;
p4.preview.nCurrent = 5; p4.preview.nCurrent = 5;
$('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty(); $('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty();
resizePreview(); resizePreview();
if(env == 'BASK') if(env == 'BASK')
roll = 1; roll = 1;
} }
if(reload === true) if(reload === true)
roll = 1; roll = 1;
$('#tooltip').css({ $('#tooltip').css({
'display': 'none' 'display': 'none'
}); });
$('#PREVIEWIMGCONT').empty(); $('#PREVIEWIMGCONT').empty();
var options_serial = p4.tot_options; var options_serial = p4.tot_options;
var query = p4.tot_query; var query = p4.tot_query;
prevAjax = $.ajax({ prevAjax = $.ajax({
type: "POST", type: "POST",
url: "../prod/records/", url: "../prod/records/",
dataType: 'json', dataType: 'json',
data: { data: {
env: env, env: env,
pos: pos, pos: pos,
cont: contId, cont: contId,
roll: roll, roll: roll,
options_serial:options_serial, options_serial:options_serial,
query:query query:query
}, },
beforeSend: function(){ beforeSend: function(){
if (prevAjaxrunning) if (prevAjaxrunning)
prevAjax.abort(); prevAjax.abort();
if(env == 'RESULT') if(env == 'RESULT')
$('#current_result_n').empty().append(parseInt(pos)+1); $('#current_result_n').empty().append(parseInt(pos)+1);
prevAjaxrunning = true; prevAjaxrunning = true;
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading'); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading');
}, },
error: function(data){ error: function(data){
prevAjaxrunning = false; prevAjaxrunning = false;
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
posAsk = null; posAsk = null;
}, },
timeout: function(){ timeout: function(){
prevAjaxrunning = false; prevAjaxrunning = false;
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
posAsk = null; posAsk = null;
}, },
success: function(data){ success: function(data){
cancelPreview(); cancelPreview();
prevAjaxrunning = false; prevAjaxrunning = false;
posAsk = null; posAsk = null;
if(data.error) if(data.error)
{ {
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
alert(data.error); alert(data.error);
if(justOpen) if(justOpen)
closePreview(); closePreview();
return; return;
} }
posAsk = data.pos - 1; posAsk = data.pos - 1;
$('#PREVIEWIMGCONT').empty().append(data.html_preview); $('#PREVIEWIMGCONT').empty().append(data.html_preview);
$('#PREVIEWIMGCONT .thumb_wrapper') $('#PREVIEWIMGCONT .thumb_wrapper')
.width('100%').height('100%').image_enhance({zoomable:true}); .width('100%').height('100%').image_enhance({zoomable:true});
$('#PREVIEWIMGDESCINNER').empty().append(data.desc); $('#PREVIEWIMGDESCINNER').empty().append(data.desc);
$('#HISTORICOPS').empty().append(data.history); $('#HISTORICOPS').empty().append(data.history);
$('#popularity').empty().append(data.popularity); $('#popularity').empty().append(data.popularity);
if($('#popularity .bitly_link').length>0) if($('#popularity .bitly_link').length>0)
{ {
BitlyCB.statsResponse = function(data) { BitlyCB.statsResponse = function(data) {
var result = data.results; var result = data.results;
if( $( '#popularity .bitly_link_' + result.userHash ).length > 0 ) if( $( '#popularity .bitly_link_' + result.userHash ).length > 0 )
{ {
$( '#popularity .bitly_link_' + result.userHash ).append( ' (' + result.clicks + ' clicks)'); $( '#popularity .bitly_link_' + result.userHash ).append( ' (' + result.clicks + ' clicks)');
} }
}; };
BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse'); BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse');
} }
p4.preview.current = {}; p4.preview.current = {};
p4.preview.current.width = parseInt($('#PREVIEWIMGCONT input[name=width]').val()); p4.preview.current.width = parseInt($('#PREVIEWIMGCONT input[name=width]').val());
p4.preview.current.height = parseInt($('#PREVIEWIMGCONT input[name=height]').val()); p4.preview.current.height = parseInt($('#PREVIEWIMGCONT input[name=height]').val());
p4.preview.current.tot = data.tot; p4.preview.current.tot = data.tot;
p4.preview.current.pos = data.pos; p4.preview.current.pos = data.pos;
if($('#PREVIEWBOX img.record.zoomable').length > 0) if($('#PREVIEWBOX img.record.zoomable').length > 0)
{ {
$('#PREVIEWBOX img.record.zoomable').draggable(); $('#PREVIEWBOX img.record.zoomable').draggable();
} }
setTitle(data.title); setTitle(data.title);
setPreview(); setPreview();
if(env != 'RESULT') if(env != 'RESULT')
{ {
setCurrent(data.current); setCurrent(data.current);
viewCurrent($('#PREVIEWCURRENT li.selected')); viewCurrent($('#PREVIEWCURRENT li.selected'));
} }
else else
{ {
if(!justOpen) if(!justOpen)
{ {
$('#PREVIEWCURRENT li.selected').removeClass('selected'); $('#PREVIEWCURRENT li.selected').removeClass('selected');
$('#PREVIEWCURRENTCONT li.current'+pos).addClass('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])) 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); getAnswerTrain(pos, data.tools, query,options_serial);
} }
viewCurrent($('#PREVIEWCURRENT li.selected')); viewCurrent($('#PREVIEWCURRENT li.selected'));
} }
if(env == 'REG' && $('#PREVIEWCURRENT').html() === '') if(env == 'REG' && $('#PREVIEWCURRENT').html() === '')
{ {
getRegTrain(contId,pos,data.tools); getRegTrain(contId,pos,data.tools);
} }
setOthers(data.others); setOthers(data.others);
setTools(data.tools); setTools(data.tools);
$('#tooltip').css({ $('#tooltip').css({
'display': 'none' 'display': 'none'
}); });
$('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading');
if(!justOpen || (p4.preview.mode != env)) if(!justOpen || (p4.preview.mode != env))
resizePreview(); resizePreview();
p4.preview.mode = env; p4.preview.mode = env;
$('#EDIT_query').focus(); $('#EDIT_query').focus();
$('#PREVIEWOTHERSINNER .otherBaskToolTip').tooltip(); $('#PREVIEWOTHERSINNER .otherBaskToolTip').tooltip();
return; return;
} }
}); });
} }
function zoomPreview(bool){ function zoomPreview(bool){
var el = $('#PREVIEWIMGCONT img.record'); var el = $('#PREVIEWIMGCONT img.record');
if(el.length === 0) if(el.length === 0)
return; return;
var t1 = parseInt(el.css('top')); var t1 = parseInt(el.css('top'));
var l1 = parseInt(el.css('left')); var l1 = parseInt(el.css('left'));
var w1 = el.width(); var w1 = el.width();
var h1 = el.height(); var h1 = el.height();
var w2,t2; var w2,t2;
if(bool) if(bool)
{ {
if(w1 * 1.08 < 32767) if(w1 * 1.08 < 32767)
w2 = w1 * 1.08; w2 = w1 * 1.08;
else else
w2 = w1; w2 = w1;
} }
else else
{ {
if(w1 / 1.08 > 20) if(w1 / 1.08 > 20)
w2 = w1 / 1.08; w2 = w1 / 1.08;
else else
w2 = w1; w2 = w1;
} }
var ratio = p4.preview.current.width / p4.preview.current.height; var ratio = p4.preview.current.width / p4.preview.current.height;
h2 = Math.round(w2 / ratio); h2 = Math.round(w2 / ratio);
w2 = Math.round(w2); w2 = Math.round(w2);
t2 = Math.round(t1 - (h2 - h1) / 2)+'px'; t2 = Math.round(t1 - (h2 - h1) / 2)+'px';
var l2 = Math.round(l1 - (w2 - w1) / 2)+'px'; var l2 = Math.round(l1 - (w2 - w1) / 2)+'px';
var wPreview = $('#PREVIEWIMGCONT').width()/2; var wPreview = $('#PREVIEWIMGCONT').width()/2;
var hPreview = $('#PREVIEWIMGCONT').height()/2; var hPreview = $('#PREVIEWIMGCONT').height()/2;
var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview); var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview);
var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview); var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview);
el.css({ el.css({
left: nl, left: nl,
top: nt top: nt
}).width(w2).height(h2); }).width(w2).height(h2);
} }
function getAnswerTrain(pos, tools, query,options_serial) function getAnswerTrain(pos, tools, query,options_serial)
{ {
$('#PREVIEWCURRENTCONT').fadeOut('fast'); $('#PREVIEWCURRENTCONT').fadeOut('fast');
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/prod/query/answer-train/", url: "/prod/query/answer-train/",
dataType: 'json', dataType: 'json',
data: { data: {
pos:pos, pos:pos,
options_serial:options_serial, options_serial:options_serial,
query:query query:query
}, },
success: function(data){ success: function(data){
setCurrent(data.current); setCurrent(data.current);
viewCurrent($('#PREVIEWCURRENT li.selected')); viewCurrent($('#PREVIEWCURRENT li.selected'));
setTools(tools); setTools(tools);
return; return;
} }
}); });
} }
function getRegTrain(contId,pos,tools) function getRegTrain(contId,pos,tools)
{ {
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/prod/query/reg-train/", url: "/prod/query/reg-train/",
dataType: 'json', dataType: 'json',
data: { data: {
cont:contId, cont:contId,
pos:pos pos:pos
}, },
success: function(data){ success: function(data){
setCurrent(data.current); setCurrent(data.current);
viewCurrent($('#PREVIEWCURRENT li.selected')); viewCurrent($('#PREVIEWCURRENT li.selected'));
if(typeof(tools) != 'undefined') if(typeof(tools) != 'undefined')
setTools(tools); setTools(tools);
return; return;
} }
}); });
} }
function bounce(sbid, term, field){ function bounce(sbid, term, field){
doThesSearch('T', sbid, term, field); doThesSearch('T', sbid, term, field);
closePreview(); closePreview();
} }
function setTitle(title){ function setTitle(title){
$('#SPANTITLE').empty().append(title); $('#SPANTITLE').empty().append(title);
} }
function cancelPreview(){ function cancelPreview(){
$('#PREVIEWIMGDESCINNER').empty(); $('#PREVIEWIMGDESCINNER').empty();
$('#PREVIEWIMGCONT').empty(); $('#PREVIEWIMGCONT').empty();
p4.preview.current = false; p4.preview.current = false;
} }
function startSlide(){ function startSlide(){
if (!p4.slideShow) { if (!p4.slideShow) {
p4.slideShow = true; p4.slideShow = true;
} }
if (p4.slideShowCancel) { if (p4.slideShowCancel) {
p4.slideShowCancel = false; p4.slideShowCancel = false;
p4.slideShow = false; p4.slideShow = false;
$('#start_slide').show(); $('#start_slide').show();
$('#stop_slide').hide(); $('#stop_slide').hide();
} }
if(!p4.preview.open) if(!p4.preview.open)
{ {
p4.slideShowCancel = false; p4.slideShowCancel = false;
p4.slideShow = false; p4.slideShow = false;
$('#start_slide').show(); $('#start_slide').show();
$('#stop_slide').hide(); $('#stop_slide').hide();
} }
if (p4.slideShow) { if (p4.slideShow) {
$('#start_slide').hide(); $('#start_slide').hide();
$('#stop_slide').show(); $('#stop_slide').show();
getNext(); getNext();
setTimeout("startSlide()", 3000); setTimeout("startSlide()", 3000);
} }
} }
function stopSlide(){ function stopSlide(){
p4.slideShowCancel = true; p4.slideShowCancel = true;
$('#start_slide').show(); $('#start_slide').show();
$('#stop_slide').hide(); $('#stop_slide').hide();
} }
//var posAsk = null; //var posAsk = null;
function getNext(){ function getNext(){
if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0) if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0)
$('#PREVIEWCURRENTCONT li img:first').trigger("click"); $('#PREVIEWCURRENTCONT li img:first').trigger("click");
else { else {
if (p4.preview.mode == 'RESULT') { if (p4.preview.mode == 'RESULT') {
posAsk = parseInt(p4.preview.current.pos) + 1; posAsk = parseInt(p4.preview.current.pos) + 1;
posAsk = (posAsk > parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk; posAsk = (posAsk > parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk;
openPreview('RESULT', posAsk); openPreview('RESULT', posAsk);
} }
else else
{ {
if(!$('#PREVIEWCURRENT li.selected').is(':last-child')) if(!$('#PREVIEWCURRENT li.selected').is(':last-child'))
$('#PREVIEWCURRENT li.selected').next().children('img').trigger("click"); $('#PREVIEWCURRENT li.selected').next().children('img').trigger("click");
else else
$('#PREVIEWCURRENT li:first-child').children('img').trigger("click"); $('#PREVIEWCURRENT li:first-child').children('img').trigger("click");
} }
} }
} }
function reloadPreview(){ function reloadPreview(){
$('#PREVIEWCURRENT li.selected img').trigger("click"); $('#PREVIEWCURRENT li.selected img').trigger("click");
} }
function getPrevious(){ function getPrevious(){
if (p4.preview.mode == 'RESULT') if (p4.preview.mode == 'RESULT')
{ {
posAsk = parseInt(p4.preview.current.pos) - 1; posAsk = parseInt(p4.preview.current.pos) - 1;
posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk; posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk;
openPreview('RESULT', posAsk); openPreview('RESULT', posAsk);
} }
else else
{ {
if(!$('#PREVIEWCURRENT li.selected').is(':first-child')) if(!$('#PREVIEWCURRENT li.selected').is(':first-child'))
$('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click"); $('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click");
else else
$('#PREVIEWCURRENT li:last-child').children('img').trigger("click"); $('#PREVIEWCURRENT li:last-child').children('img').trigger("click");
} }
} }
function setOthers(others){ function setOthers(others){
$('#PREVIEWOTHERSINNER').empty(); $('#PREVIEWOTHERSINNER').empty();
if (others !== '') { if (others !== '') {
$('#PREVIEWOTHERSINNER').append(others); $('#PREVIEWOTHERSINNER').append(others);
$('#PREVIEWOTHERS table.otherRegToolTip').tooltip(); $('#PREVIEWOTHERS table.otherRegToolTip').tooltip();
} }
} }
function setTools(tools){ function setTools(tools){
$('#PREVIEWTOOL').empty().append(tools); $('#PREVIEWTOOL').empty().append(tools);
if(!p4.slideShowCancel && p4.slideShow) if(!p4.slideShowCancel && p4.slideShow)
{ {
$('#start_slide').hide(); $('#start_slide').hide();
$('#stop_slide').show(); $('#stop_slide').show();
}else }else
{ {
$('#start_slide').show(); $('#start_slide').show();
$('#stop_slide').hide(); $('#stop_slide').hide();
} }
} }
function setCurrent(current){ function setCurrent(current){
if (current !== '') { if (current !== '') {
var el = $('#PREVIEWCURRENT'); var el = $('#PREVIEWCURRENT');
el.removeClass('loading').empty().append(current); el.removeClass('loading').empty().append(current);
$('ul',el).width($('li',el).length * 80); $('ul',el).width($('li',el).length * 80);
$('img.prevRegToolTip',el).tooltip(); $('img.prevRegToolTip',el).tooltip();
$.each($('img.openPreview'), function(i, el){ $.each($('img.openPreview'), function(i, el){
var jsopt = $(el).attr('jsargs').split('|'); var jsopt = $(el).attr('jsargs').split('|');
$(el).removeAttr('jsargs'); $(el).removeAttr('jsargs');
$(el).removeClass('openPreview'); $(el).removeClass('openPreview');
$(el).bind('click', function(){ $(el).bind('click', function(){
viewCurrent($(this).parent()); viewCurrent($(this).parent());
openPreview(jsopt[0], jsopt[1], jsopt[2]); openPreview(jsopt[0], jsopt[1], jsopt[2]);
}); });
}); });
} }
} }
function viewCurrent(el){ function viewCurrent(el){
if (el.length === 0) if (el.length === 0)
{ {
return; return;
} }
$('#PREVIEWCURRENT li.selected').removeClass('selected'); $('#PREVIEWCURRENT li.selected').removeClass('selected');
el.addClass('selected'); el.addClass('selected');
$('#PREVIEWCURRENTCONT').animate({'scrollLeft':($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width()/2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))}); $('#PREVIEWCURRENTCONT').animate({'scrollLeft':($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width()/2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))});
return; return;
} }
function setPreview(){ function setPreview(){
if (!p4.preview.current) if (!p4.preview.current)
return; return;
var zoomable = $('img.record.zoomable'); var zoomable = $('img.record.zoomable');
if(zoomable.length > 0 && zoomable.hasClass('zoomed')) if(zoomable.length > 0 && zoomable.hasClass('zoomed'))
return; return;
var h = parseInt(p4.preview.current.height); var h = parseInt(p4.preview.current.height);
var w = parseInt(p4.preview.current.width); var w = parseInt(p4.preview.current.width);
// if(p4.preview.current.type == 'video') // if(p4.preview.current.type == 'video')
// { // {
// var h = parseInt(p4.preview.current.flashcontent.height); // var h = parseInt(p4.preview.current.flashcontent.height);
// var w = parseInt(p4.preview.current.flashcontent.width); // var w = parseInt(p4.preview.current.flashcontent.width);
// } // }
var t=20; var t=20;
var de = 0; var de = 0;
var margX = 0; var margX = 0;
var margY = 0; var margY = 0;
if($('#PREVIEWIMGCONT .record_audio').length > 0) if($('#PREVIEWIMGCONT .record_audio').length > 0)
{ {
margY = 100; margY = 100;
de = 60; de = 60;
} }
// if(p4.preview.current.type != 'flash') // if(p4.preview.current.type != 'flash')
// { // {
var ratioP = w / h; var ratioP = w / h;
var ratioD = parseInt(p4.preview.width) / parseInt(p4.preview.height); var ratioD = parseInt(p4.preview.width) / parseInt(p4.preview.height);
if (ratioD > ratioP) { if (ratioD > ratioP) {
//je regle la hauteur d'abord //je regle la hauteur d'abord
if ((parseInt(h) + margY) > parseInt(p4.preview.height)) { if ((parseInt(h) + margY) > parseInt(p4.preview.height)) {
h = Math.round(parseInt(p4.preview.height) - margY); h = Math.round(parseInt(p4.preview.height) - margY);
w = Math.round(h * ratioP); w = Math.round(h * ratioP);
} }
} }
else { else {
if ((parseInt(w) + margX) > parseInt(p4.preview.width)) { if ((parseInt(w) + margX) > parseInt(p4.preview.width)) {
w = Math.round(parseInt(p4.preview.width) - margX); w = Math.round(parseInt(p4.preview.width) - margX);
h = Math.round(w / ratioP); h = Math.round(w / ratioP);
} }
} }
// } // }
// else // else
// { // {
@@ -484,42 +484,42 @@ function setPreview(){
// h = Math.round(parseInt(p4.preview.height) - margY); // h = Math.round(parseInt(p4.preview.height) - margY);
// w = Math.round(parseInt(p4.preview.width) - margX); // w = Math.round(parseInt(p4.preview.width) - margX);
// } // }
t = Math.round((parseInt(p4.preview.height) - h - de) / 2); t = Math.round((parseInt(p4.preview.height) - h - de) / 2);
var l = Math.round((parseInt(p4.preview.width) - w) / 2); var l = Math.round((parseInt(p4.preview.width) - w) / 2);
$('#PREVIEWIMGCONT .record').css({ $('#PREVIEWIMGCONT .record').css({
width: w, width: w,
height: h, height: h,
top: t, top: t,
left: l left: l
}).attr('width',w).attr('height',h); }).attr('width',w).attr('height',h);
} }
function classicMode(){ function classicMode(){
$('#PREVIEWCURRENTCONT').animate({'scrollLeft' : ($('#PREVIEWCURRENT li.selected').position().left - 160)}); $('#PREVIEWCURRENTCONT').animate({'scrollLeft' : ($('#PREVIEWCURRENT li.selected').position().left - 160)});
p4.currentViewMode = 'classic'; p4.currentViewMode = 'classic';
} }
function doudouMode(){ function doudouMode(){
$('#PREVIEWCURRENT li').removeClass('see-all'); $('#PREVIEWCURRENT li').removeClass('see-all');
$('#PREVIEWCURRENT ul').width('auto'); $('#PREVIEWCURRENT ul').width('auto');
$('#PREVIEWCURRENTCONT').css({ $('#PREVIEWCURRENTCONT').css({
'overflow-x': 'hidden' 'overflow-x': 'hidden'
}); });
p4.currentViewMode = 'enhance'; p4.currentViewMode = 'enhance';
viewCurrent($('#PREVIEWCURRENT li.selected')); viewCurrent($('#PREVIEWCURRENT li.selected'));
} }
function closePreview(){ function closePreview(){
p4.preview.open = false; p4.preview.open = false;
hideOverlay(); hideOverlay();
$('#PREVIEWBOX').fadeTo(500, 0); $('#PREVIEWBOX').fadeTo(500, 0);
$('#PREVIEWBOX').queue(function(){ $('#PREVIEWBOX').queue(function(){
$(this).css({ $(this).css({
'display': 'none' 'display': 'none'
}); });
cancelPreview(); cancelPreview();
$(this).dequeue(); $(this).dequeue();
}); });
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -6,278 +6,278 @@
(function( window ) { (function( window ) {
var Selectable = function($container, options) { var Selectable = function($container, options) {
var defaults = { var defaults = {
allow_multiple : false, allow_multiple : false,
selector : '', selector : '',
callbackSelection : null, callbackSelection : null,
selectStart : null, selectStart : null,
selectStop : null, selectStop : null,
limit : 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 : {}; hasReachLimit : function() {
if(this.options.limit !== null && this.options.limit <= this.datas.length)
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()) return true;
{
var k = get_value(jQuery(n), $this);
$this.push(k);
jQuery(n).addClass('selected');
}
else
{
alert(language.max_record_selected);
stopped = true;
}
} }
}); return false;
} },
remove : function(element){
this.datas = jQuery.grep(this.datas, function(n){
return(n !== element);
});
if($this.has(k) === false && stopped === false) return this;
{ },
if(!$this.hasReachLimit()) has : function(element){
{
$this.push(k); return jQuery.inArray(element,this.datas) >= 0;
$that.addClass('selected'); },
} get : function(){
else
{ return this.datas;
alert(language.max_record_selected); },
} empty : function(){
} var $this = this;
} this.datas = new Array();
else
{ jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected');
if(!is_ctrl_key(event))
{ if(typeof $this.options.selectStop === 'function')
$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); $this.options.selectStop(jQuery.Event('selectStop'), $this);
$that.addClass('selected');
} }
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'); window.Selectable = Selectable;
$that.addClass('last_selected'); })(window);
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);

View File

@@ -2,284 +2,284 @@ var p4 = p4 || {};
(function( window, p4, $ ) { (function( window, p4, $ ) {
var Lists = function() { var Lists = function() {
}; };
var List = function (id) { var List = function (id) {
if(parseInt(id) <= 0) if(parseInt(id) <= 0)
{ {
throw 'Invalid list id'; 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({ if(!arrayUsers instanceof Array)
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); throw 'addUsers takes array as argument';
callback(list);
} }
}
else var $this = this;
{ var data = {usr_ids : $(arrayUsers).toArray()};
humane.error(data.message);
} $.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({ p4.Lists = new Lists();
type: 'POST', document.List = List;
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({ })(document, p4, jQuery);
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);

View File

@@ -1,115 +1,115 @@
(function( $ ){ (function( $ ){
var methods = { var methods = {
init : function( options ) { init : function( options ) {
var settings = { var settings = {
'url' : '/admin/tests/pathurl/path/' 'url' : '/admin/tests/pathurl/path/'
}; };
return this.each(function() { 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 ( ! 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'))
{ {
$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); },
}); destroy : function( ) {
return this.each(function() {
$this.trigger('keyup'); $(this).data('path_file_tests', null);
});
$this.nextAll('.reload').bind('click', function(){
$this.trigger('keyup');
});
} }
}); };
},
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] ) { if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) { } else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments ); return methods.init.apply( this, arguments );
} else { } else {
$.error( 'Method ' + method + ' does not exist on jQuery.path_file_test' ); $.error( 'Method ' + method + ' does not exist on jQuery.path_file_test' );
} }
}; };
})( jQuery ); })( jQuery );
@@ -117,121 +117,121 @@
(function( $ ){ (function( $ ){
var methods = { var methods = {
init : function( options ) { init : function( options ) {
var settings = { var settings = {
'url' : '/admin/tests/pathurl/url/' 'url' : '/admin/tests/pathurl/url/'
}; };
return this.each(function() { return this.each(function() {
var $this = $(this), data = $(this).data('url_tests'); var $this = $(this), data = $(this).data('url_tests');
if ( ! data ) 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)
{ {
el_status.attr('src','/skins/icons/delete.png'); if ( options ) {
return; $.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); },
}); destroy : function( ) {
return this.each(function() {
$this.trigger('keyup'); $(this).data('url_tests', null);
$this.nextAll('.reload').bind('click', function(){ });
$this.trigger('keyup');
});
} }
}); };
},
destroy : function( ) {
return this.each(function() {
$(this).data('url_tests', null);
});
}
};
$.fn.url_test = function(method) { $.fn.url_test = function(method) {
if ( methods[method] ) { if ( methods[method] ) {
return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
} else if ( typeof method === 'object' || ! method ) { } else if ( typeof method === 'object' || ! method ) {
return methods.init.apply( this, arguments ); return methods.init.apply( this, arguments );
} else { } else {
$.error( 'Method ' + method + ' does not exist on jQuery.url_test' ); $.error( 'Method ' + method + ' does not exist on jQuery.url_test' );
} }
}; };
})( jQuery ); })( jQuery );

View File

@@ -20,8 +20,8 @@ define([
"apps/admin/fields/views/fieldError", "apps/admin/fields/views/fieldError",
"apps/admin/fields/errors/errorManager" "apps/admin/fields/errors/errorManager"
], function( ], function(
$, _, Backbone, i18n, FieldsCollection, VocabulariesCollection, $, _, Backbone, i18n, FieldsCollection, VocabulariesCollection,
DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) { DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) {
var initialize = function() { var initialize = function() {
AdminFieldApp = { AdminFieldApp = {
$window : $(window), $window : $(window),
@@ -66,16 +66,16 @@ define([
// load all collections // load all collections
$.when.apply($, [ $.when.apply($, [
AdminFieldApp.fieldsCollection.fetch(), AdminFieldApp.fieldsCollection.fetch(),
AdminFieldApp.vocabularyCollection.fetch(), AdminFieldApp.vocabularyCollection.fetch(),
AdminFieldApp.dcFieldsCollection.fetch(), AdminFieldApp.dcFieldsCollection.fetch(),
$.ajax({ $.ajax({
url: '/available-languages', url: '/available-languages',
success: function(languages) { success: function(languages) {
AdminFieldApp.languages = languages; AdminFieldApp.languages = languages;
} }
}) })
]).done( ]).done(
function() { function() {
// register views // register views
AdminFieldApp.saveView = new SaveView({ AdminFieldApp.saveView = new SaveView({

View File

@@ -138,15 +138,15 @@ define([
AdminFieldApp.fieldsCollection.add(field); AdminFieldApp.fieldsCollection.add(field);
_.last(AdminFieldApp.fieldListView.itemViews).clickAction().animate(); _.last(AdminFieldApp.fieldListView.itemViews).clickAction().animate();
new AlertView({alert: "info", message: i18n.t("created_success", { new AlertView({alert: "info", message: i18n.t("created_success", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: [field.get("name")] sprintf: [field.get("name")]
}) })
}).render(); }).render();
}, },
error: function(xhr, textStatus, errorThrown) { error: function(xhr, textStatus, errorThrown) {
new AlertView({ 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(); ).render();
self.toggleCreateFormAction(); self.toggleCreateFormAction();

View File

@@ -38,5 +38,5 @@ define([
} }
}); });
return DcFieldsView; return DcFieldsView;
}); });

View File

@@ -207,7 +207,7 @@ define([
}, },
// select temView by index in itemList // select temView by index in itemList
_selectModelView: function(index) { _selectModelView: function(index) {
// select previous or next itemview // select previous or next itemview
if (index >= 0) { if (index >= 0) {
AdminFieldApp.fieldListView.itemViews[index].select().animate().click(); AdminFieldApp.fieldListView.itemViews[index].select().animate().click();
} }

View File

@@ -63,7 +63,7 @@ define([
// highlight view if edit view model match current view model // highlight view if edit view model match current view model
if (AdminFieldApp.fieldEditView if (AdminFieldApp.fieldEditView
&& AdminFieldApp.fieldEditView.model.get("id") === this.model.get("id")) { && AdminFieldApp.fieldEditView.model.get("id") === this.model.get("id")) {
this.select(); this.select();
} }

View File

@@ -38,19 +38,19 @@ define([
if (this._isModelDesync()) { if (this._isModelDesync()) {
this._loadingState(true); this._loadingState(true);
$.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function(m){ $.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function(m){
return m.destroy({ return m.destroy({
success: function(model, response) { success: function(model, response) {
AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){ AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){
return model.get("id") !== m.get("id"); return model.get("id") !== m.get("id");
}); });
}, },
error: function(xhr, textStatus, errorThrown) { error: function(xhr, textStatus, errorThrown) {
new AlertView({ 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(); }).render();
} }
}); });
})).done( })).done(
function() { function() {
AdminFieldApp.fieldsCollection.save({ AdminFieldApp.fieldsCollection.save({
success: function(fields) { success: function(fields) {
@@ -69,8 +69,8 @@ define([
}).render(); }).render();
} }
}).done(function() { }).done(function() {
self._loadingState(false); self._loadingState(false);
}); });
} }
); );
} }

View File

@@ -19,7 +19,7 @@ require([
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
new LoginForm({ new LoginForm({
el : $("form[name=loginForm]"), el : $("form[name=loginForm]"),
rules: [{ rules: [{
name: "login", name: "login",

View File

@@ -36,9 +36,9 @@ define([
} else { } else {
return i18n.t( return i18n.t(
options.length === 1 ? "one_collection_selected": "collections_selected", { options.length === 1 ? "one_collection_selected": "collections_selected", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: [options.length] sprintf: [options.length]
}) + ' <b class="caret"></b>'; }) + ' <b class="caret"></b>';
} }
} }
}); });

View File

@@ -19,7 +19,7 @@ require([
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
new LoginForm({ new LoginForm({
el : $("form[name=loginForm]"), el : $("form[name=loginForm]"),
rules: [{ rules: [{
name: "login", name: "login",

View File

@@ -19,7 +19,7 @@ require([
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
new LoginForm({ new LoginForm({
el : $("form[name=loginForm]"), el : $("form[name=loginForm]"),
rules: [{ rules: [{
name: "login", name: "login",

View File

@@ -17,9 +17,9 @@ require([
i18n.init({ i18n.init({
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
new LoginForm({ new LoginForm({
el : $("form[name=loginForm]"), el : $("form[name=loginForm]"),
rules: [{ rules: [{
name: "login", name: "login",

View File

@@ -14,8 +14,8 @@ require([
"common/forms/views/formType/passwordSetter" "common/forms/views/formType/passwordSetter"
], function($, i18n, Common, RenewPassword) { ], function($, i18n, Common, RenewPassword) {
i18n.init({ i18n.init({
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
Common.initialize(); Common.initialize();

View File

@@ -18,97 +18,97 @@ require([
var fieldsConfiguration = []; var fieldsConfiguration = [];
$.when.apply($, [ $.when.apply($, [
$.ajax({ $.ajax({
url: '/login/registration-fields/', url: '/login/registration-fields/',
success: function(config) { success: function(config) {
fieldsConfiguration = 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);
} }
}); })
]).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({ _.each(fieldsConfiguration, function(field) {
el : $form, if (field.required) {
rules: rules var rule = {
}); "name": field.name,
"rules": "required",
"message": i18n.t("validation_blank")
};
var geocompleter = geonames.init($("#geonameid"), { rules.push(rule);
"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 var $form = $("form[name=registerForm]");
geocompleter.geocompleter("autocompleter", "option", "position", {
"of": geocompleter.closest(".input-table"),
"my": "left top",
"at": "left bottom"
});
// On open menu calculate max-width new RegisterForm({
geocompleter.geocompleter("autocompleter", "on", "autocompleteopen", function(event, ui) { el : $form,
$(this).autocomplete("widget").css("min-width", geocompleter.closest(".input-table").outerWidth()); 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());
});
}); });
}); });
});
}); });

View File

@@ -19,71 +19,71 @@ require([
var fieldsConfiguration = []; var fieldsConfiguration = [];
$.when.apply($, [ $.when.apply($, [
$.ajax({ $.ajax({
url: '/login/registration-fields/', url: '/login/registration-fields/',
success: function(config) { success: function(config) {
fieldsConfiguration = 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);
} }
}); })
]).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({ _.each(fieldsConfiguration, function(field) {
el : $("form[name=registerForm]"), if (field.required) {
rules: rules var rule = {
"name": field.name,
"rules": "required",
"message": i18n.t("validation_blank")
};
rules.push(rule);
}
});
new RegisterForm({
el : $("form[name=registerForm]"),
rules: rules
});
}); });
}); });
});
}); });

View File

@@ -14,8 +14,8 @@ require([
"common/forms/views/form" "common/forms/views/form"
], function($, i18n, Common, RenewEmail) { ], function($, i18n, Common, RenewEmail) {
i18n.init({ i18n.init({
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
Common.initialize(); Common.initialize();

View File

@@ -14,8 +14,8 @@ require([
"common/forms/views/formType/passwordSetter" "common/forms/views/formType/passwordSetter"
], function($, i18n, Common, RenewPassword) { ], function($, i18n, Common, RenewPassword) {
i18n.init({ i18n.init({
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function() { }, function() {
Common.initialize(); Common.initialize();

View File

@@ -55,7 +55,7 @@ define([
return this; return this;
}, },
reset: function() { reset: function() {
this.$el.empty(); this.$el.empty();
} }
}); });

View File

@@ -17,9 +17,9 @@ define([
], function($, _, i18n, Backbone, bootstrap, FormView) { ], function($, _, i18n, Backbone, bootstrap, FormView) {
var PasswordSetterForm = FormView.extend({ var PasswordSetterForm = FormView.extend({
events: function(){ events: function(){
return _.extend({},FormView.prototype.events,{ return _.extend({},FormView.prototype.events,{
'keyup input[type=password]' : 'onPasswordKeyup' 'keyup input[type=password]' : 'onPasswordKeyup'
}); });
}, },
onPasswordKeyup : function(event) { onPasswordKeyup : function(event) {
var input = $(event.target); var input = $(event.target);

View File

@@ -32,7 +32,7 @@ define([
ModalView, ModalView,
SaveView, SaveView,
DcFieldView DcFieldView
) { ) {
var expect = chai.expect; var expect = chai.expect;
var assert = chai.assert; var assert = chai.assert;
var should = chai.should(); var should = chai.should();
@@ -176,14 +176,14 @@ define([
describe("DcField Views", function() { describe("DcField Views", function() {
beforeEach(function() { beforeEach(function() {
this.collection = new DcFieldCollection([{ this.collection = new DcFieldCollection([{
"label": "Contributor", "label": "Contributor",
"definition": "An entity responsible for making contributions to the resource.", "definition": "An entity responsible for making contributions to the resource.",
"URI": "http://dublincore.org/documents/dces/#contributor" "URI": "http://dublincore.org/documents/dces/#contributor"
}, { }, {
"label": "Coverage", "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.", "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" "URI": "http://dublincore.org/documents/dces/#coverage"
} }
]); ]);
var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); 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() { 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(); view.$('input#tag').val("").blur();

View File

@@ -12,7 +12,7 @@ define([
FormView, FormView,
InputView, InputView,
ErrorView ErrorView
) { ) {
var expect = chai.expect; var expect = chai.expect;
var assert = chai.assert; var assert = chai.assert;
var should = chai.should(); var should = chai.should();

View File

@@ -52,11 +52,11 @@ $(document).ready(function() {
saveBtn.show(); saveBtn.show();
// wrapp current calback in an input // wrapp current calback in an input
input input
.empty() .empty()
.wrapInner('' .wrapInner(''
+ '<input value = "'+inputVal+'"' + '<input value = "'+inputVal+'"'
+ ' name="oauth_callback" size="50" type="text"/>' + ' name="oauth_callback" size="50" type="text"/>'
); );
$(".url_callback").die(); $(".url_callback").die();
@@ -71,9 +71,9 @@ $(document).ready(function() {
data :{callback : callback}, data :{callback : callback},
success : function(data) { success : function(data) {
if(data.success) { if(data.success) {
input.empty().append(callback); input.empty().append(callback);
} else { } else {
input.empty().append(inputVal); input.empty().append(inputVal);
} }
} }
}); });

View File

@@ -1,507 +1,507 @@
function ini_edit_usrs(){ function ini_edit_usrs(){
$('.users_col.options').bind('click', function(event){ $('.users_col.options').bind('click', function(event){
$('#users_check_uncheck').remove(); $('#users_check_uncheck').remove();
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
check_uncheck_menu($('input[name="right"]', $(this)).val(),$('input[name="sbas_id"]', $(this)).val(), $(this)); 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();
});
$('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);
}); });
return false; $(document).unbind('click.usersoptions').bind('click.usersoptions', function(event){
}); $('#users_check_uncheck').remove();
});
var time_buttons = { $('table.hoverable tr').hover(
'Ok':function(){ function(){
save_time(); $(this).addClass('hovered');
}, },
'Cancel':function(){ function(){
$('#time_dialog').dialog('close'); $(this).removeClass('hovered');
} }
}; );
$('#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 = { $('table.hoverable td').hover(
'Ok':function(){ function(){
save_masks(); var attr = $('input:first', this).attr('name');
}, var right = attr ? attr.split('_').shift() : false;
'Cancel':function(){ if(right)
$('#masks_dialog').dialog('close'); $('td.case_right_'+right).addClass('hovered');
} },
}; function(){
$('#masks_dialog').dialog({ var attr = $('input:first', this).attr('name');
resizable:false, var right = attr ? attr.split('_').shift() : false;
autoOpen:false, if(right)
draggable:false, $('td.hovered').removeClass('hovered');
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")) { function user_click_box(event, element, status)
dialog.html(data).dialog('open'); {
} var newclass, newvalue, boxes;
$('div.switch_time', dialog).bind('click', function(event){ var $element = $(element);
var newclass, boxes;
boxes = $(this).closest('form').find('input.datepicker'); if($element.hasClass('right_access'))
{
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) var base_id = $element.find('input').attr('name').split('_').pop();
{ boxes = $('div.base_'+base_id+':not(:first)');
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){ if((typeof status !== 'undefined' && status == 'checked') || (typeof status === 'undefined' && (($element.hasClass('mixed') === true) || ($element.hasClass('unchecked') === true))))
var newclass, boxes; {
boxes = $(this).closest('form').find('input:text');
if(($(this).hasClass('mixed')===true) || ($(this).hasClass('unchecked') === true))
{
newclass = 'checked'; newclass = 'checked';
boxes.removeAttr('readonly'); newvalue = '1';
}
else if(boxes)
{ boxes.show();
}
else
{
newclass = 'unchecked'; 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(){ $element.find('input').val(newvalue);
var base_id = $(this).find('input[name="masks_base_id"]').val(); $element.removeClass('mixed checked unchecked').addClass(newclass);
$.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
{ $('#users_rights_form div.switch_right').bind('click', function(event){
newclass="unchecked"; user_click_box(event, $(this));
}
$('.inside_sbas_'+sbas_id+'.'+right+':visible').each(function(i,n){
user_click_box(null, $(n), newclass);
}); });
} $('#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);
});
}
} }

View File

@@ -6,387 +6,387 @@
$(document).ready(function(){ $(document).ready(function(){
function users_select_this(n,k) function users_select_this(n,k)
{
if(p4.users.sel.length >= 800)
{ {
alert(language.max_record_selected);
return false;
}
p4.users.sel.push(k);
$(n).addClass('selected');
return true;
}
$('#users th.sortable').live('click', function(){ if(p4.users.sel.length >= 800)
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")) { alert(language.max_record_selected);
container.dialog('close'); return false;
} }
$('input[name="value"]', container).val(''); p4.users.sel.push(k);
$('#right-ajax').empty().addClass('loading'); $(n).addClass('selected');
p4.users.sel = []; return true;
$.ajax({ }
$('#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', type: 'POST',
url: '../admin/users/rights/', url: '../admin/users/rights/',
data: { data: {
users : data.data users : users
}, },
success: function(data){ 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)
{ $('#users_page_form .user_deleter').live('click', function(){
if(!users_select_this(el,k)) var users = p4.users.sel.join(';');
return false; if(users === '')
}
}
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; return false;
} }
}
else $('#right-ajax').empty().addClass('loading');
{ p4.users.sel = [];
if($.inArray(k,p4.users.sel)>=0) $.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; return false;
} }
}
}
$('.last_selected', cont).removeClass('last_selected');
$(el).addClass('last_selected');
}).live('mousedown', function(evt){
if(evt.stopPropagation) $('#right-ajax').empty().addClass('loading');
evt.stopPropagation(); p4.users.sel = [];
evt.cancelBubble = true; $.ajax({
evt.preventDefault(); type: 'POST',
}); url: '../admin/users/rights/',
data: {
$('#users_apply_template').live('submit', function(){ users : users
var users = p4.users.sel.join(';'); },
if(users === '') success: function(data){
{ $('#right-ajax').removeClass('loading').html(data);
return false; }
} });
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 : 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

View File

@@ -1,127 +1,127 @@
$(document).ready(function(){ $(document).ready(function(){
if(typeof validator_loaded === 'boolean') if(typeof validator_loaded === 'boolean')
return; return;
$('.confirm_report').live('click',function(){ $('.confirm_report').live('click',function(){
var $this = $(this); var $this = $(this);
$('.loader', $this).css({ $('.loader', $this).css({
visibility:'visible' 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({ $('.agreement_radio').live('vmousedown', function(){
type: "POST", var sselcont_id = $(this).attr('for').split('_').pop();
url: "/lightbox/ajax/SET_RELEASE/" + $('#basket_validation_id').val() + "/", var agreement = $('#' + $(this).attr('for')).val() == 'yes' ? '1' : '-1';
dataType: 'json',
error: function(data) { $.mobile.loading();
$('.loader', $this).css({
visibility: 'hidden' $.ajax({
}); type: "POST",
}, url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/",
timeout: function(data) { dataType: 'json',
$('.loader', $this).css({ data: {
visibility: 'hidden' agreement : agreement
}); },
}, error: function(datas){
success: function(data) { alert('error');
$('.loader', $this).css({ $.mobile.loading();
visibility: 'hidden' },
}); timeout: function(datas){
if (data.datas) { alert('error');
alert(data.datas); $.mobile.loading();
} },
if (!data.error) { success: function(datas){
releasable = false; 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;
});

View File

@@ -1,245 +1,245 @@
; ;
(function(document){ (function(document){
/***************** /*****************
* Canva Object * Canva Object
*****************/ *****************/
var Canva = function(domCanva){ var Canva = function(domCanva){
this.domCanva = 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();
}
}; };
};
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); })(document);

View File

@@ -2,63 +2,63 @@ var p4 = p4 || {};
(function(p4){ (function(p4){
function create_dialog() function create_dialog()
{
if($('#p4_alerts').length === 0)
{ {
$('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)
}
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
{ {
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; return;
}
p4.Alerts = alert;
return;
}(p4)); }(p4));

View File

@@ -4,284 +4,284 @@ var p4 = p4 || {};
; ;
(function(p4, $){ (function(p4, $){
function getLevel (level) { function getLevel (level) {
level = parseInt(level); level = parseInt(level);
if(isNaN(level) || level < 1) if(isNaN(level) || level < 1)
{ {
return 1; return 1;
} }
return level; 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;
}; };
var defaults = { function getId (level)
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': return 'DIALOG' + getLevel(level);
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')) { function addButtons(buttons, dialog)
this.$dialog.dialog('destroy'); {
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) var phraseaDialog = function (options, level) {
.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) var createDialog = function(level) {
{
this.$dialog.addClass('loading');
}
if(this.options.size === 'Full') var $dialog = $('#' + getId(level));
{
var $this = this; if($dialog.length > 0)
$(window).unbind('resize.DIALOG' + getLevel(level)) {
.bind('resize.DIALOG' + getLevel(level), function(){ throw 'Dialog already exists at this level';
if ($this.$dialog.data("ui-dialog")) { }
$this.$dialog.dialog('option', {
width : bodySize.x - 30, $dialog = $('<div style="display:none;" id="' + getId(level) + '"></div>');
height : bodySize.y - 30 $('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 = { Dialog.prototype = {
Close : function() { Create : function(options, level) {
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({ if(this.get(level) instanceof phraseaDialog)
type: this.loader.method, {
url: this.loader.url, this.get(level).Close();
dataType: 'html', }
data : this.loader.params,
beforeSend:function(){ $dialog = new phraseaDialog(options, level);
this.currentStack[$dialog.getId()] = $dialog;
return $dialog;
}, },
success: function(data){ get : function (level) {
$this.setContent(data);
return; var id = getId(level);
if(id in this.currentStack)
{
return this.currentStack[id];
}
return null;
}, },
error: function(){ Close : function (level) {
return;
}, $(window).unbind('resize.DIALOG' + getLevel(level));
timeout: function(){
return; 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 () { p4.Dialog = new Dialog();
this.currentStack = {};
};
Dialog.prototype = { }(p4, jQuery));
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));

File diff suppressed because it is too large Load Diff

View File

@@ -2,23 +2,23 @@ var p4 = p4 || {};
(function(p4, window){ (function(p4, window){
p4.Results = { p4.Results = {
'Selection':new Selectable($('#answers'), { 'Selection':new Selectable($('#answers'), {
selector : '.IMGT', selector : '.IMGT',
limit:800, limit:800,
selectStart:function(event, selection){ selectStart:function(event, selection){
$('#answercontextwrap table:visible').hide(); $('#answercontextwrap table:visible').hide();
}, },
selectStop:function(event, selection){ selectStop:function(event, selection){
viewNbSelect(); viewNbSelect();
}, },
callbackSelection:function(element){ callbackSelection:function(element){
var elements = $(element).attr('id').split('_'); 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)); }(p4, window));

View File

@@ -98,20 +98,20 @@ var p4 = p4 || {};
var texte = '<p>' + language.confirmRemoveReg + '</p><div><input type="checkbox" onchange="toggleRemoveReg(this);"/>' + language.hideMessage + '</div>'; var texte = '<p>' + language.confirmRemoveReg + '</p><div><input type="checkbox" onchange="toggleRemoveReg(this);"/>' + language.hideMessage + '</div>';
$('body').append('<div id="DIALOG-baskets"></div>'); $('body').append('<div id="DIALOG-baskets"></div>');
$("#DIALOG-baskets").attr('title', language.removeTitle) $("#DIALOG-baskets").attr('title', language.removeTitle)
.empty() .empty()
.append(texte) .append(texte)
.dialog({ .dialog({
autoOpen: false, autoOpen: false,
closeOnEscape: true, closeOnEscape: true,
resizable: false, resizable: false,
draggable: false, draggable: false,
modal: true, modal: true,
buttons: buttons, buttons: buttons,
overlay: { overlay: {
backgroundColor: '#000', backgroundColor: '#000',
opacity: 0.7 opacity: 0.7
} }
}).dialog('open'); }).dialog('open');
return; return;
} }
@@ -145,11 +145,11 @@ var p4 = p4 || {};
if (selectedItemIndex === 0 && carouselItemLength > 1) { if (selectedItemIndex === 0 && carouselItemLength > 1) {
// click next item // click next item
selectedItem.next().find("img").trigger("click"); 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)) { } else if (carouselItemLength > 1 && selectedItemIndex === (carouselItemLength - 1)) {
// click previous item // click previous item
selectedItem.prev().find("img").trigger("click"); selectedItem.prev().find("img").trigger("click");
// Basket is empty // Basket is empty
} else if (carouselItemLength > 1) { } else if (carouselItemLength > 1) {
// click next item // click next item
selectedItem.next().find("img").trigger("click"); selectedItem.next().find("img").trigger("click");
@@ -236,24 +236,24 @@ var p4 = p4 || {};
} }
$(".SSTT, .content", cache) $(".SSTT, .content", cache)
.droppable({ .droppable({
scope: 'objects', scope: 'objects',
hoverClass: 'baskDrop', hoverClass: 'baskDrop',
tolerance: 'pointer', tolerance: 'pointer',
accept: function(elem) { accept: function(elem) {
if ($(elem).hasClass('CHIM')) { if ($(elem).hasClass('CHIM')) {
if ($(elem).closest('.content').prev()[0] === $(this)[0]) { if ($(elem).closest('.content').prev()[0] === $(this)[0]) {
return false; 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) if ($('#basketcontextwrap').length === 0)
$('body').append('<div id="basketcontextwrap"></div>'); $('body').append('<div id="basketcontextwrap"></div>');
@@ -312,8 +312,8 @@ var p4 = p4 || {};
$('a.WorkZoneElementRemover', dest).bind('mousedown', function(event) { $('a.WorkZoneElementRemover', dest).bind('mousedown', function(event) {
return false; return false;
}).bind('click', function(event) { }).bind('click', function(event) {
return WorkZoneElementRemover($(this), false); return WorkZoneElementRemover($(this), false);
}); });
dest.droppable({ dest.droppable({
accept: function(elem) { accept: function(elem) {
@@ -339,10 +339,10 @@ var p4 = p4 || {};
dest.find('.CHIM').draggable({ dest.find('.CHIM').draggable({
helper: function() { helper: function() {
$('body').append('<div id="dragDropCursor" ' + $('body').append('<div id="dragDropCursor" ' +
'style="position:absolute;z-index:9999;background:red;' + 'style="position:absolute;z-index:9999;background:red;' +
'-moz-border-radius:8px;-webkit-border-radius:8px;">' + '-moz-border-radius:8px;-webkit-border-radius:8px;">' +
'<div style="padding:2px 5px;font-weight:bold;">' + '<div style="padding:2px 5px;font-weight:bold;">' +
p4.WorkZone.Selection.length() + '</div></div>'); p4.WorkZone.Selection.length() + '</div></div>');
return $('#dragDropCursor'); return $('#dragDropCursor');
}, },
scope: "objects", scope: "objects",
@@ -356,7 +356,7 @@ var p4 = p4 || {};
start: function(event, ui) { start: function(event, ui) {
var baskets = $('#baskets'); var baskets = $('#baskets');
baskets.append('<div class="top-scroller"></div>' + baskets.append('<div class="top-scroller"></div>' +
'<div class="bottom-scroller"></div>'); '<div class="bottom-scroller"></div>');
$('.bottom-scroller', baskets).bind('mousemove', function() { $('.bottom-scroller', baskets).bind('mousemove', function() {
$('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop() + 30); $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop() + 30);
}); });
@@ -366,8 +366,8 @@ var p4 = p4 || {};
}, },
stop: function() { stop: function() {
$('#baskets').find('.top-scroller, .bottom-scroller') $('#baskets').find('.top-scroller, .bottom-scroller')
.unbind() .unbind()
.remove(); .remove();
}, },
drag: function(event, ui) { drag: function(event, ui) {
if (is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping')) if (is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping'))
@@ -572,13 +572,13 @@ var p4 = p4 || {};
frame.data('openwidth', frame.width()); frame.data('openwidth', frame.width());
frame.animate({width: 100}, frame.animate({width: 100},
300, 300,
'linear', 'linear',
function() { function() {
answerSizer(); answerSizer();
linearize(); linearize();
$('#answers').trigger('resize'); $('#answers').trigger('resize');
}); });
frame.addClass('closed'); frame.addClass('closed');
$('.escamote', frame).hide(); $('.escamote', frame).hide();
$('li.ui-tabs-selected', frame).removeClass('ui-tabs-selected'); $('li.ui-tabs-selected', frame).removeClass('ui-tabs-selected');

File diff suppressed because it is too large Load Diff

View File

@@ -428,7 +428,7 @@ function afterSearch()
$('.rollover-gif-hover',this).hide(); $('.rollover-gif-hover',this).hide();
$('.rollover-gif-out',this).show(); $('.rollover-gif-out',this).show();
} }
); );
viewNbSelect(); viewNbSelect();
$('#answers div.IMGT').draggable({ $('#answers div.IMGT').draggable({
helper : function(){ helper : function(){
@@ -464,7 +464,7 @@ function initAnswerForm(){
searchForm.unbind('submit').bind('submit',function(){ searchForm.unbind('submit').bind('submit',function(){
var $this = $(this), var $this = $(this),
method = $this.attr('method') ? $this.attr('method') : 'POST'; method = $this.attr('method') ? $this.attr('method') : 'POST';
answAjax = $.ajax({ answAjax = $.ajax({
type: method, type: method,
@@ -750,7 +750,7 @@ function toHex(N) {
N=Math.min(N,255); N=Math.min(N,255);
N=Math.round(N); N=Math.round(N);
return "0123456789ABCDEF".charAt((N-N%16)/16) return "0123456789ABCDEF".charAt((N-N%16)/16)
+ "0123456789ABCDEF".charAt(N%16); + "0123456789ABCDEF".charAt(N%16);
} }
function hsl2rgb(h, s, l) { function hsl2rgb(h, s, l) {
var m1, m2, hue; var m1, m2, hue;
@@ -917,10 +917,10 @@ $(document).ready(function(){
$('style[title=color_selection]').empty(); $('style[title=color_selection]').empty();
var datas = '.diapo.selected,#reorder_box .diapo.selected, #EDIT_ALL .diapo.selected, .list.selected, .list.selected .diapo' + var datas = '.diapo.selected,#reorder_box .diapo.selected, #EDIT_ALL .diapo.selected, .list.selected, .list.selected .diapo' +
'{'+ '{'+
' COLOR: #'+back_hex+';'+ ' COLOR: #'+back_hex+';'+
' BACKGROUND-COLOR: #'+hex+';'+ ' BACKGROUND-COLOR: #'+hex+';'+
'}'; '}';
$('style[title=color_selection]').empty().text(datas); $('style[title=color_selection]').empty().text(datas);
} }
}); });
@@ -1022,22 +1022,22 @@ $(document).ready(function(){
$("#DIALOG").dialog('destroy'); $("#DIALOG").dialog('destroy');
} }
$("#DIALOG").attr('title',data.titre) $("#DIALOG").attr('title',data.titre)
.empty() .empty()
.append(data.texte) .append(data.texte)
.dialog({ .dialog({
autoOpen:false, autoOpen:false,
closeOnEscape:true, closeOnEscape:true,
resizable:false, resizable:false,
draggable:false, draggable:false,
modal:true, modal:true,
buttons:buttons, buttons:buttons,
width:650, width:650,
height:250, height:250,
overlay: { overlay: {
backgroundColor: '#000', backgroundColor: '#000',
opacity: 0.7 opacity: 0.7
} }
}).dialog('open'); }).dialog('open');
} }
} }
@@ -1053,8 +1053,8 @@ $(document).ready(function(){
$('#history-queries ul li').live('mouseover',function(){ $('#history-queries ul li').live('mouseover',function(){
$(this).addClass('hover'); $(this).addClass('hover');
}).live('mouseout',function(){ }).live('mouseout',function(){
$(this).removeClass('hover'); $(this).removeClass('hover');
}); });
startThesaurus(); startThesaurus();
checkFilters(); checkFilters();
@@ -1094,15 +1094,15 @@ $(document).ready(function(){
$('#idFrameC').stop().animate({ $('#idFrameC').stop().animate({
width : nwidth width : nwidth
}, },
300, 300,
'linear', 'linear',
function(){ function(){
answerSizer(); answerSizer();
linearize(); linearize();
saveWindows(); saveWindows();
}); });
} }
}); });
@@ -1163,17 +1163,17 @@ $(document).ready(function(){
$('.tools .answer_selector').bind('click',function(){ $('.tools .answer_selector').bind('click',function(){
selector($(this)); selector($(this));
}).bind('mouseover',function(event){ }).bind('mouseover',function(event){
if(is_ctrl_key(event)) if(is_ctrl_key(event))
{ {
$(this).addClass('add_selector'); $(this).addClass('add_selector');
} }
else else
{ {
$(this).removeClass('add_selector');
}
}).bind('mouseout',function(){
$(this).removeClass('add_selector'); $(this).removeClass('add_selector');
} });
}).bind('mouseout',function(){
$(this).removeClass('add_selector');
});
getLanguage(); getLanguage();
@@ -1233,27 +1233,27 @@ $(document).ready(function(){
if(p4.preview.open) if(p4.preview.open)
{ {
if (($('#dialog_dwnl:visible').length === 0 && $('#DIALOG1').length === 0 && $('#DIALOG2').length === 0)) { if (($('#dialog_dwnl:visible').length === 0 && $('#DIALOG1').length === 0 && $('#DIALOG2').length === 0)) {
switch(event.keyCode) switch(event.keyCode)
{ {
case 39: case 39:
getNext(); getNext();
cancelKey = shortCut = true; cancelKey = shortCut = true;
break; break;
case 37: case 37:
getPrevious(); getPrevious();
cancelKey = shortCut = true; cancelKey = shortCut = true;
break; break;
case 27://escape case 27://escape
closePreview(); closePreview();
break; break;
case 32: case 32:
if(p4.slideShow) if(p4.slideShow)
stopSlide(); stopSlide();
else else
startSlide(); startSlide();
cancelKey = shortCut = true; cancelKey = shortCut = true;
break; break;
} }
} }
} }
else else
@@ -1411,8 +1411,8 @@ $(document).ready(function(){
$('#EDIT_query').bind('focus',function(){ $('#EDIT_query').bind('focus',function(){
$(this).addClass('focused'); $(this).addClass('focused');
}).bind('blur',function(){ }).bind('blur',function(){
$(this).removeClass('focused'); $(this).removeClass('focused');
}); });
$('.basketTips').tooltip({ $('.basketTips').tooltip({
delay: 200 delay: 200
@@ -1716,7 +1716,7 @@ function toolREFACTOR(datas){
dialog.setContent(data); dialog.setContent(data);
return; 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) for(i in value)
{ {
return chgCollThis(value); return chgCollThis(value);
@@ -2098,7 +2098,7 @@ function activeIcons()
} }
} else { } else {
if ($this.hasClass('basket_element')) { 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 { } else {
if ($this.hasClass('story_window')) { if ($this.hasClass('story_window')) {
if (p4.WorkZone.Selection.length() > 0) { if (p4.WorkZone.Selection.length() > 0) {
@@ -2388,21 +2388,21 @@ function printThis(value)
$("#DIALOG").dialog('destroy'); $("#DIALOG").dialog('destroy');
} }
$('#DIALOG').attr('title', language.print) $('#DIALOG').attr('title', language.print)
.empty().addClass('loading') .empty().addClass('loading')
.dialog({ .dialog({
resizable:false, resizable:false,
closeOnEscape:true, closeOnEscape:true,
modal:true, modal:true,
width:'800', width:'800',
height:'500', height:'500',
open: function(event, ui) { open: function(event, ui) {
$(this).dialog("widget").css("z-index", "1999"); $(this).dialog("widget").css("z-index", "1999");
}, },
close: function(event, ui) { close: function(event, ui) {
$(this).dialog("widget").css("z-index", "auto"); $(this).dialog("widget").css("z-index", "auto");
} }
}) })
.dialog('open'); .dialog('open');
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -2413,7 +2413,7 @@ function printThis(value)
}, },
success: function(data){ success: function(data){
$('#DIALOG').removeClass('loading').empty() $('#DIALOG').removeClass('loading').empty()
.append(data); .append(data);
return; return;
} }
}); });
@@ -2432,7 +2432,7 @@ function downloadThis(datas)
$('.close_button', dialog.getDomElement()).bind('click',function(){ $('.close_button', dialog.getDomElement()).bind('click',function(){
dialog.Close(); dialog.Close();
}); });
return false; return false;
}); });
@@ -2581,8 +2581,8 @@ function doDelete(lst)
$.each(data,function(i,n){ $.each(data,function(i,n){
var imgt = $('#IMGT_'+n), var imgt = $('#IMGT_'+n),
chim = $('.CHIM_'+n), chim = $('.CHIM_'+n),
stories = $('.STORY_'+n); stories = $('.STORY_'+n);
$('.doc_infos', imgt).remove(); $('.doc_infos', imgt).remove();
imgt.unbind("click").removeAttr("ondblclick").removeClass("selected").removeClass("IMGT").find("img").unbind(); 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'); $(this).addClass('selected');
$('input[name="feed_id"]', $form).val($('input', this).val()); $('input[name="feed_id"]', $form).val($('input', this).val());
}).hover(function(){ }).hover(function(){
$(this).addClass('hover'); $(this).addClass('hover');
},function(){ },function(){
$(this).removeClass('hover'); $(this).removeClass('hover');
}); });
$form.bind('submit', function(){ $form.bind('submit', function(){
return false; return false;

View File

@@ -8,11 +8,11 @@ function publicator_reload_publicator()
function init_publicator(datas) function init_publicator(datas)
{ {
var dialog = p4.Dialog.Create({ var dialog = p4.Dialog.Create({
size:'Full', size:'Full',
title:'Bridge', title:'Bridge',
loading: false loading: false
}); });
dialog.load('/prod/bridge/manager/', 'POST', datas); dialog.load('/prod/bridge/manager/', 'POST', datas);
} }

View File

@@ -101,8 +101,8 @@ function bindEvents() {
}, },
text: false text: false
}).unbind("click").bind("click", function () { }).unbind("click").bind("click", function () {
showMenu(); showMenu();
}); });
$("#liste_dash").find("em").unbind("click").bind("click", function () { $("#liste_dash").find("em").unbind("click").bind("click", function () {
id = $(this).attr('id').substr(3); id = $(this).attr('id').substr(3);

View File

@@ -1,108 +1,108 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// sprintf function for javascript // sprintf function for javascript
function sprintf() function sprintf()
{ {
if (!arguments || arguments.length < 1 || !RegExp) if (!arguments || arguments.length < 1 || !RegExp)
{ {
return ''; return '';
} }
str = arguments[0]; str = arguments[0];
while((newstr = str.replace("\n", "\x01")) != str) while((newstr = str.replace("\n", "\x01")) != str)
str = newstr; str = newstr;
// var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; // 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"); var re = new RegExp("^([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)$", "m");
re["$*"] = true; re["$*"] = true;
var a = b = [], numSubstitutions = 0, numMatches = 0; 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;
a = re.exec(str); a = re.exec(str);
} while (a)
while((newstr = str.replace("\x01", "\n")) != str) {
str = newstr; var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
return(str); 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);
}

View File

@@ -1,422 +1,422 @@
function loadXMLDoc(url, post_parms, asxml) function loadXMLDoc(url, post_parms, asxml)
{ {
if(typeof(asxml)=="undefined") if(typeof(asxml)=="undefined")
asxml = false; asxml = false;
out = null; out = null;
xmlhttp = null; xmlhttp = null;
// code for Mozilla, etc. // code for Mozilla, etc.
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
else if (window.ActiveXObject) else if (window.ActiveXObject)
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp) if (xmlhttp)
{ {
// xmlhttp.onreadystatechange=state_Change // xmlhttp.onreadystatechange=state_Change
if(post_parms) if(post_parms)
{ {
xmlhttp.open("POST", url, false); xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(post_parms); xmlhttp.send(post_parms);
} }
else else
{ {
xmlhttp.open("GET", url, false); xmlhttp.open("GET", url, false);
xmlhttp.send(null); xmlhttp.send(null);
} }
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText; out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
} }
return(out); return(out);
} }
function showFound2(term, lterm, branch, depth) function showFound2(term, lterm, branch, depth)
{ {
var c; var c;
var ret = 0; var ret = 0;
var thb = branch.firstChild.nextSibling.nextSibling; var thb = branch.firstChild.nextSibling.nextSibling;
// branch est un <DIV ID="THE_xxx"> // branch est un <DIV ID="THE_xxx">
if(thb) if(thb)
{ {
for(c=thb.firstChild; c; c=c.nextSibling) // THE, les SY ou les TA for(c=thb.firstChild; c; c=c.nextSibling) // THE, les SY ou les TA
{ {
if(c.nodeName=="DIV") if(c.nodeName=="DIV")
ret += showFound2(term, lterm, c, depth+1); // on descend uniquement les THE_yyy ret += showFound2(term, lterm, c, depth+1); // on descend uniquement les THE_yyy
} }
} }
if(branch.firstChild.nextSibling.nodeValue.substr(0, lterm)==term) if(branch.firstChild.nextSibling.nodeValue.substr(0, lterm)==term)
{ {
ret = 1; ret = 1;
// alert(branch.firstChild.nextSibling.nodeValue + " : " + thb.id); // alert(branch.firstChild.nextSibling.nodeValue + " : " + thb.id);
} }
// if(ret > 0) // if(ret > 0)
// if(depth > 0) // if(depth > 0)
// { // {
if(ret > 0) if(ret > 0)
{ {
//eventObj.Src0.innerHTML = "+"; //eventObj.Src0.innerHTML = "+";
thb.className = "OB"; thb.className = "OB";
} }
else else
{ {
//eventObj.Src0.innerHTML = "+"; //eventObj.Src0.innerHTML = "+";
thb.className = "ob"; thb.className = "ob";
} }
// } // }
/* /*
if(depth == 0) if(depth == 0)
{ {
document.getElementById("WT1").style.visibility="hidden"; document.getElementById("WT1").style.visibility="hidden";
if(document.forms["fTh"].textT1.value!=term) if(document.forms["fTh"].textT1.value!=term)
{ {
// oups! le mot a changé durant le traitement, on recommence // oups! le mot a changé durant le traitement, on recommence
evt_kup_T1(); evt_kup_T1();
} }
} }
*/ */
return(ret); return(ret);
} }
function showAll(branch, depth) function showAll(branch, depth)
{ {
depth = parseInt(depth); depth = parseInt(depth);
var c; var c;
for(c=branch.firstChild; c; c=c.nextSibling) for(c=branch.firstChild; c; c=c.nextSibling)
{ {
if(c.nodeType==1 && c.nodeName=="DIV") // 1=XML_ELEMENT_NODE if(c.nodeType==1 && c.nodeName=="DIV") // 1=XML_ELEMENT_NODE
showAll(c, depth+1); showAll(c, depth+1);
} }
if(depth > 0) if(depth > 0)
branch.style.display = ""; branch.style.display = "";
if(depth===0) if(depth===0)
{ {
document.getElementById("WT1").style.visibility="hidden"; document.getElementById("WT1").style.visibility="hidden";
if(document.forms["fTh"].textT1.value!=="") if(document.forms["fTh"].textT1.value!=="")
{ {
// oups! le mot a changé durant le traitement, on recommence // oups! le mot a changé durant le traitement, on recommence
evt_kup_T1(); evt_kup_T1();
} }
} }
} }
function scanTerms(inputName, zTerm, showhide) function scanTerms(inputName, zTerm, showhide)
{ {
showhide = !!showhide; showhide = !!showhide;
var lTerm = zTerm.length; var lTerm = zTerm.length;
var zTable = document.getElementById("L"+inputName); var zTable = document.getElementById("L"+inputName);
var zTr = zTable.childNodes; // TR's var zTr = zTable.childNodes; // TR's
var l = zTr.length; var l = zTr.length;
var found = null; var found = null;
for(var i=0; i<l; i++) for(var i=0; i<l; i++)
{ {
// if(renum) // if(renum)
// zTr[i].id = inputName+"_"+i // zTr[i].id = inputName+"_"+i
var t = zTr[i].firstChild.firstChild.nodeValue; var t = zTr[i].firstChild.firstChild.nodeValue;
// alert(i+" "+t); // alert(i+" "+t);
if(zTerm == t) if(zTerm == t)
found = zTr[i]; found = zTr[i];
if(showhide === true) if(showhide === true)
{ {
if(lTerm==0 || (t.substr(0, lTerm)==zTerm)) if(lTerm==0 || (t.substr(0, lTerm)==zTerm))
zTr[i].style.display = ""; zTr[i].style.display = "";
else else
zTr[i].style.display = "none"; zTr[i].style.display = "none";
} }
else else
{ {
zTr[i].style.display = ""; zTr[i].style.display = "";
} }
} }
return(found); return(found);
} }
function addTerm(inputName, zTerm, oldid) // inputName = "TS"|"TA"|"SY" 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 if(typeof(zTerm)=="undefined") // si pas de terme en argument, prendre dans la zone de saisie
zTerm = document.forms["fTh"]["text"+inputName].value; zTerm = document.forms["fTh"]["text"+inputName].value;
// alert(zTerm); // alert(zTerm);
// on cherche si le zTerm existe déjà // on cherche si le zTerm existe déjà
// var parent_id = selectedThesaurusItem.getAttribute("id"); // var parent_id = selectedThesaurusItem.getAttribute("id");
// alert("parent_id = " + parent_id); // alert("parent_id = " + parent_id);
// found = scanTerms(inputName, true, false); // renuméroter et tout afficher // found = scanTerms(inputName, true, false); // renuméroter et tout afficher
var found = scanTerms(inputName, zTerm, false); // tout afficher var found = scanTerms(inputName, zTerm, false); // tout afficher
if(!found) if(!found)
{ {
// on cherche la div "thb" si elle existe // on cherche la div "thb" si elle existe
var thb, thRef; var thb, thRef;
for(thb=selectedThesaurusItem.firstChild; thb; thb=thb.nextSibling) for(thb=selectedThesaurusItem.firstChild; thb; thb=thb.nextSibling)
{ {
if(thb.nodeType==1 && thb.tagName=="DIV" && thb.id.substr(0,4)=="THB_") if(thb.nodeType==1 && thb.tagName=="DIV" && thb.id.substr(0,4)=="THB_")
break; break;
} }
if(!thb) if(!thb)
{ {
// on ajoute le premier fils ... // on ajoute le premier fils ...
// ... on crée le +/- en face du terme // ... on crée le +/- en face du terme
selectedThesaurusItem.firstChild.className = "tri"; selectedThesaurusItem.firstChild.className = "tri";
selectedThesaurusItem.firstChild.id = "THP_" + selectedThesaurusItem.id.substr(4); selectedThesaurusItem.firstChild.id = "THP_" + selectedThesaurusItem.id.substr(4);
selectedThesaurusItem.firstChild.innerHTML = "-"; selectedThesaurusItem.firstChild.innerHTML = "-";
// selectedThesaurusItem.nextid = "0"; // selectedThesaurusItem.nextid = "0";
selectedThesaurusItem.setAttribute("nextid", "0"); selectedThesaurusItem.setAttribute("nextid", "0");
// ... on crée la div "THB" // ... on crée la div "THB"
thb = selectedThesaurusItem.appendChild(document.createElement("DIV")); thb = selectedThesaurusItem.appendChild(document.createElement("DIV"));
thb.className = "ob"; thb.className = "ob";
thb.id = "THB_" + selectedThesaurusItem.id.substr(4); 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));
// on ajoute le nouveau terme dans le thb : on crée une nouvelle div if(inputName=="TS") // on ajoute un terme spécifique
var div = document.createElement("DIV"); {
div.className = "s_"; // un id pour le nouveau terme
if(selectedThesaurusItem.id == "THE_") var nextid = parseInt(selectedThesaurusItem.getAttribute("nextid"));
div.id = "THE_" + nextid; // selectedThesaurusItem.nextid = "" + (nextid+1);
else selectedThesaurusItem.setAttribute("nextid", "" + (nextid+1));
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 = "&nbsp;";
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++;
}
// on ajoute aussi à la liste des termes // on ajoute le nouveau terme dans le thb : on crée une nouvelle div
tr = appendTerm(inputName, zTerm, nextid); var div = document.createElement("DIV");
// on scroll la liste pour montrer le nouveau terme, et on le selectionne div.className = "s_";
tr.scrollIntoView(false); if(selectedThesaurusItem.id == "THE_")
myGUI.select(tr); 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 = "&nbsp;";
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; document.forms["fTh"]["text"+inputName].value = "";
dirty(); termChanged = true;
}
dirty();
}
// else // 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() function dirty()
{ {
thesaurusChanged = true; thesaurusChanged = true;
document.getElementById("saveButton").style.display = ""; document.getElementById("saveButton").style.display = "";
} }
/* /*
function delTerm(inputName, zTerm) // inputName = "TS"|"TA"|"SY" function delTerm(inputName, zTerm) // inputName = "TS"|"TA"|"SY"
{ {
if(typeof(zTerm)=="undefined") if(typeof(zTerm)=="undefined")
zTerm = document.forms["fTh"]["text"+inputName].value; zTerm = document.forms["fTh"]["text"+inputName].value;
// on cherche si le zTerm existe déjà // on cherche si le zTerm existe déjà
// zTr = scanTerms(inputName, true, false); // renuméroter et tout afficher // zTr = scanTerms(inputName, true, false); // renuméroter et tout afficher
var zTr = scanTerms(inputName, zTerm, false); // tout afficher var zTr = scanTerms(inputName, zTerm, false); // tout afficher
if(zTr) if(zTr)
{ {
// si on a supprimé un terme spécifique, on vérifie s'il en reste // si on a supprimé un terme spécifique, on vérifie s'il en reste
var thb = zTr.thRef.parentNode; 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);
}
// var d = thb_deleted.appendChild(document.createElement("DIV") ); if(inputName == "TS")
// d.className = "s_ R_"; {
// d.id = "TCE_R" + zid + "." + deleted.nextid; // on deplace du thesaurus vers les candidats (refuse), pour le champ special '(deleted)'
// d.appendChild(zTr.thRef.firstChild.nextSibling.cloneNode(false) ); var deleted=null
// d.setAttribute("oldid", zTr.thRef.oldid ? zTr.thRef.oldid : zTr.thRef.id.substr(4) ); var thb_deleted;
// on cherche la branche de 'deleted' dans les cterms
// deleted.setAttribute("nextid", parseInt(deleted.getAttribute("nextid")+1) ); 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); // on cree le grp
} deleted = document.getElementById("CTERMS").appendChild(document.createElement("DIV"));
thb.removeChild(zTr.thRef); // supprime le node du thesaurus deleted.name = "CTERMSGRP";
if(!thb.firstChild) deleted.className = "s_ R_";
{ deleted.id = "C"+zid;
// plus de ts : on nettoie deleted.setAttribute("nextid", "0");
var the = thb.parentNode; deleted.setAttribute("field", "(deleted)");
the.removeChild(thb); // supprime thb
var u = the.firstChild;
u.innerHTML = "&nbsp;" // vire le +/-
u.className = "";
}
// on supprime aussi de la liste des termes var u = deleted.appendChild(document.createElement("U"));
zTr.parentNode.removeChild(zTr); u.className = "tri";
document.forms["fTh"]["text"+inputName].value = ""; u.id = "THP_C"+zid;
u.innerText = "+ ";
termChanged = true; deleted.appendChild(document.createTextNode("(deleted)"));
dirty(); thb_deleted = deleted.appendChild(document.createElement("DIV"));
} thb_deleted.className = "ob";
else thb_deleted.id = "THB_C"+zid;
{ }
// alert("Le terme associé '"+newterm+"' n' existe pas."); else
} {
evt_kup(inputName); 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 = "&nbsp;" // 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)' ) // supprime un terme et tous ses fils (deplace la branche dans '(deleted)' )
function deleteBranch(the, thb_deleted) function deleteBranch(the, thb_deleted)
{ {
newdel = thb_deleted.appendChild(the.cloneNode(true)); newdel = thb_deleted.appendChild(the.cloneNode(true));
deleteBranch0(newdel, "R"+thb_deleted.parentNode.id.substr(1)); deleteBranch0(newdel, "R"+thb_deleted.parentNode.id.substr(1));
} }
function deleteBranch0(node, pfxid) function deleteBranch0(node, pfxid)
{ {
if(node.id && node.id.substr(0,2)=="TH") if(node.id && node.id.substr(0,2)=="TH")
{ {
oldid = node.oldid ? node.oldid : node.id.substr(4); oldid = node.oldid ? node.oldid : node.id.substr(4);
if(node.id.substr(0,4)=="THE_") if(node.id.substr(0,4)=="THE_")
{ {
node.id = "TCE_" + pfxid + "_" + oldid; node.id = "TCE_" + pfxid + "_" + oldid;
node.className = "s_ R_"; node.className = "s_ R_";
node.setAttribute("oldid", oldid); node.setAttribute("oldid", oldid);
} }
else // THB_ ou THP_ else // THB_ ou THP_
{ {
node.id = node.id.substr(0,4) + pfxid + "_" + oldid; node.id = node.id.substr(0,4) + pfxid + "_" + oldid;
} }
} }
for(var node=node.firstChild; node; node=node.nextSibling) for(var node=node.firstChild; node; node=node.nextSibling)
{ {
deleteBranch0(node, pfxid); deleteBranch0(node, pfxid);
} }
} }
*/ */
// supprime un terme et tous ses fils (deplace 'e plat') dans '(deleted)' // supprime un terme et tous ses fils (deplace 'e plat') dans '(deleted)'
function deleteBranch(the, thb_deleted) function deleteBranch(the, thb_deleted)
{ {
if(the.id.substr(0,4)=="THE_") if(the.id.substr(0,4)=="THE_")
{ {
var d = thb_deleted.appendChild(document.createElement("DIV") ); var d = thb_deleted.appendChild(document.createElement("DIV") );
d.className = "s_ R_"; d.className = "s_ R_";
d.id = "TCE_R" + (thb_deleted.parentNode.id.substr(1)) + "." + (thb_deleted.parentNode.getAttribute("nextid")); 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) ); thb_deleted.parentNode.setAttribute("nextid", parseInt(thb_deleted.parentNode.getAttribute("nextid")+1) );
d.appendChild(the.firstChild.nextSibling.cloneNode(false) ); d.appendChild(the.firstChild.nextSibling.cloneNode(false) );
d.setAttribute("oldid", the.oldid ? the.oldid : the.id.substr(4) ); d.setAttribute("oldid", the.oldid ? the.oldid : the.id.substr(4) );
if(the.firstChild.nextSibling.nextSibling) if(the.firstChild.nextSibling.nextSibling)
{ {
for(var the=the.firstChild.nextSibling.nextSibling.firstChild; the; the=the.nextSibling) for(var the=the.firstChild.nextSibling.nextSibling.firstChild; the; the=the.nextSibling)
{ {
deleteBranch(the, thb_deleted); deleteBranch(the, thb_deleted);
} }
} }
} }
} }
function alertNode(n, msg) function alertNode(n, msg)
{ {
if(typeof(msg)=="undefined") if(typeof(msg)=="undefined")
msg = ""; msg = "";
if(n) if(n)
{ {
if(n.nodeType==1) if(n.nodeType==1)
{ {
alert(msg + " : <"+n.nodeName+" id='"+n.id+"'>"); alert(msg + " : <"+n.nodeName+" id='"+n.id+"'>");
} }
else else
{ {
alert(msg + " : nodeType="+n.nodeType); alert(msg + " : nodeType="+n.nodeType);
} }
} }
else else
{ {
alert(msg + " : NULL"); alert(msg + " : NULL");
} }
} }
function appendTerm(inputName, new_term, id) function appendTerm(inputName, new_term, id)
{ {
var tr = document.createElement("TR"); var tr = document.createElement("TR");
tr.id = inputName + "_"+id; tr.id = inputName + "_"+id;
tr.className = "s_"; tr.className = "s_";
var td = tr.appendChild(document.createElement("TD")); var td = tr.appendChild(document.createElement("TD"));
td.appendChild(document.createTextNode(new_term)); td.appendChild(document.createTextNode(new_term));
td = tr.appendChild(document.createElement("TD")); td = tr.appendChild(document.createElement("TD"));
td.innerHTML = "<img id='"+inputName+"f_"+id+"' src='./images/noflag.gif' />"; td.innerHTML = "<img id='"+inputName+"f_"+id+"' src='./images/noflag.gif' />";
td = tr.appendChild(document.createElement("TD")); td = tr.appendChild(document.createElement("TD"));
td.appendChild(document.createTextNode(" ")); td.appendChild(document.createTextNode(" "));
var zTable = document.getElementById("L"+inputName); var zTable = document.getElementById("L"+inputName);
return(zTable.appendChild(tr)); return(zTable.appendChild(tr));
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,31 @@
function loadXMLDoc(url, post_parms, asxml) function loadXMLDoc(url, post_parms, asxml)
{ {
if(typeof(asxml)=="undefined") if(typeof(asxml)=="undefined")
asxml = false; asxml = false;
out = null; out = null;
xmlhttp = null; xmlhttp = null;
// code for Mozilla, etc. // code for Mozilla, etc.
if (window.XMLHttpRequest) if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest(); xmlhttp=new XMLHttpRequest();
else if (window.ActiveXObject) else if (window.ActiveXObject)
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
if (xmlhttp) if (xmlhttp)
{ {
// xmlhttp.onreadystatechange=state_Change // xmlhttp.onreadystatechange=state_Change
if(post_parms) if(post_parms)
{ {
xmlhttp.open("POST", url, false); xmlhttp.open("POST", url, false);
xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
xmlhttp.send(post_parms); xmlhttp.send(post_parms);
} }
else else
{ {
xmlhttp.open("GET", url, false); xmlhttp.open("GET", url, false);
xmlhttp.send(null); xmlhttp.send(null);
} }
out = asxml ? xmlhttp.responseXML : xmlhttp.responseText; out = asxml ? xmlhttp.responseXML : xmlhttp.responseText;
} }
return(out); return(out);
} }