Notice: Undefined offset: 1 in /home/plusensd/steelhammer.com.ua/route.php on line 89
$(function() { var is_animate = false; var slideWidth = "80px"; //var newLeftPos = $('.thumbnails').position().left - slideWidth; var position = 0; var count = $(".thumbnails>div:last").attr("count"); if(count < 3){ $(".prev-slide").css({"background-image": "url(/_common/img/left-arrow-disable.png)", "cursor" : "default"}); $(".next-slide").css({"background-image": "url(/_common/img/right-arrow-disable.png)", "cursor" : "default"}); } else if(position == 0){ $(".prev-slide").css({"background-image": "url(/_common/img/left-arrow-disable.png)", "cursor" : "default"}); } $(".next-slide").click(function(){ //if(!$('.thumbnails').is(':animated')) { //$('.thumbnails').animate({left: newLeftPos}, 500, function(){ //alert(position+ " - "+ count); if(position < 95*(count-2)){ position = position + 95; $('.thumbnails') //.find('.slide-item:first') //.appendTo($('.thumbnails')) //.parent() .css({'left': "-"+position+"px"}); $(".prev-slide").css({"background-image": "url(/_common/img/left-arrow.png)", "cursor" : "pointer"}); if(position == 95*(count-2)) { $(".next-slide").css({"background-image": "url(/_common/img/right-arrow-disable.png)", "cursor" : "default"}); } } //}); //} }); $(".prev-slide").click(function(){ //if(!$('.thumbnails').is(':animated')) { if(position > 0){ position = position - 95; $('.thumbnails') .css({'left': "-"+position+"px"}); //.find('.slide-item:last') //.prependTo($('.thumbnails')).show() //.parent() //.animate({left: 0}, 500); $(".next-slide").css({"background-image": "url(/_common/img/right-arrow.png)", "cursor" : "pointer"}); if(position == 0) { $(".prev-slide").css({"background-image": "url(/_common/img/left-arrow-disable.png)", "cursor" : "default"}); } } //} }); $(".thumbnails>div").mouseover(function() { //$(this).parents(".photo-gallery").first().find(".photo").css("background-image", $(">div", this).css("background-image").replace("60x70.png", "300x350.png")); $(this).parents(".photo-gallery").first().find(".photo>img").attr("src", $(">img", this).attr("src").replace("60x70.png", "300x350.png")); }).click(function() { $(this).parents(".photo-gallery").first().find(".photo").click(); }).dblclick(function() { if ($("body").hasClass("admin") || $("body").hasClass("content_manager")) { var imageNo = $(this).index(); if (confirm("Вы хотите удалить это изображение товара?")) { post({ remove_image: imageNo }, function() { location.reload(); }); } } }); $(".photo-gallery .photo").click(function() { var that = this; setTimeout(function() { console.log(); var lightBox = $("#light-box"); //var imageUrl = $(that).css("background-image").match(/url\('?"?(.*?)'?"?\)/)[1]; var imageUrl = $(".photo-gallery .photo img").attr("src"); var bigImageUrl = imageUrl.indexOf("300x350.png") != -1 ? imageUrl.replace("300x350.png", "1000x1000.png") : imageUrl.replace(".png", "_big.png"); lightBox.empty().show().append($("").append($("").append($("
").append( $("", { src: bigImageUrl }).load(function() { setTimeout(function() { lightBox.scrollLeft(999999); lightBox.scrollTop(999999); lightBox.scrollLeft(lightBox.scrollLeft() / 2); lightBox.scrollTop(lightBox.scrollTop() / 2); }); }) )))); }, $("body").hasClass("admin") ? 300 : 1); }).dblclick(function() { if ($("body").hasClass("admin")) { var imageNo = $(">img", this).attr("src").match(/(\d+)_\d+x\d+\.png/)[1]; if (confirm("Вы хотите удалить это изображение товара?")) { post({ remove_image: imageNo }, function() { location.reload(); }); } } }); $(".product-name").on("savechanges", function() { if ($(this).text()) { post({ name: $(this).text() }, function() { location.reload(); }); } else if (confirm("Удалить этот товар?")) { post("products", "product", { remove_product_id: id }, function() { location = "/"; }); } }); $(".price").on("savechanges", function() { var price = parseInt($(this).text().replace(/\s/g, "")); post({ price: price }, function() { location.reload(); }); }); $(".description").on("savechanges", function() { post({ description: $(this).html() }); }); /* $("body").on("click", ".description img", function() { var originalWidth = $(this).width(); var width = prompt("Введите желаемую ширину картинки:", originalWidth); if (width != originalWidth) { $(this).css({ width: width || "auto" }); } }); */ $(".photo-gallery").on("dropbox", function() { var images = $(this).data("dropbox"); var ping = 0; var pong = 0; (function() { if (ping != pong) { setTimeout(arguments.callee, 100); return; } if (ping < images.length) { post({ add_image: images[ping] }, function() { pong++; }); ping++; setTimeout(arguments.callee, 100); } else { location.reload(); } })(); }); $(".manufacturer select").change(function() { if ($(this).val() == "NEW") { var manufacturerName = prompt("Введите бренд производителя:"); if (manufacturerName) { post({ new_manufacturer: manufacturerName }, function(response) { manufacturerId = Number(response); if (manufacturerId) { post({ manufacturer_id: manufacturerId }, function() { location.reload(); }); } }); } } else { post({ manufacturer_id: $(this).val() }, function() { location.reload(); }); } }); $(".status select").change(function(){ post({ status_id: $(this).val() }, function() { location.reload(); }); }); $(".existance select").change(function() { post({ availability_id: $(this).val() }) }); $("#top-sale").change(function() { post({ top_sale: $(this).is(":checked") }) }); $("#recommended").change(function() { post({ recommended: $(this).is(":checked") }) }); $("#market_discount_date_end").blur(function(){ post({ market_discount_date_end: $(this).val()}, function() { location.reload(); }); }); $("#market_discount").blur(function(){ post({ market_discount: $(this).val()}, function() { location.reload(); }); }); $(".youtube-icon").click(function() { var youtube = prompt("Введите адрес видео YouTube:"); if (youtube) { var m = youtube.match(/v=(.*?)($|&)/); if (!m) { m = youtube.match(/([^/]+?)($|\?)/); } youtube = m[1]; $(".description").append($('')); } }); var draggingProduct = undefined; $("body").on("dragstart", ".quicksearch-content [productid]>a:first-child", function() { $(".new-present").show(); draggingProduct = { id: $(this).parents("[productid]").attr("productid"), name: $(this).text().trim() }; }).on("dragend", ".quicksearch-content [productid]>a:first-child", function() { setTimeout(function() { $(".new-present").hide(); draggingProduct = undefined; }, 100); }).on("drop", ".new-present", function(e) { if (draggingProduct) { post({ new_present_product_id: draggingProduct.id }, function() { location.reload(); }); $("#search [name='pattern']").val("").keydown(); } }); $(".presents .photo").dblclick(function() { if ($("body").hasClass("admin")) { var presentId = Number($(this).parents(".present").attr("presentid")); if (confirm("Вы хотите удалить этот товар из списка подарков к " + $(".product-name").text() + "?")) { post({ remove_present_id: presentId }, function() { location.reload(); }); } } }); $("body").on("click", ".menuDiscr", function(){ $(".comments").attr("hidden", true); $(".descriptionOuter").attr("hidden", false); }); $("body").on("click", ".menuComment", function(){ $(".comments").attr("hidden", false); $(".descriptionOuter").attr("hidden", true); }); $(".leftCommentButton").click(function(){ $("#comment_form").toggle(); }); $("body").on("click", "#commentButton", function(e){ var productID = $("#productID").val(); var userName = $("#userName").val(); var userEmail = $("#userEmail").val(); var userComment = $("#comment").val(); if(userName.length != 0 && userComment.length != 0){ e.preventDefault(); post("products","product", { comment : userComment, productID : productID, userName : userName, userEmail : userEmail}, function(){alert("Ваш комментарий отправлен на рассмотерние администратором"); location.reload();}); } else { alert("заполните все необходимые поля"); } }); $("body").on("click", "#more_comments", function(e){ $(".allComments").attr("hidden", false); $(".lastComments").attr("hidden", true); }); $("body").on("click", "#hideComments", function(e){ $(".allComments").attr("hidden", true); $(".lastComments").attr("hidden", false); }); $.rating = function(e, o){ this.options = $.extend({ fx: 'full', image: '../../_common/images/rating/stars.png', stars: 5, minimal: 0, titles: ['отзыв','отзыва','отзывов'], readOnly: false, url: '../../products/product_post', type: 'post', loader: '../../_common/images/rating/ajax-loader.gif', click: function(){}, callback: function(){} }, o || {}); this.el = $(e); this.left = 0; this.width = 0; this.height = 0; this._data = {}; var self = this; this.el.find(':hidden').each(function(){ var $this = $(this); self._data[$this.attr('name')] = $this.val(); }); this._data.val = parseFloat(this._data.val) || 0; this._data.votes = parseFloat(this._data.votes) || ''; if(this._data.val > this.options.stars) this._data.val = this.options.stars; if(this._data.val < 0) this._data.val = 0; this.old = this._data.val; this.vote_wrap = $('
'); this.vote_block = $('
'); this.vote_hover = $('
'); this.vote_stars = $('
'); this.vote_active = $('
'); this.vote_result = $('
'); this.vote_success = $('
'); this.loader = $('load...'); this.el.html(this.loader); //Загружаем изображение звезд и высчитываем ширину и высоту одной звезды var img = new Image(); img.src = this.options.image; img.onload = function() { self.width = this.width; //Ширина одной звезды self.height = this.height/3; //Высота одной звезды self.init(); }; }; var $r = $.rating; $r.fn = $r.prototype = { rating: '2.0' }; $r.fn.extend = $r.extend = $.extend; $r.fn.extend({ init: function(){ this.render(); var status = $("input[name=rating]").val(); if(status == "yes"){this.options.readOnly = true;} if(this.options.readOnly) return; var self = this, left = 0, width = 0; this.vote_hover.bind('mousemove mouseover',function(e){ if(self.options.readOnly) return; var $this = $(this), score = 0; left = e.clientX>0 ? e.clientX: e.pageX; width = left - $this.offset().left - 2; var max = self.width*self.options.stars, min = self.options.minimal*self.width; if(width > max) width = max; if(width < min) width = min; score = Math.round( width/self.width * 10 ) / 10; //округляем до 1 знака после запятой if(self.options.fx == 'half'){ width = Math.ceil(width/self.width*2)*self.width/2; } else if(self.options.fx != 'float'){ width = Math.ceil(width/self.width) * self.width; } score = Math.round( width/self.width * 10 ) / 10; self.vote_active.css({ 'width':width, 'background-position':'left center' }); self.vote_success.html('Ваша оценка: '+score); }) .bind('mouseout',function(){ if(self.options.readOnly) return; self.reset(); self.vote_success.empty(); }). bind('click.rating',function(){ if(self.options.readOnly) return; var score = Math.round( width/self.width * 10 ) / 10; if(score > self.options.stars) score = self.options.stars; if(score < 0) score = 0; self.old = self._data.val; self._data.val = (self._data.val*self._data.votes +score)/(self._data.votes + 1); self._data.val = Math.round( self._data.val * 100 ) / 100; self._data.score = score; self.vote_success.html('Ваша оценка: '+score); if(self.options.url != ''){ self.send(); } self.options.readOnly = true; self.options.click.apply(this,[score]); }); }, set: function(){ this.vote_active.css({ 'width':this._data.val*this.width, 'background-position':'left bottom' }); }, reset: function(){ this.vote_active.css({ 'width':this.old*this.width, 'background-position':'left bottom' }); }, setvoters: function(){ this.vote_result.html(this.declOfNum(this._data.votes)); }, render: function(){ this.el.html(this.vote_wrap.append( this.vote_hover.css({ padding:'12px 4px', height:this.height, width:this.width*this.options.stars }), this.vote_result.text(this.declOfNum(this._data.votes)), this.vote_success )); this.vote_block.append( this.vote_stars.css({ height:this.height, width:this.width*this.options.stars, background:"url('"+this.options.image+"') left top" }), this.vote_active.css({ height:this.height, width:this._data.val*this.width, background:"url('"+this.options.image+"') left bottom" }) ).appendTo(this.vote_hover); }, send: function(score){ var self = this; this.vote_result.html(this.loader); this._data.votes++; $.ajax({ url: self.options.url, type: self.options.type, data: this._data, dataType: 'json', success: function(data){ if(data.status == 'OK') { self.set(); } else{ self.reset(); } self.setvoters(); if(data.msg)self.vote_success.html(data.msg); if(typeof self.options.callback == 'function'){ self.options.callback.apply(self,[data]); } } }); }, declOfNum: function(number){ if(number <= 0) return ''; number = Math.abs(Math.floor(number)); cases = [2, 0, 1, 1, 1, 2]; return number+' '+ this.options.titles[ (number%100>4 && number%100<20)? 2 : cases[(number%10<5)?number%10:5] ]; } }); $.fn.rating = function(o){ if (typeof o == 'string') { var instance = $(this).data('rating'), args = Array.prototype.slice.call(arguments, 1); return instance[o].apply(instance, args); } else { return this.each(function() { var instance = $(this).data('rating'); if (instance) { if (o) { $.extend(instance.options, o); } instance.init(); } else { $(this).data('rating', new $r(this, o)); } }); } }; $('div.rating').rating(); });