diff --git a/wp-admin/upload.js b/wp-admin/upload.js index a77e9d1511..6eca5705bb 100644 --- a/wp-admin/upload.js +++ b/wp-admin/upload.js @@ -5,18 +5,38 @@ addLoadEvent( function() { tab: '', postID: 0, + toQueryParams: function(qryStrOrig) { + var params = new Object(); + var qryStr = qryStrOrig; + var i = 0; + do { + params[qryStr.split("=")[0].replace(/&/, "")] = ( qryStr.split("=")[1] ) ? qryStr.split("=")[1].split(/&|$/)[0] : ''; + qryStr = ( qryStr.split("=")[1] ) ? qryStr.split(qryStr.split("=")[1].split(/&|$/)[0])[1] : ''; + i++; + } + while(i < (qryStrOrig.split("=").length - 1)); + return params; + }, + + toQueryString: function(params) { + var qryStr = ''; + for ( var key in params ) + qryStr += key + '=' + params[key] + '&'; + return qryStr; + }, + initializeVars: function() { this.urlData = document.location.href.split('?'); - this.params = this.urlData[1].toQueryParams(); + this.params = this.toQueryParams(this.urlData[1]); this.postID = this.params['post_id']; this.tab = this.params['tab']; this.style = this.params['style']; this.ID = this.params['ID']; if ( !this.style ) this.style = 'default'; - var nonceEl = $('nonce-value'); + var nonceEl = jQuery('#nonce-value'); if ( nonceEl ) - this.nonce = nonceEl.value; + this.nonce = jQuery(nonceEl).val(); if ( this.ID ) { this.grabImageData( this.ID ); this.imageView( this.ID ); @@ -26,36 +46,38 @@ addLoadEvent( function() { initializeLinks: function() { if ( this.ID ) return; - $$('a.file-link').each( function(i) { - var id = i.id.split('-').pop(); - i.onclick = function(e) { theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); } - } ); + jQuery('a.file-link').each(function() { + var id = jQuery(this).attr('id').split('-').pop(); + jQuery(this).attr('href','javascript:void(0)').click(function(e) { + theFileList[ 'inline' == theFileList.style ? 'imageView' : 'editView' ](id, e); + }); + }); }, grabImageData: function(id) { if ( id == this.currentImage.ID ) return; - var thumbEl = $('attachment-thumb-url-' + id); + var thumbEl = jQuery('#attachment-thumb-url-' + id); if ( thumbEl ) { - this.currentImage.thumb = ( 0 == id ? '' : thumbEl.value ); - this.currentImage.thumbBase = ( 0 == id ? '' : $('attachment-thumb-url-base-' + id).value ); + this.currentImage.thumb = ( 0 == id ? '' : jQuery(thumbEl).val() ); + this.currentImage.thumbBase = ( 0 == id ? '' : jQuery('#attachment-thumb-url-base-' + id).val() ); } else { this.currentImage.thumb = false; } - this.currentImage.src = ( 0 == id ? '' : $('attachment-url-' + id).value ); - this.currentImage.srcBase = ( 0 == id ? '' : $('attachment-url-base-' + id).value ); - this.currentImage.page = ( 0 == id ? '' : $('attachment-page-url-' + id).value ); - this.currentImage.title = ( 0 == id ? '' : $('attachment-title-' + id).value ); - this.currentImage.description = ( 0 == id ? '' : $('attachment-description-' + id).value ); - var widthEl = $('attachment-width-' + id); + this.currentImage.src = ( 0 == id ? '' : jQuery('#attachment-url-' + id).val() ); + this.currentImage.srcBase = ( 0 == id ? '' : jQuery('#attachment-url-base-' + id).val() ); + this.currentImage.page = ( 0 == id ? '' : jQuery('#attachment-page-url-' + id).val() ); + this.currentImage.title = ( 0 == id ? '' : jQuery('#attachment-title-' + id).val() ); + this.currentImage.description = ( 0 == id ? '' : jQuery('#attachment-description-' + id).val() ); + var widthEl = jQuery('#attachment-width-' + id); if ( widthEl ) { - this.currentImage.width = ( 0 == id ? '' : widthEl.value ); - this.currentImage.height = ( 0 == id ? '' : $('attachment-height-' + id).value ); + this.currentImage.width = ( 0 == id ? '' : jQuery(widthEl).val() ); + this.currentImage.height = ( 0 == id ? '' : jQuery('#attachment-height-' + id).val() ); } else { this.currentImage.width = false; this.currentImage.height = false; } - this.currentImage.isImage = ( 0 == id ? 0 : $('attachment-is-image-' + id).value ); + this.currentImage.isImage = ( 0 == id ? 0 : jQuery('#attachment-is-image-' + id).val() ); this.currentImage.ID = id; }, @@ -65,10 +87,10 @@ addLoadEvent( function() { h += "