tinyeditor_rails 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -8
- data/lib/tinyeditor_rails.rb +6 -0
- metadata +4 -16
- data/.document +0 -5
- data/Gemfile +0 -13
- data/Gemfile.lock +0 -63
- data/Rakefile +0 -43
- data/VERSION +0 -1
- data/app/assets/javascripts/tinyeditor_rails/main.js +0 -1
- data/vendor/assets/images/header-bg.gif +0 -0
- data/vendor/assets/images/icons.png +0 -0
- data/vendor/assets/images/resize.gif +0 -0
- data/vendor/assets/javascripts/tiny.editor.js +0 -233
- data/vendor/assets/javascripts/tiny.editor.packed.js +0 -1
- data/vendor/assets/stylesheets/tinyeditor.css +0 -17
data/README.rdoc
CHANGED
@@ -1,16 +1,31 @@
|
|
1
1
|
= tinyeditor_rails
|
2
2
|
|
3
|
-
|
3
|
+
Add this line to your application's Gemfile:
|
4
|
+
|
5
|
+
gem 'tinyeditor_rails'
|
6
|
+
|
7
|
+
And then execute:
|
8
|
+
|
9
|
+
$ bundle
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Add to your application.css
|
14
|
+
|
15
|
+
*= require tinyeditor_rails/style
|
16
|
+
|
17
|
+
Add to your application.js
|
18
|
+
|
19
|
+
//= require tinyeditor_rails/main
|
20
|
+
|
4
21
|
|
5
22
|
== Contributing to tinyeditor_rails
|
6
23
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
-
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
24
|
+
1. Fork it
|
25
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
26
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
27
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
28
|
+
5. Create new Pull Request
|
14
29
|
|
15
30
|
== Copyright
|
16
31
|
|
data/lib/tinyeditor_rails.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tinyeditor_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -83,21 +83,9 @@ extra_rdoc_files:
|
|
83
83
|
- LICENSE.txt
|
84
84
|
- README.rdoc
|
85
85
|
files:
|
86
|
-
- .
|
87
|
-
- Gemfile
|
88
|
-
- Gemfile.lock
|
86
|
+
- lib/tinyeditor_rails.rb
|
89
87
|
- LICENSE.txt
|
90
88
|
- README.rdoc
|
91
|
-
- Rakefile
|
92
|
-
- VERSION
|
93
|
-
- app/assets/javascripts/tinyeditor_rails/main.js
|
94
|
-
- lib/tinyeditor_rails.rb
|
95
|
-
- vendor/assets/images/header-bg.gif
|
96
|
-
- vendor/assets/images/icons.png
|
97
|
-
- vendor/assets/images/resize.gif
|
98
|
-
- vendor/assets/javascripts/tiny.editor.js
|
99
|
-
- vendor/assets/javascripts/tiny.editor.packed.js
|
100
|
-
- vendor/assets/stylesheets/tinyeditor.css
|
101
89
|
homepage: http://github.com/yunanhelmy/tinyeditor_rails
|
102
90
|
licenses:
|
103
91
|
- MIT
|
@@ -113,7 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
101
|
version: '0'
|
114
102
|
segments:
|
115
103
|
- 0
|
116
|
-
hash: -
|
104
|
+
hash: -272364365
|
117
105
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
106
|
none: false
|
119
107
|
requirements:
|
data/.document
DELETED
data/Gemfile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
|
-
|
6
|
-
# Add dependencies to develop your gem here.
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
group :development do
|
9
|
-
gem "rspec"
|
10
|
-
gem "rdoc", "~> 3.12"
|
11
|
-
gem "bundler", "~> 1.0"
|
12
|
-
gem "jeweler", "~> 1.8.7"
|
13
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,63 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
addressable (2.3.5)
|
5
|
-
builder (3.2.2)
|
6
|
-
diff-lcs (1.2.5)
|
7
|
-
faraday (0.8.8)
|
8
|
-
multipart-post (~> 1.2.0)
|
9
|
-
git (1.2.6)
|
10
|
-
github_api (0.10.1)
|
11
|
-
addressable
|
12
|
-
faraday (~> 0.8.1)
|
13
|
-
hashie (>= 1.2)
|
14
|
-
multi_json (~> 1.4)
|
15
|
-
nokogiri (~> 1.5.2)
|
16
|
-
oauth2
|
17
|
-
hashie (2.0.5)
|
18
|
-
highline (1.6.20)
|
19
|
-
httpauth (0.2.0)
|
20
|
-
jeweler (1.8.8)
|
21
|
-
builder
|
22
|
-
bundler (~> 1.0)
|
23
|
-
git (>= 1.2.5)
|
24
|
-
github_api (= 0.10.1)
|
25
|
-
highline (>= 1.6.15)
|
26
|
-
nokogiri (= 1.5.10)
|
27
|
-
rake
|
28
|
-
rdoc
|
29
|
-
json (1.8.1)
|
30
|
-
jwt (0.1.8)
|
31
|
-
multi_json (>= 1.5)
|
32
|
-
multi_json (1.8.2)
|
33
|
-
multi_xml (0.5.5)
|
34
|
-
multipart-post (1.2.0)
|
35
|
-
nokogiri (1.5.10)
|
36
|
-
oauth2 (0.9.2)
|
37
|
-
faraday (~> 0.8)
|
38
|
-
httpauth (~> 0.2)
|
39
|
-
jwt (~> 0.1.4)
|
40
|
-
multi_json (~> 1.0)
|
41
|
-
multi_xml (~> 0.5)
|
42
|
-
rack (~> 1.2)
|
43
|
-
rack (1.5.2)
|
44
|
-
rake (10.1.0)
|
45
|
-
rdoc (3.12.2)
|
46
|
-
json (~> 1.4)
|
47
|
-
rspec (2.14.1)
|
48
|
-
rspec-core (~> 2.14.0)
|
49
|
-
rspec-expectations (~> 2.14.0)
|
50
|
-
rspec-mocks (~> 2.14.0)
|
51
|
-
rspec-core (2.14.7)
|
52
|
-
rspec-expectations (2.14.4)
|
53
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
54
|
-
rspec-mocks (2.14.4)
|
55
|
-
|
56
|
-
PLATFORMS
|
57
|
-
ruby
|
58
|
-
|
59
|
-
DEPENDENCIES
|
60
|
-
bundler (~> 1.0)
|
61
|
-
jeweler (~> 1.8.7)
|
62
|
-
rdoc (~> 3.12)
|
63
|
-
rspec
|
data/Rakefile
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "tinyeditor_rails"
|
16
|
-
gem.homepage = "http://github.com/yunanhelmy/tinyeditor_rails"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = "Javascript WYSIWYG using tinyEditor"
|
19
|
-
gem.description = "Javascript WYSIWYG using tinyEditor"
|
20
|
-
gem.email = "m.yunan.helmy@gmail.com"
|
21
|
-
gem.authors = ["yunanhelmy"]
|
22
|
-
# dependencies defined in Gemfile
|
23
|
-
end
|
24
|
-
Jeweler::RubygemsDotOrgTasks.new
|
25
|
-
|
26
|
-
require 'rake/testtask'
|
27
|
-
Rake::TestTask.new(:test) do |test|
|
28
|
-
test.libs << 'lib' << 'test'
|
29
|
-
test.pattern = 'test/**/test_*.rb'
|
30
|
-
test.verbose = true
|
31
|
-
end
|
32
|
-
|
33
|
-
task :default => :test
|
34
|
-
|
35
|
-
require 'rdoc/task'
|
36
|
-
Rake::RDocTask.new do |rdoc|
|
37
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
38
|
-
|
39
|
-
rdoc.rdoc_dir = 'rdoc'
|
40
|
-
rdoc.title = "tinyeditor_rails #{version}"
|
41
|
-
rdoc.rdoc_files.include('README*')
|
42
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
43
|
-
end
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.0
|
@@ -1 +0,0 @@
|
|
1
|
-
//require tiny.editor
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,233 +0,0 @@
|
|
1
|
-
var TINY = TINY || {},
|
2
|
-
T$ = T$ || function(i) {return document.getElementById(i)},
|
3
|
-
T$$$ = T$$$ || function() {return document.all?1 : 0};
|
4
|
-
|
5
|
-
TINY.editor = function() {
|
6
|
-
var c = [], offset = -30;
|
7
|
-
c['bold'] = [4, 'Bold', 'a', 'bold'];
|
8
|
-
c['italic'] = [5, 'Italic', 'a', 'italic'];
|
9
|
-
c['underline'] = [6, 'Underline', 'a', 'underline'];
|
10
|
-
c['strikethrough'] = [7, 'Strikethrough', 'a', 'strikethrough'];
|
11
|
-
c['subscript'] = [8, 'Subscript', 'a', 'subscript'];
|
12
|
-
c['superscript'] = [9, 'Superscript', 'a', 'superscript'];
|
13
|
-
c['orderedlist'] = [10, 'Insert Ordered List', 'a', 'insertorderedlist'];
|
14
|
-
c['unorderedlist'] = [11, 'Insert Unordered List', 'a', 'insertunorderedlist'];
|
15
|
-
c['outdent'] = [12, 'Outdent', 'a', 'outdent'];
|
16
|
-
c['indent'] = [13, 'Indent', 'a', 'indent'];
|
17
|
-
c['leftalign'] = [14, 'Left Align', 'a', 'justifyleft'];
|
18
|
-
c['centeralign'] = [15, 'Center Align', 'a', 'justifycenter'];
|
19
|
-
c['rightalign'] = [16, 'Right Align', 'a', 'justifyright'];
|
20
|
-
c['blockjustify'] = [17, 'Block Justify', 'a', 'justifyfull'];
|
21
|
-
c['undo'] = [18, 'Undo', 'a', 'undo'];
|
22
|
-
c['redo'] = [19, 'Redo', 'a', 'redo'];
|
23
|
-
c['image'] = [20, 'Insert Image', 'i', 'insertimage', 'Enter Image URL:', 'http://'];
|
24
|
-
c['hr'] = [21, 'Insert Horizontal Rule', 'a', 'inserthorizontalrule'];
|
25
|
-
c['link'] = [22, 'Insert Hyperlink', 'i', 'createlink', 'Enter URL:', 'http://'];
|
26
|
-
c['unlink'] = [23, 'Remove Hyperlink', 'a', 'unlink'];
|
27
|
-
c['unformat'] = [24, 'Remove Formatting', 'a', 'removeformat'];
|
28
|
-
c['print'] = [25, 'Print', 'a', 'print'];
|
29
|
-
function edit(n, obj) {
|
30
|
-
this.n = n; window[n] = this; this.t = T$(obj.id); this.obj = obj; this.xhtml = obj.xhtml;
|
31
|
-
var p = document.createElement('div'), w = document.createElement('div'), h = document.createElement('div'),
|
32
|
-
l = obj.controls.length, i = 0;
|
33
|
-
this.i = document.createElement('iframe');
|
34
|
-
this.i.width = obj.width || '500'; this.i.height = obj.height || '250'; this.ie = T$$$();
|
35
|
-
h.className = obj.rowclass || 'tinyeditor-header'; p.className = obj.cssclass || 'tinyeditor'; p.style.width = this.i.width + 'px'; p.appendChild(h);
|
36
|
-
for(i; i < l; i++) {
|
37
|
-
var id = obj.controls[i];
|
38
|
-
if(id = = 'n') {
|
39
|
-
h = document.createElement('div'); h.className = obj.rowclass || 'tinyeditor-header'; p.appendChild(h);
|
40
|
-
} else if(id = = '|') {
|
41
|
-
var d = document.createElement('div'); d.className = obj.dividerclass || 'tinyeditor-divider'; h.appendChild(d);
|
42
|
-
} else if(id = = 'font') {
|
43
|
-
var sel = document.createElement('select'), fonts = obj.fonts || ['Verdana', 'Arial', 'Georgia'], fl = fonts.length, x = 0;
|
44
|
-
sel.className = 'tinyeditor-font'; sel.onchange = new Function(this.n + '.ddaction(this, "fontname")');
|
45
|
-
sel.options[0] = new Option('Font', '');
|
46
|
-
for(x; x < fl; x++) {
|
47
|
-
var font = fonts[x];
|
48
|
-
sel.options[x + 1] = new Option(font, font);
|
49
|
-
}
|
50
|
-
h.appendChild(sel)
|
51
|
-
} else if(id = = 'size') {
|
52
|
-
var sel = document.createElement('select'), sizes = obj.sizes || [1, 2, 3, 4, 5, 6, 7], sl = sizes.length, x = 0;
|
53
|
-
sel.className = 'tinyeditor-size'; sel.onchange = new Function(this.n + '.ddaction(this, "fontsize")');
|
54
|
-
for(x; x < sl; x++) {
|
55
|
-
var size = sizes[x];
|
56
|
-
sel.options[x] = new Option(size, size);
|
57
|
-
}
|
58
|
-
h.appendChild(sel)
|
59
|
-
} else if(id = = 'style') {
|
60
|
-
var sel = document.createElement('select'),
|
61
|
-
styles = obj.styles || [['Style', ''], ['Paragraph', '<p>'], ['Header 1', '<h1>'], ['Header 2', '<h2>'], ['Header 3', '<h3>'], ['Header 4', '<h4>'], ['Header 5', '<h5>'], ['Header 6', '<h6>']],
|
62
|
-
sl = styles.length, x = 0;
|
63
|
-
sel.className = 'tinyeditor-style'; sel.onchange = new Function(this.n + '.ddaction(this, "formatblock")');
|
64
|
-
for(x; x < sl; x++) {
|
65
|
-
var style = styles[x];
|
66
|
-
sel.options[x] = new Option(style[0], style[1]);
|
67
|
-
}
|
68
|
-
h.appendChild(sel);
|
69
|
-
} else if(c[id]) {
|
70
|
-
var div = document.createElement('div'), x = c[id], func = x[2], ex, pos = x[0] * offset;
|
71
|
-
div.className = obj.controlclass;
|
72
|
-
div.unselectable = 'on';
|
73
|
-
div.style.backgroundPosition = '0px ' + pos + 'px';
|
74
|
-
div.title = x[1];
|
75
|
-
ex = func = = 'a'?'.action("' + x[3] + '", 0, ' + (x[4] || 0) + ')' : '.insert("' + x[4] + '", "' + x[5] + '", "' + x[3] + '")';
|
76
|
-
div.onmousedown = new Function(this.n + (id = = 'print'?'.print()' : ex));
|
77
|
-
div.onmouseover = new Function(this.n + '.hover(this, ' + pos + ', 1)');
|
78
|
-
div.onmouseout = new Function(this.n + '.hover(this, ' + pos + ', 0)');
|
79
|
-
h.appendChild(div);
|
80
|
-
if(this.ie) {div.unselectable = 'on'}
|
81
|
-
}
|
82
|
-
}
|
83
|
-
this.t.parentNode.insertBefore(p, this.t); this.t.style.width = this.i.width + 'px';
|
84
|
-
w.appendChild(this.t); w.appendChild(this.i); p.appendChild(w); this.t.style.display = 'none';
|
85
|
-
if(obj.footer) {
|
86
|
-
var f = document.createElement('div'); f.className = obj.footerclass || 'tinyeditor-footer';
|
87
|
-
if(obj.toggle) {
|
88
|
-
var to = obj.toggle, ts = document.createElement('div');
|
89
|
-
ts.className = to.cssclass || 'toggle'; ts.innerHTML = obj.toggletext || 'source';
|
90
|
-
ts.onclick = new Function(this.n + '.toggle(0, this);return false');
|
91
|
-
f.appendChild(ts);
|
92
|
-
}
|
93
|
-
if(obj.resize) {
|
94
|
-
var ro = obj.resize, rs = document.createElement('div'); rs.className = ro.cssclass || 'resize';
|
95
|
-
rs.onmousedown = new Function('event', this.n + '.resize(event);return false');
|
96
|
-
rs.onselectstart = function() {return false};
|
97
|
-
f.appendChild(rs);
|
98
|
-
}
|
99
|
-
p.appendChild(f);
|
100
|
-
}
|
101
|
-
this.e = this.i.contentWindow.document; this.e.open();
|
102
|
-
var m = '<html><head>', bodyid = obj.bodyid?" id=\"" + obj.bodyid + "\"" : "";
|
103
|
-
if(obj.cssfile) {m + = '<link rel="stylesheet" href="' + obj.cssfile + '" />'}
|
104
|
-
if(obj.css) {m + = '<style type="text/css">' + obj.css + '</style>'}
|
105
|
-
m + = '</head><body' + bodyid + ' contenteditable="true">' + (obj.content || this.t.value);
|
106
|
-
m + = '</body></html>';
|
107
|
-
this.e.write(m);
|
108
|
-
this.e.close(); this.e.designMode = 'On'; this.d = 1;
|
109
|
-
if(this.xhtml) {
|
110
|
-
try{this.e.execCommand("styleWithCSS", 0, 0)}
|
111
|
-
catch(e) {try{this.e.execCommand("useCSS", 0, 1)}catch(e) {}}
|
112
|
-
}
|
113
|
-
};
|
114
|
-
edit.prototype.print = function() {
|
115
|
-
this.i.contentWindow.print();
|
116
|
-
};
|
117
|
-
edit.prototype.hover = function(div, pos, dir) {
|
118
|
-
this.getSelection();
|
119
|
-
div.style.backgroundPosition = (dir ? '34px ' : '0px ') + (pos) + 'px';
|
120
|
-
};
|
121
|
-
edit.prototype.getSelection = function() {
|
122
|
-
if(this.ie && this.e.getSelection) {
|
123
|
-
this.sel = this.e.getSelection();
|
124
|
-
if(this.sel.getRangeAt && this.sel.rangeCount) {
|
125
|
-
this.range = this.sel.getRangeAt(0);
|
126
|
-
}
|
127
|
-
}
|
128
|
-
};
|
129
|
-
edit.prototype.restoreSelection = function() {
|
130
|
-
if (this.range && this.ie) {
|
131
|
-
if (this.e.getSelection) {
|
132
|
-
this.sel = this.e.getSelection();
|
133
|
-
this.sel.removeAllRanges();
|
134
|
-
this.sel.addRange(this.range);
|
135
|
-
}
|
136
|
-
}
|
137
|
-
};
|
138
|
-
edit.prototype.ddaction = function(dd, a) {
|
139
|
-
var i = dd.selectedIndex, v = dd.options[i].value;
|
140
|
-
this.action(a, v);
|
141
|
-
};
|
142
|
-
edit.prototype.action = function(cmd, val, ie) {
|
143
|
-
if(ie && !this.ie) {
|
144
|
-
alert('Your browser does not support this function.')
|
145
|
-
} else{
|
146
|
-
this.restoreSelection();
|
147
|
-
this.e.execCommand(cmd, 0, val || null);
|
148
|
-
}
|
149
|
-
};
|
150
|
-
edit.prototype.insert = function(pro, msg, cmd) {
|
151
|
-
var val = prompt(pro, msg);
|
152
|
-
if(val! = null && val! = '') {this.e.execCommand(cmd, 0, val)}
|
153
|
-
};
|
154
|
-
edit.prototype.setfont = function() {
|
155
|
-
this.restoreSelection();
|
156
|
-
execCommand('formatblock', 0, hType);
|
157
|
-
};
|
158
|
-
edit.prototype.resize = function(e) {
|
159
|
-
if(this.mv) {this.freeze()}
|
160
|
-
this.i.bcs = TINY.cursor.top(e);
|
161
|
-
this.mv = new Function('event', this.n + '.move(event)');
|
162
|
-
this.sr = new Function(this.n + '.freeze()');
|
163
|
-
if(this.ie) {
|
164
|
-
document.attachEvent('onmousemove', this.mv); document.attachEvent('onmouseup', this.sr);
|
165
|
-
} else{
|
166
|
-
document.addEventListener('mousemove', this.mv, 1); document.addEventListener('mouseup', this.sr, 1);
|
167
|
-
}
|
168
|
-
};
|
169
|
-
edit.prototype.move = function(e) {
|
170
|
-
var pos = TINY.cursor.top(e);
|
171
|
-
this.i.height = parseInt(this.i.height) + pos-this.i.bcs;
|
172
|
-
this.i.bcs = pos;
|
173
|
-
};
|
174
|
-
edit.prototype.freeze = function() {
|
175
|
-
if(this.ie) {
|
176
|
-
document.detachEvent('onmousemove', this.mv); document.detachEvent('onmouseup', this.sr);
|
177
|
-
} else{
|
178
|
-
document.removeEventListener('mousemove', this.mv, 1); document.removeEventListener('mouseup', this.sr, 1);
|
179
|
-
}
|
180
|
-
};
|
181
|
-
edit.prototype.toggle = function(post, div) {
|
182
|
-
if(!this.d) {
|
183
|
-
var v = this.t.value;
|
184
|
-
if(div) {div.innerHTML = this.obj.toggletext || 'source'}
|
185
|
-
if(this.xhtml && !this.ie) {
|
186
|
-
v = v.replace(/<strong>(.*)<\/strong>/gi, '<span style="font-weight:bold;">$1</span>');
|
187
|
-
v = v.replace(/<em>(.*)<\/em>/gi, '<span style="font-weight:italic;">$1</span>');
|
188
|
-
}
|
189
|
-
this.e.body.innerHTML = v;
|
190
|
-
this.t.style.display = 'none'; this.i.style.display = 'block'; this.d = 1;
|
191
|
-
} else{
|
192
|
-
var v = this.e.body.innerHTML;
|
193
|
-
if(this.xhtml) {
|
194
|
-
v = v.replace(/<span class="apple-style-span">(.*)<\/span>/gi, '$1');
|
195
|
-
v = v.replace(/ class="apple-style-span"/gi, '');
|
196
|
-
v = v.replace(/<span style="">/gi, '');
|
197
|
-
v = v.replace(/<br>/gi, '<br />');
|
198
|
-
v = v.replace(/<br ?\/?>$/gi, '');
|
199
|
-
v = v.replace(/^<br ?\/?>/gi, '');
|
200
|
-
v = v.replace(/(<img [^>]+[^\/])>/gi, '$1 />');
|
201
|
-
v = v.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>');
|
202
|
-
v = v.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi, '<em>$1</em>');
|
203
|
-
v = v.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi, '<span style="text-decoration:underline">$1</span>');
|
204
|
-
v = v.replace(/<(b|strong|em|i|u) style="font-weight:normal;?">(.*)<\/(b|strong|em|i|u)>/gi, '$2');
|
205
|
-
v = v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi, '<span style="$2"><$4>$3</$4></span>');
|
206
|
-
v = v.replace(/<span style="font-weight:normal;?">(.*)<\/span>/gi, '$1');
|
207
|
-
v = v.replace(/<span style="font-weight:bold;?">(.*)<\/span>/gi, '<strong>$1</strong>');
|
208
|
-
v = v.replace(/<span style="font-style:italic;?">(.*)<\/span>/gi, '<em>$1</em>');
|
209
|
-
v = v.replace(/<span style="font-weight:bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>');
|
210
|
-
}
|
211
|
-
if(div) {div.innerHTML = this.obj.toggletext || 'wysiwyg'}
|
212
|
-
this.t.value = v;
|
213
|
-
if(!post) {
|
214
|
-
this.t.style.height = this.i.height + 'px';
|
215
|
-
this.i.style.display = 'none'; this.t.style.display = 'block'; this.d = 0;
|
216
|
-
}
|
217
|
-
}
|
218
|
-
};
|
219
|
-
edit.prototype.post = function() {
|
220
|
-
if(this.d) {
|
221
|
-
this.toggle(1);
|
222
|
-
}
|
223
|
-
};
|
224
|
-
return { edit : edit }
|
225
|
-
}();
|
226
|
-
|
227
|
-
TINY.cursor = function() {
|
228
|
-
return {
|
229
|
-
top : function(e) {
|
230
|
-
return T$$$()?window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop : e.clientY + window.scrollY;
|
231
|
-
}
|
232
|
-
}
|
233
|
-
}();
|
@@ -1 +0,0 @@
|
|
1
|
-
var TINY=TINY||{},T$=T$||function(i){return document.getElementById(i)},T$$$=T$$$||function(){return document.all?1:0};TINY.editor=function(){var c=[],offset=-30;c['bold']=[4,'Bold','a','bold'];c['italic']=[5,'Italic','a','italic'];c['underline']=[6,'Underline','a','underline'];c['strikethrough']=[7,'Strikethrough','a','strikethrough'];c['subscript']=[8,'Subscript','a','subscript'];c['superscript']=[9,'Superscript','a','superscript'];c['orderedlist']=[10,'Insert Ordered List','a','insertorderedlist'];c['unorderedlist']=[11,'Insert Unordered List','a','insertunorderedlist'];c['outdent']=[12,'Outdent','a','outdent'];c['indent']=[13,'Indent','a','indent'];c['leftalign']=[14,'Left Align','a','justifyleft'];c['centeralign']=[15,'Center Align','a','justifycenter'];c['rightalign']=[16,'Right Align','a','justifyright'];c['blockjustify']=[17,'Block Justify','a','justifyfull'];c['undo']=[18,'Undo','a','undo'];c['redo']=[19,'Redo','a','redo'];c['image']=[20,'Insert Image','i','insertimage','Enter Image URL:','http://'];c['hr']=[21,'Insert Horizontal Rule','a','inserthorizontalrule'];c['link']=[22,'Insert Hyperlink','i','createlink','Enter URL:','http://'];c['unlink']=[23,'Remove Hyperlink','a','unlink'];c['unformat']=[24,'Remove Formatting','a','removeformat'];c['print']=[25,'Print','a','print'];function edit(n,obj){this.n=n;window[n]=this;this.t=T$(obj.id);this.obj=obj;this.xhtml=obj.xhtml;var p=document.createElement('div'),w=document.createElement('div'),h=document.createElement('div'),l=obj.controls.length,i=0;this.i=document.createElement('iframe');this.i.width=obj.width||'500';this.i.height=obj.height||'250';this.ie=T$$$();h.className=obj.rowclass||'tinyeditor-header';p.className=obj.cssclass||'tinyeditor';p.style.width=this.i.width+'px';p.appendChild(h);for(i;i<l;i++){var id=obj.controls[i];if(id=='n'){h=document.createElement('div');h.className=obj.rowclass||'tinyeditor-header';p.appendChild(h)}else if(id=='|'){var d=document.createElement('div');d.className=obj.dividerclass||'tinyeditor-divider';h.appendChild(d)}else if(id=='font'){var sel=document.createElement('select'),fonts=obj.fonts||['Verdana','Arial','Georgia'],fl=fonts.length,x=0;sel.className='tinyeditor-font';sel.onchange=new Function(this.n+'.ddaction(this, "fontname")');sel.options[0]=new Option('Font','');for(x;x<fl;x++){var font=fonts[x];sel.options[x+1]=new Option(font,font)}h.appendChild(sel)}else if(id=='size'){var sel=document.createElement('select'),sizes=obj.sizes||[1,2,3,4,5,6,7],sl=sizes.length,x=0;sel.className='tinyeditor-size';sel.onchange=new Function(this.n+'.ddaction(this, "fontsize")');for(x;x<sl;x++){var size=sizes[x];sel.options[x]=new Option(size,size)}h.appendChild(sel)}else if(id=='style'){var sel=document.createElement('select'),styles=obj.styles||[['Style',''],['Paragraph','<p>'],['Header 1','<h1>'],['Header 2','<h2>'],['Header 3','<h3>'],['Header 4','<h4>'],['Header 5','<h5>'],['Header 6','<h6>']],sl=styles.length,x=0;sel.className='tinyeditor-style';sel.onchange=new Function(this.n+'.ddaction(this, "formatblock")');for(x;x<sl;x++){var style=styles[x];sel.options[x]=new Option(style[0],style[1])}h.appendChild(sel)}else if(c[id]){var div=document.createElement('div'),x=c[id],func=x[2],ex,pos=x[0]*offset;div.className=obj.controlclass;div.unselectable='on';div.style.backgroundPosition='0px '+pos+'px';div.title=x[1];ex=func=='a'?'.action("'+x[3]+'", 0, '+(x[4]||0)+')':'.insert("'+x[4]+'", "'+x[5]+'", "'+x[3]+'")';div.onmousedown=new Function(this.n+(id=='print'?'.print()':ex));div.onmouseover=new Function(this.n+'.hover(this, '+pos+', 1)');div.onmouseout=new Function(this.n+'.hover(this, '+pos+', 0)');h.appendChild(div);if(this.ie){div.unselectable='on'}}}this.t.parentNode.insertBefore(p,this.t);this.t.style.width=this.i.width+'px';w.appendChild(this.t);w.appendChild(this.i);p.appendChild(w);this.t.style.display='none';if(obj.footer){var f=document.createElement('div');f.className=obj.footerclass||'tinyeditor-footer';if(obj.toggle){var to=obj.toggle,ts=document.createElement('div');ts.className=to.cssclass||'toggle';ts.innerHTML=obj.toggletext||'source';ts.onclick=new Function(this.n+'.toggle(0, this);return false');f.appendChild(ts)}if(obj.resize){var ro=obj.resize,rs=document.createElement('div');rs.className=ro.cssclass||'resize';rs.onmousedown=new Function('event',this.n+'.resize(event);return false');rs.onselectstart=function(){return false};f.appendChild(rs)}p.appendChild(f)}this.e=this.i.contentWindow.document;this.e.open();var m='<html><head>',bodyid=obj.bodyid?" id=\""+obj.bodyid+"\"":"";if(obj.cssfile){m+='<link rel="stylesheet" href="'+obj.cssfile+'" />'}if(obj.css){m+='<style type="text/css">'+obj.css+'</style>'}m+='</head><body'+bodyid+' contenteditable="true">'+(obj.content||this.t.value);m+='</body></html>';this.e.write(m);this.e.close();this.e.designMode='On';this.d=1;if(this.xhtml){try{this.e.execCommand("styleWithCSS",0,0)}catch(e){try{this.e.execCommand("useCSS",0,1)}catch(e){}}}};edit.prototype.print=function(){this.i.contentWindow.print()};edit.prototype.hover=function(div,pos,dir){this.getSelection();div.style.backgroundPosition=(dir?'34px ':'0px ')+(pos)+'px'};edit.prototype.getSelection=function(){if(this.ie&&this.e.getSelection){this.sel=this.e.getSelection();if(this.sel.getRangeAt&&this.sel.rangeCount){this.range=this.sel.getRangeAt(0)}}};edit.prototype.restoreSelection=function(){if(this.range&&this.ie){if(this.e.getSelection){this.sel=this.e.getSelection();this.sel.removeAllRanges();this.sel.addRange(this.range)}}};edit.prototype.ddaction=function(dd,a){var i=dd.selectedIndex,v=dd.options[i].value;this.action(a,v)};edit.prototype.action=function(cmd,val,ie){if(ie&&!this.ie){alert('Your browser does not support this function.')}else{this.restoreSelection();this.e.execCommand(cmd,0,val||null)}};edit.prototype.insert=function(pro,msg,cmd){var val=prompt(pro,msg);if(val!=null&&val!=''){this.e.execCommand(cmd,0,val)}};edit.prototype.setfont=function(){this.restoreSelection();execCommand('formatblock',0,hType)};edit.prototype.resize=function(e){if(this.mv){this.freeze()}this.i.bcs=TINY.cursor.top(e);this.mv=new Function('event',this.n+'.move(event)');this.sr=new Function(this.n+'.freeze()');if(this.ie){document.attachEvent('onmousemove',this.mv);document.attachEvent('onmouseup',this.sr)}else{document.addEventListener('mousemove',this.mv,1);document.addEventListener('mouseup',this.sr,1)}};edit.prototype.move=function(e){var pos=TINY.cursor.top(e);this.i.height=parseInt(this.i.height)+pos-this.i.bcs;this.i.bcs=pos};edit.prototype.freeze=function(){if(this.ie){document.detachEvent('onmousemove',this.mv);document.detachEvent('onmouseup',this.sr)}else{document.removeEventListener('mousemove',this.mv,1);document.removeEventListener('mouseup',this.sr,1)}};edit.prototype.toggle=function(post,div){if(!this.d){var v=this.t.value;if(div){div.innerHTML=this.obj.toggletext||'source'}if(this.xhtml&&!this.ie){v=v.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight:bold;">$1</span>');v=v.replace(/<em>(.*)<\/em>/gi,'<span style="font-weight:italic;">$1</span>')}this.e.body.innerHTML=v;this.t.style.display='none';this.i.style.display='block';this.d=1}else{var v=this.e.body.innerHTML;if(this.xhtml){v=v.replace(/<span class="apple-style-span">(.*)<\/span>/gi,'$1');v=v.replace(/ class="apple-style-span"/gi,'');v=v.replace(/<span style="">/gi,'');v=v.replace(/<br>/gi,'<br />');v=v.replace(/<br ?\/?>$/gi,'');v=v.replace(/^<br ?\/?>/gi,'');v=v.replace(/(<img [^>]+[^\/])>/gi,'$1 />');v=v.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>');v=v.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,'<em>$1</em>');v=v.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');v=v.replace(/<(b|strong|em|i|u) style="font-weight:normal;?">(.*)<\/(b|strong|em|i|u)>/gi,'$2');v=v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>');v=v.replace(/<span style="font-weight:normal;?">(.*)<\/span>/gi,'$1');v=v.replace(/<span style="font-weight:bold;?">(.*)<\/span>/gi,'<strong>$1</strong>');v=v.replace(/<span style="font-style:italic;?">(.*)<\/span>/gi,'<em>$1</em>');v=v.replace(/<span style="font-weight:bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>')}if(div){div.innerHTML=this.obj.toggletext||'wysiwyg'}this.t.value=v;if(!post){this.t.style.height=this.i.height+'px';this.i.style.display='none';this.t.style.display='block';this.d=0}}};edit.prototype.post=function(){if(this.d){this.toggle(1)}};return{edit:edit}}();TINY.cursor=function(){return{top:function(e){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY}}}();
|
@@ -1,17 +0,0 @@
|
|
1
|
-
body {margin:0; padding:25px; font:12px Verdana,Arial}
|
2
|
-
#tinyeditor {border:none; margin:0; padding:0; font:14px 'Courier New',Verdana}
|
3
|
-
.tinyeditor {border:1px solid #bbb; padding:0 1px 1px; font:12px Verdana,Arial}
|
4
|
-
.tinyeditor iframe {border:none; overflow-x:hidden}
|
5
|
-
.tinyeditor-header {height:31px; border-bottom:1px solid #bbb; background:url(images/header-bg.gif) repeat-x; padding-top:1px}
|
6
|
-
.tinyeditor-header select {float:left; margin-top:5px}
|
7
|
-
.tinyeditor-font {margin-left:12px}
|
8
|
-
.tinyeditor-size {margin:0 3px}
|
9
|
-
.tinyeditor-style {margin-right:12px}
|
10
|
-
.tinyeditor-divider {float:left; width:1px; height:30px; background:#ccc}
|
11
|
-
.tinyeditor-control {float:left; width:34px; height:30px; cursor:pointer; background-image:url(images/icons.png)}
|
12
|
-
.tinyeditor-control:hover {background-color:#fff; background-position:30px 0}
|
13
|
-
.tinyeditor-footer {height:32px; border-top:1px solid #bbb; background:#f5f5f5}
|
14
|
-
.toggle {float:left; background:url(images/icons.png) -34px 2px no-repeat; padding:9px 13px 0 31px; height:23px; border-right:1px solid #ccc; cursor:pointer; color:#666}
|
15
|
-
.toggle:hover {background-color:#fff}
|
16
|
-
.resize {float:right; height:32px; width:32px; background:url(images/resize.gif) 15px 15px no-repeat; cursor:s-resize}
|
17
|
-
#editor {cursor:text; margin:10px}
|