-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the Javascript a common file, rather than lightbox specific
- Loading branch information
1 parent
622d7ba
commit c8bb2e5
Showing
3 changed files
with
104 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
function a8c_developer_lightbox() { | ||
(function($){ | ||
function make_colorbox( href, transition ) { | ||
$.colorbox({ | ||
inline: true, | ||
href: href, | ||
title: a8c_developer_i18n.lightbox_title, | ||
innerWidth: 500, | ||
maxHeight: '100%', | ||
transition: transition | ||
}); | ||
} | ||
|
||
make_colorbox( '#a8c-developer-setup-dialog-step-1', 'none' ); | ||
|
||
$('#a8c-developer-setup-dialog-step-1-form').submit( function(e) { | ||
var form = this; | ||
|
||
$('#a8c-developer-setup-dialog-step-1-submit').val( a8c_developer_i18n.saving ); | ||
|
||
if ( 'yes' != a8c_developer_i18n.go_to_step_2 ) | ||
return; | ||
|
||
e.preventDefault(); | ||
|
||
$.post( ajaxurl, $(form).serialize() ) | ||
.success( function( result ) { | ||
// If there was an error with the AJAX save, then do a normal POST | ||
if ( '-1' == result ) { | ||
location.href = 'options-general.php?page=' + a8c_developer_i18n.settings_slug + '&a8cdev_errorsaving=1'; | ||
return; | ||
} | ||
|
||
// AJAX says no step 2 needed, so head to the settings page | ||
if ( 'redirect' == result ) { | ||
location.href = 'options-general.php?page=' + a8c_developer_i18n.settings_slug + '&updated=1'; | ||
return; | ||
} | ||
|
||
// Display the AJAX reponse | ||
$('#a8c-developer-setup-dialog-step-2').html( result ); | ||
make_colorbox( '#a8c-developer-setup-dialog-step-2' ); | ||
}) | ||
; | ||
}); | ||
})(jQuery); | ||
} | ||
|
||
function a8c_developer_bind_events() { | ||
(function($){ | ||
$('.a8c_developer_button_install').click( function() { | ||
var button = this; | ||
|
||
$(button).html( a8c_developer_i18n.installing ); | ||
|
||
$.post( ajaxurl, { | ||
'action': 'a8c_developer_install_plugin', | ||
'_ajax_nonce': $(button).attr('data-nonce'), | ||
'plugin_slug': $(button).attr('data-pluginslug') | ||
} ) | ||
.success( function( result ) { | ||
if ( '1' == result ) { | ||
$(button).html( a8c_developer_i18n.installed ); | ||
$(button).unbind('click').prop('disabled', true); | ||
} else { | ||
$(button).html( a8c_developer_i18n.error ); | ||
} | ||
}) | ||
.error( function() { | ||
$(button).html( a8c_developer_i18n.error ); | ||
}) | ||
; | ||
}); | ||
|
||
$('.a8c_developer_button_activate').click( function() { | ||
var button = this; | ||
|
||
$(button).html( a8c_developer_i18n.activating ); | ||
|
||
$.post( ajaxurl, { | ||
'action': 'a8c_developer_activate_plugin', | ||
'_ajax_nonce': $(button).attr('data-nonce'), | ||
'path': $(button).attr('data-path') | ||
} ) | ||
.success( function( result ) { | ||
if ( '1' == result ) { | ||
$(button).html( a8c_developer_i18n.activated ); | ||
$(button).unbind('click').prop('disabled', true); | ||
} else { | ||
$(button).html( a8c_developer_i18n.error ); | ||
} | ||
}) | ||
.error( function() { | ||
$(button).html( a8c_developer_i18n.error ); | ||
}) | ||
; | ||
}); | ||
})(jQuery); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.