diff --git a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-debug.js b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-debug.js index 8b0224aaf10..cdd69fbd6ba 100644 --- a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-debug.js +++ b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-debug.js @@ -1,26 +1,51 @@ YUI.add('moodle-gradereport_history-userselector', function (Y, NAME) { +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * The User Selector for the grade history report. + * + * @module moodle-gradereport_history-userselector + * @package gradereport_history + * @copyright 2013 NetSpot Pty Ltd (https://www.netspot.com.au) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @main moodle-gradereport_history-userselector + */ + +/** + * @module moodle-gradereport_history-userselector + */ + var COMPONENT = 'gradereport_history'; var USP = { NAME : 'User Selector Manager', - /** Properties **/ BASE : 'base', SEARCH : 'search', SEARCHBTN : 'searchbtn', PARAMS : 'params', URL : 'url', AJAXURL : 'ajaxurl', - MULTIPLE : 'multiple', PAGE : 'page', COURSEID : 'courseid', SELECTEDUSERS : 'selectedusers', USERFULLNAMES : 'userfullnames', USERS : 'users', USERCOUNT : 'userCount', - LASTSEARCH : 'lastPreSearchValue', PERPAGE : 'perPage' }; -/** CSS classes for nodes in structure **/ var CSS = { ACCESSHIDE : 'accesshide', AJAXCONTENT : 'usp-ajax-content', @@ -78,14 +103,46 @@ var SELECTORS = { }; var create = Y.Node.create; +/** + * User Selector. + * + * @namespace M.gradereport_history + * @class UserSelector + * @constructor + */ + var USERSELECTOR = function() { USERSELECTOR.superclass.constructor.apply(this, arguments); }; Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Base, { - _searchTimeout : null, + + /** + * The loading node. + * + * @property _loadingNode + * @type Node + * @private + */ _loadingNode : null, + + /** + * The Escape key close event. + * + * @property _escCloseEvent + * @type Event + * @private + */ _escCloseEvent : null, + + /** + * Compiled template function for a user node. + * + * @property _userTemplate + * @type Function + * @private + */ _userTemplate : null, + initializer : function() { var list, params, @@ -164,9 +221,21 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas base.one(SELECTORS.HEADING).setStyle('cursor', 'move'); }, + + /** + * Before the search starts. + * + * @method preSearch + */ preSearch : function(e) { this.search(null, false); }, + + /** + * Display the dialogue. + * + * @method show + */ show : function(e) { e.preventDefault(); e.halt(); @@ -186,6 +255,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas this._escCloseEvent = Y.on('key', this.hide, document.body, 'down:27', this); }, + + /** + * Hide the dialogue. + * + * @method hide + */ hide : function(e) { if (this._escCloseEvent) { this._escCloseEvent.detach(); @@ -193,6 +268,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } this.get(USP.BASE).addClass(CSS.HIDDEN); }, + + /** + * Search for users. + * + * @method search + */ search : function(e, append) { if (e) { e.halt(); @@ -226,12 +307,30 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } }); }, + + /** + * Display the loading info. + * + * @method displayLoading + */ displayLoading : function() { this._loadingNode.removeClass(CSS.HIDDEN); }, + + /** + * Hide the loading info. + * + * @method removeLoading + */ removeLoading : function() { this._loadingNode.addClass(CSS.HIDDEN); }, + + /** + * Process and display the search results. + * + * @method processSearchResults + */ processSearchResults : function(tid, outcome, args) { var result = false, users, @@ -331,6 +430,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } } }, + + /** + * Deselect a user. + * + * @method deselectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ deselectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); var list = this.get(USP.SELECTEDUSERS); @@ -350,6 +457,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas user.removeClass(CSS.SELECTED); }, + + /** + * Select a user. + * + * @method SelectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ selectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); @@ -367,9 +482,22 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas Y.one(SELECTORS.USERIDS).set('value', list.join()); user.addClass(CSS.SELECTED); }, + + /** + * Set the content of the dialogue. + * + * @method setContent + * @param {String} content The content. + */ setContent: function(content) { this.get(USP.BASE).one(SELECTORS.AJAXCONTENT).setContent(content); }, + + /** + * Display the names of the selected users in the form. + * + * @method setnamedisplay + */ setnamedisplay: function() { var namelist = this.get(USP.USERFULLNAMES); namelist = namelist.filter(function(x) { @@ -381,12 +509,33 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas }, { NAME : USP.NAME, ATTRS : { + + /** + * The current page URL. + * + * @attribute url + * @type String + */ url : { validator : Y.Lang.isString }, + + /** + * The URL to the Ajax file. + * + * @attribute ajaxurl + * @type String + */ ajaxurl : { validator : Y.Lang.isString }, + + /** + * The dialogue. + * + * @attribute base + * @type Node + */ base : { setter : function(node) { var n = Y.one(node); @@ -396,41 +545,89 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, + + /** + * The initial list of users. + * + * @attribute userfullnames + * @type Object + */ users : { validator : Y.Lang.isArray, value : null }, + + /** + * IDs of the selected users. + * + * @attribute selectedusers + * @type Array + */ selectedusers : { validator : Y.Lang.isArray, value : null }, + + /** + * The names of the selected users. + * + * @attribute userfullnames + * @type Object + */ userfullnames : { validator : Y.Lang.isObject, value : null }, + + /** + * The course ID. + * + * @attribute courseid + * @type Number + */ courseid : { value : null }, + + /** + * Array of parameters. + * + * @attribute params + * @type Array + */ params : { validator : Y.Lang.isArray, value : [] }, - multiple : { - validator : Y.Lang.isBool, - value : false - }, + + /** + * The page we are on. + * + * @attribute page + * @type Number + */ page : { validator : Y.Lang.isNumber, value : 0 }, + + /** + * The number of users displayed. + * + * @attribute userCount + * @type Number + */ userCount : { value : 0, validator : Y.Lang.isNumber }, - requiresRefresh : { - value : false, - validator : Y.Lang.isBool - }, + + /** + * The search field. + * + * @attribute search + * @type Node + */ search : { setter : function(node) { var n = Y.one(node); @@ -440,14 +637,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, - lastPreSearchValue : { - value : '', - validator : Y.Lang.isString - }, - strings : { - value : {}, - validator : Y.Lang.isObject - }, + + /** + * The number of results per page. + * + * @attribute perPage + * @type Number + */ perPage : { value: 25, Validator: Y.Lang.isNumber diff --git a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-min.js b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-min.js index 6fa133c95cd..6b483b7d534 100644 --- a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-min.js +++ b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector-min.js @@ -1,2 +1,2 @@ -YUI.add("moodle-gradereport_history-userselector",function(e,t){var n="gradereport_history",r={NAME:"User Selector Manager",BASE:"base",SEARCH:"search",SEARCHBTN:"searchbtn",PARAMS:"params",URL:"url",AJAXURL:"ajaxurl",MULTIPLE:"multiple",PAGE:"page",COURSEID:"courseid",SELECTEDUSERS:"selectedusers",USERFULLNAMES:"userfullnames",USERS:"users",USERCOUNT:"userCount",LASTSEARCH:"lastPreSearchValue",PERPAGE:"perPage"},i={ACCESSHIDE:"accesshide",AJAXCONTENT:"usp-ajax-content",CLOSE:"close",CLOSEBTN:"close-button",CONTENT:"usp-content",COUNT:"count",DESELECT:"deselect",DETAILS:"details",EVEN:"even",EXTRAFIELDS:"extrafields",FOOTER:"usp-footer",FULLNAME:"fullname",HEADER:"usp-header",HIDDEN:"hidden",LIGHTBOX:"usp-loading-lightbox",LOADINGICON:"loading-icon",MORERESULTS:"usp-more-results",ODD:"odd",OPTIONS:"options",PANEL:"user-selector-panel",PICTURE:"picture",SEARCH:"usp-search",SEARCHBTN:"usp-search-btn",SEARCHFIELD:"usp-search-field",SEARCHRESULTS:"usp-search-results",SELECT:"select",SELECTED:"selected",TOTALUSERS:"totalusers",USER:"user",USERS:"users",WRAP:"usp-wrap"},s={AJAXCONTENT:"."+i.CONTENT+" ."+i.AJAXCONTENT,DESELECT:"."+i.DESELECT,FOOTERCLOSE:"."+i.FOOTER+" ."+i.CLOSEBTN+" input",FULLNAME:"."+i.FULLNAME,HEADERCLOSE:"."+i.HEADER+" ."+i.CLOSE,HEADING:"."+i.HEADER+" h2",LIGHTBOX:"."+i.CONTENT+" ."+i.LIGHTBOX,MORERESULTS:"."+i.MORERESULTS,OPTIONS:"."+i.OPTIONS,RESULTSUSERS:"."+i.SEARCHRESULTS+" ."+i.USERS,SEARCHBTN:"."+i.SEARCHBTN,SEARCHFIELD:"."+i.SEARCHFIELD,SELECT:"."+i.SELECT,SELECTEDNAMES:".felement .selectednames",TRIGGER:".gradereport_history_plugin input.selectortrigger",USER:"."+i.USER,USERDESELECT:"."+i.USER+" ."+i.DESELECT,USERFULLNAMES:'input[name="userfullnames"]',USERIDS:'input[name="userids"]',USERSELECT:"."+i.USER+" ."+i.SELECT},o=e.Node.create,u=function(){u.superclass.constructor.apply(this,arguments)};e.namespace("M.gradereport_history").UserSelector=e.extend(u,e.Base,{_searchTimeout:null,_loadingNode:null,_escCloseEvent:null,_userTemplate:null,initializer:function(){var t,u,a;a=e.Handlebars.compile('

{{get_string "selectuser" COMPONENT}}

{{get_string
'),this.set(r.BASE,o(a({COMPONENT:n,CSS:i,loadingIcon:M.util.image_url("i/loading","moodle")}))),this.set(r.SEARCH,this.get(r.BASE).one(s.SEARCHFIELD)),this.set(r.SEARCHBTN,this.get(r.BASE).one(s.SEARCHBTN)),t=e.one(s.USERIDS).get("value").split(","),t[0]===""&&(t=[]),this.set(r.SELECTEDUSERS,t),t=[],this.get(r.USERFULLNAMES)!==null&&e.each(this.get(r.USERFULLNAMES),function(e,n){t[n]=e}),this.set(r.USERFULLNAMES,t),e.one(s.TRIGGER).on("click",this.show,this),this.get(r.BASE).one(s.HEADERCLOSE).on("click",this.hide,this),this.get(r.BASE).one(s.FOOTERCLOSE).on("click",this.hide,this),this._loadingNode=this.get(r.BASE).one(s.LIGHTBOX),u=this.get(r.PARAMS),u.id=this.get(r.COURSEID),this.set(r.PARAMS,u),e.on("key",this.preSearch,this.get(r.SEARCH),"down:13",this),this.get(r.SEARCHBTN).on("click",this.preSearch,this),e.one(document.body).append(this.get(r.BASE));var f=this.get(r.BASE);f.plug(e.Plugin.Drag),f.dd.addHandle(s.HEADING),f.one(s.HEADING).setStyle("cursor","move")},preSearch:function(e){this.search(null,!1)},show:function(t){t.preventDefault(),t.halt();var n=this.get(r.BASE);n.removeClass(i.HIDDEN);var s=(n.get("winWidth")-400)/2,o=(parseInt(n.get("winHeight"),10)-n.get("offsetHeight"))/2+parseInt(n.get("docScrollY"),10);o'),this._userTemplate||(this._userTemplate=e.Handlebars.compile('
{{count}}
{{{picture}}}
{{fullname}}
{{extrafields}}
' -)),c=this._userTemplate,h=this.get(r.USERCOUNT),p="";for(d in f.response.users)h++,user=f.response.users[d],this.get(r.SELECTEDUSERS).indexOf(user.userid)>=0?p=" "+i.SELECTED:p="",y=o(c({COMPONENT:n,count:h,CSS:i,extrafields:user.extrafields,fullname:user.fullname,picture:user.picture,selected:p,userId:user.userid})),l.append(y);this.set(r.USERCOUNT,h),a.append?f.response.totalusers<=(this.get(r.PAGE)+1)*this.get(r.PERPAGE)&&this.get(r.BASE).one(s.MORERESULTS).remove():(f.response.totalusers=="1"?b=M.util.get_string("ajaxoneuserfound","enrol"):b=M.util.get_string("ajaxxusersfound","enrol",f.response.totalusers),w=o('
').append(o('
'+b+"
")).append(l),f.response.totalusers>(this.get(r.PAGE)+1)*this.get(r.PERPAGE)&&(E=o('"),E.on("click",this.search,this,!0),w.append(E)),this.setContent(w),e.delegate("click",this.selectUser,l,s.USERSELECT,this,a),e.delegate("click",this.deselectUser,l,s.USERDESELECT,this,a))},deselectUser:function(t,n){var o=t.currentTarget.ancestor(s.USER),u=this.get(r.SELECTEDUSERS),a=u.indexOf(o.getData("userid"));a!=-1&&u.splice(a,1),this.set(r.SELECTEDUSERS,u),e.one(s.USERIDS).set("value",u.join());var f=this.get(r.USERFULLNAMES);delete f[o.getData("userid")],this.set(r.USERFULLNAMES,f),this.setnamedisplay(),o.removeClass(i.SELECTED)},selectUser:function(t,n){var o=t.currentTarget.ancestor(s.USER),u=this.get(r.SELECTEDUSERS);u.push(o.getData("userid")),this.set(r.SELECTEDUSERS,u);var a=o.one(s.FULLNAME).get("innerHTML"),f=this.get(r.USERFULLNAMES);f[o.getData("userid")]=a,this.set(r.USERFULLNAMES,f),this.setnamedisplay(),e.one(s.USERIDS).set("value",u.join()),o.addClass(i.SELECTED)},setContent:function(e){this.get(r.BASE).one(s.AJAXCONTENT).setContent(e)},setnamedisplay:function(){var t=this.get(r.USERFULLNAMES);t=t.filter(function(e){return e}),e.one(s.SELECTEDNAMES).set("innerHTML",t.join(", ")),e.one(s.USERFULLNAMES).set("value",t.join())}},{NAME:r.NAME,ATTRS:{url:{validator:e.Lang.isString},ajaxurl:{validator:e.Lang.isString},base:{setter:function(t){var n=e.one(t);return n||e.fail(r.NAME+": invalid base node set"),n}},users:{validator:e.Lang.isArray,value:null},selectedusers:{validator:e.Lang.isArray,value:null},userfullnames:{validator:e.Lang.isObject,value:null},courseid:{value:null},params:{validator:e.Lang.isArray,value:[]},multiple:{validator:e.Lang.isBool,value:!1},page:{validator:e.Lang.isNumber,value:0},userCount:{value:0,validator:e.Lang.isNumber},requiresRefresh:{value:!1,validator:e.Lang.isBool},search:{setter:function(t){var n=e.one(t);return n||e.fail(r.NAME+": invalid search node set"),n}},lastPreSearchValue:{value:"",validator:e.Lang.isString},strings:{value:{},validator:e.Lang.isObject},perPage:{value:25,Validator:e.Lang.isNumber}}}),e.augment(e.namespace("M.gradereport_history").UserSelector,e.EventTarget),e.namespace("M.gradereport_history.UserSelector").init=function(e){return new u(e)}},"@VERSION@",{requires:["dd-plugin","escape","event-delegate","event-key","handlebars","io-base","json-parse","moodle-core-notification-dialogue","overlay"]}); +YUI.add("moodle-gradereport_history-userselector",function(e,t){var n="gradereport_history",r={NAME:"User Selector Manager",BASE:"base",SEARCH:"search",SEARCHBTN:"searchbtn",PARAMS:"params",URL:"url",AJAXURL:"ajaxurl",PAGE:"page",COURSEID:"courseid",SELECTEDUSERS:"selectedusers",USERFULLNAMES:"userfullnames",USERS:"users",USERCOUNT:"userCount",PERPAGE:"perPage"},i={ACCESSHIDE:"accesshide",AJAXCONTENT:"usp-ajax-content",CLOSE:"close",CLOSEBTN:"close-button",CONTENT:"usp-content",COUNT:"count",DESELECT:"deselect",DETAILS:"details",EVEN:"even",EXTRAFIELDS:"extrafields",FOOTER:"usp-footer",FULLNAME:"fullname",HEADER:"usp-header",HIDDEN:"hidden",LIGHTBOX:"usp-loading-lightbox",LOADINGICON:"loading-icon",MORERESULTS:"usp-more-results",ODD:"odd",OPTIONS:"options",PANEL:"user-selector-panel",PICTURE:"picture",SEARCH:"usp-search",SEARCHBTN:"usp-search-btn",SEARCHFIELD:"usp-search-field",SEARCHRESULTS:"usp-search-results",SELECT:"select",SELECTED:"selected",TOTALUSERS:"totalusers",USER:"user",USERS:"users",WRAP:"usp-wrap"},s={AJAXCONTENT:"."+i.CONTENT+" ."+i.AJAXCONTENT,DESELECT:"."+i.DESELECT,FOOTERCLOSE:"."+i.FOOTER+" ."+i.CLOSEBTN+" input",FULLNAME:"."+i.FULLNAME,HEADERCLOSE:"."+i.HEADER+" ."+i.CLOSE,HEADING:"."+i.HEADER+" h2",LIGHTBOX:"."+i.CONTENT+" ."+i.LIGHTBOX,MORERESULTS:"."+i.MORERESULTS,OPTIONS:"."+i.OPTIONS,RESULTSUSERS:"."+i.SEARCHRESULTS+" ."+i.USERS,SEARCHBTN:"."+i.SEARCHBTN,SEARCHFIELD:"."+i.SEARCHFIELD,SELECT:"."+i.SELECT,SELECTEDNAMES:".felement .selectednames",TRIGGER:".gradereport_history_plugin input.selectortrigger",USER:"."+i.USER,USERDESELECT:"."+i.USER+" ."+i.DESELECT,USERFULLNAMES:'input[name="userfullnames"]',USERIDS:'input[name="userids"]',USERSELECT:"."+i.USER+" ."+i.SELECT},o=e.Node.create,u=function(){u.superclass.constructor.apply(this,arguments)};e.namespace("M.gradereport_history").UserSelector=e.extend(u,e.Base,{_loadingNode:null,_escCloseEvent:null,_userTemplate:null,initializer:function(){var t,u,a;a=e.Handlebars.compile('

{{get_string "selectuser" COMPONENT}}

{{get_string
'),this.set(r.BASE,o(a({COMPONENT:n,CSS:i,loadingIcon:M.util.image_url("i/loading","moodle")}))),this.set(r.SEARCH,this.get(r.BASE).one(s.SEARCHFIELD)),this.set(r.SEARCHBTN,this.get(r.BASE).one(s.SEARCHBTN)),t=e.one(s.USERIDS).get("value").split(","),t[0]===""&&(t=[]),this.set(r.SELECTEDUSERS,t),t=[],this.get(r.USERFULLNAMES)!==null&&e.each(this.get(r.USERFULLNAMES),function(e,n){t[n]=e}),this.set(r.USERFULLNAMES,t),e.one(s.TRIGGER).on("click",this.show,this),this.get(r.BASE).one(s.HEADERCLOSE).on("click",this.hide,this),this.get(r.BASE).one(s.FOOTERCLOSE).on("click",this.hide,this),this._loadingNode=this.get(r.BASE).one(s.LIGHTBOX),u=this.get(r.PARAMS),u.id=this.get(r.COURSEID),this.set(r.PARAMS,u),e.on("key",this.preSearch,this.get(r.SEARCH),"down:13",this),this.get(r.SEARCHBTN).on("click",this.preSearch,this),e.one(document.body).append(this.get(r.BASE));var f=this.get(r.BASE);f.plug(e.Plugin.Drag),f.dd.addHandle(s.HEADING),f.one(s.HEADING).setStyle("cursor","move")},preSearch:function(e){this.search(null,!1)},show:function(t){t.preventDefault(),t.halt();var n=this.get(r.BASE);n.removeClass(i.HIDDEN);var s=(n.get("winWidth")-400)/2,o=(parseInt(n.get("winHeight"),10)-n.get("offsetHeight"))/2+parseInt(n.get("docScrollY"),10);o'),this._userTemplate||(this._userTemplate=e.Handlebars.compile('
{{count}}
{{{picture}}}
{{fullname}}
{{extrafields}}
')),c=this._userTemplate +,h=this.get(r.USERCOUNT),p="";for(d in f.response.users)h++,user=f.response.users[d],this.get(r.SELECTEDUSERS).indexOf(user.userid)>=0?p=" "+i.SELECTED:p="",y=o(c({COMPONENT:n,count:h,CSS:i,extrafields:user.extrafields,fullname:user.fullname,picture:user.picture,selected:p,userId:user.userid})),l.append(y);this.set(r.USERCOUNT,h),a.append?f.response.totalusers<=(this.get(r.PAGE)+1)*this.get(r.PERPAGE)&&this.get(r.BASE).one(s.MORERESULTS).remove():(f.response.totalusers=="1"?b=M.util.get_string("ajaxoneuserfound","enrol"):b=M.util.get_string("ajaxxusersfound","enrol",f.response.totalusers),w=o('
').append(o('
'+b+"
")).append(l),f.response.totalusers>(this.get(r.PAGE)+1)*this.get(r.PERPAGE)&&(E=o('"),E.on("click",this.search,this,!0),w.append(E)),this.setContent(w),e.delegate("click",this.selectUser,l,s.USERSELECT,this,a),e.delegate("click",this.deselectUser,l,s.USERDESELECT,this,a))},deselectUser:function(t,n){var o=t.currentTarget.ancestor(s.USER),u=this.get(r.SELECTEDUSERS),a=u.indexOf(o.getData("userid"));a!=-1&&u.splice(a,1),this.set(r.SELECTEDUSERS,u),e.one(s.USERIDS).set("value",u.join());var f=this.get(r.USERFULLNAMES);delete f[o.getData("userid")],this.set(r.USERFULLNAMES,f),this.setnamedisplay(),o.removeClass(i.SELECTED)},selectUser:function(t,n){var o=t.currentTarget.ancestor(s.USER),u=this.get(r.SELECTEDUSERS);u.push(o.getData("userid")),this.set(r.SELECTEDUSERS,u);var a=o.one(s.FULLNAME).get("innerHTML"),f=this.get(r.USERFULLNAMES);f[o.getData("userid")]=a,this.set(r.USERFULLNAMES,f),this.setnamedisplay(),e.one(s.USERIDS).set("value",u.join()),o.addClass(i.SELECTED)},setContent:function(e){this.get(r.BASE).one(s.AJAXCONTENT).setContent(e)},setnamedisplay:function(){var t=this.get(r.USERFULLNAMES);t=t.filter(function(e){return e}),e.one(s.SELECTEDNAMES).set("innerHTML",t.join(", ")),e.one(s.USERFULLNAMES).set("value",t.join())}},{NAME:r.NAME,ATTRS:{url:{validator:e.Lang.isString},ajaxurl:{validator:e.Lang.isString},base:{setter:function(t){var n=e.one(t);return n||e.fail(r.NAME+": invalid base node set"),n}},users:{validator:e.Lang.isArray,value:null},selectedusers:{validator:e.Lang.isArray,value:null},userfullnames:{validator:e.Lang.isObject,value:null},courseid:{value:null},params:{validator:e.Lang.isArray,value:[]},page:{validator:e.Lang.isNumber,value:0},userCount:{value:0,validator:e.Lang.isNumber},search:{setter:function(t){var n=e.one(t);return n||e.fail(r.NAME+": invalid search node set"),n}},perPage:{value:25,Validator:e.Lang.isNumber}}}),e.augment(e.namespace("M.gradereport_history").UserSelector,e.EventTarget),e.namespace("M.gradereport_history.UserSelector").init=function(e){return new u(e)}},"@VERSION@",{requires:["dd-plugin","escape","event-delegate","event-key","handlebars","io-base","json-parse","moodle-core-notification-dialogue","overlay"]}); diff --git a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector.js b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector.js index 8b0224aaf10..cdd69fbd6ba 100644 --- a/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector.js +++ b/grade/report/history/yui/build/moodle-gradereport_history-userselector/moodle-gradereport_history-userselector.js @@ -1,26 +1,51 @@ YUI.add('moodle-gradereport_history-userselector', function (Y, NAME) { +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * The User Selector for the grade history report. + * + * @module moodle-gradereport_history-userselector + * @package gradereport_history + * @copyright 2013 NetSpot Pty Ltd (https://www.netspot.com.au) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @main moodle-gradereport_history-userselector + */ + +/** + * @module moodle-gradereport_history-userselector + */ + var COMPONENT = 'gradereport_history'; var USP = { NAME : 'User Selector Manager', - /** Properties **/ BASE : 'base', SEARCH : 'search', SEARCHBTN : 'searchbtn', PARAMS : 'params', URL : 'url', AJAXURL : 'ajaxurl', - MULTIPLE : 'multiple', PAGE : 'page', COURSEID : 'courseid', SELECTEDUSERS : 'selectedusers', USERFULLNAMES : 'userfullnames', USERS : 'users', USERCOUNT : 'userCount', - LASTSEARCH : 'lastPreSearchValue', PERPAGE : 'perPage' }; -/** CSS classes for nodes in structure **/ var CSS = { ACCESSHIDE : 'accesshide', AJAXCONTENT : 'usp-ajax-content', @@ -78,14 +103,46 @@ var SELECTORS = { }; var create = Y.Node.create; +/** + * User Selector. + * + * @namespace M.gradereport_history + * @class UserSelector + * @constructor + */ + var USERSELECTOR = function() { USERSELECTOR.superclass.constructor.apply(this, arguments); }; Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Base, { - _searchTimeout : null, + + /** + * The loading node. + * + * @property _loadingNode + * @type Node + * @private + */ _loadingNode : null, + + /** + * The Escape key close event. + * + * @property _escCloseEvent + * @type Event + * @private + */ _escCloseEvent : null, + + /** + * Compiled template function for a user node. + * + * @property _userTemplate + * @type Function + * @private + */ _userTemplate : null, + initializer : function() { var list, params, @@ -164,9 +221,21 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas base.one(SELECTORS.HEADING).setStyle('cursor', 'move'); }, + + /** + * Before the search starts. + * + * @method preSearch + */ preSearch : function(e) { this.search(null, false); }, + + /** + * Display the dialogue. + * + * @method show + */ show : function(e) { e.preventDefault(); e.halt(); @@ -186,6 +255,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas this._escCloseEvent = Y.on('key', this.hide, document.body, 'down:27', this); }, + + /** + * Hide the dialogue. + * + * @method hide + */ hide : function(e) { if (this._escCloseEvent) { this._escCloseEvent.detach(); @@ -193,6 +268,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } this.get(USP.BASE).addClass(CSS.HIDDEN); }, + + /** + * Search for users. + * + * @method search + */ search : function(e, append) { if (e) { e.halt(); @@ -226,12 +307,30 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } }); }, + + /** + * Display the loading info. + * + * @method displayLoading + */ displayLoading : function() { this._loadingNode.removeClass(CSS.HIDDEN); }, + + /** + * Hide the loading info. + * + * @method removeLoading + */ removeLoading : function() { this._loadingNode.addClass(CSS.HIDDEN); }, + + /** + * Process and display the search results. + * + * @method processSearchResults + */ processSearchResults : function(tid, outcome, args) { var result = false, users, @@ -331,6 +430,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } } }, + + /** + * Deselect a user. + * + * @method deselectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ deselectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); var list = this.get(USP.SELECTEDUSERS); @@ -350,6 +457,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas user.removeClass(CSS.SELECTED); }, + + /** + * Select a user. + * + * @method SelectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ selectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); @@ -367,9 +482,22 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas Y.one(SELECTORS.USERIDS).set('value', list.join()); user.addClass(CSS.SELECTED); }, + + /** + * Set the content of the dialogue. + * + * @method setContent + * @param {String} content The content. + */ setContent: function(content) { this.get(USP.BASE).one(SELECTORS.AJAXCONTENT).setContent(content); }, + + /** + * Display the names of the selected users in the form. + * + * @method setnamedisplay + */ setnamedisplay: function() { var namelist = this.get(USP.USERFULLNAMES); namelist = namelist.filter(function(x) { @@ -381,12 +509,33 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas }, { NAME : USP.NAME, ATTRS : { + + /** + * The current page URL. + * + * @attribute url + * @type String + */ url : { validator : Y.Lang.isString }, + + /** + * The URL to the Ajax file. + * + * @attribute ajaxurl + * @type String + */ ajaxurl : { validator : Y.Lang.isString }, + + /** + * The dialogue. + * + * @attribute base + * @type Node + */ base : { setter : function(node) { var n = Y.one(node); @@ -396,41 +545,89 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, + + /** + * The initial list of users. + * + * @attribute userfullnames + * @type Object + */ users : { validator : Y.Lang.isArray, value : null }, + + /** + * IDs of the selected users. + * + * @attribute selectedusers + * @type Array + */ selectedusers : { validator : Y.Lang.isArray, value : null }, + + /** + * The names of the selected users. + * + * @attribute userfullnames + * @type Object + */ userfullnames : { validator : Y.Lang.isObject, value : null }, + + /** + * The course ID. + * + * @attribute courseid + * @type Number + */ courseid : { value : null }, + + /** + * Array of parameters. + * + * @attribute params + * @type Array + */ params : { validator : Y.Lang.isArray, value : [] }, - multiple : { - validator : Y.Lang.isBool, - value : false - }, + + /** + * The page we are on. + * + * @attribute page + * @type Number + */ page : { validator : Y.Lang.isNumber, value : 0 }, + + /** + * The number of users displayed. + * + * @attribute userCount + * @type Number + */ userCount : { value : 0, validator : Y.Lang.isNumber }, - requiresRefresh : { - value : false, - validator : Y.Lang.isBool - }, + + /** + * The search field. + * + * @attribute search + * @type Node + */ search : { setter : function(node) { var n = Y.one(node); @@ -440,14 +637,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, - lastPreSearchValue : { - value : '', - validator : Y.Lang.isString - }, - strings : { - value : {}, - validator : Y.Lang.isObject - }, + + /** + * The number of results per page. + * + * @attribute perPage + * @type Number + */ perPage : { value: 25, Validator: Y.Lang.isNumber diff --git a/grade/report/history/yui/src/userselector/js/userselector.js b/grade/report/history/yui/src/userselector/js/userselector.js index b7a58b83c86..741e8257e7b 100644 --- a/grade/report/history/yui/src/userselector/js/userselector.js +++ b/grade/report/history/yui/src/userselector/js/userselector.js @@ -1,24 +1,49 @@ +// This file is part of Moodle - http://moodle.org/ +// +// Moodle is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Moodle is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Moodle. If not, see . + +/** + * The User Selector for the grade history report. + * + * @module moodle-gradereport_history-userselector + * @package gradereport_history + * @copyright 2013 NetSpot Pty Ltd (https://www.netspot.com.au) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @main moodle-gradereport_history-userselector + */ + +/** + * @module moodle-gradereport_history-userselector + */ + var COMPONENT = 'gradereport_history'; var USP = { NAME : 'User Selector Manager', - /** Properties **/ BASE : 'base', SEARCH : 'search', SEARCHBTN : 'searchbtn', PARAMS : 'params', URL : 'url', AJAXURL : 'ajaxurl', - MULTIPLE : 'multiple', PAGE : 'page', COURSEID : 'courseid', SELECTEDUSERS : 'selectedusers', USERFULLNAMES : 'userfullnames', USERS : 'users', USERCOUNT : 'userCount', - LASTSEARCH : 'lastPreSearchValue', PERPAGE : 'perPage' }; -/** CSS classes for nodes in structure **/ var CSS = { ACCESSHIDE : 'accesshide', AJAXCONTENT : 'usp-ajax-content', @@ -76,14 +101,46 @@ var SELECTORS = { }; var create = Y.Node.create; +/** + * User Selector. + * + * @namespace M.gradereport_history + * @class UserSelector + * @constructor + */ + var USERSELECTOR = function() { USERSELECTOR.superclass.constructor.apply(this, arguments); }; Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Base, { - _searchTimeout : null, + + /** + * The loading node. + * + * @property _loadingNode + * @type Node + * @private + */ _loadingNode : null, + + /** + * The Escape key close event. + * + * @property _escCloseEvent + * @type Event + * @private + */ _escCloseEvent : null, + + /** + * Compiled template function for a user node. + * + * @property _userTemplate + * @type Function + * @private + */ _userTemplate : null, + initializer : function() { var list, params, @@ -162,9 +219,21 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas base.one(SELECTORS.HEADING).setStyle('cursor', 'move'); }, + + /** + * Before the search starts. + * + * @method preSearch + */ preSearch : function(e) { this.search(null, false); }, + + /** + * Display the dialogue. + * + * @method show + */ show : function(e) { e.preventDefault(); e.halt(); @@ -184,6 +253,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas this._escCloseEvent = Y.on('key', this.hide, document.body, 'down:27', this); }, + + /** + * Hide the dialogue. + * + * @method hide + */ hide : function(e) { if (this._escCloseEvent) { this._escCloseEvent.detach(); @@ -191,6 +266,12 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } this.get(USP.BASE).addClass(CSS.HIDDEN); }, + + /** + * Search for users. + * + * @method search + */ search : function(e, append) { if (e) { e.halt(); @@ -224,12 +305,30 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } }); }, + + /** + * Display the loading info. + * + * @method displayLoading + */ displayLoading : function() { this._loadingNode.removeClass(CSS.HIDDEN); }, + + /** + * Hide the loading info. + * + * @method removeLoading + */ removeLoading : function() { this._loadingNode.addClass(CSS.HIDDEN); }, + + /** + * Process and display the search results. + * + * @method processSearchResults + */ processSearchResults : function(tid, outcome, args) { var result = false, users, @@ -329,6 +428,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas } } }, + + /** + * Deselect a user. + * + * @method deselectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ deselectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); var list = this.get(USP.SELECTEDUSERS); @@ -348,6 +455,14 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas user.removeClass(CSS.SELECTED); }, + + /** + * Select a user. + * + * @method SelectUser + * @param {EventFacade} e The event. + * @param {Object} args A list of argments. + */ selectUser : function(e, args) { var user = e.currentTarget.ancestor(SELECTORS.USER); @@ -365,9 +480,22 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas Y.one(SELECTORS.USERIDS).set('value', list.join()); user.addClass(CSS.SELECTED); }, + + /** + * Set the content of the dialogue. + * + * @method setContent + * @param {String} content The content. + */ setContent: function(content) { this.get(USP.BASE).one(SELECTORS.AJAXCONTENT).setContent(content); }, + + /** + * Display the names of the selected users in the form. + * + * @method setnamedisplay + */ setnamedisplay: function() { var namelist = this.get(USP.USERFULLNAMES); namelist = namelist.filter(function(x) { @@ -379,12 +507,33 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas }, { NAME : USP.NAME, ATTRS : { + + /** + * The current page URL. + * + * @attribute url + * @type String + */ url : { validator : Y.Lang.isString }, + + /** + * The URL to the Ajax file. + * + * @attribute ajaxurl + * @type String + */ ajaxurl : { validator : Y.Lang.isString }, + + /** + * The dialogue. + * + * @attribute base + * @type Node + */ base : { setter : function(node) { var n = Y.one(node); @@ -394,41 +543,89 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, + + /** + * The initial list of users. + * + * @attribute userfullnames + * @type Object + */ users : { validator : Y.Lang.isArray, value : null }, + + /** + * IDs of the selected users. + * + * @attribute selectedusers + * @type Array + */ selectedusers : { validator : Y.Lang.isArray, value : null }, + + /** + * The names of the selected users. + * + * @attribute userfullnames + * @type Object + */ userfullnames : { validator : Y.Lang.isObject, value : null }, + + /** + * The course ID. + * + * @attribute courseid + * @type Number + */ courseid : { value : null }, + + /** + * Array of parameters. + * + * @attribute params + * @type Array + */ params : { validator : Y.Lang.isArray, value : [] }, - multiple : { - validator : Y.Lang.isBool, - value : false - }, + + /** + * The page we are on. + * + * @attribute page + * @type Number + */ page : { validator : Y.Lang.isNumber, value : 0 }, + + /** + * The number of users displayed. + * + * @attribute userCount + * @type Number + */ userCount : { value : 0, validator : Y.Lang.isNumber }, - requiresRefresh : { - value : false, - validator : Y.Lang.isBool - }, + + /** + * The search field. + * + * @attribute search + * @type Node + */ search : { setter : function(node) { var n = Y.one(node); @@ -438,14 +635,13 @@ Y.namespace('M.gradereport_history').UserSelector = Y.extend(USERSELECTOR, Y.Bas return n; } }, - lastPreSearchValue : { - value : '', - validator : Y.Lang.isString - }, - strings : { - value : {}, - validator : Y.Lang.isObject - }, + + /** + * The number of results per page. + * + * @attribute perPage + * @type Number + */ perPage : { value: 25, Validator: Y.Lang.isNumber