var MARKET_SECTION_PATH = 'market'; function showDialogWindow(width,height) { //alert(width+':'+height); $("
", { "class": "blackass", id: "blackass" }).appendTo('body'); $("
", { "class": "dialog_window", id: "dialog" }).appendTo('#blackass'); $('#dialog').css("width",width); $('#dialog').css("height",height); $('#dialog').addClass('dialog_window_loading'); } $(document).ready(function(){ $('#blackass').live('click',function(e) { if(e.target != this) return; $('#dialog').fadeOut('fast',function(){ $('#blackass').fadeOut('fast',function(){ $('#blackass').remove(); }) }); //$(this).fadeOut('fast').remove(); }); /** * Showing teasers block */ var teaserElArr = $('.teaser_block'); teaserElArr.each(function(i,teaserEl){ //alert(i+": "+$(teaserEl).attr("count")); $(teaserEl).load("/index.php?section=teaser&act=teaser_ajax&subact=get_teaser_block&count="+$(teaserEl).attr("count"),function(){ $(teaserEl).append("Как разместить здесь тизер?"); }); }); // Top teasers var teaserElArr = $('.teaser_top'); teaserElArr.each(function(i,teaserEl){ //alert(i+": "+$(teaserEl).attr("count")); $(teaserEl).load("/index.php?section=teaser&act=teaser_ajax&subact=get_teaser_top&top_pos="+$(teaserEl).attr("teaser_top_pos")); }); /** * end of teasers block */ $(".market_link2more_sections").click(function(){ $(this).parent().addClass('ajax_standby'); $(this).parent().load("/index.php?section="+MARKET_SECTION_PATH+"&act=market_ajax&subact=market_load_sections&parent_section_id="+$(this).attr('otrasl_parent_id'),function(){ $(this).removeClass('ajax_standby'); }); return false; }); /** * Autocommplete data_producer field */ $('#market_form_producer_select').change(function(){ $('#data_producer').val($(this).val()); }); $('#data_producer').keyup(function(event){ if (event.keyCode=='40' && $('#data_producer_autocomplete').css('display')=='block') $('#data_producer_autocomplete').focus(); var cur_el = $(this); cur_val = $(this).val(); var arr = new Array("ООО ","ЗАО ","ОАО ","ИП ","<",">","\"","`","'"); var disabled=false; $.each(arr,function(i,data){ if (cur_val.indexOf(data)>=0) { $('#data_producer_error').html("Не указывайте форму собственности или кавычки!"); $(cur_el).parent("form").find("input:last-child").attr("disabled",true); disabled=true; } }); if (!disabled) { $('#data_producer_error').html(""); $(cur_el).parent("form").find("input:last-child").attr("disabled",false); if (cur_val.length>1) { $.ajaxSetup({ scriptCharset: "utf-8" , contentType: "application/x-www-form-urlencoded; charset=utf-8", cache: false}); $.get("/index.php?section=production&act=market_ajax&subact=market_get_brands_options",{ keyword:cur_val },function(data) { if (data.length>0) { //alert(data); $('#data_producer_autocomplete').html(data); $('#data_producer_autocomplete').slideDown('fast'); } else { $('#data_producer_autocomplete').html(''); $('#data_producer_autocomplete').slideUp('fast'); } }); } } }); $('#data_producer').focus(function(){ $(this).attr('focused','true'); }); $('#data_producer').blur(function(){ $(this).attr('focused','false'); }); $('#data_producer_autocomplete').click(function(){ //alert($(this).val()); $('#data_producer').val($(this).val()); $('#data_producer_autocomplete').slideUp('fast'); }); $('#data_producer_autocomplete').blur(function(){ if ($('#data_producer').attr('focused') == 'false') $(this).slideUp(); }); $('#data_producer_autocomplete').keypress(function(event){ if (event.keyCode == '13' || event.keyCode == '9') { $('#data_producer').val($(this).val()); $(this).slideUp('fast'); } }); /** * endof: Autocommplete data_producer field */ $('.checkRequired').submit(function(){ var reqarr = $(this).find(".required"); var error = false; tinyMCE.triggerSave(); var data_text = $('#data_text').val(); data_text = data_text.trim(); if (data_text == '[p] [/p]') $('#data_text').val(''); reqarr.each(function(i,req) { //alert($(req).attr('name')+" : "+$(req).val()); if (!$(req).val() || $(req).val() == '0') { $(req).css({border:'1px red solid'}); error = true; } else { $(req).css({border:'1px #aaa solid'}); } }); if (error) { $(this).find("#form_check_msg").html("Заполните обязательные поля"); return false; } }); $('#market_mass_update_form').submit(function(){ //alert($('input:radio[name=mu_action]:checked').val()); if ( !$('input:radio[name=mu_action]:checked').val() ) { $('#mass_update_form_msg').html('Выберите действие'); return false; } if ( !$('.data_item_checkbox:checked').val() ) { $('#mass_update_form_msg').html('Выберите хотябы одну запись'); return false; } }); $('input:radio[name=mu_action]').change(function(){ $('#mass_update_form_msg').html(''); }); $('.market_list_mine_mass_price_input').change(function(){ $('#data_id_'+$(this).attr('data_id')).attr("checked","checked"); }); $('.tender_invalid2valid_link').click(function(){ $(this).removeClass('tender_invalid2valid_link'); $(this).addClass('tender_turned2valid_link'); $(this).load("/index.php?section=tenders&act=tender_ajax&subact=tender_validate&tender_id="+$(this).attr('tender_id'),function(){ //$(this).parent().parent("div").fadeOut('slow'); }); }); $('#tenders_validate_all_on_page').click(function(){ if ( confirm('Утвердить все тендеры на странице?') ) { $('.tender_invalid2valid_link').each(function(i,obj) { //$('#tenders_validate_all_on_page').append(i+" : "+$(obj).attr('tender_id')+"
"); $(obj).load("/index.php?section=tenders&act=tender_ajax&subact=tender_validate&tender_id="+$(obj).attr('tender_id'),function() { $(obj).removeClass('tender_invalid2valid_link'); $(obj).addClass('tender_turned2valid_link'); }); }); } return false; }); $('#prod_add_strings_btn').click(function(){ $('#cloneTR').clone().appendTo('#prod_table'); }); $('.checkRequiredNoMCE').live('submit',function(){ var reqarr = $(this).find(".required"); var error = false; reqarr.each(function(i,req) { //alert($(req).attr('name')+" : "+$(req).val()); if (!$(req).val() || $(req).val() == '0') { $(req).css({border:'1px red solid'}); error = true; } else { $(req).css({border:'1px #aaa solid'}); } }); if (error) { $(this).find("#form_check_msg").html("Заполните обязательные поля"); return false; } }); $('.checkRequiredNoMCE input.required').blur(function(){ if ($(this).val()) $(this).css({border:'1px #aaa solid'}); }); $('.uord_invalid2valid_link').click(function(){ $(this).load("/index.php?section=buy&act=orders_ajax&subact=orders_validate&uord_id="+$(this).attr('uord_id'),function(){ $(this).removeClass('uord_invalid2valid_link'); $(this).addClass('uord_turned2valid_link'); }); }); $('.whatis').click(function(){ var pos = $(this).position(); //alert($(this).left()); $(this).children("div").css("left",$(this).width()+pos.left); $(this).children("div").slideToggle('fast'); return false; }); $('#mmq_counter').load('/index.php?section=massmail&act=massmail_ajax&subact=mmq_counter&comp_id='+$('#mmq_counter').attr('comp_id')); var refreshId = setInterval(function() { $('#mmq_counter').html(""); $('#mmq_counter').load('/index.php?section=massmail&act=massmail_ajax&subact=mmq_counter&comp_id='+$('#mmq_counter').attr('comp_id')); }, 5000); /** * Обработка статистических блоков (div) */ $('.stat_counter').html(""); var stat_divs = $('.stat_counter'); $.each(stat_divs,function(i,obj) { //alert("/index.php?section=stat&act=stat_ajax&subact=stat_count&stat_type="+$(obj).attr('stat_type')+"&comp_id="+$(obj).attr('comp_id')+"&extraF="+$(obj).attr('extraF')+"&extraV="+$(obj).attr('extraV')); $(obj).load("/index.php?section=stat&act=stat_ajax&subact=stat_count&stat_type="+$(obj).attr('stat_type')+"&comp_id="+$(obj).attr('comp_id')+"&extraF="+$(obj).attr('extraF')+"&extraV="+$(obj).attr('extraV')); }); $('.stat_counter_click').click(function(){ $.get("/index.php?section=stat&act=stat_ajax&subact=stat_count&stat_type="+$(this).attr('stat_type')+"&comp_id="+$(this).attr('comp_id')+"&extraF="+$(this).attr('extraF')+"&extraV="+$(this).attr('extraV')); //return false; }); $('.img_first_stat_date').live("click",function(){ var obj = $(this); $.get("/index.php?section=stat&act=stat_ajax&subact=stat_get_first_date",function(data){ $(obj).after("
"+data+"
"); $(obj).remove(); }); }); $('.question2answer').click(function(){ $(this).after("
"+$(this).attr('titlehtml')+"
"); $(this).remove(); return false; }); });