source: trunk/plugins/InsertSnippet/popups/insertsnippet.html @ 580

Last change on this file since 580 was 439, checked in by gocher, 14 years ago

new plugin InsertSnippet?

from Ticket #622 (only the img/ed_snippet.gif changed)

File size: 3.5 KB
Line 
1<html>
2<head>
3<title>Insert Snippet</title>
4<link rel="stylesheet" type="text/css" href="../../../popups/popup.css" />
5<script type="text/javascript" src="../../../popups/popup.js"></script>
6<script type="text/javascript">
7
8var InsertSnippet = window.opener.InsertSnippet;
9var editor = null;
10var config;
11
12function Init() {
13  __dlg_translate("InsertSnippet");
14  __dlg_init();
15 
16  var config = window.dialogArguments;
17 
18 eval(HTMLArea._geturlcontent(config.InsertSnippet.snippets));
19 
20  if (config.InsertSnippet.css.length > 0)
21  {
22          for (var i=0;i< config.InsertSnippet.css.length;i++)
23          {
24                var style = document.createElement("link");
25            style.rel = 'stylesheet';
26            style.href =  config.InsertSnippet.css[i];
27            document.getElementsByTagName("HEAD")[0].appendChild(style);
28          }
29  }
30
31  window.resizeTo(800, 600);
32  window.moveTo(80, 80);
33  var tbody = document.getElementById("snippettable");
34  var snippet_html;
35  var snippet_name;
36  var trow;
37  for(var i = 0; i < snippets.length; i++)
38  {
39          trow = tbody.insertRow(i);
40          snippet_html = snippets[i]['HTML'];
41          snippet_name = snippets[i]['id'];
42         
43          var insertAsVariable = '';
44          if (config.InsertSnippet.showInsertVariable)
45          {
46                insertAsVariable = ' | <a href="javascript:onOK('+i+','+'\'variable\''+')">'+HTMLArea._lc("Variable","InsertSnippet")+'</a>';
47          }
48          var new_cell = trow.insertCell(0);
49          new_cell.innerHTML = snippet_name +': '+HTMLArea._lc("Insert as","InsertSnippet")+' <a href="javascript:onOK('+i+','+'\'html\''+')">HTML</a>'+insertAsVariable + ' (<a id="show_preview'+i+'" href="javascript:preview(\'show\','+i+')">'+HTMLArea._lc("Show preview","InsertSnippet")+'</a>)<div id="preview'+i+'" style="display:none">'+snippets[i]['HTML']+'</div>';
50          new_cell.id = 'cell' + i;
51         
52  }
53
54  document.body.onkeypress = __dlg_key_press;
55}
56
57function preview(action,i) {
58        var show_preview_link = document.getElementById('show_preview'+i);
59        switch(action)
60        {
61                case 'show':
62                        document.getElementById('preview'+i).style.display = 'block';
63                        show_preview_link.innerHTML = HTMLArea._lc("Hide preview","InsertSnippet");
64                        show_preview_link.href = "javascript:preview('hide','"+i+"');";
65                       
66                break;
67                case 'hide':
68                        document.getElementById('preview'+i).style.display = 'none';
69                        show_preview_link.innerHTML = HTMLArea._lc("Show preview","InsertSnippet");
70                        show_preview_link.href = "javascript:preview('show','"+i+"');";
71                break;
72        }
73}
74function onCancel() {
75  __dlg_close(null);
76  return false;
77}
78
79function onOK(snippetnum,how) {
80  var params = new Object();
81  params["snippetnum"] = snippetnum;
82  params["how"] = how;
83  __dlg_close(params);
84  return false;
85}
86
87function __dlg_key_press(ev) {
88  ev || (ev = window.event);
89  switch(ev.keyCode) {
90    case 13:
91    document.getElementById('bt_ok').click();
92      break;
93    case 27:
94    __dlg_close();
95    return false;
96  }
97return true;
98}
99</script>
100
101<style type="text/css">
102body {margin:0 !IMPORTANT;padding:0 !IMPORTANT;}
103.buttons {border-top: 1px solid #999; padding: 5px; text-align: right; height: 20px; }
104td {background:white;padding:5px;border:1px solid;border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;}
105.preview {}
106</style>
107</head>
108  <body class="dialog" onload="Init()">
109<form action="" method="get">
110  <div class="title" >Insert Snippet</div>
111  <div style="height:470px;overflow:auto;">
112  <table style="border: 0; width: 100%;" id="snippettable">
113  </table>
114  </div>
115<div class="space"></div>
116<div class="buttons">
117<button type="button" onclick="return onCancel();">Cancel</button>
118</div>
119</form>
120</body>
121</html>
Note: See TracBrowser for help on using the repository browser.