MDL-31660 forms: Added checks for form change detection
authorSam Hemelryk <sam@moodle.com>
Sun, 4 Mar 2012 22:00:14 +0000 (11:00 +1300)
committerSam Hemelryk <sam@moodle.com>
Sun, 4 Mar 2012 22:00:14 +0000 (11:00 +1300)
lib/form/filemanager.js

index 10effe4..2e02de1 100644 (file)
@@ -144,7 +144,9 @@ M.form_filemanager.init = function(Y, options) {
             this.filecount++;
             this.check_buttons();
             this.refresh(this.currentpath);
-            M.core_formchangechecker.set_form_changed();
+            if (typeof M.core_formchangechecker != 'undefined') {
+                M.core_formchangechecker.set_form_changed();
+            }
         },
         check_buttons: function() {
             var button_addfile  = Y.one("#btnadd-"+this.client_id);
@@ -214,7 +216,9 @@ M.form_filemanager.init = function(Y, options) {
                                 scope.mkdir_dialog.hide();
                                 scope.refresh(filepath);
                                 Y.one('#fm-newname').set('value', '');
-                                M.core_formchangechecker.set_form_changed();
+                                if (typeof M.core_formchangechecker != 'undefined') {
+                                    M.core_formchangechecker.set_form_changed();
+                                }
                             }
                         });
                     }
@@ -568,7 +572,9 @@ M.form_filemanager.init = function(Y, options) {
                         callback: function(id, obj, args) {
                             scope.filecount--;
                             scope.refresh(obj.filepath);
-                            M.core_formchangechecker.set_form_changed();
+                            if (typeof M.core_formchangechecker != 'undefined') {
+                                M.core_formchangechecker.set_form_changed();
+                            }
                             if (scope.filecount < scope.maxfiles && scope.maxfiles!=-1) {
                                 var button_addfile  = Y.one("#btnadd-"+scope.client_id);
                                 button_addfile.setStyle('display', 'inline');
@@ -616,7 +622,9 @@ M.form_filemanager.init = function(Y, options) {
                                 alert(M.str.repository.fileexists);
                             } else {
                                 scope.refresh(obj.filepath);
-                                M.core_formchangechecker.set_form_changed();
+                                if (typeof M.core_formchangechecker != 'undefined') {
+                                    M.core_formchangechecker.set_form_changed();
+                                }
                             }
                             Y.one('#fm-rename-input').set('value', '');
                             scope.rename_dialog.hide();
@@ -694,7 +702,9 @@ M.form_filemanager.init = function(Y, options) {
                             }
                             dialog.cancel();
                             scope.refresh(p);
-                            M.core_formchangechecker.set_form_changed();
+                            if (typeof M.core_formchangechecker != 'undefined') {
+                                M.core_formchangechecker.set_form_changed();
+                            }
                         }
                     });
                 }