Menu

[r15]: / includes / htmlarea / plugins / FullPage / full-page.js  Maximize  Restore  History

Download this file

144 lines (132 with data), 3.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// FullPage Plugin for HTMLArea-3.0
// Implementation by Mihai Bazon. Sponsored by http://thycotic.com
//
// htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc.
// This notice MUST stay intact for use (see license.txt).
//
// A free WYSIWYG editor replacement for <textarea> fields.
// For full source code and docs, visit http://www.interactivetools.com/
//
// Version 3.0 developed by Mihai Bazon for InteractiveTools.
// http://dynarch.com/mishoo
//
// $Id: full-page.js,v 1.1 2004/01/15 01:41:14 fullo Exp $
function FullPage(editor) {
this.editor = editor;
var cfg = editor.config;
cfg.fullPage = true;
var tt = FullPage.I18N;
var self = this;
cfg.registerButton("FP-docprop", tt["Document properties"], editor.imgURL("docprop.gif", "FullPage"), false,
function(editor, id) {
self.buttonPress(editor, id);
});
// add a new line in the toolbar
cfg.toolbar[0].splice(0, 0, "separator");
cfg.toolbar[0].splice(0, 0, "FP-docprop");
};
FullPage._pluginInfo = {
name : "FullPage",
version : "1.0",
developer : "Mihai Bazon",
developer_url : "http://dynarch.com/mishoo/",
c_owner : "Mihai Bazon",
sponsor : "Thycotic Software Ltd.",
sponsor_url : "http://thycotic.com",
license : "htmlArea"
};
FullPage.prototype.buttonPress = function(editor, id) {
var self = this;
switch (id) {
case "FP-docprop":
var doc = editor._doc;
var links = doc.getElementsByTagName("link");
var style1 = '';
var style2 = '';
for (var i = links.length; --i >= 0;) {
var link = links[i];
if (/stylesheet/i.test(link.rel)) {
if (/alternate/i.test(link.rel))
style2 = link.href;
else
style1 = link.href;
}
}
var title = doc.getElementsByTagName("title")[0];
title = title ? title.innerHTML : '';
var init = {
f_doctype : editor.doctype,
f_title : title,
f_body_bgcolor : HTMLArea._colorToRgb(doc.body.style.backgroundColor),
f_body_fgcolor : HTMLArea._colorToRgb(doc.body.style.color),
f_base_style : style1,
f_alt_style : style2,
editor : editor
};
editor._popupDialog("plugin://FullPage/docprop", function(params) {
self.setDocProp(params);
}, init);
break;
}
};
FullPage.prototype.setDocProp = function(params) {
var txt = "";
var doc = this.editor._doc;
var head = doc.getElementsByTagName("head")[0];
var links = doc.getElementsByTagName("link");
var style1 = null;
var style2 = null;
for (var i = links.length; --i >= 0;) {
var link = links[i];
if (/stylesheet/i.test(link.rel)) {
if (/alternate/i.test(link.rel))
style2 = link;
else
style1 = link;
}
}
function createLink(alt) {
var link = doc.createElement("link");
link.rel = alt ? "alternate stylesheet" : "stylesheet";
head.appendChild(link);
return link;
};
if (!style1 && params.f_base_style)
style1 = createLink(false);
if (params.f_base_style)
style1.href = params.f_base_style;
else if (style1)
head.removeChild(style1);
if (!style2 && params.f_alt_style)
style2 = createLink(true);
if (params.f_alt_style)
style2.href = params.f_alt_style;
else if (style2)
head.removeChild(style2);
for (var i in params) {
var val = params[i];
switch (i) {
case "f_title":
var title = doc.getElementsByTagName("title")[0];
if (!title) {
title = doc.createElement("title");
head.appendChild(title);
} else while (node = title.lastChild)
title.removeChild(node);
if (!HTMLArea.is_ie)
title.appendChild(doc.createTextNode(val));
else
doc.title = val;
break;
case "f_doctype":
this.editor.setDoctype(val);
break;
case "f_body_bgcolor":
doc.body.style.backgroundColor = val;
break;
case "f_body_fgcolor":
doc.body.style.color = val;
break;
}
}
};
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.