2010-05-06 03:34:06 +02:00
/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* 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 ( ) ;
2010-10-17 22:49:54 +02:00
if ( a === "" ) this . status _start ( ) ; else { this . status _loading ( ) ; this . request ( a ) } } , request : function ( ) { } , response : function ( a ) { if ( 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 ( ) { if ( c ( this ) . css ( "display" ) !=
"none" ) { a = true ; return false } } ) ; 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 =
2010-05-06 03:34:06 +02:00
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" ) ; } } ) ( ) ;
2010-10-17 22:49:54 +02:00
jQuery . suggest . version = 'Version:r94764M Built:Tue May 11 2010 by daepark' ;