Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.fn.equals = function(compareTo) {
- if (!compareTo || this.length != compareTo.length) {
- return false;
- }
- for (var i = 0; i < this.length; ++i) {
- if (this[i] !== compareTo[i]) {
- return false;
- }
- }
- return true;
- };
- ys_ms_ajax_page = 1;
- function ys_ms_JSInit(ajax_page, site_id, red_url){
- $(document).ready(function () {
- var __this__ = $('#ys-ms-slider');
- __this__.speed = 200
- __this__.ajax_page = ajax_page
- __this__.site_id = site_id
- __this__.red_url = red_url
- __this__.check_nav = function(th)
- {
- var button_left = th.find('.button7')
- var button_right = th.find('.button8')
- if(th.find('li.showed:first').prev().length!=1)
- button_left.addClass('disabled')
- else
- button_left.removeClass('disabled')
- if(th.find('li.showed:last').next().length!=1)
- button_right.addClass('disabled')
- else
- button_right.removeClass('disabled')
- }
- var currentCount;
- var currentShow;
- __this__.check_count = function(th)
- {
- var slw = th.parent().width();
- var count = Math.floor(slw / 240);
- var now_count = th.find('ul li.showed').length;
- if(now_count != count)
- if(now_count > count){
- var now = th.find('ul li.showed:last')
- for(var i=0;i<now_count-count;i++){
- now.removeClass('showed');
- now = now.prev()
- }
- }else{
- var now = th.find('ul li.showed:last')
- if(now.length!=1){
- th.find('ul li:lt(' + count + ')').addClass('showed');
- }else{
- for(var i=0;i<count-now_count;i++){
- now = now.next()
- now.addClass('showed').css('left','0').css('opacity', '1');
- }
- now_count = th.find('ul li.showed').length;
- if(now_count != count){
- now = th.find('ul li.showed:first')
- for(var i=0;i<count-now_count;i++){
- now = now.prev()
- now.addClass('showed').css('left','0').css('opacity', '1');
- }
- }
- }
- }
- __this__.check_nav(th)
- currentShow = now_count;
- //console.log ("currentShow "+currentShow);
- }
- __this__.bind_li = function(th)
- {
- th.find('ul li').unbind('hover').hover(function () {
- $(this).find('.item-popup').show();
- $(this).css({'z-index': 50});
- $(this).find('.item-popup').addClass('item-hover');
- }, function () {
- var openedMenu = $(this).find('.selectBox-menuShowing')
- if (openedMenu.length != 1) {
- $(this).find('.item-popup').fadeOut();
- $(this).css({'z-index': 1});
- $(this).find('.item-popup').removeClass('item-hover');
- }
- });
- }
- __this__.ajax_loader_params = {
- loaderSymbols: ['0', '1', '2', '3', '4', '5', '6', '7'],
- loaderRate: 30
- }
- __this__.ajax_loader = function(obj)
- {
- obj.addClass("loader");
- obj.WAIT_STATUS = true;
- obj.WAIT_PARAM = __this__.ajax_loader_params;
- obj.WAIT_INDEX = 0;
- obj.WAIT_FUNC = function(){
- if(!obj) return;
- if(obj.WAIT_STATUS)
- {
- obj.html(obj.WAIT_PARAM.loaderSymbols[obj.WAIT_INDEX]);
- obj.WAIT_INDEX = obj.WAIT_INDEX < obj.WAIT_PARAM.loaderSymbols.length - 1 ? obj.WAIT_INDEX + 1 : 0;
- setTimeout(obj.WAIT_FUNC, obj.WAIT_PARAM.loaderRate);
- }
- else
- obj.removeClass("loader");
- };
- obj.WAIT_FUNC();
- }
- __this__.ajax_loader_stop = function(obj)
- {
- obj.WAIT_STATUS = false;
- }
- __this__.ajax_li_check = function(th, name, now_page)
- {
- var pp = th.parent().parent()
- var count = 0
- if(pp.hasClass('blc_special'))
- count = parseInt(pp.find('.tit .count').html());
- else
- count = parseInt(__this__.find('.slider_cat #tab_'+name+' a.count').html());
- if(count/10 > now_page)
- return true;
- //console.log("count"+count);
- return false;
- }
- __this__.ajax_li = function(th, orientation)
- {
- var button_left = th.find('.button7')
- var button_right = th.find('.button8')
- if(orientation == "right")
- {
- var elem = th.find('li:last').not(".loader");
- if(!th.find('li.showed:last').equals(elem))
- return;
- var now_page = parseInt(elem.find('hidden[name="iNumPage"]').attr('data-page'));
- var name = th.attr('id').replace('block_', '');
- if(!__this__.ajax_li_check(th, name, now_page))
- return;
- var new_page = now_page+1;
- var ajax_elem = elem
- .clone()
- .removeClass('showed')
- elem.after(ajax_elem)
- button_right.old_text = button_right.html()
- __this__.ajax_loader(button_right)
- }else if(orientation == "left"){
- var elem = th.find('li:first').not(".loader");
- if(!th.find('li.showed:first').equals(elem))
- return;
- var now_page = parseInt(elem.find('hidden[name="iNumPage"]').attr('data-page'));
- var name = th.attr('id').replace('block_', '');
- if(now_page <= 1) return;
- var new_page = now_page-1;
- var ajax_elem = elem
- .clone()
- .removeClass('showed')
- elem.before(ajax_elem)
- button_left.old_text = button_left.html()
- __this__.ajax_loader(button_left)
- }else return;
- __this__.ajax_loader(ajax_elem)
- $.post(__this__.ajax_page, {
- 'ys_ms_ajax_call':'y',
- 'iNumPage':new_page,
- 'tab_block':name,
- 'red_url':__this__.red_url,
- 'site_id':__this__.site_id,
- }, function(data) {
- var appends = $(data).find('.ms_tab_block ul li')
- if(orientation == "right")
- {
- elem.after(appends)
- var new_li = th.find('li.showed:last').next()
- th.find('li hidden[data-page=\"'+(new_page-2)+'\"]').parent().remove()
- __this__.ajax_loader_stop(button_right)
- button_right.html(button_right.old_text)
- }else if(orientation == "left"){
- elem.before(appends)
- var new_li = th.find('li.showed:first').prev()
- th.find('li hidden[data-page=\"'+(new_page+2)+'\"]').parent().remove()
- __this__.ajax_loader_stop(button_left)
- button_left.html(button_left.old_text)
- }else return;
- if(new_li.length==1){
- //if(ajax_elem.hasClass('showed')){
- new_li.addClass('showed').css('opacity', '0')
- new_li.animate(
- {
- 'opacity': '1'
- },
- __this__.speed,
- function(){__this__.normalize($(this))}
- );
- //}
- }
- __this__.ajax_loader_stop(ajax_elem)
- ajax_elem.remove();
- appends.find("select").selectBox();
- __this__.check_nav(th)
- __this__.bind_li(th)
- __this__.add2basket_events(th)
- __this__.check_count(th);
- });
- __this__.check_nav(th)
- }
- __this__.normalize = function(li)
- {
- li.css('opacity', '1').css('left','0')
- }
- //var thisParent= ms_tab_block;
- var Maxrange;
- var lastSlideValue = 0;
- var internalSlideCalling = false;
- var value =0;
- var startValue;
- var stopValue;
- $( ".slider1" ).slider({
- animate: true,
- //range: "min",
- value: 0,
- min: 0,
- max: 100,
- step: 10,
- //Получаем значение и выводим его на странице
- slide: function( event, ui ) {
- $( "#slider-result" ).html( ui.value );
- var trueoffset =parseInt($("#ys-ms-slider .ui-slider-handle").css('left') )/ $("#ys-ms-slider .ui-slider-handle").parent().width() * 100;
- console.log("trueoffset"+trueoffset);
- console.log(".position().left"+$("#ys-ms-slider .ui-slider-handle").position().left);
- },
- create: function(event, ui){
- Maxrange=( $(".slider1").parent('.ms_tab_block').find("li").size() - $(".slider1").parent('.ms_tab_block').find("li.showed").size()+1 )*10;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- console.log("Maxrange "+Maxrange);
- sliderValueOld = $(this).slider('value');
- if ( $("#ys-ms-slider .ui-slider-handle").position().left==0 ) $("#ys-ms-slider .ui-slider-handle").css('margin-left', "0");
- },
- start: function(event, ui){
- //liderValueOld = $(this).slider('value');
- },
- stop: function (event, ui){
- },
- //Обновляем скрытое поле формы, так что можно передать данные с помощью формы
- change: function(event, ui) {
- $('#hidden').attr('value', ui.value);
- //__this__.check_count(th);
- $( "#slider-result" ).html( ui.value );
- //event.stopPropagation();
- var Slideval = $(this).slider('value');
- /* if (!internalSlideCalling)
- {
- if (Slideval>lastSlideValue && lastSlideValue < $(this).slider('option','max'))
- {
- Slideval = lastSlideValue+10;
- }
- else if (lastSlideValue > $(this).slider('option','min'))
- {
- Slideval = lastSlideValue-10;
- }
- lastSlideValue = Slideval;
- }
- console.log(Slideval, value)
- if(value < Slideval) {
- console.log("incremented")
- } else if(value > Slideval){
- console.log("decremented")
- }
- value = Slideval;
- if (!internalSlideCalling){
- internalSlideCalling = true;
- $(this).slider('value',Slideval);
- }
- else
- internalSlideCalling = false;*/
- }
- });
- function handleSliderChange(e, ui){
- var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
- $("#content-scroll").animate({scrollLeft: ui.value * (maxScroll / 100) }, 1000);
- }
- function handleSliderSlide(e, ui){
- var maxScroll = $("#content-scroll").attr("scrollWidth") - $("#content-scroll").width();
- $("#content-scroll").attr({scrollLeft: ui.value * (maxScroll / 100) });
- }
- __this__.bind_nav = function(th)
- {
- var button_left = th.find('.button7')
- var button_right = th.find('.button8')
- button_left.unbind("click").click(function(){
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:first').prev()
- if(next_li.length!=1)
- return;
- var last_li = th.find('li.showed:last')
- var left = $(last_li).width()+20
- var all_li = th.find('li.showed:not(:last)')
- next_li.addClass('showed').css('opacity', '0').css('left','-'+left+'px')
- all_li.css('left','-'+left+'px')
- last_li.css('left','-'+left+'px')
- last_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': 0+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- next_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- __this__.ajax_li(th, "left")
- //PUSH BACK
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") - 10);
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount) newcount += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- // if (totalCountShow>5) totalCountShow = 5;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- //console.log("Maxrange "+Maxrange);
- //console.log("totalCountinThisLoad "+totalCountinThisLoad);
- //console.log("totalCountShow "+totalCountShow);
- //console.log("totalCountLeft "+totalCountLeft);
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- Prevli = th.find('li.showed:first').prevAll("li").size();
- if ( ( $( ".slider1" ).slider("value") == 0 ) && ( th.find('li.showed:first').prevAll("li").size()>0 ) ) {
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + Prevli*10);
- }
- });
- var newcount1;
- button_right.unbind("click").click(function(){
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:last').next()
- if(next_li.length!=1)
- return;
- var all_li = th.find('li.showed:not(:first)')
- var first_li = th.find('li.showed:first');
- var additionalCollection = th.find('li.showed:first');
- for ( var i = 0; i < 5; i++ ) {
- additionalCollection = additionalCollection.add(th.find('li.showed').eq(i));
- }
- //additionalCollection.css('background','red');
- //th.find('li.showed').eq(0).css('background','red');
- //console.log("additionalCollection "+additionalCollection);
- //additionalCollection.css('background','red');
- next_li.addClass('showed').css('opacity', '0')
- var left = $(first_li).width()+20
- first_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': '-'+left+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- next_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- __this__.ajax_li(th, "right")
- //PUSH BACK
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount1) newcount1 += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- // if (totalCountShow>5) totalCountShow = 5;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- console.log("Maxrange "+Maxrange);
- console.log("totalCountinThisLoad "+totalCountinThisLoad);
- console.log("totalCountShow "+totalCountShow);
- console.log("totalCountLeft "+totalCountLeft);
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + 10);
- if ( ( $( ".slider1" ).slider("value") == Maxrange ) && ( th.find('li.showed:last').nextAll("li").size()>0) ) {
- var remain = th.find('li.showed:last').nextAll("li").size();
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") - remain*10 );
- }
- });
- var totalCountinThisLoad;
- var totalCountShow;
- var totalCountLeft;
- var Maxrange;
- var sliderValueOld=th.find(".slider1").slider("value");
- var max = $( ".slider1" ).slider( "option", "max" );
- var min = $( ".slider1" ).slider( "option", "min" );
- var newcount = 0;
- // console.log("th "+th);
- //__this__.check_count(th);
- th.bind('mousewheel DOMMouseScroll ', function(e, ui) {
- sliderValueOld =th.find(".slider1").slider("value");
- console.log("sliderValueOld "+sliderValueOld);
- var o = e.originalEvent;
- var delta = o && (o.wheelDelta || (o.detail && -o.detail));
- if ( delta ) {
- e.preventDefault();
- var step = th.find(".slider1").slider("option", "step");
- //console.log("delta"+delta);
- step *= delta < 0 ? -1 : 1;
- //console.log("step"+step);
- var sliderValueNew;
- var Prevli;
- th.find( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + step);
- sliderValueNew=$( ".slider1" ).slider("value");
- //th.find(".slider1").css({"background": "red"});
- //console.log("sliderValueNew"+sliderValueNew);
- console.log("VPEREDI MNOGO: "+ th.find('li.showed:last').nextAll("li").size());
- /*
- if ( ( $( ".slider1" ).slider("value") == Maxrange ) && ( th.find('li.showed:last').next("li").size()==1) ) {
- var remain = th.find('li.showed:last').nextAll("li").size();
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") - 10 );
- }
- */
- if ( (th.find(".slider1").slider("value") ==min ) && th.find('li.showed:first').prevAll("li").size()==0 ) {
- return;
- }
- /* if ( ($( ".slider1" ).slider("value") ==Maxrange ) && th.find('li.showed:last').nextAll("li").size()==0 ) {
- return;
- }*/
- /* var Sliderval = $( ".slider1" ).slider("value");
- var deltaSlide = ui.value - sliderValueNew;
- console.log("deltaSlide "+deltaSlide);
- if (deltaSlide>10) { $( ".slider1" ).slider("value", $(this).slider("value") +10)
- return;
- };
- if (deltaSlide<10) { $( ".slider1" ).slider("value", $(this).slider("value") - 10)
- return;
- };*/
- if (sliderValueNew>sliderValueOld){
- // if (sliderValueNew == max){
- // console.log("STOP!")
- // return false;
- //event.preventDefault();
- // }
- // else {
- //console.log("step"+step);
- //console.log("Its scroll down")
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:last').next()
- if(next_li.length!=1)
- return;
- var all_li = th.find('li.showed:not(:first)')
- var first_li = th.find('li.showed:first')
- next_li.addClass('showed').css('opacity', '0')
- var left = $(first_li).width()+20
- first_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': '-'+left+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- next_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- __this__.ajax_li(th, "right")
- //}
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount1) newcount1 += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- // if (totalCountShow>5) totalCountShow = 5;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- console.log("Maxrange "+Maxrange);
- console.log("totalCountinThisLoad "+totalCountinThisLoad);
- console.log("totalCountShow "+totalCountShow);
- console.log("totalCountLeft "+totalCountLeft);
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- th.find(".slider1").slider( "option", "max", Maxrange);
- th.find(".slider1").slider("value", $( ".slider1" ).slider("value") + 10);
- if ( ( th.find(".slider1").slider("value") == Maxrange ) && ( th.find('li.showed:last').nextAll("li").size()>0) ) {
- var remain = th.find('li.showed:last').nextAll("li").size();
- th.find(".slider1").slider("value", th.find(".slider1").slider("value") - remain*10 );
- }
- }
- if ( ( th.find(".slider1").slider("value") == 0 ) && ( th.find('li.showed:first').prevAll("li").size()==0 ) ) {
- return;
- }
- if (sliderValueNew<sliderValueOld){
- //if (sliderValueNew==min) {
- // console.log("STOP!")
- // return false;
- //} else {
- //console.log("Its scroll up")
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:first').prev()
- if(next_li.length!=1)
- return;
- var last_li = th.find('li.showed:last')
- var left = $(last_li).width()+20
- var all_li = th.find('li.showed:not(:last)')
- next_li.addClass('showed').css('opacity', '0').css('left','-'+left+'px')
- all_li.css('left','-'+left+'px')
- last_li.css('left','-'+left+'px')
- last_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': 0+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- next_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- __this__.ajax_li(th, "left")
- th.find(".slider1").slider("value", $( ".slider1" ).slider("value") - 10);
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount) newcount += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- // if (totalCountShow>5) totalCountShow = 5;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- /*console.log("Maxrange "+Maxrange);
- console.log("totalCountinThisLoad "+totalCountinThisLoad);
- console.log("totalCountShow "+totalCountShow);
- console.log("totalCountLeft "+totalCountLeft);*/
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- th.find(".slider1").slider( "option", "max", Maxrange);
- Prevli = th.find('li.showed:first').prevAll("li").size();
- if ( ( th.find(".slider1").slider("value") == 0 ) && ( th.find('li.showed:first').prevAll("li").size()>0 ) ) {
- th.find(".slider1").slider("value", th.find(".slider1").slider("value") + Prevli*10);
- }
- //}
- }
- //Prevli = th.find('li.showed:first').prevAll("li").size();
- //console.log("Prevli "+Prevli);
- /*if ( ( $( ".slider1" ).slider("value") == 0 ) && ( th.find('li.showed:first').prevAll("li").size()>0 ) ) {
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + Prevli*10);
- }*/
- }
- // return false;
- });
- var ValueOldOnSlide=$( ".slider1" ).slider("value");
- var ValueNewOnSlide;
- //$( ".slider1" ).slider({
- $( ".slider1" ).bind( "slidechange", function(event, ui){
- //Maxrange= $(".slider1").parent('.ms_tab_block').find("li").size();
- ValueOldOnSlide=ui.value;
- });
- var newcount2 =0;
- var remain;
- var totalCountinThisLoadOLD= $(".slider1").parent('.ms_tab_block').find("li").size();
- var deltaValue;
- var ScrollToright= function (Steps){
- console.log ("Steps!!!!!!!!! "+Steps);
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:last').next()
- if(next_li.length!=1)
- return;
- var all_li = th.find('li.showed:not(:first)')
- var first_li = th.find('li.showed:first');
- var additionalCollection = th.find('li.showed:first');
- var trueIndexli = th.find('li.showed:first').index()-1;
- var next_li_add;
- console.log ("trueIndexli "+trueIndexli);
- /*for ( var i = 0; i < Steps; i++ ) {
- additionalCollection = additionalCollection.add(th.find('li.showed').eq(i));
- }*/
- for ( var i = 0; i < Steps; i++ ) {
- trueIndexli= trueIndexli+i;
- additionalCollection = additionalCollection.add(th.find('li').eq(trueIndexli));
- }
- //additionalCollection.css('background','red');
- //th.find('li.showed').eq(0).css('background','red');
- //console.log("additionalCollection "+additionalCollection);
- //additionalCollection.css('background','red');
- if (Steps>1){
- first_li = additionalCollection;
- all_li = th.find('li').not(additionalCollection);
- next_li_add = additionalCollection.last().next();
- next_li = next_li_add;
- }
- if (Steps>4) {
- all_li = additionalCollection.nextAll();
- }
- next_li.addClass('showed').css('opacity', '0')
- var left = $(first_li).width()+20
- first_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': '-'+left+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- next_li.animate(
- {
- 'left': '-'+left+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this)) }
- );
- __this__.ajax_li(th, "right")
- //PUSH BACK
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount1) newcount1 += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- // if (totalCountShow>5) totalCountShow = 5;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + Steps);
- if ( ( $( ".slider1" ).slider("value") == $( ".slider1" ).slider( "option", "max") ) && ( th.find('li.showed:last').nextAll("li").size()>0) ) {
- var remain = th.find('li.showed:last').nextAll("li").size();
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") - (remain*10) );
- }
- }
- var ScrollToLeft = function(Steps) {
- var stepback = Math.abs(Steps);
- console.log ("Steps!!!!!!!!! "+stepback);
- th.find('li').stop(true, true)
- var next_li = th.find('li.showed:first').prev()
- if(next_li.length!=1)
- return;
- var last_li = th.find('li.showed:last')
- var additionalCollection = th.find('li.showed:last');
- var trueindex = last_li.index();
- var totalShowed = th.find('li.showed').length-1;
- //th.find('li.showed').eq(totalShowed).css('background','black');
- console.log("totalShowed "+totalShowed);
- console.log("trueindex "+trueindex);
- for ( var i = 0; i <stepback; i++ ) {
- if (i<=4){
- totalShowed = totalShowed-i;
- additionalCollection = additionalCollection.add(th.find('li.showed').eq(totalShowed));
- }
- }
- if (stepback>1) last_li = additionalCollection;
- //additionalCollection.css('background','green');
- var left = $(last_li).width()+20
- var all_li = th.find('li.showed:not(:last)')
- next_li.addClass('showed').css('opacity', '0').css('left','-'+left+'px')
- all_li.css('left','-'+left+'px')
- last_li.css('left','-'+left+'px')
- last_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '0'
- },
- __this__.speed,
- function(){
- __this__.normalize($(this))
- $(this).removeClass('showed');
- __this__.check_nav(th)
- __this__.check_count(th);
- }
- );
- all_li.animate(
- {
- 'left': 0+'px'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- next_li.animate(
- {
- 'left': 0+'px',
- 'opacity': '1'
- },
- __this__.speed,
- function(){ __this__.normalize($(this))}
- );
- __this__.ajax_li(th, "left")
- //PUSH BACK
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") - 10);
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount) newcount += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- Prevli = th.find('li.showed:first').prevAll("li").size();
- if ( ( $( ".slider1" ).slider("value") == 0 ) && ( th.find('li.showed:first').prevAll("li").size()>0 ) ) {
- $( ".slider1" ).slider("value", $( ".slider1" ).slider("value") + Prevli*10);
- }
- }
- th.find( ".slider1" ).bind( "slide", function(event, ui){
- totalCountinThisLoad= th.find("li").size();
- if (totalCountinThisLoad > newcount) newcount += totalCountinThisLoad-newcount;
- totalCountShow=th.find("li.showed").size();
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- totalCountLeft=totalCountinThisLoad-totalCountShow;
- Maxrange=(totalCountinThisLoad-totalCountShow+1)*10;
- $( ".slider1" ).slider( "option", "max", Maxrange);
- deltaValueStep = (ui.value-ValueOldOnSlide)/10;
- //console.log("deltaValueSte "+deltaValueStep);
- if ( ui.value>ValueOldOnSlide){
- // console.log("step"+step);
- //console.log("Its scroll down")
- ScrollToright(deltaValueStep);
- }
- if ( ui.value<ValueOldOnSlide){
- //console.log("Its scroll up")
- ScrollToLeft(deltaValueStep);
- }
- });
- // });
- }
- __this__.add2basket_events = function(th)
- {
- th.find(".add2basket").attr('onclick','ys_ms_ajax_add2basket(this);return false;');
- }
- __this__.init = function(th)
- {
- if(!th)
- return;
- __this__.check_count(th);
- __this__.bind_nav(th);
- __this__.bind_li(th);
- __this__.add2basket_events(th);
- th.find("select").selectBox();
- $(window).resize(function(){
- __this__.check_count(th);
- });
- }
- __this__.ajax_block = function(name)
- {
- var loader_parent = __this__.find('.slider_cat li span#tab_'+name);
- var loader = loader_parent.find('.notloader');
- if(loader.hasClass('loader'))
- return;
- var loader_big = __this__.find('.ms_tab_block#loader');
- loader_big.find('ul').html('')
- var count = 0
- if(count = parseInt(loader_parent.find('.count').html())){
- if(count>10)
- count = 10;
- for ( i = 0; i < count; i++ )
- loader_big.find('ul').append($('<li></li>'));
- }
- __this__.check_count(loader_big)
- loader_big.find('li').each(function(){
- __this__.ajax_loader($(this))
- })
- loader_big.show()
- __this__.ajax_loader(loader)
- loader_parent.find('.tab_main').css('opacity', '0')
- loader_parent.find('.count').css('opacity', '0')
- $.post(__this__.ajax_page, {
- 'ys_ms_ajax_call':'y',
- 'tab_block':name,
- 'red_url':__this__.red_url,
- 'site_id':__this__.site_id,
- }, function(data) {
- loader_big.find('li').each(function(){
- __this__.ajax_loader_stop($(this))
- $(this).remove()
- })
- loader_parent.find('.tab_main').css('opacity', '1')
- loader_parent.find('.count').css('opacity', '1')
- __this__.ajax_loader_stop(loader)
- __this__.find('.ms_tab_block').hide();
- var append = $(data).find('.ms_tab_block#block_'+name)
- append.appendTo(__this__.find('.sl_wrapper'))
- __this__.init(append)
- __this__.find('.slider_cat li')
- .removeClass('active')
- .find('span#tab_'+name)
- .parent()
- .addClass('active')
- });
- }
- __this__.find('.slider_cat li').unbind('click').click(function(){
- if(!$(this).hasClass('active'))
- {
- var val = $(this).find('span').attr('id');
- val = val.replace('tab_', '');
- var block = __this__.find('.ms_tab_block#block_'+val)
- __this__.find('.slider_cat li')
- .removeClass('active')
- .find('span#tab_'+val)
- .parent()
- .addClass('active')
- __this__.find('.ms_tab_block').hide();
- if(block.length>0){
- block.show();
- }
- else
- __this__.ajax_block(val)
- }
- })
- __this__.find('.ms_tab_block#loader').hide()
- __this__.find('.ms_tab_block').each(function(){
- __this__.init($(this))
- });
- });
- }
- /**
- * Add params to add_url
- *
- * @param {Object} select object
- */
- function ys_ms_onSelectChange(select) {
- var a = $(select).parent().parent().parent().parent().find('div a.button2'),
- href,
- params,
- i = 0,
- flag = 0,
- val = select.name + '=' + select.value;
- $(select).next().find('span.selectBox-label').css('color', 'black');
- if (a.attr('href') === 'javascript:void(0);') {
- a.attr('href', a.attr('rev'));
- }
- href = a.attr('href');
- href = decodeURI(href);
- params = href.split('&');
- for (; i < params.length; i += 1) {
- if (params[i].indexOf(select.name) != -1) {
- if (select.value == 0) {
- params.splice(i, 1);
- } else {
- params[i] = val;
- flag = 1;
- }
- }
- }
- if ( select.value != 0 && !flag ) {
- params.push(val);
- }
- href = params.join('&');
- a.attr('href', href);
- a.removeClass('button_in_basket');
- $(select).parent().parent().find('select').each(function(){
- if(this.value == 0 ){
- a.addClass('button_in_basket');
- return false;
- }
- });
- }
- $(document).ready(function () {
- $('.catalog .add2basket').unbind('click');
- $('.catalog').on('click', '.add2basket', function(){
- if(!$(this).hasClass('button_in_basket'))
- {
- var button = $(this)
- var id = button.attr('id').replace('ys-ms-','');
- var splitData = id.split('-');
- var iblock_id = splitData[0];
- var element_id = splitData[1];
- var href = $(this).attr('href') ;
- var action_add2b = $('#action_add2b').attr('value') ;
- var ob_post_params = JSON.parse('{"'+href.substr(href.indexOf('?')+1).split('&').join('","').split('=').join('":"')+'", "iblock_id":"'+iblock_id+'","sessid":"'+BX.message.bitrix_sessid+'", "action_add2b":"'+action_add2b+'", "main_page":"Y"}');
- var url = SITE_TEMPLATE_PATH+'/ajax/add2basket.php';
- if($('.yen-bs-box').length > 0 && typeof SITE_TEMPLATE_PATH != "undefined" && typeof yenisite_bs_flyObjectTo != "undefined"){
- $.post(url, ob_post_params, function(data) {
- button.addClass("button_in_basket")
- var pic_src = $('#product_photo_'+element_id).attr('src');
- if($('#action_add2b').attr('value') == 'popup_window')
- {
- var arData = data.split('<!-- add2basket -->');
- $('.yen-bs-box').html(arData[0]);
- $('#add_2b_popup').html(arData[1]);
- $('#add_2b_popup').fadeIn('300');
- $('#mask').fadeIn('300');
- }
- else
- {
- var what = '#ys-ms-'+id+'-photo';
- var to = '.yen-bs-box';
- yenisite_bs_flyObjectTo(what, to);
- $('.yen-bs-box').html(data);
- }
- });
- return false;
- }
- }
- });
- })
- function ys_ms_ajax_add2basket(self){
- if(!$(self).hasClass('button_in_basket')){
- var button = $(self)
- var id = button.attr('id').replace('ys-ms-','');
- var splitData = id.split('-');
- var iblock_id = splitData[0];
- var element_id = splitData[1];
- var href = button.attr('href');
- if($('.yen-bs-box').length > 0 && typeof SITE_TEMPLATE_PATH != "undefined" && typeof yenisite_bs_flyObjectTo != "undefined"){
- var action_add2b = $('#action_add2b').attr('value') ;
- var ob_post_params = JSON.parse('{"'+href.substr(href.indexOf('?')+1).split('&').join('","').split('=').join('":"')+'", "action":"ADD2BASKET", "id":"'+element_id+'", "iblock_id":"'+iblock_id+'","sessid":"'+BX.message.bitrix_sessid+'", "action_add2b":"'+action_add2b+'", "main_page":"Y"}');
- var url = SITE_TEMPLATE_PATH+'/ajax/add2basket.php';
- $.post(url, ob_post_params, function(data) {
- button.addClass("button_in_basket")
- var pic_src = $('#product_photo_'+element_id).attr('src');
- if($('#action_add2b').attr('value') == 'popup_window')
- {
- var arData = data.split('<!-- add2basket -->');
- $('.yen-bs-box').html(arData[0]);
- $('#add_2b_popup').html(arData[1]);
- $('#add_2b_popup').fadeIn('300');
- $('#mask').fadeIn('300');
- }
- else
- {
- var what = '#ys-ms-'+id+'-photo';
- var to = '.yen-bs-box';
- yenisite_bs_flyObjectTo(what, to);
- $('.yen-bs-box').html(data);
- }
- });
- }else{
- throw "stop";
- }
- }
- }
- $(document).ready(function() {
- /* var loghandle = function(event, delta) {
- var o = '', id = event.currentTarget.id || event.currentTarget.nodeName;
- o = '#' + id + ':';
- if (delta > 0)
- o += ' up (' + delta + ')';
- else if (delta < 0)
- o += ' down (' + delta + ')';
- if (event.deltaY > 0)
- o += ' north (' + event.deltaY + ')';
- else if (event.deltaY < 0)
- o += ' south (' + event.deltaY + ')';
- if (event.deltaX > 0)
- o += ' east (' + event.deltaX + ')';
- else if (event.deltaX < 0)
- o += ' west (' + event.deltaX + ')';
- o += ' deltaFactor (' + event.deltaFactor + ')';
- // log( o );
- };
- */
- $("#ys-ms-slider").hover(function() {
- //console.log("test");
- });
- // get handle to the scrollable DIV
- /*var scroll = $("#scroll");
- // initialize rangeinput
- $(":range").rangeinput({
- // slide the DIV along with the range using jQuery's css() method
- onSlide: function(ev, step) {
- scroll.css({left: -step});
- },
- // display progressbar
- progress: false,
- // initial value. also sets the DIV's initial scroll position
- value: 50,
- // this is called when the slider is clicked. we animate the DIV
- change: function(e, i) {
- scroll.animate({left: -i}, "fast");
- },
- css: {
- input: 'range', /* class name for the generated text input field */
- // slider: 'slider1', /* class name for rangeinput */
- // progress: 'progress', /* class name for progress bar */
- // handle: 'handle' /* class name for drag handle */
- //},
- // disable drag handle animation when when slider is clicked
- //speed: 0
- //});*/
- /*
- var currentValue= $("input:range").val();
- console.log("currentValue "+currentValue);
- $("input:range").change(function() {
- currentValue= $("input:range").val();
- console.log("currentValue "+currentValue);
- });
- */
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement