Guest User

Untitled

a guest
Jan 21st, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.66 KB | None | 0 0
  1. function objTest()
  2. {
  3. //Properties
  4. var self = this;
  5. this.envList = {};
  6. this.handlerList = {};
  7. var envirPath = 'images/environments/';
  8.  
  9. this.set = function(param,handleData)
  10. {
  11. if ( param === 'envList' || param === 'handlerList' )
  12. {
  13.  
  14. $.ajax({
  15. context : this,
  16. type: "POST",
  17. url: "debug_ambientes_ajax_v0_2_1.php",
  18. dataType : 'json',
  19. data: {
  20. list : param
  21. },
  22. success: function( data ){
  23.  
  24. handleData(data);
  25.  
  26. }
  27. });
  28.  
  29. }
  30. else if ( param === 'environments' )
  31. {
  32. $.ajax({
  33. context : this,
  34. type: "POST",
  35. url: "debug_ambientes_ajax_v0_2_1.php",
  36. dataType : 'json',
  37. data: {
  38. list : param
  39. },
  40. success: function( data ){
  41. jQuery.each( data.images, function(key, val){
  42. $('#sideEnvirList').append($('<li><img src="' + envirPath + val.thumb + '" title="Img" alt="Img"/><span class="highResImg hidden">' + val.high + '</span></li>'));
  43. });
  44.  
  45. }
  46. });
  47. }
  48.  
  49.  
  50. }; //end set
  51.  
  52. this.set('envList', function(output) { this.envList = self = output; } );
  53. this.set('handlerList', function(output) { this.handlerList = self = output; });
  54. this.set('environments');
  55.  
  56. //debug propouses only
  57. setTimeout(function() {
  58. //console.log( this.envList )
  59. }, 3000);
  60.  
  61. setTimeout(function() {
  62. //console.log( this.handlerList )
  63. }, 3000);
  64.  
  65.  
  66. /*
  67. * bind mouse events to functions
  68. */
  69. $(function(){
  70.  
  71. var intLeft = 0;
  72. var antecipation = 0;
  73.  
  74. $('#confoGalHorSlider .handlers').bind({
  75.  
  76. click : function(){
  77. if ( $(this).attr('id') === 'confoGalLeft' )
  78. {
  79. if ( self.curProdIndex > 1 )
  80. {
  81.  
  82. //antecipate anim
  83. antecipation = intLeft - 25;
  84. $('#galleryProductRow').animate({
  85. left : antecipation
  86. }, 250 );
  87.  
  88. intLeft = intLeft + self.eachProdBlockWidth;
  89. self.curProdIndex = self.curProdIndex - 1;
  90.  
  91. $('#galleryProductRow').animate({
  92. left : intLeft
  93. });
  94. }
  95. }
  96. else if ( $(this).attr('id') === 'confoGalRight' )
  97. {
  98. if ( self.curProdIndex <= self.totalProducts - self.nrDisplayProds )
  99. {
  100.  
  101. //antecipate anim
  102. antecipation = intLeft + 25;
  103. $('#galleryProductRow').animate({
  104. left : antecipation
  105. }, 250 );
  106.  
  107. intLeft = intLeft - self.eachProdBlockWidth;
  108. self.curProdIndex = self.curProdIndex + 1;
  109.  
  110. $('#galleryProductRow').animate({
  111. left : intLeft
  112. });
  113. }
  114. }
  115. }
  116.  
  117. });
  118.  
  119. $('.eachProduct').bind({
  120.  
  121. mouseover: function(){
  122.  
  123. $(this).animate({
  124. top : -25,
  125. height : '125px'
  126. },200);
  127.  
  128. $(this).find('.eachProdBack').fadeIn();
  129.  
  130. },
  131. mouseleave: function(){
  132.  
  133. $(this).animate({
  134. top : 0,
  135. height: '100px'
  136. },200);
  137.  
  138. $(this).find('.eachProdBack').fadeOut();
  139.  
  140. }
  141.  
  142. });
  143.  
  144. var intTop = 0;
  145. antecipation = 0;
  146.  
  147. $('.handlersVert').bind({
  148. click : function(){
  149.  
  150. if ( $(this).attr('id') == 'confoGalVertTop' )
  151. {
  152. if ( self.slideCurProdIndex > 1 )
  153. {
  154.  
  155. //antecipate anim
  156. antecipation = intTop - 25;
  157. $('#hiddenVertEnvir ul#sideEnvirList').animate({
  158. top : antecipation
  159. }, 250 );
  160.  
  161. intTop = intTop + self.slideProdBlockHeight;
  162. self.slideCurProdIndex = self.slideCurProdIndex - 1;
  163.  
  164.  
  165. $('#hiddenVertEnvir ul#sideEnvirList').animate({
  166. top : intTop
  167. });
  168.  
  169. }
  170. }
  171. else if ( $(this).attr('id') == 'confoGalVertBot' )
  172. {
  173. if ( self.slideCurProdIndex <= self.slideTotalProducts-self.slideCurProdIndex )
  174. {
  175. //antecipate anim
  176. antecipation = intTop + 25;
  177. $('#hiddenVertEnvir ul#sideEnvirList').animate({
  178. top : antecipation
  179. }, 250 );
  180.  
  181. intTop = intTop - self.slideProdBlockHeight;
  182. self.slideCurProdIndex = self.slideCurProdIndex + 1;
  183.  
  184. $('#hiddenVertEnvir ul#sideEnvirList').animate({
  185. top : intTop
  186. });
  187. }
  188. } //end if
  189.  
  190. }
  191. });
  192.  
  193. $('ul#sideEnvirList li').bind({
  194.  
  195. click : function(){
  196.  
  197. /*
  198. var slideTxt = $(this).text();
  199. $('#confoImgCont').text( 'Ambiente: ' + slideTxt );
  200.  
  201.  
  202. $('#confoGalHorSlider').animate({
  203. bottom : '-68px'
  204. });
  205.  
  206.  
  207. setTimeout(function() {
  208.  
  209. $('#confoGalHorSlider').animate({
  210. bottom : '0px'
  211. });
  212.  
  213. }, 500);
  214. */
  215.  
  216. var highResImg = $(this).find('.highResImg').text();
  217.  
  218. var img = new Image();
  219.  
  220. //hidde horizontal slider
  221. $('#confoGalHorSlider').animate({
  222. bottom : '-68px'
  223. });
  224.  
  225. $(img).load(function () {
  226.  
  227. //remove current img
  228. $('#highResImg').remove();
  229. //hide img being loaded
  230. $(this).hide();
  231.  
  232. $('#confoImgCont').removeClass('loading').append(this);
  233. $(this).fadeIn();
  234.  
  235. //show horizontal slider
  236. $('#confoGalHorSlider').animate({
  237. bottom : '0px'
  238. });
  239.  
  240. }).error(function () {
  241. // notify the user that the image could not be loaded
  242. }).attr('src', envirPath + highResImg).attr('id', 'highResImg').attr('title','title').attr('alt','alt');
  243.  
  244. }
  245.  
  246. });
  247.  
  248. $('.eachProduct').bind({
  249. click : function(){
  250. $('#galProductDetails').fadeIn();
  251. }
  252. });
  253.  
  254. $('.closeBtn').bind({
  255. click : function(){
  256. $('#galProductDetails').fadeOut();
  257. }
  258. });
  259.  
  260. });
  261.  
  262. } //end objTest
  263.  
  264. //run test
  265. var runMe = new objTest();
Add Comment
Please, Sign In to add comment