From fb2b704b15e495daca12896e76d7df428a055328 Mon Sep 17 00:00:00 2001 From: akalata Date: Thu, 26 Oct 2017 11:06:05 -0500 Subject: [PATCH] Add backwards-compatibility for jQuery versions before 1.6 --- stacktable.js | 46 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/stacktable.js b/stacktable.js index 82b2524..5271f0c 100755 --- a/stacktable.js +++ b/stacktable.js @@ -29,7 +29,16 @@ if ($table.hasClass('stacktable')) { return; } - var table_css = $(this).prop('class'); + var jQprop = true; + if ($.fn.jquery.replace(/\.(\d)/g,".0$1").replace(/\.0(\d{2})/g,".$1") < "1.06.00") { + jQprop = false; + } + var table_css; + if (jQprop) { + table_css = $(this).prop('class'); + } else { + table_css = $(this).attr('class'); + } var $stacktable = $('
'); if (typeof settings.myClass !== 'undefined') $stacktable.addClass(settings.myClass); var markup = ''; @@ -49,7 +58,11 @@ // declaring headMarkup and bodyMarkup, to be used for separately head and body of single records headMarkup = ''; bodyMarkup = ''; - tr_class = $(this).prop('class'); + if (jQprop) { + tr_class = $(this).prop('class'); + } else { + tr_class = $(this).attr('class'); + } // for the first row, "headIndex" cell is the head of the table // for the other rows, put the "headIndex" cell as the head for that row // then iterate through the key/values @@ -61,7 +74,13 @@ } else { bodyMarkup += ''; } - bodyMarkup += ''+$(this).html()+''; + var td_class; + if (jQprop) { + td_class = $(this).prop('class'); + } else { + td_class = $(this).attr('class'); + } + bodyMarkup += ''+$(this).html()+''; bodyMarkup += ''; } }); @@ -94,7 +113,12 @@ headIndex = 0; return $tables.each(function() { - var table_css = $(this).prop('class'); + var table_css; + if (jQprop) { + table_css = $(this).prop('class'); + } else { + table_css = $(this).attr('class'); + } var $stacktable = $('
'); if (typeof settings.myClass !== 'undefined') $stacktable.addClass(settings.myClass); var markup = ''; @@ -113,7 +137,11 @@ // declaring headMarkup and bodyMarkup, to be used for separately head and body of single records headMarkup = ''; bodyMarkup = ''; - tr_class = $(this).prop('class'); + if (jQprop) { + tr_class = $(this).prop('class'); + } else { + tr_class = $(this).attr('class'); + } // for the first row, "headIndex" cell is the head of the table if (rowIndex === 0) { @@ -135,7 +163,13 @@ } else { bodyMarkup += ''; } - bodyMarkup += ''+$(this).html()+''; + var td_class + if (jQprop) { + td_class = $(this).prop('class'); + } else { + td_class = $(this).attr('class'); + } + bodyMarkup += ''+$(this).html()+''; bodyMarkup += ''; } }