//************************************************************************************** //* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/jquery.sticky.js //************************************************************************************** // Sticky Plugin v1.0.0 for jQuery // ============= // Author: Anthony Garand // Improvements by German M. Bravo (Kronuz) and Ruud Kamphuis (ruudk) // Improvements by Leonardo C. Daronco (daronco) // Created: 2/14/2011 // Date: 2/12/2012 // Website: http://labs.anthonygarand.com/sticky // Description: Makes an element on the page stick on the screen as you scroll // It will only set the 'top' and 'position' of your element, you // might need to adjust the width in some cases. (function($) { var defaults = { topSpacing: 0, bottomSpacing: 0, className: 'is-sticky', wrapperClassName: 'sticky-wrapper', center: false, getWidthFrom: '', responsiveWidth: false }, $window = $(window), $document = $(document), sticked = [], windowHeight = $window.height(), scroller = function() { var scrollTop = $window.scrollTop(), documentHeight = $document.height(), dwh = documentHeight - windowHeight, extra = (scrollTop > dwh) ? dwh - scrollTop : 0; for (var i = 0; i < sticked.length; i++) { var s = sticked[i], elementTop = s.stickyWrapper.offset().top, etse = elementTop - s.topSpacing - extra; if (scrollTop <= etse) { if (s.currentTop !== null) { s.stickyElement .css('position', '') .css('top', ''); s.stickyElement.trigger('sticky-end', [s]).parent().removeClass(s.className); s.currentTop = null; } } else { var newTop = documentHeight - s.stickyElement.outerHeight() - s.topSpacing - s.bottomSpacing - scrollTop - extra; if (newTop < 0) { newTop = newTop + s.topSpacing; } else { newTop = s.topSpacing; } if (s.currentTop != newTop) { s.stickyElement .css('position', 'fixed') .css('top', newTop); if (typeof s.getWidthFrom !== 'undefined') { s.stickyElement.css('width', $(s.getWidthFrom).width()); } s.stickyElement.trigger('sticky-start', [s]).parent().addClass(s.className); s.currentTop = newTop; } } } }, resizer = function() { windowHeight = $window.height(); for (var i = 0; i < sticked.length; i++) { var s = sticked[i]; if (typeof s.getWidthFrom !== 'undefined' && s.responsiveWidth === true) { s.stickyElement.css('width', $(s.getWidthFrom).width()); } } }, methods = { init: function(options) { var o = $.extend({}, defaults, options); return this.each(function() { var stickyElement = $(this); var stickyId = stickyElement.attr('id'); var wrapperId = stickyId ? stickyId + '-' + defaults.wrapperClassName : defaults.wrapperClassName var wrapper = $('
') .attr('id', stickyId + '-sticky-wrapper') .addClass(o.wrapperClassName); stickyElement.wrapAll(wrapper); if (o.center) { stickyElement.parent().css({width:stickyElement.outerWidth(),marginLeft:"auto",marginRight:"auto"}); } if (stickyElement.css("float") == "right") { stickyElement.css({"float":"none"}).parent().css({"float":"right"}); } var stickyWrapper = stickyElement.parent(); stickyWrapper.css('height', stickyElement.outerHeight()); sticked.push({ topSpacing: o.topSpacing, bottomSpacing: o.bottomSpacing, stickyElement: stickyElement, currentTop: null, stickyWrapper: stickyWrapper, className: o.className, getWidthFrom: o.getWidthFrom, responsiveWidth: o.responsiveWidth }); }); }, update: scroller, unstick: function(options) { return this.each(function() { var unstickyElement = $(this); var removeIdx = -1; for (var i = 0; i < sticked.length; i++) { if (sticked[i].stickyElement.get(0) == unstickyElement.get(0)) { removeIdx = i; } } if(removeIdx != -1) { sticked.splice(removeIdx,1); unstickyElement.unwrap(); unstickyElement.removeAttr('style'); } }); } }; // should be more efficient than using $window.scroll(scroller) and $window.resize(resizer): if (window.addEventListener) { window.addEventListener('scroll', scroller, false); window.addEventListener('resize', resizer, false); } else if (window.attachEvent) { window.attachEvent('onscroll', scroller); window.attachEvent('onresize', resizer); } $.fn.sticky = 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 ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $.fn.unstick = function(method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method ) { return methods.unstick.apply( this, arguments ); } else { $.error('Method ' + method + ' does not exist on jQuery.sticky'); } }; $(function() { setTimeout(scroller, 0); }); })(jQuery); //************************************************************************************** //* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/main.js //************************************************************************************** var topMenu = {}; topMenu.toElement = function (id) { block = $("#" + id); if (block.length) { menuHeight = $("#top-menu").height(); positionY = block.offset().top - menuHeight; $('body,html').animate({ scrollTop: positionY }, Math.abs(positionY - $("html").scrollTop()) / 2); } }; // ----------------------------------------------------------------------------- var request = { ajaxManagerUrl: '/data_manager.php' }; request.showForm = function () { dialog.openWithWaiter('Заявка на доставку бетона'); $.post(request.ajaxManagerUrl, { section: "getRequestFormHtml" }, request.showFormComplete); }; request.showFormComplete = function (data) { dialog.change(data, 500); }; request.send = function () { volume = $("#request_volume").val().trim(); name = $("#request_name").val().trim(); phone = $("#request_phone").val().trim(); err = ''; if (volume == '') { err += '- Нужно указать заказываемый объем.\n'; } if (name == '') { err += '- Нужно указать ваше имя.\n'; } if (phone == '') { err += '- Нужно указать контактный телефон.\n'; } if (err != '') { alert(err); return; } $.post(request.ajaxManagerUrl, { section: "sendRequest", name: name, volume: volume, phone: phone }, request.sendComplete); }; request.sendComplete = function (data) { $("#request_form").slideUp(500, function () { $("#request_form").html(data).slideDown(500); }) }; var zhbi = {}; zhbi.showInfo = function (id, width) { title = $("#zhbi-title-" + id + " b").html(); html = $("#zhbi-info-" + id).html(); /* html += '\ \ '; */ dialog.open(title, html, width); }; //************************************************************************************** //* /home3/yhekobro/public_html/ptz-beton.ru/js/libs/common/core.js //************************************************************************************** // ***************************************************************************** // ****** // ****** Common procedures // ****** // ***************************************************************************** // Divs for waiting icon document.write(''); document.write(''); document.write(' '); document.write(''); var getResult, execQueryFinish; var loading_icon = "loading_32.gif"; var loading_icon_24 = "loading_24.gif"; var _info_frames = new Array(); // ----------------------------------------------------------------------------- jQuery.fn.screenCenter = function () { w = $(window); this.css("position", "absolute"); this.css("top", (w.height() - this.height()) / 2 + w.scrollTop() + "px"); this.css("left", (w.width() - this.width()) / 2 + w.scrollLeft() + "px"); return this; } // ----------------------------------------------------------------------------- jQuery.fn.elementCenter = function (id) { e = $('#' + id); this.css("position", "absolute"); this.css("top", (e.innerHeight() - this.height()) / 2 + e.offset().top + "px"); this.css("left", (e.innerWidth() - this.width()) / 2 + e.offset().left + "px"); return this; } // ----------------------------------------------------------------------------- function mask_screen(func) { mask_width = $(window).width(); mask_height = $(document).height(); $('.grey_box').css({ top: '0px', left: '0px', width: mask_width + 'px', height: mask_height + 'px', opacity: '0.5' }).fadeIn(); $(".wait_slider").screenCenter().fadeTo('slow', '1', func); } // ----------------------------------------------------------------------------- function mask_element(id, func) { qid = '#' + id; if ($(qid).length == 0 || $('body').css('display') == 'none') func(); else { mask_width = $(qid).innerWidth(); mask_height = $(qid).innerHeight(); mask_top = $(qid).offset().top + 1; mask_left = $(qid).offset().left + 1; mask_border = $(qid).css('border'); mask_border_radius = $(qid).css('borderRadius'); $('.grey_box').css({ top: mask_top + 'px', left: mask_left + 'px', width: mask_width + 'px', height: mask_height + 'px', opacity: '0.6', border: mask_border, borderRadius: mask_border_radius }).show(); $('.wait_slider').elementCenter(id).fadeTo(300, '1', func); } } // ----------------------------------------------------------------------------- function mask_element_noicon(id, func) { mask_width = $('#' + id).innerWidth(); mask_height = $('#' + id).innerHeight(); mask_top = $('#' + id).offset().top + 1; mask_left = $('#' + id).offset().left + 1; mask_border = $('#' + id).css('border'); $('.grey_box').css({ top: mask_top + 'px', left: mask_left + 'px', width: mask_width + 'px', height: mask_height + 'px', opacity: '0.5', border: mask_border }).show(); func(); } // ----------------------------------------------------------------------------- function mask_screen_noicon(func) { mask_width = $(window).width(); mask_height = $(document).height(); $('.grey_box').offset({top: 0, left: 0}).css({ top: '0px', left: '0px', width: mask_width + 'px', height: mask_height + 'px', opacity: '0.5' }).fadeIn(300); func(); } // ----------------------------------------------------------------------------- function clear_mask() { $('.wait_slider').fadeOut(); $('.grey_box').fadeOut();//.css({width: '0px', height: '0px'}); } // ----------------------------------------------------------------------------- function execQueryCallback(data) { getResult = data; } // ----------------------------------------------------------------------------- function execQuery(url, params) { $.ajaxSetup({async: false}); $.post(url, params, execQueryCallback, 'text'); $.ajaxSetup({async: true}); return getResult; } // ----------------------------------------------------------------------------- if (!String.prototype.trim) { String.prototype.trim = function () { return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ''); } } // ----------------------------------------------------------------------------- function get_unique_id() { do { n = Math.floor(Math.random() * Math.random() * 18954785965458745895); id = 'uid_' + Math.floor(Math.random() * Math.random() * 18954785965458745895).toString(36).substr(2, 8); l = $('#' + id).length; } while (l != 0); return id; } // ----------------------------------------------------------------------------- function info_frame_show(title, html, info_width) { __info_show_id = get_unique_id(); _info_frames.push(__info_show_id); w = $(window).width(); h = $(window).height(); hd = $(document).height(); $("body").append(''); $('#white_box_' + __info_show_id).css({width: w + 'px', height: hd + 'px', opacity: '0.7'}).fadeIn(); if (info_width == null) { info_width = w * 2 / 3; if (info_width > 600) info_width = 600; } if (title != '') info_html = "...
"); complete_function(_swfu.customSettings.uname); _swfu.destroy(); } // ----------------------------------------------------------------------------- var core = {}; core.setCookie = function (cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000)); var expires = "expires=" + d.toUTCString(); document.cookie = cname + "=" + cvalue + "; " + expires; }; core.getCookie = function (cname) { var name = cname + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1); if (c.indexOf(name) != -1) return c.substring(name.length, c.length); } return ""; }; core.isEmail = function (email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); }; core.getMaxZIndex = function () { var highest = -999; $("*").each(function () { var current = parseInt($(this).css("z-index"), 10); // if (current == 1999999) current = 0; id = $(this).attr('id'); if (id == 'colorbox' || id == 'cboxOverlay' || id == 'cboxWrapper') current = 0; if (current && highest < current) highest = current; }); return highest; }; // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- // -------------------------------------------------------------------------------- /* * The dialog class */ var dialog = { ajaxManagerUrl: '/data_manager.php', frames: new Array(), closeHandlers: new Array(), waitHtml: '', scrollWidth: 0, heightMax: $(window).height() * 5 / 6 }; /* * Open the dialog contains waiter icon. */ dialog.openWithWaiter = function (title) { dialog.open(title, dialog.waitHtml, 200); }; /* * Disable vertical scroller before show first dialog */ dialog.hideScroller = function () { if (dialog.frames.length) return; body = $('body'); w0 = $(window).innerWidth(); body.css('overflow-y', 'hidden'); w1 = $(window).innerWidth(); marginLeft = parseInt(body.css('margin-left'), 10); dialog.scrollWidth = Math.ceil((w1 - w0) / 2); // dialog.scrollWidth = w1 - w0; marginLeft -= dialog.scrollWidth; body.css('margin-left', marginLeft + 'px'); try { dialog.offsetDesignElements(-dialog.scrollWidth); } catch (err) { } }; /* * Disable vertical scroller before show first dialog */ dialog.showScroller = function () { if (dialog.frames.length) return; body = $('body'); marginLeft = parseInt(body.css('margin-left'), 10); marginLeft += dialog.scrollWidth; body.css({'margin-left': marginLeft + 'px', 'overflow-y': 'scroll'}); try { dialog.offsetDesignElements(this.scrollWidth); } catch (err) { } }; /* * Open the dialog contains HTML code. * * html - The HTML code inserting into dialog container. * width - The width of opened dialog in pixels. */ dialog.open = function (title, html, width, closeHandler) { dialog.hideScroller(); dialogId = get_unique_id(); dialog.frames.push(dialogId); dialog.closeHandlers.push(closeHandler); h = $(window).height() * 5 / 6; w = $(window).width() * 5 / 6; if (width > w) { width = w; } // add dialog container $("body").append(''); dialogElement = $("#" + dialogId); dialogElement.attr("title", title); dialogHtml = "