| 1 |
(function( $ ) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
var tables = $( '#wp-tables' ); |
| 5 |
|
| 6 |
tables.bsmSelect({ |
| 7 |
animate: true, |
| 8 |
title: dbReset.selectTable, |
| 9 |
plugins: [$.bsmSelect.plugins.compatibility()] |
| 10 |
}); |
| 11 |
|
| 12 |
$( '#select-all' ).on('click', function(e) { |
| 13 |
e.preventDefault(); |
| 14 |
|
| 15 |
tables.children() |
| 16 |
.attr( 'selected', 'selected' ) |
| 17 |
.end() |
| 18 |
.change(); |
| 19 |
}); |
| 20 |
|
| 21 |
tables.on( 'change', function() { |
| 22 |
$( '#reactivate' ).showIfSelected( 'options' ); |
| 23 |
$( '#disclaimer' ).showIfSelected( 'users' ); |
| 24 |
}); |
| 25 |
|
| 26 |
$( '#db-reset-code-confirm' ).on( 'change keyup paste', function() { |
| 27 |
$( '#db-reset-submit' ).prop( 'disabled', $( this ).val() !== $( "#security-code" ).text() ); |
| 28 |
}); |
| 29 |
|
| 30 |
$( '#db-reset-submit' ).on( 'click', function(e) { |
| 31 |
e.preventDefault(); |
| 32 |
|
| 33 |
if ( !$( '#wp-tables' ).val() ) { |
| 34 |
alert( dbReset.selectOneTable ); |
| 35 |
return false; |
| 36 |
} |
| 37 |
|
| 38 |
if ( confirm( dbReset.confirmAlert ) ) { |
| 39 |
$( '#db-reset-form' ).submit(); |
| 40 |
$( '#loader' ).show(); |
| 41 |
$( '#db-reset-form' ).css( 'pointer-events', 'none' ); |
| 42 |
} |
| 43 |
}); |
| 44 |
|
| 45 |
if ( !localStorage.getItem( 'rate-plugin-notice-dismiss' ) ) { |
| 46 |
$( '#rate-plugin-notice' ).show(); |
| 47 |
} |
| 48 |
|
| 49 |
$( '.tools_page_database-reset' ).on( 'click', '#rate-plugin-notice .notice-dismiss', function( e ) { |
| 50 |
localStorage.setItem( 'rate-plugin-notice-dismiss', true ); |
| 51 |
|
| 52 |
return false; |
| 53 |
}); |
| 54 |
|
| 55 |
|
| 56 |
$( '.tools_page_database-reset' ).on( 'click', '.open-wpr-upsell', function( e ) { |
| 57 |
e.preventDefault(); |
| 58 |
$( this ).blur(); |
| 59 |
|
| 60 |
$( '#wpr-upsell-dialog' ).dialog( 'open' ); |
| 61 |
|
| 62 |
return false; |
| 63 |
}); |
| 64 |
|
| 65 |
|
| 66 |
// upsell dialog init |
| 67 |
$( '#wpr-upsell-dialog' ).dialog( { 'dialogClass': 'wp-dialog wpr-upsell-dialog', |
| 68 |
'modal': 1, |
| 69 |
'resizable': false, |
| 70 |
'title': 'Develop & Debug in WordPress Faster', |
| 71 |
'zIndex': 9999, |
| 72 |
'width': 550, |
| 73 |
'height': 'auto', |
| 74 |
'show': 'fade', |
| 75 |
'hide': 'fade', |
| 76 |
'open': function( event, ui ) { |
| 77 |
wpr_fix_dialog_close( event, ui ); |
| 78 |
$( this ).siblings().find( 'span.ui-dialog-title' ).html( dbReset.wprDialogTitle ); |
| 79 |
}, |
| 80 |
'close': function( event, ui ) { }, |
| 81 |
'autoOpen': false, |
| 82 |
'closeOnEscape': true |
| 83 |
}); |
| 84 |
|
| 85 |
|
| 86 |
$( window ).resize( function(e) { |
| 87 |
$( '#wpr-upsell-dialog' ).dialog( 'option', 'position', { my: 'center', at: 'center', of: window } ); |
| 88 |
}); |
| 89 |
|
| 90 |
|
| 91 |
$( '.install-wpr' ).on( 'click', function(e) { |
| 92 |
$( '#wpr-upsell-dialog' ).dialog( 'close' ); |
| 93 |
$( 'body' ).append( '<div style="width:550px;height:450px; position:fixed;top:10%;left:50%;margin-left:-275px; color:#444; background-color: #fbfbfb;border:1px solid #DDD; border-radius:4px;box-shadow: 0px 0px 0px 4000px rgba(0, 0, 0, 0.85);z-index: 9999999;"><iframe src="' + dbReset.wprInstallUrl + '" style="width:100%;height:100%;border:none;" /></div>' ); |
| 94 |
$( '#wpwrap' ).css( 'pointer-events', 'none' ); |
| 95 |
|
| 96 |
e.preventDefault(); |
| 97 |
return false; |
| 98 |
}); |
| 99 |
|
| 100 |
|
| 101 |
$.fn.showIfSelected = function( selectValue ) { |
| 102 |
$( this ).toggle( $( "option[value='" + selectValue + "']:selected", tables ).length > 0 ); |
| 103 |
} |
| 104 |
|
| 105 |
})( jQuery ); |
| 106 |
|
| 107 |
function wpr_fix_dialog_close(event, ui) { |
| 108 |
jQuery( '.ui-widget-overlay' ).bind( 'click', function() { |
| 109 |
jQuery( '#' + event.target.id ).dialog( 'close' ); |
| 110 |
}); |
| 111 |
} // wpr_fix_dialog_close |
| 112 |
|