Revert "Merge branch 'MDL-54915-30' of git://github.com/andrewnicols/moodle into MOODLE_30_STABLE"

This reverts commit 4b6e0cbd57, reversing
changes made to 8d6dde0805.
This commit is contained in:
Dan Poltawski
2016-07-19 09:37:36 +01:00
parent 1e56841201
commit 19421799cb
2 changed files with 10 additions and 7 deletions
+1 -1
View File
@@ -1 +1 @@
define(["core/mustache","jquery","core/ajax","core/str","core/notification","core/url","core/config","core/localstorage","core/event"],function(a,b,c,d,e,f,g,h,i){var j={},k=[],l=1,m="",n=function(b,c){var d,e=b.split(","),g="",h="",i="";e.length>0&&(g=e.shift().trim()),e.length>0&&(h=e.shift().trim()),e.length>0&&(i=e.join(",").trim());var k=f.imageUrl(g,h),l={attributes:[{name:"src",value:k},{name:"alt",value:c(i)},{name:"class",value:"smallicon"}]},n=j[m+"/core/pix_icon"];return d=a.render(n,l,o),d.trim()},o=function(a){var b="";return v(a,!1).done(function(a){b=a}).fail(e.exception),b},p=function(a,b){return this.jsBlocks.push(b(a,this)),""},q=function(a,b){var c=a.split(","),d="",e="",f="";c.length>0&&(d=c.shift().trim()),c.length>0&&(e=c.shift().trim()),c.length>0&&(f=c.join(",").trim()),""!==f&&(f=b(f,this)),0===f.indexOf("{")&&0!==f.indexOf("{{")&&(f=JSON.parse(f));var g=k.length;return k.push({key:d,component:e,param:f}),"{{_s"+g+"}}"},r=function(a,b){var c=b(a.trim(),this);return c=c.replace('"','\\"').replace(/([\{\}]{2,3})/g,"{{=<% %>=}}$1<%={{ }}=%>"),'"'+c+'"'},s=function(a,b){m=b,k=[],a.uniqid=l++,a.str=function(){return q},a.pix=function(){return n},a.js=function(){return p},a.jsBlocks=[],a.quote=function(){return r},a.globals={config:g},a.currentTheme=b},t=function(a){var b="";this.jsBlocks.length>0&&(b=this.jsBlocks.join(";\n"));var c=0;for(c=0;c<a.length;c++)b=b.replace("{{_s"+c+"}}",a[c]);return b},u=function(c,e,f){var g=b.Deferred();m=f;var h=v("core/pix_icon",!0);return h.done(function(){s(e,f);var b="";try{b=a.render(c,e,o)}catch(h){g.reject(h)}k.length>0?d.get_strings(k).done(function(a){var c;for(c=0;c<a.length;c++)b=b.replace("{{_s"+c+"}}",a[c]);g.resolve(b.trim(),t.bind(e)(a))}).fail(function(a){g.reject(a)}):g.resolve(b.trim(),t.bind(e)([]))}).fail(function(a){g.reject(a)}),g.promise()},v=function(a,d){var e=b.Deferred(),f=a.split("/"),g=f.shift(),i=f.shift(),k=m+"/"+a;if(k in j)return e.resolve(j[k]),e.promise();var l=h.get("core_template/"+k);if(l)return e.resolve(l),j[k]=l,e.promise();var n=c.call([{methodname:"core_output_load_template",args:{component:g,template:i,themename:m}}],d,!1);return n[0].done(function(a){h.set("core_template/"+k,a),j[k]=a,e.resolve(a)}).fail(function(a){e.reject(a)}),e.promise()},w=function(a){if(""!==a.trim()){var c=b("<script>").attr("type","text/javascript").html(a);b("head").append(c)}},x=function(a,c,d,e){var f=b(a);if(f.length){var g=b(c);e?(f.empty(),f.append(g)):f.replaceWith(g),w(d),i.notifyFilterContentUpdated(g)}};return{render:function(a,c,d){var e=b.Deferred();"undefined"==typeof d&&(d=g.theme),m=d;var f=v(a,!0);return f.done(function(a){var b=u(a,c,d);b.done(function(a,b){e.resolve(a,b)}).fail(function(a){e.reject(a)})}).fail(function(a){e.reject(a)}),e.promise()},runTemplateJS:w,replaceNodeContents:function(a,b,c){return x(a,b,c,!0)},replaceNode:function(a,b,c){return x(a,b,c,!1)}}});
define(["core/mustache","jquery","core/ajax","core/str","core/notification","core/url","core/config","core/localstorage","core/event"],function(a,b,c,d,e,f,g,h,i){var j={},k=[],l=[],m=1,n="",o=function(b,c){var d,e=b.split(","),g="",h="",i="";e.length>0&&(g=e.shift().trim()),e.length>0&&(h=e.shift().trim()),e.length>0&&(i=e.join(",").trim());var k=f.imageUrl(g,h),l={attributes:[{name:"src",value:k},{name:"alt",value:c(i)},{name:"class",value:"smallicon"}]},m=j[n+"/core/pix_icon"];return d=a.render(m,l,p),d.trim()},p=function(a){var b="";return w(a,!1).done(function(a){b=a}).fail(e.exception),b},q=function(a,b){return l.push(b(a,this)),""},r=function(a,b){var c=a.split(","),d="",e="",f="";c.length>0&&(d=c.shift().trim()),c.length>0&&(e=c.shift().trim()),c.length>0&&(f=c.join(",").trim()),""!==f&&(f=b(f,this)),0===f.indexOf("{")&&0!==f.indexOf("{{")&&(f=JSON.parse(f));var g=k.length;return k.push({key:d,component:e,param:f}),"{{_s"+g+"}}"},s=function(a,b){var c=b(a.trim(),this);return c=c.replace('"','\\"').replace(/([\{\}]{2,3})/g,"{{=<% %>=}}$1<%={{ }}=%>"),'"'+c+'"'},t=function(a,b){n=b,k=[],l=[],a.uniqid=m++,a.str=function(){return r},a.pix=function(){return o},a.js=function(){return q},a.quote=function(){return s},a.globals={config:g},a.currentTheme=b},u=function(a){var b="";l.length>0&&(b=l.join(";\n"));var c=0;for(c=0;c<a.length;c++)b=b.replace("{{_s"+c+"}}",a[c]);return b},v=function(c,e,f){var g=b.Deferred();n=f;var h=w("core/pix_icon",!0);return h.done(function(){t(e,f);var b="";try{b=a.render(c,e,p)}catch(h){g.reject(h)}k.length>0?d.get_strings(k).done(function(a){var c;for(c=0;c<a.length;c++)b=b.replace("{{_s"+c+"}}",a[c]);g.resolve(b.trim(),u(a))}).fail(function(a){g.reject(a)}):g.resolve(b.trim(),u([]))}).fail(function(a){g.reject(a)}),g.promise()},w=function(a,d){var e=b.Deferred(),f=a.split("/"),g=f.shift(),i=f.shift(),k=n+"/"+a;if(k in j)return e.resolve(j[k]),e.promise();var l=h.get("core_template/"+k);if(l)return e.resolve(l),j[k]=l,e.promise();var m=c.call([{methodname:"core_output_load_template",args:{component:g,template:i,themename:n}}],d,!1);return m[0].done(function(a){h.set("core_template/"+k,a),j[k]=a,e.resolve(a)}).fail(function(a){e.reject(a)}),e.promise()},x=function(a){if(""!==a.trim()){var c=b("<script>").attr("type","text/javascript").html(a);b("head").append(c)}},y=function(a,c,d,e){var f=b(a);if(f.length){var g=b(c);e?(f.empty(),f.append(g)):f.replaceWith(g),x(d),i.notifyFilterContentUpdated(g)}};return{render:function(a,c,d){var e=b.Deferred();"undefined"==typeof d&&(d=g.theme),n=d;var f=w(a,!0);return f.done(function(a){var b=v(a,c,d);b.done(function(a,b){e.resolve(a,b)}).fail(function(a){e.reject(a)})}).fail(function(a){e.reject(a)}),e.promise()},runTemplateJS:x,replaceNodeContents:function(a,b,c){return y(a,b,c,!0)},replaceNode:function(a,b,c){return y(a,b,c,!1)}}});
+9 -6
View File
@@ -43,6 +43,9 @@ define([ 'core/mustache',
/** @var {string[]} requiredStrings - Collection of strings found during the rendering of one template */
var requiredStrings = [];
/** @var {string[]} requiredJS - Collection of js blocks found during the rendering of one template */
var requiredJS = [];
/** @var {Number} uniqid Incrementing value that is changed for every call to render */
var uniqid = 1;
@@ -119,7 +122,7 @@ define([ 'core/mustache',
* @return {string}
*/
var jsHelper = function(sectionText, helper) {
this.jsBlocks.push(helper(sectionText, this));
requiredJS.push(helper(sectionText, this));
return '';
};
@@ -195,11 +198,11 @@ define([ 'core/mustache',
var addHelpers = function(context, themeName) {
currentThemeName = themeName;
requiredStrings = [];
requiredJS = [];
context.uniqid = uniqid++;
context.str = function() { return stringHelper; };
context.pix = function() { return pixHelper; };
context.js = function() { return jsHelper; };
context.jsBlocks = [];
context.quote = function() { return quoteHelper; };
context.globals = { config : config };
context.currentTheme = themeName;
@@ -215,8 +218,8 @@ define([ 'core/mustache',
*/
var getJS = function(strings) {
var js = '';
if (this.jsBlocks.length > 0) {
js = this.jsBlocks.join(";\n");
if (requiredJS.length > 0) {
js = requiredJS.join(";\n");
}
var i = 0;
@@ -270,7 +273,7 @@ define([ 'core/mustache',
for (i = 0; i < strings.length; i++) {
result = result.replace('{{_s' + i + '}}', strings[i]);
}
deferred.resolve(result.trim(), getJS.bind(context)(strings));
deferred.resolve(result.trim(), getJS(strings));
}
).fail(
function(ex) {
@@ -278,7 +281,7 @@ define([ 'core/mustache',
}
);
} else {
deferred.resolve(result.trim(), getJS.bind(context)([]));
deferred.resolve(result.trim(), getJS([]));
}
}
).fail(