759
* @var pending_js - The keys are the list of all pending js actions.
762
M.util.pending_js = [];
763
M.util.complete_js = [];
766
* Register any long running javascript code with a unique identifier.
767
* Should be followed with a call to js_complete with a matching
768
* idenfitier when the code is complete. May also be called with no arguments
769
* to test if there is any js calls pending. This is relied on by behat so that
770
* it can wait for all pending updates before interacting with a page.
771
* @param String uniqid - optional, if provided,
772
* registers this identifier until js_complete is called.
773
* @return boolean - True if there is any pending js.
775
M.util.js_pending = function(uniqid) {
776
if (uniqid !== false) {
777
M.util.pending_js.push(uniqid);
780
return M.util.pending_js.length;
784
* Register listeners for Y.io start/end so we can wait for them in behat.
786
M.util.js_watch_io = function() {
787
YUI.add('moodle-core-io', function(Y) {
788
Y.on('io:start', function(id) {
789
M.util.js_pending('io:' + id);
791
Y.on('io:end', function(id) {
792
M.util.js_complete('io:' + id);
801
requires: ['moodle-core-io'],
809
M.util.js_pending('init');
810
M.util.js_watch_io();
813
* Unregister any long running javascript code by unique identifier.
814
* This function should form a matching pair with js_pending
816
* @param String uniqid - required, unregisters this identifier
817
* @return boolean - True if there is any pending js.
819
M.util.js_complete = function(uniqid) {
820
// Use the Y.Array.indexOf instead of the native because some older browsers do not support
821
// the native function. Y.Array polyfills the native function if it does not exist.
822
var index = Y.Array.indexOf(M.util.pending_js, uniqid);
824
M.util.complete_js.push(M.util.pending_js.splice(index, 1));
827
return M.util.pending_js.length;
759
831
* Returns a string registered in advance for usage in JavaScript
761
833
* If you do not pass the third parameter, the function will just return
1839
1911
for(var i=0; i<M.util.video_players.length; i++) {
1840
1912
var video = M.util.video_players[i];
1841
1913
if (video.width > 0 && video.height > 0) {
1842
var src = {src: M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.16.swf', width: video.width, height: video.height};
1914
var src = {src: M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.18.swf', width: video.width, height: video.height};
1844
var src = M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.16.swf';
1916
var src = M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.18.swf';
1846
1918
flowplayer(video.id, src, {
1847
1919
plugins: {controls: controls},
1941
2013
controls.height = 25;
1942
2014
controls.time = true;
1944
flowplayer(audio.id, M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.16.swf', {
1945
plugins: {controls: controls, audio: {url: M.cfg.wwwroot + '/lib/flowplayer/flowplayer.audio-3.2.10.swf'}},
2016
flowplayer(audio.id, M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.18.swf', {
2017
plugins: {controls: controls, audio: {url: M.cfg.wwwroot + '/lib/flowplayer/flowplayer.audio-3.2.11.swf'}},
1946
2018
clip: {url: audio.fileurl, provider: "audio", autoPlay: false}
1951
2023
if (M.cfg.jsrev == -1) {
1952
var jsurl = M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.12.js';
2024
var jsurl = M.cfg.wwwroot + '/lib/flowplayer/flowplayer-3.2.13.js';
1954
var jsurl = M.cfg.wwwroot + '/lib/javascript.php?jsfile=/lib/flowplayer/flowplayer-3.2.12.min.js&rev=' + M.cfg.jsrev;
2026
var jsurl = M.cfg.wwwroot + '/lib/javascript.php?jsfile=/lib/flowplayer/flowplayer-3.2.13.min.js&rev=' + M.cfg.jsrev;
1956
2028
var fileref = document.createElement('script');
1957
2029
fileref.setAttribute('type','text/javascript');