Advertisement
Guest User

Untitled

a guest
Feb 24th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.58 KB | None | 0 0
  1. // The purpose of this code is to fix the height of overflow: auto blocks, because some browsers can't figure it out for themselves.
  2. function smf_codeBoxFix()
  3. {
  4. var codeFix = document.getElementsByTagName('code');
  5. for (var i = codeFix.length - 1; i >= 0; i--)
  6. {
  7. if (is_webkit && codeFix[i].offsetHeight < 20)
  8. codeFix[i].style.height = (codeFix[i].offsetHeight + 20) + 'px';
  9.  
  10. else if (is_ff && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0))
  11. codeFix[i].style.overflow = 'scroll';
  12.  
  13. else if ('currentStyle' in codeFix[i] && codeFix[i].currentStyle.overflow == 'auto' && (codeFix[i].currentStyle.height == '' || codeFix[i].currentStyle.height == 'auto') && (codeFix[i].scrollWidth > codeFix[i].clientWidth || codeFix[i].clientWidth == 0) && (codeFix[i].offsetHeight != 0))
  14. codeFix[i].style.height = (codeFix[i].offsetHeight + 24) + 'px';
  15. }
  16. }
  17.  
  18. // Add a fix for code stuff?
  19. if ((is_ie && !is_ie4) || is_webkit || is_ff)
  20. addLoadEvent(smf_codeBoxFix);
  21.  
  22. // Toggles the element height and width styles of an image.
  23. function smc_toggleImageDimensions()
  24. {
  25. var oImages = document.getElementsByTagName('IMG');
  26. for (oImage in oImages)
  27. {
  28. // Not a resized image? Skip it.
  29. if (oImages[oImage].className == undefined || oImages[oImage].className.indexOf('bbc_img resized') == -1)
  30. continue;
  31.  
  32. oImages[oImage].style.cursor = 'pointer';
  33. oImages[oImage].onclick = function() {
  34. this.style.width = this.style.height = this.style.width == 'auto' ? null : 'auto';
  35. };
  36. }
  37. }
  38.  
  39. // Add a load event for the function above.
  40. addLoadEvent(smc_toggleImageDimensions);
  41.  
  42. // Adds a button to a certain button strip.
  43. function smf_addButton(sButtonStripId, bUseImage, oOptions)
  44. {
  45. var oButtonStrip = document.getElementById(sButtonStripId);
  46. var aItems = oButtonStrip.getElementsByTagName('span');
  47.  
  48. // Remove the 'last' class from the last item.
  49. if (aItems.length > 0)
  50. {
  51. var oLastSpan = aItems[aItems.length - 1];
  52. oLastSpan.className = oLastSpan.className.replace(/\s*last/, 'position_holder');
  53. }
  54.  
  55. // Add the button.
  56. var oButtonStripList = oButtonStrip.getElementsByTagName('ul')[0];
  57. var oNewButton = document.createElement('li');
  58. setInnerHTML(oNewButton, '<a href="' + oOptions.sUrl + '" ' + ('sCustom' in oOptions ? oOptions.sCustom : '') + '><span class="last"' + ('sId' in oOptions ? ' id="' + oOptions.sId + '"': '') + '>' + oOptions.sText + '</span></a>');
  59.  
  60. oButtonStripList.appendChild(oNewButton);
  61. }
  62.  
  63. // Adds hover events to list items. Used for a versions of IE that don't support this by default.
  64. var smf_addListItemHoverEvents = function()
  65. {
  66. var cssRule, newSelector;
  67.  
  68. // Add a rule for the list item hover event to every stylesheet.
  69. for (var iStyleSheet = 0; iStyleSheet < document.styleSheets.length; iStyleSheet ++)
  70. for (var iRule = 0; iRule < document.styleSheets[iStyleSheet].rules.length; iRule ++)
  71. {
  72. oCssRule = document.styleSheets[iStyleSheet].rules[iRule];
  73. if (oCssRule.selectorText.indexOf('LI:hover') != -1)
  74. {
  75. sNewSelector = oCssRule.selectorText.replace(/LI:hover/gi, 'LI.iehover');
  76. document.styleSheets[iStyleSheet].addRule(sNewSelector, oCssRule.style.cssText);
  77. }
  78. }
  79.  
  80. // Now add handling for these hover events.
  81. var oListItems = document.getElementsByTagName('LI');
  82. for (oListItem in oListItems)
  83. {
  84. oListItems[oListItem].onmouseover = function() {
  85. this.className += ' iehover';
  86. };
  87.  
  88. oListItems[oListItem].onmouseout = function() {
  89. this.className = this.className.replace(new RegExp(' iehover\\b'), '');
  90. };
  91. }
  92. }
  93.  
  94. // Add hover events to list items if the browser requires it.
  95. if (is_ie7down && 'attachEvent' in window)
  96. window.attachEvent('onload', smf_addListItemHoverEvents);
  97.  
  98.  
  99. $(document).ready(function(){
  100. $('[data-toggle="tooltip"]').tooltip();
  101. });
  102.  
  103. $(document).ready(function() {
  104. // Show or hide the sticky footer button
  105. $(window).scroll(function() {
  106. if ($(this).scrollTop() > 200) {
  107. $(".go-top").fadeIn(200);
  108. } else {
  109. $(".go-top").fadeOut(200);
  110. }
  111. });
  112.  
  113. // Animate the scroll to top
  114. $(".go-top").click(function(event) {
  115. event.preventDefault();
  116.  
  117. $("html, body").animate({scrollTop: 0}, 300);
  118. })
  119. });
  120.  
  121. jQuery(document).ready(function(){
  122. jQuery(".increment_qty").click(function() {
  123. var oldVal = jQuery(this).parent().find("input").val();
  124. if ( parseFloat(oldVal) >= 1 ) {
  125. var newVal = parseFloat(oldVal) + 1;
  126. jQuery(this).parent().find("input").val(newVal);
  127. }
  128. });
  129.  
  130. jQuery(".decrement_qty").click(function() {
  131. var oldVal = jQuery(this).parent().find("input").val();
  132. if ( parseFloat(oldVal) >= 2 ) {
  133. var newVal = parseFloat(oldVal) - 1;
  134. jQuery(this).parent().find("input").val(newVal);
  135. }
  136. });
  137. });
  138.  
  139. $(document).ready(function() {
  140. $('.counter').each(function() {
  141. var $this = $(this),
  142. countTo = $this.attr('data-count');
  143.  
  144. $({ countNum: $this.text()}).animate({
  145. countNum: countTo
  146. },
  147.  
  148. {
  149.  
  150. duration: 4000,
  151. easing:'linear',
  152. step: function() {
  153. $this.text(Math.floor(this.countNum));
  154. },
  155. complete: function() {
  156. $this.text(this.countNum);
  157. //alert('finished');
  158. }
  159.  
  160. });
  161. });
  162. });
  163.  
  164. $(function () {
  165. $('a[href="#search"]').on('click', function(event) {
  166. event.preventDefault();
  167. $('#search').addClass('open');
  168. $('#search > form > input[type="search"]').focus();
  169. });
  170.  
  171. $('#search, #search button.searchclose').on('click keyup', function(event) {
  172. if (event.target == this || event.target.className == 'searchclose' || event.keyCode == 27) {
  173. $(this).removeClass('open');
  174. }
  175. });
  176. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement