Commit Graph

12 Commits

Author SHA1 Message Date
Damyon Wiese
8d00afb12c MDL-54915 templates: Fix async rendering of js blocks
Mustache JS helper can overwrite JS blocks when using nested templates.

Each call to render should have it's own scope.
2016-07-19 12:55:50 +08:00
Dan Poltawski
7f70d548fe MDL-54939 amd: build modified files 2016-06-17 09:03:18 +01:00
Frederic Massart
29879f8f4c MDL-53667 templates: Improve JS string handling in templates
The native String.replace method in extremely slow when we are
dealing with a large string and large quantity of strings to replace.
This new solution walks through the string looking for placeholders
to replace.
2016-04-18 17:14:32 +08:00
Damyon Wiese
1fca8a7bdd MDL-53056 javascript: Improve the fragments API
Instead of injecting the HTML + JS directly - return a promise that is resolve with
the HTML and JS. This gives the caller control over how and when to inject the nodes
in the DOM. Also modify templates.replaceNode functions to cleanup YUI events mess.
Also pass the context to the callback so it can be verified.
Also pass the arguments to the callback as a named array - not a flat argument list.
Also - only load external scripts if they are not already loaded.
2016-03-30 11:48:38 +08:00
Eloy Lafuente (stronk7)
df190d18a1 MDL-52136 mod_forum: fix some out-of-sync stuff
Thanks CIs!
2016-03-02 05:42:29 +01:00
Dan Poltawski
f992dcf6e8 MDL-52204 js: fix 'used before defined' errors
Newer versions of jshint detect this coding error, we fix it
by simply reordering the definition of methods.
2015-12-04 11:43:10 +00:00
Damyon Wiese
28de777199 MDL-51222 Javascript: Trigger events for filters on DOM insertion
When nodes are added to the dom, they may need to be re-processed by a JS based
filter. To do this we need to trigger the legacy YUI event filter-content-updated.

To make this easier I added some wrappers to template that will insert the node, run any
JS and trigger the event.

I also changed existing yui code to call the amd function to trigger the event. This way
all jquery and yui listeners will always be notified.
2015-09-22 15:40:51 +08:00
Damyon Wiese
ba224fb42c MDL-50783 Ajax: Configure how to call a webservice through db/service.php
Now the db/service.php array can contain these extra keys to provide information
on how a webservice may be called:

    'ajax' => true (Default is false)

Replaces the xx_is_allowed_from_ajax callback.

    'loginrequired' => false (Default is true)

Means that this webservice can be called through lib/ajax/service-nosession.php
which sets NO_MOODLE_COOKIES to true (faster). This is only safe for webservices returning
static public data (e.g. get_string).
2015-09-14 15:10:21 +08:00
Damyon Wiese
e0d08bfa5d MDL-51116 Mustache: Caching issue exists with mustache templates
The first ajax load fetches the template and puts it in localstorage + a js var

The second load gets it from local storage, but does not put it in the js var.

The pix_icon helper expects it to be in the js var always.
2015-08-24 10:50:40 +08:00
Jetha Chan
e37d53dac1 MDL-50520 templates: fix helpers not firing inside pix helper 2015-06-09 15:23:04 +08:00
Damyon Wiese
4b9e532633 MDL-49604 Javascript: Add a localstorage cache for strings and templates 2015-04-08 12:31:48 +08:00
Damyon Wiese
9bdcf57951 MDL-49152 output: Templates for renderers (JS and PHP)
Mustache support for rendering templates from either php or js.
2015-03-14 22:48:40 +08:00