var p4 = p4 || {}; $(document).ready(function () { $('input.input-button').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') { jq_date = 'en-GB'; } $.datepicker.setDefaults({showMonthAfterYear: false}); $.datepicker.setDefaults($.datepicker.regional[jq_date]); $('body').on('click', '.infoDialog', function (event) { 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 }); }); 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({ type: "POST", url: "/user/preferences/", data: { prop: name, value: value }, dataType: 'json', timeout: function () { jQuery.data['pref_' + name] = false; }, error: function () { jQuery.data['pref_' + name] = false; }, success: function (data) { if (data.success) { humane.info(data.message); } else { humane.error(data.message); } jQuery.data['pref_' + name] = false; return; } }); } function infoDialog(el) { $("#DIALOG").attr('title', '') .empty() .append(el.attr('infos')) .dialog({ 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'}); } // @deprecated function manageSession(data, showMessages) { if (typeof(showMessages) == "undefined") showMessages = false; if (data.status == 'disconnected' || data.status == 'session') { disconnected(); return false; } if (showMessages) { var box = $('#notification_box'); box.empty().append(data.notifications); if (box.is(':visible')) fix_notification_height(); if ($('.notification.unread', box).length > 0) { var trigger = $('#notification_trigger'); $('.counter', trigger) .empty() .append($('.notification.unread', box).length); $('.counter', trigger).css('visibility', 'visible'); } else $('#notification_trigger .counter').css('visibility', 'hidden').empty(); if (data.changed.length > 0) { var current_open = $('.SSTT.ui-state-active'); var current_sstt = current_open.length > 0 ? current_open.attr('id').split('_').pop() : false; 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() }); main_open = true; } } else { if (!sstt.hasClass('active')) sstt.addClass('unread'); else { $('.alert_datas_changed', $('#SSTT_content_' + data.changed[i])).show(); } } } } if ('' !== $.trim(data.message)) { if ($('#MESSAGE').length === 0) $('body').append('
'); $('#MESSAGE') .empty() .append('