[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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() { 42 var args = { 43 sesskey: M.cfg.sesskey, 44 pageid: wiki.pageid 45 }; 46 if (wiki.section) { 47 args.section = wiki.section; 48 } 49 YUI().use('io', function(Y) { 50 function renewLock() { 51 Y.io('lock.php?' + build_querystring(args), { 52 method: 'POST' 53 }); 54 } 55 setInterval(renewLock, wiki.renew_lock_timeout * 1000); 56 }); 57 }; 58 M.mod_wiki.history = function(Y, args) { 59 var compare = false; 60 var comparewith = false; 61 var radio = document.getElementsByName('compare'); 62 var radio2 = document.getElementsByName('comparewith'); 63 for(var i=0; i<radio.length;i++){ 64 if(radio[i].checked){ 65 compare = true; 66 } 67 if(!comparewith){ 68 radio[i].disabled=true; 69 radio2[i].disabled=false; 70 } else if(!compare && comparewith){ 71 radio[i].disabled=false; 72 radio2[i].disabled=false; 73 } else { 74 radio[i].disabled=false; 75 radio2[i].disabled=true; 76 } 77 78 if(radio2[i].checked){ 79 comparewith = true; 80 } 81 } 82 } 83 84 M.mod_wiki.deleteversion = function(Y, args) { 85 var fromversion = false; 86 var toversion = false; 87 var radio = document.getElementsByName('fromversion'); 88 var radio2 = document.getElementsByName('toversion'); 89 var length = radio.length; 90 //version to should be more then version from 91 for (var i = 0; i < radio.length; i++) { 92 //if from-version is selected then disable all to-version options after that. 93 if (fromversion) { 94 radio2[i].disabled = true; 95 } else { 96 radio2[i].disabled = false; 97 } 98 //check when to-version option is selected 99 if (radio2[i].checked) { 100 toversion = true; 101 } 102 //make sure to-version should be >= from-version 103 if (radio[i].checked) { 104 fromversion = true; 105 if (!toversion) { 106 radio2[i].checked = true; 107 } 108 } 109 } 110 //avoid selecting first and last version 111 if (radio[0].checked && radio2[length-1].checked) { 112 radio2[length - 2].checked = true; 113 } else if(radio[length - 1].checked && radio2[0].checked) { 114 radio2[1].checked = true; 115 radio2[0].disabled = true; 116 toversion = true; 117 } 118 } 119 120 M.mod_wiki.init_tree = function(Y, expand_all, htmlid) { 121 Y.use('yui2-treeview', function(Y) { 122 var tree = new Y.YUI2.widget.TreeView(htmlid); 123 124 tree.subscribe("clickEvent", function(node, event) { 125 // we want normal clicking which redirects to url 126 return false; 127 }); 128 129 if (expand_all) { 130 tree.expandAll(); 131 } 132 133 tree.render(); 134 }); 135 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |