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

Last change on this file since 681 was 681, checked in by ray, 13 years ago

Ticket #916 TODO: Change plugins to use Xinha object name

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