Merge branch 'MDL-62945-master' of https://github.com/HuongNV13/moodle
[moodle.git] / lib / form / url.js
blobd1b793dbd30f3ed2478d8e4fb3df739139de2e85
1 M.form_url = {};
3 M.form_url.init = function(Y, options) {
4     options.formcallback = M.form_url.callback;
5     if (!M.core_filepicker.instances[options.client_id]) {
6         M.core_filepicker.init(Y, options);
7     }
8     Y.on('click', function(e, client_id) {
9         e.preventDefault();
10         M.core_filepicker.instances[client_id].show();
11     }, '#filepicker-button-js-'+options.client_id, null, options.client_id);
14 M.form_url.callback = function (params) {
15     // Get the first child of type 'input' within the wrapper div associated with the filepicker's id.
16     var urlElement = document.getElementById('url-wrapper-' + params.client_id).getElementsByTagName('input')[0];
17     urlElement.value = params.url;
18     urlElement.focus();