1// JavaScript Document 2/** Vyskakovaci okno 3 * v 1.3 4 */ 5 6/** 7 * 8.6.2012 8 * - Nove moznost zadat afterCloseCallback 9 * - funkce setVazba(id) - kde id je okno jiz otevreneho. Z okna id udelame rodice okna prave otevreneho. Volat po funkci .show(). Zavre-li se rodic, zavre se i potomek (vazba) 10 * 11 */ 12 13function As4uPopup() { 14 this.overlay = []; 15 this.dataContainer = []; 16 this.dataContainerClose = []; 17 this.dataContainerIn = []; 18 this.dataContainerLista = []; 19 this.nooverlay = true; 20 this.counter = 0; 21 this.zIndex = 0; 22 this.afterDataLoaded = ""; 23 this.scrollPositions = []; 24 this.afterCloseCallbacks = []; 25 this.rozmery = []; 26} 27 28if(typeof jQuery == 'function'){ 29 if (typeof $ == "undefined") var $ = jQuery; 30} 31 32function log(d) { 33 try { 34 //if (typeof console != "undefined") console.log(d); 35 } catch(e) {} 36} 37 38/** 39 * Otevreni okna popupu 40 * cw - sirka okna (mozno i v procentech napr. '25%') 41 * ch - vyska okna -- || -- 42 * callback - funkce zavolana po nacteni ajaxu do okna -> pokud predano jako objekt, muze obsahovat dva parametry {callback: , afterCloseCallback: } 43 * frame - boolean - true -> nacteni url do iframu 44 * win - parametr okna do ktereho se ma popap otevrit -> win.documet -> ze nej body a vne nove okno 45 * @return - vraci id otevreneho okna 46 * afterCloseCallback - callback po zavreni okna (fce) 47 * 48 */ 49 50 //pokud je volba frame vlozi se ulr do iframe 51As4uPopup.prototype.show = function(url,cw,ch,callback,frame,win,afterCloseCallback) { 52 if (typeof callback == 'object') { 53 if(callback != null){ 54 var afterCloseCallback = callback.afterCloseCallback; 55 var callback = callback.callback; 56 } 57 } 58 59 if (callback) 60 this.afterDataLoaded = callback; //callback support - 31.5.2011 61 62 var profi = this; 63 if (!this.overlay) { 64 this.overlay = []; 65 } 66 //this.counter++; 67 this.counter = this.getAvailableId(); 68 this.zIndex++; 69 var counter = this.counter; 70 //if (!this.overlay) { 71 72 if (typeof afterCloseCallback == "function") { 73 this.afterCloseCallbacks[counter] = afterCloseCallback; 74 } else { 75 this.afterCloseCallbacks[counter] = null; 76 } 77 78 var isoverlay = this.nooverlay; 79 for (var i=0; i < this.overlay.length;i++) { 80 if (this.overlay[i]) { 81 if (this.overlay[i].attr('id')) { 82 isoverlay = true; 83 } 84 } 85 } 86 87 if (win) { 88 console.log(win); 89 var body = jQuery(win.document).find('body'); 90 } else { 91 var body = jQuery('body'); 92 } 93 94 if (!isoverlay) { 95 var overlayheight = jQuery(window).height() > jQuery('body').height() ? jQuery(window).height() : jQuery('body').height(); 96 this.overlay[this.counter] = jQuery('<div>', { 97 id: "as4uPopupOverlay"+this.counter, 98 'class': "as4uPopupOverlay", 99 click: function(){ 100 profi.close(counter); 101 } 102 }).appendTo(body).css("width",jQuery(body).width()).css("height",overlayheight).css("opacity",0.5); 103 } 104 var adurl = ""; 105 //novinka 6.6.2011 - mozno zadat velikost v procentech 106 var percentage_w = 0.6; 107 var percentage_h = 0.75; 108 if (typeof cw == "string") { 109 if (cw.indexOf('%') !== -1 ) { 110 cw = cw.replace('%', ''); 111 percentage_w = parseInt(cw)/100; 112 cw = false; 113 } 114 } 115 if (typeof ch == "string") { 116 if (ch.indexOf('%') !== -1 ) { 117 ch = ch.replace('%', ''); 118 percentage_w = parseInt(ch)/100; 119 ch = false; 120 } 121 } 122 123 if (!cw) { 124 var cw = Math.round(jQuery(window).width()*percentage_w); 125 var cwidth = cw; 126 } else { 127 var cwidth = cw; 128 } 129 if (!ch) { 130 var ch = Math.round(jQuery(window).height()*percentage_w); 131 var cheight = ch; 132 } else { 133 var cheight = ch; 134 } 135 if (ch+100 > jQuery(window).height()) { 136 var ch = Math.round(jQuery(window).height()-105); 137 var cheight = ch; 138 } 139 //log( cw + ' x ' + ch ); 140 if (cw+80 > jQuery(window).width()) { 141 var cw = Math.round(jQuery(window).width()-80); 142 var cwidth = cw; 143 } 144 //log( cw + ' x ' + ch ); 145 146 147 148 if (url) { //BUG FIX 6.6.2012 149 if (url.indexOf('&w=') == -1) 150 adurl += "&w="+cw; 151 152 if (url.indexOf('&h=') == -1) 153 adurl += "&h="+ch; 154 //id okna do url 155 adurl +='&thisPopupId='+this.counter; 156 } 157 //create data container 158 try { 159 if (jQuery("#as4uPopupDataContainer"+this.counter).length > 0) { 160 this.dataContainer[this.counter] = jQuery("#as4uPopupDataContainer"+this.counter); 161 this.dataContainer[this.counter].removeClass('as4uPopupDataContainerUnactive').show(); 162 } else { 163 this.dataContainer[this.counter] = jQuery('<div>',{ id: "as4uPopupDataContainer"+this.counter, 'class': "as4uPopupDataContainer" 164 }).appendTo(body); 165 } 166 } catch(e) { 167 log('Chyba '+e.message); 168 return false;
169 } 170 this.dataContainer[this.counter].css("width", cw).css("height",ch); 171 /* 172 this.dataContainer[this.counter] = jQuery('<div>',{ id: "as4uPopupDataContainer"+this.counter, 'class': "as4uPopupDataContainer" 173 }).appendTo(body).css("width", cw).css("height",ch); */ 174 175 //log( cw + ' x ' + ch ); 176 if (this.dataContainer[this.counter].css('position').toLowerCase() == 'fixed') { 177 var scrollTop = 0; 178 var scrollLeft = 0; 179 } else { 180 var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 181 var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); 182 } 183 //if (jQuery(window).height() < jQuery(body).height()) scrollLeft -= 20; 184 var fWidth = cw; 185 var fHeight = ch; 186 187 var paddingsH = parseInt(this.dataContainer[this.counter].css('paddingLeft'))+parseInt(this.dataContainer[this.counter].css('paddingRight'))+2*parseInt(this.dataContainer[this.counter].css('borderWidth')); 188 var paddingsV = parseInt(this.dataContainer[this.counter].css('paddingTop'))+parseInt(this.dataContainer[this.counter].css('paddingBottom'))+2*parseInt(this.dataContainer[this.counter].css('borderWidth')); 189 if (!(paddingsV >= 0)) paddingsV = 32; 190 if (!(paddingsH >= 0)) paddingsH = 67; 191 192 193 //log( paddingsV + ' x ' + paddingsH ); 194 var top = Math.round((jQuery(window).height()/2 - (ch+paddingsV)/2) ) + scrollTop; 195 var left = Math.round((jQuery(window).width()/2 - (cw+paddingsH)/2)) + scrollLeft; 196 197 //log( jQuery(window).width() + ' - ' + (cw+paddingsH) + ' - ' + scrollLeft); 198 199 //log('TOP:' + top); 200 //log('LEFT:' + left); 201 202 this.dataContainer[this.counter].css("top",top).css("left",left); 203 204 this.dataContainerLista[this.counter] = jQuery('<div>',{ id: "as4uPopupLista"+this.counter, 205 'class': "as4uPopupLista"}).appendTo(this.dataContainer[this.counter]); 206 207 //this.dataContainerLista[this.counter].html('<div class="inner"><div class="inner2"></div></div>'); 208 this.dataContainerLista[this.counter].html('<div class="inner"><div class="inner2"><span class="lista_title"></span></div></div>'); 209 210 this.dataContainerClose[this.counter] = jQuery('<a>',{ id: "as4uPopupClose"+this.counter, 211 'class': "as4uPopupClose", 212 href: "javascript:;", 213 click: function() { 214 profi.close(counter); 215 }}).appendTo( this.dataContainerLista[this.counter].find('.inner2').eq(0) ); 216 217 this.dataContainerIn[this.counter] = jQuery('<div>',{ id: "as4uPopupDataContainerIn"+this.counter, 'class': "as4uPopupDataContainerIn" 218 }).appendTo(this.dataContainer[this.counter]); 219 220 //nastaveni dragable 221 this.dataContainer[counter].draggable({ 222 handle:profi.dataContainerLista[profi.counter], 223 drag: function(event, ui) { 224 var oldtop = parseInt(profi.dataContainer[counter].css('top'), 10); 225 var oldleft = parseInt(profi.dataContainer[counter].css('left'), 10); 226 var percentTop = (100/jQuery(window).height())*oldtop; 227 var percentLeft = (100/jQuery(window).width())*oldleft; 228 try { 229 profi.rozmery[counter].percentTop = percentTop; 230 profi.rozmery[counter].percentLeft = percentLeft; 231 } catch (e) {} 232 //profi.rozmery[profi.counter].clearTop = oldtop - scrollTop; 233 //profi.rozmery[profi.counter].clearLeft = oldleft - scrollLeft; 234 } 235 }); 236 237 this.casovac = []; 238 //8.6.2012 - upravime rozmery -> prevedem si rozmer pri otevreni na % -> pote vzdy prepocet procentuelne z aktualni velikosti okna 239 //pouzijeme cwidth, cheight 240 var percentWidth = (100/jQuery(window).width())*cwidth; 241 var percentHeight = (100/jQuery(window).height())*cheight; 242 //procentni top left pozice 243 var percentTop = (100/jQuery(window).height())*top; 244 var percentLeft = (100/jQuery(window).width())*left; 245 246 //log('Percent rozmery: ' +percentWidth+'x'+percentHeight + ' in PX ' + cwidth + 'x' + cheight ); 247 this.rozmery[counter] = { 248 width:jQuery(window).width(), 249 height:jQuery(window).height(), 250 bwidth:jQuery('body').width(), 251 bheight:jQuery('body').height(), 252 percentWidth: percentWidth, 253 percentHeight:percentHeight, 254 percentTop:percentTop, 255 percentLeft:percentLeft 256 }; 257 258 259 260 this.sizeTimer(frame); 261 262 //jQuery(document).scroll(function() {profi.sizeCounter(profi.counter,frame);}); 263 //z-index 264 //log(this.dataContainer[this.counter].css('zIndex')); 265 if (!this.startZindex) { 266 this.startZindex = this.dataContainer[this.counter].css('zIndex'); 267 } 268 this.dataContainer[this.counter].css('zIndex',parseInt(this.startZindex)+this.zIndex); 269 if (frame) { //vlozeni obsahu do iframu 270 var iframe = '<div style="width:100%; height:'+parseInt(ch-75)+'px;"><iframe border="0" frameBorder="0" name="profiPopupDataIframe'+this.counter+'" style="width:100%;height:'+parseInt(ch-10)+'px;border:0px solid #fff;padding:0;margin:0;" id="profiPopupDataIframe'+this.counter+'" src="'+url + (url.indexOf('?') == -1 ? '?' : '&') + 'frameheight='+parseInt(ch-10)+'"></iframe></div>'; 271 this.dataContainerIn[this.counter].html(iframe); 272 if (typeof callback == "function") { //bude fungovat ? Otestovat !! 273 jQuery('#profiPopupDataIframe'+this.counter).load(callback); 274 } 275 } else { 276 277 if(url == 'map') { 278 jQuery('#as4uPopupDataContainerIn'+counter).html('<div style="position: relative; width: 100%; height: 100%;" id="map"></div>'); 279 } else if (url) { 280 url += adurl; 281 this.loadData(url); 282 return this.counter; 283 } else { 284 return this.counter; 285 } 286 } 287 288}; 289 290As4uPopup.prototype.getAvailableId = function() { 291 try { 292 var els = jQuery('.as4uPopupDataContainerUnactive'); 293 if (els.length > 0) { 294 log(jQuery(els[0])); 295 return jQuery(els[0]).attr('id').replace('as4uPopupDataContainer',''); 296 } else { 297 return jQuery('.as4uPopupDataContainer').length + 1; 298 } 299 } catch (e) { 300 log(e.message); 301 return 5; 302 } 303}; 304 305 //specialni volani pro mapy -> nutna absolutni pozice 306As4uPopup.prototype.show4map = function(url,cw,ch,callback,frame,win) { 307 308 309 //zapamatujeme si pozice scroll baru 310 //var counter = this.counter + 1; 311 this.counter = this.getAvailableId(); 312 this.zIndex++; 313 var counter = this.counter; 314 315 var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); 316 var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); 317 if (typeof this.scrollPositions[counter] == "undefined") { 318 this.scrollPositions[counter] = {}; 319 } 320 this.scrollPositions[counter].top = scrollTop; 321 this.scrollPositions[counter].left = scrollLeft; 322
323 var toto = this; 324 var fce = function() { 325 if (document.documentElement.scrollTop) { 326 document.documentElement.scrollTop = 0; 327 } else { 328 document.body.scrollTop = 0; 329 } 330 if (document.documentElement.scrollLeft) { 331 document.documentElement.scrollLeft = 0; 332 } else { 333 document.body.scrollLeft = 0; 334 } 335 if (jQuery('#as4uPopupDataContainer'+counter).length > 0) { 336 if (!jQuery('#as4uPopupDataContainer'+counter).hasClass('as4uPopupDataContainerUnactive')) { 337 toto.scrollPositions[counter].timer = setTimeout( 338 fce, 100 339 ); 340 } 341 } 342 }; 343 this.scrollPositions[counter].timer = setTimeout( 344 fce, 100 345 ); 346 347 348 if(url == 'defaultmap'){ 349 this.show('map',cw,ch,callback,frame,win); 350 } else { 351 this.show(url,cw,ch,callback,frame,win); 352 } 353 354 355}; 356 357As4uPopup.prototype.sizeTimer = function(frame) { 358 359 for (var id in this.rozmery) { 360 this.sizeCounter(id, frame); 361 } 362 var profi = this; 363 this.sizeCasovac = setTimeout(function () { 364 profi.sizeTimer(frame); 365 }, 100); 366 367}; 368 369As4uPopup.prototype.sizeCounter = function(id,frame) { 370 /*console.log('Resize kontrola'); 371 console.log('Stavajici rozmery'); 372 console.log(this.rozmery[id]); 373 console.log(this.rozmery[id].width);*/ 374 if (!this.dataContainer[id]) { 375 //console.log('Neni okno, konec casovace'); 376 return; 377 } 378 379 if (typeof this.rozmery[id] == "undefined") return; 380 381 //log('Okno - ' + id); 382 383 if ((this.rozmery[id].width != jQuery(window).width() 384 || this.rozmery[id].height != jQuery(window).height() 385 || this.rozmery[id].bwidth != jQuery('body').width() 386 || this.rozmery[id].bheight != jQuery('body').height()) 387 && this.dataContainer[id]) { 388 //log('Detekovana zmÄna ' + id); 389 //log(this.dataContainer[id].length); 390 391 //vypocteme nove rozmery z puvodnich procentnich 392 var cw = ((this.rozmery[id].percentWidth/100)*jQuery(window).width()); 393 var ch = ((this.rozmery[id].percentHeight/100)*jQuery(window).height()); 394 395 //log('Resize rozmery: ' +jQuery(window).width()+'x'+jQuery(window).height() + ' -- ' + cw + 'x' + ch ); 396 397 jQuery(this.dataContainer[id]).css('width', cw); 398 jQuery(this.dataContainer[id]).css('height', ch); 399 if (frame) { 400 var listah = 0; 401 try { 402 if (this.dataContainerLista[id]) { 403 listah = this.dataContainerLista[id].height(); 404 } 405 } catch (e) {} 406 jQuery('#profiPopupDataIframe'+id).css('height', ch-10 - listah); 407 } 408 409 //top left pozice z procentni pozice 410 var top = ((this.rozmery[id].percentTop/100)*jQuery(window).height()); 411 var left = ((this.rozmery[id].percentLeft/100)*jQuery(window).width()); 412 413 jQuery(this.dataContainer[id]).css('top', top); 414 jQuery(this.dataContainer[id]).css('left', left); 415 416 417 this.rozmery[id].width = jQuery(window).width(); 418 this.rozmery[id].height = jQuery(window).height(); 419 this.rozmery[id].bwidth = jQuery('body').width(); 420 this.rozmery[id].bheight = jQuery('body').height(); 421 422 if (this.overlay[id]) { 423 jQuery(this.overlay[id]).css('width', jQuery('body').width()); 424 jQuery(this.overlay[id]).css('height', jQuery('body').height()); 425 } 426 427 //pozici okna odpocteme z puvodnich souradnic 428 //var oldtop = parseInt(this.dataContainer[id].css('top'), 10); 429 //var oldleft = parseInt(this.dataContainer[id].css('left'), 10); 430 431 432 433 } 434 435}; 436 437/** 438 * seVazba umozni nastavit vazbu prave otevrenemu oknu na jiz existujici okno 439 * zavre-li se okno id -> zavre se i okno s nastavenou vazbou 440 */ 441 442As4uPopup.prototype.setVazba = function(id) { 443 var i = this.counter; 444 if (typeof this.vazby == "undefined") { 445 this.vazby = {}; 446 } 447 if (!this.vazby[id]) this.vazby[id] = []; 448 this.vazby[id].push(i); 449}; 450 451As4uPopup.prototype.close = function(id) { 452 try { 453 if (!id) { 454 var id = this.counter; 455 } 456 if (this.overlay[id]) { 457 this.overlay[id].detach(); 458 this.overlay[id] = ''; 459 } 460 /*this.dataContainer[id].detach(); 461 this.dataContainer[id] = null; 462 jQuery('#as4uPopupDataContainer'+[id]).detach(); */ 463 464 465 this.dataContainer[id].html(''); 466 if ($('#as4uPopupDataContainer'+id).length > 0) { 467 $('#as4uPopupDataContainer'+id).html(''); 468 $('#as4uPopupDataContainer'+id).addClass('as4uPopupDataContainerUnactive').hide(); 469 } 470 471 472 //after close callback 473 if (typeof this.afterCloseCallbacks[id] == "function") { 474 this.afterCloseCallbacks[id](); 475 this.afterCloseCallbacks[id] = null; 476 } 477 478 if (typeof this.scrollPositions[id] != 'undefined') { 479 jQuery('html, body').animate({scrollTop:this.scrollPositions[id].top}, 100); 480 } 481 if (typeof this.scrollPositions[id] != 'undefined') 482 jQuery('html, body').animate({scrollLeft:this.scrollPositions[id].left}, 100); 483 484 clearTimeout(this.casovac[id]); 485 486 if (typeof this.vazby != "undefined") { 487 if (this.vazby[id]) { 488 for (var i in this.vazby[id]) { 489 this.close(this.vazby[id][i]); 490 } 491 } 492 } 493 494 } catch(e) {log('Chyba close'+ e.message); } 495}; 496 497As4uPopup.prototype.loadData = function(url,plus,dataType) { 498 var profi = this; 499 var counter = this.counter; 500 if (!dataType) 501 var dataType = 'xml'; 502 503 this.dataContainerIn[this.counter].css("background",'url(/images/gallery/loading.gif) no-repeat scroll center center #FFFFFF'); 504 505 profi.dataContainerIn[counter].load(url, 506 function(){ 507 jQuery(profi.dataContainerIn[counter]).css("backgroundImage", ""); 508 509 try { //inicializace galerie 510 if (!this.gallery4u) { 511 this.gallery4u = new Gallery4u(''); //inicializace 512 var obj = this; 513 jQuery(document).mousemove(function(e){ 514 obj.gallery4u.jMousePosX = e.pageX; 515 obj.gallery4u.jMousePosY = e.pageY; 516 }); 517 } else {
518 this.gallery4u.init(); 519 } 520 } catch(e) { 521 } 522 if (typeof profi.afterDataLoaded == "function") { //callback 523 profi.afterDataLoaded(); 524 profi.afterDataLoaded = ""; 525 //alert(profi.dataContainerIn[counter]); 526 } 527 }); 528 529}; 530 531//29.8.2011 - set title - moznost zadat title okna 532 //- pokud nezadam id, beru posledni vytvoreny popup 533As4uPopup.prototype.setTitle = function(title, id) { 534 if (!id) { 535 var id = this.counter; 536 } 537 //lista_title 538 this.dataContainer[id].find('.lista_title').eq(0).html(title); 539}; 540 541var as4uPopup = new As4uPopup();
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.