| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/wp-content/plugins/ninja-forms/client/dashboard/models/ |
Upload File : |
define( [], function() {
var model = Backbone.Model.extend( {
defaults: {
objectType: 'service',
name: '',
slug: '',
installPath: '',
description: '',
enabled: null,
infoLink: null,
serviceLink: null,
is_installing: false,
classes: ''
},
url: function() {
return ajaxurl + "?action=nf_service_" + this.get( 'slug' );
},
/*
* - Check for "Success"/Setup modal.
* - (Maybe) Auto-redirect to the service.
*/
initialize: function() {
// Check for successful setup.
if( this.get( 'slug' ) == serviceSuccess && this.get( 'successMessage' ) ){
new jBox( 'Modal', {
width: 300,
addClass: 'dashboard-modal',
overlay: true,
closeOnClick: true,
content: this.get( 'successMessage' ),
title: this.get( 'successMessageTitle' ),
closeButton: 'box'
} ).open();
}
// Auto-redirect to the serviceLink on install.
var that = this;
nfRadio.channel( 'dashboard' ).reply( 'install:service:' + this.get( 'slug' ), function(){
// If no service link url, then no need to auto-redirect.
if( ! that.get( 'serviceLink' ) ) return;
if( ! that.get( 'serviceLink' ).href ) return;
var redirect = that.get( 'serviceLink' ).href;
// Display a redirect notice.
new jBox( 'Modal', {
width: 300,
addClass: 'dashboard-modal',
overlay: true,
closeOnClick: 'body',
content: nfi18n.serviceRedirect,
} ).open();
// Trigger a redirect, where depends on the connected status.
var oauth = nfRadio.channel( 'dashboard' ).request( 'get:oauth' );
if( ! oauth.get( 'connected' ) ){
if( that.get( 'connect_url' ) ){
return window.location = that.get( 'connect_url' ) + '&redirect=' + redirect;
}
window.location = oauth.get( 'connect_url' ) + '&redirect=' + redirect;
} else {
window.location = redirect;
}
} );
},
/*
* Sync the server with the model.
*/
save: function() {
var that = this;
jQuery.ajax({
type: "POST",
url: this.url(),
data: this.toJSON()
}).done( function( response ){
var data = JSON.parse( response );
if( 'undefined' !== typeof data.error ) {
alert( nfi18n.serviceUpdateError + ' ' + data.error );
that.set( 'enabled', ! that.get( 'enabled' ) );
}
nfRadio.channel( 'dashboard').trigger( 'save:service-' + that.get( 'slug' ) );
});
}
} );
return model;
} );