Make WordPress Core

Changeset 10793


Ignore:
Timestamp:
03/16/2009 01:05:09 PM (15 years ago)
Author:
azaozz
Message:

Add sort order for the gallery in the uploader

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/css/media.css

    r10156 r10793  
    425425    width: 6em;
    426426}
     427
     428#sort-buttons {
     429    font-size: 0.8em;
     430    margin: 3px 25px -8px 0;
     431    text-align: right;
     432    max-width: 625px;
     433}
     434
     435#sort-buttons a {
     436    padding: 0 2px;
     437    text-decoration: none;
     438}
     439
  • trunk/wp-admin/includes/media.php

    r10774 r10793  
    15491549-->
    15501550</script>
    1551 
     1551<div id="sort-buttons" class="hide-if-no-js">
     1552<?php _e('Sort Order:'); ?>
     1553<a href="#" id="asc"><?php _e('Ascending'); ?></a>
     1554<a href="#" id="desc"><?php _e('Descending'); ?></a>
     1555<a href="#" id="clear"><?php _e('Clear'); ?></a>
     1556</div>
    15521557<form enctype="multipart/form-data" method="post" action="<?php echo attribute_escape($form_action_url); ?>" class="media-upload-form validate" id="gallery-form">
    15531558<?php wp_nonce_field('media-form'); ?>
  • trunk/wp-admin/js/gallery.dev.js

    r10291 r10793  
    11jQuery(document).ready(function($) {
    2     var gallerySortable, gallerySortableInit, galleryReorder, w;
     2    var gallerySortable, gallerySortableInit, galleryReorder, w, desc = false;
    33
    44    gallerySortableInit = function() {
     
    1414    // When an update has occurred, adjust the order for each item
    1515    galleryReorder = function(e, sort) {
    16         jQuery.each(sort['element'].sortable('toArray'), function(i, id) {
    17             jQuery('#' + id + ' .menu_order input')[0].value = (1+i);
     16        var all = sort['element'].sortable('toArray'), len = all.length;
     17        $.each(all, function(i, id) {
     18            var order = desc ? (len - i) : (1 + i);
     19            $('#' + id + ' .menu_order input').val(order);
    1820        });
    1921    }
    2022
     23    sortIt = function() {
     24        var all = $('.menu_order_input'), len = all.length;
     25        all.each(function(i){
     26            var order = desc ? (len - i) : (1 + i);
     27            $(this).val(order);
     28        });
     29    }
     30
     31    clearAll = function(c) {
     32        c = c || 0;
     33        $('.menu_order_input').each(function(){
     34            if ( this.value == '0' || c ) this.value = '';
     35        });
     36    }
     37
     38    $('#asc').click(function(){desc = false; sortIt(); return false;});
     39    $('#desc').click(function(){desc = true; sortIt(); return false;});
     40    $('#clear').click(function(){clearAll(1); return false;});
     41
    2142    // initialize sortable
    2243    gallerySortableInit();
    23 
    24     $('.menu_order_input').each(function(){
    25         if ( this.value == '0' ) this.value = '';
    26     });
     44    clearAll();
    2745
    2846    if ( $('#media-items>*').length > 1 ) {
  • trunk/wp-admin/js/gallery.js

    r10291 r10793  
    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}};
     1jQuery(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}};
  • trunk/wp-includes/script-loader.php

    r10791 r10793  
    325325        ) );
    326326
    327         $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090102' );
     327        $scripts->add( 'admin-gallery', "/wp-admin/js/gallery$suffix.js", array( 'jquery-ui-sortable' ), '20090315' );
    328328
    329329        $scripts->add( 'media-upload', "/wp-admin/js/media-upload$suffix.js", array( 'thickbox' ), '20090114' );
     
    438438
    439439    $styles->add( 'global', '/wp-admin/css/global.css', array(), '20081226' );
    440     $styles->add( 'media', '/wp-admin/css/media.css', array(), '20081210' );
     440    $styles->add( 'media', '/wp-admin/css/media.css', array(), '20090315' );
    441441    $styles->add( 'widgets', '/wp-admin/css/widgets.css', array(), '20081210' );
    442442    $styles->add( 'dashboard', '/wp-admin/css/dashboard.css', array(), '20090305' );
Note: See TracChangeset for help on using the changeset viewer.