daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest Oct 17th, 2018 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. "use strict";
  2. (function($){
  3. $(function(){
  4. // Сам Popup
  5. var popup =     '<div class="pmc">'+
  6. '<div class="pmc_close"></div>'+
  7. '<div class="popup_container">'+
  8. '<div class="popup">'+
  9. '<div class="popup__navigation">'+
  10. '<div class="popup__navigation__search">'+
  11. '<input class="search_input" type="text" name="search_input" value="" placeholder="Ваш поисковый запрос" autofocus="autofocus">'+
  12. '</div>'+
  13. '<div class="popup_close" title="Закрыть">X</div>'+
  14. '</div>'+
  15. '<div class="popup__search">'+
  16. '<div class="popup__search__block">'+
  17. '<div class="popup__search_text">'+
  18. '<h2>Где искать?</h2>'+
  19. '</div>'+
  20. '</div>'+
  21. '<div class="popup__search__block">'+
  22. '<div class="popup__search_select">'+
  23. '<div class="block_label">'+
  24. '<div id="bli_1" class="block_label__item">'+
  25. '<label class="label_select_fild">'+
  26. '<span class="label_select_fild__text">№ Брони</span>'+
  27. '<input style="display:none;" type="radio" name="field" value="id">'+
  28. '</label>'+
  29. '</div>'+
  30. '<div id="bli_2" class="block_label__item">'+
  31. '<label class="label_select_fild">'+
  32. '<span class="label_select_fild__text">Дата</span>'+
  33. '<input style="display:none;" type="radio" name="field" value="date">'+
  34. '</label>'+
  35. '</div>'+
  36. '<div id="bli_3" class="block_label__item">'+
  37. '<label class="label_select_fild">'+
  38. '<span class="label_select_fild__text">Дилер</span>'+
  39. '<input style="display:none;" type="radio" name="field" value="dealer">'+
  40. '</label>'+
  41. '</div>'+
  42. '</div>'+
  43. '<div class="block_label">'+
  44. '<div id="bli_4" class="block_label__item">'+
  45. '<label class="label_select_fild">'+
  46. '<span class="label_select_fild__text">Менеджер</span>'+
  47. '<input style="display:none;" type="radio" name="field" value=manager>'+
  48. '</label>'+
  49. '</div>'+
  50. '<div id="bli_5" class="block_label__item">'+
  51. '<label class="label_select_fild">'+
  52. '<span class="label_select_fild__text">Бренд</span>'+
  53. '<input style="display:none;" type="radio" name="field" value="brend">'+
  54. '</label>'+
  55. '</div>'+
  56. '</div>'+
  57. '</div>'+
  58. '<div class="popup__search_select">'+
  59. '<div class="block_label">'+
  60. '<div id="bli_7" class="block_label__item">'+
  61. '<label class="label_select_fild">'+
  62. '<span class="label_select_fild__text">ИНН ЮЛ</span>'+
  63. '<input style="display:none;" type="radio" name="field" value="ur_inn">'+
  64. '</label>'+
  65. '</div>'+
  66. '<div id="bli_8" class="block_label__item">'+
  67. '<label class="label_select_fild">'+
  68. '<span class="label_select_fild__text">Адрес</span>'+
  69. '<input style="display:none;" type="radio" name="field" value="address" checked="checked">'+
  70. '</label>'+
  71. '</div>'+
  72. '<div id="bli_9" class="block_label__item">'+
  73. '<label class="label_select_fild">'+
  74. '<span class="label_select_fild__text">Оборудование</span>'+
  75. '<input style="display:none;" type="radio" name="field" value="tool">'+
  76. '</label>'+
  77. '</div>'+
  78. '</div>'+
  79. '<div class="block_label">'+
  80. '<div id="bli_10" class="block_label__item">'+
  81. '<label class="label_select_fild">'+
  82. '<span class="label_select_fild__text">Комментарий к проекту</span>'+
  83. '<input style="display:none;" type="radio" name="field" value="comment_by_project">'+
  84. '</label>'+
  85. '</div>'+
  86. '<div id="bli_11" class="block_label__item">'+
  87. '<label class="label_select_fild">'+
  88. '<span class="label_select_fild__text">Не учитывать</span>'+
  89. '<input style="display:none;" type="radio" name="field" value="none">'+
  90. '</label>'+
  91. '</div>'+
  92. '</div>'+
  93. '</div>'+
  94. '</div>'+
  95. '<div class="popup__search__block">'+
  96. '<div class="popup__search_text">'+
  97. '<h2>Учитавать статус?</h2>'+
  98. '</div>'+
  99. '</div>'+
  100. '<div class="popup__search__block">'+
  101. '<div class="popup__search_select">'+
  102. '<div class="block_label">'+
  103. '<div id="bli_12" class="block_label__item">'+
  104. '<label class="label_select_fild">'+
  105. '<span class="label_select_fild__text">Не учитывать</span>'+
  106. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="0" checked="checked">'+
  107. '</label>'+
  108. '</div>'+
  109. '<div id="bli_13" class="block_label__item">'+
  110. '<label class="label_select_fild">'+
  111. '<span class="label_select_fild__text">Не обработано</span>'+
  112. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="1">'+
  113. '</label>'+
  114. '</div>'+
  115. '</div>'+
  116. '<div class="block_label">'+
  117. '<div id="bli_14" class="block_label__item">'+
  118. '<label class="label_select_fild">'+
  119. '<span class="label_select_fild__text">Авторизовано</span>'+
  120. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="2">'+
  121. '</label>'+
  122. '</div>'+
  123. '<div id="bli_15" class="block_label__item">'+
  124. '<label class="label_select_fild">'+
  125. '<span class="label_select_fild__text">Не авторизовано</span>'+
  126. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="3">'+
  127. '</label>'+
  128. '</div>'+
  129. '</div>'+
  130. '<div class="block_label">'+
  131. '<div id="bli_16" class="block_label__item">'+
  132. '<label class="label_select_fild">'+
  133. '<span class="label_select_fild__text">Реализовано</span>'+
  134. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="4">'+
  135. '</label>'+
  136. '</div>'+
  137. '<div id="bli_17" class="block_label__item">'+
  138. '<label class="label_select_fild">'+
  139. '<span class="label_select_fild__text">Не реализовано</span>'+
  140. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="5">'+
  141. '</label>'+
  142. '</div>'+
  143. '</div>'+
  144. '</div>'+
  145. '<div class="popup__search_select">'+
  146. '<div class="block_label">'+
  147. '<div id="bli_18" class="block_label__item">'+
  148. '<label class="label_select_fild">'+
  149. '<span class="label_select_fild__text">Авторизация прекращена</span>'+
  150. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="6">'+
  151. '</label>'+
  152. '</div>'+
  153. '<div id="bli_19" class="block_label__item">'+
  154. '<label class="label_select_fild">'+
  155. '<span class="label_select_fild__text">Авторизация продлена</span>'+
  156. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="7">'+
  157. '</label>'+
  158. '</div>'+
  159. '</div>'+
  160. '<div class="block_label">'+
  161. '<div id="bli_20" class="block_label__item">'+
  162. '<label class="label_select_fild">'+
  163. '<span class="label_select_fild__text">Авторизация просрочена</span>'+
  164. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="8">'+
  165. '</label>'+
  166. '</div>'+
  167. '<div id="bli_21" class="block_label__item">'+
  168. '<label class="label_select_fild">'+
  169. '<span class="label_select_fild__text">Запрос актуальности</span>'+
  170. '<input class="select_status" style="display:none;" type="radio" name="select_status" value="9">'+
  171. '</label>'+
  172. '</div>'+
  173. '</div>'+
  174. '</div>'+
  175. '</div>'+
  176. '<div class="popup__search__block">'+
  177. '<div class="popup__search_text">'+
  178. '<h2>Порядок вывода?</h2>'+
  179. '</div>'+
  180. '</div>'+
  181. '<div class="popup__search__block">'+
  182. '<div class="popup__search_select">'+
  183. '<div class="block_label">'+
  184. '<div id="bli_22" class="block_label__item">'+
  185. '<label class="label_select_fild">'+
  186. '<span class="label_select_fild__text">Возрастание</span>'+
  187. '<input style="display:none;" type="radio" name="sort" value="asc">'+
  188. '</label>'+
  189. '</div>'+
  190. '<div id="bli_23" class="block_label__item">'+
  191. '<label class="label_select_fild">'+
  192. '<span class="label_select_fild__text">Убывание</span>'+
  193. '<input style="display:none;" type="radio" name="sort" value="desc" checked="checked">'+
  194. '</label>'+
  195. '</div>'+
  196. '</div>'+
  197. '</div>'+
  198. '</div>'+
  199. '</div>'+
  200. '<div class="popup__footer">'+
  201. '<div class="popup__footer__item">'+
  202. '<input class="popup__footer__submit" type="button" name="popup__footer__submit" value="Найти">'+
  203. '</div>'+
  204. '</div>'+
  205. '</div>'+
  206. '</div>'+
  207. '</div>';
  208. var elem;
  209. $('body').on('mouseover', '.search_btn', function (event) {
  210. // Добавляем блюр
  211. $('main').removeClass('custom_no_blur').addClass('custom_blur');
  212. // Если не создан елемент с классом .pmc - создать, иначе показать
  213. if ($('.pmc').length<1){$('footer').after(popup);$('.pmc').css({'display':'block'});}
  214. else{$('.pmc').css({'display':'block'});}
  215. $('.popup').fadeIn(800);
  216. // Подсветим checked
  217. $('.block_label__item input[checked="checked"]:radio').parent().parent().css({'background-color':'rgba(0, 128, 0, 0.3)', 'border-radius':'5px', 'color':'darkgreen'});
  218. // выделяем при наведении
  219. $('.block_label__item').on('mouseover', function() {
  220. $(this).css({'background-color':'rgba(0, 128, 0, 0.3)', 'border-radius':'5px', 'color':'darkgreen'});
  221. });
  222. //снимаем выделение только у не выбранных
  223. $('.block_label__item').on('mouseout', function() {
  224. elem = $(this).children().children();
  225. if ($(elem[1]).attr('checked') != 'checked'){
  226. $(this).css({'background-color':'white', 'color':'#ccc'});
  227. }
  228. });
  229. $('.block_label__item').on('click', function(event) {
  230. elem = $(this).children().children();
  231. var name = $(elem[1]).attr('name');
  232. var mas_input = $('.block_label__item input[name="'+name+'"]');
  233. for(let i=0; i<mas_input.length;i++){
  234. $(mas_input[i]).attr('checked', false);
  235. }
  236. $('.block_label__item input[name="'+name+'"]').parent().parent().css({'background-color':'white', 'color':'#ccc'});
  237. $(elem[1]).attr('checked', true);
  238. $('.block_label__item input[checked="checked"]:radio').parent().parent().css({'background-color':'rgba(0, 128, 0, 0.3)', 'border-radius':'5px', 'color':'darkgreen'});
  239. });
  240. // Если нажата клавиша Enter начать поиск
  241. $('.search_input').keydown(function(event){
  242. if(event.keyCode===13){
  243. var input=$('.block_label__item input[checked="checked"]:radio');
  244. var searchStr=$('.search_input').val();
  245. var searchField=$(input[0]).val();
  246. var searchStatusId=$(input[1]).val();
  247. var searchSort=$(input[2]).val();
  248. if (searchField=='none'&searchStatusId=='0'){
  249. $('main').removeClass('custom_blur').addClass('custom_no_blur');
  250. $('.popup').fadeOut(800,function(){$('.pmc').css({'display':'none'});});
  251. $('.loader-container').fadeIn(300);
  252. let url = '/project/searchAjax/';
  253. $.post(url,{searchStr:searchStr,searchField:searchField,searchStatusId:searchStatusId,searchSort:searchSort},function(data){
  254. $('.blocks .table tbody').html(data);
  255. $('.pagination').hide();
  256. $('.loader-container').fadeOut(300,function(){$('.blocks .table tbody').ready().ajaxComplete();});
  257. });
  258. }else{
  259. if(searchStr.length>2){
  260. $('main').removeClass('custom_blur').addClass('custom_no_blur');
  261. $('.popup').fadeOut(800,function(){$('.pmc').css({'display':'none'});});
  262. $('.loader-container').fadeIn(300);
  263. let url = '/project/searchAjax/';
  264. $.post(url,{searchStr:searchStr,searchField:searchField,searchStatusId:searchStatusId,searchSort:searchSort},function(data){
  265. $('.blocks .table tbody').html(data);
  266. $('.pagination').hide();
  267. $('.loader-container').fadeOut(300,function(){$('.blocks .table tbody').ready().ajaxComplete();});
  268. });
  269. }else{alert('Запрос должен быть не менее 3-х символов!');}
  270. }
  271. }
  272. });
  273. // Если нажата кнопка поиска - начать поиск
  274. $('.popup__footer__submit').on('click',function(){
  275. $('main').removeClass('custom_blur').addClass('custom_no_blur');
  276. $('.popup').fadeOut(800,function(){$('.pmc').css({'display':'none'});});
  277. $('.loader-container').fadeIn(300);
  278. let input=$('.block_label__item input[checked="checked"]:radio');
  279. let searchStr=$('.search_input').val();
  280. let searchField=$(input[0]).val();
  281. let searchStatusId=$(input[1]).val();
  282. let searchSort=$(input[2]).val();
  283. let url = '/project/searchAjax/';
  284. $.post(url,{searchStr:searchStr,searchField:searchField,searchStatusId:searchStatusId,searchSort:searchSort},function(data){
  285. $('.blocks .table tbody').html(data);
  286. $('.pagination').hide();
  287. $('.loader-container').fadeOut(300,function(){$('.blocks .table tbody').ready().ajaxComplete();});
  288. });
  289. });
  290. $('.pmc_close').on('click', function (){
  291. $('main').removeClass('custom_blur').addClass('custom_no_blur');
  292. $('.popup').fadeOut(800, function () {
  293. $('.pmc').css({'display':'none'});
  294. });
  295. });
  296. $('.popup_close').on('click', function (){
  297. $('main').removeClass('custom_blur').addClass('custom_no_blur');
  298. $('.popup').fadeOut(800, function () {
  299. $('.pmc').css({'display':'none'});
  300. });
  301. });
  302. });
  303. });
  304. })(jQuery);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top