Advertisement
Guest User

Untitled

a guest
Sep 25th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.00 KB | None | 0 0
  1. $.fn.textWidth = function(text, font) {
  2.  
  3. if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>').hide().appendTo(document.body);
  4. $.fn.textWidth.fakeEl.text(text || this.val() || this.text()).css('font', font || this.css('font'));
  5. return $.fn.textWidth.fakeEl.width();
  6. };
  7.  
  8. $(function(){
  9. $('#filter_price_range_from, #filter_price_range_to').keyup(function(){
  10. var value = $(this).val();
  11. $(this).val($(this).val().replace(/[^0-9]/g, ''));
  12. value = $(this).val();
  13. var in_width = $.fn.textWidth(value, '13px Arial');
  14. $(this).width(in_width+12);
  15. })
  16. $('#filter_price_range_from, #filter_price_range_to').keyup();
  17. })
  18.  
  19.  
  20.  
  21.  
  22. app_shop.run(function(){
  23. $('._mobile #menu_filter .filter_header').live('click',function(){
  24. $this = $(this);
  25. $this.next().slideToggle(function(){
  26. if($this.next().is(':visible')){
  27. $this.addClass('openList');
  28. }else{
  29. $this.removeClass('openList');
  30. }
  31. });
  32. });
  33.  
  34. app_shop.vars.sendFilter = false;
  35. $('#menu_filter div.filter_item.list_type input, #menu_filter div.filter_item.dual_type input').click(function(){
  36. app_shop.vars.sendFilter = true;
  37. })
  38.  
  39.  
  40. $('._mobile #filter_form').live('submit',function(){
  41. if(!app_shop.vars.sendFilter){
  42. $('html').removeClass('filter_on');
  43. }
  44.  
  45. return app_shop.vars.sendFilter;
  46. });
  47.  
  48. $('#select_top_sort').removeAttr('onchange');
  49. $('#select_top_sort').live('change',function(){
  50.  
  51.  
  52. if(app_shop.vars.view == 1){
  53. $.getJSON('/settings.php?sort_order=' + $(this).val());
  54. app_shop.vars.sendFilter = true;
  55. }else{
  56. $(this).parents('form').submit();
  57. }
  58.  
  59.  
  60. })
  61.  
  62. },'all','#menu_filter');
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77. var xpress_txt = [];
  78. xpress_txt["zipcode_invalid"] = <iai:variable vid="xpress__1" description="Podany kod pocztowy jest nieprawidłowy." />;
  79. xpress_txt["localization"] = <iai:variable vid="xpress__2" description="Lokalizacja" />;
  80. xpress_txt["courier_not_available"] = <iai:variable vid="xpress__3" description="Przykro nam, ale nasz ekspresowy kurier nie obsługuje tej okolicy." />;
  81. xpress_txt["courier_not_available2"] = <iai:variable vid="xpress__4" description="Twoje zamówienie zostanie dostarczone w standardowym czasie, a kuriera wybierzesz podczas składania zamówienia." />;
  82. xpress_txt["courier_not_available3"] = <iai:variable vid="xpress__5" description="OK" />;
  83. xpress_txt["ajax_error"] = <iai:variable vid="xpress__6" description="Wystąpił nieoczekiwany błąd. Proszę spróbować ponownie." />;
  84. xpress_txt["geolocation_error"] = <iai:variable vid="xpress__7" description="Wystąpił błąd poczas sprawdzania kodu pocztowego. Proszę spróbować ponownie." />;
  85. xpress_txt["geolocation_error2"] = <iai:variable vid="xpress__8" description="Nie można pobrać kodu pocztowego." />;
  86.  
  87. $.fn.textWidth = function(text, font) {
  88.  
  89. if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>').hide().appendTo(document.body);
  90. $.fn.textWidth.fakeEl.text(text || this.val() || this.text()).css('font', font || this.css('font'));
  91. return $.fn.textWidth.fakeEl.width();
  92. };
  93. app_shop.fn.getParamsFormURL = function(_url) {
  94.  
  95. if(_url === undefined) {
  96. _url = window.location.search;
  97. }
  98.  
  99. var afterMark = _url.split('?')[1];
  100. if(!afterMark) {
  101. return {};
  102. }
  103.  
  104. _url = afterMark.split('&');
  105.  
  106. var b = {};
  107. for (var i = 0; i < _url.length; ++i)
  108. {
  109. var p=_url[i].split('=', 2);
  110. if (p.length == 1)
  111. b[p[0]] = "";
  112. else
  113. b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
  114. }
  115. return b;
  116. };
  117. /*** JS - V5 ***/
  118.  
  119. /* Deklaracja callback */
  120. var filtering_callback = function() { /* void */ }
  121. /* callback po tym jak form został uzupełniony/a , czyli po click a przed wysłaniem AJAX*/
  122. var filtering_callback_click = function() { /* void */ }
  123.  
  124. /* filtrownie V5 - ajax */
  125. var xhr = '';
  126. var v66412_ajax_off = <iai:variable vid="v66412_ajax_off" description="true - brak AJAX" />
  127. var v66412_suwaczek_on = <iai:variable vid="v66412_suwaczek_on" description="true - włącz suwak" />
  128.  
  129. var filter_active_ajax = function(global, global_status, filter_id) {
  130.  
  131. if ( !global ) {
  132. if ( $('#'+filter_id+'_toggle').is(':visible') ) {
  133. $('#'+filter_id+'_toggle').hide();
  134. $('#'+filter_id+'_loader').show();
  135. } else {
  136. $('#'+filter_id+'_toggle').show(); $('#'+filter_id+'_loader').hide();
  137. }
  138. }
  139. else {
  140. if ( global_status == true ) {
  141. $('a.filter_toggle[id != "filter_text_toggle"]').hide();
  142. $('span.filter_loader[id != "filter_text_loader"]').show();
  143. } else {
  144. $('a.filter_toggle[id != "filter_text_toggle"]').show();
  145. $('span.filter_loader[id != "filter_text_loader"]').hide();
  146. }
  147. }
  148. }
  149.  
  150. var filter_response_ajax = function(xml) {
  151. // dla każdego filtra
  152. //for (n=0;filterJSON.filter.length;n++) {
  153. $('navigation>filtering>filter', xml).each(function(){
  154. var $this = $(this);
  155. var filter_id = $this.attr('id').replace('[','').replace(']','');
  156. if ( $('#'+filter_id).length && filter_id != 'filter_text' ) {
  157. $this.find('>item').each(function(){
  158. var $this = $(this);
  159. var quantity = $this.attr('quantity');
  160. var value = $this.attr('value');
  161.  
  162.  
  163. if ( quantity ) {
  164. if ( quantity > 0 ) {
  165. // oznacz jako dostępny z quantity
  166. $('#'+filter_id+'_val'+value+'_quantity').show();
  167. $('#'+filter_id+'_val'+value+'_quantity span.filter_quantity_value').html(quantity);
  168. $('#'+filter_id+'_val'+value).removeAttr('disabled');
  169. $('#'+filter_id+'_'+value+'_box').removeClass('disabled');
  170. }else{
  171. // oznacz jako dostępny z quantity == 0
  172. $('#'+filter_id+'_val'+value+'_quantity').show();
  173. $('#'+filter_id+'_val'+value+'_quantity span.filter_quantity_value').html(quantity);
  174. $('#'+filter_id+'_val'+value).attr('disabled','disabled');
  175. $('#'+filter_id+'_'+value+'_box').addClass('disabled');
  176. }
  177. }else{
  178. // oznacz jako dostępny bez quantity
  179. $('#'+filter_id+'_val'+value+'_quantity').hide();
  180. $('#'+filter_id+'_val'+value).removeAttr('disabled');
  181. $('#'+filter_id+'_'+value+'_box').removeClass('disabled');
  182. }
  183.  
  184. });
  185. $('div.filter_item.list_type').each(function(){
  186. if($(this).find('li').not('.disabled').length){
  187. $(this).find('.filter_header a').removeClass('active');
  188. }else{
  189. $(this).find('.filter_header a').addClass('active');
  190. }
  191. });
  192. filter_active_ajax(true, false);
  193. }else{
  194. // nie ma takiego filtra
  195. }
  196. })
  197. }
  198.  
  199.  
  200. var filter_prepare_ajaxfilter = function() {
  201.  
  202. filter_fill_form();
  203.  
  204. if(v66412_ajax_off==='true'){filter_submit();return false;}
  205.  
  206. var filter_data = $('#filter_form').serialize();
  207. xhr = filter_send_ajaxfilter(xhr, filter_data);
  208. filter_active_ajax(true, true);
  209.  
  210. }
  211.  
  212. var filter_send_ajaxfilter = function(xhr, filter_data) {
  213.  
  214. xhr = xhr;
  215. if(xhr && xhr.readystate != 4){
  216. xhr.abort();
  217. filter_active_ajax(true, false);
  218. }
  219.  
  220. xhr = $.ajax({
  221. type: 'GET',
  222. //timeout: 8000,
  223. url: '/search.php?'+filter_data+'&getProductXML=true&xmlType=filtering',
  224. //dataType: 'xml',
  225. dataType: 'text',
  226. success: function(xml){
  227. filter_response_ajax(xml);
  228. },
  229. error: function(xml, sTextStatus, oErrorThrown) {
  230. filter_active_ajax(true, false);
  231. }
  232. });
  233. return xhr;
  234. }
  235. /* /filtrownie V5 - ajax */
  236.  
  237. /* Literały */
  238. var txt_66412_008_001 = <iai:variable vid="66412_008_001" description="wybierz datę" />
  239.  
  240. /* Wyrównanie */
  241. $.fn.setOneHeight=function(){var a=0;$(this).each(function(){if($(this).height()>a){a=$(this).height();}});$(this).css('height',a);}
  242.  
  243. var align_filter_gfx = function(id) {
  244. if ( id ) { $('#'+id+' li').setOneHeight(); }
  245. else {
  246. $('#menu_filter div.filter_gfxonly').each(function() { if ( $(this).is(':visible') ) {$(this).find('li').setOneHeight(); } });
  247. }
  248. }
  249.  
  250. /* Wyrównanie */
  251. function set_filter_cookie() {
  252. var filter_hidden_list = new Array();
  253. $('#menu_filter a.filter_toggle.active').each(function() {
  254. filter_hidden_list.push($(this).attr('href').substring(8));
  255. });
  256. $.cookie('filter_hidden', '', { expires: 355 });
  257. $.cookie('filter_hidden', filter_hidden_list, { expires: 355 });
  258. }
  259.  
  260. function get_filter_cookie() {
  261. var flistA = $.cookie('filter_hidden');
  262. if ( !!flistA ) {
  263. var flist = flistA.split(',');
  264. for(var i=0;i < flist.length;i++) {
  265. $('#menu_filter a.filter_toggle[href="#toggle_'+flist[i]+'"]').addClass('active');
  266. $('#'+flist[i]).addClass('filter_hide').removeClass('filter_show').hide();
  267. }
  268. }
  269. }
  270. /* /Ukrywanie filtrów */
  271.  
  272. /* Button - zastosuj */
  273. var show_options = function() {
  274. $('#menu_filter div.list_type, #menu_filter div.dual_type').each(function() {
  275. if ( $(this).find('input').is(':checked') ) {
  276. $('a.filter_submit[data-filter="'+$(this).attr('id')+'"]').show('fast');
  277. $('#filter_buttons').show('fast');
  278. }
  279. });
  280. }
  281. /* /Button - zastosuj */
  282.  
  283. /* Button - pokaż wszystkie */
  284. var filter_showall = function(obj) {
  285. if ( obj.hasClass('active') ) {
  286. obj.removeClass('active');
  287. obj.html(filter_pokaz);
  288. $('#'+obj.attr('data-filter')+' li.filterhidden').removeClass('showhidden');
  289. } else {
  290. obj.addClass('active');
  291. obj.html(filter_ukryj);
  292. $('#'+obj.attr('data-filter')+' li.filterhidden').addClass('showhidden');
  293. }
  294. }
  295.  
  296.  
  297. /* /Button - pokaż wszystkie */
  298.  
  299. // ze wzgledu na koniecznosc przekazania informacji o parametrach wyszukiwania,
  300. // do formularza trzeba dodać inputy odpowiadające parametrom zapisanym w ACTION
  301. var filter_fill_form_action = function() {
  302.  
  303.  
  304. var params = app_shop.fn.getParamsFormURL( $('#filter_form').attr('action'));
  305.  
  306. for(var k in params) {
  307.  
  308. var oInput = $('<input type="hidden">');
  309. oInput.attr('name',k);
  310. oInput.attr('value',params[k]);
  311. $('#filter_form').append(oInput);
  312. }
  313.  
  314. }
  315.  
  316. /* Wypełnienie formularza na starcie */
  317. var filter_fill_form = function() {
  318.  
  319.  
  320. /* list_type */
  321. $('#menu_filter div.filter_item.list_type').each(function() {
  322. var fID = $(this).attr('id');
  323. var fvt = new Array();
  324. $('#'+fID+'_content input[type=checkbox]:checked').each(function() {
  325. if ($(this).attr('disabled') != 'disabled' ) { fvt.push($(this).val()); }
  326. });
  327. $('#'+fID+'_form').val(fvt);
  328. });
  329.  
  330. if ($.cookie('f_getPriceRange') == '1'){
  331. /* range */
  332. $('#menu_filter div.filter_range').each(function() {
  333. var fV = $('#'+$(this).attr('data-filter')+'_range_from').val()+'-'+$('#'+$(this).attr('data-filter')+'_range_to').val();
  334. if ( fV != '-' ) { $('#'+$(this).attr('data-filter')+'_form').val(fV); }
  335. });
  336. }
  337.  
  338. /* dual_type */
  339. $('#menu_filter div.filter_item.dual_type input').each(function() {
  340. if ( $(this).is(':checked') && $(this).attr('disabled') != 'disabled') { $('#'+$(this).attr('id')+'_form').val('y'); }
  341. else { $('#'+$(this).attr('id')+'_form').val('') }
  342. });
  343.  
  344. /* text */
  345. if ( $('#filter_text_input').length && $('#filter_text_input').val() != $('#filter_text_input').attr('data-filter') ) { $('#filter_text_form').val($('#filter_text_input').val()); }
  346.  
  347.  
  348.  
  349.  
  350. filtering_callback_click();
  351. }
  352. /* /Wypełnienie formularza na starcie */
  353.  
  354. /* Wysłanie formularza */
  355. var filter_submit = function() {
  356.  
  357. //Wypełnienie formularza
  358. filter_fill_form();
  359.  
  360. filter_fill_form_action();
  361.  
  362. //Wysłanie formularza
  363. $('#filter_form').submit();
  364.  
  365.  
  366.  
  367. }
  368. /* /Wysłanie formularza */
  369.  
  370. /* oznaczenie aktywnych filtrów na starcie */
  371. var mark_active = function(obj) {
  372. if ( $('#filter_dual #'+obj).length ) {
  373. obj_box = obj+'_y_box';
  374. if ( $('#'+obj).is(':checked') ) { $('#'+obj_box).addClass('enabled'); } else { $('#'+obj_box).removeClass('enabled'); }
  375. } else {
  376. obj_box = obj.replace('_val','_')+'_box';
  377. if ( $('#'+obj).is(':checked') ) { $('#'+obj_box).addClass('enabled'); } else { $('#'+obj_box).removeClass('enabled'); }
  378. }
  379. }
  380.  
  381. /* Korekta dla buga pod IE 7 i 8 - brak zaznaczenia dla 'label img'
  382. if( (navigator.appVersion.indexOf("MSIE 8.")>-1 || navigator.appVersion.indexOf("MSIE 7.")>-1) && navigator.appVersion.indexOf("Windows")>-1 )
  383. {
  384. $("label img").live("click", function() {
  385. $("#" + $(this).parents("label").attr("for")).click();
  386. });
  387. }
  388. */
  389.  
  390. app_shop.fn.xpressCouriersInit = function(){
  391.  
  392. $('.filter_content.xpress input').on('change', function(){
  393. var $this = $(this);
  394.  
  395. app_shop.vars.clickedXPRESS = $this.attr('id');
  396. app_shop.vars.clickedXPRESS = app_shop.vars.clickedXPRESS.split('_');
  397. app_shop.vars.clickedXPRESS = app_shop.vars.clickedXPRESS[1];
  398.  
  399. if($this.is(':checked') && $this.parent().attr('data-localized') == 'false'){
  400. $('body').dialog({
  401. width: 300,
  402. content: $('#xpress_toplayer').html(),
  403. wrapperClass: 'xpress_zipcode_verification',
  404. fixed: false
  405. });
  406. }
  407. });
  408.  
  409. $('input#xpress_zipcode').live('input', function(){
  410. clearTimeout(app_shop.formControl.timeHandle);
  411. obj = $(this);
  412. app_shop.formControl.timeHandle = setTimeout(function(){
  413. app_shop.formControl.validate(obj);
  414. }, 500);
  415. });
  416.  
  417. $('#xpress_zipcode_submit').live('click', function(){
  418. var $input = $(this).parent().siblings('.form-group').find('#xpress_zipcode');
  419.  
  420. var region = $input.data('region');
  421. var zipcode = $input.val();
  422.  
  423. if(!$input.val()){
  424. $('input#xpress_zipcode').addClass('error');
  425. return false;
  426. }
  427.  
  428. var _data = "client_zipcode=" + zipcode + '&' + region;
  429.  
  430. $.ajax({
  431. url: '/ajax/client-new.php?validAjax=true',
  432. type: 'post',
  433. data: _data,
  434. dataType: 'json',
  435. beforeSend: function(){
  436. $('html').addClass('load-content');
  437. },
  438. success: function(json) {
  439. var err = json.errno;
  440.  
  441. if (err > 0){
  442. Alertek.show_alert(xpress_txt["zipcode_invalid"]);
  443.  
  444. $('input#xpress_zipcode').addClass('error');
  445. $('html').removeClass('load-content');
  446.  
  447. return false;
  448. }
  449.  
  450. $.ajax({
  451. url: '/ajax/client-new.php?setClientSamedayLocation=1&zipcode='+zipcode,
  452. type: 'post',
  453. dataType: 'json',
  454. success: function(){
  455. var filterUrl = $(location).attr('href');
  456. var filter_vals = $('form#filter_form').serialize();
  457. $.ajax({
  458. url: '/search.php?'+filter_vals+'&getProductXML=true&xmlType=filtering',
  459. dataType: 'xml',
  460. success: function(xml){
  461. if($(xml).find(app_shop.vars.clickedXPRESS).attr('client_localized') == 'true' && $(xml).find(app_shop.vars.clickedXPRESS).attr('service_available_for_current_location') == 'true')
  462. $('#filter_form').submit();
  463. else
  464. $('body').dialog({
  465. width: 300,
  466. content: $('#xpress_toplayer_error').html(),
  467. wrapperClass: 'xpress_zipcode_verification',
  468. fixed: false
  469. });
  470. $('html').removeClass('load-content');
  471. }
  472. })
  473.  
  474. },
  475. error: function(){
  476. $('html').removeClass('load-content');
  477. Alertek.show_alert();
  478. }
  479. })
  480. },
  481. error: function(){
  482. $('html').removeClass('load-content');
  483. Alertek.show_alert(xpress_txt["geolocation_error"]);
  484. }
  485. })
  486.  
  487. return false;
  488. });
  489.  
  490. $('#xpress_zipcode_geolocation').live('click', function(){
  491. if(navigator.geolocation) {
  492. navigator.geolocation.getCurrentPosition(function(position) {
  493.  
  494. $('.xpress_zipcode_verification').addClass('load-content');
  495. var lat = position.coords.latitude;
  496. var long = position.coords.longitude;
  497.  
  498. var point = new google.maps.LatLng(lat, long);
  499. new google.maps.Geocoder().geocode({'latLng': point}, function (res, status) {
  500. var zipcode = res[0].formatted_address.match(/\d{2}-\d{3}/);
  501.  
  502. if(zipcode)
  503. $('input#xpress_zipcode').val(zipcode[0]);
  504. else
  505. Alertek.show_alert(xpress_txt["geolocation_error2"]);
  506.  
  507. $('.xpress_zipcode_verification').removeClass('load-content');
  508.  
  509. });
  510. });
  511. }
  512.  
  513. return false;
  514. });
  515.  
  516. $('#express_close_dialog').live('click', function(){
  517. $('#dialog_close').click();
  518.  
  519. return false;
  520. });
  521.  
  522. }
  523.  
  524.  
  525. function menu_filter_init() {
  526.  
  527. /* Scroll do góry strony po przeładowaniu */
  528. // if ( $('#menu_filter').length ) { $(this).scrollTop(0); }
  529.  
  530. /* Oznacz jako zaznaczony filtr na starcie */
  531. $('#menu_filter div.menu_filter_wrapper input[type=checkbox]').each(function() { mark_active($(this).attr('id')); });
  532. $('#menu_filter div.menu_filter_wrapper input[type=checkbox]').change(function() { mark_active($(this).attr('id')); });
  533.  
  534. /* Wypełnienie formularza na starcie */
  535. filter_fill_form();
  536.  
  537. /* Wysłanie formularza na enter w input[text] */
  538. $('#menu_filter input[type=text]').on('keyup', function(e) {
  539. if (e.which == 13) { filter_submit(); }
  540. });
  541.  
  542. /* Filtr list_type - click */
  543. $('#menu_filter div.filter_item.list_type input[type="checkbox"]').click(function() {
  544. var fID = String($(this).attr('id')).substring(0, String($(this).attr('id')).indexOf('_val'));
  545. $('a.filter_submit[data-filter="'+fID+'"]').show('fast');
  546. $('#filter_buttons').show('fast');
  547. var fvt = new Array();
  548. $('#'+fID+'_content input[type="checkbox"]').each(function() {
  549. if ( $(this).is(':checked') ) { fvt.push($(this).val()); }
  550. });
  551. $('#'+fID+'_form').val(fvt);
  552. if ( $(this).attr('id') != 'filter_price_range_from' && $(this).attr('id') != 'filter_price_range_to' && $(this).attr('id') != 'filter_text_input' && $(this).attr('id') != 'filter_date_datepicker' && $(this).attr('data-filter') != 'filter_date_option' ) {
  553. filter_prepare_ajaxfilter();
  554. }
  555. });
  556.  
  557. /* Filtr dual_type - click */
  558. $('#menu_filter div.filter_item.dual_type input').click(function() {
  559. if ( $(this).is(':checked') ) { $('#'+$(this).attr('id')+'_form').val('y'); }
  560. else { $('#'+$(this).attr('id')+'_form').val('') }
  561. $('a.filter_submit[data-filter="filter_dual"]').show('fast');
  562. $('#filter_buttons').show('fast');
  563. filter_prepare_ajaxfilter();
  564. });
  565.  
  566. /* Filtr text - click */
  567. $('#filter_text_input').focus(function() { if ( $(this).val() == $(this).attr('data-filter') ) { $(this).val('');} });
  568. $('#filter_text_submit').click(function() { filter_submit(); });
  569. $('#filter_text_input').keyup(function() { $('#filter_text_form').val($('#filter_text_input').val()); });
  570.  
  571. /* Filtr - range */
  572. $('#menu_filter a.filter_submit_range').click (function() {
  573. filter_fill_form();
  574.  
  575. $('#menu_filter div.filter_range').each(function() {
  576. //$('#'+$(this).attr('data-filter').replace('_range','_content')+' input[type="checkbox"]').prop('checked',false);
  577. var fV = $('#'+$(this).attr('data-filter')+'_range_from').val()+'-'+$('#'+$(this).attr('data-filter')+'_range_to').val();
  578. if ( fV != '-' ) { $('#'+$(this).attr('data-filter')+'_form').val(fV); }
  579. });
  580.  
  581. $('#filter_form').submit();
  582. });
  583.  
  584. /* Filter - data dodania */
  585. if ( $('#filter_date').length ) {
  586. $('#filter_date input[type="checkbox"]').click(function() {
  587. var tP = $(this).prop('checked');
  588. $('#filter_date input').prop('checked',false);
  589. if ( !tP ) { $(this).prop('checked',false); } else { $(this).prop('checked',true); }
  590. if ( $(this).attr('id') != 'filter_date_calendar_picker' ) {
  591. $('#filter_date_calendar_picker').val('');
  592. $(this).parents('ul').find('span.filter_calendar_from').hide();
  593. $('#filter_date_datepicker').val(txt_66412_008_001);
  594. }
  595. filter_prepare_ajaxfilter();
  596. });
  597.  
  598. $('.filter_datepicker').datepicker({
  599. onSelect: function(dateText, inst) {
  600. $(this).parent().find('span.filter_calendar_from').show();
  601. $('#'+$(this).attr('id').replace('_datepicker','')+' input[type="checkbox"]').prop('checked',false);
  602. $(this).parent().find('input.filter_calendar').val($(this).val());
  603. $(this).parent().find('input.filter_calendar').prop('checked',true);
  604. $('#'+$(this).attr('id').replace('_datepicker','_submit')).show('fast');
  605. },
  606. dateFormat: iaical_dateFormat,
  607. dayNamesMin: iaical_daysShort,
  608. monthNames: iaical_monthNames,
  609. nextText: iaical_monthNext,
  610. firstDay: iaical_firstDay,
  611. prevText: iaical_monthPrev
  612. });
  613.  
  614. $('.filter_datepicker').datepicker( "option", "dateFormat", "yy-mm-dd" );
  615. datepicker_min_year = parseInt(datepicker_min.substring(0, 4)); datepicker_min_month = parseInt(datepicker_min.substring(5, 7)); datepicker_min_day = parseInt(datepicker_min.substring(8, 10));
  616. datepicker_max_year = parseInt(datepicker_max.substring(0, 4)); datepicker_max_month = parseInt(datepicker_max.substring(5, 7)); datepicker_max_day = parseInt(datepicker_max.substring(8, 10));
  617. var minDate = $( ".filter_datepicker" ).datepicker( "option", "minDate" );
  618. $( ".filter_datepicker" ).datepicker( "option", "minDate", new Date(datepicker_min_year, datepicker_min_month - 1, datepicker_min_day) );
  619. var maxDate = $( ".filter_datepicker" ).datepicker( "option", "maxDate" );
  620. $( ".filter_datepicker" ).datepicker( "option", "maxDate", new Date(datepicker_max_year, datepicker_max_month - 1, datepicker_max_day) );
  621. $('.filter_datepicker').each(function() { $(this).val($(this).attr('data-filter')); });
  622. }
  623.  
  624. if ( $('#menu_filter').length ) {
  625. $('#ui-datepicker-div a').live('click', function() { filter_prepare_ajaxfilter(); });
  626. }
  627. /* /Filter - data dodania */
  628.  
  629. /* Ukrycie filtrów oznaczonych jak ukryte */
  630. get_filter_cookie();
  631.  
  632. /* Button zastosuj - przypisanie na starcie */
  633. //show_options();
  634. $('a.filter_submit').click(function() { filter_submit(); });
  635. $('a.show_all').click(function() { filter_showall($(this)); });
  636.  
  637. /* Pokaż/Ukryj filtr - click */
  638. $('#menu_filter a.filter_toggle').click(function() {
  639.  
  640. if ( $(this).hasClass('active') ) {
  641. $(this).removeClass('active');
  642. $('#'+$(this).attr('href').substring(8)).addClass('filter_hide').removeClass('filter_show').slideToggle( 'fast', function(){$('body').resize()});
  643. set_filter_cookie();
  644. if ( $('#'+$(this).attr('id').replace('_toggle','_content')).hasClass('filter_gfxonly') ) { align_filter_gfx($(this).attr('id').replace('_toggle','')); }
  645. } else {
  646. $(this).addClass('active');
  647. $('#'+$(this).attr('href').substring(8)).addClass('filter_show').removeClass('filter_hide').slideToggle('fast', function(){$('body').resize()});
  648. set_filter_cookie();
  649. }
  650.  
  651. return false;
  652. });
  653.  
  654. /* Filtr gfxonly */
  655. $('#menu_filter div.filter_item.list_type label').click(function() {
  656. if ( !$('#'+$(this).attr('for').replace('_val','_')+'_box').hasClass('disabled') ) {
  657. if ( $('#'+$(this).attr('for')).prop('checked') ) { $(this).removeClass('active'); }
  658. else { $(this).addClass('active'); }
  659. }
  660. });
  661.  
  662. simple_tooltip("div.filter_gfxonly img","filter_tooltip");
  663.  
  664. /* Zastosuj wybrane filtry - click */
  665. $('#filter_buttons a.filters_submit').click(function() { filter_submit(); });
  666.  
  667.  
  668. /*suwaczek*/
  669. if(v66412_suwaczek_on) {
  670.  
  671. if($.ui.slider){
  672. $("#slider-price").slider({
  673. range: true,
  674. min: parseInt($("#min_price_start").val()),
  675. max: parseInt($("#max_price_start").val()),
  676. values: [parseInt( $("#min_price_set").val() || $("#min_price_start").val() ), parseInt( $("#max_price_set").val() || $("#max_price_start").val() )],
  677. slide: function(event, ui) {
  678. $("#filter_price_range_from").val(ui.values[0]);
  679. $("#filter_price_range_to").val(ui.values[1]);
  680. },
  681.  
  682. stop: function(event, ui) {
  683.  
  684. $("#filter_price_range_from").val(ui.values[0]);
  685. $("#filter_price_range_to").val(ui.values[1]);
  686. }
  687. });
  688. }
  689.  
  690. }
  691.  
  692. // ciastko dla wyboru filtra ceny
  693. $('#filter_price_range_content input').live('focus click change',function(){
  694. $.cookie('f_getPriceRange', '1');
  695. });
  696. $('#filter_price_content input, #filter_price_content label').live('click',function(){
  697. $.cookie('f_getPriceRange', '0');
  698. });
  699.  
  700. app_shop.fn.xpressCouriersInit();
  701.  
  702. }
  703.  
  704.  
  705.  
  706. $(window).load(function() {
  707. /* Wyrównanie - gfxonly i gfx */
  708. align_filter_gfx();
  709. if (!$('#filter_price_list').length) $.cookie('f_getPriceRange', '0'); // zerowanie wyboru filtra ceny
  710. /* Scroll do góry strony po przeładowaniu */
  711. // if ( $('#menu_filter').length ) { $(this).scrollTop(0); }
  712. });
  713.  
  714. /*** JS - V5 END ***/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement