diff --git a/www/include/jquery.common.js b/www/include/jquery.common.js index de02e23ad7..09af63a0b8 100644 --- a/www/include/jquery.common.js +++ b/www/include/jquery.common.js @@ -1,48 +1,53 @@ var p4 = p4 || {}; -$(document).ready(function(){ +$(document).ready(function () { $('input.input-button').hover( - function(){$(this).addClass('hover');}, - function(){$(this).removeClass('hover');} + function () { + $(this).addClass('hover'); + }, + function () { + $(this).removeClass('hover'); + } ); var locale = $.cookie('locale'); 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'; } $.datepicker.setDefaults({showMonthAfterYear: false}); $.datepicker.setDefaults($.datepicker.regional[jq_date]); - $('a.infoDialog,div.infoDialog').live('click',function(event){ + $('a.infoDialog,div.infoDialog').live('click', function (event) { console.log("click"); infoDialog($(this)); }); var cache = $('#mainMenu .helpcontextmenu'); - $('.context-menu-item',cache).hover(function(){$(this).addClass('context-menu-item-hover');},function(){$(this).removeClass('context-menu-item-hover');}); - - $('#help-trigger').contextMenu('#mainMenu .helpcontextmenu',{openEvt:'click',dropDown:true,theme:'vista', dropDown:true, - showTransition:'slideDown', - hideTransition:'hide', - shadow:false + $('.context-menu-item', cache).hover(function () { + $(this).addClass('context-menu-item-hover'); + }, function () { + $(this).removeClass('context-menu-item-hover'); }); - $('#notification_trigger').bind('mousedown',function(event){ + $('#help-trigger').contextMenu('#mainMenu .helpcontextmenu', {openEvt: 'click', dropDown: true, theme: 'vista', dropDown: true, + showTransition: 'slideDown', + hideTransition: 'hide', + shadow: false + }); + + $('#notification_trigger').bind('mousedown', function (event) { event.stopPropagation(); var box = $('#notification_box'); - if($(this).hasClass('open')) - { + if ($(this).hasClass('open')) { box.hide(); $(this).removeClass('open'); clear_notifications(); } - else - { + else { box.show(); fix_notification_height(); @@ -52,24 +57,26 @@ $(document).ready(function(){ } }); - $(this).bind('mousedown',function(){ + $(this).bind('mousedown', function () { var not_trigger = $('#notification_trigger'); - if(not_trigger.hasClass('open')) + if (not_trigger.hasClass('open')) not_trigger.trigger('click'); }); - $('#notification_box').bind('mousedown',function(event){ + $('#notification_box').bind('mousedown', function (event) { event.stopPropagation(); }); - $('#notification_box div.notification').live('mouseover',function(){$(this).addClass('hover');}); - $('#notification_box div.notification').live('mouseout',function(){$(this).removeClass('hover');}); + $('#notification_box div.notification').live('mouseover', function () { + $(this).addClass('hover'); + }); + $('#notification_box div.notification').live('mouseout', function () { + $(this).removeClass('hover'); + }); - - $(this).bind('mousedown',function(){ + $(this).bind('mousedown', function () { var box = $('#notification_box'); - if($('#notification_trigger').hasClass('open')) - { + if ($('#notification_trigger').hasClass('open')) { box.hide(); $('#notification_trigger').removeClass('open'); clear_notifications(); @@ -82,12 +89,10 @@ $(document).ready(function(){ }); -function login(what) -{ +function login(what) { if (confirm(language.confirmRedirectAuth)) { - if(what != undefined) - { - EcrireCookie('last_act',what,null,'/'); + if (what != undefined) { + EcrireCookie('last_act', what, null, '/'); } self.location.replace('/login/?postlog=1'); } @@ -95,127 +100,119 @@ function login(what) } -function EcrireCookie(nom, valeur) -{ - var argv=EcrireCookie.arguments; - var argc=EcrireCookie.arguments.length; - var expires=(argc > 2) ? argv[2] : null; - var path=(argc > 3) ? argv[3] : null; - var domain=(argc > 4) ? argv[4] : null; - var secure=(argc > 5) ? argv[5] : false; - var cook = nom+"="+escape(valeur)+ - ((expires===null) ? "" : ("; expires="+expires.toGMTString()))+ - ((path===null) ? "" : ("; path="+path))+ - ((domain===null) ? "" : ("; domain="+domain))+ - ((secure===true) ? "; secure" : ""); +function EcrireCookie(nom, valeur) { + var argv = EcrireCookie.arguments; + var argc = EcrireCookie.arguments.length; + var expires = (argc > 2) ? argv[2] : null; + var path = (argc > 3) ? argv[3] : null; + var domain = (argc > 4) ? argv[4] : null; + var secure = (argc > 5) ? argv[5] : false; + var cook = nom + "=" + escape(valeur) + + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + + ((path === null) ? "" : ("; path=" + path)) + + ((domain === null) ? "" : ("; domain=" + domain)) + + ((secure === true) ? "; secure" : ""); document.cookie = cook; } -function fix_notification_height() -{ +function fix_notification_height() { var box = $('#notification_box'); - var not = $('.notification',box); + var not = $('.notification', box); var n = not.length; - var not_t = $('.notification_title',box); + var not_t = $('.notification_title', box); var n_t = not_t.length; h = not.outerHeight() * n + not_t.outerHeight() * n_t; h = h > 350 ? 350 : h; - box.stop().animate({height:h}); + box.stop().animate({height: h}); } -function set_notif_position() -{ +function set_notif_position() { var trigger = $('#notification_trigger'); - if(trigger.length === 0) + if (trigger.length === 0) return; $('#notification_box').css({ - 'left':Math.round(trigger.offset().left - 1) + 'left': Math.round(trigger.offset().left - 1) }); } -$(window).bind('resize', function(){ +$(window).bind('resize', function () { set_notif_position(); }); -function print_notifications(page) -{ +function print_notifications(page) { page = parseInt(page); var buttons = {}; - buttons[language.fermer] = function(){ + buttons[language.fermer] = function () { $('#notifications-dialog').dialog('close'); }; - if($('#notifications-dialog').length === 0) + if ($('#notifications-dialog').length === 0) $('body').append('
'); $('#notifications-dialog') .dialog({ - title:language.notifications, - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - width:500, - height:400, + title: language.notifications, + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true, + width: 500, + height: 400, overlay: { backgroundColor: '#000', opacity: 0.7 }, - close:function(event,ui) - { + close: function (event, ui) { $('#notifications-dialog').dialog('destroy').remove(); } - }).dialog('option','buttons',buttons) + }).dialog('option', 'buttons', buttons) .dialog('open'); $.ajax({ type: "GET", url: "/user/notifications/", - dataType : 'json', + dataType: 'json', data: { - page:page + page: page }, - error: function(data){ + error: function (data) { $('#notifications-dialog').removeClass('loading'); }, - timeout: function(data){ + timeout: function (data) { $('#notifications-dialog').removeClass('loading'); }, - success: function(data){ + success: function (data) { $('#notifications-dialog').removeClass('loading'); var cont = $('#notifications-dialog'); - if(page === 0) + if (page === 0) cont.empty(); else - $('.notification_next',cont).remove(); + $('.notification_next', cont).remove(); - for (i in data.notifications) - { - var id = 'notif_date_'+i; - var date_cont = $('#'+id); - if(date_cont.length === 0) - { - cont.append('
'+data.notifications[i].display+'
'); - date_cont = $('#'+id); + for (i in data.notifications) { + var id = 'notif_date_' + i; + var date_cont = $('#' + id); + if (date_cont.length === 0) { + cont.append('
' + data.notifications[i].display + '
'); + 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 html = '
'+ - '
'+ - loc_dat.icon+ - ''+ - '
'+ - loc_dat.text+' '+loc_dat.time+'
'+ - '
'+ + var html = '
' + + '
' + + loc_dat.icon + + '' + + '
' + + loc_dat.text + ' ' + loc_dat.time + '
' + + '
' + '
'; date_cont.append(html); } @@ -223,9 +220,8 @@ function print_notifications(page) var next_ln = $.trim(data.next); - if(next_ln !== '') - { - cont.append('
'+next_ln+'
'); + if (next_ln !== '') { + cont.append('
' + next_ln + '
'); } // '
'. @@ -243,11 +239,10 @@ function print_notifications(page) } -function read_notifications() -{ +function read_notifications() { var notifications = []; - $('#notification_box .unread').each(function(){ + $('#notification_box .unread').each(function () { notifications.push($(this).attr('id').split('_').pop()); }); @@ -255,180 +250,158 @@ function read_notifications() type: "POST", url: "/user/notifications/read/", data: { - notifications:notifications.join('_') + notifications: notifications.join('_') }, - success: function(data){ - $('#notification_trigger .counter').css('visibility','hidden').empty(); + success: function (data) { + $('#notification_trigger .counter').css('visibility', 'hidden').empty(); } }); } -function clear_notifications() -{ +function clear_notifications() { var unread = $('#notification_box .unread'); - if(unread.length === 0) + if (unread.length === 0) return; unread.removeClass('unread'); - $('#notification_trigger .counter').css('visibility','hidden').empty(); + $('#notification_trigger .counter').css('visibility', 'hidden').empty(); } - - - - - -function getMyRss(renew) -{ +function getMyRss(renew) { $.ajax({ type: "POST", url: "/prod/prodFeedBack.php", dataType: 'json', data: datas, - success: function(data){ + success: function (data) { } }); } -function setPref(name,value) -{ - if(jQuery.data['pref_'+name] && jQuery.data['pref_'+name].abort) - { - jQuery.data['pref_'+name].abort(); - jQuery.data['pref_'+name] = false; +function setPref(name, value) { + if (jQuery.data['pref_' + name] && jQuery.data['pref_' + name].abort) { + jQuery.data['pref_' + name].abort(); + jQuery.data['pref_' + name] = false; } - jQuery.data['pref_'+name] = $.ajax({ + jQuery.data['pref_' + name] = $.ajax({ type: "POST", url: "/user/preferences/", data: { - prop:name, - value:value + prop: name, + value: value }, - dataType:'json', - timeout: function(){ - jQuery.data['pref_'+name] = false; + dataType: 'json', + timeout: function () { + jQuery.data['pref_' + name] = false; }, - error: function(){ - jQuery.data['pref_'+name] = false; + error: function () { + jQuery.data['pref_' + name] = false; }, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); } - else - { + else { humane.error(data.message); } - jQuery.data['pref_'+name] = false; + jQuery.data['pref_' + name] = false; return; } }); } -function infoDialog(el) -{ +function infoDialog(el) { - $("#DIALOG").attr('title','') + $("#DIALOG").attr('title', '') .empty() .append(el.attr('infos')) .dialog({ - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - width:600, - height:400, - modal:true, + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + width: 600, + height: 400, + modal: true, overlay: { backgroundColor: '#000', opacity: 0.7 } - }).dialog('open').css({'overflow-x':'auto','overflow-y':'auto'}); + }).dialog('open').css({'overflow-x': 'auto', 'overflow-y': 'auto'}); } -function manageSession(data, showMessages) -{ - if(typeof(showMessages) == "undefined") +function manageSession(data, showMessages) { + if (typeof(showMessages) == "undefined") showMessages = false; - if(data.status == 'disconnected' || data.status == 'session') - { + if (data.status == 'disconnected' || data.status == 'session') { disconnected(); return false; } - if(showMessages) - { + if (showMessages) { var box = $('#notification_box'); box.empty().append(data.notifications); - if(box.is(':visible')) + if (box.is(':visible')) fix_notification_height(); - if($('.notification.unread',box).length > 0) - { - var trigger = $('#notification_trigger') ; - $('.counter',trigger) + if ($('.notification.unread', box).length > 0) { + var trigger = $('#notification_trigger'); + $('.counter', trigger) .empty() - .append($('.notification.unread',box).length); - $('.counter',trigger).css('visibility','visible'); + .append($('.notification.unread', box).length); + $('.counter', trigger).css('visibility', 'visible'); } 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_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false; var main_open = false; - for(var i=0; i!=data.changed.length; i++) - { - var sstt = $('#SSTT_'+data.changed[i]); - if(sstt.size() === 0) - { - if(main_open === false) - { - $('#baskets .bloc').animate({'top':30}, function(){$('#baskets .alert_datas_changed:first').show()}); + for (var i = 0; i != data.changed.length; i++) { + var sstt = $('#SSTT_' + data.changed[i]); + if (sstt.size() === 0) { + if (main_open === false) { + $('#baskets .bloc').animate({'top': 30}, function () { + $('#baskets .alert_datas_changed:first').show() + }); main_open = true; } } - else - { - if(!sstt.hasClass('active')) + else { + if (!sstt.hasClass('active')) sstt.addClass('unread'); - else - { - $('.alert_datas_changed', $('#SSTT_content_'+data.changed[i])).show(); + else { + $('.alert_datas_changed', $('#SSTT_content_' + data.changed[i])).show(); } } } } - if('' !== $.trim(data.message)) - { - if($('#MESSAGE').length === 0) + if ('' !== $.trim(data.message)) { + if ($('#MESSAGE').length === 0) $('body').append('
'); $('#MESSAGE') .empty() - .append(data.message+'
'+language.hideMessage+'
') - .attr('title','Global Message') + .append(data.message + '
' + language.hideMessage + '
') + .attr('title', 'Global Message') .dialog({ - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - close:function() - { - if($('.dialog_remove:checked',$(this)).length > 0) - setTemporaryPref('message',0); + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true, + close: function () { + if ($('.dialog_remove:checked', $(this)).length > 0) + setTemporaryPref('message', 0); } }) .dialog('open'); @@ -438,25 +411,23 @@ function manageSession(data, showMessages) } - -function disconnected() -{ - showModal('disconnected',{title:'Disconnection'}); +function disconnected() { + showModal('disconnected', {title: 'Disconnection'}); } -function showModal(cas, options){ +function showModal(cas, options) { var content = ''; var callback = null; var button = { - "OK": function(e) - { + "OK": function (e) { hideOverlay(3); $(this).dialog("close"); return; }}; var escape = true; - var onClose = function(){}; + var onClose = function () { + }; switch (cas) { case 'timeout': @@ -467,8 +438,10 @@ function showModal(cas, options){ break; case 'disconnected': content = language.serverDisconnected; - escape=false; - callback = function(e){ self.location.replace(self.location.href)}; + escape = false; + callback = function (e) { + self.location.replace(self.location.href) + }; break; default: break; @@ -479,35 +452,37 @@ function showModal(cas, options){ return; } -function showOverlay(n,appendto,callback, zIndex){ +function showOverlay(n, appendto, callback, zIndex) { - var div ="OVERLAY"; - if(typeof(n)!="undefined") - div+=n; - if($('#'+div).length === 0) - { - if(typeof(appendto)=='undefined') + var div = "OVERLAY"; + if (typeof(n) != "undefined") + div += n; + if ($('#' + div).length === 0) { + if (typeof(appendto) == 'undefined') appendto = 'body'; - $(appendto).append(''); + $(appendto).append(''); } var css = { display: 'block', opacity: 0, - right:0, - bottom:0, - position:'absolute', - top:0, - zIndex:zIndex, - left:0 + right: 0, + bottom: 0, + position: 'absolute', + top: 0, + zIndex: zIndex, + left: 0 }; - if(parseInt(zIndex) > 0) + if (parseInt(zIndex) > 0) css['zIndex'] = parseInt(zIndex); - if(typeof(callback) != 'function') - callback = function(){}; - $('#'+div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click',function(){(callback)();}); + if (typeof(callback) != 'function') + callback = function () { + }; + $('#' + div).css(css).addClass('overlay').fadeTo(500, 0.7).bind('click', function () { + (callback)(); + }); if ($.browser.msie && $.browser.version == '6.0') { $('select').css({ visibility: 'hidden' @@ -515,22 +490,22 @@ function showOverlay(n,appendto,callback, zIndex){ } } -function hideDwnl(){ +function hideDwnl() { hideOverlay(2); $('#MODALDL').css({ 'display': 'none' }); } -function hideOverlay(n){ +function hideOverlay(n) { if ($.browser.msie && $.browser.version == '6.0') { $('select').css({ visibility: 'visible' }); } var div = "OVERLAY"; - if(typeof(n)!="undefined") - div+=n; - $('#'+div).hide().remove(); + if (typeof(n) != "undefined") + div += n; + $('#' + div).hide().remove(); } diff --git a/www/include/jquery.image_enhancer.js b/www/include/jquery.image_enhancer.js index f10c5f247a..c2980c6fb6 100644 --- a/www/include/jquery.image_enhancer.js +++ b/www/include/jquery.image_enhancer.js @@ -1,145 +1,136 @@ -(function( $ ){ +(function ($) { var methods = { - init : function( options ) { + init: function (options) { var settings = { - 'zoomable' : false, - 'display_full_screen' : false + 'zoomable': false, + 'display_full_screen': false }; - return this.each(function() { + return this.each(function () { var $this = $(this), data = $(this).data('image_enhance'); - if ( ! data ) - { - if ( options ) { - $.extend( settings, options ); + if (!data) { + if (options) { + $.extend(settings, options); } var wrapper = $('.thumb_wrapper', $(this)); - var $image =$('img', $this); + var $image = $('img', $this); - wrapper.css('position','relative'); + wrapper.css('position', 'relative'); reset_position($this); - if(settings.display_full_screen) - { + if (settings.display_full_screen) { $image.parent() .append(''); - var $titlebar = $('.image_enhance_titlebar',$this); + var $titlebar = $('.image_enhance_titlebar', $this); - $('.image_enhance_title_bg',$titlebar).css('opacity',0.5); + $('.image_enhance_title_bg', $titlebar).css('opacity', 0.5); $image.parent() - .bind('mouseover.image_enhance', function(){ + .bind('mouseover.image_enhance', function () { $titlebar.stop().show().animate({ - 'height':28 + 'height': 28 }, 150); }) - .bind('mouseout.image_enhance', function(){ + .bind('mouseout.image_enhance', function () { $titlebar.stop().animate({ - 'height':0 - }, 150, function(){ + 'height': 0 + }, 150, function () { $titlebar.hide() }); }); - $('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function(){ + $('.image_enhance_titlebar .full', wrapper).bind('click.image_enhance', function () { $('body').append('
\n\ \n\
close
\n\ - \n\ + \n\
'); var $theatre = $('.image_enhance_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'); } - else - { - if($theatre_img.hasClass('zoomed')) + else { + if ($theatre_img.hasClass('zoomed')) return; } var datas = calculate_sizes($(this).width(), $(this).height(), image_width, image_height, 80); - $theatre_img.width(datas.width).height(datas.height).css('top',datas.top).css('left',datas.left); + $theatre_img.width(datas.width).height(datas.height).css('top', datas.top).css('left', datas.left); }) $(window).trigger('resize.image_enhance'); - $('.closer', $theatre).bind('click.image_enhance', function(){ + $('.closer', $theatre).bind('click.image_enhance', function () { $theatre.remove(); }); - if(typeof $theatre.disableSelection !== 'function' && window.console) + if (typeof $theatre.disableSelection !== 'function' && window.console) console.error('enhanced image require jquery UI\'s disableSelection'); $('img', $theatre).disableSelection(); }); } - if(settings.zoomable) - { - if(typeof $image.draggable !== 'function' && window.console) + if (settings.zoomable) { + if (typeof $image.draggable !== 'function' && window.console) console.error('zoomable require jquery UI\'s draggable'); - if($image.attr('ondragstart')) - { + if ($image.attr('ondragstart')) { $image.removeAttr('ondragstart'); } $image.draggable(); $image.css({ - 'max-width':'none', - 'max-height':'none' + 'max-width': 'none', + 'max-height': 'none' }); var image_width = parseInt($('input[name="width"]', $this).val()); var image_height = parseInt($('input[name="height"]', $this).val()); var ratio = image_width / image_height; - $this.bind('mousewheel',function(event, delta){ + $this.bind('mousewheel',function (event, delta) { $image.addClass('zoomed'); - if(delta > 0) - { + if (delta > 0) { event.stopPropagation(); zoomPreview(true, ratio, $image, $(this)); } - else - { + else { event.stopPropagation(); zoomPreview(false, ratio, $image, $(this)); } return false; - }).bind('dblclick', function(event){ + }).bind('dblclick', function (event) { reset_position($this); }); } $(this).data('image_enhance', { - width:image_width, - height:image_height + width: image_width, + height: image_height }); } }); }, - destroy : function( ) { - return this.each(function() { + destroy: function () { + return this.each(function () { $(this).data('image_enhance', null); - $('.image_enhance_titlebar, .image_enhance_theatre',this).remove(); + $('.image_enhance_titlebar, .image_enhance_theatre', this).remove(); }); } }; - function zoomPreview(bool, ratio, $img, $container) - { - if($img.length === 0) + function zoomPreview(bool, ratio, $img, $container) { + if ($img.length === 0) return; var t1 = parseInt($img.css('top')); @@ -147,19 +138,17 @@ var w1 = $img.width(); var h1 = $img.height(); - var w2,t2; + var w2, t2; - if(bool) - { - if((w1 * 1.08) < 32767) { + if (bool) { + if ((w1 * 1.08) < 32767) { w2 = w1 * 1.08; } else { w2 = w1; } } - else - { - if((w1 / 1.08) > 20) { + else { + if ((w1 / 1.08) > 20) { w2 = w1 / 1.08; } else { w2 = w1; @@ -171,11 +160,11 @@ h2 = Math.round(w2 / ratio); w2 = Math.round(w2); - t2 = Math.round(t1 - (h2 - h1) / 2)+'px'; - var l2 = Math.round(l1 - (w2 - w1) / 2)+'px'; + t2 = Math.round(t1 - (h2 - h1) / 2) + 'px'; + var l2 = Math.round(l1 - (w2 - w1) / 2) + 'px'; - var wPreview = $container.width()/2; - var hPreview = $container.height()/2; + var wPreview = $container.width() / 2; + var hPreview = $container.height() / 2; var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview); var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview); @@ -186,64 +175,60 @@ }).width(w2).height(h2); } - function calculate_sizes(window_width, window_height,image_width, image_height, border) - { - if(typeof border !== 'number') + function calculate_sizes(window_width, window_height, image_width, image_height, border) { + if (typeof border !== 'number') border = 0; var width, height; var ratio_display = window_width / window_height; var ratio_image = image_width / image_height; - if(ratio_image > ratio_display) - { + if (ratio_image > ratio_display) { width = window_width - border; height = Math.round(width / ratio_image); } - else - { + else { height = window_height - border; width = Math.round(height * ratio_image); } var top = Math.round((window_height - height) / 2); - var left = Math.round((window_width - width )/2); + var left = Math.round((window_width - width ) / 2); return { - top:top, - left:left, - width:width, - height:height + top: top, + left: left, + width: width, + height: height }; } - function reset_position($this) - { + function reset_position($this) { var display_width = $this.width(); var display_height = $this.height(); var image_width = parseInt($('input[name="width"]', $this).val()); var image_height = parseInt($('input[name="height"]', $this).val()); var datas = calculate_sizes(display_width, display_height, image_width, image_height); - var $image =$('img', $this); + var $image = $('img', $this); - var top = Math.round((display_height - datas.height) / 2)+'px'; - var left = Math.round((display_width - datas.width) / 2)+'px'; + var top = Math.round((display_height - datas.height) / 2) + 'px'; + var left = Math.round((display_width - datas.width) / 2) + 'px'; - $image.width(datas.width).height(datas.height).css({top:top, left:left}); + $image.width(datas.width).height(datas.height).css({top: top, left: left}); return; } - $.fn.image_enhance = function(method) { + $.fn.image_enhance = function (method) { - if ( methods[method] ) { - return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( typeof method === 'object' || ! method ) { - return methods.init.apply( this, arguments ); + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); } else { - $.error( 'Method ' + method + ' does not exist on jQuery.image_enhance' ); + $.error('Method ' + method + ' does not exist on jQuery.image_enhance'); } }; -})( jQuery ); +})(jQuery); diff --git a/www/include/jquery.kb-event.js b/www/include/jquery.kb-event.js index 18505af160..a4a158b2a3 100644 --- a/www/include/jquery.kb-event.js +++ b/www/include/jquery.kb-event.js @@ -1,26 +1,22 @@ - - -function is_ctrl_key(event) -{ - if(event.altKey) +function is_ctrl_key(event) { + if (event.altKey) return true; - if(event.ctrlKey) + if (event.ctrlKey) return true; - if(event.metaKey) // apple key opera + if (event.metaKey) // apple key opera return true; - if(event.keyCode == '17') // apple key opera + if (event.keyCode == '17') // apple key opera return true; - if(event.keyCode == '224') // apple key mozilla + if (event.keyCode == '224') // apple key mozilla return true; - if(event.keyCode == '91') // apple key safari + if (event.keyCode == '91') // apple key safari return true; return false; } -function is_shift_key(event) -{ - if(event.shiftKey) +function is_shift_key(event) { + if (event.shiftKey) return true; return false; } diff --git a/www/include/jquery.nicoslider.js b/www/include/jquery.nicoslider.js index d0d9c4eece..10acff56fa 100644 --- a/www/include/jquery.nicoslider.js +++ b/www/include/jquery.nicoslider.js @@ -1,29 +1,27 @@ -(function($){ - $.fn.nicoslider = function(options) - { +(function ($) { + $.fn.nicoslider = function (options) { var defaults = { - start : 0, - color : '#F6F2F1', - sliderHeight : false + start: 0, + color: '#F6F2F1', + sliderHeight: false }; - var opts = $.extend({}, $.fn.nicoslider.defaults,defaults, options); + var opts = $.extend({}, $.fn.nicoslider.defaults, defaults, options); - return this.each(function(){ + return this.each(function () { new nicoslide(this, opts); }); }; - var nicoslide = function(slider, o) - { + var nicoslide = function (slider, o) { var $slider = $(slider); $sliderWidth = $slider.parent().innerWidth(); $sliderCss = { - 'width':$sliderWidth, - 'background-color':o.color + 'width': $sliderWidth, + 'background-color': o.color }; $slider.css($sliderCss); @@ -32,36 +30,34 @@ var ulWidth = 0; var liHeight = 0; - $slider.find("li").each(function(){ + $slider.find("li").each(function () { ulWidth += $(this).width() + 5; ulWidth += parseInt($(this).css("padding-left")); ulWidth += parseInt($(this).css("padding-right")); ulWidth += parseInt($(this).css("margin-left")); ulWidth += parseInt($(this).css("margin-right")); - liHeight = Math.max(liHeight,$(this).outerHeight()); + liHeight = Math.max(liHeight, $(this).outerHeight()); }); //5 % of slider width $scrollWidth = Math.round(parseInt($sliderWidth) * parseFloat("0.05")); //min 30 px; - if($scrollWidth < 30) - { + if ($scrollWidth < 30) { $scrollWidth = 30; } var $wrapperWidth = Math.round(parseInt($sliderWidth) - ( 2 * $scrollWidth )); - if(ulWidth > $wrapperWidth) - { + if (ulWidth > $wrapperWidth) { ul.wrapAll("
"); $wrapper = $slider.find(".wrapper"); $ulHeight = ul.height(); $wrapper.width($wrapperWidth); $wrapper.height($ulHeight); - $wrapperCss= { - 'overflow':'hidden', - 'float':'left', - 'position':'relative' + $wrapperCss = { + 'overflow': 'hidden', + 'float': 'left', + 'position': 'relative' }; $wrapper.css($wrapperCss); @@ -79,19 +75,19 @@ $("div.rb").css('float', 'right'); rightCss = { - 'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), - 'height' : liHeight + 5, - 'float' : 'right', - 'background-color' : o.color, + 'width': $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), + 'height': liHeight + 5, + 'float': 'right', + 'background-color': o.color, 'cursor': 'pointer', ' user-select': 'none' }; leftCss = { - 'width' : $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), - 'height' : liHeight + 5, - 'float' : 'left', - 'background-color' : o.color, + 'width': $scrollWidth - ($wrapper.outerWidth(true) - $wrapper.innerWidth()), + 'height': liHeight + 5, + 'float': 'left', + 'background-color': o.color, 'cursor': 'pointer', ' user-select': 'none' }; @@ -108,13 +104,12 @@ //scroll a droite - rightScroll.bind("click", function(e){ + rightScroll.bind("click", function (e) { var x = e.pageX - ($(this).offset().left); 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; } ul.animate({ @@ -123,14 +118,13 @@ }); //scroll a gauche - leftScroll.bind("click", function(e){ + leftScroll.bind("click", function (e) { var x = $(this).innerWidth() - (e.pageX - $(this).offset().left); scrollXpos = Math.round((x / leftScrollWidth) * scrollStepSpeed); - shift -= (scrollXpos * speed); + shift -= (scrollXpos * speed); - if(shift < 0) - { + if (shift < 0) { shift = 0; } diff --git a/www/include/jquery.p4.modal.js b/www/include/jquery.p4.modal.js index 752fb33498..91c7d3facc 100644 --- a/www/include/jquery.p4.modal.js +++ b/www/include/jquery.p4.modal.js @@ -1,12 +1,15 @@ -$(document).ready(function(){ +$(document).ready(function () { $('#tabs').tabs(); $('input.input-button').hover( - function(){parent.$(this).addClass('hover');}, - function(){parent.$(this).removeClass('hover');} + function () { + parent.$(this).addClass('hover'); + }, + function () { + parent.$(this).removeClass('hover'); + } ); - $(this).bind('keydown',function(event){ - switch(event.keyCode) - { + $(this).bind('keydown', function (event) { + switch (event.keyCode) { case 27: parent.hideDwnl(); break; diff --git a/www/include/jquery.p4.preview.js b/www/include/jquery.p4.preview.js index a59c30f420..ebb884fc6b 100644 --- a/www/include/jquery.p4.preview.js +++ b/www/include/jquery.p4.preview.js @@ -1,14 +1,13 @@ -var prevAjax,prevAjaxrunning; +var prevAjax, prevAjaxrunning; prevAjaxrunning = false; p4.slideShow = false; -$(document).ready(function(){ +$(document).ready(function () { $('#PREVIEWIMGDESC').tabs(); }); -function getNewVideoToken(lst, obj) -{ +function getNewVideoToken(lst, obj) { $.ajax({ type: "POST", url: "../prod/records/renew-url/", @@ -16,11 +15,11 @@ function getNewVideoToken(lst, obj) data: { lst: lst }, - success: function(data){ - if(!data[lst]) + success: function (data) { + if (!data[lst]) return; obj.unload(); - obj.setClip({url:data[lst]}); + obj.setClip({url: data[lst]}); obj.play(); return; } @@ -28,7 +27,7 @@ function getNewVideoToken(lst, obj) }); } -function openPreview(env, pos, contId, reload){ +function openPreview(env, pos, contId, reload) { if (contId == undefined) contId = ''; @@ -47,8 +46,7 @@ function openPreview(env, pos, contId, reload){ 'display': 'block', 'opacity': 0 }).fadeTo(500, 1); - }else - { + } else { $('#PREVIEWBOX').css({ 'display': 'block', 'opacity': 1 @@ -58,12 +56,12 @@ function openPreview(env, pos, contId, reload){ p4.preview.nCurrent = 5; $('#PREVIEWCURRENT, #PREVIEWOTHERSINNER, #SPANTITLE').empty(); resizePreview(); - if(env == 'BASK') + if (env == 'BASK') roll = 1; } - if(reload === true) + if (reload === true) roll = 1; @@ -85,37 +83,36 @@ function openPreview(env, pos, contId, reload){ pos: pos, cont: contId, roll: roll, - options_serial:options_serial, - query:query + options_serial: options_serial, + query: query }, - beforeSend: function(){ + beforeSend: function () { if (prevAjaxrunning) prevAjax.abort(); - if(env == 'RESULT') - $('#current_result_n').empty().append(parseInt(pos)+1); + if (env == 'RESULT') + $('#current_result_n').empty().append(parseInt(pos) + 1); prevAjaxrunning = true; $('#PREVIEWIMGDESC, #PREVIEWOTHERS').addClass('loading'); }, - error: function(data){ + error: function (data) { prevAjaxrunning = false; $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); posAsk = null; }, - timeout: function(){ + timeout: function () { prevAjaxrunning = false; $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); posAsk = null; }, - success: function(data){ + success: function (data) { cancelPreview(); prevAjaxrunning = false; posAsk = null; - if(data.error) - { + if (data.error) { $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); alert(data.error); - if(justOpen) + if (justOpen) closePreview(); return; } @@ -123,20 +120,18 @@ function openPreview(env, pos, contId, reload){ $('#PREVIEWIMGCONT').empty().append(data.html_preview); $('#PREVIEWIMGCONT .thumb_wrapper') - .width('100%').height('100%').image_enhance({zoomable:true}); + .width('100%').height('100%').image_enhance({zoomable: true}); $('#PREVIEWIMGDESCINNER').empty().append(data.desc); $('#HISTORICOPS').empty().append(data.history); $('#popularity').empty().append(data.popularity); - if($('#popularity .bitly_link').length>0) - { + if ($('#popularity .bitly_link').length > 0) { - BitlyCB.statsResponse = function(data) { + BitlyCB.statsResponse = function (data) { var result = data.results; - if( $( '#popularity .bitly_link_' + result.userHash ).length > 0 ) - { - $( '#popularity .bitly_link_' + result.userHash ).append( ' (' + result.clicks + ' clicks)'); + if ($('#popularity .bitly_link_' + result.userHash).length > 0) { + $('#popularity .bitly_link_' + result.userHash).append(' (' + result.clicks + ' clicks)'); } }; BitlyClient.stats($('#popularity .bitly_link').html(), 'BitlyCB.statsResponse'); @@ -148,36 +143,30 @@ function openPreview(env, pos, contId, reload){ p4.preview.current.tot = data.tot; 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(); } setTitle(data.title); setPreview(); - if(env != 'RESULT') - { + if (env != 'RESULT') { setCurrent(data.current); viewCurrent($('#PREVIEWCURRENT li.selected')); } - else - { - if(!justOpen) - { + else { + if (!justOpen) { $('#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])) - { - getAnswerTrain(pos, data.tools, query,options_serial); + if (justOpen || ($('#PREVIEWCURRENTCONT li.current' + pos).length === 0) || ($('#PREVIEWCURRENTCONT li:last')[0] == $('#PREVIEWCURRENTCONT li.selected')[0]) || ($('#PREVIEWCURRENTCONT li:first')[0] == $('#PREVIEWCURRENTCONT li.selected')[0])) { + getAnswerTrain(pos, data.tools, query, options_serial); } viewCurrent($('#PREVIEWCURRENT li.selected')); } - if(env == 'REG' && $('#PREVIEWCURRENT').html() === '') - { - getRegTrain(contId,pos,data.tools); + if (env == 'REG' && $('#PREVIEWCURRENT').html() === '') { + getRegTrain(contId, pos, data.tools); } setOthers(data.others); setTools(data.tools); @@ -185,7 +174,7 @@ function openPreview(env, pos, contId, reload){ 'display': 'none' }); $('#PREVIEWIMGDESC, #PREVIEWOTHERS').removeClass('loading'); - if(!justOpen || (p4.preview.mode != env)) + if (!justOpen || (p4.preview.mode != env)) resizePreview(); p4.preview.mode = env; @@ -200,11 +189,11 @@ function openPreview(env, pos, contId, reload){ } -function zoomPreview(bool){ +function zoomPreview(bool) { var el = $('#PREVIEWIMGCONT img.record'); - if(el.length === 0) + if (el.length === 0) return; var t1 = parseInt(el.css('top')); @@ -212,18 +201,16 @@ function zoomPreview(bool){ var w1 = el.width(); var h1 = el.height(); - var w2,t2; + var w2, t2; - if(bool) - { - if(w1 * 1.08 < 32767) + if (bool) { + if (w1 * 1.08 < 32767) w2 = w1 * 1.08; else w2 = w1; } - else - { - if(w1 / 1.08 > 20) + else { + if (w1 / 1.08 > 20) w2 = w1 / 1.08; else w2 = w1; @@ -233,11 +220,11 @@ function zoomPreview(bool){ h2 = Math.round(w2 / ratio); w2 = Math.round(w2); - t2 = Math.round(t1 - (h2 - h1) / 2)+'px'; - var l2 = Math.round(l1 - (w2 - w1) / 2)+'px'; + t2 = Math.round(t1 - (h2 - h1) / 2) + 'px'; + var l2 = Math.round(l1 - (w2 - w1) / 2) + 'px'; - var wPreview = $('#PREVIEWIMGCONT').width()/2; - var hPreview = $('#PREVIEWIMGCONT').height()/2; + var wPreview = $('#PREVIEWIMGCONT').width() / 2; + var hPreview = $('#PREVIEWIMGCONT').height() / 2; var nt = Math.round((h2 / h1) * (t1 - hPreview) + hPreview); var nl = Math.round(((w2 / w1) * (l1 - wPreview)) + wPreview); @@ -248,19 +235,18 @@ function zoomPreview(bool){ }).width(w2).height(h2); } -function getAnswerTrain(pos, tools, query,options_serial) -{ +function getAnswerTrain(pos, tools, query, options_serial) { $('#PREVIEWCURRENTCONT').fadeOut('fast'); $.ajax({ type: "POST", url: "/prod/query/answer-train/", dataType: 'json', data: { - pos:pos, - options_serial:options_serial, - query:query + pos: pos, + options_serial: options_serial, + query: query }, - success: function(data){ + success: function (data) { setCurrent(data.current); viewCurrent($('#PREVIEWCURRENT li.selected')); setTools(tools); @@ -270,43 +256,42 @@ function getAnswerTrain(pos, tools, query,options_serial) } -function getRegTrain(contId,pos,tools) -{ +function getRegTrain(contId, pos, tools) { $.ajax({ type: "POST", url: "/prod/query/reg-train/", dataType: 'json', data: { - cont:contId, - pos:pos + cont: contId, + pos: pos }, - success: function(data){ + success: function (data) { setCurrent(data.current); viewCurrent($('#PREVIEWCURRENT li.selected')); - if(typeof(tools) != 'undefined') + if (typeof(tools) != 'undefined') setTools(tools); return; } }); } -function bounce(sbid, term, field){ +function bounce(sbid, term, field) { doThesSearch('T', sbid, term, field); closePreview(); } -function setTitle(title){ +function setTitle(title) { $('#SPANTITLE').empty().append(title); } -function cancelPreview(){ +function cancelPreview() { $('#PREVIEWIMGDESCINNER').empty(); $('#PREVIEWIMGCONT').empty(); p4.preview.current = false; } -function startSlide(){ +function startSlide() { if (!p4.slideShow) { p4.slideShow = true; } @@ -316,8 +301,7 @@ function startSlide(){ $('#start_slide').show(); $('#stop_slide').hide(); } - if(!p4.preview.open) - { + if (!p4.preview.open) { p4.slideShowCancel = false; p4.slideShow = false; $('#start_slide').show(); @@ -331,7 +315,7 @@ function startSlide(){ } } -function stopSlide(){ +function stopSlide() { p4.slideShowCancel = true; $('#start_slide').show(); $('#stop_slide').hide(); @@ -339,7 +323,7 @@ function stopSlide(){ //var posAsk = null; -function getNext(){ +function getNext() { if (p4.preview.mode == 'REG' && parseInt(p4.preview.current.pos) === 0) $('#PREVIEWCURRENTCONT li img:first').trigger("click"); else { @@ -348,9 +332,8 @@ function getNext(){ posAsk = (posAsk > parseInt(p4.tot) || isNaN(posAsk)) ? 0 : posAsk; openPreview('RESULT', posAsk); } - else - { - if(!$('#PREVIEWCURRENT li.selected').is(':last-child')) + else { + if (!$('#PREVIEWCURRENT li.selected').is(':last-child')) $('#PREVIEWCURRENT li.selected').next().children('img').trigger("click"); else $('#PREVIEWCURRENT li:first-child').children('img').trigger("click"); @@ -358,27 +341,25 @@ function getNext(){ } } -function reloadPreview(){ +function reloadPreview() { $('#PREVIEWCURRENT li.selected img').trigger("click"); } -function getPrevious(){ - if (p4.preview.mode == 'RESULT') - { +function getPrevious() { + if (p4.preview.mode == 'RESULT') { posAsk = parseInt(p4.preview.current.pos) - 1; posAsk = (posAsk < 0) ? ((parseInt(p4.tot) - 1)) : posAsk; openPreview('RESULT', posAsk); } - else - { - if(!$('#PREVIEWCURRENT li.selected').is(':first-child')) + else { + if (!$('#PREVIEWCURRENT li.selected').is(':first-child')) $('#PREVIEWCURRENT li.selected').prev().children('img').trigger("click"); else $('#PREVIEWCURRENT li:last-child').children('img').trigger("click"); } } -function setOthers(others){ +function setOthers(others) { $('#PREVIEWOTHERSINNER').empty(); if (others !== '') { @@ -388,31 +369,29 @@ function setOthers(others){ } } -function setTools(tools){ +function setTools(tools) { $('#PREVIEWTOOL').empty().append(tools); - if(!p4.slideShowCancel && p4.slideShow) - { + if (!p4.slideShowCancel && p4.slideShow) { $('#start_slide').hide(); $('#stop_slide').show(); - }else - { + } else { $('#start_slide').show(); $('#stop_slide').hide(); } } -function setCurrent(current){ +function setCurrent(current) { if (current !== '') { var el = $('#PREVIEWCURRENT'); el.removeClass('loading').empty().append(current); - $('ul',el).width($('li',el).length * 80); - $('img.prevRegToolTip',el).tooltip(); - $.each($('img.openPreview'), function(i, el){ + $('ul', el).width($('li', el).length * 80); + $('img.prevRegToolTip', el).tooltip(); + $.each($('img.openPreview'), function (i, el) { var jsopt = $(el).attr('jsargs').split('|'); $(el).removeAttr('jsargs'); $(el).removeClass('openPreview'); - $(el).bind('click', function(){ + $(el).bind('click', function () { viewCurrent($(this).parent()); openPreview(jsopt[0], jsopt[1], jsopt[2]); }); @@ -420,23 +399,22 @@ function setCurrent(current){ } } -function viewCurrent(el){ - if (el.length === 0) - { +function viewCurrent(el) { + if (el.length === 0) { return; } $('#PREVIEWCURRENT li.selected').removeClass('selected'); el.addClass('selected'); - $('#PREVIEWCURRENTCONT').animate({'scrollLeft':($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width()/2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))}); + $('#PREVIEWCURRENTCONT').animate({'scrollLeft': ($('#PREVIEWCURRENT li.selected').position().left + $('#PREVIEWCURRENT li.selected').width() / 2 - ($('#PREVIEWCURRENTCONT').width() / 2 ))}); return; } -function setPreview(){ +function setPreview() { if (!p4.preview.current) return; var zoomable = $('img.record.zoomable'); - if(zoomable.length > 0 && zoomable.hasClass('zoomed')) + if (zoomable.length > 0 && zoomable.hasClass('zoomed')) return; var h = parseInt(p4.preview.current.height); @@ -446,14 +424,13 @@ function setPreview(){ // var h = parseInt(p4.preview.current.flashcontent.height); // var w = parseInt(p4.preview.current.flashcontent.width); // } - var t=20; + var t = 20; var de = 0; var margX = 0; var margY = 0; - if($('#PREVIEWIMGCONT .record_audio').length > 0) - { + if ($('#PREVIEWIMGCONT .record_audio').length > 0) { margY = 100; de = 60; } @@ -491,15 +468,15 @@ function setPreview(){ height: h, top: t, left: l - }).attr('width',w).attr('height',h); + }).attr('width', w).attr('height', h); } -function classicMode(){ - $('#PREVIEWCURRENTCONT').animate({'scrollLeft' : ($('#PREVIEWCURRENT li.selected').position().left - 160)}); +function classicMode() { + $('#PREVIEWCURRENTCONT').animate({'scrollLeft': ($('#PREVIEWCURRENT li.selected').position().left - 160)}); p4.currentViewMode = 'classic'; } -function doudouMode(){ +function doudouMode() { $('#PREVIEWCURRENT li').removeClass('see-all'); $('#PREVIEWCURRENT ul').width('auto'); $('#PREVIEWCURRENTCONT').css({ @@ -509,12 +486,12 @@ function doudouMode(){ viewCurrent($('#PREVIEWCURRENT li.selected')); } -function closePreview(){ +function closePreview() { p4.preview.open = false; hideOverlay(); $('#PREVIEWBOX').fadeTo(500, 0); - $('#PREVIEWBOX').queue(function(){ + $('#PREVIEWBOX').queue(function () { $(this).css({ 'display': 'none' }); diff --git a/www/include/jquery.tooltip.js b/www/include/jquery.tooltip.js index 75d8f29370..8ddca19495 100644 --- a/www/include/jquery.tooltip.js +++ b/www/include/jquery.tooltip.js @@ -13,7 +13,7 @@ * http://www.gnu.org/licenses/gpl.html */ -(function($) { +(function ($) { // the tooltip element var helper = {}, @@ -28,15 +28,15 @@ $.tooltip = { blocked: false, - ajaxTimeout : false, - ajaxRequest : false, - ajaxEvent : false, + ajaxTimeout: false, + ajaxRequest: false, + ajaxEvent: false, current: null, visible: false, defaults: { delay: 700, - fixable:false, - fixableIndex:100, + fixable: false, + fixableIndex: 100, fade: true, showURL: true, outside: true, @@ -45,27 +45,26 @@ left: 15, id: "tooltip" }, - block: function() { + block: function () { $.tooltip.blocked = !$.tooltip.blocked; }, - delayAjax : function(a,b,c) - { + delayAjax: function (a, b, c) { var options_serial = p4.tot_options; var query = p4.tot_query; var datas = { - options_serial:options_serial, - query:query + options_serial: options_serial, + query: query }; $.tooltip.ajaxRequest = $.ajax({ url: $.tooltip.current.tooltipSrc, - type:'post', - data:datas, - success: function(data) { + type: 'post', + data: datas, + success: function (data) { title = data; positioning($.tooltip.ajaxEvent); }, - "error":function(){ + "error": function () { return; } }); @@ -73,10 +72,10 @@ }; $.fn.extend({ - tooltip: function(settings) { + tooltip: function (settings) { settings = $.extend({}, $.tooltip.defaults, settings); createHelper(settings); - return this.each(function() { + return this.each(function () { $.data(this, "tooltip", settings); // copy tooltip into its own expando and remove the title this.tooltipText = $(this).attr('title'); @@ -94,7 +93,7 @@ .mouseout(hide) .mousedown(fix); }, - fixPNG: IE ? function() { + fixPNG: IE ? function () { return this.each(function () { var image = $(this).css('backgroundImage'); if (image.match(/^url\(["']?(.*\.png)["']?\)$/i)) { @@ -109,32 +108,32 @@ }); } }); - } : function() { + } : function () { return this; }, - unfixPNG: IE ? function() { + unfixPNG: IE ? function () { return this.each(function () { $(this).css({ 'filter': '', backgroundImage: '' }); }); - } : function() { + } : function () { return this; }, - hideWhenEmpty: function() { - return this.each(function() { + hideWhenEmpty: function () { + return this.each(function () { $(this)[ $(this).html() ? "show" : "hide" ](); }); }, - url: function() { + url: function () { return this.attr('href') || this.attr('src'); } }); function createHelper(settings) { // there can be only one tooltip helper - if( helper.parent ) + if (helper.parent) return; // create the helper, h3 for title, div for url helper.parent = $('
') @@ -144,7 +143,7 @@ .hide(); // apply bgiframe if available - if ( $.fn.bgiframe ) + if ($.fn.bgiframe) helper.parent.bgiframe(); // save references to title and url elements @@ -160,11 +159,11 @@ // main event handler to start showing tooltips function handle(event) { - if($($.tooltip.current).hasClass('SSTT') && $($.tooltip.current).hasClass('ui-state-active')) + if ($($.tooltip.current).hasClass('SSTT') && $($.tooltip.current).hasClass('ui-state-active')) return; // show helper, either with timeout or on instant - if( settings(this).delay ) + if (settings(this).delay) tID = setTimeout(visible, settings(this).delay); else visible(); @@ -181,12 +180,12 @@ // save elements title before the tooltip is displayed function save(event) { // if this is the current source, or it has no title (occurs with click event), stop - if(event.stopPropagation) + if (event.stopPropagation) event.stopPropagation(); event.cancelBubble = true; - if ( $.tooltip.blocked || this == $.tooltip.current || (!this.tooltipText && !this.tooltipSrc && !settings(this).bodyHandler) ) + if ($.tooltip.blocked || this == $.tooltip.current || (!this.tooltipText && !this.tooltipSrc && !settings(this).bodyHandler)) return; // save current @@ -194,28 +193,26 @@ title = this.tooltipText; // if element has href or src, add and show it, otherwise hide it - if( settings(this).showURL && $(this).url() ) - helper.url.html( $(this).url().replace('http://', '') ).show(); + if (settings(this).showURL && $(this).url()) + helper.url.html($(this).url().replace('http://', '')).show(); else helper.url.hide(); // add an optional class for this tip // helper.parent.addClass(settings(this).extraClass); - if(this.ajaxLoad) - { + if (this.ajaxLoad) { clearTimeout($.tooltip.ajaxTimeout); $.tooltip.ajaxTimeout = setTimeout("$.tooltip.delayAjax()", 300); $.tooltip.ajaxEvent = event; } - else - { - title = '
'+ - '
'+ - '
'+ - '
'+ - title+ - '
'+ - '
'+ + else { + title = '
' + + '
' + + '
' + + '
' + + title + + '
' + + '
' + '
'; positioning.apply(this, arguments); @@ -224,16 +221,14 @@ } - function positioning(event) - { + function positioning(event) { helper.body.html(title); helper.body.show(); $this = $.tooltip.current; // fix PNG background for IE - if (settings($this).fixPNG ) + if (settings($this).fixPNG) helper.parent.fixPNG(); - if(settings($this).outside) - { + if (settings($this).outside) { var width = 'auto'; var height = 'auto'; var ratio = 1; @@ -245,53 +240,52 @@ resizeImgTips = true; width = parseInt($imgTips[0].style.width); height = parseInt($imgTips[0].style.height); - ratio = width/height; - $imgTips.css({top:'0px',left:'0px'}); + ratio = width / height; + $imgTips.css({top: '0px', left: '0px'}); } if ($videoTips[0] && $('#' + settings($.tooltip.current).id + ' .noToolTipResize').length === 0) { resizeVideoTips = true; width = parseInt($videoTips.attr('width')); height = parseInt($videoTips.attr('height')); - ratio = width/height; - $videoTips.css({top:'0px',left:'0px'}); + ratio = width / height; + $videoTips.css({top: '0px', left: '0px'}); } var v = viewport(), h = helper.parent; helper.parent.css({ - width:width, - top:0, - left:0, - visibility:'hidden', + width: width, + top: 0, + left: 0, + visibility: 'hidden', // visibility:'visible', - display:'block', - height:height + display: 'block', + height: height }); $(h).width($(h).width()); - width = ($(h).width()>(v.x-40))?(v.x-40):$(h).width(); - height = ($(h).height()>(v.y-40))?(v.y-40):$(h).height(); + width = ($(h).width() > (v.x - 40)) ? (v.x - 40) : $(h).width(); + height = ($(h).height() > (v.y - 40)) ? (v.y - 40) : $(h).height(); // $('#' + 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; } $(h).css({ - width:width, - height:height + width: width, + height: height }); if (event) { - var vert, vertS, hor, horS, top, left,ratioH,ratioV; + var vert, vertS, hor, horS, top, left, ratioH, ratioV; // ratio = $(h).width()/$(h).height(); var ratioSurfaceH; - var ratioSurfaceV, wiH,wiV,heH,heV; - var ratioImage = $(h).width()/$(h).height(); + var ratioSurfaceV, wiH, wiV, heH, heV; + var ratioImage = $(h).width() / $(h).height(); //position de l'image if ($(event.target).offset().left > (v.x - $(event.target).offset().left - $(event.target).width())) { @@ -325,66 +319,58 @@ //correction par ratio if (resizeImgTips && $('#' + settings($.tooltip.current).id + ' .imgTips')[0]) { - if(ratioSurfaceH > ratioImage) - { - horS = v.y * ratioImage*v.y; + if (ratioSurfaceH > ratioImage) { + horS = v.y * ratioImage * v.y; } - else - { - horS = wiH * wiH/ratioImage; + else { + horS = wiH * wiH / ratioImage; } - if(ratioSurfaceV > ratioImage) - { - vertS = heV * ratioImage*heV; + if (ratioSurfaceV > ratioImage) { + vertS = heV * ratioImage * heV; } - else - { - vertS = v.x * v.x/ratioImage; + else { + vertS = v.x * v.x / ratioImage; } } 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 zW = $(h).width(); zH = $(h).height(); var ETOT = $(event.target).offset().top; var ETH = $(event.target).height(); - left = (zL - zW/2)<20?20:(((zL + zW/2+20)>v.x)?(v.x-zW-20):(zL -zW/2)); - switch(vert) - { + left = (zL - zW / 2) < 20 ? 20 : (((zL + zW / 2 + 20) > v.x) ? (v.x - zW - 20) : (zL - zW / 2)); + switch (vert) { case 'haut': - height = (zH>(ETOT-40))?(ETOT-40):zH; - top = ETOT - height-20; + height = (zH > (ETOT - 40)) ? (ETOT - 40) : zH; + top = ETOT - height - 20; break; case 'bas': - height = ((v.y-ETH-ETOT-40)>zH)?zH:(v.y-ETH-ETOT-40); - top = ETOT +ETH+20; + height = ((v.y - ETH - ETOT - 40) > zH) ? zH : (v.y - ETH - ETOT - 40); + top = ETOT + ETH + 20; break; default: break; } } - else - { + else { // height = ($(h).height()>(v.y-40))?(v.y-40):$(h).height(); zH = $(h).height(); var zT = event.pageY; var EOTL = $(event.target).offset().left; var ETW = $(event.target).width(); var zw = $(h).width(); - top = (zT - zH/2)<20?20:(((zT + zH/2+20)>v.y)?(v.y-zH-20):(zT - zH/2)); - switch(hor) - { + top = (zT - zH / 2) < 20 ? 20 : (((zT + zH / 2 + 20) > v.y) ? (v.y - zH - 20) : (zT - zH / 2)); + switch (hor) { case 'gauche': - width = (zw>(EOTL-40))?(EOTL-40):zw; - left = EOTL - width-20; + width = (zw > (EOTL - 40)) ? (EOTL - 40) : zw; + left = EOTL - width - 20; break; case 'droite': - width = ((v.x-ETW-EOTL-40)>zw)?zw:(v.x-ETW-EOTL-40); - left = EOTL +ETW+20; + width = ((v.x - ETW - EOTL - 40) > zw) ? zw : (v.x - ETW - EOTL - 40); + left = EOTL + ETW + 20; break; default: break; @@ -401,9 +387,9 @@ //si ya une image on re-ajuste au ratio if (resizeImgTips && $('#' + settings($.tooltip.current).id + ' .imgTips')[0]) { - if(width == 'auto') + if (width == 'auto') width = $('#' + settings($.tooltip.current).id).width(); - if(height == 'auto') + if (height == 'auto') height = $('#' + settings($.tooltip.current).id).height(); if (ratio > 1) { var nh = width / ratio; @@ -421,16 +407,13 @@ } width = nw; } - }else - { - if(vertS < horS) - { + } else { + if (vertS < horS) { height = 'auto'; } } - if(resizeImgTips) - { + if (resizeImgTips) { var factor = Math.min((width - 45) / width, (height - 75) / height); var imgWidth = Math.round(width * 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 imgWidth = Math.round(width * factor); var imgHeight = Math.round(height * factor); @@ -488,25 +470,23 @@ update(); } - function fix(event) - { - if(!settings(this).fixable) - { + function fix(event) { + if (!settings(this).fixable) { hide(event); return; } event.cancelBubble = true; - if(event.stopPropagation) + if (event.stopPropagation) event.stopPropagation(); - showOverlay('_tooltip','body',unfix_tooltip, settings(this).fixableIndex); + showOverlay('_tooltip', 'body', unfix_tooltip, settings(this).fixableIndex); $('#tooltip .tooltip_closer').show().bind('click', unfix_tooltip); $.tooltip.blocked = true; } - function visible(){ + function visible() { $.tooltip.visible = true; helper.parent.css({ - visibility:'visible' + visibility: 'visible' }); } @@ -515,9 +495,9 @@ * updates the helper position * removes itself when no current element */ - function update(event) { + function update(event) { - if($.tooltip.blocked) + if ($.tooltip.blocked) return; if (event && event.target.tagName == "OPTION") { @@ -525,12 +505,12 @@ } // stop updating when tracking is disabled and the tooltip is visible - if ( !track && helper.parent.is(":visible")) { + if (!track && helper.parent.is(":visible")) { $(document.body).unbind('mousemove', update); } // if no current element is available, remove this listener - if( $.tooltip.current === null ) { + if ($.tooltip.current === null) { $(document.body).unbind('mousemove', update); return; } @@ -538,8 +518,7 @@ // remove position helper classes 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 top = helper.parent[0].offsetTop; helper.parent.width('auto'); @@ -548,7 +527,7 @@ // position the helper 15 pixel to bottom right, starting from mouse position left = event.pageX + settings($.tooltip.current).left; top = event.pageY + settings($.tooltip.current).top; - var right='auto'; + var right = 'auto'; if (settings($.tooltip.current).positionLeft) { right = $(window).width() - left; left = 'auto'; @@ -590,27 +569,26 @@ } // hide helper and restore added classes and the title - function hide(event) - { - if($.tooltip.blocked || !$.tooltip.current) + function hide(event) { + if ($.tooltip.blocked || !$.tooltip.current) return; // clear timeout if possible - if(tID) + if (tID) clearTimeout(tID); // no more current element $.tooltip.visible = false; var tsettings = settings($.tooltip.current); clearTimeout($.tooltip.ajaxTimeout); - if($.tooltip.ajaxRequest && $.tooltip.ajaxRequest.abort) - { + if ($.tooltip.ajaxRequest && $.tooltip.ajaxRequest.abort) { $.tooltip.ajaxRequest.abort(); } helper.body.empty(); $.tooltip.current = null; 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 (helper.parent.is(':animated')) helper.parent.stop().fadeTo(tsettings.fade, 0, complete); @@ -619,14 +597,13 @@ } else complete(); - if( tsettings.fixPNG ) + if (tsettings.fixPNG) helper.parent.unfixPNG(); } })(jQuery); -function unfix_tooltip() -{ +function unfix_tooltip() { $.tooltip.blocked = false; $.tooltip.visible = false; $.tooltip.current = null; @@ -636,9 +613,8 @@ function unfix_tooltip() } -$(document).bind('keydown', function(event){ - if(event.keyCode == 27 && $.tooltip.blocked === true) - { +$(document).bind('keydown', function (event) { + if (event.keyCode == 27 && $.tooltip.blocked === true) { unfix_tooltip(); } }); diff --git a/www/include/js/jquery.Edit.js b/www/include/js/jquery.Edit.js index b5cf581a84..8665472b1a 100644 --- a/www/include/js/jquery.Edit.js +++ b/www/include/js/jquery.Edit.js @@ -1,47 +1,45 @@ +(function (window) { -(function( window ) { - - function checkVocabId(VocabularyId) - { - if(typeof VocabularyId === 'undefined') + function checkVocabId(VocabularyId) { + if (typeof VocabularyId === 'undefined') VocabularyId = null; - if(VocabularyId === '') + if (VocabularyId === '') VocabularyId = null; return VocabularyId; } - var recordFieldValue = function(meta_id, value, VocabularyId) { + var recordFieldValue = function (meta_id, value, VocabularyId) { VocabularyId = checkVocabId(VocabularyId); this.datas = { - meta_id:meta_id, - value:value, - VocabularyId:VocabularyId + meta_id: meta_id, + value: value, + VocabularyId: VocabularyId }; var $this = this; }; recordFieldValue.prototype = { - getValue : function() { + getValue: function () { return this.datas.value; }, - getMetaId : function() { + getMetaId: function () { return this.datas.meta_id; }, - getVocabularyId : function() { + getVocabularyId: function () { return this.datas.VocabularyId; }, - setValue : function(value, VocabularyId) { + setValue: function (value, VocabularyId) { this.datas.value = value; this.datas.VocabularyId = checkVocabId(VocabularyId); return this; }, - remove : function() { + remove: function () { this.datas.value = ''; this.datas.VocabularyId = null; @@ -49,23 +47,22 @@ } }; - var databoxField = function(name, label, meta_struct_id, options) { + var databoxField = function (name, label, meta_struct_id, options) { var defaults = { - multi : false, - required : false, - readonly : false, - maxLength : null, - minLength : null, - type : 'string', - separator : null, - vocabularyControl : null, - vocabularyRestricted : false + multi: false, + required: false, + readonly: false, + maxLength: null, + minLength: null, + type: 'string', + separator: null, + vocabularyControl: null, + vocabularyRestricted: false }, options = (typeof options == 'object') ? options : {}; - if(isNaN(meta_struct_id)) - { + if (isNaN(meta_struct_id)) { throw 'meta_struct_id should be a number'; } @@ -74,93 +71,83 @@ this.meta_struct_id = meta_struct_id; 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 = ';'; } }; databoxField.prototype = { - getMetaStructId : function() { + getMetaStructId: function () { return this.meta_struct_id; }, - getName : function() { + getName: function () { return this.name; }, - getLabel : function() { + getLabel: function () { return this.label; }, - isMulti : function() { + isMulti: function () { return this.options.multi; }, - isRequired : function() { + isRequired: function () { return this.options.required; }, - isReadonly : function() { + isReadonly: function () { return this.options.readonly; }, - getMaxLength : function() { + getMaxLength: function () { return this.options.maxLength; }, - getMinLength : function() { + getMinLength: function () { return this.options.minLength; }, - getType : function() { + getType: function () { return this.options.type; }, - getSeparator : function() { + getSeparator: function () { return this.options.separator; } }; - var recordField = function(databoxField, arrayValues) { + var recordField = function (databoxField, arrayValues) { this.databoxField = databoxField; this.options = { - dirty : false + dirty: false }; this.datas = new Array(); - if(arrayValues instanceof Array) - { - if(arrayValues.length > 1 && !databoxField.isMulti()) + if (arrayValues instanceof Array) { + if (arrayValues.length > 1 && !databoxField.isMulti()) throw 'You can not add multiple values to a non multi field ' + databoxField.getName(); var first = true; - for(v in arrayValues) - { - if(typeof arrayValues[v] !== 'object') - { - if(window.console) - { + for (v in arrayValues) { + if (typeof arrayValues[v] !== 'object') { + if (window.console) { console.error('Trying to add a non-recordFieldValue to the field...'); } continue; } - if(isNaN(arrayValues[v].getMetaId())) - { - if(window.console) - { + if (isNaN(arrayValues[v].getMetaId())) { + if (window.console) { console.error('Trying to add a recordFieldValue without metaId...'); } continue; } - if(!first && this.options.multi === false) - { - if(window.console) - { + if (!first && this.options.multi === false) { + if (window.console) { 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]); } @@ -172,101 +159,81 @@ var $this = this; } recordField.prototype = { - getName : function() { + getName: function () { return this.databoxField.getName(); }, - getMetaStructId : function() { + getMetaStructId: function () { return this.databoxField.getMetaStructId(); }, - isMulti : function() { + isMulti: function () { return this.databoxField.isMulti(); }, - isRequired : function() { + isRequired: function () { return this.databoxField.isRequired(); }, - isDirty : function() { + isDirty: function () { return this.options.dirty; }, - addValue : function(value, merge, VocabularyId) { + addValue: function (value, merge, VocabularyId) { VocabularyId = checkVocabId(VocabularyId); merge = !!merge; - if(this.databoxField.isReadonly()) - { - if(window.console) - { + if (this.databoxField.isReadonly()) { + if (window.console) { console.error('Unable to set a value to a readonly field'); } return; } - if(window.console) - { - console.log('adding value ',value,' vocId : ', VocabularyId , ' ; merge is ',merge); + if (window.console) { + console.log('adding value ', value, ' vocId : ', VocabularyId, ' ; merge is ', merge); } - if(this.isMulti()) - { - if(!this.hasValue(value, VocabularyId)) - { - if(window.console) - { - console.log('adding new multi value ',value); + if (this.isMulti()) { + if (!this.hasValue(value, VocabularyId)) { + if (window.console) { + console.log('adding new multi value ', value); } this.datas.push(new recordFieldValue(null, value, VocabularyId)); this.options.dirty = true; } - else - { - if(window.console) - { - console.log('already have ',value); + else { + if (window.console) { + console.log('already have ', value); } } } - else - { - if(merge === true && this.isEmpty() === false && VocabularyId === null) - { - if(window.console) - { - console.log('Merging value ',value); + else { + if (merge === true && this.isEmpty() === false && VocabularyId === null) { + if (window.console) { + console.log('Merging value ', value); } this.datas[0].setValue(this.datas[0].getValue() + ' ' + value, VocabularyId); this.options.dirty = true; } - else - { - if(merge === true && this.isEmpty() === false && VocabularyId !== null) - { - if(window.console) - { + else { + if (merge === true && this.isEmpty() === false && VocabularyId !== null) { + if (window.console) { console.error('Cannot merge vocabularies'); } this.datas[0].setValue(value, VocabularyId); } - else - { + else { - if(!this.hasValue(value, VocabularyId)) - { - if(this.datas.length === 0) - { - if(window.console) - { - console.log('Adding new value ',value); + if (!this.hasValue(value, VocabularyId)) { + if (this.datas.length === 0) { + if (window.console) { + console.log('Adding new value ', value); } this.datas.push(new recordFieldValue(null, value, VocabularyId)); } - else - { - if(window.console) - { - console.log('Updating value ',value); + else { + if (window.console) { + console.log('Updating value ', value); } this.datas[0].setValue(value, VocabularyId); } @@ -278,35 +245,27 @@ return this; }, - hasValue : function(value, VocabularyId) { + hasValue: function (value, VocabularyId) { - if(typeof value === 'undefined') - { - if(window.console) - { + if (typeof value === 'undefined') { + if (window.console) { console.error('Trying to check the presence of an undefined value'); } } VocabularyId = checkVocabId(VocabularyId); - for(d in this.datas) - { - if(VocabularyId !== null) - { - if(this.datas[d].getVocabularyId() === VocabularyId) - { - if(window.console) - { + for (d in this.datas) { + if (VocabularyId !== null) { + if (this.datas[d].getVocabularyId() === VocabularyId) { + if (window.console) { console.log('already got the vocab ID'); } return true; } } - else if(this.datas[d].getVocabularyId() === null && this.datas[d].getValue() == value) - { - if(window.console) - { + else if (this.datas[d].getVocabularyId() === null && this.datas[d].getValue() == value) { + if (window.console) { console.log('already got this value'); } return true; @@ -314,12 +273,10 @@ } return false; }, - removeValue : function(value, vocabularyId) { + removeValue: function (value, vocabularyId) { - if(this.databoxField.isReadonly()) - { - if(window.console) - { + if (this.databoxField.isReadonly()) { + if (window.console) { console.error('Unable to set a value to a readonly field'); } @@ -328,33 +285,25 @@ vocabularyId = checkVocabId(vocabularyId); - if(window.console) - { + if (window.console) { console.log('Try to remove value ', value, vocabularyId, this.datas); } - for(d in this.datas) - { - if(window.console) - { + for (d in this.datas) { + if (window.console) { console.log('loopin... ', this.datas[d].getValue()); } - if(this.datas[d].getVocabularyId() !== null) - { - if(this.datas[d].getVocabularyId() == vocabularyId) - { - if(window.console) - { + if (this.datas[d].getVocabularyId() !== null) { + if (this.datas[d].getVocabularyId() == vocabularyId) { + if (window.console) { console.log('Found within the vocab ! removing... '); } this.datas[d].remove(); this.options.dirty = true; } } - else if(this.datas[d].getValue() == value) - { - if(window.console) - { + else if (this.datas[d].getValue() == value) { + if (window.console) { console.log('Found ! removing... '); } this.datas[d].remove(); @@ -363,60 +312,54 @@ } return this; }, - isEmpty : function() { + isEmpty: function () { var empty = true; - for(d in this.datas) - { - if(this.datas[d].getValue() !== '') + for (d in this.datas) { + if (this.datas[d].getValue() !== '') empty = false; } return empty; }, - empty : function() { + empty: function () { - if(this.databoxField.isReadonly()) - { - if(window.console) - { + if (this.databoxField.isReadonly()) { + if (window.console) { console.error('Unable to set a value to a readonly field'); } return; } - for(d in this.datas) - { + for (d in this.datas) { this.datas[d].remove(); this.options.dirty = true; } return this; }, - getValue : function() { + getValue: function () { - if(this.isMulti()) + if (this.isMulti()) throw 'This field is multi, I can not give you a single value'; - if(this.isEmpty()) + if (this.isEmpty()) return null; return this.datas[0]; }, - getValues : function() { + getValues: function () { - if(!this.isMulti()) - { + if (!this.isMulti()) { throw 'This field is not multi, I can not give you multiple values'; } - if(this.isEmpty()) + if (this.isEmpty()) return new Array(); var arrayValues = []; - for(d in this.datas) - { - if(this.datas[d].getValue() === '') + for (d in this.datas) { + if (this.datas[d].getValue() === '') continue; arrayValues.push(this.datas[d]); @@ -424,29 +367,26 @@ return arrayValues; }, - sort : function(algo) { + sort: function (algo) { this.datas.sort(algo); return this; }, - getSerializedValues : function() { + getSerializedValues: function () { var arrayValues = []; var values = this.getValues(); - for(v in values) - { + for (v in values) { arrayValues.push(values[v].getValue()); } return arrayValues.join(' ' + this.databoxField.getSeparator() + ' '); }, - replaceValue : function(search, replace) { + replaceValue: function (search, replace) { - if(this.databoxField.isReadonly()) - { - if(window.console) - { + if (this.databoxField.isReadonly()) { + if (window.console) { console.error('Unable to set a value to a readonly field'); } @@ -455,18 +395,15 @@ var n = 0; - for(d in this.datas) - { - if(this.datas[d].getVocabularyId() !== null) - { + for (d in this.datas) { + if (this.datas[d].getVocabularyId() !== null) { continue; } var value = this.datas[d].getValue(); var replacedValue = value.replace(search, replace); - if(value === replacedValue) - { + if (value === replacedValue) { continue; } @@ -474,8 +411,7 @@ this.removeValue(value); - if(!this.hasValue(replacedValue)) - { + if (!this.hasValue(replacedValue)) { this.addValue(replacedValue); } @@ -484,20 +420,18 @@ return n; }, - exportDatas : function() { + exportDatas: function () { var returnValue = new Array(); - for(d in this.datas) - { + for (d in this.datas) { var temp = { - meta_id : this.datas[d].getMetaId() ? this.datas[d].getMetaId() : '', - meta_struct_id : this.getMetaStructId(), - value : this.datas[d].getValue() + meta_id: this.datas[d].getMetaId() ? this.datas[d].getMetaId() : '', + meta_struct_id: this.getMetaStructId(), + value: this.datas[d].getValue() }; - if(this.datas[d].getVocabularyId()) - { + if (this.datas[d].getVocabularyId()) { temp.vocabularyId = this.datas[d].getVocabularyId(); } returnValue.push(temp); diff --git a/www/include/js/jquery.Selection.js b/www/include/js/jquery.Selection.js index f0415bfa33..db6d30c24e 100644 --- a/www/include/js/jquery.Selection.js +++ b/www/include/js/jquery.Selection.js @@ -4,27 +4,25 @@ * */ -(function( window ) { +(function (window) { - var Selectable = function($container, options) { + var Selectable = function ($container, options) { var defaults = { - allow_multiple : false, - selector : '', - callbackSelection : null, - selectStart : null, - selectStop : null, - limit : null + allow_multiple: false, + selector: '', + callbackSelection: null, + selectStart: null, + selectStop: null, + limit: null }, options = (typeof options == 'object') ? options : {}; var $this = this; - if($container.data('selectionnable')) - { + if ($container.data('selectionnable')) { /* this container is already selectionnable */ - if(window.console) - { + if (window.console) { console.error('Trying to apply new selection to existing one'); } @@ -39,10 +37,9 @@ this.$container.addClass('selectionnable'); 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); } @@ -50,15 +47,13 @@ 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 index1 = jQuery.inArray( jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst ); - var index2 = jQuery.inArray( $that[0], lst ); + var index1 = jQuery.inArray(jQuery('.last_selected', this.$container).filter($this.options.selector)[0], lst); + var index2 = jQuery.inArray($that[0], lst); - if(index2= 0; + return jQuery.inArray(element, this.datas) >= 0; }, - get : function(){ + get: function () { return this.datas; }, - empty : function(){ + empty: function () { var $this = this; this.datas = new Array(); jQuery(this.options.selector, this.$container).filter('.selected:visible').removeClass('selected'); - if(typeof $this.options.selectStop === 'function') - { + if (typeof $this.options.selectStop === 'function') { $this.options.selectStop(jQuery.Event('selectStop'), $this); } return this; }, - length : function(){ + length: function () { return this.datas.length; }, - size : function(){ + size: function () { return this.datas.length; }, - serialize : function(separator){ + serialize: function (separator) { separator = separator || ';'; return this.datas.join(separator); }, - selectAll : function(){ + selectAll: function () { this.select('*'); return this; }, - select : function(selector){ + select: function (selector) { var $this = this, stopped = false; - jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function(){ - if(!$this.hasReachLimit()) - { + jQuery(this.options.selector, this.$container).filter(selector).not('.selected').filter(':visible').each(function () { + if (!$this.hasReachLimit()) { $this.push(get_value(this, $this)); $(this).addClass('selected'); } - else - { - if(stopped === false) - { + else { + if (stopped === false) { alert(language.max_record_selected); } 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); } diff --git a/www/include/js/jquery.lists.js b/www/include/js/jquery.lists.js index 64e3d286c7..c3c5886990 100644 --- a/www/include/js/jquery.lists.js +++ b/www/include/js/jquery.lists.js @@ -1,15 +1,14 @@ var p4 = p4 || {}; -(function( window, p4, $ ) { +(function (window, p4, $) { - var Lists = function() { + var Lists = function () { }; var List = function (id) { - if(parseInt(id) <= 0) - { + if (parseInt(id) <= 0) { throw 'Invalid list id'; } @@ -17,7 +16,7 @@ var p4 = p4 || {}; }; Lists.prototype = { - create : function(name, callback){ + create: function (name, callback) { var $this = this; @@ -25,27 +24,24 @@ var p4 = p4 || {}; type: 'POST', url: '/prod/lists/list/', dataType: 'json', - data: {name : name}, - success: function(data){ - if(data.success) - { + data: {name: name}, + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { var list = new List(data.list_id); callback(list); } } - else - { + else { humane.error(data.message); } } }); }, - get : function(callback, type) { + get: function (callback, type) { var $this = this; type = typeof type === 'undefined' ? 'json' : type; @@ -55,27 +51,21 @@ var p4 = p4 || {}; url: '/prod/lists/all/', dataType: type, data: {}, - success: function(data){ - if(type == 'json') - { - if(data.success) - { + success: function (data) { + if (type == 'json') { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback(data.result); } } - else - { + else { humane.error(data.message); } } - else - { - if(typeof callback === 'function') - { + else { + if (typeof callback === 'function') { callback(data); } } @@ -86,42 +76,38 @@ var p4 = p4 || {}; } List.prototype = { - addUsers : function(arrayUsers, callback) { + addUsers: function (arrayUsers, callback) { - if(!arrayUsers instanceof Array) - { + if (!arrayUsers instanceof Array) { throw 'addUsers takes array as argument'; } var $this = this; - var data = {usr_ids : $(arrayUsers).toArray()}; + var data = {usr_ids: $(arrayUsers).toArray()}; $.ajax({ type: 'POST', url: '/prod/lists/list/' + $this.id + '/add/', dataType: 'json', data: data, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this, data); } } - else - { + else { humane.error(data.message); } } }); }, - addUser : function(usr_id, callback) { + addUser: function (usr_id, callback) { this.addUsers([usr_id], callback); }, - remove : function(callback) { + remove: function (callback) { var $this = this; @@ -130,24 +116,21 @@ var p4 = p4 || {}; url: '/prod/lists/list/' + this.id + '/delete/', dataType: 'json', data: {}, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this); } } - else - { + else { humane.error(data.message); } } }); }, - update : function(name, callback) { + update: function (name, callback) { var $this = this; @@ -155,25 +138,22 @@ var p4 = p4 || {}; type: 'POST', url: '/prod/lists/list/' + this.id + '/update/', dataType: 'json', - data: { name : name }, - success: function(data){ - if(data.success) - { + data: { name: name }, + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this); } } - else - { + else { humane.error(data.message); } } }); }, - removeUser : function(usr_id, callback) { + removeUser: function (usr_id, callback) { var $this = this; @@ -182,24 +162,21 @@ var p4 = p4 || {}; url: '/prod/lists/list/' + this.id + '/remove/' + usr_id + '/', dataType: 'json', data: {}, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this, data); } } - else - { + else { humane.error(data.message); } } }); }, - shareWith : function(usr_id, role, callback) { + shareWith: function (usr_id, role, callback) { var $this = this; @@ -207,25 +184,22 @@ var p4 = p4 || {}; type: 'POST', url: '/prod/lists/list/' + this.id + '/share/' + usr_id + '/', dataType: 'json', - data: {role : role}, - success: function(data){ - if(data.success) - { + data: {role: role}, + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this); } } - else - { + else { humane.error(data.message); } } }); }, - unshareWith : function(callback) { + unshareWith: function (callback) { var $this = this; @@ -234,24 +208,21 @@ var p4 = p4 || {}; url: '/prod/lists/list/' + this.id + '/unshare/' + usr_id + '/', dataType: 'json', data: {}, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this); } } - else - { + else { humane.error(data.message); } } }); }, - get : function(callback) { + get: function (callback) { var $this = this; @@ -260,18 +231,15 @@ var p4 = p4 || {}; url: '/prod/lists/list/' + this.id + '/', dataType: 'json', data: {}, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); - if(typeof callback === 'function') - { + if (typeof callback === 'function') { callback($this, data); } } - else - { + else { humane.error(data.message); } } diff --git a/www/include/path_files_tests.jquery.js b/www/include/path_files_tests.jquery.js index 90d10861fc..2607643157 100644 --- a/www/include/path_files_tests.jquery.js +++ b/www/include/path_files_tests.jquery.js @@ -1,18 +1,17 @@ -(function( $ ){ +(function ($) { var methods = { - init : function( options ) { + init: function (options) { var settings = { - 'url' : '/admin/tests/pathurl/path/' + 'url': '/admin/tests/pathurl/path/' }; - return this.each(function() { + return this.each(function () { var $this = $(this), data = $(this).data('path_file_tests'); - if ( ! data ) - { - if ( options ) { - $.extend( settings, options ); + if (!data) { + if (options) { + $.extend(settings, options); } $this.data('path_file_tests', {}); @@ -21,19 +20,18 @@ $this.after(''); - $this.bind('keyup blur', function(){ + $this.bind('keyup blur', function () { var el_loader = $this.nextAll('.loader'); var el_status = $this.nextAll('.status'); - if($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function') + if ($this.data('ajax_path_test') && typeof $this.data('ajax_path_test').abort == 'function') $this.data('ajax_path_test').abort(); - if(!$this.hasClass('test_executable') && !$this.hasClass('test_writeable') && !$this.hasClass('test_readable')) + if (!$this.hasClass('test_executable') && !$this.hasClass('test_writeable') && !$this.hasClass('test_readable')) return; - if(!$this.hasClass('required') && $.trim($this.val()) === '') - { + if (!$this.hasClass('required') && $.trim($this.val()) === '') { el_status.css('visibility', 'hidden'); return; } @@ -43,43 +41,39 @@ type: "GET", url: settings.url, data: { - path : $this.val() + path: $this.val() }, - beforeSend:function(){ + beforeSend: function () { el_loader.css('visibility', 'visible'); }, - success: function(data){ + success: function (data) { el_loader.css('visibility', 'hidden'); - if($this.hasClass('required')) - { + if ($this.hasClass('required')) { $this.addClass('field_error'); } - if($this.hasClass('test_executable') && (data.executable === false || data.file !== true)) - { - el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible'); + if ($this.hasClass('test_executable') && (data.executable === false || data.file !== true)) { + el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); return; } - if($this.hasClass('test_writeable') && data.writeable === false) - { - el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible'); + if ($this.hasClass('test_writeable') && data.writeable === false) { + el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); return; } - if($this.hasClass('test_readable') && data.readable === false) - { - el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible'); + if ($this.hasClass('test_readable') && data.readable === false) { + el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); return; } - el_status.attr('src','/skins/icons/ok.png').css('visibility', 'visible'); + el_status.attr('src', '/skins/icons/ok.png').css('visibility', 'visible'); $this.removeClass('field_error'); return; }, - timeout:function(){ + timeout: function () { el_loader.css('visibility', 'hidden'); - el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible'); + el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); }, - error:function(){ + error: function () { el_loader.css('visibility', 'hidden'); - el_status.attr('src','/skins/icons/delete.png').css('visibility', 'visible'); + el_status.attr('src', '/skins/icons/delete.png').css('visibility', 'visible'); } }); $this.data('ajax_path_test', ajax); @@ -87,49 +81,46 @@ $this.trigger('keyup'); - $this.nextAll('.reload').bind('click', function(){ + $this.nextAll('.reload').bind('click', function () { $this.trigger('keyup'); }); } }); }, - destroy : function( ) { - return this.each(function() { + destroy: function () { + return this.each(function () { $(this).data('path_file_tests', null); }); } }; - $.fn.path_file_test = function(method) { + $.fn.path_file_test = function (method) { - if ( methods[method] ) { - return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( typeof method === 'object' || ! method ) { - return methods.init.apply( this, arguments ); + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); } else { - $.error( 'Method ' + method + ' does not exist on jQuery.path_file_test' ); + $.error('Method ' + method + ' does not exist on jQuery.path_file_test'); } }; -})( jQuery ); +})(jQuery); - - -(function( $ ){ +(function ($) { var methods = { - init : function( options ) { + init: function (options) { var settings = { - 'url' : '/admin/tests/pathurl/url/' + 'url': '/admin/tests/pathurl/url/' }; - return this.each(function() { + return this.each(function () { var $this = $(this), data = $(this).data('url_tests'); - if ( ! data ) - { - if ( options ) { - $.extend( settings, options ); + if (!data) { + if (options) { + $.extend(settings, options); } $this.data('url_tests', {}); @@ -137,7 +128,7 @@ $this.after(''); $this.after(''); - $this.bind('keyup blur', function(){ + $this.bind('keyup blur', function () { var el_loader = $(this).nextAll('.loader'); var el_status = $(this).nextAll('.status'); @@ -147,91 +138,84 @@ var value = $.trim($this.val()); - if(!required && value === '') - { - el_status.attr('src','/skins/icons/ok.png'); + if (!required && value === '') { + el_status.attr('src', '/skins/icons/ok.png'); return; } - if(required && value === '') - { - el_status.attr('src','/skins/icons/delete.png'); + if (required && value === '') { + el_status.attr('src', '/skins/icons/delete.png'); return; } - if(same_domain && value.substring(0,1) != '/') - { - value = '/'+value; + if (same_domain && value.substring(0, 1) != '/') { + value = '/' + value; } - if(same_domain) - { - value = location.protocol+'//'+location.hostname+value; + if (same_domain) { + value = location.protocol + '//' + location.hostname + value; } - if($this.data('ajax_url_test') && typeof $this.data('ajax_url_test').abort == 'function') + if ($this.data('ajax_url_test') && typeof $this.data('ajax_url_test').abort == 'function') $this.data('ajax_url_test').abort(); var ajax = $.ajax({ type: "GET", url: settings.url, - dataType:'json', + dataType: 'json', data: { - url : value + url: value }, - beforeSend:function(){ + beforeSend: function () { el_loader.css('visibility', 'visible'); }, - success: function(datas){ + success: function (datas) { el_loader.css('visibility', 'hidden'); - if(datas.code === 404) - { - el_status.attr('src','/skins/icons/delete.png'); + if (datas.code === 404) { + el_status.attr('src', '/skins/icons/delete.png'); return; } - if(!listable && datas.code === 403) - { - el_status.attr('src','/skins/icons/ok.png'); + if (!listable && datas.code === 403) { + el_status.attr('src', '/skins/icons/ok.png'); } - else - { - el_status.attr('src','/skins/icons/delete.png'); + else { + el_status.attr('src', '/skins/icons/delete.png'); } return; }, - timeout:function(){ + timeout: function () { el_loader.css('visibility', 'hidden'); - el_status.attr('src','/skins/icons/delete.png'); + el_status.attr('src', '/skins/icons/delete.png'); }, - error:function(datas){ + error: function (datas) { el_loader.css('visibility', 'hidden'); - el_status.attr('src','/skins/icons/delete.png'); + el_status.attr('src', '/skins/icons/delete.png'); } }); $this.data('ajax_url_test', ajax); }); $this.trigger('keyup'); - $this.nextAll('.reload').bind('click', function(){ + $this.nextAll('.reload').bind('click', function () { $this.trigger('keyup'); }); } }); }, - destroy : function( ) { - return this.each(function() { + destroy: function () { + return this.each(function () { $(this).data('url_tests', null); }); } }; - $.fn.url_test = function(method) { + $.fn.url_test = function (method) { - if ( methods[method] ) { - return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); - } else if ( typeof method === 'object' || ! method ) { - return methods.init.apply( this, arguments ); + if (methods[method]) { + return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); + } else if (typeof method === 'object' || !method) { + return methods.init.apply(this, arguments); } else { - $.error( 'Method ' + method + ' does not exist on jQuery.url_test' ); + $.error('Method ' + method + ' does not exist on jQuery.url_test'); } }; -})( jQuery ); +})(jQuery); diff --git a/www/scripts/apps/admin/fields/app.js b/www/scripts/apps/admin/fields/app.js index 6470c314ee..936935c785 100644 --- a/www/scripts/apps/admin/fields/app.js +++ b/www/scripts/apps/admin/fields/app.js @@ -19,19 +19,17 @@ define([ "apps/admin/fields/views/save", "apps/admin/fields/views/fieldError", "apps/admin/fields/errors/errorManager" -], function( - $, _, Backbone, i18n, FieldsCollection, VocabulariesCollection, - DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) { - var initialize = function() { +], function ($, _, Backbone, i18n, FieldsCollection, VocabulariesCollection, DcFieldsCollection, FieldListView, SaveView, FieldErrorView, ErrorManager) { + var initialize = function () { AdminFieldApp = { - $window : $(window), - $scope : $("#admin-field-app"), - $top : $(".row-top", this.$scope), - $bottom : $(".row-bottom", this.$scope), - $leftBlock : $(".left-block", this.$bottom), - $rightBlock : $(".right-block", this.$bottom), - fieldsToDelete : [], - lng : function() { + $window: $(window), + $scope: $("#admin-field-app"), + $top: $(".row-top", this.$scope), + $bottom: $(".row-bottom", this.$scope), + $leftBlock: $(".left-block", this.$bottom), + $rightBlock: $(".right-block", this.$bottom), + fieldsToDelete: [], + lng: function () { return typeof p4 === "undefined" ? "en" : (p4.lng || "en"); }, resizeListBlock: function () { @@ -56,7 +54,7 @@ define([ // initiliaze collections AdminFieldApp.fieldsCollection = new FieldsCollection(null, { - sbas_id : AdminFieldApp.sbas_id + sbas_id: AdminFieldApp.sbas_id }); AdminFieldApp.vocabularyCollection = new VocabulariesCollection(); AdminFieldApp.dcFieldsCollection = new DcFieldsCollection(); @@ -71,12 +69,12 @@ define([ AdminFieldApp.dcFieldsCollection.fetch(), $.ajax({ url: '/available-languages', - success: function(languages) { + success: function (languages) { AdminFieldApp.languages = languages; } }) ]).done( - function() { + function () { // register views AdminFieldApp.saveView = new SaveView({ el: $(".save-block", AdminFieldApp.scope) @@ -96,7 +94,7 @@ define([ AdminFieldApp.$window.trigger("resize"); // click on first item list - if (AdminFieldApp.fieldListView.itemViews.length > 0 ) { + if (AdminFieldApp.fieldListView.itemViews.length > 0) { _.first(AdminFieldApp.fieldListView.itemViews).clickAction().animate(); } } diff --git a/www/scripts/apps/admin/fields/collections/dcFields.js b/www/scripts/apps/admin/fields/collections/dcFields.js index 29f78c4885..0e66ed8258 100644 --- a/www/scripts/apps/admin/fields/collections/dcFields.js +++ b/www/scripts/apps/admin/fields/collections/dcFields.js @@ -11,13 +11,13 @@ define([ "underscore", "backbone", "models/dcField" -], function(_, Backbone, DcFieldModel) { +], function (_, Backbone, DcFieldModel) { var DcFieldCollection = Backbone.Collection.extend({ model: DcFieldModel, - url: function() { + url: function () { return "/admin/fields/dc-fields"; }, - comparator: function(item) { + comparator: function (item) { return item.get("label"); } }); diff --git a/www/scripts/apps/admin/fields/collections/fields.js b/www/scripts/apps/admin/fields/collections/fields.js index 49fb876732..bed46b47cd 100644 --- a/www/scripts/apps/admin/fields/collections/fields.js +++ b/www/scripts/apps/admin/fields/collections/fields.js @@ -11,9 +11,9 @@ define([ "underscore", "backbone", "models/field" -], function(_, Backbone, FieldModel) { +], function (_, Backbone, FieldModel) { var FieldCollection = Backbone.Collection.extend({ - initialize: function(models, options) { + initialize: function (models, options) { options = options || {}; if (typeof options === "object" && false === "sbas_id" in options) { throw "You must set a sbas id" @@ -21,23 +21,23 @@ define([ this.sbasId = options.sbas_id; }, model: FieldModel, - url: function() { + url: function () { return "/admin/fields/" + this.sbasId + "/fields"; }, - search: function(letters) { + search: function (letters) { if (letters === "") return this; var pattern = new RegExp(letters, "gi"); - return _(this.filter(function(data) { + return _(this.filter(function (data) { return pattern.test(data.get("name")); })); }, - comparator: function(item) { + comparator: function (item) { return item.get("sorter"); }, - nextIndex: function(model) { + nextIndex: function (model) { var index = this.indexOf(model); if (index < 0) { @@ -50,7 +50,7 @@ define([ return index + 1; }, - previousIndex: function(model) { + previousIndex: function (model) { var index = this.indexOf(model); if (index < 0) { @@ -64,7 +64,7 @@ define([ return index - 1; }, // save all collection - save: function(options) { + save: function (options) { return Backbone.sync("update", this, options || {}); } }); diff --git a/www/scripts/apps/admin/fields/collections/vocabularies.js b/www/scripts/apps/admin/fields/collections/vocabularies.js index 75a6afe6ec..eb6eba9385 100644 --- a/www/scripts/apps/admin/fields/collections/vocabularies.js +++ b/www/scripts/apps/admin/fields/collections/vocabularies.js @@ -11,13 +11,13 @@ define([ "underscore", "backbone", "models/vocabulary" -], function(_, Backbone, VocabularyModel) { +], function (_, Backbone, VocabularyModel) { var VocabularyCollection = Backbone.Collection.extend({ model: VocabularyModel, - url: function() { + url: function () { return "/admin/fields/vocabularies"; }, - comparator: function(item) { + comparator: function (item) { return item.get("name"); } }); diff --git a/www/scripts/apps/admin/fields/errors/error.js b/www/scripts/apps/admin/fields/errors/error.js index 1e8b734978..086d82442c 100644 --- a/www/scripts/apps/admin/fields/errors/error.js +++ b/www/scripts/apps/admin/fields/errors/error.js @@ -10,7 +10,7 @@ define([ "jquery", "underscore" -], function($, _) { +], function ($, _) { var Error = function (model, fieldId, message) { this.model = model; diff --git a/www/scripts/apps/admin/fields/errors/errorManager.js b/www/scripts/apps/admin/fields/errors/errorManager.js index d87a636db0..87485fc2a3 100644 --- a/www/scripts/apps/admin/fields/errors/errorManager.js +++ b/www/scripts/apps/admin/fields/errors/errorManager.js @@ -12,9 +12,9 @@ define([ "underscore", "backbone", "apps/admin/fields/errors/errorModel" -], function($, _, Backbone, ErrorModel) { +], function ($, _, Backbone, ErrorModel) { - var ErrorManager = function() { + var ErrorManager = function () { this.errors = {}; _.extend(this, Backbone.Events); }; @@ -38,8 +38,8 @@ define([ containsModelError: function (model) { return "undefined" !== typeof this.errors[model.get("id")]; }, - addModelFieldError: function(error) { - if (! error instanceof Error) { + addModelFieldError: function (error) { + if (!error instanceof Error) { throw "Item must be an error object"; } @@ -56,7 +56,7 @@ define([ return this; }, - removeModelFieldError: function(model, fieldId) { + removeModelFieldError: function (model, fieldId) { var modelError = this.getModelError(model); if (modelError) { @@ -72,7 +72,7 @@ define([ } } }, - clearModelFieldErrors: function(model, fieldId) { + clearModelFieldErrors: function (model, fieldId) { var modelError = this.getModelError(model); if (modelError) { @@ -93,7 +93,7 @@ define([ return false; }, - getModelFieldError: function(model, fieldId) { + getModelFieldError: function (model, fieldId) { var modelError = this.getModelError(model); if (modelError) { @@ -102,7 +102,7 @@ define([ return null; }, - clearAll: function() { + clearAll: function () { this.errors = {}; this.trigger("no-error"); }, @@ -120,8 +120,8 @@ define([ }, all: function () { var errors = []; - _.each(this.errors, function(modelErrors) { - _.each(modelErrors.all(), function(error) { + _.each(this.errors, function (modelErrors) { + _.each(modelErrors.all(), function (error) { errors.push(error); }); }); diff --git a/www/scripts/apps/admin/fields/errors/errorModel.js b/www/scripts/apps/admin/fields/errors/errorModel.js index 50e5108e52..0bcea22dd9 100644 --- a/www/scripts/apps/admin/fields/errors/errorModel.js +++ b/www/scripts/apps/admin/fields/errors/errorModel.js @@ -10,21 +10,21 @@ define([ "jquery", "underscore" -], function($, _) { - var ErrorModel = function(id) { +], function ($, _) { + var ErrorModel = function (id) { this.id = id; this.errors = {}; }; ErrorModel.prototype = { - add: function(id, error) { - if (! error instanceof Error) { + add: function (id, error) { + if (!error instanceof Error) { throw "Item must be an error object"; } this.errors[id] = error; }, - get: function(id) { + get: function (id) { if (this.has(id)) { return this.errors[id]; } @@ -33,12 +33,12 @@ define([ has: function (id) { return "undefined" !== typeof this.errors[id]; }, - remove: function(id) { + remove: function (id) { if (this.has(id)) { delete this.errors[id]; } }, - count: function() { + count: function () { var count = 0; for (var k in this.errors) { if (this.errors.hasOwnProperty(k)) { diff --git a/www/scripts/apps/admin/fields/main.js b/www/scripts/apps/admin/fields/main.js index 1e59cdb7e2..124c04c44d 100644 --- a/www/scripts/apps/admin/fields/main.js +++ b/www/scripts/apps/admin/fields/main.js @@ -19,7 +19,7 @@ require.config({ bootstrap: "../skins/build/bootstrap/js/bootstrap.min" }, shim: { - bootstrap : ["jquery"], + bootstrap: ["jquery"], jqueryui: { deps: [ "jquery" ] } @@ -27,6 +27,6 @@ require.config({ }); // launch application -require(["apps/admin/fields/app"], function(App) { +require(["apps/admin/fields/app"], function (App) { App.initialize(); }); diff --git a/www/scripts/apps/admin/fields/views/alert.js b/www/scripts/apps/admin/fields/views/alert.js index 1bc5f5fbee..50f3c968b5 100644 --- a/www/scripts/apps/admin/fields/views/alert.js +++ b/www/scripts/apps/admin/fields/views/alert.js @@ -13,11 +13,11 @@ define([ "backbone", "i18n", "bootstrap" -], function($, _, Backbone, i18n, bootstrap) { +], function ($, _, Backbone, i18n, bootstrap) { var AlertView = Backbone.View.extend({ tagName: "div", className: "alert", - initialize: function(options) { + initialize: function (options) { var self = this; if (options) { @@ -30,7 +30,7 @@ define([ self.remove(); }); }, - render: function() { + render: function () { var self = this; var template = _.template($("#alert_template").html(), { msg: this.message @@ -39,7 +39,9 @@ define([ this.$el.addClass("alert-" + this.alert).html(template).alert(); 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); diff --git a/www/scripts/apps/admin/fields/views/create.js b/www/scripts/apps/admin/fields/views/create.js index db6a87db84..edf31393be 100644 --- a/www/scripts/apps/admin/fields/views/create.js +++ b/www/scripts/apps/admin/fields/views/create.js @@ -15,31 +15,31 @@ define([ "bootstrap", "apps/admin/fields/views/alert", "models/field" -], function($, _, Backbone, i18n, bootstrap, AlertView, FieldModel) { +], function ($, _, Backbone, i18n, bootstrap, AlertView, FieldModel) { var CreateView = Backbone.View.extend({ tagName: "div", events: { "click .btn-submit-field": "createAction", "click .btn-add-field": "toggleCreateFormAction", "click .btn-cancel-field": "toggleCreateFormAction", - "keyup input": "onKeyupInput" + "keyup input": "onKeyupInput" }, - render: function() { + render: function () { var template = _.template($("#create_template").html()); this.$el.html(template); $("#new-source", this.$el).autocomplete({ minLength: 2, - source: function(request, response) { + source: function (request, response) { $.ajax({ url: "/admin/fields/tags/search", dataType: "json", data: { term: request.term }, - success: function(data) { - response($.map(data, function(item) { + success: function (data) { + response($.map(data, function (item) { return { label: item.label, value: item.value @@ -59,7 +59,7 @@ define([ .find(".help-block") .empty(); }, - createAction: function(event) { + createAction: function (event) { var self = this; var formErrors = 0; @@ -81,7 +81,7 @@ define([ } // check for duplicate field name - if ("undefined" !== typeof AdminFieldApp.fieldsCollection.find(function(model){ + if ("undefined" !== typeof AdminFieldApp.fieldsCollection.find(function (model) { return model.get("name").toLowerCase() === fieldNameValue.toLowerCase(); })) { fieldName @@ -118,7 +118,7 @@ define([ formErrors++; } - if (formErrors > 0 ) { + if (formErrors > 0) { return; } @@ -126,15 +126,15 @@ define([ "sbas-id": AdminFieldApp.sbas_id, "name": fieldNameValue, "tag": fieldTagValue, - "label_en" : $("#new-label_en", this.$el).val(), - "label_fr" : $("#new-label_fr", this.$el).val(), - "label_de" : $("#new-label_de", this.$el).val(), - "label_nl" : $("#new-label_nl", this.$el).val(), + "label_en": $("#new-label_en", this.$el).val(), + "label_fr": $("#new-label_fr", this.$el).val(), + "label_de": $("#new-label_de", this.$el).val(), + "label_nl": $("#new-label_nl", this.$el).val(), "multi": $("#new-multivalued", this.$el).is(":checked") }); field.save(null, { - success: function(field, response, options) { + success: function (field, response, options) { AdminFieldApp.fieldsCollection.add(field); _.last(AdminFieldApp.fieldListView.itemViews).clickAction().animate(); @@ -144,7 +144,7 @@ define([ }) }).render(); }, - error: function(xhr, textStatus, errorThrown) { + error: function (xhr, textStatus, errorThrown) { new AlertView({ alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong")} ).render(); @@ -155,7 +155,7 @@ define([ return this; }, - toggleCreateFormAction: function(event) { + toggleCreateFormAction: function (event) { var fieldBlock = $(".add-field-block", this.$el); var addBtn = $(".btn-add-field", this.$el); diff --git a/www/scripts/apps/admin/fields/views/edit.js b/www/scripts/apps/admin/fields/views/edit.js index 16da4a4bbe..4e297e47a1 100644 --- a/www/scripts/apps/admin/fields/views/edit.js +++ b/www/scripts/apps/admin/fields/views/edit.js @@ -17,22 +17,22 @@ define([ "apps/admin/fields/views/modal", "apps/admin/fields/views/dcField", "apps/admin/fields/errors/error" -], function($, _, Backbone, i18n, MultiViews, AlertView, ModalView, DcFieldView, Error) { +], function ($, _, Backbone, i18n, MultiViews, AlertView, ModalView, DcFieldView, Error) { // Add multiview methods var FieldEditView = Backbone.View.extend(_.extend({}, MultiViews, { tagName: "div", className: "field-edit", - initialize: function() { + initialize: function () { this.model.on("change", this._onModelChange, this); }, - updateModel: function(model) { + updateModel: function (model) { // unbind event to previous model this.model.off("change"); this.model = model; return this; }, - render: function() { + render: function () { var self = this; var template = _.template($("#edit_template").html(), { lng: AdminFieldApp.lng(), @@ -45,7 +45,7 @@ define([ this.$el.empty().html(template); this._assignView({ - ".dc-fields-subview" : new DcFieldView({ + ".dc-fields-subview": new DcFieldView({ collection: AdminFieldApp.dcFieldsCollection, field: this.model }) @@ -53,15 +53,15 @@ define([ var completer = $("#tag", this.$el).autocomplete({ minLength: 2, - source: function(request, response) { + source: function (request, response) { $.ajax({ url: "/admin/fields/tags/search", dataType: "json", data: { term: request.term }, - success: function(data) { - response($.map(data, function(item) { + success: function (data) { + response($.map(data, function (item) { return { label: item.label, value: item.value @@ -70,7 +70,7 @@ define([ } }); }, - close: function(e) { + close: function (e) { self.tagFieldChangedAction(e); } }); @@ -95,7 +95,7 @@ define([ "change select": "selectionChangedAction", "click .lng-label a": "_toggleLabels" }, - triggerControlledVocabulary: function(e) { + triggerControlledVocabulary: function (e) { if ($(e.target, this.$el).find("option:selected").val() === "") { this.model.set("vocabulary-type", false); this.render(); @@ -105,7 +105,7 @@ define([ this.render(); } }, - selectionChangedAction: function(e) { + selectionChangedAction: function (e) { var field = $(e.target); var data = {}; data[field.attr("id")] = $("option:selected", field).val(); @@ -113,7 +113,7 @@ define([ return this; }, - fieldChangedAction: function(e) { + fieldChangedAction: function (e) { var field = $(e.target); var fieldId = field.attr("id"); var data = {}; @@ -122,7 +122,7 @@ define([ return this; }, - labelChangedAction: function(e) { + labelChangedAction: function (e) { var field = $(e.target); var fieldId = field.attr("id"); var data = this.model.get("labels"); @@ -133,13 +133,13 @@ define([ return this; }, - tagFieldChangedAction: function(e) { + tagFieldChangedAction: function (e) { var $this = this; var fieldTag = $(e.target); var fieldTagId = fieldTag.attr("id"); var fieldTagValue = fieldTag.val(); - var onFieldValid = function() { + var onFieldValid = function () { if (fieldTag.closest(".control-group").hasClass("error")) { // remove error AdminFieldApp.errorManager.removeModelFieldError( @@ -157,7 +157,7 @@ define([ } if ("" !== fieldTagValue) { - var jqxhr = $.get( "/admin/fields/tags/"+fieldTagValue, onFieldValid).fail(function() { + var jqxhr = $.get("/admin/fields/tags/" + fieldTagValue, onFieldValid).fail(function () { fieldTag .closest(".control-group") .addClass("error") @@ -173,7 +173,7 @@ define([ onFieldValid(); } }, - deleteAction: function() { + deleteAction: function () { var self = this; var modalView = new ModalView({ model: this.model, @@ -191,7 +191,7 @@ define([ var index = previousIndex ? previousIndex : (nextIndex ? nextIndex - 1 : -1); modalView.render(); - modalView.on("modal:confirm", function() { + modalView.on("modal:confirm", function () { AdminFieldApp.fieldsToDelete.push(self.model); AdminFieldApp.fieldListView.collection.remove(self.model); self._selectModelView(index); @@ -200,19 +200,19 @@ define([ return this; }, - _onModelChange: function() { + _onModelChange: function () { AdminFieldApp.fieldListView.collection.remove(this.model, {silent: true}); AdminFieldApp.fieldListView.collection.add(this.model, {silent: true}); AdminFieldApp.saveView.updateStateButton(); }, // select temView by index in itemList - _selectModelView: function(index) { + _selectModelView: function (index) { // select previous or next itemview if (index >= 0) { AdminFieldApp.fieldListView.itemViews[index].select().animate().click(); } }, - _toggleLabels: function(event) { + _toggleLabels: function (event) { event.preventDefault(); var curLabel = $(event.target); $('.lng-label', this.$el).removeClass("select"); diff --git a/www/scripts/apps/admin/fields/views/fieldError.js b/www/scripts/apps/admin/fields/views/fieldError.js index bfa6dcc3be..db8254a6b6 100644 --- a/www/scripts/apps/admin/fields/views/fieldError.js +++ b/www/scripts/apps/admin/fields/views/fieldError.js @@ -12,20 +12,20 @@ define([ "underscore", "backbone", "i18n" -], function($, _, Backbone, i18n) { +], function ($, _, Backbone, i18n) { var FieldErrorView = Backbone.View.extend({ - initialize: function() { + initialize: function () { AdminFieldApp.errorManager.on("add-error", this.render, this); AdminFieldApp.errorManager.on("remove-error", this.render, this); }, - render: function() { + render: function () { var messages = []; var errors = AdminFieldApp.errorManager.all(); - _.each(_.groupBy(errors, function(error) { + _.each(_.groupBy(errors, function (error) { return error.model.get("name"); - }), function(groupedErrors) { - _.each(groupedErrors, function(error) { + }), function (groupedErrors) { + _.each(groupedErrors, function (error) { messages.push(i18n.t("field_error", { postProcess: "sprintf", sprintf: [error.model.get("name")] diff --git a/www/scripts/apps/admin/fields/views/list.js b/www/scripts/apps/admin/fields/views/list.js index fe8086bafd..44fc23ea1b 100644 --- a/www/scripts/apps/admin/fields/views/list.js +++ b/www/scripts/apps/admin/fields/views/list.js @@ -16,13 +16,13 @@ define([ "common/multiviews", "apps/admin/fields/views/listRow", "apps/admin/fields/views/create" -], function($, jqueryui, _, Backbone, i18n, MultiViews, FieldListRowView, CreateView) { +], function ($, jqueryui, _, Backbone, i18n, MultiViews, FieldListRowView, CreateView) { var FieldListView = Backbone.View.extend(_.extend({}, MultiViews, { events: { "keyup #live_search": "searchAction", "update-sort": "updateSortAction" }, - initialize: function() { + initialize: function () { var self = this; // store all single rendered views this.itemViews = []; @@ -40,9 +40,9 @@ define([ this.collection.bind("remove", this._onRemove, this); this.collection.bind("remove", this.render, this); - AdminFieldApp.errorManager.on('add-error', function(error) { + AdminFieldApp.errorManager.on('add-error', function (error) { var model = error.model; - var itemView = _.find(self.itemViews, function(view) { + var itemView = _.find(self.itemViews, function (view) { return model.get('id') === view.model.get('id'); }); @@ -51,8 +51,8 @@ define([ } }); - AdminFieldApp.errorManager.on('remove-error', function(model) { - var itemView = _.find(self.itemViews, function(view) { + AdminFieldApp.errorManager.on('remove-error', function (model) { + var itemView = _.find(self.itemViews, function (view) { return model.get('id') === view.model.get('id'); }); @@ -61,7 +61,7 @@ define([ } }); }, - render: function() { + render: function () { var template = _.template($("#item_list_view_template").html()); this.$el.empty().html(template); @@ -71,7 +71,7 @@ define([ this._renderList(this.collection); this._assignView({ - ".create-subview" : new CreateView() + ".create-subview": new CreateView() }); AdminFieldApp.resizeListBlock(); @@ -79,13 +79,13 @@ define([ return this; }, // render list by appending single item view, also fill itemViews - _renderList: function(fields) { + _renderList: function (fields) { var that = this; this.$listEl.empty(); this.itemViews = []; - fields.each(function(field) { + fields.each(function (field) { var fieldErrors = AdminFieldApp.errorManager.getModelError(field); var singleView = new FieldListRowView({ @@ -100,10 +100,10 @@ define([ this.$listEl.sortable({ handle: ".handle", placeholder: "item-list-placeholder", - start: function(event, ui) { + start: function (event, ui) { ui.item.addClass("border-bottom"); }, - stop: function(event, ui) { + stop: function (event, ui) { ui.firstItemPosition = $("li:first", $(this).sortable('widget')).position().top; ui.item.trigger("drop", ui); } @@ -115,14 +115,14 @@ define([ return this; }, - searchAction: function(event) { + searchAction: function (event) { this._renderList(this.collection.search($("#live_search", this.$el).val())); return this; }, - _onRemove : function (model) { + _onRemove: function (model) { var models = []; - this.collection.each(function(m) { + this.collection.each(function (m) { if (m.get("sorter") > model.get("sorter")) { m.set("sorter", m.get("sorter") - 1); } @@ -132,7 +132,7 @@ define([ this.collection.reset(models); }, - updateSortAction: function(event, model, ui) { + updateSortAction: function (event, model, ui) { var newPosition = ui.item.index(); this.collection.remove(model, {silent: true}); this.collection.each(function (model, index) { @@ -145,7 +145,7 @@ define([ this.itemViews[0].animate(Math.abs(ui.firstItemPosition)); // update edit view model - AdminFieldApp.fieldEditView.updateModel(this.collection.find(function(el) { + AdminFieldApp.fieldEditView.updateModel(this.collection.find(function (el) { return el.get("id") === AdminFieldApp.fieldEditView.model.get("id"); })); diff --git a/www/scripts/apps/admin/fields/views/listRow.js b/www/scripts/apps/admin/fields/views/listRow.js index 87eef78d3d..11831fd202 100644 --- a/www/scripts/apps/admin/fields/views/listRow.js +++ b/www/scripts/apps/admin/fields/views/listRow.js @@ -12,18 +12,18 @@ define([ "underscore", "backbone", "apps/admin/fields/views/edit" -], function($, _, Backbone, FieldEditView) { +], function ($, _, Backbone, FieldEditView) { var FieldListRowView = Backbone.View.extend({ tagName: "li", className: "field-row", - initialize: function() { + initialize: function () { // destroy view is model is deleted this.model.on("change", this.onChange, this); this.model.on("destroy", this.remove, this); }, - events : { + events: { "click .trigger-click": "clickAction", - "drop" : "dropAction" + "drop": "dropAction" }, clickAction: function (e) { this.select(); @@ -33,7 +33,7 @@ define([ el: AdminFieldApp.$rightBlock, model: this.model }); - } else { + } else { AdminFieldApp.fieldEditView.updateModel(this.model).initialize(); } @@ -41,17 +41,17 @@ define([ return this; }, - dropAction: function(event, ui) { + dropAction: function (event, ui) { this.$el.trigger("update-sort", [this.model, ui]); return this; }, - onChange: function() { + onChange: function () { if (this.model.hasChanged("tag")) { this.render(); } }, - render: function() { + render: function () { var template = _.template($("#list_row_template").html(), { id: this.model.get("id"), position: this.model.get("sorter"), @@ -76,7 +76,7 @@ define([ return this; }, - click: function() { + click: function () { this.$el.find('.trigger-click').first().trigger('click'); return this; }, @@ -96,7 +96,7 @@ define([ error: function (errored) { if (errored) { this.$el.addClass("error"); - } else { + } else { this.$el.removeClass("error"); } diff --git a/www/scripts/apps/admin/fields/views/modal.js b/www/scripts/apps/admin/fields/views/modal.js index f55f308984..401dabc62e 100644 --- a/www/scripts/apps/admin/fields/views/modal.js +++ b/www/scripts/apps/admin/fields/views/modal.js @@ -13,7 +13,7 @@ define([ "backbone", "i18n", "bootstrap" -], function($, _, Backbone, i18n, bootstrap) { +], function ($, _, Backbone, i18n, bootstrap) { var ModalView = Backbone.View.extend({ tagName: "div", className: "modal", @@ -23,7 +23,7 @@ define([ initialize: function (options) { var self = this; // remove view when modal is closed - this.$el.on("hidden", function() { + this.$el.on("hidden", function () { self.remove(); }); @@ -31,7 +31,7 @@ define([ this.message = options.message; } }, - render: function() { + render: function () { var template = _.template($("#modal_template").html(), { msg: this.message || "" }); diff --git a/www/scripts/apps/admin/fields/views/save.js b/www/scripts/apps/admin/fields/views/save.js index 81fd1cf71a..887d64aac6 100644 --- a/www/scripts/apps/admin/fields/views/save.js +++ b/www/scripts/apps/admin/fields/views/save.js @@ -14,46 +14,46 @@ define([ "i18n", "bootstrap", "apps/admin/fields/views/alert" -], function($, _, Backbone, i18n, bootstrap, AlertView) { +], function ($, _, Backbone, i18n, bootstrap, AlertView) { var SaveView = Backbone.View.extend({ - initialize: function() { + initialize: function () { var self = this; this.previousAttributes = []; this.$overlay = null; - AdminFieldApp.errorManager.on("add-error", function(errors) { + AdminFieldApp.errorManager.on("add-error", function (errors) { self._disableSaveButton(true); }); - AdminFieldApp.errorManager.on("no-error", function() { + AdminFieldApp.errorManager.on("no-error", function () { self._disableSaveButton(false); }); }, events: { - "click button.save-all" : "clickSaveAction" + "click button.save-all": "clickSaveAction" }, - clickSaveAction: function(event) { + clickSaveAction: function (event) { var self = this; if (this._isModelDesync()) { this._loadingState(true); - $.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function(m){ + $.when.apply($, _.map(AdminFieldApp.fieldsToDelete, function (m) { return m.destroy({ - success: function(model, response) { - AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function(m){ + success: function (model, response) { + AdminFieldApp.fieldsToDelete = _.filter(AdminFieldApp.fieldsToDelete, function (m) { return model.get("id") !== m.get("id"); }); }, - error: function(xhr, textStatus, errorThrown) { + error: function (xhr, textStatus, errorThrown) { new AlertView({ alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong") }).render(); } }); })).done( - function() { + function () { AdminFieldApp.fieldsCollection.save({ - success: function(fields) { + success: function (fields) { // reset collection with new one AdminFieldApp.fieldsCollection.reset(fields); @@ -63,12 +63,12 @@ define([ delay: 2000 }).render(); }, - error: function(xhr, textStatus, errorThrown) { + error: function (xhr, textStatus, errorThrown) { new AlertView({ alert: "error", message: '' !== xhr.responseText ? xhr.responseText : i18n.t("something_wrong") }).render(); } - }).done(function() { + }).done(function () { self._loadingState(false); }); } @@ -84,18 +84,18 @@ define([ return this; }, - updateStateButton: function() { + updateStateButton: function () { this._disableSaveButton(!this._isModelDesync()); }, // check whether model has changed or not _isModelDesync: function () { - return "undefined" !== typeof AdminFieldApp.fieldsCollection.find(function(model) { + return "undefined" !== typeof AdminFieldApp.fieldsCollection.find(function (model) { return !_.isEmpty(model.previousAttributes()); }); }, // create a transparent overlay on top of the application - _overlay: function(showOrHide) { - if(showOrHide && !this.$overlay) { + _overlay: function (showOrHide) { + if (showOrHide && !this.$overlay) { this.$overlay = $("
").addClass("overlay"); AdminFieldApp.$bottom.append(this.$overlay); } else if (!showOrHide && this.$overlay) { @@ -107,7 +107,7 @@ define([ $("button.save-all", this.$el).attr("disabled", active); }, // put application on loading state (add overlay, add spinner, disable global save button) - _loadingState: function(active) { + _loadingState: function (active) { if (active) { $(".save-block", AdminFieldApp.$top).addClass("loading"); $(".block-alert", AdminFieldApp.$top).empty(); diff --git a/www/scripts/apps/login/home/bind.js b/www/scripts/apps/login/home/bind.js index 49be549e7c..b71ad96644 100644 --- a/www/scripts/apps/login/home/bind.js +++ b/www/scripts/apps/login/home/bind.js @@ -12,24 +12,27 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, LoginForm) { +], function ($, i18n, Common, LoginForm) { Common.initialize(); i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { new LoginForm({ - el : $("form[name=loginForm]"), - rules: [{ - name: "login", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password", - rules: "required", - message: i18n.t("validation_blank") - }] + el: $("form[name=loginForm]"), + rules: [ + { + name: "login", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password", + rules: "required", + message: i18n.t("validation_blank") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/common.js b/www/scripts/apps/login/home/common.js index 2e5f03d1f6..726f79e73e 100644 --- a/www/scripts/apps/login/home/common.js +++ b/www/scripts/apps/login/home/common.js @@ -14,28 +14,28 @@ define([ "backbone", "bootstrap", "multiselect" -], function($, _, i18n, Backbone, bootstrap, multiselect) { - var initialize = function() { +], function ($, _, i18n, Backbone, bootstrap, multiselect) { + var initialize = function () { // close alerts - $(document).on("click", ".alert .alert-block-close a", function(e){ + $(document).on("click", ".alert .alert-block-close a", function (e) { e.preventDefault(); $(this).closest('.alert').alert('close'); return false; }); $("select[multiple='multiple']").multiselect({ - buttonWidth : "100%", + buttonWidth: "100%", buttonClass: 'btn btn-inverse', maxHeight: 185, includeSelectAllOption: true, selectAllValue: 'all', selectAllText: i18n.t("all_collections"), - buttonText: function(options, select) { + buttonText: function (options, select) { if (options.length === 0) { return i18n.t("no_collection_selected") + ''; } else { return i18n.t( - options.length === 1 ? "one_collection_selected": "collections_selected", { + options.length === 1 ? "one_collection_selected" : "collections_selected", { postProcess: "sprintf", sprintf: [options.length] }) + ' '; diff --git a/www/scripts/apps/login/home/config.js b/www/scripts/apps/login/home/config.js index 81f260c28d..6cfad90dca 100644 --- a/www/scripts/apps/login/home/config.js +++ b/www/scripts/apps/login/home/config.js @@ -21,11 +21,11 @@ require.config({ "jquery.geonames": "../assets/geonames-server-jquery-plugin/jquery.geonames" }, shim: { - bootstrap : ["jquery"], + bootstrap: ["jquery"], jqueryui: { deps: ["jquery"] }, - "jquery.geonames" : { + "jquery.geonames": { deps: ['jquery', 'jqueryui'], exports: '$.fn.geocompleter' }, diff --git a/www/scripts/apps/login/home/forgotPassword.js b/www/scripts/apps/login/home/forgotPassword.js index c0420372b4..80bdf21c88 100644 --- a/www/scripts/apps/login/home/forgotPassword.js +++ b/www/scripts/apps/login/home/forgotPassword.js @@ -12,24 +12,27 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, ForgotPassWordForm) { +], function ($, i18n, Common, ForgotPassWordForm) { Common.initialize(); i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { new ForgotPassWordForm({ - el : $("form[name=forgottenPasswordForm]"), - rules: [{ - name: "email", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "email", - rules: "valid_email", - message: i18n.t("validation_email") - }] + el: $("form[name=forgottenPasswordForm]"), + rules: [ + { + name: "email", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "email", + rules: "valid_email", + message: i18n.t("validation_email") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/login.js b/www/scripts/apps/login/home/login.js index 49be549e7c..b71ad96644 100644 --- a/www/scripts/apps/login/home/login.js +++ b/www/scripts/apps/login/home/login.js @@ -12,24 +12,27 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, LoginForm) { +], function ($, i18n, Common, LoginForm) { Common.initialize(); i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { new LoginForm({ - el : $("form[name=loginForm]"), - rules: [{ - name: "login", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password", - rules: "required", - message: i18n.t("validation_blank") - }] + el: $("form[name=loginForm]"), + rules: [ + { + name: "login", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password", + rules: "required", + message: i18n.t("validation_blank") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/mapping.js b/www/scripts/apps/login/home/mapping.js index 49be549e7c..b71ad96644 100644 --- a/www/scripts/apps/login/home/mapping.js +++ b/www/scripts/apps/login/home/mapping.js @@ -12,24 +12,27 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, LoginForm) { +], function ($, i18n, Common, LoginForm) { Common.initialize(); i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { new LoginForm({ - el : $("form[name=loginForm]"), - rules: [{ - name: "login", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password", - rules: "required", - message: i18n.t("validation_blank") - }] + el: $("form[name=loginForm]"), + rules: [ + { + name: "login", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password", + rules: "required", + message: i18n.t("validation_blank") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/oauthLogin.js b/www/scripts/apps/login/home/oauthLogin.js index 49be549e7c..b71ad96644 100644 --- a/www/scripts/apps/login/home/oauthLogin.js +++ b/www/scripts/apps/login/home/oauthLogin.js @@ -12,24 +12,27 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, LoginForm) { +], function ($, i18n, Common, LoginForm) { Common.initialize(); i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { new LoginForm({ - el : $("form[name=loginForm]"), - rules: [{ - name: "login", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password", - rules: "required", - message: i18n.t("validation_blank") - }] + el: $("form[name=loginForm]"), + rules: [ + { + name: "login", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password", + rules: "required", + message: i18n.t("validation_blank") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/recoverPassword.js b/www/scripts/apps/login/home/recoverPassword.js index cf048c80f5..03cf169421 100644 --- a/www/scripts/apps/login/home/recoverPassword.js +++ b/www/scripts/apps/login/home/recoverPassword.js @@ -12,31 +12,35 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/formType/passwordSetter" -], function($, i18n, Common, RenewPassword) { +], function ($, i18n, Common, RenewPassword) { i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { Common.initialize(); new RenewPassword({ - el : $("form[name=passwordRenewForm]"), - rules: [{ - name: "password[password]", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password[password]", - rules: "min_length[5]", - message: i18n.t("validation_length_min", { - postProcess: "sprintf", - sprintf: ["5"] - }) - },{ - name: "password[confirm]", - rules: "matches[password[password]]", - message: i18n.t("password_match") - }] + el: $("form[name=passwordRenewForm]"), + rules: [ + { + name: "password[password]", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password[password]", + rules: "min_length[5]", + message: i18n.t("validation_length_min", { + postProcess: "sprintf", + sprintf: ["5"] + }) + }, + { + name: "password[confirm]", + rules: "matches[password[password]]", + message: i18n.t("password_match") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/register.js b/www/scripts/apps/login/home/register.js index 79a6fe98df..f1cf587ce6 100644 --- a/www/scripts/apps/login/home/register.js +++ b/www/scripts/apps/login/home/register.js @@ -14,62 +14,70 @@ require([ "apps/login/home/common", "common/forms/views/formType/passwordSetter", "common/geonames" -], function($, i18n, Common, RegisterForm, geonames) { +], function ($, i18n, Common, RegisterForm, geonames) { var fieldsConfiguration = []; $.when.apply($, [ $.ajax({ url: '/login/registration-fields/', - success: function(config) { + success: function (config) { fieldsConfiguration = config; } }) - ]).done(function(){ + ]).done(function () { i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { Common.initialize(); - var rules = [{ - name: "email", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "email", - rules: "valid_email", - message: i18n.t("validation_email") - },{ - name: "password[password]", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password[password]", - rules: "min_length[5]", - message: i18n.t("validation_length_min", { - postProcess: "sprintf", - sprintf: ["5"] - }) - },{ - name: "password[confirm]", - rules: "matches[password[password]]", - message: i18n.t("password_match") - },{ - name: "accept-tou", - rules: "required", - message: i18n.t("accept_tou"), - type: "checkbox" - },{ - name: "collections[]", - rules: "min_length[1]", - message: i18n.t("validation_choice_min", { - postProcess: "sprintf", - sprintf: ["1"] - }), - type: "multiple" - }]; + var rules = [ + { + name: "email", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "email", + rules: "valid_email", + message: i18n.t("validation_email") + }, + { + name: "password[password]", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password[password]", + rules: "min_length[5]", + message: i18n.t("validation_length_min", { + postProcess: "sprintf", + sprintf: ["5"] + }) + }, + { + name: "password[confirm]", + rules: "matches[password[password]]", + message: i18n.t("password_match") + }, + { + name: "accept-tou", + rules: "required", + message: i18n.t("accept_tou"), + type: "checkbox" + }, + { + name: "collections[]", + rules: "min_length[1]", + message: i18n.t("validation_choice_min", { + postProcess: "sprintf", + sprintf: ["1"] + }), + type: "multiple" + } + ]; - _.each(fieldsConfiguration, function(field) { + _.each(fieldsConfiguration, function (field) { if (field.required) { var rule = { "name": field.name, @@ -84,7 +92,7 @@ require([ var $form = $("form[name=registerForm]"); new RegisterForm({ - el : $form, + el: $form, rules: rules }); @@ -92,7 +100,7 @@ require([ "server": $form.data("geonames-server-adress"), "limit": 40, "init-input": false, - "onInit": function(input, autoinput) { + "onInit": function (input, autoinput) { // Set default name to geonameid-completer autoinput.prop("name", "geonameid-completer"); } @@ -106,7 +114,7 @@ require([ }); // On open menu calculate max-width - geocompleter.geocompleter("autocompleter", "on", "autocompleteopen", function(event, ui) { + geocompleter.geocompleter("autocompleter", "on", "autocompleteopen", function (event, ui) { $(this).autocomplete("widget").css("min-width", geocompleter.closest(".input-table").outerWidth()); }); }); diff --git a/www/scripts/apps/login/home/registerProvider.js b/www/scripts/apps/login/home/registerProvider.js index 76eb7221be..ae64b6b8d6 100644 --- a/www/scripts/apps/login/home/registerProvider.js +++ b/www/scripts/apps/login/home/registerProvider.js @@ -13,7 +13,7 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, RegisterForm) { +], function ($, i18n, Common, RegisterForm) { Common.initialize(); var fieldsConfiguration = []; @@ -21,54 +21,62 @@ require([ $.when.apply($, [ $.ajax({ url: '/login/registration-fields/', - success: function(config) { + success: function (config) { fieldsConfiguration = config; } }) - ]).done(function(){ + ]).done(function () { i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { - var rules = [{ - name: "email", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "email", - rules: "valid_email", - message: i18n.t("validation_email") - },{ - name: "password", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password", - rules: "min_length[5]", - message: i18n.t("validation_length_min", { - postProcess: "sprintf", - sprintf: ["5"] - }) - },{ - name: "passwordConfirm", - rules: "matches[password]", - message: i18n.t("password_match") - },{ - name: "accept-tou", - rules: "required", - message: i18n.t("accept_tou"), - type: "checkbox" - },{ - name: "collections[]", - rules: "min_length[1]", - message: i18n.t("validation_choice_min", { - postProcess: "sprintf", - sprintf: ["1"] - }), - type: "multiple" - }]; + }, function () { + var rules = [ + { + name: "email", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "email", + rules: "valid_email", + message: i18n.t("validation_email") + }, + { + name: "password", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password", + rules: "min_length[5]", + message: i18n.t("validation_length_min", { + postProcess: "sprintf", + sprintf: ["5"] + }) + }, + { + name: "passwordConfirm", + rules: "matches[password]", + message: i18n.t("password_match") + }, + { + name: "accept-tou", + rules: "required", + message: i18n.t("accept_tou"), + type: "checkbox" + }, + { + name: "collections[]", + rules: "min_length[1]", + message: i18n.t("validation_choice_min", { + postProcess: "sprintf", + sprintf: ["1"] + }), + type: "multiple" + } + ]; - _.each(fieldsConfiguration, function(field) { + _.each(fieldsConfiguration, function (field) { if (field.required) { var rule = { "name": field.name, @@ -81,7 +89,7 @@ require([ }); new RegisterForm({ - el : $("form[name=registerForm]"), + el: $("form[name=registerForm]"), rules: rules }); }); diff --git a/www/scripts/apps/login/home/renewEmail.js b/www/scripts/apps/login/home/renewEmail.js index fccb7b9c25..45ca481723 100644 --- a/www/scripts/apps/login/home/renewEmail.js +++ b/www/scripts/apps/login/home/renewEmail.js @@ -12,36 +12,41 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/form" -], function($, i18n, Common, RenewEmail) { +], function ($, i18n, Common, RenewEmail) { i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { Common.initialize(); new RenewEmail({ - el : $("form[name=changeEmail]"), + el: $("form[name=changeEmail]"), errorTemplate: "#field_errors_block", - onRenderError: function(name, $el) { + onRenderError: function (name, $el) { $el.closest(".control-group").addClass("error"); }, - rules: [{ - name: "form_password", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "form_email", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "form_email", - rules: "email", - message: i18n.t("validation_email") - },{ - name: "form_email_confirm", - rules: "matches[form_email]", - message: i18n.t("email_match") - }] + rules: [ + { + name: "form_password", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "form_email", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "form_email", + rules: "email", + message: i18n.t("validation_email") + }, + { + name: "form_email_confirm", + rules: "matches[form_email]", + message: i18n.t("email_match") + } + ] }); }); }); diff --git a/www/scripts/apps/login/home/renewPassword.js b/www/scripts/apps/login/home/renewPassword.js index c09b7463c5..189c918478 100644 --- a/www/scripts/apps/login/home/renewPassword.js +++ b/www/scripts/apps/login/home/renewPassword.js @@ -12,35 +12,40 @@ require([ "i18n", "apps/login/home/common", "common/forms/views/formType/passwordSetter" -], function($, i18n, Common, RenewPassword) { +], function ($, i18n, Common, RenewPassword) { i18n.init({ resGetPath: Common.languagePath, useLocalStorage: true - }, function() { + }, function () { Common.initialize(); new RenewPassword({ - el : $("form[name=passwordChangeForm]"), - rules: [{ - name: "oldPassword", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password[password]", - rules: "required", - message: i18n.t("validation_blank") - },{ - name: "password[password]", - rules: "min_length[5]", - message: i18n.t("validation_length_min", { - postProcess: "sprintf", - sprintf: ["5"] - }) - },{ - name: "password[confirm]", - rules: "matches[password[password]]", - message: i18n.t("password_match") - }] + el: $("form[name=passwordChangeForm]"), + rules: [ + { + name: "oldPassword", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password[password]", + rules: "required", + message: i18n.t("validation_blank") + }, + { + name: "password[password]", + rules: "min_length[5]", + message: i18n.t("validation_length_min", { + postProcess: "sprintf", + sprintf: ["5"] + }) + }, + { + name: "password[confirm]", + rules: "matches[password[password]]", + message: i18n.t("password_match") + } + ] }); }); }); diff --git a/www/scripts/common/forms/validator.js b/www/scripts/common/forms/validator.js index 3f149b9a15..4866cabed4 100644 --- a/www/scripts/common/forms/validator.js +++ b/www/scripts/common/forms/validator.js @@ -11,8 +11,8 @@ define([ "jquery", "underscore", "backbone" -], function($, _, Backbone) { - var FormValidator = function(rules, handlers) { +], function ($, _, Backbone) { + var FormValidator = function (rules, handlers) { // rules setted by user this.rules = rules || []; // custom callbacks @@ -22,7 +22,7 @@ define([ var self = this; - _.each(this.rules, function(field) { + _.each(this.rules, function (field) { if ("name" in field && "rules" in field) { self._addField(field); } @@ -30,16 +30,16 @@ define([ }; // Validate method, argument is the serialize form - FormValidator.prototype.validate = function(inputs) { + FormValidator.prototype.validate = function (inputs) { var self = this; // possible errors this.errors = []; // inputs present in form this.inputs = {}; - _.each(_.groupBy(inputs, function(input){ + _.each(_.groupBy(inputs, function (input) { return input.name; - }), function(fields, name) { + }), function (fields, name) { self.inputs[name] = fields; }); @@ -48,19 +48,19 @@ define([ return this; }; - FormValidator.prototype.getErrors = function() { + FormValidator.prototype.getErrors = function () { return this.errors; }; - FormValidator.prototype.hasErrors = function() { + FormValidator.prototype.hasErrors = function () { return this.errors.length > 0; }; - FormValidator.prototype.getRules = function() { + FormValidator.prototype.getRules = function () { return this.rules; }; - FormValidator.prototype._addField = function(field) { + FormValidator.prototype._addField = function (field) { this.fields.push({ name: field.name, rules: field.rules, @@ -70,15 +70,15 @@ define([ }); }; - FormValidator.prototype._validateForm = function() { + FormValidator.prototype._validateForm = function () { var self = this; this.errors = []; - _.each(this.fields, function(field){ + _.each(this.fields, function (field) { if (_.has(self.inputs, field.name)) { // values can be multiple var values = []; - _.each(self.inputs[field.name], function(field){ + _.each(self.inputs[field.name], function (field) { return values.push(field.value); }); @@ -92,13 +92,13 @@ define([ }); }; - FormValidator.prototype._validateField = function(field) { + FormValidator.prototype._validateField = function (field) { var self = this; var ruleRegex = /^(.+?)\[(.+)\]$/; var rules = field.rules.split('|'); // Run through the rules and execute the validation methods as needed - _.every(rules, function(method) { + _.every(rules, function (method) { var param = null; var failed = false; var parts = ruleRegex.exec(method); @@ -141,32 +141,32 @@ define([ }; FormValidator.prototype.Regexp = { - numericRegex : /^[0-9]+$/, - integerRegex : /^\-?[0-9]+$/, - decimalRegex : /^\-?[0-9]*\.?[0-9]+$/, - emailRegex : /^[^@]+@[^@]+\.[^@]+$/, - alphaRegex : /^[a-z]+$/i, - alphaNumericRegex : /^[a-z0-9]+$/i, - alphaDashRegex : /^[a-z0-9_\-]+$/i, - naturalRegex : /^[0-9]+$/i, - naturalNoZeroRegex : /^[1-9][0-9]*$/i, + numericRegex: /^[0-9]+$/, + integerRegex: /^\-?[0-9]+$/, + decimalRegex: /^\-?[0-9]*\.?[0-9]+$/, + emailRegex: /^[^@]+@[^@]+\.[^@]+$/, + alphaRegex: /^[a-z]+$/i, + alphaNumericRegex: /^[a-z0-9]+$/i, + alphaDashRegex: /^[a-z0-9_\-]+$/i, + naturalRegex: /^[0-9]+$/i, + naturalNoZeroRegex: /^[1-9][0-9]*$/i, // IP v6 a v4 or hostname, by Mikulas Dite see http://stackoverflow.com/a/9209720/96656 - ipRegex : /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^(?:(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-fA-F]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,1}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,2}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,3}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:[0-9a-fA-F]{1,4})):)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,4}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,5}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,6}(?:(?:[0-9a-fA-F]{1,4})))?::))))$/i, - numericDashRegex : /^[\d\-\s]+$/, - urlRegex : /^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/ + ipRegex: /^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$|^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$|^(?:(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){6})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:::(?:(?:(?:[0-9a-fA-F]{1,4})):){5})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){4})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,1}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){3})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,2}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:(?:[0-9a-fA-F]{1,4})):){2})(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,3}(?:(?:[0-9a-fA-F]{1,4})))?::(?:(?:[0-9a-fA-F]{1,4})):)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,4}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9]))\.){3}(?:(?:25[0-5]|(?:[1-9]|1[0-9]|2[0-4])?[0-9])))))))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,5}(?:(?:[0-9a-fA-F]{1,4})))?::)(?:(?:[0-9a-fA-F]{1,4})))|(?:(?:(?:(?:(?:(?:[0-9a-fA-F]{1,4})):){0,6}(?:(?:[0-9a-fA-F]{1,4})))?::))))$/i, + numericDashRegex: /^[\d\-\s]+$/, + urlRegex: /^((http|https):\/\/(\w+:{0,1}\w*@)?(\S+)|)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/ }; // Object containing all of the validation hooks FormValidator.prototype._hooks = { - "required": function(field) { + "required": function (field) { var value = field.value; return (value !== null && value !== ''); }, - "equal": function(field, defaultName) { + "equal": function (field, defaultName) { return field.value === defaultName; }, - "matches": function(field, matchName) { + "matches": function (field, matchName) { if (typeof this.inputs[matchName] === "undefined") { return false; } @@ -179,10 +179,10 @@ define([ return false; }, - "valid_email": function(field) { + "valid_email": function (field) { return this.Regexp.emailRegex.test(field.value); }, - "valid_emails": function(field) { + "valid_emails": function (field) { var result = field.value.split(","); for (var i = 0; i < result.length; i++) { @@ -193,9 +193,11 @@ define([ return true; }, - "min_length": function(field, length) { + "min_length": function (field, length) { 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)) { @@ -204,9 +206,11 @@ define([ return (field.value.length >= parseInt(length, 10)); }, - "max_length": function(field, length) { + "max_length": function (field, length) { 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)) { @@ -215,9 +219,11 @@ define([ return (field.value.length <= parseInt(length, 10)); }, - "exact_length": function(field, length) { + "exact_length": function (field, length) { 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)) { @@ -226,48 +232,48 @@ define([ return (field.value.length === parseInt(length, 10)); }, - "greater_than": function(field, param) { + "greater_than": function (field, param) { if (!this.Regexp.decimalRegex.test(field.value)) { return false; } return (parseFloat(field.value) > parseFloat(param)); }, - "less_than": function(field, param) { + "less_than": function (field, param) { if (!this.Regexp.decimalRegex.test(field.value)) { return false; } return (parseFloat(field.value) < parseFloat(param)); }, - "alpha": function(field) { + "alpha": function (field) { return (this.Regexp.alphaRegex.test(field.value)); }, - "alpha_numeric": function(field) { + "alpha_numeric": function (field) { return (this.Regexp.alphaNumericRegex.test(field.value)); }, - "alpha_dash": function(field) { + "alpha_dash": function (field) { return (this.Regexp.alphaDashRegex.test(field.value)); }, - "numeric": function(field) { + "numeric": function (field) { return (this.Regexp.numericRegex.test(field.value)); }, - "integer": function(field) { + "integer": function (field) { return (this.Regexp.integerRegex.test(field.value)); }, - "decimal": function(field) { + "decimal": function (field) { return (this.Regexp.decimalRegex.test(field.value)); }, - "is_natural": function(field) { + "is_natural": function (field) { return (this.Regexp.naturalRegex.test(field.value)); }, - "is_natural_no_zero": function(field) { + "is_natural_no_zero": function (field) { return (this.Regexp.naturalNoZeroRegex.test(field.value)); }, - "valid_ip": function(field) { + "valid_ip": function (field) { return (this.Regexp.ipRegex.test(field.value)); }, - "valid_url": function(field) { + "valid_url": function (field) { return (this.Regexp.urlRegex.test(field.value)); } }; diff --git a/www/scripts/common/forms/views/error.js b/www/scripts/common/forms/views/error.js index 85f8034fbe..5c7247fa1e 100644 --- a/www/scripts/common/forms/views/error.js +++ b/www/scripts/common/forms/views/error.js @@ -11,11 +11,11 @@ define([ "jquery", "underscore", "backbone" -], function($, _, Backbone) { +], function ($, _, Backbone) { var ErrorView = Backbone.View.extend({ tagName: "div", - initialize: function(options) { - options = options || {}; + initialize: function (options) { + options = options || {}; if (false === "name" in options) { throw "Missing name attribute in error view"; @@ -28,11 +28,11 @@ define([ this.name = options.name; this.errorTemplate = options.errorTemplate; - this.errors = options.errors || {}; + this.errors = options.errors || {}; this.onRenderError = options.onRenderError || null; }, - render: function() { - if (this.errors.length > 0 ) { + render: function () { + if (this.errors.length > 0) { var template = _.template($(this.errorTemplate).html(), { errors: this.errors }); @@ -54,7 +54,7 @@ define([ return this; }, - reset: function() { + reset: function () { this.$el.empty(); } }); diff --git a/www/scripts/common/forms/views/form.js b/www/scripts/common/forms/views/form.js index 0237ca1ff6..19f7cafd38 100644 --- a/www/scripts/common/forms/views/form.js +++ b/www/scripts/common/forms/views/form.js @@ -14,13 +14,13 @@ define([ "bootstrap", "common/forms/validator", "common/forms/views/input" -], function($, _, Backbone, bootstrap, Validator, InputView) { +], function ($, _, Backbone, bootstrap, Validator, InputView) { var Form = Backbone.View.extend({ events: { "submit": "_onSubmit" }, - initialize: function(options) { - options = options || {}; + initialize: function (options) { + options = options || {}; var self = this; @@ -49,7 +49,7 @@ define([ // cancel submit event.preventDefault(); // group errors by input - _.each(_.groupBy(this.validator.getErrors(), function(error){ + _.each(_.groupBy(this.validator.getErrors(), function (error) { return error.name; }), function (errors, name) { // show new errors in the views @@ -66,17 +66,17 @@ define([ }); } }, - _resetInputErrors: function() { - _.each(this.inputViews, function(view) { + _resetInputErrors: function () { + _.each(this.inputViews, function (view) { view.resetErrors(); }); }, - _addInputView: function(input) { + _addInputView: function (input) { var name = input.name; this.inputViews[name] = new InputView({ name: name, - el : $("input[name='"+name+"'], select[name='"+name+"'], textarea[name='"+name+"']", this.$el).first().closest("div"), + el: $("input[name='" + name + "'], select[name='" + name + "'], textarea[name='" + name + "']", this.$el).first().closest("div"), errorTemplate: this.errorTemplate, onRenderError: this.onRenderError }); diff --git a/www/scripts/common/forms/views/formType/passwordSetter.js b/www/scripts/common/forms/views/formType/passwordSetter.js index e5f112aeaa..5a6a657b60 100644 --- a/www/scripts/common/forms/views/formType/passwordSetter.js +++ b/www/scripts/common/forms/views/formType/passwordSetter.js @@ -14,14 +14,14 @@ define([ "backbone", "bootstrap", "common/forms/views/form" -], function($, _, i18n, Backbone, bootstrap, FormView) { +], function ($, _, i18n, Backbone, bootstrap, FormView) { var PasswordSetterForm = FormView.extend({ - events: function(){ - return _.extend({},FormView.prototype.events,{ - 'keyup input[type=password]' : 'onPasswordKeyup' + events: function () { + return _.extend({}, FormView.prototype.events, { + 'keyup input[type=password]': 'onPasswordKeyup' }); }, - onPasswordKeyup : function(event) { + onPasswordKeyup: function (event) { var input = $(event.target); var password = input.val(); var inputView = this.inputViews[input.attr("name")]; @@ -34,7 +34,7 @@ define([ }; var result = ""; - if (password.length > 0 ) { + if (password.length > 0) { var passMeter = zxcvbn(input.val()); switch (passMeter.score) { diff --git a/www/scripts/common/forms/views/input.js b/www/scripts/common/forms/views/input.js index 6b838296d1..a00df7eb00 100644 --- a/www/scripts/common/forms/views/input.js +++ b/www/scripts/common/forms/views/input.js @@ -13,10 +13,10 @@ define([ "backbone", "common/forms/views/error", "common/multiviews" -], function($, _, Backbone, ErrorView, MultiViews) { +], function ($, _, Backbone, ErrorView, MultiViews) { var InputView = Backbone.View.extend(_.extend({}, MultiViews, { - initialize: function(options) { - options = options || {}; + initialize: function (options) { + options = options || {}; if (false === "name" in options) { throw "Missing name attribute in input view"; @@ -35,7 +35,7 @@ define([ }); }, render: function () { - this._assignView({".error-view" : this.errorView}); + this._assignView({".error-view": this.errorView}); }, showErrors: function (errors) { this.render(); diff --git a/www/scripts/common/geonames.js b/www/scripts/common/geonames.js index f974fb7b1b..7c1ae63e47 100644 --- a/www/scripts/common/geonames.js +++ b/www/scripts/common/geonames.js @@ -1,4 +1,5 @@ -;(function (root, factory) { +; +(function (root, factory) { if (typeof define === 'function' && define.amd) { define([''], factory); } else { @@ -6,33 +7,33 @@ } }(this, function () { return { - init: function($field, options) { + init: function ($field, options) { var geocompleter = $field.geocompleter(options); // On focus add select-state - geocompleter.geocompleter("autocompleter", "on", "autocompletefocus", function(event, ui) { + geocompleter.geocompleter("autocompleter", "on", "autocompletefocus", function (event, ui) { $("li", $(event.originalEvent.target)).closest("li").removeClass("selected"); $("a.ui-state-active, a.ui-state-hover, a.ui-state-focus", $(event.originalEvent.target)).closest("li").addClass("selected"); }); // On search request add loading-state - geocompleter.geocompleter("autocompleter", "on", "autocompletesearch", function(event, ui) { + geocompleter.geocompleter("autocompleter", "on", "autocompletesearch", function (event, ui) { $(this).addClass('input-loading'); $(this).removeClass('input-error'); }); // On response remove loading-state - geocompleter.geocompleter("autocompleter", "on", "autocompleteresponse", function(event, ui) { + geocompleter.geocompleter("autocompleter", "on", "autocompleteresponse", function (event, ui) { $(this).removeClass('input-loading'); }); // On close menu remove loading-state - geocompleter.geocompleter("autocompleter", "on", "autocompleteclose", function(event, ui) { + geocompleter.geocompleter("autocompleter", "on", "autocompleteclose", function (event, ui) { $(this).removeClass('input-loading'); }); // On request error add error-state - geocompleter.geocompleter("autocompleter", "on", "geotocompleter.request.error", function(jqXhr, status, error) { + geocompleter.geocompleter("autocompleter", "on", "geotocompleter.request.error", function (jqXhr, status, error) { $(this).removeClass('input-loading'); $(this).addClass('input-error'); }); diff --git a/www/scripts/common/multiviews.js b/www/scripts/common/multiviews.js index 76d1680938..c1fbde3564 100644 --- a/www/scripts/common/multiviews.js +++ b/www/scripts/common/multiviews.js @@ -11,10 +11,10 @@ define([ "jquery", "underscore", "backbone" -], function($, _, Backbone) { +], function ($, _, Backbone) { return { // bind a subview to a DOM element - "_assignView": function(selector, view) { + "_assignView": function (selector, view) { var selectors; if (_.isObject(selector)) { selectors = selector; @@ -23,7 +23,7 @@ define([ selectors[selector] = view; } if (!selectors) return; - _.each(selectors, function(view, selector) { + _.each(selectors, function (view, selector) { view.setElement(this.$(selector)).render(); }, this); } diff --git a/www/scripts/models/dcField.js b/www/scripts/models/dcField.js index 65cec8e6b6..33a72e4fbf 100644 --- a/www/scripts/models/dcField.js +++ b/www/scripts/models/dcField.js @@ -10,7 +10,7 @@ define([ "underscore", "backbone" -], function(_, Backbone) { +], function (_, Backbone) { var DcFieldModel = Backbone.Model.extend({ urlRoot: function () { return "/admin/fields/dc-fields"; diff --git a/www/scripts/models/field.js b/www/scripts/models/field.js index fa8692bab3..1c807b2d00 100644 --- a/www/scripts/models/field.js +++ b/www/scripts/models/field.js @@ -10,16 +10,16 @@ define([ "underscore", "backbone" -], function(_, Backbone) { +], function (_, Backbone) { var FieldModel = Backbone.Model.extend({ - initialize : function(attributes, options) { + initialize: function (attributes, options) { attributes = attributes || {}; if (typeof attributes === "object" && false === "sbas-id" in attributes) { throw "You must set a sbas id"; } }, urlRoot: function () { - return "/admin/fields/"+ this.get("sbas-id") +"/fields"; + return "/admin/fields/" + this.get("sbas-id") + "/fields"; }, defaults: { "business": false, @@ -36,10 +36,10 @@ define([ "vocabulary-type": null, "vocabulary-restricted": false, "labels": { - "fr" : "", - "en" : "", - "de" : "", - "nl" : "" + "fr": "", + "en": "", + "de": "", + "nl": "" } } }); diff --git a/www/scripts/models/vocabulary.js b/www/scripts/models/vocabulary.js index e681dc98b5..42ed7813ae 100644 --- a/www/scripts/models/vocabulary.js +++ b/www/scripts/models/vocabulary.js @@ -10,7 +10,7 @@ define([ "underscore", "backbone" -], function(_, Backbone) { +], function (_, Backbone) { var VocabularyModel = Backbone.Model.extend({ urlRoot: function () { return "/admin/fields/vocabularies"; diff --git a/www/scripts/tests/baseTest.js b/www/scripts/tests/baseTest.js index 660954f6f5..f2334f6b83 100644 --- a/www/scripts/tests/baseTest.js +++ b/www/scripts/tests/baseTest.js @@ -1,4 +1,4 @@ -define(["chai"], function(shai) { +define(["chai"], function (shai) { window.expect = shai.expect; window.assert = shai.assert; }); diff --git a/www/scripts/tests/main.js b/www/scripts/tests/main.js index 2b387702c9..dac11c88fc 100644 --- a/www/scripts/tests/main.js +++ b/www/scripts/tests/main.js @@ -18,7 +18,7 @@ require.config({ bootstrap: "../skins/build/bootstrap/js/bootstrap.min" }, shim: { - bootstrap : ["jquery"], + bootstrap: ["jquery"], jqueryui: { deps: ["jquery"] }, @@ -39,11 +39,12 @@ mocha.setup({ globals: ['js-fixtures'] }); -console = window.console || function() {}; +console = window.console || function () { +}; window.notrack = true; -var runMocha = function() { +var runMocha = function () { if (window.mochaPhantomJS) { mochaPhantomJS.run(); } else { diff --git a/www/scripts/tests/specs/admin/fields.js b/www/scripts/tests/specs/admin/fields.js index d1ef466795..129c527881 100644 --- a/www/scripts/tests/specs/admin/fields.js +++ b/www/scripts/tests/specs/admin/fields.js @@ -15,24 +15,7 @@ define([ 'apps/admin/fields/views/modal', 'apps/admin/fields/views/save', 'apps/admin/fields/views/dcField' -], function( - chai, - fixtures, - $, - App, - FieldModel, - FieldCollection, - DcFieldCollection, - VocabularyCollection, - SingleItemView, - ListItemView, - AlertView, - EditView, - FieldErrorView, - ModalView, - SaveView, - DcFieldView - ) { +], function (chai, fixtures, $, App, FieldModel, FieldCollection, DcFieldCollection, VocabularyCollection, SingleItemView, ListItemView, AlertView, EditView, FieldErrorView, ModalView, SaveView, DcFieldView) { var expect = chai.expect; var assert = chai.assert; var should = chai.should(); @@ -44,36 +27,36 @@ define([ App.initialize(); - describe("Admin field", function() { - describe("Initialization", function() { - it("should create a global variable", function() { + describe("Admin field", function () { + describe("Initialization", function () { + it("should create a global variable", function () { should.exist(AdminFieldApp); }); }); - describe("Collections", function() { - describe("DcField Collection", function() { - beforeEach(function() { + describe("Collections", function () { + describe("DcField Collection", function () { + beforeEach(function () { this.collection = new DcFieldCollection([]); }); - it("should set collection url according to provided 'sbas-id'", function() { + it("should set collection url according to provided 'sbas-id'", function () { this.collection.url().should.equal("/admin/fields/dc-fields"); }); }); - describe("Vocabulary Collection", function() { - beforeEach(function() { + describe("Vocabulary Collection", function () { + beforeEach(function () { this.collection = new VocabularyCollection([]); }); - it("should set collection url according to provided 'sbas-id'", function() { + it("should set collection url according to provided 'sbas-id'", function () { this.collection.url().should.equal("/admin/fields/vocabularies"); }); }); - describe("Field Collection", function() { - beforeEach(function() { + describe("Field Collection", function () { + beforeEach(function () { this.collection = new FieldCollection([ {"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}, {"id": 2, "sbas-id": sbasId, "name": "Object", "tag": "XMP:Object"} @@ -82,24 +65,24 @@ define([ }); }); - describe("Initialization", function() { - it("should throw an exception if 'sbas_id' is missing", function() { - expect(function() { + describe("Initialization", function () { + it("should throw an exception if 'sbas_id' is missing", function () { + expect(function () { new FieldCollection([]); }).to.throw("You must set a sbas id"); }); - it("should set collection url according to provided 'sbas-id'", function() { - this.collection.url().should.equal("/admin/fields/"+sbasId+"/fields"); + it("should set collection url according to provided 'sbas-id'", function () { + this.collection.url().should.equal("/admin/fields/" + sbasId + "/fields"); }); }); - describe("Methods", function() { - it("should retrieve categorie item if searching terms begins with 'cat'", function() { + describe("Methods", function () { + it("should retrieve categorie item if searching terms begins with 'cat'", function () { this.collection.search('Cat')._wrapped.length.should.equal(1); }); - it("should retrieve previous and next index for given model", function() { + it("should retrieve previous and next index for given model", function () { expect(this.collection.previousIndex(this.collection.first())).to.be.null; this.collection.nextIndex(this.collection.first()).should.equal(1); this.collection.previousIndex(this.collection.last()).should.equal(0); @@ -109,29 +92,29 @@ define([ }); }); - describe("Views", function() { - describe("Single Item Views", function() { - beforeEach(function() { + describe("Views", function () { + describe("Single Item Views", function () { + beforeEach(function () { this.field = new FieldModel({"sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); this.view = new SingleItemView({model: this.field}); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a LI element", function() { + it("should render as a LI element", function () { this.view.render().el.nodeName.should.equal("LI"); }); - it("should render as a LI element with proper properties", function() { + it("should render as a LI element with proper properties", function () { this.view.render().$el.find('.field-name').html().should.equal("Categorie"); this.view.render().$el.find('.field-tag').html().should.equal("XMP:Categorie"); }); }); - describe("List Item Views", function() { - beforeEach(function() { + describe("List Item Views", function () { + beforeEach(function () { this.collection = new FieldCollection([ {"sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}, {"sbas-id": sbasId, "name": "Object", "tag": "XMP:Object"} @@ -145,45 +128,47 @@ define([ }); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV block", function() { + it("should render as a DIV block", function () { this.view.render().el.nodeName.should.equal("DIV"); }); - it("should include list items for all models in collection", function() { + it("should include list items for all models in collection", function () { this.view.render(); this.view.$el.find("li").should.have.length(2); }); }); - describe("Alert Views", function() { - beforeEach(function() { + describe("Alert Views", function () { + beforeEach(function () { this.view = new AlertView({alert: "info", message: "Hello world!"}); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); }); }); - describe("DcField Views", function() { - beforeEach(function() { - this.collection = new DcFieldCollection([{ - "label": "Contributor", - "definition": "An entity responsible for making contributions to the resource.", - "URI": "http://dublincore.org/documents/dces/#contributor" - }, { - "label": "Coverage", - "definition": "The spatial or temporal topic of the resource, the spatial applicability of the resource,\n or the jurisdiction under which the resource\n is relevant.", - "URI": "http://dublincore.org/documents/dces/#coverage" - } + describe("DcField Views", function () { + beforeEach(function () { + this.collection = new DcFieldCollection([ + { + "label": "Contributor", + "definition": "An entity responsible for making contributions to the resource.", + "URI": "http://dublincore.org/documents/dces/#contributor" + }, + { + "label": "Coverage", + "definition": "The spatial or temporal topic of the resource, the spatial applicability of the resource,\n or the jurisdiction under which the resource\n is relevant.", + "URI": "http://dublincore.org/documents/dces/#coverage" + } ]); var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); @@ -194,17 +179,17 @@ define([ }); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); }); }); - describe("Edit Views", function() { - beforeEach(function() { + describe("Edit Views", function () { + beforeEach(function () { var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); this.view = new EditView({"model": model}); @@ -227,24 +212,24 @@ define([ AdminFieldApp.fieldListView.render(); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); }); - it("should not render an error message if provided tag is empty", function() { - var view = this.view.render(); + it("should not render an error message if provided tag is empty", function () { + var view = this.view.render(); view.$('input#tag').val("").blur(); assert.isFalse(view.$('input#tag').closest(".control-group").hasClass("error")); }); - it("should uncheck vocabulary restricted if provided vocabulary is empty", function() { - var view = this.view.render(); + it("should uncheck vocabulary restricted if provided vocabulary is empty", function () { + var view = this.view.render(); view.$('input#vocabulary-restricted').attr("checked", true); view.$('input#vocabulary-type option').first().attr("selected", true); @@ -253,22 +238,22 @@ define([ }); }); - describe("FieldError Views", function() { - beforeEach(function() { + describe("FieldError Views", function () { + beforeEach(function () { this.view = new FieldErrorView(); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); }); }); - describe("Modal Views", function() { - beforeEach(function() { + describe("Modal Views", function () { + beforeEach(function () { var model = new FieldModel({"id": 1, "sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); this.view = new ModalView({ @@ -277,34 +262,34 @@ define([ }); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); this.view.remove(); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); this.view.remove(); }); }); - describe("Save Views", function() { - beforeEach(function() { + describe("Save Views", function () { + beforeEach(function () { this.view = new SaveView(); }); - it("render() should return the view object", function() { + it("render() should return the view object", function () { this.view.render().should.equal(this.view); }); - it("should render as a DIV element", function() { + it("should render as a DIV element", function () { this.view.render().el.nodeName.should.equal("DIV"); }); }); }); - describe("Edge cases", function() { - beforeEach(function() { + describe("Edge cases", function () { + beforeEach(function () { AdminFieldApp.fieldsCollection.reset(); AdminFieldApp.fieldsCollection.add({"sbas-id": sbasId, "name": "Categorie", "tag": "XMP:Categorie"}); AdminFieldApp.dcFieldsCollection.add({ @@ -324,7 +309,7 @@ define([ AdminFieldApp.fieldListView.render(); }); - it("should update collection when model change", function() { + it("should update collection when model change", function () { AdminFieldApp.fieldListView.itemViews[0].clickAction(); AdminFieldApp.fieldEditView.model.set({ "name": "new name" @@ -332,15 +317,17 @@ define([ assert.equal(AdminFieldApp.fieldListView.itemViews[0].model.get('name'), "new name", 'model is updated'); }); - it("should update edit view when clicking on single element", function() { + it("should update edit view when clicking on single element", function () { AdminFieldApp.fieldListView.itemViews[0].clickAction(); should.exist(AdminFieldApp.fieldEditView); assert.equal(AdminFieldApp.fieldEditView.model, AdminFieldApp.fieldListView.collection.first(), 'model is updated'); }); - it("should reorder collection on drop action", function() { - var ui = {item: {index: function() {return 2;}}}; - AdminFieldApp.fieldListView.itemViews[0].dropAction({},ui); + it("should reorder collection on drop action", function () { + var ui = {item: {index: function () { + return 2; + }}}; + AdminFieldApp.fieldListView.itemViews[0].dropAction({}, ui); assert.equal(AdminFieldApp.fieldListView.collection.last().get('sorter'), 3, 'model is updated'); }); }); diff --git a/www/scripts/tests/specs/login/home.js b/www/scripts/tests/specs/login/home.js index 756eddb266..e59315573c 100644 --- a/www/scripts/tests/specs/login/home.js +++ b/www/scripts/tests/specs/login/home.js @@ -5,14 +5,7 @@ define([ 'common/forms/views/form', 'common/forms/views/input', 'common/forms/views/error' -], function( - chai, - fixtures, - $, - FormView, - InputView, - ErrorView - ) { +], function (chai, fixtures, $, FormView, InputView, ErrorView) { var expect = chai.expect; var assert = chai.assert; var should = chai.should(); @@ -20,10 +13,12 @@ define([ fixtures.path = 'fixtures'; $("body").append(fixtures.read('home/login/form', 'home/login/templates')); - describe("Login Home", function() { - describe("Form View", function() { - it("should initialize validator with proper rules", function() { - var rules = [{name: "hello",rules: "simple_rules"}]; + describe("Login Home", function () { + describe("Form View", function () { + it("should initialize validator with proper rules", function () { + var rules = [ + {name: "hello", rules: "simple_rules"} + ]; var form = new FormView({ el: $('form[name=loginForm]'), rules: rules @@ -31,7 +26,7 @@ define([ form.validator.getRules().should.equal(rules); }); - it("should initialize input views", function() { + it("should initialize input views", function () { var form = new FormView({ el: $('form[name=loginForm]') }); @@ -39,7 +34,7 @@ define([ Object.keys(form.inputViews).length.should.equal(5); }); - it("should initialize errors", function() { + it("should initialize errors", function () { var form = new FormView({ el: $('form[name=loginForm]') }); @@ -47,14 +42,16 @@ define([ assert.isTrue(_.isEmpty(form.validator.getErrors())); }); - it("should render errors on submit", function() { + it("should render errors on submit", function () { var form = new FormView({ el: $('form[name=loginForm]'), - rules: [{ - "name": "login", - "rules": "required", - "message" : "something is wrong" - }] + rules: [ + { + "name": "login", + "rules": "required", + "message": "something is wrong" + } + ] }); form._onSubmit(document.createEvent("Event")); @@ -62,8 +59,8 @@ define([ }); }); - describe("Input View", function() { - it("should initialize error view", function() { + describe("Input View", function () { + it("should initialize error view", function () { var input = new InputView({ "name": "test", "errorTemplate": "#field_errors" @@ -72,9 +69,9 @@ define([ }); }); - describe("Error View", function() { - it("should render errors", function() { - var error ={ + describe("Error View", function () { + it("should render errors", function () { + var error = { name: "test", message: "Something is wrong" }; @@ -82,7 +79,7 @@ define([ var errorView = new ErrorView({ "name": "test", "errors": [error], - "el" : $(".error-view").first(), + "el": $(".error-view").first(), "errorTemplate": "#field_errors" }); @@ -91,7 +88,7 @@ define([ assert.isTrue(errorView.$el.html().indexOf(error.message) !== -1); }); - it("should empty errors content if there are no errors", function() { + it("should empty errors content if there are no errors", function () { var $el = $(".error-view").first(); $el.html('previous error here'); @@ -99,7 +96,7 @@ define([ var errorView = new ErrorView({ "name": "test", "errors": [], - "el" : $el, + "el": $el, "errorTemplate": "#field_errors" }); diff --git a/www/scripts/tests/specs/models.js b/www/scripts/tests/specs/models.js index f1552e4177..bf4c240779 100644 --- a/www/scripts/tests/specs/models.js +++ b/www/scripts/tests/specs/models.js @@ -3,108 +3,108 @@ define([ 'models/field', 'models/dcField', 'models/vocabulary' -], function(chai, Field, DcField, Vocabulary) { +], function (chai, Field, DcField, Vocabulary) { var expect = chai.expect; var assert = chai.assert; var should = chai.should(); - describe("Models", function(){ - describe("Field Model", function(){ - describe("Initialization", function() { + describe("Models", function () { + describe("Field Model", function () { + describe("Initialization", function () { var sbasId = 1; - beforeEach(function() { + beforeEach(function () { this.field = new Field({ - "sbas-id" : sbasId + "sbas-id": sbasId }); }); - it("should throw an exception if 'sbas-id' is missing", function() { - expect(function() { + it("should throw an exception if 'sbas-id' is missing", function () { + expect(function () { new Field(); }).to.throw("You must set a sbas id"); }); - it("should set model url according to provided 'sbas-id'", function() { - this.field.urlRoot().should.equal("/admin/fields/"+sbasId+"/fields"); + it("should set model url according to provided 'sbas-id'", function () { + this.field.urlRoot().should.equal("/admin/fields/" + sbasId + "/fields"); }); - it("should default business property to 'false'", function() { + it("should default business property to 'false'", function () { this.field.get('business').should.be.false; }); - it("should default type property to 'string'", function() { + it("should default type property to 'string'", function () { this.field.get('type').should.equal("string"); }); - it("should default thumbtitle property to '0'", function() { + it("should default thumbtitle property to '0'", function () { this.field.get('thumbtitle').should.equal("0"); }); - it("should default tbranch property to 'empty'", function() { + it("should default tbranch property to 'empty'", function () { this.field.get('tbranch').should.equal(""); }); - it("should default separator property to 'empty'", function() { + it("should default separator property to 'empty'", function () { this.field.get('separator').should.equal(""); }); - it("should default required property to 'false'", function() { + it("should default required property to 'false'", function () { this.field.get('required').should.be.false; }); - it("should default readonly property to 'false'", function() { + it("should default readonly property to 'false'", function () { this.field.get('readonly').should.be.false; }); - it("should default multi property to 'false'", function() { + it("should default multi property to 'false'", function () { this.field.get('multi').should.be.false; }); - it("should default vocabulary-restricted property to 'false'", function() { + it("should default vocabulary-restricted property to 'false'", function () { this.field.get('vocabulary-restricted').should.be.false; }); - it("should default vocabulary-restricted property to 'false'", function() { + it("should default vocabulary-restricted property to 'false'", function () { this.field.get('vocabulary-restricted').should.be.false; }); - it("should default report property to 'true'", function() { + it("should default report property to 'true'", function () { this.field.get('report').should.be.true; }); - it("should default indexable property to 'true'", function() { + it("should default indexable property to 'true'", function () { this.field.get('indexable').should.be.true; }); - it("should default dces-element property to 'null'", function() { + it("should default dces-element property to 'null'", function () { expect(this.field.get('dces-element')).to.be.null; }); - it("should default vocabulary-type property to 'null'", function() { + it("should default vocabulary-type property to 'null'", function () { expect(this.field.get('vocabulary-type')).to.be.null; }); }); }); - describe("DcField Model", function(){ - describe("Initialization", function() { - beforeEach(function() { + describe("DcField Model", function () { + describe("Initialization", function () { + beforeEach(function () { this.dcField = new DcField(); }); - it("should set proper model url", function() { + it("should set proper model url", function () { this.dcField.urlRoot().should.equal("/admin/fields/dc-fields"); }); }); }); - describe("DcField Model", function(){ - describe("Initialization", function() { - beforeEach(function() { + describe("DcField Model", function () { + describe("Initialization", function () { + beforeEach(function () { this.vocabulary = new Vocabulary(); }); - it("should set proper model url", function() { + it("should set proper model url", function () { this.vocabulary.urlRoot().should.equal("/admin/fields/vocabularies"); }); }); diff --git a/www/scripts/tests/specs/validator.js b/www/scripts/tests/specs/validator.js index 26510ca118..c59261e04b 100644 --- a/www/scripts/tests/specs/validator.js +++ b/www/scripts/tests/specs/validator.js @@ -1,490 +1,611 @@ define([ 'chai', 'common/forms/validator' -], function(chai, Validator) { +], function (chai, Validator) { var expect = chai.expect; var assert = chai.assert; var should = chai.should(); - describe("Validator", function(){ - describe("Validator rules", function(){ + describe("Validator", function () { + describe("Validator rules", function () { - beforeEach(function() { - this.validator = new Validator([{ - name: "required", - rules: "required" - },{ - name: "valid_email", - rules: "valid_email" - },{ - name: "equal", - rules: "equal[toto]" - },{ - name: "matches", - rules: "matches[to_match]" - },{ - name: "valid_emails", - rules: "valid_emails" - },{ - name: "min_length", - rules: "min_length[5]" - },{ - name: "max_length", - rules: "max_length[5]" - },{ - name: "exact_length", - rules: "exact_length[5]" - },{ - name: "greater_than", - rules: "greater_than[5]" - },{ - name: "less_than", - rules: "less_than[5]" - },{ - name: "alpha", - rules: "alpha" - },{ - name: "alpha_numeric", - rules: "alpha_numeric" - },{ - name: "alpha_dash", - rules: "alpha_dash" - },{ - name: "numeric", - rules: "numeric" - },{ - name: "integer", - rules: "integer" - },{ - name: "decimal", - rules: "decimal" - },{ - name: "is_natural", - rules: "is_natural" - },{ - name: "is_natural_no_zero", - rules: "is_natural_no_zero" - },{ - name: "valid_ip", - rules: "valid_ip" - },{ - name: "valid_url", - rules: "valid_url" - }]); + beforeEach(function () { + this.validator = new Validator([ + { + name: "required", + rules: "required" + }, + { + name: "valid_email", + rules: "valid_email" + }, + { + name: "equal", + rules: "equal[toto]" + }, + { + name: "matches", + rules: "matches[to_match]" + }, + { + name: "valid_emails", + rules: "valid_emails" + }, + { + name: "min_length", + rules: "min_length[5]" + }, + { + name: "max_length", + rules: "max_length[5]" + }, + { + name: "exact_length", + rules: "exact_length[5]" + }, + { + name: "greater_than", + rules: "greater_than[5]" + }, + { + name: "less_than", + rules: "less_than[5]" + }, + { + name: "alpha", + rules: "alpha" + }, + { + name: "alpha_numeric", + rules: "alpha_numeric" + }, + { + name: "alpha_dash", + rules: "alpha_dash" + }, + { + name: "numeric", + rules: "numeric" + }, + { + name: "integer", + rules: "integer" + }, + { + name: "decimal", + rules: "decimal" + }, + { + name: "is_natural", + rules: "is_natural" + }, + { + name: "is_natural_no_zero", + rules: "is_natural_no_zero" + }, + { + name: "valid_ip", + rules: "valid_ip" + }, + { + name: "valid_url", + rules: "valid_url" + } + ]); }); - it("should detect an error if field is required and value is blank", function() { - this.validator.validate([{ - name :"required", - value: "" - }]); + it("should detect an error if field is required and value is blank", function () { + this.validator.validate([ + { + name: "required", + value: "" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should detect an error if field is not a valid email", function() { - this.validator.validate([{ - name :"valid_email", - value: "email.not.va@" - }]); + it("should detect an error if field is not a valid email", function () { + this.validator.validate([ + { + name: "valid_email", + value: "email.not.va@" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field is a valid email", function() { - this.validator.validate([{ - name :"valid_email", - value: "valid@email.com" - }]); + it("should not detect an error if field is a valid email", function () { + this.validator.validate([ + { + name: "valid_email", + value: "valid@email.com" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_email", - value: "valid+34@email.com" - }]); + this.validator.validate([ + { + name: "valid_email", + value: "valid+34@email.com" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field is not a valid emails", function() { - this.validator.validate([{ - name :"valid_emails", - value: "valid@email.com, email.not.va@" - }]); + it("should detect an error if field is not a valid emails", function () { + this.validator.validate([ + { + name: "valid_emails", + value: "valid@email.com, email.not.va@" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field is a valid emails", function() { - this.validator.validate([{ - name :"valid_emails", - value: "valid32@email.com, valid2@email.com" - }]); + it("should not detect an error if field is a valid emails", function () { + this.validator.validate([ + { + name: "valid_emails", + value: "valid32@email.com, valid2@email.com" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_emails", - value: "valid@email.com" - }]); + this.validator.validate([ + { + name: "valid_emails", + value: "valid@email.com" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field is not equal to default string toto", function() { - this.validator.validate([{ - name :"equal", - value: "tata" - }]); + it("should detect an error if field is not equal to default string toto", function () { + this.validator.validate([ + { + name: "equal", + value: "tata" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field is equal to default string toto", function() { - this.validator.validate([{ - name :"equal", - value: "toto" - }]); + it("should not detect an error if field is equal to default string toto", function () { + this.validator.validate([ + { + name: "equal", + value: "toto" + } + ]); 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() { - this.validator.validate([{ - name :"matches", - value: "toto" - }, { - name: "to_match", - value: "tata" - }]); + it("should detect an error if field value 'match 'is not equal to field value 'to_match'", function () { + this.validator.validate([ + { + name: "matches", + value: "toto" + }, + { + name: "to_match", + value: "tata" + } + ]); 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() { - this.validator.validate([{ - name :"matches", - value: "toto" - }, { - name: "to_match", - value: "toto" - }]); + it("should not detect an error if field value 'match' is equal to field value 'to_match'", function () { + this.validator.validate([ + { + name: "matches", + value: "toto" + }, + { + name: "to_match", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'min_length' is < to 5", function() { - this.validator.validate([{ - name :"min_length", - value: "toto" - }]); + it("should detect an error if field value 'min_length' is < to 5", function () { + this.validator.validate([ + { + name: "min_length", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'min_length' is >= to 5", function() { - this.validator.validate([{ - name :"min_length", - value: "totos" - }]); + it("should not detect an error if field value 'min_length' is >= to 5", function () { + this.validator.validate([ + { + name: "min_length", + value: "totos" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'max_length' is > to 5", function() { - this.validator.validate([{ - name :"max_length", - value: "tostos" - }]); + it("should detect an error if field value 'max_length' is > to 5", function () { + this.validator.validate([ + { + name: "max_length", + value: "tostos" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'max_length' is <= to 5", function() { - this.validator.validate([{ - name :"max_length", - value: "toto" - }]); + it("should not detect an error if field value 'max_length' is <= to 5", function () { + this.validator.validate([ + { + name: "max_length", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'greater_than' is < to 5", function() { - this.validator.validate([{ - name :"greater_than", - value: "3" - }]); + it("should detect an error if field value 'greater_than' is < to 5", function () { + this.validator.validate([ + { + name: "greater_than", + value: "3" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'greater_than' is > to 5", function() { - this.validator.validate([{ - name :"greater_than", - value: "6" - }]); + it("should not detect an error if field value 'greater_than' is > to 5", function () { + this.validator.validate([ + { + name: "greater_than", + value: "6" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'less_than' is > to 5", function() { - this.validator.validate([{ - name :"less_than", - value: "6" - }]); + it("should detect an error if field value 'less_than' is > to 5", function () { + this.validator.validate([ + { + name: "less_than", + value: "6" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'less_than' is <= to 5", function() { - this.validator.validate([{ - name :"less_than", - value: "3" - }]); + it("should not detect an error if field value 'less_than' is <= to 5", function () { + this.validator.validate([ + { + name: "less_than", + value: "3" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'exact_length' is = to 5", function() { - this.validator.validate([{ - name :"exact_length", - value: "toto" - }]); + it("should detect an error if field value 'exact_length' is = to 5", function () { + this.validator.validate([ + { + name: "exact_length", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'exact_length' is = to 5", function() { - this.validator.validate([{ - name :"exact_length", - value: "totos" - }]); + it("should not detect an error if field value 'exact_length' is = to 5", function () { + this.validator.validate([ + { + name: "exact_length", + value: "totos" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'alpha' is not alpha", function() { - this.validator.validate([{ - name :"alpha", - value: "toto12" - }]); + it("should detect an error if field value 'alpha' is not alpha", function () { + this.validator.validate([ + { + name: "alpha", + value: "toto12" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'alpha' is alpha", function() { - this.validator.validate([{ - name :"alpha", - value: "totos" - }]); + it("should not detect an error if field value 'alpha' is alpha", function () { + this.validator.validate([ + { + name: "alpha", + value: "totos" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'alpha_numeric' is not alpha numeric", function() { - this.validator.validate([{ - name :"alpha_numeric", - value: "toto#" - }]); + it("should detect an error if field value 'alpha_numeric' is not alpha numeric", function () { + this.validator.validate([ + { + name: "alpha_numeric", + value: "toto#" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'alpha_numeric' is alpha numeric", function() { - this.validator.validate([{ - name :"alpha_numeric", - value: "totos12" - }]); + it("should not detect an error if field value 'alpha_numeric' is alpha numeric", function () { + this.validator.validate([ + { + name: "alpha_numeric", + value: "totos12" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'numeric' is not numeric", function() { - this.validator.validate([{ - name :"numeric", - value: "toto" - }]); + it("should detect an error if field value 'numeric' is not numeric", function () { + this.validator.validate([ + { + name: "numeric", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'numeric' is numeric", function() { - this.validator.validate([{ - name :"numeric", - value: "123" - }]); + it("should not detect an error if field value 'numeric' is numeric", function () { + this.validator.validate([ + { + name: "numeric", + value: "123" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'integer' is not integer", function() { - this.validator.validate([{ - name :"integer", - value: "3.44" - }]); + it("should detect an error if field value 'integer' is not integer", function () { + this.validator.validate([ + { + name: "integer", + value: "3.44" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'integer' is integer", function() { - this.validator.validate([{ - name :"integer", - value: "123" - }]); + it("should not detect an error if field value 'integer' is integer", function () { + this.validator.validate([ + { + name: "integer", + value: "123" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'decimal' is not decimal", function() { - this.validator.validate([{ - name :"decimal", - value: "23a" - }]); + it("should detect an error if field value 'decimal' is not decimal", function () { + this.validator.validate([ + { + name: "decimal", + value: "23a" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'decimal' is decimal", function() { - this.validator.validate([{ - name :"decimal", - value: "1.23" - }]); + it("should not detect an error if field value 'decimal' is decimal", function () { + this.validator.validate([ + { + name: "decimal", + value: "1.23" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"decimal", - value: "123" - }]); + this.validator.validate([ + { + name: "decimal", + value: "123" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'natural' is not natural", function() { - this.validator.validate([{ - name :"is_natural", - value: "-2" - }]); + it("should detect an error if field value 'natural' is not natural", function () { + this.validator.validate([ + { + name: "is_natural", + value: "-2" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'natural' is natural", function() { - this.validator.validate([{ - name :"is_natural", - value: "0" - }]); + it("should not detect an error if field value 'natural' is natural", function () { + this.validator.validate([ + { + name: "is_natural", + value: "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() { - this.validator.validate([{ - name :"is_natural_no_zero", - value: "0" - }]); + it("should detect an error if field value 'is_natural_no_zero' is not a natural no zero", function () { + this.validator.validate([ + { + name: "is_natural_no_zero", + value: "0" + } + ]); 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() { - this.validator.validate([{ - name :"is_natural_no_zero", - value: "1" - }]); + it("should not detect an error if field value 'is_natural_no_zero' is a natural no zero", function () { + this.validator.validate([ + { + name: "is_natural_no_zero", + value: "1" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'valid_ip' is not a valid ip", function() { - this.validator.validate([{ - name :"valid_ip", - value: "12.8.1.187.2" - }]); + it("should detect an error if field value 'valid_ip' is not a valid ip", function () { + this.validator.validate([ + { + name: "valid_ip", + value: "12.8.1.187.2" + } + ]); this.validator.getErrors().length.should.equal(1); - this.validator.validate([{ - name :"valid_ip", - value: "1234.12.12" - }]); + this.validator.validate([ + { + name: "valid_ip", + value: "1234.12.12" + } + ]); this.validator.getErrors().length.should.equal(1); - this.validator.validate([{ - name :"valid_ip", - value: "0.0" - }]); + this.validator.validate([ + { + name: "valid_ip", + value: "0.0" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'valid_ip' a valid ip", function() { - this.validator.validate([{ - name :"valid_ip", - value: "127.0.0.1" - }]); + it("should not detect an error if field value 'valid_ip' a valid ip", function () { + this.validator.validate([ + { + name: "valid_ip", + value: "127.0.0.1" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_ip", - value: "my.domain" - }]); + this.validator.validate([ + { + name: "valid_ip", + value: "my.domain" + } + ]); this.validator.getErrors().length.should.equal(0); }); - it("should detect an error if field value 'valid_url' is not a valid http url", function() { - this.validator.validate([{ - name :"valid_url", - value: "toto" - }]); + it("should detect an error if field value 'valid_url' is not a valid http url", function () { + this.validator.validate([ + { + name: "valid_url", + value: "toto" + } + ]); this.validator.getErrors().length.should.equal(1); - this.validator.validate([{ - name :"valid_url", - value: "toto.123s" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "toto.123s" + } + ]); this.validator.getErrors().length.should.equal(1); - this.validator.validate([{ - name :"valid_url", - value: "http:/#toto.com" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "http:/#toto.com" + } + ]); this.validator.getErrors().length.should.equal(1); - this.validator.validate([{ - name :"valid_url", - value: "htp:/toto.com" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "htp:/toto.com" + } + ]); this.validator.getErrors().length.should.equal(1); }); - it("should not detect an error if field value 'valid_url' is a valid http url", function() { - this.validator.validate([{ - name :"valid_url", - value: "http://valid.url.com" - }]); + it("should not detect an error if field value 'valid_url' is a valid http url", function () { + this.validator.validate([ + { + name: "valid_url", + value: "http://valid.url.com" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_url", - value: "https://valid.url.com" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "https://valid.url.com" + } + ]); this.validator.getErrors().length.should.equal(0); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_url", - value: "http://valid.url.com/?test=3" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "http://valid.url.com/?test=3" + } + ]); this.validator.getErrors().length.should.equal(0); - this.validator.validate([{ - name :"valid_url", - value: "http://valid.url.com/?test=3#salut" - }]); + this.validator.validate([ + { + name: "valid_url", + value: "http://valid.url.com/?test=3#salut" + } + ]); this.validator.getErrors().length.should.equal(0); }); diff --git a/www/skins/account/account.js b/www/skins/account/account.js index e948fcd1dd..86c2fef1e9 100644 --- a/www/skins/account/account.js +++ b/www/skins/account/account.js @@ -1,16 +1,16 @@ -$(document).ready(function() { +$(document).ready(function () { // revoke third party application access - $("a.app-btn").bind("click", function(e) { + $("a.app-btn").bind("click", function (e) { e.preventDefault(); var $this = $(this); $.ajax({ - type:"GET", - url : $this.attr("href"), + type: "GET", + url: $this.attr("href"), dataType: 'json', - data : {revoke : $this.hasClass("authorize") ? 1 : 0}, - success : function(data) { - if(data.success) { - var li = $this.closest('li'); + data: {revoke: $this.hasClass("authorize") ? 1 : 0}, + success: function (data) { + if (data.success) { + var li = $this.closest('li'); var hidden = $('.app-btn.hidden , .status.hidden', li); var notHidden = $('.app-btn:not(.hidden), .status:not(.hidden)', li); @@ -23,18 +23,18 @@ $(document).ready(function() { }); // generate new access token - $("a#generate_access").bind("click", function(e) { + $("a#generate_access").bind("click", function (e) { e.preventDefault(); var $this = $(this); $.ajax({ - type:"POST", - url : $this.attr("href"), + type: "POST", + url: $this.attr("href"), dataType: 'json', - data : { - usr_id : $this.closest("div").attr("id") + data: { + usr_id: $this.closest("div").attr("id") }, - success : function(data){ - if(data.success) { + success: function (data) { + if (data.success) { $("#my_access_token").empty().append(data.token); } } @@ -42,7 +42,7 @@ $(document).ready(function() { }); //modify application callback url - $(".modifier_callback").bind("click", function() { + $(".modifier_callback").bind("click", function () { var modifierBtn = $(this); var saveBtn = $("a.save_callback"); var input = $(".url_callback_input"); @@ -54,23 +54,23 @@ $(document).ready(function() { input .empty() .wrapInner('' - + '' ); $(".url_callback").die(); // save new callback - saveBtn.bind("click", function(e) { + saveBtn.bind("click", function (e) { e.preventDefault(); var callback = $("input[name=oauth_callback]").val(); $.ajax({ - type:"POST", - url : saveBtn.attr("href"), + type: "POST", + url: saveBtn.attr("href"), dataType: 'json', - data :{callback : callback}, - success : function(data) { - if(data.success) { + data: {callback: callback}, + success: function (data) { + if (data.success) { input.empty().append(callback); } else { input.empty().append(inputVal); @@ -81,8 +81,8 @@ $(document).ready(function() { }); // hide or show callback url input whether user choose a web or dektop application - $("#form_create input[name=type]").bind("click", function() { - if($(this).val() === "desktop") { + $("#form_create input[name=type]").bind("click", function () { + if ($(this).val() === "desktop") { $("#form_create .callback td").hide().find("input").val(''); } else { $("#form_create .callback td").show(); @@ -90,30 +90,31 @@ $(document).ready(function() { }); // authorize password grant type or not - $('.grant-type').bind('click', function(){ + $('.grant-type').bind('click', function () { var $this = $(this); $.ajax({ - type:"POST", - url : $this.attr("value") , + type: "POST", + url: $this.attr("value"), dataType: 'json', - data : {grant : $this.is(":checked") ? "1": "0"}, - success : function(data){} + data: {grant: $this.is(":checked") ? "1" : "0"}, + success: function (data) { + } }); }); // delete an application - $("a.delete-app").bind("click", function(e) { + $("a.delete-app").bind("click", function (e) { e.preventDefault(); var $this = $(this); var li = $this.closest("li"); $.ajax({ - type:"DELETE", - url : $this.attr('href'), + type: "DELETE", + url: $this.attr('href'), dataType: 'json', - data : {}, - success : function(data){ - if(data.success) { + data: {}, + success: function (data) { + if (data.success) { li.find('.modal').modal('hide'); li.remove(); } diff --git a/www/skins/admin/editusers.js b/www/skins/admin/editusers.js index 6748579e89..a444fca23e 100644 --- a/www/skins/admin/editusers.js +++ b/www/skins/admin/editusers.js @@ -1,66 +1,62 @@ -function ini_edit_usrs(){ - $('.users_col.options').bind('click', function(event){ +function ini_edit_usrs() { + $('.users_col.options').bind('click', function (event) { $('#users_check_uncheck').remove(); event.stopPropagation(); event.preventDefault(); - check_uncheck_menu($('input[name="right"]', $(this)).val(),$('input[name="sbas_id"]', $(this)).val(), $(this)); + check_uncheck_menu($('input[name="right"]', $(this)).val(), $('input[name="sbas_id"]', $(this)).val(), $(this)); return false; }); - $(document).unbind('click.usersoptions').bind('click.usersoptions', function(event){ + $(document).unbind('click.usersoptions').bind('click.usersoptions', function (event) { $('#users_check_uncheck').remove(); }); $('table.hoverable tr').hover( - function(){ + function () { $(this).addClass('hovered'); }, - function(){ + function () { $(this).removeClass('hovered'); } ); $('table.hoverable td').hover( - function(){ + function () { var attr = $('input:first', this).attr('name'); var right = attr ? attr.split('_').shift() : false; - if(right) - $('td.case_right_'+right).addClass('hovered'); + if (right) + $('td.case_right_' + right).addClass('hovered'); }, - function(){ + function () { var attr = $('input:first', this).attr('name'); var right = attr ? attr.split('_').shift() : false; - if(right) + if (right) $('td.hovered').removeClass('hovered'); } ); - function user_click_box(event, element, status) - { + function user_click_box(event, element, status) { var newclass, newvalue, boxes; var $element = $(element); - if($element.hasClass('right_access')) - { + if ($element.hasClass('right_access')) { 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'; newvalue = '1'; - if(boxes) + if (boxes) boxes.show(); } - else - { + else { newclass = 'unchecked'; newvalue = '0'; - if(boxes) + if (boxes) boxes.hide(); } @@ -68,23 +64,23 @@ function ini_edit_usrs(){ $element.removeClass('mixed checked unchecked').addClass(newclass); } - $('#users_rights_form div.switch_right').bind('click', function(event){ + $('#users_rights_form div.switch_right').bind('click', function (event) { user_click_box(event, $(this)); }); - $('#right-ajax button.users_rights_valid').bind('click', function(){ + $('#right-ajax button.users_rights_valid').bind('click', function () { var datas = { - users:$('#users_rights_form input[name="users"]').val(), - values:$('#users_rights_form').serialize(), - template:$('#users_rights_form select[name="template"]').val(), - user_infos:$('#user_infos_form').serialize() + users: $('#users_rights_form input[name="users"]').val(), + values: $('#users_rights_form').serialize(), + template: $('#users_rights_form select[name="template"]').val(), + user_infos: $('#user_infos_form').serialize() }; $.ajax({ type: 'POST', url: '../admin/users/rights/apply/', - dataType:'json', + dataType: 'json', data: datas, - success: function(data){ - if(!data.error) + success: function (data) { + if (!data.error) $('a.zone_editusers').trigger('click'); else alert(data.message); @@ -93,11 +89,11 @@ function ini_edit_usrs(){ return false; }); - $('#right-ajax .users_rights_cancel').bind('click', function(){ + $('#right-ajax .users_rights_cancel').bind('click', function () { var $this = $(this); $('#right-ajax').empty().addClass('loading').parent().show(); $('#right').hide(); - $.get($this.attr('href'), function(data) { + $.get($this.attr('href'), function (data) { $('#right-ajax').removeClass('loading').html(data); }); @@ -105,84 +101,82 @@ function ini_edit_usrs(){ }); var time_buttons = { - 'Ok':function(){ + 'Ok': function () { save_time(); }, - 'Cancel':function(){ + 'Cancel': function () { $('#time_dialog').dialog('close'); } }; $('#time_dialog').dialog({ - resizable:false, - autoOpen:false, - draggable:false, - buttons:time_buttons, - modal:true + resizable: false, + autoOpen: false, + draggable: false, + buttons: time_buttons, + modal: true }); var quota_buttons = { - 'Ok':function(){ + 'Ok': function () { save_quotas(); }, - 'Cancel':function(){ + 'Cancel': function () { $('#quotas_dialog').dialog('close'); } }; $('#quotas_dialog').dialog({ - resizable:false, - autoOpen:false, - draggable:false, - buttons:quota_buttons, - modal:true + resizable: false, + autoOpen: false, + draggable: false, + buttons: quota_buttons, + modal: true }); var masks_buttons = { - 'Ok':function(){ + 'Ok': function () { save_masks(); }, - 'Cancel':function(){ + 'Cancel': function () { $('#masks_dialog').dialog('close'); } }; $('#masks_dialog').dialog({ - resizable:false, - autoOpen:false, - draggable:false, - buttons:masks_buttons, - width:900, - height:300, - modal:true + resizable: false, + autoOpen: false, + draggable: false, + buttons: masks_buttons, + width: 900, + height: 300, + modal: true }); - $('#users_rights_form .time_trigger').bind('click', function(){ + $('#users_rights_form .time_trigger').bind('click', function () { var base_id = $(this).find('input[name="time_base_id"]').val(); if ('undefined' !== typeof base_id) { $.ajax({ type: 'POST', url: '../admin/users/rights/time/', data: { - users:$('#users_rights_form input[name="users"]').val(), - base_id:base_id + users: $('#users_rights_form input[name="users"]').val(), + base_id: base_id }, - success: function(data){ + success: function (data) { var dialog = $('#time_dialog'); if (dialog.data("ui-dialog")) { dialog.html(data).dialog('open'); } - $('div.switch_time', dialog).bind('click', function(event){ + $('div.switch_time', dialog).bind('click', function (event) { var newclass, boxes; boxes = $(this).closest('form').find('input.datepicker'); - if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) - { + if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) { newclass = 'checked'; boxes.removeAttr('readonly'); } - else - { + else { newclass = 'unchecked'; - boxes.attr('readonly','readonly'); + boxes.attr('readonly', 'readonly'); } $(this).removeClass('mixed checked unchecked').addClass(newclass); @@ -196,29 +190,27 @@ function ini_edit_usrs(){ type: 'POST', url: '../admin/users/rights/time/sbas/', data: { - users:$('#users_rights_form input[name="users"]').val(), - sbas_id:sbas_id + users: $('#users_rights_form input[name="users"]').val(), + sbas_id: sbas_id }, - success: function(data){ + success: function (data) { var dialog = $('#time_dialog'); dialog.html(data); dialog.dialog('open'); - $('div.switch_time', dialog).bind('click', function(event){ + $('div.switch_time', dialog).bind('click', function (event) { var newclass, boxes; boxes = $(this).closest('form').find('input.datepicker'); - if(($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) - { + if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) { newclass = 'checked'; boxes.removeAttr('readonly'); } - else - { + else { newclass = 'unchecked'; - boxes.attr('readonly','readonly'); + boxes.attr('readonly', 'readonly'); } $(this).removeClass('mixed checked unchecked').addClass(newclass); @@ -227,36 +219,34 @@ function ini_edit_usrs(){ }); } }); - $('#users_rights_form .quota_trigger').bind('click', function(){ + $('#users_rights_form .quota_trigger').bind('click', function () { var base_id = $(this).find('input[name="quota_base_id"]').val(); $.ajax({ type: 'POST', url: '../admin/users/rights/quotas/', data: { - users:$('#users_rights_form input[name="users"]').val(), - base_id:base_id + users: $('#users_rights_form input[name="users"]').val(), + base_id: base_id }, - success: function(data){ + success: function (data) { var dialog = $('#quotas_dialog'); if (dialog.data("ui-dialog")) { dialog.html(data).dialog('open'); } - $('div.switch_quota', dialog).bind('click', function(event){ + $('div.switch_quota', dialog).bind('click', function (event) { var newclass, boxes; boxes = $(this).closest('form').find('input:text'); - if(($(this).hasClass('mixed')===true) || ($(this).hasClass('unchecked') === true)) - { + if (($(this).hasClass('mixed') === true) || ($(this).hasClass('unchecked') === true)) { newclass = 'checked'; boxes.removeAttr('readonly'); } - else - { + else { newclass = 'unchecked'; - boxes.attr('readonly','readonly'); + boxes.attr('readonly', 'readonly'); } $(this).removeClass('mixed checked unchecked').addClass(newclass); @@ -265,82 +255,74 @@ function ini_edit_usrs(){ }); }); - $('#users_rights_form .masks_trigger').bind('click', function(){ + $('#users_rights_form .masks_trigger').bind('click', function () { var base_id = $(this).find('input[name="masks_base_id"]').val(); $.ajax({ type: 'POST', url: '../admin/users/rights/masks/', data: { - users:$('#users_rights_form input[name="users"]').val(), - base_id:base_id + users: $('#users_rights_form input[name="users"]').val(), + base_id: base_id }, - success: function(data){ + success: function (data) { $('#masks_dialog').html(data).dialog('open'); - $('.switch_masks').bind('click', function(){ + $('.switch_masks').bind('click', function () { var currentclass, newclass; var bit = $(this).find('input[name="bit"]').val(); currentclass = 'unchecked'; - if($(this).hasClass('mixed')) - { + if ($(this).hasClass('mixed')) { currentclass = 'mixed'; } - if($(this).hasClass('checked')) - { + if ($(this).hasClass('checked')) { currentclass = 'checked'; } - switch(currentclass) - { + switch (currentclass) { case 'mixed': default: - $('.bitnum_'+bit).removeClass('mixed checked unchecked').addClass('checked') + $('.bitnum_' + bit).removeClass('mixed checked unchecked').addClass('checked') break; case 'unchecked': $(this).removeClass('mixed checked unchecked').addClass('checked') break; case 'checked': - if($('.checked.bitnum_'+bit).length == 2) - { + if ($('.checked.bitnum_' + bit).length == 2) { $(this).removeClass('mixed checked unchecked').addClass('unchecked') } - else - { + else { alert("admin::user:mask: vous devez cocher au moins une case pour chaque status"); return; } break; } - var left = $('.bitnum_'+bit+'.bit_left'); - var right = $('.bitnum_'+bit+'.bit_right'); + var left = $('.bitnum_' + bit + '.bit_left'); + var right = $('.bitnum_' + bit + '.bit_right'); var maskform = $('#masks_dialog form'); var vand_and = $('input[name="vand_and"]', maskform); - var vand_or = $('input[name="vand_or"]', maskform); + var vand_or = $('input[name="vand_or"]', maskform); var vxor_and = $('input[name="vxor_and"]', maskform); - var vxor_or = $('input[name="vxor_or"]', maskform); + var vxor_or = $('input[name="vxor_or"]', maskform); var newbit_vand_and = newbit_vand_or = newbit_vxor_and = newbit_vxor_or = 0; - if( left.length === 1 && right.length === 1 ) - { - if(left.hasClass('checked') && right.hasClass('unchecked') ) - { + if (left.length === 1 && right.length === 1) { + if (left.hasClass('checked') && right.hasClass('unchecked')) { 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_or = "1"; + newbit_vand_or = "1"; newbit_vxor_and = "1"; - newbit_vxor_or = "1"; + newbit_vxor_or = "1"; } - vand_and.val( vand_and.val().substr(0, 31 - bit) + newbit_vand_and + vand_and.val().substr(31 + 1 - bit) ); - vand_or.val ( vand_or.val().substr( 0, 31 - bit) + newbit_vand_or + vand_or.val().substr( 31 + 1 - bit) ); - vxor_and.val( vxor_and.val().substr(0, 31 - bit) + newbit_vxor_and + vxor_and.val().substr(31 + 1 - bit) ); - vxor_or.val ( vxor_or.val().substr( 0, 31 - bit) + newbit_vxor_or + vxor_and.val().substr(31 + 1 - bit) ); + vand_and.val(vand_and.val().substr(0, 31 - bit) + newbit_vand_and + vand_and.val().substr(31 + 1 - bit)); + vand_or.val(vand_or.val().substr(0, 31 - bit) + newbit_vand_or + vand_or.val().substr(31 + 1 - bit)); + vxor_and.val(vxor_and.val().substr(0, 31 - bit) + newbit_vxor_and + vxor_and.val().substr(31 + 1 - bit)); + vxor_or.val(vxor_or.val().substr(0, 31 - bit) + newbit_vxor_or + vxor_and.val().substr(31 + 1 - bit)); } }); } @@ -348,39 +330,37 @@ function ini_edit_usrs(){ }); - function save_masks() - { + function save_masks() { var cont = $('#masks_dialog'); var maskform = $('#masks_dialog form'); - var base_id = $('input[name="base_id"]', maskform).val(); - var users = $('input[name="users"]', maskform).val(); + var base_id = $('input[name="base_id"]', maskform).val(); + var users = $('input[name="users"]', maskform).val(); var vand_and = $('input[name="vand_and"]', maskform).val(); - var vand_or = $('input[name="vand_or"]', maskform).val(); + var vand_or = $('input[name="vand_or"]', maskform).val(); var vxor_and = $('input[name="vxor_and"]', maskform).val(); - var vxor_or = $('input[name="vxor_or"]', maskform).val(); + var vxor_or = $('input[name="vxor_or"]', maskform).val(); $.ajax({ type: 'POST', url: '../admin/users/rights/masks/apply/', data: { - users:users, - base_id:base_id, - vand_and:vand_and, - vand_or:vand_or, - vxor_and:vxor_and, - vxor_or:vxor_or + users: users, + base_id: base_id, + vand_and: vand_and, + vand_or: vand_or, + vxor_and: vxor_and, + vxor_or: vxor_or }, - success: function(data){ + success: function (data) { $('#masks_dialog').dialog('close'); } }); } - function save_quotas() - { + function save_quotas() { var cont = $('#quotas_dialog'); var base_id = $('input[name="base_id"]', cont).val(); var users = $('input[name="users"]', cont).val(); @@ -389,33 +369,32 @@ function ini_edit_usrs(){ var switch_quota = $('.switch_quota', cont); - if(switch_quota.hasClass('mixed')) + if (switch_quota.hasClass('mixed')) return; var quota = 0; - if(switch_quota.hasClass('checked')) + if (switch_quota.hasClass('checked')) quota = 1; $.ajax({ type: 'POST', url: '../admin/users/rights/quotas/apply/', data: { - act:"APPLYQUOTAS", - users:users, - base_id:base_id, - quota:quota, - droits:droits, - restes:restes + act: "APPLYQUOTAS", + users: users, + base_id: base_id, + quota: quota, + droits: droits, + restes: restes }, - success: function(data){ + success: function (data) { $('#quotas_dialog').dialog('close'); } }); } - function save_time() - { + function save_time() { var cont = $('#time_dialog'); var dmin = $('input[name="dmin"]', cont).val(); var dmax = $('input[name="dmax"]', cont).val(); @@ -425,83 +404,79 @@ function ini_edit_usrs(){ var switch_time = $('.switch_time', cont); - if(switch_time.hasClass('mixed')) + if (switch_time.hasClass('mixed')) return; var limit = 0; - if(switch_time.hasClass('checked')) + if (switch_time.hasClass('checked')) limit = 1; $.ajax({ type: 'POST', url: '../admin/users/rights/time/apply/', data: { - users:users, - base_id:base_id, - sbas_id:sbas_id, - limit:limit, - dmin:dmin, - dmax:dmax + users: users, + base_id: base_id, + sbas_id: sbas_id, + limit: limit, + dmin: dmin, + dmax: dmax }, - success: function(data){ + success: function (data) { $('#time_dialog').dialog('close'); } }); } - function check_uncheck_menu(right, sbas_id, el) - { - var top = el.offset().top ; + function check_uncheck_menu(right, sbas_id, el) { + var top = el.offset().top; var left = el.offset().left + 16; - $('body').append('
'+ - '
'+ - language.check_all+ - ''+ - ''+ - '
'+ - '
'+ - language.uncheck_all+ - ''+ - ''+ + $('body').append('
' + + '
' + + language.check_all + + '' + + '' + + '
' + + '
' + + language.uncheck_all + + '' + + '' + '
'); $('#users_check_uncheck div').hover( - function(){ + function () { $(this).addClass('hovered'); }, - function(){ + function () { $(this).removeClass('hovered'); } ); - $('#users_check_uncheck div.checker').bind('click',function(event){ + $('#users_check_uncheck div.checker').bind('click', function (event) { event.stopPropagation(); event.preventDefault(); - users_check(true, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val()); + users_check(true, $('input[name="sbas_id"]', $(this)).val(), $('input[name="right"]', $(this)).val()); $('#users_check_uncheck').remove(); }); - $('#users_check_uncheck div.unchecker').bind('click',function(event){ + $('#users_check_uncheck div.unchecker').bind('click', function (event) { event.stopPropagation(); event.preventDefault(); - users_check(false, $('input[name="sbas_id"]',$(this)).val(), $('input[name="right"]',$(this)).val()); + users_check(false, $('input[name="sbas_id"]', $(this)).val(), $('input[name="right"]', $(this)).val()); $('#users_check_uncheck').remove(); }); } - function users_check(bool, sbas_id, right) - { + + function users_check(bool, sbas_id, right) { var newclass; - if(bool) - { - newclass="checked"; + if (bool) { + newclass = "checked"; } - else - { - newclass="unchecked"; + else { + newclass = "unchecked"; } - $('.inside_sbas_'+sbas_id+'.'+right+':visible').each(function(i,n){ + $('.inside_sbas_' + sbas_id + '.' + right + ':visible').each(function (i, n) { user_click_box(null, $(n), newclass); }); } } - diff --git a/www/skins/admin/users.js b/www/skins/admin/users.js index fe6fdc98f2..6c944af51d 100644 --- a/www/skins/admin/users.js +++ b/www/skins/admin/users.js @@ -4,13 +4,11 @@ */ -$(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); return false; } @@ -19,19 +17,17 @@ $(document).ready(function(){ return true; } - $('#users th.sortable').live('click', function(){ + $('#users th.sortable').live('click',function () { var $this = $(this); var sort = $('input', $this).val(); - if((sort == $('#users_page_form input[name="srt"]').val()) - && ($('#users_page_form input[name="ord"]').val() == 'asc')) - { + if ((sort == $('#users_page_form input[name="srt"]').val()) + && ($('#users_page_form input[name="ord"]').val() == 'asc')) { var ord = 'desc'; } - else - { + else { var ord = 'asc'; } @@ -39,63 +35,65 @@ $(document).ready(function(){ $('#users_page_form input[name="ord"]').val(ord); $('#users_page_form').trigger('submit'); - }).live('mouseover', function(){$(this).addClass('hover');}) - .live('mouseout', function(){$(this).removeClass('hover');}); + }).live('mouseover', function () { + $(this).addClass('hover'); + }) + .live('mouseout', function () { + $(this).removeClass('hover'); + }); var buttons = {}; - buttons[language.create_user] = function(){ + buttons[language.create_user] = function () { check_new_user(false); }; - buttons[language.annuler] = function(){ + buttons[language.annuler] = function () { $('#user_add_dialog').dialog('close') }; $('#user_add_dialog').dialog({ - buttons:buttons, - modal:true, - resizable:false, - draggable:false, - width:500 + buttons: buttons, + modal: true, + resizable: false, + draggable: false, + width: 500 }).dialog('close'); var buttons = {}; - buttons[language.create_template] = function(){ + buttons[language.create_template] = function () { check_new_user(true); }; - buttons[language.annuler] = function(){ + buttons[language.annuler] = function () { $('#template_add_dialog').dialog('close'); }; $('#template_add_dialog').dialog({ - buttons:buttons, - modal:true, - resizable:false, - draggable:false, - width:500 + buttons: buttons, + modal: true, + resizable: false, + draggable: false, + width: 500 }).dialog('close'); - function check_new_user(is_template) - { + function check_new_user(is_template) { var container = is_template ? $('#template_add_dialog') : $('#user_add_dialog'); $('#new_user_loader').show(); $.ajax({ type: 'POST', url: '../admin/users/create/', - dataType : 'json', + dataType: 'json', data: { - act:'CREATENEWUSER', - value:$('input[name="value"]', container).val(), + act: 'CREATENEWUSER', + value: $('input[name="value"]', container).val(), send_credentials: $('input[name="send_credentials"]', container).is(':checked') ? 1 : 0, validate_mail: $('input[name="validate_mail"]', container).is(':checked') ? 1 : 0, - template:is_template ? '1':'0' + template: is_template ? '1' : '0' }, - success: function(data){ + success: function (data) { $('.new_user_loader', container).hide(); - if(!data.error) - { + if (!data.error) { if (container.data("ui-dialog")) { container.dialog('close'); } @@ -106,51 +104,48 @@ $(document).ready(function(){ type: 'POST', url: '../admin/users/rights/', data: { - users : data.data + users: data.data }, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').html(data); } }); } - else - { + else { alert(data.message); } }, - error:function() - { + error: function () { alert(language.serverError); }, - timeout:function() - { + timeout: function () { alert(language.serverTimeout); } }); } - $('#users_page .user_adder').live('click', function(){ + $('#users_page .user_adder').live('click', function () { if ($('#user_add_dialog').data("ui-dialog")) { $('#user_add_dialog').dialog('open'); } }); - $('#users_page .template_adder').live('click', function(){ + $('#users_page .template_adder').live('click', function () { if ($('#template_add_dialog').data("ui-dialog")) { $('#template_add_dialog').dialog('open'); } }); - $('#users_page_form').live('submit', function(){ + $('#users_page_form').live('submit', function () { var datas = $('#users_page_form').serializeArray(); $('#right-ajax').empty().addClass('loading'); $.ajax({ type: 'POST', url: '../admin/users/search/', data: datas, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').empty().html(data); } }); @@ -158,14 +153,14 @@ $(document).ready(function(){ return false; }); - $('#users_page_search').live('submit', function(){ + $('#users_page_search').live('submit', function () { var datas = $('#users_page_search').serializeArray(); $('#right-ajax').empty().addClass('loading'); $.ajax({ type: 'POST', url: '../admin/users/search/', data: datas, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').empty().html(data); } }); @@ -173,7 +168,7 @@ $(document).ready(function(){ return false; }); - $('#users_page_form .pager').live('click', function(){ + $('#users_page_form .pager').live('click', function () { var form = $('#users_page_form'); var current_page = parseInt($('input[name="page"]', form).val()); @@ -182,32 +177,28 @@ $(document).ready(function(){ var offset_start = 0; - if($(this).hasClass('prev')) - { - offset_start = (current_page-2) * perPage; + if ($(this).hasClass('prev')) { + offset_start = (current_page - 2) * perPage; } - if($(this).hasClass('first')) - { + if ($(this).hasClass('first')) { offset_start = 0; } - if($(this).hasClass('next')) - { + if ($(this).hasClass('next')) { offset_start = current_page * perPage; } - if($(this).hasClass('last')) - { - offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage))* perPage; + if ($(this).hasClass('last')) { + offset_start = (Math.floor(parseInt($('input[name=total_results]').val()) / perPage)) * perPage; } $('input[name="offset_start"]', form).val(offset_start); }); - $('#users tbody tr, #users tbody td').live('dblclick', function(evt){ + $('#users tbody tr, #users tbody td').live('dblclick', function (evt) { $('#users_page_form .user_modifier').trigger('click'); }); - $('#users tbody tr, #users tbody td').live('click', function(evt){ - if(evt.stopPropagation) + $('#users tbody tr, #users tbody td').live('click',function (evt) { + if (evt.stopPropagation) evt.stopPropagation(); evt.cancelBubble = true; evt.preventDefault(); @@ -216,29 +207,24 @@ $(document).ready(function(){ 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 index1 = $.inArray($('tr.last_selected', cont)[0],lst); - var index2 = $.inArray($(el)[0],lst); - if(index2=0) - { - p4.users.sel = $.grep(p4.users.sel,function(n){ - return(n!=k); + else { + if ($.inArray(k, p4.users.sel) >= 0) { + p4.users.sel = $.grep(p4.users.sel, function (n) { + return(n != k); }); $(el).removeClass('selected'); } - else - { - if(!users_select_this(el,k)) + else { + if (!users_select_this(el, k)) return false; } } } $('.last_selected', cont).removeClass('last_selected'); $(el).addClass('last_selected'); - }).live('mousedown', function(evt){ + }).live('mousedown', function (evt) { - if(evt.stopPropagation) + if (evt.stopPropagation) evt.stopPropagation(); evt.cancelBubble = true; evt.preventDefault(); }); - $('#users_apply_template').live('submit', function(){ + $('#users_apply_template').live('submit', function () { var users = p4.users.sel.join(';'); - if(users === '') - { + if (users === '') { return false; } var $this = $(this); var template = $('select[name="template_chooser"]', $this).val(); - if(template === '') - { + if (template === '') { return false; } @@ -313,20 +290,19 @@ $(document).ready(function(){ type: $this.attr('method'), url: $this.attr('action'), data: { - users : users, - template : template + users: users, + template: template }, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').html(data); } }); return false; }); - $('#users_page_form .user_modifier').live('click', function(){ + $('#users_page_form .user_modifier').live('click', function () { var users = p4.users.sel.join(';'); - if(users === '') - { + if (users === '') { return false; } @@ -336,9 +312,9 @@ $(document).ready(function(){ type: 'POST', url: '../admin/users/rights/', data: { - users : users + users: users }, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').html(data); } }); @@ -346,10 +322,9 @@ $(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(';'); - if(users === '') - { + if (users === '') { return false; } @@ -359,19 +334,18 @@ $(document).ready(function(){ type: 'POST', url: '../admin/users/delete/', data: { - users : users + users: users }, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').html(data); } }); return false; }); - $('#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(); - if($.trim(users) === '') - { + if ($.trim(users) === '') { return false; } @@ -381,9 +355,9 @@ $(document).ready(function(){ type: 'POST', url: '../admin/users/rights/', data: { - users : users + users: users }, - success: function(data){ + success: function (data) { $('#right-ajax').removeClass('loading').html(data); } }); diff --git a/www/skins/client/jquery.p4client.1.0.js b/www/skins/client/jquery.p4client.1.0.js index cc3a04f56f..5a9b895078 100644 --- a/www/skins/client/jquery.p4client.1.0.js +++ b/www/skins/client/jquery.p4client.1.0.js @@ -3,41 +3,38 @@ **************/ var p4 = $.extend(p4 || {}, { - tot:0, - preview :{open:false,current:false}, - currentViewMode:'classic', - nbNoview:0 + tot: 0, + preview: {open: false, current: false}, + currentViewMode: 'classic', + nbNoview: 0 }); -var baskAjax,baskAjaxrunning; +var baskAjax, baskAjaxrunning; baskAjaxrunning = false; -var answAjax,answAjaxrunning; +var answAjax, answAjaxrunning; answAjaxrunning = false; var wCompare = null; var language = {}; -var bodySize = {x:0,y:0}; +var bodySize = {x: 0, y: 0}; /************* * INITIALISATION **************/ -function acceptCgus(name,value) -{ - setPref(name,value); +function acceptCgus(name, value) { + setPref(name, value); } -function cancelCgus(id) -{ +function cancelCgus(id) { $.ajax({ type: "POST", - url: "/prod/TOU/deny/"+id+"/", + url: "/prod/TOU/deny/" + id + "/", data: {}, - success: function(data){ - if(data == '1') - { + success: function (data) { + if (data == '1') { alert(language.cgusRelog); self.location.replace(self.location.href); } @@ -46,73 +43,71 @@ function cancelCgus(id) } -function activateCgus() -{ +function activateCgus() { $('.cgu-dialog:first').dialog({ - autoOpen : true, - closeOnEscape:false, - draggable:false, - modal:true, - resizable:false, - width:800, - height:600, - open:function() { + autoOpen: true, + closeOnEscape: false, + draggable: false, + modal: true, + resizable: false, + width: 800, + height: 600, + open: function () { $(this).parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").remove(); var currentdialog = $(this); - $('.cgus-accept',$(this)).bind('click',function(){ - acceptCgus($('.cgus-accept',currentdialog).attr('id'),$('.cgus-accept',currentdialog).attr('date')); + $('.cgus-accept', $(this)).bind('click', function () { + acceptCgus($('.cgus-accept', currentdialog).attr('id'), $('.cgus-accept', currentdialog).attr('date')); if ($('.cgu-dialog').data("ui-dialog")) { $('.cgu-dialog').dialog('close'); } }); - $('.cgus-cancel',$(this)).bind('click',function(){ - if(confirm(language.warningDenyCgus)) - { - cancelCgus($('.cgus-cancel',currentdialog).attr('id').split('_').pop()); + $('.cgus-cancel', $(this)).bind('click', function () { + if (confirm(language.warningDenyCgus)) { + cancelCgus($('.cgus-cancel', currentdialog).attr('id').split('_').pop()); } }); }, - close:function(){ + close: function () { activateCgus(); } }); } -$(document).ready(function(){ +$(document).ready(function () { activateCgus(); }); -$(document).ready(function(){ +$(document).ready(function () { $.ajaxSetup({ - error: function(){ - showModal('error',{title:'Server error'}); + error: function () { + showModal('error', {title: 'Server error'}); }, - timeout: function(){ - showModal('timeout',{title:'Server not responding'}); + timeout: function () { + showModal('timeout', {title: 'Server not responding'}); } }); getLanguage(); $('.datepicker').datepicker({ firstDay: 1, - changeYear: true, changeMonth:true, - showOn: 'button', buttonImage:'/skins/icons/cal.png', buttonImageOnly: true + changeYear: true, changeMonth: true, + showOn: 'button', buttonImage: '/skins/icons/cal.png', buttonImageOnly: true }); checkFilters(); window.setTimeout("checkBaskets();", 5000); - $('.actives').hover(function(){ + $('.actives').hover(function () { $(this).addClass("hover"); - },function(){ + }, function () { $(this).removeClass("hover"); }); sessionactive(); resize(); - $(window).resize(function(){ + $(window).resize(function () { resize(); resizeSearch(); }); @@ -120,7 +115,7 @@ $(document).ready(function(){ initAnswerForm(); initBasketForm(); - $('#PREVIEWHD').bind('click',function(){ + $('#PREVIEWHD').bind('click', function () { $(this).hide(); $(this).empty(); }); @@ -130,12 +125,9 @@ $(document).ready(function(){ getBaskets(); afterSearch(); - $(this).bind('keydown',function(event) - { - if(p4.preview.open) - { - switch(event.keyCode) - { + $(this).bind('keydown', function (event) { + if (p4.preview.open) { + switch (event.keyCode) { case 39: getNext(); break; @@ -151,17 +143,15 @@ $(document).ready(function(){ } break; case 32: - if(p4.slideShow) + if (p4.slideShow) stopSlide(); else startSlide(); break; } } - else - { - switch(event.keyCode) - { + else { + switch (event.keyCode) { case 39: $('#NEXT_PAGE').trigger('click'); break; @@ -172,31 +162,31 @@ $(document).ready(function(){ $('#PREV_PAGE').trigger('click'); break; case 38: - $('#answers').scrollTop($('#answers').scrollTop()-50); + $('#answers').scrollTop($('#answers').scrollTop() - 50); break; case 40: - $('#answers').scrollTop($('#answers').scrollTop()+50); + $('#answers').scrollTop($('#answers').scrollTop() + 50); break; } } }); - $('.boxPubli .diapo').css('width','').addClass('w160px').css('margin','0pt 0px 8px 8px'); + $('.boxPubli .diapo').css('width', '').addClass('w160px').css('margin', '0pt 0px 8px 8px'); } ); -function resizePreview(){ - $('#PREVIEWCURRENTCONT').width($('#PREVIEWCURRENT').width() - 80 - ($('#PREVMAINREG').length>0?$('#PREVMAINREG').width():0) - 90); +function resizePreview() { + $('#PREVIEWCURRENTCONT').width($('#PREVIEWCURRENT').width() - 80 - ($('#PREVMAINREG').length > 0 ? $('#PREVMAINREG').width() : 0) - 90); var h = $('#PREVIEWBOX').height(); h = h - $('#PREVIEWTITLE').height(); - $.each($('div.preview_col'), function(i, n){ + $.each($('div.preview_col'), function (i, n) { $(n).height(h); }); $('#PREVIEWIMGCONT').height(h - $('#PREVIEWCURRENT').height()); - $('#PREVIEWIMGDESC').height(h-$('#PREVIEWOTHERS').height()); + $('#PREVIEWIMGDESC').height(h - $('#PREVIEWOTHERS').height()); $('#PREVIEWIMGDESC .descBoxes').height($('#PREVIEWIMGDESC').height() - 30); p4.preview.height = $('#PREVIEWIMGCONT').height(); @@ -204,24 +194,22 @@ function resizePreview(){ setPreview(); } -function controlPubliSize() -{ +function controlPubliSize() { $('#publications ul').height('auto'); - if(50+$('#publications ul').height()>bodySize.y) - $('#publications ul').height(bodySize.y-50); + if (50 + $('#publications ul').height() > bodySize.y) + $('#publications ul').height(bodySize.y - 50); } -function pquit(){ +function pquit() { if (parent.opener) self.close(); - else - { + else { document.forms['logout'].submit(); } } -function resize(){ +function resize() { var h = bodySize.y = $(document).height() - $('#mainMenu').outerHeight(); var w = bodySize.x = $(document).width(); @@ -253,17 +241,16 @@ function resize(){ } bodyW = rightw; - if($('#MODALDL').is(':visible')) - { + if ($('#MODALDL').is(':visible')) { $('#MODALDL').css({ - top:((h-$('#MODALDL').height())/2), - left:((w-$('#MODALDL').width())/2) + top: ((h - $('#MODALDL').height()) / 2), + left: ((w - $('#MODALDL').width()) / 2) }); } reModCol(); } -function getHome(cas){ +function getHome(cas) { switch (cas) { case 'QUERY': newSearch(); @@ -276,23 +263,23 @@ function getHome(cas){ data: { type: cas }, - beforeSend: function(){ + beforeSend: function () { clearAnswers(); answAjaxrunning = true; $('#answers').addClass('loading'); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(data){ + success: function (data) { $('#answers').append(data); afterSearch(); - $('.boxPubli .diapo').css('width','').addClass('w160px').css('margin','0pt 0px 8px 8px'); + $('.boxPubli .diapo').css('width', '').addClass('w160px').css('margin', '0pt 0px 8px 8px'); } }); case 'HELP': @@ -303,20 +290,20 @@ function getHome(cas){ data: { type: cas }, - beforeSend: function(){ + beforeSend: function () { clearAnswers(); answAjaxrunning = true; $('#answers').addClass('loading'); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(data){ + success: function (data) { $('#answers').append(data); afterSearch(); } @@ -328,46 +315,45 @@ function getHome(cas){ } -function changeModCol(){ +function changeModCol() { reModCol(); doSearch(); } -function getLanguage(){ +function getLanguage() { $.ajax({ type: "GET", url: "/client/language/", dataType: 'json', data: {}, - success: function(data){ + success: function (data) { language = data; return false; } }); } -function initBasketForm(){ +function initBasketForm() { var options = { target: '#baskets', - beforeSend: function(){ + beforeSend: function () { if (baskAjaxrunning) baskAjax.abort(); baskAjaxrunning = true; $('.baskIndicator').addClass('baskLoading'); }, - error: function(){ + error: function () { baskAjaxrunning = false; $('#baskets').removeClass('loading'); $('.baskIndicator').removeClass('baskLoading'); }, - timeout: function(){ + timeout: function () { baskAjaxrunning = false; $('#baskets').removeClass('loading'); $('.baskIndicator').removeClass('baskLoading'); }, - success: function(data){ + success: function (data) { baskAjaxrunning = false; - if(p4.preview.open && $.browser.msie && $.browser.version == '6.0') - { + if (p4.preview.open && $.browser.msie && $.browser.version == '6.0') { $('select').css({ visibility: 'hidden' }); @@ -378,28 +364,28 @@ function initBasketForm(){ $('.baskIndicator').removeClass('baskLoading'); $('#blocBask img.baskTips').tooltip(); - $("#flechenochu").bind('click', function(){ + $("#flechenochu").bind('click', function () { baskDisplay = false; saveBaskStatus(false); $("#blocBask").slideToggle("slow"); - $("#blocNoBask").slideToggle("slow").queue(function(){ + $("#blocNoBask").slideToggle("slow").queue(function () { $('#baskets').height($('#blocNoBask').height() + 6); resizeSearch(); $(this).dequeue(); }); }); - $("#flechechu").bind('click', function(){ + $("#flechechu").bind('click', function () { baskDisplay = true; saveBaskStatus(true); $("#blocNoBask").slideToggle("slow"); - $("#blocBask").slideToggle("slow").queue(function(){ + $("#blocBask").slideToggle("slow").queue(function () { $('#baskets').height($('#blocBask').height() + 6); resizeSearch(); $(this).dequeue(); }); }); - if($('#chutier_name').length > 0) { + if ($('#chutier_name').length > 0) { $('#formChuBaskId')[0].value = $('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value; } $('#formChubas')[0].value = $('#formChup0')[0].value = ''; @@ -410,7 +396,7 @@ function initBasketForm(){ baskAjax = $('#formChu').ajaxForm(options); } -function setBaskStatus(){ +function setBaskStatus() { if (baskDisplay) { $("#blocNoBask").hide(); $("#blocBask").show(); @@ -427,17 +413,17 @@ function setBaskStatus(){ function saveBaskStatus(val) { $.post("/user/preferences/", { prop: "client_basket_status", - value: (val?'1':'0') - }, function(data){ + value: (val ? '1' : '0') + }, function (data) { return false; }); } -function checkBaskets(){ - $.post("/client/baskets/check/", {}, function(data){ - if(data.success) { - if(parseInt(data.no_view) > p4.nbNoview){ +function checkBaskets() { + $.post("/client/baskets/check/", {}, function (data) { + if (data.success) { + if (parseInt(data.no_view) > p4.nbNoview) { getBaskets(); } window.setTimeout("checkBaskets();", 52000); @@ -446,10 +432,10 @@ function checkBaskets(){ }); } -function initAnswerForm(){ +function initAnswerForm() { var options = { target: '#answers', - beforeSend: function(formData){ + beforeSend: function (formData) { clearAnswers(); if (answAjaxrunning) return; @@ -459,15 +445,15 @@ function initAnswerForm(){ }); $('#answers').addClass('loading'); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(){ + success: function () { answAjaxrunning = false; afterSearch(); return false; @@ -479,27 +465,26 @@ function initAnswerForm(){ * SEARCH **************/ -function afterSearch() -{ +function afterSearch() { $('#answers').removeClass('loading'); $("#answers").scrollTop(0); - $('div.infoTips, div.previewTips,img.captionTips',$('#answers')).tooltip(); + $('div.infoTips, div.previewTips,img.captionTips', $('#answers')).tooltip(); $('#nb_answers a.infoTips').tooltip(); } -function chkSbas(val,el){ +function chkSbas(val, el) { var bool = false; - if($(el)[0].checked) + if ($(el)[0].checked) bool = true; - $('.basItem' + val).each(function(){ + $('.basItem' + val).each(function () { $(this)[0].checked = bool; }); } -function chgOngSearch(tab){ +function chgOngSearch(tab) { tTabs = new Array("ongSearch", "ongAdvSearch", "ongTopic"); - if($('#'+tab).length == 0) + if ($('#' + tab).length == 0) return; for (i = 0; i <= tTabs.length; i++) { if ((o = $('#' + tTabs[i]))) @@ -512,7 +497,7 @@ function chgOngSearch(tab){ o.style.display = (tTabs[i] == tab) ? "" : "none"; } } - $('#idongAdvSearch :text').each(function(){ + $('#idongAdvSearch :text').each(function () { this.value = ""; }); if (tab == "ongAdvSearch") { @@ -522,18 +507,18 @@ function chgOngSearch(tab){ resizeSearch(); } -function doSpecialSearch(qry, allbase){ +function doSpecialSearch(qry, allbase) { // if($('#ongSearch').length>0) // chgOngSearch('ongSearch'); // else // if($('#ongAdvSearch').length>0) // chgOngSearch('ongAdvSearch'); if (allbase) { - $('input.basItem').each(function(){ + $('input.basItem').each(function () { this.checked = true; }); var first = true; - $('#basSelector option').each(function(){ + $('#basSelector option').each(function () { this.selected = first; first = false; }); @@ -542,24 +527,22 @@ function doSpecialSearch(qry, allbase){ doSearch(); } -function clearAnswers(){ +function clearAnswers() { $('#formAnswerPage')[0].value = ''; $("#nb_answers").empty(); $("#navigation").empty(); $("#answers").empty(); } -function newSearch() -{ +function newSearch() { $('#searchForm').submit(); } -function doSearch() -{ +function doSearch() { $('#searchForm').submit(); } -function chgOng(num){ +function chgOng(num) { for (i = 1; i <= 5; i++) { if ((o = document.getElementById("idOnglet" + i))) o.className = (i == num) ? "actif" : "inactif"; @@ -569,36 +552,35 @@ function chgOng(num){ return; } -function checkBases(etat){ - $('.basItem, .basChecker').each(function(){ +function checkBases(etat) { + $('.basItem, .basChecker').each(function () { this.checked = etat; }); } -function resizeSearch(){ +function resizeSearch() { - var searchh = (bodySize.y-$('#baskets').height()); - searchh = ((searchh)>0)?searchh:0; + var searchh = (bodySize.y - $('#baskets').height()); + searchh = ((searchh) > 0) ? searchh : 0; var menu = $('#bigTabsBckg').height(); $('#search').height(searchh); - $('#idongTopic').height($("#search").height()-8-menu); - $('#searchMiddle').height($("#search").height()-8-menu-$('#mainSearch').height()); + $('#idongTopic').height($("#search").height() - 8 - menu); + $('#searchMiddle').height($("#search").height() - 8 - menu - $('#mainSearch').height()); } /************* * Topics **************/ -function doThesSearch(type,sbid,term,field) -{ +function doThesSearch(type, sbid, term, field) { - if(type=='T') + if (type == 'T') v = '*:"' + term.replace("(", "[").replace(")", "]") + '"'; else v = '"' + term + '" IN ' + field; doSpecialSearch(v, true); } -function chgProp(path, v, k){ +function chgProp(path, v, k) { var q2; if (!k) k = "*"; @@ -619,7 +601,7 @@ function chgProp(path, v, k){ return (false); } -function clktri(id){ +function clktri(id) { var o = $('#TOPIC_UL' + id); if ($('#TOPIC_UL' + id).hasClass('closed')) $('#TOPIC_TRI' + id + ' ,#TOPIC_UL' + id).removeClass('closed').addClass('opened'); @@ -628,18 +610,17 @@ function clktri(id){ } - /************* * CHUTIER **************/ -function evt_add_in_chutier(sbas_id, record_id){ +function evt_add_in_chutier(sbas_id, record_id) { // No basket - if($('#chutier_name option').length === 0) { + if ($('#chutier_name option').length === 0) { var alert = p4.Dialog.Create({ - size : 'Alert', - closeOnEscape : true, - closeButton:true + size: 'Alert', + closeOnEscape: true, + closeButton: true }); alert.setContent(language.no_basket); @@ -652,37 +633,40 @@ function evt_add_in_chutier(sbas_id, record_id){ $('#formChu').attr('action', '/client/baskets/add-element/').submit(); } -function chg_chu() -{ +function chg_chu() { var id = document.getElementById("chutier_name").value; document.forms["formChu"].courChuId.value = id; $("#formChu").submit(); } -function getBaskets() -{ - $('#formChu').attr("action","/client/baskets/") +function getBaskets() { + $('#formChu').attr("action", "/client/baskets/") $('#formChu').submit(); } -function newBasket(){ +function newBasket() { var buttons = {}; - buttons["OK"] = function(e){saveNewBask();$(this).dialog('close');}; - buttons[language.annuler] = function(e){$(this).dialog('close');}; + buttons["OK"] = function (e) { + saveNewBask(); + $(this).dialog('close'); + }; + buttons[language.annuler] = function (e) { + $(this).dialog('close'); + }; - $('#DIALOG').empty().append("").attr('title',language.createWinInvite).dialog({ - autoOpen:false, - closeOnEscape :true, - resizable:false, - draggable:false, - modal:true - }).dialog('open').dialog('option','buttons',buttons); + $('#DIALOG').empty().append("").attr('title', language.createWinInvite).dialog({ + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true + }).dialog('open').dialog('option', 'buttons', buttons); } -function saveNewBask(){ +function saveNewBask() { var tmp = $('#newBaskName')[0].value; if (tmp == null) return; @@ -700,7 +684,7 @@ function saveNewBask(){ $("#formChu").submit(); } -function evt_chutier(arg_commande){ +function evt_chutier(arg_commande) { switch (arg_commande) { case "DELSSEL": if (confirm(language.confirmDelBasket)) { @@ -714,41 +698,41 @@ function evt_chutier(arg_commande){ } } -function reload_chu(id){ +function reload_chu(id) { document.forms["formChu"].courChuId.value = id; $("#formChu").submit(); } -function evt_del_in_chutier(selid){ +function evt_del_in_chutier(selid) { document.forms["formChu"].p0.value = selid; $("#formChu").attr("action", "/client/baskets/delete-element/") $("#formChu").submit(); } -function openCompare(sselid){ +function openCompare(sselid) { $('#ssel2val')[0].value = sselid; $('#validatorEject').submit(); } -function setVisible(el){ +function setVisible(el) { el.style.visibility = 'visible'; } -function beforeAnswer(){ +function beforeAnswer() { if ($('#basSelector')) { var serialBas = $('#basSelector')[0].options[$('#basSelector')[0].selectedIndex].value; serialBas = serialBas.split(';'); - $.each($('.basItem'), function(i, el){ + $.each($('.basItem'), function (i, el) { el.checked = false; }); - $.each(serialBas, function(i, n){ + $.each(serialBas, function (i, n) { $('#basChk' + n)[0].checked = true; }); } return true; } -function gotopage(pag){ +function gotopage(pag) { if ($('#searchForm').length > 0) { $('#searchForm input[name=nba]').val(p4.tot); $('#searchForm input[name=pag]').val(pag); @@ -759,25 +743,25 @@ function gotopage(pag){ } -function evt_print(basrec){ - if(typeof(basrec) == 'undefined') { - if($('#chutier_name option').length === 0) { +function evt_print(basrec) { + if (typeof(basrec) == 'undefined') { + if ($('#chutier_name option').length === 0) { return false; } - var datas = "&ssel="+$('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value; + var datas = "&ssel=" + $('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value; } else { - var datas = "&lst=" + basrec; + var datas = "&lst=" + basrec; } - var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['print']: ''}); + var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['print'] : ''}); - $.post("/prod/printer/", datas, function(data) { + $.post("/prod/printer/", datas, function (data) { dialog.setContent(data); $('.tabs', dialog.getDomElement()).tabs(); - $('.close_button', dialog.getDomElement()).bind('click',function(){ + $('.close_button', dialog.getDomElement()).bind('click', function () { dialog.Close(); }); @@ -786,26 +770,25 @@ function evt_print(basrec){ } -function evt_dwnl(lst) -{ - if(typeof(lst) == 'undefined') { - if($('#chutier_name option').length === 0) { +function evt_dwnl(lst) { + if (typeof(lst) == 'undefined') { + if ($('#chutier_name option').length === 0) { return false; } - var datas = "&ssel="+$('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value; + var datas = "&ssel=" + $('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value; } else { - var datas = "&lst=" + lst; + var datas = "&lst=" + lst; } - 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/", datas, function(data) { + $.post("/prod/export/multi-export/", datas, function (data) { dialog.setContent(data); $('.tabs', dialog.getDomElement()).tabs(); - $('.close_button', dialog.getDomElement()).bind('click',function(){ + $('.close_button', dialog.getDomElement()).bind('click', function () { dialog.Close(); }); @@ -813,19 +796,18 @@ function evt_dwnl(lst) }); } -function profil(value) -{ +function profil(value) { var top; var left; - if(value==undefined) + if (value == undefined) value = "0"; var url = "" + "/include/profile.php" + - "?callclient=1&onglet="+value; + "?callclient=1&onglet=" + value; - $('#MODALDL').attr('src',url); + $('#MODALDL').attr('src', url); var t = (bodySize.y - 550) / 2; @@ -844,152 +826,136 @@ function profil(value) showOverlay(2); } -function setCss(color) -{ - $('#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.datepicker.css,'+ - 'skins/client/'+color+'/ui.theme.css'); +function setCss(color) { + $('#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.datepicker.css,' + + 'skins/client/' + color + '/ui.theme.css'); $.post("/user/preferences/", { prop: "css", value: color - }, function(data){ + }, function (data) { return; }); if ($.browser.msie && $.browser.version == '6.0') $('select').hide().show(); } -function lessPubli(sselid) -{ - $('#PUBLICONTMORE'+sselid+', #PUBLICONTLESS'+sselid).toggle(); - $('#PUBLICONT'+sselid).css({height: '135px'}); - $('#PUBLIMORE'+sselid+', #PUBLILESS'+sselid).toggle(); +function lessPubli(sselid) { + $('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle(); + $('#PUBLICONT' + sselid).css({height: '135px'}); + $('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle(); } -function morePubli(sselid) -{ - $('#PUBLICONTMORE'+sselid+', #PUBLICONTLESS'+sselid).toggle(); - $('#PUBLICONT'+sselid).css({height: 'auto'}); - $('#PUBLIMORE'+sselid+', #PUBLILESS'+sselid).toggle(); +function morePubli(sselid) { + $('#PUBLICONTMORE' + sselid + ', #PUBLICONTLESS' + sselid).toggle(); + $('#PUBLICONT' + sselid).css({height: 'auto'}); + $('#PUBLIMORE' + sselid + ', #PUBLILESS' + sselid).toggle(); } -function toggleFilter(filter,ele) -{ - var el = $('#'+filter); - if(el.is(':hidden')) +function toggleFilter(filter, ele) { + var el = $('#' + filter); + if (el.is(':hidden')) $(ele).parent().addClass('open'); else $(ele).parent().removeClass('open'); - $('#'+filter).slideToggle('fast'); + $('#' + filter).slideToggle('fast'); } -function checkFilters() -{ +function checkFilters() { var danger = false; var d = {}; - $('.filter_danger').each(function(){ + $('.filter_danger').each(function () { d[$(this).attr('id')] = false; }); - $('.basContTitle .base_filter :text').each(function(){ - if($(this)[0].value != "") - { + $('.basContTitle .base_filter :text').each(function () { + if ($(this)[0].value != "") { danger = true; - d['filter_danger'+parseInt($(this).attr('db'))] = true; + d['filter_danger' + parseInt($(this).attr('db'))] = true; } }); - $('.basContTitle .base_filter :checkbox').each(function(){ - if($(this)[0].checked) - { + $('.basContTitle .base_filter :checkbox').each(function () { + if ($(this)[0].checked) { danger = true; - d['filter_danger'+parseInt($(this).attr('db'))] = true; + d['filter_danger' + parseInt($(this).attr('db'))] = true; } }); - $('.basContTitle .base_filter select').each(function(){ - if($(this)[0].selectedIndex != 0) - { + $('.basContTitle .base_filter select').each(function () { + if ($(this)[0].selectedIndex != 0) { danger = true; - d['filter_danger'+parseInt($(this).attr('db'))] = true; + d['filter_danger' + parseInt($(this).attr('db'))] = true; } }); - $.each(d,function(i,bool){ - if(bool) - $('#'+i).show(); + $.each(d, function (i, bool) { + if (bool) + $('#' + i).show(); else - $('#'+i).hide(); + $('#' + i).hide(); }); - if(danger) + if (danger) $('#filter_danger').show(); else $('#filter_danger').hide(); } -function removeFilters(bas) -{ +function removeFilters(bas) { if (typeof(bas) == 'undefined') { - $('.basContTitle .base_filter :checkbox').each(function(){ + $('.basContTitle .base_filter :checkbox').each(function () { $(this)[0].checked = false; }); - $('.basContTitle .base_filter :text').each(function(){ + $('.basContTitle .base_filter :text').each(function () { $(this)[0].value = ""; }); - $('.basContTitle .base_filter select').each(function(){ + $('.basContTitle .base_filter select').each(function () { $(this)[0].selectedIndex = 0; }); } else { - $('#Filters' + bas + ' :checkbox').each(function(){ + $('#Filters' + bas + ' :checkbox').each(function () { $(this)[0].checked = false; }); - $('#Filters' + bas + ' :text').each(function(){ + $('#Filters' + bas + ' :text').each(function () { $(this)[0].value = ""; }); - $('#Filters' + bas + ' select').each(function(){ + $('#Filters' + bas + ' select').each(function () { $(this)[0].selectedIndex = 0; }); } checkFilters(); } -function execLastAct(lastAct) -{ - if(lastAct.act) - { - switch (lastAct.act) - { +function execLastAct(lastAct) { + if (lastAct.act) { + switch (lastAct.act) { case 'dwnl': - if(lastAct.SSTTID) - { + if (lastAct.SSTTID) { if (baskAjaxrunning) { setTimeout("execLastAct(lastAct);", 500); } else { - if($('#chutier_name option').length === 0) { + if ($('#chutier_name option').length === 0) { return false; } - if($('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value != lastAct.SSTTID) - { - $('#chutier_name option').each(function(i, n){ + if ($('#chutier_name')[0].options[$('#chutier_name')[0].selectedIndex].value != lastAct.SSTTID) { + $('#chutier_name option').each(function (i, n) { if (lastAct.SSTTID == this.value) { $('#chutier_name')[0].selectedIndex = i; $('#chutier_name').trigger('change'); setTimeout("execLastAct(lastAct);", 500); } }); - }else + } else evt_dwnl(); } } - else - if(lastAct.lst) - { + else if (lastAct.lst) { evt_dwnl(lastAct.lst); } break; diff --git a/www/skins/lightbox/jquery.lightbox.ie6.js b/www/skins/lightbox/jquery.lightbox.ie6.js index 24b46f818f..3b2fd2ea00 100644 --- a/www/skins/lightbox/jquery.lightbox.ie6.js +++ b/www/skins/lightbox/jquery.lightbox.ie6.js @@ -3,30 +3,27 @@ var p4 = p4 || {}; p4.releasable = false; var bodySize = { - x:0, - y:0 + x: 0, + y: 0 }; -$(window).bind('beforeunload', function(){ - if(p4.releasable !== false) - { - if(confirm(p4.releasable)) - { +$(window).bind('beforeunload', function () { + if (p4.releasable !== false) { + if (confirm(p4.releasable)) { $('#basket_options .confirm_report').trigger('click'); } } }); -$(document).ready(function(){ +$(document).ready(function () { bodySize.y = $('#mainContainer').height(); bodySize.x = $('#mainContainer').width(); - $(window).bind('resize',function(){ + $(window).bind('resize',function () { resize(); }).trigger('resize'); - function resize() - { + function resize() { bodySize.y = $('#mainContainer').height(); bodySize.x = $('#mainContainer').width(); @@ -41,51 +38,49 @@ $(document).ready(function(){ // var right_column_wrapper_height = $('#right_column').innerHeight() - $('.right_column_title').outerHeight() - 10; // $('.right_column_wrapper').height(right_column_wrapper_height); - $('.record_display_box').each(function(i,n){ - $('.lightbox_container',n).height($(n).innerHeight() - $('.header').outerHeight()); + $('.record_display_box').each(function (i, n) { + $('.lightbox_container', n).height($(n).innerHeight() - $('.header').outerHeight()); }); display_record($('#record_compare').css('visibility') != 'hidden'); } - $(this).data('slideshow',false); + $(this).data('slideshow', false); $(this).data('slideshow_ctime', false); $('#mainMenu, .unselectable').disableSelection(); display_basket(); - $(window).bind('mousedown', function(){ + $(window).bind('mousedown',function () { $(this).focus(); }).trigger('mousedown'); - $('.basket_downloader').bind('click', function(){ + $('.basket_downloader').bind('click', function () { download_basket(); }); $('.basket_wrapper').hover( - function(){ + function () { $(this).addClass('hover'); }, - function(){ + function () { $(this).removeClass('hover'); } - ).bind('click', function(){ - var id = $('input[name=ssel_id]',this).val(); - document.location = '/lightbox/validate/'+id+'/'; + ).bind('click', function () { + var id = $('input[name=ssel_id]', this).val(); + document.location = '/lightbox/validate/' + id + '/'; return; }); - $('.right_column_title').bind('click', function(){ + $('.right_column_title').bind('click',function () { 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_caption').show(); $('.caption', title).addClass('highlight'); $('.validate', title).removeClass('highlight'); } - else - { + else { $('.right_column_wrapper_user').height('auto'); $('.right_column_wrapper_caption').hide(); $('.caption', title).removeClass('highlight'); @@ -94,8 +89,7 @@ $(document).ready(function(){ }).addClass('clickable'); var sselcont = $('#sc_container .basket_element:first'); - if(sselcont.length > 0) - { + if (sselcont.length > 0) { display_basket_element(false, sselcont.attr('id').split('_').pop()); } @@ -104,34 +98,31 @@ $(document).ready(function(){ $('#navigation') .bind('change', - function() - { - window.location.replace(window.location.protocol+"//"+window.location.host+'/lightbox/validate/'+$(this).val()+'/'); + function () { + window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/'); } ); bind_keyboard(); }); -function bind_keyboard() -{ - $(document).bind('keydown', function(event){ +function bind_keyboard() { + $(document).bind('keydown', function (event) { var stop = false; - $('.notes_wrapper').each(function(i,n){ - if(parseInt($(n).css('top')) >= 0) + $('.notes_wrapper').each(function (i, n) { + if (parseInt($(n).css('top')) >= 0) stop = true; }); - if(stop) + if (stop) return true; var cancelKey = false; var el, id; - switch(event.keyCode) - { + switch (event.keyCode) { case 39: get_next(); cancelKey = true; @@ -146,16 +137,14 @@ function bind_keyboard() break; case 38: el = $('#sc_container .basket_element.selected'); - if(el.length === 1) - { + if (el.length === 1) { id = el.attr('id').split('_').pop(); set_agreement(event, el, id, 1); } break; case 40: el = $('#sc_container .basket_element.selected'); - if(el.length === 1) - { + if (el.length === 1) { id = el.attr('id').split('_').pop(); set_agreement(event, el, id, -1); } @@ -164,10 +153,9 @@ function bind_keyboard() break; } - if(cancelKey) - { + if (cancelKey) { event.cancelBubble = true; - if(event.stopPropagation) + if (event.stopPropagation) event.stopPropagation(); return(false); } @@ -175,29 +163,26 @@ function bind_keyboard() }); } -function set_release(el) -{ - $('.loader', el).css({visibility:'visible'}); +function set_release(el) { + $('.loader', el).css({visibility: 'visible'}); $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_RELEASE/"+$('#navigation').val()+"/", + url: "/lightbox/ajax/SET_RELEASE/" + $('#navigation').val() + "/", dataType: 'json', - error: function(data){ - $('.loader', el).css({visibility:'hidden'}); + error: function (data) { + $('.loader', el).css({visibility: 'hidden'}); }, - timeout: function(data){ - $('.loader', el).css({visibility:'hidden'}); + timeout: function (data) { + $('.loader', el).css({visibility: 'hidden'}); }, - success: function(data){ + success: function (data) { $('.loader', el).css({ - visibility:'hidden' + visibility: 'hidden' }); - if(data.datas) - { + if (data.datas) { alert(data.datas); } - if(!data.error) - { + if (!data.error) { p4.releasable = false; } @@ -206,18 +191,17 @@ function set_release(el) }); } -function load_report() -{ +function load_report() { $.ajax({ type: "GET", - url: "/lightbox/ajax/LOAD_REPORT/"+$('#navigation').val()+"/", + url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/", dataType: 'html', - success: function(data){ + success: function (data) { $('#report').empty().append(data); - $('#report .reportTips').tooltip({delay:false}); + $('#report .reportTips').tooltip({delay: false}); $('#report').dialog({ - width : 600, - height : Math.round($(window).height() * 0.8) + width: 600, + height: Math.round($(window).height() * 0.8) }).dialog('open').show(); return; } @@ -225,17 +209,16 @@ function load_report() } -function set_sizeable(container) -{ +function set_sizeable(container) { - $(container).bind('mousewheel',function(event,delta){ + $(container).bind('mousewheel', function (event, delta) { - if($(this).hasClass('note_editing')) + if ($(this).hasClass('note_editing')) return; var record = $('.record', this); - if(record.length === 0) + if (record.length === 0) return; var o_top = parseInt(record.css('top')); @@ -243,8 +226,7 @@ function set_sizeable(container) var o_width, o_height, width, height; - if(delta > 0) - { + if (delta > 0) { if (record.width() > 29788 || record.height() >= 29788) return; o_width = record.width(); @@ -252,8 +234,7 @@ function set_sizeable(container) width = Math.round(o_width * 1.1); height = Math.round(o_height * 1.1); } - else - { + else { if (record.width() < 30 || record.height() < 30) return; o_width = record.width(); @@ -265,34 +246,32 @@ function set_sizeable(container) var top = Math.round((height / o_height) * (o_top - $(this).height() / 2) + $(this).height() / 2); var left = Math.round((width / o_width) * (o_left - $(this).width() / 2) + $(this).width() / 2); - record.width(width).height(height).css({top:top, left:left}); + record.width(width).height(height).css({top: top, left: left}); }); } - -function display_basket() -{ +function display_basket() { var sc_wrapper = $('#sc_wrapper'); var basket_options = $('#basket_options'); - $('.report').bind('click', function(){ + $('.report').bind('click',function () { load_report(); }).addClass('clickable'); $('.confirm_report', basket_options).button({ - }).bind('click',function(){ + }).bind('click', function () { set_release($(this)); }); - $('.basket_element',sc_wrapper).parent() - .bind('click',function(event){ + $('.basket_element', sc_wrapper).parent() + .bind('click', function (event) { scid_click(event, this); return false; }) .addClass('clickable'); - $('.agree_button, .disagree_button',sc_wrapper).bind('click',function(event){ + $('.agree_button, .disagree_button', sc_wrapper).bind('click',function (event) { var sselcont_id = $(this).closest('.basket_element').attr('id').split('_').pop(); @@ -302,57 +281,39 @@ function display_basket() return false; }).addClass('clickable'); - n = $('.basket_element',sc_wrapper).length; - $('#sc_container').width(n * $('.basket_element_wrapper:first',sc_wrapper).outerWidth() + 1); + n = $('.basket_element', sc_wrapper).length; + $('#sc_container').width(n * $('.basket_element_wrapper:first', sc_wrapper).outerWidth() + 1); $('.previewTips').tooltip(); } - - - - - - - - - - - - -function display_basket_element(compare, sselcont_id) -{ +function display_basket_element(compare, sselcont_id) { var container; - if(compare) - { + if (compare) { container = $('#record_compare'); } - else - { + else { container = $('#record_main'); } $('.record_image', container).removeAttr('ondragstart'); $('.record_image', container).draggable(); - var options_container = $('.options',container); + var options_container = $('.options', container); $('.download_button', options_container).button({ - text : false - }).bind('click',function(){ + text: false + }).bind('click', function () { download($(this).next('form[name=download_form]').find('input').val()); }); $('.comment_button', options_container).button({ - text : true - }).bind('click',function() - { - if($('.lightbox_container', container).hasClass('note_editing')) - { + text: true + }).bind('click', function () { + if ($('.lightbox_container', container).hasClass('note_editing')) { hide_notes(container); } - else - { + else { show_notes(container); } } @@ -361,72 +322,65 @@ function display_basket_element(compare, sselcont_id) activate_notes(container); $('.previous_button', options_container).button({ - text : false - }).bind('click',function(){ + text: false + }).bind('click', function () { get_prev(); }); $('.play_button', options_container).button({ - text : false - }).bind('click',function(){ + text: false + }).bind('click', function () { slideshow(true); }); $('.pause_button', options_container).button({ - text : false - }).bind('click',function(){ + text: false + }).bind('click', function () { slideshow(false); }); - if($(document).data('slideshow')) - { + if ($(document).data('slideshow')) { $('.play_button, .next_button.play, .previous_button.play', options_container).hide(); } - else - { + else { $('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide(); } $('.next_button', options_container).button({ - text : false - }).bind('click',function(){ + text: false + }).bind('click', function () { get_next(); }); - $('.lightbox_container', container).bind('dblclick',function(event){ + $('.lightbox_container', container).bind('dblclick', function (event) { display_record(); }); - $('#record_wrapper .agree_'+sselcont_id+', .big_box.agree') + $('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree') .bind('click', - function(event) - { + function (event) { set_agreement(event, $(this), sselcont_id, '1'); } ) .addClass('clickable'); - $('#record_wrapper .disagree_'+sselcont_id+', .big_box.disagree') + $('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree') .bind('click', - function(event) - { + function (event) { set_agreement(event, $(this), sselcont_id, '-1'); } ) .addClass('clickable'); - if(compare == $('#record_wrapper').hasClass('single')) - { - if(compare) - { + if (compare == $('#record_wrapper').hasClass('single')) { + if (compare) { $('#record_infos, #right_column').hide(); - $('#record_wrapper').stop().css({width:'100%'}); + $('#record_wrapper').stop().css({width: '100%'}); display_record(compare); } - else - { + else { $('#record_wrapper').css({ - width:($('#innerWrapper').width() - $('#record_infos').outerWidth() - $('#right_column').outerWidth() - 2) + width: ($('#innerWrapper').width() - $('#record_infos').outerWidth() - $('#right_column').outerWidth() - 2) }); display_record(compare); $('#record_infos, #right_column').show(); @@ -434,37 +388,31 @@ function display_basket_element(compare, sselcont_id) } } - else - { + else { display_record(compare); } } -function set_container_status(status) -{ +function set_container_status(status) { $('#record_wrapper').removeClass('paysage portrait single').addClass(status); } -function show_notes(container) -{ - $('.notes_wrapper', container).animate({top:0}); +function show_notes(container) { + $('.notes_wrapper', container).animate({top: 0}); $('.lightbox_container', container).addClass('note_editing'); } -function hide_notes(container) -{ - $('.notes_wrapper', container).animate({top:'-100%'}); +function hide_notes(container) { + $('.notes_wrapper', container).animate({top: '-100%'}); $('.lightbox_container', container).removeClass('note_editing'); } -function activate_notes(container) -{ +function activate_notes(container) { $('.note_closer', container).button({ - text : true - }).bind('click',function() - { + text: true + }).bind('click', function () { // $(this).blur(); hide_notes(container); return false; @@ -472,9 +420,8 @@ function activate_notes(container) ); $('.note_saver', container).button({ - text : true - }).bind('click',function() - { + text: true + }).bind('click', function () { // $(this).blur(); save_note(container, this); return false; @@ -483,19 +430,16 @@ function activate_notes(container) } +function download(value) { + var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export'] : ''}); - -function download(value) -{ - 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) { dialog.setContent(data); $('.tabs', dialog.getDomElement()).tabs(); - $('.close_button', dialog.getDomElement()).bind('click',function(){ + $('.close_button', dialog.getDomElement()).bind('click', function () { dialog.Close(); }); @@ -504,167 +448,155 @@ function download(value) } -function display_record(compare) -{ - var main_container = $('#record_wrapper'); +function display_record(compare) { + var main_container = $('#record_wrapper'); main_container.width($('#innerWrapper').innerWidth() - $('#right_column').outerWidth() - 2); - if(typeof compare == 'undefined') + if (typeof compare == 'undefined') compare = !main_container.hasClass('single'); - var main_box = $('#record_main'); - var compare_box = $('#record_compare'); + var main_box = $('#record_main'); + var compare_box = $('#record_compare'); - var main_record = $('.lightbox_container .record', main_box); - var compare_record = $('.lightbox_container .record', compare_box); + var main_record = $('.lightbox_container .record', main_box); + var compare_record = $('.lightbox_container .record', compare_box); - var main_record_width = parseInt($('input[name=width]', main_box).val()); - var main_record_height = parseInt($('input[name=height]', main_box).val()); - var compare_record_width = parseInt($('input[name=width]', compare_box).val()); - var compare_record_height = parseInt($('input[name=height]', compare_box).val()); + var main_record_width = parseInt($('input[name=width]', main_box).val()); + var main_record_height = parseInt($('input[name=height]', main_box).val()); + var compare_record_width = parseInt($('input[name=width]', compare_box).val()); + var compare_record_height = parseInt($('input[name=height]', compare_box).val()); - var main_container_width = main_container.width(); - var main_container_innerwidth = main_container.innerWidth(); - var main_container_height = main_container.height(); - var main_container_innerheight = main_container.innerHeight(); + var main_container_width = main_container.width(); + var main_container_innerwidth = main_container.innerWidth(); + var main_container_height = main_container.height(); + var main_container_innerheight = main_container.innerHeight(); - if(compare) - { + if (compare) { $('.agreement_selector').show(); main_container.addClass('comparison'); - var double_portrait_width = main_container_innerwidth / 2; - var double_portrait_height = main_container_innerheight - $('.header', main_box).outerHeight(); + var double_portrait_width = main_container_innerwidth / 2; + var double_portrait_height = main_container_innerheight - $('.header', main_box).outerHeight(); - var double_paysage_width = main_container_innerwidth; - var double_paysage_height = main_container_innerheight / 2 - $('.header', main_box).outerHeight(); + var double_paysage_width = main_container_innerwidth; + var double_paysage_height = main_container_innerheight / 2 - $('.header', main_box).outerHeight(); - var main_display_portrait = calculate_display( + var main_display_portrait = calculate_display( double_portrait_width, double_portrait_height, main_record_width, main_record_height ); - var main_display_paysage = calculate_display( + var main_display_paysage = calculate_display( double_paysage_width, double_paysage_height, main_record_width, main_record_height ); - var compare_display_portrait = calculate_display( + var compare_display_portrait = calculate_display( double_portrait_width, double_portrait_height, compare_record_width, compare_record_height ); - var compare_display_paysage = calculate_display( + var compare_display_paysage = calculate_display( double_paysage_width, double_paysage_height, compare_record_width, compare_record_height ); - var surface_main_portrait = main_display_portrait.width * main_display_portrait.height; - var surface_main_paysage = main_display_paysage.width * main_display_paysage.height; - var surface_compare_portrait = compare_display_portrait.width * compare_display_portrait.height; - var surface_compare_paysage = compare_display_paysage.width * compare_display_paysage.height; + var surface_main_portrait = main_display_portrait.width * main_display_portrait.height; + var surface_main_paysage = main_display_paysage.width * main_display_paysage.height; + var surface_compare_portrait = compare_display_portrait.width * compare_display_portrait.height; + var surface_compare_paysage = compare_display_paysage.width * compare_display_paysage.height; - var double_portrait_surface = (surface_main_portrait + surface_compare_portrait) / 2; - var double_paysage_surface = (surface_main_paysage + surface_compare_paysage) / 2; + var double_portrait_surface = (surface_main_portrait + surface_compare_portrait) / 2; + var double_paysage_surface = (surface_main_paysage + surface_compare_paysage) / 2; var smooth_image = false; var m_width_image, m_height_image, c_width_image, c_height_image, dim_container; - if(double_portrait_surface > double_paysage_surface) - { - if(!main_container.hasClass('portrait')) - { + if (double_portrait_surface > double_paysage_surface) { + if (!main_container.hasClass('portrait')) { smooth_image = true; smooth_transform( main_box, parseInt($('#innerWrapper').width() / 2 - 13), $('#innerWrapper').height(), - function() - { + function () { set_container_status('portrait'); } ); - compare_box.css('visibility','hidden'); + compare_box.css('visibility', 'hidden'); smooth_transform( compare_box, parseInt($('#innerWrapper').width() / 2 - 13), $('#innerWrapper').height(), - function() - { - compare_box.css('display','none') - .css('visibility','visible').show(); + function () { + compare_box.css('display', 'none') + .css('visibility', 'visible').show(); } ); } - m_width_image = main_display_portrait.width; - m_height_image = main_display_portrait.height; - c_width_image = compare_display_portrait.width; - c_height_image = compare_display_portrait.height; - dim_container = {width:double_portrait_width,height:double_portrait_height}; + m_width_image = main_display_portrait.width; + m_height_image = main_display_portrait.height; + c_width_image = compare_display_portrait.width; + c_height_image = compare_display_portrait.height; + dim_container = {width: double_portrait_width, height: double_portrait_height}; } - else - { - if(!main_container.hasClass('paysage')) - { + else { + if (!main_container.hasClass('paysage')) { smooth_image = true; smooth_transform( main_box, $('#innerWrapper').width(), parseInt($('#innerWrapper').height() / 2), - function() - { + function () { set_container_status('paysage'); } ); - compare_box.css('visibility','hidden'); + compare_box.css('visibility', 'hidden'); smooth_transform( compare_box, $('#innerWrapper').width(), parseInt($('#innerWrapper').height() / 2), - function() - { - compare_box.css('display','none') - .css('visibility','visible') + function () { + compare_box.css('display', 'none') + .css('visibility', 'visible') .show(); } ); } - m_width_image = main_display_paysage.width; - m_height_image = main_display_paysage.height; - c_width_image = compare_display_paysage.width; - c_height_image = compare_display_paysage.height; - dim_container = {width:double_paysage_width,height:double_paysage_height}; + m_width_image = main_display_paysage.width; + m_height_image = main_display_paysage.height; + c_width_image = compare_display_paysage.width; + c_height_image = compare_display_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); } - else - { + else { $('.agreement_selector').hide(); main_container.removeClass('comparison'); - if(compare_box.is(':visible')) - { - compare_box.hide().css('visibility','hidden').css('display','block'); + if (compare_box.is(':visible')) { + compare_box.hide().css('visibility', 'hidden').css('display', 'block'); } - var main_display = calculate_display( + var main_display = calculate_display( main_container_innerwidth , (main_container_innerheight - $('.header', main_box).outerHeight()) , main_record_width , main_record_height ); - if(!main_container.hasClass('single')) - { + if (!main_container.hasClass('single')) { main_box.width('100%') .height('100%'); @@ -677,17 +609,15 @@ function display_record(compare) , main_display.width , main_display.height , { - width : main_container_width - ,height : (main_container_height - $('.header', main_box).outerHeight()) + width: main_container_width, height: (main_container_height - $('.header', main_box).outerHeight()) } ); } } -function set_agreement(event, el, sselcont_id, boolean_value) -{ - if(event.stopPropagation) +function set_agreement(event, el, sselcont_id, boolean_value) { + if (event.stopPropagation) event.stopPropagation(); event.cancelBubble = true; @@ -695,35 +625,30 @@ function set_agreement(event, el, sselcont_id, boolean_value) $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/" + sselcont_id + "/", dataType: 'json', data: { - agreement : boolean_value + agreement: boolean_value }, - success: function(datas){ - if(!datas.error) - { - if(boolean_value == '1') - { - $('.agree_'+sselcont_id+'').removeClass('not_decided'); - $('.disagree_'+sselcont_id+'').addClass('not_decided'); + success: function (datas) { + if (!datas.error) { + if (boolean_value == '1') { + $('.agree_' + sselcont_id + '').removeClass('not_decided'); + $('.disagree_' + sselcont_id + '').addClass('not_decided'); $('.userchoice.me').addClass('agree').removeClass('disagree'); } - else - { - $('.agree_'+sselcont_id+'').addClass('not_decided'); - $('.disagree_'+sselcont_id+'').removeClass('not_decided'); + else { + $('.agree_' + sselcont_id + '').addClass('not_decided'); + $('.disagree_' + sselcont_id + '').removeClass('not_decided'); $('.userchoice.me').addClass('disagree').removeClass('agree'); } p4.releasable = datas.releasable; - if(datas.releasable !== false) - { - if(confirm(datas.releasable)) + if (datas.releasable !== false) { + if (confirm(datas.releasable)) $('#basket_options .confirm_report').trigger('click'); } } - else - { + else { alert(datas.datas); } return; @@ -732,48 +657,43 @@ function set_agreement(event, el, sselcont_id, boolean_value) } - -function get_next() -{ +function get_next() { var current_wrapper = $('#sc_container .basket_element.selected').parent(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) return; current_wrapper = current_wrapper.next(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) current_wrapper = $('#sc_container .basket_element_wrapper:first'); $('.basket_element', current_wrapper).trigger('click'); adjust_visibility($('.basket_element', current_wrapper)); - if($(document).data('slideshow')) - { + if ($(document).data('slideshow')) { var timer = setTimeout('get_next();', 3500); $(document).data('slideshow_ctime', timer); } } -function get_prev() -{ +function get_prev() { var current_wrapper = $('#sc_container .basket_element.selected').parent(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) return; slideshow(false); current_wrapper = current_wrapper.prev(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) current_wrapper = $('#sc_container .basket_element_wrapper:last'); $('.basket_element', current_wrapper).trigger('click'); adjust_visibility($('.basket_element', current_wrapper)); } -function is_viewable(el) -{ +function is_viewable(el) { var sc_wrapper = $('#sc_wrapper'); var sc_container = $('#sc_container'); @@ -786,14 +706,13 @@ function is_viewable(el) placeup = el_position.left + el_width - sc_scroll_left, placedown = el_position.left - sc_scroll_left; - if(placeup <= boundup && placedown >= bounddown) + if (placeup <= boundup && placedown >= bounddown) return true; return false; } -function adjust_visibility(el) -{ - if(is_viewable(el)) +function adjust_visibility(el) { + if (is_viewable(el)) return; var sc_wrapper = $('#sc_wrapper'); @@ -801,17 +720,15 @@ function adjust_visibility(el) var sc_left = el_parent.position().left + el_parent.outerWidth() / 2 - sc_wrapper.width() / 2; - sc_wrapper.stop().animate({'scrollLeft':sc_left}); + sc_wrapper.stop().animate({'scrollLeft': sc_left}); } -function slideshow(boolean_value) -{ - if(boolean_value == $(document).data('slideshow')) +function slideshow(boolean_value) { + if (boolean_value == $(document).data('slideshow')) return; - if(!boolean_value && $(document).data('slideshow_ctime')) - { + if (!boolean_value && $(document).data('slideshow_ctime')) { clearTimeout($(document).data('slideshow_ctime')); $(document).data('slideshow_ctime', false); } @@ -820,30 +737,28 @@ function slideshow(boolean_value) var headers = $('#record_wrapper .header'); - if(boolean_value) - { + if (boolean_value) { $('.play_button, .next_button.play, .previous_button.play').hide(); $('.pause_button, .next_button.pause, .previous_button.pause').show(); get_next(); } - else - { + else { $('.pause_button, .next_button.pause, .previous_button.pause').hide(); $('.play_button, .next_button.play, .previous_button.play').show(); } } -function smooth_transform(box, width, height, callback) -{ - if(typeof callback == 'undefined') - callback = function(){}; +function smooth_transform(box, width, height, callback) { + if (typeof callback == 'undefined') + callback = function () { + }; $(box).stop() .css( { - width : width, - height : height + width: width, + height: height } // , // 500, @@ -852,19 +767,18 @@ function smooth_transform(box, width, height, callback) callback(); } -function save_note(container, button) -{ +function save_note(container, button) { var sselcont_id = $(button).attr('id').split('_').pop(); var note = $('.notes_wrapper textarea', container).val(); $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_NOTE/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_NOTE/" + sselcont_id + "/", dataType: 'json', data: { - note : note + note: note }, - success: function(datas){ + success: function (datas) { hide_notes(container); $('.notes_wrapper', container).remove(); $('.lightbox_container', container).append(datas.datas); @@ -874,54 +788,50 @@ function save_note(container, button) }); } -function calculate_display(display_width, display_height, width, height, margin) -{ - if(typeof margin == 'undefined') +function calculate_display(display_width, display_height, width, height, margin) { + if (typeof margin == 'undefined') margin = 10; var display_ratio = display_width / display_height; var ratio = width / height; - var w,h; + var w, h; - if(ratio > display_ratio)//landscape + if (ratio > display_ratio)//landscape { w = display_width - 2 * margin; - if(w > width) + if (w > width) w = width; h = w / ratio; } - else - { + else { h = display_height - 2 * margin; - if(h > height) + if (h > height) h = height; w = ratio * h; } - return {width:w,height:h}; + return {width: w, height: h}; } -function set_image_position(smooth, image, width, height, container, callback) -{ +function set_image_position(smooth, image, width, height, container, callback) { var dimensions = {}; - if(typeof container !== 'undefined') - { - var c_width = container.width; - var c_height = container.height; + if (typeof container !== 'undefined') { + var c_width = container.width; + var c_height = container.height; - dimensions.top = parseInt((c_height - height) / 2); - dimensions.left = parseInt((c_width - width) / 2); + dimensions.top = parseInt((c_height - height) / 2); + dimensions.left = parseInt((c_width - width) / 2); } - if(typeof callback == 'undefined') - { - callback = function(){}; + if (typeof callback == 'undefined') { + callback = function () { + }; } } -dimensions.width = parseInt(width); -dimensions.height = parseInt(height); +dimensions.width = parseInt(width); +dimensions.height = parseInt(height); // if(smooth) // { // $(image).stop().animate(dimensions,500,callback); @@ -934,17 +844,14 @@ callback; } -function scid_click(event, el) -{ +function scid_click(event, el) { var compare = is_ctrl_key(event); - if(compare) - { - if($('.basket_element', el).hasClass('selected')) + if (compare) { + if ($('.basket_element', el).hasClass('selected')) return; } - else - { + else { $('#sc_container .basket_element.selected').removeClass('selected'); $('.basket_element', el).addClass('selected'); } @@ -955,8 +862,7 @@ function scid_click(event, el) var container = $('#sc_container'); var request = container.data('request'); - if(request && typeof(request.abort) == 'function') - { + if (request && typeof(request.abort) == 'function') { request.abort(); } @@ -964,15 +870,13 @@ function scid_click(event, el) type: "GET", url: $(el).attr('href'),//"/lightbox/ajax/LOAD_BASKET_ELEMENT/"+sselcont_id+'/', dataType: 'json', - success: function(data){ + success: function (data) { var container = false; - if(compare) - { + if (compare) { container = $('#record_compare'); } - else - { + else { container = $('#record_main'); $('#record_infos .lightbox_container') @@ -984,22 +888,22 @@ function scid_click(event, el) .append(data.agreement_html); } - $('.display_id',container) + $('.display_id', container) .empty() .append(data.number); - $('.title',container) + $('.title', container) .empty() .append(data.title) .attr('title', data.title); - var options_container = $('.options',container); + var options_container = $('.options', container); options_container .empty() .append(data.options_html); $('.lightbox_container', container).empty() - .append(data.preview+data.selector_html+data.note_html); + .append(data.preview + data.selector_html + data.note_html); display_basket_element(compare, sselcont_id); @@ -1012,36 +916,32 @@ function scid_click(event, el) } - -function download_basket() -{ - var ids = $.map($('#sc_container .download_form').toArray(), function(el, i){ - return $('input[name="basrec"]',$(el)).val(); +function download_basket() { + var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) { + return $('input[name="basrec"]', $(el)).val(); }); download(ids.join(';')); } -function is_ctrl_key(event) -{ - if(event.altKey) +function is_ctrl_key(event) { + if (event.altKey) return true; - if(event.ctrlKey) + if (event.ctrlKey) return true; - if(event.metaKey) // apple key opera + if (event.metaKey) // apple key opera return true; - if(event.keyCode == '17') // apple key opera + if (event.keyCode == '17') // apple key opera return true; - if(event.keyCode == '224') // apple key mozilla + if (event.keyCode == '224') // apple key mozilla return true; - if(event.keyCode == '91') // apple key safari + if (event.keyCode == '91') // apple key safari return true; return false; } -function is_shift_key(event) -{ - if(event.shiftKey) +function is_shift_key(event) { + if (event.shiftKey) return true; return false; } diff --git a/www/skins/lightbox/jquery.lightbox.js b/www/skins/lightbox/jquery.lightbox.js index 0753ca8bcd..25db63a63d 100644 --- a/www/skins/lightbox/jquery.lightbox.js +++ b/www/skins/lightbox/jquery.lightbox.js @@ -3,56 +3,53 @@ var p4 = p4 || {}; p4.releasable = false; var bodySize = { - x:0, - y:0 + x: 0, + y: 0 }; -$(document).ready(function(){ +$(document).ready(function () { bodySize.y = $('#mainContainer').height(); bodySize.x = $('#mainContainer').width(); - $(this).data('slideshow',false); + $(this).data('slideshow', false); $(this).data('slideshow_ctime', false); $('#mainMenu, .unselectable').disableSelection(); display_basket(); - $(window).bind('mousedown', function(){ + $(window).bind('mousedown',function () { $(this).focus(); }).trigger('mousedown'); $('.basket_wrapper').hover( - function(){ + function () { $(this).addClass('hover'); }, - function(){ + function () { $(this).removeClass('hover'); } - ).bind('click', function(){ - var id = $('input[name=ssel_id]',this).val(); - document.location = '/lightbox/validate/'+id+'/'; + ).bind('click', function () { + var id = $('input[name=ssel_id]', this).val(); + document.location = '/lightbox/validate/' + id + '/'; return; }); - $('.basket_downloader').bind('click', function(){ + $('.basket_downloader').bind('click', function () { download_basket(); }); - if($('.right_column_wrapper_user').length > 0) - { - $('.right_column_title, #right_column_validation_toggle').bind('click', function(){ - if(!$('.right_column_wrapper_caption').is(':visible')) - { - $('.right_column_wrapper_user').height($('.right_column_wrapper_user').height()).css('top','auto').animate({ - 'height':0 + if ($('.right_column_wrapper_user').length > 0) { + $('.right_column_title, #right_column_validation_toggle').bind('click',function () { + if (!$('.right_column_wrapper_caption').is(':visible')) { + $('.right_column_wrapper_user').height($('.right_column_wrapper_user').height()).css('top', 'auto').animate({ + 'height': 0 }); $('.right_column_wrapper_caption').slideDown(); $('#right_column_validation_toggle').show(); } - else - { + else { $('.right_column_wrapper_user').height('auto').animate({ - 'top':$('.right_column_title').height() + 'top': $('.right_column_title').height() }); $('.right_column_wrapper_caption').slideUp(); $('#right_column_validation_toggle').hide(); @@ -62,8 +59,7 @@ $(document).ready(function(){ }).addClass('clickable'); } var sselcont = $('#sc_container .basket_element:first'); - if(sselcont.length > 0) - { + if (sselcont.length > 0) { display_basket_element(false, sselcont.attr('id').split('_').pop()); } @@ -72,63 +68,55 @@ $(document).ready(function(){ $('#navigation') .bind('change', - function() - { - window.location.replace(window.location.protocol+"//"+window.location.host+'/lightbox/validate/'+$(this).val()+'/'); + function () { + window.location.replace(window.location.protocol + "//" + window.location.host + '/lightbox/validate/' + $(this).val() + '/'); } ); $('#left_scroller') .bind('click', - function() - { + function () { scroll_elements(false); } ); $('#right_scroller') - .bind('click', function() - { + .bind('click', function () { scroll_elements(true); } ); $(window) - .bind('resize',function() - { + .bind('resize', function () { resize(); } ); bind_keyboard(); }); -$(window).bind('beforeunload', function(){ - if(p4.releasable !== false) - { - if(confirm(p4.releasable)) - { +$(window).bind('beforeunload', function () { + if (p4.releasable !== false) { + if (confirm(p4.releasable)) { $('#basket_options .confirm_report').trigger('click'); } } }); -function bind_keyboard() -{ - $(document).bind('keydown', function(event){ +function bind_keyboard() { + $(document).bind('keydown', function (event) { var stop = false; - $('.notes_wrapper').each(function(i,n){ - if(parseInt($(n).css('top')) >= 0) + $('.notes_wrapper').each(function (i, n) { + if (parseInt($(n).css('top')) >= 0) stop = true; }); - if(stop) + if (stop) return true; var cancelKey = false; var el, id; - switch(event.keyCode) - { + switch (event.keyCode) { case 39: get_next(); cancelKey = true; @@ -143,16 +131,14 @@ function bind_keyboard() break; case 38: el = $('#sc_container .basket_element.selected'); - if(el.length === 1) - { + if (el.length === 1) { id = el.attr('id').split('_').pop(); set_agreement(event, el, id, 1); } break; case 40: el = $('#sc_container .basket_element.selected'); - if(el.length === 1) - { + if (el.length === 1) { id = el.attr('id').split('_').pop(); set_agreement(event, el, id, -1); } @@ -161,10 +147,9 @@ function bind_keyboard() break; } - if(cancelKey) - { + if (cancelKey) { event.cancelBubble = true; - if(event.stopPropagation) + if (event.stopPropagation) event.stopPropagation(); return(false); } @@ -172,67 +157,61 @@ function bind_keyboard() }); } -function is_ctrl_key(event) -{ - if(event.altKey) +function is_ctrl_key(event) { + if (event.altKey) return true; - if(event.ctrlKey) + if (event.ctrlKey) return true; - if(event.metaKey) // apple key opera + if (event.metaKey) // apple key opera return true; - if(event.keyCode == '17') // apple key opera + if (event.keyCode == '17') // apple key opera return true; - if(event.keyCode == '224') // apple key mozilla + if (event.keyCode == '224') // apple key mozilla return true; - if(event.keyCode == '91') // apple key safari + if (event.keyCode == '91') // apple key safari return true; return false; } -function is_shift_key(event) -{ - if(event.shiftKey) +function is_shift_key(event) { + if (event.shiftKey) return true; return false; } -function resize() -{ +function resize() { bodySize.y = $('#mainContainer').height(); bodySize.x = $('#mainContainer').width(); display_record($('#record_compare').css('visibility') != 'hidden'); } -function set_release(el) -{ +function set_release(el) { $('.loader', el).css({ - visibility:'visible' + visibility: 'visible' }); $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_RELEASE/"+$('#navigation').val()+"/", + url: "/lightbox/ajax/SET_RELEASE/" + $('#navigation').val() + "/", dataType: 'json', - error: function(data){ + error: function (data) { $('.loader', el).css({ - visibility:'hidden' + visibility: 'hidden' }); }, - timeout: function(data){ + timeout: function (data) { $('.loader', el).css({ - visibility:'hidden' + visibility: 'hidden' }); }, - success: function(data){ + success: function (data) { $('.loader', el).css({ - visibility:'hidden' + visibility: 'hidden' }); - if(data.datas) - { + if (data.datas) { alert(data.datas); } - if(!data.error) - { + if (!data.error) { p4.releasable = false; } @@ -241,22 +220,21 @@ function set_release(el) }); } -function load_report() -{ +function load_report() { $.ajax({ type: "GET", - url: "/lightbox/ajax/LOAD_REPORT/"+$('#navigation').val()+"/", + url: "/lightbox/ajax/LOAD_REPORT/" + $('#navigation').val() + "/", dataType: 'html', - success: function(data){ + success: function (data) { $('#report').empty().append(data); $('#report .reportTips').tooltip({ - delay:false + delay: false }); $('#report').dialog({ - width : 600, - modal:true, - resizable:false, - height : Math.round($(window).height() * 0.8) + width: 600, + modal: true, + resizable: false, + height: Math.round($(window).height() * 0.8) }); return; @@ -264,12 +242,11 @@ function load_report() }); } -function display_basket() -{ +function display_basket() { var sc_wrapper = $('#sc_wrapper'); var basket_options = $('#basket_options'); - $('.report').live('click', function(){ + $('.report').live('click',function () { load_report(); return false; }).addClass('clickable'); @@ -281,17 +258,17 @@ function display_basket() // $(this).blur(); // }); $('.confirm_report', basket_options).button() - .bind('click',function(){ + .bind('click', function () { set_release($(this)); }); - $('.basket_element',sc_wrapper).parent() - .bind('click',function(event){ + $('.basket_element', sc_wrapper).parent() + .bind('click', function (event) { scid_click(event, this); return false; }); - $('.agree_button, .disagree_button',sc_wrapper).bind('click',function(event){ + $('.agree_button, .disagree_button', sc_wrapper).bind('click',function (event) { var sselcont_id = $(this).closest('.basket_element').attr('id').split('_').pop(); @@ -301,24 +278,21 @@ function display_basket() return false; }).addClass('clickable'); - n = $('.basket_element',sc_wrapper).length; - $('#sc_container').width(n * $('.basket_element_wrapper:first',sc_wrapper).outerWidth() + 1); + n = $('.basket_element', sc_wrapper).length; + $('#sc_container').width(n * $('.basket_element_wrapper:first', sc_wrapper).outerWidth() + 1); $('.previewTips').tooltip(); } -function scid_click(event, el) -{ +function scid_click(event, el) { var compare = is_ctrl_key(event); - if(compare) - { - if($('.basket_element', el).hasClass('selected')) + if (compare) { + if ($('.basket_element', el).hasClass('selected')) return; } - else - { + else { $('#sc_container .basket_element.selected').removeClass('selected'); $('.basket_element', el).addClass('selected'); } @@ -329,8 +303,7 @@ function scid_click(event, el) var container = $('#sc_container'); var request = container.data('request'); - if(request && typeof(request.abort) == 'function') - { + if (request && typeof(request.abort) == 'function') { request.abort(); } @@ -338,16 +311,14 @@ function scid_click(event, el) type: "GET", url: $(el).attr('href'),//"/lightbox/ajax/LOAD_BASKET_ELEMENT/"+sselcont_id+'/', dataType: 'json', - success: function(datas){ + success: function (datas) { var container = false; var data = datas; - if(compare) - { + if (compare) { container = $('#record_compare'); } - else - { + else { container = $('#record_main'); $('#record_infos .lightbox_container') @@ -359,22 +330,22 @@ function scid_click(event, el) .append(data.agreement_html); } - $('.display_id',container) + $('.display_id', container) .empty() .append(data.number); - $('.title',container) + $('.title', container) .empty() .append(data.title) .attr('title', data.title); - var options_container = $('.options',container); + var options_container = $('.options', container); options_container .empty() .append(data.options_html); $('.lightbox_container', container).empty() - .append(data.preview+data.selector_html+data.note_html); + .append(data.preview + data.selector_html + data.note_html); display_basket_element(compare, sselcont_id); @@ -386,19 +357,18 @@ function scid_click(event, el) container.data('request', request); } -function save_note(container, button) -{ +function save_note(container, button) { var sselcont_id = $(button).attr('id').split('_').pop(); var note = $('.notes_wrapper textarea', container).val(); $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_NOTE/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_NOTE/" + sselcont_id + "/", dataType: 'json', data: { - note : note + note: note }, - success: function(datas){ + success: function (datas) { hide_notes(container); $('.notes_wrapper', container).remove(); $('.lightbox_container', container).append(datas.datas); @@ -409,36 +379,30 @@ function save_note(container, button) } -function display_basket_element(compare, sselcont_id) -{ +function display_basket_element(compare, sselcont_id) { var container; - if(compare) - { + if (compare) { container = $('#record_compare'); } - else - { + else { container = $('#record_main'); } $('.record_image', container).removeAttr('ondragstart'); $('.record_image', container).draggable(); - var options_container = $('.options',container); + var options_container = $('.options', container); - $('.download_button', options_container).bind('click',function(){ + $('.download_button', options_container).bind('click', function () { // $(this).blur(); 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(); - if($('.lightbox_container', container).hasClass('note_editing')) - { + if ($('.lightbox_container', container).hasClass('note_editing')) { hide_notes(container); } - else - { + else { show_notes(container); } } @@ -446,77 +410,70 @@ function display_basket_element(compare, sselcont_id) activate_notes(container); - $('.previous_button', options_container).bind('click',function(){ + $('.previous_button', options_container).bind('click', function () { // $(this).blur(); get_prev(); }); - $('.play_button', options_container).bind('click',function(){ + $('.play_button', options_container).bind('click', function () { // $(this).blur(); slideshow(true); }); - $('.pause_button', options_container).bind('click',function(){ + $('.pause_button', options_container).bind('click', function () { // $(this).blur(); slideshow(false); }); - if($(document).data('slideshow')) - { + if ($(document).data('slideshow')) { $('.play_button, .next_button.play, .previous_button.play', options_container).hide(); } - else - { + else { $('.pause_button, .next_button.pause, .previous_button.pause', options_container).hide(); } - $('.next_button', options_container).bind('click',function(){ + $('.next_button', options_container).bind('click', function () { // $(this).blur(); slideshow(false); get_next(); }); - $('.lightbox_container', container).bind('dblclick',function(event){ + $('.lightbox_container', container).bind('dblclick', function (event) { display_record(); }); - $('#record_wrapper .agree_'+sselcont_id+', .big_box.agree') + $('#record_wrapper .agree_' + sselcont_id + ', .big_box.agree') .bind('click', - function(event) - { + function (event) { set_agreement(event, $(this), sselcont_id, '1'); } ) .addClass('clickable'); - $('#record_wrapper .disagree_'+sselcont_id+', .big_box.disagree') + $('#record_wrapper .disagree_' + sselcont_id + ', .big_box.disagree') .bind('click', - function(event) - { + function (event) { set_agreement(event, $(this), sselcont_id, '-1'); } ) .addClass('clickable'); - if(compare == $('#record_wrapper').hasClass('single')) - { - if(compare) - { + if (compare == $('#record_wrapper').hasClass('single')) { + if (compare) { // $('.agreement_selector').show(); // $('#record_wrapper').stop().animate({right:0},100,function(){display_record(compare);}); $('#record_wrapper').css({ - right:0 + right: 0 }); display_record(compare); $('#right_column').hide(); } - else - { + else { // $('.agreement_selector').hide(); $('#record_wrapper').css({ - right:250 + right: 250 }); display_record(compare); $('#right_column').show(); @@ -524,35 +481,30 @@ function display_basket_element(compare, sselcont_id) } } - else - { + else { display_record(compare); } } -function show_notes(container) -{ +function show_notes(container) { $('.notes_wrapper', container).animate({ - top:0 + top: 0 }); $('.lightbox_container', container).addClass('note_editing'); } -function hide_notes(container) -{ +function hide_notes(container) { $('.notes_wrapper', container).animate({ - top:'-100%' + top: '-100%' }); $('.lightbox_container', container).removeClass('note_editing'); } -function activate_notes(container) -{ +function activate_notes(container) { $('.note_closer', container).button({ - text : true - }).bind('click',function() - { + text: true + }).bind('click', function () { $(this).blur(); hide_notes(container); return false; @@ -560,9 +512,8 @@ function activate_notes(container) ); $('.note_saver', container).button({ - text : true - }).bind('click',function() - { + text: true + }).bind('click', function () { $(this).blur(); save_note(container, this); 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_container = $('#sc_container'); @@ -584,14 +534,13 @@ function is_viewable(el) placeup = el_position.left + el_width - sc_scroll_left, placedown = el_position.left - sc_scroll_left; - if(placeup <= boundup && placedown >= bounddown) + if (placeup <= boundup && placedown >= bounddown) return true; return false; } -function adjust_visibility(el) -{ - if(is_viewable(el)) +function adjust_visibility(el) { + if (is_viewable(el)) return; var sc_wrapper = $('#sc_wrapper'); @@ -600,43 +549,40 @@ function adjust_visibility(el) var sc_left = el_parent.position().left + el_parent.outerWidth() / 2 - sc_wrapper.width() / 2; sc_wrapper.stop().animate({ - 'scrollLeft':sc_left + 'scrollLeft': sc_left }); } -function get_next() -{ +function get_next() { var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) return; current_wrapper = current_wrapper.next(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) current_wrapper = $('#sc_container .basket_element_wrapper:first'); $('.basket_element', current_wrapper).parent().trigger('click'); adjust_visibility($('.basket_element', current_wrapper)); - if($(document).data('slideshow')) - { + if ($(document).data('slideshow')) { var timer = setTimeout('get_next();', 3500); $(document).data('slideshow_ctime', timer); } } -function get_prev() -{ +function get_prev() { var current_wrapper = $('#sc_container .basket_element.selected').parent().parent(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) return; slideshow(false); current_wrapper = current_wrapper.prev(); - if(current_wrapper.length === 0) + if (current_wrapper.length === 0) current_wrapper = $('#sc_container .basket_element_wrapper:last'); $('.basket_element', current_wrapper).parent().trigger('click'); @@ -644,13 +590,11 @@ function get_prev() adjust_visibility($('.basket_element', current_wrapper)); } -function slideshow(boolean_value) -{ - if(boolean_value == $(document).data('slideshow')) +function slideshow(boolean_value) { + if (boolean_value == $(document).data('slideshow')) return; - if(!boolean_value && $(document).data('slideshow_ctime')) - { + if (!boolean_value && $(document).data('slideshow_ctime')) { clearTimeout($(document).data('slideshow_ctime')); $(document).data('slideshow_ctime', false); } @@ -659,30 +603,27 @@ function slideshow(boolean_value) var headers = $('#record_wrapper .header'); - if(boolean_value) - { + if (boolean_value) { $('.play_button, .next_button.play, .previous_button.play', headers).hide(); $('.pause_button, .next_button.pause, .previous_button.pause', headers).show(); get_next(); } - else - { + else { $('.pause_button, .next_button.pause, .previous_button.pause', headers).hide(); $('.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) { - if($(this).hasClass('note_editing')) + if ($(this).hasClass('note_editing')) return; var record = $('.record_image', this); - if(record.length === 0) + if (record.length === 0) return; var o_top = parseInt(record.css('top')); @@ -690,8 +631,7 @@ function set_sizeable(container) var o_width, o_height, width, height; - if(delta > 0) - { + if (delta > 0) { if (record.width() > 29788 || record.height() >= 29788) return; o_width = record.width(); @@ -699,8 +639,7 @@ function set_sizeable(container) width = Math.round(o_width * 1.1); height = Math.round(o_height * 1.1); } - else - { + else { if (record.width() < 30 || record.height() < 30) return; o_width = record.width(); @@ -713,16 +652,15 @@ function set_sizeable(container) var left = Math.round((width / o_width) * (o_left - $(this).width() / 2) + $(this).width() / 2); record.width(width).height(height).css({ - top:top, - left:left + top: top, + left: left }); }); } -function set_agreement(event, el, sselcont_id, boolean_value) -{ - if(event.stopPropagation) +function set_agreement(event, el, sselcont_id, boolean_value) { + if (event.stopPropagation) event.stopPropagation(); event.cancelBubble = true; @@ -730,35 +668,30 @@ function set_agreement(event, el, sselcont_id, boolean_value) $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/" + sselcont_id + "/", dataType: 'json', data: { - agreement : boolean_value + agreement: boolean_value }, - success: function(datas){ - if(!datas.error) - { - if(boolean_value == '1') - { - $('.agree_'+sselcont_id+'').removeClass('not_decided'); - $('.disagree_'+sselcont_id+'').addClass('not_decided'); + success: function (datas) { + if (!datas.error) { + if (boolean_value == '1') { + $('.agree_' + sselcont_id + '').removeClass('not_decided'); + $('.disagree_' + sselcont_id + '').addClass('not_decided'); $('.userchoice.me').addClass('agree').removeClass('disagree'); } - else - { - $('.agree_'+sselcont_id+'').addClass('not_decided'); - $('.disagree_'+sselcont_id+'').removeClass('not_decided'); + else { + $('.agree_' + sselcont_id + '').addClass('not_decided'); + $('.disagree_' + sselcont_id + '').removeClass('not_decided'); $('.userchoice.me').addClass('disagree').removeClass('agree'); } p4.releasable = datas.releasable; - if(datas.releasable !== false) - { - if(confirm(datas.releasable)) + if (datas.releasable !== false) { + if (confirm(datas.releasable)) $('#basket_options .confirm_report').trigger('click'); } } - else - { + else { alert(datas.datas); } return; @@ -767,258 +700,239 @@ function set_agreement(event, el, sselcont_id, boolean_value) } -function calculate_display(display_width, display_height, width, height, margin) -{ - if(typeof margin == 'undefined') +function calculate_display(display_width, display_height, width, height, margin) { + if (typeof margin == 'undefined') margin = 10; var display_ratio = display_width / display_height; var ratio = width / height; - var w,h; + var w, h; - if(ratio > display_ratio)//landscape + if (ratio > display_ratio)//landscape { w = display_width - 2 * margin; - if(w > width) + if (w > width) w = width; h = w / ratio; } - else - { + else { h = display_height - 2 * margin; - if(h > height) + if (h > height) h = height; w = ratio * h; } return { - width:w, - height:h + width: w, + height: h }; } -function display_record(compare) -{ - var main_container = $('#record_wrapper'); +function display_record(compare) { + var main_container = $('#record_wrapper'); - if(typeof compare == 'undefined') + if (typeof compare == 'undefined') compare = !main_container.hasClass('single'); - var main_box = $('#record_main'); - var compare_box = $('#record_compare'); + var main_box = $('#record_main'); + var compare_box = $('#record_compare'); - var main_record = $('.lightbox_container .record', main_box); - var compare_record = $('.lightbox_container .record', compare_box); + var main_record = $('.lightbox_container .record', main_box); + var compare_record = $('.lightbox_container .record', compare_box); - var main_record_width = parseInt($('input[name=width]', main_box).val()); - var main_record_height = parseInt($('input[name=height]', main_box).val()); - var compare_record_width = parseInt($('input[name=width]', compare_box).val()); - var compare_record_height = parseInt($('input[name=height]', compare_box).val()); + var main_record_width = parseInt($('input[name=width]', main_box).val()); + var main_record_height = parseInt($('input[name=height]', main_box).val()); + var compare_record_width = parseInt($('input[name=width]', compare_box).val()); + var compare_record_height = parseInt($('input[name=height]', compare_box).val()); - var main_container_width = main_container.width(); - var main_container_innerwidth = main_container.innerWidth(); - var main_container_height = main_container.height(); - var main_container_innerheight = main_container.innerHeight(); + var main_container_width = main_container.width(); + var main_container_innerwidth = main_container.innerWidth(); + var main_container_height = main_container.height(); + var main_container_innerheight = main_container.innerHeight(); - if(compare) - { + if (compare) { $('.agreement_selector').show(); main_container.addClass('comparison'); - var double_portrait_width = main_container_innerwidth / 2; - var double_portrait_height = main_container_innerheight - $('.header', main_box).outerHeight(); + var double_portrait_width = main_container_innerwidth / 2; + var double_portrait_height = main_container_innerheight - $('.header', main_box).outerHeight(); - var double_paysage_width = main_container_innerwidth; - var double_paysage_height = main_container_innerheight / 2 - $('.header', main_box).outerHeight(); + var double_paysage_width = main_container_innerwidth; + var double_paysage_height = main_container_innerheight / 2 - $('.header', main_box).outerHeight(); - var main_display_portrait = calculate_display( + var main_display_portrait = calculate_display( double_portrait_width, double_portrait_height, main_record_width, main_record_height ); - var main_display_paysage = calculate_display( + var main_display_paysage = calculate_display( double_paysage_width, double_paysage_height, main_record_width, main_record_height ); - var compare_display_portrait = calculate_display( + var compare_display_portrait = calculate_display( double_portrait_width, double_portrait_height, compare_record_width, compare_record_height ); - var compare_display_paysage = calculate_display( + var compare_display_paysage = calculate_display( double_paysage_width, double_paysage_height, compare_record_width, compare_record_height ); - var surface_main_portrait = main_display_portrait.width * main_display_portrait.height; - var surface_main_paysage = main_display_paysage.width * main_display_paysage.height; - var surface_compare_portrait = compare_display_portrait.width * compare_display_portrait.height; - var surface_compare_paysage = compare_display_paysage.width * compare_display_paysage.height; + var surface_main_portrait = main_display_portrait.width * main_display_portrait.height; + var surface_main_paysage = main_display_paysage.width * main_display_paysage.height; + var surface_compare_portrait = compare_display_portrait.width * compare_display_portrait.height; + var surface_compare_paysage = compare_display_paysage.width * compare_display_paysage.height; - var double_portrait_surface = (surface_main_portrait + surface_compare_portrait) / 2; - var double_paysage_surface = (surface_main_paysage + surface_compare_paysage) / 2; + var double_portrait_surface = (surface_main_portrait + surface_compare_portrait) / 2; + var double_paysage_surface = (surface_main_paysage + surface_compare_paysage) / 2; var smooth_image = false; var m_width_image, m_height_image, c_width_image, c_height_image, dim_container; - if(double_portrait_surface > double_paysage_surface) - { - if(!main_container.hasClass('portrait')) - { + if (double_portrait_surface > double_paysage_surface) { + if (!main_container.hasClass('portrait')) { smooth_image = true; smooth_transform( main_box, '50%', '100%', - function() - { + function () { set_container_status('portrait'); } ); - compare_box.css('visibility','hidden'); + compare_box.css('visibility', 'hidden'); smooth_transform( compare_box, '50%', '100%', - function() - { - compare_box.css('display','none') - .css('visibility','visible') + function () { + compare_box.css('display', 'none') + .css('visibility', 'visible') .fadeIn(); } ); } - m_width_image = main_display_portrait.width; - m_height_image = main_display_portrait.height; - c_width_image = compare_display_portrait.width; - c_height_image = compare_display_portrait.height; - dim_container = { - width:double_portrait_width, - height:double_portrait_height + m_width_image = main_display_portrait.width; + m_height_image = main_display_portrait.height; + c_width_image = compare_display_portrait.width; + c_height_image = compare_display_portrait.height; + dim_container = { + width: double_portrait_width, + height: double_portrait_height }; } - else - { - if(!main_container.hasClass('paysage')) - { + else { + if (!main_container.hasClass('paysage')) { smooth_image = true; smooth_transform( main_box, '100%', '50%', - function() - { + function () { set_container_status('paysage'); } ); - compare_box.css('visibility','hidden'); + compare_box.css('visibility', 'hidden'); smooth_transform( compare_box, '100%', '50%', - function() - { - compare_box.css('display','none') - .css('visibility','visible') + function () { + compare_box.css('display', 'none') + .css('visibility', 'visible') .fadeIn(); } ); } - m_width_image = main_display_paysage.width; - m_height_image = main_display_paysage.height; - c_width_image = compare_display_paysage.width; - c_height_image = compare_display_paysage.height; - dim_container = { - width:double_paysage_width, - height:double_paysage_height + m_width_image = main_display_paysage.width; + m_height_image = main_display_paysage.height; + c_width_image = compare_display_paysage.width; + c_height_image = compare_display_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); } - else - { + else { $('.agreement_selector').hide(); main_container.removeClass('comparison'); - if(compare_box.is(':visible')) - { - compare_box.hide().css('visibility','hidden').css('display','block'); + if (compare_box.is(':visible')) { + compare_box.hide().css('visibility', 'hidden').css('display', 'block'); } - var main_display = calculate_display( + var main_display = calculate_display( main_container_innerwidth, (main_container_innerheight - $('.header', main_box).outerHeight()), main_record_width, main_record_height ); - if(!main_container.hasClass('single')) - { + if (!main_container.hasClass('single')) { main_box.width('100%') .height('100%'); set_container_status('single'); } set_image_position(smooth_image, main_record, main_display.width, main_display.height, { - width:main_container_width, - height:(main_container_height - $('.header', main_box).outerHeight()) + width: main_container_width, + height: (main_container_height - $('.header', main_box).outerHeight()) }); } } -function set_container_status(status) -{ +function set_container_status(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 = {}; - if(typeof container !== 'undefined') - { - var c_width = container.width; - var c_height = container.height; + if (typeof container !== 'undefined') { + var c_width = container.width; + var c_height = container.height; - dimensions.top = parseInt((c_height - height) / 2); - dimensions.left = parseInt((c_width - width) / 2); + dimensions.top = parseInt((c_height - height) / 2); + dimensions.left = parseInt((c_width - width) / 2); } - if(typeof callback == 'undefined') - { - callback = function(){}; + if (typeof callback == 'undefined') { + callback = function () { + }; } - dimensions.width = width; - dimensions.height = height; + dimensions.width = width; + dimensions.height = height; - if(smooth) - { - $(image).stop().animate(dimensions,500,callback); + if (smooth) { + $(image).stop().animate(dimensions, 500, callback); } - else - { + else { $(image).css(dimensions); callback(); } } -function smooth_transform(box, width, height, callback) -{ - if(typeof callback == 'undefined') - callback = function(){}; +function smooth_transform(box, width, height, callback) { + if (typeof callback == 'undefined') + callback = function () { + }; $(box).stop() .animate( { - width : width, - height : height + width: width, + height: height }, 500, callback @@ -1026,40 +940,37 @@ function smooth_transform(box, width, height, callback) } -function scroll_elements(boolean_value) -{ - var sc_wrapper = $('#sc_wrapper'); +function scroll_elements(boolean_value) { + var sc_wrapper = $('#sc_wrapper'); var value; - if(boolean_value) + if (boolean_value) value = sc_wrapper.scrollLeft() + 400; else value = sc_wrapper.scrollLeft() - 400; sc_wrapper.stop().animate({ - 'scrollLeft':value + 'scrollLeft': value }); return; } -function download_basket() -{ - var ids = $.map($('#sc_container .download_form').toArray(), function(el, i){ - return $('input[name="basrec"]',$(el)).val(); +function download_basket() { + var ids = $.map($('#sc_container .download_form').toArray(), function (el, i) { + return $('input[name="basrec"]', $(el)).val(); }); download(ids.join(';')); } -function download(value) -{ - var dialog = p4.Dialog.Create({title: typeof(language) !== 'undefined' ? language['export']: ''}); +function download(value) { + 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) { dialog.setContent(data); $('.tabs', dialog.getDomElement()).tabs(); - $('.close_button', dialog.getDomElement()).bind('click',function(){ + $('.close_button', dialog.getDomElement()).bind('click', function () { dialog.Close(); }); diff --git a/www/skins/lightbox/jquery.validator.mobile.js b/www/skins/lightbox/jquery.validator.mobile.js index 3ea9a12078..0152fe7094 100644 --- a/www/skins/lightbox/jquery.validator.mobile.js +++ b/www/skins/lightbox/jquery.validator.mobile.js @@ -1,31 +1,30 @@ -$(document).ready(function(){ - if(typeof validator_loaded === 'boolean') +$(document).ready(function () { + if (typeof validator_loaded === 'boolean') return; - - $('.confirm_report').live('click',function(){ + $('.confirm_report').live('click', function () { var $this = $(this); $('.loader', $this).css({ - visibility:'visible' + visibility: 'visible' }); $.ajax({ type: "POST", url: "/lightbox/ajax/SET_RELEASE/" + $('#basket_validation_id').val() + "/", dataType: 'json', - error: function(data) { + error: function (data) { $('.loader', $this).css({ visibility: 'hidden' }); }, - timeout: function(data) { + timeout: function (data) { $('.loader', $this).css({ visibility: 'hidden' }); }, - success: function(data) { + success: function (data) { $('.loader', $this).css({ visibility: 'hidden' }); @@ -41,7 +40,7 @@ $(document).ready(function(){ }); }); - $('.agreement_radio').live('vmousedown', function(){ + $('.agreement_radio').live('vmousedown', function () { var sselcont_id = $(this).attr('for').split('_').pop(); var agreement = $('#' + $(this).attr('for')).val() == 'yes' ? '1' : '-1'; @@ -49,37 +48,34 @@ $(document).ready(function(){ $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_ELEMENT_AGREEMENT/" + sselcont_id + "/", dataType: 'json', data: { - agreement : agreement + agreement: agreement }, - error: function(datas){ + error: function (datas) { alert('error'); $.mobile.loading(); }, - timeout: function(datas){ + timeout: function (datas) { alert('error'); $.mobile.loading(); }, - success: function(datas){ - if(!datas.error) - { - if(agreement == '1') - $('.valid_choice_'+sselcont_id).removeClass('disagree').addClass('agree'); + success: function (datas) { + if (!datas.error) { + if (agreement == '1') + $('.valid_choice_' + sselcont_id).removeClass('disagree').addClass('agree'); else - $('.valid_choice_'+sselcont_id).removeClass('agree').addClass('disagree'); + $('.valid_choice_' + sselcont_id).removeClass('agree').addClass('disagree'); $.mobile.loading(); - if(datas.error) - { + if (datas.error) { alert(datas.datas); return; } releasable = datas.release; } - else - { + else { alert(datas.datas); } return; @@ -88,34 +84,33 @@ $(document).ready(function(){ return false; }); - $('.note_area_validate').live('click', function(){ + $('.note_area_validate').live('click', function () { var sselcont_id = $(this).closest('form').find('input[name="sselcont_id"]').val(); $.mobile.loading(); $.ajax({ type: "POST", - url: "/lightbox/ajax/SET_NOTE/"+sselcont_id+"/", + url: "/lightbox/ajax/SET_NOTE/" + sselcont_id + "/", dataType: 'json', data: { - note : $('#note_form_'+sselcont_id).find('textarea').val() + note: $('#note_form_' + sselcont_id).find('textarea').val() }, - error: function(datas){ + error: function (datas) { alert('error'); $.mobile.loading(); }, - timeout: function(datas){ + timeout: function (datas) { alert('error'); $.mobile.loading(); }, - success: function(datas){ + success: function (datas) { $.mobile.loading(); - if(datas.error) - { + if (datas.error) { alert(datas.datas); return; } - $('#notes_'+sselcont_id).empty().append(datas.datas); + $('#notes_' + sselcont_id).empty().append(datas.datas); window.history.back(); return; } diff --git a/www/skins/prod/ThumbExtractor.js b/www/skins/prod/ThumbExtractor.js index a8f1fc912d..6a2bd35022 100644 --- a/www/skins/prod/ThumbExtractor.js +++ b/www/skins/prod/ThumbExtractor.js @@ -1,15 +1,15 @@ ; -(function(document){ +(function (document) { /***************** * Canva Object *****************/ - var Canva = function(domCanva){ + var Canva = function (domCanva) { this.domCanva = domCanva; }; Canva.prototype = { - resize : function(elementDomNode){ + resize: function (elementDomNode) { var w = elementDomNode.getWidth(); var maxH = elementDomNode.getHeight(); @@ -20,7 +20,7 @@ if (h > maxH) { var h = maxH; - var w = Math.round(h * ratio); + var w = Math.round(h * ratio); } } else { var h = maxH; @@ -31,10 +31,9 @@ return this; }, - getContext2d : function(){ + getContext2d: function () { - if (undefined === this.domCanva.getContext) - { + if (undefined === this.domCanva.getContext) { return G_vmlCanvasManager .initElement(this.domCanva) .getContext("2d"); @@ -42,13 +41,13 @@ return this.domCanva.getContext('2d'); }, - extractImage : function(){ + extractImage: function () { return this.domCanva.toDataURL("image/png"); }, - reset : function(){ + reset: function () { var context = this.getContext2d(); var w = this.getWidth(); - var h = this.getHeight(); + var h = this.getHeight(); context.save(); context.setTransform(1, 0, 0, 1, 0, 0); @@ -57,7 +56,7 @@ return this; }, - copy : function(elementDomNode){ + copy: function (elementDomNode) { var context = this.getContext2d(); context.drawImage( @@ -70,13 +69,13 @@ return this; }, - getDomElement : function(){ + getDomElement: function () { return this.domCanva; }, - getHeight : function(){ + getHeight: function () { return this.domCanva.offsetHeight; }, - getWidth : function(){ + getWidth: function () { return this.domCanva.offsetWidth; } }; @@ -85,18 +84,18 @@ /****************** * Image Object ******************/ - var Image = function(domElement){ + var Image = function (domElement) { this.domElement = domElement; }; Image.prototype = { - getDomElement : function(){ + getDomElement: function () { return this.domElement; }, - getHeight : function(){ + getHeight: function () { return this.domElement.offsetHeight; }, - getWidth : function(){ + getWidth: function () { return this.domElement.offsetWidth; } }; @@ -105,45 +104,45 @@ * Video Object inherits from Image object ******************/ - var Video = function(domElement){ + var Video = function (domElement) { Image.call(this, domElement); this.aspectRatio = domElement.getAttribute('data-ratio'); }; Video.prototype = new Image(); Video.prototype.constructor = Video; - Video.prototype.getCurrentTime = function(){ + Video.prototype.getCurrentTime = function () { return Math.floor(this.domElement.currentTime); }; - Video.prototype.getAspectRatio = function(){ + Video.prototype.getAspectRatio = function () { return this.aspectRatio; }; /****************** * Cache Object ******************/ - var Store = function(){ + var Store = function () { this.datas = {}; }; Store.prototype = { - set : function(id, item){ + set: function (id, item) { this.datas[id] = item; return this; }, - get : function(id){ - if(!this.datas[id]){ + get: function (id) { + if (!this.datas[id]) { throw 'Unknown ID'; } return this.datas[id]; }, - remove : function(id) { + remove: function (id) { delete this.datas[id]; }, - getLength : function(){ + getLength: function () { var count = 0; - for (var k in this.datas){ - if (this.datas.hasOwnProperty(k)){ + for (var k in this.datas) { + if (this.datas.hasOwnProperty(k)) { ++count; } } @@ -154,7 +153,7 @@ /****************** * Screenshot Object ******************/ - var ScreenShot = function(id, canva, video){ + var ScreenShot = function (id, canva, video) { var date = new Date(); @@ -168,16 +167,16 @@ }; ScreenShot.prototype = { - getId:function(){ + getId: function () { return this.id; }, - getDataURI: function(){ + getDataURI: function () { return this.dataURI; }, - getTimeStamp: function(){ + getTimeStamp: function () { return this.timestamp; }, - getVideoTime : function(){ + getVideoTime: function () { return this.videoTime; } }; @@ -185,7 +184,7 @@ /** * THUMB EDITOR */ - var ThumbEditor = function(videoId, canvaId){ + var ThumbEditor = function (videoId, canvaId) { var domElement = document.getElementById(videoId); @@ -194,18 +193,18 @@ } var store = new Store(); - function getCanva(){ + function getCanva() { return document.getElementById(canvaId); } return { - isSupported : function () { + isSupported: function () { var elem = document.createElement('canvas'); - return !! document.getElementById(videoId) && document.getElementById(canvaId) - && !! elem.getContext && !! elem.getContext('2d'); + return !!document.getElementById(videoId) && document.getElementById(canvaId) + && !!elem.getContext && !!elem.getContext('2d'); }, - screenshot : function(){ + screenshot: function () { var screenshot = new ScreenShot( store.getLength() + 1, new Canva(getCanva()), @@ -216,8 +215,8 @@ return screenshot; }, - store : store, - copy: function(elementDomNode){ + store: store, + copy: function (elementDomNode) { var element = new Image(elementDomNode); var editorCanva = new Canva(getCanva()); editorCanva @@ -225,15 +224,15 @@ .resize(editorVideo) .copy(element); }, - getCanvaImage : function(){ + getCanvaImage: function () { var canva = new Canva(getCanva()); return canva.extractImage(); }, - resetCanva : function(){ + resetCanva: function () { var editorCanva = new Canva(getCanva()); editorCanva.reset(); }, - getNbScreenshot : function(){ + getNbScreenshot: function () { return store.getLength(); } }; diff --git a/www/skins/prod/jquery.Alerts.js b/www/skins/prod/jquery.Alerts.js index 762b33ea3f..c25a4a735c 100644 --- a/www/skins/prod/jquery.Alerts.js +++ b/www/skins/prod/jquery.Alerts.js @@ -1,25 +1,22 @@ var p4 = p4 || {}; -(function(p4){ +(function (p4) { - function create_dialog() - { - if($('#p4_alerts').length === 0) - { + function create_dialog() { + if ($('#p4_alerts').length === 0) { $('body').append('
'); } return $('#p4_alerts'); } - function alert(title, message, callback) - { + function alert(title, message, callback) { var dialog = create_dialog(); var button = new Object(); - button['Ok'] = function(){ - if(typeof callback === 'function') + button['Ok'] = function () { + if (typeof callback === 'function') callback(); else dialog.dialog('close'); @@ -29,28 +26,28 @@ var p4 = p4 || {}; dialog.dialog('destroy'); } - dialog.attr('title',title) + dialog.attr('title', title) .empty() .append(message) .dialog({ - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - buttons : button, + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true, + buttons: button, overlay: { backgroundColor: '#000', opacity: 0.7 } }).dialog('open'); - if(typeof callback === 'function') - { - dialog.bind( "dialogclose", function(event, ui) {callback();}); + if (typeof callback === 'function') { + dialog.bind("dialogclose", function (event, ui) { + callback(); + }); } - else - { + else { } diff --git a/www/skins/prod/jquery.Dialog.js b/www/skins/prod/jquery.Dialog.js index dea87630dc..1fdf31f801 100644 --- a/www/skins/prod/jquery.Dialog.js +++ b/www/skins/prod/jquery.Dialog.js @@ -2,36 +2,31 @@ var p4 = p4 || {}; ; -(function(p4, $){ +(function (p4, $) { - function getLevel (level) { + function getLevel(level) { level = parseInt(level); - if(isNaN(level) || level < 1) - { + if (isNaN(level) || level < 1) { return 1; } return level; }; - function getId (level) - { + function getId(level) { return 'DIALOG' + getLevel(level); }; - function addButtons(buttons, dialog) - { - if(dialog.options.closeButton === true) - { - buttons[language.fermer] = function() { + function addButtons(buttons, dialog) { + if (dialog.options.closeButton === true) { + buttons[language.fermer] = function () { dialog.Close(); }; } - if(dialog.options.cancelButton === true) - { - buttons[language.annuler] = function() { + if (dialog.options.cancelButton === true) { + buttons[language.annuler] = function () { dialog.Close(); }; } @@ -41,12 +36,11 @@ var p4 = p4 || {}; var phraseaDialog = function (options, level) { - var createDialog = function(level) { + var createDialog = function (level) { var $dialog = $('#' + getId(level)); - if($dialog.length > 0) - { + if ($dialog.length > 0) { throw 'Dialog already exists at this level'; } @@ -57,15 +51,15 @@ var p4 = p4 || {}; }; var defaults = { - size : 'Medium', - buttons : {}, - loading : true, - title : '', - closeOnEscape : true, - confirmExit:false, - closeCallback:false, - closeButton:false, - cancelButton:false + size: 'Medium', + buttons: {}, + loading: true, + title: '', + closeOnEscape: true, + confirmExit: false, + closeCallback: false, + closeButton: false, + cancelButton: false }, options = typeof options === 'object' ? options : {}, width, @@ -81,11 +75,10 @@ var p4 = p4 || {}; this.options.buttons = addButtons(this.options.buttons, this); - switch(this.options.size) - { + switch (this.options.size) { case 'Full': height = bodySize.y - 30; - width = bodySize.x - 30 ; + width = bodySize.x - 30; break; case 'Medium': width = Math.min(bodySize.x - 30, 730); @@ -113,14 +106,12 @@ var p4 = p4 || {}; this.$dialog = createDialog(this.level), zIndex = Math.min(this.level * 5000 + 5000, 32767); - var CloseCallback = function() { - if(typeof $this.options.closeCallback === 'function') - { + var CloseCallback = function () { + if (typeof $this.options.closeCallback === 'function') { $this.options.closeCallback($this.$dialog); } - if($this.closing === false) - { + if ($this.closing === false) { $this.closing = true; $this.Close(); } @@ -133,34 +124,32 @@ var p4 = p4 || {}; this.$dialog.attr('title', this.options.title) .empty() .dialog({ - buttons:this.options.buttons, - draggable:false, - resizable:false, - closeOnEscape:this.options.closeOnEscape, - modal:true, - width:width, - height:height, - open: function() { + buttons: this.options.buttons, + draggable: false, + resizable: false, + closeOnEscape: this.options.closeOnEscape, + modal: true, + width: width, + height: height, + open: function () { $(this).dialog("widget").css("z-index", zIndex); }, - close:CloseCallback + close: CloseCallback }) .dialog('open').addClass('dialog-' + this.options.size); - if(this.options.loading === true) - { + if (this.options.loading === true) { this.$dialog.addClass('loading'); } - if(this.options.size === 'Full') - { + if (this.options.size === 'Full') { var $this = this; $(window).unbind('resize.DIALOG' + getLevel(level)) - .bind('resize.DIALOG' + getLevel(level), function(){ + .bind('resize.DIALOG' + getLevel(level), function () { if ($this.$dialog.data("ui-dialog")) { $this.$dialog.dialog('option', { - width : bodySize.x - 30, - height : bodySize.y - 30 + width: bodySize.x - 30, + height: bodySize.y - 30 }); } }); @@ -170,61 +159,59 @@ var p4 = p4 || {}; }; phraseaDialog.prototype = { - Close : function() { + Close: function () { p4.Dialog.Close(this.level); }, - setContent : function (content) { + setContent: function (content) { this.$dialog.removeClass('loading').empty().append(content); }, - getId : function () { + getId: function () { return this.$dialog.attr('id'); }, - load : function(url, method, params) { + load: function (url, method, params) { var $this = this; this.loader = { - url : url, - method : typeof method === 'undefined' ? 'GET' : method, - params : typeof params === 'undefined' ? {} : params + url: url, + method: typeof method === 'undefined' ? 'GET' : method, + params: typeof params === 'undefined' ? {} : params }; $.ajax({ type: this.loader.method, url: this.loader.url, dataType: 'html', - data : this.loader.params, - beforeSend:function(){ + data: this.loader.params, + beforeSend: function () { }, - success: function(data){ + success: function (data) { $this.setContent(data); return; }, - error: function(){ + error: function () { return; }, - timeout: function(){ + timeout: function () { return; } }); }, - refresh : function() { - if(typeof this.loader === 'undefined') - { + refresh: function () { + if (typeof this.loader === 'undefined') { throw 'Nothing to refresh'; } this.load(this.loader.url, this.loader.method, this.loader.params); }, - getDomElement : function () { + getDomElement: function () { return this.$dialog; }, - getOption : function (optionName) { + getOption: function (optionName) { if (this.$dialog.data("ui-dialog")) { return this.$dialog.dialog('option', optionName); } return null; }, - setOption : function (optionName, optionValue) { - if(optionName === 'buttons') - { + setOption: function (optionName, optionValue) { + if (optionName === 'buttons') { optionValue = addButtons(optionValue, this); } if (this.$dialog.data("ui-dialog")) { @@ -238,10 +225,9 @@ var p4 = p4 || {}; }; 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(); } @@ -251,18 +237,17 @@ var p4 = p4 || {}; return $dialog; }, - get : function (level) { + get: function (level) { var id = getId(level); - if(id in this.currentStack) - { + if (id in this.currentStack) { return this.currentStack[id]; } return null; }, - Close : function (level) { + Close: function (level) { $(window).unbind('resize.DIALOG' + getLevel(level)); @@ -275,8 +260,7 @@ var p4 = p4 || {}; var id = this.get(level).getId(); - if(id in this.currentStack) - { + if (id in this.currentStack) { delete this.currentStack.id; } } diff --git a/www/skins/prod/jquery.Feedback.js b/www/skins/prod/jquery.Feedback.js index 63bfdf1648..ae689dfcd0 100644 --- a/www/skins/prod/jquery.Feedback.js +++ b/www/skins/prod/jquery.Feedback.js @@ -1,8 +1,7 @@ - ; -(function(window){ +(function (window) { - var Feedback = function($container, context){ + var Feedback = function ($container, context) { this.container = $($container); this.Context = context; @@ -10,23 +9,23 @@ this.selection = new Selectable( $('.user_content .badges', this.container), { - selector:'.badge' + selector: '.badge' } ); var $this = this; - $('.content .options .select-all', this.container).bind('click', function(){ + $('.content .options .select-all', this.container).bind('click', function () { $this.selection.selectAll(); }); - $('.content .options .unselect-all', this.container).bind('click', function(){ + $('.content .options .unselect-all', this.container).bind('click', function () { $this.selection.empty(); }); $('.UserTips', this.container).tooltip(); - $('a.user_adder', this.container).bind('click', function(){ + $('a.user_adder', this.container).bind('click', function () { var $this = $(this); @@ -34,22 +33,22 @@ type: "GET", url: $this.attr('href'), dataType: 'html', - beforeSend:function(){ + beforeSend: function () { var options = { - size : 'Medium', - title : $this.html() + size: 'Medium', + title: $this.html() }; p4.Dialog.Create(options, 2).getDomElement().addClass('loading'); }, - success: function(data){ + success: function (data) { p4.Dialog.get(2).getDomElement().removeClass('loading').empty().append(data); return; }, - error: function(){ + error: function () { p4.Dialog.get(2).Close(); return; }, - timeout: function(){ + timeout: function () { p4.Dialog.get(2).Close(); return; } @@ -58,7 +57,7 @@ return false; }); - $('.recommended_users', this.container).bind('click', function(){ + $('.recommended_users', this.container).bind('click', function () { var usr_id = $('input[name="usr_id"]', $(this)).val(); @@ -67,19 +66,19 @@ return false; }); - $('.recommended_users_list', this.container).bind('click', function(){ + $('.recommended_users_list', this.container).bind('click', function () { var content = $('#push_user_recommendations').html(); var options = { - size : 'Small', - title : $(this).attr('title') + size: 'Small', + title: $(this).attr('title') }; $dialog = p4.Dialog.Create(options, 2); $dialog.setContent(content); - $dialog.getDomElement().find('a.adder').bind('click', function(){ + $dialog.getDomElement().find('a.adder').bind('click', function () { $(this).addClass('added'); @@ -90,24 +89,21 @@ return false; }); - $dialog.getDomElement().find('a.adder').each(function(i, el){ + $dialog.getDomElement().find('a.adder').each(function (i, el) { 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'); } }); - - return false; }); - $('#PushBox form[name="FeedBackForm"]').bind('submit', function(){ + $('#PushBox form[name="FeedBackForm"]').bind('submit', function () { var $this = $(this); @@ -116,27 +112,25 @@ url: $this.attr('action'), dataType: 'json', data: $this.serializeArray(), - beforeSend:function(){ + beforeSend: function () { }, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); p4.Dialog.Close(1); p4.WorkZone.refresh(); } - else - { + else { humane.error(data.message); } return; }, - error: function(){ + error: function () { return; }, - timeout: function(){ + timeout: function () { return; } @@ -145,21 +139,20 @@ return false; }); - $('.FeedbackSend', this.container).bind('click', function(){ - if($('.badges .badge', $container).length === 0) - { + $('.FeedbackSend', this.container).bind('click', function () { + if ($('.badges .badge', $container).length === 0) { alert(language.FeedBackNoUsersSelected); return; } var buttons = {}; - buttons[language.send] = function(){ + buttons[language.send] = function () { if ($.trim($('input[name="name"]', $dialog.getDomElement()).val()) === '') { options = { - size : 'Alert', - closeButton : true, - title : language.warning + size: 'Alert', + closeButton: true, + title: language.warning }, $dialog = p4.Dialog.Create(options, 3); $dialog.setContent(language.FeedBackNameMandatory); @@ -178,12 +171,12 @@ }; var options = { - size : 'Small', - buttons : buttons, - loading : true, - title : language.send, - closeOnEscape : true, - cancelButton : true + size: 'Small', + buttons: buttons, + loading: true, + title: language.send, + closeOnEscape: true, + cancelButton: true }; var $dialog = p4.Dialog.Create(options, 2); @@ -198,14 +191,14 @@ $('textarea[name="message"]', $dialog.getDomElement()).val($('textarea[name="message"]', $FeedBackForm).val()); $('.' + $this.Context, $dialog.getDomElement()).show(); - $('form', $dialog.getDomElement()).submit(function() { + $('form', $dialog.getDomElement()).submit(function () { return false; }); }); $('.user_content .badges', this.container).disableSelection(); - $('.user_content .badges .badge .toggle', this.container).die('click').live('click', function(event){ + $('.user_content .badges .badge .toggle', this.container).die('click').live('click', function (event) { var $this = $(this); @@ -216,19 +209,17 @@ return false; }); - $('.general_togglers .general_toggler', this.container).bind('click', function(){ + $('.general_togglers .general_toggler', this.container).bind('click', function () { var feature = $(this).attr('feature'); var $badges = $('.user_content .badge.selected', this.container); var toggles = $('.status_off.toggle_' + feature, $badges); - if(toggles.length === 0) - { + if (toggles.length === 0) { var toggles = $('.status_on.toggle_' + feature, $badges); } - if(toggles.length === 0) - { + if (toggles.length === 0) { humane.info('No user selected'); } @@ -236,26 +227,25 @@ return false; }); - $('.user_content .badges .badge .deleter', this.container).live('click', function(event){ + $('.user_content .badges .badge .deleter', this.container).live('click', function (event) { var $elem = $(this).closest('.badge'); - $elem.fadeOut(function(){ + $elem.fadeOut(function () { $elem.remove(); }); return; }); - $('.list_manager', this.container).bind('click', function(){ + $('.list_manager', this.container).bind('click', function () { $('#PushBox').hide(); $('#ListManager').show(); return false; }); - $('a.list_loader', this.container).bind('click', function(){ + $('a.list_loader', this.container).bind('click', function () { var url = $(this).attr('href'); - var callbackList = function(list){ - for(var i in list.entries) - { + var callbackList = function (list) { + for (var i in list.entries) { this.selectUser(list.entries[i].User); } }; @@ -267,19 +257,18 @@ $('.options button', this.container); - $('form.list_saver', this.container).bind('submit', function(){ + $('form.list_saver', this.container).bind('submit', function () { var $form = $(this); var $input = $('input[name="name"]', $form); var users = p4.Feedback.getUsers(); - if(users.length === 0) - { + if (users.length === 0) { humane.error('No users'); return false; } - p4.Lists.create($input.val(), function(list){ + p4.Lists.create($input.val(), function (list) { $input.val(''); list.addUsers(users); }); @@ -289,68 +278,64 @@ $('input[name="users-search"]', this.container).autocomplete({ minLength: 2, - source: function( request, response ) { + source: function (request, response) { $.ajax({ url: '/prod/push/search-user/', dataType: "json", data: { query: request.term }, - success: function( data ) { + success: function (data) { response(data); } }); }, - focus: function( event, ui ) { - $( 'input[name="users-search"]' ).val( ui.item.label ); + focus: function (event, ui) { + $('input[name="users-search"]').val(ui.item.label); }, - select: function( event, ui ) { - if(ui.item.type === 'USER') { + select: function (event, ui) { + if (ui.item.type === 'USER') { $this.selectUser(ui.item); - } else if(ui.item.type === 'LIST') { - for(var e in ui.item.entries) { + } else if (ui.item.type === 'LIST') { + for (var e in ui.item.entries) { $this.selectUser(ui.item.entries[e].User); } } return false; } }) - .data( "ui-autocomplete" )._renderItem = function( ul, item ) { + .data("ui-autocomplete")._renderItem = function (ul, item) { var html = ""; - if(item.type === 'USER') { + if (item.type === 'USER') { html = _.template($("#list_user_tpl").html(), { item: item }); - } else if(item.type === 'LIST') { + } else if (item.type === 'LIST') { html = _.template($("#list_list_tpl").html(), { item: item }); } - return $(html).data( "ui-autocomplete-item", item ).appendTo(ul); + return $(html).data("ui-autocomplete-item", item).appendTo(ul); }; return this; }; Feedback.prototype = { - selectUser : function(user){ - if(typeof user !== 'object') - { - if(window.console) - { + selectUser: function (user) { + if (typeof user !== 'object') { + if (window.console) { 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'); return; } - if(window.console) - { + if (window.console) { console.log('Selecting', user); } @@ -360,7 +345,7 @@ p4.Feedback.appendBadge(html); }, - loadUser : function(usr_id, callback) { + loadUser: function (usr_id, callback) { var $this = this; $.ajax({ @@ -368,35 +353,33 @@ url: '/prod/push/user/' + usr_id + '/', dataType: 'json', data: { - usr_id : usr_id + usr_id: usr_id }, - success: function(data){ - if(typeof callback === 'function') - { + success: function (data) { + if (typeof callback === 'function') { callback.call($this, data); } } }); }, - loadList : function(url, callback) { + loadList: function (url, callback) { var $this = this; $.ajax({ type: 'GET', url: url, dataType: 'json', - success: function(data){ - if(typeof callback === 'function') - { + success: function (data) { + if (typeof callback === 'function') { callback.call($this, data); } } }); }, - appendBadge : function(badge){ + appendBadge: function (badge) { $('.user_content .badges', this.container).append(badge); }, - addUser : function($form, callback){ + addUser: function ($form, callback) { var $this = this; @@ -405,50 +388,47 @@ url: '/prod/push/add-user/', dataType: 'json', data: $form.serializeArray(), - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); $this.selectUser(data.user); callback(); } - else - { + else { humane.error(data.message); } } }); }, - getSelection : function() { + getSelection: function () { return this.selection; }, - getUsers : function() { - return $('.user_content .badge', this.container).map(function(){ + getUsers: function () { + return $('.user_content .badge', this.container).map(function () { return $('input[name="id"]', $(this)).val(); }); } }; - - var ListManager = function($container) { + var ListManager = function ($container) { this.list = null; this.container = $container; - $('.back_link', this.container).bind('click', function(){ + $('.back_link', this.container).bind('click', function () { $('#PushBox').show(); $('#ListManager').hide(); return false; }); - $('a.list_sharer', this.container).die('click').live('click', function(){ + $('a.list_sharer', this.container).die('click').live('click', function () { var $this = $(this), options = { - size : 'Small', - closeButton : true, - title : $this.attr('title') + size: 'Small', + closeButton: true, + title: $this.attr('title') }, $dialog = p4.Dialog.Create(options, 2); @@ -458,7 +438,7 @@ }); - $('a.user_adder', this.container).bind('click', function(){ + $('a.user_adder', this.container).bind('click', function () { var $this = $(this); @@ -466,21 +446,22 @@ type: "GET", url: $this.attr('href'), dataType: 'html', - beforeSend:function(){ + beforeSend: function () { var options = { - size : 'Medium', - title : $this.html() + size: 'Medium', + title: $this.html() }; - p4.Dialog.Create(options, 2).getDomElement().addClass('loading'); }, - success: function(data){ + p4.Dialog.Create(options, 2).getDomElement().addClass('loading'); + }, + success: function (data) { p4.Dialog.get(2).getDomElement().removeClass('loading').empty().append(data); return; }, - error: function(){ + error: function () { p4.Dialog.get(2).Close(); return; }, - timeout: function(){ + timeout: function () { p4.Dialog.get(2).Close(); return; } @@ -490,11 +471,10 @@ }); + var initLeft = function () { + $('a.list_refresh', $container).bind('click', function (event) { - var initLeft = function() { - $('a.list_refresh', $container).bind('click', function(event){ - - var callback = function(datas){ + var callback = function (datas) { $('.all-lists', $container).removeClass('loading').append(datas); initLeft(); }; @@ -506,13 +486,13 @@ return false; }); - $('a.list_adder', $container).bind('click', function(event){ + $('a.list_adder', $container).bind('click', function (event) { var makeDialog = function (box) { var buttons = {}; - buttons[language.valider] = function() { + buttons[language.valider] = function () { var callbackOK = function () { $('a.list_refresh', $container).trigger('click'); @@ -521,8 +501,7 @@ var name = $('input[name="name"]', p4.Dialog.get(2).getDomElement()).val(); - if($.trim(name) === '') - { + if ($.trim(name) === '') { alert(language.listNameCannotBeEmpty); return; } @@ -531,9 +510,9 @@ }; var options = { - cancelButton : true, - buttons : buttons, - size:'Alert' + cancelButton: true, + buttons: buttons, + size: 'Alert' }; p4.Dialog.Create(options, 2).setContent(box); @@ -546,7 +525,7 @@ return false; }); - $('li.list a.list_link', $container).bind('click', function(event){ + $('li.list a.list_link', $container).bind('click', function (event) { var $this = $(this); @@ -557,11 +536,11 @@ type: 'GET', url: $this.attr('href'), dataType: 'html', - success: function(data){ + success: function (data) { $('.editor', $container).removeClass('loading').append(data); initRight(); }, - beforeSend: function(){ + beforeSend: function () { $('.editor', $container).empty().addClass('loading'); } }); @@ -570,11 +549,11 @@ }); }; - var initRight = function(){ + var initRight = function () { var $container = $('#ListManager .editor'); - $('form[name="list-editor-search"]', $container).bind('submit', function(){ + $('form[name="list-editor-search"]', $container).bind('submit', function () { var $this = $(this); var dest = $('.list-editor-results', $container); @@ -584,10 +563,10 @@ type: $this.attr('method'), dataType: "html", data: $this.serializeArray(), - beforeSend : function () { + beforeSend: function () { dest.empty().addClass('loading'); }, - success: function( datas ) { + success: function (datas) { dest.empty().removeClass('loading').append(datas); } @@ -595,20 +574,20 @@ return false; }); - $('form[name="list-editor-search"] select, form[name="list-editor-search"] input[name="ListUser"]', $container).bind('change', function(){ + $('form[name="list-editor-search"] select, form[name="list-editor-search"] input[name="ListUser"]', $container).bind('change', function () { $(this).closest('form').trigger('submit'); }); - $('.EditToggle', $container).bind('click', function(){ + $('.EditToggle', $container).bind('click', function () { $('.content.readonly, .content.readwrite', $('#ListManager')).toggle(); return false; }); - $('.Refresher', $container).bind('click', function(){ + $('.Refresher', $container).bind('click', function () { $('#ListManager ul.lists .list.selected a').trigger('click'); return false; }); - $('form[name="SaveName"]', $container).bind('submit', function(){ + $('form[name="SaveName"]', $container).bind('submit', function () { var $this = $(this); $.ajax({ @@ -616,26 +595,24 @@ url: $this.attr('action'), dataType: 'json', data: $this.serializeArray(), - beforeSend:function(){ + beforeSend: function () { }, - success: function(data){ - if(data.success) - { + success: function (data) { + if (data.success) { humane.info(data.message); $('#ListManager .lists .list_refresh').trigger('click'); } - else - { + else { humane.error(data.message); } return; }, - error: function(){ + error: function () { return; }, - timeout: function(){ + timeout: function () { return; } @@ -645,7 +622,7 @@ }); - $('button.deleter', $container).bind('click', function(event){ + $('button.deleter', $container).bind('click', function (event) { var list_id = $(this).find('input[name=list_id]').val(); @@ -653,7 +630,7 @@ var buttons = {}; - buttons[language.valider] = function() { + buttons[language.valider] = function () { var callbackOK = function () { $('#ListManager .all-lists a.list_refresh').trigger('click'); @@ -665,9 +642,9 @@ }; var options = { - cancelButton : true, - buttons : buttons, - size:'Alert' + cancelButton: true, + buttons: buttons, + size: 'Alert' }; p4.Dialog.Create(options, 2).setContent(box); @@ -683,15 +660,15 @@ initLeft(); - $('.badges a.deleter', this.container).live('click', function(){ + $('.badges a.deleter', this.container).live('click', function () { var badge = $(this).closest('.badge'); var usr_id = badge.find('input[name="id"]').val(); - var callback = function(list, datas){ - $('.counter.current, .list.selected .counter', $('#ListManager')).each(function(){ + var callback = function (list, datas) { + $('.counter.current, .list.selected .counter', $('#ListManager')).each(function () { $(this).text(parseInt($(this).text()) - 1); }); @@ -706,19 +683,18 @@ }; ListManager.prototype = { - workOn : function(list_id) { + workOn: function (list_id) { this.list = new document.List(list_id); }, - getList : function(){ + getList: function () { return this.list; }, - appendBadge : function(datas) { + appendBadge: function (datas) { $('#ListManager .badges').append(datas); } }; - window.Feedback = Feedback; window.ListManager = ListManager; diff --git a/www/skins/prod/jquery.Prod.js b/www/skins/prod/jquery.Prod.js index a92976cb91..9596dd3321 100644 --- a/www/skins/prod/jquery.Prod.js +++ b/www/skins/prod/jquery.Prod.js @@ -1,9 +1,9 @@ -(function() { - $(document).ready(function() { +(function () { + $(document).ready(function () { humane.info = humane.spawn({addnCls: 'humane-libnotify-info', timeout: 1000}); humane.error = humane.spawn({addnCls: 'humane-libnotify-error', timeout: 1000}); - $('a.dialog').live('click', function(event) { + $('a.dialog').live('click', function (event) { var $this = $(this), size = 'Medium'; if ($this.hasClass('small-dialog')) { @@ -25,7 +25,7 @@ type: "GET", url: $this.attr('href'), dataType: 'html', - success: function(data) { + success: function (data) { $dialog.setContent(data); return; } diff --git a/www/skins/prod/jquery.Results.js b/www/skins/prod/jquery.Results.js index 706acd3fb5..dbbb063b41 100644 --- a/www/skins/prod/jquery.Results.js +++ b/www/skins/prod/jquery.Results.js @@ -1,21 +1,21 @@ var p4 = p4 || {}; -(function(p4, window){ +(function (p4, window) { p4.Results = { - 'Selection':new Selectable($('#answers'), { - selector : '.IMGT', - limit:800, - selectStart:function(event, selection){ + 'Selection': new Selectable($('#answers'), { + selector: '.IMGT', + limit: 800, + selectStart: function (event, selection) { $('#answercontextwrap table:visible').hide(); }, - selectStop:function(event, selection){ + selectStop: function (event, selection) { viewNbSelect(); }, - callbackSelection:function(element){ + callbackSelection: function (element) { var elements = $(element).attr('id').split('_'); - return elements.slice(elements.length - 2 ,elements.length).join('_'); + return elements.slice(elements.length - 2, elements.length).join('_'); } }) }; diff --git a/www/skins/prod/jquery.Upload.js b/www/skins/prod/jquery.Upload.js index 4cb9c3988e..99853bf7eb 100644 --- a/www/skins/prod/jquery.Upload.js +++ b/www/skins/prod/jquery.Upload.js @@ -2,40 +2,40 @@ var p4 = p4 || {}; ; -(function(p4, $){ +(function (p4, $) { /** * UPLOADER MANAGER */ - var UploaderManager = function(options){ + var UploaderManager = function (options) { var options = options || {}; - if(false === ("container" in options)){ + if (false === ("container" in options)) { throw "missing container parameter"; } - else if(! options.container.jquery){ + else if (!options.container.jquery) { throw "container parameter must be a jquery dom element"; } - if(false === ("settingsBox" in options)){ + if (false === ("settingsBox" in options)) { throw "missing settingBox parameter"; } - else if(! options.settingsBox.jquery){ + else if (!options.settingsBox.jquery) { throw "container parameter must be a jquery dom element"; } - if(false === ("uploadBox" in options)){ + if (false === ("uploadBox" in options)) { throw "missing uploadBox parameter"; } - else if(! options.uploadBox.jquery){ + else if (!options.uploadBox.jquery) { throw "container parameter must be a jquery dom element"; } - if(false === ("downloadBox" in options)){ + if (false === ("downloadBox" in options)) { throw "missing downloadBox parameter"; } - else if(! options.downloadBox.jquery){ + else if (!options.downloadBox.jquery) { throw "container parameter must be a jquery dom element"; } @@ -51,7 +51,7 @@ var p4 = p4 || {}; this.options.downloadBox = this.options.downloadBox.find('ul:first'); - if($.isFunction($.fn.sortable)){ + if ($.isFunction($.fn.sortable)) { this.options.uploadBox.sortable(); } @@ -63,54 +63,54 @@ var p4 = p4 || {}; }; UploaderManager.prototype = { - setOptions : function(options){ + setOptions: function (options) { return $.extend(this.options, options); }, - getContainer : function(){ + getContainer: function () { return this.options.container; }, - getUploadBox : function(){ + getUploadBox: function () { return this.options.uploadBox; }, - getSettingsBox : function(){ + getSettingsBox: function () { return this.options.settingsBox; }, - getDownloadBox : function(){ + getDownloadBox: function () { return this.options.downloadBox; }, - clearUploadBox: function(){ + clearUploadBox: function () { this.getUploadBox().empty(); this.uploadIndex = 0; this.Queue.clear(); }, - getDatas : function(){ + getDatas: function () { return this.Queue.all(); }, - getData : function(index){ + getData: function (index) { return this.Queue.get(index); }, - addData: function(data){ + addData: function (data) { this.uploadIndex++; data.uploadIndex = this.uploadIndex; this.Queue.set(this.uploadIndex, data); }, - removeData : function(index){ + removeData: function (index) { this.Queue.remove(index); }, - addAttributeToData : function(indexOfData, attribute, value){ + addAttributeToData: function (indexOfData, attribute, value) { var data = this.getData(indexOfData); - if($.type(attribute) === "string"){ + if ($.type(attribute) === "string") { data[attribute] = value; this.Queue.set(indexOfData, data); } }, - getUploadIndex : function(){ + getUploadIndex: function () { return this.uploadIndex; }, - hasData : function(){ + hasData: function () { return !this.Queue.isEmpty(); }, - countData: function (){ + countData: function () { return this.Queue.getLength(); } }; @@ -130,29 +130,29 @@ var p4 = p4 || {}; * canva: (boolean) render preview as canva if supported by the navigator */ - var Preview = function(){ + var Preview = function () { this.options = { fileType: /^image\/(gif|jpeg|png|jpg)$/, - maxSize : 5242880 // 5MB + maxSize: 5242880 // 5MB }; }; Preview.prototype = { - setOptions: function(options){ + setOptions: function (options) { this.options = $.extend(this.options, options); }, - getOptions: function(){ + getOptions: function () { return this.options; }, - render: function(file, callback){ - if(typeof loadImage === 'function' && this.options.fileType.test(file.type)){ - if($.type(this.options.maxSize) !== 'number' || file.size < this.options.maxSize){ + render: function (file, callback) { + if (typeof loadImage === 'function' && this.options.fileType.test(file.type)) { + if ($.type(this.options.maxSize) !== 'number' || file.size < this.options.maxSize) { var options = { maxWidth: this.options.maxWidth || 150, maxHeight: this.options.maxHeight || 75, minWidth: this.options.minWidth || 80, minHeight: this.options.minHeight || 40, - canvas : this.options.canva || true + canvas: this.options.canva || true }; loadImage(file, callback, options); } @@ -165,7 +165,7 @@ var p4 = p4 || {}; * FORMATER */ - var Formater = function(){ + var Formater = function () { }; @@ -200,50 +200,50 @@ var p4 = p4 || {}; } return bytes + ' o/s'; }, - pourcent: function(current, total){ - return (current/ total * 100).toFixed(2); + pourcent: function (current, total) { + return (current / total * 100).toFixed(2); } }; /** * QUEUE */ - var Queue = function(){ + var Queue = function () { this.list = {}; }; Queue.prototype = { - all : function(){ + all: function () { return this.list; }, - set : function(id, item){ + set: function (id, item) { this.list[id] = item; return this; }, - get : function(id){ - if(!this.list[id]){ + get: function (id) { + if (!this.list[id]) { throw 'Unknown ID' + id; } return this.list[id]; }, - remove : function(id) { + remove: function (id) { delete this.list[id]; }, - getLength : function(){ + getLength: function () { var count = 0; - for (var k in this.list){ - if (this.list.hasOwnProperty(k)){ + for (var k in this.list) { + if (this.list.hasOwnProperty(k)) { ++count; } } return count; }, - isEmpty: function(){ + isEmpty: function () { return this.getLength() === 0; }, - clear: function(){ + clear: function () { var $this = this; - $.each(this.list, function(k){ + $.each(this.list, function (k) { $this.remove(k); }); } diff --git a/www/skins/prod/jquery.WorkZone.js b/www/skins/prod/jquery.WorkZone.js index f97508dee8..63a137dee9 100644 --- a/www/skins/prod/jquery.WorkZone.js +++ b/www/skins/prod/jquery.WorkZone.js @@ -1,8 +1,7 @@ var p4 = p4 || {}; -(function(p4) { - function refreshBaskets(baskId, sort, scrolltobottom, type) - { +(function (p4) { + function refreshBaskets(baskId, sort, scrolltobottom, type) { type = typeof type === 'undefined' ? 'basket' : type; var active = $('#baskets .SSTT.ui-state-active'); @@ -19,12 +18,12 @@ var p4 = p4 || {}; data: { id: baskId, sort: sort, - type:type + type: type }, - beforeSend: function() { + beforeSend: function () { $('#basketcontextwrap').remove(); }, - success: function(data) { + success: function (data) { var cache = $("#idFrameC #baskets"); if ($(".SSTT", cache).data("ui-droppable")) { @@ -53,8 +52,7 @@ var p4 = p4 || {}; }); } - function setTemporaryPref(name, value) - { + function setTemporaryPref(name, value) { $.ajax({ type: "POST", url: "/user/preferences/temporary/", @@ -62,13 +60,13 @@ var p4 = p4 || {}; prop: name, value: value }, - success: function(data) { + success: function (data) { return; } }); } - $("#baskets div.content select[name=valid_ord]").live('change', function() { + $("#baskets div.content select[name=valid_ord]").live('change', function () { var active = $('#baskets .SSTT.ui-state-active'); if (active.length === 0) { return; @@ -79,19 +77,18 @@ var p4 = p4 || {}; getContent(active, order); }); - function WorkZoneElementRemover(el, confirm) - { + function WorkZoneElementRemover(el, confirm) { var context = el.data('context'); if (confirm !== true && $(el).hasClass('groupings') && p4.reg_delete) { var buttons = {}; - buttons[language.valider] = function() { + buttons[language.valider] = function () { $("#DIALOG-baskets").dialog('close').remove(); WorkZoneElementRemover(el, true); }; - buttons[language.annuler] = function() { + buttons[language.annuler] = function () { $("#DIALOG-baskets").dialog('close').remove(); }; @@ -121,10 +118,10 @@ var p4 = p4 || {}; type: "POST", url: $(el).attr('href'), dataType: 'json', - beforeSend: function() { + beforeSend: function () { $('.wrapCHIM_' + id).find('.CHIM').fadeOut(); }, - success: function(data) { + success: function (data) { if (data.success) { humane.info(data.message); p4.WorkZone.Selection.remove(id); @@ -153,7 +150,7 @@ var p4 = p4 || {}; } else if (carouselItemLength > 1) { // click next item selectedItem.next().find("img").trigger("click"); - } else { + } else { closePreview(); } @@ -170,8 +167,7 @@ var p4 = p4 || {}; } - function activeBaskets() - { + function activeBaskets() { var cache = $("#idFrameC #baskets"); cache.accordion({ @@ -179,7 +175,7 @@ var p4 = p4 || {}; heightStyle: "content", collapsible: true, header: 'div.header', - activate: function(event, ui) { + activate: function (event, ui) { var b_active = $('#baskets .SSTT.active'); if (p4.next_bask_scroll) { p4.next_bask_scroll = false; @@ -200,7 +196,8 @@ var p4 = p4 || {}; b_active.not('.ui-state-active').removeClass('active'); if (uiactive.length === 0) { - return; /* everything is closed */ + return; + /* everything is closed */ } uiactive.addClass('ui-state-focus active'); @@ -210,14 +207,14 @@ var p4 = p4 || {}; getContent(uiactive); }, - beforeActivate: function(event, ui) { + beforeActivate: function (event, ui) { ui.newHeader.addClass('active'); $('#basketcontextwrap .basketcontextmenu').hide(); } }); $('.bloc', cache).droppable({ - accept: function(elem) { + accept: function (elem) { if ($(elem).hasClass('grouping') && !$(elem).hasClass('SSTT')) return true; return false; @@ -225,7 +222,7 @@ var p4 = p4 || {}; scope: 'objects', hoverClass: 'groupDrop', tolerance: 'pointer', - drop: function() { + drop: function () { fix(); } }); @@ -240,8 +237,8 @@ var p4 = p4 || {}; scope: 'objects', hoverClass: 'baskDrop', tolerance: 'pointer', - accept: function(elem) { - if ($(elem).hasClass('CHIM')) { + accept: function (elem) { + if ($(elem).hasClass('CHIM')) { if ($(elem).closest('.content').prev()[0] === $(this)[0]) { return false; } @@ -250,7 +247,7 @@ var p4 = p4 || {}; return false; return true; }, - drop: function(event, ui) { + drop: function (event, ui) { dropOnBask(event, ui.draggable, $(this)); } }); @@ -258,12 +255,12 @@ var p4 = p4 || {}; if ($('#basketcontextwrap').length === 0) $('body').append('
'); - $('.context-menu-item', cache).hover(function() { + $('.context-menu-item', cache).hover(function () { $(this).addClass('context-menu-item-hover'); - }, function() { + }, function () { $(this).removeClass('context-menu-item-hover'); }); - $.each($(".SSTT", cache), function() { + $.each($(".SSTT", cache), function () { var el = $(this); $(this).find('.contextMenuTrigger').contextMenu('#' + $(this).attr('id') + ' .contextMenu', { 'appendTo': '#basketcontextwrap', @@ -278,9 +275,8 @@ var p4 = p4 || {}; } - function getContent(header, order) - { - if (window.console) { + function getContent(header, order) { + if (window.console) { console.log('Reload content for ', header); } @@ -294,11 +290,11 @@ var p4 = p4 || {}; type: "GET", url: url, dataType: 'html', - beforeSend: function() { + beforeSend: function () { $('#tooltip').hide(); header.next().addClass('loading'); }, - success: function(data) { + success: function (data) { header.removeClass('unread'); var dest = header.next(); @@ -309,14 +305,14 @@ var p4 = p4 || {}; dest.append(data); - $('a.WorkZoneElementRemover', dest).bind('mousedown', function(event) { + $('a.WorkZoneElementRemover', dest).bind('mousedown',function (event) { return false; - }).bind('click', function(event) { + }).bind('click', function (event) { return WorkZoneElementRemover($(this), false); }); dest.droppable({ - accept: function(elem) { + accept: function (elem) { if ($(elem).hasClass('CHIM')) { if ($(elem).closest('.content')[0] === $(this)[0]) { return false; @@ -328,7 +324,7 @@ var p4 = p4 || {}; }, hoverClass: 'baskDrop', scope: 'objects', - drop: function(event, ui) { + drop: function (event, ui) { dropOnBask(event, ui.draggable, $(this).prev()); }, tolerance: 'pointer' @@ -337,7 +333,7 @@ var p4 = p4 || {}; $('.noteTips, .captionRolloverTips', dest).tooltip(); dest.find('.CHIM').draggable({ - helper: function() { + helper: function () { $('body').append('
' + @@ -353,23 +349,23 @@ var p4 = p4 || {}; top: 10, left: -20 }, - start: function(event, ui) { + start: function (event, ui) { var baskets = $('#baskets'); baskets.append('
' + '
'); - $('.bottom-scroller', baskets).bind('mousemove', function() { + $('.bottom-scroller', baskets).bind('mousemove', function () { $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop() + 30); }); - $('.top-scroller', baskets).bind('mousemove', function() { + $('.top-scroller', baskets).bind('mousemove', function () { $('#baskets .bloc').scrollTop($('#baskets .bloc').scrollTop() - 30); }); }, - stop: function() { + stop: function () { $('#baskets').find('.top-scroller, .bottom-scroller') .unbind() .remove(); }, - drag: function(event, ui) { + drag: function (event, ui) { if (is_ctrl_key(event) || $(this).closest('.content').hasClass('grouping')) $('#dragDropCursor div').empty().append('+ ' + p4.WorkZone.Selection.length()); else @@ -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"; if (from.hasClass("CHIM")) { @@ -422,7 +417,7 @@ var p4 = p4 || {}; lstbr = p4.Results.Selection.get(); } } else { - sselcont = $.map(p4.WorkZone.Selection.get(), function(n, i) { + sselcont = $.map(p4.WorkZone.Selection.get(), function (n, i) { return $('.CHIM_' + n, $('#baskets .content:visible')).attr('id').split('_').slice(1, 2).pop(); }); lstbr = p4.WorkZone.Selection.get(); @@ -486,10 +481,10 @@ var p4 = p4 || {}; url: url, data: data, dataType: 'json', - beforeSend: function() { + beforeSend: function () { }, - success: function(data) { + success: function (data) { if (!data.success) { humane.error(data.message); } else { @@ -506,37 +501,35 @@ var p4 = p4 || {}; }); } - function fix() - { + function fix() { $.ajax({ type: "POST", url: "../prod/WorkZone/attachStories/", data: {stories: p4.Results.Selection.get()}, dataType: "json", - success: function(data) { + success: function (data) { humane.info(data.message); p4.WorkZone.refresh(); } }); } - function unfix(link) - { + function unfix(link) { $.ajax({ type: "POST", url: link, dataType: "json", - success: function(data) { + success: function (data) { humane.info(data.message); p4.WorkZone.refresh(); } }); } - $(document).ready(function() { + $(document).ready(function () { activeBaskets(); - $('a.story_unfix').live('click', function() { + $('a.story_unfix').live('click', function () { unfix($(this).attr('href')); return false; @@ -545,7 +538,7 @@ var p4 = p4 || {}; p4.WorkZone = { 'Selection': new Selectable($('#baskets'), {selector: '.CHIM'}), 'refresh': refreshBaskets, - 'addElementToBasket': function(sbas_id, record_id, event, singleSelection) { + 'addElementToBasket': function (sbas_id, record_id, event, singleSelection) { singleSelection = !!singleSelection || false; if ($('#baskets .SSTT.active').length === 1) { @@ -554,27 +547,26 @@ var p4 = p4 || {}; humane.info(language.noActiveBasket); } }, - "removeElementFromBasket": WorkZoneElementRemover, - 'reloadCurrent': function() { + "removeElementFromBasket": WorkZoneElementRemover, + 'reloadCurrent': function () { var sstt = $('#baskets .content:visible'); if (sstt.length === 0) return; getContent(sstt.prev()); }, - 'close': function() { + 'close': function () { var frame = $('#idFrameC'), that = this; - if (!frame.hasClass('closed')) - { + if (!frame.hasClass('closed')) { // hide tabs content var activeTabIdx = $('#idFrameC .tabs').tabs("option", "active"); - $('#idFrameC .tabs > div:eq('+activeTabIdx+')').hide(); + $('#idFrameC .tabs > div:eq(' + activeTabIdx + ')').hide(); frame.data('openwidth', frame.width()); frame.animate({width: 100}, 300, 'linear', - function() { + function () { answerSizer(); linearize(); $('#answers').trigger('resize'); @@ -582,16 +574,15 @@ var p4 = p4 || {}; frame.addClass('closed'); $('.escamote', frame).hide(); $('li.ui-tabs-selected', frame).removeClass('ui-tabs-selected'); - frame.unbind('click.escamote').bind('click.escamote', function() { + frame.unbind('click.escamote').bind('click.escamote', function () { that.open(); }); } }, - 'open': function() { + 'open': function () { var frame = $('#idFrameC'); - if (frame.hasClass('closed')) - { + if (frame.hasClass('closed')) { var width = frame.data('openwidth') ? frame.data('openwidth') : 300; frame.css({width: width}); answerSizer(); @@ -601,7 +592,7 @@ var p4 = p4 || {}; frame.unbind('click.escamote'); // show tabs content var activeTabIdx = $('#idFrameC .tabs').tabs("option", "active"); - $('#idFrameC .tabs > div:eq('+activeTabIdx+')').show(); + $('#idFrameC .tabs > div:eq(' + activeTabIdx + ')').show(); } } }; diff --git a/www/skins/prod/jquery.edit.js b/www/skins/prod/jquery.edit.js index d5e07f26a1..5f2ac50e0e 100644 --- a/www/skins/prod/jquery.edit.js +++ b/www/skins/prod/jquery.edit.js @@ -1,5 +1,4 @@ -function initializeEdit() -{ +function initializeEdit() { p4.edit = {}; p4.edit.curField = "?"; p4.edit.editBox = $('#idFrameE'); @@ -13,45 +12,41 @@ function initializeEdit() p4.edit.ssel = false; } -$(document).ready(function(){ - $(window).bind('resize',function(){ +$(document).ready(function () { + $(window).bind('resize', function () { setPreviewEdit(); setSizeLimits(); }); }); -function setSizeLimits() -{ - if(!$('#EDITWINDOW').is(':visible')) +function setSizeLimits() { + if (!$('#EDITWINDOW').is(':visible')) return; if ($('#EDIT_TOP').data("ui-resizable")) { - $('#EDIT_TOP').resizable('option','maxHeight', ($('#EDIT_ALL').height() - $('#buttonEditing').height() - 10 - 160)); + $('#EDIT_TOP').resizable('option', 'maxHeight', ($('#EDIT_ALL').height() - $('#buttonEditing').height() - 10 - 160)); } if ($('#divS_wrapper').data("ui-resizable")) { - $('#divS_wrapper').resizable('option','maxWidth', ($('#EDIT_MID_L').width() - 270)); + $('#divS_wrapper').resizable('option', 'maxWidth', ($('#EDIT_MID_L').width() - 270)); } if ($('#EDIT_MID_R').data("ui-resizable")) { - $('#EDIT_MID_R').resizable('option','maxWidth', ($('#EDIT_MID_R').width() + $('#idEditZone').width() - 240)); + $('#EDIT_MID_R').resizable('option', 'maxWidth', ($('#EDIT_MID_R').width() + $('#idEditZone').width() - 240)); } } -function edit_kdwn(evt, src) -{ +function edit_kdwn(evt, src) { cancelKey = false; - switch(evt.keyCode) - { + switch (evt.keyCode) { case 13: case 10: - if(p4.edit.T_fields[p4.edit.curField].type == "date") + if (p4.edit.T_fields[p4.edit.curField].type == "date") cancelKey = true; } - if(cancelKey) - { + if (cancelKey) { evt.cancelBubble = true; - if(evt.stopPropagation) + if (evt.stopPropagation) evt.stopPropagation(); return(false); } @@ -61,32 +56,27 @@ function edit_kdwn(evt, src) // ---------------------------------------------------------------------------------------------- // des events sur le textarea pour tracker la selection (chercher dans le thesaurus...) // ---------------------------------------------------------------------------------------------- -function edit_mdwn_ta(evt) -{ +function edit_mdwn_ta(evt) { evt.cancelBubble = true; return(true); } // mouse up textarea -function edit_mup_ta(evt, obj) -{ +function edit_mup_ta(evt, obj) { - if(p4.edit.T_fields[p4.edit.curField].tbranch) - { - if(obj.value != "") + if (p4.edit.T_fields[p4.edit.curField].tbranch) { + if (obj.value != "") ETHSeeker.search(obj.value); } return(true); } // key up textarea -function edit_kup_ta(evt, obj) -{ +function edit_kup_ta(evt, obj) { var cancelKey = false; var o; - switch(evt.keyCode) - { + switch (evt.keyCode) { case 27: // esc : on restore la valeur avant editing // $("#btn_cancel", p4.edit.editBox).parent().css("backgroundColor", "#000000"); edit_validField(evt, "cancel"); @@ -95,22 +85,19 @@ function edit_kup_ta(evt, obj) break; } - if(cancelKey) - { + if (cancelKey) { evt.cancelBubble = true; - if(evt.stopPropagation) + if (evt.stopPropagation) evt.stopPropagation(); return(false); } - if(!p4.edit.textareaIsDirty && ($("#idEditZTextArea", p4.edit.editBox).val() != p4.edit.fieldLastValue)) - { + if (!p4.edit.textareaIsDirty && ($("#idEditZTextArea", p4.edit.editBox).val() != p4.edit.fieldLastValue)) { p4.edit.textareaIsDirty = true; } var s = obj.value; - if(p4.edit.T_fields[p4.edit.curField].tbranch) - { - if(s != "") + if (p4.edit.T_fields[p4.edit.curField].tbranch) { + if (s != "") ETHSeeker.search(s); } return(true); @@ -119,12 +106,11 @@ function edit_kup_ta(evt, obj) // --------------------------------------------------------------------------- // on a clique sur le peudo champ 'status' // --------------------------------------------------------------------------- -function edit_mdwn_status(evt) -{ - if(!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok")==true) +function edit_mdwn_status(evt) { + if (!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok") == true) editStatus(evt); evt.cancelBubble = true; - if(evt.stopPropagation) + if (evt.stopPropagation) evt.stopPropagation(); return(false); } @@ -132,31 +118,25 @@ function edit_mdwn_status(evt) // --------------------------------------------------------------------------- // on a clique sur un champ // --------------------------------------------------------------------------- -function edit_mdwn_fld(evt, meta_struct_id, fieldname) -{ - if(!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok")==true) +function edit_mdwn_fld(evt, meta_struct_id, fieldname) { + if (!p4.edit.textareaIsDirty || edit_validField(evt, "ask_ok") == true) editField(evt, meta_struct_id); } // --------------------------------------------------------------------------- // change de champ (avec les fleches autour du nom champ) // --------------------------------------------------------------------------- -function edit_chgFld(evt, dir) -{ +function edit_chgFld(evt, dir) { var current_field = $('#divS .edit_field.active'); - if(current_field.length == 0) - { + if (current_field.length == 0) { current_field = $('#divS .edit_field:first'); current_field.trigger('click'); } - else - { - if(dir >= 0) - { + else { + if (dir >= 0) { current_field.next().trigger('click'); } - else - { + else { current_field.prev().trigger('click'); } } @@ -165,14 +145,13 @@ function edit_chgFld(evt, dir) // --------------------------------------------------------------------------- // on active le pseudo champ 'status' // --------------------------------------------------------------------------- -function editStatus(evt) -{ +function editStatus(evt) { $(".editDiaButtons", p4.edit.editBox).hide(); document.getElementById('idEditZTextArea').blur(); document.getElementById('EditTextMultiValued').blur(); - $("#idFieldNameEdit", p4.edit.editBox).html("[STATUS]") ; + $("#idFieldNameEdit", p4.edit.editBox).html("[STATUS]"); $("#idExplain", p4.edit.editBox).html(" "); $("#ZTextMultiValued", p4.edit.editBox).hide(); @@ -186,20 +165,18 @@ function editStatus(evt) activeField(); } -function activeField() -{ +function activeField() { var meta_struct_id = parseInt(p4.edit.curField); - meta_struct_id = (isNaN(meta_struct_id) || meta_struct_id <0)?'status':meta_struct_id; + meta_struct_id = (isNaN(meta_struct_id) || meta_struct_id < 0) ? 'status' : meta_struct_id; $('#divS div.active, #divS div.hover').removeClass('active hover'); - $('#EditFieldBox_'+meta_struct_id).addClass('active'); + $('#EditFieldBox_' + meta_struct_id).addClass('active'); var cont = $('#divS'); - var calc = $('#EditFieldBox_'+meta_struct_id).offset().top - cont.offset().top;// hauteur relative par rapport au visible + var calc = $('#EditFieldBox_' + meta_struct_id).offset().top - cont.offset().top;// hauteur relative par rapport au visible - if(calc > cont.height() || calc <0) - { + if (calc > cont.height() || calc < 0) { cont.scrollTop(calc + cont.scrollTop()); } } @@ -208,8 +185,7 @@ function activeField() //// on change de champ courant //// --------------------------------------------------------------------------- -function editField(evt, meta_struct_id) -{ +function editField(evt, meta_struct_id) { document.getElementById('idEditZTextArea').blur(); document.getElementById('EditTextMultiValued').blur(); $(".editDiaButtons", p4.edit.editBox).hide(); @@ -217,16 +193,15 @@ function editField(evt, meta_struct_id) $('#idEditZTextArea, #EditTextMultiValued').unbind('keyup.maxLength'); p4.edit.curField = meta_struct_id; - if(meta_struct_id >= 0) - { + if (meta_struct_id >= 0) { var name = p4.edit.T_fields[meta_struct_id].label + (p4.edit.T_fields[meta_struct_id].required ? ' * ' : ''); - $("#idFieldNameEdit", p4.edit.editBox).html(name) ; + $("#idFieldNameEdit", p4.edit.editBox).html(name); var vocabType = p4.edit.T_fields[meta_struct_id].vocabularyControl; $('#idEditZTextArea, #EditTextMultiValued').autocomplete({ minLength: 2, - source: function( request, response ) { + source: function (request, response) { $.ajax({ url: '../prod/records/edit/vocabulary/' + vocabType + '/', dataType: "json", @@ -234,12 +209,12 @@ function editField(evt, meta_struct_id) sbas_id: p4.edit.sbas_id, query: request.term }, - success: function( data ) { - response( data.results ); + success: function (data) { + response(data.results); } }); }, - select: function( event, ui ) { + select: function (event, ui) { edit_addmval(ui.item.label, ui.item.id); @@ -248,34 +223,29 @@ function editField(evt, meta_struct_id) }); - if(p4.edit.T_fields[meta_struct_id].maxLength > 0) - { + if (p4.edit.T_fields[meta_struct_id].maxLength > 0) { var idexplain = $("#idExplain"); idexplain.html(''); - $('#idEditZTextArea, #EditTextMultiValued').bind('keyup.maxLength', function(){ + $('#idEditZTextArea, #EditTextMultiValued').bind('keyup.maxLength',function () { var remaining = Math.max((p4.edit.T_fields[meta_struct_id].maxLength - $(this).val().length), 0); - idexplain.html(" Caracteres restants : "+(remaining)+""); + idexplain.html(" Caracteres restants : " + (remaining) + ""); $('.metadatas_restrictionsTips', idexplain).tooltip(); }).trigger('keyup.maxLength'); } - else - { + else { $("#idExplain").html(""); } - if(!p4.edit.T_fields[meta_struct_id].multi) - { + if (!p4.edit.T_fields[meta_struct_id].multi) { // champ monovalue : textarea $(".editDiaButtons", p4.edit.editBox).hide(); - if(p4.edit.T_fields[meta_struct_id].type == "date") - { + if (p4.edit.T_fields[meta_struct_id].type == "date") { $("#idEditZTextArea", p4.edit.editBox).css("height", "16px"); $("#idEditDateZone", p4.edit.editBox).show(); } - else - { + else { $("#idEditDateZone", p4.edit.editBox).hide(); $("#idEditZTextArea", p4.edit.editBox).css("height", "100%"); } @@ -284,29 +254,25 @@ function editField(evt, meta_struct_id) $("#ZTextMultiValued", p4.edit.editBox).hide(); $("#ZTextMonoValued", p4.edit.editBox).show(); - if(p4.edit.T_fields[meta_struct_id]._status == 2) - { + if (p4.edit.T_fields[meta_struct_id]._status == 2) { // heterogene - $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue = "") ; + $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue = ""); $("#idEditZTextArea", p4.edit.editBox).addClass("hetero"); $("#idDivButtons", p4.edit.editBox).show(); // valeurs h�t�rog�nes : les 3 boutons remplacer/ajouter/annuler } - else - { + else { // homogene $("#idEditZTextArea", p4.edit.editBox).val(p4.edit.fieldLastValue = p4.edit.T_fields[meta_struct_id]._value); $("#idEditZTextArea", p4.edit.editBox).removeClass("hetero"); $("#idDivButtons", p4.edit.editBox).hide(); // valeurs homog�nes - if(p4.edit.T_fields[meta_struct_id].type == "date") - { + if (p4.edit.T_fields[meta_struct_id].type == "date") { var v = p4.edit.T_fields[meta_struct_id]._value.split(' '); d = v[0].split('/'); var dateObj = new Date(); - if(d.length == 3) - { + if (d.length == 3) { dateObj.setYear(d[0]); - dateObj.setMonth((d[1]-1)); + dateObj.setMonth((d[1] - 1)); dateObj.setDate(d[2]); } @@ -323,8 +289,7 @@ function editField(evt, meta_struct_id) self.setTimeout("document.getElementById('idEditZTextArea').focus();", 50); } - else - { + else { // champ multivalue : liste $("#ZTextStatus", p4.edit.editBox).hide(); $("#ZTextMonoValued", p4.edit.editBox).hide(); @@ -344,8 +309,7 @@ function editField(evt, meta_struct_id) // reveal_mval(); } } - else - { + else { // pas de champ, masquer la zone du textarea $("#idEditZone", p4.edit.editBox).hide(); $(".editDiaButtons", p4.edit.editBox).hide(); @@ -354,38 +318,34 @@ function editField(evt, meta_struct_id) activeField(); } -function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) -{ +function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) { // on compare toutes les valeurs de chaque fiche selectionnee p4.edit.T_mval = []; // tab des mots, pour trier var a = []; // key : mot ; val : nbr d'occurences distinctes var n = 0; // le nbr de records selectionnes - for(r in p4.edit.T_records) - { - if(!p4.edit.T_records[r]._selected) + for (r in p4.edit.T_records) { + if (!p4.edit.T_records[r]._selected) continue; p4.edit.T_records[r].fields[meta_struct_id].sort(SortCompareMetas); var values = p4.edit.T_records[r].fields[meta_struct_id].getValues(); - for(v in values) - { + for (v in values) { var word = values[v].getValue(); var key = values[v].getVocabularyId() + '%' + word; - if(typeof(a[key]) == 'undefined') - { + if (typeof(a[key]) == 'undefined') { a[key] = { - 'n':0, - 'f':new Array() + 'n': 0, + 'f': new Array() }; // n:nbr d'occurences DISTINCTES du mot ; f:flag presence mot dans r p4.edit.T_mval.push(values[v]); } - if(!a[key].f[r]) + if (!a[key].f[r]) a[key].n++; // premiere apparition du mot dans le record r a[key].f[r] = true; // on ne recomptera pas le mot s'il apparait a nouveau dans le meme record @@ -397,7 +357,7 @@ function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) p4.edit.T_mval.sort(SortCompareMetas); var t = ""; - for(var i in p4.edit.T_mval) // pour lire le tableau 'a' dans l'ordre trie par 'p4.edit.T_mval' + for (var i in p4.edit.T_mval) // pour lire le tableau 'a' dans l'ordre trie par 'p4.edit.T_mval' { var value = p4.edit.T_mval[i]; var word = value.getValue(); @@ -405,22 +365,18 @@ function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) var extra = value.getVocabularyId() ? ' ' : ''; - if(i>0) - { - if(value.getVocabularyId() !== null && p4.edit.T_mval[i-1].getVocabularyId() == value.getVocabularyId()) - { + if (i > 0) { + if (value.getVocabularyId() !== null && p4.edit.T_mval[i - 1].getVocabularyId() == value.getVocabularyId()) { continue; } - if(value.getVocabularyId() === null && p4.edit.T_mval[i-1].getVocabularyId() === null) - { - if(p4.edit.T_mval[i-1].getValue() == value.getValue()) - { + if (value.getVocabularyId() === null && p4.edit.T_mval[i - 1].getVocabularyId() === null) { + if (p4.edit.T_mval[i - 1].getValue() == value.getValue()) { continue; // on n'accepte pas les doublons } } } - t += "
" + '
' @@ -435,7 +391,7 @@ function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) } $('#ZTextMultiValued_values', p4.edit.editBox).html(t); - $('#ZTextMultiValued_values .add_all', p4.edit.editBox).unbind('click').bind('click', function(){ + $('#ZTextMultiValued_values .add_all', p4.edit.editBox).unbind('click').bind('click', function () { var container = $(this).closest('div'); var span = $('span.value', container) @@ -447,7 +403,7 @@ function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) updateFieldDisplay(); return false; }); - $('#ZTextMultiValued_values .remove_all', p4.edit.editBox).unbind('click').bind('click', function(){ + $('#ZTextMultiValued_values .remove_all', p4.edit.editBox).unbind('click').bind('click', function () { var container = $(this).closest('div'); var span = $('span.value', container) @@ -467,8 +423,7 @@ function updateCurrentMval(meta_struct_id, HighlightValue, vocabularyId) // --------------------------------------------------------------------------- // on a clique sur une des multi-valeurs dans la liste // --------------------------------------------------------------------------- -function edit_clkmval(mvaldiv, ival) -{ +function edit_clkmval(mvaldiv, ival) { $(mvaldiv).parent().find('.hilighted').removeClass('hilighted'); $(mvaldiv).addClass('hilighted'); reveal_mval(p4.edit.T_mval[ival].getValue(), p4.edit.T_mval[ival].getVocabularyId()); @@ -479,44 +434,38 @@ function edit_clkmval(mvaldiv, ival) // highlight la valeur en cours de saisie dans la liste des multi-valeurs // appele par le onkeyup // --------------------------------------------------------------------------- -function reveal_mval(value, vocabularyId) -{ - if(typeof vocabularyId === 'undefined') +function reveal_mval(value, vocabularyId) { + if (typeof vocabularyId === 'undefined') vocabularyId = null; var textZone = $('#EditTextMultiValued'); - if(p4.edit.T_fields[p4.edit.curField].tbranch) - { - if(value != "") + if (p4.edit.T_fields[p4.edit.curField].tbranch) { + if (value != "") ETHSeeker.search(value); } - if(value != "") - { + if (value != "") { // var nsel = 0; - for(rec_i in p4.edit.T_records) - { - if(p4.edit.T_records[rec_i].fields[p4.edit.curField].hasValue(value, vocabularyId)) - { - $("#idEditDiaButtonsP_"+rec_i).hide(); - var talt = $.sprintf(language.editDelSimple,value); - $("#idEditDiaButtonsM_"+rec_i).show() + for (rec_i in p4.edit.T_records) { + if (p4.edit.T_records[rec_i].fields[p4.edit.curField].hasValue(value, vocabularyId)) { + $("#idEditDiaButtonsP_" + rec_i).hide(); + var talt = $.sprintf(language.editDelSimple, value); + $("#idEditDiaButtonsM_" + rec_i).show() .attr('alt', talt) .attr('Title', talt) - .unbind('click').bind('click', function(){ + .unbind('click').bind('click', function () { var indice = $(this).attr('id').split('_').pop(); edit_diabutton(indice, 'del', value, vocabularyId); }); } - else - { - $("#idEditDiaButtonsM_"+rec_i).hide(); - $("#idEditDiaButtonsP_"+rec_i).show(); - var talt = $.sprintf(language.editAddSimple,value); - $("#idEditDiaButtonsP_"+rec_i).show().attr('alt', talt) + else { + $("#idEditDiaButtonsM_" + rec_i).hide(); + $("#idEditDiaButtonsP_" + rec_i).show(); + var talt = $.sprintf(language.editAddSimple, value); + $("#idEditDiaButtonsP_" + rec_i).show().attr('alt', talt) .attr('Title', talt) - .unbind('click').bind('click', function(){ + .unbind('click').bind('click', function () { var indice = $(this).attr('id').split('_').pop(); edit_diabutton(indice, 'add', value, vocabularyId); }); @@ -529,16 +478,13 @@ function reveal_mval(value, vocabularyId) return(true); } -function edit_diabutton(record_indice, act, value, vocabularyId) -{ +function edit_diabutton(record_indice, act, value, vocabularyId) { var meta_struct_id = p4.edit.curField; // le champ en cours d'editing - if(act == 'del') - { + if (act == 'del') { p4.edit.T_records[record_indice].fields[meta_struct_id].removeValue(value, vocabularyId); } - if(act=='add') - { + if (act == 'add') { p4.edit.T_records[record_indice].fields[meta_struct_id].addValue(value, false, vocabularyId); } updateCurrentMval(meta_struct_id, value, vocabularyId); @@ -549,14 +495,12 @@ function edit_diabutton(record_indice, act, value, vocabularyId) // --------------------------------------------------------------------------- // on a clique sur le bouton 'ajouter' un mot dans le multi-val // --------------------------------------------------------------------------- -function edit_addmval(value, VocabularyId) -{ +function edit_addmval(value, VocabularyId) { var meta_struct_id = p4.edit.curField; // le champ en cours d'editing // on ajoute le mot dans tous les records selectionnes - for(var r=0; r= $('.diapo',cache).length) + else if (i >= $('.diapo', cache).length) i = 0; edit_clk_editimg(evt, i); } -function edit_select_all() -{ +function edit_select_all() { $('#EDIT_FILM2 .diapo', p4.edit.editBox).addClass('selected'); - for(i in p4.edit.T_records) + for (i in p4.edit.T_records) p4.edit.T_records[i]._selected = true; - p4.edit.lastClickId = 1 ; + p4.edit.lastClickId = 1; updateEditSelectedRecords(null); // null : no evt available } @@ -676,89 +608,77 @@ function edit_select_all() // --------------------------------------------------------------------------- // on a clique sur une thumbnail // --------------------------------------------------------------------------- -function edit_clk_editimg(evt, i) -{ - if(p4.edit.curField >= 0) - { - if(p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok")==false) +function edit_clk_editimg(evt, i) { + if (p4.edit.curField >= 0) { + if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) return; } // guideline : si on mousedown sur une selection, c'est qu'on risque de draguer, donc on ne desectionne pas - if(evt && evt.type=="mousedown" && p4.edit.T_records[i]._selected) + if (evt && evt.type == "mousedown" && p4.edit.T_records[i]._selected) return; - if( evt && is_shift_key(evt) && p4.edit.lastClickId != null ) - { + if (evt && is_shift_key(evt) && p4.edit.lastClickId != null) { // shift donc on sel du p4.edit.lastClickId a ici var pos_from = p4.edit.T_pos[p4.edit.lastClickId]; - var pos_to = p4.edit.T_pos[i]; - if( pos_from > pos_to ) - { - var tmp = pos_from; + var pos_to = p4.edit.T_pos[i]; + if (pos_from > pos_to) { + var tmp = pos_from; pos_from = pos_to; - pos_to = tmp; + pos_to = tmp; } var pos; - for(pos=pos_from; pos<=pos_to; pos++ ) - { + for (pos = pos_from; pos <= pos_to; pos++) { var id = p4.edit.T_id[pos]; - if(!p4.edit.T_records[id]._selected) // toutes les fiches selectionnees + if (!p4.edit.T_records[id]._selected) // toutes les fiches selectionnees { p4.edit.T_records[id]._selected = true; - $("#idEditDiapo_"+id, p4.edit.editBox).addClass('selected'); + $("#idEditDiapo_" + id, p4.edit.editBox).addClass('selected'); } } } - else - { - if( !evt || !is_ctrl_key(evt) ) - { + else { + if (!evt || !is_ctrl_key(evt)) { // on deselectionne tout avant var id; - for(id in p4.edit.T_records) - { - if(p4.edit.T_records[id]._selected) // toutes les fiches selectionnees + for (id in p4.edit.T_records) { + if (p4.edit.T_records[id]._selected) // toutes les fiches selectionnees { p4.edit.T_records[id]._selected = false; - $("#idEditDiapo_"+id, p4.edit.editBox).removeClass('selected'); + $("#idEditDiapo_" + id, p4.edit.editBox).removeClass('selected'); } } } - if(i >= 0) - { + if (i >= 0) { p4.edit.T_records[i]._selected = !p4.edit.T_records[i]._selected; - if(p4.edit.T_records[i]._selected) - $("#idEditDiapo_"+i, p4.edit.editBox).addClass('selected'); + if (p4.edit.T_records[i]._selected) + $("#idEditDiapo_" + i, p4.edit.editBox).addClass('selected'); else - $("#idEditDiapo_"+i, p4.edit.editBox).removeClass('selected'); + $("#idEditDiapo_" + i, p4.edit.editBox).removeClass('selected'); } } $('#TH_Opreview .PNB10').empty(); var selected = $('#EDIT_FILM2 .diapo.selected'); - if(selected.length == 1) - { + if (selected.length == 1) { var r = selected.attr('id').split('_').pop(); previewEdit(r); } - p4.edit.lastClickId = i ; + p4.edit.lastClickId = i; updateEditSelectedRecords(evt); } // --------------------------------------------------------------------------- // on a clique sur une checkbow de status // --------------------------------------------------------------------------- -function edit_clkstatus(evt, bit, val) -{ - var ck0 = $("#idCheckboxStatbit0_"+bit); - var ck1 = $("#idCheckboxStatbit1_"+bit); - switch(val) - { +function edit_clkstatus(evt, bit, val) { + var ck0 = $("#idCheckboxStatbit0_" + bit); + var ck1 = $("#idCheckboxStatbit1_" + bit); + switch (val) { case 0: ck0.attr('class', "gui_ckbox_1"); ck1.attr('class', "gui_ckbox_0"); @@ -769,11 +689,10 @@ function edit_clkstatus(evt, bit, val) break; } var id; - for(id in p4.edit.T_records) - { - if(p4.edit.T_records[id]._selected) // toutes les fiches selectionnees + for (id in p4.edit.T_records) { + if (p4.edit.T_records[id]._selected) // toutes les fiches selectionnees { - if($('#idEditDiapo_'+id).hasClass('nostatus')) + if ($('#idEditDiapo_' + id).hasClass('nostatus')) continue; p4.edit.T_records[id].statbits[bit].value = val; @@ -782,31 +701,27 @@ function edit_clkstatus(evt, bit, val) } } -function updateEditSelectedRecords(evt) -{ +function updateEditSelectedRecords(evt) { $(".editDiaButtons", p4.edit.editBox).hide(); - for(n in p4.edit.T_statbits) // tous les statusbits de la base + for (n in p4.edit.T_statbits) // tous les statusbits de la base { p4.edit.T_statbits[n]._value = "-1"; // val unknown - for(i in p4.edit.T_records) - { - if(!p4.edit.T_records[i]._selected) + for (i in p4.edit.T_records) { + if (!p4.edit.T_records[i]._selected) continue; - if(p4.edit.T_records[i].statbits.length === 0) + if (p4.edit.T_records[i].statbits.length === 0) continue; - if(p4.edit.T_statbits[n]._value == "-1") + if (p4.edit.T_statbits[n]._value == "-1") p4.edit.T_statbits[n]._value = p4.edit.T_records[i].statbits[n].value; - else - if(p4.edit.T_statbits[n]._value != p4.edit.T_records[i].statbits[n].value) + else if (p4.edit.T_statbits[n]._value != p4.edit.T_records[i].statbits[n].value) p4.edit.T_statbits[n]._value = "2"; } - var ck0 = $("#idCheckboxStatbit0_"+n); - var ck1 = $("#idCheckboxStatbit1_"+n); + var ck0 = $("#idCheckboxStatbit0_" + n); + var ck1 = $("#idCheckboxStatbit1_" + n); - switch(p4.edit.T_statbits[n]._value) - { + switch (p4.edit.T_statbits[n]._value) { case "0": case 0: ck0.removeClass('gui_ckbox_0 gui_ckbox_2').addClass("gui_ckbox_1"); @@ -829,86 +744,71 @@ function updateEditSelectedRecords(evt) var status_box = $('#ZTextStatus'); $('.nostatus, .somestatus, .displaystatus', status_box).hide(); - if(nostatus == 0) - { + if (nostatus == 0) { $('.displaystatus', status_box).show(); } - else - { + else { var yesstatus = $('.diapo.selected', p4.edit.editBox).length; - if(nostatus == yesstatus) - { + if (nostatus == yesstatus) { $('.nostatus', status_box).show(); } - else - { + else { $('.somestatus, .displaystatus', status_box).show(); } } // calcul des valeurs suggerees COMMUNES aux records (collections) selectionnes // - for(f in p4.edit.T_fields) // tous les champs de la base + for (f in p4.edit.T_fields) // tous les champs de la base p4.edit.T_fields[f]._sgval = []; var t_lsgval = {}; var t_selcol = {}; // les bases (coll) dont au - une thumb est selectionnee var ncolsel = 0; var nrecsel = 0; - for(i in p4.edit.T_records) - { - if(!p4.edit.T_records[i]._selected) + for (i in p4.edit.T_records) { + if (!p4.edit.T_records[i]._selected) continue; nrecsel++; - var bid = "b"+p4.edit.T_records[i].bid; - if(t_selcol[bid]) + var bid = "b" + p4.edit.T_records[i].bid; + if (t_selcol[bid]) continue; t_selcol[bid] = 1; ncolsel++; - for(f in p4.edit.T_sgval[bid]) - { - if(!t_lsgval[f]) + for (f in p4.edit.T_sgval[bid]) { + if (!t_lsgval[f]) t_lsgval[f] = {}; - for(ivs in p4.edit.T_sgval[bid][f]) - { + for (ivs in p4.edit.T_sgval[bid][f]) { vs = p4.edit.T_sgval[bid][f][ivs]; - if(!t_lsgval[f][vs]) + if (!t_lsgval[f][vs]) t_lsgval[f][vs] = 0; t_lsgval[f][vs]++; } } } var t_sgval = {}; - for(f in t_lsgval) - { - for(sv in t_lsgval[f]) - { - if(t_lsgval[f][sv] == ncolsel) - { - p4.edit.T_fields[f]._sgval.push( { - label:sv, - onclick: function(menuItem, menu, e, label) - { - if(p4.edit.T_fields[p4.edit.curField].multi) - { + for (f in t_lsgval) { + for (sv in t_lsgval[f]) { + if (t_lsgval[f][sv] == ncolsel) { + p4.edit.T_fields[f]._sgval.push({ + label: sv, + onclick: function (menuItem, menu, e, label) { + if (p4.edit.T_fields[p4.edit.curField].multi) { $("#EditTextMultiValued", p4.edit.editBox).val(label); $('#EditTextMultiValued').trigger('keyup.maxLength'); edit_addmval($('#EditTextMultiValued', p4.edit.editBox).val(), null); } - else - { - if(is_ctrl_key(e)) - { + else { + if (is_ctrl_key(e)) { var t = $("#idEditZTextArea", p4.edit.editBox).val(); - $("#idEditZTextArea", p4.edit.editBox).val(t + (t?" ; ":"") + label); + $("#idEditZTextArea", p4.edit.editBox).val(t + (t ? " ; " : "") + label); } - else - { + else { $("#idEditZTextArea", p4.edit.editBox).val(label); } $('#idEditZTextArea').trigger('keyup.maxLength'); p4.edit.textareaIsDirty = true; - if(p4.edit.T_fields[p4.edit.curField]._status != 2) + if (p4.edit.T_fields[p4.edit.curField]._status != 2) edit_validField(evt, "ask_ok"); } } @@ -916,91 +816,77 @@ function updateEditSelectedRecords(evt) ); } } - if(p4.edit.T_fields[f]._sgval.length > 0) - { - $("#editSGtri_"+f, p4.edit.editBox).css("visibility", "visible"); - $("#editSGtri_"+f, p4.edit.editBox).unbind(); - $("#editSGtri_"+f, p4.edit.editBox).contextMenu( + if (p4.edit.T_fields[f]._sgval.length > 0) { + $("#editSGtri_" + f, p4.edit.editBox).css("visibility", "visible"); + $("#editSGtri_" + f, p4.edit.editBox).unbind(); + $("#editSGtri_" + f, p4.edit.editBox).contextMenu( p4.edit.T_fields[f]._sgval, { - theme:'vista', - openEvt:"click", - beforeShow:function(a,b,c,d) - { + theme: 'vista', + openEvt: "click", + beforeShow: function (a, b, c, d) { var fid = this.target.getAttribute('id').substr(10); - if(!p4.edit.textareaIsDirty || edit_validField(null, "ask_ok")==true) - { + if (!p4.edit.textareaIsDirty || edit_validField(null, "ask_ok") == true) { editField(null, fid); return(true); } - else - { + else { return(false); } } } ); } - else - { - $("#editSGtri_"+f, p4.edit.editBox).css("visibility", "hidden"); + else { + $("#editSGtri_" + f, p4.edit.editBox).css("visibility", "hidden"); } } - $('#idFrameE .ww_status', p4.edit.editBox).html( nrecsel + " record(s) selected for editing"); + $('#idFrameE .ww_status', p4.edit.editBox).html(nrecsel + " record(s) selected for editing"); updateFieldDisplay(); - if(p4.edit.curField == -1) + if (p4.edit.curField == -1) editStatus(evt); else editField(evt, p4.edit.curField); } -function updateFieldDisplay() -{ - for(f in p4.edit.T_fields) // tous les champs de la base +function updateFieldDisplay() { + for (f in p4.edit.T_fields) // tous les champs de la base { p4.edit.T_fields[f]._status = 0; // val unknown - for(i in p4.edit.T_records) - { - if(!p4.edit.T_records[i]._selected) + for (i in p4.edit.T_records) { + if (!p4.edit.T_records[i]._selected) continue; - if(p4.edit.T_records[i].fields[f].isEmpty()) - { + if (p4.edit.T_records[i].fields[f].isEmpty()) { var v = ""; } - else - { + else { // le champ existe dans la fiche - if(p4.edit.T_fields[f].multi) - { + if (p4.edit.T_fields[f].multi) { // champ multi : on compare la concat des valeurs var v = p4.edit.T_records[i].fields[f].getSerializedValues() } - else - { + else { var v = p4.edit.T_records[i].fields[f].getValue().getValue(); } } - if(p4.edit.T_fields[f]._status == 0) - { - p4.edit.T_fields[f]._value = v; + if (p4.edit.T_fields[f]._status == 0) { + p4.edit.T_fields[f]._value = v; p4.edit.T_fields[f]._status = 1; } - else if(p4.edit.T_fields[f]._status == 1 && p4.edit.T_fields[f]._value != v) - { - p4.edit.T_fields[f]._value = "*****"; + else if (p4.edit.T_fields[f]._status == 1 && p4.edit.T_fields[f]._value != v) { + p4.edit.T_fields[f]._value = "*****"; p4.edit.T_fields[f]._status = 2; break; // plus la peine de verifier le champ sur les autres records } } - if(o = document.getElementById("idEditField_"+f)) - { - if(p4.edit.T_fields[f]._status == 2) // mixed + if (o = document.getElementById("idEditField_" + f)) { + if (p4.edit.T_fields[f]._status == 2) // mixed o.innerHTML = "xxxxx"; else o.innerHTML = cleanTags(p4.edit.T_fields[f]._value).replace(/\n/gm, "
"); @@ -1008,15 +894,14 @@ function updateFieldDisplay() } } -function SortCompareMetas(a, b) -{ - if(typeof(a) != 'object') +function SortCompareMetas(a, b) { + if (typeof(a) != 'object') return(-1); - if(typeof(b) != 'object') + if (typeof(b) != 'object') return(1); var na = a.getValue().toUpperCase(); var nb = b.getValue().toUpperCase(); - if(na == nb) + if (na == nb) return(0); return(na < nb ? -1 : 1); } @@ -1024,75 +909,70 @@ function SortCompareMetas(a, b) //--------------------------------------------------------------------- //nettoie //--------------------------------------------------------------------- -function cleanTags(string) -{ - var chars2replace = [ { - f:"&", - t:"&" - }, { - 'f':"<", - 't':"<" - }, { - 'f':">", - 't':">" - } ]; - for(c in chars2replace) - string = string.replace(RegExp(chars2replace[c].f,"g") ,chars2replace[c].t); +function cleanTags(string) { + var chars2replace = [ + { + f: "&", + t: "&" + }, + { + 'f': "<", + 't': "<" + }, + { + 'f': ">", + 't': ">" + } + ]; + for (c in chars2replace) + string = string.replace(RegExp(chars2replace[c].f, "g"), chars2replace[c].t); return string; } -function check_required(id_r, id_f) -{ +function check_required(id_r, id_f) { var required_fields = false; - if(typeof id_r == 'undefined') + if (typeof id_r == 'undefined') id_r = false; - if(typeof id_f == 'undefined') + if (typeof id_f == 'undefined') id_f = false; - for(f in p4.edit.T_fields) - { - if(id_f !== false && f != id_f) + for (f in p4.edit.T_fields) { + if (id_f !== false && f != id_f) continue; var name = p4.edit.T_fields[f].name; - if(!p4.edit.T_fields[f].required) + if (!p4.edit.T_fields[f].required) continue; - for(r in p4.edit.T_records) - { - if(id_r !== false && r != id_r) + for (r in p4.edit.T_records) { + if (id_r !== false && r != id_r) continue; - var elem = $('#idEditDiapo_'+r+' .require_alert'); + var elem = $('#idEditDiapo_' + r + ' .require_alert'); elem.hide(); - if(!p4.edit.T_records[r].fields[f]) - { + if (!p4.edit.T_records[r].fields[f]) { elem.show(); required_fields = true; } - else - { + else { var check_required = ''; // le champ existe dans la fiche - if(p4.edit.T_fields[f].multi) - { + if (p4.edit.T_fields[f].multi) { // champ multi : on compare la concat des valeurs check_required = $.trim(p4.edit.T_records[r].fields[f].getSerializedValues()) } - else if(p4.edit.T_records[r].fields[f].getValue()) - { + else if (p4.edit.T_records[r].fields[f].getValue()) { check_required = $.trim(p4.edit.T_records[r].fields[f].getValue().getValue()); } - if(check_required == '') - { + if (check_required == '') { elem.show(); required_fields = true; } @@ -1106,20 +986,18 @@ function check_required(id_r, id_f) // ---------------------------------------------------------------------------------- // on a clique sur le 'ok' general : save // ---------------------------------------------------------------------------------- -function edit_applyMultiDesc(evt) -{ +function edit_applyMultiDesc(evt) { var sendorder = ""; var sendChuOrder = ""; var t = []; - if(p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok")==false) + if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) return(false); var required_fields = check_required(); - if(required_fields) - { + if (required_fields) { alert(language.some_required_fields); return; } @@ -1128,21 +1006,18 @@ function edit_applyMultiDesc(evt) $("#EDIT_WORKING", p4.edit.editBox).show(); - for(r in p4.edit.T_records) - { + for (r in p4.edit.T_records) { var record_datas = { - record_id : p4.edit.T_records[r].rid, - metadatas : [], - edit : 0, - status : null + record_id: p4.edit.T_records[r].rid, + metadatas: [], + edit: 0, + status: null }; var editDirty = false; - for(f in p4.edit.T_records[r].fields) - { - if(!p4.edit.T_records[r].fields[f].isDirty()) - { + for (f in p4.edit.T_records[r].fields) { + if (!p4.edit.T_records[r].fields[f].isDirty()) { continue; } @@ -1155,22 +1030,19 @@ function edit_applyMultiDesc(evt) } // les statbits - var tsb = []; - for(var n=0; n<64; n++) + var tsb = []; + for (var n = 0; n < 64; n++) tsb[n] = 'x'; sb_dirty = false; - for(var n in p4.edit.T_records[r].statbits) - { - if(p4.edit.T_records[r].statbits[n].dirty) - { - tsb[63-n] = p4.edit.T_records[r].statbits[n].value; + for (var n in p4.edit.T_records[r].statbits) { + if (p4.edit.T_records[r].statbits[n].dirty) { + tsb[63 - n] = p4.edit.T_records[r].statbits[n].value; sb_dirty = true; } } - if(sb_dirty || editDirty) - { - if(sb_dirty === true) + if (sb_dirty || editDirty) { + if (sb_dirty === true) record_datas.status = tsb.join(""); t.push(record_datas); @@ -1178,38 +1050,35 @@ function edit_applyMultiDesc(evt) } var options = { - mds:t, - sbid : p4.edit.sbas_id, - act:'WORK', - lst:$('#edit_lst').val(), - act_option:'SAVE'+p4.edit.what, - regbasprid:p4.edit.regbasprid, + mds: t, + sbid: p4.edit.sbas_id, + act: 'WORK', + lst: $('#edit_lst').val(), + act_option: 'SAVE' + p4.edit.what, + regbasprid: p4.edit.regbasprid, // newrepresent:p4.edit.newrepresent, - ssel:p4.edit.ssel + ssel: p4.edit.ssel }; - if(p4.edit.newrepresent != false) + if (p4.edit.newrepresent != false) options.newrepresent = p4.edit.newrepresent; // options.mds = t; $.ajax({ - url :"../prod/records/edit/apply/" - , - data : options + url: "../prod/records/edit/apply/", + data: options // ,dataType:'json' , - type:'POST' - , - success : function(data){ - if(p4.edit.what == 'GRP' || p4.edit.what == 'SSEL') - { + type: 'POST', + success: function (data) { + if (p4.edit.what == 'GRP' || p4.edit.what == 'SSEL') { p4.WorkZone.refresh('current'); } $("#Edit_copyPreset_dlg").remove(); $('#EDITWINDOW').hide(); hideOverlay(2); - if(p4.preview.open) + if (p4.preview.open) reloadPreview(); return; } @@ -1217,46 +1086,40 @@ function edit_applyMultiDesc(evt) } -function edit_cancelMultiDesc(evt) -{ +function edit_cancelMultiDesc(evt) { var dirty = false; evt.cancelBubble = true; - if(evt.stopPropagation) + if (evt.stopPropagation) evt.stopPropagation(); - if(p4.edit.curField >= 0) - { - if(p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok")==false) + if (p4.edit.curField >= 0) { + if (p4.edit.textareaIsDirty && edit_validField(evt, "ask_ok") == false) return; } - for(r in p4.edit.T_records) - { - for(f in p4.edit.T_records[r].fields) - { - if( (dirty |= p4.edit.T_records[r].fields[f].isDirty()) ) + for (r in p4.edit.T_records) { + for (f in p4.edit.T_records[r].fields) { + if ((dirty |= p4.edit.T_records[r].fields[f].isDirty())) break; } - for(var n in p4.edit.T_records[r].statbits) - { - if( (dirty |= p4.edit.T_records[r].statbits[n].dirty) ) + for (var n in p4.edit.T_records[r].statbits) { + if ((dirty |= p4.edit.T_records[r].statbits[n].dirty)) break; } } - if(!dirty || confirm(language.confirm_abandon)) - { + if (!dirty || confirm(language.confirm_abandon)) { $("#Edit_copyPreset_dlg").remove(); $('#idFrameE .ww_content', p4.edit.editBox).empty(); // on reaffiche tous les thesaurus - for(i in p4.thesau.thlist) // tous les thesaurus + for (i in p4.thesau.thlist) // tous les thesaurus { var bid = p4.thesau.thlist[i].sbas_id; - var e = document.getElementById('TH_T.'+bid+'.T'); - if(e) + var e = document.getElementById('TH_T.' + bid + '.T'); + if (e) e.style.display = ""; } self.setTimeout("$('#EDITWINDOW').fadeOut();hideOverlay(2);", 100); @@ -1271,14 +1134,12 @@ function edit_cancelMultiDesc(evt) function edit_clickThesaurus(event) // onclick dans le thesaurus { // on cherche ou on a clique - for(e=event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e=e.parentNode) + for (e = event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e = e.parentNode) ; - if(e) - { - switch(e.id.substr(0,4)) - { + if (e) { + switch (e.id.substr(0, 4)) { case "TH_P": // +/- de deploiement de mot - js = "edit_thesaurus_ow('"+e.id.substr(5)+"')"; + js = "edit_thesaurus_ow('" + e.id.substr(5) + "')"; self.setTimeout(js, 10); break; } @@ -1288,24 +1149,19 @@ function edit_clickThesaurus(event) // onclick dans le thesaurus function edit_dblclickThesaurus(event) // ondblclick dans le thesaurus { - for(e=event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e=e.parentNode) + for (e = event.srcElement ? event.srcElement : event.target; e && ((!e.tagName) || (!e.id)); e = e.parentNode) ; - if(e) - { - switch(e.id.substr(0,4)) - { + if (e) { + switch (e.id.substr(0, 4)) { case "TH_W": - if(p4.edit.curField >= 0) - { + if (p4.edit.curField >= 0) { var w = $(e).text(); - if(p4.edit.T_fields[p4.edit.curField].multi) - { + if (p4.edit.T_fields[p4.edit.curField].multi) { $("#EditTextMultiValued", p4.edit.editBox).val(w); $('#EditTextMultiValued').trigger('keyup.maxLength'); edit_addmval($('#EditTextMultiValued', p4.edit.editBox).val(), null); } - else - { + else { $("#idEditZTextArea", p4.edit.editBox).val(w); $('#idEditZTextArea').trigger('keyup.maxLength'); p4.edit.textareaIsDirty = true; @@ -1319,27 +1175,25 @@ function edit_dblclickThesaurus(event) // ondblclick dans le thesaurus function edit_thesaurus_ow(id) // on ouvre ou ferme une branche de thesaurus { - var o = document.getElementById("TH_K."+id); - if(o.className=="o") - { + var o = document.getElementById("TH_K." + id); + if (o.className == "o") { // on ferme o.className = "c"; - document.getElementById("TH_P."+id).innerHTML = "+"; - document.getElementById("TH_K."+id).innerHTML = language.loading; + document.getElementById("TH_P." + id).innerHTML = "+"; + document.getElementById("TH_K." + id).innerHTML = language.loading; } - else if(o.className=="c" || o.className=="h") - { + else if (o.className == "c" || o.className == "h") { // on ouvre o.className = "o"; - document.getElementById("TH_P."+id).innerHTML = "-"; + document.getElementById("TH_P." + id).innerHTML = "-"; var t_id = id.split("."); var sbas_id = t_id[0]; t_id.shift(); var thid = t_id.join("."); var url = "/xmlhttp/getterm_prod.x.php"; - var parms = "bid=" + sbas_id; - parms += "&lng="+p4.lng; + var parms = "bid=" + sbas_id; + parms += "&lng=" + p4.lng; parms += "&sortsy=1"; parms += "&id=" + thid; parms += "&typ=TH"; @@ -1349,40 +1203,38 @@ function edit_thesaurus_ow(id) // on ouvre ou ferme une branche de thesaurus return(false); } -function EditThesaurusSeeker(sbas_id) -{ +function EditThesaurusSeeker(sbas_id) { this.jq = null; this.sbas_id = sbas_id; - var zid = (""+sbas_id).replace(new RegExp("\\.", "g"), "\\.") + "\\.T"; + var zid = ("" + sbas_id).replace(new RegExp("\\.", "g"), "\\.") + "\\.T"; this.TH_P_node = $("#TH_P\\." + zid, p4.edit.editBox); this.TH_K_node = $("#TH_K\\." + zid, p4.edit.editBox); this._ctimer = null; - this.search = function(txt) { - if(this._ctimer) + this.search = function (txt) { + if (this._ctimer) clearTimeout(this._ctimer); - var js = "ETHSeeker.search_delayed('"+txt.replace("'", "\\'")+"');" ; + var js = "ETHSeeker.search_delayed('" + txt.replace("'", "\\'") + "');"; this._ctimer = setTimeout(js, 125); }; - this.search_delayed = function(txt) { - if(this.jq && typeof this.jq.abort == "function") - { + this.search_delayed = function (txt) { + if (this.jq && typeof this.jq.abort == "function") { this.jq.abort(); this.jq = null; } txt = txt.replace("'", "\\'"); var url = "/xmlhttp/openbranches_prod.h.php"; - var parms = { - bid:this.sbas_id, - lng:p4.lng, - t:txt, - mod:"TREE", - u:Math.random() + var parms = { + bid: this.sbas_id, + lng: p4.lng, + t: txt, + mod: "TREE", + u: Math.random() }; var me = this; @@ -1390,52 +1242,49 @@ function EditThesaurusSeeker(sbas_id) this.jq = $.ajax({ url: url, data: parms, - type:'POST', - success: function(ret) - { + type: 'POST', + success: function (ret) { me.TH_P_node.html("..."); me.TH_K_node.attr("class", "h").html(ret); me.jq = null; }, - error:function(){ + error: function () { }, - timeout:function(){ + timeout: function () { } }); }; - this.openBranch = function(id, thid) { - if(this.jq) - { + this.openBranch = function (id, thid) { + if (this.jq) { this.jq.abort(); this.jq = null; } var url = "/xmlhttp/getterm_prod.h.php"; - var parms = { - bid:this.sbas_id, - lng:p4.lng, - sortsy:1, - id:thid, - typ:"TH" - } ; + var parms = { + bid: this.sbas_id, + lng: p4.lng, + sortsy: 1, + id: thid, + typ: "TH" + }; var me = this; this.jq = $.ajax({ url: url, data: parms, - success: function(ret) - { + success: function (ret) { var zid = "#TH_K\\." + id.replace(new RegExp("\\.", "g"), "\\."); // escape les '.' pour jquery $(zid, p4.edit.editBox).html(ret); me.jq = null; }, - error:function(){ + error: function () { }, - timeout:function(){ + timeout: function () { } }); @@ -1443,50 +1292,42 @@ function EditThesaurusSeeker(sbas_id) } - -function replace() -{ - var field = $("#EditSRField", p4.edit.editBox).val(); - var search = $("#EditSearch", p4.edit.editBox).val(); +function replace() { + var field = $("#EditSRField", p4.edit.editBox).val(); + var search = $("#EditSearch", p4.edit.editBox).val(); var replace = $("#EditReplace", p4.edit.editBox).val(); - var where = $("[name=EditSR_Where]:checked", p4.edit.editBox).val(); - var commut = ""; - var rgxp = $("#EditSROptionRX", p4.edit.editBox).attr('checked') ? true : false; + var where = $("[name=EditSR_Where]:checked", p4.edit.editBox).val(); + var commut = ""; + var rgxp = $("#EditSROptionRX", p4.edit.editBox).attr('checked') ? true : false; var r_search; - if(rgxp) - { + if (rgxp) { r_search = search; - commut = ($("#EditSR_RXG", p4.edit.editBox).attr('checked') ? "g" : "") - + ($("#EditSR_RXI", p4.edit.editBox).attr('checked') ? "i" : "") ; + commut = ($("#EditSR_RXG", p4.edit.editBox).attr('checked') ? "g" : "") + + ($("#EditSR_RXI", p4.edit.editBox).attr('checked') ? "i" : ""); } - else - { - commut = $("#EditSR_case", p4.edit.editBox).attr('checked') ? "g" : "gi"; + else { + commut = $("#EditSR_case", p4.edit.editBox).attr('checked') ? "g" : "gi"; r_search = ""; - for(i=0; i 0 && zoomable.hasClass('zoomed')) + if (zoomable.length > 0 && zoomable.hasClass('zoomed')) return; // var datas = p4.edit.T_records[id].preview; @@ -1712,14 +1518,13 @@ function setPreviewEdit() // var h = parseInt(datas.height); // var w = parseInt(datas.width); // } - var t=0; + var t = 0; var de = 0; var margX = 0; var margY = 0; - if($('img.record.record_audio', container).length > 0) - { + if ($('img.record.record_audio', container).length > 0) { var margY = 100; de = 60; } @@ -1756,17 +1561,16 @@ function setPreviewEdit() // } t = Math.round((dheight - h - de) / 2); var l = Math.round((dwidth - w) / 2); - $('.record',container).css({ + $('.record', container).css({ width: w, height: h, top: t, left: l - }).attr('width',w).attr('height',h); + }).attr('width', w).attr('height', h); } -function previewEdit(r) -{ +function previewEdit(r) { $('#TH_Opreview .PNB10').empty().append(p4.edit.T_records[r].preview); @@ -1814,27 +1618,23 @@ function previewEdit(r) // } // } - if($('img.PREVIEW_PIC.zoomable').length > 0) - { + if ($('img.PREVIEW_PIC.zoomable').length > 0) { $('img.PREVIEW_PIC.zoomable').draggable(); } setPreviewEdit(); } -function startThisEditing(sbas_id,what,regbasprid,ssel) -{ +function startThisEditing(sbas_id, what, regbasprid, ssel) { p4.edit.sbas_id = sbas_id; p4.edit.what = what; p4.edit.regbasprid = regbasprid; p4.edit.ssel = ssel; - for(r in p4.edit.T_records) - { + for (r in p4.edit.T_records) { var fields = {}; - for(f in p4.edit.T_records[r].fields) - { + for (f in p4.edit.T_records[r].fields) { var meta_struct_id = p4.edit.T_records[r].fields[f].meta_struct_id; var name = p4.edit.T_fields[meta_struct_id].name; @@ -1851,23 +1651,22 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) var vocabularyRestricted = p4.edit.T_fields[meta_struct_id].vocabularyRestricted; var fieldOptions = { - multi:multi, - required:required, - readonly:readonly, - maxLength:maxLength, - minLength:minLength, - type:type, - separator:separator, - vocabularyControl:vocabularyControl, - vocabularyRestricted:vocabularyRestricted + multi: multi, + required: required, + readonly: readonly, + maxLength: maxLength, + minLength: minLength, + type: type, + separator: separator, + vocabularyControl: vocabularyControl, + vocabularyRestricted: vocabularyRestricted }; var databoxField = new p4.databoxField(name, label, meta_struct_id, fieldOptions); var values = []; - for(v in p4.edit.T_records[r].fields[f].values) - { + for (v in p4.edit.T_records[r].fields[f].values) { var meta_id = p4.edit.T_records[r].fields[f].values[v].meta_id; var value = p4.edit.T_records[r].fields[f].values[v].value; var vocabularyId = p4.edit.T_records[r].fields[f].values[v].vocabularyId; @@ -1883,48 +1682,47 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) } - $('#EditTextMultiValued').bind('keyup', function(){ + $('#EditTextMultiValued').bind('keyup', function () { reveal_mval($(this).val()); }); $('#EDIT_MID_R .tabs').tabs(); $('#divS div.edit_field:odd').addClass('odd'); - $('#divS div').bind('mouseover',function(){ + $('#divS div').bind('mouseover',function () { $(this).addClass('hover'); - }).bind('mouseout',function(){ + }).bind('mouseout', function () { $(this).removeClass('hover'); }); $('#editcontextwrap').remove(); - if($('#editcontextwrap').length == 0) + if ($('#editcontextwrap').length == 0) $('body').append('
'); self.setTimeout("edit_select_all();", 100); $('.previewTips, .DCESTips, .fieldTips', p4.edit.editBox).tooltip({ - fixable:true, - fixableIndex:1200 + fixable: true, + fixableIndex: 1200 }); $('.infoTips', p4.edit.editBox).tooltip(); - if(p4.edit.what == 'GRP') - { + if (p4.edit.what == 'GRP') { $('#EDIT_FILM2 .reg_opts').show(); - $.each($('#EDIT_FILM2 .contextMenuTrigger'),function(){ + $.each($('#EDIT_FILM2 .contextMenuTrigger'), function () { - var id = $(this).attr('id').split('_').slice(1,3).join('_'); - $(this).contextMenu('#editContext_'+id+'',{ - appendTo:'#editcontextwrap', - openEvt:'click', - dropDown:true, - theme:'vista', - dropDown:true, - showTransition:'slideDown', - hideTransition:'hide', - shadow:false + var id = $(this).attr('id').split('_').slice(1, 3).join('_'); + $(this).contextMenu('#editContext_' + id + '', { + appendTo: '#editcontextwrap', + openEvt: 'click', + dropDown: true, + theme: 'vista', + dropDown: true, + showTransition: 'slideDown', + hideTransition: 'hide', + shadow: false }); }); } @@ -1934,13 +1732,13 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) vsplit1(); $('#EDIT_TOP', p4.edit.editBox).resizable({ - handles : 's', - minHeight:100, - resize:function(){ + handles: 's', + minHeight: 100, + resize: function () { hsplit1(); setPreviewEdit(); }, - stop:function(){ + stop: function () { hsplit1(); setPref('editing_top_box', Math.floor($('#EDIT_TOP').height() * 100 / $('#EDIT_ALL').height()) + '%'); setSizeLimits(); @@ -1948,13 +1746,13 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) }); $('#divS_wrapper', p4.edit.editBox).resizable({ - handles : 'e', - minWidth:200, - resize:function(){ + handles: 'e', + minWidth: 200, + resize: function () { vsplit1(); setPreviewEdit(); }, - stop:function(){ + stop: function () { setPref('editing_right_box', Math.floor($('#divS').width() * 100 / $('#EDIT_MID_L').width()) + '%'); vsplit1(); setSizeLimits(); @@ -1964,13 +1762,13 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) $('#EDIT_MID_R') .css('left', $('#EDIT_MID_L').position().left + $('#EDIT_MID_L').width() + 15) .resizable({ - handles : 'w', - minWidth:200, - resize:function(){ + handles: 'w', + minWidth: 200, + resize: function () { vsplit2(); setPreviewEdit(); }, - stop:function(){ + stop: function () { setPref('editing_left_box', Math.floor($('#EDIT_MID_R').width() * 100 / $('#EDIT_MID').width()) + '%'); vsplit2(); setSizeLimits(); @@ -1978,78 +1776,69 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) }); $('#EDIT_ZOOMSLIDER', p4.edit.editBox).slider({ - min:60, - max:300, - value:p4.edit.diapoSize, - slide:function(event,ui) - { + min: 60, + max: 300, + value: p4.edit.diapoSize, + slide: function (event, ui) { var v = $(ui.value)[0]; $('#EDIT_FILM2 .diapo', p4.edit.editBox).width(v).height(v); }, - change:function(event,ui) - { + change: function (event, ui) { p4.edit.diapoSize = $(ui.value)[0]; setPref("editing_images_size", p4.edit.diapoSize); } }); var buttons = {}; - buttons[language.valider] = function(e) - { + buttons[language.valider] = function (e) { $(this).dialog("close"); edit_applyMultiDesc(e); }; - buttons[language.annuler] = function(e) - { + buttons[language.annuler] = function (e) { $(this).dialog("close"); edit_cancelMultiDesc(e); }; $("#EDIT_CLOSEDIALOG", p4.edit.editBox).dialog({ autoOpen: false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true, buttons: buttons }); var buttons = {}; - buttons[language.valider] = function() - { + buttons[language.valider] = function () { var form = $("#Edit_copyPreset_dlg FORM"); var jtitle = $(".EDIT_presetTitle", form); - if(jtitle.val() == '') - { + if (jtitle.val() == '') { alert(language.needTitle); jtitle[0].focus(); return; } var p = { - "act":"SAVE", - "sbas":p4.edit.sbas_id, - "title":jtitle.val(), - "f":{} + "act": "SAVE", + "sbas": p4.edit.sbas_id, + "title": jtitle.val(), + "f": {} }; var f = {}; var x = ""; $(":checkbox", form).each( - function(idx, elem) - { - if(elem.checked) - { - var i = 0|elem.value; + function (idx, elem) { + if (elem.checked) { + var i = 0 | elem.value; var f; - if(p4.edit.T_fields[i].multi) + if (p4.edit.T_fields[i].multi) f = p4.edit.T_fields[i]._value.split(";"); else f = [ p4.edit.T_fields[i]._value ]; - for(j in f) - { - x += "<"+p4.edit.T_fields[i].name+">" - + cleanTags(f[j]) - + ""; + for (j in f) { + x += "<" + p4.edit.T_fields[i].name + ">" + + cleanTags(f[j]) + + ""; } } } @@ -2063,8 +1852,7 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) url: "/xmlhttp/editing_presets.j.php", data: p, dataType: 'json', - success: function(data, textStatus) - { + success: function (data, textStatus) { preset_paint(data); if ($("#Edit_copyPreset_dlg").data("ui-dialog")) { @@ -2073,40 +1861,37 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) } }); }; - buttons[language.annuler] = function() - { + buttons[language.annuler] = function () { $(this).dialog("close"); }; $("#Edit_copyPreset_dlg", p4.edit.editBox).dialog({ - stack:true, - closeOnEscape:true, - resizable:false, - draggable:false, - autoOpen:false, - modal:true, - width:600, - title:language.newPreset, - close: function(event,ui) { + stack: true, + closeOnEscape: true, + resizable: false, + draggable: false, + autoOpen: false, + modal: true, + width: 600, + title: language.newPreset, + close: function (event, ui) { $(this).dialog("widget").css("z-index", "auto"); }, - open:function(event, ui) { + open: function (event, ui) { $(this).dialog("widget").css("z-index", "5000"); $(".EDIT_presetTitle")[0].focus(); }, - buttons:buttons + buttons: buttons }); $('#idEditDateZone', p4.edit.editBox).datepicker({ changeYear: true, - changeMonth:true, + changeMonth: true, dateFormat: 'yy/mm/dd', - onSelect: function(dateText, inst) - { + onSelect: function (dateText, inst) { var lval = $('#idEditZTextArea', p4.edit.editBox).val(); - if(lval != dateText) - { + if (lval != dateText) { fieldLastValue = lval; $('#idEditZTextArea', p4.edit.editBox).val(dateText); $('#idEditZTextArea').trigger('keyup.maxLength'); @@ -2121,43 +1906,39 @@ function startThisEditing(sbas_id,what,regbasprid,ssel) setSizeLimits(); var p = { - "act":"LIST", - "sbas":p4.edit.sbas_id + "act": "LIST", + "sbas": p4.edit.sbas_id }; $.getJSON( "/xmlhttp/editing_presets.j.php", p, - function(data, textStatus) - { + function (data, textStatus) { preset_paint(data); } ); check_required(); - $('#TH_Opresets button.adder').bind('click', function(){ + $('#TH_Opresets button.adder').bind('click', function () { preset_copy(); }); - try{ + try { $('#divS .edit_field:first').trigger('mousedown'); } - catch(err) - { + catch (err) { } } - -function setRegDefault(n,record_id) -{ +function setRegDefault(n, record_id) { p4.edit.newrepresent = record_id; - var src = $('#idEditDiapo_'+n).find('img.edit_IMGT').attr('src'); - var style = $('#idEditDiapo_'+n).find('img.edit_IMGT').attr('style'); + var src = $('#idEditDiapo_' + n).find('img.edit_IMGT').attr('src'); + var style = $('#idEditDiapo_' + n).find('img.edit_IMGT').attr('style'); - $('#EDIT_GRPDIAPO .edit_IMGT').attr('src',src).attr('style',style); + $('#EDIT_GRPDIAPO .edit_IMGT').attr('src', src).attr('style', style); } diff --git a/www/skins/prod/jquery.main-prod.js b/www/skins/prod/jquery.main-prod.js index f495fd70a5..3077e9ee74 100644 --- a/www/skins/prod/jquery.main-prod.js +++ b/www/skins/prod/jquery.main-prod.js @@ -2,28 +2,28 @@ document.getElementById('loader_bar').style.width = '30%'; var p4 = p4 || {}; -var baskAjax,baskAjaxrunning; +var baskAjax, baskAjaxrunning; baskAjaxrunning = false; -var answAjax,answAjaxrunning; +var answAjax, answAjaxrunning; answAjaxrunning = false; -var searchAjax,searchAjaxRunning; +var searchAjax, searchAjaxRunning; searchAjaxRunning = false; var language = {}; var bodySize = { - x:0, - y:0 + x: 0, + y: 0 }; -function resizePreview(){ +function resizePreview() { p4.preview.height = $('#PREVIEWIMGCONT').height(); p4.preview.width = $('#PREVIEWIMGCONT').width(); setPreview(); } -function getHome(cas, page){ +function getHome(cas, page) { - if(typeof(page) === 'undefined') + if (typeof(page) === 'undefined') page = 0; switch (cas) { @@ -38,23 +38,23 @@ function getHome(cas, page){ data: { page: page }, - beforeSend: function(){ + beforeSend: function () { if (answAjaxrunning && answAjax.abort) answAjax.abort(); - if(page === 0) + if (page === 0) clearAnswers(); answAjaxrunning = true; $('#answers').addClass('loading'); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(data){ + success: function (data) { answAjaxrunning = false; var answers = $('#answers'); @@ -67,11 +67,10 @@ function getHome(cas, page){ }); afterSearch(); - if(page > 0) - { + if (page > 0) { answers.stop().animate({ - scrollTop:answers.scrollTop()+answers.height() - },700); + scrollTop: answers.scrollTop() + answers.height() + }, 700); } return; } @@ -86,22 +85,22 @@ function getHome(cas, page){ data: { type: cas }, - beforeSend: function(){ + beforeSend: function () { if (answAjaxrunning && answAjax.abort) answAjax.abort(); clearAnswers(); answAjaxrunning = true; $('#answers').addClass('loading'); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(data){ + success: function (data) { answAjaxrunning = false; $('#answers').append(data); afterSearch(); @@ -117,71 +116,63 @@ function getHome(cas, page){ } } -function getLanguage(){ +function getLanguage() { $.ajax({ type: "GET", url: "../prod/language/", dataType: 'json', - success: function(data){ + success: function (data) { language = data; return; } }); } -function is_ctrl_key(event) -{ - if(event.altKey) +function is_ctrl_key(event) { + if (event.altKey) return true; - if(event.ctrlKey) + if (event.ctrlKey) return true; - if(event.metaKey) // apple key opera + if (event.metaKey) // apple key opera return true; - if(event.keyCode === 17) // apple key opera + if (event.keyCode === 17) // apple key opera return true; - if(event.keyCode === 224) // apple key mozilla + if (event.keyCode === 224) // apple key mozilla return true; - if(event.keyCode === 91) // apple key safari + if (event.keyCode === 91) // apple key safari return true; return false; } -function is_shift_key(event) -{ - if(event.shiftKey) +function is_shift_key(event) { + if (event.shiftKey) return true; return false; } - - -function checkBases(bool) -{ - $('form.phrasea_query .sbas_list').each(function(){ +function checkBases(bool) { + $('form.phrasea_query .sbas_list').each(function () { var id = $(this).find('input[name=reference]:first').val(); - if(bool) - $(this).find(':checkbox').attr('checked','checked'); + if (bool) + $(this).find(':checkbox').attr('checked', 'checked'); else $(this).find(':checkbox').removeAttr('checked'); infoSbas(false, id, true, false); }); - if(bool) - { + if (bool) { $('.sbascont label').addClass('selected'); } - else - { + else { $('.sbascont label').removeClass('selected'); } checkFilters(true); } -function checkFilters(save) -{ +function checkFilters(save) { var danger = false; var search = { bases: {}, @@ -212,7 +203,7 @@ function checkFilters(save) var nbSelectedColls = 0; - $.each($('.sbascont', adv_box), function(){ + $.each($('.sbascont', adv_box), function () { var $this = $(this); var sbas_id = $this.parent().find('input[name="reference"]').val(); @@ -220,19 +211,19 @@ function checkFilters(save) var bas_ckbox = $this.find('.checkbas'); - if(bas_ckbox.filter(':not(:checked)').length > 0) { + if (bas_ckbox.filter(':not(:checked)').length > 0) { danger = 'medium'; } var checked = bas_ckbox.filter(':checked'); - if(checked.length>0) { + if (checked.length > 0) { var sbas_fields = $('.field_' + sbas_id, container).removeClass("hidden"); sbas_fields.filter('option').show().filter('.was').removeClass('was').attr('selected', 'selected').selected(true); - sbas_fields.filter(':checkbox').parent().show().find('.was').attr('checked','checked').removeClass('was'); + sbas_fields.filter(':checkbox').parent().show().find('.was').attr('checked', 'checked').removeClass('was'); } - checked.each(function(){ + checked.each(function () { nbSelectedColls++; search.bases[sbas_id].push($(this).val()); }); @@ -246,84 +237,80 @@ function checkFilters(save) var reset_field = false; - $.each(search.fields, function(i,n){ - if(n === 'phraseanet--all--fields') + $.each(search.fields, function (i, n) { + if (n === 'phraseanet--all--fields') reset_field = true; }); - if(reset_field) - { + if (reset_field) { $('select[name="fields[]"] option:selected', container).removeAttr('selected').selected(false); search.fields = new Array; } - if(!reset_field && search.fields.length>0) - { + if (!reset_field && search.fields.length > 0) { danger = true; $('.field_filter', adv_box).addClass('danger'); } - $('.status_filter :checkbox[checked]').each(function(){ + $('.status_filter :checkbox[checked]').each(function () { var n = $(this).attr('n'); search.status[n] = $(this).val().split('_'); danger = true; - $('.status_filter', adv_box) .addClass('danger'); + $('.status_filter', adv_box).addClass('danger'); }); - search.dates.minbound = $('.date_filter input[name=date_min]', adv_box).val(); - search.dates.maxbound = $('.date_filter input[name=date_max]', adv_box).val(); - search.dates.field = $('.date_filter select[name=date_field]', adv_box).val(); + search.dates.minbound = $('.date_filter input[name=date_min]', adv_box).val(); + search.dates.maxbound = $('.date_filter input[name=date_max]', adv_box).val(); + search.dates.field = $('.date_filter select[name=date_field]', adv_box).val(); - if($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) - { + if ($.trim(search.dates.minbound) || $.trim(search.dates.maxbound)) { danger = true; $('.date_filter', adv_box).addClass('danger'); } fieldsSelect.scrollTop(scroll); - if(save===true) - setPref('search',JSON.stringify(search)); + if (save === true) + setPref('search', JSON.stringify(search)); - if(danger===true || danger === 'medium') + if (danger === true || danger === 'medium') $('#EDIT_query').addClass('danger'); else $('#EDIT_query').removeClass('danger'); } -function toggleFilter(filter,ele) -{ - var el = $('#'+filter); - if(el.is(':hidden')) +function toggleFilter(filter, ele) { + var el = $('#' + filter); + if (el.is(':hidden')) $(ele).parent().addClass('open'); else $(ele).parent().removeClass('open'); - $('#'+filter).slideToggle('fast'); + $('#' + filter).slideToggle('fast'); } -function setVisible(el){ +function setVisible(el) { el.style.visibility = 'visible'; } -function resize(){ +function resize() { bodySize.y = $('#mainContainer').height(); bodySize.x = $('#mainContainer').width(); - if(false) + if (false) $('.overlay').height(bodySize.y).width(bodySize.x); var headBlockH = $('#headBlock').outerHeight(); - var bodyY = bodySize.y - headBlockH-2; - var bodyW = bodySize.x-2; + var bodyY = bodySize.y - headBlockH - 2; + var bodyW = bodySize.x - 2; //$('#desktop').height(bodyY).width(bodyW); - if(p4.preview.open) + if (p4.preview.open) resizePreview(); if ($('#idFrameC').data('ui-resizable')) { - $('#idFrameC').resizable('option', 'maxWidth',(bodySize.x-670)); - $('#idFrameC').resizable('option', 'minWidth',265); + $('#idFrameC').resizable('option', 'maxWidth', (bodySize.x - 670)); + $('#idFrameC').resizable('option', 'minWidth', 265); } answerSizer(); @@ -333,14 +320,13 @@ function resize(){ } -function clearAnswers(){ +function clearAnswers() { $('#formAnswerPage').val(''); $('#searchForm input[name="nba"]').val(''); $('#answers, #dyn_tool').empty(); } -function reset_adv_search() -{ +function reset_adv_search() { $('#sbasfiltercont select[name="sort"]').val($('#sbasfiltercont select[name="sort"] option.default-selection').attr('value')); $('#sbasfiltercont input:checkbox.field_switch').removeAttr('checked'); $('#sbasfiltercont .datepicker').val(''); @@ -348,14 +334,12 @@ function reset_adv_search() checkBases(true); } -function search_doubles() -{ +function search_doubles() { $('#EDIT_query').val('sha256=sha256'); newSearch(); } -function newSearch() -{ +function newSearch() { $('#proposals').empty(); p4.Results.Selection.empty(); @@ -363,12 +347,11 @@ function newSearch() var val = $('#searchForm input[name="qry"]').val(); var histo = $('#history-queries ul'); - histo.prepend('
  • '+val+'
  • '); + histo.prepend('
  • ' + val + '
  • '); - var lis = $('li',histo); - if(lis.length > 25) - { - $('li:last',histo).remove(); + var lis = $('li', histo); + if (lis.length > 25) { + $('li:last', histo).remove(); } $('#idFrameC li.proposals_WZ').removeClass('active'); @@ -377,8 +360,7 @@ function newSearch() return false; } -function beforeSearch() -{ +function beforeSearch() { if (answAjaxrunning) return; answAjaxrunning = true; @@ -391,77 +373,75 @@ function beforeSearch() $('#answercontextwrap').remove(); } -function afterSearch() -{ - if($('#answercontextwrap').length === 0) +function afterSearch() { + if ($('#answercontextwrap').length === 0) $('body').append('
    '); - $.each($('#answers .contextMenuTrigger'),function(){ + $.each($('#answers .contextMenuTrigger'), function () { - var id = $(this).closest('.IMGT').attr('id').split('_').slice(1,3).join('_'); + var id = $(this).closest('.IMGT').attr('id').split('_').slice(1, 3).join('_'); - $(this).contextMenu('#IMGT_'+id+' .answercontextmenu',{ - appendTo:'#answercontextwrap', - openEvt:'click', - dropDown:true, - theme:'vista', - showTransition:'slideDown', - hideTransition:'hide', - shadow:false + $(this).contextMenu('#IMGT_' + id + ' .answercontextmenu', { + appendTo: '#answercontextwrap', + openEvt: 'click', + dropDown: true, + theme: 'vista', + showTransition: 'slideDown', + hideTransition: 'hide', + shadow: false }); }); answAjaxrunning = false; $('#answers').removeClass('loading'); $('.captionTips, .captionRolloverTips, .infoTips').tooltip({ - delay:0 + delay: 0 }); $('.previewTips').tooltip({ - fixable:true + fixable: true }); $('.thumb .rollovable').hover( - function(){ - $('.rollover-gif-hover',this).show(); - $('.rollover-gif-out',this).hide(); + function () { + $('.rollover-gif-hover', this).show(); + $('.rollover-gif-out', this).hide(); }, - function(){ - $('.rollover-gif-hover',this).hide(); - $('.rollover-gif-out',this).show(); + function () { + $('.rollover-gif-hover', this).hide(); + $('.rollover-gif-out', this).show(); } ); viewNbSelect(); $('#answers div.IMGT').draggable({ - helper : function(){ - $('body').append('
    '+p4.Results.Selection.length()+'
    '); + helper: function () { + $('body').append('
    ' + p4.Results.Selection.length() + '
    '); return $('#dragDropCursor'); }, - scope:"objects", - distance : 20, - scroll : false, + scope: "objects", + distance: 20, + scroll: false, cursorAt: { - top:-10, - left:-20 + top: -10, + left: -20 }, - start:function(event, ui) - { - if(!$(this).hasClass('selected')) + start: function (event, ui) { + if (!$(this).hasClass('selected')) return false; } }); linearize(); } -function initAnswerForm(){ +function initAnswerForm() { var searchForm = $('#searchForm'); - $('button[type="submit"]', searchForm).bind('click', function(){ + $('button[type="submit"]', searchForm).bind('click', function () { newSearch(); $('searchForm').trigger('submit'); return false; }); - searchForm.unbind('submit').bind('submit',function(){ + searchForm.unbind('submit').bind('submit', function () { var $this = $(this), method = $this.attr('method') ? $this.attr('method') : 'POST'; @@ -470,21 +450,21 @@ function initAnswerForm(){ type: method, url: $this.attr('action'), data: $this.serialize(), - dataType:'json', - beforeSend: function(formData){ - if(answAjaxrunning && answAjax.abort) + dataType: 'json', + beforeSend: function (formData) { + if (answAjaxrunning && answAjax.abort) answAjax.abort(); beforeSearch(); }, - error: function(){ + error: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - timeout: function(){ + timeout: function () { answAjaxrunning = false; $('#answers').removeClass('loading'); }, - success: function(datas){ + success: function (datas) { $('#answers').empty().append(datas.results).removeClass('loading'); @@ -495,12 +475,11 @@ function initAnswerForm(){ $('#tool_results').empty().append(datas.infos); $('#tool_navigate').empty().append(datas.navigation); - $.each(p4.Results.Selection.get(), function(i, el){ + $.each(p4.Results.Selection.get(), function (i, el) { $('#IMGT_' + el).addClass('selected'); }); - if(datas.phrasea_props && $.trim(datas.phrasea_props) !== '') - { + if (datas.phrasea_props && $.trim(datas.phrasea_props) !== '') { $('#proposals').empty().append(datas.phrasea_props); $('#idFrameC li.proposals_WZ').addClass('active'); } @@ -508,25 +487,21 @@ function initAnswerForm(){ p4.tot_options = datas.form; p4.tot_query = datas.query; - if(datas.next_page) - { - $("#NEXT_PAGE").bind('click',function(){ + if (datas.next_page) { + $("#NEXT_PAGE").bind('click', function () { gotopage(datas.next_page); }); } - else - { + else { $("#NEXT_PAGE").unbind('click'); } - if(datas.prev_page) - { - $("#PREV_PAGE").bind('click',function(){ + if (datas.prev_page) { + $("#PREV_PAGE").bind('click', function () { gotopage(datas.prev_page); }); } - else - { + else { $("#PREV_PAGE").unbind('click'); } @@ -535,107 +510,95 @@ function initAnswerForm(){ }); return false; }); - if(searchForm.hasClass('triggerAfterInit')) - { + if (searchForm.hasClass('triggerAfterInit')) { searchForm.removeClass('triggerAfterInit').trigger('submit'); } } -function answerSizer() -{ +function answerSizer() { var el = $('#idFrameC').outerWidth(); - if(!$.support.cssFloat) - { + if (!$.support.cssFloat) { $('#idFrameC .insidebloc').width(el - 56); } - var widthA = Math.round(bodySize.x-el-10); + var widthA = Math.round(bodySize.x - el - 10); $('#rightFrame').width(widthA); } -function linearize() -{ +function linearize() { var list = $('#answers .list'); - if(list.length>0) - { + if (list.length > 0) { var fllWidth = $('#answers').innerWidth(); fllWidth -= 16; var stdWidth = 460; - var diff=28; - var n = Math.round(fllWidth/(stdWidth)); - var w = Math.floor(fllWidth/n)-diff; - if(w<360 && n>1) - w = Math.floor(fllWidth/(n-1))-diff; + var diff = 28; + var n = Math.round(fllWidth / (stdWidth)); + var w = Math.floor(fllWidth / n) - diff; + if (w < 360 && n > 1) + w = Math.floor(fllWidth / (n - 1)) - diff; $('#answers .list').width(w); } - else - { + else { var margin = 0; var el = $('#answers .diapo:first'); var brdrWidth = el.css('border-width'); - var stdWidth = el.outerWidth()+10; + var stdWidth = el.outerWidth() + 10; var fllWidth = $('#answers').innerWidth(); fllWidth -= 16; - var n = Math.floor(fllWidth/(stdWidth)); + var n = Math.floor(fllWidth / (stdWidth)); - margin = Math.floor((fllWidth % stdWidth)/(2*n)); - $('#answers .diapo').css('margin','5px '+(5+margin)+'px'); + margin = Math.floor((fllWidth % stdWidth) / (2 * n)); + $('#answers .diapo').css('margin', '5px ' + (5 + margin) + 'px'); } } - -function initLook() -{ +function initLook() { $('#nperpage_slider').slider({ - value:parseInt($('#nperpage_value').val()), - min:10, - max:100, - step:10, - slide:function(event,ui){ + value: parseInt($('#nperpage_value').val()), + min: 10, + max: 100, + step: 10, + slide: function (event, ui) { $('#nperpage_value').val(ui.value); }, - stop:function(event,ui){ - setPref('images_per_page',$('#nperpage_value').val()); + stop: function (event, ui) { + setPref('images_per_page', $('#nperpage_value').val()); } }); $('#sizeAns_slider').slider({ - value:parseInt($('#sizeAns_value').val()), - min:90, - max:270, - step:10, - slide:function(event,ui){ + value: parseInt($('#sizeAns_value').val()), + min: 90, + max: 270, + step: 10, + slide: function (event, ui) { $('#sizeAns_value').val(ui.value); }, - stop:function(event,ui){ - setPref('images_size',$('#sizeAns_value').val()); + stop: function (event, ui) { + setPref('images_size', $('#sizeAns_value').val()); } }); } -function acceptCgus(name,value) -{ - setPref(name,value); +function acceptCgus(name, value) { + setPref(name, value); } -function cancelCgus(id) -{ +function cancelCgus(id) { $.ajax({ type: "POST", url: "../prod/TOU/deny/" + id + "/", - dataType:'json', - success: function(data){ - if(data.success) - { + dataType: 'json', + success: function (data) { + if (data.success) { alert(language.cgusRelog); self.location.replace(self.location.href); } - else - { + else { humane.error(data.message); } } @@ -643,73 +606,70 @@ function cancelCgus(id) } -function activateCgus() -{ +function activateCgus() { var $this = $('.cgu-dialog:first'); $this.dialog({ - autoOpen : true, - closeOnEscape:false, - draggable:false, - modal:true, - resizable:false, - width:800, - height:500, - open:function() { + autoOpen: true, + closeOnEscape: false, + draggable: false, + modal: true, + resizable: false, + width: 800, + height: 500, + open: function () { $this.parents(".ui-dialog:first").find(".ui-dialog-titlebar-close").remove(); - $('.cgus-accept',$(this)).bind('click',function(){ - acceptCgus($('.cgus-accept',$this).attr('id'),$('.cgus-accept',$this).attr('date')); + $('.cgus-accept', $(this)).bind('click', function () { + acceptCgus($('.cgus-accept', $this).attr('id'), $('.cgus-accept', $this).attr('date')); $this.dialog('close').remove(); activateCgus(); }); - $('.cgus-cancel',$(this)).bind('click',function(){ - if(confirm(language.warningDenyCgus)) - { - cancelCgus($('.cgus-cancel',$this).attr('id').split('_').pop()); + $('.cgus-cancel', $(this)).bind('click', function () { + if (confirm(language.warningDenyCgus)) { + cancelCgus($('.cgus-cancel', $this).attr('id').split('_').pop()); } }); } }); } -$(document).ready(function(){ +$(document).ready(function () { humane.forceNew = true; activateCgus(); }); -function triggerShortcuts() -{ +function triggerShortcuts() { - $('#keyboard-stop').bind('click', function(){ + $('#keyboard-stop').bind('click', function () { var display = $(this).get(0).checked ? '0' : '1'; - setPref('keyboard_infos',display); + setPref('keyboard_infos', display); }); var buttons = {}; - buttons[language.fermer] = function() { + buttons[language.fermer] = function () { $("#keyboard-dialog").dialog('close'); }; $('#keyboard-dialog').dialog({ - closeOnEscape:false, - resizable:false, - draggable:false, - modal:true, - width:600, - height:400, + closeOnEscape: false, + resizable: false, + draggable: false, + modal: true, + width: 600, + height: 400, overlay: { backgroundColor: '#000', opacity: 0.7 }, - open: function(event, ui) { + open: function (event, ui) { $(this).dialog("widget").css("z-index", "1400"); }, - close : function(){ + close: function () { $(this).dialog("widget").css("z-index", "auto"); - if($('#keyboard-stop').get(0).checked) { + if ($('#keyboard-stop').get(0).checked) { var dialog = $('#keyboard-dialog'); if (dialog.data("ui-dialog")) { dialog.dialog('destroy'); @@ -717,20 +677,18 @@ function triggerShortcuts() dialog.remove(); } } - }).dialog('option','buttons',buttons).dialog('open'); + }).dialog('option', 'buttons', buttons).dialog('open'); $('#keyboard-dialog').scrollTop(0); return false; } -function activeZoning() -{ - $('#idFrameC, #rightFrame').bind('mousedown',function(event){ +function activeZoning() { + $('#idFrameC, #rightFrame').bind('mousedown', function (event) { var old_zone = p4.active_zone; p4.active_zone = $(this).attr('id'); - if(p4.active_zone !== old_zone && p4.active_zone !== 'headBlock') - { + if (p4.active_zone !== old_zone && p4.active_zone !== 'headBlock') { $('.effectiveZone.activeZone').removeClass('activeZone'); $('.effectiveZone', this).addClass('activeZone');//.flash('#555555'); } @@ -739,23 +697,23 @@ function activeZoning() $('#rightFrame').trigger('mousedown'); } -function RGBtoHex(R,G,B) { - return toHex(R)+toHex(G)+toHex(B); +function RGBtoHex(R, G, B) { + return toHex(R) + toHex(G) + toHex(B); } function toHex(N) { if (N === null) return "00"; - N=parseInt(N); + N = parseInt(N); if (N === 0 || isNaN(N)) return "00"; - N=Math.max(0,N); - N=Math.min(N,255); - N=Math.round(N); - return "0123456789ABCDEF".charAt((N-N%16)/16) - + "0123456789ABCDEF".charAt(N%16); + N = Math.max(0, N); + N = Math.min(N, 255); + N = Math.round(N); + return "0123456789ABCDEF".charAt((N - N % 16) / 16) + + "0123456789ABCDEF".charAt(N % 16); } function hsl2rgb(h, s, l) { var m1, m2, hue; var r, g, b; - s /=100; + s /= 100; l /= 100; if (s === 0) r = g = b = (l * 255); @@ -766,9 +724,9 @@ function hsl2rgb(h, s, l) { m2 = l + s - l * s; m1 = l * 2 - m2; hue = h / 360; - r = HueToRgb(m1, m2, hue + 1/3); + r = HueToRgb(m1, m2, hue + 1 / 3); g = HueToRgb(m1, m2, hue); - b = HueToRgb(m1, m2, hue - 1/3); + b = HueToRgb(m1, m2, hue - 1 / 3); } return { r: r, @@ -789,22 +747,22 @@ function HueToRgb(m1, m2, hue) { else if (2 * hue < 1) v = m2; else if (3 * hue < 2) - v = m1 + (m2 - m1) * (2/3 - hue) * 6; + v = m1 + (m2 - m1) * (2 / 3 - hue) * 6; else v = m1; return 255 * v; } -$(document).ready(function(){ +$(document).ready(function () { - $('.adv_search_button').live('click', function(){ + $('.adv_search_button').live('click', function () { var searchForm = $('#searchForm'); var parent = searchForm.parent(); var options = { - loading:false, - closeCallback: function(dialog){ + loading: false, + closeCallback: function (dialog) { var datas = dialog.find('form.phrasea_query').appendTo(parent);//.clone(); @@ -820,7 +778,7 @@ $(document).ready(function(){ $dialog.getDomElement().find('.adv_options').show(); $dialog.getDomElement().find('.adv_trigger').hide(); - $dialog.getDomElement().find('form').bind('submit.conbo', function(){ + $dialog.getDomElement().find('form').bind('submit.conbo', function () { $(this).unbind('submit.conbo'); $dialog.Close(); return false; @@ -830,12 +788,11 @@ $(document).ready(function(){ return false; }); - $(document).bind('contextmenu', function(event){ + $(document).bind('contextmenu', function (event) { var targ; if (event.target) targ = event.target; - else - if (event.srcElement) + else if (event.srcElement) targ = event.srcElement; if (targ.nodeType === 3)// safari bug targ = targ.parentNode; @@ -843,30 +800,28 @@ $(document).ready(function(){ var gogo = true; var targ_name = targ.nodeName ? targ.nodeName.toLowerCase() : false; - if(targ_name !== 'input' && targ_name.toLowerCase() !== 'textarea') - { + if (targ_name !== 'input' && targ_name.toLowerCase() !== 'textarea') { gogo = false; } - if(targ_name === 'input') - { - if($(targ).is(':checkbox')) + if (targ_name === 'input') { + if ($(targ).is(':checkbox')) gogo = false; } return gogo; }); - $('.basket_refresher').live('click', function(){ + $('.basket_refresher').live('click', function () { return p4.WorkZone.refresh('current'); return false; }); $('#loader_bar').stop().animate({ - width:'70%' - },450); + width: '70%' + }, 450); p4.preview = { - open:false, - current:false + open: false, + current: false }; p4.currentViewMode = 'classic'; p4.nbNoview = 0; @@ -875,7 +830,7 @@ $(document).ready(function(){ p4.baskSel = []; p4.edit = {}; p4.thesau = { - tabs:null + tabs: null }; p4.active_zone = false; p4.next_bask_scroll = false; @@ -883,23 +838,20 @@ $(document).ready(function(){ $('#backcolorpickerHolder').ColorPicker({ flat: true, - color:'404040', - livePreview:false, - eventName:'mouseover', - onSubmit: function(hsb, hex, rgb, el){ + color: '404040', + livePreview: false, + eventName: 'mouseover', + onSubmit: function (hsb, hex, rgb, el) { var back_hex = ''; var unactive = ''; - - if(hsb.b >=50) - { + if (hsb.b >= 50) { back_hex = '000000'; var sim_b = 0.1 * hsb.b; } - else - { + else { back_hex = 'FFFFFF'; var sim_b = 100 - 0.1 * (100 - hsb.b); @@ -908,7 +860,7 @@ $(document).ready(function(){ var sim_b = 0.1 * hsb.b; var sim_rgb = hsl2rgb(hsb.h, hsb.s, sim_b); - var sim_hex = RGBtoHex(sim_rgb.r,sim_rgb.g,sim_rgb.b); + var sim_hex = RGBtoHex(sim_rgb.r, sim_rgb.g, sim_rgb.b); setPref('background-selection', hex); setPref('background-selection-disabled', sim_hex); @@ -917,30 +869,30 @@ $(document).ready(function(){ $('style[title=color_selection]').empty(); var datas = '.diapo.selected,#reorder_box .diapo.selected, #EDIT_ALL .diapo.selected, .list.selected, .list.selected .diapo' + - '{'+ - ' COLOR: #'+back_hex+';'+ - ' BACKGROUND-COLOR: #'+hex+';'+ + '{' + + ' COLOR: #' + back_hex + ';' + + ' BACKGROUND-COLOR: #' + hex + ';' + '}'; $('style[title=color_selection]').empty().text(datas); } }); - $('#backcolorpickerHolder').find('.colorpicker_submit').append($('#backcolorpickerHolder .submiter')).bind('click',function(){ + $('#backcolorpickerHolder').find('.colorpicker_submit').append($('#backcolorpickerHolder .submiter')).bind('click', function () { $(this).highlight('#CCCCCC'); }); - $('#answers .see_more a').live('click', function(event){ + $('#answers .see_more a').live('click', function (event) { $see_more = $(this).closest('.see_more'); $see_more.addClass('loading'); }); - $('#answers .feed .entry').live('mouseover', function(){ + $('#answers .feed .entry').live('mouseover', function () { $(this).addClass('hover'); }); - $('#answers .feed .entry').live('mouseout', function(){ + $('#answers .feed .entry').live('mouseout', function () { $(this).removeClass('hover'); }); - $('a.ajax_answers').live('click', function(event){ + $('a.ajax_answers').live('click', function (event) { event.stopPropagation(); var $this = $(this); @@ -948,23 +900,20 @@ $(document).ready(function(){ var no_scroll = $this.hasClass('no_scroll'); $.ajax({ - type:"GET", - url : $this.attr('href'), + type: "GET", + url: $this.attr('href'), dataType: 'html', - success : function(data){ + success: function (data) { var $answers = $('#answers'); - if(!append) - { + if (!append) { $answers.empty(); - if(!no_scroll) - { + if (!no_scroll) { $answers.scrollTop(0); } $answers.append(data); } - else - { + else { $('.see_more.loading', $answers).remove(); $answers.append(data); @@ -972,10 +921,9 @@ $(document).ready(function(){ container: $answers }); - if(!no_scroll) - { + if (!no_scroll) { $answers.animate({ - 'scrollTop':($answers.scrollTop()+$answers.innerHeight()-80) + 'scrollTop': ($answers.scrollTop() + $answers.innerHeight() - 80) }); } } @@ -987,24 +935,23 @@ $(document).ready(function(){ }); - - $('a.subscribe_rss').live('click',function(event){ + $('a.subscribe_rss').live('click', function (event) { var $this = $(this); - if(typeof(renew) === 'undefined') + if (typeof(renew) === 'undefined') renew = 'false'; else renew = renew ? 'true' : 'false'; var buttons = {}; - buttons[language.renewRss] = function() { + buttons[language.renewRss] = function () { $this.trigger({ - type:'click', - renew:true + type: 'click', + renew: true }); }; - buttons[language.fermer] = function() { + buttons[language.fermer] = function () { $('#DIALOG').empty().dialog('destroy'); }; @@ -1012,27 +959,26 @@ $(document).ready(function(){ var $this = $(this); $.ajax({ - type:"GET", - url : $this.attr('href')+(event.renew === true ? '?renew=true' : ''), + type: "GET", + url: $this.attr('href') + (event.renew === true ? '?renew=true' : ''), dataType: 'json', - success : function(data){ - if(data.texte !== false && data.titre !== false) - { + success: function (data) { + if (data.texte !== false && data.titre !== false) { if ($("#DIALOG").data("ui-dialog")) { $("#DIALOG").dialog('destroy'); } - $("#DIALOG").attr('title',data.titre) + $("#DIALOG").attr('title', data.titre) .empty() .append(data.texte) .dialog({ - autoOpen:false, - closeOnEscape:true, - resizable:false, - draggable:false, - modal:true, - buttons:buttons, - width:650, - height:250, + autoOpen: false, + closeOnEscape: true, + resizable: false, + draggable: false, + modal: true, + buttons: buttons, + width: 650, + height: 250, overlay: { backgroundColor: '#000', opacity: 0.7 @@ -1046,13 +992,13 @@ $(document).ready(function(){ return false; }); - $('#search_submit').live('mousedown',function(event){ + $('#search_submit').live('mousedown', function (event) { return false; }); - $('#history-queries ul li').live('mouseover',function(){ + $('#history-queries ul li').live('mouseover',function () { $(this).addClass('hover'); - }).live('mouseout',function(){ + }).live('mouseout', function () { $(this).removeClass('hover'); }); @@ -1061,44 +1007,43 @@ $(document).ready(function(){ activeZoning(); - $('.shortcuts-trigger').bind('click',function(){ + $('.shortcuts-trigger').bind('click', function () { triggerShortcuts(); }); $('#idFrameC').resizable({ - handles : 'e', - resize:function(){ + handles: 'e', + resize: function () { answerSizer(); linearize(); }, - stop:function(){ + stop: function () { var el = $('.SSTT.active').next().find('div:first'); var w = el.find('div.chim-wrapper:first').outerWidth(); var iw = el.innerWidth(); - var diff = $('#idFrameC').width() - el.outerWidth(); - var n = Math.floor(iw/w); + var diff = $('#idFrameC').width() - el.outerWidth(); + var n = Math.floor(iw / w); $('#idFrameC').height('auto'); - var nwidth = (n)*w+diff+n; - if(isNaN(nwidth)) - { + var nwidth = (n) * w + diff + n; + if (isNaN(nwidth)) { saveWindows(); return; } - if(nwidth<265) + if (nwidth < 265) nwidth = 265; - if(el.find('div.chim-wrapper:first').hasClass('valid') && nwidth<410) + if (el.find('div.chim-wrapper:first').hasClass('valid') && nwidth < 410) nwidth = 410; $('#idFrameC').stop().animate({ - width : nwidth + width: nwidth }, 300, 'linear', - function(){ + function () { answerSizer(); linearize(); saveWindows(); @@ -1106,7 +1051,7 @@ $(document).ready(function(){ } }); - $('#idFrameC .escamote').bind('click', function(event){ + $('#idFrameC .escamote').bind('click', function (event) { event.stopImmediatePropagation(); p4.WorkZone.close(); return false; @@ -1116,20 +1061,20 @@ $(document).ready(function(){ resize(); - $(window).bind('resize', function(){ + $(window).bind('resize', function () { resize(); }); $('body').append(''); $('body').append(''); - $('#basket_menu_trigger').contextMenu('#basket_menu',{ - openEvt:'click', - dropDown:true, - theme:'vista', - showTransition:'slideDown', - hideTransition:'hide', - shadow:false + $('#basket_menu_trigger').contextMenu('#basket_menu', { + openEvt: 'click', + dropDown: true, + theme: 'vista', + showTransition: 'slideDown', + hideTransition: 'hide', + shadow: false }); $('#basket_menu_trigger').trigger("click"); @@ -1137,41 +1082,39 @@ $(document).ready(function(){ $('.datepicker').datepicker({ changeYear: true, - changeMonth:true, - dateFormat:'yy/mm/dd' + changeMonth: true, + dateFormat: 'yy/mm/dd' }); $.ajaxSetup({ - error: function(jqXHR, textStatus, errorThrown) { + error: function (jqXHR, textStatus, errorThrown) { //Request is aborted if (errorThrown === 'abort') { return false; } else { - showModal('error',{ + showModal('error', { title: language.errorAjaxRequest + ' ' + jqXHR.responseText }); } }, - timeout: function(){ - showModal('timeout',{ - title:'Server not responding' + timeout: function () { + showModal('timeout', { + title: 'Server not responding' }); } }); - $('.tools .answer_selector').bind('click',function(){ + $('.tools .answer_selector').bind('click',function () { selector($(this)); - }).bind('mouseover',function(event){ - if(is_ctrl_key(event)) - { + }).bind('mouseover',function (event) { + if (is_ctrl_key(event)) { $(this).addClass('add_selector'); } - else - { + else { $(this).removeClass('add_selector'); } - }).bind('mouseout',function(){ + }).bind('mouseout', function () { $(this).removeClass('add_selector'); }); @@ -1185,27 +1128,21 @@ $(document).ready(function(){ setTimeout("sessionactive();", 30000); - $(this).bind('keydown',function(event) - { + $(this).bind('keydown', function (event) { var cancelKey = false; var shortCut = false; - if ($('#MODALDL').is(':visible')) - { - switch(event.keyCode) - { + if ($('#MODALDL').is(':visible')) { + switch (event.keyCode) { case 27: hideDwnl(); break; } } - else - { - if($('#EDITWINDOW').is(':visible')) - { + else { + if ($('#EDITWINDOW').is(':visible')) { - switch(event.keyCode) - { + switch (event.keyCode) { case 9: // tab ou shift-tab edit_chgFld(event, is_shift_key(event) ? -1 : 1); cancelKey = shortCut = true; @@ -1216,25 +1153,22 @@ $(document).ready(function(){ break; case 33: // pg up - if(!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok")) + if (!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok")) skipImage(event, 1); cancelKey = true; break; case 34: // pg dn - if(!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok")) + if (!p4.edit.textareaIsDirty || edit_validField(event, "ask_ok")) skipImage(event, -1); cancelKey = true; break; } } - else - { - if(p4.preview.open) - { + else { + if (p4.preview.open) { if (($('#dialog_dwnl:visible').length === 0 && $('#DIALOG1').length === 0 && $('#DIALOG2').length === 0)) { - switch(event.keyCode) - { + switch (event.keyCode) { case 39: getNext(); cancelKey = shortCut = true; @@ -1247,7 +1181,7 @@ $(document).ready(function(){ closePreview(); break; case 32: - if(p4.slideShow) + if (p4.slideShow) stopSlide(); else startSlide(); @@ -1256,49 +1190,43 @@ $(document).ready(function(){ } } } - else - { - if($('#EDIT_query').hasClass('focused')) + else { + if ($('#EDIT_query').hasClass('focused')) return true; - if($('.overlay').is(':visible')) + if ($('.overlay').is(':visible')) return true; - if($('.ui-widget-overlay').is(':visible')) + if ($('.ui-widget-overlay').is(':visible')) return true; - switch(p4.active_zone) - { + switch (p4.active_zone) { case 'rightFrame': - switch(event.keyCode) - { + switch (event.keyCode) { case 65: // a - if(is_ctrl_key(event)) - { + if (is_ctrl_key(event)) { $('.tools .answer_selector.all_selector').trigger('click'); cancelKey = shortCut = true; } break; case 80://P - if(is_ctrl_key(event)) - { - printThis("lst="+p4.Results.Selection.serialize()); + if (is_ctrl_key(event)) { + printThis("lst=" + p4.Results.Selection.serialize()); cancelKey = shortCut = true; } break; case 69://e - if(is_ctrl_key(event)) - { - editThis('IMGT',p4.Results.Selection.serialize()); + if (is_ctrl_key(event)) { + editThis('IMGT', p4.Results.Selection.serialize()); cancelKey = shortCut = true; } break; case 40: // down arrow - $('#answers').scrollTop($('#answers').scrollTop()+30); + $('#answers').scrollTop($('#answers').scrollTop() + 30); cancelKey = shortCut = true; break; case 38: // down arrow - $('#answers').scrollTop($('#answers').scrollTop()-30); + $('#answers').scrollTop($('#answers').scrollTop() - 30); cancelKey = shortCut = true; break; case 37://previous page @@ -1310,8 +1238,7 @@ $(document).ready(function(){ shortCut = true; break; case 9://tab - if(!is_ctrl_key(event) && !$('.ui-widget-overlay').is(':visible') && !$('.overlay_box').is(':visible')) - { + if (!is_ctrl_key(event) && !$('.ui-widget-overlay').is(':visible') && !$('.overlay_box').is(':visible')) { document.getElementById('EDIT_query').focus(); cancelKey = shortCut = true; } @@ -1321,26 +1248,22 @@ $(document).ready(function(){ case 'idFrameC': - switch(event.keyCode) - { + switch (event.keyCode) { case 65: // a - if(is_ctrl_key(event)) - { + if (is_ctrl_key(event)) { p4.WorkZone.Selection.selectAll(); cancelKey = shortCut = true; } break; case 80://P - if(is_ctrl_key(event)) - { - printThis("lst="+p4.WorkZone.Selection.serialize()); + if (is_ctrl_key(event)) { + printThis("lst=" + p4.WorkZone.Selection.serialize()); cancelKey = shortCut = true; } break; case 69://e - if(is_ctrl_key(event)) - { - editThis('IMGT',p4.WorkZone.Selection.serialize()); + if (is_ctrl_key(event)) { + editThis('IMGT', p4.WorkZone.Selection.serialize()); cancelKey = shortCut = true; } break; @@ -1349,11 +1272,11 @@ $(document).ready(function(){ // cancelKey = true; // break; case 40: // down arrow - $('#baskets div.bloc').scrollTop($('#baskets div.bloc').scrollTop()+30); + $('#baskets div.bloc').scrollTop($('#baskets div.bloc').scrollTop() + 30); cancelKey = shortCut = true; break; case 38: // down arrow - $('#baskets div.bloc').scrollTop($('#baskets div.bloc').scrollTop()-30); + $('#baskets div.bloc').scrollTop($('#baskets div.bloc').scrollTop() - 30); cancelKey = shortCut = true; break; // case 37://previous page @@ -1363,8 +1286,7 @@ $(document).ready(function(){ // $('#NEXT_PAGE').trigger('click'); // break; case 9://tab - if(!is_ctrl_key(event) && !$('.ui-widget-overlay').is(':visible') && !$('.overlay_box').is(':visible')) - { + if (!is_ctrl_key(event) && !$('.ui-widget-overlay').is(':visible') && !$('.overlay_box').is(':visible')) { document.getElementById('EDIT_query').focus(); cancelKey = shortCut = true; } @@ -1388,18 +1310,15 @@ $(document).ready(function(){ } } - if(!$('#EDIT_query').hasClass('focused') && event.keyCode !== 17) - { + if (!$('#EDIT_query').hasClass('focused') && event.keyCode !== 17) { - if($('#keyboard-dialog.auto').length > 0 && shortCut) - { + if ($('#keyboard-dialog.auto').length > 0 && shortCut) { triggerShortcuts(); } } - if(cancelKey) - { + if (cancelKey) { event.cancelBubble = true; - if(event.stopPropagation) + if (event.stopPropagation) event.stopPropagation(); return(false); } @@ -1407,10 +1326,9 @@ $(document).ready(function(){ }); - - $('#EDIT_query').bind('focus',function(){ + $('#EDIT_query').bind('focus',function () { $(this).addClass('focused'); - }).bind('blur',function(){ + }).bind('blur', function () { $(this).removeClass('focused'); }); @@ -1419,8 +1337,8 @@ $(document).ready(function(){ }); $('#idFrameC .tabs').tabs({ - activate: function(event, ui){ - if(ui.newTab.context.hash == "#thesaurus_tab") { + activate: function (event, ui) { + if (ui.newTab.context.hash == "#thesaurus_tab") { thesau_show(); } p4.WorkZone.open(); @@ -1428,12 +1346,11 @@ $(document).ready(function(){ }); $('#PREVIEWBOX .gui_vsplitter', p4.edit.editBox).draggable({ - axis:'x', - containment:'parent', - drag:function(event,ui){ + axis: 'x', + containment: 'parent', + drag: function (event, ui) { var x = $(ui.position.left)[0]; - if(x<330 || x>(bodySize.x-400)) - { + if (x < 330 || x > (bodySize.x - 400)) { return false; } var v = $(ui.position.left)[0]; @@ -1443,44 +1360,43 @@ $(document).ready(function(){ } }); - $('input.input_select_copy').live('focus', function(){ + $('input.input_select_copy').live('focus', function () { $(this).select(); }); - $('input.input_select_copy').live('blur', function(){ + $('input.input_select_copy').live('blur', function () { $(this).deselect(); }); - $('input.input_select_copy').live('click', function(){ + $('input.input_select_copy').live('click', function () { $(this).select(); }); - $('#answers .feed .entry a.options').live('click', function(){ + $('#answers .feed .entry a.options').live('click', function () { var $this = $(this); $.ajax({ - type:"GET", - url : $this.attr('href'), + type: "GET", + url: $this.attr('href'), dataType: 'html', - success : function(data){ + success: function (data) { return set_up_feed_box(data); } }); return false; }); - $('#answers .feed .entry a.feed_delete').live('click', function(){ - if(!confirm('etes vous sur de vouloir supprimer cette entree ?')) + $('#answers .feed .entry a.feed_delete').live('click', function () { + if (!confirm('etes vous sur de vouloir supprimer cette entree ?')) return false; var $this = $(this); $.ajax({ - type:"POST", - url : $this.attr('href'), + type: "POST", + url: $this.attr('href'), dataType: 'json', - success : function(data){ - if(data.error === false) - { + success: function (data) { + if (data.error === false) { var $entry = $this.closest('.entry'); $entry.animate({ - height:0, - opacity:0 - }, function(){ + height: 0, + opacity: 0 + }, function () { $entry.remove(); }); } @@ -1493,9 +1409,9 @@ $(document).ready(function(){ $('#loader_bar').stop().animate({ - width:'100%' - }, 450, function(){ - $('#loader').parent().fadeOut('slow',function(){ + width: '100%' + }, 450, function () { + $('#loader').parent().fadeOut('slow', function () { $(this).remove(); }); }); @@ -1504,8 +1420,7 @@ $(document).ready(function(){ }); -function editThis(type,value) -{ +function editThis(type, value) { $('#idFrameE').empty().addClass('loading'); showOverlay(2); @@ -1513,12 +1428,12 @@ function editThis(type,value) $('#EDITWINDOW').show(); var options = { - lst:'', - ssel:'', - act:'' + lst: '', + ssel: '', + act: '' }; - switch(type){ + switch (type) { case "IMGT": options.lst = value; break; @@ -1537,14 +1452,14 @@ function editThis(type,value) type: "POST", dataType: "html", data: options, - success: function(data){ + success: function (data) { initializeEdit(); $('#idFrameE').removeClass('loading').empty().html(data); $('#tooltip').hide(); return; }, - error: function(XHR, textStatus, errorThrown){ - if(XHR.status === 0){ + error: function (XHR, textStatus, errorThrown) { + if (XHR.status === 0) { return false; } } @@ -1553,60 +1468,57 @@ function editThis(type,value) return; } -(function($) { +(function ($) { $.fn.extend({ - highlight: function(color) { - if($(this).hasClass('animating')) - { + highlight: function (color) { + if ($(this).hasClass('animating')) { return; } color = typeof color !== 'undefined' ? color : 'red'; var oldColor = $(this).css('backgroundColor'); return $(this).addClass('animating').stop().animate({ backgroundColor: color - }, 50, 'linear', function(){ + }, 50, 'linear', function () { $(this).stop().animate({ backgroundColor: oldColor - }, 450, 'linear',function(){ + }, 450, 'linear', function () { $(this).removeClass('animating'); - } ); + }); }); } }); })(jQuery); -(function($) { +(function ($) { $.fn.extend({ - flash: function(color) { - if($(this).hasClass('animating')) - { + flash: function (color) { + if ($(this).hasClass('animating')) { return true; } color = typeof color !== 'undefined' ? color : 'red'; var pos = $(this).offset(); - if(!pos) - { + if (!pos) { pos = { - top:0, - left:0 + top: 0, + left: 0 }; } var h = $(this).height(); var w = $(this).width(); - $('body').append('
    '); + $('body').append('
    '); $(this).addClass('animating'); var el = $(this); $('#flashing').stop().animate({ - top:(pos.top+(h/4)), - left:(pos.left+(w/4)), - opacity:0, - width:($(this).width()/2), - height:($(this).height()/2) - },700,function(){ + top: (pos.top + (h / 4)), + left: (pos.left + (w / 4)), + opacity: 0, + width: ($(this).width() / 2), + height: ($(this).height() / 2) + }, 700, function () { $('#flashing').remove(); $(el).removeClass('animating'); }); @@ -1615,25 +1527,21 @@ function editThis(type,value) })(jQuery); -function toggleRemoveReg(el) -{ +function toggleRemoveReg(el) { var state = !el.checked; - setPref('reg_delete', (state?'1':'0')); + setPref('reg_delete', (state ? '1' : '0')); p4.reg_delete = state; } - - -function deleteThis(lst) -{ - if(lst.split(';').length === 0 ) { +function deleteThis(lst) { + if (lst.split(';').length === 0) { alert(language.nodocselected); return false; } var $dialog = p4.Dialog.Create({ - size:'Small', + size: 'Small', title: language.deleteRecords }); @@ -1642,7 +1550,7 @@ function deleteThis(lst) url: "../prod/records/delete/what/", dataType: 'html', data: {lst: lst}, - success: function(data){ + success: function (data) { $dialog.setContent(data); } }); @@ -1650,69 +1558,66 @@ function deleteThis(lst) return false; } -function chgCollThis(datas) -{ +function chgCollThis(datas) { $dialog = p4.Dialog.Create({ - size:'Small', + size: 'Small', title: language.move, - closeButton:true + closeButton: true }); $.ajax({ type: "POST", url: "../prod/records/movecollection/", data: datas, - success: function(data){ + success: function (data) { $dialog.setContent(data); } }); } -function pushThis(sstt_id, lst, story) -{ +function pushThis(sstt_id, lst, story) { $dialog = p4.Dialog.Create({ - size:'Full', - title:language.push + size: 'Full', + title: language.push }); $.post("../prod/push/sendform/", { - lst : lst, - ssel : sstt_id, - story : story - }, function(data){ + lst: lst, + ssel: sstt_id, + story: story + }, function (data) { $dialog.setContent(data); return; }); } -function feedbackThis(sstt_id, lst, story) -{ +function feedbackThis(sstt_id, lst, story) { /* disable push closeonescape as an over dialog may exist (add user) */ $dialog = p4.Dialog.Create({ - size:'Full', - title:language.feedback + size: 'Full', + title: language.feedback }); $.post("../prod/push/validateform/", { - lst : lst, - ssel : sstt_id, - story : story - }, function(data){ + lst: lst, + ssel: sstt_id, + story: story + }, function (data) { $dialog.setContent(data); return; }); } -function toolREFACTOR(datas){ +function toolREFACTOR(datas) { var dialog = p4.Dialog.Create({ - size:'Medium', - title:language.toolbox, + size: 'Medium', + title: language.toolbox, loading: true }); $.get("../prod/tools/" , datas - , function(data){ + , function (data) { dialog.setContent(data); return; } @@ -1720,293 +1625,231 @@ function toolREFACTOR(datas){ } -function activeIcons() -{ - $('.TOOL_print_btn').live('click', function(){ - var value=""; +function activeIcons() { + $('.TOOL_print_btn').live('click', function () { + var value = ""; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) value = "lst=" + p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) value = "lst=" + p4.WorkZone.Selection.serialize(); else - value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + value = "SSTTID=" + $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { value = "lst=" + p4.WorkZone.Selection.serialize(); } - else - { - value = "story=" + $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + value = "story=" + $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(value !== '') - { + if (value !== '') { printThis(value); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_bridge_btn').live('click', function(){ + $('.TOOL_bridge_btn').live('click', function () { var datas = {}; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) datas.lst = p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) datas.lst = p4.WorkZone.Selection.serialize(); else - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { datas.lst = p4.WorkZone.Selection.serialize(); } - else - { - datas.story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + datas.story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(datas.ssel || datas.lst || datas.story) - { + if (datas.ssel || datas.lst || datas.story) { init_publicator(datas); } - else - { + else { alert(language.nodocselected); } }); - - $('.TOOL_trash_btn').live('click', function(){ - var type=""; + $('.TOOL_trash_btn').live('click', function () { + var type = ""; var el = false; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) type = 'IMGT'; } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) type = 'CHIM'; - else{ + else { type = 'SSTT'; el = $('.SSTT.active'); } } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { type = 'CHIM'; } - else - { + else { type = 'STORY'; el = $(this).find('input[name=story_key]'); } } } } - if(type !== '') - { + if (type !== '') { checkDeleteThis(type, el); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_ppen_btn').live('click', function(){ - var value=""; + $('.TOOL_ppen_btn').live('click', function () { + var value = ""; var type = ""; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) - { + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) { type = 'IMGT'; value = p4.Results.Selection.serialize(); } } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; value = p4.WorkZone.Selection.serialize(); } - else - { + else { type = 'SSTT'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } - else - { - if($(this).hasClass('basket_element')) - { + else { + if ($(this).hasClass('basket_element')) { type = 'SSTT'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; value = p4.WorkZone.Selection.serialize(); } - else - { + else { type = 'STORY'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(value !== '') - { - editThis(type,value); + if (value !== '') { + editThis(type, value); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_publish_btn').live('click', function(){ - var value=""; + $('.TOOL_publish_btn').live('click', function () { + var value = ""; var type = ""; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) - { + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) { type = 'IMGT'; value = p4.Results.Selection.serialize(); } } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; value = p4.WorkZone.Selection.serialize(); } - else - { + else { type = 'SSTT'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } - else - { - if($(this).hasClass('basket_element')) - { + else { + if ($(this).hasClass('basket_element')) { type = 'SSTT'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { type = 'IMGT'; value = p4.WorkZone.Selection.serialize(); } - else - { + else { type = 'STORY'; - value = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(value !== '') - { - feedThis(type,value); + if (value !== '') { + feedThis(type, value); } - else - { + else { alert(language.nodocselected); } }); - function feedThis(type,value) - { + function feedThis(type, value) { var $feed_box = $('#modal_feed'); var options = { - lst:'', - ssel:'', - act:'' + lst: '', + ssel: '', + act: '' }; - switch(type){ + switch (type) { case "IMGT": case "CHIM": options.lst = value; @@ -2022,7 +1865,7 @@ function activeIcons() $.post("../prod/feeds/requestavailable/" , options - , function(data){ + , function (data) { return set_up_feed_box(data); }); @@ -2030,40 +1873,31 @@ function activeIcons() return; } - $('.TOOL_chgcoll_btn').live('click', function(){ + $('.TOOL_chgcoll_btn').live('click', function () { var value = {}; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) value.lst = p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) value.lst = p4.WorkZone.Selection.serialize(); else - value.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + value.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - value.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + value.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { value.lst = p4.WorkZone.Selection.serialize(); } - else - { - value.story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + value.story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } @@ -2073,15 +1907,14 @@ function activeIcons() /** * if works, then the object is not empty */ - for(i in value) - { + for (i in value) { return chgCollThis(value); } alert(language.nodocselected); }); - $('.TOOL_chgstatus_btn').live('click', function(){ + $('.TOOL_chgstatus_btn').live('click', function () { var params = {}; var $this = $(this); @@ -2094,17 +1927,17 @@ function activeIcons() if (p4.WorkZone.Selection.length() > 0) { params.lst = p4.WorkZone.Selection.serialize(); } else { - params.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + params.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } else { if ($this.hasClass('basket_element')) { - params.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + params.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } else { if ($this.hasClass('story_window')) { if (p4.WorkZone.Selection.length() > 0) { params.lst = p4.WorkZone.Selection.serialize(); } else { - params.story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + params.story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } @@ -2119,203 +1952,157 @@ function activeIcons() } }); - $('.TOOL_pushdoc_btn').live('click', function(){ - var value="",type="",sstt_id="", story =""; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + $('.TOOL_pushdoc_btn').live('click', function () { + var value = "", type = "", sstt_id = "", story = ""; + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) value = p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) value = p4.WorkZone.Selection.serialize(); else - sstt_id = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + sstt_id = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - sstt_id = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + sstt_id = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { value = p4.WorkZone.Selection.serialize(); } - else - { - story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(value !== '' || sstt_id !== '' || story !== '') - { + if (value !== '' || sstt_id !== '' || story !== '') { pushThis(sstt_id, value, story); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_feedback_btn').live('click', function(){ - var value="",type="",sstt_id="", story=''; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + $('.TOOL_feedback_btn').live('click', function () { + var value = "", type = "", sstt_id = "", story = ''; + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) value = p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) value = p4.WorkZone.Selection.serialize(); else - sstt_id = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + sstt_id = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - sstt_id = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + sstt_id = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { value = p4.WorkZone.Selection.serialize(); } - else - { - story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(value !== '' || sstt_id !== '' || story !== '') - { + if (value !== '' || sstt_id !== '' || story !== '') { feedbackThis(sstt_id, value, story); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_imgtools_btn').live('click', function(){ + $('.TOOL_imgtools_btn').live('click', function () { var datas = {}; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) datas.lst = p4.Results.Selection.serialize(); } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) datas.lst = p4.WorkZone.Selection.serialize(); else - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('basket_element')) - { - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { datas.lst = p4.WorkZone.Selection.serialize(); } - else - { - datas.story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + datas.story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - if(!$.isEmptyObject(datas)) - { + if (!$.isEmptyObject(datas)) { toolREFACTOR(datas); } - else - { + else { alert(language.nodocselected); } }); - $('.TOOL_disktt_btn').live('click', function(){ + $('.TOOL_disktt_btn').live('click', function () { var datas = {}; - if($(this).hasClass('results_window')) - { - if(p4.Results.Selection.length() > 0) - { + if ($(this).hasClass('results_window')) { + if (p4.Results.Selection.length() > 0) { datas.lst = p4.Results.Selection.serialize(); } } - else - { - if($(this).hasClass('basket_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('basket_window')) { + if (p4.WorkZone.Selection.length() > 0) { datas.lst = p4.WorkZone.Selection.serialize(); } - else - { - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } - else - { - if($(this).hasClass('basket_element')) - { - datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + if ($(this).hasClass('basket_element')) { + datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } - else - { - if($(this).hasClass('story_window')) - { - if(p4.WorkZone.Selection.length() > 0) - { + else { + if ($(this).hasClass('story_window')) { + if (p4.WorkZone.Selection.length() > 0) { datas.lst = p4.WorkZone.Selection.serialize(); } - else - { - datas.story = $('.SSTT.active').attr('id').split('_').slice(1,2).pop(); + else { + datas.story = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } } } } } - for(var i in datas) - { + for (var i in datas) { return downloadThis(datas); } @@ -2325,11 +2112,9 @@ function activeIcons() } -function checkDeleteThis(type, el) -{ +function checkDeleteThis(type, el) { el = $(el); - switch(type){ - + switch (type) { case "IMGT": @@ -2337,9 +2122,9 @@ function checkDeleteThis(type, el) var lst = ''; - if(type === 'IMGT') + if (type === 'IMGT') lst = p4.Results.Selection.serialize(); - if(type === 'CHIM') + if (type === 'CHIM') lst = p4.WorkZone.Selection.serialize(); deleteThis(lst); @@ -2351,17 +2136,16 @@ function checkDeleteThis(type, el) case "SSTT": var buttons = {}; - buttons[language.valider]= function(e) - { + buttons[language.valider] = function (e) { deleteBasket(el); }; $('#DIALOG').empty().append(language.confirmDel).attr('title', language.attention).dialog({ - autoOpen:false, - resizable:false, - modal:true, - draggable:false - }).dialog('open').dialog('option','buttons',buttons); + autoOpen: false, + resizable: false, + modal: true, + draggable: false + }).dialog('open').dialog('option', 'buttons', buttons); $('#tooltip').hide(); return; break; @@ -2373,32 +2157,30 @@ function checkDeleteThis(type, el) } } -function shareThis(bas,rec) -{ +function shareThis(bas, rec) { var dialog = p4.Dialog.Create({ title: language['share'] }); - dialog.load("../prod/share/record/"+bas+"/"+rec+ "/","GET"); + dialog.load("../prod/share/record/" + bas + "/" + rec + "/", "GET"); } -function printThis(value) -{ +function printThis(value) { if ($("#DIALOG").data("ui-dialog")) { $("#DIALOG").dialog('destroy'); } $('#DIALOG').attr('title', language.print) .empty().addClass('loading') .dialog({ - resizable:false, - closeOnEscape:true, - modal:true, - width:'800', - height:'500', - open: function(event, ui) { + resizable: false, + closeOnEscape: true, + modal: true, + width: '800', + height: '500', + open: function (event, ui) { $(this).dialog("widget").css("z-index", "1999"); }, - close: function(event, ui) { + close: function (event, ui) { $(this).dialog("widget").css("z-index", "auto"); } }) @@ -2406,12 +2188,12 @@ function printThis(value) $.ajax({ type: "POST", - url: '../prod/printer/?'+value, + url: '../prod/printer/?' + value, dataType: 'html', - beforeSend:function(){ + beforeSend: function () { }, - success: function(data){ + success: function (data) { $('#DIALOG').removeClass('loading').empty() .append(data); return; @@ -2420,17 +2202,16 @@ function printThis(value) } -function downloadThis(datas) -{ +function downloadThis(datas) { var dialog = p4.Dialog.Create({title: language['export']}); - $.post("../prod/export/multi-export/", datas, function(data) { + $.post("../prod/export/multi-export/", datas, function (data) { dialog.setContent(data); $('.tabs', dialog.getDomElement()).tabs(); - $('.close_button', dialog.getDomElement()).bind('click',function(){ + $('.close_button', dialog.getDomElement()).bind('click', function () { dialog.Close(); }); @@ -2439,55 +2220,39 @@ function downloadThis(datas) } - -function viewNbSelect() -{ +function viewNbSelect() { $("#nbrecsel").empty().append(p4.Results.Selection.length()); } -function selector(el) -{ - if(el.hasClass('all_selector')) - { +function selector(el) { + if (el.hasClass('all_selector')) { p4.Results.Selection.selectAll(); } - else - { - if(el.hasClass('none_selector')) - { + else { + if (el.hasClass('none_selector')) { p4.Results.Selection.empty(); } - else - { - if(el.hasClass('starred_selector')) - { + else { + if (el.hasClass('starred_selector')) { } - else - { - if(el.hasClass('video_selector')) - { + else { + if (el.hasClass('video_selector')) { p4.Results.Selection.empty(); p4.Results.Selection.select('.type-video'); } - else - { - if(el.hasClass('image_selector')) - { + else { + if (el.hasClass('image_selector')) { p4.Results.Selection.empty(); p4.Results.Selection.select('.type-image'); } - else - { - if(el.hasClass('document_selector')) - { + else { + if (el.hasClass('document_selector')) { p4.Results.Selection.empty(); p4.Results.Selection.select('.type-document'); } - else - { - if(el.hasClass('audio_selector')) - { + else { + if (el.hasClass('audio_selector')) { p4.Results.Selection.empty(); p4.Results.Selection.select('.type-audio'); } @@ -2499,30 +2264,26 @@ function selector(el) } } -function evt_dwnl(value) -{ - downloadThis("lst="+value); +function evt_dwnl(value) { + downloadThis("lst=" + value); } -function evt_print(value) -{ - printThis("lst="+value); +function evt_print(value) { + printThis("lst=" + value); } -function evt_add_in_chutier(sbas_id, record_id,event, singleSelection) -{ +function evt_add_in_chutier(sbas_id, record_id, event, singleSelection) { var singleSelection = singleSelection || false; p4.WorkZone.addElementToBasket(sbas_id, record_id, event, singleSelection); } -function remove_from_basket(el, confirm) -{ +function remove_from_basket(el, confirm) { var confirm = confirm || false; p4.WorkZone.removeElementFromBasket(el, confirm); } -function doSpecialSearch(qry, allbase){ +function doSpecialSearch(qry, allbase) { if (allbase) { checkBases(true); } @@ -2530,7 +2291,7 @@ function doSpecialSearch(qry, allbase){ newSearch(); } -function clktri(id){ +function clktri(id) { var o = $('#TOPIC_UL' + id); if ($('#TOPIC_UL' + id).hasClass('closed')) $('#TOPIC_TRI' + id + ' ,#TOPIC_UL' + id).removeClass('closed').addClass('opened'); @@ -2540,14 +2301,13 @@ function clktri(id){ // ---------------------- fcts du thesaurus -function chgProp(path, v, k) -{ +function chgProp(path, v, k) { var q2; - if(!k) + if (!k) k = "*"; //if(k!=null) - v = v+" ["+k+"]"; - $("#thprop_a_"+path).html('"'+ v + '"'); + v = v + " [" + k + "]"; + $("#thprop_a_" + path).html('"' + v + '"'); // q = document.getElementById("thprop_q").innerText; // if(!q ) // if(document.getElementById("thprop_q") && document.getElementById("thprop_q").textContent) @@ -2555,8 +2315,8 @@ function chgProp(path, v, k) q = $("#thprop_q").text(); q2 = ""; - for(i=0; i 0) - { + if (stories.length > 0) { p4.WorkZone.refresh(); } - else - { + else { p4.WorkZone.Selection.remove(n); } }); @@ -2614,19 +2371,17 @@ function doDelete(lst) }); } -function archiveBasket(basket_id) -{ +function archiveBasket(basket_id) { $.ajax({ type: "POST", url: "../prod/baskets/" + basket_id + "/archive/?archive=1", - dataType:'json', - beforeSend:function(){ + dataType: 'json', + beforeSend: function () { }, - success: function(data){ - if(data.success) - { - var basket = $('#SSTT_'+basket_id); + success: function (data) { + if (data.success) { + var basket = $('#SSTT_' + basket_id); var next = basket.next(); if (next.data("ui-droppable")) { @@ -2641,12 +2396,11 @@ function archiveBasket(basket_id) basket.slideUp().remove(); - if($('#baskets .SSTT').length === 0) { + if ($('#baskets .SSTT').length === 0) { return p4.WorkZone.refresh(false); } } - else - { + else { alert(data.message); } return; @@ -2655,24 +2409,22 @@ function archiveBasket(basket_id) } -function deleteBasket(item) -{ +function deleteBasket(item) { if ($("#DIALOG").data("ui-dialog")) { $("#DIALOG").dialog('destroy'); } - var k = $(item).attr('id').split('_').slice(1,2).pop(); // id de chutier + var k = $(item).attr('id').split('_').slice(1, 2).pop(); // id de chutier $.ajax({ type: "POST", - url: "../prod/baskets/"+k+'/delete/', - dataType:'json', - beforeSend:function(){ + url: "../prod/baskets/" + k + '/delete/', + dataType: 'json', + beforeSend: function () { }, - success: function(data){ - if(data.success) - { - var basket = $('#SSTT_'+k); + success: function (data) { + if (data.success) { + var basket = $('#SSTT_' + k); var next = basket.next(); if (next.data("ui-droppable")) { @@ -2687,12 +2439,11 @@ function deleteBasket(item) basket.slideUp().remove(); - if($('#baskets .SSTT').length === 0) { + if ($('#baskets .SSTT').length === 0) { return p4.WorkZone.refresh(false); } } - else - { + else { alert(data.message); } return; @@ -2700,83 +2451,70 @@ function deleteBasket(item) }); } -function clksbas(num, el) -{ +function clksbas(num, el) { var bool = true; - if(el.attr('checked')) - { + if (el.attr('checked')) { bool = false; - $('.sbasChkr_'+num).removeAttr('checked'); + $('.sbasChkr_' + num).removeAttr('checked'); } - else - { - $('.sbasChkr_'+num).attr('checked','checked'); + else { + $('.sbasChkr_' + num).attr('checked', 'checked'); } - $.each($('.sbascont_'+num+' :checkbox'),function(){ + $.each($('.sbascont_' + num + ' :checkbox'), function () { this.checked = bool; }); - if(bool) - { - $('.sbascont_'+num+' label').addClass('selected'); + if (bool) { + $('.sbascont_' + num + ' label').addClass('selected'); } - else - { - $('.sbascont_'+num+' label').removeClass('selected'); + else { + $('.sbascont_' + num + ' label').removeClass('selected'); } infoSbas(false, num, false, false); } -function cancelEvent(event) -{ - if(event.stopPropagation) +function cancelEvent(event) { + if (event.stopPropagation) event.stopPropagation(); - if(event.preventDefault) + if (event.preventDefault) event.preventDefault(); event.cancelBubble = true; return false; } -function infoSbas(el,num,donotfilter, event) -{ - if(event) +function infoSbas(el, num, donotfilter, event) { + if (event) cancelEvent(event); - if(el) - { - var item = $('input.ck_'+$(el).val()); - var label = $('label.ck_'+$(el).val()); + if (el) { + var item = $('input.ck_' + $(el).val()); + var label = $('label.ck_' + $(el).val()); - if($(el).attr('checked')) - { + if ($(el).attr('checked')) { label.removeClass('selected'); item.removeAttr('checked'); } - else - { + else { label.addClass('selected'); - item.attr('checked','checked'); + item.attr('checked', 'checked'); } } - $('.infos_sbas_'+num).empty().append($('.basChild_'+num+':first .checkbas:checked').length+'/'+$('.basChild_'+num+':first .checkbas').length); + $('.infos_sbas_' + num).empty().append($('.basChild_' + num + ':first .checkbas:checked').length + '/' + $('.basChild_' + num + ':first .checkbas').length); - if(donotfilter !== true) + if (donotfilter !== true) checkFilters(true); } -function advSearch(event) -{ +function advSearch(event) { event.cancelBubble = true; // alternateSearch(false); $('#idFrameC .tabs a.adv_search').trigger('click'); } -function start_page_selector() -{ +function start_page_selector() { var el = $('#look_box_settings select[name=start_page]'); - switch(el.val()) - { + switch (el.val()) { case "LAST_QUERY": case "PUBLI": case "HELP": @@ -2788,37 +2526,33 @@ function start_page_selector() } } -function set_start_page() -{ +function set_start_page() { var el = $('#look_box_settings select[name=start_page]'); var val = el.val(); var start_page_query = $('#look_box_settings input[name=start_page_value]').val(); - if(val === 'QUERY') - { - if($.trim(start_page_query) === '') - { + if (val === 'QUERY') { + if ($.trim(start_page_query) === '') { alert(language.start_page_query_error); return; } - setPref('start_page_query',start_page_query); + setPref('start_page_query', start_page_query); } - setPref('start_page',val); + setPref('start_page', val); } -function basketPrefs() -{ +function basketPrefs() { $('#basket_preferences').dialog({ - closeOnEscape:true, - resizable:false, - width:450, - height:500, - modal:true, - draggable:false, + closeOnEscape: true, + resizable: false, + width: 450, + height: 500, + modal: true, + draggable: false, overlay: { backgroundColor: '#000', opacity: 0.7 @@ -2826,15 +2560,14 @@ function basketPrefs() }).dialog('open'); } -function lookBox(el,event) -{ +function lookBox(el, event) { $("#look_box").dialog({ - closeOnEscape:true, - resizable:false, - width:450, - height:500, - modal:true, - draggable:false, + closeOnEscape: true, + resizable: false, + width: 450, + height: 500, + modal: true, + draggable: false, overlay: { backgroundColor: '#000', opacity: 0.7 @@ -2842,74 +2575,62 @@ function lookBox(el,event) }).dialog('open'); } -function showAnswer(p) -{ +function showAnswer(p) { var o; - if(p ==='Results') - { + if (p === 'Results') { // on montre les results - if(o = document.getElementById("AnswerExplain")) + if (o = document.getElementById("AnswerExplain")) o.style.visibility = "hidden"; - if(o = document.getElementById("AnswerResults")) - { + if (o = document.getElementById("AnswerResults")) { o.style.visibility = ""; o.style.display = "block"; } // on montre explain - if(document.getElementById("divpage")) - document.getElementById("divpage").style.visibility = visibilityDivPage; + if (document.getElementById("divpage")) + document.getElementById("divpage").style.visibility = visibilityDivPage; - if(document.getElementById("explainResults") ) + if (document.getElementById("explainResults")) document.getElementById("explainResults").style.display = "none"; } - else - { + else { // on montre explain - if(document.getElementById("divpage")) - { + if (document.getElementById("divpage")) { visibilityDivPage = "visible"; - document.getElementById("divpage").style.visibility = "hidden" ; + document.getElementById("divpage").style.visibility = "hidden"; } - if(document.getElementById("explainResults") ) + if (document.getElementById("explainResults")) document.getElementById("explainResults").style.display = "block"; - if(o = document.getElementById("AnswerResults")) - { + if (o = document.getElementById("AnswerResults")) { o.style.visibility = "hidden"; o.style.display = "none"; } - if(o = document.getElementById("AnswerExplain")) + if (o = document.getElementById("AnswerExplain")) o.style.visibility = ""; - if(o = document.getElementById("AnswerExplain")) - { + if (o = document.getElementById("AnswerExplain")) { o.style.display = "none"; - setTimeout('document.getElementById("AnswerExplain").style.display = "block";',200); + setTimeout('document.getElementById("AnswerExplain").style.display = "block";', 200); } } } /** FROM INDEX.php **/ -function saveeditPbar(idesc, ndesc) -{ +function saveeditPbar(idesc, ndesc) { document.getElementById("saveeditPbarI").innerHTML = idesc; document.getElementById("saveeditPbarN").innerHTML = ndesc; } -function getSelText() -{ +function getSelText() { var txt = ''; - if (window.getSelection) - { + if (window.getSelection) { txt = window.getSelection(); } - else if (document.getSelection) - { + else if (document.getSelection) { txt = document.getSelection(); } - else if (document.selection) - { + else if (document.selection) { txt = document.selection.createRange().text; } else @@ -2917,87 +2638,77 @@ function getSelText() return txt; } -function getWinPosAsXML() -{ - var ret = ''; +function getWinPosAsXML() { + var ret = ''; - if($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible')) - ret += ''; + if ($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible')) + ret += ''; return ret; } -function saveWindows() -{ +function saveWindows() { var key = ''; var value = ''; - if($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible')) - { + if ($('#idFrameE').is(':visible') && $('#EDITWINDOW').is(':visible')) { key = 'edit_window'; - value = $('#idFrameE').outerWidth()/$('#EDITWINDOW').innerWidth(); + value = $('#idFrameE').outerWidth() / $('#EDITWINDOW').innerWidth(); } - else - { + else { key = 'search_window'; - value = $('#idFrameC').outerWidth()/bodySize.x; + value = $('#idFrameC').outerWidth() / bodySize.x; } setPref(key, value); } -function gotopage(pag) -{ +function gotopage(pag) { $('#searchForm input[name="sel"]').val(p4.Results.Selection.serialize()); $('#formAnswerPage').val(pag); $('#searchForm').submit(); } -function addFilterMulti(filter,link,sbasid) -{ - var clone = $('#filter_multi_'+sbasid+'_'+filter); +function addFilterMulti(filter, link, sbasid) { + var clone = $('#filter_multi_' + sbasid + '_' + filter); var orig = clone; - if(!$('#filter_multi_'+sbasid+'_'+filter).is(':visible')) - { + if (!$('#filter_multi_' + sbasid + '_' + filter).is(':visible')) { clone = orig.clone(true); var par = orig.parent(); orig.remove(); par.append(clone); - clone.slideDown('fast',function(){ + clone.slideDown('fast', function () { $(this); }); $(link).addClass('filterActive'); } - else - { + else { clone.slideUp(); $(link).removeClass('filterActive'); } return false; } -function autoorder() -{ +function autoorder() { var val = $.trim($('#auto_order').val()); - if(val === '') + if (val === '') return; var sorter = new Array(); - $('#reorder_box .diapo form').each(function(i,n){ + $('#reorder_box .diapo form').each(function (i, n) { - var id = $('input[name=id]',n).val(); + var id = $('input[name=id]', n).val(); - switch(val) - { + switch (val) { case 'title': default: - var data = $('input[name=title]',n).val(); + var data = $('input[name=title]', n).val(); break; case 'default': - var data = $('input[name=default]',n).val(); + var data = $('input[name=default]', n).val(); break; } @@ -3006,8 +2717,7 @@ function autoorder() var data_type = 'string'; - switch(val) - { + switch (val) { case 'default': var data_type = 'integer'; break; @@ -3017,15 +2727,12 @@ function autoorder() var last_moved = false; - for(i in sorter) - { - var elem = $('#ORDER_'+i); - if(last_moved) - { + for (i in sorter) { + var elem = $('#ORDER_' + i); + if (last_moved) { elem.insertAfter(last_moved); } - else - { + else { $('#reorder_box').prepend(elem); } last_moved = elem; @@ -3033,59 +2740,54 @@ function autoorder() } -function set_up_feed_box(data) -{ +function set_up_feed_box(data) { var $feed_box = $('#modal_feed'); $feed_box.empty().append(data).dialog({ - modal:true, - width:800, - height:500, - resizable:false, - draggable:false + modal: true, + width: 800, + height: 500, + resizable: false, + draggable: false }); var $feeds_item = $('.feeds .feed', $feed_box); var $form = $('form.main_form', $feed_box); - $feeds_item.bind('click', function(){ + $feeds_item.bind('click',function () { $feeds_item.removeClass('selected'); $(this).addClass('selected'); $('input[name="feed_id"]', $form).val($('input', this).val()); - }).hover(function(){ + }).hover(function () { $(this).addClass('hover'); - },function(){ + }, function () { $(this).removeClass('hover'); }); - $form.bind('submit', function(){ + $form.bind('submit', function () { return false; }); - $('button.valid_form').bind('click', function(){ + $('button.valid_form').bind('click', function () { var error = false; - $('.required_text', $form).each(function(i, el){ - if($.trim($(el).val()) === '') - { + $('.required_text', $form).each(function (i, el) { + if ($.trim($(el).val()) === '') { $(el).addClass('error'); error = true; } }); - if(error) - { + if (error) { alert(language.feed_require_fields); } - if($('input[name="feed_id"]', $form).val() === '') - { + if ($('input[name="feed_id"]', $form).val() === '') { alert(language.feed_require_feed); error = true; } - if(error) - { + if (error) { return false; } @@ -3093,28 +2795,26 @@ function set_up_feed_box(data) type: 'POST', url: $form.attr('action'), data: $form.serializeArray(), - dataType:'json', - beforeSend:function(){ + dataType: 'json', + beforeSend: function () { $('button', $feed_box).attr('disabled', 'disabled'); }, - error:function(){ + error: function () { $('button', $feed_box).removeAttr('disabled'); }, - timeout:function(){ + timeout: function () { $('button', $feed_box).removeAttr('disabled'); }, - success: function(data){ + success: function (data) { $('button', $feed_box).removeAttr('disabled'); - if(data.error === true) - { + if (data.error === true) { alert(data.message); return; } - if($('form.main_form', $feed_box).hasClass('entry_update')) - { + if ($('form.main_form', $feed_box).hasClass('entry_update')) { var id = $('form input[name="entry_id"]', $feed_box).val(); - var container = $('#entry_'+id); + var container = $('#entry_' + id); container.replaceWith(data.datas); @@ -3134,8 +2834,8 @@ function set_up_feed_box(data) }); return false; }); - $('button.close_dialog').bind('click', function(){ - if($feed_box.data("ui-dialog")) { + $('button.close_dialog').bind('click', function () { + if ($feed_box.data("ui-dialog")) { $feed_box.dialog('destroy'); } diff --git a/www/skins/prod/publicator.js b/www/skins/prod/publicator.js index 6b805c8ed9..bfd162c2fb 100644 --- a/www/skins/prod/publicator.js +++ b/www/skins/prod/publicator.js @@ -1,16 +1,13 @@ - -function publicator_reload_publicator() -{ +function publicator_reload_publicator() { var options = $('#dialog_publicator form[name="current_datas"]').serializeArray(); var dialog = p4.Dialog.get(1); dialog.load('/prod/bridge/manager/', 'POST', options); } -function init_publicator(datas) -{ +function init_publicator(datas) { var dialog = p4.Dialog.Create({ - size:'Full', - title:'Bridge', + size: 'Full', + title: 'Bridge', loading: false }); diff --git a/www/skins/report/report.js b/www/skins/report/report.js index 990d97dfc5..c0faced736 100644 --- a/www/skins/report/report.js +++ b/www/skins/report/report.js @@ -38,19 +38,19 @@ $(document).ready(function () { configure_dash(); bindEvents(); - $("a.select-all").bind("click", function(e) { + $("a.select-all").bind("click", function (e) { $("ul.multiselect .coll-checkbox", $(this).closest('.form2')).attr("checked", true); }); - $("a.deselect-all").bind("click", function(e) { + $("a.deselect-all").bind("click", function (e) { $("ul.multiselect .coll-checkbox", $(this).closest('.form2')).attr("checked", false); }); - $(".multiselect-group").toggle(function() { + $(".multiselect-group").toggle(function () { var $this = $(this); var groupId = $this.data('group-id'); $(".checkbox-" + groupId, $this.closest('.form2')).attr("checked", true); - }, function() { + }, function () { var $this = $(this); var groupId = $this.data('group-id'); $(".checkbox-" + groupId, $this.closest('.form2')).attr("checked", false); diff --git a/www/skins/thesaurus/sprintf.js b/www/skins/thesaurus/sprintf.js index 3c0773938b..cbf4abf928 100644 --- a/www/skins/thesaurus/sprintf.js +++ b/www/skins/thesaurus/sprintf.js @@ -1,46 +1,39 @@ ////////////////////////////////////////////////////////////////////////////// // sprintf function for javascript -function sprintf() -{ - if (!arguments || arguments.length < 1 || !RegExp) - { +function sprintf() { + if (!arguments || arguments.length < 1 || !RegExp) { return ''; } str = arguments[0]; - while((newstr = str.replace("\n", "\x01")) != str) + while ((newstr = str.replace("\n", "\x01")) != str) str = newstr; // var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/; var re = new RegExp("^([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)$", "m"); re["$*"] = true; var a = b = [], numSubstitutions = 0, numMatches = 0; a = re.exec(str); - while (a) - { + while (a) { var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4]; - var pPrecision = a[5], pType = a[6], rightPart = a[7]; numMatches++; + var pPrecision = a[5], pType = a[6], rightPart = a[7]; + numMatches++; // alert("str:"+str + "\nl:"+leftpart + "\nr:"+rightPart); - if (pType == '%') - { + if (pType == '%') { subst = '%'; } - else - { + else { 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).'); } var param = arguments[numSubstitutions]; var pad = ''; - if (pPad && pPad.substr(0,1) == "'") - { - pad = leftpart.substr(1,1); + if (pPad && pPad.substr(0, 1) == "'") { + pad = leftpart.substr(1, 1); } - else if (pPad) - { + else if (pPad) { pad = pPad; } var justifyRight = true; @@ -50,13 +43,11 @@ function sprintf() if (pMinLength) minLength = parseInt(pMinLength); var precision = -1; - if (pPrecision && pType == 'f') - { + if (pPrecision && pType == 'f') { precision = parseInt(pPrecision.substring(1)); } var subst = param; - switch (pType) - { + switch (pType) { case 'b': subst = parseInt(param).toString(2); break; @@ -64,7 +55,7 @@ function sprintf() subst = String.fromCharCode(parseInt(param)); break; case 'd': - subst = parseInt(param)? parseInt(param) : 0; + subst = parseInt(param) ? parseInt(param) : 0; break; case 'u': subst = Math.abs(param); @@ -89,20 +80,18 @@ function sprintf() } var padLeft = minLength - subst.toString().length; var padding; - if (padLeft > 0) - { - var arrTmp = new Array(padLeft+1); - padding = arrTmp.join(pad?pad:" "); + if (padLeft > 0) { + var arrTmp = new Array(padLeft + 1); + padding = arrTmp.join(pad ? pad : " "); } - else - { + else { padding = ""; } } str = leftpart + padding + subst + rightPart; a = re.exec(str); } - while((newstr = str.replace("\x01", "\n")) != str) + while ((newstr = str.replace("\x01", "\n")) != str) str = newstr; return(str); } diff --git a/www/skins/thesaurus/thesaurus.js b/www/skins/thesaurus/thesaurus.js index 3e93a69a7b..6c7e846efb 100644 --- a/www/skins/thesaurus/thesaurus.js +++ b/www/skins/thesaurus/thesaurus.js @@ -1,26 +1,21 @@ - -function loadXMLDoc(url, post_parms, asxml) -{ - if(typeof(asxml)=="undefined") +function loadXMLDoc(url, post_parms, asxml) { + if (typeof(asxml) == "undefined") asxml = false; out = null; xmlhttp = null; // code for Mozilla, etc. if (window.XMLHttpRequest) - xmlhttp=new XMLHttpRequest(); + xmlhttp = new XMLHttpRequest(); else if (window.ActiveXObject) - xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); - if (xmlhttp) - { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + if (xmlhttp) { // xmlhttp.onreadystatechange=state_Change - if(post_parms) - { + if (post_parms) { 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); } - else - { + else { xmlhttp.open("GET", url, false); xmlhttp.send(null); } @@ -30,25 +25,22 @@ function loadXMLDoc(url, post_parms, asxml) } -function showFound2(term, lterm, branch, depth) -{ +function showFound2(term, lterm, branch, depth) { var c; var ret = 0; var thb = branch.firstChild.nextSibling.nextSibling; // branch est un
    - if(thb) - { - for(c=thb.firstChild; c; c=c.nextSibling) // THE, les SY ou les TA + if (thb) { + for (c = thb.firstChild; c; c = c.nextSibling) // THE, les SY ou les TA { - if(c.nodeName=="DIV") - ret += showFound2(term, lterm, c, depth+1); // on descend uniquement les THE_yyy + if (c.nodeName == "DIV") + ret += showFound2(term, lterm, c, depth + 1); // on descend uniquement les THE_yyy } } - if(branch.firstChild.nextSibling.nodeValue.substr(0, lterm)==term) - { + if (branch.firstChild.nextSibling.nodeValue.substr(0, lterm) == term) { ret = 1; // alert(branch.firstChild.nextSibling.nodeValue + " : " + thb.id); } @@ -56,13 +48,11 @@ function showFound2(term, lterm, branch, depth) // if(ret > 0) // if(depth > 0) // { - if(ret > 0) - { + if (ret > 0) { //eventObj.Src0.innerHTML = "+"; thb.className = "OB"; } - else - { + else { //eventObj.Src0.innerHTML = "+"; thb.className = "ob"; } @@ -81,24 +71,20 @@ function showFound2(term, lterm, branch, depth) return(ret); } -function showAll(branch, depth) -{ +function showAll(branch, depth) { depth = parseInt(depth); var c; - for(c=branch.firstChild; c; c=c.nextSibling) - { - if(c.nodeType==1 && c.nodeName=="DIV") // 1=XML_ELEMENT_NODE - showAll(c, depth+1); + for (c = branch.firstChild; c; c = c.nextSibling) { + if (c.nodeType == 1 && c.nodeName == "DIV") // 1=XML_ELEMENT_NODE + showAll(c, depth + 1); } - if(depth > 0) + if (depth > 0) branch.style.display = ""; - if(depth===0) - { - document.getElementById("WT1").style.visibility="hidden"; - if(document.forms["fTh"].textT1.value!=="") - { + if (depth === 0) { + document.getElementById("WT1").style.visibility = "hidden"; + if (document.forms["fTh"].textT1.value !== "") { // oups! le mot a changé durant le traitement, on recommence evt_kup_T1(); } @@ -106,33 +92,28 @@ function showAll(branch, depth) } - -function scanTerms(inputName, zTerm, showhide) -{ +function scanTerms(inputName, zTerm, showhide) { showhide = !!showhide; var lTerm = zTerm.length; - var zTable = document.getElementById("L"+inputName); + var zTable = document.getElementById("L" + inputName); var zTr = zTable.childNodes; // TR's var l = zTr.length; var found = null; - for(var i=0; i"); + if (n) { + if (n.nodeType == 1) { + alert(msg + " : <" + n.nodeName + " id='" + n.id + "'>"); } - else - { - alert(msg + " : nodeType="+n.nodeType); + else { + alert(msg + " : nodeType=" + n.nodeType); } } - else - { + else { alert(msg + " : NULL"); } } -function appendTerm(inputName, new_term, id) -{ +function appendTerm(inputName, new_term, id) { var tr = document.createElement("TR"); - tr.id = inputName + "_"+id; + tr.id = inputName + "_" + id; tr.className = "s_"; var td = tr.appendChild(document.createElement("TD")); td.appendChild(document.createTextNode(new_term)); td = tr.appendChild(document.createElement("TD")); - td.innerHTML = ""; + td.innerHTML = ""; td = tr.appendChild(document.createElement("TD")); td.appendChild(document.createTextNode(" ")); - var zTable = document.getElementById("L"+inputName); + var zTable = document.getElementById("L" + inputName); return(zTable.appendChild(tr)); } diff --git a/www/skins/thesaurus/win.js b/www/skins/thesaurus/win.js index ae8e3cd81d..4d30c99781 100644 --- a/www/skins/thesaurus/win.js +++ b/www/skins/thesaurus/win.js @@ -1,33 +1,31 @@ -var clickObj = { X:0, Y:0, lastClickX:-1, lastClickY:-1, Src:null, Src0:null }; -var balloonObj = { X:0, Y:0, Src:null, Src0:null }; -var dragObj = { objCursor:null, dragging:0, X:0, Y:0, lastClickX:-1, lastClickY:-1, Src:null, Src0:null, Target:null, Target0:null, idTarget:null, callBack:null } ; +var clickObj = { X: 0, Y: 0, lastClickX: -1, lastClickY: -1, Src: null, Src0: null }; +var balloonObj = { X: 0, Y: 0, Src: null, Src0: null }; +var dragObj = { objCursor: null, dragging: 0, X: 0, Y: 0, lastClickX: -1, lastClickY: -1, Src: null, Src0: null, Target: null, Target0: null, idTarget: null, callBack: null }; debuglog = ""; -function ww_setDragObj(obj) -{ - if(dragObj.objCursor) +function ww_setDragObj(obj) { + if (dragObj.objCursor) dragObj.objCursor.style.visibility = "hidden"; dragObj.objCursor = obj ? obj : document.getElementById("dragDropCursor"); obj.style.visibility = "visible"; } -function evt_dblclk_doc(event, gui) -{ +function evt_dblclk_doc(event, gui) { var gui = eval(gui); var button; - if(typeof(event.which) != 'undefined') - button = gui.firefoxButtons["b"+event.which]; + if (typeof(event.which) != 'undefined') + button = gui.firefoxButtons["b" + event.which]; else button = event.button; - if(!dragObj.objCursor) + if (!dragObj.objCursor) dragObj.objCursor = document.getElementById("dragDropCursor"); dragObj.Src0 = dragObj.Src = dragObj.Target = dragObj.Target0 = null; dragObj.dragging = 0; var srcElement = (event.target) ? event.target : event.srcElement; var src0; - for(src0=srcElement; src0 && !src0.id; src0=src0.parentNode) + for (src0 = srcElement; src0 && !src0.id; src0 = src0.parentNode) ; // src0 = (event.srcElement.tagName) ? event.srcElement : null; // correction safari pour le srcElement // alert("<"+src0.tagName + " id='"+src0.id+"'>"); @@ -37,38 +35,34 @@ function evt_dblclk_doc(event, gui) var ymouse = parseInt(event.clientY); var acceptClick = true; var e; - for(e=src0; e && acceptClick && (!e.tagName || !clickfound); e=e.parentNode) - { - if(e && e.clickable) - { + for (e = src0; e && acceptClick && (!e.tagName || !clickfound); e = e.parentNode) { + if (e && e.clickable) { clickObj.X = xmouse; clickObj.Y = ymouse; clickObj.Src = e; clickObj.Src0 = src0; clickfound = true; - if(e.clickCallback) + if (e.clickCallback) (e.clickCallback)(event, "DBLCLICK", clickObj); } } } -var iiii=0; +var iiii = 0; -function ww_evt_mdwn_doc(gui, evt) -{ +function ww_evt_mdwn_doc(gui, evt) { var gui = eval(gui); - if(gui.elemBalloon) + if (gui.elemBalloon) gui.elemBalloon.style.visibility = "hidden"; - if(timer_ballon) - { + if (timer_ballon) { clearTimeout(timer_ballon); timer_ballon = null; } var button; - if(typeof(evt.which) != 'undefined') - button = gui.firefoxButtons["b"+evt.which]; + if (typeof(evt.which) != 'undefined') + button = gui.firefoxButtons["b" + evt.which]; else button = evt.button; @@ -78,39 +72,36 @@ function ww_evt_mdwn_doc(gui, evt) var srcElement = evt.srcElement ? evt.srcElement : evt.target; // for(src0=srcElement; src0 && (!src0.tagName); src0=src0.parentNode) - for(src0=srcElement; src0 && (!src0.tagName || src0.tagName=='APPLET' || src0.tagName=='OBJECT' || !src0.id); src0=src0.parentNode) + for (src0 = srcElement; src0 && (!src0.tagName || src0.tagName == 'APPLET' || src0.tagName == 'OBJECT' || !src0.id); src0 = src0.parentNode) ; - if(src0.className == 'hslider') - { + if (src0.className == 'hslider') { var x; var wslider = parseInt(src0.style.width); - var posmax = parseInt(src0.parentNode.style.width)-wslider; - var min=0, max=posmax; - if( (x = src0.getAttribute('min')) != "") + var posmax = parseInt(src0.parentNode.style.width) - wslider; + var min = 0, max = posmax; + if ((x = src0.getAttribute('min')) != "") min = parseInt(x); - if( (x = src0.getAttribute('max')) != "") + if ((x = src0.getAttribute('max')) != "") max = parseInt(x); var pos = parseInt(src0.style.left); - var val = min + (((max-min) * pos) / posmax); + var val = min + (((max - min) * pos) / posmax); // var pos = (int)(((val-min) * divmax) / (max-min)); var cb = null; - if( (x=src0.getAttribute('callback')) != "") + if ((x = src0.getAttribute('callback')) != "") cb = eval(x); - gui.sliding = { 'obj':src0, 'dir':"H", 'posmax':posmax, 'opos':pos, 'pos':pos, 'min':min, 'max':max, 'val':val, 'callback':cb }; + gui.sliding = { 'obj': src0, 'dir': "H", 'posmax': posmax, 'opos': pos, 'pos': pos, 'min': min, 'max': max, 'val': val, 'callback': cb }; return(false); } - if(src0.className == 'hsplitter') - { + if (src0.className == 'hsplitter') { src0.setAttribute('otop', parseInt(src0.style.top)); src0.setAttribute('ozindex', parseInt(src0.style.zIndex)); src0.style.zIndex = 999; gui.splitting = src0; return(false); } - if(src0.className == 'vsplitter') - { + if (src0.className == 'vsplitter') { src0.setAttribute('oleft', parseInt(src0.style.left)); src0.setAttribute('ozindex', parseInt(src0.style.zIndex)); src0.style.zIndex = 999; @@ -124,12 +115,10 @@ function ww_evt_mdwn_doc(gui, evt) var ymouse = parseInt(evt.clientY); var acceptClick = true; var e; - for(var e=src0; e && acceptClick && (!e.tagName || !dragfound || !clickfound); e=e.parentNode) - { + for (var e = src0; e && acceptClick && (!e.tagName || !dragfound || !clickfound); e = e.parentNode) { - if(e && e.clickable) - { + if (e && e.clickable) { clickObj.X = xmouse; clickObj.Y = ymouse; clickObj.Src = e; @@ -143,17 +132,15 @@ function ww_evt_mdwn_doc(gui, evt) // alert("dT :" + dT); clickfound = true; - if(e.clickCallback) - { - if(button == 1) // && !event.altKey) // left button + if (e.clickCallback) { + if (button == 1) // && !event.altKey) // left button acceptClick = (e.clickCallback)(evt, evt.ctrlKey ? "RMOUSEDOWN" : "MOUSEDOWN", clickObj); - else - if(button == 2 && !evt.ctrlKey) // right button + else if (button == 2 && !evt.ctrlKey) // right button acceptClick = (e.clickCallback)(evt, "RMOUSEDOWN", clickObj); } } - if(acceptClick && e && e.draggable) // && (!src0.draggable || src0.draggable!=-1)) + if (acceptClick && e && e.draggable) // && (!src0.draggable || src0.draggable!=-1)) { // alert(e.draggable); dragObj.lastClickX = xmouse; @@ -278,15 +265,13 @@ function ww_evt_mdwn_doc(gui, evt) } */ -function ww_evt_mmov_doc(gui, evt) -{ +function ww_evt_mmov_doc(gui, evt) { var gui = eval(gui); var button, xmouse, ymouse; - if(gui.elemBalloon) + if (gui.elemBalloon) gui.elemBalloon.style.visibility = "hidden"; - if(timer_ballon) - { + if (timer_ballon) { clearTimeout(timer_ballon); timer_ballon = null; } @@ -295,87 +280,73 @@ function ww_evt_mmov_doc(gui, evt) //window.status = xmouse + '-' + ymouse; under_ballon = (evt.target) ? evt.target : evt.srcElement; - if(under_ballon.id) - { - js = "timeout_ballon('"+under_ballon.id+"', "+xmouse+", "+ymouse+");"; + if (under_ballon.id) { + js = "timeout_ballon('" + under_ballon.id + "', " + xmouse + ", " + ymouse + ");"; timer_ballon = setTimeout(js, 300); } xmouse = parseInt(evt.clientX); ymouse = parseInt(evt.clientY); - if(dragObj.Src) - { - if(dragObj.dragging == 1) - { + if (dragObj.Src) { + if (dragObj.dragging == 1) { dx = xmouse - dragObj.lastClickX; dy = ymouse - dragObj.lastClickY; - if(Math.abs(dx)>4 || Math.abs(dy)>4) - { - if(dragObj.objCursor) - { + if (Math.abs(dx) > 4 || Math.abs(dy) > 4) { + if (dragObj.objCursor) { dragObj.objCursor.style.visibility = "visible"; } dragObj.dragging = 2; - if(dragObj.Src.ondragstart) - { + if (dragObj.Src.ondragstart) { // alert("gui is calling ondragstart"); (dragObj.Src.ondragstart)(); } - if(dragObj.Src.dragCallback) - { + if (dragObj.Src.dragCallback) { var r = (dragObj.Src.dragCallback)(evt, "DRAGSTART", dragObj); - if(!r) - { + if (!r) { dragObj.dragging = 0; dragObj.Src0 = dragObj.Src = dragObj.Target0 = dragObj.Target = null; - if(dragObj.objCursor) + if (dragObj.objCursor) dragObj.objCursor.style.visibility = "hidden"; } } } } - if(dragObj.dragging == 2) - { - if(dragObj.objCursor) - { + if (dragObj.dragging == 2) { + if (dragObj.objCursor) { // window.status = xmouse + '-' + ymouse; - dragObj.objCursor.style.left = (xmouse+8)+"px"; - dragObj.objCursor.style.top = (ymouse+8)+"px"; + dragObj.objCursor.style.left = (xmouse + 8) + "px"; + dragObj.objCursor.style.top = (ymouse + 8) + "px"; } var srcElement = (evt.target) ? evt.target : evt.srcElement; var src0; var e; - for(src0=srcElement; src0 && !src0.id; src0=src0.parentNode) + for (src0 = srcElement; src0 && !src0.id; src0 = src0.parentNode) ; - for(e=src0; e && (!e.tagName || !e.droppable); e=e.parentNode) + for (e = src0; e && (!e.tagName || !e.droppable); e = e.parentNode) ; - if(src0) - { + if (src0) { dragObj.Target0 = src0; - if(dragObj.Target && e != dragObj.Target) // && src0 != e) + if (dragObj.Target && e != dragObj.Target) // && src0 != e) { - if(dragObj.Target.ondragleave) + if (dragObj.Target.ondragleave) (dragObj.Target.ondragleave)(); - if(dragObj.Target.dropCallback) + if (dragObj.Target.dropCallback) (dragObj.Target.dropCallback)(evt, "DRAGLEAVE", dragObj); dragObj.Target = null; } - if(e) - { - if(!dragObj.Target) - { + if (e) { + if (!dragObj.Target) { dragObj.Target = e; - if(e.ondragenter) + if (e.ondragenter) (e.ondragenter)(); - if(dragObj.Target.dropCallback) + if (dragObj.Target.dropCallback) (dragObj.Target.dropCallback)(evt, "DRAGENTER", dragObj); } - else - { - if(dragObj.Src.dragCallback) + else { + if (dragObj.Src.dragCallback) (dragObj.Src.dragCallback)(evt, "DRAG", dragObj); - if(dragObj.Target.dropCallback) + if (dragObj.Target.dropCallback) (dragObj.Target.dropCallback)(evt, "DRAGOVER", dragObj); } } @@ -580,72 +551,61 @@ function ww_evt_mmov_doc(gui, evt) dragObj.objCursor.style.visibility = "hidden"; } */ -function ww_evt_mup_doc(gui, evt) -{ +function ww_evt_mup_doc(gui, evt) { var gui = eval(gui); var srcElement = (evt.target) ? evt.target : evt.srcElement; var src0; - for(src0=srcElement; src0 && !src0.id; src0=src0.parentNode) + for (src0 = srcElement; src0 && !src0.id; src0 = src0.parentNode) ; var button; - if(typeof(evt.which) != 'undefined') - button = gui.firefoxButtons["b"+evt.which]; + if (typeof(evt.which) != 'undefined') + button = gui.firefoxButtons["b" + evt.which]; else button = evt.button; var xmouse = parseInt(evt.clientX); var ymouse = parseInt(evt.clientY); var e; var clickfound = false; - for(e=src0; e && (!e.tagName || !clickfound); e=e.parentNode) - { - if(e && e.clickable) - { + for (e = src0; e && (!e.tagName || !clickfound); e = e.parentNode) { + if (e && e.clickable) { clickObj.X = xmouse; clickObj.Y = ymouse; clickObj.Src = e; clickObj.Src0 = src0; clickfound = true; - if(e.clickCallback) - { - if(button == 1 && !evt.ctrlKey) // left button + if (e.clickCallback) { + if (button == 1 && !evt.ctrlKey) // left button acceptClick = (e.clickCallback)(evt, evt.ctrlKey ? "RMOUSEUP" : "MOUSEUP", clickObj); - else - if(button == 2 && !evt.ctrlKey) // right button + else if (button == 2 && !evt.ctrlKey) // right button acceptClick = (e.clickCallback)(evt, "RMOUSEUP", clickObj); } } } - if(!dragObj.Src) - { - if(dragObj.objCursor) + if (!dragObj.Src) { + if (dragObj.objCursor) dragObj.objCursor.style.visibility = "hidden"; } - else - { - if(dragObj.dragging==2) - { - for(e=src0; e && (!e.tagName || !e.droppable); e=e.parentNode) - { + else { + if (dragObj.dragging == 2) { + for (e = src0; e && (!e.tagName || !e.droppable); e = e.parentNode) { ; } - if(e) - { - if(dragObj.Target && e == dragObj.Target) - { - if(dragObj.Target.ondrop) + if (e) { + if (dragObj.Target && e == dragObj.Target) { + if (dragObj.Target.ondrop) (dragObj.Target.ondrop)(); - if(dragObj.Target.dropCallback) + if (dragObj.Target.dropCallback) (dragObj.Target.dropCallback)(evt, "DROP", dragObj); } } } - if(dragObj.Src.dropCallback) + if (dragObj.Src.dropCallback) (dragObj.Src.dropCallback)(evt, "DRAGEND", dragObj); dragObj.dragging = 0; dragObj.Src0 = dragObj.Src = dragObj.Target0 = dragObj.Target = null; - if(dragObj.objCursor) + if (dragObj.objCursor) dragObj.objCursor.style.visibility = "hidden"; } /* @@ -679,28 +639,25 @@ function ww_evt_mup_doc(gui, evt) } - -function ww_evt_kon_doc(gui, evt) -{ +function ww_evt_kon_doc(gui, evt) { var gui = eval(gui); - if(gui.elemBalloon) + if (gui.elemBalloon) gui.elemBalloon.style.visibility = "hidden"; - if(timer_ballon) - { + if (timer_ballon) { clearTimeout(timer_ballon); timer_ballon = null; } - if(!dragObj.objCursor) + if (!dragObj.objCursor) dragObj.objCursor = document.getElementById("dragDropCursor"); dragObj.Src0 = dragObj.Src = dragObj.Target = dragObj.Target0 = null; dragObj.dragging = 0; var srcElement = (evt.target) ? evt.target : evt.srcElement; var src0; - for(src0=srcElement; src0 && !src0.id; src0=src0.parentNode) + for (src0 = srcElement; src0 && !src0.id; src0 = src0.parentNode) ; var dragfound = false; @@ -709,17 +666,14 @@ function ww_evt_kon_doc(gui, evt) var ymouse = parseInt(evt.clientY); var acceptClick = true; var e; - for(var e=src0; e && acceptClick && (!e.tagName || !dragfound || !clickfound); e=e.parentNode) - { - if(e && e.clickable) - { + for (var e = src0; e && acceptClick && (!e.tagName || !dragfound || !clickfound); e = e.parentNode) { + if (e && e.clickable) { clickObj.X = xmouse; clickObj.Y = ymouse; clickObj.Src = e; clickObj.Src0 = src0; clickfound = true; - if(e.clickCallback) - { + if (e.clickCallback) { // var js = "cbDD_T0('CONTEXTMENU', '"+src0.id+"')"; // self.setTimeout(js, 3000); // (js)(); @@ -794,22 +748,18 @@ function ww_evt_kon_doc(gui, evt) var timer_ballon = null; var under_ballon = null; -function timeout_ballon(id, xmouse, ymouse) -{ +function timeout_ballon(id, xmouse, ymouse) { var src0; - if(src0 = document.getElementById(id)) - { + if (src0 = document.getElementById(id)) { var clickfound = false; - for(var e=src0; e && (!e.tagName || !clickfound); e=e.parentNode) - { - if(e && e.clickable) - { + for (var e = src0; e && (!e.tagName || !clickfound); e = e.parentNode) { + if (e && e.clickable) { balloonObj.X = xmouse; balloonObj.Y = ymouse; balloonObj.Src = e; balloonObj.Src0 = src0; clickfound = true; - if(e.clickCallback) + if (e.clickCallback) (e.clickCallback)(null, "BALLOON", balloonObj); } } @@ -818,15 +768,12 @@ function timeout_ballon(id, xmouse, ymouse) timer_ballon = null; } -function ww_evt_balloon(msg) -{ +function ww_evt_balloon(msg) { // for(var i=0; i<24; i++) // msg += "
    \n"+i; - var measurediv=0; - if(measurediv) - { - if(!this.elemMeasureBalloon) - { + var measurediv = 0; + if (measurediv) { + if (!this.elemMeasureBalloon) { var div = this.document.createElement("div"); div.style.position = "absolute"; div.style.top = div.style.left = "0px"; @@ -838,9 +785,8 @@ function ww_evt_balloon(msg) } } - var k=7; - if(!this.elemBalloon) - { + var k = 7; + if (!this.elemBalloon) { var div = this.document.createElement("div"); div.style.overflow = "visible"; div.style.position = "absolute"; @@ -849,16 +795,15 @@ function ww_evt_balloon(msg) div.style.backgroundColor = "#ff8800"; div.style.zIndex = 999; - for(var i=1; ialert('loaded');"; var msg_h = this.elemMeasureBalloon.clientHeight; var msg_w = this.elemMeasureBalloon.clientWidth; @@ -889,15 +833,13 @@ function ww_evt_balloon(msg) // var msg_sbox = this.elemBalloon.firstChild; // var msg_tbox = this.elemBalloon.children.item(k<1 ? 0 : k-1); - var msg_tbox = this.elemBalloon.childNodes[k<1 ? 0 : k-1]; - if(measurediv) - { + var msg_tbox = this.elemBalloon.childNodes[k < 1 ? 0 : k - 1]; + if (measurediv) { msg_tbox.innerHTML = msg; - msg_tbox.style.width = (msg_w+0)+"px"; - msg_tbox.style.height = (msg_h+0)+"px"; + msg_tbox.style.width = (msg_w + 0) + "px"; + msg_tbox.style.height = (msg_h + 0) + "px"; } - else - { + else { // this.elemBalloon.style.visibility = "visible"; this.elemBalloon.style.top = "0px"; this.elemBalloon.style.left = "0px"; @@ -906,28 +848,25 @@ function ww_evt_balloon(msg) msg_tbox.innerHTML = msg; var msg_h = this.elemBalloon.clientHeight; var msg_w = this.elemBalloon.clientWidth; - msg_tbox.style.width = (msg_w-4)+"px"; - msg_tbox.style.height = (msg_h-4)+"px"; + msg_tbox.style.width = (msg_w - 4) + "px"; + msg_tbox.style.height = (msg_h - 4) + "px"; } - var ymouse = 0+balloonObj.Y; - var xmouse = 0+balloonObj.X; + var ymouse = 0 + balloonObj.Y; + var xmouse = 0 + balloonObj.X; var body_h = document.documentElement.clientHeight; var msg_t; msg_t = ymouse + 5; // en dessous - if(msg_t + msg_h > body_h) - { + if (msg_t + msg_h > body_h) { // tiens pas en dessous msg_t = ymouse - msg_h - 3; // au dessus - if(msg_t < 3) - { + if (msg_t < 3) { // tiens pas au dessus msg_t = body_h - msg_h - 10; // colle en bas - if(msg_t < 3) - { + if (msg_t < 3) { // tiens pas colle en bas msg_t = 3; // colle en haut, tant pis si ea deborde en bas } @@ -936,45 +875,36 @@ function ww_evt_balloon(msg) var msg_l; msg_l = xmouse + 3; - this.elemBalloon.style.top = msg_t+"px"; - this.elemBalloon.style.left = msg_l+"px"; + this.elemBalloon.style.top = msg_t + "px"; + this.elemBalloon.style.left = msg_l + "px"; this.elemBalloon.style.visibility = "visible"; } -function evt_false() -{ +function evt_false() { return false; } -function evt_true() -{ +function evt_true() { return true; } -function ww_mdwn_win(idx) -{ +function ww_mdwn_win(idx) { wf = this.frontWindow(); - if(wf.modal && this.twin[idx] != wf) - { + if (wf.modal && this.twin[idx] != wf) { wf.blink(); return(false); } - if(o = document.getElementById(this.varname+"w"+idx)) - { + if (o = document.getElementById(this.varname + "w" + idx)) { e = window.event; z = o.style.zIndex; - if(z != 99) - { + if (z != 99) { o.style.zIndex = this.twin[idx].properties["z-index"] = this.maxdepth; - for(i=0; i z && z2 != 99) - { + if (z2 > z && z2 != 99) { z2--; o2.style.zIndex = this.twin[i].properties["z-index"] = z2; } @@ -982,7 +912,7 @@ function ww_mdwn_win(idx) } } - this.w_active=idx; + this.w_active = idx; this.new_t = this.t0 = o.offsetTop; this.new_l = this.l0 = o.offsetLeft; @@ -996,16 +926,13 @@ function ww_mdwn_win(idx) } return false; } -function ww_evt_mdwn_window(idx) -{ +function ww_evt_mdwn_window(idx) { this.mdwn_win(idx); } -function ww_evt_mdwn_title(idx) -{ - if(!this.twin[idx] || this.twin[idx].moveable<=0) +function ww_evt_mdwn_title(idx) { + if (!this.twin[idx] || this.twin[idx].moveable <= 0) return; - if(this.mdwn_win(idx)) - { + if (this.mdwn_win(idx)) { // this.twin[idx].hide(); /* for(w in this.twin) { @@ -1019,48 +946,43 @@ function ww_evt_mdwn_title(idx) /* */ window.event.cancelBubble = true; - if(window.event.stopPropagation) + if (window.event.stopPropagation) window.event.stopPropagation(); } } -function ww_evt_mdwn_sizer(idx) -{ - if(!this.twin[idx] || this.twin[idx].sizeable<=0) +function ww_evt_mdwn_sizer(idx) { + if (!this.twin[idx] || this.twin[idx].sizeable <= 0) return; - if(this.mdwn_win(idx)) + if (this.mdwn_win(idx)) this.sizing = true; window.event.cancelBubble = true; - if(window.event.stopPropagation) + if (window.event.stopPropagation) window.event.stopPropagation(); } -function ww_evt_mdwn_reducer(idx) -{ +function ww_evt_mdwn_reducer(idx) { // alert("recucer"); - if(o = document.getElementById(this.varname+"w"+idx)) - { - if(this.twin[idx].reduced) - { + if (o = document.getElementById(this.varname + "w" + idx)) { + if (this.twin[idx].reduced) { // restore // o.style.clip = "rect(auto auto auto auto)"; // alert(this.twin[idx].oldheight); - this.twin[idx].setProperties({height:this.twin[idx].oldheight+"px"}); + this.twin[idx].setProperties({height: this.twin[idx].oldheight + "px"}); //o.style.height = (this.twin[idx].oldheight + "px"); this.twin[idx].reduced = false; } - else - { + else { // reduce // o.style.clip = "rect(0px auto 17px auto)"; this.twin[idx].oldheight = parseInt(o.style.height); - tith = (document.getElementById(this.varname+"tbar"+idx).clientHeight) + "px"; + tith = (document.getElementById(this.varname + "tbar" + idx).clientHeight) + "px"; - this.twin[idx].setProperties({height:tith}); + this.twin[idx].setProperties({height: tith}); this.twin[idx].reduced = true; } } window.event.cancelBubble = true; - if(window.event.stopPropagation) + if (window.event.stopPropagation) window.event.stopPropagation(); //if(!this.twin[idx] || this.twin[idx].sizeable<=0) // return; @@ -1068,18 +990,15 @@ function ww_evt_mdwn_reducer(idx) // this.sizing = true; } -function ww_evt_mdwn_closer(idx) -{ - if(o = document.getElementById(this.varname+"w"+idx)) - { +function ww_evt_mdwn_closer(idx) { + if (o = document.getElementById(this.varname + "w" + idx)) { // alert(this.twin[idx].onclose); - if(!this.twin[idx].onclose || (this.twin[idx].onclose)(this.twin[idx])==true) - { + if (!this.twin[idx].onclose || (this.twin[idx].onclose)(this.twin[idx]) == true) { this.twin[idx].hide(); // o.style.visibility = "hidden"; } window.event.cancelBubble = true; - if(window.event.stopPropagation) + if (window.event.stopPropagation) window.event.stopPropagation(); } } @@ -1142,30 +1061,27 @@ function ww_evt_mdwn_closer(idx) return false; } */ -function ww_setProperties(properties) -{ +function ww_setProperties(properties) { style = ""; - for(p in this.properties) - { - if(properties[p]) + for (p in this.properties) { + if (properties[p]) this.properties[p] = properties[p]; - style += p + ":" + this.properties[p] + ";" ; + style += p + ":" + this.properties[p] + ";"; } // if(this.reduced) // style += "clip:rect(0px auto 17px auto);" ; - document.getElementById(this.varname+"w"+this.idx).style.cssText = style; + document.getElementById(this.varname + "w" + this.idx).style.cssText = style; // alert("ww_setProperties : style="+style); - tith = document.getElementById(this.varname+"tbar"+this.idx).clientHeight; + tith = document.getElementById(this.varname + "tbar" + this.idx).clientHeight; // alert("tith=" + tith); tv = false; win_w = parseInt(this.properties.width); win_h = parseInt(this.properties.height); - o_h = win_h-tith-2; - if(o_h < 0) + o_h = win_h - tith - 2; + if (o_h < 0) o_h = 0; - if(this.twoviews && (o = document.getElementById(this.varname+"e"+this.idx).style)) - { + if (this.twoviews && (o = document.getElementById(this.varname + "e" + this.idx).style)) { /* if(this.hasscroll) o.overflow = "scroll"; @@ -1173,32 +1089,30 @@ function ww_setProperties(properties) o.overflow = "hiddden"; */ tv = true; - o.height = (o_h) + "px" ; - o.width = (Math.round(win_w*.25)-2) + "px" ; + o.height = (o_h) + "px"; + o.width = (Math.round(win_w * .25) - 2) + "px"; // document.getElementById(this.varname+"e"+this.idx).style.cssText = style; } - if(o = document.getElementById(this.varname+"c"+this.idx).style) - { + if (o = document.getElementById(this.varname + "c" + this.idx).style) { /* if(this.hasscroll) o.style.overflow = "scroll"; else o.style.overflow = "hiddden"; */ - o.height = (o_h) + "px" ; - if(tv) - o.width = (Math.round(win_w*.75)-2) + "px" ; + o.height = (o_h) + "px"; + if (tv) + o.width = (Math.round(win_w * .75) - 2) + "px"; else - o.width = (Math.round(win_w*1)-2) + "px" ; + o.width = (Math.round(win_w * 1) - 2) + "px"; // style += "width:" + document.getElementById(this.varname+"c"+this.idx).style.width+";"; // alert("ww_setProperties : style=" + style); // document.getElementById(this.varname+"c"+this.idx).style.cssText = style; } - if(o = document.getElementById(this.varname+"r"+this.idx)) - { - t = "top:" + (parseInt(this.properties.height)-18) + "px; left:" + (parseInt(this.properties.width)-18) + "px;" ; + if (o = document.getElementById(this.varname + "r" + this.idx)) { + t = "top:" + (parseInt(this.properties.height) - 18) + "px; left:" + (parseInt(this.properties.width) - 18) + "px;"; o.style.cssText = t; } } @@ -1219,19 +1133,17 @@ function ww_setProperties(properties) return true; } */ -function ww_repaint() -{ +function ww_repaint() { w = parseInt(this.gui.twin[this.idx].properties.width); h = parseInt(this.gui.twin[this.idx].properties.height); - this.gui.twin[this.idx].setProperties( { width:(w)+"px", height:(h)+"px" } ); + this.gui.twin[this.idx].setProperties({ width: (w) + "px", height: (h) + "px" }); } -function ww_sizeto(w, h) -{ - if(w == -1) +function ww_sizeto(w, h) { + if (w == -1) w = parseInt(this.gui.twin[this.idx].properties.width); - if(h == -1) + if (h == -1) h = parseInt(this.gui.twin[this.idx].properties.height); - this.gui.twin[this.idx].setProperties( { width:(w)+"px", height:(h)+"px" } ); + this.gui.twin[this.idx].setProperties({ width: (w) + "px", height: (h) + "px" }); /* if(w != -1 && h != -1) this.gui.twin[this.idx].setProperties( { width:(w)+"px", height:(h)+"px" } ); @@ -1242,55 +1154,44 @@ function ww_sizeto(w, h) if(h != -1) this.gui.twin[this.idx].setProperties( { height:(h)+"px" } ); */ - if(this.gui.twin[this.idx].onresized) + if (this.gui.twin[this.idx].onresized) (this.gui.twin[this.idx].onresized)(parseInt(this.gui.twin[this.idx].properties.top) , parseInt(this.gui.twin[this.idx].properties.left), w, h); } -function ww_moveto(t, l) -{ - this.gui.twin[this.idx].setProperties( { top:(t)+"px", left:(l)+"px" } ); +function ww_moveto(t, l) { + this.gui.twin[this.idx].setProperties({ top: (t) + "px", left: (l) + "px" }); } -function ww_setTitle(t) -{ - document.getElementById(this.varname+"t"+this.idx).innerHTML = " "+t; +function ww_setTitle(t) { + document.getElementById(this.varname + "t" + this.idx).innerHTML = " " + t; } -function ww_setContent(t, view) -{ - if(!view || !this.twoviews || view != "e") +function ww_setContent(t, view) { + if (!view || !this.twoviews || view != "e") view = "c"; - document.getElementById(this.varname+view+this.idx).innerHTML = t; + document.getElementById(this.varname + view + this.idx).innerHTML = t; } -function ww_show() -{ +function ww_show() { this.properties.visibility = "visible"; - document.getElementById(this.varname+"w"+this.idx).style.visibility = "visible"; + document.getElementById(this.varname + "w" + this.idx).style.visibility = "visible"; } -function ww_toFront() -{ +function ww_toFront() { wf = this.gui.frontWindow(); - if(wf.modal && this != wf) - { + if (wf.modal && this != wf) { wf.blink(); return(false); } var o; - if(o = document.getElementById(this.varname+"w"+this.idx)) - { + if (o = document.getElementById(this.varname + "w" + this.idx)) { e = window.event; z = o.style.zIndex; - if(z != 99) - { + if (z != 99) { o.style.zIndex = this.gui.twin[this.idx].properties["z-index"] = this.gui.maxdepth; - for(i=0; i z && z2 != 99) - { + if (z2 > z && z2 != 99) { z2--; o2.style.zIndex = this.gui.twin[i].properties["z-index"] = z2; } @@ -1299,7 +1200,7 @@ function ww_toFront() // this.gui.frontWindow = this.idx; } - this.gui.w_active=this.idx; + this.gui.w_active = this.idx; this.gui.new_t = this.gui.t0 = o.offsetTop; this.gui.new_l = this.gui.l0 = o.offsetLeft; @@ -1309,71 +1210,59 @@ function ww_toFront() } return false; } -function ww_hide() -{ +function ww_hide() { this.properties.visibility = "hidden"; - document.getElementById(this.varname+"w"+this.idx).style.visibility = "hidden"; + document.getElementById(this.varname + "w" + this.idx).style.visibility = "hidden"; } -function ww_blink() -{ - if(o = document.getElementById(this.varname+"t"+this.idx)) - { +function ww_blink() { + if (o = document.getElementById(this.varname + "t" + this.idx)) { o.className = "ww_title_blink"; - window.setTimeout("ww_noblink('"+this.varname+"t"+this.idx+"');", 500); + window.setTimeout("ww_noblink('" + this.varname + "t" + this.idx + "');", 500); } } -function ww_noblink(titleid) -{ - if(o = document.getElementById(titleid)) +function ww_noblink(titleid) { + if (o = document.getElementById(titleid)) o.className = "ww_title"; } -function ww_getClientSize(view) -{ - if(!view || !this.twoviews || view != "e") +function ww_getClientSize(view) { + if (!view || !this.twoviews || view != "e") view = "c"; - if(o = document.getElementById(this.varname+view+this.idx)) - { + if (o = document.getElementById(this.varname + view + this.idx)) { // alert("ww_getClientSize : o.style.width="+o.style.width + " o.style.height="+o.style.height ); // return({w:(o.clientWidth-20), h:(o.clientHeight-2)}); - return({w:(parseInt(o.style.width)-2), h:(parseInt(o.style.height)-2)}); + return({w: (parseInt(o.style.width) - 2), h: (parseInt(o.style.height) - 2)}); } return(null); } -function ww_autoMove() -{ +function ww_autoMove() { // alert("ww_autoMove"); var moved = false; var sized = false; - if(o = document.getElementById(this.varname+"w"+this.idx).style) - { + if (o = document.getElementById(this.varname + "w" + this.idx).style) { wgui = document.getElementById(this.gui.desktop).clientWidth; hgui = document.getElementById(this.gui.desktop).clientHeight; twin = parseInt(o.top); lwin = parseInt(o.left); wwin = parseInt(o.width); hwin = parseInt(o.height); - bwin = twin+hwin; - if(lwin > wgui-wwin) - { - lwin = wgui-wwin; + bwin = twin + hwin; + if (lwin > wgui - wwin) { + lwin = wgui - wwin; moved = true; } - if(lwin < 0) - { + if (lwin < 0) { lwin = 0; wwin = wgui; moved = true; sized = true; } - if(twin > hgui-hwin) - { - twin = hgui-hwin; + if (twin > hgui - hwin) { + twin = hgui - hwin; moved = true; } - if(twin < 0) - { + if (twin < 0) { twin = 0; hwin = hgui; moved = true; @@ -1381,9 +1270,9 @@ function ww_autoMove() } // o.top = twin+"px"; // o.left = lwin+"px"; - if(moved) + if (moved) this.moveto(twin, lwin); - if(sized) + if (sized) this.sizeto(wwin, hwin); // this.setProperties( {top:twin+"px", left:lwin+"px" } ); } @@ -1391,16 +1280,15 @@ function ww_autoMove() */ } -function ww_Window(gui, anchor, varname, idx, properties) -{ - if(!document.getElementById(anchor)) +function ww_Window(gui, anchor, varname, idx, properties) { + if (!document.getElementById(anchor)) return; oldContent = document.getElementById(anchor).innerHTML; this.gui = gui; this.varname = varname; this.idx = idx; this.anchor = anchor; - this.properties = { top:"0px", left:"0px", width:"200px", height:"200px", "z-index":"0", visibility:"visible" }; + this.properties = { top: "0px", left: "0px", width: "200px", height: "200px", "z-index": "0", visibility: "visible" }; // this.evt_mdwn_window = ww_evt_mdwn_window; // this.evt_mdwn_title = ww_evt_mdwn_title; @@ -1420,26 +1308,25 @@ function ww_Window(gui, anchor, varname, idx, properties) this.blink = ww_blink; this.getClientSize = ww_getClientSize; // this.mdwn_win = ww_mdwn_win; - this.modal = (properties.modal && properties.modal>0); - this.twoviews = (properties.twoviews && properties.twoviews>0); - this.hasscroll = (properties.scroll && properties.scroll>0); - this.closeable = (properties.closeable && properties.closeable>0); - this.moveable = (properties.moveable && properties.moveable>0); - this.sizeable = (properties.sizeable && properties.sizeable>0); - this.visibility = (properties.visibility && properties.visibility=="hidden") ? "hidden":"visible"; - this.ontop = (properties.ontop && properties.ontop>0); - this.minwidth = (properties.minwidth && properties.minwidth>0) ? properties.minwidth : 50; - this.maxwidth = (properties.maxwidth && properties.maxwidth>0) ? properties.maxwidth : 20000; - this.minheight = (properties.minheight && properties.minheight>0) ? properties.minheight : 40; - this.maxheight = (properties.maxheight && properties.maxheight>0) ? properties.maxheight : 20000; + this.modal = (properties.modal && properties.modal > 0); + this.twoviews = (properties.twoviews && properties.twoviews > 0); + this.hasscroll = (properties.scroll && properties.scroll > 0); + this.closeable = (properties.closeable && properties.closeable > 0); + this.moveable = (properties.moveable && properties.moveable > 0); + this.sizeable = (properties.sizeable && properties.sizeable > 0); + this.visibility = (properties.visibility && properties.visibility == "hidden") ? "hidden" : "visible"; + this.ontop = (properties.ontop && properties.ontop > 0); + this.minwidth = (properties.minwidth && properties.minwidth > 0) ? properties.minwidth : 50; + this.maxwidth = (properties.maxwidth && properties.maxwidth > 0) ? properties.maxwidth : 20000; + this.minheight = (properties.minheight && properties.minheight > 0) ? properties.minheight : 40; + this.maxheight = (properties.maxheight && properties.maxheight > 0) ? properties.maxheight : 20000; this.onresized = properties.onresized; this.oncreated = properties.oncreated; this.onclose = properties.onclose; this.reduced = false; this.oldheight = -1; - if(!this.ontop) - { + if (!this.ontop) { // gui.frontWindow = this; this.properties["z-index"] = ++gui.maxdepth; } @@ -1448,40 +1335,35 @@ function ww_Window(gui, anchor, varname, idx, properties) s = ""; style = ""; - for(p in this.properties) - { - if(properties[p]) - { - if(p=="height") - { - if(parseInt(properties[p])<60) + for (p in this.properties) { + if (properties[p]) { + if (p == "height") { + if (parseInt(properties[p]) < 60) properties[p] = "60px"; } this.properties[p] = properties[p]; } - style += p + ":" + this.properties[p] + ";" ; + style += p + ":" + this.properties[p] + ";"; } - s += "
    \n"; + s += "
    \n"; // s += "
    "; // s += "
    "; // s += "
    "; s += "
    "; - s += "
    \n"; + s += "
    \n"; s += ""; s += " "; s += " "; - if(properties.title) - { + if (properties.title) { // s += " "; - s += " "; + s += " "; } else s += " "; - if(properties.title2) - { - s += "\n"; + if (properties.title2) { + s += "\n"; s += "\n"; } @@ -1494,9 +1376,9 @@ function ww_Window(gui, anchor, varname, idx, properties) s += "
    \n"; - s += ""; - if(this.closeable) - s += "\n"; + s += ""; + if (this.closeable) + s += "\n"; //else // s += " "; s += "
    \n"; @@ -1505,29 +1387,26 @@ function ww_Window(gui, anchor, varname, idx, properties) //s += "
    "; style = ""; - if(this.hasscroll) + if (this.hasscroll) style += "overflow:scroll;"; else style += "overflow:hidden;"; - if(properties.width) - style += "width" + ":" + (parseInt(this.properties["width"])-2) + "px;" ; - if(properties.heigth) - style += "heigth" + ":" + (parseInt(this.properties["heigth"])-20) + "px;" ; + if (properties.width) + style += "width" + ":" + (parseInt(this.properties["width"]) - 2) + "px;"; + if (properties.heigth) + style += "heigth" + ":" + (parseInt(this.properties["heigth"]) - 20) + "px;"; - if(this.twoviews) - { - s += "
    \n"; - s += "
    " + oldContent + "
    \n"; + if (this.twoviews) { + s += "
    \n"; + s += "
    " + oldContent + "
    \n"; } - else - { - s += "
    "+oldContent+"
    \n"; + else { + s += "
    " + oldContent + "
    \n"; } - if(this.sizeable) - { - s += "
    \n"; + if (this.sizeable) { + s += "
    \n"; } // alert("ww_Window : style=" + style); //s += "
    \n"; @@ -1537,28 +1416,25 @@ function ww_Window(gui, anchor, varname, idx, properties) // alert(s); // document.write(s); document.getElementById(anchor).innerHTML = s; - this.setProperties( this.properties ); - if(this.oncreated) + this.setProperties(this.properties); + if (this.oncreated) (this.oncreated)(); return this; } -function ww_createWindow(anchor, properties) -{ +function ww_createWindow(anchor, properties) { this.twin[this.nwin] = new ww_Window(this, anchor, this.varname, this.nwin, properties); //this.nwin++; return(this.twin[this.nwin++]); } -function ww_getWinPosAsXML() -{ - var t=""; +function ww_getWinPosAsXML() { + var t = ""; // t += "<"++"?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n\r\n"; - for(w in this.twin) - { + for (w in this.twin) { t += " z && z2 != 99) - { + if (z2 > z && z2 != 99) { z = z2; idx = i; } @@ -1589,8 +1461,7 @@ function ww_frontWindow() return(idx >= 0 ? this.twin[idx] : null); } -function ww_openCenterWindow(zurl, w, h, name, params) -{ +function ww_openCenterWindow(zurl, w, h, name, params) { p = new Array(); p.directories = "no"; p.location = "no"; @@ -1599,37 +1470,32 @@ function ww_openCenterWindow(zurl, w, h, name, params) p.help = "no"; p.status = "no"; p.resizable = "no"; - for(cc in params) - { - if(p[params[cc].n]) + for (cc in params) { + if (p[params[cc].n]) p[params[cc].n] = params[cc].v; } - t = ((document.getElementById(this.desktop).clientHeight - h)/2) + self.screenTop; - l = ((document.getElementById(this.desktop).clientWidth - w)/2) + self.screenLeft; - if(t<10) + t = ((document.getElementById(this.desktop).clientHeight - h) / 2) + self.screenTop; + l = ((document.getElementById(this.desktop).clientWidth - w) / 2) + self.screenLeft; + if (t < 10) t = 10; - if(l<10) + if (l < 10) l = 10; - s = "top="+t+", left="+l+", width="+w+", height="+h; - for(cc in p) + s = "top=" + t + ", left=" + l + ", width=" + w + ", height=" + h; + for (cc in p) s += "," + cc + "=" + p[cc]; return(window.open(zurl, name, s, true)); } -function ww_select(obj) -{ +function ww_select(obj) { this.unselect(); - if(obj) - { + if (obj) { obj.className = obj.className.replace("s_", "S_"); this.selectedObject = obj; } } -function ww_unselect() -{ - if(this.selectedObject) - { +function ww_unselect() { + if (this.selectedObject) { var cn = this.selectedObject.className; cn = cn.replace("S_", "s_"); this.selectedObject.className = cn; @@ -1637,18 +1503,16 @@ function ww_unselect() } } -function ww_runAsMenu(event, backparm) -{ +function ww_runAsMenu(event, backparm) { // alert(event); this.backparm = backparm; - if(this.gui.activeMenu != null) - { + if (this.gui.activeMenu != null) { this.gui.activeMenu.style.visibility = "hidden"; this.gui.activeMenu = null; } - if(typeof(event.which) != 'undefined') - button = this.gui.firefoxButtons["b"+event.which]; // safari aussi ??? + if (typeof(event.which) != 'undefined') + button = this.gui.firefoxButtons["b" + event.which]; // safari aussi ??? else button = event.button; xmouse = parseInt(event.clientX); @@ -1661,71 +1525,61 @@ function ww_runAsMenu(event, backparm) var bodyH = document.documentElement.clientHeight; - if(ymouse+this.clientHeight < bodyH) - { + if (ymouse + this.clientHeight < bodyH) { // menu en dessous - this.style.top = (ymouse-3)+"px"; - this.style.left = (xmouse-3)+"px"; + this.style.top = (ymouse - 3) + "px"; + this.style.left = (xmouse - 3) + "px"; } - else - { + else { // menu au dessus - this.style.top = (ymouse+0-this.clientHeight)+"px"; - this.style.left = (xmouse-3)+"px"; + this.style.top = (ymouse + 0 - this.clientHeight) + "px"; + this.style.left = (xmouse - 3) + "px"; } this.style.visibility = "visible"; this.gui.activeMenu = this; } -function ww_dieMenu(mid) -{ +function ww_dieMenu(mid) { var m = document.getElementById(mid); - if(m.gui.activeMenu) - { + if (m.gui.activeMenu) { m.style.visibility = "hidden"; m.gui.activeMenu = null; (m.menuCallback)("DIE", m.backparm, null); } } -function ww_evt_mouseout_menu() -{ - this.dieMenuTimer = self.setTimeout("ww_dieMenu('"+this.id+"');", 500); +function ww_evt_mouseout_menu() { + this.dieMenuTimer = self.setTimeout("ww_dieMenu('" + this.id + "');", 500); } -function ww_evt_mousemove_menu() -{ +function ww_evt_mousemove_menu() { // var str=''; for (var k in event) {str+='event.'+k+'='+event[k]+'
    \n'} // document.getElementById("debug").innerHTML = "MOVE "+(iiii++)+"
    \n" + str ; - if(this.dieMenuTimer) - { + if (this.dieMenuTimer) { clearTimeout(this.dieMenuTimer); this.dieMenuTimer = null; } } -function ww_evt_click_menu(e) -{ - if(this.dieMenuTimer) - { +function ww_evt_click_menu(e) { + if (this.dieMenuTimer) { clearTimeout(this.dieMenuTimer); this.dieMenuTimer = null; } - if(!e) + if (!e) e = window.event; var tg = (e.target) ? e.target : e.srcElement; - while(tg && (tg.nodeType!=1 || !tg.id)) + while (tg && (tg.nodeType != 1 || !tg.id)) tg = tg.parentNode; - if(tg.className=="disabled") + if (tg.className == "disabled") return; this.style.visibility = "hidden"; this.gui.activeMenu = null; (this.menuCallback)("SELECT", this.backparm, tg.id); } -function ww_setAsMenu(id, callback) -{ - o=this.document.getElementById(id); - o.ismenu=1; - o.gui=this; - o.runAsMenu=ww_runAsMenu; +function ww_setAsMenu(id, callback) { + o = this.document.getElementById(id); + o.ismenu = 1; + o.gui = this; + o.runAsMenu = ww_runAsMenu; o.menuCallback = callback; o.onmouseout = ww_evt_mouseout_menu; o.onmousemove = ww_evt_mousemove_menu; @@ -1733,21 +1587,20 @@ function ww_setAsMenu(id, callback) } -function GUI(varname, idbody, skin) -{ - this.firefoxButtons = {"b65536":0, "b1":1, "b2":4, "b3":2}; - if(!skin) +function GUI(varname, idbody, skin) { + this.firefoxButtons = {"b65536": 0, "b1": 1, "b2": 4, "b3": 2}; + if (!skin) skin = "FR"; this.skin = skin; this.document = document; - this.sizing=false, - this.dragging=false, + this.sizing = false, + this.dragging = false, this.w_active = -1, this.varname = varname; - this.t0=0, this.l0=0, // le top/left initial de la win - this.w0=0, this.h0=0, // le width/height - this.x0=0, this.y0=0, // la pos de la souris - this.new_t=0, this.new_l=0, this.new_w=0, this.new_h=0; + this.t0 = 0, this.l0 = 0, // le top/left initial de la win + this.w0 = 0, this.h0 = 0, // le width/height + this.x0 = 0, this.y0 = 0, // la pos de la souris + this.new_t = 0, this.new_l = 0, this.new_w = 0, this.new_h = 0; this.nwin = 0; this.twin = new Array(); // le tableau des win this.maxdepth = 0; // le zindex de la win au premier plan (hors win 'ontop') @@ -1759,11 +1612,11 @@ function GUI(varname, idbody, skin) this.createWindow = ww_createWindow; this.frontWindow = ww_frontWindow; this.evt_mdwn_window = ww_evt_mdwn_window; - this.evt_mdwn_title = ww_evt_mdwn_title; - this.evt_mdwn_sizer = ww_evt_mdwn_sizer; - this.evt_mdwn_reducer = ww_evt_mdwn_reducer; - this.evt_mdwn_closer = ww_evt_mdwn_closer; - this.showBalloon = ww_evt_balloon; + this.evt_mdwn_title = ww_evt_mdwn_title; + this.evt_mdwn_sizer = ww_evt_mdwn_sizer; + this.evt_mdwn_reducer = ww_evt_mdwn_reducer; + this.evt_mdwn_closer = ww_evt_mdwn_closer; + this.showBalloon = ww_evt_balloon; this.mdwn_win = ww_mdwn_win; this.getWinPosAsXML = ww_getWinPosAsXML; this.openCenterWindow = ww_openCenterWindow; @@ -1773,7 +1626,7 @@ function GUI(varname, idbody, skin) var node; node = document.createElement("div"); - node.id = this.varname+"wb"; + node.id = this.varname + "wb"; node.className = "ww_winborder"; this.windowBorder = desk.appendChild(node); // this.windowBorder = document.getElementById("winborder"); @@ -1788,38 +1641,54 @@ function GUI(varname, idbody, skin) node.src = "cursors/nodrop01.gif"; dragObj.objCursor = desk.appendChild(node); - desk.onmousemove = function (e) {ww_evt_mmov_doc(varname, (e ? e : window.event));}; + desk.onmousemove = function (e) { + ww_evt_mmov_doc(varname, (e ? e : window.event)); + }; desk.onmousedown = function (e) { var evt = e ? e : window.event; // ---- prevent selection into ff var srcElement = evt.srcElement ? evt.srcElement : evt.target; - if (typeof evt.preventDefault != 'undefined' && (srcElement.tagName!="INPUT" && srcElement.tagName!="SELECT" && srcElement.tagName!="TEXTAREA")) - { + if (typeof evt.preventDefault != 'undefined' && (srcElement.tagName != "INPUT" && srcElement.tagName != "SELECT" && srcElement.tagName != "TEXTAREA")) { evt.preventDefault(); } // ---- ww_evt_mdwn_doc(varname, evt); }; - desk.onmouseup = function (e) {ww_evt_mup_doc(varname, (e ? e : window.event));}; + desk.onmouseup = function (e) { + ww_evt_mup_doc(varname, (e ? e : window.event)); + }; - if(typeof(document.onselectstart) != "undefined") - { + if (typeof(document.onselectstart) != "undefined") { // ie document.onselectstart = evt_select_doc; } // on interdit les menus contextuels de explorer // document.oncontextmenu = function (e) { if(e){e.returnValue=false}else{window.event.returnValue=false}; return false; }; - document.oncontextmenu = function (e) {ww_evt_kon_doc(varname, (e ? e : window.event));}; + document.oncontextmenu = function (e) { + ww_evt_kon_doc(varname, (e ? e : window.event)); + }; - this.setClickable = function(id, clickCallback){o=this.document.getElementById(id); o.clickable=1; o.clickCallback=clickCallback; }; - this.setDraggable = function(id, dragCallback){o=this.document.getElementById(id); o.draggable=1; o.dragCallback=dragCallback; }; - this.setDroppable = function(id, dropCallback){o=this.document.getElementById(id); o.droppable=1; o.dropCallback=dropCallback; }; + this.setClickable = function (id, clickCallback) { + o = this.document.getElementById(id); + o.clickable = 1; + o.clickCallback = clickCallback; + }; + this.setDraggable = function (id, dragCallback) { + o = this.document.getElementById(id); + o.draggable = 1; + o.dragCallback = dragCallback; + }; + this.setDroppable = function (id, dropCallback) { + o = this.document.getElementById(id); + o.droppable = 1; + o.dropCallback = dropCallback; + }; this.activeMenu = null; // this.setAsMenu = function(id){o=this.document.getElementById(id); o.ismenu=1; o.gui=this; o.runAsMenu=ww_runAsMenu}; - this.setAsMenu = ww_setAsMenu; + this.setAsMenu = ww_setAsMenu; this.selectedObject = null; this.select = ww_select; @@ -1870,47 +1739,43 @@ function GUI(varname, idbody, skin) */ } -function evt_select_doc(evt) -{ +function evt_select_doc(evt) { evt = evt ? evt : window.event; var srcElement = evt.srcElement ? evt.srcElement : evt.target; - return(srcElement.tagName=="INPUT" || srcElement.tagName=="TEXTAREA"); + return(srcElement.tagName == "INPUT" || srcElement.tagName == "TEXTAREA"); } -function w2md(e) -{ - if(!e) +function w2md(e) { + if (!e) e = window.event; // var str=''; for (var k in e) {str+='event.'+k+'='+e[k]+'
    \n'} // document.getElementById("debug").innerHTML = "DOWN "+(iiii++)+"
    \n" + str ; - document.getElementById("debug").innerHTML += "DOWN " ; - e.cancelBubble=true; - e.returnValue=false; + document.getElementById("debug").innerHTML += "DOWN "; + e.cancelBubble = true; + e.returnValue = false; // e.stopPropagation(); return(false); } -function w2mu(e) -{ - if(!e) +function w2mu(e) { + if (!e) e = window.event; // var str=''; for (var k in e) {str+='event.'+k+'='+e[k]+'
    \n'} // document.getElementById("debug").innerHTML = "UP "+(iiii++)+"
    \n" + str ; - document.getElementById("debug").innerHTML += "UP " ; - e.cancelBubble=true; - e.returnValue=false; + document.getElementById("debug").innerHTML += "UP "; + e.cancelBubble = true; + e.returnValue = false; // e.stopPropagation(); return(false); } -function w2k(e) -{ - if(!e) +function w2k(e) { + if (!e) e = window.event; // var str=''; for (var k in e) {str+='event.'+k+'='+e[k]+'
    \n'} // document.getElementById("debug").innerHTML = "KON "+(iiii++)+"
    \n" + str ; - document.getElementById("debug").innerHTML += "KON " ; + document.getElementById("debug").innerHTML += "KON "; // e.cancelBubble=true; // e.returnValue=false; // e.stopPropagation(); @@ -1918,26 +1783,23 @@ function w2k(e) } -function ww_selectStart() -{ - return(window.event.srcElement.tagName=="INPUT" || window.event.srcElement.tagName=="TEXTAREA"); +function ww_selectStart() { + return(window.event.srcElement.tagName == "INPUT" || window.event.srcElement.tagName == "TEXTAREA"); } escapeCharString = "*+@-/"; -escapeCharCodes = new Array( 42,43,64,45,47 ); -function fullEscape(s) -{ - var s2,ret,i,x,c; +escapeCharCodes = new Array(42, 43, 64, 45, 47); +function fullEscape(s) { + var s2, ret, i, x, c; s2 = escape(s); ret = ""; - for(i=0; i
    \"\"
    " + properties.title + "
    " + properties.title + "" + properties.title + " "+properties.title2+"" + properties.title2 + "