Ticket #1432: template.html

File template.html, 5.7 KB (added by barns, 17 years ago)

Patched to template file with template doc preview

Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!--
3 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
4 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
5 *
6 * == BEGIN LICENSE ==
7 *
8 * Licensed under the terms of any of the following licenses at your
9 * choice:
10 *
11 *  - GNU General Public License Version 2 or later (the "GPL")
12 *    http://www.gnu.org/licenses/gpl.html
13 *
14 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
15 *    http://www.gnu.org/licenses/lgpl.html
16 *
17 *  - Mozilla Public License Version 1.1 or later (the "MPL")
18 *    http://www.mozilla.org/MPL/MPL-1.1.html
19 *
20 * == END LICENSE ==
21 *
22 * Link dialog window.
23-->
24<html>
25<head>
26        <title>Template Properties</title>
27        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
28        <meta name="robots" content="noindex, nofollow" />
29        <script src="common/fck_dialog_common.js" type="text/javascript"></script>
30        <link href="common/fck_dialog_common.css" rel="stylesheet" type="text/css" />
31        <script type="text/javascript">
32
33var oEditor             = window.parent.InnerDialogLoaded() ;
34var FCK                 = oEditor.FCK ;
35var FCKLang             = oEditor.FCKLang ;
36var FCKConfig   = oEditor.FCKConfig ;
37var FCKRegexLib = oEditor.FCKRegexLib ;
38var FCKTools    = oEditor.FCKTools ;
39
40document.write( '<script src="' + FCKConfig.BasePath + 'dialog/common/fck_dialog_common.js" type="text/javascript"><\/script>' ) ;
41
42        </script>
43        <script type="text/javascript">
44
45//#### Dialog Tabs
46
47// Set the dialog tabs.
48window.parent.AddTab( 'Edit', 'Edit' ) ;
49window.parent.AddTab( 'Manual', 'Manual' ) ;
50
51function OnDialogTabChange( tabCode )
52{
53        ShowE('divEdit'         , ( tabCode == 'Edit' ) ) ;
54        ShowE('divManual'               , ( tabCode == 'Manual' ) ) ;
55}
56
57// Get the selected flash embed (if available).
58var oFakeImage = FCK.Selection.GetSelectedElement() ;
59var oTemplateSpan ;
60
61if ( oFakeImage )
62{
63        if ( oFakeImage.tagName == 'IMG' && oFakeImage.getAttribute('_fck_mw_template') )
64                oTemplateSpan = FCK.GetRealElement( oFakeImage ) ;
65        else
66                oFakeImage = null ;
67}
68
69window.onload = function()
70{
71        // Translate the dialog box texts.
72        oEditor.FCKLanguageManager.TranslatePage(document) ;
73
74        // Load the selected link information (if any).
75        LoadSelection() ;
76
77        // Activate the "OK" button.
78        window.parent.SetOkButton( true ) ;
79        window.parent.SetAutoSize( true ) ;
80}
81
82function LoadSearchResults( result )
83{
84        var results = result.responseText.Trim().split( '\n' ) ;
85        var select = GetE( 'xWikiResults' ) ;
86
87        if ( results.length > 0 && !( results.length == 1 && results[0].length == 0 ) )
88        {
89                for ( var i = 0 ; i < results.length ; i++ )
90                        FCKTools.AddSelectOption( select, 'Template:' + results[i], results[i] ) ;
91        }
92}
93
94function LoadSelection()
95{
96        // Make an Ajax search for the pages.
97        var empty = '';
98        oEditor.window.parent.sajax_request_type = 'GET' ;
99        oEditor.window.parent.sajax_do_call( 'wfSajaxSearchTemplateFCKeditor',[empty], LoadSearchResults ) ;
100       
101        if ( !oTemplateSpan ) return ;
102
103        var inputText = FCKTools.HTMLDecode(oTemplateSpan.innerHTML);
104        if (inputText.length>0 && inputText.indexOf('{{#')<0 && inputText.indexOf('{{:')<0 ) 
105        {
106                var templateName = inputText.substring(2,inputText.indexOf('fckLR'));
107                if (inputText.indexOf('fckLR')<1) 
108                        templateName = inputText.substring(2,inputText.indexOf('|'));
109                if (inputText.indexOf('|')<1) 
110                        templateName = inputText.substring(2,inputText.indexOf('}}'));
111                       
112                SetUrl(templateName.charAt(0).toUpperCase() + templateName.substr(1));
113        }
114        GetE('xTemplateRaw').value = inputText.replace(/fckLR/g,'\r\n').replace( /&quot;/g, '"' ) ;
115}
116
117function SetUrl(link)
118{
119        var urlTemplate = '/wiki/index.php?title=Template:' + link + '&printable=yes';
120        SetAttribute(GetE('xTemplateManual'),'src',urlTemplate); 
121}
122
123//#### The OK button was hit.
124function Ok()
125{
126        if ( !oTemplateSpan )
127        {
128                oTemplateSpan = FCK.EditorDocument.createElement( 'SPAN' ) ;
129                oTemplateSpan.className = 'fck_mw_template' ;
130        }
131       
132        var templateData = FCKTools.HTMLEncode(GetE('xTemplateRaw').value.Trim().replace(/(\r\n|\n)/g, 'fckLR')).replace( /"/g, '&quot;' ) ;
133       
134        if ( !( /^{{[\s\S]+}}$/.test( templateData ) ) )
135        {
136                alert( 'Templates must start with {{ and end with }}. Please check it.' ) ;
137                return false ;
138        }
139       
140        oTemplateSpan.innerHTML = templateData ;
141
142        if ( !oFakeImage )
143        {
144                oFakeImage      = oEditor.FCKDocumentProcessor_CreateFakeImage( 'FCK__MWTemplate', oTemplateSpan ) ;
145                oFakeImage.setAttribute( '_fck_mw_template', 'true', 0 ) ;
146                oFakeImage      = FCK.InsertElement( oFakeImage ) ;
147        }
148
149        //GetE('xTestSpan').innerHTML = GetE('xTemplateRaw').value.Trim().replace( /"/g, '&quot;' ).replace(/(\r\n|\n)/g, '___') ;
150        return true ;
151}
152
153        </script>
154</head>
155<body style="overflow: hidden">
156        <div id="divEdit">
157                <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
158                        <tr>
159                                <td>
160                                        <span>Template raw definition (from {{ to }})</span><br />
161                                </td>
162                        </tr>
163                        <tr>
164                                <td height="100%">
165                                        <textarea id="xTemplateRaw" style="width: 100%; height: 100%; font-family: Monospace"
166                                                cols="50" rows="10" wrap="off"></textarea>
167                                </td>
168                        </tr>
169                        <tr>
170                                <td>
171                                        <span id="xTestSpan" class="fck_mw_template"></span>
172                                </td>
173                        </tr>
174                </table>
175        </div>
176        <div id="divManual" style="display: none">
177                <table cellpadding="0" cellspacing="0" border="0" width="100%" height="100%">
178                        <tr>
179                                <select id="xWikiResults" style="width: 100%;" onchange="SetUrl( this.value );">
180                                <option value="">&lt;Pick up a template manual here&gt;</option>
181                                </select>
182                        </tr>
183                        <tr>
184                                <td>
185                                        <iframe id="xTemplateManual" width="100%" scrolling="yes" height="100%" src=""></iframe>
186                                </td>
187                        </tr>
188                </table>
189        </div>
190</body>
191</html>
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy