update to the latest suggest

git-svn-id: http://google-refine.googlecode.com/svn/trunk@608 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-05-06 01:34:06 +00:00
parent 5d6fa58258
commit df7a79089a
4 changed files with 85 additions and 153 deletions

View File

@ -52,7 +52,7 @@ li.fbs-selected .fbs-item-name{border-color:#f60;background:#fff;}
.fbs-suggestnew-button{color:#444444;}
ul.fbs-list,.fbs-flyout-content,.fbs-attribution,.fbs-header{border:1px solid #dae3e9;}
.fbs-header{border-bottom:0;}
li.fbs-item{border-bottom:1px solid #dae3e9;}
li.fbs-item{border-bottom:1px solid #dae3e9;list-style-type:none;}
.fbs-attribution{border-top:0;}
.fbs-pane,.fbs-flyout-pane{font-size:16px;font-family:Helvetica Neue, Arial, Helvetica, sans-serif;}
ul.fbs-list,.fbs-flyout-content,.fbs-attribution,div.fbs-header{font-size:62.5%;}
@ -111,4 +111,4 @@ p.fbs-flyout-image-true,h3.fbs-flyout-image-true,h1.fbs-flyout-image-true{margin
* html .fbs-item-name{width:253px !important;}
* html .fbs-item-name{width:100%;}
* html .fbs-flyout-content:after{height:1px;}
/* Version:r87595 Built:Tue Jan 05 2010 by daepark */
/* Version:r94143M Built:Thu Apr 29 2010 by daepark */

View File

@ -1,149 +0,0 @@
/******************************************************************************
* All source and examples in this project are subject to the
* following copyright, unless specifically stated otherwise
* in the file itself:
*
* Copyright (c) 2007-2009, Metaweb Technologies, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB TECHNOLOGIES BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
(function($,undefined){if(!window.console){window.console={log:function(){},info:function(){},debug:function(){},warn:function(){},error:function(){}};}
$.suggest=function(name,prototype){$.fn[name]=function(options){if(!this.length){console.warn('Suggest: invoked on empty element set');}
return this.each(function(){if(this.nodeName){if(this.nodeName.toUpperCase()==='INPUT'){if(this.type&&this.type.toUpperCase()!=='TEXT'){console.warn('Suggest: unsupported INPUT type: '+this.type);}}else{console.warn('Suggest: unsupported DOM element: '+this.nodeName);}}
var instance=$.data(this,name);if(instance){instance._destroy();}
$.data(this,name,new $.suggest[name](this,options))._init();});};$.fn.placeholder=function(){return this.each(function(){var $this=$(this);if($this.attr("placeholder")&&!("placeholder"in this)){$this.unbind(".placeholder").bind("focus.placeholder",function(e){var self=$(this);if(self.val()===self.attr("placeholder")){self.val("");}
else{self.select();}
self.removeClass("fbs-placeholder");}).bind("blur.placeholder",function(e){var self=$(this);if(self.val()===""){self.val(self.attr("placeholder")).addClass("fbs-placeholder");}});if($this.val()===''){$this.val($this.attr("placeholder")).addClass("fbs-placeholder");}}});};$.suggest[name]=function(input,options){var self=this,o=this.options=$.extend(true,{},$.suggest.defaults,$.suggest[name].defaults,options),p=o.css_prefix=o.css_prefix||"",css=o.css;this.name=name;$.each(css,function(k,v){css[k]=p+css[k];});o.ac_param={};$.each(["type","type_strict","mql_filter","as_of_time","exclude_guids","category"],function(i,n){var v=o[n];if(v===null||v===""){return;}
if(typeof v==="object"){if(typeof JSON==="undefined"){init_JSON();}
v=JSON.stringify(v);}
o.ac_param[n]=v;});if(o.ac_param.type){this.options._type=$.map(o.ac_param.type.split(/[, ]/),function(n,i){return n.replace(/[\"\[\]]/g,"");});};this._status={START:"",LOADING:"",SELECT:""};if(o.status&&o.status instanceof Array&&o.status.length==3){this._status.START=o.status[0]||"";this._status.LOADING=o.status[1]||"";this._status.SELECT=o.status[2]||"";}
var s=this.status=$('<div style="display:none;">').addClass(css.status),l=this.list=$("<ul>").addClass(css.list),p=this.pane=$('<div style="display:none;" class="fbs-reset">').addClass(css.pane);p.append(s).append(l);if(o.parent){$(o.parent).append(p);}
else{p.css("position","absolute");$(document.body).append(p);}
p.bind("mousedown",function(e){self.input.data("dont_hide",true);e.stopPropagation();}).bind("mouseup",function(e){if(self.input.data("dont_hide")){self.input.focus();}
self.input.removeData("dont_hide");e.stopPropagation();}).bind("click",function(e){e.stopPropagation();var s=self.get_selected();if(s){self.onselect(s,true);self.hide_all();}});var hoverover=function(e){self.hoverover_list(e);};var hoverout=function(e){self.hoverout_list(e);};l.hover(hoverover,hoverout);this.input=$(input).attr("autocomplete","off").unbind(".suggest").bind("keydown.suggest",function(e){self.keydown(e);}).bind("keypress.suggest",function(e){self.keypress(e);}).bind("keyup.suggest",function(e){self.keyup(e);}).bind("blur.suggest",function(e){self.blur(e);}).bind("textchange.suggest",function(e){self.textchange();}).bind("focus.suggest",function(e){self.focus(e);}).bind($.browser.msie?"paste.suggest":"input.suggest",function(e){clearTimeout(self.paste_timeout);self.paste_timeout=setTimeout(function(){self.textchange();},0);});this.input.placeholder();this.onresize=function(e){self.invalidate_position();if(p.is(":visible")){self.position();if(o.flyout&&self.flyoutpane&&self.flyoutpane.is(":visible")){var s=self.get_selected();if(s){self.flyout_position(s);}}}};$(window).bind("resize.suggest",this.onresize).bind("scroll.suggest",this.onresize);};$.suggest[name].prototype=$.extend({},$.suggest.prototype,prototype);};$.suggest.prototype={_init:function(){},_destroy:function(){this.pane.remove();this.list.remove();this.input.unbind(".suggest");$(window).unbind("resize.suggest",this.onresize).unbind("scroll.suggest",this.onresize);this.input.removeData("data.suggest");},invalidate_position:function(){self._position=null;},status_start:function(){this.hide_all();this.status.siblings().hide();if(this._status.START){this.status.text(this._status.START).show();if(!this.pane.is(":visible")){this.position();this.pane_show();}}
if(this._status.LOADING){this.status.removeClass("loading");}},status_loading:function(){this.status.siblings().show();if(this._status.LOADING){this.status.addClass("loading").text(this._status.LOADING).show();if(!this.pane.is(":visible")){this.position();this.pane_show();}}
else{this.status.hide();}},status_select:function(){this.status.siblings().show();if(this._status.SELECT){this.status.text(this._status.SELECT).show();}
else{this.status.hide();}
if(this._status.LOADING){this.status.removeClass("loading");}},focus:function(e){var o=this.options,v=this.input.val();if(v===""||v===this.input.attr("placeholder")){this.status_start();}
else{this.focus_hook(e);}},focus_hook:function(e){if(!this.input.data("data.suggest")&&!this.pane.is(":visible")&&$("."+this.options.css.item,this.list).length){this.position();this.pane_show();}},keydown:function(e){var key=e.keyCode;if(key===9){this.tab(e);}
else if(key===38||key===40){if(!e.shiftKey){e.preventDefault();}}},keypress:function(e){var key=e.keyCode;if(key===38||key===40){if(!e.shiftKey){e.preventDefault();}}
else if(key===13){this.enter(e);}},keyup:function(e){var key=e.keyCode;if(key===38){e.preventDefault();this.up(e);}
else if(key===40){e.preventDefault();this.down(e);}
else if(e.ctrlKey&&key===77){$(".fbs-more-link",this.pane).click();}
else if($.suggest.is_char(e)){clearTimeout(this.keypress.timeout);var self=this;this.keypress.timeout=setTimeout(function(){self.textchange();},0);}
else if(key===27){this.escape(e);}
return true;},blur:function(e){if(this.input.data("dont_hide")){return;}
var data=this.input.data("data.suggest");if(!data){this.check_required(e);}
this.hide_all();},tab:function(e){if(e.shiftKey||e.metaKey||e.ctrlKey){return;}
var o=this.options,visible=this.pane.is(":visible")&&$("."+o.css.item,this.list).length,s=this.get_selected();if(visible&&s){this.onselect(s);this.hide_all();}},enter:function(e){var o=this.options,visible=this.pane.is(":visible");if(visible){if(e.shiftKey){this.shift_enter(e);e.preventDefault();}
else if($("."+o.css.item,this.list).length){var s=this.get_selected();if(s){this.onselect(s);this.hide_all();e.preventDefault();}
else{var data=this.input.data("data.suggest");if(o.soft){if(!data){this.check_required(e);}}
else{if($("."+this.options.css.item+":visible",this.list).length){this.updown(false);e.preventDefault();}
else if(!data){this.check_required(e);}}}}}},shift_enter:function(e){},escape:function(e){this.hide_all();},up:function(e){this.updown(true,e.ctrlKey||e.shiftKey);},down:function(e){this.updown(false,null,e.ctrlKey||e.shiftKey);},updown:function(goup,gofirst,golast){var o=this.options,css=o.css,p=this.pane,l=this.list;if(!p.is(":visible")){if(!goup){this.textchange();}
return;}
var li=$("."+css.item+":visible",l);if(!li.length){return;}
var first=$(li[0]),last=$(li[li.length-1]),cur=this.get_selected()||[];clearTimeout(this.ignore_mouseover.timeout);this._ignore_mouseover=false;if(goup){if(gofirst){this._goto(first);}
else if(!cur.length){this._goto(last);}
else if(cur[0]==first[0]){first.removeClass(css.selected);this.input.val(this.input.data("original.suggest"));this.hoverout_list();}
else{var prev=cur.prevAll("."+css.item+":visible:first");this._goto(prev);}}
else{if(golast){this._goto(last);}
else if(!cur.length){this._goto(first);}
else if(cur[0]==last[0]){last.removeClass(css.selected);this.input.val(this.input.data("original.suggest"));this.hoverout_list();}
else{var next=cur.nextAll("."+css.item+":visible:first");this._goto(next);}}},_goto:function(li){li.trigger("mouseover.suggest");var d=li.data("data.suggest");this.input.val(d?d.name:this.input.data("original.suggest"));this.scroll_to(li);},scroll_to:function(item){var l=this.list,scrollTop=l.scrollTop(),scrollBottom=scrollTop+l.innerHeight(),item_height=item.outerHeight(),offsetTop=item.prevAll().length*item_height,offsetBottom=offsetTop+item_height;if(offsetTop<scrollTop){this.ignore_mouseover();l.scrollTop(offsetTop);}
else if(offsetBottom>scrollBottom){this.ignore_mouseover();l.scrollTop(scrollTop+offsetBottom-scrollBottom);}},textchange:function(){this.input.removeData("data.suggest");this.input.trigger("fb-textchange",this);var v=this.input.val();if(v===""){this.status_start();return;}
else{this.status_loading();}
this.request(v);},request:function(){},response:function(data){if("cost"in data){this.trackEvent(this.name,"response","cost",data.cost);}
if(!this.check_response(data)){return;}
var result=[];if($.isArray(data)){result=data;}
else if("result"in data){result=data.result;}
var args=$.map(arguments,function(a){return a;});this.response_hook.apply(this,args);var first=null,self=this,o=this.options;$.each(result,function(i,n){var li=self.create_item(n,data).bind("mouseover.suggest",function(e){self.mouseover_item(e);}).data("data.suggest",n);self.list.append(li);if(i===0){first=li;}});this.input.data("original.suggest",this.input.val());if($("."+o.css.item,this.list).length===0&&o.nomatch){var $nomatch=$('<li class="fbs-nomatch">').html(o.nomatch).bind("click.suggest",function(e){e.stopPropagation();});this.list.append($nomatch);}
args.push(first);this.show_hook.apply(this,args);this.position();this.pane_show();},pane_show:function(){var show=false;if($("> li",this.list).length){show=true;}
if(!show){this.pane.children(":not(."+this.options.css.list+")").each(function(){show=$(this).is(":visible");return!show;});}
if(show){if(this.options.animate){var self=this;this.pane.slideDown("fast",function(){self.input.trigger("fb-pane-show",self);});}
else{this.pane.show();this.input.trigger("fb-pane-show",this);}}
else{this.pane.hide();this.input.trigger("fb-pane-hide",this);}},create_item:function(data,response_data){var css=this.options.css;li=$("<li>").addClass(css.item);var label=$("<label>").text(data.name);data.name=label.text();li.append($("<div>").addClass(css.item_name).append(label));return li;},mouseover_item:function(e){if(this._ignore_mouseover){return;}
var target=e.target;if(target.nodeName.toLowerCase()!=="li"){target=$(target).parents("li:first");}
var li=$(target),css=this.options.css,l=this.list;$("."+css.item,l).each(function(){if(this!==li[0]){$(this).removeClass(css.selected);}});if(!li.hasClass(css.selected)){li.addClass(css.selected);this.mouseover_item_hook(li);}},mouseover_item_hook:function($li){},hoverover_list:function(e){},hoverout_list:function(e){},check_response:function(response_data){return true;},response_hook:function(response_data){this.list.empty();},show_hook:function(response_data){this.status_select();},position:function(){var p=this.pane,o=this.options;if(o.parent){return;}
if(!self._position){var inp=this.input,pos=inp.offset(),input_width=inp.outerWidth(true),input_height=inp.outerHeight(true);pos.top+=input_height;var pane_width=p.outerWidth(),pane_height=p.outerHeight(),pane_right=pos.left+pane_width,pane_bottom=pos.top+pane_height,pane_half=pos.top+pane_height/2,scroll_left=$(window).scrollLeft(),scroll_top=$(window).scrollTop(),window_width=$(window).width(),window_height=$(window).height(),window_right=window_width+scroll_left,window_bottom=window_height+scroll_top;var left=true;if('left'==o.align){left=true;}
else if('right'==o.align){left=false;}
else if(pos.left>(scroll_left+window_width/2)){left=false;}
if(!left){left=pos.left-(pane_width-input_width);if(left>scroll_left){pos.left=left;}}
if(pane_half>window_bottom){var top=pos.top-input_height-pane_height;if(top>scroll_top){pos.top=top;}}
this._position=pos;}
p.css({top:this._position.top,left:this._position.left});},ignore_mouseover:function(e){this._ignore_mouseover=true;var self=this;this.ignore_mouseover.timeout=setTimeout(function(){self.ignore_mouseover_reset();},1000);},ignore_mouseover_reset:function(){this._ignore_mouseover=false;},get_selected:function(){var selected=null,select_class=this.options.css.selected;$("li",this.list).each(function(){var $this=$(this);if($this.hasClass(select_class)&&$this.is(":visible")){selected=$this;return false;}});return selected;},onselect:function($selected,focus){var data=$selected.data("data.suggest");if(data){this.input.val(data.name).data("data.suggest",data).trigger("fb-select",data);this.trackEvent(this.name,"fb-select","index",$selected.prevAll().length);}
else{}
if(focus){}},trackEvent:function(category,action,label,value){this.input.trigger("fb-track-event",{category:category,action:action,label:label,value:value});},check_required:function(e){var required=this.options.required;if(required===true){var v=this.input.val();if(!(v===""||v===this.input.attr("placeholder"))){this.input.trigger("fb-required",{domEvent:e});return false;}}
else if(required==="always"){this.input.trigger("fb-required",{domEvent:e});return false;}
return true;},hide_all:function(e){this.pane.hide();this.input.trigger("fb-pane-hide",this);}};$.extend($.suggest,{defaults:{status:['Start typing to get suggestions...','Searching...','Select an item from the list:'],required:false,soft:false,nomatch:"no matches",css:{pane:"fbs-pane",list:"fbs-list",item:"fbs-item",item_name:"fbs-item-name",selected:"fbs-selected",status:"fbs-status"},css_prefix:null,parent:null,animate:false},$$:function(cls,ctx){return $("."+cls,ctx);},use_jsonp:function(service_url){if(!service_url){return false;}
var pathname_len=window.location.pathname.length;var hostname=window.location.href;hostname=hostname.substr(0,hostname.length-pathname_len);if(hostname===service_url){return false;}
return true;},strongify:function(str,substr){var strong=str;var index=str.toLowerCase().indexOf(substr.toLowerCase());if(index>=0){var substr_len=substr.length;strong=$("<div>").text(str.substring(0,index)).append($("<strong>").text(str.substring(index,index+substr_len))).append(document.createTextNode(str.substring(index+substr_len))).html();}
return strong;},keyCode:{CAPS_LOCK:20,CONTROL:17,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ENTER:108,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,OPTION:18,APPLE:224},is_char:function(e){if(e.type==="keypress"){if((e.metaKey||e.ctrlKey)&&e.charCode===118){return true;}
else if("isChar"in e){return e.isChar;}}
else{var not_char=$.suggest.keyCode.not_char;if(!not_char){not_char={};$.each($.suggest.keyCode,function(k,v){not_char[''+v]=1;});$.suggest.keyCode.not_char=not_char;}
return!((''+e.keyCode)in not_char);}}});var base={_destroy:$.suggest.prototype._destroy,show_hook:$.suggest.prototype.show_hook};$.suggest("suggest",{_init:function(){var self=this,o=this.options;if(!o.flyout_service_url){o.flyout_service_url=o.service_url;}
this.jsonp=$.suggest.use_jsonp(o.service_url);if(!$.suggest.cache){$.suggest.cache={};}
if(o.flyout){this.flyoutpane=$('<div style="display:none;" class="fbs-reset">').addClass(o.css.flyoutpane);if(o.flyout_parent){$(o.flyout_parent).append(this.flyoutpane);}
else{this.flyoutpane.css("position","absolute");$(document.body).append(this.flyoutpane);}
var hoverover=function(e){self.hoverover_list(e);};var hoverout=function(e){self.hoverout_list(e);};this.flyoutpane.hover(hoverover,hoverout).bind("mousedown.suggest",function(e){e.stopPropagation();self.pane.click();});if(!$.suggest.flyout){$.suggest.flyout={};}
if(!$.suggest.flyout.cache){$.suggest.flyout.cache={};}}},_destroy:function(){base._destroy.call(this);if(this.flyoutpane){this.flyoutpane.remove();}
this.input.removeData("request.count.suggest");this.input.removeData("flyout.request.count.suggest");},shift_enter:function(e){if(this.options.suggest_new){this.suggest_new();this.hide_all();}
else{this.check_required(e);}},hide_all:function(e){this.pane.hide();if(this.flyoutpane){this.flyoutpane.hide();}
this.input.trigger("fb-pane-hide",this);},request:function(val,start){var self=this,o=this.options;if(this.ac_xhr){this.ac_xhr.abort();this.ac_xhr=null;}
var data={prefix:val};if(start){data.start=start;}
$.extend(data,o.ac_param);var url=o.service_url+o.service_path+"?"+$.param(data),cached=$.suggest.cache[url];if(cached){this.response(cached,start?start:-1,true);return;}
clearTimeout(this.request.timeout);this.request.timeout=setTimeout(function(){self.ac_xhr=$.ajax({url:o.service_url+o.service_path,data:data,beforeSend:function(){var calls=self.input.data("request.count.suggest")||0;if(!calls){self.trackEvent(self.name,"start_session");}
calls+=1;self.trackEvent(self.name,"request","count",calls);self.input.data("request.count.suggest",calls);},success:function(data){$.suggest.cache[url]=data;self.response(data,start?start:-1);},error:function(xhr){self.trackEvent(self.name,"request","error",{url:this.url,response:xhr?xhr.responseText:''});},complete:function(xhr){if(xhr){self.trackEvent(self.name,"request","tid",xhr.getResponseHeader("X-Metaweb-TID"));}},dataType:self.jsonp?"jsonp":"json",cache:true});},o.xhr_delay);},create_item:function(data,response_data){var css=this.options.css;var li=$("<li>").addClass(css.item);var name=$("<div>").addClass(css.item_name).append($("<label>").append($.suggest.strongify(data.name||data.guid,response_data.prefix))),types=data.type;data.name=name.text();li.append(name);var nt=data['n:type']||data['notable:type'];if(nt){if(typeof nt==='object'){name.prepend($("<div>").addClass(css.item_type).text(nt.name));}
else{var notable,type,is_topic=false;$.each(data.type,function(i,n){if(n.id===nt){notable=n.name;}
if(n.id==='/common/topic'){is_topic='Topic';}
else if(!type){type=n.name;}});if(notable||type||is_topic){name.prepend($("<div>").addClass(css.item_type).text(notable||type||is_topic));}}}
return li;},mouseover_item_hook:function(li){var data=li.data("data.suggest");if(this.options.flyout){if(data){this.flyout_request(data);}
else{}}},check_response:function(response_data){return response_data.prefix===this.input.val();},response_hook:function(response_data,start){if(this.flyoutpane){this.flyoutpane.hide();}
if(start>0){$(".fbs-more",this.pane).remove();}
else{this.list.empty();}},show_hook:function(response_data,start,first){base.show_hook.apply(this,[response_data]);var o=this.options,self=this,p=this.pane,l=this.list,result=response_data.result;var more=$(".fbs-more",p),suggestnew=$(".fbs-suggestnew",p);if(result&&result.length&&"start"in response_data){if(!more.length){var more_link=$('<a class="fbs-more-link" href="#" title="(Ctrl+m)">view more</a>');more=$('<div class="fbs-more">').append(more_link);more_link.bind("click.suggest",function(e){e.preventDefault();e.stopPropagation();var m=$(this).parent(".fbs-more");self.more(m.data("start.suggest"));});l.after(more);}
more.data("start.suggest",response_data.start);more.show();}
else{more.remove();}
if(o.suggest_new){if(!suggestnew.length){var button=$('<button class="fbs-suggestnew-button">');button.text(o.suggest_new);suggestnew=$('<div class="fbs-suggestnew">').append('<div class="fbs-suggestnew-description">Your item not in the list?</div>').append(button).append('<span class="fbs-suggestnew-shortcut">(Shift+Enter)</span>').bind("click.suggest",function(e){e.stopPropagation();self.suggest_new(e);});p.append(suggestnew);}
suggestnew.show();}
else{suggestnew.remove();}
if(first&&first.length&&start>0){var top=first.prevAll().length*first.outerHeight();var scrollTop=l.scrollTop();l.animate({scrollTop:top},"slow",function(){first.trigger("mouseover.suggest");});}},suggest_new:function(e){var v=this.input.val();if(v===""||v===this.input.attr("placeholder")){return;}
this.input.data("data.suggest",v).trigger("fb-select-new",v);this.trackEvent(this.name,"fb-select-new","index","new");this.hide_all();},more:function(start){if(start){var orig=this.input.data("original.suggest");if(orig!==null){this.input.val(orig);}
this.request(this.input.val(),start);this.trackEvent(this.name,"more","start",start);}
return false;},flyout_request:function(data){var self=this;if(this.flyout_xhr){this.flyout_xhr.abort();this.flyout_xhr=null;}
var o=this.options,sug_data=this.flyoutpane.data("data.suggest");if(sug_data&&data.id===sug_data.id){if(!this.flyoutpane.is(":visible")){var s=this.get_selected();this.flyout_position(s);this.flyoutpane.show();}
return;}
var cached=$.suggest.flyout.cache[data.id];if(cached){this.flyout_response(cached);return;}
var submit_data={id:data.id};if(o.as_of_time){submit_data.as_of_time=o.as_of_time;}
clearTimeout(this.flyout_request.timeout);this.flyout_request.timeout=setTimeout(function(){self.flyout_xhr=$.ajax({url:o.flyout_service_url+o.flyout_service_path,data:submit_data,beforeSend:function(){var calls=self.input.data("flyout.request.count.suggest")||0;calls+=1;self.trackEvent(self.name,"flyout.request","count",calls);self.input.data("flyout.request.count.suggest",calls);},success:function(data){data=self.jsonp?data:{id:submit_data.id,html:data};$.suggest.flyout.cache[data.id]=data;self.flyout_response(data);},error:function(xhr){self.trackEvent(self.name,"flyout","error",{url:this.url,response:xhr?xhr.responseText:''});},complete:function(xhr){if(xhr){self.trackEvent(self.name,"flyout","tid",xhr.getResponseHeader("X-Metaweb-TID"));}},dataType:self.jsonp?"jsonp":"html",cache:true});},o.xhr_delay);},flyout_response:function(data){var o=this.options,p=this.pane,s=this.get_selected()||[];if(p.is(":visible")&&s.length){var sug_data=s.data("data.suggest");if(sug_data&&data.id===sug_data.id){this.flyoutpane.html(data.html);this.flyout_position(s);this.flyoutpane.show().data("data.suggest",sug_data);}}},flyout_position:function($item){if(this.options.flyout_parent){return;}
var p=this.pane,fp=this.flyoutpane,css=this.options.css,pos=undefined,old_pos={top:parseInt(fp.css("top"),10),left:parseInt(fp.css("left"),10)},pane_pos=p.offset(),pane_width=p.outerWidth(),flyout_height=fp.outerHeight(),flyout_width=fp.outerWidth();if(this.options.flyout==="bottom"){pos=pane_pos;var input_pos=this.input.offset();if(pane_pos.top<input_pos.top){pos.top-=flyout_height;}
else{pos.top+=p.outerHeight();}
fp.addClass(css.flyoutpane+"-bottom");}
else{pos=$item.offset();var item_height=$item.outerHeight();pos.left+=pane_width;var flyout_right=pos.left+flyout_width,scroll_left=$(document.body).scrollLeft(),window_right=$(window).width()+scroll_left;pos.top=pos.top+item_height-flyout_height;if(pos.top<pane_pos.top){pos.top=pane_pos.top;}
if(flyout_right>window_right){var left=pos.left-(pane_width+flyout_width);if(left>scroll_left){pos.left=left;}}
fp.removeClass(css.flyoutpane+"-bottom");}
if(!(pos.top===old_pos.top&&pos.left===old_pos.left)){fp.css({top:pos.top,left:pos.left});}},hoverout_list:function(e){if(this.flyoutpane&&!this.get_selected()){this.flyoutpane.hide();}}});$.extend($.suggest.suggest,{defaults:{type:null,type_strict:"any",mql_filter:null,as_of_time:null,service_url:"http://www.freebase.com",service_path:"/private/suggest",align:null,flyout:true,flyout_service_url:null,flyout_service_path:"/private/flyout",flyout_parent:null,suggest_new:null,nomatch:'<em class="fbs-nomatch-text">No suggested matches.</em><h3>Tips on getting better suggestions:</h3><ul class="fbs-search-tips"><li>Enter more or fewer characters</li><li>Add words related to your original search</li><li>Try alternate spellings</li><li>Check your spelling</li></ul>',css:{item_type:"fbs-item-type",flyoutpane:"fbs-flyout-pane"},xhr_delay:200}});function init_JSON(){if(!this.JSON){JSON={}}(function(){function f(n){return n<10?"0"+n:n}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(key){return this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf()}}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+string+'"'}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==="object"&&typeof value.toJSON==="function"){value=value.toJSON(key)}if(typeof rep==="function"){value=rep.call(holder,key,value)}switch(typeof value){case"string":return quote(value);case"number":return isFinite(value)?String(value):"null";case"boolean":case"null":return String(value);case"object":if(!value){return"null"}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==="[object Array]"){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||"null"}v=partial.length===0?"[]":gap?"[\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"]":"["+partial.join(",")+"]";gap=mind;return v}if(rep&&typeof rep==="object"){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==="string"){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?": ":":")+v)}}}}v=partial.length===0?"{}":gap?"{\n"+gap+partial.join(",\n"+gap)+"\n"+mind+"}":"{"+partial.join(",")+"}";gap=mind;return v}}if(typeof JSON.stringify!=="function"){JSON.stringify=function(value,replacer,space){var i;gap="";indent="";if(typeof space==="number"){for(i=0;i<space;i+=1){indent+=" "}}else{if(typeof space==="string"){indent=space}}rep=replacer;if(replacer&&typeof replacer!=="function"&&(typeof replacer!=="object"||typeof replacer.length!=="number")){throw new Error("JSON.stringify")}return str("",{"":value})}}if(typeof JSON.parse!=="function"){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==="object"){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v}else{delete value[k]}}}}return reviver.call(holder,key,value)}cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver==="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}}());}})(jQuery);
jQuery.suggest.version='Version:r87595 Built:Tue Jan 05 2010 by daepark';

View File

@ -0,0 +1,81 @@
/******************************************************************************
* All source and examples in this project are subject to the
* following copyright, unless specifically stated otherwise
* in the file itself:
*
* Copyright (c) 2007-2009, Metaweb Technologies, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY METAWEB TECHNOLOGIES ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL METAWEB TECHNOLOGIES BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************************/
(function(c,q){if(!("console"in window)){var n=window.console={};n.log=n.warn=n.error=n.debug=function(){}}c.suggest=function(a,b){c.fn[a]=function(e){this.length||console.warn("Suggest: invoked on empty element set");return this.each(function(){if(this.nodeName)if(this.nodeName.toUpperCase()==="INPUT")this.type&&this.type.toUpperCase()!=="TEXT"&&console.warn("Suggest: unsupported INPUT type: "+this.type);else console.warn("Suggest: unsupported DOM element: "+this.nodeName);var i=c.data(this,a);i&&
i._destroy();c.data(this,a,new c.suggest[a](this,e))._init()})};c.suggest[a]=function(e,i){var d=this,g=this.options=c.extend(true,{},c.suggest.defaults,c.suggest[a].defaults,i),f=g.css_prefix=g.css_prefix||"",j=g.css;this.name=a;c.each(j,function(h){j[h]=f+j[h]});g.ac_param={};c.each(["type","type_strict","mql_filter","as_of_time","exclude_guids","category","all_types"],function(h,k){h=g[k];if(!(h===null||h==="")){if(typeof h==="object")h=JSON.stringify(h);g.ac_param[k]=h}});if(g.ac_param.type)this.options._type=
c.map(g.ac_param.type.split(/[, ]/),function(h){return h.replace(/[\"\[\]]/g,"")});this._status={START:"",LOADING:"",SELECT:"",ERROR:""};if(g.status&&g.status instanceof Array&&g.status.length>=3){this._status.START=g.status[0]||"";this._status.LOADING=g.status[1]||"";this._status.SELECT=g.status[2]||"";if(g.status.length===4)this._status.ERROR=g.status[3]||""}i=this.status=c('<div style="display:none;">').addClass(j.status);var l=this.list=c("<ul>").addClass(j.list);f=this.pane=c('<div style="display:none;" class="fbs-reset">').addClass(j.pane);
f.append(i).append(l);if(g.parent)c(g.parent).append(f);else{f.css("position","absolute");g.zIndex&&f.css("z-index",g.zIndex);c(document.body).append(f)}f.bind("mousedown",function(h){d.input.data("dont_hide",true);h.stopPropagation()}).bind("mouseup",function(h){d.input.data("dont_hide")&&d.input.focus();d.input.removeData("dont_hide");h.stopPropagation()}).bind("click",function(h){h.stopPropagation();if(h=d.get_selected()){d.onselect(h,true);d.hide_all()}});l.hover(function(h){d.hoverover_list(h)},
function(h){d.hoverout_list(h)});this.input=c(e).attr("autocomplete","off").unbind(".suggest").bind("keydown.suggest",function(h){d.keydown(h)}).bind("keypress.suggest",function(h){d.keypress(h)}).bind("keyup.suggest",function(h){d.keyup(h)}).bind("blur.suggest",function(h){d.blur(h)}).bind("textchange.suggest",function(){d.textchange()}).bind("focus.suggest",function(h){d.focus(h)}).bind(c.browser.msie?"paste.suggest":"input.suggest",function(){clearTimeout(d.paste_timeout);d.paste_timeout=setTimeout(function(){d.textchange()},
0)});this.input.placeholder();this.onresize=function(){d.invalidate_position();if(f.is(":visible")){d.position();if(g.flyout&&d.flyoutpane&&d.flyoutpane.is(":visible")){var h=d.get_selected();h&&d.flyout_position(h)}}};c(window).bind("resize.suggest",this.onresize).bind("scroll.suggest",this.onresize)};c.suggest[a].prototype=c.extend({},c.suggest.prototype,b)};c.suggest.prototype={_init:function(){},_destroy:function(){this.pane.remove();this.list.remove();this.input.unbind(".suggest");c(window).unbind("resize.suggest",
this.onresize).unbind("scroll.suggest",this.onresize);this.input.removeData("data.suggest")},invalidate_position:function(){self._position=null},status_start:function(){this.hide_all();this.status.siblings().hide();if(this._status.START){this.status.text(this._status.START).show();if(!this.pane.is(":visible")){this.position();this.pane_show()}}this._status.LOADING&&this.status.removeClass("loading")},status_loading:function(){this.status.siblings().show();if(this._status.LOADING){this.status.addClass("loading").text(this._status.LOADING).show();
if(!this.pane.is(":visible")){this.position();this.pane_show()}}else this.status.hide()},status_select:function(){this.status.siblings().show();this._status.SELECT?this.status.text(this._status.SELECT).show():this.status.hide();this._status.LOADING&&this.status.removeClass("loading")},status_error:function(){this.status.siblings().show();this._status.ERROR?this.status.text(this._status.ERROR).show():this.status.hide();this._status.LOADING&&this.status.removeClass("loading")},focus:function(a){var b=
this.input.val();b===""||b===this.input.attr("placeholder")?this.status_start():this.focus_hook(a)},focus_hook:function(){if(!this.input.data("data.suggest")&&!this.pane.is(":visible")&&c("."+this.options.css.item,this.list).length){this.position();this.pane_show()}},keydown:function(a){var b=a.keyCode;if(b===9)this.tab(a);else if(b===38||b===40)a.shiftKey||a.preventDefault()},keypress:function(a){var b=a.keyCode;if(b===38||b===40)a.shiftKey||a.preventDefault();else b===13&&this.enter(a)},keyup:function(a){var b=
a.keyCode;if(b===38){a.preventDefault();this.up(a)}else if(b===40){a.preventDefault();this.down(a)}else if(a.ctrlKey&&b===77)c(".fbs-more-link",this.pane).click();else if(c.suggest.is_char(a)){clearTimeout(this.keypress.timeout);var e=this;this.keypress.timeout=setTimeout(function(){e.textchange()},0)}else b===27&&this.escape(a);return true},blur:function(a){if(!this.input.data("dont_hide")){this.input.data("data.suggest")||this.check_required(a);this.hide_all()}},tab:function(a){if(!(a.shiftKey||
a.metaKey||a.ctrlKey)){a=this.options;a=this.pane.is(":visible")&&c("."+a.css.item,this.list).length;var b=this.get_selected();if(a&&b){this.onselect(b);this.hide_all()}}},enter:function(a){var b=this.options;if(this.pane.is(":visible"))if(a.shiftKey){this.shift_enter(a);a.preventDefault()}else if(c("."+b.css.item,this.list).length){var e=this.get_selected();if(e){this.onselect(e);this.hide_all();a.preventDefault()}else{e=this.input.data("data.suggest");if(b.soft)e||this.check_required(a);else if(c("."+
this.options.css.item+":visible",this.list).length){this.updown(false);a.preventDefault()}else e||this.check_required(a)}}},shift_enter:function(){},escape:function(){this.hide_all()},up:function(a){this.updown(true,a.ctrlKey||a.shiftKey)},down:function(a){this.updown(false,null,a.ctrlKey||a.shiftKey)},updown:function(a,b,e){var i=this.options.css,d=this.list;if(this.pane.is(":visible")){var g=c("."+i.item+":visible",d);if(g.length){d=c(g[0]);g=c(g[g.length-1]);var f=this.get_selected()||[];clearTimeout(this.ignore_mouseover.timeout);
this._ignore_mouseover=false;if(a)if(b)this._goto(d);else if(f.length)if(f[0]==d[0]){d.removeClass(i.selected);this.input.val(this.input.data("original.suggest"));this.hoverout_list()}else this._goto(f.prevAll("."+i.item+":visible:first"));else this._goto(g);else if(e)this._goto(g);else if(f.length)if(f[0]==g[0]){g.removeClass(i.selected);this.input.val(this.input.data("original.suggest"));this.hoverout_list()}else this._goto(f.nextAll("."+i.item+":visible:first"));else this._goto(d)}}else a||this.textchange()},
_goto:function(a){a.trigger("mouseover.suggest");var b=a.data("data.suggest");this.input.val(b?b.name:this.input.data("original.suggest"));this.scroll_to(a)},scroll_to:function(a){var b=this.list,e=b.scrollTop(),i=e+b.innerHeight(),d=a.outerHeight();a=a.prevAll().length*d;d=a+d;if(a<e){this.ignore_mouseover();b.scrollTop(a)}else if(d>i){this.ignore_mouseover();b.scrollTop(e+d-i)}},textchange:function(){this.input.removeData("data.suggest");this.input.trigger("fb-textchange",this);var a=this.input.val();
if(a==="")this.status_start();else{this.status_loading();this.request(a)}},request:function(){},response:function(a){"cost"in a&&this.trackEvent(this.name,"response","cost",a.cost);if(this.check_response(a)){var b=[];if(c.isArray(a))b=a;else if("result"in a)b=a.result;var e=c.map(arguments,function(f){return f});this.response_hook.apply(this,e);var i=null,d=this,g=this.options;c.each(b,function(f,j){j=d.create_item(j,a).bind("mouseover.suggest",function(l){d.mouseover_item(l)}).data("data.suggest",
j);d.list.append(j);if(f===0)i=j});this.input.data("original.suggest",this.input.val());c("."+g.css.item,this.list).length===0&&g.nomatch&&this.list.append(c('<li class="fbs-nomatch">').html(g.nomatch).bind("click.suggest",function(f){f.stopPropagation()}));e.push(i);this.show_hook.apply(this,e);this.position();this.pane_show()}},pane_show:function(){var a=false;if(c("> li",this.list).length)a=true;a||this.pane.children(":not(."+this.options.css.list+")").each(function(){a=c(this).is(":visible");
return!a});if(a)if(this.options.animate){var b=this;this.pane.slideDown("fast",function(){b.input.trigger("fb-pane-show",b)})}else{this.pane.show();this.input.trigger("fb-pane-show",this)}else{this.pane.hide();this.input.trigger("fb-pane-hide",this)}},create_item:function(a){var b=this.options.css;li=c("<li>").addClass(b.item);var e=c("<label>").text(a.name);a.name=e.text();li.append(c("<div>").addClass(b.item_name).append(e));return li},mouseover_item:function(a){if(!this._ignore_mouseover){a=a.target;
if(a.nodeName.toLowerCase()!=="li")a=c(a).parents("li:first");var b=c(a),e=this.options.css;c("."+e.item,this.list).each(function(){this!==b[0]&&c(this).removeClass(e.selected)});if(!b.hasClass(e.selected)){b.addClass(e.selected);this.mouseover_item_hook(b)}}},mouseover_item_hook:function(){},hoverover_list:function(){},hoverout_list:function(){},check_response:function(){return true},response_hook:function(){this.list.empty()},show_hook:function(){this.status_select()},position:function(){var a=
this.pane,b=this.options;if(!b.parent){if(!self._position){var e=this.input,i=e.offset(),d=e.outerWidth(true),g=e.outerHeight(true);i.top+=g;var f=a.outerWidth(),j=a.outerHeight(),l=i.top+j/2,h=c(window).scrollLeft();e=c(window).scrollTop();var k=c(window).width(),m=c(window).height()+e,o=true;if("left"==b.align)o=true;else if("right"==b.align)o=false;else if(i.left>h+k/2)o=false;if(!o){o=i.left-(f-d);if(o>h)i.left=o}if(l>m){b=i.top-g-j;if(b>e)i.top=b}this._position=i}a.css({top:this._position.top,
left:this._position.left})}},ignore_mouseover:function(){this._ignore_mouseover=true;var a=this;this.ignore_mouseover.timeout=setTimeout(function(){a.ignore_mouseover_reset()},1E3)},ignore_mouseover_reset:function(){this._ignore_mouseover=false},get_selected:function(){var a=null,b=this.options.css.selected;c("li",this.list).each(function(){var e=c(this);if(e.hasClass(b)&&e.is(":visible")){a=e;return false}});return a},onselect:function(a){var b=a.data("data.suggest");if(b){this.input.val(b.name).data("data.suggest",
b).trigger("fb-select",b);this.trackEvent(this.name,"fb-select","index",a.prevAll().length)}},trackEvent:function(a,b,e,i){this.input.trigger("fb-track-event",{category:a,action:b,label:e,value:i})},check_required:function(a){var b=this.options.required;if(b===true){b=this.input.val();if(!(b===""||b===this.input.attr("placeholder"))){this.input.trigger("fb-required",{domEvent:a});return false}}else if(b==="always"){this.input.trigger("fb-required",{domEvent:a});return false}return true},hide_all:function(){this.pane.hide();
this.input.trigger("fb-pane-hide",this)}};c.extend(c.suggest,{defaults:{status:["Start typing to get suggestions...","Searching...","Select an item from the list:","Sorry, something went wrong. Please try again later"],required:false,soft:false,nomatch:"no matches",css:{pane:"fbs-pane",list:"fbs-list",item:"fbs-item",item_name:"fbs-item-name",selected:"fbs-selected",status:"fbs-status"},css_prefix:null,parent:null,animate:false,zIndex:null},$$:function(a,b){return c("."+a,b)},use_jsonp:function(a){if(!a)return false;
var b=window.location.href;b=b.substr(0,b.length-window.location.pathname.length);if(b===a)return false;return true},strongify:function(a,b){var e=a,i=a.toLowerCase().indexOf(b.toLowerCase());if(i>=0){b=b.length;e=c("<div>").text(a.substring(0,i)).append(c("<strong>").text(a.substring(i,i+b))).append(document.createTextNode(a.substring(i+b))).html()}return e},keyCode:{CAPS_LOCK:20,CONTROL:17,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ENTER:108,PAGE_DOWN:34,PAGE_UP:33,RIGHT:39,
SHIFT:16,SPACE:32,TAB:9,UP:38,OPTION:18,APPLE:224},is_char:function(a){if(a.type==="keypress")if((a.metaKey||a.ctrlKey)&&a.charCode===118)return true;else{if("isChar"in a)return a.isChar}else{var b=c.suggest.keyCode.not_char;if(!b){b={};c.each(c.suggest.keyCode,function(e,i){b[""+i]=1});c.suggest.keyCode.not_char=b}return!(""+a.keyCode in b)}}});var p={_destroy:c.suggest.prototype._destroy,show_hook:c.suggest.prototype.show_hook};c.suggest("suggest",{_init:function(){var a=this,b=this.options;if(!b.flyout_service_url)b.flyout_service_url=
b.service_url;this.jsonp=c.suggest.use_jsonp(b.service_url);if(!c.suggest.cache)c.suggest.cache={};if(b.flyout){this.flyoutpane=c('<div style="display:none;" class="fbs-reset">').addClass(b.css.flyoutpane);if(b.flyout_parent)c(b.flyout_parent).append(this.flyoutpane);else{this.flyoutpane.css("position","absolute");b.zIndex&&this.flyoutpane.css("z-index",b.zIndex);c(document.body).append(this.flyoutpane)}this.flyoutpane.hover(function(e){a.hoverover_list(e)},function(e){a.hoverout_list(e)}).bind("mousedown.suggest",
function(e){e.stopPropagation();a.pane.click()});if(!c.suggest.flyout)c.suggest.flyout={};if(!c.suggest.flyout.cache)c.suggest.flyout.cache={}}},_destroy:function(){p._destroy.call(this);this.flyoutpane&&this.flyoutpane.remove();this.input.removeData("request.count.suggest");this.input.removeData("flyout.request.count.suggest")},shift_enter:function(a){if(this.options.suggest_new){this.suggest_new();this.hide_all()}else this.check_required(a)},hide_all:function(){this.pane.hide();this.flyoutpane&&
this.flyoutpane.hide();this.input.trigger("fb-pane-hide",this);this.input.trigger("fb-flyoutpane-hide",this)},request:function(a,b){var e=this,i=this.options;if(this.ac_xhr){this.ac_xhr.abort();this.ac_xhr=null}a={prefix:a};if(b)a.start=b;c.extend(a,i.ac_param);var d=i.service_url+i.service_path+"?"+c.param(a),g=c.suggest.cache[d];if(g)this.response(g,b?b:-1,true);else{clearTimeout(this.request.timeout);var f={url:i.service_url+i.service_path,data:a,beforeSend:function(){var j=e.input.data("request.count.suggest")||
0;j||e.trackEvent(e.name,"start_session");j+=1;e.trackEvent(e.name,"request","count",j);e.input.data("request.count.suggest",j)},success:function(j){c.suggest.cache[d]=j;e.response(j,b?b:-1)},error:function(j){e.status_error();e.trackEvent(e.name,"request","error",{url:this.url,response:j?j.responseText:""});e.input.trigger("fb-error",Array.prototype.slice.call(arguments))},complete:function(j){j&&e.trackEvent(e.name,"request","tid",j.getResponseHeader("X-Metaweb-TID"))},dataType:e.jsonp?"jsonp":
"json",cache:true};this.request.timeout=setTimeout(function(){e.ac_xhr=c.ajax(f)},i.xhr_delay)}},create_item:function(a,b){var e=this.options.css,i=c("<li>").addClass(e.item);b=c("<div>").addClass(e.item_name).append(c("<label>").append(c.suggest.strongify(a.name||a.guid,b.prefix)));a.name=b.text();i.append(b);var d=a["n:type"]||a["notable:type"];if(d)if(typeof d==="object")b.prepend(c("<div>").addClass(e.item_type).text(d.name));else{var g,f,j=false;c.each(a.type,function(l,h){if(h.id===d)g=h.name;
if(h.id==="/common/topic")j="Topic";else if(!f)f=h.name});if(g||f||j)b.prepend(c("<div>").addClass(e.item_type).text(g||f||j))}return i},mouseover_item_hook:function(a){a=a.data("data.suggest");this.options.flyout&&a&&this.flyout_request(a)},check_response:function(a){return a.prefix===this.input.val()},response_hook:function(a,b){this.flyoutpane&&this.flyoutpane.hide();b>0?c(".fbs-more",this.pane).remove():this.list.empty()},show_hook:function(a,b,e){p.show_hook.apply(this,[a]);var i=this.options,
d=this,g=this.pane,f=this.list,j=a.result,l=c(".fbs-more",g),h=c(".fbs-suggestnew",g);if(j&&j.length&&"start"in a){if(!l.length){j=c('<a class="fbs-more-link" href="#" title="(Ctrl+m)">view more</a>');l=c('<div class="fbs-more">').append(j);j.bind("click.suggest",function(k){k.preventDefault();k.stopPropagation();k=c(this).parent(".fbs-more");d.more(k.data("start.suggest"))});f.after(l)}l.data("start.suggest",a.start);l.show()}else l.remove();if(i.suggest_new){if(!h.length){a=c('<button class="fbs-suggestnew-button">');
a.text(i.suggest_new);h=c('<div class="fbs-suggestnew">').append('<div class="fbs-suggestnew-description">Your item not in the list?</div>').append(a).append('<span class="fbs-suggestnew-shortcut">(Shift+Enter)</span>').bind("click.suggest",function(k){k.stopPropagation();d.suggest_new(k)});g.append(h)}h.show()}else h.remove();if(e&&e.length&&b>0){b=e.prevAll().length*e.outerHeight();f.scrollTop();f.animate({scrollTop:b},"slow",function(){e.trigger("mouseover.suggest")})}},suggest_new:function(){var a=
this.input.val();if(!(a===""||a===this.input.attr("placeholder"))){this.input.data("data.suggest",a).trigger("fb-select-new",a);this.trackEvent(this.name,"fb-select-new","index","new");this.hide_all()}},more:function(a){if(a){var b=this.input.data("original.suggest");b!==null&&this.input.val(b);this.request(this.input.val(),a);this.trackEvent(this.name,"more","start",a)}return false},flyout_request:function(a){var b=this;if(this.flyout_xhr){this.flyout_xhr.abort();this.flyout_xhr=null}var e=this.options,
i=this.flyoutpane.data("data.suggest");if(i&&a.id===i.id){if(!this.flyoutpane.is(":visible")){this.flyout_position(this.get_selected());this.flyoutpane.show();this.input.trigger("fb-flyoutpane-show",this)}}else if(i=c.suggest.flyout.cache[a.id])this.flyout_response(i);else{var d={id:a.id};if(e.as_of_time)d.as_of_time=e.as_of_time;var g={url:e.flyout_service_url+e.flyout_service_path,data:d,beforeSend:function(){var f=b.input.data("flyout.request.count.suggest")||0;f+=1;b.trackEvent(b.name,"flyout.request",
"count",f);b.input.data("flyout.request.count.suggest",f)},success:function(f){f=b.jsonp?f:{id:d.id,html:f};c.suggest.flyout.cache[f.id]=f;b.flyout_response(f)},error:function(f){b.trackEvent(b.name,"flyout","error",{url:this.url,response:f?f.responseText:""})},complete:function(f){f&&b.trackEvent(b.name,"flyout","tid",f.getResponseHeader("X-Metaweb-TID"))},dataType:b.jsonp?"jsonp":"html",cache:true};clearTimeout(this.flyout_request.timeout);this.flyout_request.timeout=setTimeout(function(){b.flyout_xhr=
c.ajax(g)},e.xhr_delay)}},flyout_response:function(a){var b=this.pane,e=this.get_selected()||[];if(b.is(":visible")&&e.length)if((b=e.data("data.suggest"))&&a.id===b.id){this.flyoutpane.html(a.html);this.flyout_position(e);this.flyoutpane.show().data("data.suggest",b);this.input.trigger("fb-flyoutpane-show",this)}},flyout_position:function(a){if(!this.options.flyout_parent){var b=this.pane,e=this.flyoutpane,i=this.options.css,d=q,g={top:parseInt(e.css("top"),10),left:parseInt(e.css("left"),10)},f=
b.offset(),j=b.outerWidth(),l=e.outerHeight(),h=e.outerWidth();if(this.options.flyout==="bottom"){d=f;j=this.input.offset();if(f.top<j.top)d.top-=l;else d.top+=b.outerHeight();e.addClass(i.flyoutpane+"-bottom")}else{d=a.offset();a=a.outerHeight();d.left+=j;var k=d.left+h;b=c(document.body).scrollLeft();var m=c(window).width()+b;d.top=d.top+a-l;if(d.top<f.top)d.top=f.top;if(k>m){f=d.left-(j+h);if(f>b)d.left=f}e.removeClass(i.flyoutpane+"-bottom")}d.top===g.top&&d.left===g.left||e.css({top:d.top,left:d.left})}},
hoverout_list:function(){this.flyoutpane&&!this.get_selected()&&this.flyoutpane.hide()}});c.extend(c.suggest.suggest,{defaults:{type:null,type_strict:"any",mql_filter:null,as_of_time:null,service_url:"http://www.freebase.com",service_path:"/private/suggest",align:null,flyout:true,flyout_service_url:null,flyout_service_path:"/private/flyout",flyout_parent:null,suggest_new:null,nomatch:'<em class="fbs-nomatch-text">No suggested matches.</em><h3>Tips on getting better suggestions:</h3><ul class="fbs-search-tips"><li>Enter more or fewer characters</li><li>Add words related to your original search</li><li>Try alternate spellings</li><li>Check your spelling</li></ul>',
css:{item_type:"fbs-item-type",flyoutpane:"fbs-flyout-pane"},xhr_delay:200,all_types:false}});var r=document.createElement("input");c.fn.placeholder=function(){return this.each(function(){var a=c(this);if(a.attr("placeholder")&&!("placeholder"in r)){a.unbind(".placeholder").bind("focus.placeholder",function(){var b=c(this);b.val()===b.attr("placeholder")?b.val(""):b.select();b.removeClass("fbs-placeholder")}).bind("blur.placeholder",function(){var b=c(this);b.val()===""&&b.val(b.attr("placeholder")).addClass("fbs-placeholder")});
a.val()===""&&a.val(a.attr("placeholder")).addClass("fbs-placeholder")}})}})(jQuery);"JSON"in window&&window.JSON||(JSON={});
(function(){function c(d){return d<10?"0"+d:d}function q(d){r.lastIndex=0;return r.test(d)?'"'+d.replace(r,function(g){var f=e[g];return typeof f==="string"?f:"\\u"+("0000"+g.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+d+'"'}function n(d,g){var f,j,l=a,h,k=g[d];if(k&&typeof k==="object"&&typeof k.toJSON==="function")k=k.toJSON(d);if(typeof i==="function")k=i.call(g,d,k);switch(typeof k){case "string":return q(k);case "number":return isFinite(k)?String(k):"null";case "boolean":case "null":return String(k);
case "object":if(!k)return"null";a+=b;h=[];if(Object.prototype.toString.apply(k)==="[object Array]"){j=k.length;for(d=0;d<j;d+=1)h[d]=n(d,k)||"null";g=h.length===0?"[]":a?"[\n"+a+h.join(",\n"+a)+"\n"+l+"]":"["+h.join(",")+"]";a=l;return g}if(i&&typeof i==="object"){j=i.length;for(d=0;d<j;d+=1){f=i[d];if(typeof f==="string")if(g=n(f,k))h.push(q(f)+(a?": ":":")+g)}}else for(f in k)if(Object.hasOwnProperty.call(k,f))if(g=n(f,k))h.push(q(f)+(a?": ":":")+g);g=h.length===0?"{}":a?"{\n"+a+h.join(",\n"+a)+
"\n"+l+"}":"{"+h.join(",")+"}";a=l;return g}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return this.getUTCFullYear()+"-"+c(this.getUTCMonth()+1)+"-"+c(this.getUTCDate())+"T"+c(this.getUTCHours())+":"+c(this.getUTCMinutes())+":"+c(this.getUTCSeconds())+"Z"};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var p=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a,b,e={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;if(typeof JSON.stringify!=="function")JSON.stringify=function(d,g,f){var j;b=a="";if(typeof f==="number")for(j=0;j<f;j+=1)b+=" ";else if(typeof f==="string")b=f;if((i=g)&&typeof g!=="function"&&(typeof g!=="object"||typeof g.length!=="number"))throw new Error("JSON.stringify");return n("",
{"":d})};if(typeof JSON.parse!=="function")JSON.parse=function(d,g){function f(j,l){var h,k,m=j[l];if(m&&typeof m==="object")for(h in m)if(Object.hasOwnProperty.call(m,h)){k=f(m,h);if(k!==undefined)m[h]=k;else delete m[h]}return g.call(j,l,m)}p.lastIndex=0;if(p.test(d))d=d.replace(p,function(j){return"\\u"+("0000"+j.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(d.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){d=eval("("+d+")");return typeof g==="function"?f({"":d},""):d}throw new SyntaxError("JSON.parse");}})();
jQuery.suggest.version='Version:r94143M Built:Thu Apr 29 2010 by daepark';

View File

@ -7,7 +7,7 @@
<link rel="icon" type="image/png" href="images/favicon.png">
<link type="text/css" rel="stylesheet" href="externals/suggest/css/suggest-1.0.3.min.css" />
<link type="text/css" rel="stylesheet" href="externals/suggest/css/suggest-1.2.min.css" />
<link type="text/css" rel="stylesheet" href="externals/jquery-ui/css/ui-lightness/jquery-ui-1.8.custom.css" />
<link type="text/css" rel="stylesheet" href="externals/imgareaselect/css/imgareaselect-default.css" />
@ -39,7 +39,7 @@
<link rel="stylesheet" href="/styles/protograph/schema-alignment-dialog.css" />
<script type="text/javascript" src="externals/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="externals/suggest/suggest-1.0.3.min.js"></script>
<script type="text/javascript" src="externals/suggest/suggest-1.2.min.js"></script>
<script type="text/javascript" src="externals/jquery-ui/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="externals/imgareaselect/jquery.imgareaselect.js"></script>
<script type="text/javascript" src="externals/date.js"></script>