芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/moodledata/localcache/js/993cf0344ec41ca131b8e8be49f31a0d236a598c
M.core_role={};M.core_role.init_cap_table_filter=function(Y,tableid,contextid){var CapTableFilter=function(tableid){this.tableid=tableid;this.context=contextid;this.initializer()};CapTableFilter.prototype={tableid:null,context:null,delayhandle:-1,searchdelay:100,table:null,div:null,input:null,label:null,button:null,initializer:function(){var filtervalue=this.getFilterCookieValue();this.table=Y.one('#'+this.tableid);this.div=Y.Node.create('
').setStyles({width:this.table.get('offsetWidth'),marginLeft:'auto',marginRight:'auto'});this.input=Y.Node.create('
');this.label=Y.Node.create('
'+M.util.get_string('filter','moodle')+'
');this.button=Y.Node.create('
').set('disabled',filtervalue=='');this.div.append(this.label).append(this.input).append(this.button);this.table.ancestor().insert(this.div,this.table);this.input.on('keyup',this.change,this);this.button.on('click',this.clear,this);if(filtervalue!=''){this.filter()}},setFilterCookieValue:function(value){var cookie={fltcontext:this.context,flttime:new Date().getTime(),fltvalue:value} Y.Cookie.setSubs("captblflt",cookie)},getFilterCookieValue:function(){var cookie=Y.Cookie.getSubs('captblflt');if(cookie!=null&&cookie.fltcontext&&cookie.fltcontext==this.context&&parseInt(cookie.flttime)>new Date().getTime()-(60*60*1000)){return cookie.fltvalue} return ''},clear:function(){this.input.set('value','');if(this.delayhandle!=-1){clearTimeout(this.delayhandle);this.delayhandle=-1} this.filter()},change:function(){var self=this;var handle=setTimeout(function(){self.filter()},this.searchdelay);if(this.delayhandle!=-1){clearTimeout(this.delayhandle)} this.delayhandle=handle},setVisible:function(row,visible){if(visible){row.removeClass('hiddenrow')}else{row.addClass('hiddenrow')}},filter:function(){var filtertext=this.input.get('value').toLowerCase(),lastheading=null;this.setFilterCookieValue(filtertext);this.button.set('disabled',(filtertext==''));this.table.all('tr').each(function(row){if(row.hasClass('rolecapheading')){this.setVisible(row,!1);lastheading=row} if(row.hasClass('rolecap')){var capname=row.one('.cap-name').get('text')+'|'+row.one('.cap-desc a').get('text').toLowerCase();if(capname.indexOf(filtertext)>=0){this.setVisible(row,!0);if(lastheading){this.setVisible(lastheading,!0);lastheading=null}}else{this.setVisible(row,!1)}}},this)}} new CapTableFilter(tableid)};M.core_role.init_add_assign_page=function(Y){var add=Y.one('#add');var addselect=M.core_user.get_user_selector('addselect');add.set('disabled',addselect.is_selection_empty());addselect.on('user_selector:selectionchanged',function(isempty){add.set('disabled',isempty)});var remove=Y.one('#remove');var removeselect=M.core_user.get_user_selector('removeselect');remove.set('disabled',removeselect.is_selection_empty());removeselect.on('user_selector:selectionchanged',function(isempty){remove.set('disabled',isempty)})}