Guest User

Untitled

a guest
Jan 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.61 KB | None | 0 0
  1. $(document).ready(function () {
  2.  
  3. //25.12.2018
  4. var minimized_elements = $('p.goods-text-desc');
  5. minimized_elements.each(function () {
  6. var t = $(this).text();
  7. if (t.length < 1300)
  8. return;
  9.  
  10. $(this).html(
  11. t.slice(0, 1300) + '<span>... </span><a href="#" class="more">Читать далее</a>' +
  12. '<span style="display:none;">' + t.slice(1300, t.length) + ' <a href="#" class="less">Скрыть текст</a></span>'
  13. );
  14.  
  15. });
  16.  
  17. $('a.more', minimized_elements).click(function (event) {
  18. event.preventDefault();
  19. $(this).hide().prev().hide();
  20. $(this).next().show();
  21. });
  22.  
  23. $('a.less', minimized_elements).click(function (event) {
  24. event.preventDefault();
  25. $(this).parent().hide().prev().show().prev().show();
  26. });
  27.  
  28. /*25.12.2018 end */
  29. /*FOR INDEX PAGE 20.01.2019*/
  30. initSlider('.shop-item .single-item');
  31. initSlider('.shops-wrap_card .carusel-wrap .single-item');
  32. initSlider('.shops-wrap_card>.single-item');
  33.  
  34. /*FOR SHOPS PAGE 20.01.2019*/
  35.  
  36.  
  37. $(" #number ").inputmask("+382-99-999-999");
  38. $('#id_of_page_container').pajinate();
  39.  
  40. /*Скрыть PopUp при загрузке страницы*/
  41. PopUpHide();
  42. removeConfirmPopup();
  43.  
  44. $("#btnShow").click(function (e) {
  45. e.preventDefault();
  46. $("#modal").show();
  47. $(".popup_overlay").show();
  48. setTimeout(removeConfirmPopup, 3000);
  49. });
  50.  
  51.  
  52. $('.image-upload-wrap').bind('dragover', function () {
  53. $('.image-upload-wrap').addClass('image-dropping');
  54. });
  55. $('.image-upload-wrap').bind('dragleave', function () {
  56. $('.image-upload-wrap').removeClass('image-dropping');
  57. });
  58.  
  59. $("#search").focus(function () {
  60. $(".search-box").addClass("border-searching");
  61. $(".search-icon").addClass("si-rotate");
  62. });
  63. $("#search").blur(function () {
  64. $(".search-box").removeClass("border-searching");
  65. $(".search-icon").removeClass("si-rotate");
  66. });
  67. $("#search").keyup(function () {
  68. if ($(this).val().length > 0) {
  69. $(".go-icon").addClass("go-in");
  70. } else {
  71. $(".go-icon").removeClass("go-in");
  72. }
  73. });
  74. $(".go-icon").click(function () {
  75. $(".search-form").submit();
  76. });
  77.  
  78. modalRatingRespond();
  79.  
  80. var offset, i;
  81. if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
  82. offset = 3;
  83. } else {
  84. offset = 12;
  85. }
  86.  
  87. $('#more-btn').on('click', function (e) {
  88. e.preventDefault();
  89. $.ajax({
  90. url: './data.html',
  91. type: 'POST',
  92. data: {
  93. offset: offset
  94. },
  95. success: function (data) {
  96. if (data) {
  97. for (i = 0; i < offset; i++) {
  98. $('#list-container').append(data);
  99. }
  100. $('.shop-item.uploaded').addClass("hidden").viewportChecker({
  101. classToAdd: 'visible animated fadeInLeft',
  102. offset: 100
  103. });
  104. initSlider('.single-item.ajax_added');
  105. $('#list-container').find('.ajax_added').removeClass('ajax_added');
  106. }
  107.  
  108. }
  109. })
  110. });
  111. });
  112. function initSlider(name) {
  113. $(name).not('.slick-initialized').slick({
  114. dots: false,
  115. infinite: true,
  116. speed: 700,
  117. slidesToScroll: 1,
  118. arrows: true
  119. });
  120. }
  121. function readURL(input) {
  122. if (input.files && input.files[0]) {
  123.  
  124. var reader = new FileReader();
  125.  
  126. reader.onload = function (e) {
  127. $('.image-upload-wrap').hide();
  128.  
  129. $('.file-upload-image').attr('src', e.target.result);
  130. $('.file-upload-content').show();
  131.  
  132. $('.image-title').html(input.files[0].name);
  133. };
  134.  
  135. reader.readAsDataURL(input.files[0]);
  136.  
  137. } else {
  138. removeUpload();
  139. }
  140. }
  141. function removeUpload() {
  142. var cloned = $('.file-upload-input').clone();
  143. $('.file-upload-input').replaceWith(cloned);
  144. $('.file-upload-content').hide();
  145. $('.image-upload-wrap').show();
  146. }
  147. /*Функция отображения PopUp Main*/
  148. function PopUpShowMainPage() {
  149. $("#popup1").show();
  150. $(".popup_overlay").show();
  151. }
  152. /*Функция отображения PopUp Shop*/
  153. function PopUpShowShopPage() {
  154. $('#popup2').show();
  155. $(".popup_overlay").show();
  156. initSlider('#popup2>.main-goods-wrap>.single-item');
  157. initSlider('#popup2 .slide-goods-wrap>.single-item');
  158. }
  159. //Функция скрытия PopUp
  160. function PopUpHide() {
  161. $("#popup1").hide();
  162. $("#popup2").hide();/*25.12.2018*/
  163. $(".popup_overlay").hide();
  164. }
  165. function removeConfirmPopup() {
  166. $("#modal").hide();
  167. $(".popup_overlay").hide();
  168. }
  169. function modalRatingRespond() {
  170. var starWidth = 20; //width of one rating star in px
  171. var averageWidth;
  172. var userMark;
  173. $('.review_rating').mouseenter(function () {
  174. averageWidth = $(this).find('.current_rating').width();
  175. $(this).css('cursor', 'pointer');
  176. }).mousemove(function (evt) {
  177. userMark = Math.ceil((evt.pageX - $('.review_rating').offset().left) / starWidth);
  178. $(this).find('.current_rating').width(userMark * starWidth);
  179. }).click(function () {
  180. averageWidth = Math.round(userMark) * starWidth;
  181. //вот этот кусок записывает в скрытый инпут который с name = comment_mark
  182. $('input[name=comment_mark]').val(userMark);
  183. }).mouseleave(function () {
  184. $(this).find('.current_rating').width(averageWidth);
  185. });
  186. }
Add Comment
Please, Sign In to add comment