jquery.rivathemes.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. /*
  2. * Riva Slider
  3. */
  4. (function( $ ){
  5. $.fn.rivaSlider = function( options ) {
  6. /*
  7. * Vars
  8. */
  9. var $this = this,
  10. selector = options['selector'],
  11. padding_left = options['padding_left'],
  12. $elems = $this.find('.' + selector),
  13. $controls = $this.find('.rivaslider-navigation'),
  14. visible = options['visible'],
  15. $wrapper, $inner, scrol, qty, offsetLeft, fixH = 0, steps, bodyWidth, current = 0, isReadry = 0;
  16. /*
  17. * Methods
  18. */
  19. var methods = {
  20. /*
  21. * Constructor
  22. */
  23. init : function() {
  24. /*
  25. * Wrap all selected elements into wrapper
  26. */
  27. if (!isReadry) {
  28. $elems.wrapAll('<div class="rivaslider-wrapper"></div>');
  29. $wrapper = $this.find('.rivaslider-wrapper');
  30. $wrapper.wrapInner('<div class="rivaslider-wrapper-inner"></div>');
  31. $inner = $this.find('.rivaslider-wrapper-inner');
  32. }
  33. qty = $elems.length;
  34. bodyWidth = $('body').width()
  35. offsetLeft = parseInt($elems.eq(0).css('padding-left'));
  36. if (bodyWidth > 768) {
  37. steps = qty - visible -1;
  38. scrol = $this.parents('[class*="col"]').width() / visible + offsetLeft / visible;
  39. // $wrapper.width(scrol * visible - offsetLeft);
  40. $elems.width(scrol - offsetLeft);
  41. } else {
  42. steps = qty - 2;
  43. scrol = $this.parents('[class*="col"]').width() + offsetLeft;
  44. // $wrapper.width(scrol - offsetLeft);
  45. $elems.width(scrol - offsetLeft);
  46. }
  47. if (!isReadry) {
  48. if ($this.hasClass('envor-section-projects')) {
  49. fixH = scrol * 0.6;
  50. }
  51. }
  52. $inner.css('margin-left', '-' + offsetLeft + 'px');
  53. $wrapper.height(function() {
  54. var h = 0;
  55. $elems.each(function() {
  56. if ($(this).height() > h)
  57. h = $(this).height();
  58. });
  59. return h + fixH;
  60. });
  61. isReadry = 1;
  62. },
  63. /*
  64. * scroler
  65. */
  66. scroler : function(direction) {
  67. if (direction > 0) {
  68. if (current <= steps) {
  69. $this.find('.sl-navi a.back').removeClass('end');
  70. $inner.filter(':not(:animated)').animate({
  71. 'left' : '-=' + scrol
  72. }, 400, function() { current = current + 1; });
  73. } else {
  74. $this.find('.sl-navi a.forward').removeClass('end');
  75. $inner.filter(':not(:animated)').animate({
  76. 'left' : '0px'
  77. }, 400, function() { current = 0; });
  78. }
  79. } else {
  80. var f;
  81. if (bodyWidth > 768) {
  82. f = visible;
  83. } else {
  84. f = 1;
  85. }
  86. if (current > 0) {
  87. $this.find('.sl-navi a.forward').removeClass('end');
  88. $inner.filter(':not(:animated)').animate({
  89. 'left' : '+=' + scrol
  90. }, 400, function() { current = current - 1; });
  91. } else {
  92. $this.find('.sl-navi a.forward').removeClass('end');
  93. $inner.filter(':not(:animated)').animate({
  94. 'left' : '-=' + (scrol * (qty - f))
  95. }, 400, function() { current = qty - f; });
  96. }
  97. }
  98. }
  99. }
  100. return this.each(
  101. function()
  102. {
  103. /*
  104. * On init call
  105. */
  106. methods.init();
  107. $('a.back', $controls).click(function(e) {
  108. e.preventDefault();
  109. methods.scroler(-1);
  110. });
  111. $('a.forward', $controls).click(function(e) {
  112. e.preventDefault();
  113. methods.scroler(+1);
  114. });
  115. /*
  116. * On window resize
  117. */
  118. $(window).resize(function() {
  119. fixH = 0;
  120. methods.init();
  121. $inner.css('left','0px');
  122. // alert('reszize');
  123. });
  124. }
  125. );
  126. }
  127. })( jQuery );
  128. /*
  129. * Riva Carousel
  130. */
  131. (function( $ ){
  132. $.fn.rivaCarousel = function( options ) {
  133. /*
  134. * Vars
  135. */
  136. var $this = this,
  137. selector = options['selector'],
  138. useoffest = options['useoffest'],
  139. $elems = $this.find('.' + selector),
  140. $controls = $this.find('.rivaslider-controls'),
  141. same_height = options['same_height'],
  142. visible = options['visible'],
  143. mobile_visible = options['mobile_visible'],
  144. $wrapper, $inner, scrol, qty, steps, offsetLeft, bodyWidth, current = 0, isReadry = 0, v, fixW;
  145. /*
  146. * Methods
  147. */
  148. var methods = {
  149. /*
  150. * Constructor
  151. */
  152. init : function() {
  153. /*
  154. * Wrap all selected elements into wrapper
  155. */
  156. fixW = parseInt($elems.css('padding-left')) + parseInt($elems.css('padding-right'));
  157. offsetLeft = parseInt($elems.eq(0).css('padding-left'));
  158. qty = $elems.length;
  159. bodyWidth = $('body').width()
  160. if (bodyWidth > 768) {
  161. steps = Math.ceil(qty / visible);
  162. v = visible;
  163. scrol = $this.parents('[class*="col"]').width() / visible + offsetLeft / visible;
  164. } else {
  165. if ('undefined' == mobile_visible)
  166. mobile_visible = visible;
  167. steps = Math.ceil(qty / mobile_visible);
  168. v = mobile_visible;
  169. scrol = $this.parents('[class*="col"]').width() / mobile_visible;
  170. }
  171. if (!isReadry) {
  172. $elems.wrapAll('<div class="rivaslider-wrapper"></div>');
  173. $wrapper = $this.find('.rivaslider-wrapper');
  174. $wrapper.wrapInner('<div class="rivaslider-wrapper-inner"></div>');
  175. $inner = $this.find('.rivaslider-wrapper-inner');
  176. }
  177. $wrapper.width($this.parents('[class*="col"]').width());
  178. $inner.css('margin-left', '-' + offsetLeft + 'px');
  179. $controls.find('span').remove().detach();
  180. for (var i = 0; i < steps; i++) {
  181. $controls.append('<span></span>');
  182. }
  183. $controls.find('span').first().addClass('active');
  184. $elems.css('width', (parseInt($wrapper.width()) / v) - fixW + offsetLeft);
  185. if (bodyWidth > 768) {
  186. $elems.width(scrol - offsetLeft);
  187. } else {
  188. scrol = $this.parents('[class*="col"]').width() + offsetLeft;
  189. $elems.width(scrol - offsetLeft);
  190. }
  191. if (v == 1) {
  192. $wrapper.height($elems.eq(current).height());
  193. } else {
  194. $wrapper.height(function() {
  195. var h = 0;
  196. $elems.each(function() {
  197. if ($(this).height() > h)
  198. h = $(this).height();
  199. });
  200. return h;
  201. });
  202. }
  203. if (same_height) {
  204. $elems.height($wrapper.height());
  205. }
  206. isReadry = 1;
  207. },
  208. /*
  209. * scroler
  210. */
  211. scroler : function(step) {
  212. if (step != current) {
  213. if (bodyWidth > 768) {
  214. v = visible;
  215. } else {
  216. if ('undefined' == mobile_visible)
  217. mobile_visible = visible
  218. v = mobile_visible;
  219. }
  220. $inner.filter(':not(:animated)').animate({'left' : '-' + (scrol * v * step) + 'px'}, 400, function() {
  221. current = step;
  222. $controls.find('span').removeClass('active');
  223. $controls.find('span').eq(current).addClass('active');
  224. if (v == 1)
  225. $wrapper.animate({'height':$elems.eq(current).height()});
  226. });
  227. }
  228. }
  229. }
  230. return this.each(function() {
  231. /*
  232. * On init call
  233. */
  234. methods.init();
  235. $controls.find('span').click(function(e) {
  236. e.preventDefault();
  237. methods.scroler($(this).index());
  238. });
  239. /*
  240. * On window resize
  241. */
  242. $(window).resize(function() {
  243. methods.init();
  244. $controls.find('span').click(function(e) {
  245. e.preventDefault();
  246. methods.scroler($(this).index());
  247. });
  248. $inner.css('left','0px');
  249. });
  250. });
  251. }
  252. })( jQuery );
  253. /*
  254. * Riva Countdown
  255. */
  256. (function( $ ){
  257. $.fn.rivaCountdown = function( options ) {
  258. /*
  259. * Vars
  260. */
  261. var $this = this,
  262. year = options['year'],
  263. month = options['month'],
  264. date = options['date'],
  265. hour = options['hour'],
  266. minute = options['minute'],
  267. second = options['second'],
  268. endDate, today, mils,
  269. $daysValue = $this.find('#riva-countdown-days .value p'),
  270. $hoursValue = $this.find('#riva-countdown-hours .value p'),
  271. $minsValue = $this.find('#riva-countdown-minutes .value p'),
  272. $secsValue = $this.find('#riva-countdown-seconds .value p'),
  273. dividers = new Array(86400, 3600, 60, 1), rest, t,
  274. values = new Array($daysValue, $hoursValue, $minsValue, $secsValue),
  275. timer_is_on = 0;
  276. endDate = new Date(year, month - 1, date, hour, minute, second);
  277. if (!timer_is_on) {
  278. timer_is_on = 1;
  279. changeTime();
  280. }
  281. function changeTime() {
  282. today = new Date();
  283. rest = (endDate - today) / 1000;
  284. for (var i = 0; i < dividers.length; i++) {
  285. values[i].html(Math.floor(rest / dividers[i]));
  286. rest = rest % dividers[i];
  287. }
  288. t = setTimeout(changeTime,1000);
  289. }
  290. }
  291. })( jQuery );
  292. (function( $ ){
  293. $.fn.envorInView = function(){
  294. var win = $(window);
  295. obj = $(this);
  296. var scrollPosition = win.scrollTop();
  297. var visibleArea = win.scrollTop() + win.height();
  298. var objEndPos = (obj.offset().top + obj.outerHeight());
  299. return(visibleArea >= objEndPos && scrollPosition <= objEndPos ? true : false)
  300. };
  301. })( jQuery );
  302. (function( $ ){
  303. $.fn.envorAnimateObj = function(){
  304. var $obj = this,
  305. animation = new Array(),
  306. type = 0;
  307. animation.push('bounce');
  308. animation.push('flash');
  309. animation.push('pulse');
  310. animation.push('rubberBand');
  311. animation.push('shake');
  312. animation.push('swing');
  313. animation.push('tada');
  314. animation.push('wobble');
  315. animation.push('bounceIn');
  316. animation.push('bounceInLeft');
  317. animation.push('bounceInRight');
  318. animation.push('bounceInUp');
  319. animation.push('fadeIn');
  320. animation.push('fadeInDown');
  321. animation.push('fadeInDownBig');
  322. animation.push('fadeInLeft');
  323. animation.push('fadeInLeftBig');
  324. animation.push('fadeInRight');
  325. animation.push('fadeInRightBig');
  326. animation.push('fadeInUp');
  327. animation.push('fadeInUpBig');
  328. animation.push('flip');
  329. animation.push('flipInX');
  330. animation.push('flipInY');
  331. animation.push('lightSpeedIn');
  332. animation.push('rotateIn');
  333. animation.push('rotateInDownLeft');
  334. animation.push('rotateInDownRight');
  335. animation.push('rotateInUpLeft');
  336. animation.push('rotateInUpRight');
  337. animation.push('slideInDown');
  338. animation.push('slideInLeft');
  339. animation.push('slideInRight');
  340. animation.push('hinge');
  341. animation.push('rollIn');
  342. type = (Math.random()*animation.length)+1|0;
  343. return this.each(function() {
  344. $obj.fadeTo(0, 0);
  345. $(window).scroll(function(){
  346. if ($obj.envorInView()) {
  347. $obj.fadeTo(0,1).addClass('animated ' + animation[type]);
  348. }
  349. });
  350. });
  351. };
  352. })( jQuery );
  353. /*
  354. * Riva Sorting
  355. */
  356. (function( $ ){
  357. $.fn.rivaSorting = function( options ) {
  358. var $this = this,
  359. showAll = options['showAll'],
  360. $filters = $this.find('.envor-sorting-filters'),
  361. $elems = $this.find('.envor-sorting-item');
  362. if (showAll) {
  363. $('<span data-value="*">All</span>').prependTo($filters);
  364. $elems.show();
  365. } else {
  366. $elems.hide().each(function() {
  367. if ($(this).hasClass($filters.find('[data-value]').first().attr('data-value')))
  368. $(this).show();
  369. });
  370. }
  371. $filters.find('span').click(function() {
  372. var val = $(this).attr('data-value');
  373. $filters.find('span').removeClass('active');
  374. $(this).addClass('active');
  375. $elems.hide().each(function() {
  376. if (val == '*') {
  377. $elems.fadeIn();
  378. return;
  379. }
  380. if ($(this).hasClass(val)) {
  381. $(this).fadeIn();
  382. return;
  383. }
  384. });
  385. }).first().addClass('active');
  386. }
  387. })( jQuery );
  388. /*
  389. * Riva Toggle Tabs
  390. */
  391. (function( $ ){
  392. $.fn.rivaToggleTabs = function( options ) {
  393. var $this = this,
  394. $links = $this.find('li'),
  395. $elems = $('.riva-toggle-tab');
  396. $elems.hide().first().show();
  397. $links.first().addClass('active');
  398. $links.click(function(e) {
  399. e.preventDefault();
  400. $links.removeClass('active');
  401. $(this).addClass('active');
  402. $elems.hide().eq($(this).index()).fadeIn();
  403. });
  404. $elems.each(function() {
  405. $(this).find('.riva-next-tab').click(function(e) {
  406. e.preventDefault();
  407. var index = $(this).parents('.riva-toggle-tab').index();
  408. $elems.hide().eq(index + 1).show();
  409. $links.removeClass('active');
  410. $links.eq(index + 1).addClass('active');
  411. });
  412. $(this).find('.riva-prev-tab').click(function(e) {
  413. e.preventDefault();
  414. var index = $(this).parents('.riva-toggle-tab').index();
  415. $elems.hide().eq(index - 1).show();
  416. $links.removeClass('active');
  417. $links.eq(index - 1).addClass('active');
  418. });
  419. })
  420. }
  421. })( jQuery );