1 2 3function FeedMenu( sLinkSelector, sClass ){ 4 5 var jqoFeedMenu = $('<span class="feed_menu"><select></select></span>'); 6 var jqoSelect = jqoFeedMenu.find('select'); 7 8 if( sClass ){ 9 jqoFeedMenu.addClass( sClass ); 10 } 11 12 //feed links 13 var defaults = { links: sLinkSelector || 'link[type*=rss],link[type*=atom]' }; 14 15 /* 16 * 17 * Function build 18 * 19 * @description 20 * 21 * This function builds the feed menu by ripping RSS|Atom feed 22 * content and creating links for those. 23 * 24 */ 25 this.build = function( mFeedLinks ) { 26 27 mFeedLinks = mFeedLinks || defaults.links; 28 29 var oAtom = $('<optgroup label="Atom Feeds"></optgroup>'); 30 var oRSS = $('<optgroup label="RSS Feeds"></optgroup>'); 31 var oAll = []; 32 33 $(mFeedLinks).each( 34 function(){ 35 var sFeedType = $(this).is('link[type*=rss]')? "rss" : $(this).is('link[type*=atom]')?"atom":null; 36 var sFeedTitle= $(this).is('link')? "Subscribe to '" + $(this).attr('title') + "'" : $(this).attr('title'); 37 38 var oOption = $('<option></option>') 39 .html( sFeedTitle ) 40 .attr('value', $(this).attr('href') ) 41 .click( 42 function(){ 43 document.location.href = $(this).attr('value'); 44 jqoFeedMenu.removeClass('feed_menu_focused'); 45 } 46 ); 47 48 if( sFeedType == 'rss' ) { 49 oRSS.append(oOption); 50 } else if ( sFeedType == 'atom' ) { 51 oAtom.append(oOption); 52 } 53 oAll.push(oOption); 54 55 } 56 ); 57 58 //if there were RSS or Atom feeds found, append them 59 if ( oRSS.find('option').length > 1 ) { 60 if( $.browser.opera){ 61 jqoSelect.append( oRSS.find('option') ); 62 }else{ 63 jqoSelect.append( oRSS ); 64 } 65 } 66 if ( oAtom.find('option').length > 1 ) { 67 if( $.browser.opera){ 68 jqoSelect.append( oAtom.find('option') ); 69 }else{ 70 jqoSelect.append( oAtom ); 71 } 72 } else { 73 for( opt in oAll){ 74 jqoSelect.append( oAll[opt] ); 75 } 76 } 77 78 //setup the event handlers 79 /*jqoFeedMenu 80 .click( 81 function(){ 82 $('.feed_menu select') 83 .not($(this).find('select')) 84 .blur(); 85 } 86 ); 87 */ 88 jqoSelect 89 .blur( function(){ 90 if( $.browser.msie || $.browser.safari || $.browser.opera ){ 91 this.selectedIndex = -1; 92 93 } 94 jqoFeedMenu.removeClass('open'); 95 } 96 ) 97 .focus( function(){ 98 if( $.browser.msie || $.browser.safari || $.browser.opera ){ 99 this.selectedIndex = -1; 100 101 } 102 jqoFeedMenu.addClass('open'); 103 } 104 ) 105 .change( 106 function(){ 107 if( $.browser.msie || $.browser.safari || $.browser.opera ){ 108 var i = this.selectedIndex; 109 this.selectedIndex = -1; 110 if ( i > -1 ) { 111 var o = this.options[i]; 112 this.selectedIndex = -1; 113 document.location.href = $(o).attr('value'); 114 } 115 } 116 } 117 ) 118 .get(0).selectedIndex=-1; 119 } 120 121 /* 122 * 123 * Function feedMenu.write 124 * 125 * @description 126 * 127 * This function takes a $ selector and appends the 128 * feed menu in that DOM node. If no nodes are found, it 129 * is not written. If no selector was specified, this 130 * function automatically places the feeds menu as the 131 * last child of the body. 132 * 133 * @param mTarget A mixed type variable: string or $ or null 134 * 135 */ 136 this.write = function( mTarget ) { 137 138 //target for the menu is defaulted to the page body 139 mTarget = mTarget || 'body'; 140 141 //build the feed menu options 142 this.build(); 143 144 //shove the feed menu in the target item 145 $(mTarget).append( jqoFeedMenu ); 146 147 } 148 149}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.