Ticket #188: 188.diff

File 188.diff, 10.9 KB (added by nacin, 14 months ago)
  • css/style.css

     
    5252        padding: 0.25em 0.5em; 
    5353        color: #444; 
    5454} 
     55select { 
     56        font-size: 12px; 
     57        line-height: 14px; 
     58        -webkit-border-radius: 3px; 
     59        border-radius: 3px; 
     60        border: 1px solid #dfdfdf; 
     61        background-color: #fff; 
     62        padding: 2px; 
     63        height: 2em; 
     64} 
     65input.button { 
     66        text-decoration: none; 
     67        font-size: 12px; 
     68        line-height: 14px; 
     69        padding: 3px 8px; 
     70        cursor: pointer; 
     71        border: 1px solid #bbb; 
     72        color: #464646; 
     73        -webkit-border-radius: 3px; 
     74        border-radius: 3px; 
     75        -moz-box-sizing: content-box; 
     76        -webkit-box-sizing: content-box; 
     77        box-sizing: content-box; 
     78        background-color: #f2f2f2; /* Fallback */ 
     79        background-image: -ms-linear-gradient(bottom, #ededed, #fff); /* IE10 */ 
     80        background-image: -moz-linear-gradient(bottom, #ededed, #fff); /* Firefox */ 
     81        background-image: -o-linear-gradient(bottom, #ededed, #fff); /* Opera */ 
     82        background-image: -webkit-gradient(linear, left bottom, left top, from(#ededed), to(#fff)); /* old Webkit  */ 
     83        background-image: -webkit-linear-gradient(bottom, #ededed, #fff); /* new Webkit */ 
     84        background-image: linear-gradient(bottom, #ededed, #fff); /* proposed W3C Markup */ 
     85        text-shadow: #fff 0 1px 0; 
     86} 
    5587.breadcrumb a { 
    5688    color: #3A7399; 
    5789    text-decoration: none; 
     
    315347.paging .current { 
    316348    font-weight: bold; 
    317349} 
     350.paging .next { 
     351        margin-right: 1px; 
     352} 
    318353.paging .disabled { 
    319354    color: #999; 
    320355    border-color: #eee; 
    321356} 
    322 form.filters-toolbar { 
    323     float: left; 
     357.bulk-actions { 
     358        float: left; 
    324359} 
     360.bulk-actions input { 
     361        margin-right: 8px; 
     362} 
     363.bulk-actions select { 
     364        width: 130px; 
     365} 
     366form.filters-toolbar > div { 
     367        line-height: 2em; 
     368} 
    325369form.filters-toolbar ul { 
    326370    list-style-type: none;     
    327371} 
     
    342386    vertical-align: bottom; 
    343387} 
    344388dl.filters-expanded { 
     389        float: left; 
    345390    font-size: 80%;     
    346391    padding: 0.8em; 
    347392    margin: 0 0 0.5em 0.2em; 
  • gp-templates/translation-row.php

     
    1010); 
    1111?> 
    1212<tr class="preview <?php echo $parity().' '.$status_class.' '.$warning_class.' '.$priority_class ?>" id="preview-<?php echo $t->row_id ?>" row="<?php echo $t->row_id; ?>"> 
    13         <th scope="row" class="checkbox"><input type="checkbox" name="selected-row[]" /></th> 
     13        <?php if ( $can_approve ) : ?><th scope="row" class="checkbox"><input type="checkbox" name="selected-row[]" /></th><?php endif; ?> 
    1414        <?php /* 
    1515        <td class="priority" style="background-color: <?php echo $priority_char[$t->priority][1] ?>; color: <?php echo $priority_char[$t->priority][2] ?>; text-align: center; font-size: 1.2em;" title="<?php echo esc_attr('Priority: '.gp_array_get( GP::$original->get_static( 'priorities' ), $t->priority )); ?>"> 
    1616        */ ?> 
     
    5151        </td> 
    5252</tr> 
    5353<tr class="editor <?php echo $warning_class; ?>" id="editor-<?php echo $t->row_id; ?>" row="<?php echo $t->row_id; ?>"> 
    54         <td colspan="5"> 
     54        <td colspan="<?php echo $can_approve ? 5 : 4 ?>"> 
    5555                <div class="strings"> 
    5656                <?php if ( !$t->plural ): ?> 
    5757                <p class="original"><?php echo prepare_original( esc_translation($t->singular) ); ?></p> 
  • gp-templates/translations.php

     
    1010$editor_options = compact('can_approve', 'can_write', 'url', 'discard_warning_url', 'set_priority_url', 'set_status_url'); 
    1111$editor_options['google_translate_language'] = $locale->google_code; 
    1212wp_localize_script( 'editor', '$gp_editor_options', $editor_options ); 
    13 wp_localize_script( 'translations-page', '$gp_translations_options', array('action' => $bulk_action) ); 
    1413$parity = gp_parity_factory(); 
    1514add_action( 'gp_head', lambda( '', 'gp_preferred_sans_serif_style_tag($locale);', compact( 'locale' ) ) ); 
    1615 
     
    2120        Translation of <?php echo esc_html( $project->name ); ?>: <?php echo esc_html( $translation_set->name ); ?> 
    2221        <?php gp_link_set_edit( $translation_set, $project, '(edit)' ); ?> 
    2322</h2> 
    24 <!-- TODO: use another form for bulk actions --> 
     23<?php if ( $can_approve ): ?> 
     24<form id="bulk-actions-toolbar" class="filters-toolbar bulk-actions" action="<?php echo $bulk_action; ?>" method="post"> 
     25        <div> 
     26        <select name="bulk[action]"> 
     27                <option value="" selected="selected">Bulk Actions</option> 
     28                <option value="approve">Approve</option> 
     29                <option value="reject">Reject</option> 
     30                <option value="gtranslate">Translate via Google</option> 
     31        </select> 
     32        <input type="hidden" name="bulk[redirect_to]" value="<?php echo esc_attr(gp_url_current()); ?>" id="bulk[redirect_to]" /> 
     33        <input type="hidden" name="bulk[row-ids]" value="" id="bulk[row-ids]" /> 
     34        <input type="submit" class="button" value="<?php esc_attr_e( 'Apply' ); ?>" /> 
     35        </div> 
     36</form> 
     37<?php endif; ?> 
     38<?php echo gp_pagination( $page, $per_page, $total_translations_count ); ?> 
    2539<form id="upper-filters-toolbar" class="filters-toolbar" action="" method="get" accept-charset="utf-8"> 
    2640        <div> 
    27         <?php if ( $can_approve ): ?> 
    28         <a href="#" class="revealing bulk"><?php _e('Bulk &darr;'); ?></a> <strong class="separator">&bull;</strong> 
    29         <?php endif; ?> 
    3041        <a href="#" class="revealing filter"><?php _e('Filter &darr;'); ?></a> <span class="separator">&bull;</span> 
    3142        <a href="#" class="revealing sort"><?php _e('Sort &darr;'); ?></a> <strong class="separator">&bull;</strong> 
    3243        <?php 
     
    106117                </dd> 
    107118                <dd><input type="submit" value="<?php echo esc_attr(__('Sort')); ?>" name="sorts" /></dd> 
    108119        </dl> 
    109         <dl class="hidden bulk-actions filters-expanded clearfix"> 
    110                 <dd> 
    111                         <input type="hidden" name="bulk[redirect_to]" value="<?php echo esc_attr(gp_url_current()); ?>" id="bulk[redirect_to]" /> 
    112                         <input type="hidden" name="bulk[row-ids]" value="" id="bulk[row-ids]" /> 
    113                         <input type="submit" value="<?php echo esc_attr(__('Approve Selected')); ?>" name="approve" /><br /> 
    114                         <input type="submit" value="<?php echo esc_attr(__('Reject Selected')); ?>" name="reject" /> 
    115                 </dd> 
    116                 <dd class="separator"></dd> 
    117                 <dd> 
    118                         <input type="submit" value="<?php echo esc_attr(__('Translate via Google')); ?>" name="gtranslate" /> 
    119                 </dd> 
    120         </dl> 
    121120</form> 
    122  
    123 <?php echo gp_pagination( $page, $per_page, $total_translations_count ); ?> 
    124121<table id="translations" class="translations clear"> 
    125122        <thead> 
    126123        <tr> 
    127                 <th class="checkbox"><input type="checkbox" /></th> 
     124                <?php if ( $can_approve ) : ?><th class="checkbox"><input type="checkbox" /></th><?php endif; ?> 
    128125                <th><?php /* Translators: Priority */ _e('Prio'); ?></th> 
    129126                <th class="original"><?php _e('Original string'); ?></th> 
    130127                <th class="translation"><?php _e('Translation'); ?></th> 
     
    138135<?php 
    139136        if ( !$translations ): 
    140137?> 
    141         <tr><td colspan="4"><?php _e('No translations were found!'); ?></td></tr> 
     138        <tr><td colspan="<?php echo $can_approve ? 5 : 4; ?>"><?php _e('No translations were found!'); ?></td></tr> 
    142139<?php 
    143140        endif; 
    144141?> 
    145142</table> 
     143<?php echo gp_pagination( $page, $per_page, $total_translations_count ); ?> 
    146144<div id="legend" class="secondary clearfix"> 
    147145        <div><strong><?php _e('Legend:'); ?></strong></div> 
    148146<?php  
     
    156154        <div><?php _e('with warnings'); ?></div> 
    157155 
    158156</div> 
    159 <?php echo gp_pagination( $page, $per_page, $total_translations_count ); ?> 
    160157<p class="clear actionlist secondary"> 
    161158        <?php 
    162159                $footer_links = array(); 
  • gp-includes/routes/translation.php

     
    135135                $bulk = gp_post('bulk'); 
    136136                $bulk['row-ids'] = array_filter( explode( ',', $bulk['row-ids'] ) ); 
    137137                if ( !empty( $bulk['row-ids'] ) ) { 
    138                         if ( gp_post( 'approve' ) || gp_post( 'reject' ) ) { 
     138                        if ( 'approve' == $bulk['action'] || 'reject' == $bulk['action'] ) { 
    139139                                $this->_bulk_approve( $project, $locale, $translation_set, $bulk ); 
    140140                        } 
    141141 
    142                         if ( gp_post( 'gtranslate' ) ) { 
     142                        if ( 'gtranslate' == $bulk['action'] ) { 
    143143                                $this->_bulk_google_translate( $project, $locale, $translation_set, $bulk ); 
    144144                        } 
    145145                } else { 
     
    155155         
    156156        function _bulk_approve( $project, $locale, $translation_set, $bulk ) { 
    157157                 
    158                 $action = gp_post( 'approve' )? 'approve' : 'reject'; 
     158                $action = $bulk['action']; 
    159159                 
    160160                $ok = $error = 0; 
    161161                $new_status = 'approve' == $action? 'current' : 'rejected'; 
  • js/translations-page.js

     
    99                hide_text: 'Filter &uarr;', 
    1010                focus: '#filters\\[term\\]' 
    1111        }); 
    12         $gp.showhide('#upper-filters-toolbar a.bulk', '#upper-filters-toolbar dl.bulk-actions', { 
    13                 show_text: 'Bulk &darr;', 
    14                 hide_text: 'Bulk &uarr;', 
    15                 focus: '#filters\\[term\\]' 
    16         }); 
    17  
    18         var bulk_dl = $('.filters-toolbar dl.bulk-actions'); 
    19         var submits = $('input[type=submit]', bulk_dl); 
    2012         
    2113        var rows_checked = 0; 
    2214 
    23         $('#upper-filters-toolbar a.bulk').click(function() { 
    24                 rows_checked = $('input:checked', $('table#translations th.checkbox')).length; 
    25                 change_row_checked(0); 
     15        $('form.filters-toolbar.bulk-actions').submit(function(e) { 
     16                var     row_ids = $('input:checked', $('table#translations th.checkbox')).map(function() { 
     17                        return $(this).parents('tr.preview').attr('row'); 
     18                }).get().join(','); 
     19                $('input[name="bulk[row-ids]"]', $(this)).val(row_ids); 
    2620        }); 
    2721         
    28         var change_row_checked = function(num) { 
    29                 rows_checked += num; 
    30                 submits.prop('disabled', ! rows_checked); 
    31         } 
    32          
    33         $(':checkbox', $('table#translations th.checkbox')).each(function() { 
    34                 $(this).change(function() { 
    35                         this.checked? change_row_checked(+1) : change_row_checked(-1); 
    36                 }); 
    37         }); 
    38          
    39  
    40         var set_all = function (value) { 
    41                 $(':checkbox', $('table#translations th.checkbox')).each(function() { 
    42                         if ( !this.checked && value) change_row_checked(+1); 
    43                         if ( this.checked && !value) change_row_checked(-1); 
    44                         this.checked = value; 
    45                 }); 
    46         } 
    47          
    48         $('.filters-toolbar dl.bulk-actions a.all').click( function() { 
    49                 set_all(true); 
    50         }); 
    51         $('.filters-toolbar dl.bulk-actions a.none').click( function() { 
    52                 set_all(false); 
    53         }); 
    54          
    55         submits.prop('disabled', true); 
    56          
    57         $('form.filters-toolbar').submit(function(e) { 
    58                 if ($('input[name=approve]', bulk_dl).is(':visible')) { 
    59                         this.method = 'post'; 
    60                         this.action = $gp_translations_options.action; 
    61                         var     row_ids = $('input:checked', $('table#translations th.checkbox')).map(function() { 
    62                                 return $(this).parents('tr.preview').attr('row'); 
    63                         }).get().join(','); 
    64                         $('input[name="bulk[row-ids]"]', $(this)).val(row_ids); 
    65                 } else { 
    66                         // do not litter the GET form with the long redirect_to 
    67                         $('input[name^="bulk"]', $(this)).remove(); 
    68                 } 
    69                 return true; 
    70         }); 
    71          
    7222        $('a#export').click(function() { 
    7323                var format = $('#export-format').val(); 
    7424                var what_to_export = $('#what-to-export').val();