source: trunk/plugins/Filter/filter.js @ 849

Last change on this file since 849 was 849, checked in by gocher, 12 years ago

change htmlarea to Xinha in plugin Filter

  • Property svn:keywords set to LastChangedDate LastChangedRevision LastChangedBy HeadURL Id
File size: 2.2 KB
Line 
1// Filter plugin for Xinha
2// Implementation by Udo Schmal & Schaffrath NeueMedien
3// Original Author - Udo Schmal
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).
8function Filter(editor) {
9  this.editor = editor;
10  var cfg = editor.config;
11  var self = this;
12  // register the toolbar buttons provided by this plugin
13  cfg.registerButton({
14    id: "filter",
15    tooltip  : this._lc("Filter"),
16    image    : editor.imgURL("ed_filter.gif", "Filter"),
17    textMode : false,
18    action   : function(editor) {
19                 self.buttonPress(editor);
20               }
21  });
22  if (!cfg.Filters)
23    cfg.Filters = ["Paragraph","Word"];
24  for (var i = 0; i < editor.config.Filters.length; i++) {
25    self.add(editor.config.Filters[i]);
26  }
27  cfg.addToolbarElement("filter", "removeformat", 1);
28}
29
30Filter._pluginInfo =
31{
32  name          : "Filter",
33  version       : "1.0",
34  developer     : "Udo Schmal (gocher)",
35  developer_url : "",
36  sponsor       : "L.N.Schaffrath NeueMedien",
37  sponsor_url   : "http://www.schaffrath-neuemedien.de/",
38  c_owner       : "Udo Schmal & Schaffrath-NeueMedien",
39  license       : "htmlArea"
40};
41
42Filter.prototype.add = function(filterName) {
43  if(eval('typeof ' + filterName) == 'undefined') {
44    var filter = _editor_url + "plugins/filter/filters/" + filterName + ".js";
45    var head = document.getElementsByTagName("head")[0];
46    var evt = Xinha.is_ie ? "onreadystatechange" : "onload";
47    var script = document.createElement("script");
48    script.type = "text/javascript";
49    script.src = filter;
50    script[evt] = function() {
51      if(Xinha.is_ie && !/loaded|complete/.test(window.event.srcElement.readyState))  return;
52    }
53    head.appendChild(script);
54    //document.write("<script type='text/javascript' src='" + plugin_file + "'></script>");
55  }
56};
57
58Filter.prototype._lc = function(string) {
59    return Xinha._lc(string, 'Filter');
60};
61
62Filter.prototype.buttonPress = function(editor) {
63  var html = editor.getInnerHTML();
64  for (var i = 0; i < editor.config.Filters.length; i++) {
65    html = eval(editor.config.Filters[i])(html);
66  }
67  editor.setHTML(html);
68};
Note: See TracBrowser for help on using the repository browser.