fck_template.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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-2010 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. * Template selection dialog window.
  23. -->
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <title></title>
  27. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  28. <meta name="robots" content="noindex, nofollow" />
  29. <style type="text/css">
  30. .TplList {
  31. border: #fff 2px solid;
  32. background-color: #ffffff;
  33. overflow: auto;
  34. width: 148px;
  35. }
  36. .TplItemPopupSelectionBox {
  37. background-color: #eee;
  38. }
  39. .TplItem, .TplItemPopupSelectionBox {
  40. margin: 5px;
  41. padding: 7px;
  42. border: #eeeeee 1px solid;
  43. text-decoration: none;
  44. }
  45. .TplItem table {
  46. display: inline;
  47. }
  48. .TplTitle {
  49. font-weight: bold;
  50. }
  51. .TplTitle a {
  52. color:000;
  53. text-decoration: none;
  54. }
  55. </style>
  56. <script src="common/fck_dialog_common.js" type="text/javascript"></script>
  57. <script type="text/javascript">
  58. var oEditor = window.parent.InnerDialogLoaded() ;
  59. var FCK = oEditor.FCK ;
  60. var FCKLang = oEditor.FCKLang ;
  61. var FCKConfig = oEditor.FCKConfig ;
  62. var Size = window.parent.WindowSize;
  63. // Added by Ivan Tcholakov, a temporary fix.
  64. // The following statement sets the Skin CSS.
  65. // This is needed only when this dialog is shown in the Documents tool.
  66. document.write( '<link href="' + FCKConfig.SkinPath + 'fck_dialog.css" type="text/css" rel="stylesheet">' ) ;
  67. //
  68. window.onload = function()
  69. {
  70. // Set the right box height (browser dependent).
  71. GetE('eList').style.height = document.all ? '100%' : Size ;
  72. // Translate the dialog box texts.
  73. oEditor.FCKLanguageManager.TranslatePage(document) ;
  74. //window.parent.SetAutoSize( true ) ;
  75. LoadTemplatesXml() ;
  76. // Select first by default (Chamilo customization)
  77. if ( window.top.load_default_template )
  78. SelectTemplate( 0 ) ;
  79. }
  80. function LoadTemplatesXml()
  81. {
  82. var oTemplate ;
  83. if ( !FCK._Templates )
  84. {
  85. GetE('eLoading').style.display = '' ;
  86. // Create the Templates array.
  87. FCK._Templates = new Array() ;
  88. // Load the XML file.
  89. var oXml = new oEditor.FCKXml() ;
  90. oXml.LoadUrl( FCKConfig.TemplatesXmlPath ) ;
  91. // Get the Images Base Path.
  92. var oAtt = oXml.SelectSingleNode( 'Templates/@imagesBasePath' ) ;
  93. var sImagesBasePath = oAtt ? oAtt.value : '' ;
  94. // Get the "Template" nodes defined in the XML file.
  95. var aTplNodes = oXml.SelectNodes( 'Templates/Template' ) ;
  96. for ( var i = 0 ; i < aTplNodes.length ; i++ )
  97. {
  98. var oNode = aTplNodes[i] ;
  99. oTemplate = new Object() ;
  100. var oPart ;
  101. // Get the Template Title.
  102. if ( (oPart = oNode.attributes.getNamedItem('title')) )
  103. oTemplate.Title = oPart.value ;
  104. else
  105. oTemplate.Title = 'Template ' + ( i + 1 ) ;
  106. // Get the Template Description.
  107. if ( (oPart = oXml.SelectSingleNode( 'Description', oNode )) )
  108. oTemplate.Description = oPart.text ? oPart.text : oPart.textContent ;
  109. // Get the Template Image.
  110. if ( (oPart = oNode.attributes.getNamedItem('image')) )
  111. oTemplate.Image = sImagesBasePath + oPart.value ;
  112. // Get the Template HTML.
  113. if ( (oPart = oXml.SelectSingleNode( 'Html', oNode )) )
  114. oTemplate.Html = oPart.text ? oPart.text : oPart.textContent ;
  115. else
  116. {
  117. alert( 'No HTML defined for template index ' + i + '. Please review the "' + FCKConfig.TemplatesXmlPath + '" file.' ) ;
  118. continue ;
  119. }
  120. FCK._Templates[ FCK._Templates.length ] = oTemplate ;
  121. }
  122. GetE('eLoading').style.display = 'none' ;
  123. }
  124. if ( FCK._Templates.length == 0 )
  125. GetE('eEmpty').style.display = '' ;
  126. else
  127. {
  128. for ( var j = 0 ; j < FCK._Templates.length ; j++ )
  129. {
  130. oTemplate = FCK._Templates[j] ;
  131. var oItemDiv = GetE('eList').appendChild( document.createElement( 'DIV' ) ) ;
  132. oItemDiv.TplIndex = j ;
  133. oItemDiv.className = 'TplItem' ;
  134. // Build the inner HTML of our new item DIV.
  135. var sInner = '<table><tr>' ;
  136. if ( oTemplate.Image )
  137. sInner += '<td valign="top"><img src="' + oTemplate.Image + '"><br />' ;
  138. else
  139. sInner += '<td valign="top"><img src="fck_template/images/noimage.gif"><br />' ;
  140. sInner += '<div class="TplTitle"><a href="javascript:void(0);" title="'+oTemplate.Description+'" >' + oTemplate.Title + '<\/a><\/div>';
  141. if ( oTemplate.Description )
  142. sInner += '<div>' + oTemplate.Description + '<\/div>' ;
  143. sInner += '<\/td><\/tr><\/table>' ;
  144. oItemDiv.innerHTML = sInner ;
  145. oItemDiv.onmouseover = ItemDiv_OnMouseOver ;
  146. oItemDiv.onmouseout = ItemDiv_OnMouseOut ;
  147. oItemDiv.onclick = ItemDiv_OnClick ;
  148. }
  149. }
  150. }
  151. function ItemDiv_OnMouseOver()
  152. {
  153. this.className += ' PopupSelectionBox' ;
  154. }
  155. function ItemDiv_OnMouseOut()
  156. {
  157. this.className = this.className.replace( /\s*PopupSelectionBox\s*/, '' ) ;
  158. }
  159. function ItemDiv_OnClick()
  160. {
  161. SelectTemplate( this.TplIndex ) ;
  162. if (window.top.hide_bar) {
  163. window.top.hide_bar();
  164. }
  165. }
  166. function SelectTemplate( index )
  167. {
  168. oEditor.FCKUndo.SaveUndoStep() ;
  169. FCK.SetHTML( FCK._Templates[index].Html ) ;
  170. }
  171. </script>
  172. </head>
  173. <body scroll="no" style="overflow: hidden; background-color: #ffffff;">
  174. <table width="100%" style="height: 100%;" valign="top">
  175. <tr>
  176. <td height="100%" align="center" valign="top">
  177. <div id="eList" align="left" valign="top" class="TplList">
  178. <div id="eLoading" align="center" style="display: none"><br />
  179. <span fcklang="DlgTemplatesLoading">Loading templates list. Please wait...</span>
  180. </div>
  181. <div id="eEmpty" align="center" style="display: none"><br />
  182. <span fcklang="DlgTemplatesNoTpl">(No templates defined)</span>
  183. </div>
  184. </div>
  185. </td>
  186. </tr>
  187. </table>
  188. </body>
  189. </html>