Add sort order for the gallery in the uploader
git-svn-id: http://svn.automattic.com/wordpress/trunk@10793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
083218222c
commit
9f9fcdfa9d
|
@ -424,3 +424,16 @@ h3.media-title {
|
||||||
#gallery-settings select#columns {
|
#gallery-settings select#columns {
|
||||||
width: 6em;
|
width: 6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#sort-buttons {
|
||||||
|
font-size: 0.8em;
|
||||||
|
margin: 3px 25px -8px 0;
|
||||||
|
text-align: right;
|
||||||
|
max-width: 625px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#sort-buttons a {
|
||||||
|
padding: 0 2px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1548,7 +1548,12 @@ jQuery(function($){
|
||||||
});
|
});
|
||||||
-->
|
-->
|
||||||
</script>
|
</script>
|
||||||
|
<div id="sort-buttons" class="hide-if-no-js">
|
||||||
|
<?php _e('Sort Order:'); ?>
|
||||||
|
<a href="#" id="asc"><?php _e('Ascending'); ?></a>
|
||||||
|
<a href="#" id="desc"><?php _e('Descending'); ?></a>
|
||||||
|
<a href="#" id="clear"><?php _e('Clear'); ?></a>
|
||||||
|
</div>
|
||||||
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
|
<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
|
||||||
<?php wp_nonce_field('media-form'); ?>
|
<?php wp_nonce_field('media-form'); ?>
|
||||||
<?php //media_upload_form( $errors ); ?>
|
<?php //media_upload_form( $errors ); ?>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
jQuery(document).ready(function($) {
|
jQuery(document).ready(function($) {
|
||||||
var gallerySortable, gallerySortableInit, galleryReorder, w;
|
var gallerySortable, gallerySortableInit, galleryReorder, w, desc = false;
|
||||||
|
|
||||||
gallerySortableInit = function() {
|
gallerySortableInit = function() {
|
||||||
gallerySortable = $('#media-items').sortable( {
|
gallerySortable = $('#media-items').sortable( {
|
||||||
|
@ -13,17 +13,35 @@ jQuery(document).ready(function($) {
|
||||||
|
|
||||||
// When an update has occurred, adjust the order for each item
|
// When an update has occurred, adjust the order for each item
|
||||||
galleryReorder = function(e, sort) {
|
galleryReorder = function(e, sort) {
|
||||||
jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
|
var all = sort['element'].sortable('toArray'), len = all.length;
|
||||||
jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
|
$.each(all, function(i, id) {
|
||||||
|
var order = desc ? (len - i) : (1 + i);
|
||||||
|
$('#' + id + ' .menu_order input').val(order);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sortIt = function() {
|
||||||
|
var all = $('.menu_order_input'), len = all.length;
|
||||||
|
all.each(function(i){
|
||||||
|
var order = desc ? (len - i) : (1 + i);
|
||||||
|
$(this).val(order);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
clearAll = function(c) {
|
||||||
|
c = c || 0;
|
||||||
|
$('.menu_order_input').each(function(){
|
||||||
|
if ( this.value == '0' || c ) this.value = '';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#asc').click(function(){desc = false; sortIt(); return false;});
|
||||||
|
$('#desc').click(function(){desc = true; sortIt(); return false;});
|
||||||
|
$('#clear').click(function(){clearAll(1); return false;});
|
||||||
|
|
||||||
// initialize sortable
|
// initialize sortable
|
||||||
gallerySortableInit();
|
gallerySortableInit();
|
||||||
|
clearAll();
|
||||||
$('.menu_order_input').each(function(){
|
|
||||||
if ( this.value == '0' ) this.value = '';
|
|
||||||
});
|
|
||||||
|
|
||||||
if ( $('#media-items>*').length > 1 ) {
|
if ( $('#media-items>*').length > 1 ) {
|
||||||
w = wpgallery.getWin();
|
w = wpgallery.getWin();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
jQuery(document).ready(function(d){var c,e,b,a;e=function(){c=d("#media-items").sortable({items:".media-item",placeholder:"sorthelper",axis:"y",distance:2,update:b})};b=function(g,f){jQuery.each(f.element.sortable("toArray"),function(h,j){jQuery("#"+j+" .menu_order input")[0].value=(1+h)})};e();d(".menu_order_input").each(function(){if(this.value=="0"){this.value=""}});if(d("#media-items>*").length>1){a=wpgallery.getWin();d("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{d("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},restoreSelection:function(){var a=this;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},setup:function(){var f=this,c,d=f.editor,i;if(!f.mcemode){return}f.restoreSelection();f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;var e=c.match(/columns=['"]([0-9]+)['"]/),h=c.match(/link=['"]([^'"]+)['"]/i),b=c.match(/order=['"]([^'"]+)['"]/i),j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};
|
jQuery(document).ready(function(d){var c,f,b,a,e=false;f=function(){c=d("#media-items").sortable({items:".media-item",placeholder:"sorthelper",axis:"y",distance:2,update:b})};b=function(j,h){var i=h.element.sortable("toArray"),g=i.length;d.each(i,function(l,m){var k=e?(g-l):(1+l);d("#"+m+" .menu_order input").val(k)})};sortIt=function(){var h=d(".menu_order_input"),g=h.length;h.each(function(k){var j=e?(g-k):(1+k);d(this).val(j)})};clearAll=function(g){g=g||0;d(".menu_order_input").each(function(){if(this.value=="0"||g){this.value=""}})};d("#asc").click(function(){e=false;sortIt();return false});d("#desc").click(function(){e=true;sortIt();return false});d("#clear").click(function(){clearAll(1);return false});f();clearAll();if(d("#media-items>*").length>1){a=wpgallery.getWin();d("#save-all, #gallery-settings").show();if(typeof a.tinyMCE!="undefined"&&a.tinyMCE.activeEditor&&!a.tinyMCE.activeEditor.isHidden()){wpgallery.mcemode=true;wpgallery.init()}else{d("#insert-gallery").show()}}});jQuery(window).unload(function(){tinymce=tinyMCE=wpgallery=null});var tinymce=null,tinyMCE,wpgallery;wpgallery={mcemode:false,editor:{},dom:{},is_update:false,el:{},I:function(a){return document.getElementById(a)},init:function(){var d=this,a,f,c,e,b=d.getWin();if(!d.mcemode){return}a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.setup()},getWin:function(){return window.dialogArguments||opener||parent||top},restoreSelection:function(){var a=this;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}},setup:function(){var f=this,c,d=f.editor,i;if(!f.mcemode){return}f.restoreSelection();f.el=d.selection.getNode();if(f.el.nodeName!="IMG"||!d.dom.hasClass(f.el,"wpGallery")){if((i=d.dom.select("img.wpGallery"))&&i[0]){f.el=i[0]}else{if(getUserSetting("galfile")=="1"){f.I("linkto-file").checked="checked"}if(getUserSetting("galdesc")=="1"){f.I("order-desc").checked="checked"}if(getUserSetting("galcols")){f.I("columns").value=getUserSetting("galcols")}if(getUserSetting("galord")){f.I("orderby").value=getUserSetting("galord")}jQuery("#insert-gallery").show();return}}c=d.dom.getAttrib(f.el,"title");c=d.dom.decode(c);if(c){jQuery("#update-gallery").show();f.is_update=true;var e=c.match(/columns=['"]([0-9]+)['"]/),h=c.match(/link=['"]([^'"]+)['"]/i),b=c.match(/order=['"]([^'"]+)['"]/i),j=c.match(/orderby=['"]([^'"]+)['"]/i);if(h&&h[1]){f.I("linkto-file").checked="checked"}if(b&&b[1]){f.I("order-desc").checked="checked"}if(e&&e[1]){f.I("columns").value=""+e[1]}if(j&&j[1]){f.I("orderby").value=j[1]}}else{jQuery("#insert-gallery").show()}},update:function(){var b=this,a=b.editor,d="",c;if(!b.mcemode||!b.is_update){c="[gallery"+b.getSettings()+"]";b.getWin().send_to_editor(c);return}if(b.el.nodeName!="IMG"){return}d=a.dom.decode(a.dom.getAttrib(b.el,"title"));d=d.replace(/\s*(order|link|columns|orderby)=['"]([^'"]+)['"]/gi,"");d+=b.getSettings();a.dom.setAttrib(b.el,"title",d);b.getWin().tb_remove()},getSettings:function(){var a=this.I,b="";if(a("linkto-file").checked){b+=' link="file"';setUserSetting("galfile","1")}if(a("order-desc").checked){b+=' order="DESC"';setUserSetting("galdesc","1")}if(a("columns").value!=3){b+=' columns="'+a("columns").value+'"';setUserSetting("galcols",a("columns").value)}if(a("orderby").value!="menu_order"){b+=' orderby="'+a("orderby").value+'"';setUserSetting("galord",a("orderby").value)}return b}};
|
|
@ -324,7 +324,7 @@ function wp_default_scripts( &$scripts ) {
|
||||||
'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
|
'l10n_print_after' => 'try{convertEntities(commentL10n);}catch(e){};'
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090102' );
|
$scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090315' );
|
||||||
|
|
||||||
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20090114' );
|
$scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20090114' );
|
||||||
$scripts->add_data( 'media-upload', 'group', 1 );
|
$scripts->add_data( 'media-upload', 'group', 1 );
|
||||||
|
@ -437,7 +437,7 @@ function wp_default_styles( &$styles ) {
|
||||||
$styles->add_data( 'colors-classic', 'rtl', true );
|
$styles->add_data( 'colors-classic', 'rtl', true );
|
||||||
|
|
||||||
$styles->add( 'global', '/wp-admin/css/global.css', array(), '20081226' );
|
$styles->add( 'global', '/wp-admin/css/global.css', array(), '20081226' );
|
||||||
$styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' );
|
$styles->add( 'media', '/wp-admin/css/media.css', array(), '20090315' );
|
||||||
$styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' );
|
$styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' );
|
||||||
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090305' );
|
$styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090305' );
|
||||||
$styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' );
|
$styles->add( 'install', '/wp-admin/css/install.css', array(), '20081210' );
|
||||||
|
|
Loading…
Reference in New Issue