") == -1 ){ $("#pop_aut").html(data); ptform(); } } }); } showPopup($elem); } } function onBodyClick (e) { if (!options.hideOnAroundClick) return; var $elem = $elements.filter("." + options.popupOnClass); var $popup = $elem.length === 1 ? $elem.data("popup-element") : null; if (!$popup) return; var $target = $(e.target), $find = $target.closest($popup); if ($find.length!==1) { hidePopup($elem); } } $("body").on("click.popup", onBodyClick); return this.each(function(){ var $this = $(this), $popup = $($this.data("popup")); $this .data("popup-element", $popup) .on("click", function(){ onBtnClick($this); return false; }); }); }; $.fn.blockToggle = function (options) { function open ($elem) { $elem.addClass("on"); $elem.data("block-element").addClass("on"); if( location.pathname != "/catalog_sro" ){ //alkh $.ajax({ type: "GET", url: "/catalog_sro", data: {ajx: 1}, success: function(msg){ $("#toggle_body").html(msg); $(":submit, :text, :password, select").add(".pretty").not(".dontpretty").prettyform({ autoHide: false }); } }); } } function close ($elem) { $elem.removeClass("on"); $elem.data("block-element").removeClass("on"); } return this.each(function(){ var $this = $(this), $block = $($this.data("block")); $this .data("block-element", $block) .on("click.block", function(){ if ($this.hasClass("on")) { close($this); } else { open($this); } return false; }) .on("mousedown selectstart", false); if ($this.hasClass("on")) { open($this); } }); }; })(jQuery); var ToggleFunc = function (options) { var self = this, $elem = options.target $btn = options.trigger; this.open = function () { $elem.removeClass("hide"); $btn.addClass("on"); }; this.close = function () { $elem.addClass("hide"); $btn.removeClass("on"); }; $btn .on("selectstart mousedown", false) .on("click.tggl", function(){ if ($btn.hasClass("on")) { self.close(); } else { self.open(); } }); self.close(); } var labelToggle = function ($labels) { $labels.each(function(){ var $this = $(this), $parent = $(this).closest(".div_form"), $elem = $parent.find("#" + $this.attr("for")); $elem.on({ "focus": foc, "blur": blu }); function foc () { $this.addClass("hide"); } function blu () { if ($elem.val()==="") { $this.removeClass("hide"); } } }); } //alkh // при смене параметров фильтра $(function(){ $("#s-1, #s-2").live("change", function(){ var form_data = $(".filter_form form").serialize(); $.ajax({ type: "GET", url: "/catalog_sro", data: "ajx=1&"+form_data, success: function(msg){ $("#toggle_body").html(msg); $(":submit, :text, :password, select").add(".pretty").not(".dontpretty").prettyform({ autoHide: false }); } }); }); }); $(function(){ $("#pop_reg input[type='submit']").live("click", function(e){ e.preventDefault(); var form_data = $(this).parents("form").serialize(); $.ajax({ type: "POST", url: "/user/register?ajx=1", data: form_data, success: function(msg){ $("#pop_reg").html(msg); ptform(); } }); return false; }); $("#pop_aut input[type='submit']").live("click", function(e){ e.preventDefault(); var form_data = $(this).parents("form").serialize(); $.ajax({ type: "POST", url: "/user?ajx=1", data: form_data, success: function(msg){ $("#pop_aut").html(msg); ptform(); } }); return false; }); }); function ptform(){ $(":submit, :text, :password, select", ".filter_form, .search_form, .form_block").add(".pretty").not(".dontpretty").prettyform({ autoHide: false }); $(".registr *[data-popup]").popupToggle(); $("*[data-block]").blockToggle(); labelToggle($(".hide_label")); } // #federal #regional $(function(){ $("#federal").on("click", function(e){ e.preventDefault(); var sortby = ""; if( $("#sel_1").val().length > 0 ){ sortby = $("#sel_1").val(); } $(".switcher a").removeClass("on"); $(this).addClass("on"); $.ajax({ type: "GET", url: "/", data: {ajx:1, _filter:1, type: [9600], _sort: 0, _sortby: sortby}, success: function(msg){ $(".news-sections-item.active .news-list").remove(); $(".news-sections-item.active .pagination").remove(); $(".news-sections-item.active").append(msg); } }); return false; }); $("#regional").on("click", function(e){ e.preventDefault(); var sortby = ""; if( $("#sel_1").val().length > 0 ){ sortby = $("#sel_1").val(); } $(".switcher a").removeClass("on"); $(this).addClass("on"); $.ajax({ type: "GET", url: "/", data: {ajx:1, _filter:1, type: [9800], _sort: 0, _sortby: sortby}, success: function(msg){ $(".news-sections-item.active .news-list").remove(); $(".news-sections-item.active .pagination").remove(); $(".news-sections-item.active").append(msg); } }); return false; }); $("#sel_1").on("change", function(){ var sort_by = $(this).val(); var type = []; if( $(".switcher a.on").length ){ if( $(".switcher a.on").attr("id")=="regional" ){ type = [9800]; } else { type = [9600]; } } $.ajax({ type: "GET", url: "/", data: {ajx:1, _filter:1, type: type, _sort: 1, _sortby: sort_by}, success: function(msg){ $(".news-sections-item.active .news-list").remove(); $(".news-sections-item.active .pagination").remove(); $(".news-sections-item.active").append(msg); if( sort_by == "news_date" ){ $("i.date").show(); $("i.date").live("click", function(){ $("#news_period .pretty_text").css("width", "64px"); $("#news_period").show(); $( "#news_date_from" ).datepicker({ defaultDate: "-1w", maxDate: "0", changeMonth: true, numberOfMonths: 2, onClose: function( selectedDate ) { $( "#news_date_to" ).datepicker( "option", "minDate", selectedDate ); }, onSelect: function(dateText, inst){ $.ajax({ type: "GET", url: "/", data: {ajx:1, _filter:1, news_date_from: $("#news_date_from").val(), _sort: 0, _sortby: "news_date"}, success: function(msg){ $(".news-sections-item.active .news-list").remove(); $(".news-sections-item.active .pagination").remove(); $(".news-sections-item.active").append(msg); } }); } }); $( "#news_date_to" ).datepicker({ defaultDate: "+1w", changeMonth: true, numberOfMonths: 2, maxDate: "0", onClose: function( selectedDate ) { $( "#news_date_from" ).datepicker( "option", "maxDate", selectedDate ); }, onSelect: function(dateText, inst){ $.ajax({ type: "GET", url: "/", data: {ajx:1, _filter:1, news_date_from: $("#news_date_from").val(), news_date_to: $("#news_date_to").val(), _sort: 0, _sortby: "news_date"}, success: function(msg){ $(".news-sections-item.active .news-list").remove(); $(".news-sections-item.active .pagination").remove(); $(".news-sections-item.active").append(msg); } }); } }); $( "#news_date_from" ).focus(); }); } else { $("i.date").hide(); $("#news_period").hide(); } } }); }); $(".filter_form form").submit(function(){ var old_val = $("#t-2").val(); $("#t-2").val( old_val.replace(/\-/g,"\\-") ); return true; }); });