MDL-69680 lib: Replace deprecated jQuery functions
This commit is contained in:
committed by
Adrian Greeve
parent
bb2179cbb7
commit
98aa5b1ac3
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(b,c){var d=[],e=a(b),f=a(b).data("originaloptionsjson"),g=e.val();a.each(f,function(b,e){return""!==a.trim(c)&&e.label.toLocaleLowerCase().indexOf(c.toLocaleLowerCase())===-1||(a.inArray(e.value,g)>-1||(d.push(e),!0))});var h=new a.Deferred;return h.resolve(d),h.promise()},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.value,label:b.label})}),d},transport:function(a,b,d){this.list(a,b).then(d)["catch"](c.exception)}}});
|
||||
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(b,c){var d=[],e=a(b),f=a(b).data("originaloptionsjson"),g=e.val();a.each(f,function(b,e){return""!==c.trim()&&e.label.toLocaleLowerCase().indexOf(c.toLocaleLowerCase())===-1||(a.inArray(e.value,g)>-1||(d.push(e),!0))});var h=new a.Deferred;return h.resolve(d),h.promise()},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.value,label:b.label})}),d},transport:function(a,b,d){this.list(a,b).then(d)["catch"](c.exception)}}});
|
||||
@@ -41,7 +41,7 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
|
||||
var selectedFilters = el.val();
|
||||
$.each(originalOptions, function(index, option) {
|
||||
// Skip option if it does not contain the query string.
|
||||
if ($.trim(query) !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
|
||||
if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
|
||||
return true;
|
||||
}
|
||||
// Skip filters that have already been selected.
|
||||
|
||||
@@ -1 +1 @@
|
||||
define(["jquery","core/templates","core/notification","core/yui"],function(a,b,c){return{initialise:function(d,e,f,g){function h(b,c){var e="<label>"+M.util.get_string("insertcomment","gradingform_guide")+"</label>",g="comment-chooser-"+d+"-cancel",h='<button id="'+g+'">'+M.util.get_string("cancel","moodle")+"</button>",i=new M.core.dialogue({modal:!0,headerContent:e,bodyContent:b,footerContent:h,focusAfterHide:"#"+f,id:"comments-chooser-dialog-"+d});a("#"+g).click(function(){i.hide()}),a.each(c,function(b,c){var e="#comment-option-"+d+"-"+c.id;a(e).click(function(){var b=a("#"+f),d=b.val();""!==a.trim(d)&&(d+="\n"),d+=c.description,b.val(d),i.hide()}),a(document).off("keypress",e).on("keypress",e,function(){var b=event.which||event.keyCode;13!=b&&32!=b||a(e).click()})}),i.after("visibleChange",function(a){a.prevVal&&!a.newVal&&this.destroy()},i),i.show()}function i(){var a={criterionId:d,comments:g};b.render("gradingform_guide/comment_chooser",a).done(function(a){h(a,g)}).fail(c.exception)}a("#"+e).click(function(a){a.preventDefault(),i()})}}});
|
||||
define(["jquery","core/templates","core/notification","core/yui"],function(a,b,c){return{initialise:function(d,e,f,g){function h(b,c){var e="<label>"+M.util.get_string("insertcomment","gradingform_guide")+"</label>",g="comment-chooser-"+d+"-cancel",h='<button id="'+g+'">'+M.util.get_string("cancel","moodle")+"</button>",i=new M.core.dialogue({modal:!0,headerContent:e,bodyContent:b,footerContent:h,focusAfterHide:"#"+f,id:"comments-chooser-dialog-"+d});a("#"+g).click(function(){i.hide()}),a.each(c,function(b,c){var e="#comment-option-"+d+"-"+c.id;a(e).click(function(){var b=a("#"+f),d=b.val();""!==d.trim()&&(d+="\n"),d+=c.description,b.val(d),i.hide()}),a(document).off("keypress",e).on("keypress",e,function(){var b=event.which||event.keyCode;13!=b&&32!=b||a(e).click()})}),i.after("visibleChange",function(a){a.prevVal&&!a.newVal&&this.destroy()},i),i.show()}function i(){var a={criterionId:d,comments:g};b.render("gradingform_guide/comment_chooser",a).done(function(a){h(a,g)}).fail(c.exception)}a("#"+e).click(function(a){a.preventDefault(),i()})}}});
|
||||
@@ -77,7 +77,7 @@ define(['jquery', 'core/templates', 'core/notification', 'core/yui'], function($
|
||||
var remarkText = remarkTextArea.val();
|
||||
|
||||
// Add line break if the current value of the remark text is not empty.
|
||||
if ($.trim(remarkText) !== '') {
|
||||
if (remarkText.trim() !== '') {
|
||||
remarkText += '\n';
|
||||
}
|
||||
remarkText += comment.description;
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/config","core/notification","core/templates","core/yui"],function(a,b,c,d,e){var f,g,h,i,j={ADDROLE:"a.allowlink, a.prohibitlink",REMOVEROLE:"a.preventlink, a.unprohibitlink",UNPROHIBIT:"a.unprohibitlink"},k=a.Event("rolesloaded"),l=null,m=function(){var d={contextid:f,getroles:1,sesskey:b.sesskey};a.post(h+"roles/ajax.php",d,null,"json").done(function(b){try{i=b,m=function(){a("body").trigger(k)},m()}catch(d){c.exception(d)}}).fail(function(a,b,d){c.exception(d)})},n=function(b,e,g){var j={contextid:f,roleid:e,sesskey:M.cfg.sesskey,action:g,capability:b.data("name")};a.post(h+"roles/ajax.php",j,null,"json").done(function(f){var g=f;try{var j={rolename:i[e],roleid:e,adminurl:h,imageurl:M.util.image_url("t/delete","moodle")};switch(g){case"allow":j.spanclass="allowed",j.linkclass="preventlink",j.action="prevent",j.icon="t/delete";break;case"prohibit":j.spanclass="forbidden",j.linkclass="unprohibitlink",j.action="unprohibit",j.icon="t/delete";break;case"prevent":return void b.find('a[data-role-id="'+e+'"]').first().closest(".allowed").remove();case"unprohibit":return void b.find('a[data-role-id="'+e+'"]').first().closest(".forbidden").remove();default:return}d.render("core/permissionmanager_role",j).done(function(c){if("allow"==g)a(c).insertBefore(b.find(".allowmore:first"));else if("prohibit"==g){a(c).insertBefore(b.find(".prohibitmore:first"));var d=b.find(".allowedroles").first().find('a[data-role-id="'+e+'"]');d&&d.first().closest(".allowed").remove()}l.hide()}).fail(c.exception)}catch(k){c.exception(k)}}).fail(function(a,b,d){c.exception(d)})},o=function(b){b.preventDefault(),e.use("moodle-core-notification-dialogue",function(){a("body").one("rolesloaded",function(){var e=a(b.currentTarget),f=e.data("action"),h=e.closest("tr.rolecap"),k={cap:h.data("humanname"),context:g},m=M.util.get_string("role"+f+"info","core_role",k);null===l&&(l=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,width:"450px"})),l.set("headerContent",M.util.get_string("role"+f+"header","core_role"));var o,p,q=[];switch(f){case"allow":p=h.find(j.REMOVEROLE);break;case"prohibit":p=h.find(j.UNPROHIBIT)}for(o in i){var r="",s=p.filter("[data-role-id='"+o+"']").length;s&&(r="disabled");var t={roleid:o,rolename:i[o],disabled:r};q.push(t)}d.render("core/permissionmanager_panelcontent",{message:m,roles:q}).done(function(b){l.set("bodyContent",b),l.show(),a("div.role_buttons").delegate("input","click",function(b){var c=a(b.currentTarget).data("role-id");n(h,c,f)})}).fail(c.exception)})}),m()},p=function(b){b.preventDefault(),a("body").one("rolesloaded",function(){var d=a(b.currentTarget),e=d.data("action"),f=d.data("role-id"),h=d.closest("tr.rolecap"),j={role:i[f],cap:h.data("humanname"),context:g};c.confirm(M.util.get_string("confirmunassigntitle","core_role"),M.util.get_string("confirmrole"+e,"core_role",j),M.util.get_string("confirmunassignyes","core_role"),M.util.get_string("confirmunassignno","core_role"),function(){n(h,f,e)})}),m()};return{initialize:function(b){f=b.contextid,g=b.contextname,h=b.adminurl;var c=a("body");c.delegate(j.ADDROLE,"click",o),c.delegate(j.REMOVEROLE,"click",p)}}});
|
||||
define(["jquery","core/config","core/notification","core/templates","core/yui"],function(a,b,c,d,e){var f,g,h,i,j={ADDROLE:"a.allowlink, a.prohibitlink",REMOVEROLE:"a.preventlink, a.unprohibitlink",UNPROHIBIT:"a.unprohibitlink"},k=a.Event("rolesloaded"),l=null,m=function(){var d={contextid:f,getroles:1,sesskey:b.sesskey};a.post(h+"roles/ajax.php",d,null,"json").done(function(b){try{i=b,m=function(){a("body").trigger(k)},m()}catch(d){c.exception(d)}}).fail(function(a,b,d){c.exception(d)})},n=function(b,e,g){var j={contextid:f,roleid:e,sesskey:M.cfg.sesskey,action:g,capability:b.data("name")};a.post(h+"roles/ajax.php",j,null,"json").done(function(f){var g=f;try{var j={rolename:i[e],roleid:e,adminurl:h,imageurl:M.util.image_url("t/delete","moodle")};switch(g){case"allow":j.spanclass="allowed",j.linkclass="preventlink",j.action="prevent",j.icon="t/delete";break;case"prohibit":j.spanclass="forbidden",j.linkclass="unprohibitlink",j.action="unprohibit",j.icon="t/delete";break;case"prevent":return void b.find('a[data-role-id="'+e+'"]').first().closest(".allowed").remove();case"unprohibit":return void b.find('a[data-role-id="'+e+'"]').first().closest(".forbidden").remove();default:return}d.render("core/permissionmanager_role",j).done(function(c){if("allow"==g)a(c).insertBefore(b.find(".allowmore").first());else if("prohibit"==g){a(c).insertBefore(b.find(".prohibitmore").first());var d=b.find(".allowedroles").first().find('a[data-role-id="'+e+'"]');d&&d.first().closest(".allowed").remove()}l.hide()}).fail(c.exception)}catch(k){c.exception(k)}}).fail(function(a,b,d){c.exception(d)})},o=function(b){b.preventDefault(),e.use("moodle-core-notification-dialogue",function(){a("body").one("rolesloaded",function(){var e=a(b.currentTarget),f=e.data("action"),h=e.closest("tr.rolecap"),k={cap:h.data("humanname"),context:g},m=M.util.get_string("role"+f+"info","core_role",k);null===l&&(l=new M.core.dialogue({draggable:!0,modal:!0,closeButton:!0,width:"450px"})),l.set("headerContent",M.util.get_string("role"+f+"header","core_role"));var o,p,q=[];switch(f){case"allow":p=h.find(j.REMOVEROLE);break;case"prohibit":p=h.find(j.UNPROHIBIT)}for(o in i){var r="",s=p.filter("[data-role-id='"+o+"']").length;s&&(r="disabled");var t={roleid:o,rolename:i[o],disabled:r};q.push(t)}d.render("core/permissionmanager_panelcontent",{message:m,roles:q}).done(function(b){l.set("bodyContent",b),l.show(),a("div.role_buttons").delegate("input","click",function(b){var c=a(b.currentTarget).data("role-id");n(h,c,f)})}).fail(c.exception)})}),m()},p=function(b){b.preventDefault(),a("body").one("rolesloaded",function(){var d=a(b.currentTarget),e=d.data("action"),f=d.data("role-id"),h=d.closest("tr.rolecap"),j={role:i[f],cap:h.data("humanname"),context:g};c.confirm(M.util.get_string("confirmunassigntitle","core_role"),M.util.get_string("confirmrole"+e,"core_role",j),M.util.get_string("confirmunassignyes","core_role"),M.util.get_string("confirmunassignno","core_role"),function(){n(h,f,e)})}),m()};return{initialize:function(b){f=b.contextid,g=b.contextname,h=b.adminurl;var c=a("body");c.delegate(j.ADDROLE,"click",o),c.delegate(j.REMOVEROLE,"click",p)}}});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery"],function(a){var b=/(\s*\S+|\s)$/,c=/^(\S*)/,d=/\s/,e=function(a,b){if(null==this)throw TypeError();var c=String(a),d=c.length,e=b?Number(b):0;if(e!=e&&(e=0),e<=-1||e>=d)return"";e=0|e;var f,g=c.charCodeAt(e),h=e+1,i=1;return g>=55296&&g<=56319&&d>h&&(f=c.charCodeAt(h),f>=56320&&f<=57343&&(i=2)),i},f=function(a){for(var b=0,c=0;c<a.length;c+=e(a,c))b++;return b},g=function(a,b){if(!a.length)return 0;var c=0,d=0;do c+=e(a,c),d++;while(c<a.length&&d<b);return c};return a.truncate=function(b,c){return a("<div></div>").append(b).truncate(c).html()},a.fn.truncate=function(e){a.isNumeric(e)&&(e={length:e});var h=a.extend({},a.truncate.defaults,e);return this.each(function(){var e=a(this);h.noBreaks&&e.find("br").replaceWith(" ");var i=h.ellipsis.length,j=e.text(),k=f(j),l=k-h.length+i;if(!(k<h.length)){if(h.stripTags&&e.text(j),h.words&&l>0){var m=j.slice(0,g(j,h.length-i)+1),n=m.replace(b,""),o=f(n),p=!m.match(d);l=h.keepFirstWord&&0===o?k-f(c.exec(j)[0])-i:p&&0===o?k-h.length+i:k-o-1}l>k&&(l=k-h.length),l<0||!l&&!h.truncated||a.each(e.contents().get().reverse(),function(b,c){var d=a(c),e=d.text(),j=f(e);if(j<=l)return h.truncated=!0,l-=j,void d.remove();if(3===c.nodeType){var k=j-l;return k=k>=0?g(e,k):0,a(c.splitText(k)).replaceWith(h.ellipsis),!1}return d.truncate(a.extend(h,{length:j-l+i})),!1})}})},a.truncate.defaults={stripTags:!1,words:!1,keepFirstWord:!1,noBreaks:!1,length:1/0,ellipsis:"…"},{truncate:a.truncate}});
|
||||
define(["jquery"],function(a){var b=/(\s*\S+|\s)$/,c=/^(\S*)/,d=/\s/,e=function(a,b){if(null==this)throw TypeError();var c=String(a),d=c.length,e=b?Number(b):0;if(e!=e&&(e=0),e<=-1||e>=d)return"";e=0|e;var f,g=c.charCodeAt(e),h=e+1,i=1;return g>=55296&&g<=56319&&d>h&&(f=c.charCodeAt(h),f>=56320&&f<=57343&&(i=2)),i},f=function(a){for(var b=0,c=0;c<a.length;c+=e(a,c))b++;return b},g=function(a,b){if(!a.length)return 0;var c=0,d=0;do c+=e(a,c),d++;while(c<a.length&&d<b);return c};return a.truncate=function(b,c){return a("<div></div>").append(b).truncate(c).html()},a.fn.truncate=function(e){isNaN(parseFloat(e))||(e={length:e});var h=a.extend({},a.truncate.defaults,e);return this.each(function(){var e=a(this);h.noBreaks&&e.find("br").replaceWith(" ");var i=h.ellipsis.length,j=e.text(),k=f(j),l=k-h.length+i;if(!(k<h.length)){if(h.stripTags&&e.text(j),h.words&&l>0){var m=j.slice(0,g(j,h.length-i)+1),n=m.replace(b,""),o=f(n),p=!m.match(d);l=h.keepFirstWord&&0===o?k-f(c.exec(j)[0])-i:p&&0===o?k-h.length+i:k-o-1}l>k&&(l=k-h.length),l<0||!l&&!h.truncated||a.each(e.contents().get().reverse(),function(b,c){var d=a(c),e=d.text(),j=f(e);if(j<=l)return h.truncated=!0,l-=j,void d.remove();if(3===c.nodeType){var k=j-l;return k=k>=0?g(e,k):0,a(c.splitText(k)).replaceWith(h.ellipsis),!1}return d.truncate(a.extend(h,{length:j-l+i})),!1})}})},a.truncate.defaults={stripTags:!1,words:!1,keepFirstWord:!1,noBreaks:!1,length:1/0,ellipsis:"…"},{truncate:a.truncate}});
|
||||
@@ -37,7 +37,7 @@ define(['jquery', 'core/log', 'core/str', 'core/templates', 'core/notification']
|
||||
UP: 38
|
||||
};
|
||||
|
||||
var uniqueId = $.now();
|
||||
var uniqueId = Date.now();
|
||||
|
||||
/**
|
||||
* Make an item in the selection list "active".
|
||||
|
||||
@@ -124,9 +124,9 @@ define(['jquery', 'core/config', 'core/notification', 'core/templates', 'core/yu
|
||||
templates.render('core/permissionmanager_role', templatedata)
|
||||
.done(function(content) {
|
||||
if (action == 'allow') {
|
||||
$(content).insertBefore(row.find('.allowmore:first'));
|
||||
$(content).insertBefore(row.find('.allowmore').first());
|
||||
} else if (action == 'prohibit') {
|
||||
$(content).insertBefore(row.find('.prohibitmore:first'));
|
||||
$(content).insertBefore(row.find('.prohibitmore').first());
|
||||
// Remove allowed link
|
||||
var allowedLink = row.find('.allowedroles').first().find('a[data-role-id="' + roleid + '"]');
|
||||
if (allowedLink) {
|
||||
|
||||
@@ -118,7 +118,7 @@ define(['jquery'], function($) {
|
||||
|
||||
// Truncate the contents of an element in place.
|
||||
$.fn.truncate = function(options) {
|
||||
if ($.isNumeric(options)) options = {length: options};
|
||||
if (!isNaN(parseFloat(options))) options = {length: options};
|
||||
var o = $.extend({}, $.truncate.defaults, options);
|
||||
|
||||
return this.each(function() {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/log","core/str","core/modal_factory","core/modal_events","core/ajax","core/templates","core/tree"],function(a,b,c,d,e,f,g,h){"use strict";var i=function(c,d,e,f){if(this.elementId=c,this.elementLabel=d,this.onlyTypes=e,this.allowAll=f,this.inputField=a("#"+c),this.wrapperBrowserTrigger=a('[data-filetypesbrowser="'+c+'"]'),this.wrapperDescriptions=a('[data-filetypesdescriptions="'+c+'"]'),this.wrapperBrowserTrigger.length)return this.inputField.length&&this.wrapperDescriptions.length?void this.prepareBrowserTrigger().then(function(){return this.prepareBrowserModal()}.bind(this)).then(function(){return this.prepareBrowserTree()}.bind(this)):void b.error("core_form/filetypes: Unexpected DOM structure, unable to enhance filetypes field "+c)};return i.prototype.prepareBrowserTrigger=function(){return g.render("core_form/filetypes-trigger",{}).then(function(a){this.wrapperBrowserTrigger.html(a),this.browserTrigger=this.wrapperBrowserTrigger.find('[data-filetypeswidget="browsertrigger"]')}.bind(this))},i.prototype.prepareBrowserModal=function(){return d.create({type:d.types.SAVE_CANCEL,title:this.elementLabel}).then(function(a){this.browserModal=a}.bind(this)).then(function(){this.browserModal.getRoot().on(e.hidden,function(){this.browserTrigger.focus()}.bind(this)),this.browserModal.getRoot().on(e.save,function(){this.saveBrowserModal()}.bind(this))}.bind(this))},i.prototype.prepareBrowserTree=function(){return this.browserTrigger.on("click",function(b){if(b.preventDefault(),!this.inputField.is("[disabled]")){var c=this.loadBrowserModalBody();c.then(function(){this.browserTree=new h(this.browserModal.getBody()),this.browserTree.handleKeyDown=function(a,b){b.keyCode==this.browserTree.keys.enter||b.keyCode==this.browserTree.keys.space?(b.preventDefault(),b.stopPropagation(),this.toggleCheckbox(a.attr("data-filetypesbrowserkey"))):h.prototype.handleKeyDown.call(this.browserTree,a,b)}.bind(this),this.allowAll&&(this.hideOrShowItemsDependingOnAllowAll(this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="*"]:first')),this.browserModal.getRoot().on("change",'input[type="checkbox"][data-filetypesbrowserkey="*"]',function(b){this.hideOrShowItemsDependingOnAllowAll(a(b.currentTarget))}.bind(this))),this.browserModal.getRoot().on("change",'input[type="checkbox"][data-filetypesbrowserkey]',function(b){var c=a(b.currentTarget),d=c.attr("data-filetypesbrowserkey");this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="'+d+'"]').prop("checked",c.prop("checked"))}.bind(this))}.bind(this)).then(function(){this.browserModal.show()}.bind(this)),this.browserModal.setBody(c)}}.bind(this)),a.when()},i.prototype.loadBrowserModalBody=function(){var a={onlytypes:this.onlyTypes.join(),allowall:this.allowAll,current:this.inputField.val()};return f.call([{methodname:"core_form_get_filetypes_browser_data",args:a}])[0].then(function(a){return g.render("core_form/filetypes-browser",{elementid:this.elementId,groups:a.groups})}.bind(this))},i.prototype.toggleCheckbox=function(a){var b=this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="'+a+'"]:first');b.prop("checked",!b.prop("checked"))},i.prototype.saveBrowserModal=function(){if(this.allowAll){var b=this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="*"]');if(b.length&&b.prop("checked"))return this.inputField.val("*"),void this.updateDescriptions(["*"])}var c=[];this.browserModal.getRoot().find('input[type="checkbox"]').each(function(){var b=a(this),d=b.attr("data-filetypesbrowserkey");b.prop("checked")&&c.push(d)}),c=c.filter(function(a,b,c){return c.indexOf(a)==b}),this.inputField.val(c.join(" ")),this.updateDescriptions(c)},i.prototype.updateDescriptions=function(a){var b=[];a.forEach(function(a){b.push({description:this.browserModal.getRoot().find('[data-filetypesname="'+a+'"]:first').text().trim(),extensions:this.browserModal.getRoot().find('[data-filetypesextensions="'+a+'"]:first').text().trim()})}.bind(this));var c={hasdescriptions:b.length>0,descriptions:b};return g.render("core_form/filetypes-descriptions",c).then(function(a){this.wrapperDescriptions.html(a)}.bind(this))},i.prototype.hideOrShowItemsDependingOnAllowAll=function(a){var b=this.browserModal.getRoot().find('[role="treeitem"][data-filetypesbrowserkey!="*"]');a.prop("checked")?b.hide():b.show()},{init:function(a,b,c,d){new i(a,b,c,d)}}});
|
||||
define(["jquery","core/log","core/str","core/modal_factory","core/modal_events","core/ajax","core/templates","core/tree"],function(a,b,c,d,e,f,g,h){"use strict";var i=function(c,d,e,f){if(this.elementId=c,this.elementLabel=d,this.onlyTypes=e,this.allowAll=f,this.inputField=a("#"+c),this.wrapperBrowserTrigger=a('[data-filetypesbrowser="'+c+'"]'),this.wrapperDescriptions=a('[data-filetypesdescriptions="'+c+'"]'),this.wrapperBrowserTrigger.length)return this.inputField.length&&this.wrapperDescriptions.length?void this.prepareBrowserTrigger().then(function(){return this.prepareBrowserModal()}.bind(this)).then(function(){return this.prepareBrowserTree()}.bind(this)):void b.error("core_form/filetypes: Unexpected DOM structure, unable to enhance filetypes field "+c)};return i.prototype.prepareBrowserTrigger=function(){return g.render("core_form/filetypes-trigger",{}).then(function(a){this.wrapperBrowserTrigger.html(a),this.browserTrigger=this.wrapperBrowserTrigger.find('[data-filetypeswidget="browsertrigger"]')}.bind(this))},i.prototype.prepareBrowserModal=function(){return d.create({type:d.types.SAVE_CANCEL,title:this.elementLabel}).then(function(a){this.browserModal=a}.bind(this)).then(function(){this.browserModal.getRoot().on(e.hidden,function(){this.browserTrigger.focus()}.bind(this)),this.browserModal.getRoot().on(e.save,function(){this.saveBrowserModal()}.bind(this))}.bind(this))},i.prototype.prepareBrowserTree=function(){return this.browserTrigger.on("click",function(b){if(b.preventDefault(),!this.inputField.is("[disabled]")){var c=this.loadBrowserModalBody();c.then(function(){this.browserTree=new h(this.browserModal.getBody()),this.browserTree.handleKeyDown=function(a,b){b.keyCode==this.browserTree.keys.enter||b.keyCode==this.browserTree.keys.space?(b.preventDefault(),b.stopPropagation(),this.toggleCheckbox(a.attr("data-filetypesbrowserkey"))):h.prototype.handleKeyDown.call(this.browserTree,a,b)}.bind(this),this.allowAll&&(this.hideOrShowItemsDependingOnAllowAll(this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="*"]').first()),this.browserModal.getRoot().on("change",'input[type="checkbox"][data-filetypesbrowserkey="*"]',function(b){this.hideOrShowItemsDependingOnAllowAll(a(b.currentTarget))}.bind(this))),this.browserModal.getRoot().on("change",'input[type="checkbox"][data-filetypesbrowserkey]',function(b){var c=a(b.currentTarget),d=c.attr("data-filetypesbrowserkey");this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="'+d+'"]').prop("checked",c.prop("checked"))}.bind(this))}.bind(this)).then(function(){this.browserModal.show()}.bind(this)),this.browserModal.setBody(c)}}.bind(this)),a.when()},i.prototype.loadBrowserModalBody=function(){var a={onlytypes:this.onlyTypes.join(),allowall:this.allowAll,current:this.inputField.val()};return f.call([{methodname:"core_form_get_filetypes_browser_data",args:a}])[0].then(function(a){return g.render("core_form/filetypes-browser",{elementid:this.elementId,groups:a.groups})}.bind(this))},i.prototype.toggleCheckbox=function(a){var b=this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="'+a+'"]').first();b.prop("checked",!b.prop("checked"))},i.prototype.saveBrowserModal=function(){if(this.allowAll){var b=this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="*"]');if(b.length&&b.prop("checked"))return this.inputField.val("*"),void this.updateDescriptions(["*"])}var c=[];this.browserModal.getRoot().find('input[type="checkbox"]').each(function(){var b=a(this),d=b.attr("data-filetypesbrowserkey");b.prop("checked")&&c.push(d)}),c=c.filter(function(a,b,c){return c.indexOf(a)==b}),this.inputField.val(c.join(" ")),this.updateDescriptions(c)},i.prototype.updateDescriptions=function(a){var b=[];a.forEach(function(a){b.push({description:this.browserModal.getRoot().find('[data-filetypesname="'+a+'"]').first().text().trim(),extensions:this.browserModal.getRoot().find('[data-filetypesextensions="'+a+'"]').first().text().trim()})}.bind(this));var c={hasdescriptions:b.length>0,descriptions:b};return g.render("core_form/filetypes-descriptions",c).then(function(a){this.wrapperDescriptions.html(a)}.bind(this))},i.prototype.hideOrShowItemsDependingOnAllowAll=function(a){var b=this.browserModal.getRoot().find('[role="treeitem"][data-filetypesbrowserkey!="*"]');a.prop("checked")?b.hide():b.show()},{init:function(a,b,c,d){new i(a,b,c,d)}}});
|
||||
@@ -151,7 +151,7 @@ define(['jquery', 'core/log', 'core/str', 'core/modal_factory', 'core/modal_even
|
||||
if (this.allowAll) {
|
||||
// Hide all other items if "All file types" is enabled.
|
||||
this.hideOrShowItemsDependingOnAllowAll(this.browserModal.getRoot()
|
||||
.find('input[type="checkbox"][data-filetypesbrowserkey="*"]:first'));
|
||||
.find('input[type="checkbox"][data-filetypesbrowserkey="*"]').first());
|
||||
// And do the same whenever we click that checkbox.
|
||||
this.browserModal.getRoot().on('change', 'input[type="checkbox"][data-filetypesbrowserkey="*"]', function(e) {
|
||||
this.hideOrShowItemsDependingOnAllowAll($(e.currentTarget));
|
||||
@@ -213,7 +213,7 @@ define(['jquery', 'core/log', 'core/str', 'core/modal_factory', 'core/modal_even
|
||||
*/
|
||||
FileTypes.prototype.toggleCheckbox = function(key) {
|
||||
|
||||
var checkbox = this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="' + key + '"]:first');
|
||||
var checkbox = this.browserModal.getRoot().find('input[type="checkbox"][data-filetypesbrowserkey="' + key + '"]').first();
|
||||
|
||||
checkbox.prop('checked', !checkbox.prop('checked'));
|
||||
};
|
||||
@@ -268,8 +268,8 @@ define(['jquery', 'core/log', 'core/str', 'core/modal_factory', 'core/modal_even
|
||||
|
||||
keys.forEach(function(key) {
|
||||
descriptions.push({
|
||||
description: this.browserModal.getRoot().find('[data-filetypesname="' + key + '"]:first').text().trim(),
|
||||
extensions: this.browserModal.getRoot().find('[data-filetypesextensions="' + key + '"]:first').text().trim()
|
||||
description: this.browserModal.getRoot().find('[data-filetypesname="' + key + '"]').first().text().trim(),
|
||||
extensions: this.browserModal.getRoot().find('[data-filetypesextensions="' + key + '"]').first().text().trim()
|
||||
});
|
||||
}.bind(this));
|
||||
|
||||
|
||||
@@ -16,3 +16,8 @@ Description of import of various jQuery libraries into Moodle:
|
||||
6/ Update the version of jquery in core_privacy\local\request\moodle_content_writer::write_html_data()
|
||||
|
||||
Petr Skoda
|
||||
|
||||
Note: jQuery.trim(), jQuery.isFunction(), jQuery.isNumeric(), jQuery.type(), jQuery.now() functions
|
||||
and :first pseudo-class are deprecated. We use String.prototype.trim() and .first()
|
||||
in Moodle code instead. Please note that in third party libraries there are still usages of jQuery.trim
|
||||
for example xhprof and jQuery UI.
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){var h,i,j={init:function(a,e,j){i=j;var k={url:a,postData:e},l=d.render("mod_lti/contentitem",k);return h?(h.setBody(l),void h.show()):void c.get_string("selectcontent","lti").then(function(a){return f.create({title:a,body:l,large:!0})}).then(function(a){h=a,a.getRoot().on(g.hidden,function(){a.setBody(""),b.fetchNotifications()}),a.show()})["catch"](b.exception)}},k=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0),new e("grade_modgrade_point",e.TYPES.TEXT,(!1),""),new e("cmidnumber",e.TYPES.TEXT,(!0),"")];return window.processContentItemReturnData=function(b){h&&h.hide();var c;for(c in k){var d=k[c],e=null;"undefined"!==a.type(b[d.name])&&(e=b[d.name]),d.setFieldValue(e)}i&&i()},j});
|
||||
define(["jquery","core/notification","core/str","core/templates","mod_lti/form-field","core/modal_factory","core/modal_events"],function(a,b,c,d,e,f,g){var h,i,j={init:function(a,e,j){i=j;var k={url:a,postData:e},l=d.render("mod_lti/contentitem",k);return h?(h.setBody(l),void h.show()):void c.get_string("selectcontent","lti").then(function(a){return f.create({title:a,body:l,large:!0})}).then(function(a){h=a,a.getRoot().on(g.hidden,function(){a.setBody(""),b.fetchNotifications()}),a.show()})["catch"](b.exception)}},k=[new e("name",e.TYPES.TEXT,(!1),""),new e("introeditor",e.TYPES.EDITOR,(!1),""),new e("toolurl",e.TYPES.TEXT,(!0),""),new e("securetoolurl",e.TYPES.TEXT,(!0),""),new e("instructorchoiceacceptgrades",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendname",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorchoicesendemailaddr",e.TYPES.CHECKBOX,(!0),(!0)),new e("instructorcustomparameters",e.TYPES.TEXT,(!0),""),new e("icon",e.TYPES.TEXT,(!0),""),new e("secureicon",e.TYPES.TEXT,(!0),""),new e("launchcontainer",e.TYPES.SELECT,(!0),0),new e("grade_modgrade_point",e.TYPES.TEXT,(!1),""),new e("cmidnumber",e.TYPES.TEXT,(!0),"")];return window.processContentItemReturnData=function(a){h&&h.hide();var b;for(b in k){var c=k[b],d=null;"undefined"!=typeof a[c.name]&&(d=a[c.name]),c.setFieldValue(d)}i&&i()},j});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery"],function(a){var b=function(a,b,c,d){this.name=a,this.id="id_"+this.name,this.selector="#"+this.id,this.type=b,this.resetIfUndefined=c,this.defaultValue=d};return b.TYPES={TEXT:1,SELECT:2,CHECKBOX:3,EDITOR:4},b.prototype.setFieldValue=function(c){if(null===c){if(!this.resetIfUndefined)return;c=this.defaultValue}switch(this.type){case b.TYPES.CHECKBOX:c?a(this.selector).prop("checked",!0):a(this.selector).prop("checked",!1);break;case b.TYPES.EDITOR:if("undefined"!==a.type(c.text)){var d=a(this.selector+"editable");d.length?d.html(c.text):"undefined"!=typeof tinyMCE&&tinyMCE.execInstanceCommand(this.id,"mceInsertContent",!1,c.text),a(this.selector).val(c.text)}break;default:a(this.selector).val(c)}},b});
|
||||
define(["jquery"],function(a){var b=function(a,b,c,d){this.name=a,this.id="id_"+this.name,this.selector="#"+this.id,this.type=b,this.resetIfUndefined=c,this.defaultValue=d};return b.TYPES={TEXT:1,SELECT:2,CHECKBOX:3,EDITOR:4},b.prototype.setFieldValue=function(c){if(null===c){if(!this.resetIfUndefined)return;c=this.defaultValue}switch(this.type){case b.TYPES.CHECKBOX:c?a(this.selector).prop("checked",!0):a(this.selector).prop("checked",!1);break;case b.TYPES.EDITOR:if("undefined"!=typeof c.text){var d=a(this.selector+"editable");d.length?d.html(c.text):"undefined"!=typeof tinyMCE&&tinyMCE.execInstanceCommand(this.id,"mceInsertContent",!1,c.text),a(this.selector).val(c.text)}break;default:a(this.selector).val(c)}},b});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/keys","mod_lti/tool_type","mod_lti/tool_proxy","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-container",EXTERNAL_REGISTRATION_PAGE_CONTAINER:"#external-registration-page-container",CARTRIDGE_REGISTRATION_CONTAINER:"#cartridge-registration-container",CARTRIDGE_REGISTRATION_FORM:"#cartridge-registration-form",ADD_TOOL_FORM:"#add-tool-form",TOOL_LIST_CONTAINER:"#tool-list-container",TOOL_CREATE_BUTTON:"#tool-create-button",REGISTRATION_CHOICE_CONTAINER:"#registration-choice-container",TOOL_URL:"#tool-url"},k=function(){return a(j.TOOL_CREATE_BUTTON)},l=function(){return a(j.TOOL_LIST_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},n=function(){return a(j.CARTRIDGE_REGISTRATION_CONTAINER)},o=function(){return a(j.REGISTRATION_CHOICE_CONTAINER)},p=function(){return a(j.TOOL_URL).val()},q=function(){m().addClass("hidden")},r=function(){n().addClass("hidden")},s=function(){o().addClass("hidden")},t=function(){r(),s(),m().removeClass("hidden"),w(m())},u=function(a){q(),s(),n().removeClass("hidden"),n().find(j.CARTRIDGE_REGISTRATION_FORM).attr("data-cartridge-url",a),w(n())},v=function(){q(),r(),o().removeClass("hidden"),w(o())},w=function(a){var b=a.children().detach();b.appendTo(a)},x=function(){l().addClass("hidden")},y=function(){l().removeClass("hidden")},z=function(a){var b=a.error?"error":"success";c.addNotification({message:a.message,type:b})},A=function(a){a.addClass("loading")},B=function(a){a.removeClass("loading")},C=function(){var b=a.Deferred(),e=l();A(e),a.when(g.query(),h.query({orphanedonly:!0})).done(function(a,c){d.render("mod_lti/tool_list",{tools:a,proxies:c}).done(function(a,c){e.empty(),e.append(a),d.runTemplateJS(c),b.resolve()}).fail(b.reject)}).fail(b.reject),b.fail(c.exception).always(function(){B(e)})},D=function(){var b=a.trim(p());if(""===b)return a.Deferred().resolve();var d=k();A(d);var f=g.isCartridge(b);return f.always(function(){B(d)}),f.done(function(c){c.iscartridge?(a(j.TOOL_URL).val(""),a(document).trigger(e.START_CARTRIDGE_REGISTRATION,b)):a(document).trigger(e.START_EXTERNAL_REGISTRATION,{url:b})}),f.fail(function(){i.get_string("errorbadurl","mod_lti").done(function(b){a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b,error:!0})}).fail(c.exception)}),f},E=function(){a(document).on(e.NEW_TOOL_TYPE,function(){C()}),a(document).on(e.START_EXTERNAL_REGISTRATION,function(){t(),a(j.TOOL_URL).val(""),x()}),a(document).on(e.STOP_EXTERNAL_REGISTRATION,function(){y(),v()}),a(document).on(e.START_CARTRIDGE_REGISTRATION,function(a,b){u(b)}),a(document).on(e.STOP_CARTRIDGE_REGISTRATION,function(){n().find(j.CARTRIDGE_REGISTRATION_FORM).removeAttr("data-cartridge-url"),v()}),a(document).on(e.REGISTRATION_FEEDBACK,function(a,b){z(b)});var b=a(j.ADD_TOOL_FORM);b.submit(function(a){a.preventDefault(),D()})};return{init:function(){E(),C()}}});
|
||||
define(["jquery","core/ajax","core/notification","core/templates","mod_lti/events","mod_lti/keys","mod_lti/tool_type","mod_lti/tool_proxy","core/str"],function(a,b,c,d,e,f,g,h,i){var j={EXTERNAL_REGISTRATION_CONTAINER:"#external-registration-container",EXTERNAL_REGISTRATION_PAGE_CONTAINER:"#external-registration-page-container",CARTRIDGE_REGISTRATION_CONTAINER:"#cartridge-registration-container",CARTRIDGE_REGISTRATION_FORM:"#cartridge-registration-form",ADD_TOOL_FORM:"#add-tool-form",TOOL_LIST_CONTAINER:"#tool-list-container",TOOL_CREATE_BUTTON:"#tool-create-button",REGISTRATION_CHOICE_CONTAINER:"#registration-choice-container",TOOL_URL:"#tool-url"},k=function(){return a(j.TOOL_CREATE_BUTTON)},l=function(){return a(j.TOOL_LIST_CONTAINER)},m=function(){return a(j.EXTERNAL_REGISTRATION_CONTAINER)},n=function(){return a(j.CARTRIDGE_REGISTRATION_CONTAINER)},o=function(){return a(j.REGISTRATION_CHOICE_CONTAINER)},p=function(){return a(j.TOOL_URL).val()},q=function(){m().addClass("hidden")},r=function(){n().addClass("hidden")},s=function(){o().addClass("hidden")},t=function(){r(),s(),m().removeClass("hidden"),w(m())},u=function(a){q(),s(),n().removeClass("hidden"),n().find(j.CARTRIDGE_REGISTRATION_FORM).attr("data-cartridge-url",a),w(n())},v=function(){q(),r(),o().removeClass("hidden"),w(o())},w=function(a){var b=a.children().detach();b.appendTo(a)},x=function(){l().addClass("hidden")},y=function(){l().removeClass("hidden")},z=function(a){var b=a.error?"error":"success";c.addNotification({message:a.message,type:b})},A=function(a){a.addClass("loading")},B=function(a){a.removeClass("loading")},C=function(){var b=a.Deferred(),e=l();A(e),a.when(g.query(),h.query({orphanedonly:!0})).done(function(a,c){d.render("mod_lti/tool_list",{tools:a,proxies:c}).done(function(a,c){e.empty(),e.append(a),d.runTemplateJS(c),b.resolve()}).fail(b.reject)}).fail(b.reject),b.fail(c.exception).always(function(){B(e)})},D=function(){var b=p().trim();if(""===b)return a.Deferred().resolve();var d=k();A(d);var f=g.isCartridge(b);return f.always(function(){B(d)}),f.done(function(c){c.iscartridge?(a(j.TOOL_URL).val(""),a(document).trigger(e.START_CARTRIDGE_REGISTRATION,b)):a(document).trigger(e.START_EXTERNAL_REGISTRATION,{url:b})}),f.fail(function(){i.get_string("errorbadurl","mod_lti").done(function(b){a(document).trigger(e.REGISTRATION_FEEDBACK,{message:b,error:!0})}).fail(c.exception)}),f},E=function(){a(document).on(e.NEW_TOOL_TYPE,function(){C()}),a(document).on(e.START_EXTERNAL_REGISTRATION,function(){t(),a(j.TOOL_URL).val(""),x()}),a(document).on(e.STOP_EXTERNAL_REGISTRATION,function(){y(),v()}),a(document).on(e.START_CARTRIDGE_REGISTRATION,function(a,b){u(b)}),a(document).on(e.STOP_CARTRIDGE_REGISTRATION,function(){n().find(j.CARTRIDGE_REGISTRATION_FORM).removeAttr("data-cartridge-url"),v()}),a(document).on(e.REGISTRATION_FEEDBACK,function(a,b){z(b)});var b=a(j.ADD_TOOL_FORM);b.submit(function(a){a.preventDefault(),D()})};return{init:function(){E(),C()}}});
|
||||
@@ -123,7 +123,7 @@ define(
|
||||
for (index in ltiFormFields) {
|
||||
var field = ltiFormFields[index];
|
||||
var value = null;
|
||||
if ($.type(returnData[field.name]) !== 'undefined') {
|
||||
if (typeof returnData[field.name] !== 'undefined') {
|
||||
value = returnData[field.name];
|
||||
}
|
||||
field.setFieldValue(value);
|
||||
|
||||
@@ -79,7 +79,7 @@ define(['jquery'],
|
||||
}
|
||||
break;
|
||||
case FormField.TYPES.EDITOR:
|
||||
if ($.type(value.text) !== 'undefined') {
|
||||
if (typeof value.text !== 'undefined') {
|
||||
/* global tinyMCE:false */
|
||||
|
||||
// Set text in editor's editable content, if applicable.
|
||||
|
||||
@@ -293,7 +293,7 @@ define(['jquery', 'core/ajax', 'core/notification', 'core/templates', 'mod_lti/e
|
||||
* @return {Promise} jQuery Deferred object
|
||||
*/
|
||||
var addTool = function() {
|
||||
var url = $.trim(getToolURL());
|
||||
var url = getToolURL().trim();
|
||||
|
||||
if (url === "") {
|
||||
return $.Deferred().resolve();
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(b,c){var d=[],e=a(b),f=a(b).data("originaloptionsjson"),g=e.val();a.each(f,function(b,e){return""!==a.trim(c)&&e.label.toLocaleLowerCase().indexOf(c.toLocaleLowerCase())===-1||(a.inArray(e.value,g)>-1||(d.push(e),!0))});var h=new a.Deferred;return h.resolve(d),h.promise()},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.value,label:b.label})}),d},transport:function(a,b,d){this.list(a,b).then(d)["catch"](c.exception)}}});
|
||||
define(["jquery","core/ajax","core/notification"],function(a,b,c){return{list:function(b,c){var d=[],e=a(b),f=a(b).data("originaloptionsjson"),g=e.val();a.each(f,function(b,e){return""!==c.trim()&&e.label.toLocaleLowerCase().indexOf(c.toLocaleLowerCase())===-1||(a.inArray(e.value,g)>-1||(d.push(e),!0))});var h=new a.Deferred;return h.resolve(d),h.promise()},processResults:function(b,c){var d=[];return a.each(c,function(a,b){d.push({value:b.value,label:b.label})}),d},transport:function(a,b,d){this.list(a,b).then(d)["catch"](c.exception)}}});
|
||||
@@ -41,7 +41,7 @@ define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notificat
|
||||
var selectedFilters = el.val();
|
||||
$.each(originalOptions, function(index, option) {
|
||||
// Skip option if it does not contain the query string.
|
||||
if ($.trim(query) !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
|
||||
if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
|
||||
return true;
|
||||
}
|
||||
// Skip filters that have already been selected.
|
||||
|
||||
Reference in New Issue
Block a user