/* global window, document, jQuery, inlineEditL10n, ajaxurl */ var inlineEditKey; ( function( $ ) { inlineEditKey = { init: function() { var t = this, row = $( '#security-keys-section #inline-edit' ); t.what = '#key-'; $( '#security-keys-section #the-list' ).on( 'click', 'a.editinline', function() { inlineEditKey.edit( this ); return false; } ); // Prepare the edit row. row.keyup( function( event ) { if ( 27 === event.which ) { return inlineEditKey.revert(); } } ); $( 'a.cancel', row ).click( function() { return inlineEditKey.revert(); } ); $( 'a.save', row ).click( function() { return inlineEditKey.save( this ); } ); $( 'input, select', row ).keydown( function( event ) { if ( 13 === event.which ) { return inlineEditKey.save( this ); } } ); }, toggle: function( el ) { var t = this; if ( 'none' === $( t.what + t.getId( el ) ).css( 'display' ) ) { t.revert(); } else { t.edit( el ); } }, edit: function( id ) { var editRow, rowData, val, t = this; t.revert(); if ( 'object' === typeof id ) { id = t.getId( id ); } editRow = $( '#inline-edit' ).clone( true ); rowData = $( '#inline_' + id ); $( 'td', editRow ).attr( 'colspan', $( 'th:visible, td:visible', '#security-keys-section .widefat thead' ).length ); $( t.what + id ).hide().after( editRow ).after( '