diff --git a/js/ajax.js b/js/ajax.js
index 52a5312224..a6aca577b2 100644
--- a/js/ajax.js
+++ b/js/ajax.js
@@ -160,13 +160,19 @@ var AJAX = {
}
if (data._reloadQuerywindow) {
var params = data._reloadQuerywindow;
- reload_querywindow(
+ PMA_querywindow.reload(
params.db,
params.table,
params.sql_query
);
}
+ if (data._focusQuerywindow) {
+ PMA_querywindow.focus(
+ data._focusQuerywindow
+ );
+ }
+
if (data._title) {
$('title').replaceWith(data._title);
}
@@ -197,6 +203,9 @@ var AJAX = {
AJAX.scriptHandler.load(data._scripts, 1);
}
+ if (data._params) {
+ PMA_commonParams.setAll(data._params);
+ }
$('#pma_errors').remove();
if (data._errors) {
$('
', {id:'pma_errors'})
diff --git a/js/common.js b/js/common.js
index 1cb6743df6..b5654e3fd7 100644
--- a/js/common.js
+++ b/js/common.js
@@ -1,269 +1,292 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * common functions used for communicating between main, navigation and querywindow
+ * Functionality for communicating with the querywindow
+ */
+$(function () {
+ /**
+ * Event handler for click on the open query window link
+ * in the top menu of the navigation panel
+ */
+ $('#pma_open_querywindow').click(function (event) {
+ event.preventDefault();
+ PMA_querywindow.focus();
+ });
+});
+
+/**
+ * Holds common parameters such as server, db, table, etc
*
+ * The content for this is normally loaded from Header.class.php or
+ * Response.class.php and executed by ajax.js
*/
-
-/**
- * holds the browser query window
- */
-var querywindow = '';
-
-/**
- * holds the query to be load from a new query window
- */
-var query_to_load = '';
-
-/**
- * sets current selected db
- *
- * @param string db name
- */
-function setDb(new_db)
-{
- //alert('setDb(' + new_db + ')');
- if (new_db != db) {
- // db has changed
- //alert( new_db + '(' + new_db.length + ') : ' + db );
-
- var old_db = db;
- db = new_db;
-
- // the db name as an id exists only when LeftFrameLight is false
- if (window.frame_navigation.document.getElementById(db) == null) {
- // happens when LeftFrameLight is true
- // db is unknown, reload complete left frame
- refreshNavigation();
- }
-
- // TODO: add code to expand db in lightview mode
-
- // refresh querywindow
- refreshQuerywindow();
- }
-}
-
-/**
- * sets current selected table (called from navigation.php)
- *
- * @param string table name
- */
-function setTable(new_table)
-{
- //alert('setTable(' + new_table + ')');
- if (new_table != table) {
- // table has changed
- //alert( new_table + '(' + new_table.length + ') : ' + table );
-
- table = new_table;
-
- if (window.frame_navigation.document.getElementById(db + '.' + table) == null
- && table != '') {
- // table is unknown, reload complete left frame
- refreshNavigation();
-
- }
- // TODO: add code to expand table in lightview mode
-
- // refresh querywindow
- refreshQuerywindow();
- }
-}
-
-/**
- * reloads main frame
- *
- * @param string url name of page to be loaded
- */
-function refreshMain(url)
-{
- console.log('Call to deprecate function refreshMain() ignored');
-}
-
-/**
- * reloads navigation frame
- * TODO: drop this function
- *
- * @param boolean force force reloading
- */
-function refreshNavigation(force)
-{
- PMA_reloadNavigation();
-}
-
-/**
- * sets current selected server, table and db (called from the footer)
- */
-function setAll( new_lang, new_collation_connection, new_server, new_db, new_table, new_token )
-{
- if (new_server != server || new_lang != lang
- || new_collation_connection != collation_connection) {
- // something important has changed
- server = new_server;
- db = new_db;
- table = new_table;
- collation_connection = new_collation_connection;
- lang = new_lang;
- token = new_token;
- refreshNavigation();
- } else if (new_db != db || new_table != table) {
- // save new db and table
- var old_db = db;
- var old_table = table;
- db = new_db;
- table = new_table;
-
- if (window.frame_navigation.document.getElementById(db) == null
- && window.frame_navigation.document.getElementById(db + '.' + table) == null ) {
- // table or db is unknown, reload complete left frame
- refreshNavigation();
- }
-
- // TODO: add code to expand db in lightview mode
-
- // refresh querywindow
- refreshQuerywindow();
- }
-}
-
-function reload_querywindow(db, table, sql_query)
-{
- if ( ! querywindow.closed && querywindow.location ) {
- if ( ! querywindow.document.sqlform.LockFromUpdate
- || ! querywindow.document.sqlform.LockFromUpdate.checked ) {
- querywindow.document.getElementById('hiddenqueryform').db.value = db;
- querywindow.document.getElementById('hiddenqueryform').table.value = table;
-
- if (sql_query) {
- querywindow.document.getElementById('hiddenqueryform').sql_query.value = sql_query;
+var PMA_commonParams = (function () {
+ /**
+ * @var hash params An associative array of key value pairs
+ * @access private
+ */
+ var params = {};
+ // The returned object is the public part of the module
+ return {
+ /**
+ * Saves all the key value pair that
+ * are provided in the input array
+ *
+ * @param hash obj The input array
+ *
+ * @return void
+ */
+ setAll: function (obj) {
+ var reload = false;
+ for (var i in obj) {
+ if (params[i] !== undefined && params[i] !== obj[i]) {
+ reload = true;
+ }
+ params[i] = obj[i];
}
-
- querywindow.document.getElementById('hiddenqueryform').submit();
+ if (reload) {
+ PMA_querywindow.refresh();
+ }
+ },
+ /**
+ * Retrieves a value given its key
+ * Returns empty string for undefined values
+ *
+ * @param string name The key
+ *
+ * @return string
+ */
+ get: function (name) {
+ return params[name] || '';
+ },
+ /**
+ * Saves a single key value pair
+ *
+ * @param string name The key
+ * @param string value The value
+ *
+ * @return self For chainability
+ */
+ set: function (name, value) {
+ if (params[name] !== undefined && params[name] !== value) {
+ PMA_querywindow.refresh();
+ PMA_reloadNavigation();
+ }
+ params[name] = value;
+ return this;
+ },
+ /**
+ * Returns the url query string using the saved parameters
+ *
+ * @return string
+ */
+ getUrlQuery: function () {
+ return $.sprintf(
+ '?%s&db=%s&table=%s',
+ this.get('common_query'),
+ encodeURIComponent(this.get('db')),
+ encodeURIComponent(this.get('table'))
+ );
}
- }
-}
+ };
+})();
/**
- * brings query window to front and inserts query to be edited
- */
-function focus_querywindow(sql_query)
-{
- /* if ( querywindow && !querywindow.closed && querywindow.location) { */
- if ( !querywindow || querywindow.closed || !querywindow.location) {
- // we need first to open the window and cannot pass the query with it
- // as we dont know if the query exceeds max url length
- query_to_load = sql_query;
- open_querywindow();
- insertQuery(0);
- } else {
- //var querywindow = querywindow;
- if ( querywindow.document.getElementById('hiddenqueryform').querydisplay_tab != 'sql' ) {
- querywindow.document.getElementById('hiddenqueryform').querydisplay_tab.value = "sql";
- querywindow.document.getElementById('hiddenqueryform').sql_query.value = sql_query;
- querywindow.document.getElementById('hiddenqueryform').submit();
- querywindow.focus();
- } else {
- querywindow.focus();
- }
- }
- return true;
-}
-
-/**
- * inserts query string into query window textarea
- * called from script tag in querywindow
- */
-function insertQuery()
-{
- if (query_to_load != '' && querywindow.document && querywindow.document.getElementById && querywindow.document.getElementById('sqlquery')) {
- querywindow.document.getElementById('sqlquery').value = query_to_load;
- query_to_load = '';
- return true;
- }
- return false;
-}
-
-function open_querywindow( url )
-{
- if ( ! url ) {
- url = 'querywindow.php?' + common_query + '&db=' + encodeURIComponent(db) + '&table=' + encodeURIComponent(table);
- }
-
- if (!querywindow.closed && querywindow.location) {
- goTo( url, 'query' );
- querywindow.focus();
- } else {
- querywindow = window.open( url + '&init=1', '',
- 'toolbar=0,location=0,directories=0,status=1,menubar=0,' +
- 'scrollbars=yes,resizable=yes,' +
- 'width=' + querywindow_width + ',' +
- 'height=' + querywindow_height );
- }
-
- if ( ! querywindow.opener ) {
- querywindow.opener = window.window;
- }
-
- if ( window.focus ) {
- querywindow.focus();
- }
-
- return true;
-}
-
-function refreshQuerywindow( url )
-{
-
- if ( ! querywindow.closed && querywindow.location ) {
- if ( ! querywindow.document.sqlform.LockFromUpdate
- || ! querywindow.document.sqlform.LockFromUpdate.checked ) {
- open_querywindow( url )
- }
- }
-}
-
-/**
- * opens new url in target frame, with default being left frame
- * valid is 'main' and 'querywindow' all others leads to 'left'
+ * Holds common parameters such as server, db, table, etc
*
- * @param string targeturl new url to load
- * @param string target frame where to load the new url
+ * The content for this is normally loaded from Header.class.php or
+ * Response.class.php and executed by ajax.js
*/
-function goTo(targeturl, target)
-{
- //alert(targeturl);
- if ( target == 'main' ) {
- target = window.frame_content;
- } else if ( target == 'query' ) {
- target = querywindow;
- //return open_querywindow( targeturl );
- } else if ( ! target ) {
- target = window.frame_navigation;
- }
-
- if ( target ) {
- if ( target.location.href == targeturl ) {
- return true;
- } else if ( target.location.href == pma_absolute_uri + targeturl ) {
- return true;
+var PMA_commonActions = {
+ /**
+ * Saves the database name when it's changed
+ * and reloads the query window, if necessary
+ *
+ * @param string new_db The name of the new database
+ *
+ * @return void
+ */
+ setDb: function (new_db) {
+ if (new_db != PMA_commonParams.get('db')) {
+ PMA_commonParams.set('db', new_db);
+ PMA_querywindow.refresh();
}
-
- if ( safari_browser ) {
- target.location.href = targeturl;
- } else {
- target.location.replace(targeturl);
+ },
+ /**
+ * Opens a database in the main part of the page
+ *
+ * @param string new_db The name of the new database
+ *
+ * @return void
+ */
+ openDb: function (new_db) {
+ PMA_commonParams
+ .set('db', new_db)
+ .set('table', '');
+ PMA_querywindow.refresh();
+ this.refreshMain(
+ PMA_commonParams.get('opendb_url')
+ );
+ },
+ /**
+ * Refreshes the main frame
+ *
+ * @param mixed url Undefined to refresh to the same page
+ * String to go to a different page, e.g: 'index.php'
+ *
+ * @return void
+ */
+ refreshMain: function (url) {
+ if (! url) {
+ url = $('#selflink a').attr('href');
+ url = url.substring(0, url.indexOf('?'));
}
+ url += PMA_commonParams.getUrlQuery();
+ $('', {href: url}).click();
}
+};
- return true;
-}
-
-// opens selected db in main frame
-function openDb(new_db)
-{
- //alert('opendb(' + new_db + ')');
- setDb(new_db);
- setTable('');
- refreshMain(opendb_url);
- return true;
-}
+/**
+ * Common functions used for communicating with the querywindow
+ */
+var PMA_querywindow = (function ($, window) {
+ /**
+ * @var Object querywindow Reference to the window
+ * object of the querywindow
+ * @access private
+ */
+ var querywindow = {};
+ /**
+ * @var string queryToLoad Stores the SQL query that is to be displayed
+ * in the querywindow when it is ready
+ * @access private
+ */
+ var queryToLoad = '';
+ // The returned object is the public part of the module
+ return {
+ /**
+ * Opens the query window
+ *
+ * @param mixed url Undefined to open the default page
+ * String to go to a different
+ *
+ * @return void
+ */
+ open: function (url) {
+ if (! url) {
+ url = 'querywindow.php' + PMA_commonParams.getUrlQuery();
+ }
+ if (! querywindow.closed && querywindow.location) {
+ var href = querywindow.location.href;
+ if (href != url
+ && href != PMA_commonParams.get('pma_absolute_uri') + url
+ ) {
+ if (PMA_commonParams.get('safari_browser')) {
+ querywindow.location.href = targeturl;
+ } else {
+ querywindow.location.replace(targeturl);
+ }
+ querywindow.focus();
+ }
+ } else {
+ querywindow = window.open(
+ url + '&init=1',
+ '',
+ 'toolbar=0,location=0,directories=0,status=1,'
+ + 'menubar=0,scrollbars=yes,resizable=yes,'
+ + 'width=' + PMA_commonParams.get('querywindow_width') + ','
+ + 'height=' + PMA_commonParams.get('querywindow_height')
+ );
+ }
+ if (! querywindow.opener) {
+ querywindow.opener = window.window;
+ }
+ if (window.focus) {
+ querywindow.focus();
+ }
+ },
+ /**
+ * Opens, if necessary, focuses the query window
+ * and displays an SQL query.
+ *
+ * @param string sql_query The SQL query to display in
+ * the query window
+ *
+ * @return void
+ */
+ focus: function (sql_query) {
+ if (! querywindow || querywindow.closed || ! querywindow.location) {
+ // we need first to open the window and cannot pass the query with it
+ // as we dont know if the query exceeds max url length
+ queryToLoad = sql_query;
+ this.open();
+ this.showQuery();
+ } else {
+ //var querywindow = querywindow;
+ var hiddenqueryform = querywindow
+ .document
+ .getElementById('hiddenqueryform');
+ if (hiddenqueryform.querydisplay_tab != 'sql' ) {
+ hiddenqueryform.querydisplay_tab.value = "sql";
+ hiddenqueryform.sql_query.value = sql_query;
+ $(hiddenqueryform).addClass('disableAjax');
+ hiddenqueryform.submit();
+ querywindow.focus();
+ } else {
+ querywindow.focus();
+ }
+ }
+ },
+ /**
+ * Displays the stored SQL query in the SQL form of the query window
+ *
+ * @return void
+ */
+ showQuery: function () {
+ var $sqlBox = $('#sqlquery', querywindow);
+ if (queryToLoad != '' && $sqlBox.length) {
+ $sqlBox.val(queryToLoad);
+ queryToLoad = '';
+ }
+ },
+ /**
+ * Refreshes the query window given a url
+ *
+ * @param string url Where to go to
+ *
+ * @return void
+ */
+ refresh: function (url) {
+ if (! querywindow.closed && querywindow.location) {
+ var $form = $(querywindow.document).find('#sqlqueryform');
+ if ($form.find('#checkbox_lock:checked').length == 0) {
+ PMA_querywindow.open(url);
+ }
+ }
+ },
+ /**
+ * Reloads the query window given the details
+ * of a db, a table and an sql_query
+ *
+ * @param string db The name of the database
+ * @param string table The name of the table
+ * @param string sql_query The SQL query to be displayed
+ *
+ * @return void
+ */
+ reload: function (db, table, sql_query) {
+ if (! querywindow.closed && querywindow.location) {
+ var $form = $(querywindow.document).find('#sqlqueryform');
+ if ($form.find('#checkbox_lock:checked').length == 0) {
+ var $hiddenform = $(querywindow.document)
+ .find('#hiddenqueryform');
+ $hiddenform.find('input[name=db]').val(db);
+ $hiddenform.find('input[name=table]').val(table);
+ if (sql_query) {
+ $hiddenform.find('input[name=sql_query]').val(sql_query);
+ }
+ $hiddenform.addClass('disableAjax').submit();
+ }
+ }
+ }
+ };
+})(jQuery, window);
diff --git a/js/db_operations.js b/js/db_operations.js
index a59e9e79e7..b4600b0628 100644
--- a/js/db_operations.js
+++ b/js/db_operations.js
@@ -39,7 +39,7 @@ AJAX.registerOnload('db_operations.js', function() {
var $form = $(this);
- var question = escapeHtml('CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + window.parent.db);
+ var question = escapeHtml('CREATE DATABASE ' + $('#new_db_name').val() + ' / DROP DATABASE ' + PMA_commonParams.get('db'));
PMA_prepareForAjaxRequest($form);
/**
@@ -47,36 +47,36 @@ AJAX.registerOnload('db_operations.js', function() {
*/
var button_options = {};
button_options[PMA_messages['strYes']] = function() {
- $(this).dialog("close").remove();
- window.parent.refreshMain();
- PMA_reloadNavigation();
- };
- button_options[PMA_messages['strNo']] = function() { $(this).dialog("close").remove(); }
+ $(this).dialog("close").remove();
+ PMA_commonActions.refreshMain();
+ PMA_reloadNavigation();
+ };
+ button_options[PMA_messages['strNo']] = function() {
+ $(this).dialog("close").remove();
+ }
$form.PMA_confirm(question, $form.attr('action'), function(url) {
PMA_ajaxShowMessage(PMA_messages['strRenamingDatabases'], false);
-
$.get(url, $("#rename_db_form").serialize() + '&is_js_confirmed=1', function(data) {
if(data.success == true) {
-
PMA_ajaxShowMessage(data.message);
+ PMA_commonParams.set('db', data.newname);
- window.parent.db = data.newname;
-
- $("#floating_menubar")
- .next('div')
- .remove()
- .end()
- .after(data.sql_query);
+ $("#page_content")
+ .find('#result_query')
+ .remove();
+ $("#page_content")
+ .prepend(data.sql_query);
//Remove the empty notice div generated due to a NULL query passed to PMA_Util::getMessage()
- var $notice_class = $("#floating_menubar").next("div").find('.notice');
+ var $notice_class = $('#result_query').find('.notice');
if ($notice_class.text() == '') {
$notice_class.remove();
}
$("" + PMA_messages['strReloadDatabase'] + "?").dialog({
- buttons: button_options
+ buttons: button_options,
+ modal: true
}) //end dialog options
} else {
PMA_ajaxShowMessage(data.error, false);
@@ -104,9 +104,10 @@ AJAX.registerOnload('db_operations.js', function() {
$('div.success, div.error').fadeOut();
if(data.success == true) {
PMA_ajaxShowMessage(data.message);
+ PMA_commonParams.set('db', data.newname);
if( $("#checkbox_switch").is(":checked")) {
- window.parent.db = data.newname;
- window.parent.refreshMain();
+ PMA_commonParams.set('db', data.newname);
+ PMA_commonActions.refreshMain();
PMA_reloadNavigation();
} else {
PMA_reloadNavigation();
diff --git a/js/db_search.js b/js/db_search.js
index ed43cea4b0..b9eb1dfffd 100644
--- a/js/db_search.js
+++ b/js/db_search.js
@@ -53,9 +53,6 @@ function loadResult(result_path, table_name, link, ajaxEnable)
scrollTop: $("#browse-results").offset().top
}, 1000);
PMA_ajaxRemoveMessage($msg);
- // because under db_search, window.parent.table is not defined yet,
- // we assign it manually from #table-link
- window.parent.table = $('#table-link').text().trim();
PMA_makegrid($('#table_results')[0], true, true, true, true);
}).show();
} else {
diff --git a/js/db_structure.js b/js/db_structure.js
index 4d1c73e3cf..815ce0b5af 100644
--- a/js/db_structure.js
+++ b/js/db_structure.js
@@ -397,10 +397,6 @@ AJAX.registerOnload('db_structure.js', function() {
toggleRowColors($curr_row.next());
$curr_row.hide("medium").remove();
PMA_adjustTotals();
-
- if (window.parent && window.parent.frame_navigation) {
- window.parent.frame_navigation.location.reload();
- }
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(PMA_messages['strErrorProcessingRequest'] + " : " + data.error, false);
diff --git a/js/functions.js b/js/functions.js
index 8fd60edf13..85040880f3 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -1945,9 +1945,9 @@ AJAX.registerOnload('functions.js', function() {
var tables_table = $("#tablesForm").find("tbody").not("#tbl_summary_row");
// this is the first table created in this db
if (tables_table.length == 0) {
- if (window.parent && window.parent.frame_content) {
- window.parent.frame_content.location.reload();
- }
+ PMA_commonActions.refreshMain(
+ PMA_commonParams.get('opendb_url')
+ );
} else {
/**
* @var curr_last_row Object referring to the last element in {@link tables_table}
@@ -2169,25 +2169,24 @@ AJAX.registerTeardown('functions.js', function() {
AJAX.registerOnload('functions.js', function() {
$("#drop_db_anchor.ajax").live('click', function(event) {
event.preventDefault();
-
- //context is top.frame_content, so we need to use window.parent.db to access the db var
/**
* @var question String containing the question to be asked for confirmation
*/
- var question =
- PMA_messages.strDropDatabaseStrongWarning + ' '
- + $.sprintf(PMA_messages.strDoYouReally, 'DROP DATABASE ' + escapeHtml(window.parent.db));
-
+ var question = PMA_messages.strDropDatabaseStrongWarning + ' ';
+ question += $.sprintf(
+ PMA_messages.strDoYouReally,
+ 'DROP DATABASE ' + escapeHtml(PMA_commonParams.get('db'))
+ );
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
-
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
//Database deleted successfully, refresh both the frames
PMA_reloadNavigation();
- window.parent.refreshMain();
- }); // end $.get()
- }); // end $.PMA_confirm()
- }); //end of Drop Database Ajax action
+ PMA_commonParams.set('db', '');
+ PMA_commonActions.refreshMain('index.php');
+ });
+ });
+ });
}); // end of $() for Drop Database
/**
@@ -3311,14 +3310,14 @@ AJAX.registerTeardown('functions.js', function() {
AJAX.registerOnload('functions.js', function() {
$("#drop_tbl_anchor.ajax").live('click', function(event) {
event.preventDefault();
-
- //context is top.frame_content, so we need to use window.parent.table to access the table var
/**
* @var question String containing the question to be asked for confirmation
*/
- var question =
- PMA_messages.strDropTableStrongWarning + ' '
- + $.sprintf(PMA_messages.strDoYouReally, 'DROP TABLE ' + window.parent.table);
+ var question = PMA_messages.strDropTableStrongWarning + ' ';
+ question += $.sprintf(
+ PMA_messages.strDoYouReally,
+ 'DROP TABLE ' + PMA_commonParams.get('table')
+ );
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
@@ -3328,7 +3327,10 @@ AJAX.registerOnload('functions.js', function() {
PMA_ajaxRemoveMessage($msgbox);
// Table deleted successfully, refresh both the frames
PMA_reloadNavigation();
- window.parent.refreshMain();
+ PMA_commonParams.set('table', '');
+ PMA_commonActions.refreshMain(
+ PMA_commonParams.get('opendb_url')
+ );
} else {
PMA_ajaxShowMessage(data.error, false);
}
@@ -3338,17 +3340,15 @@ AJAX.registerOnload('functions.js', function() {
$("#truncate_tbl_anchor.ajax").live('click', function(event) {
event.preventDefault();
-
- //context is top.frame_content, so we need to use window.parent.table to access the table var
/**
* @var question String containing the question to be asked for confirmation
*/
- var question =
- PMA_messages.strTruncateTableStrongWarning + ' '
- + $.sprintf(PMA_messages.strDoYouReally, 'TRUNCATE ' + window.parent.table);
-
+ var question = PMA_messages.strTruncateTableStrongWarning + ' ';
+ question += $.sprintf(
+ PMA_messages.strDoYouReally,
+ 'TRUNCATE ' + PMA_commonParams.get('table')
+ );
$(this).PMA_confirm(question, $(this).attr('href'), function(url) {
-
PMA_ajaxShowMessage(PMA_messages['strProcessingRequest']);
$.get(url, {'is_js_confirmed': '1', 'ajax_request': true}, function(data) {
if ($("#sqlqueryresults").length != 0) {
diff --git a/js/pmd/move.js b/js/pmd/move.js
index 36238d5d06..c8433b558a 100644
--- a/js/pmd/move.js
+++ b/js/pmd/move.js
@@ -610,12 +610,14 @@ function New_relation()
function Start_table_new()
{
- window.location.href = 'tbl_create.php?server=' + server + '&db=' + db + '&token=' + token;
+ PMA_commonParams.set('table', '');
+ PMA_commonActions.refreshMain('tbl_create.php');
}
function Start_tab_upd(table)
{
- window.location.href = 'tbl_structure.php?server=' + server + '&db=' + db + '&token=' + token + '&table=' + table;
+ PMA_commonParams.set('table', table);
+ PMA_commonActions.refreshMain('tbl_structure.php');
}
//--------------------------- hide tables --------------------------------------
diff --git a/js/querywindow.js b/js/querywindow.js
index 67eef0d55e..d10069ce1b 100644
--- a/js/querywindow.js
+++ b/js/querywindow.js
@@ -11,7 +11,7 @@ function PMA_querywindowCommit(tab)
{
var $hiddenqueryform = $('#hiddenqueryform');
$hiddenqueryform.find("input[name='querydisplay_tab']").val(tab);
- $hiddenqueryform.submit();
+ $hiddenqueryform.addClass('disableAjax').submit();
return false;
}
@@ -20,28 +20,6 @@ function PMA_querywindowSetFocus()
$('#sqlquery').focus();
}
-function PMA_querywindowResize()
-{
- var $el = $(this)[0];
- var $querywindowcontainer = $('#querywindowcontainer');
-
- // for Gecko
- if (typeof($el.sizeToContent) == 'function') {
- $el.sizeToContent();
- //self.scrollbars.visible = false;
- // give some more space ... to prevent 'fli(pp/ck)ing'
- $el.resizeBy(10, 50);
- return;
- }
-
- // for IE, Opera
- if ($querywindowcontainer.length) {
- // get content size
- var newWidth = $querywindowcontainer.width();
- var newHeight = $querywindowcontainer.height();
-
- // set size to contentsize
- // plus some offset for scrollbars, borders, statusbar, menus ...
- $el.resizeTo(newWidth + 45, newHeight + 75);
- }
-}
+$(function () {
+ $('#topmenucontainer').css('padding', 0);
+});
diff --git a/js/tbl_structure.js b/js/tbl_structure.js
index 01c2f4a1ab..6e19551e2f 100644
--- a/js/tbl_structure.js
+++ b/js/tbl_structure.js
@@ -116,7 +116,7 @@ AJAX.registerOnload('tbl_structure.js', function() {
PMA_ajaxShowMessage(data.message);
$(this).remove();
if (typeof data.reload != 'undefined') {
- window.parent.frame_content.location.reload();
+ PMA_commonActions.refreshMain();
}
PMA_reloadNavigation();
} else {
diff --git a/js/tbl_zoom_plot_jqplot.js b/js/tbl_zoom_plot_jqplot.js
index 229dbb915e..b12796588a 100644
--- a/js/tbl_zoom_plot_jqplot.js
+++ b/js/tbl_zoom_plot_jqplot.js
@@ -148,11 +148,11 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
$.post('tbl_zoom_select.php',{
'ajax_request' : true,
'change_tbl_info' : true,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'db' : PMA_commonParams('db'),
+ 'table' : PMA_commonParams('table'),
'field' : $('#tableid_0').val(),
'it' : 0,
- 'token' : window.parent.token
+ 'token' : PMA_commonParams('token')
},function(data) {
$('#tableFieldsId tr:eq(1) td:eq(0)').html(data.field_type);
$('#tableFieldsId tr:eq(1) td:eq(1)').html(data.field_collation);
@@ -172,11 +172,11 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
$.post('tbl_zoom_select.php',{
'ajax_request' : true,
'change_tbl_info' : true,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'db' : PMA_commonParams('db'),
+ 'table' : PMA_commonParams('table'),
'field' : $('#tableid_1').val(),
'it' : 1,
- 'token' : window.parent.token
+ 'token' : PMA_commonParams('token')
},function(data) {
$('#tableFieldsId tr:eq(3) td:eq(0)').html(data.field_type);
$('#tableFieldsId tr:eq(3) td:eq(1)').html(data.field_collation);
@@ -195,11 +195,11 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
$.post('tbl_zoom_select.php',{
'ajax_request' : true,
'change_tbl_info' : true,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'db' : PMA_commonParams('db'),
+ 'table' : PMA_commonParams('table'),
'field' : $('#tableid_2').val(),
'it' : 2,
- 'token' : window.parent.token
+ 'token' : PMA_commonParams('token')
},function(data) {
$('#tableFieldsId tr:eq(6) td:eq(0)').html(data.field_type);
$('#tableFieldsId tr:eq(6) td:eq(1)').html(data.field_collation);
@@ -216,11 +216,11 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
$.post('tbl_zoom_select.php',{
'ajax_request' : true,
'change_tbl_info' : true,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'db' : PMA_commonParams('db'),
+ 'table' : PMA_commonParams('table'),
'field' : $('#tableid_3').val(),
'it' : 3,
- 'token' : window.parent.token
+ 'token' : PMA_commonParams('token')
},function(data) {
$('#tableFieldsId tr:eq(8) td:eq(0)').html(data.field_type);
$('#tableFieldsId tr:eq(8) td:eq(1)').html(data.field_collation);
@@ -308,7 +308,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
//Update the chart series and replot
if (xChange || yChange) {
- //Logic similar to plot generation, replot only if xAxis changes or yAxis changes.
+ //Logic similar to plot generation, replot only if xAxis changes or yAxis changes.
//Code includes a lot of checks so as to replot only when necessary
if (xChange) {
xCord[searchedDataKey] = selectedRow[xLabel];
@@ -316,7 +316,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
if (xType == 'numeric') {
series[0][searchedDataKey][0] = selectedRow[xLabel];
} else if (xType == 'time') {
- series[0][searchedDataKey][0] =
+ series[0][searchedDataKey][0] =
getTimeStamp(selectedRow[xLabel], $('#types_0').val());
} else {
// todo: text values
@@ -332,7 +332,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
if (yType == 'numeric') {
series[0][searchedDataKey][1] = selectedRow[yLabel];
} else if (yType == 'time') {
- series[0][searchedDataKey][1] =
+ series[0][searchedDataKey][1] =
getTimeStamp(selectedRow[yLabel], $('#types_1').val());
} else {
// todo: text values
@@ -345,7 +345,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
//Generate SQL query for update
if (!isEmpty(newValues)) {
- var sql_query = 'UPDATE `' + window.parent.table + '` SET ';
+ var sql_query = 'UPDATE `' + PMA_commonParams('table') + '` SET ';
for (key in newValues) {
sql_query += '`' + key + '`=' ;
var value = newValues[key];
@@ -380,8 +380,8 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
//Post SQL query to sql.php
$.post('sql.php', {
- 'token' : window.parent.token,
- 'db' : window.parent.db,
+ 'token' : PMA_commonParams('token')
+ 'db' : PMA_commonParams('db'),
'ajax_request' : true,
'sql_query' : sql_query,
'inline_edit' : false
@@ -425,7 +425,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
/*
- * Generate plot using jqplot
+ * Generate plot using jqplot
*/
if (searchedData != null) {
@@ -460,11 +460,11 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
axes: {
xaxis: {
label: $('#tableid_0').val(),
- labelRenderer: $.jqplot.CanvasAxisLabelRenderer
+ labelRenderer: $.jqplot.CanvasAxisLabelRenderer
},
yaxis: {
label: $('#tableid_1').val(),
- labelRenderer: $.jqplot.CanvasAxisLabelRenderer
+ labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
},
highlighter: {
@@ -497,7 +497,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
originalXType = $('#types_0').val();
if (originalXType == 'date') {
format = '%Y-%m-%d';
- }
+ }
// todo: does not seem to work
//else if (originalXType == 'time') {
// format = '%H:%M';
@@ -507,7 +507,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
$.extend(options.axes.xaxis, {
renderer:$.jqplot.DateAxisRenderer,
tickOptions: {
- formatString: format
+ formatString: format
}
});
}
@@ -515,15 +515,15 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
originalYType = $('#types_1').val();
if (originalYType == 'date') {
format = '%Y-%m-%d';
- }
+ }
$.extend(options.axes.yaxis, {
renderer:$.jqplot.DateAxisRenderer,
tickOptions: {
- formatString: format
+ formatString: format
}
});
}
-
+
$.each(searchedData, function(key, value) {
if (xType == 'numeric') {
var xVal = parseFloat(value[xLabel]);
@@ -538,8 +538,8 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
var yVal = getTimeStamp(value[yLabel], originalYType);
}
series[0].push([
- xVal,
- yVal,
+ xVal,
+ yVal,
// extra Y values
value[dataLabel], // for highlighter
// (may set an undefined value)
@@ -548,7 +548,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
]);
});
- // under IE 8, the initial display is mangled; after a manual
+ // under IE 8, the initial display is mangled; after a manual
// resizing, it's ok
// under IE 9, everything is fine
currentChart = $.jqplot('querychart', series, options);
@@ -574,14 +574,14 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function() {
var post_params = {
'ajax_request' : true,
'get_data_row' : true,
- 'db' : window.parent.db,
- 'table' : window.parent.table,
+ 'db' : PMA_commonParams('db'),
+ 'table' : PMA_commonParams('table'),
'where_clause' : data[3],
- 'token' : window.parent.token
+ 'token' : PMA_commonParams('token')
};
$.post('tbl_zoom_select.php', post_params, function(data) {
- // Row is contained in data.row_info,
+ // Row is contained in data.row_info,
// now fill the displayResultForm with row values
for (key in data.row_info) {
$field = $('#edit_fieldID_' + field_id);
diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php
index 1ce4e989a0..ba76af75f7 100644
--- a/libraries/Footer.class.php
+++ b/libraries/Footer.class.php
@@ -60,61 +60,6 @@ class PMA_Footer
$this->_isEnabled = true;
$this->_scripts = new PMA_Scripts();
$this->_isMinimal = false;
- $this->_addDefaultScripts();
- }
-
- /**
- * Loads common scripts
- *
- * @return void
- */
- private function _addDefaultScripts()
- {
- if (empty($GLOBALS['error_message'])) {
- $this->_scripts->addCode(
- "$(function() {
- // updates current settings
- if (window.parent.setAll) {
- window.parent.setAll(
- '" . PMA_escapeJsString($GLOBALS['lang']) . "',
- '" . PMA_escapeJsString($GLOBALS['collation_connection']) . "',
- '" . PMA_escapeJsString($GLOBALS['server']) . "',
- '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['db'], '')) . "',
- '" . PMA_escapeJsString(PMA_ifSetOr($GLOBALS['table'], '')) . "',
- '" . PMA_escapeJsString($_SESSION[' PMA_token ']) . "'
- );
- }
- });"
- );
-
- if (! empty($GLOBALS['focus_querywindow'])) {
- // set focus to the querywindow
- $this->_scripts->addCode(
- "if (parent.querywindow && !parent.querywindow.closed
- && parent.querywindow.location
- ) {
- self.focus();
- }"
- );
- }
- $this->_scripts->addCode(
- "if (window.parent.frame_content) {
- // reset content frame name, as querywindow needs
- // to set a unique name before submitting form data,
- // and navigation frame needs the original name
- if (typeof(window.parent.frame_content.name) != 'undefined'
- && window.parent.frame_content.name != 'frame_content') {
- window.parent.frame_content.name = 'frame_content';
- }
- if (typeof(window.parent.frame_content.id) != 'undefined'
- && window.parent.frame_content.id != 'frame_content') {
- window.parent.frame_content.id = 'frame_content';
- }
- //window.parent.frame_content.setAttribute('name', 'frame_content');
- //window.parent.frame_content.setAttribute('id', 'frame_content');
- }"
- );
- }
}
/**
diff --git a/libraries/Header.class.php b/libraries/Header.class.php
index fd64982840..6dc54a4a65 100644
--- a/libraries/Header.class.php
+++ b/libraries/Header.class.php
@@ -101,6 +101,10 @@ class PMA_Header
* @var bool
*/
private $_headerIsSent;
+ /**
+ * @var object A reference to the common functions object
+ */
+ private $_commonFunctions;
/**
* Creates a new class instance
@@ -109,6 +113,7 @@ class PMA_Header
*/
public function __construct()
{
+ $this->_commonFunctions = PMA_commonFunctions::getInstance();
$this->_isEnabled = true;
$this->_isAjax = false;
$this->_bodyId = '';
@@ -175,6 +180,43 @@ class PMA_Header
$this->_scripts->addFile('functions.js');
$this->_scripts->addFile('navigation.js');
$this->_scripts->addFile('indexes.js');
+ $this->_scripts->addFile('common.js');
+ $this->_scripts->addCode($this->getJsParamsCode());
+ }
+
+ public function getJsParams()
+ {
+ return array(
+ 'common_query' => PMA_generate_common_url('', '', '&'),
+ 'opendb_url' => $GLOBALS['cfg']['DefaultTabDatabase'],
+ 'safari_browser' => PMA_USR_BROWSER_AGENT == 'SAFARI' ? 'true' : 'false',
+ 'querywindow_height' => $GLOBALS['cfg']['QueryWindowHeight'],
+ 'querywindow_width' => $GLOBALS['cfg']['QueryWindowWidth'],
+ 'collation_connection' => $GLOBALS['collation_connection'],
+ 'lang' => $GLOBALS['lang'],
+ 'server' => $GLOBALS['server'],
+ 'table' => $GLOBALS['table'],
+ 'db' => $GLOBALS['db'],
+ 'token' => $_SESSION[' PMA_token '],
+ 'text_dir' => $GLOBALS['text_dir'],
+ 'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'],
+ 'pma_text_default_tab' => $this->_commonFunctions->getTitleForTarget(
+ $GLOBALS['cfg']['DefaultTabTable']
+ ),
+ 'pma_text_left_default_tab' => $this->_commonFunctions->getTitleForTarget(
+ $GLOBALS['cfg']['NavigationTreeDefaultTabTable']
+ )
+ );
+ }
+
+
+ public function getJsParamsCode()
+ {
+ $params = $this->getJsParams();
+ foreach ($params as $key => $value) {
+ $params[$key] = $key . ':"' . PMA_escapeJsString($value) . '"';
+ }
+ return 'PMA_commonParams.setAll({' . implode(',', $params) . '});';
}
/**
diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php
index b887716a38..7e6a7d54ef 100644
--- a/libraries/List_Database.class.php
+++ b/libraries/List_Database.class.php
@@ -394,7 +394,7 @@ class PMA_List_Database extends PMA_List
}
$return = '