/html/wp-content/themes/FLER/ddpanel/shortcodes/js/shortcodes.js

https://github.com/ideahackdev/local · JavaScript · 308 lines · 149 code · 116 blank · 43 comment · 21 complexity · 1a7f35596a7a90f0aee6381f0536861a MD5 · raw file

  1. (function($){
  2. $.fn.extend({
  3. DDTooltip: function() {
  4. //our main container
  5. var mainCont = this;
  6. //when hovered
  7. this.hover(function() {
  8. mainCont.children('span').children('span').css({ display: 'block' });
  9. mainCont.children('span').stop().css({ display: 'block', opacity: 0, bottom: '30px' }).animate({ opacity: 1, bottom: '40px' }, 200);
  10. }, function() {
  11. mainCont.children('span').stop().animate({ opacity: 0, bottom: '50px' }, 200, function() {
  12. jQuery(this).hide();
  13. });
  14. });
  15. },
  16. closeNotification: function() {
  17. //our main container
  18. var mainCont = this;
  19. //when clicked
  20. this.children('span.close').click(function() {
  21. mainCont.slideUp(300);
  22. });
  23. },
  24. ddImageSlider: function() {
  25. //main container
  26. var mainCont = this;
  27. //main height and width
  28. var slideHeight = mainCont.children('.ddimage-slider-images').height();
  29. var slideWidth = mainCont.children('.ddimage-slider-images').width();
  30. //lets fix the images and add the current class to the first one
  31. var i = 1;
  32. mainCont.children('.ddimage-slider-images').children('li').each(function() {
  33. if(i === 1) { jQuery(this).addClass('current').css({ display: 'block', left: 0 }).addClass('ddslide_'+i); }
  34. else { jQuery(this).css({ display: 'block', left: slideWidth }).addClass('ddslide_'+i); }
  35. mainCont.children('.ddimage-slider-selector').append('<li></li>');
  36. i++;
  37. });
  38. //lets set the left od our selector
  39. var totalSel = mainCont.children('.ddimage-slider-selector').children('li:not(.border)').length;
  40. var mainSelWidth = ((totalSel * 11));
  41. var selLeft = (slideWidth / 2) - (mainSelWidth / 2);
  42. mainCont.children('.ddimage-slider-selector').css({ left: selLeft });
  43. //let's set up the selectors
  44. var i = 1;
  45. mainCont.children('.ddimage-slider-selector').children('li:not(.border)').each(function() {
  46. if(i === 1) { jQuery(this).addClass('ddsel_'+i).addClass('current'); }
  47. else { jQuery(this).addClass('ddsel_'+i); }
  48. i++;
  49. });
  50. //when clicking in a next arrow
  51. mainCont.children('.arrow-right').click(function() {
  52. mainCont.ddImageSlideCallNext();
  53. });
  54. //when clicking in a previous arrow
  55. mainCont.children('.arrow-left').click(function() {
  56. mainCont.ddImageSlideCallPrev();
  57. });
  58. //when selector is clicked
  59. mainCont.children('.ddimage-slider-selector').children('li:not(.border)').click(function() {
  60. var newSlide = jQuery(this).attr('class').split('_');
  61. var slideCur = jQuery(this).attr('class').split(' ');
  62. if(slideCur[1] != 'current') {
  63. mainCont.ddImageSlideCallSlide(newSlide[1]);
  64. }
  65. });
  66. },
  67. ddImageSlideCallNext: function() {
  68. //main container
  69. var mainCont = this;
  70. //main height and width
  71. var slideHeight = mainCont.children('.ddimage-slider-images').height();
  72. var slideWidth = mainCont.children('.ddimage-slider-images').width();
  73. //find next and current
  74. var current = mainCont.children('.ddimage-slider-images').children('li.current');
  75. var next = current.next();
  76. //if next does not exist select the first slide
  77. if(next.length == 0) { next = mainCont.children('.ddimage-slider-images').children('li:first'); }
  78. //find next and current selectors
  79. var currentSel = mainCont.children('.ddimage-slider-selector').children('li.current');
  80. var nextSel = currentSel.next();
  81. //if next does not exist select the first selector
  82. if(nextSel.length == 0) { nextSel = mainCont.children('.ddimage-slider-selector').children('li:not(.border):first'); }
  83. //animates the next one
  84. next.css({ left: slideWidth }).stop().animate({ left: 0 }, 200,function() {
  85. jQuery(this).addClass('current');
  86. currentSel.removeClass('current');
  87. });
  88. //animates the current one
  89. current.stop().animate({ left: -slideWidth }, 200,function() {
  90. jQuery(this).removeClass('current');
  91. nextSel.addClass('current');
  92. });
  93. },
  94. ddImageSlideCallPrev: function() {
  95. //main container
  96. var mainCont = this;
  97. //main height and width
  98. var slideHeight = mainCont.children('.ddimage-slider-images').height();
  99. var slideWidth = mainCont.children('.ddimage-slider-images').width();
  100. //find next and current
  101. var current = mainCont.children('.ddimage-slider-images').children('li.current');
  102. var prev = current.prev();
  103. //if next does not exist select the first slide
  104. if(prev.length == 0) { prev = mainCont.children('.ddimage-slider-images').children('li:last'); }
  105. //find next and current selector
  106. var currentSel = mainCont.children('.ddimage-slider-selector').children('li.current');
  107. var prevSel = currentSel.prev(':not(.border)');
  108. //if next does not exist select the first selector
  109. if(prevSel.length == 0) { prevSel = mainCont.children('.ddimage-slider-selector').children('li:not(.border):last'); }
  110. //animates the next one
  111. prev.css({ left: -slideWidth }).stop().animate({ left: 0 }, 200,function() {
  112. jQuery(this).addClass('current');
  113. prevSel.addClass('current');
  114. });
  115. //animates the current one
  116. current.stop().animate({ left: slideWidth }, 200,function() {
  117. jQuery(this).removeClass('current');
  118. currentSel.removeClass('current');
  119. });
  120. },
  121. ddImageSlideCallSlide: function(num) {
  122. //main container
  123. var mainCont = this;
  124. //main height and width
  125. var slideHeight = mainCont.children('.ddimage-slider-images').height();
  126. var slideWidth = mainCont.children('.ddimage-slider-images').width();
  127. //find next and current
  128. var current = mainCont.children('.ddimage-slider-images').children('li.current');
  129. var next = mainCont.children('.ddimage-slider-images').children('li.ddslide_'+num);
  130. //find next and current selectors
  131. var currentSel = mainCont.children('.ddimage-slider-selector').children('li.current');
  132. var nextSel = mainCont.children('.ddimage-slider-selector').children('li.ddsel_'+num);
  133. //animates the next one
  134. next.css({ left: slideWidth }).stop().animate({ left: 0 }, 200,function() {
  135. jQuery(this).addClass('current');
  136. currentSel.removeClass('current');
  137. });
  138. //animates the current one
  139. current.stop().animate({ left: -slideWidth }, 200,function() {
  140. jQuery(this).removeClass('current');
  141. nextSel.addClass('current');
  142. });
  143. },
  144. ddToggle: function() {
  145. //main container
  146. var mainCont = this;
  147. if(mainCont.attr('class') == 'ddtoggle-open') { mainCont.children('.toggle-content').css({ 'display': 'block' }) }
  148. //when clicked
  149. mainCont.children('.toggle-handler').click(function() {
  150. if(mainCont.children('.toggle-content').css('display') == 'none') {
  151. mainCont.removeClass('ddtoggle-closed').addClass('ddtoggle-open');
  152. mainCont.children('.toggle-content').slideDown(200);
  153. } else {
  154. mainCont.children('.toggle-content').slideUp(200);
  155. mainCont.removeClass('ddtoggle-open').addClass('ddtoggle-closed');
  156. }
  157. });
  158. },
  159. ddTabbed: function() {
  160. //main container
  161. var mainCont = this;
  162. //categorizes our tabs
  163. var i = 1;
  164. mainCont.children('.tabs').children('li').each(function() {
  165. jQuery(this).addClass('tab_'+i);
  166. i++;
  167. });
  168. //categorizes our tabbed
  169. var i = 1;
  170. mainCont.children('.tabbed').children('li').each(function() {
  171. jQuery(this).addClass('tabbed_'+i);
  172. i++;
  173. });
  174. //set up the current tab and tabbed
  175. mainCont.children('.tabs').children('li:first').addClass('current');
  176. mainCont.children('.tabbed').children('li:first').addClass('current');
  177. //when user clicks a tab
  178. mainCont.children('.tabs').children('li').click(function() {
  179. var tempClass = jQuery(this).attr('class').split(' ');
  180. if(tempClass[1] != 'current') {
  181. var myClass = tempClass[0].split('_');
  182. //removes the current
  183. mainCont.children('.tabbed').children('li.current').removeClass('current');
  184. mainCont.children('.tabs').children('li.current').removeClass('current');
  185. //adds a new current
  186. mainCont.children('.tabbed').children('li.tabbed_'+myClass[1]).addClass('current');
  187. mainCont.children('.tabs').children('li.tab_'+myClass[1]).addClass('current');
  188. }
  189. });
  190. }
  191. });
  192. })(jQuery);