[Koha-patches] [PATCH] Bug 3128: IE7 tweak

Joe Atzberger joe.atzberger at liblime.com
Wed Apr 22 23:16:56 CEST 2009


Again, jquery has the answer, mainly because it fails cleanly and
quietly on NULL/undef elements.
---
 .../prog/en/modules/authorities/authorities.tmpl   |   26 ++++++++-----------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tmpl
index c27a01f..57af9dc 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tmpl
@@ -35,27 +35,25 @@
  */
 function AreMandatoriesNotOk(){
     var mandatories = new Array();
-    var tab = new Array();
+    var   tab = new Array();
     var label = new Array();
-    var flag=0;
     <!-- TMPL_LOOP NAME='BIG_LOOP' --><!-- TMPL_LOOP NAME='innerloop' --><!-- TMPL_LOOP NAME='subfield_loop'--><!-- TMPL_IF NAME='mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
                         tab.push("<!-- TMPL_VAR NAME='number' -->");
                         label.push("<!-- TMPL_VAR NAME='marc_lib' ESCAPE=JS-->");<!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
-    var StrAlert = _("Can't save this record because the following field aren't filled :\n\n");
+    var StrAlert = "";
     for(var i=0,len=mandatories.length; i<len ; i++){
-        //alert (  mandatories[i]);
-        if( ! document.getElementById(mandatories[i]).value){
-            flag = 1;
-            document.getElementById(mandatories[i]).setAttribute('class','subfield_not_filled');
-            document.getElementById(mandatories[i]).focus();
+        var id_string = mandatories[i];
+        alert (id_string);
+        if( ! $("#" + id_string).val() ){
+            $("#" + id_string).attr('class','subfield_not_filled').focus();
             StrAlert += "\t* "+label[i]+_(" in tab ")+tab[i]+"\n";
         }
     }
-    if(flag){
-      return StrAlert;
-  } else {
-    return flag;
-  }
+    if(StrAlert){
+        return _("Can't save this record because the following field aren't filled :\n\n") + StrAlert;
+    } else {
+        return flag;
+    }
 }
 
 /**
@@ -74,8 +72,6 @@ function Check(){
 }
 
 
-
-
 function AddField(field,cntrepeatfield) {
     document.forms['f'].op.value = "addfield";
     document.forms['f'].addfield_field.value=field;
-- 
1.5.6.5




More information about the Koha-patches mailing list