Changeset 24098
- Timestamp:
- 04/26/2013 12:22:55 PM (12 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/colors-classic.css
r24064 r24098 165 165 } 166 166 167 .post-format-options, 167 168 .widget .widget-top, 168 169 .postbox h3, … … 689 690 } 690 691 692 .post-format-options, 691 693 .postbox h3 { 692 694 color: #174f69; -
trunk/wp-admin/css/colors-fresh.css
r24064 r24098 165 165 } 166 166 167 .post-format-options, 167 168 .widget .widget-top, 168 169 .postbox h3, … … 691 692 } 692 693 694 .post-format-options, 693 695 .postbox h3 { 694 696 color: #464646; -
trunk/wp-admin/css/wp-admin.css
r24092 r24098 4001 4001 4002 4002 .wp-format-status #titlewrap, 4003 .wp-format-image .wp-media-buttons .insert-media, 4004 .wp-format-audio .wp-media-buttons .insert-media, 4005 .wp-format-video .wp-media-buttons .insert-media, 4003 4006 .wp-format-aside .wp-media-buttons .insert-media, 4004 4007 .wp-format-status .wp-media-buttons .insert-media { … … 4102 4105 4103 4106 .post-format-options { 4104 height: 50px; 4107 border-width: 1px; 4108 border-style: solid; 4109 -webkit-border-radius: 3px; 4110 border-radius: 3px; 4111 border-color: #CCC; 4105 4112 margin: 13px 0 10px; 4106 padding: 0;4113 padding: 5px; 4107 4114 } 4108 4115 4109 4116 .post-format-options a { 4110 4117 display: inline-block; 4111 height: 34px; 4112 margin-right: 33px; 4118 min-width: 62px; 4119 padding:5px; 4120 border:1px solid transparent; 4121 margin-right: 10px; 4113 4122 position: relative; 4114 4123 text-decoration: none; 4115 4124 text-align: center; 4125 transition: opacity 0.1s linear; 4126 opacity: 0.6; 4127 } 4128 4129 .post-format-options:hover a { 4130 opacity: 1.0; 4131 } 4132 .post-format-options a:hover, 4133 .post-format-options a.active { 4134 opacity: 1.0; 4135 background-color: #fff; 4136 border-color: #ccc; 4116 4137 } 4117 4138 … … 4128 4149 } 4129 4150 4130 .post-format- change, .post-format-set .post-format-options {4151 .post-format-set .post-format-options { 4131 4152 display: none; 4132 4153 } … … 4137 4158 4138 4159 #poststuff .post-format-change { 4139 margin: 11px 0 13px;4160 margin: -7px 0 13px 2px; 4140 4161 padding: 0; 4141 4162 font-size: 1.5em; … … 4151 4172 } 4152 4173 4153 .post-format-change span.icon. standard {4174 .post-format-change span.icon.wp-format-standard { 4154 4175 background: url(../images/post-formats.png) no-repeat -8px -8px; 4155 4176 } 4156 4177 4157 .post-format-change span.icon. image {4178 .post-format-change span.icon.wp-format-image { 4158 4179 background: url(../images/post-formats.png) no-repeat -40px -8px; 4159 4180 } 4160 4181 4161 .post-format-change span.icon. gallery {4182 .post-format-change span.icon.wp-format-gallery { 4162 4183 background: url(../images/post-formats.png) no-repeat -72px -8px; 4163 4184 } 4164 4185 4165 .post-format-change span.icon. audio {4186 .post-format-change span.icon.wp-format-audio { 4166 4187 background: url(../images/post-formats.png) no-repeat -104px -8px; 4167 4188 } 4168 4189 4169 .post-format-change span.icon. video {4190 .post-format-change span.icon.wp-format-video { 4170 4191 background: url(../images/post-formats.png) no-repeat -136px -8px; 4171 4192 } 4172 4193 4173 .post-format-change span.icon. chat {4194 .post-format-change span.icon.wp-format-chat { 4174 4195 background: url(../images/post-formats.png) no-repeat -168px -8px; 4175 4196 } 4176 4197 4177 .post-format-change span.icon. status {4198 .post-format-change span.icon.wp-format-status { 4178 4199 background: url(../images/post-formats.png) no-repeat -200px -8px; 4179 4200 } 4180 4201 4181 .post-format-change span.icon. aside {4202 .post-format-change span.icon.wp-format-aside { 4182 4203 background: url(../images/post-formats.png) no-repeat -232px -8px; 4183 4204 } 4184 4205 4185 .post-format-change span.icon. quote {4206 .post-format-change span.icon.wp-format-quote { 4186 4207 background: url(../images/post-formats.png) no-repeat -264px -8px; 4187 4208 } 4188 4209 4189 .post-format-change span.icon. link {4210 .post-format-change span.icon.wp-format-link { 4190 4211 background: url(../images/post-formats.png) no-repeat -296px -8px; 4191 4212 } -
trunk/wp-admin/edit-form-advanced.php
r24097 r24098 137 137 wp_enqueue_style( 'wp-mediaelement' ); 138 138 $post_format = get_post_format(); 139 $post_format_set_class = 'post-format-set';140 139 141 140 if ( ! $post_format ) { … … 144 143 if ( ! empty( $_REQUEST['format'] ) && in_array( $_REQUEST['format'], get_post_format_slugs() ) ) 145 144 $post_format = $_REQUEST['format']; 146 elseif ( 'auto-draft' == $post->post_status )147 $post_format_set_class = '';148 145 } 149 146 … … 426 423 <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> 427 424 <div id="post-body-content"<?php echo $format_class; ?>> 425 <div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>"> 426 <div class="post-format-change"><span class="icon <?php echo esc_attr( 'wp-format-' . $post_format ); ?>"></span> <span class="post-format-description"><?php echo $all_post_formats[$post_format]['description']; ?></span></div> 427 </div> 428 428 <?php if ( post_type_supports($post_type, 'title') ) { ?> 429 429 <div id="titlediv"> -
trunk/wp-admin/includes/post-formats.php
r24092 r24098 11 11 ?> 12 12 <div class="wp-post-format-ui<?php if ( ! $show_post_format_ui ) echo ' no-ui' ?>"> 13 <div class="post-format-change"><span class="icon <?php echo esc_attr( $post_format ); ?>"></span> <span class="post-format-description"><?php echo $all_post_formats[$post_format]['description']; ?></span> <a href="#"><?php _e('Change format'); ?></a></div>14 13 <div class="post-formats-fields"> 15 14 -
trunk/wp-admin/js/post-formats.js
r24092 r24098 1 /*globals window, $, jQuery, document, _, postFormats, tinymce, ajaxurl, wp, getUserSetting */ 2 1 3 window.wp = window.wp || {}; 2 4 3 (function($) { 4 var container, $container, mediaFrame, lastMimeType, mediaPreview, lastHeight = 360, content, insertMediaButton, 5 (function ($) { 6 "use strict"; 7 8 var mediaFrame, insertMediaButton, container, icon, formatField, 9 lastMimeType, 10 classRegex = /\s?\bwp-format-[^ ]+/g, 11 shortHeight = 120, 12 lastHeight = 360, 5 13 initialFormat = 'standard', 6 14 shortClass = 'short-format', 15 noTitleFormats = ['status'], 16 noMediaFormats = ['status', 'aside', 'image', 'audio', 'video'], 7 17 shortContentFormats = ['status', 'aside'], 8 noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery'], 9 $screenIcon = $( '.icon32' ); 10 18 noUIFormats = ['standard', 'chat', 'status', 'aside', 'gallery']; 11 19 12 20 function switchFormatClass( format ) { 13 container.get(0).className = container.get(0).className.replace( /\s?\bwp-format-[^ ]+/g, '' ); 14 container.addClass('wp-format-' + format); 15 $screenIcon.get(0).className = $screenIcon.get(0).className.replace( /\s?\bwp-format-[^ ]+/g, '' ); 16 $screenIcon.addClass('wp-format-' + format); 21 formatField.val( format ); 22 23 container 24 .prop( 'className', container.prop( 'className' ).replace( classRegex, '' ) ) 25 .addClass( 'wp-format-' + format ); 26 27 icon 28 .prop( 'className', icon.prop( 'className' ).replace( classRegex, '' ) ) 29 .addClass( 'wp-format-' + format ); 17 30 } 18 31 19 32 function resizeContent( format, noAnimate ) { 20 var height; 21 22 content = $('#content, #content_ifr'); 23 24 height = content.height(); 25 if ( 120 < height ) { 33 var height, content = $( '#content, #content_ifr' ); 34 35 height = content.outerHeight(); 36 if ( shortHeight < height ) { 26 37 lastHeight = height; 27 38 } 28 39 29 40 if ( -1 < $.inArray( format, shortContentFormats ) ) { 30 if ( ! content.hasClass(shortClass) ) { 31 content.addClass(shortClass); 32 if ( noAnimate ) { 33 content.each(function () { 34 $(this).css({ height : 120 }); 35 }); 36 } else { 37 content.each(function () { 38 $(this).animate({ height : 120 }); 39 }); 40 } 41 if ( ! content.hasClass( shortClass ) ) { 42 content.addClass( shortClass ); 43 _(content).each(function (elem) { 44 $(elem)[noAnimate ? 'css' : 'animate']( { height : shortHeight } ); 45 }); 41 46 } 42 47 } else { 43 content.removeClass( shortClass).animate({ height : lastHeight });48 content.removeClass( shortClass ).animate( { height : lastHeight } ); 44 49 } 45 50 } 46 51 47 function switchFormat($this) { 48 var editor, body, 49 parent = $this.parent(), 50 format = $this.data('wp-format'), 51 description = $('.post-format-description'), 52 postTitle = $('#title'); 53 54 if ( typeof container === 'undefined' ) 55 container = $('#post-body-content'); 56 57 parent.slideUp().find('a.active').removeClass('active'); 58 $this.addClass('active'); 59 $('#post_format').val(format); 60 $('.post-format-change').show().find('span.icon').removeClass(postFormats.currentPostFormat).addClass(format); 61 62 if ( -1 < $.inArray( format, noUIFormats ) ) { 63 switchFormatClass( format ); // No slide 64 $container.hide(); 65 } else { 66 $container.slideUp( 200, function(){ 52 function switchFormat(elem) { 53 var editor, body, formatTo, formatFrom, 54 format = elem.data( 'wp-format' ), 55 titlePrompt = $( '#title-prompt-text' ), 56 description = $( '.post-format-description' ), 57 postTitle = $( '#title'), 58 fields = $( '.post-formats-fields' ), 59 tinyIcon = $( '.post-format-change span.icon' ); 60 61 if ( format === postFormats.currentPostFormat ) { 62 return; 63 } 64 65 elem.addClass( 'active' ).siblings().removeClass( 'active' ); 66 67 // Animate the media button going away or coming back 68 formatTo = -1 < $.inArray( format, noMediaFormats ); 69 formatFrom = -1 < $.inArray( postFormats.currentPostFormat, noMediaFormats ); 70 if ( formatFrom ? !formatTo : formatTo ) { // XOR 71 insertMediaButton.fadeToggle( 200 ).css( 'display', 'inline-block' ); 72 } 73 // Animate the title going away or coming back 74 formatTo = -1 < $.inArray( format, noTitleFormats ); 75 formatFrom = -1 < $.inArray( postFormats.currentPostFormat, noTitleFormats ); 76 if ( formatFrom ? !formatTo : formatTo ) { // XOR 77 $( '#titlewrap' ).fadeToggle( 200 ); 78 } 79 80 // Animate the fields moving going away or coming in 81 formatTo = -1 < $.inArray( format, noUIFormats ); 82 formatFrom = -1 < $.inArray( postFormats.currentPostFormat, noUIFormats ); 83 if ( formatTo && formatFrom ) { // To/from have no UI. No slide. 84 console.log( 'both no UI' ); 85 switchFormatClass( format ); 86 fields.hide(); 87 } else if ( formatFrom ) { // Only destination has UI. Slide down. 88 console.log( 'destination only' ); 89 fields.hide(); 90 switchFormatClass( format ); 91 fields.slideDown( 400 ); 92 } else if ( formatTo ) { // Only source has UI. Slide up. 93 console.log( 'source only' ); 94 fields.slideUp( 200, function(){ 67 95 switchFormatClass( format ); 68 $container.slideDown( 400 );69 96 }); 97 } else { // Both have UI. Slide both ways. 98 console.log( 'both' ); 99 fields.slideUp( 200, function(){ 100 switchFormatClass( format ); 101 fields.slideDown( 400 ); 102 }); 70 103 } 71 104 72 105 resizeContent( format ); 73 74 106 postTitle.focus(); 75 107 76 if ( '' === postTitle.val() ) 77 $('#title-prompt-text').removeClass('screen-reader-text'); 108 if ( '' === postTitle.val() ) { 109 titlePrompt.removeClass( 'screen-reader-text' ); 110 111 postTitle.keydown( function (e) { 112 titlePrompt.addClass( 'screen-reader-text' ); 113 $( e.currentTarget ).unbind( e ); 114 } ); 115 } 78 116 79 117 // Update description line 80 description.html($this.data('description')); 81 82 if (description.not(':visible')) 83 description.slideDown('fast'); 84 85 if ( typeof tinymce != 'undefined' ) { 86 editor = tinymce.get('content'); 118 description.html( elem.data( 'description' ) ); 119 tinyIcon 120 .show() 121 .prop( 'className', tinyIcon.prop( 'className' ).replace( classRegex, '' ) ) 122 .addClass( 'wp-format-' + format ); 123 124 if ( description.not( ':visible' ) ) { 125 description.slideDown( 'fast' ); 126 } 127 128 if ( tinymce ) { 129 editor = tinymce.get( 'content' ); 87 130 88 131 if ( editor ) { … … 95 138 // If gallery, force it to open to gallery state 96 139 insertMediaButton.toggleClass( 'gallery', 'gallery' === format ); 97 98 140 postFormats.currentPostFormat = format; 99 141 } 100 142 101 102 103 $(function() { 143 $(function () { 144 container = $( '#post-body-content' ); 145 icon = $( '.icon32' ); 146 formatField = $( '#post_format' ); 104 147 insertMediaButton = $( '#insert-media-button' ).toggleClass( 'gallery', 'gallery' === postFormats.currentPostFormat ); 105 $container = $( '.post-formats-fields' );106 107 148 initialFormat = $( '.post-format-options .active' ).data( 'wp-format' ); 149 108 150 if ( -1 < $.inArray( initialFormat, shortContentFormats ) ) { 109 151 resizeContent( initialFormat, true ); 110 152 } 111 153 112 $( '#show_post_format_ui').on('change', function() {113 $( '.wp-post-format-ui').toggleClass('no-ui', ! this.checked );154 $( '#show_post_format_ui' ).on( 'change', function () { 155 $( '.wp-post-format-ui' ).toggleClass( 'no-ui', ! this.checked ); 114 156 $.post( ajaxurl, { 115 157 action: 'show-post-format-ui', 116 post_type: $( '#post_type').val(),158 post_type: $( '#post_type' ).val(), 117 159 show: this.checked ? 1 : 0, 118 nonce: $('#show_post_format_ui_nonce').val() 119 }); 120 }); 121 122 $('.post-format-change a').click(function() { 123 $('.post-formats-fields, .post-format-change').slideUp(); 124 $('.post-format-options').slideDown(); 125 return false; 126 }); 160 nonce: $( '#show_post_format_ui_nonce' ).val() 161 } ); 162 } ); 127 163 128 164 // Post formats selection 129 $( '.post-format-options').on( 'click', 'a', function (e) {165 $( '.post-format-options' ).on( 'click', 'a', function (e) { 130 166 e.preventDefault(); 131 switchFormat( $(this));132 } );167 switchFormat( $( e.currentTarget ) ); 168 } ); 133 169 134 170 // Media selection 135 $('.wp-format-media-select').click(function(event) { 136 event.preventDefault(); 137 var $el = $(this), mime = 'image', 138 $holder = $el.closest('.wp-format-media-holder'), 139 $field = $( '#wp_format_' + $holder.data('format') ); 140 141 mime = $holder.data('format'); 171 $( '.wp-format-media-select' ).click( function (e) { 172 e.preventDefault(); 173 174 var $el = $(e.currentTarget), mediaPreview, mime = 'image', $holder, $field; 175 176 $holder = $el.closest( '.wp-format-media-holder' ); 177 $field = $( '#wp_format_' + $holder.data( 'format' ) ); 178 mime = $holder.data( 'format' ); 142 179 143 180 // If the media frame already exists, reopen it. … … 151 188 mediaFrame = wp.media.frames.formatMedia = wp.media( { 152 189 button: { 153 text: $el.data( 'update')190 text: $el.data( 'update' ) 154 191 }, 155 192 states: [ 156 193 new wp.media.controller.Library({ 157 194 library: wp.media.query( { type: mime } ), 158 title: $el.data( 'choose'),195 title: $el.data( 'choose' ), 159 196 displaySettings: 'image' === mime 160 197 }) … … 162 199 } ); 163 200 164 mediaPreview = function (attachment) {201 mediaPreview = function (attachment) { 165 202 var w, h, dimensions = '', url = attachment.url, mime = attachment.mime, format = attachment.type; 166 203 … … 168 205 if ( attachment.width ) { 169 206 w = attachment.width; 170 if ( w > 600 ) 207 if ( w > 600 ) { 171 208 w = 600; 209 } 172 210 dimensions += ' width="' + w + '"'; 173 211 } … … 175 213 if ( attachment.height ) { 176 214 h = attachment.height; 177 if ( attachment.width && w < attachment.width ) 215 if ( attachment.width && w < attachment.width ) { 178 216 h = Math.round( ( h * w ) / attachment.width ); 217 } 179 218 dimensions += ' height="' + h + '"'; 180 219 } 181 220 } 182 221 183 $( '#' + format + '-preview').remove();222 $( '#' + format + '-preview' ).remove(); 184 223 $holder.parent().prepend( '<div id="' + format + '-preview" class="wp-format-media-preview">' + 185 224 '<' + format + dimensions + ' class="wp-' + format + '-shortcode" controls="controls" preload="none">' + 186 225 '<source type="' + mime + '" src="' + url + '" />' + 187 226 '</' + format + '></div>' ); 188 $( '.wp-' + format + '-shortcode').mediaelementplayer();227 $( '.wp-' + format + '-shortcode' ).mediaelementplayer(); 189 228 }; 190 229 191 230 // When an image is selected, run a callback. 192 mediaFrame.on( 'select', function () {231 mediaFrame.on( 'select', function () { 193 232 // Grab the selected attachment. 194 var w = 0, h = 0, html, attachment = mediaFrame.state().get( 'selection').first().toJSON();195 196 if ( 0 === attachment.mime.indexOf( 'audio') ) {197 $field.val( attachment.url);233 var w = 0, h = 0, html, attachment = mediaFrame.state().get( 'selection' ).first().toJSON(); 234 235 if ( 0 === attachment.mime.indexOf( 'audio' ) ) { 236 $field.val( attachment.url ); 198 237 // show one preview at a time 199 mediaPreview( attachment);200 } else if ( 0 === attachment.mime.indexOf( 'video') ) {238 mediaPreview( attachment ); 239 } else if ( 0 === attachment.mime.indexOf( 'video' ) ) { 201 240 attachment.src = attachment.url; 202 $field.val( wp.shortcode.string({241 $field.val( wp.shortcode.string( { 203 242 tag: 'video', 204 243 attrs: _.pick( attachment, 'src', 'width', 'height' ) 205 } ));244 } ) ); 206 245 // show one preview at a time 207 mediaPreview( attachment);246 mediaPreview( attachment ); 208 247 } else { 209 248 html = wp.media.string.image({ 210 align : getUserSetting( 'align'),211 size : getUserSetting( 'imgsize'),212 link : getUserSetting( 'urlbutton')249 align : getUserSetting( 'align' ), 250 size : getUserSetting( 'imgsize' ), 251 link : getUserSetting( 'urlbutton' ) 213 252 }, attachment); 253 214 254 // set the hidden input's value 215 $field.val(html); 216 $('#image-preview').remove(); 217 if ( attachment.width ) 255 $field.val( html ); 256 257 $( '#image-preview' ).remove(); 258 259 if ( attachment.width ) { 218 260 w = attachment.width > 600 ? 600 : attachment.width; 219 if ( attachment.height ) 261 } 262 263 if ( attachment.height ) { 220 264 h = attachment.height; 221 if ( w < attachment.width ) 265 } 266 267 if ( w < attachment.width ) { 222 268 h = Math.round( ( h * w ) / attachment.width ); 269 } 270 223 271 $holder.parent().prepend( ['<div id="image-preview" class="wp-format-media-preview">', 224 272 '<img src="', attachment.url, '"', … … 226 274 h ? ' height="' + h + '"' : '', 227 275 ' />', 228 '</div>'].join( '') );276 '</div>'].join( '' ) ); 229 277 } 230 278 }); … … 233 281 }); 234 282 }); 235 } )(jQuery);283 }( jQuery ) );
Note: See TracChangeset
for help on using the changeset viewer.