Показать сообщение отдельно
  #6 (permalink)  
Старый 30.08.2011, 13:06
sinistral
Посмотреть профиль Найти все сообщения от melky
 
Регистрация: 28.03.2011
Сообщений: 5,418

делать нехер

весь скрипт
function CompanyPanoramaController() {
  this.DoInit()
}
CompanyPanoramaController.prototype = { 
  X_OFFSET_MAX:72,
  Y_OFFSET_MAX:70,
  _wrapperOffsetX:0,
  _wrapperOffsetY:0,
  _xOffsetStep:0,
  _yOffsetStep:0,
  _lastX:0,
  _lastY:0,
  SLIDE_TIME_FAST:1,
  SLIDE_TIME_LONG:300,
  _isOnSlide:false,
  _nextFunc:null,

DoInit:function() {
  this.DoDefineOffsetSteps();
  this.DoDefineWrapperOffset();
  this.DoBindEvents()
}, 

DoDefineOffsetSteps:function() {
  var a = parseInt($("#companyKalevaWindowPic").width(), 10);
  var b = parseInt($("#companyKalevaWindowPic").height(), 10);
  this._xOffsetStep = parseInt(a / this.X_OFFSET_MAX);
  this._yOffsetStep = parseInt(b / this.Y_OFFSET_MAX)
},

DoDefineWrapperOffset:function() {
  var a = $("#companyKalevaWindowWrapper").offset();
  this._wrapperOffsetX = parseInt(a.left, 10);
  this._wrapperOffsetY = parseInt(a.top, 10)
}, 

DoBindEvents:function() {
  var a = this;
  $("#companyKalevaWindowWrapper").bind("mousemove", function(b) {
    b.offsetX = b.pageX - a._wrapperOffsetX;
    b.offsetY = b.pageY - a._wrapperOffsetY;
    if(a._isOnSlide) {
      a._nextFunc = function() {
      }
    }else {
      a._nextFunc = null;
      a.DoChangeOffset($(this), b, a)
    }
  })
}, 

DoChangeOffset:function(f, h, c) {
  $("#companyKalevaPanoramaPic").stop();
  var d = parseInt($("#companyKalevaPanoramaPic").css("left"));
  var b = parseInt($("#companyKalevaPanoramaPic").css("top"));
  var j = c.GetNewLeftPos(h.offsetX);
  var a = c.GetNewTopPos(h.offsetY);
  var g = c.GetSlideTime(d, j, b, a);
  c._isOnSlide = true;
  c._lastX = h.offsetX;
  c._lastY = h.offsetY;
  $("#companyKalevaPanoramaPic").animate({left:j, top:a}, g, "linear", function() {
    c._isOnSlide = false;
    if(c._nextFunc != null) {
      c._nextFunc();
      c._nextFunc = null
    }
  })
}, 

GetSlideTime:function(c, f, b, a) {
  if(Math.abs(c - parseInt(f, 10)) > 20 || Math.abs(b - parseInt(a, 10)) > 10) {
    var d = this.SLIDE_TIME_LONG
  }else {
    var d = this.SLIDE_TIME_FAST
  }
  return d
}, 

GetNewLeftPos:function(b) {
  var a = -parseInt(b / this._xOffsetStep, 10);
  a += parseInt(this.X_OFFSET_MAX / 2, 10);
  a += "px";
  return a
}, 

GetNewTopPos:function(b) {
  var a = -parseInt(b / this._yOffsetStep, 10);
  a += parseInt(this.Y_OFFSET_MAX / 2, 10);
  a += "px";
  return a
}};



$(document).ready(function() {
  if($("#companyKalevaPanoramaPic").length > 0) {
    new CompanyPanoramaController
  }
});
function ContactsMapController() {
  this.DoInit()
}
ContactsMapController.prototype = {DoInit:function() {
  $("#contactsMapArea area, #contactsMapArea ul li").hover(function() {
    var b = $(this).attr("class");
    var a = "#contactsMapArea ." + b + " a";
    if($(a).length > 0) {
      $(a).addClass("hover");
      $("#contactsMapHoverArea").attr("class", "");
      $("#contactsMapHoverArea").addClass("contactsMapHoverArea").addClass(b)
    }
  }, function() {
    var b = $(this).attr("class");
    var a = "#contactsMapArea ." + b + " a";
    $(a).removeClass("hover");
    $("#contactsMapHoverArea").attr("class", "");
    $("#contactsMapHoverArea").addClass("contactsMapHoverArea").addClass("none")
  })
}};
$(document).ready(function() {
  if($("#contactsMapArea").length > 0) {
    new ContactsMapController;
    var a = Array("cao", "sao", "svao", "szao", "uao", "uvao", "uzao", "uza", "vao", "zao");
    if($.support.opacity) {
      var c = ".png"
    }else {
      var c = ".gif"
    }
    for(var b = 0;b < a.length;b++) {
      img = new Image;
      img.src = "http://www.kaleva-ru.ru//images/contacts/area/" + a[b] + c
    }
  }
});
function GalleryController() {
  this.DoInit()
}
GalleryController.prototype = {PATH_TO_BIG_IMG:"/image/Menu/86/696x0/", DoInit:function() {
  this.DoBindEvents()
}, DoBindEvents:function() {
  var a = this;
  $("#gallery .picListArea li a").bind("click", function() {
    var b = !$(this).parent().hasClass("selected");
    if(b) {
      $("#bigPic").children("img").attr("src", $(this).attr("href"));
      $("#gallery").children("h3").html($(this).attr("alt"));
      $("#gallery .picListArea li").removeClass("selected");
      $(this).parents("li").addClass("selected")
    }
    return false
  })
}};

$(document).ready(function() {
  if($("#companyKalevaPanoramaPic").length > 0) {
    new CompanyPanoramaController
  }
});

а вот работающий пример
Пример: и он работает! :)
<style>
#companyKalevaWindowPreWrapper {
margin: 0 auto;
width: 893px;
padding-right: 2%;
}
#companyKalevaWindowWrapper {
position: relative;
width: 893px;
height: 298px;
overflow: hidden;
}
#companyKalevaWindowPic {
position: absolute;
left: 0;
top: 0;
width: 893px;
height: 298px;
background: url('http://www.kaleva-ru.ru/images/company/kaleva-window.png') no-repeat;
-background: url('http://www.kaleva-ru.ru/images/company/kaleva-window.gif') no-repeat;
z-index: 2;
}
#companyKalevaPanoramaPic {
position: absolute;
left: 0;
top: 0;
margin-top: -30px;
width: 893px;
height: 298px;
background: url('http://www.kaleva-ru.ru/images/company/kaleva-panorama.jpg') no-repeat;
z-index: 1;
}
</style>

<div id="companyKalevaWindowPreWrapper">
			<div id="companyKalevaWindowWrapper">
				<div id="companyKalevaWindowPic"></div>
				<div id="companyKalevaPanoramaPic" style="left: 31px; top: -30px; "></div>
			</div>
		</div>

<script src="http://yandex.st/jquery/1.6.2/jquery.min.js"></script>
<script>
function CompanyPanoramaController(){this.DoInit()}CompanyPanoramaController.prototype={X_OFFSET_MAX:72,Y_OFFSET_MAX:70,_wrapperOffsetX:0,_wrapperOffsetY:0,_xOffsetStep:0,_yOffsetStep:0,_lastX:0,_lastY:0,SLIDE_TIME_FAST:1,SLIDE_TIME_LONG:300,_isOnSlide:false,_nextFunc:null,DoInit:function(){this.DoDefineOffsetSteps();this.DoDefineWrapperOffset();this.DoBindEvents()},DoDefineOffsetSteps:function(){var a=parseInt($("#companyKalevaWindowPic").width(),10);var b=parseInt($("#companyKalevaWindowPic").height(),10);this._xOffsetStep=parseInt(a/this.X_OFFSET_MAX);this._yOffsetStep=parseInt(b/this.Y_OFFSET_MAX)},DoDefineWrapperOffset:function(){var a=$("#companyKalevaWindowWrapper").offset();this._wrapperOffsetX=parseInt(a.left,10);this._wrapperOffsetY=parseInt(a.top,10)},DoBindEvents:function(){var a=this;$("#companyKalevaWindowWrapper").bind("mousemove",function(b){b.offsetX=b.pageX-a._wrapperOffsetX;b.offsetY=b.pageY-a._wrapperOffsetY;if(a._isOnSlide){a._nextFunc=function(){}}else{a._nextFunc=null;a.DoChangeOffset($(this),b,a)}})},DoChangeOffset:function(f,h,c){$("#companyKalevaPanoramaPic").stop();var d=parseInt($("#companyKalevaPanoramaPic").css("left"));var b=parseInt($("#companyKalevaPanoramaPic").css("top"));var j=c.GetNewLeftPos(h.offsetX);var a=c.GetNewTopPos(h.offsetY);var g=c.GetSlideTime(d,j,b,a);c._isOnSlide=true;c._lastX=h.offsetX;c._lastY=h.offsetY;$("#companyKalevaPanoramaPic").animate({left:j,top:a},g,"linear",function(){c._isOnSlide=false;if(c._nextFunc!=null){c._nextFunc();c._nextFunc=null}})},GetSlideTime:function(c,f,b,a){if(Math.abs(c-parseInt(f,10))>20||Math.abs(b-parseInt(a,10))>10){var d=this.SLIDE_TIME_LONG}else{var d=this.SLIDE_TIME_FAST}return d},GetNewLeftPos:function(b){var a=-parseInt(b/this._xOffsetStep,10);a+=parseInt(this.X_OFFSET_MAX/2,10);a+="px";return a},GetNewTopPos:function(b){var a=-parseInt(b/this._yOffsetStep,10);a+=parseInt(this.Y_OFFSET_MAX/2,10);a+="px";return a}};$(document).ready(function(){if($("#companyKalevaPanoramaPic").length>0){new CompanyPanoramaController}});function ContactsMapController(){this.DoInit()}ContactsMapController.prototype={DoInit:function(){$("#contactsMapArea area, #contactsMapArea ul li").hover(function(){var b=$(this).attr("class");var a="#contactsMapArea ."+b+" a";if($(a).length>0){$(a).addClass("hover");$("#contactsMapHoverArea").attr("class","");$("#contactsMapHoverArea").addClass("contactsMapHoverArea").addClass(b)}},function(){var b=$(this).attr("class");var a="#contactsMapArea ."+b+" a";$(a).removeClass("hover");$("#contactsMapHoverArea").attr("class","");$("#contactsMapHoverArea").addClass("contactsMapHoverArea").addClass("none")})}};$(document).ready(function(){if($("#contactsMapArea").length>0){new ContactsMapController;var a=Array("cao","sao","svao","szao","uao","uvao","uzao","uza","vao","zao");if($.support.opacity){var c=".png"}else{var c=".gif"}for(var b=0;b<a.length;b++){img=new Image;img.src="http://www.kaleva-ru.ru//images/contacts/area/"+a[b]+c}}});function GalleryController(){this.DoInit()}GalleryController.prototype={PATH_TO_BIG_IMG:"/image/Menu/86/696x0/",DoInit:function(){this.DoBindEvents()},DoBindEvents:function(){var a=this;$("#gallery .picListArea li a").bind("click",function(){var b=!$(this).parent().hasClass("selected");if(b){$("#bigPic").children("img").attr("src",$(this).attr("href"));$("#gallery").children("h3").html($(this).attr("alt"));$("#gallery .picListArea li").removeClass("selected");$(this).parents("li").addClass("selected")}return false})}};$(document).ready(function(){if($("#companyKalevaPanoramaPic").length>0){new CompanyPanoramaController}});
</script>


вот тут тот же пример на jsfiddle
Ответить с цитированием