MDL-25937 Forms Library: Added Javascript validation for filepicker and filemanager. Also fixed disbledif rule check for both

This commit is contained in:
Rajesh Taneja 2011-09-09 16:50:12 +08:00
parent f03a17bb09
commit 7dfe3c517b
5 changed files with 28 additions and 9 deletions

View file

@ -53,6 +53,9 @@ M.form_filemanager.init = function(Y, options) {
api: M.cfg.wwwroot+'/repository/draftfiles_ajax.php',
menus: {},
initializer: function(options) {
//For client side validation, remove hidden draft_id
Y.one('#id_'+options.elementname).set('value', '');
this.options = options;
if (options.mainfile) {
this.enablemainfile = options.mainfile;
@ -69,6 +72,7 @@ M.form_filemanager.init = function(Y, options) {
this.filepicker_options.maxbytes = this.maxbytes;
this.filepicker_options.env = 'filemanager';
this.filepicker_options.itemid = options.itemid;
this.filepicker_options.elementname = options.elementname;
if (options.filecount) {
this.filecount = options.filecount;
@ -150,6 +154,12 @@ M.form_filemanager.init = function(Y, options) {
button_addfile.setStyle('display', 'none');
}
this.refresh(this.currentpath);
//When file is added then set draftid for validation
var elementname = M.core_filepicker.instances[this.client_id].options.elementname;
var itemid = M.core_filepicker.instances[this.client_id].options.itemid;
Y.one('#id_'+elementname).set('value', itemid);
//generate event to indicate changes which will be used by disable if code.
Y.one('#id_'+elementname).simulate('change');
},
refresh: function(filepath) {
var scope = this;