');
}
});
content.append(list);
submenu.append(header).append(content).append(footer);
jQuery(trigger).before(submenu);
jQuery(submenu).fadeIn();
}
function toggleMenu(trigger) {
hideAllSubmenus();
jQuery(trigger).siblings('.simplemenu-submenu').toggle().toggleClass('opened');
}
function hideAllSubmenus() {
jQuery('.menu-submenu.up:visible').fadeOut('slow');
jQuery('.simplemenu-submenu:visible').hide().toggleClass('opened');
jQuery('.menu-submenu.down:visible').fadeOut('slow');
jQuery('#chat-online-users-content').hide();
}
// Hide visible ballons when clicked outside them
jQuery(document).ready(function() {
jQuery('body').live('click', function() { hideAllSubmenus(); });
jQuery('.menu-submenu-trigger').click(function(e) { e.stopPropagation(); });
jQuery('.simplemenu-trigger').click(function(e) { e.stopPropagation(); });
jQuery('#chat-online-users').click(function(e) { e.stopPropagation(); });
});
function input_javascript_ordering_stuff() {
jQuery(function() {
jQuery(".input-list").sortable({
placeholder: 'ui-state-highlight',
axis: 'y',
opacity: 0.8,
tolerance: 'pointer',
forcePlaceholderSize: true,
update: function(event, ui) {
jQuery.post(jQuery(this).next('.order-inputs').attr('href'), jQuery(this).sortable('serialize'));
}
});
jQuery(".input-list li").disableSelection();
jQuery(".input-list li").hover(
function() {
jQuery(this).addClass('editing-input');
jQuery(this).css('cursor', 'move');
},
function() {
jQuery(this).removeClass('editing-input');
jQuery(this).css('cursor', 'pointer');
}
);
jQuery("#display-add-input-button > .hint").show();
});
}
function display_input_stuff() {
jQuery(function() {
jQuery("#add-input-button").click(function() {
jQuery("#display-add-input-button").find('.loading-area').addClass('small-loading');
url = jQuery(this).attr('href');
jQuery.get(url, function(data){
jQuery("#" + "new-product-input").html(data);
jQuery("#display-add-input-button").find('.loading-area').removeClass('small-loading');
jQuery("#add-input-button").hide();
});
return false;
});
});
}
function add_input_stuff() {
jQuery(function() {
jQuery(".cancel-add-input").click(function() {
jQuery("#new-product-input").html('');
jQuery("#add-input-button").show();
return false;
});
jQuery("#input-category-form").submit(function() {
id = "product-inputs";
jQuery(this).find('.loading-area').addClass('small-loading');
jQuery("#input-category-form,#input-category-form *").css('cursor', 'progress');
jQuery.post(this.action, jQuery(this).serialize(), function(data) {
jQuery("#" + id).html(data);
});
return false;
});
jQuery('body').scrollTo('50%', 500);
});
}
function input_javascript_stuff(id) {
jQuery(function() {
id = 'input-' + id;
jQuery("#add-"+ id +"-details,#edit-"+id).click(function() {
target = '#' + id + '-form';
jQuery('#' + id + ' ' + '.input-details').hide();
jQuery(target).show();
// make request only if the form is not loaded yet
if (jQuery(target + ' form').length == 0) {
small_loading(id);
jQuery(target).load(jQuery(this).attr('href'), function() {
loading_done(id);
jQuery('#' + id + ' .input-informations').removeClass('input-form-closed').addClass('input-form-opened');
});
}
else {
jQuery('#' + id + ' .input-informations').removeClass('input-form-closed').addClass('input-form-opened');
}
return false;
});
jQuery("#remove-" + id).unbind('click').click(function() {
if (confirm(jQuery(this).attr('data-confirm'))) {
url = jQuery(this).attr('href');
small_loading("product-inputs");
jQuery.post(url, function(data){
jQuery("#" + "product-inputs").html(data);
loading_done("product-inputs");
});
}
return false;
});
});
}
function edit_input_stuff(id, currency_separator) {
id = "input-" + id;
jQuery(function() {
jQuery("#" + "edit-" + id + "-form").ajaxForm({
target: "#" + id,
beforeSubmit: function(a,f,o) {
o.loading = small_loading('edit-' + id + '-form');
o.loaded = loading_done(id);
}
});
jQuery("#cancel-edit-" + id).click(function() {
jQuery("#" + id + ' ' + '.input-details').show();
jQuery("#" + id + '-form').hide();
jQuery('#' + id + ' .input-informations').removeClass('input-form-opened').addClass('input-form-closed');
return false;
});
jQuery(".numbers-only").keypress(function(event) {
return numbersonly(event, currency_separator)
});
add_input_unit(id, jQuery("#" + id + " select :selected").val())
jQuery("#" + id + ' select').change(function() {
add_input_unit(id, jQuery("#" + id + " select :selected").val())
});
jQuery("#" + id).enableSelection();
});
}
function add_input_unit(id, selected_unit) {
if (selected_unit != '') {
jQuery("#" + id + ' .price-by-unit').show();
jQuery("#" + id + ' .selected-unit').text(jQuery("#" + id + " select :selected").text());
} else {
jQuery("#" + id + ' .price-by-unit').hide();
}
}
function loading_for_button(selector) {
jQuery(selector).append("");
jQuery(selector).css('cursor', 'progress');
}
function new_qualifier_row(selector, select_qualifiers, delete_button) {
index = jQuery(selector + ' tr').size() - 1;
jQuery(selector).append("
" + select_qualifiers + "
" + delete_button + "
");
}
// controls the display of the login/logout stuff
jQuery(function($) {
$.ajaxSetup({cache: false});
$.getJSON('/account/user_data', function userDataCallBack(data) {
if (data.login) {
// logged in
loggedInDataCallBack(data);
addManageEnterprisesToOldStyleMenu(data);
chatOnlineUsersDataCallBack(data);
} else {
// not logged in
$('#user .not-logged-in, .login-block .not-logged-user').fadeIn();
}
if (data.notice) {
display_notice(data.notice);
}
// Bind this event to do more actions with the user data (for example, inside plugins)
$(window).trigger("userDataLoaded", data);
});
function loggedInDataCallBack(data) {
// logged in
$('body').addClass('logged-in');
$('#user .logged-in, .login-block .logged-user-info').each(function() {
$(this).find('a[href]').each(function() {
var new_href = $(this).attr('href').replace('{login}', data.login);
if (data.email_domain) {
new_href = new_href.replace('{email_domain}', data.email_domain);
}
$(this).attr('href', new_href);
});
var html = $(this).html().replace(/{login}/g, data.login).replace('{month}', data.since_month).replace('{year}', data.since_year);
$(this).html(html).fadeIn();
if (data.is_admin) {
$('#user .admin-link').show();
}
if (data.email_domain) {
$('#user .webmail-link').show();
}
});
}
function addManageEnterprisesToOldStyleMenu(data) {
if ($('#manage-enterprises-link-template').length > 0) {
$.each(data.enterprises, function(index, enterprise) {
var item = $('