Commit | Line | Data |
---|---|---|
00710f4c DC |
1 | // This file is part of Moodle - http://moodle.org/ |
2 | // | |
3 | // Moodle is free software: you can redistribute it and/or modify | |
4 | // it under the terms of the GNU General Public License as published by | |
5 | // the Free Software Foundation, either version 3 of the License, or | |
6 | // (at your option) any later version. | |
7 | // | |
8 | // Moodle is distributed in the hope that it will be useful, | |
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | // GNU General Public License for more details. | |
12 | // | |
13 | // You should have received a copy of the GNU General Public License | |
14 | // along with Moodle. If not, see <http://www.gnu.org/licenses/>. | |
15 | ||
16 | /** | |
17 | * Javascript helper function for wiki | |
18 | * | |
19 | * @package mod-wiki | |
20 | * @copyright 2010 Dongsheng Cai <dongsheng@moodle.com> | |
21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | |
22 | */ | |
23 | ||
24 | M.mod_wiki = {}; | |
25 | ||
26 | M.mod_wiki.init = function(Y, args) { | |
27 | var WikiHelper = function(args) { | |
28 | WikiHelper.superclass.constructor.apply(this, arguments); | |
29 | } | |
30 | WikiHelper.NAME = "WIKI"; | |
31 | WikiHelper.ATTRS = { | |
32 | options: {}, | |
33 | lang: {} | |
34 | }; | |
35 | Y.extend(WikiHelper, Y.Base, { | |
36 | initializer: function(args) { | |
37 | } | |
38 | }); | |
39 | new WikiHelper(args); | |
40 | }; | |
41 | M.mod_wiki.renew_lock = function(Y, args) { | |
42 | function renewLock() { | |
43 | var args = 'pageid=' + wiki.pageid; | |
44 | if (wiki.section) { | |
45 | args += '§ion=' + wiki.section; | |
46 | } | |
47 | var callback = {}; | |
48 | YAHOO.util.Connect.asyncRequest('GET', 'lock.php?' + args, callback); | |
49 | } | |
50 | setInterval(renewLock, wiki.renew_lock_timeout * 1000); | |
51 | } | |
52 | M.mod_wiki.history = function(Y, args) { | |
53 | var compare = false; | |
54 | var comparewith = false; | |
55 | var radio = document.getElementsByName('compare'); | |
56 | var radio2 = document.getElementsByName('comparewith'); | |
57 | for(var i=0; i<radio.length;i++){ | |
58 | if(radio[i].checked){ | |
59 | compare = true; | |
60 | } | |
61 | if(!comparewith){ | |
62 | radio[i].disabled=true; | |
63 | radio2[i].disabled=false; | |
64 | } else if(!compare && comparewith){ | |
65 | radio[i].disabled=false; | |
66 | radio2[i].disabled=false; | |
67 | } else { | |
68 | radio[i].disabled=false; | |
69 | radio2[i].disabled=true; | |
70 | } | |
71 | ||
72 | if(radio2[i].checked){ | |
73 | comparewith = true; | |
74 | } | |
75 | } | |
76 | } |