1/* DokuWiki MoaiEditor Sprintdoc.js file 2 Author : MoaiTools <info@moaitools.org> 3 License : GPL 3 (http://www.gnu.org/licenses/gpl.html) */ 4/* 5 This class extends 'MoaiEditor.Template' class and allows to override 6 some methods to support a specific template, in this case 'Sprintdoc'. 7 8 If you copy this file to support your template, be sure to put it in 9 the 'user_templates/' folder. 10 11 Also change the class name below from 'Template_sprintdoc' to something 12 like 'UserTemplate_mytemplate'. 13 │ │ 14 │ └ same as the filename (without the '.js' suffix) 15 └ add the 'User' prefix 16 17 This is the list of functions you generally can override to support your 18 template: 19 20 importance 21 detectTemplate 22 addStartButton 23 24 find_ElementsToHide 25 find_Messages() 26 find_Toolbar 27 find_Pagetools 28 find_EditSummary 29 find_Form 30 find_Textarea 31 find_EditButtons 32 33 See 'templates/default.js' to understand each of these methods. 34 35 See 'README' to learn how to support a new template. 36*/ 37MoaiEditor.Template_sprintdoc = class extends MoaiEditor.Template { 38 39 importance() { 40 return 1; // See the README file of this plugin to see an explanation of this value 41 } 42 detectTemplate() { 43 if (DOKU_TPL.endsWith ('tpl/sprintdoc/')) 44 return true; 45 return false; 46 47 /* Shown below is an alternative way to identify templates, 48 by using a DOM signature. This might have the advantage 49 of indentifying a template even if it lives in another 50 folder. Say you have 'sprintdoc' and a slighly customized 51 version called 'sprint_personal'. By detecting the template 52 by something other than the file path, you can target many 53 templates with just one file, and without knowing beforehand 54 where it will be located. 55 56 This example code works with sprintdoc: 57 58 var element = document.getElementById('dokuwiki__site'); 59 if (element && element.classList.contains('tpl_sprintdoc')) 60 return true; 61 return false; 62 */ 63 } 64 find_Messages() { 65 // Find the displayed messages (info, error, success, notify) usually rendered by inc/html.php -> html_msgarea(). 66 // Some templates like bootstrap3 implement their own message rendering function and don't use html_msgarea(). 67 // In order to check how (and if) your template's messages are being displayed in this editor, you can simulate 68 // fake messages by either: 69 // a) Adding '&fakemsg' to the browser's URL while in edit mode. 70 // b) Set the MOAIED_FAKE_MESSAGES constant to true in: lib/plugins/moaieditor/action.php 71 var query = ""; 72 var container = "#dokuwiki__content div.msg-area "; 73 query += container + "div.error, "; 74 query += container + "div.info, "; 75 query += container + "div.success, "; 76 query += container + "div.notify "; 77 var messages = document.body.querySelectorAll(query); 78 return messages; 79 } 80 81}; // End Class 82 83 84 85