Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Čihař <mcihar@suse.cz>2011-08-05 16:49:23 +0400
committerMichal Čihař <mcihar@suse.cz>2011-08-05 16:49:23 +0400
commit1ec0b69e6bf3378188a051b45fb2c0e7ea93b990 (patch)
tree1bf578071b04275411cdb69c64ce0e54ce10391d /js/server_variables.js
parent6205d419b68d57105d985a4a5335498337f6ccf4 (diff)
Coding style, function definitions
Diffstat (limited to 'js/server_variables.js')
-rw-r--r--js/server_variables.js55
1 files changed, 28 insertions, 27 deletions
diff --git a/js/server_variables.js b/js/server_variables.js
index 8776440079..1aded3b43c 100644
--- a/js/server_variables.js
+++ b/js/server_variables.js
@@ -1,13 +1,14 @@
-function editVariable(link) {
+function editVariable(link)
+{
var varName = $(link).parent().parent().find('th:first').first().text().replace(/ /g,'_');
var mySaveLink = $(saveLink);
var myCancelLink = $(cancelLink);
var $cell = $(link).parent();
-
+
$cell.addClass('edit');
// remove edit link
$cell.find('a.editLink').remove();
-
+
mySaveLink.click(function() {
$.get('server_variables.php?' + url_query,
{ ajax_request: true, type: 'setval', varName: varName, varValue: $cell.find('input').attr('value') },
@@ -23,14 +24,14 @@ function editVariable(link) {
);
return false;
});
-
+
myCancelLink.click(function() {
$cell.html($cell.find('span.oldContent').html());
$cell.removeClass('edit');
return false;
});
-
-
+
+
$.get('server_variables.php?' + url_query,
{ ajax_request: true, type: 'getval', varName: varName },
function(data) {
@@ -42,17 +43,17 @@ function editVariable(link) {
$cell.find('table td:first').append(myCancelLink);
}
);
-
+
return false;
}
-$(function() {
+$(function() {
var textFilter=null;
var odd_row=false;
var testString = 'abcdefghijklmnopqrstuvwxyz0123456789,ABCEFGHIJKLMOPQRSTUVWXYZ';
var $tmpDiv;
var charWidth;
-
+
// Global vars
editLink = '<a href="#" class="editLink" onclick="return editVariable(this);"><img class="icon ic_b_edit" src="themes/dot.gif" alt=""> '+PMA_messages['strEdit']+'</a>';
saveLink = '<a href="#" class="saveLink"><img class="icon ic_b_save" src="themes/dot.gif" alt=""> '+PMA_messages['strSave']+'</a> ';
@@ -62,7 +63,7 @@ $(function() {
$.ajaxSetup({
cache:false
});
-
+
/* Variable editing */
if(isSuperuser) {
$('table.data tbody tr td:nth-child(2)').hover(
@@ -76,36 +77,36 @@ $(function() {
}
);
}
-
+
/*** This code snippet takes care that the table stays readable. It cuts off long strings the table overlaps the window size ***/
$('table.data').after($tmpDiv=$('<span>'+testString+'</span>'));
charWidth = $tmpDiv.width() / testString.length;
$tmpDiv.remove();
-
+
$(window).resize(limitTableWidth);
limitTableWidth();
-
+
function limitTableWidth() {
var fulltext;
var charDiff;
var maxTableWidth;
var $tmpTable;
-
+
$('table.data').after($tmpTable=$('<table id="testTable" style="width:100%;"><tr><td>'+testString+'</td></tr></table>'));
- maxTableWidth = $('#testTable').width();
+ maxTableWidth = $('#testTable').width();
$tmpTable.remove();
charDiff = ($('table.data').width()-maxTableWidth) / charWidth;
-
+
if($('body').innerWidth() < $('table.data').width()+10 || $('body').innerWidth() > $('table.data').width()+20) {
var maxChars=0;
-
+
$('table.data tbody tr td:nth-child(2)').each(function() {
maxChars=Math.max($(this).text().length,maxChars);
});
-
+
// Do not resize smaller if there's only 50 chars displayed already
if(charDiff > 0 && maxChars < 50) return;
-
+
$('table.data tbody tr td:nth-child(2)').each(function() {
if((charDiff>0 && $(this).text().length > maxChars-charDiff) || (charDiff<0 && $(this).find('abbr.cutoff').length>0)) {
if($(this).find('abbr.cutoff').length > 0)
@@ -115,7 +116,7 @@ $(function() {
// Do not cut off elements with html in it and hope they are not too long
if(fulltext.length != $(this).html().length) return 0;
}
-
+
if(fulltext.length < maxChars-charDiff)
$(this).html(fulltext);
else $(this).html('<abbr class="cutoff" title="'+fulltext+'">'+fulltext.substr(0,maxChars-charDiff-3)+'...</abbr>');
@@ -123,31 +124,31 @@ $(function() {
});
}
}
-
+
// Filter options are invisible for disabled js users
$('fieldset#tableFilter').css('display','');
-
+
$('#filterText').keyup(function(e) {
if($(this).val().length==0) textFilter=null;
else textFilter = new RegExp("(^| )"+$(this).val().replace(/_/g,' '),'i');
filterVariables();
});
-
+
function filterVariables() {
odd_row=false;
var mark_next=false;
var firstCell;
-
+
$('table.filteredData tbody tr').each(function() {
firstCell = $(this).children(':first');
-
+
if(mark_next || textFilter==null || textFilter.exec(firstCell.text())) {
// If current row is 'marked', also display next row
if($(this).hasClass('marked') && !mark_next)
mark_next=true;
else mark_next=false;
- odd_row = !odd_row;
+ odd_row = !odd_row;
$(this).css('display','');
if(odd_row) {
$(this).addClass('odd');
@@ -161,4 +162,4 @@ $(function() {
}
});
}
-}); \ No newline at end of file
+});