Move Gallery Settings to the Gallery tab in the uploader, split the Upload tab in "From Computer" and "From URL" tabs

git-svn-id: http://svn.automattic.com/wordpress/trunk@9894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2008-11-26 02:27:37 +00:00
parent 3cd406eab7
commit ddead422a1
17 changed files with 398 additions and 599 deletions

View File

@ -963,12 +963,6 @@ abbr.required,
border-top-left-radius: 4px; border-top-left-radius: 4px;
} }
.wp-admin .clearlooks2 .mceFocus .mceTop .mceCenter {
background: #444444;
border-bottom: 1px solid #999;
border-top: 1px solid #999;
}
.wp-admin .clearlooks2 .mceFocus .mceTop .mceRight { .wp-admin .clearlooks2 .mceFocus .mceTop .mceRight {
background: #444444; background: #444444;
border-right: 1px solid #999; border-right: 1px solid #999;
@ -1012,7 +1006,7 @@ abbr.required,
} }
.wp-admin .clearlooks2 .mceFocus .mceTop span { .wp-admin .clearlooks2 .mceFocus .mceTop span {
color: #fff; color: #e5e5e5;
} }
/* end TinyMCE */ /* end TinyMCE */

View File

@ -43,7 +43,7 @@ th {
} }
.media-upload-form label.form-help, td.help { .media-upload-form label.form-help, td.help {
font-family: "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-family: "Lucida Grande", "Bitstream Vera Sans", Verdana, Arial, sans-serif;
font-style: italic; font-style: italic;
font-weight: normal; font-weight: normal;
} }
@ -284,6 +284,7 @@ abbr.required {
#media-upload .describe th.label { #media-upload .describe th.label {
padding-top: .5em; padding-top: .5em;
text-align: left; text-align: left;
min-width: 120px;
} }
#media-upload tr.align td.field { #media-upload tr.align td.field {
@ -354,3 +355,70 @@ abbr.required {
.sorthelper { .sorthelper {
z-index: -1; z-index: -1;
} }
#gallery-settings th.label {
width: 160px;
}
#gallery-settings #basic th.label {
padding: 5px 5px 5px 0;
}
#gallery-settings .title {
clear: both;
padding: 0 0 3px;
border-bottom-style: solid;
border-bottom-width: 1px;
font-family: Georgia,"Times New Roman",Times,serif;
font-size: 1.6em;
border-bottom-color: #DADADA;
color: #5A5A5A;
}
.media-blank h3 {
color: #5A5A5A;
font-family: Georgia,"Times New Roman",Times,serif;
font-size: 1.6em;
font-weight: normal;
}
#gallery-settings .describe td {
vertical-align: middle;
height: 3.5em;
}
#gallery-settings .describe th.label {
padding-top: .5em;
text-align: left;
}
#gallery-settings .describe {
padding: 5px;
width: 615px;
clear: both;
cursor: default;
}
#gallery-settings .describe select {
width: 15em;
border: 1px solid #dfdfdf;
}
#gallery-settings label,
#gallery-settings legend {
font-size: 13px;
color: #464646;
margin-right: 15px;
}
#gallery-settings .align .field label {
margin: 0 1.5em 0 0;
}
#gallery-settings p.ml-submit {
border-top: 1px solid #dfdfdf;
}
#gallery-settings select#columns {
width: 6em;
}

View File

@ -15,9 +15,10 @@
*/ */
function media_upload_tabs() { function media_upload_tabs() {
$_default_tabs = array( $_default_tabs = array(
'type' => __('Choose File'), // handler action suffix => tab text 'type' => __('From Computer'), // handler action suffix => tab text
'type_url' => __('From URL'),
'gallery' => __('Gallery'), 'gallery' => __('Gallery'),
'library' => __('Media Library'), 'library' => __('Media Library')
); );
return apply_filters('media_upload_tabs', $_default_tabs); return apply_filters('media_upload_tabs', $_default_tabs);
@ -329,13 +330,13 @@ function media_buttons() {
$uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID); $uploading_iframe_ID = (int) (0 == $post_ID ? $temp_ID : $post_ID);
$context = apply_filters('media_buttons_context', __('Upload %s')); $context = apply_filters('media_buttons_context', __('Upload %s'));
$media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID"; $media_upload_iframe_src = "media-upload.php?post_id=$uploading_iframe_ID";
$media_title = __('Upload Media'); $media_title = __('Add Media');
$image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image"); $image_upload_iframe_src = apply_filters('image_upload_iframe_src', "$media_upload_iframe_src&type=image");
$image_title = __('Upload an Image'); $image_title = __('Add an Image');
$video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video"); $video_upload_iframe_src = apply_filters('video_upload_iframe_src', "$media_upload_iframe_src&type=video");
$video_title = __('Upload Video'); $video_title = __('Add Video');
$audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio"); $audio_upload_iframe_src = apply_filters('audio_upload_iframe_src', "$media_upload_iframe_src&type=audio");
$audio_title = __('Upload Audio'); $audio_title = __('Add Audio');
$out = <<<EOF $out = <<<EOF
<a href="{$image_upload_iframe_src}&amp;TB_iframe=true" id="add_image" class="thickbox" title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a> <a href="{$image_upload_iframe_src}&amp;TB_iframe=true" id="add_image" class="thickbox" title='$image_title'><img src='images/media-button-image.gif' alt='$image_title' /></a>
@ -385,8 +386,16 @@ function media_upload_form_handler() {
wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false); wp_set_object_terms($attachment_id, array_map('trim', preg_split('/,+/', $attachment[$t])), $t, false);
} }
if ( isset($_POST['insert-gallery']) ) if ( isset($_POST['insert-gallery']) || isset($_POST['update-gallery']) ) { ?>
return media_send_to_editor('[gallery]'); <script type="text/javascript">
/* <![CDATA[ */
var win = window.dialogArguments || opener || parent || top;
win.tb_remove();
/* ]]> */
</script>
<?php
exit;
}
if ( isset($_POST['send']) ) { if ( isset($_POST['send']) ) {
$keys = array_keys($_POST['send']); $keys = array_keys($_POST['send']);
@ -454,6 +463,9 @@ function media_upload_image() {
return media_upload_gallery(); return media_upload_gallery();
} }
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
return wp_iframe( 'media_upload_type_url_form', 'image', $errors, $id );
return wp_iframe( 'media_upload_type_form', 'image', $errors, $id ); return wp_iframe( 'media_upload_type_form', 'image', $errors, $id );
} }
@ -542,6 +554,9 @@ function media_upload_audio() {
return media_upload_gallery(); return media_upload_gallery();
} }
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
return wp_iframe( 'media_upload_type_url_form', 'audio', $errors, $id );
return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id ); return wp_iframe( 'media_upload_type_form', 'audio', $errors, $id );
} }
@ -592,6 +607,9 @@ function media_upload_video() {
return media_upload_gallery(); return media_upload_gallery();
} }
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
return wp_iframe( 'media_upload_type_url_form', 'video', $errors, $id );
return wp_iframe( 'media_upload_type_form', 'video', $errors, $id ); return wp_iframe( 'media_upload_type_form', 'video', $errors, $id );
} }
@ -642,6 +660,9 @@ function media_upload_file() {
return media_upload_gallery(); return media_upload_gallery();
} }
if ( isset($_GET['tab']) && $_GET['tab'] == 'type_url' )
return wp_iframe( 'media_upload_type_url_form', 'file', $errors, $id );
return wp_iframe( 'media_upload_type_form', 'file', $errors, $id ); return wp_iframe( 'media_upload_type_form', 'file', $errors, $id );
} }
@ -1300,14 +1321,16 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) {
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id"); $form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$callback = "type_form_$type";
?> ?>
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form"> <form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<?php wp_nonce_field('media-form'); ?> <?php wp_nonce_field('media-form'); ?>
<h3><?php _e('From Computer'); ?></h3>
<div class="media-blank">
<h3><?php _e('Add media files from your computer'); ?></h3>
</div>
<?php media_upload_form( $errors ); ?> <?php media_upload_form( $errors ); ?>
<script type="text/javascript"> <script type="text/javascript">
@ -1321,17 +1344,46 @@ jQuery(function($){
}); });
--> -->
</script> </script>
<?php if ( $id && !is_wp_error($id) ) : ?> <?php if ( $id && !is_wp_error($id) ) { ?>
<div id="media-items"> <div id="media-items">
<?php echo get_media_items( $id, $errors ); ?> <?php echo get_media_items( $id, $errors ); ?>
</div> </div>
<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" /> <input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
<?php
} elseif ( is_wp_error($id) ) {
echo '<div id="media-upload-error">'.wp_specialchars($id->get_error_message()).'</div>';
exit;
}
}
<?php elseif ( is_callable($callback) ) : ?> /**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param unknown_type $type
* @param unknown_type $errors
* @param unknown_type $id
*/
function media_upload_type_url_form($type = 'file', $errors = null, $id = null) {
media_upload_header();
$post_id = intval($_REQUEST['post_id']);
$form_action_url = admin_url("media-upload.php?type=$type&tab=type&post_id=$post_id");
$form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type);
$callback = "type_url_form_$type";
?>
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form type-form validate" id="<?php echo $type; ?>-form">
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<?php wp_nonce_field('media-form'); ?>
<?php if ( is_callable($callback) ) { ?>
<div class="media-blank"> <div class="media-blank">
<p style="text-align:center"><?php _e('&mdash; OR &mdash;'); ?></p> <h3><?php _e('Add media file from URL'); ?></h3>
<h3><?php _e('From URL'); ?></h3>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@ -1414,10 +1466,11 @@ var addExtImage = {
<?php echo call_user_func($callback); ?> <?php echo call_user_func($callback); ?>
</div> </div>
</div> </div>
<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
</form> </form>
<?php <?php
endif; } else {
wp_die( __('Unknown action.') );
}
} }
/** /**
@ -1461,13 +1514,88 @@ jQuery(function($){
<div id="media-items"> <div id="media-items">
<?php echo get_media_items($post_id, $errors); ?> <?php echo get_media_items($post_id, $errors); ?>
</div> </div>
<p class="ml-submit"> <p class="ml-submit">
<input type="submit" class="button savebutton" name="save" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" /> <input type="submit" class="button savebutton" style="display:none;" name="save" id="save-all" value="<?php echo attribute_escape( __( 'Save all changes' ) ); ?>" />
<input type="submit" class="button insert-gallery" name="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery into post' ) ); ?>" />
<input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" /> <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?>" />
<input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" /> <input type="hidden" name="type" value="<?php echo attribute_escape( $GLOBALS['type'] ); ?>" />
<input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" /> <input type="hidden" name="tab" value="<?php echo attribute_escape( $GLOBALS['tab'] ); ?>" />
</p> </p>
<div id="gallery-settings" style="display:none;">
<div class="title"><?php _e('Gallery Settings'); ?></div>
<table id="basic" class="describe"><tbody>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Link thumbnails to:'); ?></span>
</label>
</th>
<td class="field">
<input type="radio" name="linkto" id="linkto-file" value="file" />
<label for="linkto-file" class="radio"><?php _e('Image File'); ?></label>
<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
<label for="linkto-post" class="radio"><?php _e('Attachment Page'); ?></label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Order images by:'); ?></span>
</label>
</th>
<td class="field">
<select id="orderby" name="orderby">
<option value="menu_order" selected="selected"><?php _e('Menu order'); ?></option>
<option value="post_name"><?php _e('Name'); ?></option>
<option value="ID"><?php _e('Date/Time'); ?></option>
</select>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Order:'); ?></span>
</label>
</th>
<td class="field">
<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
<label for="order-asc" class="radio"><?php _e('Ascending'); ?></label>
<input type="radio" name="order" id="order-desc" value="desc" />
<label for="order-desc" class="radio"><?php _e('Descending'); ?></label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft"><?php _e('Gallery columns:'); ?></span>
</label>
</th>
<td class="field">
<select id="columns" name="columns">
<option value="2"><?php _e('2'); ?></option>
<option value="3" selected="selected"><?php _e('3'); ?></option>
<option value="4"><?php _e('4'); ?></option>
<option value="5"><?php _e('5'); ?></option>
<option value="6"><?php _e('6'); ?></option>
<option value="7"><?php _e('7'); ?></option>
<option value="8"><?php _e('8'); ?></option>
<option value="9"><?php _e('9'); ?></option>
</select>
</td>
</tr>
</tbody></table>
<p class="ml-submit">
<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="insert-gallery" id="insert-gallery" value="<?php echo attribute_escape( __( 'Insert gallery' ) ); ?>" />
<input type="button" class="button" style="display:none;" onmousedown="wpgallery.update();" name="update-gallery" id="update-gallery" value="<?php echo attribute_escape( __( 'Update gallery settings' ) ); ?>" />
</p>
</div>
</form> </form>
<?php <?php
} }
@ -1634,7 +1762,7 @@ jQuery(function($){
* *
* @return unknown * @return unknown
*/ */
function type_form_image() { function type_url_form_image() {
if ( apply_filters( 'disable_captions', '' ) ) { if ( apply_filters( 'disable_captions', '' ) ) {
$alt = __('Alternate Text'); $alt = __('Alternate Text');
@ -1717,7 +1845,7 @@ function type_form_image() {
* *
* @return unknown * @return unknown
*/ */
function type_form_audio() { function type_url_form_audio() {
return ' return '
<table class="describe"><tbody> <table class="describe"><tbody>
<tr> <tr>
@ -1752,7 +1880,7 @@ function type_form_audio() {
* *
* @return unknown * @return unknown
*/ */
function type_form_video() { function type_url_form_video() {
return ' return '
<table class="describe"><tbody> <table class="describe"><tbody>
<tr> <tr>
@ -1787,7 +1915,7 @@ function type_form_video() {
* *
* @return unknown * @return unknown
*/ */
function type_form_file() { function type_url_form_file() {
return ' return '
<table class="describe"><tbody> <table class="describe"><tbody>
<tr> <tr>

View File

@ -25,4 +25,153 @@ jQuery(document).ready(function($){
$('.menu_order_input').each(function(){ $('.menu_order_input').each(function(){
if ( this.value == '0' ) this.value = ''; if ( this.value == '0' ) this.value = '';
}); });
if ( $('#media-items>*').length > 1 ) {
var w = wpgallery.getWin();
$('#save-all, #gallery-settings').show();
if ( typeof w.tinyMCE != 'undefined' && w.tinyMCE.activeEditor && ! w.tinyMCE.activeEditor.isHidden() ) {
wpgallery.mcemode = true;
wpgallery.init();
} else {
$('#insert-gallery').show();
}
}
}); });
jQuery(window).unload( function () { tinymce = tinyMCE = wpgallery = null; } ); // Cleanup
/* gallery settings */
var tinymce = null, tinyMCE;
var wpgallery = {
mcemode : false,
editor : {},
dom : {},
is_update : false,
el : {},
I : function(e) {
return document.getElementById(e);
},
init: function() {
var t = this, li, q, i, it, w = t.getWin();
if ( ! t.mcemode ) return;
li = ('' + document.location.search).replace(/^\?/, '').split('&');
q = {};
for (i=0; i<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.setup();
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
restoreSelection : function() {
var t = this;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
},
setup : function() {
var t = this, a, f = document.forms[0], ed = t.editor, el, g;
if ( ! t.mcemode ) return;
t.restoreSelection();
t.el = ed.selection.getNode();
if ( t.el.nodeName != 'IMG' || ! ed.dom.hasClass(t.el, 'wpGallery') ) {
if ( (g = ed.dom.select('img.wpGallery')) && g[0] ) {
t.el = g[0];
} else {
if ( getUserSetting('galfile') == '1' ) t.I('linkto-file').checked = "checked";
if ( getUserSetting('galdesc') == '1' ) t.I('order-desc').checked = "checked";
if ( getUserSetting('galcols') ) t.I('columns').value = getUserSetting('galcols');
if ( getUserSetting('galord') ) t.I('orderby').value = getUserSetting('galord');
jQuery('#insert-gallery').show();
return;
}
}
a = ed.dom.getAttrib(t.el, 'title');
a = ed.dom.decode(a);
if ( a ) {
jQuery('#update-gallery').show();
t.is_update = true;
var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
var order = a.match(/order=['"]([^'"]+)['"]/i), orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
if ( order && order[1] ) t.I('order-desc').checked = "checked";
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
} else {
jQuery('#insert-gallery').show();
}
},
update : function() {
var t = this, ed = t.editor, el, all = '';
if ( ! t.mcemode || ! t.is_update ) {
var s = '[gallery'+t.getSettings()+']';
t.getWin().send_to_editor(s);
return;
}
if (t.el.nodeName != 'IMG') return;
all = ed.dom.decode(ed.dom.getAttrib(t.el, 'title'));
all = all.substr(0, all.lastIndexOf(']'));
all = all.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi, '');
all += t.getSettings();
all += ']';
ed.dom.setAttrib(t.el, 'title', all);
t.getWin().tb_remove();
},
getSettings : function() {
var I = this.I, s = '';
if ( I('linkto-file').checked ) {
s += ' link="file"';
setUserSetting('galfile', '1');
}
if ( I('order-desc').checked ) {
s += ' order="DESC"';
setUserSetting('galdesc', '1');
}
if ( I('columns').value != 3 ) {
s += ' columns="'+I('columns').value+'"';
setUserSetting('galcols', I('columns').value);
}
if ( I('orderby').value != 'menu_order' ) {
s += ' orderby="'+I('orderby').value+'"';
setUserSetting('galord', I('orderby').value);
}
return s;
}
};

View File

@ -5,11 +5,17 @@ function send_to_editor(h) {
if (tinymce.isIE) if (tinymce.isIE)
ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark); ed.selection.moveToBookmark(tinymce.EditorManager.activeEditor.windowManager.bookmark);
if ( h.indexOf('[caption') != -1 ) if ( h.indexOf('[caption') === 0 ) {
if ( ed.plugins.wpeditimage )
h = ed.plugins.wpeditimage._do_shcode(h); h = ed.plugins.wpeditimage._do_shcode(h);
} else if ( h.indexOf('[gallery') === 0 ) {
if ( ed.plugins.wpgallery )
h = ed.plugins.wpgallery._do_gallery(h);
}
ed.execCommand('mceInsertContent', false, h); ed.execCommand('mceInsertContent', false, h);
} else if ( jQuery.isFunction( 'edInsertContent' ) ) {
} else if ( typeof edInsertContent == 'function' ) {
edInsertContent(edCanvas, h); edInsertContent(edCanvas, h);
} else { } else {
jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h ); jQuery( edCanvas ).val( jQuery( edCanvas ).val() + h );

View File

@ -102,7 +102,7 @@ if ( isset($_GET['inline']) ) {
$body_id = 'media-upload'; $body_id = 'media-upload';
// let the action code decide how to handle the request // let the action code decide how to handle the request
if ( $tab == 'type' ) if ( $tab == 'type' || $tab == 'type_url' )
do_action("media_upload_$type"); do_action("media_upload_$type");
else else
do_action("media_upload_$tab"); do_action("media_upload_$tab");

View File

@ -1540,7 +1540,7 @@ table.form-table td .updated {
.howto { .howto {
font-style: italic; font-style: italic;
display: block; display: block;
font-family: "Lucida Sans", "Lucida Grande", Verdana, Arial, "Bitstream Vera Sans", sans-serif; font-family: "Lucida Grande", "Bitstream Vera Sans", "Lucida Sans", Verdana, Arial, sans-serif;
} }
.ac_results { .ac_results {
@ -3055,7 +3055,7 @@ br.clear {
} }
.swfupload { .swfupload {
margin: 0 10px; margin: 5px 10px;
vertical-align: middle; vertical-align: middle;
} }

View File

@ -56,7 +56,7 @@ function prepareMediaItemInit(fileObj) {
jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new')); jQuery('#media-item-' + fileObj.id + ' .filename.original').replaceWith(jQuery('#media-item-' + fileObj.id + ' .filename.new'));
// Also bind toggle to the links // Also bind toggle to the links
jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){window.scrollTo(0,this.parentNode.offsetTop);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;}); jQuery('#media-item-' + fileObj.id + ' a.toggle').bind('click', function(){jQuery(this).siblings('.slidetoggle').slideToggle(150, function(){var o=jQuery(this).offset();window.scrollTo(0,o.top-36);});jQuery(this).parent().eq(0).children('.toggle').toggle();jQuery(this).siblings('a.toggle').focus();return false;});
// Bind AJAX to the new Delete button // Bind AJAX to the new Delete button
jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){ jQuery('#media-item-' + fileObj.id + ' a.delete').bind('click',function(){

View File

@ -427,29 +427,3 @@ img_title:"Edit Image Title",
caption:"Edit Image Caption", caption:"Edit Image Caption",
alt:"Edit Alternate Text" alt:"Edit Alternate Text"
}); });
tinyMCE.addI18n("en.gallery",{
settings:"Gallery Settings",
linkto:"Link thumbnails to:",
linktofile:"Image File",
linktopost:"Attachment Page",
orderby:"Order images by:",
menu_order:"Menu order",
byname:"Name",
bydate:"Date/Time",
random:"Random",
order:"Order:",
orderasc:"Ascending",
orderdesc:"Descending",
cols:"Gallery columns:",
two:"two",
three:"three",
four:"four",
five:"five",
six:"six",
seven:"seven",
eight:"eight",
nine:"nine",
imgwidth:"Limit the thumbnails width:",
imgwidthhelp:"Overrides the thumbnail images width. The default can be changed from the Media Settings page."
});

View File

@ -450,30 +450,4 @@ img_title:"' . mce_escape( __('Edit Image Title') ) . '",
caption:"' . mce_escape( __('Edit Image Caption') ) . '", caption:"' . mce_escape( __('Edit Image Caption') ) . '",
alt:"' . mce_escape( __('Edit Alternate Text') ) . '" alt:"' . mce_escape( __('Edit Alternate Text') ) . '"
}); });
tinyMCE.addI18n("' . $language . '.gallery",{
settings:"' . mce_escape( __('Gallery Settings') ) . '",
linkto:"' . mce_escape( __('Link thumbnails to:') ) . '",
linktofile:"' . mce_escape( __('Image File') ) . '",
linktopost:"' . mce_escape( __('Attachment Page') ) . '",
orderby:"' . mce_escape( __('Order images by:') ) . '",
menu_order:"' . mce_escape( __('Menu order') ) . '",
byname:"' . mce_escape( __('Name') ) . '",
bydate:"' . mce_escape( __('Date/Time') ) . '",
random:"' . mce_escape( __('Random') ) . '",
order:"' . mce_escape( __('Order:') ) . '",
orderasc:"' . mce_escape( __('Ascending') ) . '",
orderdesc:"' . mce_escape( __('Descending') ) . '",
cols:"' . mce_escape( __('Gallery columns:') ) . '",
two:"' . mce_escape( __('two') ) . '",
three:"' . mce_escape( __('three') ) . '",
four:"' . mce_escape( __('four') ) . '",
five:"' . mce_escape( __('five') ) . '",
six:"' . mce_escape( __('six') ) . '",
seven:"' . mce_escape( __('seven') ) . '",
eight:"' . mce_escape( __('eight') ) . '",
nine:"' . mce_escape( __('nine') ) . '",
imgwidth:"' . mce_escape( __('Limit the thumbnails width:') ) . '",
imgwidthhelp:"' . mce_escape( __('Overrides the thumbnail images width. The default can be changed from the Media Settings page.') ) . '"
});
'; ';

View File

@ -1,208 +0,0 @@
html, body {
background-color: #f9f9f9;
margin: 0;
padding: 0;
}
.button,
.button-primary,
.button-secondary {
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
text-decoration: none;
font-size: 11px !important;
line-height: 16px;
padding: 2px 8px;
cursor: pointer;
border-width: 1px;
border-style: solid;
-moz-border-radius: 11px;
-khtml-border-radius: 11px;
-webkit-border-radius: 11px;
border-radius: 11px;
-moz-box-sizing: content-box;
-webkit-box-sizing: content-box;
-khtml-box-sizing: content-box;
box-sizing: content-box;
}
a.button {
padding: 4px 8px;
}
textarea,
input,
select {
font: 13px Verdana, Arial, Helvetica, sans-serif;
margin: 1px;
padding: 2px;
background-color: #fff;
}
.align input {
vertical-align: middle;
}
body, td {
font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, sans-serif;
}
.alignright {
float: right;
}
.alignleft {
float: left;
}
.aligncenter {
display: block;
margin-left: auto;
margin-right: auto;
}
label {
cursor: pointer;
}
th.label {
width: 160px;
}
#media-upload #basic th.label {
padding: 5px 5px 5px 0;
}
#media-upload #basic .imgwidth {
vertical-align: top;
}
#saveeditimg {
padding: 10px 0 0 5px;
}
#sidemenu,
#sidemenu li {
list-style: none;
}
#sidemenu li {
display: inline;
}
#sidemenu a {
border-bottom-style: solid;
border-bottom-width: 1px;
border-top-style: solid;
border-top-width: 1px;
display: block;
float: left;
line-height: 28px;
text-decoration: none;
text-align: center;
white-space: nowrap;
margin: 0;
padding: 0pt 7px;
}
#sidemenu a.current {
-moz-border-radius-topleft: 4px;
-khtml-border-top-left-radius: 4px;
-webkit-border-top-left-radius: 4px;
border-top-left-radius: 4px;
-moz-border-radius-topright: 4px;
-khtml-border-top-right-radius: 4px;
-webkit-border-top-right-radius: 4px;
border-top-right-radius: 4px;
border-style:solid;
border-width:1px;
font-weight:normal;
}
#media-upload h3 {
clear: both;
padding: 0pt 0pt 3px;
border-bottom-style: solid;
border-bottom-width: 1px;
font-family: Georgia,"Times New Roman",Times,serif;
font-size: 20px;
font-weight: normal;
line-height: normal;
margin: 0 0 10px -4px;
padding: 15px 0 3px;
border-bottom-color: #DADADA;
color: #5A5A5A;
}
#basic {
padding-top: 2px;
}
td {
padding: 2px 0;
}
.describe td {
vertical-align: middle;
height: 3.5em;
}
#media-upload .describe th.label {
padding-top: .5em;
text-align: left;
}
#media-upload .describe {
border: 1px solid #dfdfdf;
padding: 5px 15px;
width: 100%;
clear: both;
cursor: default;
}
form {
margin: 1em;
}
.describe select {
width: 15em;
border: 1px solid #dfdfdf;
}
#imgwidth {
width: 3em;
border: 1px solid #dfdfdf;
}
.media-upload-form label,
.media-upload-form legend {
font-size: 13px;
color: #464646;
}
.align .field label {
margin: 0 1.5em 0 0;
}
div#media-upload-header {
margin: 0;
padding: 0 5px;
font-weight: bold;
position: relative;
border-bottom-width: 1px;
border-bottom-style: solid;
height: 2.5em;
}
body#media-upload ul#sidemenu {
font-weight: normal;
margin: 0 5px;
position: relative;
left: 0px;
bottom: -4px;
}
div#media-upload-error {
margin: 1em;
font-weight: bold;
}

View File

@ -15,7 +15,9 @@
if ( el.nodeName != 'IMG' ) return; if ( el.nodeName != 'IMG' ) return;
if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return; if ( ed.dom.getAttrib(el, 'class').indexOf('wpGallery') == -1 ) return;
tb_show('', url + '/gallery.html?ver=321&TB_iframe=true'); var post_id = tinymce.DOM.get('post_ID').value;
tb_show('', tinymce.documentBaseURL + '/media-upload.php?post_id='+post_id+'&tab=gallery&TB_iframe=true');
/*
tinymce.DOM.setStyles('TB_window', { tinymce.DOM.setStyles('TB_window', {
'width':( W - 50 )+'px', 'width':( W - 50 )+'px',
'height':'430px', 'height':'430px',
@ -33,6 +35,7 @@
'width':( W - 50 )+'px', 'width':( W - 50 )+'px',
'height':'400px' 'height':'400px'
}); });
*/
tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' ); tinymce.DOM.setStyle( ['TB_overlay','TB_window','TB_load'], 'z-index', '999999' );
}); });
@ -95,7 +98,7 @@
if ( cls.indexOf('wpGallery') != -1 ) if ( cls.indexOf('wpGallery') != -1 )
return '<p>'+getAttr(im, 'title')+'</p>'; return '<p>'+getAttr(im, 'title')+'</p>';
return im; return a;
}); });
}, },
@ -164,7 +167,7 @@
wp_delgallery.onmousedown = function(e) { wp_delgallery.onmousedown = function(e) {
var ed = tinyMCE.activeEditor, el = ed.selection.getNode(); var ed = tinyMCE.activeEditor, el = ed.selection.getNode();
if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('mceItemWPgallery') != -1 ) { if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('wpGallery') != -1 ) {
ed.dom.remove(el); ed.dom.remove(el);
this.parentNode.style.display = 'none'; this.parentNode.style.display = 'none';

View File

@ -1,121 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title></title>
<script type="text/javascript" src="js/gallery.js?ver=321"></script>
<script type="text/javascript" src="../../utils/form_utils.js?ver=321"></script>
<link rel="stylesheet" href="css/gallery.css?ver=321" type="text/css" media="all" />
<script type="text/javascript">
if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') )
document.write('<link rel="stylesheet" href="css/gallery-rtl.css?ver=321" type="text/css" media="all" />');
</script>
<base target="_self" />
</head>
<body id="media-upload" style="display:none;">
<div id="media-upload-header">
<ul id="sidemenu">
<li><a href="javascript:;" id="tab_basic" class="current">{#gallery.settings}</a></li>
</ul>
</div>
<div id="img-edit">
<form class="media-upload-form" action="" onsubmit="wpgallery.update();">
<div id="div_basic">
<table id="basic" class="describe">
<tbody>
<tr class="align">
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.linkto}</span>
</label>
</th>
<td class="field">
<input type="radio" name="linkto" id="linkto-file" value="file" />
<label for="linkto-file" class="radio">{#gallery.linktofile}</label>
<input type="radio" checked="checked" name="linkto" id="linkto-post" value="post" />
<label for="linkto-post" class="radio">{#gallery.linktopost}</label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.orderby}</span>
</label>
</th>
<td class="field">
<select id="orderby" name="orderby">
<option value="menu_order" selected="selected">{#gallery.menu_order}</option>
<option value="post_name">{#gallery.byname}</option>
<option value="ID">{#gallery.bydate}</option>
<option value="RAND()">{#gallery.random}</option>
</select>
</td>
</tr>
<tr class="align">
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.order}</span>
</label>
</th>
<td class="field">
<input type="radio" checked="checked" name="order" id="order-asc" value="asc" />
<label for="order-asc" class="radio">{#gallery.orderasc}</label>
<input type="radio" name="order" id="order-desc" value="desc" />
<label for="order-desc" class="radio">{#gallery.orderdesc}</label>
</td>
</tr>
<tr>
<th scope="row" class="label">
<label>
<span class="alignleft">{#gallery.cols}</span>
</label>
</th>
<td class="field">
<select id="columns" name="columns">
<option value="2">{#gallery.two}</option>
<option value="3" selected="selected">{#gallery.three}</option>
<option value="4">{#gallery.four}</option>
<option value="5">{#gallery.five}</option>
<option value="6">{#gallery.six}</option>
<option value="7">{#gallery.seven}</option>
<option value="8">{#gallery.eight}</option>
<option value="9">{#gallery.nine}</option>
</select>
</td>
</tr>
<tr>
<th scope="row" class="label imgwidth">
<label>
<span class="alignleft">{#gallery.imgwidth}</span>
</label>
</th>
<td class="field">
<input type="text" id="imgwidth" name="imgwidth" value="" size="6" />
<p>{#gallery.imgwidthhelp}</p>
</td>
</tr>
</tbody>
</table></div>
<div id="saveeditimg">
<input type="button" class="button alignleft" id="cancelimg" name="cancelimg" value="{#cancel}" onclick="tinyMCEPopup.close();" />
<input type="submit" id="saveimg" class="button-primary alignright" value="{#update}" />
<div style="clear:both"></div>
</div>
</form>
</div>
</body>
</html>

View File

@ -1,165 +0,0 @@
var tinymce = null, tinyMCEPopup, tinyMCE;
tinyMCEPopup = {
init: function() {
var t = this, w, ti, li, q, i, it;
li = ('' + document.location.search).replace(/^\?/, '').split('&');
q = {};
for (i=0; i<li.length; i++) {
it = li[i].split('=');
q[unescape(it[0])] = unescape(it[1]);
}
if (q.mce_rdomain)
document.domain = q.mce_rdomain;
// Find window & API
w = t.getWin();
tinymce = w.tinymce;
tinyMCE = w.tinyMCE;
t.editor = tinymce.EditorManager.activeEditor;
t.params = t.editor.windowManager.params;
// Setup local DOM
t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document);
t.editor.windowManager.onOpen.dispatch(t.editor.windowManager, window);
},
getWin : function() {
return window.dialogArguments || opener || parent || top;
},
getParam : function(n, dv) {
return this.editor.getParam(n, dv);
},
close : function() {
var t = this, win = t.getWin();
// To avoid domain relaxing issue in Opera
function close() {
win.tb_remove();
tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
};
if (tinymce.isOpera)
win.setTimeout(close, 0);
else
close();
},
execCommand : function(cmd, ui, val, a) {
a = a || {};
a.skip_focus = 1;
this.restoreSelection();
return this.editor.execCommand(cmd, ui, val, a);
},
storeSelection : function() {
this.editor.windowManager.bookmark = tinyMCEPopup.editor.selection.getBookmark('simple');
},
restoreSelection : function() {
var t = tinyMCEPopup;
if (tinymce.isIE)
t.editor.selection.moveToBookmark(t.editor.windowManager.bookmark);
}
}
tinyMCEPopup.init();
var wpgallery = {
preInit : function() {
// import colors stylesheet from parent
var win = tinyMCEPopup.getWin();
var styles = win.document.styleSheets;
for ( i = 0; i < styles.length; i++ ) {
var url = styles.item(i).href;
if ( url && url.indexOf('colors') != -1 )
document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' );
}
},
I : function(e) {
return document.getElementById(e);
},
init : function() {
var ed = tinyMCEPopup.editor, h;
h = document.body.innerHTML;
// Replace a=x with a="x" in IE
if (tinymce.isIE)
h = h.replace(/ (value|title|alt)=([^"][^\s>]+)/gi, ' $1="$2"')
document.body.innerHTML = ed.translate(h);
window.setTimeout( function(){wpgallery.setup();}, 100 );
},
setup : function() {
var t = this, a, f = document.forms[0], ed = tinyMCEPopup.editor, dom = tinyMCEPopup.dom;
document.dir = tinyMCEPopup.editor.getParam('directionality','');
tinyMCEPopup.restoreSelection();
el = ed.selection.getNode();
if (el.nodeName != 'IMG') return;
a = ed.dom.getAttrib(el, 'title');
a = ed.dom.decode(a);
if ( a ) {
var columns = a.match(/columns=['"]([0-9]+)['"]/), link = a.match(/link=['"]([^'"]+)['"]/i);
var imgwidth = a.match(/imgwidth=['"]([0-9]+)['"]/), order = a.match(/order=['"]([^'"]+)['"]/i);
var orderby = a.match(/orderby=['"]([^'"]+)['"]/i), all = '';
if ( link && link[1] ) t.I('linkto-file').checked = "checked";
if ( order && order[1] ) t.I('order-desc').checked = "checked";
if ( columns && columns[1] ) t.I('columns').value = ''+columns[1];
if ( orderby && orderby[1] ) t.I('orderby').value = orderby[1];
if ( imgwidth && imgwidth[1] ) t.I('imgwidth').value = imgwidth[1];
}
document.body.style.display = '';
},
update : function() {
var t = this, ed = tinyMCEPopup.editor, el, all;
tinyMCEPopup.restoreSelection();
el = ed.selection.getNode();
if (el.nodeName != 'IMG') return;
all = ed.dom.decode(ed.dom.getAttrib(el, 'title'));
all = all.substr(0, all.lastIndexOf(']'));
all = all.replace(/\s*(order|link|columns|orderby|imgwidth)=['"]([^'"]+)['"]/gi, '');
if ( t.I('linkto-file').checked )
all += ' link="file"';
if ( t.I('order-desc').checked )
all += ' order="DESC"';
if ( t.I('columns').value != 3 )
all += ' columns="'+t.I('columns').value+'"';
if ( t.I('orderby').value != 'menu_order' )
all += ' orderby="'+t.I('orderby').value+'"';
if ( t.I('imgwidth').value )
all += ' imgwidth="'+t.I('imgwidth').value+'"';
all += ']';
ed.dom.setAttrib(el, 'title', all);
tinyMCEPopup.close();
}
};
window.onload = function(){wpgallery.init();}
wpgallery.preInit();

View File

@ -522,16 +522,15 @@ function wp_get_attachment_image_src($attachment_id, $size='thumbnail', $icon =
* @param int $attachment_id Image attachment ID. * @param int $attachment_id Image attachment ID.
* @param string $size Optional, default is 'thumbnail'. * @param string $size Optional, default is 'thumbnail'.
* @param bool $icon Optional, default is false. Whether it is an icon. * @param bool $icon Optional, default is false. Whether it is an icon.
* @param int $imgwidth Override image width.
* @return string HTML img element or empty string on failure. * @return string HTML img element or empty string on failure.
*/ */
function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false, $imgwidth = false) { function wp_get_attachment_image($attachment_id, $size = 'thumbnail', $icon = false) {
$html = ''; $html = '';
$image = wp_get_attachment_image_src($attachment_id, $size, $icon); $image = wp_get_attachment_image_src($attachment_id, $size, $icon);
if ( $image ) { if ( $image ) {
list($src, $width, $height) = $image; list($src, $width, $height) = $image;
$hwstring = $imgwidth ? image_hwstring($imgwidth, '') : image_hwstring($width, $height); $hwstring = image_hwstring($width, $height);
if ( is_array($size) ) if ( is_array($size) )
$size = join('x', $size); $size = join('x', $size);
$html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />'; $html = '<img src="'.attribute_escape($src).'" '.$hwstring.'class="attachment-'.attribute_escape($size).'" alt="" />';
@ -618,8 +617,7 @@ function gallery_shortcode($attr) {
'icontag' => 'dt', 'icontag' => 'dt',
'captiontag' => 'dd', 'captiontag' => 'dd',
'columns' => 3, 'columns' => 3,
'size' => 'thumbnail', 'size' => 'thumbnail'
'imgwidth' => ''
), $attr)); ), $attr));
$id = intval($id); $id = intval($id);
@ -639,7 +637,6 @@ function gallery_shortcode($attr) {
$captiontag = tag_escape($captiontag); $captiontag = tag_escape($captiontag);
$columns = intval($columns); $columns = intval($columns);
$itemwidth = $columns > 0 ? floor(100/$columns) : 100; $itemwidth = $columns > 0 ? floor(100/$columns) : 100;
$imgwidth = isset($imgwidth) && (int) $imgwidth ? $imgwidth : false;
$output = apply_filters('gallery_style', " $output = apply_filters('gallery_style', "
<style type='text/css'> <style type='text/css'>
@ -663,7 +660,7 @@ function gallery_shortcode($attr) {
$i = 0; $i = 0;
foreach ( $attachments as $id => $attachment ) { foreach ( $attachments as $id => $attachment ) {
$link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false, $imgwidth) : wp_get_attachment_link($id, $size, true, false, $imgwidth); $link = isset($attr['link']) && 'file' == $attr['link'] ? wp_get_attachment_link($id, $size, false, false) : wp_get_attachment_link($id, $size, true, false);
$output .= "<{$itemtag} class='gallery-item'>"; $output .= "<{$itemtag} class='gallery-item'>";
$output .= " $output .= "

View File

@ -757,7 +757,7 @@ function the_attachment_link($id = 0, $fullsize = false, $deprecated = false, $p
* @param bool $icon Optional, default is false. Whether to include icon. * @param bool $icon Optional, default is false. Whether to include icon.
* @return string HTML content. * @return string HTML content.
*/ */
function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $imgwidth = false) { function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
$id = intval($id); $id = intval($id);
$_post = & get_post( $id ); $_post = & get_post( $id );
@ -769,7 +769,7 @@ function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false
$post_title = attribute_escape($_post->post_title); $post_title = attribute_escape($_post->post_title);
$link_text = wp_get_attachment_image($id, $size, $icon, $imgwidth); $link_text = wp_get_attachment_image($id, $size, $icon);
if ( !$link_text ) if ( !$link_text )
$link_text = $_post->post_title; $link_text = $_post->post_title;

View File

@ -61,7 +61,7 @@ function wp_default_scripts( &$scripts ) {
// Modify this version when tinyMCE plugins are changed. // Modify this version when tinyMCE plugins are changed.
function mce_version() { function mce_version() {
return '20081122'; return '20081125';
} }
add_filter( 'tiny_mce_version', 'mce_version' ); add_filter( 'tiny_mce_version', 'mce_version' );
@ -225,8 +225,8 @@ function wp_default_scripts( &$scripts ) {
'edit' => __('Edit'), 'edit' => __('Edit'),
'submittedOn' => __('Submitted on:') 'submittedOn' => __('Submitted on:')
) ); ) );
$scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20080709' ); $scripts->add( 'admin-gallery', '/wp-admin/js/gallery.js', array( 'jquery-ui-sortable' ), '20081125' );
$scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081031' ); $scripts->add( 'media-upload', '/wp-admin/js/media-upload.js', array( 'thickbox' ), '20081125' );
$scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081120' ); $scripts->add( 'admin-widgets', '/wp-admin/js/widgets.js', array( 'interface' ), '20081120' );
$scripts->localize( 'admin-widgets', 'widgetsL10n', array( $scripts->localize( 'admin-widgets', 'widgetsL10n', array(