Fix JS codestyle

This commit is contained in:
Romain Neutron
2013-11-12 12:49:23 +01:00
parent 51fb364d13
commit 9fa95db23c
78 changed files with 5184 additions and 6309 deletions

View File

@@ -2,16 +2,19 @@ var p4 = p4 || {};
$(document).ready(function () { $(document).ready(function () {
$('input.input-button').hover( $('input.input-button').hover(
function(){$(this).addClass('hover');}, function () {
function(){$(this).removeClass('hover');} $(this).addClass('hover');
},
function () {
$(this).removeClass('hover');
}
); );
var locale = $.cookie('locale'); var locale = $.cookie('locale');
var jq_date = p4.lng = typeof locale !== "undefined" ? locale.split('_').reverse().pop() : 'en'; var jq_date = p4.lng = typeof locale !== "undefined" ? locale.split('_').reverse().pop() : 'en';
if(jq_date == 'en') if (jq_date == 'en') {
{
jq_date = 'en-GB'; jq_date = 'en-GB';
} }
@@ -24,7 +27,11 @@ $(document).ready(function(){
}); });
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',
@@ -35,14 +42,12 @@ $(document).ready(function(){
$('#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();
@@ -61,15 +66,17 @@ $(document).ready(function(){
event.stopPropagation(); event.stopPropagation();
}); });
$('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');}); $('#notification_box div.notification').live('mouseover', function () {
$('#notification_box div.notification').live('mouseout',function(){$(this).removeClass('hover');}); $(this).addClass('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();
@@ -82,11 +89,9 @@ $(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');
@@ -95,8 +100,7 @@ function login(what)
} }
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;
@@ -111,8 +115,7 @@ function EcrireCookie(nom, valeur)
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;
@@ -125,8 +128,7 @@ function fix_notification_height()
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;
@@ -139,8 +141,7 @@ $(window).bind('resize', function(){
}); });
function print_notifications(page) function print_notifications(page) {
{
page = parseInt(page); page = parseInt(page);
var buttons = {}; var buttons = {};
@@ -166,8 +167,7 @@ function print_notifications(page)
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)
@@ -196,18 +196,15 @@ function print_notifications(page)
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;">' +
@@ -223,8 +220,7 @@ function print_notifications(page)
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>');
} }
@@ -243,8 +239,7 @@ function print_notifications(page)
} }
function read_notifications() function read_notifications() {
{
var notifications = []; var notifications = [];
$('#notification_box .unread').each(function () { $('#notification_box .unread').each(function () {
@@ -263,8 +258,7 @@ function read_notifications()
}); });
} }
function clear_notifications() function clear_notifications() {
{
var unread = $('#notification_box .unread'); var unread = $('#notification_box .unread');
if (unread.length === 0) if (unread.length === 0)
@@ -275,13 +269,7 @@ function clear_notifications()
} }
function getMyRss(renew) {
function getMyRss(renew)
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -294,10 +282,8 @@ function getMyRss(renew)
} }
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;
} }
@@ -317,12 +303,10 @@ function setPref(name,value)
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;
@@ -332,8 +316,7 @@ function setPref(name,value)
} }
function infoDialog(el) function infoDialog(el) {
{
$("#DIALOG").attr('title', '') $("#DIALOG").attr('title', '')
.empty() .empty()
@@ -353,26 +336,22 @@ function infoDialog(el)
} }
}).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()
@@ -383,36 +362,31 @@ function manageSession(data, showMessages)
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]); var sstt = $('#SSTT_' + data.changed[i]);
if(sstt.size() === 0) if (sstt.size() === 0) {
{ if (main_open === false) {
if(main_open === false) $('#baskets .bloc').animate({'top': 30}, function () {
{ $('#baskets .alert_datas_changed:first').show()
$('#baskets .bloc').animate({'top':30}, function(){$('#baskets .alert_datas_changed:first').show()}); });
main_open = true; main_open = true;
} }
} }
else else {
{
if (!sstt.hasClass('active')) if (!sstt.hasClass('active'))
sstt.addClass('unread'); sstt.addClass('unread');
else else {
{
$('.alert_datas_changed', $('#SSTT_content_' + data.changed[i])).show(); $('.alert_datas_changed', $('#SSTT_content_' + data.changed[i])).show();
} }
} }
} }
} }
if('' !== $.trim(data.message)) if ('' !== $.trim(data.message)) {
{
if ($('#MESSAGE').length === 0) if ($('#MESSAGE').length === 0)
$('body').append('<div id="#MESSAGE"></div>'); $('body').append('<div id="#MESSAGE"></div>');
$('#MESSAGE') $('#MESSAGE')
@@ -425,8 +399,7 @@ function manageSession(data, showMessages)
resizable: false, resizable: false,
draggable: false, draggable: false,
modal: true, modal: true,
close:function() close: function () {
{
if ($('.dialog_remove:checked', $(this)).length > 0) if ($('.dialog_remove:checked', $(this)).length > 0)
setTemporaryPref('message', 0); setTemporaryPref('message', 0);
} }
@@ -438,9 +411,7 @@ function manageSession(data, showMessages)
} }
function disconnected() {
function disconnected()
{
showModal('disconnected', {title: 'Disconnection'}); showModal('disconnected', {title: 'Disconnection'});
} }
@@ -449,14 +420,14 @@ 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':
@@ -468,7 +439,9 @@ function showModal(cas, options){
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;
@@ -484,8 +457,7 @@ 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>');
@@ -506,8 +478,11 @@ function showOverlay(n,appendto,callback, zIndex){
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'

View File

@@ -10,8 +10,7 @@
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);
} }
@@ -23,8 +22,7 @@
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\
@@ -59,12 +57,10 @@
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 else {
{
if ($theatre_img.hasClass('zoomed')) if ($theatre_img.hasClass('zoomed'))
return; return;
} }
@@ -84,13 +80,11 @@
} }
if(settings.zoomable) if (settings.zoomable) {
{
if (typeof $image.draggable !== 'function' && window.console) if (typeof $image.draggable !== 'function' && window.console)
console.error('zoomable require jquery UI\'s draggable'); console.error('zoomable require jquery UI\'s draggable');
if($image.attr('ondragstart')) if ($image.attr('ondragstart')) {
{
$image.removeAttr('ondragstart'); $image.removeAttr('ondragstart');
} }
$image.draggable(); $image.draggable();
@@ -105,13 +99,11 @@
$this.bind('mousewheel',function (event, delta) { $this.bind('mousewheel',function (event, delta) {
$image.addClass('zoomed'); $image.addClass('zoomed');
if(delta > 0) if (delta > 0) {
{
event.stopPropagation(); event.stopPropagation();
zoomPreview(true, ratio, $image, $(this)); zoomPreview(true, ratio, $image, $(this));
} }
else else {
{
event.stopPropagation(); event.stopPropagation();
zoomPreview(false, ratio, $image, $(this)); zoomPreview(false, ratio, $image, $(this));
} }
@@ -137,8 +129,7 @@
} }
}; };
function zoomPreview(bool, ratio, $img, $container) function zoomPreview(bool, ratio, $img, $container) {
{
if ($img.length === 0) if ($img.length === 0)
return; return;
@@ -149,16 +140,14 @@
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 {
@@ -186,8 +175,7 @@
}).width(w2).height(h2); }).width(w2).height(h2);
} }
function calculate_sizes(window_width, window_height,image_width, image_height, border) function calculate_sizes(window_width, window_height, image_width, image_height, border) {
{
if (typeof border !== 'number') if (typeof border !== 'number')
border = 0; border = 0;
@@ -195,13 +183,11 @@
var ratio_display = window_width / window_height; var ratio_display = window_width / window_height;
var ratio_image = image_width / image_height; var ratio_image = image_width / image_height;
if(ratio_image > ratio_display) if (ratio_image > ratio_display) {
{
width = window_width - border; width = window_width - border;
height = Math.round(width / ratio_image); height = Math.round(width / ratio_image);
} }
else else {
{
height = window_height - border; height = window_height - border;
width = Math.round(height * ratio_image); width = Math.round(height * ratio_image);
} }
@@ -217,8 +203,7 @@
}; };
} }
function reset_position($this) function reset_position($this) {
{
var display_width = $this.width(); var display_width = $this.width();
var display_height = $this.height(); var display_height = $this.height();
var image_width = parseInt($('input[name="width"]', $this).val()); var image_width = parseInt($('input[name="width"]', $this).val());

View File

@@ -1,7 +1,4 @@
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)
@@ -18,8 +15,7 @@ function is_ctrl_key(event)
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,6 +1,5 @@
(function ($) { (function ($) {
$.fn.nicoslider = function(options) $.fn.nicoslider = function (options) {
{
var defaults = { var defaults = {
start: 0, start: 0,
color: '#F6F2F1', color: '#F6F2F1',
@@ -15,8 +14,7 @@
}; };
var nicoslide = function(slider, o) var nicoslide = function (slider, o) {
{
var $slider = $(slider); var $slider = $(slider);
$sliderWidth = $slider.parent().innerWidth(); $sliderWidth = $slider.parent().innerWidth();
@@ -43,15 +41,13 @@
//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();
@@ -113,8 +109,7 @@
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({
@@ -129,8 +124,7 @@
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;
} }

View File

@@ -1,12 +1,15 @@
$(document).ready(function () { $(document).ready(function () {
$('#tabs').tabs(); $('#tabs').tabs();
$('input.input-button').hover( $('input.input-button').hover(
function(){parent.$(this).addClass('hover');}, function () {
function(){parent.$(this).removeClass('hover');} parent.$(this).addClass('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;

View File

@@ -7,8 +7,7 @@ $(document).ready(function(){
}); });
function getNewVideoToken(lst, obj) function getNewVideoToken(lst, obj) {
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "../prod/records/renew-url/", url: "../prod/records/renew-url/",
@@ -47,8 +46,7 @@ function openPreview(env, pos, contId, reload){
'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
@@ -111,8 +109,7 @@ function openPreview(env, pos, contId, reload){
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)
@@ -129,13 +126,11 @@ function openPreview(env, pos, contId, reload){
$('#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)');
} }
}; };
@@ -148,35 +143,29 @@ function openPreview(env, pos, contId, reload){
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);
@@ -214,15 +203,13 @@ function zoomPreview(bool){
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
@@ -248,8 +235,7 @@ function zoomPreview(bool){
}).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",
@@ -270,8 +256,7 @@ function getAnswerTrain(pos, tools, query,options_serial)
} }
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/",
@@ -316,8 +301,7 @@ function startSlide(){
$('#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();
@@ -348,8 +332,7 @@ function getNext(){
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
@@ -363,14 +346,12 @@ function reloadPreview(){
} }
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
@@ -390,12 +371,10 @@ function setOthers(others){
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();
} }
@@ -421,8 +400,7 @@ function setCurrent(current){
} }
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');
@@ -452,8 +430,7 @@ function setPreview(){
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;
} }

View File

@@ -49,8 +49,7 @@
$.tooltip.blocked = !$.tooltip.blocked; $.tooltip.blocked = !$.tooltip.blocked;
}, },
delayAjax : function(a,b,c) delayAjax: function (a, b, c) {
{
var options_serial = p4.tot_options; var options_serial = p4.tot_options;
var query = p4.tot_query; var query = p4.tot_query;
var datas = { var datas = {
@@ -201,14 +200,12 @@
// add an optional class for this tip // add an optional class for this tip
// helper.parent.addClass(settings(this).extraClass); // helper.parent.addClass(settings(this).extraClass);
if(this.ajaxLoad) if (this.ajaxLoad) {
{
clearTimeout($.tooltip.ajaxTimeout); clearTimeout($.tooltip.ajaxTimeout);
$.tooltip.ajaxTimeout = setTimeout("$.tooltip.delayAjax()", 300); $.tooltip.ajaxTimeout = setTimeout("$.tooltip.delayAjax()", 300);
$.tooltip.ajaxEvent = event; $.tooltip.ajaxEvent = event;
} }
else else {
{
title = '<div class="popover" style="display:block;position:relative;">' + title = '<div class="popover" style="display:block;position:relative;">' +
'<div class="arrow"></div>' + '<div class="arrow"></div>' +
'<div class="popover-inner" style="width:auto;">' + '<div class="popover-inner" style="width:auto;">' +
@@ -224,16 +221,14 @@
} }
function positioning(event) function positioning(event) {
{
helper.body.html(title); helper.body.html(title);
helper.body.show(); helper.body.show();
$this = $.tooltip.current; $this = $.tooltip.current;
// fix PNG background for IE // fix PNG background for IE
if (settings($this).fixPNG) if (settings($this).fixPNG)
helper.parent.fixPNG(); helper.parent.fixPNG();
if(settings($this).outside) if (settings($this).outside) {
{
var width = 'auto'; var width = 'auto';
var height = 'auto'; var height = 'auto';
var ratio = 1; var ratio = 1;
@@ -275,8 +270,7 @@
// $('#' + settings($.tooltip.current).id + ' .thumb_wrapper').width('auto').height('auto'); // $('#' + settings($.tooltip.current).id + ' .thumb_wrapper').width('auto').height('auto');
if($('#' + settings($.tooltip.current).id + ' .audioTips').length > 0) if ($('#' + settings($.tooltip.current).id + ' .audioTips').length > 0) {
{
height = height < 26 ? 26 : height; height = height < 26 ? 26 : height;
} }
@@ -325,36 +319,30 @@
//correction par ratio //correction par ratio
if (resizeImgTips && $('#' + settings($.tooltip.current).id + ' .imgTips')[0]) { if (resizeImgTips && $('#' + settings($.tooltip.current).id + ' .imgTips')[0]) {
if(ratioSurfaceH > ratioImage) if (ratioSurfaceH > ratioImage) {
{
horS = v.y * ratioImage * v.y; horS = v.y * ratioImage * v.y;
} }
else else {
{
horS = wiH * wiH / ratioImage; horS = wiH * wiH / ratioImage;
} }
if(ratioSurfaceV > ratioImage) if (ratioSurfaceV > ratioImage) {
{
vertS = heV * ratioImage * heV; vertS = heV * ratioImage * heV;
} }
else else {
{
vertS = v.x * v.x / ratioImage; vertS = v.x * v.x / ratioImage;
} }
} }
var zH; var zH;
if((Math.abs(ratioSurfaceV - ratioImage) < Math.abs(ratioSurfaceH - ratioImage))) if ((Math.abs(ratioSurfaceV - ratioImage) < Math.abs(ratioSurfaceH - ratioImage))) {
{
var zL = event.pageX; var zL = event.pageX;
var zW = $(h).width(); var zW = $(h).width();
zH = $(h).height(); zH = $(h).height();
var ETOT = $(event.target).offset().top; var ETOT = $(event.target).offset().top;
var ETH = $(event.target).height(); var ETH = $(event.target).height();
left = (zL - zW / 2) < 20 ? 20 : (((zL + zW / 2 + 20) > v.x) ? (v.x - zW - 20) : (zL - zW / 2)); left = (zL - zW / 2) < 20 ? 20 : (((zL + zW / 2 + 20) > v.x) ? (v.x - zW - 20) : (zL - zW / 2));
switch(vert) switch (vert) {
{
case 'haut': case 'haut':
height = (zH > (ETOT - 40)) ? (ETOT - 40) : zH; height = (zH > (ETOT - 40)) ? (ETOT - 40) : zH;
top = ETOT - height - 20; top = ETOT - height - 20;
@@ -367,8 +355,7 @@
break; break;
} }
} }
else else {
{
// height = ($(h).height()>(v.y-40))?(v.y-40):$(h).height(); // height = ($(h).height()>(v.y-40))?(v.y-40):$(h).height();
zH = $(h).height(); zH = $(h).height();
var zT = event.pageY; var zT = event.pageY;
@@ -376,8 +363,7 @@
var ETW = $(event.target).width(); var ETW = $(event.target).width();
var zw = $(h).width(); var zw = $(h).width();
top = (zT - zH / 2) < 20 ? 20 : (((zT + zH / 2 + 20) > v.y) ? (v.y - zH - 20) : (zT - zH / 2)); top = (zT - zH / 2) < 20 ? 20 : (((zT + zH / 2 + 20) > v.y) ? (v.y - zH - 20) : (zT - zH / 2));
switch(hor) switch (hor) {
{
case 'gauche': case 'gauche':
width = (zw > (EOTL - 40)) ? (EOTL - 40) : zw; width = (zw > (EOTL - 40)) ? (EOTL - 40) : zw;
left = EOTL - width - 20; left = EOTL - width - 20;
@@ -421,16 +407,13 @@
} }
width = nw; width = nw;
} }
}else } else {
{ if (vertS < horS) {
if(vertS < horS)
{
height = 'auto'; height = 'auto';
} }
} }
if(resizeImgTips) if (resizeImgTips) {
{
var factor = Math.min((width - 45) / width, (height - 75) / height); var factor = Math.min((width - 45) / width, (height - 75) / height);
var imgWidth = Math.round(width * factor); var imgWidth = Math.round(width * factor);
var imgHeight = Math.round(height * factor); var imgHeight = Math.round(height * factor);
@@ -444,8 +427,7 @@
}); });
} }
if(resizeVideoTips) if (resizeVideoTips) {
{
var factor = Math.min((width - 45) / width, (height - 75) / height); var factor = Math.min((width - 45) / width, (height - 75) / height);
var imgWidth = Math.round(width * factor); var imgWidth = Math.round(width * factor);
var imgHeight = Math.round(height * factor); var imgHeight = Math.round(height * factor);
@@ -488,10 +470,8 @@
update(); update();
} }
function fix(event) function fix(event) {
{ if (!settings(this).fixable) {
if(!settings(this).fixable)
{
hide(event); hide(event);
return; return;
} }
@@ -538,8 +518,7 @@
// remove position helper classes // remove position helper classes
helper.parent.removeClass("viewport-right").removeClass("viewport-bottom"); helper.parent.removeClass("viewport-right").removeClass("viewport-bottom");
if(!settings($.tooltip.current).outside) if (!settings($.tooltip.current).outside) {
{
var left = helper.parent[0].offsetLeft; var left = helper.parent[0].offsetLeft;
var top = helper.parent[0].offsetTop; var top = helper.parent[0].offsetTop;
helper.parent.width('auto'); helper.parent.width('auto');
@@ -590,8 +569,7 @@
} }
// hide helper and restore added classes and the title // hide helper and restore added classes and the title
function hide(event) function hide(event) {
{
if ($.tooltip.blocked || !$.tooltip.current) if ($.tooltip.blocked || !$.tooltip.current)
return; return;
// clear timeout if possible // clear timeout if possible
@@ -601,8 +579,7 @@
$.tooltip.visible = false; $.tooltip.visible = false;
var tsettings = settings($.tooltip.current); var tsettings = settings($.tooltip.current);
clearTimeout($.tooltip.ajaxTimeout); clearTimeout($.tooltip.ajaxTimeout);
if($.tooltip.ajaxRequest && $.tooltip.ajaxRequest.abort) if ($.tooltip.ajaxRequest && $.tooltip.ajaxRequest.abort) {
{
$.tooltip.ajaxRequest.abort(); $.tooltip.ajaxRequest.abort();
} }
@@ -611,6 +588,7 @@
function complete() { function complete() {
helper.parent.removeClass(tsettings.extraClass).hide().css("opacity", ""); helper.parent.removeClass(tsettings.extraClass).hide().css("opacity", "");
} }
if ((!IE || !$.fn.bgiframe) && tsettings.fade) { if ((!IE || !$.fn.bgiframe) && tsettings.fade) {
if (helper.parent.is(':animated')) if (helper.parent.is(':animated'))
helper.parent.stop().fadeTo(tsettings.fade, 0, complete); helper.parent.stop().fadeTo(tsettings.fade, 0, complete);
@@ -625,8 +603,7 @@
})(jQuery); })(jQuery);
function unfix_tooltip() function unfix_tooltip() {
{
$.tooltip.blocked = false; $.tooltip.blocked = false;
$.tooltip.visible = false; $.tooltip.visible = false;
$.tooltip.current = null; $.tooltip.current = null;
@@ -637,8 +614,7 @@ function unfix_tooltip()
$(document).bind('keydown', function (event) { $(document).bind('keydown', function (event) {
if(event.keyCode == 27 && $.tooltip.blocked === true) if (event.keyCode == 27 && $.tooltip.blocked === true) {
{
unfix_tooltip(); unfix_tooltip();
} }
}); });

View File

@@ -1,8 +1,6 @@
(function (window) { (function (window) {
function checkVocabId(VocabularyId) function checkVocabId(VocabularyId) {
{
if (typeof VocabularyId === 'undefined') if (typeof VocabularyId === 'undefined')
VocabularyId = null; VocabularyId = null;
@@ -64,8 +62,7 @@
}, },
options = (typeof options == 'object') ? options : {}; options = (typeof options == 'object') ? options : {};
if(isNaN(meta_struct_id)) if (isNaN(meta_struct_id)) {
{
throw 'meta_struct_id should be a number'; throw 'meta_struct_id should be a number';
} }
@@ -74,8 +71,7 @@
this.meta_struct_id = meta_struct_id; this.meta_struct_id = meta_struct_id;
this.options = jQuery.extend(defaults, options); this.options = jQuery.extend(defaults, options);
if(this.options.multi === true && this.options.separator === null) if (this.options.multi === true && this.options.separator === null) {
{
this.options.separator = ';'; this.options.separator = ';';
} }
@@ -122,45 +118,36 @@
}; };
this.datas = new Array(); this.datas = new Array();
if(arrayValues instanceof Array) if (arrayValues instanceof Array) {
{
if (arrayValues.length > 1 && !databoxField.isMulti()) if (arrayValues.length > 1 && !databoxField.isMulti())
throw 'You can not add multiple values to a non multi field ' + databoxField.getName(); throw 'You can not add multiple values to a non multi field ' + databoxField.getName();
var first = true; var first = true;
for(v in arrayValues) for (v in arrayValues) {
{ if (typeof arrayValues[v] !== 'object') {
if(typeof arrayValues[v] !== 'object') if (window.console) {
{
if(window.console)
{
console.error('Trying to add a non-recordFieldValue to the field...'); console.error('Trying to add a non-recordFieldValue to the field...');
} }
continue; continue;
} }
if(isNaN(arrayValues[v].getMetaId())) if (isNaN(arrayValues[v].getMetaId())) {
{ if (window.console) {
if(window.console)
{
console.error('Trying to add a recordFieldValue without metaId...'); console.error('Trying to add a recordFieldValue without metaId...');
} }
continue; continue;
} }
if(!first && this.options.multi === false) if (!first && this.options.multi === false) {
{ if (window.console) {
if(window.console)
{
console.error('Trying to add multi values in a non-multi field'); console.error('Trying to add multi values in a non-multi field');
} }
} }
if(window.console) if (window.console) {
{
console.log('adding a value : ', arrayValues[v]); console.log('adding a value : ', arrayValues[v]);
} }
@@ -193,79 +180,59 @@
merge = !!merge; merge = !!merge;
if(this.databoxField.isReadonly()) if (this.databoxField.isReadonly()) {
{ if (window.console) {
if(window.console)
{
console.error('Unable to set a value to a readonly field'); console.error('Unable to set a value to a readonly field');
} }
return; return;
} }
if(window.console) if (window.console) {
{
console.log('adding value ', value, ' vocId : ', VocabularyId, ' ; merge is ', merge); console.log('adding value ', value, ' vocId : ', VocabularyId, ' ; merge is ', merge);
} }
if(this.isMulti()) if (this.isMulti()) {
{ if (!this.hasValue(value, VocabularyId)) {
if(!this.hasValue(value, VocabularyId)) if (window.console) {
{
if(window.console)
{
console.log('adding new multi value ', value); console.log('adding new multi value ', value);
} }
this.datas.push(new recordFieldValue(null, value, VocabularyId)); this.datas.push(new recordFieldValue(null, value, VocabularyId));
this.options.dirty = true; this.options.dirty = true;
} }
else else {
{ if (window.console) {
if(window.console)
{
console.log('already have ', value); console.log('already have ', value);
} }
} }
} }
else else {
{ if (merge === true && this.isEmpty() === false && VocabularyId === null) {
if(merge === true && this.isEmpty() === false && VocabularyId === null) if (window.console) {
{
if(window.console)
{
console.log('Merging value ', value); console.log('Merging value ', value);
} }
this.datas[0].setValue(this.datas[0].getValue() + ' ' + value, VocabularyId); this.datas[0].setValue(this.datas[0].getValue() + ' ' + value, VocabularyId);
this.options.dirty = true; this.options.dirty = true;
} }
else else {
{ if (merge === true && this.isEmpty() === false && VocabularyId !== null) {
if(merge === true && this.isEmpty() === false && VocabularyId !== null) if (window.console) {
{
if(window.console)
{
console.error('Cannot merge vocabularies'); console.error('Cannot merge vocabularies');
} }
this.datas[0].setValue(value, VocabularyId); this.datas[0].setValue(value, VocabularyId);
} }
else else {
{
if(!this.hasValue(value, VocabularyId)) if (!this.hasValue(value, VocabularyId)) {
{ if (this.datas.length === 0) {
if(this.datas.length === 0) if (window.console) {
{
if(window.console)
{
console.log('Adding new value ', value); console.log('Adding new value ', value);
} }
this.datas.push(new recordFieldValue(null, value, VocabularyId)); this.datas.push(new recordFieldValue(null, value, VocabularyId));
} }
else else {
{ if (window.console) {
if(window.console)
{
console.log('Updating value ', value); console.log('Updating value ', value);
} }
this.datas[0].setValue(value, VocabularyId); this.datas[0].setValue(value, VocabularyId);
@@ -280,33 +247,25 @@
}, },
hasValue: function (value, VocabularyId) { hasValue: function (value, VocabularyId) {
if(typeof value === 'undefined') if (typeof value === 'undefined') {
{ if (window.console) {
if(window.console)
{
console.error('Trying to check the presence of an undefined value'); console.error('Trying to check the presence of an undefined value');
} }
} }
VocabularyId = checkVocabId(VocabularyId); VocabularyId = checkVocabId(VocabularyId);
for(d in this.datas) for (d in this.datas) {
{ if (VocabularyId !== null) {
if(VocabularyId !== null) if (this.datas[d].getVocabularyId() === VocabularyId) {
{ if (window.console) {
if(this.datas[d].getVocabularyId() === VocabularyId)
{
if(window.console)
{
console.log('already got the vocab ID'); console.log('already got the vocab ID');
} }
return true; return true;
} }
} }
else if(this.datas[d].getVocabularyId() === null && this.datas[d].getValue() == value) else if (this.datas[d].getVocabularyId() === null && this.datas[d].getValue() == value) {
{ if (window.console) {
if(window.console)
{
console.log('already got this value'); console.log('already got this value');
} }
return true; return true;
@@ -316,10 +275,8 @@
}, },
removeValue: function (value, vocabularyId) { removeValue: function (value, vocabularyId) {
if(this.databoxField.isReadonly()) if (this.databoxField.isReadonly()) {
{ if (window.console) {
if(window.console)
{
console.error('Unable to set a value to a readonly field'); console.error('Unable to set a value to a readonly field');
} }
@@ -328,33 +285,25 @@
vocabularyId = checkVocabId(vocabularyId); vocabularyId = checkVocabId(vocabularyId);
if(window.console) if (window.console) {
{
console.log('Try to remove value ', value, vocabularyId, this.datas); console.log('Try to remove value ', value, vocabularyId, this.datas);
} }
for(d in this.datas) for (d in this.datas) {
{ if (window.console) {
if(window.console)
{
console.log('loopin... ', this.datas[d].getValue()); console.log('loopin... ', this.datas[d].getValue());
} }
if(this.datas[d].getVocabularyId() !== null) if (this.datas[d].getVocabularyId() !== null) {
{ if (this.datas[d].getVocabularyId() == vocabularyId) {
if(this.datas[d].getVocabularyId() == vocabularyId) if (window.console) {
{
if(window.console)
{
console.log('Found within the vocab ! removing... '); console.log('Found within the vocab ! removing... ');
} }
this.datas[d].remove(); this.datas[d].remove();
this.options.dirty = true; this.options.dirty = true;
} }
} }
else if(this.datas[d].getValue() == value) else if (this.datas[d].getValue() == value) {
{ if (window.console) {
if(window.console)
{
console.log('Found ! removing... '); console.log('Found ! removing... ');
} }
this.datas[d].remove(); this.datas[d].remove();
@@ -366,8 +315,7 @@
isEmpty: function () { isEmpty: function () {
var empty = true; var empty = true;
for(d in this.datas) for (d in this.datas) {
{
if (this.datas[d].getValue() !== '') if (this.datas[d].getValue() !== '')
empty = false; empty = false;
} }
@@ -375,18 +323,15 @@
}, },
empty: function () { empty: function () {
if(this.databoxField.isReadonly()) if (this.databoxField.isReadonly()) {
{ if (window.console) {
if(window.console)
{
console.error('Unable to set a value to a readonly field'); console.error('Unable to set a value to a readonly field');
} }
return; return;
} }
for(d in this.datas) for (d in this.datas) {
{
this.datas[d].remove(); this.datas[d].remove();
this.options.dirty = true; this.options.dirty = true;
} }
@@ -404,8 +349,7 @@
}, },
getValues: function () { getValues: function () {
if(!this.isMulti()) if (!this.isMulti()) {
{
throw 'This field is not multi, I can not give you multiple values'; throw 'This field is not multi, I can not give you multiple values';
} }
@@ -414,8 +358,7 @@
var arrayValues = []; var arrayValues = [];
for(d in this.datas) for (d in this.datas) {
{
if (this.datas[d].getValue() === '') if (this.datas[d].getValue() === '')
continue; continue;
@@ -434,8 +377,7 @@
var arrayValues = []; var arrayValues = [];
var values = this.getValues(); var values = this.getValues();
for(v in values) for (v in values) {
{
arrayValues.push(values[v].getValue()); arrayValues.push(values[v].getValue());
} }
@@ -443,10 +385,8 @@
}, },
replaceValue: function (search, replace) { replaceValue: function (search, replace) {
if(this.databoxField.isReadonly()) if (this.databoxField.isReadonly()) {
{ if (window.console) {
if(window.console)
{
console.error('Unable to set a value to a readonly field'); console.error('Unable to set a value to a readonly field');
} }
@@ -455,18 +395,15 @@
var n = 0; var n = 0;
for(d in this.datas) for (d in this.datas) {
{ if (this.datas[d].getVocabularyId() !== null) {
if(this.datas[d].getVocabularyId() !== null)
{
continue; continue;
} }
var value = this.datas[d].getValue(); var value = this.datas[d].getValue();
var replacedValue = value.replace(search, replace); var replacedValue = value.replace(search, replace);
if(value === replacedValue) if (value === replacedValue) {
{
continue; continue;
} }
@@ -474,8 +411,7 @@
this.removeValue(value); this.removeValue(value);
if(!this.hasValue(replacedValue)) if (!this.hasValue(replacedValue)) {
{
this.addValue(replacedValue); this.addValue(replacedValue);
} }
@@ -488,16 +424,14 @@
var returnValue = new Array(); var returnValue = new Array();
for(d in this.datas) for (d in this.datas) {
{
var temp = { var temp = {
meta_id: this.datas[d].getMetaId() ? this.datas[d].getMetaId() : '', meta_id: this.datas[d].getMetaId() ? this.datas[d].getMetaId() : '',
meta_struct_id: this.getMetaStructId(), meta_struct_id: this.getMetaStructId(),
value: this.datas[d].getValue() value: this.datas[d].getValue()
}; };
if(this.datas[d].getVocabularyId()) if (this.datas[d].getVocabularyId()) {
{
temp.vocabularyId = this.datas[d].getVocabularyId(); temp.vocabularyId = this.datas[d].getVocabularyId();
} }
returnValue.push(temp); returnValue.push(temp);

View File

@@ -20,11 +20,9 @@
var $this = this; var $this = this;
if($container.data('selectionnable')) if ($container.data('selectionnable')) {
{
/* this container is already selectionnable */ /* this container is already selectionnable */
if(window.console) if (window.console) {
{
console.error('Trying to apply new selection to existing one'); console.error('Trying to apply new selection to existing one');
} }
@@ -41,8 +39,7 @@
jQuery(this.options.selector, this.$container) jQuery(this.options.selector, this.$container)
.live('click', function (event) { .live('click', function (event) {
if(typeof $this.options.selectStart === 'function') if (typeof $this.options.selectStart === 'function') {
{
$this.options.selectStart(jQuery.extend(jQuery.Event('selectStart'), event), $this); $this.options.selectStart(jQuery.extend(jQuery.Event('selectStart'), event), $this);
} }
@@ -50,15 +47,13 @@
var k = get_value($that, $this); var k = get_value($that, $this);
if(is_shift_key(event) && jQuery('.last_selected', this.$container).filter($this.options.selector).length != 0) 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 lst = jQuery($this.options.selector, this.$container);
var index1 = jQuery.inArray(jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst); var index1 = jQuery.inArray(jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst);
var index2 = jQuery.inArray($that[0], lst); var index2 = jQuery.inArray($that[0], lst);
if(index2<index1) if (index2 < index1) {
{
var tmp = index1; var tmp = index1;
index1 = (index2 - 1) < 0 ? index2 : (index2 - 1); index1 = (index2 - 1) < 0 ? index2 : (index2 - 1);
index2 = tmp; index2 = tmp;
@@ -66,21 +61,17 @@
var stopped = false; var stopped = false;
if(index2 != -1 && index1 != -1) if (index2 != -1 && index1 != -1) {
{
var exp = $this.options.selector + ':gt(' + index1 + '):lt(' + (index2 - index1) + ')'; var exp = $this.options.selector + ':gt(' + index1 + '):lt(' + (index2 - index1) + ')';
$.each(jQuery(exp, this.$container), function (i, n) { $.each(jQuery(exp, this.$container), function (i, n) {
if(!jQuery(n).hasClass('selected') && stopped === false) if (!jQuery(n).hasClass('selected') && stopped === false) {
{ if (!$this.hasReachLimit()) {
if(!$this.hasReachLimit())
{
var k = get_value(jQuery(n), $this); var k = get_value(jQuery(n), $this);
$this.push(k); $this.push(k);
jQuery(n).addClass('selected'); jQuery(n).addClass('selected');
} }
else else {
{
alert(language.max_record_selected); alert(language.max_record_selected);
stopped = true; stopped = true;
} }
@@ -88,43 +79,33 @@
}); });
} }
if($this.has(k) === false && stopped === false) if ($this.has(k) === false && stopped === false) {
{ if (!$this.hasReachLimit()) {
if(!$this.hasReachLimit())
{
$this.push(k); $this.push(k);
$that.addClass('selected'); $that.addClass('selected');
} }
else else {
{
alert(language.max_record_selected); alert(language.max_record_selected);
} }
} }
} }
else else {
{ if (!is_ctrl_key(event)) {
if(!is_ctrl_key(event))
{
$this.empty().push(k); $this.empty().push(k);
jQuery('.selected', this.$container).filter($this.options.selector).removeClass('selected'); jQuery('.selected', this.$container).filter($this.options.selector).removeClass('selected');
$that.addClass('selected'); $that.addClass('selected');
} }
else else {
{ if ($this.has(k) === true) {
if($this.has(k) === true)
{
$this.remove(k); $this.remove(k);
$that.removeClass('selected'); $that.removeClass('selected');
} }
else else {
{ if (!$this.hasReachLimit()) {
if(!$this.hasReachLimit())
{
$this.push(k); $this.push(k);
$that.addClass('selected'); $that.addClass('selected');
} }
else else {
{
alert(language.max_record_selected); alert(language.max_record_selected);
} }
} }
@@ -135,8 +116,7 @@
$that.addClass('last_selected'); $that.addClass('last_selected');
if(typeof $this.options.selectStop === 'function') if (typeof $this.options.selectStop === 'function') {
{
$this.options.selectStop(jQuery.extend(jQuery.Event('selectStop'), event), $this); $this.options.selectStop(jQuery.extend(jQuery.Event('selectStop'), event), $this);
} }
@@ -147,20 +127,16 @@
return; return;
}; };
function get_value(element, Selectable) function get_value(element, Selectable) {
{ if (typeof Selectable.options.callbackSelection === 'function') {
if(typeof Selectable.options.callbackSelection === 'function')
{
return Selectable.options.callbackSelection(jQuery(element)); return Selectable.options.callbackSelection(jQuery(element));
} }
else else {
{
return jQuery('input[name="id"]', jQuery(element)).val(); return jQuery('input[name="id"]', jQuery(element)).val();
} }
} }
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)
@@ -177,27 +153,23 @@
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;
} }
Selectable.prototype = { Selectable.prototype = {
push: function (element) { push: function (element) {
if(this.options.allow_multiple === true || !this.has(element)) if (this.options.allow_multiple === true || !this.has(element)) {
{
this.datas.push(element); this.datas.push(element);
} }
return this; return this;
}, },
hasReachLimit: function () { hasReachLimit: function () {
if(this.options.limit !== null && this.options.limit <= this.datas.length) if (this.options.limit !== null && this.options.limit <= this.datas.length) {
{
return true; return true;
} }
return false; return false;
@@ -223,8 +195,7 @@
jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected'); jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected');
if(typeof $this.options.selectStop === 'function') if (typeof $this.options.selectStop === 'function') {
{
$this.options.selectStop(jQuery.Event('selectStop'), $this); $this.options.selectStop(jQuery.Event('selectStop'), $this);
} }
@@ -254,15 +225,12 @@
stopped = false; stopped = false;
jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function () { jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function () {
if(!$this.hasReachLimit()) if (!$this.hasReachLimit()) {
{
$this.push(get_value(this, $this)); $this.push(get_value(this, $this));
$(this).addClass('selected'); $(this).addClass('selected');
} }
else else {
{ if (stopped === false) {
if(stopped === false)
{
alert(language.max_record_selected); alert(language.max_record_selected);
} }
stopped = true; stopped = true;
@@ -270,8 +238,7 @@
}); });
if(typeof $this.options.selectStop === 'function') if (typeof $this.options.selectStop === 'function') {
{
$this.options.selectStop(jQuery.Event('selectStop'), $this); $this.options.selectStop(jQuery.Event('selectStop'), $this);
} }

View File

@@ -8,8 +8,7 @@ var p4 = p4 || {};
var List = function (id) { var List = function (id) {
if(parseInt(id) <= 0) if (parseInt(id) <= 0) {
{
throw 'Invalid list id'; throw 'Invalid list id';
} }
@@ -27,18 +26,15 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {name: name}, data: {name: name},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
var list = new List(data.list_id); var list = new List(data.list_id);
callback(list); callback(list);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -56,26 +52,20 @@ var p4 = p4 || {};
dataType: type, dataType: type,
data: {}, data: {},
success: function (data) { success: function (data) {
if(type == 'json') if (type == 'json') {
{ if (data.success) {
if(data.success)
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback(data.result); callback(data.result);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
else else {
{ if (typeof callback === 'function') {
if(typeof callback === 'function')
{
callback(data); callback(data);
} }
} }
@@ -88,8 +78,7 @@ var p4 = p4 || {};
List.prototype = { List.prototype = {
addUsers: function (arrayUsers, callback) { addUsers: function (arrayUsers, callback) {
if(!arrayUsers instanceof Array) if (!arrayUsers instanceof Array) {
{
throw 'addUsers takes array as argument'; throw 'addUsers takes array as argument';
} }
@@ -102,17 +91,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: data, data: data,
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this, data); callback($this, data);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -131,17 +117,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {}, data: {},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this); callback($this);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -157,17 +140,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: { name: name }, data: { name: name },
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this); callback($this);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -183,17 +163,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {}, data: {},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this, data); callback($this, data);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -209,17 +186,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {role: role}, data: {role: role},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this); callback($this);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -235,17 +209,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {}, data: {},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this); callback($this);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -261,17 +232,14 @@ var p4 = p4 || {};
dataType: 'json', dataType: 'json',
data: {}, data: {},
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback($this, data); callback($this, data);
} }
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }

View File

@@ -9,8 +9,7 @@
var $this = $(this), data = $(this).data('path_file_tests'); var $this = $(this), data = $(this).data('path_file_tests');
if ( ! data ) if (!data) {
{
if (options) { if (options) {
$.extend(settings, options); $.extend(settings, options);
} }
@@ -32,8 +31,7 @@
return; return;
if(!$this.hasClass('required') && $.trim($this.val()) === '') if (!$this.hasClass('required') && $.trim($this.val()) === '') {
{
el_status.css('visibility', 'hidden'); el_status.css('visibility', 'hidden');
return; return;
} }
@@ -50,22 +48,18 @@
}, },
success: function (data) { success: function (data) {
el_loader.css('visibility', 'hidden'); el_loader.css('visibility', 'hidden');
if($this.hasClass('required')) if ($this.hasClass('required')) {
{
$this.addClass('field_error'); $this.addClass('field_error');
} }
if($this.hasClass('test_executable') && (data.executable === false || data.file !== true)) if ($this.hasClass('test_executable') && (data.executable === false || data.file !== true)) {
{
el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible');
return; return;
} }
if($this.hasClass('test_writeable') && data.writeable === false) if ($this.hasClass('test_writeable') && data.writeable === false) {
{
el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible');
return; return;
} }
if($this.hasClass('test_readable') && data.readable === false) if ($this.hasClass('test_readable') && data.readable === false) {
{
el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible');
return; return;
} }
@@ -113,8 +107,6 @@
})(jQuery); })(jQuery);
(function ($) { (function ($) {
var methods = { var methods = {
@@ -126,8 +118,7 @@
var $this = $(this), data = $(this).data('url_tests'); var $this = $(this), data = $(this).data('url_tests');
if ( ! data ) if (!data) {
{
if (options) { if (options) {
$.extend(settings, options); $.extend(settings, options);
} }
@@ -147,22 +138,18 @@
var value = $.trim($this.val()); var value = $.trim($this.val());
if(!required && value === '') if (!required && value === '') {
{
el_status.attr('src', '/skins/icons/ok.png'); el_status.attr('src', '/skins/icons/ok.png');
return; return;
} }
if(required && value === '') if (required && value === '') {
{
el_status.attr('src', '/skins/icons/delete.png'); el_status.attr('src', '/skins/icons/delete.png');
return; return;
} }
if(same_domain && value.substring(0,1) != '/') if (same_domain && value.substring(0, 1) != '/') {
{
value = '/' + value; value = '/' + value;
} }
if(same_domain) if (same_domain) {
{
value = location.protocol + '//' + location.hostname + value; value = location.protocol + '//' + location.hostname + value;
} }
@@ -181,17 +168,14 @@
}, },
success: function (datas) { success: function (datas) {
el_loader.css('visibility', 'hidden'); el_loader.css('visibility', 'hidden');
if(datas.code === 404) if (datas.code === 404) {
{
el_status.attr('src', '/skins/icons/delete.png'); el_status.attr('src', '/skins/icons/delete.png');
return; return;
} }
if(!listable && datas.code === 403) if (!listable && datas.code === 403) {
{
el_status.attr('src', '/skins/icons/ok.png'); el_status.attr('src', '/skins/icons/ok.png');
} }
else else {
{
el_status.attr('src', '/skins/icons/delete.png'); el_status.attr('src', '/skins/icons/delete.png');
} }
return; return;

View File

@@ -19,9 +19,7 @@ define([
"apps/admin/fields/views/save", "apps/admin/fields/views/save",
"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, DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) {
$, _, Backbone, i18n, FieldsCollection, VocabulariesCollection,
DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) {
var initialize = function () { var initialize = function () {
AdminFieldApp = { AdminFieldApp = {
$window: $(window), $window: $(window),

View File

@@ -39,7 +39,9 @@ define([
this.$el.addClass("alert-" + this.alert).html(template).alert(); this.$el.addClass("alert-" + this.alert).html(template).alert();
if (this.delay > 0) { if (this.delay > 0) {
window.setTimeout(function() { self.$el.alert('close') }, this.delay); window.setTimeout(function () {
self.$el.alert('close')
}, this.delay);
} }
$(".block-alert").empty().append(this.$el); $(".block-alert").empty().append(this.$el);

View File

@@ -21,15 +21,18 @@ require([
}, function () { }, function () {
new LoginForm({ new LoginForm({
el: $("form[name=loginForm]"), el: $("form[name=loginForm]"),
rules: [{ rules: [
{
name: "login", name: "login",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password", name: "password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
}] }
]
}); });
}); });
}); });

View File

@@ -21,15 +21,18 @@ require([
}, function () { }, function () {
new ForgotPassWordForm({ new ForgotPassWordForm({
el: $("form[name=forgottenPasswordForm]"), el: $("form[name=forgottenPasswordForm]"),
rules: [{ rules: [
{
name: "email", name: "email",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "email", name: "email",
rules: "valid_email", rules: "valid_email",
message: i18n.t("validation_email") message: i18n.t("validation_email")
}] }
]
}); });
}); });
}); });

View File

@@ -21,15 +21,18 @@ require([
}, function () { }, function () {
new LoginForm({ new LoginForm({
el: $("form[name=loginForm]"), el: $("form[name=loginForm]"),
rules: [{ rules: [
{
name: "login", name: "login",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password", name: "password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
}] }
]
}); });
}); });
}); });

View File

@@ -21,15 +21,18 @@ require([
}, function () { }, function () {
new LoginForm({ new LoginForm({
el: $("form[name=loginForm]"), el: $("form[name=loginForm]"),
rules: [{ rules: [
{
name: "login", name: "login",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password", name: "password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
}] }
]
}); });
}); });
}); });

View File

@@ -21,15 +21,18 @@ require([
}, function () { }, function () {
new LoginForm({ new LoginForm({
el: $("form[name=loginForm]"), el: $("form[name=loginForm]"),
rules: [{ rules: [
{
name: "login", name: "login",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password", name: "password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
}] }
]
}); });
}); });
}); });

View File

@@ -21,22 +21,26 @@ require([
new RenewPassword({ new RenewPassword({
el: $("form[name=passwordRenewForm]"), el: $("form[name=passwordRenewForm]"),
rules: [{ rules: [
{
name: "password[password]", name: "password[password]",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password[password]", name: "password[password]",
rules: "min_length[5]", rules: "min_length[5]",
message: i18n.t("validation_length_min", { message: i18n.t("validation_length_min", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: ["5"] sprintf: ["5"]
}) })
},{ },
{
name: "password[confirm]", name: "password[confirm]",
rules: "matches[password[password]]", rules: "matches[password[password]]",
message: i18n.t("password_match") message: i18n.t("password_match")
}] }
]
}); });
}); });
}); });

View File

@@ -31,35 +31,42 @@ require([
}, function () { }, function () {
Common.initialize(); Common.initialize();
var rules = [{ var rules = [
{
name: "email", name: "email",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "email", name: "email",
rules: "valid_email", rules: "valid_email",
message: i18n.t("validation_email") message: i18n.t("validation_email")
},{ },
{
name: "password[password]", name: "password[password]",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password[password]", name: "password[password]",
rules: "min_length[5]", rules: "min_length[5]",
message: i18n.t("validation_length_min", { message: i18n.t("validation_length_min", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: ["5"] sprintf: ["5"]
}) })
},{ },
{
name: "password[confirm]", name: "password[confirm]",
rules: "matches[password[password]]", rules: "matches[password[password]]",
message: i18n.t("password_match") message: i18n.t("password_match")
},{ },
{
name: "accept-tou", name: "accept-tou",
rules: "required", rules: "required",
message: i18n.t("accept_tou"), message: i18n.t("accept_tou"),
type: "checkbox" type: "checkbox"
},{ },
{
name: "collections[]", name: "collections[]",
rules: "min_length[1]", rules: "min_length[1]",
message: i18n.t("validation_choice_min", { message: i18n.t("validation_choice_min", {
@@ -67,7 +74,8 @@ require([
sprintf: ["1"] sprintf: ["1"]
}), }),
type: "multiple" type: "multiple"
}]; }
];
_.each(fieldsConfiguration, function (field) { _.each(fieldsConfiguration, function (field) {
if (field.required) { if (field.required) {

View File

@@ -30,35 +30,42 @@ require([
resGetPath: Common.languagePath, resGetPath: Common.languagePath,
useLocalStorage: true useLocalStorage: true
}, function () { }, function () {
var rules = [{ var rules = [
{
name: "email", name: "email",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "email", name: "email",
rules: "valid_email", rules: "valid_email",
message: i18n.t("validation_email") message: i18n.t("validation_email")
},{ },
{
name: "password", name: "password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password", name: "password",
rules: "min_length[5]", rules: "min_length[5]",
message: i18n.t("validation_length_min", { message: i18n.t("validation_length_min", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: ["5"] sprintf: ["5"]
}) })
},{ },
{
name: "passwordConfirm", name: "passwordConfirm",
rules: "matches[password]", rules: "matches[password]",
message: i18n.t("password_match") message: i18n.t("password_match")
},{ },
{
name: "accept-tou", name: "accept-tou",
rules: "required", rules: "required",
message: i18n.t("accept_tou"), message: i18n.t("accept_tou"),
type: "checkbox" type: "checkbox"
},{ },
{
name: "collections[]", name: "collections[]",
rules: "min_length[1]", rules: "min_length[1]",
message: i18n.t("validation_choice_min", { message: i18n.t("validation_choice_min", {
@@ -66,7 +73,8 @@ require([
sprintf: ["1"] sprintf: ["1"]
}), }),
type: "multiple" type: "multiple"
}]; }
];
_.each(fieldsConfiguration, function (field) { _.each(fieldsConfiguration, function (field) {
if (field.required) { if (field.required) {

View File

@@ -25,23 +25,28 @@ require([
onRenderError: function (name, $el) { onRenderError: function (name, $el) {
$el.closest(".control-group").addClass("error"); $el.closest(".control-group").addClass("error");
}, },
rules: [{ rules: [
{
name: "form_password", name: "form_password",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "form_email", name: "form_email",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "form_email", name: "form_email",
rules: "email", rules: "email",
message: i18n.t("validation_email") message: i18n.t("validation_email")
},{ },
{
name: "form_email_confirm", name: "form_email_confirm",
rules: "matches[form_email]", rules: "matches[form_email]",
message: i18n.t("email_match") message: i18n.t("email_match")
}] }
]
}); });
}); });
}); });

View File

@@ -21,26 +21,31 @@ require([
new RenewPassword({ new RenewPassword({
el: $("form[name=passwordChangeForm]"), el: $("form[name=passwordChangeForm]"),
rules: [{ rules: [
{
name: "oldPassword", name: "oldPassword",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password[password]", name: "password[password]",
rules: "required", rules: "required",
message: i18n.t("validation_blank") message: i18n.t("validation_blank")
},{ },
{
name: "password[password]", name: "password[password]",
rules: "min_length[5]", rules: "min_length[5]",
message: i18n.t("validation_length_min", { message: i18n.t("validation_length_min", {
postProcess: "sprintf", postProcess: "sprintf",
sprintf: ["5"] sprintf: ["5"]
}) })
},{ },
{
name: "password[confirm]", name: "password[confirm]",
rules: "matches[password[password]]", rules: "matches[password[password]]",
message: i18n.t("password_match") message: i18n.t("password_match")
}] }
]
}); });
}); });
}); });

View File

@@ -195,7 +195,9 @@ define([
}, },
"min_length": function (field, length) { "min_length": function (field, length) {
if (field.type === "multiple") { if (field.type === "multiple") {
return _.filter(field.value.split(","), function(value){ return value !== ""; }).length >= parseInt(length, 10) return _.filter(field.value.split(","),function (value) {
return value !== "";
}).length >= parseInt(length, 10)
} }
if (!this.Regexp.numericRegex.test(length)) { if (!this.Regexp.numericRegex.test(length)) {
@@ -206,7 +208,9 @@ define([
}, },
"max_length": function (field, length) { "max_length": function (field, length) {
if (field.type === "multiple") { if (field.type === "multiple") {
return _.filter(field.value.split(","), function(value){ return value !== ""; }).length <= parseInt(length, 10) return _.filter(field.value.split(","),function (value) {
return value !== "";
}).length <= parseInt(length, 10)
} }
if (!this.Regexp.numericRegex.test(length)) { if (!this.Regexp.numericRegex.test(length)) {
@@ -217,7 +221,9 @@ define([
}, },
"exact_length": function (field, length) { "exact_length": function (field, length) {
if (field.type === "multiple") { if (field.type === "multiple") {
return _.filter(field.value.split(","), function(value){ return value !== ""; }).length === parseInt(length, 10) return _.filter(field.value.split(","),function (value) {
return value !== "";
}).length === parseInt(length, 10)
} }
if (!this.Regexp.numericRegex.test(length)) { if (!this.Regexp.numericRegex.test(length)) {

View File

@@ -15,7 +15,7 @@ define([
var ErrorView = Backbone.View.extend({ var ErrorView = Backbone.View.extend({
tagName: "div", tagName: "div",
initialize: function (options) { initialize: function (options) {
options = options || {}; options = options || {};
if (false === "name" in options) { if (false === "name" in options) {
throw "Missing name attribute in error view"; throw "Missing name attribute in error view";
@@ -28,7 +28,7 @@ define([
this.name = options.name; this.name = options.name;
this.errorTemplate = options.errorTemplate; this.errorTemplate = options.errorTemplate;
this.errors = options.errors || {}; this.errors = options.errors || {};
this.onRenderError = options.onRenderError || null; this.onRenderError = options.onRenderError || null;
}, },
render: function () { render: function () {

View File

@@ -20,7 +20,7 @@ define([
"submit": "_onSubmit" "submit": "_onSubmit"
}, },
initialize: function (options) { initialize: function (options) {
options = options || {}; options = options || {};
var self = this; var self = this;

View File

@@ -16,7 +16,7 @@ define([
], function ($, _, Backbone, ErrorView, MultiViews) { ], function ($, _, Backbone, ErrorView, MultiViews) {
var InputView = Backbone.View.extend(_.extend({}, MultiViews, { var InputView = Backbone.View.extend(_.extend({}, MultiViews, {
initialize: function (options) { initialize: function (options) {
options = options || {}; options = options || {};
if (false === "name" in options) { if (false === "name" in options) {
throw "Missing name attribute in input view"; throw "Missing name attribute in input view";

View File

@@ -1,4 +1,5 @@
;(function (root, factory) { ;
(function (root, factory) {
if (typeof define === 'function' && define.amd) { if (typeof define === 'function' && define.amd) {
define([''], factory); define([''], factory);
} else { } else {

View File

@@ -39,7 +39,8 @@ mocha.setup({
globals: ['js-fixtures'] globals: ['js-fixtures']
}); });
console = window.console || function() {}; console = window.console || function () {
};
window.notrack = true; window.notrack = true;

View File

@@ -15,24 +15,7 @@ define([
'apps/admin/fields/views/modal', 'apps/admin/fields/views/modal',
'apps/admin/fields/views/save', 'apps/admin/fields/views/save',
'apps/admin/fields/views/dcField' 'apps/admin/fields/views/dcField'
], function( ], function (chai, fixtures, $, App, FieldModel, FieldCollection, DcFieldCollection, VocabularyCollection, SingleItemView, ListItemView, AlertView, EditView, FieldErrorView, ModalView, SaveView, DcFieldView) {
chai,
fixtures,
$,
App,
FieldModel,
FieldCollection,
DcFieldCollection,
VocabularyCollection,
SingleItemView,
ListItemView,
AlertView,
EditView,
FieldErrorView,
ModalView,
SaveView,
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();
@@ -175,11 +158,13 @@ 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"
@@ -339,7 +324,9 @@ define([
}); });
it("should reorder collection on drop action", function () { it("should reorder collection on drop action", function () {
var ui = {item: {index: function() {return 2;}}}; var ui = {item: {index: function () {
return 2;
}}};
AdminFieldApp.fieldListView.itemViews[0].dropAction({}, ui); AdminFieldApp.fieldListView.itemViews[0].dropAction({}, ui);
assert.equal(AdminFieldApp.fieldListView.collection.last().get('sorter'), 3, 'model is updated'); assert.equal(AdminFieldApp.fieldListView.collection.last().get('sorter'), 3, 'model is updated');
}); });

View File

@@ -5,14 +5,7 @@ define([
'common/forms/views/form', 'common/forms/views/form',
'common/forms/views/input', 'common/forms/views/input',
'common/forms/views/error' 'common/forms/views/error'
], function( ], function (chai, fixtures, $, FormView, InputView, ErrorView) {
chai,
fixtures,
$,
FormView,
InputView,
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();
@@ -23,7 +16,9 @@ define([
describe("Login Home", function () { describe("Login Home", function () {
describe("Form View", function () { describe("Form View", function () {
it("should initialize validator with proper rules", function () { it("should initialize validator with proper rules", function () {
var rules = [{name: "hello",rules: "simple_rules"}]; var rules = [
{name: "hello", rules: "simple_rules"}
];
var form = new FormView({ var form = new FormView({
el: $('form[name=loginForm]'), el: $('form[name=loginForm]'),
rules: rules rules: rules
@@ -50,11 +45,13 @@ define([
it("should render errors on submit", function () { it("should render errors on submit", function () {
var form = new FormView({ var form = new FormView({
el: $('form[name=loginForm]'), el: $('form[name=loginForm]'),
rules: [{ rules: [
{
"name": "login", "name": "login",
"rules": "required", "rules": "required",
"message": "something is wrong" "message": "something is wrong"
}] }
]
}); });
form._onSubmit(document.createEvent("Event")); form._onSubmit(document.createEvent("Event"));

View File

@@ -9,482 +9,603 @@ define([
describe("Validator rules", function () { describe("Validator rules", function () {
beforeEach(function () { beforeEach(function () {
this.validator = new Validator([{ this.validator = new Validator([
{
name: "required", name: "required",
rules: "required" rules: "required"
},{ },
{
name: "valid_email", name: "valid_email",
rules: "valid_email" rules: "valid_email"
},{ },
{
name: "equal", name: "equal",
rules: "equal[toto]" rules: "equal[toto]"
},{ },
{
name: "matches", name: "matches",
rules: "matches[to_match]" rules: "matches[to_match]"
},{ },
{
name: "valid_emails", name: "valid_emails",
rules: "valid_emails" rules: "valid_emails"
},{ },
{
name: "min_length", name: "min_length",
rules: "min_length[5]" rules: "min_length[5]"
},{ },
{
name: "max_length", name: "max_length",
rules: "max_length[5]" rules: "max_length[5]"
},{ },
{
name: "exact_length", name: "exact_length",
rules: "exact_length[5]" rules: "exact_length[5]"
},{ },
{
name: "greater_than", name: "greater_than",
rules: "greater_than[5]" rules: "greater_than[5]"
},{ },
{
name: "less_than", name: "less_than",
rules: "less_than[5]" rules: "less_than[5]"
},{ },
{
name: "alpha", name: "alpha",
rules: "alpha" rules: "alpha"
},{ },
{
name: "alpha_numeric", name: "alpha_numeric",
rules: "alpha_numeric" rules: "alpha_numeric"
},{ },
{
name: "alpha_dash", name: "alpha_dash",
rules: "alpha_dash" rules: "alpha_dash"
},{ },
{
name: "numeric", name: "numeric",
rules: "numeric" rules: "numeric"
},{ },
{
name: "integer", name: "integer",
rules: "integer" rules: "integer"
},{ },
{
name: "decimal", name: "decimal",
rules: "decimal" rules: "decimal"
},{ },
{
name: "is_natural", name: "is_natural",
rules: "is_natural" rules: "is_natural"
},{ },
{
name: "is_natural_no_zero", name: "is_natural_no_zero",
rules: "is_natural_no_zero" rules: "is_natural_no_zero"
},{ },
{
name: "valid_ip", name: "valid_ip",
rules: "valid_ip" rules: "valid_ip"
},{ },
{
name: "valid_url", name: "valid_url",
rules: "valid_url" rules: "valid_url"
}]); }
]);
}); });
it("should detect an error if field is required and value is blank", function () { it("should detect an error if field is required and value is blank", function () {
this.validator.validate([{ this.validator.validate([
{
name: "required", name: "required",
value: "" value: ""
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should detect an error if field is not a valid email", function () { it("should detect an error if field is not a valid email", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_email", name: "valid_email",
value: "email.not.va@" value: "email.not.va@"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field is a valid email", function () { it("should not detect an error if field is a valid email", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_email", name: "valid_email",
value: "valid@email.com" value: "valid@email.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_email", name: "valid_email",
value: "valid+34@email.com" value: "valid+34@email.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field is not a valid emails", function () { it("should detect an error if field is not a valid emails", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_emails", name: "valid_emails",
value: "valid@email.com, email.not.va@" value: "valid@email.com, email.not.va@"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field is a valid emails", function () { it("should not detect an error if field is a valid emails", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_emails", name: "valid_emails",
value: "valid32@email.com, valid2@email.com" value: "valid32@email.com, valid2@email.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_emails", name: "valid_emails",
value: "valid@email.com" value: "valid@email.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field is not equal to default string toto", function () { it("should detect an error if field is not equal to default string toto", function () {
this.validator.validate([{ this.validator.validate([
{
name: "equal", name: "equal",
value: "tata" value: "tata"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field is equal to default string toto", function () { it("should not detect an error if field is equal to default string toto", function () {
this.validator.validate([{ this.validator.validate([
{
name: "equal", name: "equal",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'match 'is not equal to field value 'to_match'", function () { it("should detect an error if field value 'match 'is not equal to field value 'to_match'", function () {
this.validator.validate([{ this.validator.validate([
{
name: "matches", name: "matches",
value: "toto" value: "toto"
}, { },
{
name: "to_match", name: "to_match",
value: "tata" value: "tata"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'match' is equal to field value 'to_match'", function () { it("should not detect an error if field value 'match' is equal to field value 'to_match'", function () {
this.validator.validate([{ this.validator.validate([
{
name: "matches", name: "matches",
value: "toto" value: "toto"
}, { },
{
name: "to_match", name: "to_match",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'min_length' is < to 5", function () { it("should detect an error if field value 'min_length' is < to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "min_length", name: "min_length",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'min_length' is >= to 5", function () { it("should not detect an error if field value 'min_length' is >= to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "min_length", name: "min_length",
value: "totos" value: "totos"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'max_length' is > to 5", function () { it("should detect an error if field value 'max_length' is > to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "max_length", name: "max_length",
value: "tostos" value: "tostos"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'max_length' is <= to 5", function () { it("should not detect an error if field value 'max_length' is <= to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "max_length", name: "max_length",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'greater_than' is < to 5", function () { it("should detect an error if field value 'greater_than' is < to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "greater_than", name: "greater_than",
value: "3" value: "3"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'greater_than' is > to 5", function () { it("should not detect an error if field value 'greater_than' is > to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "greater_than", name: "greater_than",
value: "6" value: "6"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'less_than' is > to 5", function () { it("should detect an error if field value 'less_than' is > to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "less_than", name: "less_than",
value: "6" value: "6"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'less_than' is <= to 5", function () { it("should not detect an error if field value 'less_than' is <= to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "less_than", name: "less_than",
value: "3" value: "3"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'exact_length' is = to 5", function () { it("should detect an error if field value 'exact_length' is = to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "exact_length", name: "exact_length",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'exact_length' is = to 5", function () { it("should not detect an error if field value 'exact_length' is = to 5", function () {
this.validator.validate([{ this.validator.validate([
{
name: "exact_length", name: "exact_length",
value: "totos" value: "totos"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'alpha' is not alpha", function () { it("should detect an error if field value 'alpha' is not alpha", function () {
this.validator.validate([{ this.validator.validate([
{
name: "alpha", name: "alpha",
value: "toto12" value: "toto12"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'alpha' is alpha", function () { it("should not detect an error if field value 'alpha' is alpha", function () {
this.validator.validate([{ this.validator.validate([
{
name: "alpha", name: "alpha",
value: "totos" value: "totos"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'alpha_numeric' is not alpha numeric", function () { it("should detect an error if field value 'alpha_numeric' is not alpha numeric", function () {
this.validator.validate([{ this.validator.validate([
{
name: "alpha_numeric", name: "alpha_numeric",
value: "toto#" value: "toto#"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'alpha_numeric' is alpha numeric", function () { it("should not detect an error if field value 'alpha_numeric' is alpha numeric", function () {
this.validator.validate([{ this.validator.validate([
{
name: "alpha_numeric", name: "alpha_numeric",
value: "totos12" value: "totos12"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'numeric' is not numeric", function () { it("should detect an error if field value 'numeric' is not numeric", function () {
this.validator.validate([{ this.validator.validate([
{
name: "numeric", name: "numeric",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'numeric' is numeric", function () { it("should not detect an error if field value 'numeric' is numeric", function () {
this.validator.validate([{ this.validator.validate([
{
name: "numeric", name: "numeric",
value: "123" value: "123"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'integer' is not integer", function () { it("should detect an error if field value 'integer' is not integer", function () {
this.validator.validate([{ this.validator.validate([
{
name: "integer", name: "integer",
value: "3.44" value: "3.44"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'integer' is integer", function () { it("should not detect an error if field value 'integer' is integer", function () {
this.validator.validate([{ this.validator.validate([
{
name: "integer", name: "integer",
value: "123" value: "123"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'decimal' is not decimal", function () { it("should detect an error if field value 'decimal' is not decimal", function () {
this.validator.validate([{ this.validator.validate([
{
name: "decimal", name: "decimal",
value: "23a" value: "23a"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'decimal' is decimal", function () { it("should not detect an error if field value 'decimal' is decimal", function () {
this.validator.validate([{ this.validator.validate([
{
name: "decimal", name: "decimal",
value: "1.23" value: "1.23"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "decimal", name: "decimal",
value: "123" value: "123"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'natural' is not natural", function () { it("should detect an error if field value 'natural' is not natural", function () {
this.validator.validate([{ this.validator.validate([
{
name: "is_natural", name: "is_natural",
value: "-2" value: "-2"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'natural' is natural", function () { it("should not detect an error if field value 'natural' is natural", function () {
this.validator.validate([{ this.validator.validate([
{
name: "is_natural", name: "is_natural",
value: "0" value: "0"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'is_natural_no_zero' is not a natural no zero", function () { it("should detect an error if field value 'is_natural_no_zero' is not a natural no zero", function () {
this.validator.validate([{ this.validator.validate([
{
name: "is_natural_no_zero", name: "is_natural_no_zero",
value: "0" value: "0"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'is_natural_no_zero' is a natural no zero", function () { it("should not detect an error if field value 'is_natural_no_zero' is a natural no zero", function () {
this.validator.validate([{ this.validator.validate([
{
name: "is_natural_no_zero", name: "is_natural_no_zero",
value: "1" value: "1"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'valid_ip' is not a valid ip", function () { it("should detect an error if field value 'valid_ip' is not a valid ip", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_ip", name: "valid_ip",
value: "12.8.1.187.2" value: "12.8.1.187.2"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
this.validator.validate([{ this.validator.validate([
{
name: "valid_ip", name: "valid_ip",
value: "1234.12.12" value: "1234.12.12"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
this.validator.validate([{ this.validator.validate([
{
name: "valid_ip", name: "valid_ip",
value: "0.0" value: "0.0"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'valid_ip' a valid ip", function () { it("should not detect an error if field value 'valid_ip' a valid ip", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_ip", name: "valid_ip",
value: "127.0.0.1" value: "127.0.0.1"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_ip", name: "valid_ip",
value: "my.domain" value: "my.domain"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });
it("should detect an error if field value 'valid_url' is not a valid http url", function () { it("should detect an error if field value 'valid_url' is not a valid http url", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "toto" value: "toto"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "toto.123s" value: "toto.123s"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "http:/#toto.com" value: "http:/#toto.com"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "htp:/toto.com" value: "htp:/toto.com"
}]); }
]);
this.validator.getErrors().length.should.equal(1); this.validator.getErrors().length.should.equal(1);
}); });
it("should not detect an error if field value 'valid_url' is a valid http url", function () { it("should not detect an error if field value 'valid_url' is a valid http url", function () {
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "http://valid.url.com" value: "http://valid.url.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "https://valid.url.com" value: "https://valid.url.com"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "http://valid.url.com/?test=3" value: "http://valid.url.com/?test=3"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
this.validator.validate([{ this.validator.validate([
{
name: "valid_url", name: "valid_url",
value: "http://valid.url.com/?test=3#salut" value: "http://valid.url.com/?test=3#salut"
}]); }
]);
this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0);
}); });

View File

@@ -97,7 +97,8 @@ $(document).ready(function() {
url: $this.attr("value"), url: $this.attr("value"),
dataType: 'json', dataType: 'json',
data: {grant: $this.is(":checked") ? "1" : "0"}, data: {grant: $this.is(":checked") ? "1" : "0"},
success : function(data){} success: function (data) {
}
}); });
}); });

View File

@@ -35,28 +35,24 @@ function ini_edit_usrs(){
} }
); );
function user_click_box(event, element, status) function user_click_box(event, element, status) {
{
var newclass, newvalue, boxes; var newclass, newvalue, boxes;
var $element = $(element); var $element = $(element);
if($element.hasClass('right_access')) if ($element.hasClass('right_access')) {
{
var base_id = $element.find('input').attr('name').split('_').pop(); var base_id = $element.find('input').attr('name').split('_').pop();
boxes = $('div.base_' + base_id + ':not(:first)'); boxes = $('div.base_' + base_id + ':not(:first)');
} }
if((typeof status !== 'undefined' && status == 'checked') || (typeof status === 'undefined' && (($element.hasClass('mixed') === true) || ($element.hasClass('unchecked') === true)))) if ((typeof status !== 'undefined' && status == 'checked') || (typeof status === 'undefined' && (($element.hasClass('mixed') === true) || ($element.hasClass('unchecked') === true)))) {
{
newclass = 'checked'; newclass = 'checked';
newvalue = '1'; newvalue = '1';
if (boxes) if (boxes)
boxes.show(); boxes.show();
} }
else else {
{
newclass = 'unchecked'; newclass = 'unchecked';
newvalue = '0'; newvalue = '0';
@@ -174,13 +170,11 @@ function ini_edit_usrs(){
boxes = $(this).closest('form').find('input.datepicker'); boxes = $(this).closest('form').find('input.datepicker');
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) {
{
newclass = 'checked'; newclass = 'checked';
boxes.removeAttr('readonly'); boxes.removeAttr('readonly');
} }
else else {
{
newclass = 'unchecked'; newclass = 'unchecked';
boxes.attr('readonly', 'readonly'); boxes.attr('readonly', 'readonly');
} }
@@ -210,13 +204,11 @@ function ini_edit_usrs(){
boxes = $(this).closest('form').find('input.datepicker'); boxes = $(this).closest('form').find('input.datepicker');
if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) {
{
newclass = 'checked'; newclass = 'checked';
boxes.removeAttr('readonly'); boxes.removeAttr('readonly');
} }
else else {
{
newclass = 'unchecked'; newclass = 'unchecked';
boxes.attr('readonly', 'readonly'); boxes.attr('readonly', 'readonly');
} }
@@ -248,13 +240,11 @@ function ini_edit_usrs(){
boxes = $(this).closest('form').find('input:text'); boxes = $(this).closest('form').find('input:text');
if(($(this).hasClass('mixed')===true) || ($(this).hasClass('unchecked') === true)) if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) {
{
newclass = 'checked'; newclass = 'checked';
boxes.removeAttr('readonly'); boxes.removeAttr('readonly');
} }
else else {
{
newclass = 'unchecked'; newclass = 'unchecked';
boxes.attr('readonly', 'readonly'); boxes.attr('readonly', 'readonly');
} }
@@ -282,16 +272,13 @@ function ini_edit_usrs(){
var bit = $(this).find('input[name="bit"]').val(); var bit = $(this).find('input[name="bit"]').val();
currentclass = 'unchecked'; currentclass = 'unchecked';
if($(this).hasClass('mixed')) if ($(this).hasClass('mixed')) {
{
currentclass = 'mixed'; currentclass = 'mixed';
} }
if($(this).hasClass('checked')) if ($(this).hasClass('checked')) {
{
currentclass = 'checked'; currentclass = 'checked';
} }
switch(currentclass) switch (currentclass) {
{
case 'mixed': case 'mixed':
default: default:
$('.bitnum_' + bit).removeClass('mixed checked unchecked').addClass('checked') $('.bitnum_' + bit).removeClass('mixed checked unchecked').addClass('checked')
@@ -300,12 +287,10 @@ function ini_edit_usrs(){
$(this).removeClass('mixed checked unchecked').addClass('checked') $(this).removeClass('mixed checked unchecked').addClass('checked')
break; break;
case 'checked': case 'checked':
if($('.checked.bitnum_'+bit).length == 2) if ($('.checked.bitnum_' + bit).length == 2) {
{
$(this).removeClass('mixed checked unchecked').addClass('unchecked') $(this).removeClass('mixed checked unchecked').addClass('unchecked')
} }
else else {
{
alert("admin::user:mask: vous devez cocher au moins une case pour chaque status"); alert("admin::user:mask: vous devez cocher au moins une case pour chaque status");
return; return;
} }
@@ -323,15 +308,12 @@ function ini_edit_usrs(){
var newbit_vand_and = newbit_vand_or = newbit_vxor_and = newbit_vxor_or = 0; var newbit_vand_and = newbit_vand_or = newbit_vxor_and = newbit_vxor_or = 0;
if( left.length === 1 && right.length === 1 ) if (left.length === 1 && right.length === 1) {
{ if (left.hasClass('checked') && right.hasClass('unchecked')) {
if(left.hasClass('checked') && right.hasClass('unchecked') )
{
newbit_vand_and = "1"; newbit_vand_and = "1";
newbit_vand_or = "1"; newbit_vand_or = "1";
} }
else if( left.hasClass('unchecked') && right.hasClass('checked') ) else if (left.hasClass('unchecked') && right.hasClass('checked')) {
{
newbit_vand_and = "1"; newbit_vand_and = "1";
newbit_vand_or = "1"; newbit_vand_or = "1";
newbit_vxor_and = "1"; newbit_vxor_and = "1";
@@ -348,8 +330,7 @@ function ini_edit_usrs(){
}); });
function save_masks() function save_masks() {
{
var cont = $('#masks_dialog'); var cont = $('#masks_dialog');
var maskform = $('#masks_dialog form'); var maskform = $('#masks_dialog form');
@@ -379,8 +360,7 @@ function ini_edit_usrs(){
} }
function save_quotas() function save_quotas() {
{
var cont = $('#quotas_dialog'); var cont = $('#quotas_dialog');
var base_id = $('input[name="base_id"]', cont).val(); var base_id = $('input[name="base_id"]', cont).val();
var users = $('input[name="users"]', cont).val(); var users = $('input[name="users"]', cont).val();
@@ -414,8 +394,7 @@ function ini_edit_usrs(){
}); });
} }
function save_time() function save_time() {
{
var cont = $('#time_dialog'); var cont = $('#time_dialog');
var dmin = $('input[name="dmin"]', cont).val(); var dmin = $('input[name="dmin"]', cont).val();
var dmax = $('input[name="dmax"]', cont).val(); var dmax = $('input[name="dmax"]', cont).val();
@@ -450,8 +429,7 @@ function ini_edit_usrs(){
}); });
} }
function check_uncheck_menu(right, sbas_id, el) function check_uncheck_menu(right, sbas_id, el) {
{
var top = el.offset().top; var top = el.offset().top;
var left = el.offset().left + 16; var left = el.offset().left + 16;
$('body').append('<div id="users_check_uncheck" style="position:absolute;top:' + top + 'px;left:' + left + 'px;">' + $('body').append('<div id="users_check_uncheck" style="position:absolute;top:' + top + 'px;left:' + left + 'px;">' +
@@ -488,15 +466,13 @@ function ini_edit_usrs(){
}); });
} }
function users_check(bool, sbas_id, right)
{ function users_check(bool, sbas_id, right) {
var newclass; var newclass;
if(bool) if (bool) {
{
newclass = "checked"; newclass = "checked";
} }
else else {
{
newclass = "unchecked"; newclass = "unchecked";
} }
$('.inside_sbas_' + sbas_id + '.' + right + ':visible').each(function (i, n) { $('.inside_sbas_' + sbas_id + '.' + right + ':visible').each(function (i, n) {
@@ -504,4 +480,3 @@ function ini_edit_usrs(){
}); });
} }
} }

View File

@@ -6,11 +6,9 @@
$(document).ready(function () { $(document).ready(function () {
function users_select_this(n,k) function users_select_this(n, k) {
{
if(p4.users.sel.length >= 800) if (p4.users.sel.length >= 800) {
{
alert(language.max_record_selected); alert(language.max_record_selected);
return false; return false;
} }
@@ -26,12 +24,10 @@ $(document).ready(function(){
var sort = $('input', $this).val(); var sort = $('input', $this).val();
if ((sort == $('#users_page_form input[name="srt"]').val()) if ((sort == $('#users_page_form input[name="srt"]').val())
&& ($('#users_page_form input[name="ord"]').val() == 'asc')) && ($('#users_page_form input[name="ord"]').val() == 'asc')) {
{
var ord = 'desc'; var ord = 'desc';
} }
else else {
{
var ord = 'asc'; var ord = 'asc';
} }
@@ -39,8 +35,12 @@ $(document).ready(function(){
$('#users_page_form input[name="ord"]').val(ord); $('#users_page_form input[name="ord"]').val(ord);
$('#users_page_form').trigger('submit'); $('#users_page_form').trigger('submit');
}).live('mouseover', function(){$(this).addClass('hover');}) }).live('mouseover', function () {
.live('mouseout', function(){$(this).removeClass('hover');}); $(this).addClass('hover');
})
.live('mouseout', function () {
$(this).removeClass('hover');
});
var buttons = {}; var buttons = {};
buttons[language.create_user] = function () { buttons[language.create_user] = function () {
@@ -77,8 +77,7 @@ $(document).ready(function(){
}).dialog('close'); }).dialog('close');
function check_new_user(is_template) function check_new_user(is_template) {
{
var container = is_template ? $('#template_add_dialog') : $('#user_add_dialog'); var container = is_template ? $('#template_add_dialog') : $('#user_add_dialog');
$('#new_user_loader').show(); $('#new_user_loader').show();
$.ajax({ $.ajax({
@@ -94,8 +93,7 @@ $(document).ready(function(){
}, },
success: function (data) { success: function (data) {
$('.new_user_loader', container).hide(); $('.new_user_loader', container).hide();
if(!data.error) if (!data.error) {
{
if (container.data("ui-dialog")) { if (container.data("ui-dialog")) {
container.dialog('close'); container.dialog('close');
} }
@@ -113,18 +111,15 @@ $(document).ready(function(){
} }
}); });
} }
else else {
{
alert(data.message); alert(data.message);
} }
}, },
error:function() error: function () {
{
alert(language.serverError); alert(language.serverError);
}, },
timeout:function() timeout: function () {
{
alert(language.serverTimeout); alert(language.serverTimeout);
} }
}); });
@@ -182,20 +177,16 @@ $(document).ready(function(){
var offset_start = 0; var offset_start = 0;
if($(this).hasClass('prev')) if ($(this).hasClass('prev')) {
{
offset_start = (current_page - 2) * perPage; offset_start = (current_page - 2) * perPage;
} }
if($(this).hasClass('first')) if ($(this).hasClass('first')) {
{
offset_start = 0; offset_start = 0;
} }
if($(this).hasClass('next')) if ($(this).hasClass('next')) {
{
offset_start = current_page * perPage; offset_start = current_page * perPage;
} }
if($(this).hasClass('last')) if ($(this).hasClass('last')) {
{
offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage)) * perPage; offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage)) * perPage;
} }
@@ -216,29 +207,24 @@ $(document).ready(function(){
var k = el.attr('id').split('_').pop(); var k = el.attr('id').split('_').pop();
if(is_shift_key(evt) && $('tr.last_selected', cont).length!=0) if (is_shift_key(evt) && $('tr.last_selected', cont).length != 0) {
{
var lst = $('tr', cont); var lst = $('tr', cont);
var index1 = $.inArray($('tr.last_selected', cont)[0], lst); var index1 = $.inArray($('tr.last_selected', cont)[0], lst);
var index2 = $.inArray($(el)[0], lst); var index2 = $.inArray($(el)[0], lst);
if(index2<index1) if (index2 < index1) {
{
var tmp = index1; var tmp = index1;
index1 = (index2 - 1) < 0 ? index2 : (index2 - 1); index1 = (index2 - 1) < 0 ? index2 : (index2 - 1);
index2 = tmp; index2 = tmp;
} }
var stopped = false; var stopped = false;
if(index2 != -1 && index1 != -1) if (index2 != -1 && index1 != -1) {
{
var exp = 'tr:gt(' + index1 + '):lt(' + (index2 - index1) + ')'; var exp = 'tr:gt(' + index1 + '):lt(' + (index2 - index1) + ')';
$.each($(exp, cont), function (i, n) { $.each($(exp, cont), function (i, n) {
if(!$(n).hasClass('selected')) if (!$(n).hasClass('selected')) {
{
if(!users_select_this(n,$(n).attr('id').split('_').pop())) if (!users_select_this(n, $(n).attr('id').split('_').pop())) {
{
stopped = true; stopped = true;
return false; return false;
} }
@@ -246,18 +232,14 @@ $(document).ready(function(){
}); });
} }
if(!stopped && $.inArray(k,p4.users.sel)<0) if (!stopped && $.inArray(k, p4.users.sel) < 0) {
{
if (!users_select_this(el, k)) if (!users_select_this(el, k))
return false; return false;
} }
} }
else else {
{ if (!is_ctrl_key(evt)) {
if(!is_ctrl_key(evt)) if ($.inArray(k, p4.users.sel) < 0) {
{
if($.inArray(k,p4.users.sel)<0)
{
p4.users.sel = new Array(); p4.users.sel = new Array();
$('tr', cont).removeClass('selected'); $('tr', cont).removeClass('selected');
@@ -265,17 +247,14 @@ $(document).ready(function(){
return false; return false;
} }
} }
else else {
{ if ($.inArray(k, p4.users.sel) >= 0) {
if($.inArray(k,p4.users.sel)>=0)
{
p4.users.sel = $.grep(p4.users.sel, function (n) { p4.users.sel = $.grep(p4.users.sel, function (n) {
return(n != k); return(n != k);
}); });
$(el).removeClass('selected'); $(el).removeClass('selected');
} }
else else {
{
if (!users_select_this(el, k)) if (!users_select_this(el, k))
return false; return false;
} }
@@ -293,16 +272,14 @@ $(document).ready(function(){
$('#users_apply_template').live('submit', function () { $('#users_apply_template').live('submit', function () {
var users = p4.users.sel.join(';'); var users = p4.users.sel.join(';');
if(users === '') if (users === '') {
{
return false; return false;
} }
var $this = $(this); var $this = $(this);
var template = $('select[name="template_chooser"]', $this).val(); var template = $('select[name="template_chooser"]', $this).val();
if(template === '') if (template === '') {
{
return false; return false;
} }
@@ -325,8 +302,7 @@ $(document).ready(function(){
$('#users_page_form .user_modifier').live('click', function () { $('#users_page_form .user_modifier').live('click', function () {
var users = p4.users.sel.join(';'); var users = p4.users.sel.join(';');
if(users === '') if (users === '') {
{
return false; return false;
} }
@@ -348,8 +324,7 @@ $(document).ready(function(){
$('#users_page_form .user_deleter').live('click', function () { $('#users_page_form .user_deleter').live('click', function () {
var users = p4.users.sel.join(';'); var users = p4.users.sel.join(';');
if(users === '') if (users === '') {
{
return false; return false;
} }
@@ -370,8 +345,7 @@ $(document).ready(function(){
$('#users_page .invite_modifier, #users_page .autoregister_modifier').live('click', function () { $('#users_page .invite_modifier, #users_page .autoregister_modifier').live('click', function () {
var users = $(this).next('input').val(); var users = $(this).next('input').val();
if($.trim(users) === '') if ($.trim(users) === '') {
{
return false; return false;
} }

View File

@@ -23,21 +23,18 @@ var bodySize = {x:0,y:0};
**************/ **************/
function acceptCgus(name,value) function acceptCgus(name, value) {
{
setPref(name, value); setPref(name, value);
} }
function cancelCgus(id) function cancelCgus(id) {
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/prod/TOU/deny/" + id + "/", url: "/prod/TOU/deny/" + id + "/",
data: {}, data: {},
success: function (data) { success: function (data) {
if(data == '1') if (data == '1') {
{
alert(language.cgusRelog); alert(language.cgusRelog);
self.location.replace(self.location.href); self.location.replace(self.location.href);
} }
@@ -46,8 +43,7 @@ function cancelCgus(id)
} }
function activateCgus() function activateCgus() {
{
$('.cgu-dialog:first').dialog({ $('.cgu-dialog:first').dialog({
autoOpen: true, autoOpen: true,
@@ -67,8 +63,7 @@ function activateCgus()
} }
}); });
$('.cgus-cancel', $(this)).bind('click', function () { $('.cgus-cancel', $(this)).bind('click', function () {
if(confirm(language.warningDenyCgus)) if (confirm(language.warningDenyCgus)) {
{
cancelCgus($('.cgus-cancel', currentdialog).attr('id').split('_').pop()); cancelCgus($('.cgus-cancel', currentdialog).attr('id').split('_').pop());
} }
}); });
@@ -130,12 +125,9 @@ $(document).ready(function(){
getBaskets(); getBaskets();
afterSearch(); afterSearch();
$(this).bind('keydown',function(event) $(this).bind('keydown', function (event) {
{ if (p4.preview.open) {
if(p4.preview.open) switch (event.keyCode) {
{
switch(event.keyCode)
{
case 39: case 39:
getNext(); getNext();
break; break;
@@ -158,10 +150,8 @@ $(document).ready(function(){
break; break;
} }
} }
else else {
{ switch (event.keyCode) {
switch(event.keyCode)
{
case 39: case 39:
$('#NEXT_PAGE').trigger('click'); $('#NEXT_PAGE').trigger('click');
break; break;
@@ -204,8 +194,7 @@ function resizePreview(){
setPreview(); setPreview();
} }
function controlPubliSize() function controlPubliSize() {
{
$('#publications ul').height('auto'); $('#publications ul').height('auto');
if (50 + $('#publications ul').height() > bodySize.y) if (50 + $('#publications ul').height() > bodySize.y)
$('#publications ul').height(bodySize.y - 50); $('#publications ul').height(bodySize.y - 50);
@@ -214,8 +203,7 @@ function controlPubliSize()
function pquit() { function pquit() {
if (parent.opener) if (parent.opener)
self.close(); self.close();
else else {
{
document.forms['logout'].submit(); document.forms['logout'].submit();
} }
@@ -253,8 +241,7 @@ function resize(){
} }
bodyW = rightw; bodyW = rightw;
if($('#MODALDL').is(':visible')) if ($('#MODALDL').is(':visible')) {
{
$('#MODALDL').css({ $('#MODALDL').css({
top: ((h - $('#MODALDL').height()) / 2), top: ((h - $('#MODALDL').height()) / 2),
left: ((w - $('#MODALDL').width()) / 2) left: ((w - $('#MODALDL').width()) / 2)
@@ -366,8 +353,7 @@ function initBasketForm(){
}, },
success: function (data) { success: function (data) {
baskAjaxrunning = false; baskAjaxrunning = false;
if(p4.preview.open && $.browser.msie && $.browser.version == '6.0') if (p4.preview.open && $.browser.msie && $.browser.version == '6.0') {
{
$('select').css({ $('select').css({
visibility: 'hidden' visibility: 'hidden'
}); });
@@ -479,8 +465,7 @@ function initAnswerForm(){
* SEARCH * SEARCH
**************/ **************/
function afterSearch() function afterSearch() {
{
$('#answers').removeClass('loading'); $('#answers').removeClass('loading');
$("#answers").scrollTop(0); $("#answers").scrollTop(0);
@@ -549,13 +534,11 @@ function clearAnswers(){
$("#answers").empty(); $("#answers").empty();
} }
function newSearch() function newSearch() {
{
$('#searchForm').submit(); $('#searchForm').submit();
} }
function doSearch() function doSearch() {
{
$('#searchForm').submit(); $('#searchForm').submit();
} }
@@ -588,8 +571,7 @@ function resizeSearch(){
* Topics * Topics
**************/ **************/
function doThesSearch(type,sbid,term,field) function doThesSearch(type, sbid, term, field) {
{
if (type == 'T') if (type == 'T')
v = '*:"' + term.replace("(", "[").replace(")", "]") + '"'; v = '*:"' + term.replace("(", "[").replace(")", "]") + '"';
@@ -628,7 +610,6 @@ function clktri(id){
} }
/************* /*************
* CHUTIER * CHUTIER
**************/ **************/
@@ -652,15 +633,13 @@ function evt_add_in_chutier(sbas_id, record_id){
$('#formChu').attr('action', '/client/baskets/add-element/').submit(); $('#formChu').attr('action', '/client/baskets/add-element/').submit();
} }
function chg_chu() function chg_chu() {
{
var id = document.getElementById("chutier_name").value; var id = document.getElementById("chutier_name").value;
document.forms["formChu"].courChuId.value = id; document.forms["formChu"].courChuId.value = id;
$("#formChu").submit(); $("#formChu").submit();
} }
function getBaskets() function getBaskets() {
{
$('#formChu').attr("action", "/client/baskets/") $('#formChu').attr("action", "/client/baskets/")
$('#formChu').submit(); $('#formChu').submit();
} }
@@ -669,8 +648,13 @@ function getBaskets()
function newBasket() { function newBasket() {
var buttons = {}; var buttons = {};
buttons["OK"] = function(e){saveNewBask();$(this).dialog('close');}; buttons["OK"] = function (e) {
buttons[language.annuler] = function(e){$(this).dialog('close');}; saveNewBask();
$(this).dialog('close');
};
buttons[language.annuler] = function (e) {
$(this).dialog('close');
};
$('#DIALOG').empty().append("<input type='text' value='' id='newBaskName' />").attr('title', language.createWinInvite).dialog({ $('#DIALOG').empty().append("<input type='text' value='' id='newBaskName' />").attr('title', language.createWinInvite).dialog({
autoOpen: false, autoOpen: false,
@@ -786,8 +770,7 @@ function evt_print(basrec){
} }
function evt_dwnl(lst) function evt_dwnl(lst) {
{
if (typeof(lst) == 'undefined') { if (typeof(lst) == 'undefined') {
if ($('#chutier_name option').length === 0) { if ($('#chutier_name option').length === 0) {
return false; return false;
@@ -813,8 +796,7 @@ function evt_dwnl(lst)
}); });
} }
function profil(value) function profil(value) {
{
var top; var top;
var left; var left;
@@ -844,8 +826,7 @@ function profil(value)
showOverlay(2); showOverlay(2);
} }
function setCss(color) function setCss(color) {
{
$('#skinCss').attr('href', '/include/minify/?f=skins/common/main.css,skins/client/' + color + '/clientcolor.css,' + $('#skinCss').attr('href', '/include/minify/?f=skins/common/main.css,skins/client/' + color + '/clientcolor.css,' +
'skins/client/' + color + '/ui.core.css,' + 'skins/client/' + color + '/ui.core.css,' +
'skins/client/' + color + '/ui.datepicker.css,' + 'skins/client/' + color + '/ui.datepicker.css,' +
@@ -860,22 +841,19 @@ function setCss(color)
$('select').hide().show(); $('select').hide().show();
} }
function lessPubli(sselid) function lessPubli(sselid) {
{
$('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle(); $('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle();
$('#PUBLICONT' + sselid).css({height: '135px'}); $('#PUBLICONT' + sselid).css({height: '135px'});
$('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle(); $('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle();
} }
function morePubli(sselid) function morePubli(sselid) {
{
$('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle(); $('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle();
$('#PUBLICONT' + sselid).css({height: 'auto'}); $('#PUBLICONT' + sselid).css({height: 'auto'});
$('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle(); $('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle();
} }
function toggleFilter(filter,ele) function toggleFilter(filter, ele) {
{
var el = $('#' + filter); var el = $('#' + filter);
if (el.is(':hidden')) if (el.is(':hidden'))
$(ele).parent().addClass('open'); $(ele).parent().addClass('open');
@@ -884,8 +862,7 @@ function toggleFilter(filter,ele)
$('#' + filter).slideToggle('fast'); $('#' + filter).slideToggle('fast');
} }
function checkFilters() function checkFilters() {
{
var danger = false; var danger = false;
var d = {}; var d = {};
$('.filter_danger').each(function () { $('.filter_danger').each(function () {
@@ -894,24 +871,21 @@ function checkFilters()
}); });
$('.basContTitle .base_filter :text').each(function () { $('.basContTitle .base_filter :text').each(function () {
if($(this)[0].value != "") if ($(this)[0].value != "") {
{
danger = true; danger = true;
d['filter_danger' + parseInt($(this).attr('db'))] = true; d['filter_danger' + parseInt($(this).attr('db'))] = true;
} }
}); });
$('.basContTitle .base_filter :checkbox').each(function () { $('.basContTitle .base_filter :checkbox').each(function () {
if($(this)[0].checked) if ($(this)[0].checked) {
{
danger = true; danger = true;
d['filter_danger' + parseInt($(this).attr('db'))] = true; d['filter_danger' + parseInt($(this).attr('db'))] = true;
} }
}); });
$('.basContTitle .base_filter select').each(function () { $('.basContTitle .base_filter select').each(function () {
if($(this)[0].selectedIndex != 0) if ($(this)[0].selectedIndex != 0) {
{
danger = true; danger = true;
d['filter_danger' + parseInt($(this).attr('db'))] = true; d['filter_danger' + parseInt($(this).attr('db'))] = true;
@@ -930,8 +904,7 @@ function checkFilters()
$('#filter_danger').hide(); $('#filter_danger').hide();
} }
function removeFilters(bas) function removeFilters(bas) {
{
if (typeof(bas) == 'undefined') { if (typeof(bas) == 'undefined') {
$('.basContTitle .base_filter :checkbox').each(function () { $('.basContTitle .base_filter :checkbox').each(function () {
$(this)[0].checked = false; $(this)[0].checked = false;
@@ -957,15 +930,11 @@ function removeFilters(bas)
checkFilters(); checkFilters();
} }
function execLastAct(lastAct) function execLastAct(lastAct) {
{ if (lastAct.act) {
if(lastAct.act) switch (lastAct.act) {
{
switch (lastAct.act)
{
case 'dwnl': case 'dwnl':
if(lastAct.SSTTID) if (lastAct.SSTTID) {
{
if (baskAjaxrunning) { if (baskAjaxrunning) {
setTimeout("execLastAct(lastAct);", 500); setTimeout("execLastAct(lastAct);", 500);
} }
@@ -974,8 +943,7 @@ function execLastAct(lastAct)
return false; return false;
} }
if($('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value != lastAct.SSTTID) if ($('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value != lastAct.SSTTID) {
{
$('#chutier_name option').each(function (i, n) { $('#chutier_name option').each(function (i, n) {
if (lastAct.SSTTID == this.value) { if (lastAct.SSTTID == this.value) {
$('#chutier_name')[0].selectedIndex = i; $('#chutier_name')[0].selectedIndex = i;
@@ -987,9 +955,7 @@ function execLastAct(lastAct)
evt_dwnl(); evt_dwnl();
} }
} }
else else if (lastAct.lst) {
if(lastAct.lst)
{
evt_dwnl(lastAct.lst); evt_dwnl(lastAct.lst);
} }
break; break;

View File

@@ -8,10 +8,8 @@ var bodySize = {
}; };
$(window).bind('beforeunload', function () { $(window).bind('beforeunload', function () {
if(p4.releasable !== false) if (p4.releasable !== false) {
{ if (confirm(p4.releasable)) {
if(confirm(p4.releasable))
{
$('#basket_options .confirm_report').trigger('click'); $('#basket_options .confirm_report').trigger('click');
} }
} }
@@ -25,8 +23,7 @@ $(document).ready(function(){
resize(); resize();
}).trigger('resize'); }).trigger('resize');
function resize() function resize() {
{
bodySize.y = $('#mainContainer').height(); bodySize.y = $('#mainContainer').height();
bodySize.x = $('#mainContainer').width(); bodySize.x = $('#mainContainer').width();
@@ -77,15 +74,13 @@ $(document).ready(function(){
}); });
$('.right_column_title').bind('click',function () { $('.right_column_title').bind('click',function () {
var title = $('.right_column_title'); var title = $('.right_column_title');
if(!$('.right_column_wrapper_caption').is(':visible')) if (!$('.right_column_wrapper_caption').is(':visible')) {
{
$('.right_column_wrapper_user').height(0); $('.right_column_wrapper_user').height(0);
$('.right_column_wrapper_caption').show(); $('.right_column_wrapper_caption').show();
$('.caption', title).addClass('highlight'); $('.caption', title).addClass('highlight');
$('.validate', title).removeClass('highlight'); $('.validate', title).removeClass('highlight');
} }
else else {
{
$('.right_column_wrapper_user').height('auto'); $('.right_column_wrapper_user').height('auto');
$('.right_column_wrapper_caption').hide(); $('.right_column_wrapper_caption').hide();
$('.caption', title).removeClass('highlight'); $('.caption', title).removeClass('highlight');
@@ -94,8 +89,7 @@ $(document).ready(function(){
}).addClass('clickable'); }).addClass('clickable');
var sselcont = $('#sc_container .basket_element:first'); var sselcont = $('#sc_container .basket_element:first');
if(sselcont.length > 0) if (sselcont.length > 0) {
{
display_basket_element(false, sselcont.attr('id').split('_').pop()); display_basket_element(false, sselcont.attr('id').split('_').pop());
} }
@@ -104,8 +98,7 @@ $(document).ready(function(){
$('#navigation') $('#navigation')
.bind('change', .bind('change',
function() function () {
{
window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/'); window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/');
} }
); );
@@ -113,8 +106,7 @@ $(document).ready(function(){
}); });
function bind_keyboard() function bind_keyboard() {
{
$(document).bind('keydown', function (event) { $(document).bind('keydown', function (event) {
var stop = false; var stop = false;
@@ -130,8 +122,7 @@ function bind_keyboard()
var el, id; var el, id;
switch(event.keyCode) switch (event.keyCode) {
{
case 39: case 39:
get_next(); get_next();
cancelKey = true; cancelKey = true;
@@ -146,16 +137,14 @@ function bind_keyboard()
break; break;
case 38: case 38:
el = $('#sc_container .basket_element.selected'); el = $('#sc_container .basket_element.selected');
if(el.length === 1) if (el.length === 1) {
{
id = el.attr('id').split('_').pop(); id = el.attr('id').split('_').pop();
set_agreement(event, el, id, 1); set_agreement(event, el, id, 1);
} }
break; break;
case 40: case 40:
el = $('#sc_container .basket_element.selected'); el = $('#sc_container .basket_element.selected');
if(el.length === 1) if (el.length === 1) {
{
id = el.attr('id').split('_').pop(); id = el.attr('id').split('_').pop();
set_agreement(event, el, id, -1); set_agreement(event, el, id, -1);
} }
@@ -164,8 +153,7 @@ function bind_keyboard()
break; break;
} }
if(cancelKey) if (cancelKey) {
{
event.cancelBubble = true; event.cancelBubble = true;
if (event.stopPropagation) if (event.stopPropagation)
event.stopPropagation(); event.stopPropagation();
@@ -175,8 +163,7 @@ function bind_keyboard()
}); });
} }
function set_release(el) function set_release(el) {
{
$('.loader', el).css({visibility: 'visible'}); $('.loader', el).css({visibility: 'visible'});
$.ajax({ $.ajax({
type: "POST", type: "POST",
@@ -192,12 +179,10 @@ function set_release(el)
$('.loader', el).css({ $('.loader', el).css({
visibility: 'hidden' visibility: 'hidden'
}); });
if(data.datas) if (data.datas) {
{
alert(data.datas); alert(data.datas);
} }
if(!data.error) if (!data.error) {
{
p4.releasable = false; p4.releasable = false;
} }
@@ -206,8 +191,7 @@ function set_release(el)
}); });
} }
function load_report() function load_report() {
{
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/", url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/",
@@ -225,8 +209,7 @@ function load_report()
} }
function set_sizeable(container) function set_sizeable(container) {
{
$(container).bind('mousewheel', function (event, delta) { $(container).bind('mousewheel', function (event, delta) {
@@ -243,8 +226,7 @@ function set_sizeable(container)
var o_width, o_height, width, height; var o_width, o_height, width, height;
if(delta > 0) if (delta > 0) {
{
if (record.width() > 29788 || record.height() >= 29788) if (record.width() > 29788 || record.height() >= 29788)
return; return;
o_width = record.width(); o_width = record.width();
@@ -252,8 +234,7 @@ function set_sizeable(container)
width = Math.round(o_width * 1.1); width = Math.round(o_width * 1.1);
height = Math.round(o_height * 1.1); height = Math.round(o_height * 1.1);
} }
else else {
{
if (record.width() < 30 || record.height() < 30) if (record.width() < 30 || record.height() < 30)
return; return;
o_width = record.width(); o_width = record.width();
@@ -271,9 +252,7 @@ function set_sizeable(container)
} }
function display_basket() {
function display_basket()
{
var sc_wrapper = $('#sc_wrapper'); var sc_wrapper = $('#sc_wrapper');
var basket_options = $('#basket_options'); var basket_options = $('#basket_options');
@@ -309,27 +288,12 @@ function display_basket()
} }
function display_basket_element(compare, sselcont_id) {
function display_basket_element(compare, sselcont_id)
{
var container; var container;
if(compare) if (compare) {
{
container = $('#record_compare'); container = $('#record_compare');
} }
else else {
{
container = $('#record_main'); container = $('#record_main');
} }
$('.record_image', container).removeAttr('ondragstart'); $('.record_image', container).removeAttr('ondragstart');
@@ -345,14 +309,11 @@ function display_basket_element(compare, sselcont_id)
$('.comment_button', options_container).button({ $('.comment_button', options_container).button({
text: true text: true
}).bind('click',function() }).bind('click', function () {
{ if ($('.lightbox_container', container).hasClass('note_editing')) {
if($('.lightbox_container', container).hasClass('note_editing'))
{
hide_notes(container); hide_notes(container);
} }
else else {
{
show_notes(container); show_notes(container);
} }
} }
@@ -378,12 +339,10 @@ function display_basket_element(compare, sselcont_id)
slideshow(false); slideshow(false);
}); });
if($(document).data('slideshow')) if ($(document).data('slideshow')) {
{
$('.play_button, .next_button.play, .previous_button.play', options_container).hide(); $('.play_button, .next_button.play, .previous_button.play', options_container).hide();
} }
else else {
{
$('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide(); $('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide();
} }
@@ -399,8 +358,7 @@ function display_basket_element(compare, sselcont_id)
$('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree') $('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree')
.bind('click', .bind('click',
function(event) function (event) {
{
set_agreement(event, $(this), sselcont_id, '1'); set_agreement(event, $(this), sselcont_id, '1');
} }
) )
@@ -408,23 +366,19 @@ function display_basket_element(compare, sselcont_id)
$('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree') $('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree')
.bind('click', .bind('click',
function(event) function (event) {
{
set_agreement(event, $(this), sselcont_id, '-1'); set_agreement(event, $(this), sselcont_id, '-1');
} }
) )
.addClass('clickable'); .addClass('clickable');
if(compare == $('#record_wrapper').hasClass('single')) if (compare == $('#record_wrapper').hasClass('single')) {
{ if (compare) {
if(compare)
{
$('#record_infos, #right_column').hide(); $('#record_infos, #right_column').hide();
$('#record_wrapper').stop().css({width: '100%'}); $('#record_wrapper').stop().css({width: '100%'});
display_record(compare); display_record(compare);
} }
else else {
{
$('#record_wrapper').css({ $('#record_wrapper').css({
width: ($('#innerWrapper').width() - $('#record_infos').outerWidth() - $('#right_column').outerWidth() - 2) width: ($('#innerWrapper').width() - $('#record_infos').outerWidth() - $('#right_column').outerWidth() - 2)
}); });
@@ -434,37 +388,31 @@ function display_basket_element(compare, sselcont_id)
} }
} }
else else {
{
display_record(compare); display_record(compare);
} }
} }
function set_container_status(status) function set_container_status(status) {
{
$('#record_wrapper').removeClass('paysage portrait single').addClass(status); $('#record_wrapper').removeClass('paysage portrait single').addClass(status);
} }
function show_notes(container) function show_notes(container) {
{
$('.notes_wrapper', container).animate({top: 0}); $('.notes_wrapper', container).animate({top: 0});
$('.lightbox_container', container).addClass('note_editing'); $('.lightbox_container', container).addClass('note_editing');
} }
function hide_notes(container) function hide_notes(container) {
{
$('.notes_wrapper', container).animate({top: '-100%'}); $('.notes_wrapper', container).animate({top: '-100%'});
$('.lightbox_container', container).removeClass('note_editing'); $('.lightbox_container', container).removeClass('note_editing');
} }
function activate_notes(container) function activate_notes(container) {
{
$('.note_closer', container).button({ $('.note_closer', container).button({
text: true text: true
}).bind('click',function() }).bind('click', function () {
{
// $(this).blur(); // $(this).blur();
hide_notes(container); hide_notes(container);
return false; return false;
@@ -473,8 +421,7 @@ function activate_notes(container)
$('.note_saver', container).button({ $('.note_saver', container).button({
text: true text: true
}).bind('click',function() }).bind('click', function () {
{
// $(this).blur(); // $(this).blur();
save_note(container, this); save_note(container, this);
return false; return false;
@@ -483,10 +430,7 @@ function activate_notes(container)
} }
function download(value) {
function download(value)
{
var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export'] : ''}); var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export'] : ''});
$.post("/prod/export/multi-export/", "lst=" + value, function (data) { $.post("/prod/export/multi-export/", "lst=" + value, function (data) {
@@ -504,8 +448,7 @@ function download(value)
} }
function display_record(compare) function display_record(compare) {
{
var main_container = $('#record_wrapper'); var main_container = $('#record_wrapper');
main_container.width($('#innerWrapper').innerWidth() - $('#right_column').outerWidth() - 2); main_container.width($('#innerWrapper').innerWidth() - $('#right_column').outerWidth() - 2);
@@ -530,8 +473,7 @@ function display_record(compare)
var main_container_innerheight = main_container.innerHeight(); var main_container_innerheight = main_container.innerHeight();
if(compare) if (compare) {
{
$('.agreement_selector').show(); $('.agreement_selector').show();
main_container.addClass('comparison'); main_container.addClass('comparison');
@@ -571,18 +513,15 @@ function display_record(compare)
var m_width_image, m_height_image, c_width_image, c_height_image, dim_container; var m_width_image, m_height_image, c_width_image, c_height_image, dim_container;
if(double_portrait_surface > double_paysage_surface) if (double_portrait_surface > double_paysage_surface) {
{ if (!main_container.hasClass('portrait')) {
if(!main_container.hasClass('portrait'))
{
smooth_image = true; smooth_image = true;
smooth_transform( smooth_transform(
main_box, main_box,
parseInt($('#innerWrapper').width() / 2 - 13), parseInt($('#innerWrapper').width() / 2 - 13),
$('#innerWrapper').height(), $('#innerWrapper').height(),
function() function () {
{
set_container_status('portrait'); set_container_status('portrait');
} }
); );
@@ -593,8 +532,7 @@ function display_record(compare)
compare_box, compare_box,
parseInt($('#innerWrapper').width() / 2 - 13), parseInt($('#innerWrapper').width() / 2 - 13),
$('#innerWrapper').height(), $('#innerWrapper').height(),
function() function () {
{
compare_box.css('display', 'none') compare_box.css('display', 'none')
.css('visibility', 'visible').show(); .css('visibility', 'visible').show();
} }
@@ -606,18 +544,15 @@ function display_record(compare)
c_height_image = compare_display_portrait.height; c_height_image = compare_display_portrait.height;
dim_container = {width: double_portrait_width, height: double_portrait_height}; dim_container = {width: double_portrait_width, height: double_portrait_height};
} }
else else {
{ if (!main_container.hasClass('paysage')) {
if(!main_container.hasClass('paysage'))
{
smooth_image = true; smooth_image = true;
smooth_transform( smooth_transform(
main_box, main_box,
$('#innerWrapper').width(), $('#innerWrapper').width(),
parseInt($('#innerWrapper').height() / 2), parseInt($('#innerWrapper').height() / 2),
function() function () {
{
set_container_status('paysage'); set_container_status('paysage');
} }
); );
@@ -628,8 +563,7 @@ function display_record(compare)
compare_box, compare_box,
$('#innerWrapper').width(), $('#innerWrapper').width(),
parseInt($('#innerWrapper').height() / 2), parseInt($('#innerWrapper').height() / 2),
function() function () {
{
compare_box.css('display', 'none') compare_box.css('display', 'none')
.css('visibility', 'visible') .css('visibility', 'visible')
.show(); .show();
@@ -643,16 +577,15 @@ function display_record(compare)
dim_container = {width: double_paysage_width, height: double_paysage_height}; dim_container = {width: double_paysage_width, height: double_paysage_height};
} }
var image_callback = set_image_position(false, compare_record, c_width_image, c_height_image, dim_container, function(){}); var image_callback = set_image_position(false, compare_record, c_width_image, c_height_image, dim_container, function () {
});
set_image_position(smooth_image, main_record, m_width_image, m_height_image, dim_container, image_callback); set_image_position(smooth_image, main_record, m_width_image, m_height_image, dim_container, image_callback);
} }
else else {
{
$('.agreement_selector').hide(); $('.agreement_selector').hide();
main_container.removeClass('comparison'); main_container.removeClass('comparison');
if(compare_box.is(':visible')) if (compare_box.is(':visible')) {
{
compare_box.hide().css('visibility', 'hidden').css('display', 'block'); compare_box.hide().css('visibility', 'hidden').css('display', 'block');
} }
@@ -663,8 +596,7 @@ function display_record(compare)
, main_record_height , main_record_height
); );
if(!main_container.hasClass('single')) if (!main_container.hasClass('single')) {
{
main_box.width('100%') main_box.width('100%')
.height('100%'); .height('100%');
@@ -677,16 +609,14 @@ function display_record(compare)
, main_display.width , main_display.width
, main_display.height , main_display.height
, { , {
width : main_container_width width: main_container_width, height: (main_container_height - $('.header', main_box).outerHeight())
,height : (main_container_height - $('.header', main_box).outerHeight())
} }
); );
} }
} }
function set_agreement(event, el, sselcont_id, boolean_value) function set_agreement(event, el, sselcont_id, boolean_value) {
{
if (event.stopPropagation) if (event.stopPropagation)
event.stopPropagation(); event.stopPropagation();
event.cancelBubble = true; event.cancelBubble = true;
@@ -701,29 +631,24 @@ function set_agreement(event, el, sselcont_id, boolean_value)
agreement: boolean_value agreement: boolean_value
}, },
success: function (datas) { success: function (datas) {
if(!datas.error) if (!datas.error) {
{ if (boolean_value == '1') {
if(boolean_value == '1')
{
$('.agree_' + sselcont_id + '').removeClass('not_decided'); $('.agree_' + sselcont_id + '').removeClass('not_decided');
$('.disagree_' + sselcont_id + '').addClass('not_decided'); $('.disagree_' + sselcont_id + '').addClass('not_decided');
$('.userchoice.me').addClass('agree').removeClass('disagree'); $('.userchoice.me').addClass('agree').removeClass('disagree');
} }
else else {
{
$('.agree_' + sselcont_id + '').addClass('not_decided'); $('.agree_' + sselcont_id + '').addClass('not_decided');
$('.disagree_' + sselcont_id + '').removeClass('not_decided'); $('.disagree_' + sselcont_id + '').removeClass('not_decided');
$('.userchoice.me').addClass('disagree').removeClass('agree'); $('.userchoice.me').addClass('disagree').removeClass('agree');
} }
p4.releasable = datas.releasable; p4.releasable = datas.releasable;
if(datas.releasable !== false) if (datas.releasable !== false) {
{
if (confirm(datas.releasable)) if (confirm(datas.releasable))
$('#basket_options .confirm_report').trigger('click'); $('#basket_options .confirm_report').trigger('click');
} }
} }
else else {
{
alert(datas.datas); alert(datas.datas);
} }
return; return;
@@ -732,9 +657,7 @@ function set_agreement(event, el, sselcont_id, boolean_value)
} }
function get_next() {
function get_next()
{
var current_wrapper = $('#sc_container .basket_element.selected').parent(); var current_wrapper = $('#sc_container .basket_element.selected').parent();
if (current_wrapper.length === 0) if (current_wrapper.length === 0)
@@ -748,15 +671,13 @@ function get_next()
adjust_visibility($('.basket_element', current_wrapper)); adjust_visibility($('.basket_element', current_wrapper));
if($(document).data('slideshow')) if ($(document).data('slideshow')) {
{
var timer = setTimeout('get_next();', 3500); var timer = setTimeout('get_next();', 3500);
$(document).data('slideshow_ctime', timer); $(document).data('slideshow_ctime', timer);
} }
} }
function get_prev() function get_prev() {
{
var current_wrapper = $('#sc_container .basket_element.selected').parent(); var current_wrapper = $('#sc_container .basket_element.selected').parent();
if (current_wrapper.length === 0) if (current_wrapper.length === 0)
@@ -772,8 +693,7 @@ function get_prev()
adjust_visibility($('.basket_element', current_wrapper)); adjust_visibility($('.basket_element', current_wrapper));
} }
function is_viewable(el) function is_viewable(el) {
{
var sc_wrapper = $('#sc_wrapper'); var sc_wrapper = $('#sc_wrapper');
var sc_container = $('#sc_container'); var sc_container = $('#sc_container');
@@ -791,8 +711,7 @@ function is_viewable(el)
return false; return false;
} }
function adjust_visibility(el) function adjust_visibility(el) {
{
if (is_viewable(el)) if (is_viewable(el))
return; return;
@@ -805,13 +724,11 @@ function adjust_visibility(el)
} }
function slideshow(boolean_value) function slideshow(boolean_value) {
{
if (boolean_value == $(document).data('slideshow')) if (boolean_value == $(document).data('slideshow'))
return; return;
if(!boolean_value && $(document).data('slideshow_ctime')) if (!boolean_value && $(document).data('slideshow_ctime')) {
{
clearTimeout($(document).data('slideshow_ctime')); clearTimeout($(document).data('slideshow_ctime'));
$(document).data('slideshow_ctime', false); $(document).data('slideshow_ctime', false);
} }
@@ -820,24 +737,22 @@ function slideshow(boolean_value)
var headers = $('#record_wrapper .header'); var headers = $('#record_wrapper .header');
if(boolean_value) if (boolean_value) {
{
$('.play_button, .next_button.play, .previous_button.play').hide(); $('.play_button, .next_button.play, .previous_button.play').hide();
$('.pause_button, .next_button.pause, .previous_button.pause').show(); $('.pause_button, .next_button.pause, .previous_button.pause').show();
get_next(); get_next();
} }
else else {
{
$('.pause_button, .next_button.pause, .previous_button.pause').hide(); $('.pause_button, .next_button.pause, .previous_button.pause').hide();
$('.play_button, .next_button.play, .previous_button.play').show(); $('.play_button, .next_button.play, .previous_button.play').show();
} }
} }
function smooth_transform(box, width, height, callback) function smooth_transform(box, width, height, callback) {
{
if (typeof callback == 'undefined') if (typeof callback == 'undefined')
callback = function(){}; callback = function () {
};
$(box).stop() $(box).stop()
.css( .css(
@@ -852,8 +767,7 @@ function smooth_transform(box, width, height, callback)
callback(); callback();
} }
function save_note(container, button) function save_note(container, button) {
{
var sselcont_id = $(button).attr('id').split('_').pop(); var sselcont_id = $(button).attr('id').split('_').pop();
var note = $('.notes_wrapper textarea', container).val(); var note = $('.notes_wrapper textarea', container).val();
@@ -874,8 +788,7 @@ function save_note(container, button)
}); });
} }
function calculate_display(display_width, display_height, width, height, margin) function calculate_display(display_width, display_height, width, height, margin) {
{
if (typeof margin == 'undefined') if (typeof margin == 'undefined')
margin = 10; margin = 10;
@@ -890,8 +803,7 @@ function calculate_display(display_width, display_height, width, height, margin)
w = width; w = width;
h = w / ratio; h = w / ratio;
} }
else else {
{
h = display_height - 2 * margin; h = display_height - 2 * margin;
if (h > height) if (h > height)
h = height; h = height;
@@ -902,21 +814,19 @@ function calculate_display(display_width, display_height, width, height, margin)
} }
function set_image_position(smooth, image, width, height, container, callback) function set_image_position(smooth, image, width, height, container, callback) {
{
var dimensions = {}; var dimensions = {};
if(typeof container !== 'undefined') if (typeof container !== 'undefined') {
{
var c_width = container.width; var c_width = container.width;
var c_height = container.height; var c_height = container.height;
dimensions.top = parseInt((c_height - height) / 2); dimensions.top = parseInt((c_height - height) / 2);
dimensions.left = parseInt((c_width - width) / 2); dimensions.left = parseInt((c_width - width) / 2);
} }
if(typeof callback == 'undefined') if (typeof callback == 'undefined') {
{ callback = function () {
callback = function(){}; };
} }
} }
@@ -934,17 +844,14 @@ callback;
} }
function scid_click(event, el) function scid_click(event, el) {
{
var compare = is_ctrl_key(event); var compare = is_ctrl_key(event);
if(compare) if (compare) {
{
if ($('.basket_element', el).hasClass('selected')) if ($('.basket_element', el).hasClass('selected'))
return; return;
} }
else else {
{
$('#sc_container .basket_element.selected').removeClass('selected'); $('#sc_container .basket_element.selected').removeClass('selected');
$('.basket_element', el).addClass('selected'); $('.basket_element', el).addClass('selected');
} }
@@ -955,8 +862,7 @@ function scid_click(event, el)
var container = $('#sc_container'); var container = $('#sc_container');
var request = container.data('request'); var request = container.data('request');
if(request && typeof(request.abort) == 'function') if (request && typeof(request.abort) == 'function') {
{
request.abort(); request.abort();
} }
@@ -967,12 +873,10 @@ function scid_click(event, el)
success: function (data) { success: function (data) {
var container = false; var container = false;
if(compare) if (compare) {
{
container = $('#record_compare'); container = $('#record_compare');
} }
else else {
{
container = $('#record_main'); container = $('#record_main');
$('#record_infos .lightbox_container') $('#record_infos .lightbox_container')
@@ -1012,17 +916,14 @@ function scid_click(event, el)
} }
function download_basket() {
function download_basket()
{
var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) { var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) {
return $('input[name="basrec"]', $(el)).val(); return $('input[name="basrec"]', $(el)).val();
}); });
download(ids.join(';')); download(ids.join(';'));
} }
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)
@@ -1039,8 +940,7 @@ function is_ctrl_key(event)
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

@@ -38,19 +38,16 @@ $(document).ready(function(){
$('.basket_downloader').bind('click', function () { $('.basket_downloader').bind('click', function () {
download_basket(); download_basket();
}); });
if($('.right_column_wrapper_user').length > 0) if ($('.right_column_wrapper_user').length > 0) {
{
$('.right_column_title, #right_column_validation_toggle').bind('click',function () { $('.right_column_title, #right_column_validation_toggle').bind('click',function () {
if(!$('.right_column_wrapper_caption').is(':visible')) if (!$('.right_column_wrapper_caption').is(':visible')) {
{
$('.right_column_wrapper_user').height($('.right_column_wrapper_user').height()).css('top', 'auto').animate({ $('.right_column_wrapper_user').height($('.right_column_wrapper_user').height()).css('top', 'auto').animate({
'height': 0 'height': 0
}); });
$('.right_column_wrapper_caption').slideDown(); $('.right_column_wrapper_caption').slideDown();
$('#right_column_validation_toggle').show(); $('#right_column_validation_toggle').show();
} }
else else {
{
$('.right_column_wrapper_user').height('auto').animate({ $('.right_column_wrapper_user').height('auto').animate({
'top': $('.right_column_title').height() 'top': $('.right_column_title').height()
}); });
@@ -62,8 +59,7 @@ $(document).ready(function(){
}).addClass('clickable'); }).addClass('clickable');
} }
var sselcont = $('#sc_container .basket_element:first'); var sselcont = $('#sc_container .basket_element:first');
if(sselcont.length > 0) if (sselcont.length > 0) {
{
display_basket_element(false, sselcont.attr('id').split('_').pop()); display_basket_element(false, sselcont.attr('id').split('_').pop());
} }
@@ -72,30 +68,26 @@ $(document).ready(function(){
$('#navigation') $('#navigation')
.bind('change', .bind('change',
function() function () {
{
window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/'); window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/');
} }
); );
$('#left_scroller') $('#left_scroller')
.bind('click', .bind('click',
function() function () {
{
scroll_elements(false); scroll_elements(false);
} }
); );
$('#right_scroller') $('#right_scroller')
.bind('click', function() .bind('click', function () {
{
scroll_elements(true); scroll_elements(true);
} }
); );
$(window) $(window)
.bind('resize',function() .bind('resize', function () {
{
resize(); resize();
} }
); );
@@ -103,17 +95,14 @@ $(document).ready(function(){
}); });
$(window).bind('beforeunload', function () { $(window).bind('beforeunload', function () {
if(p4.releasable !== false) if (p4.releasable !== false) {
{ if (confirm(p4.releasable)) {
if(confirm(p4.releasable))
{
$('#basket_options .confirm_report').trigger('click'); $('#basket_options .confirm_report').trigger('click');
} }
} }
}); });
function bind_keyboard() function bind_keyboard() {
{
$(document).bind('keydown', function (event) { $(document).bind('keydown', function (event) {
var stop = false; var stop = false;
@@ -127,8 +116,7 @@ function bind_keyboard()
var cancelKey = false; var cancelKey = false;
var el, id; var el, id;
switch(event.keyCode) switch (event.keyCode) {
{
case 39: case 39:
get_next(); get_next();
cancelKey = true; cancelKey = true;
@@ -143,16 +131,14 @@ function bind_keyboard()
break; break;
case 38: case 38:
el = $('#sc_container .basket_element.selected'); el = $('#sc_container .basket_element.selected');
if(el.length === 1) if (el.length === 1) {
{
id = el.attr('id').split('_').pop(); id = el.attr('id').split('_').pop();
set_agreement(event, el, id, 1); set_agreement(event, el, id, 1);
} }
break; break;
case 40: case 40:
el = $('#sc_container .basket_element.selected'); el = $('#sc_container .basket_element.selected');
if(el.length === 1) if (el.length === 1) {
{
id = el.attr('id').split('_').pop(); id = el.attr('id').split('_').pop();
set_agreement(event, el, id, -1); set_agreement(event, el, id, -1);
} }
@@ -161,8 +147,7 @@ function bind_keyboard()
break; break;
} }
if(cancelKey) if (cancelKey) {
{
event.cancelBubble = true; event.cancelBubble = true;
if (event.stopPropagation) if (event.stopPropagation)
event.stopPropagation(); event.stopPropagation();
@@ -172,8 +157,7 @@ function bind_keyboard()
}); });
} }
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)
@@ -190,22 +174,19 @@ function is_ctrl_key(event)
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;
} }
function resize() function resize() {
{
bodySize.y = $('#mainContainer').height(); bodySize.y = $('#mainContainer').height();
bodySize.x = $('#mainContainer').width(); bodySize.x = $('#mainContainer').width();
display_record($('#record_compare').css('visibility') != 'hidden'); display_record($('#record_compare').css('visibility') != 'hidden');
} }
function set_release(el) function set_release(el) {
{
$('.loader', el).css({ $('.loader', el).css({
visibility: 'visible' visibility: 'visible'
}); });
@@ -227,12 +208,10 @@ function set_release(el)
$('.loader', el).css({ $('.loader', el).css({
visibility: 'hidden' visibility: 'hidden'
}); });
if(data.datas) if (data.datas) {
{
alert(data.datas); alert(data.datas);
} }
if(!data.error) if (!data.error) {
{
p4.releasable = false; p4.releasable = false;
} }
@@ -241,8 +220,7 @@ function set_release(el)
}); });
} }
function load_report() function load_report() {
{
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/", url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/",
@@ -264,8 +242,7 @@ function load_report()
}); });
} }
function display_basket() function display_basket() {
{
var sc_wrapper = $('#sc_wrapper'); var sc_wrapper = $('#sc_wrapper');
var basket_options = $('#basket_options'); var basket_options = $('#basket_options');
@@ -308,17 +285,14 @@ function display_basket()
} }
function scid_click(event, el) function scid_click(event, el) {
{
var compare = is_ctrl_key(event); var compare = is_ctrl_key(event);
if(compare) if (compare) {
{
if ($('.basket_element', el).hasClass('selected')) if ($('.basket_element', el).hasClass('selected'))
return; return;
} }
else else {
{
$('#sc_container .basket_element.selected').removeClass('selected'); $('#sc_container .basket_element.selected').removeClass('selected');
$('.basket_element', el).addClass('selected'); $('.basket_element', el).addClass('selected');
} }
@@ -329,8 +303,7 @@ function scid_click(event, el)
var container = $('#sc_container'); var container = $('#sc_container');
var request = container.data('request'); var request = container.data('request');
if(request && typeof(request.abort) == 'function') if (request && typeof(request.abort) == 'function') {
{
request.abort(); request.abort();
} }
@@ -342,12 +315,10 @@ function scid_click(event, el)
var container = false; var container = false;
var data = datas; var data = datas;
if(compare) if (compare) {
{
container = $('#record_compare'); container = $('#record_compare');
} }
else else {
{
container = $('#record_main'); container = $('#record_main');
$('#record_infos .lightbox_container') $('#record_infos .lightbox_container')
@@ -386,8 +357,7 @@ function scid_click(event, el)
container.data('request', request); container.data('request', request);
} }
function save_note(container, button) function save_note(container, button) {
{
var sselcont_id = $(button).attr('id').split('_').pop(); var sselcont_id = $(button).attr('id').split('_').pop();
var note = $('.notes_wrapper textarea', container).val(); var note = $('.notes_wrapper textarea', container).val();
@@ -409,15 +379,12 @@ function save_note(container, button)
} }
function display_basket_element(compare, sselcont_id) function display_basket_element(compare, sselcont_id) {
{
var container; var container;
if(compare) if (compare) {
{
container = $('#record_compare'); container = $('#record_compare');
} }
else else {
{
container = $('#record_main'); container = $('#record_main');
} }
$('.record_image', container).removeAttr('ondragstart'); $('.record_image', container).removeAttr('ondragstart');
@@ -430,15 +397,12 @@ function display_basket_element(compare, sselcont_id)
download($(this).next('form[name=download_form]').find('input').val()); download($(this).next('form[name=download_form]').find('input').val());
}); });
$('.comment_button', options_container).bind('click',function() $('.comment_button', options_container).bind('click', function () {
{
// $(this).blur(); // $(this).blur();
if($('.lightbox_container', container).hasClass('note_editing')) if ($('.lightbox_container', container).hasClass('note_editing')) {
{
hide_notes(container); hide_notes(container);
} }
else else {
{
show_notes(container); show_notes(container);
} }
} }
@@ -461,12 +425,10 @@ function display_basket_element(compare, sselcont_id)
slideshow(false); slideshow(false);
}); });
if($(document).data('slideshow')) if ($(document).data('slideshow')) {
{
$('.play_button, .next_button.play, .previous_button.play', options_container).hide(); $('.play_button, .next_button.play, .previous_button.play', options_container).hide();
} }
else else {
{
$('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide(); $('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide();
} }
@@ -484,8 +446,7 @@ function display_basket_element(compare, sselcont_id)
$('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree') $('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree')
.bind('click', .bind('click',
function(event) function (event) {
{
set_agreement(event, $(this), sselcont_id, '1'); set_agreement(event, $(this), sselcont_id, '1');
} }
) )
@@ -493,17 +454,14 @@ function display_basket_element(compare, sselcont_id)
$('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree') $('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree')
.bind('click', .bind('click',
function(event) function (event) {
{
set_agreement(event, $(this), sselcont_id, '-1'); set_agreement(event, $(this), sselcont_id, '-1');
} }
) )
.addClass('clickable'); .addClass('clickable');
if(compare == $('#record_wrapper').hasClass('single')) if (compare == $('#record_wrapper').hasClass('single')) {
{ if (compare) {
if(compare)
{
// $('.agreement_selector').show(); // $('.agreement_selector').show();
// $('#record_wrapper').stop().animate({right:0},100,function(){display_record(compare);}); // $('#record_wrapper').stop().animate({right:0},100,function(){display_record(compare);});
$('#record_wrapper').css({ $('#record_wrapper').css({
@@ -512,8 +470,7 @@ function display_basket_element(compare, sselcont_id)
display_record(compare); display_record(compare);
$('#right_column').hide(); $('#right_column').hide();
} }
else else {
{
// $('.agreement_selector').hide(); // $('.agreement_selector').hide();
$('#record_wrapper').css({ $('#record_wrapper').css({
right: 250 right: 250
@@ -524,35 +481,30 @@ function display_basket_element(compare, sselcont_id)
} }
} }
else else {
{
display_record(compare); display_record(compare);
} }
} }
function show_notes(container) function show_notes(container) {
{
$('.notes_wrapper', container).animate({ $('.notes_wrapper', container).animate({
top: 0 top: 0
}); });
$('.lightbox_container', container).addClass('note_editing'); $('.lightbox_container', container).addClass('note_editing');
} }
function hide_notes(container) function hide_notes(container) {
{
$('.notes_wrapper', container).animate({ $('.notes_wrapper', container).animate({
top: '-100%' top: '-100%'
}); });
$('.lightbox_container', container).removeClass('note_editing'); $('.lightbox_container', container).removeClass('note_editing');
} }
function activate_notes(container) function activate_notes(container) {
{
$('.note_closer', container).button({ $('.note_closer', container).button({
text: true text: true
}).bind('click',function() }).bind('click', function () {
{
$(this).blur(); $(this).blur();
hide_notes(container); hide_notes(container);
return false; return false;
@@ -561,8 +513,7 @@ function activate_notes(container)
$('.note_saver', container).button({ $('.note_saver', container).button({
text: true text: true
}).bind('click',function() }).bind('click', function () {
{
$(this).blur(); $(this).blur();
save_note(container, this); save_note(container, this);
return false; return false;
@@ -570,8 +521,7 @@ function activate_notes(container)
); );
} }
function is_viewable(el) function is_viewable(el) {
{
var sc_wrapper = $('#sc_wrapper'); var sc_wrapper = $('#sc_wrapper');
var sc_container = $('#sc_container'); var sc_container = $('#sc_container');
@@ -589,8 +539,7 @@ function is_viewable(el)
return false; return false;
} }
function adjust_visibility(el) function adjust_visibility(el) {
{
if (is_viewable(el)) if (is_viewable(el))
return; return;
@@ -604,8 +553,7 @@ function adjust_visibility(el)
}); });
} }
function get_next() function get_next() {
{
var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); var current_wrapper = $('#sc_container .basket_element.selected').parent().parent();
if (current_wrapper.length === 0) if (current_wrapper.length === 0)
@@ -619,15 +567,13 @@ function get_next()
adjust_visibility($('.basket_element', current_wrapper)); adjust_visibility($('.basket_element', current_wrapper));
if($(document).data('slideshow')) if ($(document).data('slideshow')) {
{
var timer = setTimeout('get_next();', 3500); var timer = setTimeout('get_next();', 3500);
$(document).data('slideshow_ctime', timer); $(document).data('slideshow_ctime', timer);
} }
} }
function get_prev() function get_prev() {
{
var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); var current_wrapper = $('#sc_container .basket_element.selected').parent().parent();
if (current_wrapper.length === 0) if (current_wrapper.length === 0)
@@ -644,13 +590,11 @@ function get_prev()
adjust_visibility($('.basket_element', current_wrapper)); adjust_visibility($('.basket_element', current_wrapper));
} }
function slideshow(boolean_value) function slideshow(boolean_value) {
{
if (boolean_value == $(document).data('slideshow')) if (boolean_value == $(document).data('slideshow'))
return; return;
if(!boolean_value && $(document).data('slideshow_ctime')) if (!boolean_value && $(document).data('slideshow_ctime')) {
{
clearTimeout($(document).data('slideshow_ctime')); clearTimeout($(document).data('slideshow_ctime'));
$(document).data('slideshow_ctime', false); $(document).data('slideshow_ctime', false);
} }
@@ -659,21 +603,18 @@ function slideshow(boolean_value)
var headers = $('#record_wrapper .header'); var headers = $('#record_wrapper .header');
if(boolean_value) if (boolean_value) {
{
$('.play_button, .next_button.play, .previous_button.play', headers).hide(); $('.play_button, .next_button.play, .previous_button.play', headers).hide();
$('.pause_button, .next_button.pause, .previous_button.pause', headers).show(); $('.pause_button, .next_button.pause, .previous_button.pause', headers).show();
get_next(); get_next();
} }
else else {
{
$('.pause_button, .next_button.pause, .previous_button.pause', headers).hide(); $('.pause_button, .next_button.pause, .previous_button.pause', headers).hide();
$('.play_button, .next_button.play, .previous_button.play', headers).show(); $('.play_button, .next_button.play, .previous_button.play', headers).show();
} }
} }
function set_sizeable(container) function set_sizeable(container) {
{
$(container).bind('mousewheel', function (event, delta) { $(container).bind('mousewheel', function (event, delta) {
@@ -690,8 +631,7 @@ function set_sizeable(container)
var o_width, o_height, width, height; var o_width, o_height, width, height;
if(delta > 0) if (delta > 0) {
{
if (record.width() > 29788 || record.height() >= 29788) if (record.width() > 29788 || record.height() >= 29788)
return; return;
o_width = record.width(); o_width = record.width();
@@ -699,8 +639,7 @@ function set_sizeable(container)
width = Math.round(o_width * 1.1); width = Math.round(o_width * 1.1);
height = Math.round(o_height * 1.1); height = Math.round(o_height * 1.1);
} }
else else {
{
if (record.width() < 30 || record.height() < 30) if (record.width() < 30 || record.height() < 30)
return; return;
o_width = record.width(); o_width = record.width();
@@ -720,8 +659,7 @@ function set_sizeable(container)
} }
function set_agreement(event, el, sselcont_id, boolean_value) function set_agreement(event, el, sselcont_id, boolean_value) {
{
if (event.stopPropagation) if (event.stopPropagation)
event.stopPropagation(); event.stopPropagation();
event.cancelBubble = true; event.cancelBubble = true;
@@ -736,29 +674,24 @@ function set_agreement(event, el, sselcont_id, boolean_value)
agreement: boolean_value agreement: boolean_value
}, },
success: function (datas) { success: function (datas) {
if(!datas.error) if (!datas.error) {
{ if (boolean_value == '1') {
if(boolean_value == '1')
{
$('.agree_' + sselcont_id + '').removeClass('not_decided'); $('.agree_' + sselcont_id + '').removeClass('not_decided');
$('.disagree_' + sselcont_id + '').addClass('not_decided'); $('.disagree_' + sselcont_id + '').addClass('not_decided');
$('.userchoice.me').addClass('agree').removeClass('disagree'); $('.userchoice.me').addClass('agree').removeClass('disagree');
} }
else else {
{
$('.agree_' + sselcont_id + '').addClass('not_decided'); $('.agree_' + sselcont_id + '').addClass('not_decided');
$('.disagree_' + sselcont_id + '').removeClass('not_decided'); $('.disagree_' + sselcont_id + '').removeClass('not_decided');
$('.userchoice.me').addClass('disagree').removeClass('agree'); $('.userchoice.me').addClass('disagree').removeClass('agree');
} }
p4.releasable = datas.releasable; p4.releasable = datas.releasable;
if(datas.releasable !== false) if (datas.releasable !== false) {
{
if (confirm(datas.releasable)) if (confirm(datas.releasable))
$('#basket_options .confirm_report').trigger('click'); $('#basket_options .confirm_report').trigger('click');
} }
} }
else else {
{
alert(datas.datas); alert(datas.datas);
} }
return; return;
@@ -767,8 +700,7 @@ function set_agreement(event, el, sselcont_id, boolean_value)
} }
function calculate_display(display_width, display_height, width, height, margin) function calculate_display(display_width, display_height, width, height, margin) {
{
if (typeof margin == 'undefined') if (typeof margin == 'undefined')
margin = 10; margin = 10;
@@ -783,8 +715,7 @@ function calculate_display(display_width, display_height, width, height, margin)
w = width; w = width;
h = w / ratio; h = w / ratio;
} }
else else {
{
h = display_height - 2 * margin; h = display_height - 2 * margin;
if (h > height) if (h > height)
h = height; h = height;
@@ -798,8 +729,7 @@ function calculate_display(display_width, display_height, width, height, margin)
} }
function display_record(compare) function display_record(compare) {
{
var main_container = $('#record_wrapper'); var main_container = $('#record_wrapper');
if (typeof compare == 'undefined') if (typeof compare == 'undefined')
@@ -821,8 +751,7 @@ function display_record(compare)
var main_container_height = main_container.height(); var main_container_height = main_container.height();
var main_container_innerheight = main_container.innerHeight(); var main_container_innerheight = main_container.innerHeight();
if(compare) if (compare) {
{
$('.agreement_selector').show(); $('.agreement_selector').show();
main_container.addClass('comparison'); main_container.addClass('comparison');
@@ -862,18 +791,15 @@ function display_record(compare)
var m_width_image, m_height_image, c_width_image, c_height_image, dim_container; var m_width_image, m_height_image, c_width_image, c_height_image, dim_container;
if(double_portrait_surface > double_paysage_surface) if (double_portrait_surface > double_paysage_surface) {
{ if (!main_container.hasClass('portrait')) {
if(!main_container.hasClass('portrait'))
{
smooth_image = true; smooth_image = true;
smooth_transform( smooth_transform(
main_box, main_box,
'50%', '50%',
'100%', '100%',
function() function () {
{
set_container_status('portrait'); set_container_status('portrait');
} }
); );
@@ -884,8 +810,7 @@ function display_record(compare)
compare_box, compare_box,
'50%', '50%',
'100%', '100%',
function() function () {
{
compare_box.css('display', 'none') compare_box.css('display', 'none')
.css('visibility', 'visible') .css('visibility', 'visible')
.fadeIn(); .fadeIn();
@@ -901,18 +826,15 @@ function display_record(compare)
height: double_portrait_height height: double_portrait_height
}; };
} }
else else {
{ if (!main_container.hasClass('paysage')) {
if(!main_container.hasClass('paysage'))
{
smooth_image = true; smooth_image = true;
smooth_transform( smooth_transform(
main_box, main_box,
'100%', '100%',
'50%', '50%',
function() function () {
{
set_container_status('paysage'); set_container_status('paysage');
} }
); );
@@ -923,8 +845,7 @@ function display_record(compare)
compare_box, compare_box,
'100%', '100%',
'50%', '50%',
function() function () {
{
compare_box.css('display', 'none') compare_box.css('display', 'none')
.css('visibility', 'visible') .css('visibility', 'visible')
.fadeIn(); .fadeIn();
@@ -941,16 +862,15 @@ function display_record(compare)
}; };
} }
var image_callback = set_image_position(false, compare_record, c_width_image, c_height_image, dim_container, function(){}); var image_callback = set_image_position(false, compare_record, c_width_image, c_height_image, dim_container, function () {
});
set_image_position(smooth_image, main_record, m_width_image, m_height_image, dim_container, image_callback); set_image_position(smooth_image, main_record, m_width_image, m_height_image, dim_container, image_callback);
} }
else else {
{
$('.agreement_selector').hide(); $('.agreement_selector').hide();
main_container.removeClass('comparison'); main_container.removeClass('comparison');
if(compare_box.is(':visible')) if (compare_box.is(':visible')) {
{
compare_box.hide().css('visibility', 'hidden').css('display', 'block'); compare_box.hide().css('visibility', 'hidden').css('display', 'block');
} }
@@ -959,8 +879,7 @@ function display_record(compare)
main_record_width, main_record_height main_record_width, main_record_height
); );
if(!main_container.hasClass('single')) if (!main_container.hasClass('single')) {
{
main_box.width('100%') main_box.width('100%')
.height('100%'); .height('100%');
@@ -973,46 +892,41 @@ function display_record(compare)
} }
} }
function set_container_status(status) function set_container_status(status) {
{
$('#record_wrapper').removeClass('paysage portrait single').addClass(status); $('#record_wrapper').removeClass('paysage portrait single').addClass(status);
} }
function set_image_position(smooth, image, width, height, container, callback) function set_image_position(smooth, image, width, height, container, callback) {
{
var dimensions = {}; var dimensions = {};
if(typeof container !== 'undefined') if (typeof container !== 'undefined') {
{
var c_width = container.width; var c_width = container.width;
var c_height = container.height; var c_height = container.height;
dimensions.top = parseInt((c_height - height) / 2); dimensions.top = parseInt((c_height - height) / 2);
dimensions.left = parseInt((c_width - width) / 2); dimensions.left = parseInt((c_width - width) / 2);
} }
if(typeof callback == 'undefined') if (typeof callback == 'undefined') {
{ callback = function () {
callback = function(){}; };
} }
dimensions.width = width; dimensions.width = width;
dimensions.height = height; dimensions.height = height;
if(smooth) if (smooth) {
{
$(image).stop().animate(dimensions, 500, callback); $(image).stop().animate(dimensions, 500, callback);
} }
else else {
{
$(image).css(dimensions); $(image).css(dimensions);
callback(); callback();
} }
} }
function smooth_transform(box, width, height, callback) function smooth_transform(box, width, height, callback) {
{
if (typeof callback == 'undefined') if (typeof callback == 'undefined')
callback = function(){}; callback = function () {
};
$(box).stop() $(box).stop()
.animate( .animate(
@@ -1026,8 +940,7 @@ function smooth_transform(box, width, height, callback)
} }
function scroll_elements(boolean_value) function scroll_elements(boolean_value) {
{
var sc_wrapper = $('#sc_wrapper'); var sc_wrapper = $('#sc_wrapper');
var value; var value;
if (boolean_value) if (boolean_value)
@@ -1041,16 +954,14 @@ function scroll_elements(boolean_value)
return; return;
} }
function download_basket() function download_basket() {
{
var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) { var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) {
return $('input[name="basrec"]', $(el)).val(); return $('input[name="basrec"]', $(el)).val();
}); });
download(ids.join(';')); download(ids.join(';'));
} }
function download(value) function download(value) {
{
var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export'] : ''}); var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export'] : ''});
$.post("/prod/export/multi-export/", "lst=" + value, function (data) { $.post("/prod/export/multi-export/", "lst=" + value, function (data) {

View File

@@ -3,7 +3,6 @@ $(document).ready(function(){
return; return;
$('.confirm_report').live('click', function () { $('.confirm_report').live('click', function () {
var $this = $(this); var $this = $(this);
@@ -63,23 +62,20 @@ $(document).ready(function(){
$.mobile.loading(); $.mobile.loading();
}, },
success: function (datas) { success: function (datas) {
if(!datas.error) if (!datas.error) {
{
if (agreement == '1') if (agreement == '1')
$('.valid_choice_' + sselcont_id).removeClass('disagree').addClass('agree'); $('.valid_choice_' + sselcont_id).removeClass('disagree').addClass('agree');
else else
$('.valid_choice_' + sselcont_id).removeClass('agree').addClass('disagree'); $('.valid_choice_' + sselcont_id).removeClass('agree').addClass('disagree');
$.mobile.loading(); $.mobile.loading();
if(datas.error) if (datas.error) {
{
alert(datas.datas); alert(datas.datas);
return; return;
} }
releasable = datas.release; releasable = datas.release;
} }
else else {
{
alert(datas.datas); alert(datas.datas);
} }
return; return;
@@ -109,8 +105,7 @@ $(document).ready(function(){
}, },
success: function (datas) { success: function (datas) {
$.mobile.loading(); $.mobile.loading();
if(datas.error) if (datas.error) {
{
alert(datas.datas); alert(datas.datas);
return; return;
} }

View File

@@ -33,8 +33,7 @@
}, },
getContext2d: function () { getContext2d: function () {
if (undefined === this.domCanva.getContext) if (undefined === this.domCanva.getContext) {
{
return G_vmlCanvasManager return G_vmlCanvasManager
.initElement(this.domCanva) .initElement(this.domCanva)
.getContext("2d"); .getContext("2d");

View File

@@ -2,18 +2,15 @@ var p4 = p4 || {};
(function (p4) { (function (p4) {
function create_dialog() function create_dialog() {
{ if ($('#p4_alerts').length === 0) {
if($('#p4_alerts').length === 0)
{
$('body').append('<div id="p4_alerts"></div>'); $('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 dialog = create_dialog();
var button = new Object(); var button = new Object();
@@ -45,12 +42,12 @@ var p4 = p4 || {};
} }
}).dialog('open'); }).dialog('open');
if(typeof callback === 'function') if (typeof callback === 'function') {
{ dialog.bind("dialogclose", function (event, ui) {
dialog.bind( "dialogclose", function(event, ui) {callback();}); callback();
});
} }
else else {
{
} }

View File

@@ -8,29 +8,24 @@ var p4 = p4 || {};
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) function getId(level) {
{
return 'DIALOG' + getLevel(level); return 'DIALOG' + getLevel(level);
}; };
function addButtons(buttons, dialog) function addButtons(buttons, dialog) {
{ if (dialog.options.closeButton === true) {
if(dialog.options.closeButton === true)
{
buttons[language.fermer] = function () { buttons[language.fermer] = function () {
dialog.Close(); dialog.Close();
}; };
} }
if(dialog.options.cancelButton === true) if (dialog.options.cancelButton === true) {
{
buttons[language.annuler] = function () { buttons[language.annuler] = function () {
dialog.Close(); dialog.Close();
}; };
@@ -45,8 +40,7 @@ var p4 = p4 || {};
var $dialog = $('#' + getId(level)); var $dialog = $('#' + getId(level));
if($dialog.length > 0) if ($dialog.length > 0) {
{
throw 'Dialog already exists at this level'; throw 'Dialog already exists at this level';
} }
@@ -81,8 +75,7 @@ var p4 = p4 || {};
this.options.buttons = addButtons(this.options.buttons, this); this.options.buttons = addButtons(this.options.buttons, this);
switch(this.options.size) switch (this.options.size) {
{
case 'Full': case 'Full':
height = bodySize.y - 30; height = bodySize.y - 30;
width = bodySize.x - 30; width = bodySize.x - 30;
@@ -114,13 +107,11 @@ var p4 = p4 || {};
zIndex = Math.min(this.level * 5000 + 5000, 32767); zIndex = Math.min(this.level * 5000 + 5000, 32767);
var CloseCallback = function () { var CloseCallback = function () {
if(typeof $this.options.closeCallback === 'function') if (typeof $this.options.closeCallback === 'function') {
{
$this.options.closeCallback($this.$dialog); $this.options.closeCallback($this.$dialog);
} }
if($this.closing === false) if ($this.closing === false) {
{
$this.closing = true; $this.closing = true;
$this.Close(); $this.Close();
} }
@@ -147,13 +138,11 @@ var p4 = p4 || {};
}) })
.dialog('open').addClass('dialog-' + this.options.size); .dialog('open').addClass('dialog-' + this.options.size);
if(this.options.loading === true) if (this.options.loading === true) {
{
this.$dialog.addClass('loading'); this.$dialog.addClass('loading');
} }
if(this.options.size === 'Full') if (this.options.size === 'Full') {
{
var $this = this; var $this = this;
$(window).unbind('resize.DIALOG' + getLevel(level)) $(window).unbind('resize.DIALOG' + getLevel(level))
.bind('resize.DIALOG' + getLevel(level), function () { .bind('resize.DIALOG' + getLevel(level), function () {
@@ -207,8 +196,7 @@ var p4 = p4 || {};
}); });
}, },
refresh: function () { refresh: function () {
if(typeof this.loader === 'undefined') if (typeof this.loader === 'undefined') {
{
throw 'Nothing to refresh'; throw 'Nothing to refresh';
} }
this.load(this.loader.url, this.loader.method, this.loader.params); this.load(this.loader.url, this.loader.method, this.loader.params);
@@ -223,8 +211,7 @@ var p4 = p4 || {};
return null; return null;
}, },
setOption: function (optionName, optionValue) { setOption: function (optionName, optionValue) {
if(optionName === 'buttons') if (optionName === 'buttons') {
{
optionValue = addButtons(optionValue, this); optionValue = addButtons(optionValue, this);
} }
if (this.$dialog.data("ui-dialog")) { if (this.$dialog.data("ui-dialog")) {
@@ -240,8 +227,7 @@ var p4 = p4 || {};
Dialog.prototype = { Dialog.prototype = {
Create: function (options, level) { Create: function (options, level) {
if(this.get(level) instanceof phraseaDialog) if (this.get(level) instanceof phraseaDialog) {
{
this.get(level).Close(); this.get(level).Close();
} }
@@ -255,8 +241,7 @@ var p4 = p4 || {};
var id = getId(level); var id = getId(level);
if(id in this.currentStack) if (id in this.currentStack) {
{
return this.currentStack[id]; return this.currentStack[id];
} }
@@ -275,8 +260,7 @@ var p4 = p4 || {};
var id = this.get(level).getId(); var id = this.get(level).getId();
if(id in this.currentStack) if (id in this.currentStack) {
{
delete this.currentStack.id; delete this.currentStack.id;
} }
} }

View File

@@ -1,4 +1,3 @@
; ;
(function (window) { (function (window) {
@@ -94,16 +93,13 @@
var usr_id = $(this).closest('tr').find('input[name="usr_id"]').val(); var usr_id = $(this).closest('tr').find('input[name="usr_id"]').val();
if($('.badge_' + usr_id, $this.container).length > 0) if ($('.badge_' + usr_id, $this.container).length > 0) {
{
$(this).addClass('added'); $(this).addClass('added');
} }
}); });
return false; return false;
}); });
@@ -120,14 +116,12 @@
}, },
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
p4.Dialog.Close(1); p4.Dialog.Close(1);
p4.WorkZone.refresh(); p4.WorkZone.refresh();
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
return; return;
@@ -146,8 +140,7 @@
}); });
$('.FeedbackSend', this.container).bind('click', function () { $('.FeedbackSend', this.container).bind('click', function () {
if($('.badges .badge', $container).length === 0) if ($('.badges .badge', $container).length === 0) {
{
alert(language.FeedBackNoUsersSelected); alert(language.FeedBackNoUsersSelected);
return; return;
} }
@@ -223,12 +216,10 @@
var toggles = $('.status_off.toggle_' + feature, $badges); var toggles = $('.status_off.toggle_' + feature, $badges);
if(toggles.length === 0) if (toggles.length === 0) {
{
var toggles = $('.status_on.toggle_' + feature, $badges); var toggles = $('.status_on.toggle_' + feature, $badges);
} }
if(toggles.length === 0) if (toggles.length === 0) {
{
humane.info('No user selected'); humane.info('No user selected');
} }
@@ -254,8 +245,7 @@
var url = $(this).attr('href'); var url = $(this).attr('href');
var callbackList = function (list) { var callbackList = function (list) {
for(var i in list.entries) for (var i in list.entries) {
{
this.selectUser(list.entries[i].User); this.selectUser(list.entries[i].User);
} }
}; };
@@ -273,8 +263,7 @@
var users = p4.Feedback.getUsers(); var users = p4.Feedback.getUsers();
if(users.length === 0) if (users.length === 0) {
{
humane.error('No users'); humane.error('No users');
return false; return false;
} }
@@ -336,21 +325,17 @@
Feedback.prototype = { Feedback.prototype = {
selectUser: function (user) { selectUser: function (user) {
if(typeof user !== 'object') if (typeof user !== 'object') {
{ if (window.console) {
if(window.console)
{
console.log('trying to select a user with wrong datas'); console.log('trying to select a user with wrong datas');
} }
} }
if($('.badge_' + user.usr_id, this.container).length > 0) if ($('.badge_' + user.usr_id, this.container).length > 0) {
{
humane.info('User already selected'); humane.info('User already selected');
return; return;
} }
if(window.console) if (window.console) {
{
console.log('Selecting', user); console.log('Selecting', user);
} }
@@ -371,8 +356,7 @@
usr_id: usr_id usr_id: usr_id
}, },
success: function (data) { success: function (data) {
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback.call($this, data); callback.call($this, data);
} }
} }
@@ -386,8 +370,7 @@
url: url, url: url,
dataType: 'json', dataType: 'json',
success: function (data) { success: function (data) {
if(typeof callback === 'function') if (typeof callback === 'function') {
{
callback.call($this, data); callback.call($this, data);
} }
} }
@@ -406,14 +389,12 @@
dataType: 'json', dataType: 'json',
data: $form.serializeArray(), data: $form.serializeArray(),
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
$this.selectUser(data.user); $this.selectUser(data.user);
callback(); callback();
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
} }
@@ -430,7 +411,6 @@
}; };
var ListManager = function ($container) { var ListManager = function ($container) {
this.list = null; this.list = null;
@@ -471,7 +451,8 @@
size: 'Medium', size: 'Medium',
title: $this.html() title: $this.html()
}; };
p4.Dialog.Create(options, 2).getDomElement().addClass('loading'); }, p4.Dialog.Create(options, 2).getDomElement().addClass('loading');
},
success: function (data) { success: function (data) {
p4.Dialog.get(2).getDomElement().removeClass('loading').empty().append(data); p4.Dialog.get(2).getDomElement().removeClass('loading').empty().append(data);
return; return;
@@ -490,7 +471,6 @@
}); });
var initLeft = function () { var initLeft = function () {
$('a.list_refresh', $container).bind('click', function (event) { $('a.list_refresh', $container).bind('click', function (event) {
@@ -521,8 +501,7 @@
var name = $('input[name="name"]', p4.Dialog.get(2).getDomElement()).val(); var name = $('input[name="name"]', p4.Dialog.get(2).getDomElement()).val();
if($.trim(name) === '') if ($.trim(name) === '') {
{
alert(language.listNameCannotBeEmpty); alert(language.listNameCannotBeEmpty);
return; return;
} }
@@ -620,13 +599,11 @@
}, },
success: function (data) { success: function (data) {
if(data.success) if (data.success) {
{
humane.info(data.message); humane.info(data.message);
$('#ListManager .lists .list_refresh').trigger('click'); $('#ListManager .lists .list_refresh').trigger('click');
} }
else else {
{
humane.error(data.message); humane.error(data.message);
} }
return; return;
@@ -718,7 +695,6 @@
}; };
window.Feedback = Feedback; window.Feedback = Feedback;
window.ListManager = ListManager; window.ListManager = ListManager;

View File

@@ -1,8 +1,7 @@
var p4 = p4 || {}; var p4 = p4 || {};
(function (p4) { (function (p4) {
function refreshBaskets(baskId, sort, scrolltobottom, type) function refreshBaskets(baskId, sort, scrolltobottom, type) {
{
type = typeof type === 'undefined' ? 'basket' : type; type = typeof type === 'undefined' ? 'basket' : type;
var active = $('#baskets .SSTT.ui-state-active'); var active = $('#baskets .SSTT.ui-state-active');
@@ -53,8 +52,7 @@ var p4 = p4 || {};
}); });
} }
function setTemporaryPref(name, value) function setTemporaryPref(name, value) {
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/user/preferences/temporary/", url: "/user/preferences/temporary/",
@@ -79,8 +77,7 @@ var p4 = p4 || {};
getContent(active, order); getContent(active, order);
}); });
function WorkZoneElementRemover(el, confirm) function WorkZoneElementRemover(el, confirm) {
{
var context = el.data('context'); var context = el.data('context');
if (confirm !== true && $(el).hasClass('groupings') && p4.reg_delete) { if (confirm !== true && $(el).hasClass('groupings') && p4.reg_delete) {
@@ -170,8 +167,7 @@ var p4 = p4 || {};
} }
function activeBaskets() function activeBaskets() {
{
var cache = $("#idFrameC #baskets"); var cache = $("#idFrameC #baskets");
cache.accordion({ cache.accordion({
@@ -200,7 +196,8 @@ var p4 = p4 || {};
b_active.not('.ui-state-active').removeClass('active'); b_active.not('.ui-state-active').removeClass('active');
if (uiactive.length === 0) { if (uiactive.length === 0) {
return; /* everything is closed */ return;
/* everything is closed */
} }
uiactive.addClass('ui-state-focus active'); uiactive.addClass('ui-state-focus active');
@@ -278,8 +275,7 @@ var p4 = p4 || {};
} }
function getContent(header, order) function getContent(header, order) {
{
if (window.console) { if (window.console) {
console.log('Reload content for ', header); console.log('Reload content for ', header);
} }
@@ -383,8 +379,7 @@ var p4 = p4 || {};
}); });
} }
function dropOnBask(event, from, destKey, singleSelection) function dropOnBask(event, from, destKey, singleSelection) {
{
var action = "", from = $(from), dest_uri = '', lstbr = [], sselcont = [], act = "ADD"; var action = "", from = $(from), dest_uri = '', lstbr = [], sselcont = [], act = "ADD";
if (from.hasClass("CHIM")) { if (from.hasClass("CHIM")) {
@@ -506,8 +501,7 @@ var p4 = p4 || {};
}); });
} }
function fix() function fix() {
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "../prod/WorkZone/attachStories/", url: "../prod/WorkZone/attachStories/",
@@ -520,8 +514,7 @@ var p4 = p4 || {};
}); });
} }
function unfix(link) function unfix(link) {
{
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: link, url: link,
@@ -564,8 +557,7 @@ var p4 = p4 || {};
'close': function () { 'close': function () {
var frame = $('#idFrameC'), that = this; var frame = $('#idFrameC'), that = this;
if (!frame.hasClass('closed')) if (!frame.hasClass('closed')) {
{
// hide tabs content // hide tabs content
var activeTabIdx = $('#idFrameC .tabs').tabs("option", "active"); var activeTabIdx = $('#idFrameC .tabs').tabs("option", "active");
$('#idFrameC .tabs > div:eq(' + activeTabIdx + ')').hide(); $('#idFrameC .tabs > div:eq(' + activeTabIdx + ')').hide();
@@ -590,8 +582,7 @@ var p4 = p4 || {};
'open': function () { 'open': function () {
var frame = $('#idFrameC'); var frame = $('#idFrameC');
if (frame.hasClass('closed')) if (frame.hasClass('closed')) {
{
var width = frame.data('openwidth') ? frame.data('openwidth') : 300; var width = frame.data('openwidth') ? frame.data('openwidth') : 300;
frame.css({width: width}); frame.css({width: width});
answerSizer(); answerSizer();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,13 +1,10 @@
function publicator_reload_publicator() {
function publicator_reload_publicator()
{
var options = $('#dialog_publicator form[name="current_datas"]').serializeArray(); var options = $('#dialog_publicator form[name="current_datas"]').serializeArray();
var dialog = p4.Dialog.get(1); var dialog = p4.Dialog.get(1);
dialog.load('/prod/bridge/manager/', 'POST', options); dialog.load('/prod/bridge/manager/', 'POST', options);
} }
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',

View File

@@ -1,9 +1,7 @@
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// 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 '';
} }
@@ -15,32 +13,27 @@ function sprintf()
re["$*"] = true; re["$*"] = true;
var a = b = [], numSubstitutions = 0, numMatches = 0; var a = b = [], numSubstitutions = 0, numMatches = 0;
a = re.exec(str); a = re.exec(str);
while (a) while (a) {
{
var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
var pPrecision = a[5], pType = a[6], rightPart = a[7]; numMatches++; var pPrecision = a[5], pType = a[6], rightPart = a[7];
numMatches++;
// alert("str:"+str + "\nl:"+leftpart + "\nr:"+rightPart); // alert("str:"+str + "\nl:"+leftpart + "\nr:"+rightPart);
if (pType == '%') if (pType == '%') {
{
subst = '%'; subst = '%';
} }
else else {
{
numSubstitutions++; numSubstitutions++;
if (numSubstitutions >= arguments.length) 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).'); 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 param = arguments[numSubstitutions];
var pad = ''; var pad = '';
if (pPad && pPad.substr(0,1) == "'") if (pPad && pPad.substr(0, 1) == "'") {
{
pad = leftpart.substr(1, 1); pad = leftpart.substr(1, 1);
} }
else if (pPad) else if (pPad) {
{
pad = pPad; pad = pPad;
} }
var justifyRight = true; var justifyRight = true;
@@ -50,13 +43,11 @@ function sprintf()
if (pMinLength) if (pMinLength)
minLength = parseInt(pMinLength); minLength = parseInt(pMinLength);
var precision = -1; var precision = -1;
if (pPrecision && pType == 'f') if (pPrecision && pType == 'f') {
{
precision = parseInt(pPrecision.substring(1)); precision = parseInt(pPrecision.substring(1));
} }
var subst = param; var subst = param;
switch (pType) switch (pType) {
{
case 'b': case 'b':
subst = parseInt(param).toString(2); subst = parseInt(param).toString(2);
break; break;
@@ -89,13 +80,11 @@ function sprintf()
} }
var padLeft = minLength - subst.toString().length; var padLeft = minLength - subst.toString().length;
var padding; var padding;
if (padLeft > 0) if (padLeft > 0) {
{
var arrTmp = new Array(padLeft + 1); var arrTmp = new Array(padLeft + 1);
padding = arrTmp.join(pad ? pad : " "); padding = arrTmp.join(pad ? pad : " ");
} }
else else {
{
padding = ""; padding = "";
} }
} }

View File

@@ -1,6 +1,4 @@
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;
@@ -10,17 +8,14 @@ function loadXMLDoc(url, post_parms, asxml)
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);
} }
@@ -30,15 +25,13 @@ function loadXMLDoc(url, post_parms, asxml)
} }
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")
@@ -47,8 +40,7 @@ function showFound2(term, lterm, branch, depth)
} }
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);
} }
@@ -56,13 +48,11 @@ function showFound2(term, lterm, branch, depth)
// 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";
} }
@@ -81,12 +71,10 @@ function showFound2(term, lterm, branch, depth)
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);
} }
@@ -94,11 +82,9 @@ function showAll(branch, depth)
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();
} }
@@ -106,17 +92,14 @@ function showAll(branch, depth)
} }
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;
@@ -124,15 +107,13 @@ function scanTerms(inputName, zTerm, showhide)
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 = "";
} }
} }
@@ -150,17 +131,14 @@ function addTerm(inputName, zTerm, oldid) // inputName = "TS"|"TA"|"SY"
// 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";
@@ -188,13 +166,11 @@ function addTerm(inputName, zTerm, oldid) // inputName = "TS"|"TA"|"SY"
div.id = "THE_" + nextid; div.id = "THE_" + nextid;
else else
div.id = selectedThesaurusItem.id + "." + nextid; div.id = selectedThesaurusItem.id + "." + nextid;
if(typeof(oldid)=="undefined") if (typeof(oldid) == "undefined") {
{
// div.oldid = "?"; // permettra de repérer les nouveaux termes // div.oldid = "?"; // permettra de repérer les nouveaux termes
div.setAttribute("oldid", "?"); // permettra de repérer les nouveaux termes div.setAttribute("oldid", "?"); // permettra de repérer les nouveaux termes
} }
else else {
{
// div.oldid = oldid; // le terme a provient des termes candidats // div.oldid = oldid; // le terme a provient des termes candidats
div.setAttribute("oldid", oldid); // le terme a provient des termes candidats div.setAttribute("oldid", oldid); // le terme a provient des termes candidats
} }
@@ -235,8 +211,7 @@ function addTerm(inputName, zTerm, oldid) // inputName = "TS"|"TA"|"SY"
evt_kup(inputName); evt_kup(inputName);
} }
function dirty() function dirty() {
{
thesaurusChanged = true; thesaurusChanged = true;
document.getElementById("saveButton").style.display = ""; document.getElementById("saveButton").style.display = "";
} }
@@ -363,49 +338,39 @@ function dirty()
} }
*/ */
// 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_";

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,4 @@
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;
@@ -11,17 +9,14 @@ function loadXMLDoc(url, post_parms, asxml)
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);
} }