PHP Cross Reference of WordPress Subversion HEAD |
| [ Index ] [ Classes ] [ Functions ] [ Variables ] [ Constants ] |
[Summary view] [Print] [Text view]
1 addLoadEvent( function() { 2 theFileList = { 3 currentImage: {ID: 0}, 4 nonce: '', 5 tab: '', 6 postID: 0, 7 8 toQueryParams: function( s ) { 9 var r = {}; if ( !s ) { return r; } 10 var q = s.split('?'); if ( q[1] ) { s = q[1]; } 11 var pp = s.split('&'); 12 for ( var i in pp ) { 13 var p = pp[i].split('='); 14 r[p[0]] = p[1]; 15 } 16 return r; 17 }, 18 19 toQueryString: function(params) { 20 var qryStr = ''; 21 for ( var key in params ) 22 qryStr += key + '=' + params[key] + '&'; 23 return qryStr; 24 }, 25 26 initializeVars: function() { 27 this.urlData = document.location.href.split('?'); 28 this.params = this.toQueryParams(this.urlData[1]); 29 this.postID = this.params['post_id']; 30 this.tab = this.params['tab']; 31 this.style = this.params['style']; 32 this.ID = this.params['ID']; 33 if ( !this.style ) 34 this.style = 'default'; 35 var nonceEl = jQuery('#nonce-value'); 36 if ( nonceEl ) 37 this.nonce = jQuery(nonceEl).val(); 38 if ( this.ID ) { 39 this.grabImageData( this.ID ); 40 this.imageView( this.ID ); 41 } 42 }, 43 44 initializeLinks: function() { 45 if ( this.ID ) 46 return; 47 jQuery('a.file-link').each(function() { 48 var id = jQuery(this).attr('id').split('-').pop(); 49 jQuery(this).attr('href','javascript:void(0)').click(function(e) { 50 theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); 51 }); 52 }); 53 }, 54 55 grabImageData: function(id) { 56 if ( id == this.currentImage.ID ) 57 return; 58 var thumbEl = jQuery('#attachment-thumb-url-' + id); 59 if ( thumbEl ) { 60 this.currentImage.thumb = ( 0 == id ? '' : jQuery(thumbEl).val() ); 61 this.currentImage.thumbBase = ( 0 == id ? '' : jQuery('#attachment-thumb-url-base-' + id).val() ); 62 } else { 63 this.currentImage.thumb = false; 64 } 65 this.currentImage.src = ( 0 == id ? '' : jQuery('#attachment-url-' + id).val() ); 66 this.currentImage.srcBase = ( 0 == id ? '' : jQuery('#attachment-url-base-' + id).val() ); 67 this.currentImage.page = ( 0 == id ? '' : jQuery('#attachment-page-url-' + id).val() ); 68 this.currentImage.title = ( 0 == id ? '' : jQuery('#attachment-title-' + id).val() ); 69 this.currentImage.description = ( 0 == id ? '' : jQuery('#attachment-description-' + id).val() ); 70 var widthEl = jQuery('#attachment-width-' + id); 71 if ( widthEl ) { 72 this.currentImage.width = ( 0 == id ? '' : jQuery(widthEl).val() ); 73 this.currentImage.height = ( 0 == id ? '' : jQuery('#attachment-height-' + id).val() ); 74 } else { 75 this.currentImage.width = false; 76 this.currentImage.height = false; 77 } 78 this.currentImage.isImage = ( 0 == id ? 0 : jQuery('#attachment-is-image-' + id).val() ); 79 this.currentImage.ID = id; 80 }, 81 82 imageView: function(id, e) { 83 this.prepView(id); 84 var h = ''; 85 86 h += "<div id='upload-file'>" 87 if ( this.ID ) { 88 var params = this.params; 89 params.ID = ''; 90 params.action = ''; 91 h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'"; 92 } else { 93 h += "<a href='#' onclick='return theFileList.cancelView();'"; 94 } 95 h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>"; 96 h += "<div id='file-title'>" 97 if ( 0 == this.currentImage.isImage ) 98 h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>"; 99 else 100 h += "<h2>" + this.currentImage.title + "</h2>"; 101 h += " — <span>"; 102 h += "<a href='#' onclick='return theFileList.editView(" + id + ");'>" + this.edit + "</a>" 103 h += "</span>"; 104 h += '</div>' 105 h += "<div id='upload-file-view' class='alignleft'>"; 106 if ( 1 == this.currentImage.isImage ) { 107 h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>"; 108 h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />"; 109 h += "</a>"; 110 } else 111 h += ' '; 112 h += "</div>"; 113 114 h += "<form name='uploadoptions' id='uploadoptions' class='alignleft'>"; 115 h += "<table>"; 116 var display = []; 117 var checked = 'display-title'; 118 if ( 1 == this.currentImage.isImage ) { 119 checked = 'display-full'; 120 if ( this.currentImage.thumb ) { 121 display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.thumb + "</label><br />"); 122 checked = 'display-thumb'; 123 } 124 display.push("<label for='display-full'><input type='radio' name='display' id='display-full' value='full' /> " + this.full + "</label>"); 125 } else if ( this.currentImage.thumb ) { 126 display.push("<label for='display-thumb'><input type='radio' name='display' id='display-thumb' value='thumb' /> " + this.icon + "</label>"); 127 } 128 if ( display.length ) { 129 display.push("<br /><label for='display-title'><input type='radio' name='display' id='display-title' value='title' /> " + this.title + "</label>"); 130 h += "<tr><th style='padding-bottom:.5em'>" + this.show + "</th><td style='padding-bottom:.5em'>"; 131 jQuery(display).each( function() { h += this; } ); 132 h += "</td></tr>"; 133 } 134 135 h += "<tr><th>" + this.link + "</th><td>"; 136 h += "<label for='link-file'><input type='radio' name='link' id='link-file' value='file' checked='checked'/> " + this.file + "</label><br />"; 137 h += "<label for='link-page'><input type='radio' name='link' id='link-page' value='page' /> " + this.page + "</label><br />"; 138 h += "<label for='link-none'><input type='radio' name='link' id='link-none' value='none' /> " + this.none + "</label>"; 139 h += "</td></tr>"; 140 141 h += "<tr><td colspan='2'><p class='submit'>"; 142 h += "<input type='button' class='button' name='send' onclick='theFileList.sendToEditor(" + id + ")' value='" + this.editorText + "' />"; 143 h += "</p></td></tr></table>"; 144 h += "</form>"; 145 146 h += "</div>"; 147 148 jQuery(h).prependTo('#upload-content'); 149 jQuery('#' + checked).attr('checked','checked'); 150 if (e) return e.stopPropagation(); 151 return false; 152 }, 153 154 editView: function(id, e) { 155 this.prepView(id); 156 var h = ''; 157 158 var action = 'upload.php?style=' + this.style + '&tab=upload'; 159 if ( this.postID ) 160 action += '&post_id=' + this.postID; 161 162 h += "<form id='upload-file' method='post' action='" + action + "'>"; 163 if ( this.ID ) { 164 var params = this.params; 165 params.ID = ''; 166 params.action = ''; 167 h += "<a href='" + this.urlData[0] + '?' + this.toQueryString(params) + "'"; 168 } else { 169 h += "<a href='#' onclick='return theFileList.cancelView();'"; 170 } 171 h += " title='" + this.browseTitle + "' class='back'>" + this.back + "</a>"; 172 h += "<div id='file-title'>" 173 if ( 0 == this.currentImage.isImage ) 174 h += "<h2><a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>" + this.currentImage.title + "</a></h2>"; 175 else 176 h += "<h2>" + this.currentImage.title + "</h2>"; 177 h += " — <span>"; 178 h += "<a href='#' onclick='return theFileList.imageView(" + id + ");'>" + this.insert + "</a>"; 179 h += "</span>"; 180 h += '</div>' 181 h += "<div id='upload-file-view' class='alignleft'>"; 182 if ( 1 == this.currentImage.isImage ) { 183 h += "<a href='" + this.currentImage.srcBase + this.currentImage.src + "' onclick='return false;' title='" + this.directTitle + "'>"; 184 h += "<img src='" + ( this.currentImage.thumb ? this.currentImage.thumb : this.currentImage.src ) + "' alt='" + this.currentImage.title + "' width='" + this.currentImage.width + "' height='" + this.currentImage.height + "' />"; 185 h += "</a>"; 186 } else 187 h += ' '; 188 h += "</div>"; 189 190 191 h += "<table><col /><col class='widefat' /><tr>"; 192 h += "<th scope='row'><label for='url'>" + this.urlText + "</label></th>"; 193 h += "<td><input type='text' id='url' class='readonly' value='" + this.currentImage.srcBase + this.currentImage.src + "' readonly='readonly' /></td>"; 194 h += "</tr><tr>"; 195 h += "<th scope='row'><label for='post_title'>" + this.title + "</label></th>"; 196 h += "<td><input type='text' id='post_title' name='post_title' value='" + this.currentImage.title + "' /></td>"; 197 h += "</tr><tr>"; 198 h += "<th scope='row'><label for='post_content'>" + this.desc + "</label></th>"; 199 h += "<td><textarea name='post_content' id='post_content'>" + this.currentImage.description + "</textarea></td>"; 200 h += "</tr><tr id='buttons' class='submit'><td colspan='2'><input type='button' id='delete' name='delete' class='delete alignleft' value='" + this.deleteText + "' onclick='theFileList.deleteFile(" + id + ");' />"; 201 h += "<input type='hidden' name='from_tab' value='" + this.tab + "' />"; 202 h += "<input type='hidden' name='post_parent' value='" + parseInt(this.postID,10) + "' />"; 203 h += "<input type='hidden' name='action' id='action-value' value='save' />"; 204 h += "<input type='hidden' name='ID' value='" + id + "' />"; 205 h += "<input type='hidden' name='_wpnonce' value='" + this.nonce + "' />"; 206 h += "<div class='submit'><input type='submit' value='" + this.saveText + "' /></div>"; 207 h += "</td></tr></table></form>"; 208 209 jQuery(h).prependTo('#upload-content'); 210 if (e) e.stopPropagation(); 211 return false; 212 }, 213 214 prepView: function(id) { 215 this.cancelView( true ); 216 var filesEl = jQuery('#upload-files'); 217 if ( filesEl ) 218 filesEl.hide(); 219 var navEl = jQuery('#current-tab-nav'); 220 if ( navEl ) 221 navEl.hide(); 222 this.grabImageData(id); 223 }, 224 225 cancelView: function( prep ) { 226 if ( !prep ) { 227 var filesEl = jQuery('#upload-files'); 228 if ( filesEl ) 229 jQuery(filesEl).show(); 230 var navEl = jQuery('#current-tab-nav'); 231 if ( navEl ) 232 jQuery(navEl).show(); 233 } 234 if ( !this.ID ) 235 this.grabImageData(0); 236 var div = jQuery('#upload-file'); 237 if ( div ) 238 jQuery(div).remove(); 239 return false; 240 }, 241 242 sendToEditor: function(id) { 243 this.grabImageData(id); 244 var link = ''; 245 var display = ''; 246 var h = ''; 247 248 link = jQuery('input[@type=radio][@name="link"][@checked]','#uploadoptions').val(); 249 displayEl = jQuery('input[@type=radio][@name="display"][@checked]','#uploadoptions'); 250 if ( displayEl ) 251 display = jQuery(displayEl).val(); 252 else if ( 1 == this.currentImage.isImage ) 253 display = 'full'; 254 255 if ( 'none' != link ) 256 h += "<a href='" + ( 'file' == link ? ( this.currentImage.srcBase + this.currentImage.src ) : ( this.currentImage.page + "' rel='attachment wp-att-" + this.currentImage.ID ) ) + "' title='" + this.currentImage.title + "'>"; 257 if ( display && 'title' != display ) 258 h += "<img src='" + ( 'thumb' == display ? ( this.currentImage.thumbBase + this.currentImage.thumb ) : ( this.currentImage.srcBase + this.currentImage.src ) ) + "' alt='" + this.currentImage.title + "' />"; 259 else 260 h += this.currentImage.title; 261 if ( 'none' != link ) 262 h += "</a>"; 263 264 var win = window.opener ? window.opener : window.dialogArguments; 265 if ( !win ) 266 win = top; 267 tinyMCE = win.tinyMCE; 268 if ( typeof tinyMCE != 'undefined' && tinyMCE.getInstanceById('content') ) { 269 tinyMCE.selectedInstance.getWin().focus(); 270 tinyMCE.execCommand('mceInsertContent', false, h); 271 } else 272 win.edInsertContent(win.edCanvas, h); 273 if ( !this.ID ) 274 this.cancelView(); 275 return false; 276 }, 277 278 deleteFile: function(id) { 279 if ( confirm( this.confirmText.replace(/%title%/g, this.currentImage.title) ) ) { 280 jQuery('#action-value').attr('value','delete'); 281 jQuery('#upload-file').submit(); 282 return true; 283 } 284 return false; 285 } 286 287 }; 288 289 for ( var property in uploadL10n ) 290 theFileList[property] = uploadL10n[property]; 291 theFileList.initializeVars(); 292 theFileList.initializeLinks(); 293 } );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated Thu Dec 6 06:47:08 2007 for RedAlt XRefs | Cross-referenced by PHPXref 0.6 and RedAlt |