Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.96 KB | None | 0 0
  1. jQuery(function($) {
  2.  
  3. var self,
  4. wnd = $(window),
  5. wWidth, wHeight;
  6. if (wnd.width() < 980) {
  7. wWidth = 980;
  8. } else {
  9. wWidth = wnd.width();
  10. }
  11. if (wnd.height() < 650) {
  12. wHeight= 650
  13. } else {
  14. wHeight = wnd.height();
  15. }
  16. wnd.on('resize', function() {
  17. if (wnd.width() < 980) {
  18. wWidth = 980;
  19. } else {
  20. wWidth = wnd.width();
  21. }
  22.  
  23. if (wnd.height() < 650) {
  24. wHeight= 650
  25. } else {
  26. wHeight = wnd.height();
  27. }
  28. });
  29.  
  30. var dropdown = {
  31. init : function() {
  32. $('.menu .level1 li').on({
  33. 'mouseenter' : function() {
  34. self = $(this);
  35. self.addClass('opened');
  36. if (self.find('.level2').size()) {
  37. self.find('.level2').stop(true,true).animate({
  38. opacity : 'show',
  39. height : 'show'
  40. });
  41. }
  42. },
  43. 'mouseleave' : function() {
  44. self = $(this);
  45. self.removeClass('opened');
  46. if (self.find('.level2').size()) {
  47. self.find('.level2').stop(true,true).animate({
  48. opacity : 'hide',
  49. height : 'hide'
  50. });
  51. }
  52. }
  53. });
  54. }
  55. };
  56. dropdown.init();
  57.  
  58. var dropdownSide = {
  59. init : function() {
  60. var self;
  61. $('.sidebar .level1 > li').on({
  62. 'mouseenter' : function() {
  63. self = $(this);
  64. self.find('.level2').stop(true,true).animate({
  65. height : 'show'
  66. });
  67. },
  68. 'mouseleave' : function() {
  69. self = $(this);
  70. if (!self.hasClass('active-trail')) {
  71. self.find('.level2').stop(true,true).animate({
  72. height : 'hide'
  73. },100);
  74. }
  75. }
  76. });
  77. }
  78. };
  79. dropdownSide.init();
  80.  
  81. $('.toggle-link').on('click', function() {
  82. self = $(this);
  83. self.closest('.toggle-block').siblings('.opened').removeClass('opened').find('.block').stop().animate({
  84. height : 'hide',
  85. opacity : 'hide'
  86. });
  87. self.closest('.toggle-block').toggleClass('opened').find('.block').stop().animate({
  88. height : 'toggle',
  89. opacity : 'toggle'
  90. });
  91. return false;
  92. });
  93.  
  94. var toggleWindow = {
  95. init : function() {
  96.  
  97. this.toggleHeader();
  98. this.toggleFooter();
  99.  
  100. },
  101.  
  102. toggleHeader : function() {
  103. var margin,
  104. header = $('header.header'),
  105. contacts = $('.toggle-contacts');
  106. margin = contacts.outerHeight();
  107. contacts.css({display:'block'});
  108. header
  109. .css({marginTop:'-'+margin+'px'})
  110. .find('.toggle-close').on('click', function() {
  111. header.stop().animate({
  112. marginTop : -margin
  113. }, 1000, 'easeOutCubic');
  114. return false;
  115. });
  116.  
  117. $('.toggle-tel').on('click', function() {
  118. self = $(this);
  119. if ($(this).hasClass('toggled')) {
  120. self.removeClass('toggled');
  121. header.stop().animate({
  122. marginTop : -margin + $('body,html').scrollTop()
  123. }, 1000, 'easeOutQuart', function() {
  124. header.css({marginTop:-margin});
  125. $('body,html').scrollTop(0);
  126. });
  127. } else {
  128. self.addClass('toggled');
  129. header.stop().animate({
  130. marginTop : 0
  131. }, 1000, 'easeOutQuart');
  132. $('.footer .toggle-link.toggled').trigger('click');
  133. }
  134. return false;
  135. });
  136.  
  137. },
  138.  
  139. toggleFooter : function() {
  140. var height,
  141. footer = $('footer.footer'),
  142. holder = $('footer.footer .toggle-holder'),
  143. link = footer.find('.toggle-link'),
  144. close = footer.find('.toggle-close'),
  145. fHeight = $('.menu').height() + 52;
  146.  
  147. link.on('click', function() {
  148. self = $(this);
  149. holder = self.closest('.toggle-holder');
  150. height = holder.height() + 131;
  151. if (self.hasClass('toggled')) {
  152. self.removeClass('toggled');
  153. self.closest('.footer-holder').stop().animate({
  154. height: 131
  155. }, 'easeOutQuart', function() {
  156. holder.siblings().removeClass('sibling')
  157. });
  158. } else {
  159. self.addClass('toggled');
  160. holder.css({zIndex:10}).siblings().addClass('sibling');
  161. self.closest('.footer-holder').stop().animate({
  162. height: height
  163. }, 'easeOutQuart');
  164. $('.toggle-tel.toggled').trigger('click');
  165. }
  166. return false;
  167. });
  168. close.on('click', function() {
  169. holder = $(this).closest('.toggle-holder');
  170. $('.footer-holder').stop().animate({
  171. height: 131
  172. }, 'easeOutQuart', function() {
  173. holder.siblings().removeClass('sibling')
  174. }).find('.toggle-link').removeClass('toggled');
  175. return false;
  176. })
  177. }
  178. };
  179. toggleWindow.init();
  180.  
  181. var indexSlider = {
  182. init : function() {
  183. var slider = $('#index-slider'),
  184. viewport = slider.find('.viewport'),
  185. overview = slider.find('.overview'),
  186. slide = slider.find('.slide'),
  187. thumbs = slider.find('.thumbs'),
  188. close = slider.find('.toggle-close'),
  189. buttons = slider.find('.slider-button'),
  190. holder = '',
  191. self, index, width, flag = 0, hoverFlag = 0,
  192. strut = slider.find('.strut'),
  193. layer = slider.find('.layer'),
  194. layer1 = slider.find('.layer-1'),
  195. layer2 = slider.find('.layer-2'),
  196. layer3 = slider.find('.layer-3'),
  197. overlay = slider.find('.overlay'),
  198. header = $('header.header'),
  199. footer = $('footer.footer'),
  200. time, method;
  201.  
  202. if ($('body').hasClass('front')) {
  203. $('html').css({height:'auto'});
  204. }
  205. slide.each(function() {
  206. self = $(this);
  207. holder += '<a href="#"></a>';
  208. });
  209. thumbs.html(holder).find('a').first().addClass('active');
  210.  
  211. reSet(wWidth);
  212. wnd.on({
  213. 'resize' : function() {
  214. reSet(wWidth);
  215. },
  216. 'mousemove' : function(event) {
  217. if (slider.hasClass('unpack') && (event.pageY < 100 || event.pageY > wHeight - 100)) {
  218. precoverSlider()
  219. } else if (slider.hasClass('unpack') && (event.pageY >= 100 || event.pageY <= wHeight - 100)) {
  220. revealSlider();
  221. }
  222. },
  223. 'click' : function() {
  224. if (slider.hasClass('midi')) {
  225. coverSlider();
  226. return false;
  227. }
  228. }
  229. });
  230.  
  231. setDisable();
  232.  
  233. buttons.on('click', function() {
  234. self = $(this);
  235. if (!self.hasClass('disable')) {
  236. if (self.hasClass('next')) {
  237. index = thumbs.find('.active').next().index();
  238. thumbs.find('.active').removeClass('active').next().addClass('active');
  239. } else if (self.hasClass('prev')) {
  240. index = thumbs.find('.active').prev().index();
  241. thumbs.find('.active').removeClass('active').prev().addClass('active');
  242. }
  243. slideTo(index);
  244. setDisable();
  245. }
  246. $(this).blur();
  247. return false;
  248. });
  249.  
  250. thumbs.find('a').on('click', function() {
  251. self = $(this);
  252. self.addClass('active').siblings('.active').removeClass('active');
  253. slideTo(self.index());
  254. setDisable();
  255. return false;
  256. });
  257.  
  258. close.on('click', function() {
  259. coverSlider();
  260. return false;
  261. });
  262.  
  263. overlay.on({
  264. 'click' : function() {
  265. if (slider.hasClass('midi')) {
  266. coverSlider();
  267. } else {
  268. revealSlider();
  269. }
  270. return false;
  271. }
  272. });
  273.  
  274. function reSet(wWidth) {
  275. overview.css({width:wWidth*slide.size()});
  276. slide.css({width:wWidth});
  277. layer.css({width:wWidth*1.5*slide.size()});
  278. slider.css({minHeight:wHeight});
  279. strut.css({minHeight:wHeight});
  280. slide.each(function() {
  281. self = $(this);
  282. self.css({left:wWidth*self.index()});
  283. });
  284. index = $('.thumbs').find('.active').index();
  285. overview.css({left:-index*wWidth});
  286. layer1.css({left:-index*wWidth*0.5});
  287. layer2.css({left:-index*wWidth*0.25});
  288. layer3.css({left:-index*wWidth*0.15});
  289. }
  290.  
  291. function slideTo(index) {
  292. overview.stop().animate({
  293. left : -index*wWidth
  294. }, 1500, 'easeOutQuint');
  295. layer1.stop().animate({
  296. left: -index*wWidth*0.2
  297. }, 1500, 'easeOutQuint');
  298. layer2.stop().animate({
  299. left: index*wWidth*0.2
  300. }, 1500, 'easeOutQuint');
  301. layer3.stop().animate({
  302. left: index*wWidth*0.4
  303. }, 1500, 'easeOutQuint');
  304. }
  305.  
  306. function setDisable() {
  307. buttons.removeClass('disable');
  308. if (thumbs.find('.active').is(':last-child')) {
  309. buttons.filter('.next').addClass('disable');
  310. } else if (thumbs.find('.active').is(':first-child')) {
  311. buttons.filter('.prev').addClass('disable');
  312. }
  313. }
  314.  
  315. function revealSlider() {
  316. slider.addClass('unpack');
  317. if (slider.hasClass('midi')) {
  318. time = 2000;
  319. } else {
  320. time = 1000;
  321. }
  322.  
  323. header.stop().animate({
  324. top: - header.find('.wrapper').last().height() - 9,
  325. marginTop : - $('.toggle-contacts').height()
  326. }, time, 'easeOutExpo');
  327. $('.toggle-tel').removeClass('toggled');
  328. footer.stop().animate({
  329. bottom: - 131
  330. }, time, 'easeOutExpo').find('.footer-holder').stop().animate({
  331. height: 131
  332. }, 'easeOutQuart', function() {
  333. $('.toggle-holder').siblings().removeClass('sibling');
  334. $('.toggle-link').removeClass('toggled');
  335. });
  336.  
  337. // $(overlay).css({display:'none'});
  338.  
  339. buttons.stop(true,true).animate({
  340. opacity : 'show'
  341. });
  342.  
  343. thumbs.stop(true,true).animate({
  344. opacity : 'show'
  345. });
  346.  
  347. close.stop(true,true).animate({
  348. opacity : 'show'
  349. });
  350. }
  351.  
  352. function coverSlider() {
  353. slider.removeClass('unpack').removeClass('midi');
  354.  
  355. header.stop().animate({
  356. top: 0
  357. }, 1000, 'easeOutExpo');
  358. footer.stop().animate({
  359. bottom: 0
  360. }, 1000, 'easeOutExpo');
  361.  
  362. // $(overlay).css({display:'block'});
  363.  
  364. buttons.stop(true,true).animate({
  365. opacity : 'hide'
  366. });
  367.  
  368. thumbs.stop(true,true).animate({
  369. opacity : 'hide'
  370. });
  371.  
  372. close.stop(true,true).animate({
  373. opacity : 'hide'
  374. });
  375. }
  376.  
  377. function precoverSlider() {
  378. slider.addClass('midi');
  379. header.stop().animate({
  380. top: -50
  381. }, 2000, 'easeOutExpo');
  382. footer.stop().animate({
  383. bottom: -50
  384. }, 2000, 'easeOutExpo');
  385. }
  386.  
  387. $('#gofirst').on('click', function() {
  388. $('#index-slider .thumbs a:first').trigger('click');
  389. coverSlider();
  390. return false;
  391. });
  392.  
  393. }
  394. };
  395. if ($('#index-slider').size()) {
  396. indexSlider.init();
  397. }
  398.  
  399. var menuTracking = {
  400. init : function() {
  401. var menu = $('.menu'),
  402. level1 = menu.find('.level1'),
  403. mWidth = level1.outerWidth(),
  404. leftB = level1.offset().left + 60,
  405. rightB = level1.offset().left + mWidth - 60;
  406. wnd.on('resize', function() {
  407. leftB = menu.offset().left;
  408. rightB = menu.offset().left + mWidth;
  409. });
  410. wnd.on({
  411. 'mousemove' : function (event) {
  412. if (event.pageX >= 60 && event.pageX <= wWidth - 60) {
  413. level1.find('.bar').css({left:(event.pageX - 60)});
  414. }
  415. }
  416. });
  417. }
  418. };
  419. menuTracking.init();
  420.  
  421. //file
  422. $('.region-footer-right #edit-file').wrap('<div class="file-block"></div>').after('<div class="file-text"></div><a class="file-button"></a>');
  423. $('.region-footer-right .file-block .file-button').on('click', function() {
  424. $('#edit-file').trigger('click');
  425. return false;
  426. });
  427. $('.region-footer-right #edit-file').on('change', function() {
  428. $('.file-block .file-text').text($(this).val().replace(/.+[\\\/]/, ""));
  429. });
  430. $('.region-content #edit-file').before('<a href="javascript:void(0);" onclick="open_dialog();">выберите файл</a>');
  431. open_dialog = function(){
  432. $('#edit-file_wrap input:last').trigger('click');
  433. }
  434. $('.region-content #edit-file_wrap> a').after($('#webform-component-file .description'));
  435. //
  436.  
  437. //captcha
  438. /*var a=Math.floor( Math.random() * 10 ) ;
  439. var b=Math.floor( Math.random() * 10 ) ;
  440. var c =a+b;
  441. jQuery('#webform-component-file').prepend('<div><label for="capt">'+a+'+'+b+'=</label><input class="captch" id="capt" style="height:30px"></div>');
  442. jQuery('.form-textarea').css('min-height','128px').css('max-height','128px').css('height','128px');
  443. */
  444.  
  445. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement