/* JCE Editor - 2.3.2.4 | 27 March 2013 | http://www.joomlacontenteditor.net | Copyright (C) 2006 - 2013 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
(function($){$.widget("ui.listFilter",{options:{list:null,items:null,clear:null,sort:null,hide:false,filter:null},_init:function(){var self=this,el=this.element,busy;var clear=this.options.clear;if(clear){$(clear).click(function(e){if($(clear).hasClass('clear')){$(clear).removeClass('clear');if($(el).val()){self._reset();$(el).val('');self._trigger('onFind',e,[]);}}});}
$(el).keyup(function(e){if(!busy){busy=true;window.setTimeout(function(){self._find($(el).val(),e);busy=false;},500);}});},_find:function(s,e){var self=this,x=[],f,v,filter;$(this.options.clear).toggleClass('clear',!!s);if(/[a-z0-9_\.-]/i.test(s)){$(this.options.items).each(function(){var n=$.String.basename($(this).attr('title'));if(s.charAt(0)=='.'){v=s.substr(1);f=n.substr(n.lastIndexOf('.')+1);filter=true;}else{f=n.substring(0,s.length);v=s;}
if(f.toLowerCase()==v.toLowerCase()){if($.inArray(this,x)==-1){x.push(this);}}else{var i=$.inArray(this,x);if(i!=-1){x.splice(i,1);}}});}else{x=[];}
if(x.length){x=self._sort(x);self._scroll(x[0]);if(this.options.filter&&filter){$(this.options.filter).not(x).hide();}}else{self._reset();}
self._trigger('onFind',e,x);},_scroll:function(el){var self=this,$list=$(this.options.list);var pos=$(el).position();var top=$list.scrollTop();$list.css('overflow','hidden').animate({scrollTop:pos.top+top},1000,function(){$list.css('overflow','auto');});},_sort:function(x){var a=[];$(this.options.items).each(function(){if($.inArray(this,x)!=-1){a.push(this);}});return a;},_reset:function(){$(this.options.filter).show();this._scroll($('li:first',this.options.list));},destroy:function(){$.Widget.prototype.destroy.apply(this,arguments);}});$.extend($.ui.searchables,{version:"2.3.2.4"});})(jQuery);