From: stevetruckstuff Date: Thu, 24 Aug 2006 16:56:54 +0000 (+0000) Subject: Add new function setCSSClass() that is always available. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e89c305d8f864a55458f342057bdeaf65fd89bfa;p=squirrelmail.git Add new function setCSSClass() that is always available. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11626 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/templates/default/js/default.js b/templates/default/js/default.js index 1b540556..86b75719 100644 --- a/templates/default/js/default.js +++ b/templates/default/js/default.js @@ -46,6 +46,18 @@ function getCSSClass (theRow) return rowClass; } +/* + * Sets a new CSS class for the given row. Browser-specific. + */ +function setCSSClass (obj, newClass) { + if (typeof(window.opera) == 'undefined' && typeof(obj.getAttribute) != 'undefined' && obj.getAttribute('className') ) { + obj.setAttribute('className', newClass, 0); + } + else { + obj.className = newClass; + } +} + /* * This function is used to initialize the orig_row_color array so we do not * need to predefine the entire array @@ -135,23 +147,9 @@ function setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerCla } // 3. Gets the current CSS class... - var domDetect = null; var newClass = null; var currentClass = getCSSClass(theRow); - // domDetect is needed later... - // 3.1 ... with DOM compatible browsers except Opera that does not return - // valid values with "getAttribute" - if (typeof(window.opera) == 'undefined' - && typeof(theRow.getAttribute) != 'undefined' - && theRow.getAttribute('className') ) { - domDetect = true; - } - // 3.2 ... with other browsers - else { - domDetect = false; - } // end 3 - // 4. Defines the new class // 4.1 Current class is the default one if (currentClass == '' @@ -197,15 +195,8 @@ function setPointer(theRow, theRowNum, theAction, theDefaultClass, thePointerCla // 5. Sets the new color... if (newClass) { - // 5.1 ... with DOM compatible browsers except Opera - if (domDetect) { - theRow.setAttribute('className', newClass, 0); - } - // 5.2 ... with other browsers - else { - theRow.className = newClass; - } - } // end 5 + setCSSClass(theRow, newClass); + } return true; } // end of the 'setPointer()' function