| Conditions | 1 |
| Paths | 2 |
| Total Lines | 35 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | /** global: GLSR, jQuery */ |
||
| 2 | ;(function( x ) { |
||
| 3 | |||
| 4 | 'use strict'; |
||
| 5 | |||
| 6 | var Status = function( selector ) { |
||
| 7 | var elements = document.querySelectorAll( selector ); |
||
| 8 | if( !elements.length )return; |
||
| 9 | elements.forEach( function( el ) { |
||
| 10 | el.addEventListener( 'click', this.onClick_ ); |
||
| 11 | }.bind( this )); |
||
| 12 | }; |
||
| 13 | |||
| 14 | Status.prototype = { |
||
| 15 | /** @return void */ |
||
| 16 | onClick_: function( ev ) { // MouseEvent |
||
| 17 | var post_id = ev.target.href.match( /post=([0-9]+)/ ); |
||
| 18 | var status = ev.target.href.match( /action=([a-z]+)/ ); |
||
| 19 | if( post_id === null || status === null )return; |
||
| 20 | var request = { |
||
| 21 | action: 'change-review-status', |
||
| 22 | nonce: GLSR.status_nonce, |
||
| 23 | post_id: post_id[1], |
||
| 24 | status: status[1], |
||
| 25 | }; |
||
| 26 | GLSR.Ajax( ev, request, function( response ) { |
||
| 27 | if( !response.class )return; |
||
| 28 | var el = x( ev.target ); |
||
| 29 | el.closest( 'tr' ).removeClass( 'status-pending status-publish' ).addClass( response.class ); |
||
| 30 | el.closest( 'td.column-title' ).find( 'strong' ).html( response.link ); |
||
| 31 | }); |
||
| 32 | }, |
||
| 33 | }; |
||
| 34 | |||
| 35 | GLSR.Status = Status; |
||
| 36 | })( jQuery ); |
||
| 37 |