tinyeditor_rails 0.1.1 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ # gem "railties"
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
@@ -0,0 +1,52 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.3.5)
5
+ builder (3.2.2)
6
+ faraday (0.8.8)
7
+ multipart-post (~> 1.2.0)
8
+ git (1.2.6)
9
+ github_api (0.10.1)
10
+ addressable
11
+ faraday (~> 0.8.1)
12
+ hashie (>= 1.2)
13
+ multi_json (~> 1.4)
14
+ nokogiri (~> 1.5.2)
15
+ oauth2
16
+ hashie (2.0.5)
17
+ highline (1.6.20)
18
+ httpauth (0.2.0)
19
+ jeweler (1.8.8)
20
+ builder
21
+ bundler (~> 1.0)
22
+ git (>= 1.2.5)
23
+ github_api (= 0.10.1)
24
+ highline (>= 1.6.15)
25
+ nokogiri (= 1.5.10)
26
+ rake
27
+ rdoc
28
+ json (1.8.1)
29
+ jwt (0.1.8)
30
+ multi_json (>= 1.5)
31
+ multi_json (1.8.2)
32
+ multi_xml (0.5.5)
33
+ multipart-post (1.2.0)
34
+ nokogiri (1.5.10)
35
+ oauth2 (0.9.2)
36
+ faraday (~> 0.8)
37
+ httpauth (~> 0.2)
38
+ jwt (~> 0.1.4)
39
+ multi_json (~> 1.0)
40
+ multi_xml (~> 0.5)
41
+ rack (~> 1.2)
42
+ rack (1.5.2)
43
+ rake (10.1.0)
44
+ rdoc (3.12.2)
45
+ json (~> 1.4)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ bundler (~> 1.0)
52
+ jeweler (~> 1.8.7)
@@ -0,0 +1,44 @@
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
+ # gem.files = Dir.glob('lib/**/*.rb')
23
+ # dependencies defined in Gemfile
24
+ end
25
+ Jeweler::RubygemsDotOrgTasks.new
26
+
27
+ # require 'rake/testtask'
28
+ # Rake::TestTask.new(:test) do |test|
29
+ # test.libs << 'lib' << 'test'
30
+ # test.pattern = 'test/**/test_*.rb'
31
+ # test.verbose = true
32
+ # end
33
+
34
+ # task :default => :test
35
+
36
+ # require 'rdoc/task'
37
+ # Rake::RDocTask.new do |rdoc|
38
+ # version = File.exist?('VERSION') ? File.read('VERSION') : ""
39
+
40
+ # rdoc.rdoc_dir = 'rdoc'
41
+ # rdoc.title = "tinyeditor_rails #{version}"
42
+ # rdoc.rdoc_files.include('README*')
43
+ # rdoc.rdoc_files.include('lib/**/*.rb')
44
+ # end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.4
@@ -0,0 +1,2 @@
1
+ //= require tinyeditor_rails/packed
2
+ //= require_self
@@ -0,0 +1,58 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "tinyeditor_rails"
8
+ s.version = "0.1.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["yunanhelmy"]
12
+ s.date = "2014-01-19"
13
+ s.description = "Javascript WYSIWYG using tinyEditor"
14
+ s.email = "m.yunan.helmy@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "app/assets/javascripts/tinyeditor_rails/main.js",
28
+ "lib/tinyeditor_rails.rb",
29
+ "tinyeditor_rails.gemspec",
30
+ "vendor/assets/images/images/header-bg.gif",
31
+ "vendor/assets/images/images/icons.png",
32
+ "vendor/assets/images/images/resize.gif",
33
+ "vendor/assets/javascripts/tinyeditor_rails/packed.js",
34
+ "vendor/assets/javascripts/tinyeditor_rails/tinyeditor.js",
35
+ "vendor/assets/stylesheets/tinyeditor_rails/style.css"
36
+ ]
37
+ s.homepage = "http://github.com/yunanhelmy/tinyeditor_rails"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.25"
41
+ s.summary = "Javascript WYSIWYG using tinyEditor"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
48
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
49
+ else
50
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
51
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
52
+ end
53
+ else
54
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
55
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
56
+ end
57
+ end
58
+
@@ -0,0 +1 @@
1
+ function T$(e){return document.getElementById(e)}function T$$$(){return document.all?1:0}TINY={};TINY.editor=function(){function n(n,r){function P(e,t){t=t.toLowerCase();do{e=e.parentNode;if(typeof e.tagName!="undefined"){if(e.tagName.toLowerCase()==t){return e}}}while(e.parentNode)}this.n=n;window[n]=this;this.t=T$(r.id);this.obj=r;this.xhtml=r.xhtml;var i=document.createElement("div"),s=document.createElement("div"),o=document.createElement("div"),u=r.controls.length,a=0;this.i=document.createElement("iframe");this.i.frameBorder=0;this.i.width=r.width||"500";this.i.height=r.height||"250";this.ie=T$$$();o.className=r.rowclass||"teheader";i.className=r.cssclass||"te";i.style.maxWidth=this.i.width+"px";i.appendChild(o);for(a;a<u;a++){var f=r.controls[a];if(f=="n"){o=document.createElement("div");o.className=r.rowclass||"teheader";i.appendChild(o)}else if(f=="|"){var l=document.createElement("div");l.className=r.dividerclass||"tedivider";o.appendChild(l)}else if(f=="font"){var h=document.createElement("select"),p=r.fonts||["Verdana","Arial","Georgia"],d=p.length,v=0;h.className="tefont";h.onchange=new Function(this.n+'.ddaction(this,"fontname")');h.options[0]=new Option("Font","");for(v;v<d;v++){var m=p[v];h.options[v+1]=new Option(m,m)}o.appendChild(h)}else if(f=="size"){var h=document.createElement("select"),g=r.sizes||[1,2,3,4,5,6,7],y=g.length,v=0;h.className="tesize";h.onchange=new Function(this.n+'.ddaction(this,"fontsize")');for(v;v<y;v++){var b=g[v];h.options[v]=new Option(b,b)}o.appendChild(h)}else if(f=="style"){var h=document.createElement("select"),w=r.styles||[["Style",""],["Paragraph","<p>"],["Header 1","<h1>"],["Header 2","<h2>"],["Header 3","<h3>"],["Header 4","<h4>"],["Header 5","<h5>"],["Header 6","<h6>"]],y=w.length,v=0;h.className="testyle";h.onchange=new Function(this.n+'.ddaction(this,"formatblock")');for(v;v<y;v++){var E=w[v];h.options[v]=new Option(E[0],E[1])}o.appendChild(h)}else if(e[f]){var S=document.createElement("div"),v=e[f],x=v[2],T,N=v[0]*t;S.className=r.controlclass;S.style.backgroundPosition="0px "+N+"px";S.title=v[1];T=x=="a"?'.action("'+v[3]+'",0,'+(v[4]||0)+")":'.insert("'+v[4]+'","'+v[5]+'","'+v[3]+'")';S.onclick=new Function(this.n+(f=="print"?".print()":T));S.onmouseover=new Function(this.n+".hover(this,"+N+",1)");S.onmouseout=new Function(this.n+".hover(this,"+N+",0)");o.appendChild(S);if(this.ie){S.unselectable="on"}}}this.t.parentNode.insertBefore(i,this.t);this.t.style.width=this.i.width+"px";s.appendChild(this.t);s.appendChild(this.i);i.appendChild(s);this.t.style.display="none";if(r.footer){var C=document.createElement("div");C.className=r.footerclass||"tefooter";if(r.toggle){var k=r.toggle,L=document.createElement("div");L.className=k.cssclass||"toggle";L.innerHTML=k.text||"source";L.onclick=new Function(this.n+".toggle(0,this);return false");C.appendChild(L)}if(r.resize){var A=r.resize,O=document.createElement("div");O.className=A.cssclass||"resize";O.onmousedown=new Function("event",this.n+".resize(event);return false");O.onselectstart=function(){return false};C.appendChild(O)}i.appendChild(C)}this.e=this.i.contentWindow.document;this.e.open();var M="<html><head>",_=r.bodyid?' id="'+r.bodyid+'"':"";if(r.cssfile){M+='<link rel="stylesheet" href="'+r.cssfile+'" />'}if(r.css){M+='<style type="text/css">'+r.css+"</style>"}M+='</head><body class="tinyeditor_body" '+_+">"+(r.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(D){try{this.e.execCommand("useCSS",0,1)}catch(D){}}}sync_target=this.t;sync_source=this.i.contentWindow.document.body;sync_source.addEventListener("blur",new Function(this.n+".sync(sync_target,sync_source.innerHTML)"),true);parentForm=P(sync_target,"form");if(parentForm){parentForm.addEventListener("submit",new Function(this.n+".sync(sync_target,sync_source.innerHTML)"),true)}}var e=[],t=-30;e["cut"]=[1,"Cut","a","cut",1];e["copy"]=[2,"Copy","a","copy",1];e["paste"]=[3,"Paste","a","paste",1];e["bold"]=[4,"Bold","a","bold"];e["italic"]=[5,"Italic","a","italic"];e["underline"]=[6,"Underline","a","underline"];e["strikethrough"]=[7,"Strikethrough","a","strikethrough"];e["subscript"]=[8,"Subscript","a","subscript"];e["superscript"]=[9,"Superscript","a","superscript"];e["orderedlist"]=[10,"Insert Ordered List","a","insertorderedlist"];e["unorderedlist"]=[11,"Insert Unordered List","a","insertunorderedlist"];e["outdent"]=[12,"Outdent","a","outdent"];e["indent"]=[13,"Indent","a","indent"];e["leftalign"]=[14,"Left Align","a","justifyleft"];e["centeralign"]=[15,"Center Align","a","justifycenter"];e["rightalign"]=[16,"Right Align","a","justifyright"];e["blockjustify"]=[17,"Block Justify","a","justifyfull"];e["undo"]=[18,"Undo","a","undo"];e["redo"]=[19,"Redo","a","redo"];e["image"]=[20,"Insert Image","i","insertimage","Enter Image URL:","http://"];e["hr"]=[21,"Insert Horizontal Rule","a","inserthorizontalrule"];e["link"]=[22,"Insert Hyperlink","i","createlink","Enter URL:","http://"];e["unlink"]=[23,"Remove Hyperlink","a","unlink"];e["unformat"]=[24,"Remove Formatting","a","removeformat"];e["print"]=[25,"Print","a","print"];n.prototype.sync=function(e,t){var n=this.i.contentWindow.document.body.innerHTML;n=n.replace(/<span class="apple-style-span">(.*)<\/span>/gi,"$1");n=n.replace(/ class="apple-style-span"/gi,"");n=n.replace(/<span style="">/gi,"");n=n.replace(/<br>/gi,"<br />");n=n.replace(/<br ?\/?>$/gi,"");n=n.replace(/^<br ?\/?>/gi,"");n=n.replace(/(<img [^>]+[^\/])>/gi,"$1 />");n=n.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");n=n.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>");n=n.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');n=n.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2");n=n.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>');n=n.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,"$1");n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,"<strong>$1</strong>");n=n.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,"<em>$1</em>");n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");this.t.value=n;this.t.innerText=n},n.prototype.print=function(){this.i.contentWindow.print()},n.prototype.hover=function(e,t,n){e.style.backgroundPosition=(n?"34px ":"0px ")+t+"px"},n.prototype.ddaction=function(e,t){var n=e.selectedIndex,r=e.options[n].value;this.action(t,r)},n.prototype.action=function(e,t,n){if(n&&!this.ie){alert("Your browser does not support this function.")}else{this.e.execCommand(e,0,t||null)}},n.prototype.insert=function(e,t,n){var r=prompt(e,t);if(r!=null&&r!=""){this.e.execCommand(n,0,r)}},n.prototype.setfont=function(){execCommand("formatblock",0,hType)},n.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)}},n.prototype.move=function(e){var t=TINY.cursor.top(e);this.i.height=parseInt(this.i.height)+t-this.i.bcs;this.i.bcs=t},n.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)}},n.prototype.toggle=function(e,t){if(!this.d){var n=this.t.value;if(t){t.innerHTML=this.obj.toggle.text||"source"}if(this.xhtml&&!this.ie){n=n.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight: bold;">$1</span>');n=n.replace(/<em>(.*)<\/em>/gi,'<span style="font-weight: italic;">$1</span>')}this.e.body.innerHTML=n;this.t.style.display="none";this.i.style.display="block";this.d=1}else{var n=this.e.body.innerHTML;if(this.xhtml){n=n.replace(/<span class="apple-style-span">(.*)<\/span>/gi,"$1");n=n.replace(/ class="apple-style-span"/gi,"");n=n.replace(/<span style="">/gi,"");n=n.replace(/<br>/gi,"<br />");n=n.replace(/<br ?\/?>$/gi,"");n=n.replace(/^<br ?\/?>/gi,"");n=n.replace(/(<img [^>]+[^\/])>/gi,"$1 />");n=n.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>");n=n.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,"<em>$1</em>");n=n.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');n=n.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,"$2");n=n.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>');n=n.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,"$1");n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,"<strong>$1</strong>");n=n.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,"<em>$1</em>");n=n.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,"<strong>$1</strong>")}if(t){t.innerHTML=this.obj.toggle.activetext||"wysiwyg"}this.t.value=n;if(!e){this.t.style.height=this.i.height+"px";this.i.style.display="none";this.t.style.display="block";this.d=0}}},n.prototype.post=function(){if(this.d){this.toggle(1)}};return{edit:n}}();TINY.cursor=function(){return{top:function(e){return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY}}}()
@@ -0,0 +1,254 @@
1
+ TINY={};
2
+
3
+ function T$(i){return document.getElementById(i)}
4
+ function T$$$(){return document.all?1:0}
5
+
6
+ TINY.editor=function(){
7
+ var c=[], offset=-30;
8
+ c['cut']=[1,'Cut','a','cut',1];
9
+ c['copy']=[2,'Copy','a','copy',1];
10
+ c['paste']=[3,'Paste','a','paste',1];
11
+ c['bold']=[4,'Bold','a','bold'];
12
+ c['italic']=[5,'Italic','a','italic'];
13
+ c['underline']=[6,'Underline','a','underline'];
14
+ c['strikethrough']=[7,'Strikethrough','a','strikethrough'];
15
+ c['subscript']=[8,'Subscript','a','subscript'];
16
+ c['superscript']=[9,'Superscript','a','superscript'];
17
+ c['orderedlist']=[10,'Insert Ordered List','a','insertorderedlist'];
18
+ c['unorderedlist']=[11,'Insert Unordered List','a','insertunorderedlist'];
19
+ c['outdent']=[12,'Outdent','a','outdent'];
20
+ c['indent']=[13,'Indent','a','indent'];
21
+ c['leftalign']=[14,'Left Align','a','justifyleft'];
22
+ c['centeralign']=[15,'Center Align','a','justifycenter'];
23
+ c['rightalign']=[16,'Right Align','a','justifyright'];
24
+ c['blockjustify']=[17,'Block Justify','a','justifyfull'];
25
+ c['undo']=[18,'Undo','a','undo'];
26
+ c['redo']=[19,'Redo','a','redo'];
27
+ c['image']=[20,'Insert Image','i','insertimage','Enter Image URL:','http://'];
28
+ c['hr']=[21,'Insert Horizontal Rule','a','inserthorizontalrule'];
29
+ c['link']=[22,'Insert Hyperlink','i','createlink','Enter URL:','http://'];
30
+ c['unlink']=[23,'Remove Hyperlink','a','unlink'];
31
+ c['unformat']=[24,'Remove Formatting','a','removeformat'];
32
+ c['print']=[25,'Print','a','print'];
33
+ function edit(n,obj){
34
+ this.n=n; window[n]=this; this.t=T$(obj.id); this.obj=obj; this.xhtml=obj.xhtml;
35
+ var p=document.createElement('div'), w=document.createElement('div'), h=document.createElement('div'),
36
+ l=obj.controls.length, i=0;
37
+ this.i=document.createElement('iframe'); this.i.frameBorder=0;
38
+ this.i.width=obj.width||'500'; this.i.height=obj.height||'250'; this.ie=T$$$();
39
+ h.className=obj.rowclass||'teheader'; p.className=obj.cssclass||'te'; p.style.maxWidth=this.i.width+'px'; p.appendChild(h);
40
+ for(i;i<l;i++){
41
+ var id=obj.controls[i];
42
+ if(id=='n'){
43
+ h=document.createElement('div'); h.className=obj.rowclass||'teheader'; p.appendChild(h)
44
+ }else if(id=='|'){
45
+ var d=document.createElement('div'); d.className=obj.dividerclass||'tedivider'; h.appendChild(d)
46
+ }else if(id=='font'){
47
+ var sel=document.createElement('select'), fonts=obj.fonts||['Verdana','Arial','Georgia'], fl=fonts.length, x=0;
48
+ sel.className='tefont'; sel.onchange=new Function(this.n+'.ddaction(this,"fontname")');
49
+ sel.options[0]=new Option('Font','');
50
+ for(x;x<fl;x++){
51
+ var font=fonts[x];
52
+ sel.options[x+1]=new Option(font,font)
53
+ }
54
+ h.appendChild(sel)
55
+ }else if(id=='size'){
56
+ var sel=document.createElement('select'), sizes=obj.sizes||[1,2,3,4,5,6,7], sl=sizes.length, x=0;
57
+ sel.className='tesize'; sel.onchange=new Function(this.n+'.ddaction(this,"fontsize")');
58
+ for(x;x<sl;x++){
59
+ var size=sizes[x];
60
+ sel.options[x]=new Option(size,size)
61
+ }
62
+ h.appendChild(sel)
63
+ }else if(id=='style'){
64
+ var sel=document.createElement('select'),
65
+ styles=obj.styles||[['Style',''],['Paragraph','<p>'],['Header 1','<h1>'],['Header 2','<h2>'],['Header 3','<h3>'],['Header 4','<h4>'],['Header 5','<h5>'],['Header 6','<h6>']],
66
+ sl=styles.length, x=0;
67
+ sel.className='testyle'; sel.onchange=new Function(this.n+'.ddaction(this,"formatblock")');
68
+ for(x;x<sl;x++){
69
+ var style=styles[x];
70
+ sel.options[x]=new Option(style[0],style[1])
71
+ }
72
+ h.appendChild(sel)
73
+ }else if(c[id]){
74
+ var div=document.createElement('div'), x=c[id], func=x[2], ex, pos=x[0]*offset;
75
+ div.className=obj.controlclass;
76
+ div.style.backgroundPosition='0px '+pos+'px';
77
+ div.title=x[1];
78
+ ex=func=='a'?'.action("'+x[3]+'",0,'+(x[4]||0)+')':'.insert("'+x[4]+'","'+x[5]+'","'+x[3]+'")';
79
+ div.onclick=new Function(this.n+(id=='print'?'.print()':ex));
80
+ div.onmouseover=new Function(this.n+'.hover(this,'+pos+',1)');
81
+ div.onmouseout=new Function(this.n+'.hover(this,'+pos+',0)');
82
+ h.appendChild(div);
83
+ if(this.ie){div.unselectable='on'}
84
+ }
85
+ }
86
+ this.t.parentNode.insertBefore(p,this.t); this.t.style.width=this.i.width+'px';
87
+ w.appendChild(this.t); w.appendChild(this.i); p.appendChild(w); this.t.style.display='none';
88
+ if(obj.footer){
89
+ var f=document.createElement('div'); f.className=obj.footerclass||'tefooter';
90
+ if(obj.toggle){
91
+ var to=obj.toggle, ts=document.createElement('div');
92
+ ts.className=to.cssclass||'toggle'; ts.innerHTML=to.text||'source';
93
+ ts.onclick=new Function(this.n+'.toggle(0,this);return false');
94
+ f.appendChild(ts)
95
+ }
96
+ if(obj.resize){
97
+ var ro=obj.resize, rs=document.createElement('div'); rs.className=ro.cssclass||'resize';
98
+ rs.onmousedown=new Function('event',this.n+'.resize(event);return false');
99
+ rs.onselectstart=function(){return false};
100
+ f.appendChild(rs)
101
+ }
102
+ p.appendChild(f)
103
+ }
104
+ this.e=this.i.contentWindow.document; this.e.open();
105
+ var m='<html><head>', bodyid=obj.bodyid?" id=\""+obj.bodyid+"\"":"";
106
+ if(obj.cssfile){m+='<link rel="stylesheet" href="'+obj.cssfile+'" />'}
107
+ if(obj.css){m+='<style type="text/css">'+obj.css+'</style>'}
108
+ m+='</head><body class="tinyeditor_body" '+bodyid+'>'+(obj.content||this.t.value);
109
+ m+='</body></html>';
110
+ this.e.write(m);
111
+ this.e.close(); this.e.designMode='on'; this.d=1;
112
+ if(this.xhtml){
113
+ try{this.e.execCommand("styleWithCSS",0,0)}
114
+ catch(e){try{this.e.execCommand("useCSS",0,1)}catch(e){}}
115
+ }
116
+ function upTo(el,tagName){
117
+ tagName = tagName.toLowerCase();
118
+ do {
119
+ el = el.parentNode;
120
+ if(typeof el.tagName != 'undefined'){
121
+ if (el.tagName.toLowerCase() == tagName) {
122
+ return el;
123
+ }
124
+ }
125
+ } while (el.parentNode)
126
+ };
127
+ sync_target = this.t;
128
+ sync_source = this.i.contentWindow.document.body;
129
+ sync_source.addEventListener("blur",new Function(this.n+'.sync(sync_target,sync_source.innerHTML)'),true);
130
+ parentForm = upTo(sync_target,"form");
131
+ if(parentForm){
132
+ parentForm.addEventListener("submit",new Function(this.n+'.sync(sync_target,sync_source.innerHTML)'),true);
133
+ }
134
+ };
135
+ edit.prototype.sync=function(t,i){
136
+ var v= this.i.contentWindow.document.body.innerHTML;
137
+ v=v.replace(/<span class="apple-style-span">(.*)<\/span>/gi,'$1');
138
+ v=v.replace(/ class="apple-style-span"/gi,'');
139
+ v=v.replace(/<span style="">/gi,'');
140
+ v=v.replace(/<br>/gi,'<br />');
141
+ v=v.replace(/<br ?\/?>$/gi,'');
142
+ v=v.replace(/^<br ?\/?>/gi,'');
143
+ v=v.replace(/(<img [^>]+[^\/])>/gi,'$1 />');
144
+ v=v.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>');
145
+ v=v.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,'<em>$1</em>');
146
+ v=v.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');
147
+ v=v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,'$2');
148
+ v=v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>');
149
+ v=v.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,'$1');
150
+ v=v.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,'<strong>$1</strong>');
151
+ v=v.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,'<em>$1</em>');
152
+ v=v.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>')
153
+ this.t.value = v
154
+ this.t.innerText = v
155
+ // console.log(this.t.value);
156
+ },
157
+ edit.prototype.print=function(){
158
+ this.i.contentWindow.print()
159
+ },
160
+ edit.prototype.hover=function(div,pos,dir){
161
+ div.style.backgroundPosition=(dir?'34px ':'0px ')+(pos)+'px'
162
+ },
163
+ edit.prototype.ddaction=function(dd,a){
164
+ var i=dd.selectedIndex, v=dd.options[i].value;
165
+ this.action(a,v)
166
+ },
167
+ edit.prototype.action=function(cmd,val,ie){
168
+ if(ie&&!this.ie){
169
+ alert('Your browser does not support this function.')
170
+ }else{
171
+ this.e.execCommand(cmd,0,val||null)
172
+ }
173
+ },
174
+ edit.prototype.insert=function(pro,msg,cmd){
175
+ var val=prompt(pro,msg);
176
+ if(val!=null&&val!=''){this.e.execCommand(cmd,0,val)}
177
+ },
178
+ edit.prototype.setfont=function(){
179
+ execCommand('formatblock',0,hType)
180
+ },
181
+ edit.prototype.resize=function(e){
182
+ if(this.mv){this.freeze()}
183
+ this.i.bcs=TINY.cursor.top(e);
184
+ this.mv=new Function('event',this.n+'.move(event)');
185
+ this.sr=new Function(this.n+'.freeze()');
186
+ if(this.ie){
187
+ document.attachEvent('onmousemove',this.mv); document.attachEvent('onmouseup',this.sr)
188
+ }else{
189
+ document.addEventListener('mousemove',this.mv,1); document.addEventListener('mouseup',this.sr,1)
190
+ }
191
+ },
192
+ edit.prototype.move=function(e){
193
+ var pos=TINY.cursor.top(e);
194
+ this.i.height=parseInt(this.i.height)+pos-this.i.bcs;
195
+ this.i.bcs=pos
196
+ },
197
+ edit.prototype.freeze=function(){
198
+ if(this.ie){
199
+ document.detachEvent('onmousemove',this.mv); document.detachEvent('onmouseup',this.sr)
200
+ }else{
201
+ document.removeEventListener('mousemove',this.mv,1); document.removeEventListener('mouseup',this.sr,1)
202
+ }
203
+ },
204
+ edit.prototype.toggle=function(post,div){
205
+ if(!this.d){
206
+ var v=this.t.value;
207
+ if(div){div.innerHTML=this.obj.toggle.text||'source'}
208
+ if(this.xhtml&&!this.ie){
209
+ v=v.replace(/<strong>(.*)<\/strong>/gi,'<span style="font-weight: bold;">$1</span>');
210
+ v=v.replace(/<em>(.*)<\/em>/gi,'<span style="font-weight: italic;">$1</span>')
211
+ }
212
+ this.e.body.innerHTML=v;
213
+ this.t.style.display='none'; this.i.style.display='block'; this.d=1
214
+ }else{
215
+ var v=this.e.body.innerHTML;
216
+ if(this.xhtml){
217
+ v=v.replace(/<span class="apple-style-span">(.*)<\/span>/gi,'$1');
218
+ v=v.replace(/ class="apple-style-span"/gi,'');
219
+ v=v.replace(/<span style="">/gi,'');
220
+ v=v.replace(/<br>/gi,'<br />');
221
+ v=v.replace(/<br ?\/?>$/gi,'');
222
+ v=v.replace(/^<br ?\/?>/gi,'');
223
+ v=v.replace(/(<img [^>]+[^\/])>/gi,'$1 />');
224
+ v=v.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>');
225
+ v=v.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi,'<em>$1</em>');
226
+ v=v.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi,'<span style="text-decoration:underline">$1</span>');
227
+ v=v.replace(/<(b|strong|em|i|u) style="font-weight: normal;?">(.*)<\/(b|strong|em|i|u)>/gi,'$2');
228
+ v=v.replace(/<(b|strong|em|i|u) style="(.*)">(.*)<\/(b|strong|em|i|u)>/gi,'<span style="$2"><$4>$3</$4></span>');
229
+ v=v.replace(/<span style="font-weight: normal;?">(.*)<\/span>/gi,'$1');
230
+ v=v.replace(/<span style="font-weight: bold;?">(.*)<\/span>/gi,'<strong>$1</strong>');
231
+ v=v.replace(/<span style="font-style: italic;?">(.*)<\/span>/gi,'<em>$1</em>');
232
+ v=v.replace(/<span style="font-weight: bold;?">(.*)<\/span>|<b\b[^>]*>(.*?)<\/b[^>]*>/gi,'<strong>$1</strong>')
233
+ }
234
+ if(div){div.innerHTML=this.obj.toggle.activetext||'wysiwyg'}
235
+ this.t.value=v;
236
+ if(!post){
237
+ this.t.style.height=this.i.height+'px';
238
+ this.i.style.display='none'; this.t.style.display='block'; this.d=0
239
+ }
240
+ }
241
+ },
242
+ edit.prototype.post=function(){
243
+ if(this.d){this.toggle(1)}
244
+ };
245
+ return{edit:edit}
246
+ }();
247
+
248
+ TINY.cursor=function(){
249
+ return{
250
+ top:function(e){
251
+ return T$$$()?window.event.clientY+document.documentElement.scrollTop+document.body.scrollTop:e.clientY+window.scrollY
252
+ }
253
+ }
254
+ }();
@@ -0,0 +1,17 @@
1
+ body {margin:0; font:12px Verdana,Arial}
2
+ .tinyeditor_textarea {border:none; margin:0; padding:0; font:14px 'Courier New',Verdana; border:0}
3
+ .te {border:1px solid #bbb; padding:0 1px 1px; font:12px Verdana,Arial; margin:25px}
4
+ .te iframe {border:none}
5
+ .teheader {border-bottom:1px solid #bbb; background:url(images/header-bg.gif) repeat; padding-top:1px}
6
+ .teheader select {float:left; margin-top:5px}
7
+ .tefont {margin-left:12px}
8
+ .tesize {margin:0 3px}
9
+ .testyle {margin-right:12px}
10
+ .tedivider {display: inline-block; width:1px; height:30px; background:#ccc}
11
+ .tecontrol {display: inline-block; width:34px; height:30px; cursor:pointer; background-image:url(images/icons.png)}
12
+ .tecontrol:hover {background-color:#fff; background-position:30px 0}
13
+ .tefooter {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
+ .tinyeditor_body {cursor:text; margin:10px}
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.1
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,40 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-17 00:00:00.000000000 Z
12
+ date: 2014-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: rdoc
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: '3.12'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: '3.12'
46
14
  - !ruby/object:Gem::Dependency
47
15
  name: bundler
48
16
  requirement: !ruby/object:Gem::Requirement
@@ -83,9 +51,22 @@ extra_rdoc_files:
83
51
  - LICENSE.txt
84
52
  - README.rdoc
85
53
  files:
86
- - lib/tinyeditor_rails.rb
54
+ - .document
55
+ - Gemfile
56
+ - Gemfile.lock
87
57
  - LICENSE.txt
88
58
  - README.rdoc
59
+ - Rakefile
60
+ - VERSION
61
+ - app/assets/javascripts/tinyeditor_rails/main.js
62
+ - lib/tinyeditor_rails.rb
63
+ - tinyeditor_rails.gemspec
64
+ - vendor/assets/images/images/header-bg.gif
65
+ - vendor/assets/images/images/icons.png
66
+ - vendor/assets/images/images/resize.gif
67
+ - vendor/assets/javascripts/tinyeditor_rails/packed.js
68
+ - vendor/assets/javascripts/tinyeditor_rails/tinyeditor.js
69
+ - vendor/assets/stylesheets/tinyeditor_rails/style.css
89
70
  homepage: http://github.com/yunanhelmy/tinyeditor_rails
90
71
  licenses:
91
72
  - MIT
@@ -101,7 +82,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
82
  version: '0'
102
83
  segments:
103
84
  - 0
104
- hash: -272364365
85
+ hash: 830375117
105
86
  required_rubygems_version: !ruby/object:Gem::Requirement
106
87
  none: false
107
88
  requirements: