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() { | |
d2807da8 DC |
43 | var args = {}; |
44 | args['sesskey'] = M.cfg.sesskey; | |
45 | args['pageid'] = wiki.pageid; | |
00710f4c | 46 | if (wiki.section) { |
d2807da8 | 47 | args['section'] = wiki.section; |
00710f4c DC |
48 | } |
49 | var callback = {}; | |
d2807da8 | 50 | YAHOO.util.Connect.asyncRequest('GET', 'lock.php?' + build_querystring(args), callback); |
00710f4c DC |
51 | } |
52 | setInterval(renewLock, wiki.renew_lock_timeout * 1000); | |
53 | } | |
54 | M.mod_wiki.history = function(Y, args) { | |
55 | var compare = false; | |
56 | var comparewith = false; | |
57 | var radio = document.getElementsByName('compare'); | |
58 | var radio2 = document.getElementsByName('comparewith'); | |
59 | for(var i=0; i<radio.length;i++){ | |
60 | if(radio[i].checked){ | |
61 | compare = true; | |
62 | } | |
63 | if(!comparewith){ | |
64 | radio[i].disabled=true; | |
65 | radio2[i].disabled=false; | |
66 | } else if(!compare && comparewith){ | |
67 | radio[i].disabled=false; | |
68 | radio2[i].disabled=false; | |
69 | } else { | |
70 | radio[i].disabled=false; | |
71 | radio2[i].disabled=true; | |
72 | } | |
73 | ||
74 | if(radio2[i].checked){ | |
75 | comparewith = true; | |
76 | } | |
77 | } | |
78 | } | |
12c9bbbd DC |
79 | |
80 | M.mod_wiki.init_tree = function(Y, expand_all, htmlid) { | |
81 | Y.use('yui2-treeview', function(Y) { | |
82 | var tree = new YAHOO.widget.TreeView(htmlid); | |
83 | ||
84 | tree.subscribe("clickEvent", function(node, event) { | |
85 | // we want normal clicking which redirects to url | |
86 | return false; | |
87 | }); | |
88 | ||
89 | if (expand_all) { | |
90 | tree.expandAll(); | |
91 | } | |
92 | ||
93 | tree.render(); | |
94 | }); | |
95 | }; |