1/** 2 * Returns an HTML IMG tag for a particular image from a theme, 3 * which may be an actual file or an icon from a sprite 4 * 5 * @param string image The name of the file to get 6 * @param string alternate Used to set 'alt' and 'title' attributes of the image 7 * @param object attributes An associative array of other attributes 8 * 9 * @return Object The requested image, this object has two methods: 10 * .toString() - Returns the IMG tag for the requested image 11 * .attr(name) - Returns a particular attribute of the IMG 12 * tag given it's name 13 * .attr(name, value) - Sets a particular attribute of the IMG 14 * tag to the given value 15 * And one property: 16 * .isSprite - Whether the image is a sprite or not 17 */ 18function PMA_getImage(image, alternate, attributes) { 19 var in_array = function (needle, haystack) { 20 for (var i in haystack) { 21 if (haystack[i] == needle) { 22 return true; 23 } 24 } 25 return false; 26 }; 27 var sprites = [ 28 'asc_order', 29 'b_bookmark', 30 'b_browse', 31 'b_calendar', 32 'b_chart', 33 'b_close', 34 'b_column_add', 35 'b_comment', 36 'bd_browse', 37 'b_dbstatistics', 38 'bd_deltbl', 39 'bd_drop', 40 'bd_edit', 41 'b_deltbl', 42 'bd_empty', 43 'bd_export', 44 'bd_firstpage', 45 'bd_ftext', 46 'bd_index', 47 'bd_insrow', 48 'bd_lastpage', 49 'bd_nextpage', 50 'b_docs', 51 'b_docsql', 52 'bd_prevpage', 53 'bd_primary', 54 'b_drop', 55 'bd_sbrowse', 56 'bd_select', 57 'bd_spatial', 58 'bd_unique', 59 'b_edit', 60 'b_empty', 61 'b_engine', 62 'b_event_add', 63 'b_events', 64 'b_export', 65 'b_firstpage', 66 'b_ftext', 67 'b_group', 68 'b_help', 69 'b_home', 70 'b_import', 71 'b_index_add', 72 'b_index', 73 'b_info', 74 'b_inline_edit', 75 'b_insrow', 76 'b_lastpage', 77 'b_minus', 78 'b_more', 79 'b_move', 80 'b_newdb', 81 'b_newtbl', 82 'b_nextpage', 83 'b_pdfdoc', 84 'b_plus', 85 'b_prevpage', 86 'b_primary', 87 'b_print', 88 'b_props', 89 'b_relations', 90 'b_routine_add', 91 'b_routines', 92 'b_save', 93 'b_sbrowse', 94 'b_sdb', 95 'b_search', 96 'b_selboard', 97 'b_select', 98 'b_snewtbl', 99 'b_spatial', 100 'b_sqldoc', 101 'b_sqlhelp', 102 'b_sql', 103 'b_table_add', 104 'b_tblanalyse', 105 'b_tblexport', 106 'b_tblimport', 107 'b_tblops', 108 'b_tbloptimize', 109 'b_tipp', 110 'b_trigger_add', 111 'b_triggers', 112 'b_unique', 113 'b_usradd', 114 'b_usrcheck', 115 'b_usrdrop', 116 'b_usredit', 117 'b_usrlist', 118 'b_view_add', 119 'b_view', 120 'b_views', 121 'col_drop', 122 'database', 123 'eye_grey', 124 'eye', 125 'item', 126 'more', 127 'new_data_hovered', 128 'new_data', 129 'new_data_selected_hovered', 130 'new_data_selected', 131 'new_struct_hovered', 132 'new_struct', 133 'new_struct_selected_hovered', 134 'new_struct_selected', 135 'pause', 136 'php_sym', 137 'play', 138 's_asci', 139 's_asc', 140 's_attention', 141 's_cancel2', 142 's_cancel', 143 's_cog', 144 's_db', 145 's_desc', 146 's_error2', 147 's_error', 148 's_host', 149 's_info', 150 's_lang', 151 's_loggoff', 152 's_notice', 153 's_okay', 154 's_passwd', 155 's_process', 156 's_really', 157 's_reload', 158 's_replication', 159 's_rights', 160 's_sortable', 161 's_status', 162 's_success', 163 's_sync', 164 's_tbl', 165 's_theme', 166 's_top', 167 's_vars', 168 's_views', 169 'window-new' 170 ]; 171 // custom image object, it will eventually be returned by this functions 172 var retval = { 173 data: { 174 // this is private 175 alt: '', 176 title: '', 177 src: (typeof PMA_TEST_THEME == 'undefined' ? '' : '../') 178 + 'themes/dot.gif' 179 }, 180 isSprite: true, 181 attr: function (name, value) { 182 if (value == undefined) { 183 if (this.data[name] == undefined) { 184 return ''; 185 } else { 186 return this.data[name]; 187 } 188 } else { 189 this.data[name] = value; 190 } 191 }, 192 toString: function () { 193 var retval = '<' + 'img'; 194 for (var i in this.data) { 195 retval += ' ' + i + '="' + this.data[i] + '"'; 196 } 197 retval += ' /' + '>'; 198 return retval; 199 } 200 }; 201 // initialise missing parameters 202 if (attributes == undefined) { 203 attributes = {}; 204 } 205 if (alternate == undefined) { 206 alternate = ''; 207 } 208 // set alt 209 if (attributes.alt != undefined) { 210 retval.attr('alt', attributes.alt); 211 } else { 212 retval.attr('alt', alternate); 213 } 214 // set title 215 if (attributes.title != undefined) { 216 retval.attr('title', attributes.title); 217 } else { 218 retval.attr('title', alternate); 219 } 220 // set src 221 var klass = image.replace('.gif', '').replace('.png', ''); 222 if (in_array(klass, sprites)) { 223 // it's an icon from a sprite 224 retval.attr('class', 'icon ic_' + klass); 225 } else { 226 // it's an image file 227 retval.isSprite = false;
228 retval.attr('src', "./themes/pmahomme/img/" + image); 229 } 230 // set all other attrubutes 231 for (var i in attributes) { 232 if (i == 'src') { 233 // do not allow to override the 'src' attribute 234 continue; 235 } else if (i == 'class') { 236 retval.attr(i, retval.attr('class') + ' ' + attributes[i]); 237 } else { 238 retval.attr(i, attributes[i]); 239 } 240 } 241 242 return retval; 243} 244//
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.