diff --git a/js/functions.js b/js/functions.js index 0f8d8aaaae..e0a157138a 100644 --- a/js/functions.js +++ b/js/functions.js @@ -3803,54 +3803,7 @@ AJAX.registerOnload('functions.js', function() { */ $('span a.create_view.ajax').live('click', function (e) { e.preventDefault(); - var $msg = PMA_ajaxShowMessage(); - var syntaxHighlighter = null; - $.get($(this).attr('href') + '&ajax_request=1', function (data) { - if (data.success == true) { - PMA_ajaxRemoveMessage($msg); - var buttonOptions = {}; - buttonOptions[PMA_messages['strGo']] = function () { - if (typeof CodeMirror !== 'undefined') { - syntaxHighlighter.save(); - } - $msg = PMA_ajaxShowMessage(); - $.get('view_create.php', $('#createViewDialog').find('form').serialize(), function (data) { - PMA_ajaxRemoveMessage($msg); - if (data.success === true) { - $('#createViewDialog').dialog("close"); - $('#result_query').html(data.message); - PMA_reloadNavigation(); - } else { - PMA_ajaxShowMessage(data.error, false); - } - }); - }; - buttonOptions[PMA_messages['strClose']] = function () { - $(this).dialog("close"); - }; - var $dialog = $('
').attr('id', 'createViewDialog').append(data.message).dialog({ - width: 500, - minWidth: 300, - maxWidth: 620, - modal: true, - buttons: buttonOptions, - title: $('legend', $(data.message)).html(), - close: function () { - $(this).remove(); - } - }); - $dialog.find('legend').remove(); - // Attach syntax highlited editor - if (typeof CodeMirror !== 'undefined') { - var $elm = $dialog.find('textarea'); - var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"}; - syntaxHighlighter = CodeMirror.fromTextArea($elm[0], opts); - } - $('input:visible[type=text]', $dialog).first().focus(); - } else { - PMA_ajaxShowMessage(data.error); - } - }); + PMA_createViewDialog($(this)); }); /** * Attach Ajax event handlers for input fields in the editor @@ -3864,6 +3817,58 @@ AJAX.registerOnload('functions.js', function() { }); // end $.live() }); +function PMA_createViewDialog($this) +{ + var $msg = PMA_ajaxShowMessage(); + var syntaxHighlighter = null; + $.get($this.attr('href') + '&ajax_request=1', function (data) { + if (data.success == true) { + PMA_ajaxRemoveMessage($msg); + var buttonOptions = {}; + buttonOptions[PMA_messages['strGo']] = function () { + if (typeof CodeMirror !== 'undefined') { + syntaxHighlighter.save(); + } + $msg = PMA_ajaxShowMessage(); + $.get('view_create.php', $('#createViewDialog').find('form').serialize(), function (data) { + PMA_ajaxRemoveMessage($msg); + if (data.success === true) { + $('#createViewDialog').dialog("close"); + $('#result_query').html(data.message); + PMA_reloadNavigation(); + } else { + PMA_ajaxShowMessage(data.error, false); + } + }); + }; + buttonOptions[PMA_messages['strClose']] = function () { + $(this).dialog("close"); + }; + var $dialog = $('
').attr('id', 'createViewDialog').append(data.message).dialog({ + width: 500, + minWidth: 300, + maxWidth: 620, + modal: true, + buttons: buttonOptions, + title: $('legend', $(data.message)).html(), + close: function () { + $(this).remove(); + } + }); + $dialog.find('legend').remove(); + // Attach syntax highlited editor + if (typeof CodeMirror !== 'undefined') { + var $elm = $dialog.find('textarea'); + var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"}; + syntaxHighlighter = CodeMirror.fromTextArea($elm[0], opts); + } + $('input:visible[type=text]', $dialog).first().focus(); + } else { + PMA_ajaxShowMessage(data.error); + } + }); +} + /** * Watches checkboxes in a form to set the checkall box accordingly */ diff --git a/js/navigation.js b/js/navigation.js index ba8bf8ada6..43b9eb129c 100644 --- a/js/navigation.js +++ b/js/navigation.js @@ -269,6 +269,12 @@ $(function() { var title = PMA_messages['strEditIndex']; indexEditorDialog(url, title); }); + + /** New view */ + $('li.new_view a.ajax').live('click', function (event) { + event.preventDefault(); + PMA_createViewDialog($(this)); + }); }); /** diff --git a/libraries/navigation/NavigationTree.class.php b/libraries/navigation/NavigationTree.class.php index 7a5cb830cc..0eda477be0 100644 --- a/libraries/navigation/NavigationTree.class.php +++ b/libraries/navigation/NavigationTree.class.php @@ -771,7 +771,11 @@ class PMA_NavigationTree ); $parent = $node->parents(false, true); if ($parent[0]->type == Node::CONTAINER - && in_array($parent[0]->real_name, $haveAjax) + && (in_array($parent[0]->real_name, $haveAjax) + || ($parent[0]->real_name == 'views' + && $node->isNew == true + ) + ) ) { $linkClass = ' class="ajax"'; }