Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
74ff0ad1fa
@ -136,7 +136,7 @@ var AJAX = {
|
||||
return true;
|
||||
} else if (href && href.match(/^mailto/)) {
|
||||
return true;
|
||||
} else if ($(this).hasClass('ui-datepicker-next') ||
|
||||
} else if ($(this).hasClass('ui-datepicker-next') ||
|
||||
$(this).hasClass('ui-datepicker-prev')
|
||||
) {
|
||||
return true;
|
||||
@ -255,6 +255,7 @@ var AJAX = {
|
||||
$('#page_content').replaceWith(
|
||||
"<div id='page_content'>" + data.message + "</div>"
|
||||
);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
|
||||
if (data._selflink) {
|
||||
@ -277,6 +278,7 @@ var AJAX = {
|
||||
}
|
||||
if (data._displayMessage) {
|
||||
$('#page_content').prepend(data._displayMessage);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
|
||||
$('#pma_errors').remove();
|
||||
|
||||
56
js/codemirror/addon/runmode/runmode.js
vendored
Normal file
56
js/codemirror/addon/runmode/runmode.js
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
CodeMirror.runMode = function(string, modespec, callback, options) {
|
||||
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
|
||||
var ie = /MSIE \d/.test(navigator.userAgent);
|
||||
var ie_lt9 = ie && (document.documentMode == null || document.documentMode < 9);
|
||||
|
||||
if (callback.nodeType == 1) {
|
||||
var tabSize = (options && options.tabSize) || CodeMirror.defaults.tabSize;
|
||||
var node = callback, col = 0;
|
||||
node.innerHTML = "";
|
||||
callback = function(text, style) {
|
||||
if (text == "\n") {
|
||||
// Emitting LF or CRLF on IE8 or earlier results in an incorrect display.
|
||||
// Emitting a carriage return makes everything ok.
|
||||
node.appendChild(document.createTextNode(ie_lt9 ? '\r' : text));
|
||||
col = 0;
|
||||
return;
|
||||
}
|
||||
var content = "";
|
||||
// replace tabs
|
||||
for (var pos = 0;;) {
|
||||
var idx = text.indexOf("\t", pos);
|
||||
if (idx == -1) {
|
||||
content += text.slice(pos);
|
||||
col += text.length - pos;
|
||||
break;
|
||||
} else {
|
||||
col += idx - pos;
|
||||
content += text.slice(pos, idx);
|
||||
var size = tabSize - col % tabSize;
|
||||
col += size;
|
||||
for (var i = 0; i < size; ++i) content += " ";
|
||||
pos = idx + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (style) {
|
||||
var sp = node.appendChild(document.createElement("span"));
|
||||
sp.className = "cm-" + style.replace(/ +/g, " cm-");
|
||||
sp.appendChild(document.createTextNode(content));
|
||||
} else {
|
||||
node.appendChild(document.createTextNode(content));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
var lines = CodeMirror.splitLines(string), state = CodeMirror.startState(mode);
|
||||
for (var i = 0, e = lines.length; i < e; ++i) {
|
||||
if (i) callback("\n");
|
||||
var stream = new CodeMirror.StringStream(lines[i]);
|
||||
while (!stream.eol()) {
|
||||
var style = mode.token(stream, state);
|
||||
callback(stream.current(), style, i, stream.start);
|
||||
stream.start = stream.pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1352,6 +1352,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
var $form = $(this).prev('form');
|
||||
var sql_query = $form.find("input[name='sql_query']").val();
|
||||
var $inner_sql = $(this).parent().prev().find('.inner_sql');
|
||||
var $sql_highlight = $(this).parent().prev().find('.sql-highlight');
|
||||
var old_text = $inner_sql.html();
|
||||
|
||||
var new_content = "<textarea name=\"sql_query_edit\" id=\"sql_query_edit\">" + sql_query + "</textarea>\n";
|
||||
@ -1364,6 +1365,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
}
|
||||
$editor_area.html(new_content);
|
||||
$inner_sql.hide();
|
||||
$sql_highlight.hide();
|
||||
|
||||
bindCodeMirrorToInlineEditor();
|
||||
return false;
|
||||
@ -1387,8 +1389,8 @@ AJAX.registerOnload('functions.js', function () {
|
||||
|
||||
$("input#sql_query_edit_discard").live('click', function () {
|
||||
$('div#inline_editor_outer')
|
||||
.empty()
|
||||
.siblings('.inner_sql').show();
|
||||
.siblings('.sql-highlight').show();
|
||||
$('div#inline_editor_outer').remove();
|
||||
});
|
||||
|
||||
$('input.sqlbutton').click(function (evt) {
|
||||
@ -1486,6 +1488,25 @@ function catchKeypressesFromSqlTextboxes(event) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Higlights SQL using CodeMirror.
|
||||
*/
|
||||
function PMA_highlightSQL(base)
|
||||
{
|
||||
var $elm = base.find('code.sql');
|
||||
$elm.each(function () {
|
||||
var $sql = $(this);
|
||||
var $pre = $sql.find('pre');
|
||||
/* We only care about visible elements to avoid double processing */
|
||||
if ($pre.is(":visible")) {
|
||||
var $highlight = $('<div class="sql-highlight cm-s-default"></div>');
|
||||
$sql.append($highlight);
|
||||
CodeMirror.runMode($sql.text(), 'text/x-mysql', $highlight[0]);
|
||||
$pre.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a message on the top of the page for an Ajax request
|
||||
*
|
||||
@ -1597,6 +1618,7 @@ function PMA_ajaxShowMessage(message, timeout)
|
||||
PMA_messages.strDismiss
|
||||
);
|
||||
}
|
||||
PMA_highlightSQL($retval);
|
||||
|
||||
return $retval;
|
||||
}
|
||||
@ -2117,6 +2139,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
$.post($form.attr('action'), $form.serialize() + "&submit_num_fields=1", function (data) {
|
||||
if (data.success) {
|
||||
$("#page_content").html(data.message);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
PMA_verifyColumnsProperties();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
} else {
|
||||
@ -2225,6 +2248,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
PMA_commonParams.set('table', tbl);
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
$('#page_content').html(data.message);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
});
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
@ -2255,6 +2279,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$("<div id='sqlqueryresults' class='ajax'></div>").prependTo("#page_content");
|
||||
$("#sqlqueryresults").html(data.sql_query);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
scrollToTop();
|
||||
} else if (data.success === true) {
|
||||
var $temp_div = $("<div id='temp_div'></div>");
|
||||
@ -2263,6 +2288,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
PMA_ajaxShowMessage($success);
|
||||
$("<div id='sqlqueryresults' class='ajax'></div>").prependTo("#page_content");
|
||||
$("#sqlqueryresults").html(data.message);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
PMA_init_slider();
|
||||
$("#sqlqueryresults").children("fieldset,br").remove();
|
||||
scrollToTop();
|
||||
@ -2407,6 +2433,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
$.post($the_form.attr('action'), $the_form.serialize() + '&change_pw=' + this_value, function (data) {
|
||||
if (data.success === true) {
|
||||
$("#page_content").prepend(data.message);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
$("#change_password_dialog").hide().remove();
|
||||
$("#edit_user_dialog").dialog("close").remove();
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@ -2817,6 +2844,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure)
|
||||
$('<div id="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
$("#result_query .notice").remove();
|
||||
$("#result_query").prepend(data.message);
|
||||
@ -3421,6 +3449,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$("<div id='sqlqueryresults'></div>").prependTo("#page_content");
|
||||
$("#sqlqueryresults").html(data.sql_query);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
} else {
|
||||
PMA_ajaxShowMessage(data.error, false);
|
||||
}
|
||||
@ -3454,6 +3483,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
$elm.focus().bind('keydown', catchKeypressesFromSqlTextboxes);
|
||||
}
|
||||
}
|
||||
PMA_highlightSQL($('body'));
|
||||
});
|
||||
AJAX.registerTeardown('functions.js', function () {
|
||||
if (codemirror_editor) {
|
||||
|
||||
@ -159,6 +159,7 @@ AJAX.registerOnload('indexes.js', function () {
|
||||
$('<div id="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
PMA_commonActions.refreshMain(false, function () {
|
||||
$("a.ajax[href^=#indexes]").click();
|
||||
|
||||
@ -101,6 +101,7 @@ function addUser($form)
|
||||
PMA_ajaxShowMessage(data.message);
|
||||
$("#result_query").remove();
|
||||
$('#page_content').prepend(data.sql_query);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
$("#result_query").css({
|
||||
'margin-top' : '0.5em'
|
||||
});
|
||||
@ -234,6 +235,7 @@ AJAX.registerOnload('server_privileges.js', function () {
|
||||
.find("form[name=usersForm]")
|
||||
.append('<input type="hidden" name="ajax_request" value="true" />')
|
||||
.end();
|
||||
PMA_highlightSQL($div);
|
||||
displayPasswordGenerateButton();
|
||||
PMA_showHints($div);
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@ -361,6 +363,8 @@ AJAX.registerOnload('server_privileges.js', function () {
|
||||
$div.empty();
|
||||
}
|
||||
$div.html(data.message);
|
||||
PMA_highlightSQL($div);
|
||||
var $div = $('#edit_user_dialog');
|
||||
displayPasswordGenerateButton();
|
||||
$(checkboxes_sel).trigger("change");
|
||||
PMA_ajaxRemoveMessage($msgbox);
|
||||
@ -430,6 +434,7 @@ AJAX.registerOnload('server_privileges.js', function () {
|
||||
if (data.sql_query) {
|
||||
$("#result_query").remove();
|
||||
$('#page_content').prepend(data.sql_query);
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
$("#result_query").css({
|
||||
'margin-top' : '0.5em'
|
||||
});
|
||||
|
||||
@ -304,6 +304,7 @@ AJAX.registerOnload('sql.js', function () {
|
||||
$('<div id="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
});
|
||||
PMA_reloadNavigation();
|
||||
@ -635,4 +636,4 @@ function initProfilingTables()
|
||||
AJAX.registerOnload('sql.js', function () {
|
||||
makeProfilingChart();
|
||||
initProfilingTables();
|
||||
});
|
||||
});
|
||||
|
||||
@ -128,6 +128,7 @@ AJAX.registerOnload('tbl_select.js', function () {
|
||||
} else {
|
||||
$("#sqlqueryresults").html(data.error);
|
||||
}
|
||||
PMA_highlightSQL($('#sqlqueryresults'));
|
||||
}); // end $.post()
|
||||
});
|
||||
|
||||
|
||||
@ -85,6 +85,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
.append(data.message)
|
||||
.append(data.sql_query)
|
||||
.show();
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
$("#result_query .notice").remove();
|
||||
$form.remove();
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
@ -109,6 +110,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
$('<div id="change_column_dialog" class="margin"></div>')
|
||||
.html(data.message)
|
||||
.insertBefore('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
PMA_verifyColumnsProperties();
|
||||
} else {
|
||||
PMA_ajaxShowMessage(PMA_messages.strErrorProcessingRequest + " : " + data.error, false);
|
||||
@ -135,6 +137,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
.html(data.message)
|
||||
)
|
||||
.show();
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
PMA_verifyColumnsProperties();
|
||||
} else {
|
||||
$('#page_content').show();
|
||||
@ -180,6 +183,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
$('<div id="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
toggleRowColors($curr_row.next());
|
||||
// Adjust the row numbers
|
||||
@ -235,6 +239,7 @@ AJAX.registerOnload('tbl_structure.js', function () {
|
||||
$('<div id="result_query"></div>')
|
||||
.html(data.sql_query)
|
||||
.prependTo('#page_content');
|
||||
PMA_highlightSQL($('#page_content'));
|
||||
}
|
||||
});
|
||||
PMA_reloadNavigation();
|
||||
|
||||
@ -356,6 +356,7 @@ class PMA_Header
|
||||
if ($GLOBALS['cfg']['CodemirrorEnable']) {
|
||||
$this->_scripts->addFile('codemirror/lib/codemirror.js');
|
||||
$this->_scripts->addFile('codemirror/mode/sql/sql.js');
|
||||
$this->_scripts->addFile('codemirror/addon/runmode/runmode.js');
|
||||
}
|
||||
if ($this->_userprefsOfferImport) {
|
||||
$this->_scripts->addFile('config.js');
|
||||
|
||||
@ -2764,7 +2764,7 @@ $cfg['SQP'] = array();
|
||||
*
|
||||
* @global string $cfg['SQP']['fmtType']
|
||||
*/
|
||||
$cfg['SQP']['fmtType'] = 'html';
|
||||
$cfg['SQP']['fmtType'] = 'none';
|
||||
|
||||
/**
|
||||
* Amount to indent each level (floats are valid)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user