1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{ 2let window = _____WB$wombat$assign$function_____("window"); 3let self = _____WB$wombat$assign$function_____("self"); 4let document = _____WB$wombat$assign$function_____("document"); 5let location = _____WB$wombat$assign$function_____("location"); 6let top = _____WB$wombat$assign$function_____("top"); 7let parent = _____WB$wombat$assign$function_____("parent"); 8let frames = _____WB$wombat$assign$function_____("frames"); 9let opens = _____WB$wombat$assign$function_____("opens"); 10(function(){dojo.require('dojo.uacss'); 11 12dojo.declare("AJAXSearchBase", null, { 13 constructor: function(args) { 14 dojo.mixin(this,args); 15 this.list = new Array(); // the search result array 16 this.selected = 0; //the actual selected search result 17 this.pluginCounter = new Array(); 18 this.timeStamp = 0; // the latest timestamp 19 this.categoryChooserVisible = 0; // Is the category chooser visible? 0:No 1:Yes 20 this.resultsVisible = 0; // Are the results visible? 0:No 1:Yes 21 this.fadeInResult=1; // At first time the results should come up with fade-in effect 22 if(this.voicesearch == 1) dojo.attr(this.textBox, "x-webkit-speech", ""); 23 if(dojo.isIE <= 7){ 24 var w = dojo.position(this.textBox.parentNode).w-dojo.style(this.textBox, 'paddingLeft')-dojo.style(this.textBox, 'paddingRight'); 25 dojo.style(this.textBox, 'width', (w-1)+'px'); 26 } 27 28 this.searchBoxContainer = dojo.query(".offlajn-ajax-search-container", this.node)[0]; 29 30 if(this.catChooser){ 31 this.categoryChooser = dojo.query(".category-chooser", this.searchForm)[0]; 32 dojo.place(this.searchCategories,dojo.body()); 33 this.searchCategoriesList = dojo.query(".search-categories-inner div", this.searchCategories); 34 } 35 36 if(this.catChooser){ 37 dojo.connect(this.categoryChooser,'onclick',this,'showCategoryChooser'); 38 dojo.connect(this.categoryChooser, "onclick", this, "stopCategoryChooserEventBubble"); 39 } 40 41 dojo.attr(this.textBox, "value", this.searchBoxCaption); 42 dojo.addClass(this.textBox, "search-caption-on"); 43 this.suggestBox.value= "" 44 45 if(this.searchResult){ 46 dojo.connect(this.textBox,'oninput',this,'type'); 47 dojo.connect(this.textBox,'onkeyup',this,'type'); 48 dojo.connect(this.textBox,'oncompositionupdate',this,'type'); //Japanese support 49 } 50 51 dojo.connect(this.textBox,'onfocus',this,'textBoxFocus'); 52 dojo.connect(this.textBox,'onblur',this,'textBoxBlur'); 53 dojo.connect(this.textBox,'onwebkitspeechchange',this,'soundEnd'); 54 55 //if suggestion 56 if(this.keywordSuggestion=="1"){ 57 dojo.connect(this.textBox,'onkeyup',this,'suggest'); 58 } 59 dojo.connect(this.suggestBox,'onfocus',this,'suggestBoxFocus'); 60 dojo.connect(this.suggestBox, "onclick", this, "stopEventBubble"); 61 62 dojo.connect(this.closeButton,'onclick',this,'closeResults'); 63 dojo.connect(this.searchButton,'onclick',this,'loadResult'); 64 65 dojo.connect(this.textBox, "onclick", this, "stopInputEventBubble"); 66 67 if(this.catChooser) 68 dojo.forEach(this.searchCategoriesList, function(entry, i){ 69 dojo.connect(entry, "onclick", this, "categorySelection"); 70 dojo.connect(entry, "onclick", this, "stopEventBubble"); 71 },this); 72 dojo.connect(window,'onresize',this,'onResize'); 73 74 }, 75 76 stopEventBubble: function(e){ 77 e.stopPropagation(); 78 }, 79 80 stopInputEventBubble: function(e){ 81 this.dummyCloseResult = 1; 82 }, 83 84 stopCategoryChooserEventBubble: function(e){ 85 this.dummyHideCategory = 1; 86 }, 87 88 loadResult : function(e){ 89 if(this.targetsearch == 3) { 90 e.stopPropagation(); 91 } else { 92 if(this.textBox.value.length >=this.minChars){ 93 this.searchForm.submit(); 94 } 95 } 96 }, 97 98 type: function(evt, force){ 99 if (window.event) { 100 if (window.event.type == 'keyup' && window.event.keyCode != 13) return; 101 this.keycode = window.event.keyCode; 102 this.ktype = window.event.type; 103 } else if (evt) { 104 if (evt.type == 'keyup' && evt.which != 13) return; 105 this.keycode = evt.which; 106 this.ktype = evt.type; 107 } 108 if (this.ktype == 'input') this.keycode = 48; 109 clearTimeout(this.t); 110 this.t = setTimeout(dojo.hitch(this, function() { 111 if(((this.targetsearch == 3 && this.keycode==13) || (this.keycode>40 || this.keycode==13) || this.keycode==32 || this.keycode==8 || this.keycode==0 || this.ktype=="click") && this.textBox.value.length >=this.minChars || force==1){ 112 var categories = new Array();
113 dojo.forEach(this.searchCategoriesList, function(entry, i){ 114 if (dojo.hasClass(entry, "selected")) 115 categories.push(dojo.attr(entry,"id").match(/\d+/)[0]); 116 }); 117 dojo.style(this.closeButton, "visibility", "visible"); 118 dojo.style(this.textBox,"paddingRight","52px"); 119 dojo.addClass(this.closeButton, "search-area-loading"); 120 dojo.xhrGet({ 121 url : this.searchFormUrl, 122 content: { option: "com_universal_ajax_live_search", lang: this.lang, module_id : this.moduleId, search_exp: this.textBox.value, 'categ[]' : categories, dojo_preventCache: new Date().getTime(), smart_categories: this.jcategories }, 123 handleAs:"text", 124 preventCache : false, 125 load: dojo.hitch(this,'processResult'), 126 error: function(e){ 127 console.log('Error: '+e); 128 } 129 }); 130 } 131 }), this.keypressWait); 132 }, 133 134 suggest: function(evt){ 135 if (window.event) { 136 this.keycode = window.event.keyCode; 137 this.ktype = window.event.type; 138 } else if (evt) { 139 this.keycode = evt.which; 140 this.ktype = evt.type; 141 } 142 if((this.keycode>40 || this.keycode==32 || this.keycode==8 || this.keycode==0 || this.ktype=="click") && this.textBox.value.length >=2 || this.keycode==46 || this.keycode==8 ){ 143 dojo.xhrGet({ 144 url : this.searchFormUrl, 145 content: { option: "com_universal_ajax_live_search", format: "raw", search_exp: this.textBox.value, suggest: 1, dojo_preventCache : new Date().getTime(), smart_categories: this.jcategories }, 146 handleAs:"text", 147 preventCache : false, 148 load: dojo.hitch(this,'processSuggestion'), 149 error: function(e){ 150 console.log('Error: '+e); 151 } 152 }); 153 }else if(this.keycode==39 && this.getCaret(this.textBox)==this.textBox.value.length && this.suggestBox.value!= ""){ 154 this.textBox.value+= this.suggestBox.value.substr(this.textBox.value.length); 155 this.type(evt,1); 156 } 157 }, 158 159 suggestBoxFocus : function(evt){ 160 this.textBox.focus(); 161 }, 162 163 getCaret: function (el) { 164 if (el.selectionStart) { 165 return el.selectionStart; 166 } else if (document.selection) { 167 el.focus(); 168 169 var r = document.selection.createRange(); 170 if (r == null) { 171 return 0; 172 } 173 174 var re = el.createTextRange(), 175 rc = re.duplicate(); 176 re.moveToBookmark(r.getBookmark()); 177 rc.setEndPoint('EndToStart', re); 178 179 return rc.text.length; 180 } 181 return 0; 182 }, 183 184 saveSuggestion : function(evt){ 185 dojo.xhrGet({ 186 url : this.searchFormUrl, 187 content: { option: "com_universal_ajax_live_search", format: "raw", search_exp: this.textBox.value, savesuggest:1, dojo_preventCache : new Date().getTime(), smart_categories: this.jcategories }, 188 handleAs:"text", 189 preventCache : false 190 }); 191 if(this.linktarget != '1') { //check if target is _blank or not 192 setTimeout(dojo.hitch(this, function(ct) { 193 if(!ct) 194 document.location.href = dojo.attr(this.list[this.selected-1],"href"); 195 else 196 document.location.href = ct.href; 197 },evt?evt.currentTarget:null),200); 198 } 199 }, 200 201 processSuggestion : function(d,xhr){ 202 try{ 203 var data = eval('('+d+')'); 204 }catch(err){ 205 //alert('SuggestionError: '+d); return; 206 } 207 if (data[0]) 208 this.suggestBox.value= this.textBox.value + data[0].suggestion.toLowerCase().substr(this.textBox.value.length); 209 else 210 this.suggestBox.value= ""; 211 }, 212 213 changeText: function(e) { 214 this.textBox.value = e.currentTarget.innerHTML; 215 }, 216 217 textBoxFocus : function(){ 218 if (this.catChooser) this.hideCategoryChooser(); 219 dojo.addClass(this.searchBoxContainer,"active"); 220 if(dojo.hasClass(this.textBox, "search-caption-on")){ 221 dojo.attr(this.textBox, "value", ""); 222 dojo.removeClass(this.textBox, "search-caption-on"); 223 } 224 dojo.addClass(this.node,"active"); 225 }, 226 227 soundEnd : function(e) { 228 this.textBoxFocus(); 229 dojo.attr(this.textBox, "value", e.results[0].utterance); 230 this.type(e,1); 231 }, 232 233 234 textBoxBlur : function(){ 235 if(dojo.hasClass(this.searchBoxContainer, "active") && !this.resultsVisible){ 236 dojo.removeClass(this.searchBoxContainer,"active"); 237 } 238 if (this.textBox.value.length==0){ 239 dojo.attr(this.textBox, "value", this.searchBoxCaption); 240 dojo.addClass(this.textBox, "search-caption-on"); 241 this.suggestBox.value= "" 242 } 243 if(dojo.hasClass(this.node, "active")) dojo.removeClass(this.node,"active"); 244 }, 245 246 showCategoryChooser : function(evt){ 247 if(!this.categoryChooserVisible){ 248 this.textBox.blur(); 249 if(dojo.style(this.closeButton, "visibility")== "visible"){ //remove results if the were 250 dojo.attr(this.textBox, "value", ""); 251 this.closeResults(); 252 } 253 254 if(this.categoryFx && this.categoryFx.status() == "playing"){ 255 this.categoryFx.stop(); 256 } 257 this.categoryChooserVisible = 1; 258 this.textBoxPosition = dojo.position(this.textBox, true); 259 260 var left = this.getCategoryLeftPosition(); 261 262 dojo.style(this.searchCategories,{ 263 left: left+'px', 264 top: (this.textBoxPosition.y+this.textBoxPosition.h-10+this.categoryChooserTopCorrection)+'px', 265 visibility : 'visible', 266 opacity : '0' 267 });
268 this.categoryFx = dojo.animateProperty({node: this.searchCategories, properties: {opacity : 1, top: { end:this.textBoxPosition.y+this.textBoxPosition.h+this.categoryChooserTopCorrection, units:"px" }}, duration: 200}).play(); 269 dojo.addClass(this.categoryChooser,"opened"); 270 this.hideCategories = dojo.connect(dojo.body(),'onclick',this,'hideCategoryChooser'); 271 }else{ 272 this.hideCategoryChooser(); 273 } 274 }, 275 276 hideCategoryChooser : function(evt){ 277 if(this.dummyHideCategory == 1){ 278 this.dummyHideCategory = 0; 279 return; 280 } 281 dojo.disconnect(this.hideCategories); 282 if(this.categoryFx && this.categoryFx.status() == "playing"){ 283 this.categoryFx.stop(); 284 } 285 this.categoryFx = dojo.animateProperty({ 286 node: this.searchCategories, 287 properties: {opacity : 0}, 288 onEnd: function(){ 289 dojo.style(this.node,{visibility : 'hidden'})}, 290 duration: 200 291 }).play(); 292 dojo.removeClass(this.categoryChooser,"opened"); 293 this.categoryChooserVisible = 0; 294 }, 295 296 categorySelection: function(evt){ 297 var node = evt.currentTarget; 298 if(dojo.hasClass(node, "selected")) 299 dojo.removeClass(node, "selected") 300 else 301 dojo.addClass(node, "selected"); 302 303 } 304 305}); 306 307dojo.copyTouch = function(sourceObj, targetObj){ 308 targetObj.screenX = sourceObj.screenX; 309 targetObj.screenY = sourceObj.screenY; 310 targetObj.identifier = sourceObj.identifier; 311}; 312 313/*The drop-style searches base*/ 314dojo.declare("AJAXSearchDropBase", AJAXSearchBase, { 315 constructor: function(args) { 316 dojo.mixin(this,args); 317 this.categoryChooserTopCorrection = 0; 318 319 this.searchResults = dojo.create("div", {id: "search-results"+this.id}, dojo.body()); 320 this.searchResultsMoovable = dojo.create("div", {id: "search-results-moovable"+this.id}, this.searchResults); 321 this.searchResultsInner = dojo.create("div", {id: "search-results-inner"+this.id}, this.searchResultsMoovable); 322 323 this.touch = {screenX: 0, screenY: 0, identifier: ''}; 324 dojo.connect(this.searchResults, "onclick", this, "stopEventBubble"); 325 326 dojo.connect(document, "onclick", this, "closeResults"); 327 dojo.connect(this.textBox,'onkeypress',this,'arrowNavigation'); 328 }, 329 330 onResize: function(){ 331 this.textBoxPos = dojo.position(this.searchForm.parentNode, true); 332 var left = this.textBoxPos.x; 333 if (this.resultAlign==1){ // if search result aligned to right 334 left+=this.textBoxPos.w-this.searchRsWidth; 335 } 336 dojo.style(this.searchResults,{ 337 left: left+'px', 338 top: this.textBoxPos.y+this.textBoxPos.h+this.resultboxTopOffset+'px' 339 }); 340 if(this.dynamicResult=="1"){ 341 dojo.style(this.searchResults,{ 342 left: left+'px', 343 top: this.textBoxPos.y+this.textBoxPos.h+this.resultboxTopOffset+'px', 344 width : this.textBoxPos.w+'px' 345 }); 346 dojo.style(this.searchResultsInner,{ 347 width : this.textBoxPos.w+'px' 348 }); 349 350 if(dojo.query(".no-result", this.searchResults).length>0) 351 dojo.style(dojo.query(".no-result", this.searchResults)[0],{ 352 width : this.textBoxPos.w+'px' 353 }); 354 355 dojo.forEach(dojo.query(".result-element", this.searchResults), function(entry, i){ 356 dojo.style(entry,{ 357 width : this.textBoxPos.w+'px' 358 }); 359 360 var span = dojo.query("span", entry); 361 dojo.style(span[0],{ 362 width : (this.textBoxPos.w-17)+'px' 363 }); 364 365 if(this.showIntroText == 1 && span[1]) { 366 dojo.style(span[1],{ 367 width : (this.textBoxPos.w-17)+'px' 368 }); 369 } 370 371 if(dojo.hasClass(entry, "result-products")){ 372 dojo.style(span[0],{ 373 width : (this.textBoxPos.w-12-this.searchImageWidth-17)+'px' 374 }); 375 if(this.showIntroText == 1 && span[1]) { 376 dojo.style(span[1],{ 377 width : (this.textBoxPos.w-12-this.searchImageWidth-17)+'px' 378 }); 379 } 380 } 381 382 },this); 383 this.searchRsWidth = this.textBoxPos.w; 384 } 385 }, 386 387 processResult : function(d,xhr){ 388 d = d.match(/startofofflajnsearchresult(.+)endofofflajnsearchresult/)[1]; 389 try{ 390 var data = eval('('+d+')'); 391 }catch(err){ 392 alert('Error: '+d); return; 393 } 394 // timestamp check if this is the latest search 395 var regexp = /.*&dojo_preventCache=(\d+)/i; 396 var result = xhr.url.match(regexp); 397 if (result[1]){ 398 if (result[1]>this.timeStamp){ 399 this.timeStamp = result[1]; 400 }else{ 401 dojo.removeClass(this.closeButton, "search-area-loading"); 402 dojo.style(this.closeButton, "visibility", "visible"); 403 dojo.style(this.textBox,"paddingRight","52px"); 404 return; 405 } 406 } 407 408 dojo.attr(this.searchResultsInner, { innerHTML: "" }); 409 this.list=[]; 410 this.pluginCounter=[]; 411 this.selected = 0; 412 this.onResize(); 413 414 if(data.length!=0 && !data.nores){ 415 this.paginationBand = new Array(); 416 var actualPlugin = 0; 417 for(var i in data){ 418 this.paginationBand[actualPlugin] = new Array; 419 var pluginResults = data[i]; 420 var pluginNameDiv = dojo.create("div", {'class': "plugin-title"}, this.searchResultsInner); 421 if (actualPlugin==0){
422 dojo.addClass(pluginNameDiv, 'first'); 423 } 424 /*Adding plugin title*/ 425 dojo.create("div", {'class': "plugin-title-inner", innerHTML: i+" ("+pluginResults.length+")"}, pluginNameDiv); 426 427 /*Generate pagination*/ 428 this.generatePagination(pluginNameDiv,pluginResults.length,actualPlugin); 429 this.pluginCounter.push(pluginResults.length); 430 431 /*Generate resultList*/ 432 this.generateResultList(pluginResults, actualPlugin); 433 434 actualPlugin++; 435 } 436 /*Set the selected item to 0 (it is invisible)*/ 437 this.selectItem(0); 438 } 439 440 this.tags=""; 441 442 if(this.searchResultsInner.childNodes.length){ 443 this.innerHeight = dojo.marginBox(this.searchResultsInner).h; 444 } else if (data.nores && data.nores[0] && data.nores[0].tag && (data.nores.length>1 || this.textBox.value!=data.nores[0].tag)) { /* No results but keywords found. */ 445 var pluginNameDiv = dojo.create("div", {'class': "plugin-title first suggest"}, this.searchResultsInner); 446 dojo.create("div", {'class': "plugin-title-inner", innerHTML: this.stext}, pluginNameDiv); 447 dojo.create("div", {'class': "ajax-clear"}, pluginNameDiv); 448 for (var j=0;j<data.nores.length-1;j++) { 449 if (this.textBox.value!=data.nores[j].tag) 450 this.tags += "<a class='sugg-keyword'>"+data.nores[j].tag+"</a>, "; 451 } 452 this.tags += "<a class='sugg-keyword'>"+data.nores[j].tag+"</a>"; 453 454 dojo.create("div", {'class': "no-result-suggest", innerHTML: '<span>'+this.tags+'</span>'}, this.searchResultsInner); 455 dojo.query("a[class=sugg-keyword]").connect("onclick", this, "changeText"); 456 dojo.query("a[class=sugg-keyword]").connect("onclick", this, "type"); 457 this.innerHeight = dojo.marginBox(this.searchResultsInner).h; 458 }else{ /* No result for the keyword */ 459 var pluginNameDiv = dojo.create("div", {'class': "plugin-title first"}, this.searchResultsInner); 460 dojo.create("div", {'class': "plugin-title-inner", innerHTML: this.noResultsTitle}, pluginNameDiv); 461 dojo.create("div", {'class': "ajax-clear"}, pluginNameDiv); 462 dojo.create("div", {'class': "no-result", innerHTML: '<span>'+this.noResults+'</span>'}, this.searchResultsInner); 463 this.innerHeight = dojo.marginBox(this.searchResultsInner).h; 464 } 465 dojo.removeClass(this.closeButton, "search-area-loading"); 466 this.onResize(); 467 this.animateResult(); 468 }, 469 470 /*Generate pagination*/ 471 generatePagination : function(pluginNameDiv, dataLength, actualPlugin){ 472 this.paginationBand[actualPlugin].paginators= new Array(); 473 if (dataLength>this.productsPerPlugin){ //not generate if there is just 1 page 474 var pagination = dojo.create("div", {'class': "pagination "+"paginator-"+actualPlugin}, pluginNameDiv); 475 var pageNumber = Math.floor(dataLength/this.productsPerPlugin+0.99999); // 0.99999 constant because: 1.00001 must round to 2, 2.00001 to 3, etc.. 476 for(var num=0;num < pageNumber; num++){ 477 var paginatorElement = dojo.create("div", {'class': "pager"}, pagination); 478 paginatorElement.parentPlugin = actualPlugin; 479 paginatorElement.page = num; 480 481 dojo.connect(paginatorElement,'onclick',this,'moovePage'); // coonect an event to paginators 482 483 if (num==0){ 484 dojo.addClass(paginatorElement, 'active'); 485 this.paginationBand[actualPlugin].activePaginator = paginatorElement; 486 } 487 488 this.paginationBand[actualPlugin].paginators.push(paginatorElement); //adding the paginators to the band to adding active class when arrows are in use 489 } 490 } 491 dojo.create("div", {'class': "ajax-clear"}, pluginNameDiv); 492 }, 493 494 /*Generate resultList*/ 495 generateResultList : function(pluginResults, actualPlugin){ 496 497 var pageContainer = dojo.create("div", {'class': "page-container"}, this.searchResultsInner); 498 var pageBand = dojo.create("div", {'class': "page-band "+"page-band-"+actualPlugin}, pageContainer); 499 this.paginationBand[actualPlugin].band = pageBand; 500 pageBand.currentPage=0; 501 pageBand.maxPage = Math.floor(pluginResults.length/this.productsPerPlugin+0.99999); 502 pageBand.plugin = actualPlugin; 503 //connect the mouse scroller 504 if(this.enableScroll==1){ 505 dojo.connect(pageBand, (!dojo.isMozilla ? "onmousewheel" : "DOMMouseScroll"), this, "scrollResultList"); 506 dojo.connect(pageBand, "ontouchstart", this, "touchStart"); 507 dojo.connect(pageBand, "ontouchend", this, "touchEnd"); 508 dojo.connect(pageBand, "ontouchmove", dojo.stopEvent); 509 } 510 var page = null; 511 512 for(var j=0;j<pluginResults.length;j++){ 513 if (j%this.productsPerPlugin==0){ // 2 is the count to show 514 page = dojo.create("div", {'class': "page-element list"+Math.floor(j/this.productsPerPlugin)}, pageBand); 515 } 516 var atag = null; 517 var introText=""; 518 if (this.showIntroText==1 && pluginResults[j].text){ 519 introText = '<span class="small-desc">'+pluginResults[j].text+'</span>'; 520 } 521 if(pluginResults[j].product_img){ //Virtuemart products 522 atag = dojo.create("a", {'class': "result-element result-products", innerHTML: pluginResults[j].product_img+'<span>'+pluginResults[j].title+'</span>'+introText, href:pluginResults[j].href, target: (this.linktarget=="1" ? '_blank' : '') }, page); 523 }else{ // Other search results 524 atag = dojo.create("a", {'class': "result-element", 'oncl
524ick':"return false;", innerHTML: '<span>'+pluginResults[j].title+'</span>'+introText, href:pluginResults[j].href}, page); 525 } 526 527 // SUGGESTION 528 dojo.connect(atag,'onclick',this,'saveSuggestion'); 529 530 atag.plugin=actualPlugin; 531 atag.item=j; 532 533 this.list.push(atag); 534 dojo.create("div", {'class': "ajax-clear"}, atag); 535 } 536 if(pluginResults.length<this.productsPerPlugin){ 537 dojo.style(pageContainer, "height", dojo.marginBox(pageBand).h +"px"); 538 } 539 if(pluginResults.length>=this.seemoreAfter && this.seemoreEnabled){ 540 var seemorediv = dojo.create("div", {'id':"seemore",'class': "seemore", innerHTML: '<span>'+this.seeMoreResults+'</span>'}, this.searchResultsInner); 541 dojo.connect(seemorediv,'onclick',this,'loadResult'); 542 dojo.removeClass(this.searchResultsInner, "withoutseemore"); 543 //dojo.style(this.searchResultsInner,"paddingBottom","0px"); 544 }else{ 545 dojo.addClass(this.searchResultsInner, "withoutseemore"); 546 //dojo.style(this.searchResultsInner,"paddingBottom","10px"); 547 } 548 }, 549 550 moovePage : function(event){ 551 var pager = event.target; 552 var band = this.paginationBand[pager.parentPlugin].band; 553 dojo.removeClass(this.paginationBand[pager.parentPlugin].activePaginator,"active"); 554 dojo.addClass(pager, "active"); 555 this.paginationBand[pager.parentPlugin].activePaginator = pager; 556 557 if(band.actFx && band.actFx.status() == "playing"){ 558 band.actFx.stop(); 559 } 560 band.actFx = dojo.animateProperty({node: band, properties: {left: -pager.page*this.searchRsWidth}, duration: 500}).play(); 561 this.textBox.focus(); 562 }, 563 564 scrollPluginResults : function(band, page){ 565 if(band.actFx && band.actFx.status() == "playing"){ 566 band.actFx.stop(); 567 } 568 band.actFx = dojo.animateProperty({node: band, properties: {left: -page*this.searchRsWidth}, duration: 250}).play(); 569 band.currentPage=page; 570 }, 571 572 animateResult : function(){ 573 if(this.actFx && this.actFx.status() == "playing"){ 574 this.actFx.stop(); 575 } 576 this.resultsVisible = 1; 577 dojo.style(this.searchResults, "visibility", "visible"); 578 if(this.innerHeight){ 579 this.actFx = this.getResultBoxAnimation(); 580 } else{ // No results found 581 this.actFx = dojo.animateProperty({ 582 node: this.searchResultsMoovable, 583 properties: { 584 height: 0 585 }, 586 duration: 500, 587 onEnd : dojo.hitch(this,'removeResults') 588 }).play(); 589 } 590 dojo.style(this.closeButton, "visibility", "visible"); 591 dojo.style(this.textBox,"paddingRight","52px"); 592 }, 593 594 closeResults : function(e){ 595 dojo.style(this.textBox,"paddingRight","30px"); 596 if(e && e.button && e.button > 0) return; 597 if(this.dummyCloseResult == 1){ 598 this.dummyCloseResult = 0; 599 return; 600 } 601 if(this.actFx && this.actFx.status() == "playing"){ 602 if(dojo.hasClass(this.textBox, "search-caption-on")) 603 return; 604 this.actFx.stop(); 605 } 606 this.actFx = this.getCloseResultBoxAnimation(); 607 dojo.style(this.closeButton, "visibility", "hidden"); 608 dojo.style(this.textBox,"paddingRight","30px"); 609 dojo.attr(this.textBox, "value", this.searchBoxCaption); 610 dojo.addClass(this.textBox, "search-caption-on"); 611 this.suggestBox.value= "" 612 613 }, 614 615 removeResults: function(){ 616 this.fadeInResult=1; 617 dojo.attr(this.searchResultsInner, { innerHTML: "" }); 618 if(this.searchResultsInner.childNodes.length){ 619 this.innerHeight = dojo.marginBox(this.searchResultsInner).h; 620 }else{ 621 this.innerHeight=0; 622 } 623 dojo.style(this.searchResults, "visibility", "hidden"); 624 this.resultsVisible=0; 625 if(dojo.hasClass(this.searchBoxContainer, "active") && !this.resultsVisible){ 626 dojo.removeClass(this.searchBoxContainer,"active"); 627 } 628 }, 629 630 /*keyCodes: 631 UP: 38 632 DOWN: 40 633 ENTER: 13*/ 634 635 arrowNavigation: function(evt){ 636 if(evt.keyCode==27){ //blur if esc pressed 637 this.textBox.blur(); 638 if(dojo.style(this.closeButton, "visibility")== "visible"){ //remove results if the were 639 dojo.attr(this.textBox, "value", ""); 640 this.closeResults(); 641 } 642 } 643 if(this.list.length){ 644 if(evt.keyCode==38){ 645 this.selectItem(this.selected-1); 646 }else if (evt.keyCode==40){ 647 this.selectItem(this.selected+1); 648 }else if (evt.keyCode==13){ 649 if(this.selected==0){ 650 this.loadResult(); 651 }else{ 652 this.saveSuggestion(); 653 // Here was the href loading 654 } 655 } 656 657 if(this.selected>0){ 658 var actPlugin = this.list[this.selected-1].plugin; 659 var actPluginItem = this.list[this.selected-1].item; 660 var band = this.paginationBand[actPlugin].band; 661 var pgNumber = Math.floor(actPluginItem/this.productsPerPlugin); 662 if(this.paginationBand[actPlugin].activePaginator){ 663 dojo.removeClass(this.paginationBand[actPlugin].activePaginator,"active"); 664 665 this.scrollPluginResults(band,pgNumber); 666 var pager = this.paginationBand[actPlugin].paginators[pgNumber]; 667 dojo.addClass(pager, "active"); 668 this.paginationBand[actPlugin].activePaginator = pager; 669 } 670 } 671 672 }else if(evt.keyCode==13){ 673 this.loadResult(); 674 } 675 }, 676 //scrolling the results 677 scrollResultList : function(evt){ 678 var scroll = evt[(!dojo.isMozilla ? "wheelDelta" : "detail")] * (!dojo.isMozilla ? 1 : -1); 679 var band = evt.currentTarget; 680 if (band.maxPage>1){ 681 var actPlugin = band.plugin; 682 dojo.removeClass(this.paginationBand[actPlugin].activePaginator,"active"); 683 var pgNumber = band.currentPage; 684 if(scroll<0 && pgNumber<band.maxPage-1){ 685 pgNumber++; 686 }else if(scroll<0 && pgNumber>=band.maxPage-1){ 687 pgNumber=0; 688 }else if(scroll>0 && pgNumber>0){ 689 pgNumber--; 690 }else if(scroll>0 && pgNumber<=0){ 691 pgNumber=band.maxPage-1; 692 } 693 this.scrollPluginResults(band,pgNumber); 694 var pager = this.paginationBand[actPlugin].paginators[pgNumber]; 695 dojo.addClass(pager, "active"); 696 this.paginationBand[actPlugin].activePaginator = pager; 697 dojo.stopEvent(evt); 698 } 699 }, 700 701 selectItem : function(num){ 702 if(num>=this.list.length+1){ 703 num-=this.list.length+1; 704 } 705 if(num<0){ 706 num+=this.list.length+1; 707 } 708 if(this.list[this.selected-1]){ 709 dojo.removeClass(this.list[this.selected-1], "selected-element"); 710 } 711 if(this.list[num-1]){ 712 dojo.addClass(this.list[num-1], "selected-element"); 713 } 714 this.selected=num; 715 }, 716 717 post_to_url: function(path, params, method) { 718 method = method || "post"; // Set method to post by default, if not specified. 719 720 // The rest of this code assumes you are not using a library.
721 // It can be made less wordy if you use one. 722 var form = document.createElement("form"); 723 form.setAttribute("method", method); 724 form.setAttribute("action", path); 725 726 for(var key in params) { 727 var hiddenField = document.createElement("input"); 728 hiddenField.setAttribute("type", "hidden"); 729 hiddenField.setAttribute("name", key); 730 hiddenField.setAttribute("value", params[key]); 731 732 form.appendChild(hiddenField); 733 } 734 735 document.body.appendChild(form); 736 form.submit(); 737 }, 738 739 /*TOUCH Evenets*/ 740 touchStart: function(e){ 741 dojo.copyTouch(e.changedTouches[0], this.touch); 742 }, 743 744 touchEnd: function(e){ 745 if(this.touch.identifier == e.changedTouches[0].identifier){ 746 var dist = Math.sqrt(Math.pow(e.changedTouches[0].screenX-this.touch.screenX, 2) + Math.pow(e.changedTouches[0].screenY-this.touch.screenY, 2)); 747 if(dist > 80){ 748 var deg = Math.asin((e.changedTouches[0].screenY-this.touch.screenY)/dist)*180/Math.PI; 749 if(deg < 45 && deg > -45){ //horizontal 750 var scroll = e.changedTouches[0].screenX-this.touch.screenX; 751 this.paginateTouch(e,scroll); 752 } 753 } 754 } 755 }, 756 757 paginateTouch: function(evt, direction){ 758 var band = evt.currentTarget; 759 if (band.maxPage>1){ 760 var actPlugin = band.plugin; 761 dojo.removeClass(this.paginationBand[actPlugin].activePaginator,"active"); 762 var pgNumber = band.currentPage; 763 if(direction<0 && pgNumber<band.maxPage-1){ 764 pgNumber++; 765 }else if(direction<0 && pgNumber>=band.maxPage-1){ 766 pgNumber=0; 767 }else if(direction>0 && pgNumber>0){ 768 pgNumber--; 769 }else if(direction>0 && pgNumber<=0){ 770 pgNumber=band.maxPage-1; 771 } 772 this.scrollPluginResults(band,pgNumber); 773 var pager = this.paginationBand[actPlugin].paginators[pgNumber]; 774 dojo.addClass(pager, "active"); 775 this.paginationBand[actPlugin].activePaginator = pager; 776 dojo.stopEvent(evt); 777 } 778 } 779 780}); 781var AJAXSearch = {}; 782 783dojo.declare("AJAXSearchsimple", AJAXSearchDropBase, { 784 constructor: function(args) { 785 this.resultboxTopOffset = -3; 786 }, 787 788 getResultBoxAnimation: function(){ 789 if(this.fadeInResult){ //fade-in and down 790 dojo.style(this.searchResultsMoovable, "height", this.innerHeight+"px"); 791 792 this.textBoxPos = dojo.position(this.searchForm, true); 793 dojo.style(this.searchResultsMoovable, "opacity", 0); 794 dojo.style(this.searchResultsMoovable, "top", '-10px'); 795 this.fadeInResult=0; 796 return dojo.animateProperty({ 797 node: this.searchResultsMoovable, 798 properties: { 799 opacity: 1, 800 top: { end:0, units:"px" } 801 }, 802 duration: 300 803 }).play(); 804 }else{ 805 return dojo.animateProperty({ 806 node: this.searchResultsMoovable, 807 properties: { 808 height: {start: dojo.style(this.searchResultsMoovable, 'height'), end: this.innerHeight} 809 }, 810 duration: 500 811 }).play(); 812 } 813 }, 814 815 getCloseResultBoxAnimation: function(){ 816 return dojo.animateProperty({ 817 node: this.searchResultsMoovable, 818 properties: { 819 opacity: 0, 820 top: { end:10, units:"px" } 821 }, 822 duration: 300, 823 onEnd : dojo.hitch(this,'removeResults') 824 }).play(); 825 }, 826 827 getCategoryLeftPosition: function(){ 828 var categorySize = dojo.marginBox(this.searchCategories); 829 return this.textBoxPosition.x+this.textBoxPosition.w-categorySize.w; 830 } 831}); 832})(); 833}
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.