PageSourceSearch

https://www.knih-litovel.cz/js/profiShow.js?ver=1327916884

js knih-litovel.cz collected 2026-10-09 03:29:43 UTC 19,812 bytes, 533 lines download raw bytes

1/** Zobrazovac profi -> zobrazeni urciteho obsahu (inzerau) zpusobem podobnym galerii pres cele okno
2 *  19.10.2010
3 *  v 1.0 
4 *  profi.cz - Jan Navratil 
5 *  
6 *  - pokud chceme definovat seznam elementu k listovani, vytvorime skryty element s ID - seznamNabidekProfiShow
7 *  - jinak se hleda seznam v prvnim nactenem ajaxovem volani
8 *  - hledana data jsou - ###!XXX|YYY!### - kde XXX je url k nabidkam v obecnem tvaru (http://www.neco.cz/index.php?prvek_id=) a YYY je seznam ID prvku oddelenych carkami (52,6,8,15)       
9 */ 
10 
11var profiShow = {
12  
13  infoUrl : '',
14  callBack: '', //callback volany po kazdem nacteni
15  animTime: 500, //cas animace ms
16  
17  /** Inicializace - zobrazeni 
18   *  -> parametr url - obsahem vraceneho response budou div (skryty) s adresou na dalsi a s adresou na predchozi slide. Nebude-li, nezobrazi se patricna sipka
19   *  cw - container width, ch - container height   
20   */  
21      
22  init: function(url,cw,ch,jumpto,callback) {
23    if (jumpto) {
24      this.jumpto = jumpto;
25    } else {
26      this.jumpto = false;
27    }
28    if (!callback)
29      var callback = null;
30    
31    //alert($('body').width() + 'x' + $('body').height() + ' | ' + $(window).width() + 'x' + $(window).height());
32    var profi = this;
33    if (!this.overlay) {
34      this.overlay = $('<div>', {
35                    id: "profiShowOverlay",
36                    click: function(){
37                      profi.close();                        
38                    }        
39                    }).appendTo('body').css("width",$('body').width()).css("height",$(window).height()).css("opacity",0.5);
40    }
41    
42    this.inzeratyUrl = false;
43    if (!url) {
44      this.getNav(null);
45      if (this.inzeratyUrl) {
46        url = this.inzeratyUrl + this.inzeraty[0];          
47      }
48    }
49    if (url) {      
50      //prepare width and height
51      if (!cw) {
52        var cw = Math.round($(window).width()*0.6);
53        var cwidth = "";      
54      } else {
55          var cwidth = cw;
56        }
57      if (!ch) {
58        var ch = Math.round($(window).height()*0.75);
59        var cheight = "";
60      } else {
61        var cheight = ch;
62      }
63      var top = Math.round($(window).height()/2 - ch/2);
64      var left = Math.round($(window).width()/2 - cw/2);
65      //create data container
66      this.dataContainer = $('<div>',{ id: "profiShowDataContainer", tabindex: 0                   
67              }).appendTo('body').css("width", cw).css("height",ch).css("top",top).css("left",left).css("background",'url(/images/gallery/loading.gif) no-repeat scroll center center #FFFFFF');
68      //closeLink
69      this.dataContainerClose = $('<a>',{ id: "profiShowClose",
70                                       href: "javascript:;",
71                                       click: function() {
72                                            profi.close();
73                                       }                     
74              }).appendTo(profi.dataContainer);
75      
76      this.dataContainerIn = $('<div>',{ id: "profiShowDataContainerIn"                    
77              }).appendTo(profi.dataContainer);//.css("width", cw).css("height",ch).css("top",top).css("left",left);        
78      this.loadData(url,callback);  
79      /*if (typeof($('body').keydown) == "function")  
80        this.body_keydown = $('body').keydown;*/
81      
82      //info hlaska
83      if (this.infoUrl) {
84        this.infoHlaska = $('<div>').attr('class','profiShowInfoHlaska').attr('style','position:absolute;top:-65px;width:450px;height:60px;').load(this.infoUrl).appendTo(profi.dataContainer);
85        var infoLeft = Math.round(this.dataContainer.width()/2 - this.infoHlaska.width()/2); 
86        this.infoHlaska.css('left', infoLeft);
87      }
88     
89      this.rozmery = [];
90      this.casovac = [];
91      this.rozmery = {width:$(window).width(), height:$(window).height(), bwidth:$('body').width(), bheight:$('body').height()};
92      this.casovac = setTimeout(function () {
93        profi.sizeCounter(cwidth,cheight);  
94      }, 500);
95       
96      $('#profiShowDataContainer').keydown(function(event) {
97          return profi.keyPressed(event.keyCode);          
98        });
99      $('#profiShowDataContainer').keyup(function(event) {
100          profi.keyPressedUp(event.keyCode);
101        });  
102    }
103  },
104  
105  reset: function() {
106    this.inzeratyUrl = false;    
107  },
108  
109  sizeCounter: function(cw,ch) {
110    /*console.log('Resize kontrola');
111    console.log('Stavajici rozmery');
112    console.log(this.rozmery[id]);
113    console.log(this.rozmery[id].width);*/
114    if (!this.dataContainer) {
115      //console.log('Neni okno, konec casovace');
116      return;
117    } 
118    var cwidth = cw; 
119    var cheight = ch;
120    if (this.rozmery.width != $(window).width() || this.rozmery.height != $(window).height()
121        || this.rozmery.bwidth != $('body').width() || this.rozmery.bheight != $('body').height()) {
122      //console.log('Detekovana změna');
123      
124      
125      if (!cw) {
126        var cw = Math.round($(window).width()*0.6);
127        var cwidth = "";      
128      } else {
129          var cwidth = cw;
130        }
131      if (!ch) {
132        var ch = Math.round($(window).height()*0.75);
133        var cheight = "";
134      } else {
135        var cheight = ch;
136      }
137      //pozici okna odpocteme z puvodnich souradnic
138      var oldtop = parseInt(this.dataContainer.css('top'), 10);
139      var oldleft = parseInt(this.dataContainer.css('left'), 10);
140      
141      //var top = Math.round((oldtop / this.rozmery.height) * $(window).height());
142      //var left = Math.round((oldleft / this.rozmery.width) * $(window).width());
143      
144      if (cw != this.dataContainer.width()) {
145        this.dataContainer.css('width', cw);  
146      } 
147      if (ch != this.dataContainer.height()) {
148        this.dataContainer.css('height', ch);  
149      } 
150      
151      var top = Math.round($(window).height()/2 - this.dataContainer.height()/2);
152      var left = Math.round($(window).width()/2 - cw/2);
153       
154      this.dataContainer.css('top', top);
155      this.dataContainer.css('left', left);
156      
157      if (this.infoHlaska) {
158        var ifnoWidth = this.infoHlaska.width()/2; 
159        var infoLeft = Math.round(this.dataContainer.width()/2 - ifnoWidth); 
160        this.infoHlaska.css('left', infoLeft);       
161      } else {
162        var ifnoWidth = 0;
163      }
164      
165      
166      
167      $('#profiShowDataContainerIn .inzerat_detail').css('height', $('#profiShowDataContainerIn').height());
168      $('#profiShowDataContainerIn .inzerat_detail').css('width', $('#profiShowDataContainerIn').width() - 30);
169      
170      var inzerat_detal_width = parseInt($('#profiShowDataContainerIn .inzerat_detail').eq(0).width());
171      if ($('#profiShowAnimCont')) {
172        $('#profiShowAnimCont').css('width',Math.round(3*inzerat_detal_width+3*30));
173      }    
174      this.inzerat_detal_width = inzerat_detal_width-30;
175      $('#profiShowAnimCont').css('left',-(inzerat_detal_width+30));
176      
177      this.navNext.css("top", Math.round($(window).height()/2 - $('#profiShowNext').height()/2)); 
178      this.navPrew.css("top", Math.round($(window).height()/2 - $('#profiShowPrew').height()/2)); 
179      
180      if (this.overlay) {
181        this.overlay.css('width', $('body').width());
182        this.overlay.css('height', $('body').height());
183      }
184      this.rozmery = {width:$(window).width(), height:$(window).height(), bwidth:$('body').width(), bheight:$('body').height()};
185    }
186    
187    
188    var profi = this;
189    this.casovac = null;
190    this.casovac = setTimeout(function () {
191      profi.sizeCounter(cwidth,cheight);  
192    }, 500);
193  },
194  
195  close: function() {
196    if (this.animateInProgress != true) { //nezavirat uprostred animace, nedela to dobrotu
197      this.overlay.detach(); 
198      this.overlay = '';
199      this.dataContainer.detach();
200      if (this.navNext)
201        this.navNext.detach();
202      if (this.navPrew)
203        this.navPrew.detach();  
204      /*if (typeof(this.body_keydown) == "function")
205        $('body').keydown(this.body_keydown);*/        
206      clearTimeout(this.casovac);
207    } else {
208      var profi = this;  
209      setTimeout(function() {profi.close()}, 500);
210    }   
211  },
212  
213  loadData: function(url,callback) {
214    var profi = this;
215    this.dataContainerIn.html("&nbsp;");
216    this.dataContainerIn.css("background-color", "transparent");
217    $.ajax({ url: url, 
218      success: function(html){                   
219        profi.dataContainerIn.css("background-color", "white");
220        profi.dataContainerIn.html(html);
221        if (typeof callback == "function") {
222          callback();
223        }         
224        profi.getNav(profi.dataContainerIn.html()); 
225        if (typeof profi.callBack == "function") {
226          profi.callBack();  
227        }       
228        $('#profiShowDataContainer').focus();        
229        if (!this.gallery4u) {
230          this.gallery4u = new Gallery4u('',$('#profiShowDataContainer')); //inicializace
231          var obj = this; 
232          $(document).mousemove(function(e){
233            obj.gallery4u.jMousePosX = e.pageX;
234            obj.gallery4u.jMousePosY = e.pageY;
235          });                   
236        } else {
237          this.gallery4u.init($('#profiShowDataContainer'));
238        } 
239        
240     }});
241     
242       
243  },
244  
245  preLoad: function(url,el) {
246    //console.log('Opravdu preload : ' + url);
247    var profi = this;
248    url = url.replace("&amp;", "&");  
249    $.ajax({ url: url+'&preload=true', 
250      success: function(html){         
251        //el.css("background-color", "white");
252        el.html(html);
253        //profi.getNav(html);        
254        //$('#profiShowDataContainer').focus();        
255        if (!this.gallery4u) {
256          this.gallery4u = new Gallery4u('',$('#profiShowDataContainer')); //inicializace
257          var obj = this; 
258          $(document).mousemove(function(e){
259            obj.gallery4u.jMousePosX = e.pageX;
260            obj.gallery4u.jMousePosY = e.pageY;
261          });                   
262        } else {
263          this.gallery4u.init($('#profiShowDataContainer'));
264        } 
265        if (typeof profi.callBack == "function") {
266          profi.callBack();  
267        }         
268     }});
269  
270  },
271  
272  getNav: function(data) {
273    var profi = this;
274    this.params = new Array();  
275    
276    //log('GetNav start');
277    
278    if (this.inzeratyUrl == false) {
279      //log('nemame url ani seznam inzeratu');
280      //console.log('Jdeme hledat navigaci');
281        //7.9.2011 - pokud existuje tento konkretni element - ocekavame, ze potrebna data jsou v nem
282      if ($('#seznamNabidekProfiShow').length > 0) {
283        data = $('#seznamNabidekProfiShow').html();
284        //log(data);
285      }
286      var finded = ''+data.match(/###!(.*?)!###/gi);
287      finded = finded.replace("###!", "");
288      finded = finded.replace("!###", "");
289      finded = finded.replace("&amp;", "&");
290      //log('Co jsme asi našli?');
291      //log(finded);
292      //log(data);
293      var parse = finded.split("|");
294      //console.log(parse);
295      this.inzeratyUrl = parse[0]; 
296      this.inzeratyUrl = this.inzeratyUrl.replace( new RegExp('&amp;','ig'), '&');      
297      
298      this.inzeraty = new Array(); 
299      if (parse[1]) {   
300        this.inzeraty = parse[1].replace( new RegExp('&amp;','ig'), '&').split(','); //vsechny inzeraty
301      } 
302      //log('Načten seznam inzerátů');
303      //log(this.inzeraty);
304      
305      //console.log(parse[1]);
306      //console.log('Inzeraty: ');
307      //console.log(this.inzeraty);
308      this.poradiCount = 0; 
309      
310      //log('jumpto ' + this.jumpto);
311      if (this.inzeraty && this.jumpto) { //posuneme ukazatel
312        //log('Posuneme ukazatel na ' + this.jumpto);
313        for (var i = 0; i < this.inzeraty.length; i++) {
314          if (this.inzeraty[i] == this.jumpto) {
315            break;
316          }
317          this.poradiCount++;
318        } 
319        //log('Nové pořadí je ' + this.poradiCount);
320      }   
321    } else {
322      //log('Asi uz mam url i seznam inzeratu');
323      //log(this.inzeraty);
324    }
325    
326    //console.log('Counter poradi ' + this.poradiCount);
327    
328    //console.log(this.inzeratyUrl);
329    
330    /*for (var i = 0; i < parse.length ;i++ ) {
331      var stack = parse[i].split("|");
332      params[stack[0]] = stack[1];     
333    }
334    if (this.navNext) {
335      this.navNext.detach();
336      this.navNext = '';
337    }
338    this.params = params;  */
339    
340    //position: relative; width: 1800px; left: -150px;
341    //vytvorime kontejner pro pohyb (animaci)
342    if (document.getElementById('profiShowAnimCont') == null) {
343      var animCont = $('<div>').appendTo(this.dataContainerIn);   
344      animCont.attr('id','profiShowAnimCont'); 
345      animCont.addClass('profiautoajax'); 
346      //alert($('#profiShowDataContainerIn .inzerat_detail'));
347      $('#profiShowDataContainerIn .inzerat_detail').appendTo(animCont);
348      $('#profiShowDataContainerIn .inzerat_detail').css('width','100%');
349      var inzerat_detal_width = parseInt($('#profiShowDataContainerIn .inzerat_detail').width());       
350      $('#profiShowDataContainerIn .inzerat_detail').css('width',inzerat_detal_width-30); 
351      animCont.css('width',Math.round(3*inzerat_detal_width+3*30));    
352      this.inzerat_detal_width = inzerat_detal_width-30;
353      $('<div>',{'class': 'inzerat_detail'}).css('width',inzerat_detal_width-30).html('&nbsp;').appendTo(animCont);
354      $('<div>',{'class': 'clear', id: 'clearItemDiv'}).appendTo(animCont);
355      $('<div>',{'class': 'inzerat_detail'}).css('width',inzerat_detal_width-30).html('&nbsp;').prependTo(animCont);
356      
357      $('#profiShowDataContainerIn .inzerat_detail').css('height', $('#profiShowDataContainerIn').height()); 
358      animCont.css('left',-inzerat_detal_width);
359    } else {       
360      this.inzerat_detal_width = parseInt($('#profiShowDataContainerIn .inzerat_detail').eq(1).width());        
361      var inzerat_detal_width = this.inzerat_detal_width;
362      
363      $('#profiShowAnimCont').css('left',-(inzerat_detal_width+30));     
364    } 
365    
366    if (this.navPrew) {
367      this.navPrew.detach();
368      this.navPrew = '';
369    }
370    
371    if (this.navNext) {
372      this.navNext.detach();
373      this.navNext = '';
374    }
375    
376    
377    if (this.inzeraty[this.poradiCount+1]) { //zname next
378      //log('Známe next' + this.inzeraty[this.poradiCount+1]);
379      this.params['next'] = true;
380          
381      this.navNext = $('<a>', {
382        id: "profiShowNext",
383        href: "javascript:;",
384        click: function() { 
385          //profi.loadData(params['next']);
386          profi.goNext();             
387        }
388      }).appendTo('body');        
389      
390      //prednacteni
391      //alert('po: '+params['next']);
392      
393      profi.preLoad(this.inzeratyUrl+this.inzeraty[this.poradiCount+1] ,$('#profiShowAnimCont .inzerat_detail').eq(2));
394    
395              
396    } else {
397      //log('Neznáme next');
398      this.params['next'] = false;
399      
400      this.navNext = $('<a>', {
401        id: "profiShowNext",
402        "class": "deactive",
403        href: "javascript:;"
404      }).appendTo('body');
405    } 
406    
407    
408          
409
410    if (this.inzeraty[this.poradiCount-1]) {
411      //log('Známe prev' + this.inzeraty[this.poradiCount-1]);   
412      this.params['prew'] = true;     
413      this.navPrew = $('<a>', {
414        id: "profiShowPrew",
415        href: "javascript:;",
416        click: function() {
417          //profi.loadData(params['prew']);
418          profi.goPrev();     
419        }
420      }).appendTo('body'); 
421      
422      //prednacteni
423      //alert('pred: '+params['prew']);
424      
425      profi.preLoad(this.inzeratyUrl+this.inzeraty[this.poradiCount-1],$('#profiShowAnimCont .inzerat_detail').eq(0)); 
426               
427             
428    } else {
429      //log('Neznáme prev');
430      
431      this.params['prew'] = false;
432      this.navPrew = $('<a>', {
433        id: "profiShowPrew",
434        href: "javascript:;",
435        "class": "deactive"
436      }).appendTo('body'); 
437    }
438    
439    this.navNext.css("top", Math.round($(window).height()/2 - $('#profiShowNext').height()/2)); 
440    this.navPrew.css("top", Math.round($(window).height()/2 - $('#profiShowPrew').height()/2));
441    //log('getNav KONEC --- ');
442  },
443  
444  goNext: function() {
445    var profi = this;
446    profi.animateInProgress = true;
447    $('#profiShowAnimCont').animate({"left": "-="+parseInt(profi.inzerat_detal_width+30)+"px"},this.animTime,function() { 
448      
449      //prehozeni poradi - kvuli chromu musime jinak
450      var html = $('#profiShowAnimCont .inzerat_detail').eq(2).html();
451      /*var el = $('#profiShowAnimCont .inzerat_detail').eq(0); 
452      $('#profiShowAnimCont .inzerat_detail').eq(1).html(html);*/
453      $('#profiShowAnimCont .inzerat_detail').eq(0).appendTo($('#profiShowAnimCont'));       
454      $('#profiShowAnimCont #clearItemDiv').appendTo($('#profiShowAnimCont')); 
455      $('#profiShowDataContainer').focus(); 
456      profi.poradiCount = profi.poradiCount + 1;       
457      profi.getNav(html);            
458      profi.animateInProgress = false;
459    });   
460  },
461  
462  goPrev: function() {
463    var profi = this;
464    profi.animateInProgress = true;  
465    $('#profiShowAnimCont').animate({"left": "+="+parseInt(profi.inzerat_detal_width+30)+"px"},this.animTime,function() {            
466            //profi.getNav($('#profiShowAnimCont .inzerat_detail').eq(0).html()); 
467      var html = $('#profiShowAnimCont .inzerat_detail').eq(0).html(); 
468      //$('#profiShowAnimCont .inzerat_detail').eq(1).html(html);
469      $('#profiShowAnimCont .inzerat_detail').eq(2).prependTo($('#profiShowAnimCont'));          
470      
471      $('#profiShowDataContainer').focus(); 
472      profi.poradiCount = profi.poradiCount - 1;         
473      profi.getNav(html);
474      profi.animateInProgress = false;           
475    });  
476  },
477  
478  keyPressed: function(keycode) {
479    //39 - right
480    //37 - left
481    //32 - space
482    //27 - esc
483    if (keycode == 39 || keycode == 32) {
484      if (this.params['next'])     
485        this.goNext();  
486    }
487    if (keycode == 37) {
488      if (this.params['prew']) 
489        this.goPrev();//this.loadData(this.params['prew']);  
490    }
491    if (keycode == 27) {      
492        this.close();  
493    }
494    
495    if (keycode == 40) {     
496      $('body').scrollTop(0); 
497      var el = $('#profiShowAnimCont').find('.inzerat_detail').eq(1);      
498      el.scrollTop( el.scrollTop()+50  );
499      //log(el.height());
500      /*if ($(this).data('dole') != 'true') {        
501        var time = el[0].scrollHeight*5;  
502        el.stop().animate({ scrollTop: el[0].scrollHeight }, time);
503        $(this).data('dole','true');      
504      }  */
505      return false;
506    } 
507    if (keycode == 38) {      
508      $('body').scrollTop(0);
509      var el = $('#profiShowAnimCont').find('.inzerat_detail').eq(1);      
510      el.scrollTop( el.scrollTop()-50  );      
511    }                          
512  
513  },
514  
515  keyPressedUp: function(keycode) {
516  
517    if (keycode == 40) {     
518      $('body').scrollTop(0); 
519      var el = $('#profiShowAnimCont').find('.inzerat_detail').eq(1);      
520      el.scrollTop( el.scrollTop()+50  );
521      /*el.stop().animate({ scrollTop: el.scrollTop()+150 }); 
522      $(this).data('dole','false'); */      
523    } 
524    if (keycode == 38) {      
525      $('body').scrollTop(0);
526      var el = $('#profiShowAnimCont').find('.inzerat_detail').eq(1);      
527      el.scrollTop( el.scrollTop()-50  );      
528    } 
529  
530  }
531
532
533};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.