Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2015-01-29 11:41:17 +01:00
commit f301a058a5
3 changed files with 69 additions and 42 deletions

View File

@ -3363,8 +3363,7 @@ function indexEditorDialog(url, title, callback_success, callback_failure)
.dialog({
title: title,
width: 450,
// increase the chance that the footer will be visible:
height: 450,
height: 350,
open: PMA_verifyColumnsProperties,
modal: true,
buttons: button_options,
@ -3372,42 +3371,48 @@ function indexEditorDialog(url, title, callback_success, callback_failure)
$(this).remove();
}
});
checkIndexType();
checkIndexName("index_frm");
$('#index_columns td').each(function () {
$(this).css("width", $(this).width() + 'px');
});
$('#index_columns tbody').sortable();
PMA_showHints($div);
PMA_init_slider();
// Add a slider for selecting how many columns to add to the index
$div.find('.slider').slider({
animate: true,
value: 1,
min: 1,
max: 16,
slide: function (event, ui) {
$(this).closest('fieldset').find('input[type=submit]').val(
PMA_sprintf(PMA_messages.strAddToIndex, ui.value)
);
}
});
// focus index size input on column picked
$div.find('table#index_columns select').change(function () {
if ($(this).find("option:selected").val() === '') {
return true;
}
$(this).closest("tr").find("input").focus();
});
// Focus the slider, otherwise it looks nearly transparent
$('a.ui-slider-handle').addClass('ui-state-focus');
// set focus on index name input, if empty
var input = $div.find('input#input_index_name');
input.val() || input.focus();
$div.find('.tblFooters').remove();
showIndexEditDialog($div);
}
}); // end $.get()
}
function showIndexEditDialog($outer)
{
checkIndexType();
checkIndexName("index_frm");
$('#index_columns td').each(function () {
$(this).css("width", $(this).width() + 'px');
});
$('#index_columns tbody').sortable();
PMA_showHints($outer);
PMA_init_slider();
// Add a slider for selecting how many columns to add to the index
$outer.find('.slider').slider({
animate: true,
value: 1,
min: 1,
max: 16,
slide: function (event, ui) {
$(this).closest('fieldset').find('input[type=submit]').val(
PMA_sprintf(PMA_messages.strAddToIndex, ui.value)
);
}
});
// focus index size input on column picked
$outer.find('table#index_columns select').change(function () {
if ($(this).find("option:selected").val() === '') {
return true;
}
$(this).closest("tr").find("input").focus();
});
// Focus the slider, otherwise it looks nearly transparent
$('a.ui-slider-handle').addClass('ui-state-focus');
// set focus on index name input, if empty
var input = $outer.find('input#input_index_name');
input.val() || input.focus();
}
/**
* Function to display tooltips that were
* generated on the PHP side by PMA_Util::showHint()

View File

@ -37,7 +37,7 @@ function checkIndexType()
/**
* @var Object Footer containg the controllers to add more columns
*/
$add_more = $('#index_frm .tblFooters');
$add_more = $('#index_frm .add_more');
if ($select_index_choice.val() == 'SPATIAL') {
// Disable and hide the size column
@ -469,6 +469,8 @@ function PMA_indexTypeSelectionDialog(source_array, index_choice, col_index)
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('indexes.js', function () {
$(document).off('click', '#save_index_frm');
$(document).off('click', '#preview_index_frm');
$(document).off('change', '#select_index_choice');
$(document).off('click', 'a.drop_primary_key_index_anchor.ajax');
$(document).off('click', "#table_index tbody tr td.edit_index.ajax, #indexes .add_index.ajax");
@ -492,8 +494,25 @@ AJAX.registerOnload('indexes.js', function () {
indexes = [];
fulltext_indexes = [];
checkIndexType();
checkIndexName("index_frm");
var $form = $("#index_frm");
if ($form.length > 0) {
showIndexEditDialog($form);
}
$(document).on('click', '#save_index_frm', function (event) {
event.preventDefault();
var $form = $("#index_frm");
var submitData = $form.serialize() + '&do_save_data=1&ajax_request=true&ajax_page_request=true';
var $msgbox = PMA_ajaxShowMessage(PMA_messages.strProcessingRequest);
AJAX.source = $form;
$.post($form.attr('action'), submitData, AJAX.responseHandler);
})
$(document).on('click', '#preview_index_frm', function (event) {
event.preventDefault();
PMA_previewSQL($('#index_frm'));
})
$(document).on('change', '#select_index_choice', function (event) {
event.preventDefault();
checkIndexType();

View File

@ -459,18 +459,21 @@ function PMA_getHtmlForIndexForm($fields, $index, $form_params, $add_fields)
$html .= '</table>';
$html .= '</fieldset>';
$html .= '<fieldset class="tblFooters">';
$html .= '<div class="add_more">';
$btn_value = sprintf(__('Add %s column(s) to index'), 1);
$html .= '<div class="slider"></div>';
$html .= '<div class="add_fields">';
$html .= '<input type="submit" value="' . $btn_value . '" />';
$html .= '<input type="submit" id="add_fields" value="' . $btn_value . '" />';
$html .= '</div>';
$html .= '</div>';
$html .= '</fieldset>';
$html .= '<fieldset class="tblFooters">';
$html .= '<button type="submit" id="preview_index_frm">' . __('Preview SQL') . '</button>';
$html .= '<input type="submit" id="save_index_frm" value="' . __('Go') . '" />';
$html .= '</fieldset>';
$html .= '</form>';
return $html;