source: trunk/plugins/Template/template.js @ 999

Last change on this file since 999 was 999, checked in by ray, 11 years ago

#1195 Allow to specify an external url to load a plugin from

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 3.8 KB
Line 
1// Template plugin for Xinha
2// Implementation by Udo Schmal based on HTMLArea 3.0
3// Original Author - Udo Schmal www.Schaffrath-NeueMedien.de
4//
5// (c) Udo Schmal & Schaffrath NeueMedien 2004
6// Distributed under the same terms as HTMLArea itself.
7// This notice MUST stay intact for use (see license.txt).
8
9function Template(editor) {
10  this.editor = editor;
11  var cfg = editor.config;
12  var self = this;
13
14  // register the toolbar buttons provided by this plugin
15  cfg.registerButton({
16    id       : "template",
17    tooltip  : Xinha._lc("Insert template","Template"),
18    image    : editor.imgURL("ed_template.gif", "Template"),
19    textMode : false,
20    action   : function(editor) {
21                 self.buttonPress(editor);
22               }
23  });
24  cfg.addToolbarElement("template", "inserthorizontalrule", 1);
25}
26
27Template._pluginInfo = {
28  name          : "Template",
29  version       : "1.0",
30  developer     : "Udo Schmal",
31  developer_url : "http://www.schaffrath-neuemedien.de/",
32  c_owner       : "Udo Schmal & Schaffrath NeueMedien",
33  license       : "htmlArea"
34};
35
36Template.prototype.onGenerate = function() {
37  this.editor.addEditorStylesheet(Xinha.getPluginDir("Template") + '/template.css');
38};
39
40Template.prototype.buttonPress = function(editor) {
41  editor._popupDialog( "plugin://Template/template", function( obj ) {
42    if ( !obj ) {//user must have pressed Cancel
43      return false;
44    }
45
46    var bodys = editor._doc.getElementsByTagName("body");
47    var body = bodys[0];
48
49  function getElement(x) {
50    var result = editor._doc.getElementById(x);
51    if (!result) {
52      result = editor._doc.createElement("div");
53      result.id = x;
54      result.innerHTML = x;
55      body.appendChild(result);
56    }
57    if (result.style)
58      result.removeAttribute("style");
59    return result;
60  }
61
62    var content = getElement("content");
63    var menu1 = getElement("menu1");
64    var menu2 = getElement("menu2");
65    var menu3 = getElement("menu3");
66    switch (obj["templ"]) {
67      case "1": menu1.style.position = "absolute";
68                menu1.style.right = "0px";
69                menu1.style.width = "28%";
70                menu1.style.backgroundColor = "#e1ddd9";
71                menu1.style.padding = "2px 20px";
72                content.style.position = "absolute";
73                content.style.left = "0px";
74                content.style.width = "70%";
75                content.style.backgroundColor = "#fff";
76                menu2.style.visibility = "hidden";
77                menu3.style.visibility = "hidden";
78                break;
79      case "2": menu1.style.position = "absolute";
80                menu1.style.left = "0px";
81                menu1.style.width = "28%";
82                menu1.style.height = "100%";
83                menu1.style.backgroundColor = "#e1ddd9";
84                content.style.position = "absolute";
85                content.style.right = "0px";
86                content.style.width = "70%";
87                content.style.backgroundColor = "#fff";
88                menu2.style.visibility = "hidden";
89                menu3.style.visibility = "hidden";
90                break
91      case "3": menu1.style.position = "absolute";
92                menu1.style.left = "0px";
93                menu1.style.width = "28%";
94                menu1.style.backgroundColor = "#e1ddd9";
95                menu2.style.position = "absolute";
96                menu2.style.right = "0px";
97                menu2.style.width = "28%";
98                menu2.style.backgroundColor = "#e1ddd9";
99                content.style.position = "absolute";
100                content.style.right = "30%";
101                content.style.width = "60%";
102                content.style.backgroundColor = "#fff";
103                menu3.style.visibility = "hidden";
104                break
105    }
106  }, null);
107};
Note: See TracBrowser for help on using the repository browser.