Changeset 8766
- Timestamp:
- 05/09/2019 09:59:52 PM (4 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/helper-functions.php
r8758 r8766 289 289 return $count; 290 290 } 291 292 /** 293 * Lists file references for a translation. 294 * 295 * @param \GP_Project $project Current project. 296 * @param object $entry Current translation entry. 297 */ 298 function wporg_references( $project, $entry ) { 299 ?> 300 <ul> 301 <?php 302 foreach ( $entry->references as $reference ) : 303 list( $file, $line ) = array_pad( explode( ':', $reference ), 2, 0 ); 304 if ( $source_url = $project->source_url( $file, $line ) ) : 305 ?> 306 <li><a target="_blank" href="<?php echo $source_url; ?>"><?php echo $file.':'.$line ?></a></li> 307 <?php 308 else : 309 echo "<li>$file:$line</li>"; 310 endif; 311 endforeach; 312 ?> 313 </ul> 314 <?php 315 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/js/editor.js
r8751 r8766 2 2 var $html = $( 'html' ); 3 3 var $document = $( document ); 4 5 function checkStorage() { 6 var test = 'test', 7 result = false; 8 9 try { 10 window.localStorage.setItem( 'test', test ); 11 result = window.localStorage.getItem( 'test' ) === test; 12 window.localStorage.removeItem( 'test' ); 13 } catch(e) {} 14 15 hasStorage = result; 16 return result; 17 } 18 19 var hasStorage = checkStorage(); 4 20 5 21 // Handle tab view for plural forms. … … 124 140 } ); 125 141 } 142 143 $gp.editor.keydown = ( function( original ) { 144 return function( event ) { 145 // Shift-Enter = Save. 146 if ( 13 === event.keyCode && event.shiftKey ) { 147 var $textarea = $( event.target ); 148 149 if ( ! $textarea.val().trim() ) { 150 $gp.notices.error( 'Translation is empty.' ); 151 return false; 152 } 153 154 // Check plural forms. 155 var $textareas = $gp.editor.current.find( '.textareas:not(.active) textarea' ); 156 var isValid = true; 157 $textareas.each( function() { 158 if ( ! this.value.trim() ) { 159 isValid = false; 160 } 161 } ); 162 163 if ( ! isValid ) { 164 $gp.notices.error( 'Translation is empty.' ); 165 return false; 166 } 167 168 $gp.editor.save( $gp.editor.current.find( 'button.translation-actions__save' ) ); 169 170 // Ctrl-Enter or Ctrl-Shift-B = Copy original. 171 } else if ( 172 ( 13 === event.keyCode && event.ctrlKey ) || 173 ( 66 === event.keyCode && event.shiftKey && event.ctrlKey ) ) 174 { 175 var $button = $gp.editor.current.find( 'button.translation-actions__copy' ); 176 177 $button.trigger( 'click' ); 178 } else { 179 return original.apply( $gp.editor, arguments ); 180 } 181 182 return false; 183 } 184 })( $gp.editor.keydown ); 185 186 // Store the open/close state of <details> element in locale storage and apply state when editor is shown. 187 var DETAILS_STORE_KEY = 'translate-details-state'; 188 function updateDetailsState( type, state ) { 189 if ( ! hasStorage ) { 190 return; 191 } 192 193 var store = window.localStorage.getItem( DETAILS_STORE_KEY ); 194 var states = store ? JSON.parse( store ) : {}; 195 196 states[ type ] = state; 197 198 window.localStorage.setItem( DETAILS_STORE_KEY, JSON.stringify( states ) ); 199 } 200 201 function toggleDetails( event ) { 202 var $el = $( event.target ).closest( 'details' ); 203 var isClosed = $el.attr( 'open' ) === 'open'; // Gets closed when open attribute was previously set. 204 var className = $el.attr( 'class' ).replace( /^(\S*).*/, '$1' ); 205 206 updateDetailsState( className, isClosed ? 'close' : 'open' ); 207 } 208 209 function applyDetailsState() { 210 if ( ! hasStorage || ! $gp.editor.current.length ) { 211 return; 212 } 213 214 var store = window.localStorage.getItem( DETAILS_STORE_KEY ); 215 var states = store ? JSON.parse( store ) : {}; 216 217 for ( var type in states ) { 218 var state = states[ type ]; 219 220 if ( 'open' === state ) { 221 $gp.editor.current.find( '.' + type ).attr( 'open', 'open' ); 222 } else { 223 $gp.editor.current.find( '.' + type ).removeAttr( 'open' ); 224 } 225 } 226 } 227 228 $gp.editor.show = ( function( original ) { 229 return function() { 230 original.apply( $gp.editor, arguments ); 231 232 applyDetailsState(); 233 } 234 })( $gp.editor.show ); 126 235 127 236 $gp.editor.install_hooks = ( function( original ) { … … 140 249 .on( 'click', 'button.translation-actions__rtl', switchTextDirection ) 141 250 .on( 'focus', 'textarea', textareaAutosize ) 251 .on( 'click', 'summary', toggleDetails ) 142 252 .on( 'click', 'button.button-menu__toggle', toggleLinkMenu ); 143 253 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/style.css
r8751 r8766 1 1 body, html { 2 2 height: 100%; 3 } 4 5 body, 6 html, 7 .gp-content, 8 .gp-content textarea, 9 .gp-content input { 10 color: #191e23; 3 11 } 4 12 … … 313 321 314 322 table.translations td.translation li { 315 border-bottom: 1px dotted #e ee;323 border-bottom: 1px dotted #e2e4e7; 316 324 } 317 325 … … 346 354 table.locale-sub-projects td { 347 355 border: 0; 348 border-bottom: 1px solid #e ee;349 border-right: 1px solid #e ee;356 border-bottom: 1px solid #e2e4e7; 357 border-right: 1px solid #e2e4e7; 350 358 } 351 359 … … 360 368 table.locale-sub-projects th:first-child, 361 369 table.locale-sub-projects td:first-child { 362 border-left: 1px solid #e ee;370 border-left: 1px solid #e2e4e7; 363 371 } 364 372 … … 447 455 .editor .meta { 448 456 background: #fff; 449 border: 1px solid #e ee;457 border: 1px solid #e2e4e7; 450 458 font-size: 13px; 451 459 margin: 0; … … 458 466 .editor .meta h3 { 459 467 text-align: center; 460 border-bottom: 1px solid #e ee;468 border-bottom: 1px solid #e2e4e7; 461 469 margin-bottom: 15px; 462 470 } … … 859 867 padding: 10px 20px; 860 868 color: #006799; 861 border-left: 1px solid #e ee;869 border-left: 1px solid #e2e4e7; 862 870 text-align: center; 863 871 } … … 1028 1036 1029 1037 .projects .project-status > div:not(:first-child) { 1030 border-left: 1px solid #e ee;1038 border-left: 1px solid #e2e4e7; 1031 1039 } 1032 1040 … … 1161 1169 color: #509040; 1162 1170 padding: 10px 0 10px 15px; 1163 border-left: 1px solid #e ee;1171 border-left: 1px solid #e2e4e7; 1164 1172 } 1165 1173 … … 1232 1240 height: 20px; 1233 1241 font: 20px/1 "dashicons"; 1234 border-left: 1px solid #e ee;1242 border-left: 1px solid #e2e4e7; 1235 1243 padding: 5px 0 5px 12px; 1236 1244 box-shadow: inset 1px 0 0 #fff; … … 1497 1505 float: right; 1498 1506 margin: -30px 0 5px 5px; 1499 background-color: #e ee;1507 background-color: #e2e4e7; 1500 1508 padding: 5px; 1501 1509 border: 1px solid #dfdfdf; … … 1806 1814 .locale-project-contributors-table th { 1807 1815 font-weight: bold; 1808 border-bottom: 1px solid #e ee;1816 border-bottom: 1px solid #e2e4e7; 1809 1817 } 1810 1818 … … 1859 1867 .locale-project-contributors-table tbody td { 1860 1868 padding: 10px 0; 1861 border-bottom: 1px solid #e ee;1869 border-bottom: 1px solid #e2e4e7; 1862 1870 } 1863 1871 … … 2002 2010 2003 2011 .consistency-table tr { 2004 border-bottom: 1px solid #e ee;2012 border-bottom: 1px solid #e2e4e7; 2005 2013 } 2006 2014 … … 2153 2161 border: 0; 2154 2162 background: #fff; 2155 color: # 333;2163 color: #191e23; 2156 2164 outline: none; 2157 2165 padding: 15px 0; … … 2199 2207 .editor-panel__left { 2200 2208 flex: 1; 2201 border-bottom: 3px solid #e ee;2209 border-bottom: 3px solid #e2e4e7; 2202 2210 min-width: 1%; 2203 2211 } … … 2206 2214 .editor-panel__left { 2207 2215 border-bottom: 0; 2208 border-right: 3px solid #e ee;2216 border-right: 3px solid #e2e4e7; 2209 2217 } 2210 2218 } … … 2219 2227 align-items: center; 2220 2228 justify-content: flex-end; 2221 border-bottom: 1px solid #e ee;2222 background-color: #f bfbfb;2229 border-bottom: 1px solid #e2e4e7; 2230 background-color: #f3f4f5; 2223 2231 height: 40px; 2224 2232 } … … 2255 2263 letter-spacing: 1px; 2256 2264 text-transform: uppercase; 2257 color: # 666;2265 color: #191e23; 2258 2266 } 2259 2267 … … 2304 2312 2305 2313 .panel-header-actions button:hover { 2306 background: #e ee;2314 background: #e2e4e7; 2307 2315 } 2308 2316 … … 2347 2355 2348 2356 .panel-content summary:focus { 2349 color: # 0073aa;2357 color: #191e23; 2350 2358 } 2351 2359 … … 2371 2379 .source-details { 2372 2380 padding: 0 10px; 2381 font-size: 13px; 2382 } 2383 2384 .source-details summary { 2373 2385 color: #666; 2374 2386 } 2375 2387 2376 .source-details dl + dl { 2377 margin-top: 10px; 2378 } 2379 2380 .source-details dt { 2381 font-size: 12px; 2382 } 2383 2384 .source-details dd { 2385 color: #333; 2388 .source-details details[open] summary { 2389 margin: 0; 2390 } 2391 2392 .source-details details + details{ 2393 margin-top: 5px; 2386 2394 } 2387 2395 … … 2391 2399 border-top: 1px solid; 2392 2400 border-bottom: 1px solid; 2393 border-color: #e ee;2401 border-color: #e2e4e7; 2394 2402 background: #fff; 2395 2403 } … … 2412 2420 2413 2421 .translation-form-wrapper { 2414 border-bottom: 1px solid #e ee;2422 border-bottom: 1px solid #e2e4e7; 2415 2423 margin-left: -10px; 2416 2424 margin-right: -10px; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/templates/translation-row-editor.php
r8751 r8766 111 111 </div> 112 112 113 <details class="source-details"> 114 <summary>Context</summary> 115 113 <div class="source-details"> 116 114 <?php if ( $t->context ): ?> 117 <d lclass="source-details__context">118 < dt><?php _e( 'Context:', 'glotpress' ); ?></dt>119 < dd><span class="context bubble"><?php echo esc_translation( $t->context ); ?></span></dd>120 </d l>115 <details open class="source-details__context"> 116 <summary>Context</summary> 117 <span class="context bubble"><?php echo esc_translation( $t->context ); ?></span> 118 </details> 121 119 <?php endif; ?> 122 120 <?php if ( $t->extracted_comments ) : 123 121 $comments = trim( preg_replace( '/^translators:/ ', '', $t->extracted_comments ) ); 124 122 ?> 125 <dl class="source-details__comments"> 126 <dt><?php _e( 'Comment:', 'glotpress' ); ?></dt> 127 <dd><?php echo make_clickable( esc_translation( $comments ) ); ?></dd> 128 </dl> 129 <?php endif; ?> 130 <?php references( $project, $t ); ?> 131 </details> 123 <details open class="source-details__comment"> 124 <summary><?php _e( 'Comment', 'glotpress' ); ?></summary> 125 <p><?php echo make_clickable( esc_translation( $comments ) ); ?></p> 126 </details> 127 <?php endif; ?> 128 <?php if ( $t->references ) : ?> 129 <details class="source-details__references"> 130 <summary>References</summary> 131 <?php wporg_references( $project, $t ); ?> 132 </details> 133 <?php endif; ?> 134 </div> 132 135 133 136 <div class="translation-wrapper"> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-suggestions/js/translation-suggestions.js
r8732 r8766 1 1 ( function( $ ){ 2 function fetch TranslationMemorySuggestions( $container, originalId, nonce ) {2 function fetchSuggestions( $container, apiUrl, originalId, nonce ) { 3 3 var xhr = $.ajax( { 4 url: window.WPORG_TRANSLATION_MEMORY_API_URL,4 url: apiUrl, 5 5 data: { 6 6 'original': originalId, … … 33 33 function maybeFetchTranslationMemorySuggestions() { 34 34 var $container = $gp.editor.current.find( '.suggestions__translation-memory' ); 35 if ( ! 35 if ( !$container.length ) { 36 36 return; 37 37 } … … 46 46 var nonce = $container.data( 'nonce' ); 47 47 48 fetchTranslationMemorySuggestions( $container, originalId , nonce ); 49 } 50 51 function fetchOtherLanguageSuggestions( $container, originalId, nonce ) { 52 var xhr = $.ajax( { 53 url: window.WPORG_OTHER_LANGUAGES_API_URL, 54 data: { 55 'original': originalId, 56 'nonce': nonce 57 }, 58 dataType: 'json' 59 } ); 60 61 xhr.done( function( response ) { 62 $container.find( '.suggestions__loading-indicator' ).remove(); 63 if ( response.success ) { 64 $container.append( response.data ); 65 } else { 66 $container.append( $( '<span/>', { 'text': 'Error while loading suggestions.' } ) ); 67 } 68 $container.addClass( 'initialized' ); 69 } ); 70 71 xhr.fail( function() { 72 $container.find( '.suggestions__loading-indicator' ).remove(); 73 $container.append( $( '<span/>', { 'text': 'Error while loading suggestions.' } ) ); 74 $container.addClass( 'initialized' ); 75 } ); 76 77 xhr.always( function() { 78 $container.removeClass( 'fetching' ); 79 } ); 48 fetchSuggestions( $container, window.WPORG_TRANSLATION_MEMORY_API_URL, originalId, nonce ); 80 49 } 81 50 … … 95 64 var nonce = $container.data( 'nonce' ); 96 65 97 fetch OtherLanguageSuggestions( $container, originalId , nonce );66 fetchSuggestions( $container, window.WPORG_OTHER_LANGUAGES_API_URL, originalId , nonce ); 98 67 } 99 68 … … 126 95 127 96 maybeFetchTranslationMemorySuggestions(); 97 maybeFetchOtherLanguageSuggestions(); 128 98 } 129 99 })( $gp.editor.show ); … … 134 104 135 105 $( $gp.editor.table ) 136 .on( 'click', '.translation-suggestion', copySuggestion ) 137 .on( 'click', '.suggestions__other-languages summary', maybeFetchOtherLanguageSuggestions ); 106 .on( 'click', '.translation-suggestion', copySuggestion ); 138 107 } 139 108 })( $gp.editor.install_hooks );
Note: See TracChangeset
for help on using the changeset viewer.