~ubuntu-branches/ubuntu/utopic/moodle/utopic

« back to all changes in this revision

Viewing changes to lib/javascript-static.js

  • Committer: Package Import Robot
  • Author(s): Thijs Kinkhorst
  • Date: 2014-05-12 16:10:38 UTC
  • mfrom: (36.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20140512161038-puyqf65k4e0s8ytz
Tags: 2.6.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
756
756
};
757
757
 
758
758
/**
 
759
 * @var pending_js - The keys are the list of all pending js actions.
 
760
 * @type Object
 
761
 */
 
762
M.util.pending_js = [];
 
763
M.util.complete_js = [];
 
764
 
 
765
/**
 
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.
 
774
 */
 
775
M.util.js_pending = function(uniqid) {
 
776
    if (uniqid !== false) {
 
777
        M.util.pending_js.push(uniqid);
 
778
    }
 
779
 
 
780
    return M.util.pending_js.length;
 
781
};
 
782
 
 
783
/**
 
784
 * Register listeners for Y.io start/end so we can wait for them in behat.
 
785
 */
 
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);
 
790
        });
 
791
        Y.on('io:end', function(id) {
 
792
            M.util.js_complete('io:' + id);
 
793
        });
 
794
    });
 
795
    YUI.applyConfig({
 
796
        modules: {
 
797
            'moodle-core-io': {
 
798
                after: ['io-base']
 
799
            },
 
800
            'io-base': {
 
801
                requires: ['moodle-core-io'],
 
802
            }
 
803
        }
 
804
    });
 
805
 
 
806
};
 
807
 
 
808
// Start this asap.
 
809
M.util.js_pending('init');
 
810
M.util.js_watch_io();
 
811
 
 
812
/**
 
813
 * Unregister any long running javascript code by unique identifier.
 
814
 * This function should form a matching pair with js_pending
 
815
 *
 
816
 * @param String uniqid - required, unregisters this identifier
 
817
 * @return boolean - True if there is any pending js.
 
818
 */
 
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);
 
823
    if (index >= 0) {
 
824
        M.util.complete_js.push(M.util.pending_js.splice(index, 1));
 
825
    }
 
826
 
 
827
    return M.util.pending_js.length;
 
828
};
 
829
 
 
830
/**
759
831
 * Returns a string registered in advance for usage in JavaScript
760
832
 *
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};
1843
1915
                } else {
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';
1845
1917
                }
1846
1918
                flowplayer(video.id, src, {
1847
1919
                    plugins: {controls: controls},
1941
2013
                    controls.height = 25;
1942
2014
                    controls.time = true;
1943
2015
                }
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}
1947
2019
                });
1948
2020
            }
1949
2021
        }
1950
2022
 
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';
1953
2025
        } else {
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;
1955
2027
        }
1956
2028
        var fileref = document.createElement('script');
1957
2029
        fileref.setAttribute('type','text/javascript');