Files
roi-theme/wp-content/plugins/thrive-ab-page-testing/assets/js/controls/edit_title.js
root a22573bf0b Commit inicial - WordPress Análisis de Precios Unitarios
- WordPress core y plugins
- Tema Twenty Twenty-Four configurado
- Plugin allow-unfiltered-html.php simplificado
- .gitignore configurado para excluir wp-config.php y uploads

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-03 21:04:30 -06:00

60 lines
1.2 KiB
JavaScript
Executable File

var base_view = require( './../views/base' );
module.exports = base_view.extend( {
className: 'tvd-input-field',
template: TVE_Dash.tpl( 'util/edit-title' ),
events: {
'keyup input': 'keyup',
'change input': function () {
var trim_value = this.input.val().trim();
if ( ! trim_value ) {
this.input.addClass( 'tvd-invalid' );
return false;
}
this.model.set( 'post_title', trim_value );
return false;
},
'blur input': function () {
this.model.trigger( 'thrive-ab-title-no-change' );
}
},
initialize: function ( args ) {
var is_valid_args = true;
if ( ! args ) {
is_valid_args = false;
}
if ( typeof args !== 'object' ) {
is_valid_args = false;
}
if ( typeof args === 'object' && typeof args.el === 'undefined' ) {
is_valid_args = false;
}
if ( ! is_valid_args ) {
console.log( 'Error: invalid arguments for edit title control' );
return;
}
this.render();
},
keyup: function ( event ) {
if ( event.which === 27 ) {
this.model.trigger( 'thrive-ab-title-no-change' );
}
},
render: function () {
this.$el.html( this.template( {item: this.model} ) );
this.input = this.$( 'input' );
return this;
},
focus: function () {
this.input.focus().select();
}
} );