tiny_box2_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4947385fcb7dc257f8093272915ca839b2bb73e
4
+ data.tar.gz: 099804285e1c1b7c4171f061e54d7c4bfc362f02
5
+ SHA512:
6
+ metadata.gz: 6507196e84f3c78f5f21631bf64f23c8d2cd49340dc5e46d053690dd81cee2c6c774861eaf16fe06a9642b7f45b2c47eaec02f62ff50877afbede7630cafc372
7
+ data.tar.gz: c264bd708a3a1adc8262d9e3fb7b9a407670e74b11c3ab218b0b01eb44db4aeaef8e95b6552655259d335b46c205be40065cc45fb23d184cdbca96d30e2f196b
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tiny_box2_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 John Chen
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # TinyBox2Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tiny_box2_rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tiny_box2_rails
18
+
19
+ ## Usage
20
+
21
+ add to css file
22
+ ```
23
+ /*
24
+ *= require tiny_box2
25
+ */
26
+ ```
27
+
28
+ add to js file
29
+ ```
30
+ //= require tiny_box2
31
+
32
+ ```
33
+
34
+
35
+ ##
36
+
37
+ ```
38
+ visit: http://www.scriptiny.com/2011/03/javascript-modal-windows/
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/cgg5207/tiny_box2_rails/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,134 @@
1
+ TINY={};
2
+
3
+ TINY.box=function(){
4
+ var j,m,b,g,v,p=0;
5
+ return{
6
+ show:function(o){
7
+ v={opacity:70,close:1,animate:1,fixed:1,mask:1,maskid:'',boxid:'',topsplit:2,url:0,post:0,height:0,width:0,html:0,iframe:0};
8
+ for(s in o){v[s]=o[s]}
9
+ if(!p){
10
+ j=document.createElement('div'); j.className='tbox';
11
+ p=document.createElement('div'); p.className='tinner';
12
+ b=document.createElement('div'); b.className='tcontent';
13
+ m=document.createElement('div'); m.className='tmask';
14
+ g=document.createElement('div'); g.className='tclose'; g.v=0;
15
+ document.body.appendChild(m); document.body.appendChild(j); j.appendChild(p); p.appendChild(b);
16
+ m.onclick=g.onclick=TINY.box.hide; window.onresize=TINY.box.resize
17
+ }else{
18
+ j.style.display='none'; clearTimeout(p.ah); if(g.v){p.removeChild(g); g.v=0}
19
+ }
20
+ p.id=v.boxid; m.id=v.maskid; j.style.position=v.fixed?'fixed':'absolute';
21
+ if(v.html&&!v.animate){
22
+ p.style.backgroundImage='none'; b.innerHTML=v.html; b.style.display='';
23
+ p.style.width=v.width?v.width+'px':'auto'; p.style.height=v.height?v.height+'px':'auto'
24
+ }else{
25
+ b.style.display='none';
26
+ if(!v.animate&&v.width&&v.height){
27
+ p.style.width=v.width+'px'; p.style.height=v.height+'px'
28
+ }else{
29
+ p.style.width=p.style.height='100px'
30
+ }
31
+ }
32
+ if(v.mask){this.mask(); this.alpha(m,1,v.opacity)}else{this.alpha(j,1,100)}
33
+ if(v.autohide){p.ah=setTimeout(TINY.box.hide,1000*v.autohide)}else{document.onkeyup=TINY.box.esc}
34
+ },
35
+ fill:function(c,u,k,a,w,h){
36
+ if(u){
37
+ if(v.image){
38
+ var i=new Image(); i.onload=function(){w=w||i.width; h=h||i.height; TINY.box.psh(i,a,w,h)}; i.src=v.image
39
+ }else if(v.iframe){
40
+ this.psh('<iframe src="'+v.iframe+'" width="'+v.width+'" frameborder="0" height="'+v.height+'"></iframe>',a,w,h)
41
+ }else{
42
+ var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
43
+ x.onreadystatechange=function(){
44
+ if(x.readyState==4&&x.status==200){p.style.backgroundImage=''; TINY.box.psh(x.responseText,a,w,h)}
45
+ };
46
+ if(k){
47
+ x.open('POST',c,true); x.setRequestHeader('Content-type','application/x-www-form-urlencoded'); x.send(k)
48
+ }else{
49
+ x.open('GET',c,true); x.send(null)
50
+ }
51
+ }
52
+ }else{
53
+ this.psh(c,a,w,h)
54
+ }
55
+ },
56
+ psh:function(c,a,w,h){
57
+ if(typeof c=='object'){b.appendChild(c)}else{b.innerHTML=c}
58
+ var x=p.style.width, y=p.style.height;
59
+ if(!w||!h){
60
+ p.style.width=w?w+'px':''; p.style.height=h?h+'px':''; b.style.display='';
61
+ if(!h){h=parseInt(b.offsetHeight)}
62
+ if(!w){w=parseInt(b.offsetWidth)}
63
+ b.style.display='none'
64
+ }
65
+ p.style.width=x; p.style.height=y;
66
+ this.size(w,h,a)
67
+ },
68
+ esc:function(e){e=e||window.event; if(e.keyCode==27){TINY.box.hide()}},
69
+ hide:function(){TINY.box.alpha(j,-1,0,3); document.onkeypress=null; if(v.closejs){v.closejs()}},
70
+ resize:function(){TINY.box.pos(); TINY.box.mask()},
71
+ mask:function(){m.style.height=this.total(1)+'px'; m.style.width=this.total(0)+'px'},
72
+ pos:function(){
73
+ var t;
74
+ if(typeof v.top!='undefined'){t=v.top}else{t=(this.height()/v.topsplit)-(j.offsetHeight/2); t=t<20?20:t}
75
+ if(!v.fixed&&!v.top){t+=this.top()}
76
+ j.style.top=t+'px';
77
+ j.style.left=typeof v.left!='undefined'?v.left+'px':(this.width()/2)-(j.offsetWidth/2)+'px'
78
+ },
79
+ alpha:function(e,d,a){
80
+ clearInterval(e.ai);
81
+ if(d){e.style.opacity=0; e.style.filter='alpha(opacity=0)'; e.style.display='block'; TINY.box.pos()}
82
+ e.ai=setInterval(function(){TINY.box.ta(e,a,d)},20)
83
+ },
84
+ ta:function(e,a,d){
85
+ var o=Math.round(e.style.opacity*100);
86
+ if(o==a){
87
+ clearInterval(e.ai);
88
+ if(d==-1){
89
+ e.style.display='none';
90
+ e==j?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''
91
+ }else{
92
+ if(e==m){
93
+ this.alpha(j,1,100)
94
+ }else{
95
+ j.style.filter='';
96
+ TINY.box.fill(v.html||v.url,v.url||v.iframe||v.image,v.post,v.animate,v.width,v.height)
97
+ }
98
+ }
99
+ }else{
100
+ var n=a-Math.floor(Math.abs(a-o)*.5)*d;
101
+ e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'
102
+ }
103
+ },
104
+ size:function(w,h,a){
105
+ if(a){
106
+ clearInterval(p.si); var wd=parseInt(p.style.width)>w?-1:1, hd=parseInt(p.style.height)>h?-1:1;
107
+ p.si=setInterval(function(){TINY.box.ts(w,wd,h,hd)},20)
108
+ }else{
109
+ p.style.backgroundImage='none'; if(v.close){p.appendChild(g); g.v=1}
110
+ p.style.width=w+'px'; p.style.height=h+'px'; b.style.display=''; this.pos();
111
+ if(v.openjs){v.openjs()}
112
+ }
113
+ },
114
+ ts:function(w,wd,h,hd){
115
+ var cw=parseInt(p.style.width), ch=parseInt(p.style.height);
116
+ if(cw==w&&ch==h){
117
+ clearInterval(p.si); p.style.backgroundImage='none'; b.style.display='block'; if(v.close){p.appendChild(g); g.v=1}
118
+ if(v.openjs){v.openjs()}
119
+ }else{
120
+ if(cw!=w){p.style.width=(w-Math.floor(Math.abs(w-cw)*.6)*wd)+'px'}
121
+ if(ch!=h){p.style.height=(h-Math.floor(Math.abs(h-ch)*.6)*hd)+'px'}
122
+ this.pos()
123
+ }
124
+ },
125
+ top:function(){return document.documentElement.scrollTop||document.body.scrollTop},
126
+ width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},
127
+ height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},
128
+ total:function(d){
129
+ var b=document.body, e=document.documentElement;
130
+ return d?Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight)):
131
+ Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))
132
+ }
133
+ }
134
+ }();
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require_tree ./tiny_box2
3
+ */
@@ -0,0 +1,22 @@
1
+ body {font:12px/1.4 Verdana,Arial; background:#eee; height:100%; margin:25px 0; padding:0}
2
+ h1 {font:30px 'Trebuchet MS',Verdana; margin:0}
3
+ h2 {font-size:12px; font-weight:normal; font-style:italic; margin:0 0 20px}
4
+ p {margin:0 0 14px}
5
+ ul {margin:0; padding-left:20px}
6
+ #testdiv {width:600px; margin:0px auto; border:1px solid #ccc; padding:20px 25px 12px; background:#fff}
7
+ ul {list-style:none; margin-bottom:12px; padding:0}
8
+ li {font:14px Georgia,Verdana; margin-bottom:4px; padding:8px 10px 9px; border:1px solid #ccc; background:#eee; cursor:pointer}
9
+ li:hover {border:1px solid #bbb; background:#e3e3e3}
10
+
11
+ .tbox {position:absolute; display:none; padding:14px 17px; z-index:900}
12
+ .tinner {padding:15px; -moz-border-radius:5px; border-radius:5px; background:#fff url(<%=asset_path 'tiny_box2/preload.gif'%>) no-repeat 50% 50%; border-right:1px solid #333; border-bottom:1px solid #333}
13
+ .tmask {position:absolute; display:none; top:0px; left:0px; height:100%; width:100%; background:#000; z-index:800}
14
+ .tclose {position:absolute; top:0px; right:0px; width:30px; height:30px; cursor:pointer; background:url(<%=asset_path 'tiny_box2/close.png'%>) no-repeat}
15
+ .tclose:hover {background-position:0 -30px}
16
+
17
+ #error {background:#ff6969; color:#fff; text-shadow:1px 1px #cf5454; border-right:1px solid #000; border-bottom:1px solid #000; padding:0}
18
+ #error .tcontent {padding:10px 14px 11px; border:1px solid #ffb8b8; -moz-border-radius:5px; border-radius:5px}
19
+ #success {background:#2ea125; color:#fff; text-shadow:1px 1px #1b6116; border-right:1px solid #000; border-bottom:1px solid #000; padding:10; -moz-border-radius:0; border-radius:0}
20
+ #bluemask {background:#4195aa}
21
+ #frameless {padding:0}
22
+ #frameless .tclose {left:6px}
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= require_tree ./tiny_box2
3
+ */
@@ -0,0 +1,2 @@
1
+ <p>This content came from an Ajax request. Using TinyBox you can easily <a href="javascript:TINY.box.size(450,350,1)">expand</a> or <a href="javascript:TINY.box.size(200,150)">contract</a> a popup on the fly. You can even <a href="javascript:TINY.box.hide()">close it</a> or press ESC.</p>
2
+ <p><a href="javascript:TINY.box.fill('Static Content')">Click here</a> to load some static HTML or <a href="javascript:TINY.box.fill('ajax.html',1,0,1)">click here</a> to load an external HTML table.</p>
data/example/ajax.html ADDED
@@ -0,0 +1,37 @@
1
+ <table width="400" cellpadding="3" cellspacing="3" border="1" bgcolor="#eeeeee">
2
+ <tr>
3
+ <th>Table Header</th>
4
+ <th>Table Header</th>
5
+ <th>Table Header</th>
6
+ </tr>
7
+ <tr>
8
+ <td>Table Cell</td>
9
+ <td>Table Cell</td>
10
+ <td>Table Cell</td>
11
+ </tr>
12
+ <tr>
13
+ <td>Table Cell</td>
14
+ <td>Table Cell</td>
15
+ <td>Table Cell</td>
16
+ </tr>
17
+ <tr>
18
+ <td>Table Cell</td>
19
+ <td>Table Cell</td>
20
+ <td>Table Cell</td>
21
+ </tr>
22
+ <tr>
23
+ <td>Table Cell</td>
24
+ <td>Table Cell</td>
25
+ <td>Table Cell</td>
26
+ </tr>
27
+ <tr>
28
+ <td>Table Cell</td>
29
+ <td>Table Cell</td>
30
+ <td>Table Cell</td>
31
+ </tr>
32
+ <tr>
33
+ <td>Table Cell</td>
34
+ <td>Table Cell</td>
35
+ <td>Table Cell</td>
36
+ </tr>
37
+ </table>
Binary file
Binary file
Binary file
@@ -0,0 +1,32 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <title>TinyBox2 - JavaScript Modal Windows</title>
6
+ <link rel="stylesheet" href="style.css" />
7
+ <script type="text/javascript" src="tinybox.js"></script>
8
+ </head>
9
+ <body>
10
+ <div id="testdiv">
11
+ <h1>TinyBox2 JavaScript Modal Windows</h1>
12
+ <h2>For complete details visit <a href="http://www.scriptiny.com/2011/03/javascript-modal-windows/">scriptiny.com</a>.</h2>
13
+ <ul>
14
+ <li onclick="TINY.box.show({html:'This is a warning!',animate:false,close:false,boxid:'error',top:5})">No Animation, No Close Button, Auto Width/Height, Custom Styling</li>
15
+ <li onclick="TINY.box.show({url:'post.php',post:'id=16',width:200,height:100,opacity:20,topsplit:3})">Ajax Post, Fixed Width/Height, Light Mask, Custom Vertical Split</li>
16
+ <li onclick="TINY.box.show({html:'The entry has been updated successfully!',animate:false,close:false,mask:false,boxid:'success',autohide:2,top:-14,left:-17})">Custom Position, No Mask, Auto-Hide</li>
17
+ <li onclick="TINY.box.show({iframe:'http://www.scriptiny.com/',boxid:'frameless',width:750,height:450,fixed:false,maskid:'bluemask',maskopacity:40,closejs:function(){closeJS()}})">iFrame, Blue Mask, Absolute Position, Frameless, Close Callback</li>
18
+ <li onclick="TINY.box.show({url:'advanced.html',width:300,height:150})">Ajax, Advanced Functions</li>
19
+ <li onclick="TINY.box.show({image:'images/rhino.jpg',boxid:'frameless',animate:true,openjs:function(){openJS()}})">Image, Load Callback</li>
20
+ </ul>
21
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed commodo metus non diam luctus facilisis. Aenean vel urna ante, eu porta nunc. Vestibulum facilisis, tortor vitae semper iaculis, metus elit dictum leo, vitae suscipit leo augue id felis. Nam pretium tempus justo vel tempor. Pellentesque at cursus tellus. Pellentesque tincidunt ornare odio in lacinia. Aenean eget tristique ligula. Maecenas malesuada nunc at turpis lacinia consequat dignissim mi euismod. Fusce ornare magna vitae neque viverra condimentum. Vestibulum sollicitudin lacus placerat mi ornare vulputate. Vestibulum facilisis eros ut magna tincidunt sed viverra nisl tincidunt. Vivamus et tempus tellus. Vestibulum ultricies, libero nec lacinia ornare, nunc ligula dictum purus, id molestie arcu sapien et nulla. Sed sed quam ante, nec vestibulum ipsum. Phasellus ullamcorper iaculis lectus non fermentum. Nam tempor feugiat lacinia. Phasellus eu gravida sapien.</p>
22
+ <p>Cras fringilla nulla non nisi ullamcorper non ultrices est dictum. Vivamus rhoncus eros id dui viverra dictum in eget elit. Fusce dignissim ante ut erat sollicitudin ut pulvinar turpis malesuada. In scelerisque est scelerisque orci suscipit sed viverra nulla imperdiet. Proin eleifend rutrum mi, quis cursus sapien pretium vitae. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nunc non mauris ante, et posuere diam. Aliquam congue elit ac nunc luctus a mollis lectus iaculis. Aliquam consequat malesuada posuere. Maecenas orci orci, accumsan nec suscipit ac, interdum vel augue. Donec ut risus orci. Mauris purus elit, cursus id tincidunt vel, posuere eu ligula. Ut sed eros et ipsum rutrum sagittis. Vestibulum tellus felis, varius in cursus ac, venenatis id lorem. Nullam nec leo nibh. Praesent interdum ligula et metus sollicitudin auctor. Vestibulum accumsan nulla non dolor mollis mattis. In vulputate venenatis elit et pharetra.</p>
23
+ <p>Duis et velit lectus. Cras leo justo, accumsan et eleifend sit amet, consequat quis dui. Donec sed est non libero ultrices commodo sed et augue. Quisque vestibulum iaculis augue feugiat sollicitudin. Phasellus scelerisque tristique elit faucibus varius. Suspendisse lacinia, ante quis consectetur varius, erat mauris rutrum massa, id dignissim erat lacus eleifend justo. Etiam quis dolor libero. Pellentesque iaculis, velit eget bibendum adipiscing, quam augue fermentum lacus, ut ultrices velit urna at est. Fusce nulla enim, commodo vitae sodales non, molestie non eros. Sed vitae rutrum ipsum. Donec ac nulla id dolor lacinia laoreet ut at neque. Proin consectetur velit at dolor hendrerit luctus. Curabitur vehicula pharetra purus, eget malesuada tortor posuere nec. Aenean non velit ipsum, ac scelerisque eros. Praesent pretium viverra vehicula. Suspendisse hendrerit varius ante, quis rhoncus dui volutpat non.</p>
24
+ <p>Ut eros quam, mattis et vestibulum in, porta vitae nisl. Ut quis felis ipsum, non iaculis sapien. Phasellus sed nisi nulla, in vestibulum nisl. Donec turpis tellus, rutrum ut porta at, mattis eu nisl. Nulla facilisi. Cras auctor, sem quis sagittis scelerisque, ligula turpis adipiscing mi, vitae elementum elit mi sit amet felis. Nulla sapien magna, rhoncus a tincidunt ac, tempor id nunc. Nunc sit amet leo in magna pellentesque posuere ut et diam. Proin sollicitudin, est ut malesuada consectetur, magna arcu lacinia felis, et faucibus nisl diam ut quam. Ut consequat malesuada massa, vitae gravida tortor consectetur id. Praesent at risus ultrices ligula pretium pellentesque et vulputate ipsum. Morbi ante ante, placerat ac iaculis ac, sagittis nec felis. Sed vel nisl leo, ac dictum lectus. Nunc sodales urna non nisl ornare vitae viverra lorem molestie. Pellentesque sit amet risus id turpis tempor interdum. Phasellus sagittis dignissim iaculis. Ut quis dictum mauris. Integer vitae sem ac est blandit hendrerit. Vivamus ultricies, nibh vel ullamcorper eleifend, ante libero laoreet enim, nec fringilla dui lacus ut mi.</p>
25
+ <p>In feugiat, magna eu volutpat dictum, sem sapien mollis elit, at sollicitudin metus odio eu orci. Mauris egestas rutrum bibendum. Etiam sit amet erat quis nisl sodales egestas. Quisque eu velit urna, id faucibus orci. Cras sagittis tincidunt blandit. Donec id suscipit sem. Sed vitae purus in nisi consequat pretium fermentum non quam. Sed at orci libero. Mauris et felis lacus. Nulla ut turpis ligula, quis vulputate felis. Sed nulla risus, dictum et sagittis eu, venenatis vitae dui. Vestibulum luctus lectus quis arcu mollis in dignissim leo suscipit. Cras justo neque, ultricies et interdum eget, rhoncus non erat. Vestibulum eget dolor nisi, eget adipiscing orci. Sed tortor ligula, hendrerit ut hendrerit in, fermentum cursus nisi. Pellentesque ante ligula, consectetur quis pellentesque eu, tristique quis arcu. Aenean porta, nisl nec sagittis fringilla, leo eros facilisis lorem, vel iaculis augue lorem ut lectus. Mauris sit amet velit et sapien aliquam dapibus et id quam. Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
26
+ </div>
27
+ <script type="text/javascript">
28
+ function openJS(){alert('loaded')}
29
+ function closeJS(){alert('closed')}
30
+ </script>
31
+ </body>
32
+ </html>
data/example/packed.js ADDED
@@ -0,0 +1 @@
1
+ TINY={};TINY.box=function(){var j,m,b,g,v,p=0;return{show:function(o){v={opacity:70,close:1,animate:1,fixed:1,mask:1,maskid:'',boxid:'',topsplit:2,url:0,post:0,height:0,width:0,html:0,iframe:0};for(s in o){v[s]=o[s]}if(!p){j=document.createElement('div');j.className='tbox';p=document.createElement('div');p.className='tinner';b=document.createElement('div');b.className='tcontent';m=document.createElement('div');m.className='tmask';g=document.createElement('div');g.className='tclose';g.v=0;document.body.appendChild(m);document.body.appendChild(j);j.appendChild(p);p.appendChild(b);m.onclick=g.onclick=TINY.box.hide;window.onresize=TINY.box.resize}else{j.style.display='none';clearTimeout(p.ah);if(g.v){p.removeChild(g);g.v=0}}p.id=v.boxid;m.id=v.maskid;j.style.position=v.fixed?'fixed':'absolute';if(v.html&&!v.animate){p.style.backgroundImage='none';b.innerHTML=v.html;b.style.display='';p.style.width=v.width?v.width+'px':'auto';p.style.height=v.height?v.height+'px':'auto'}else{b.style.display='none';if(!v.animate&&v.width&&v.height){p.style.width=v.width+'px';p.style.height=v.height+'px'}else{p.style.width=p.style.height='100px'}}if(v.mask){this.mask();this.alpha(m,1,v.opacity)}else{this.alpha(j,1,100)}if(v.autohide){p.ah=setTimeout(TINY.box.hide,1000*v.autohide)}else{document.onkeyup=TINY.box.esc}},fill:function(c,u,k,a,w,h){if(u){if(v.image){var i=new Image();i.onload=function(){w=w||i.width;h=h||i.height;TINY.box.psh(i,a,w,h)};i.src=v.image}else if(v.iframe){this.psh('<iframe src="'+v.iframe+'" width="'+v.width+'" frameborder="0" height="'+v.height+'"></iframe>',a,w,h)}else{var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){p.style.backgroundImage='';TINY.box.psh(x.responseText,a,w,h)}};if(k){x.open('POST',c,true);x.setRequestHeader('Content-type','application/x-www-form-urlencoded');x.send(k)}else{x.open('GET',c,true);x.send(null)}}}else{this.psh(c,a,w,h)}},psh:function(c,a,w,h){if(typeof c=='object'){b.appendChild(c)}else{b.innerHTML=c}var x=p.style.width,y=p.style.height;if(!w||!h){p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';if(!h){h=parseInt(b.offsetHeight)}if(!w){w=parseInt(b.offsetWidth)}b.style.display='none'}p.style.width=x;p.style.height=y;this.size(w,h,a)},esc:function(e){e=e||window.event;if(e.keyCode==27){TINY.box.hide()}},hide:function(){TINY.box.alpha(j,-1,0,3);document.onkeypress=null;if(v.closejs){v.closejs()}},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=this.total(1)+'px';m.style.width=this.total(0)+'px'},pos:function(){var t;if(typeof v.top!='undefined'){t=v.top}else{t=(this.height()/v.topsplit)-(j.offsetHeight/2);t=t<20?20:t}if(!v.fixed&&!v.top){t+=this.top()}j.style.top=t+'px';j.style.left=typeof v.left!='undefined'?v.left+'px':(this.width()/2)-(j.offsetWidth/2)+'px'},alpha:function(e,d,a){clearInterval(e.ai);if(d){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';TINY.box.pos()}e.ai=setInterval(function(){TINY.box.ta(e,a,d)},20)},ta:function(e,a,d){var o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==j?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''}else{if(e==m){this.alpha(j,1,100)}else{j.style.filter='';TINY.box.fill(v.html||v.url,v.url||v.iframe||v.image,v.post,v.animate,v.width,v.height)}}}else{var n=a-Math.floor(Math.abs(a-o)*.5)*d;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(w,h,a){if(a){clearInterval(p.si);var wd=parseInt(p.style.width)>w?-1:1,hd=parseInt(p.style.height)>h?-1:1;p.si=setInterval(function(){TINY.box.ts(w,wd,h,hd)},20)}else{p.style.backgroundImage='none';if(v.close){p.appendChild(g);g.v=1}p.style.width=w+'px';p.style.height=h+'px';b.style.display='';this.pos();if(v.openjs){v.openjs()}}},ts:function(w,wd,h,hd){var cw=parseInt(p.style.width),ch=parseInt(p.style.height);if(cw==w&&ch==h){clearInterval(p.si);p.style.backgroundImage='none';b.style.display='block';if(v.close){p.appendChild(g);g.v=1}if(v.openjs){v.openjs()}}else{if(cw!=w){p.style.width=(w-Math.floor(Math.abs(w-cw)*.6)*wd)+'px'}if(ch!=h){p.style.height=(h-Math.floor(Math.abs(h-ch)*.6)*hd)+'px'}this.pos()}},top:function(){return document.documentElement.scrollTop||document.body.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},total:function(d){var b=document.body,e=document.documentElement;return d?Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight)):Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();
data/example/post.php ADDED
@@ -0,0 +1 @@
1
+ You posted ID <?php echo $_POST['id']; ?>.
data/example/style.css ADDED
@@ -0,0 +1,22 @@
1
+ body {font:12px/1.4 Verdana,Arial; background:#eee; height:100%; margin:25px 0; padding:0}
2
+ h1 {font:30px 'Trebuchet MS',Verdana; margin:0}
3
+ h2 {font-size:12px; font-weight:normal; font-style:italic; margin:0 0 20px}
4
+ p {margin:0 0 14px}
5
+ ul {margin:0; padding-left:20px}
6
+ #testdiv {width:600px; margin:0px auto; border:1px solid #ccc; padding:20px 25px 12px; background:#fff}
7
+ ul {list-style:none; margin-bottom:12px; padding:0}
8
+ li {font:14px Georgia,Verdana; margin-bottom:4px; padding:8px 10px 9px; border:1px solid #ccc; background:#eee; cursor:pointer}
9
+ li:hover {border:1px solid #bbb; background:#e3e3e3}
10
+
11
+ .tbox {position:absolute; display:none; padding:14px 17px; z-index:900}
12
+ .tinner {padding:15px; -moz-border-radius:5px; border-radius:5px; background:#fff url(images/preload.gif) no-repeat 50% 50%; border-right:1px solid #333; border-bottom:1px solid #333}
13
+ .tmask {position:absolute; display:none; top:0px; left:0px; height:100%; width:100%; background:#000; z-index:800}
14
+ .tclose {position:absolute; top:0px; right:0px; width:30px; height:30px; cursor:pointer; background:url(images/close.png) no-repeat}
15
+ .tclose:hover {background-position:0 -30px}
16
+
17
+ #error {background:#ff6969; color:#fff; text-shadow:1px 1px #cf5454; border-right:1px solid #000; border-bottom:1px solid #000; padding:0}
18
+ #error .tcontent {padding:10px 14px 11px; border:1px solid #ffb8b8; -moz-border-radius:5px; border-radius:5px}
19
+ #success {background:#2ea125; color:#fff; text-shadow:1px 1px #1b6116; border-right:1px solid #000; border-bottom:1px solid #000; padding:10; -moz-border-radius:0; border-radius:0}
20
+ #bluemask {background:#4195aa}
21
+ #frameless {padding:0}
22
+ #frameless .tclose {left:6px}
@@ -0,0 +1,134 @@
1
+ TINY={};
2
+
3
+ TINY.box=function(){
4
+ var j,m,b,g,v,p=0;
5
+ return{
6
+ show:function(o){
7
+ v={opacity:70,close:1,animate:1,fixed:1,mask:1,maskid:'',boxid:'',topsplit:2,url:0,post:0,height:0,width:0,html:0,iframe:0};
8
+ for(s in o){v[s]=o[s]}
9
+ if(!p){
10
+ j=document.createElement('div'); j.className='tbox';
11
+ p=document.createElement('div'); p.className='tinner';
12
+ b=document.createElement('div'); b.className='tcontent';
13
+ m=document.createElement('div'); m.className='tmask';
14
+ g=document.createElement('div'); g.className='tclose'; g.v=0;
15
+ document.body.appendChild(m); document.body.appendChild(j); j.appendChild(p); p.appendChild(b);
16
+ m.onclick=g.onclick=TINY.box.hide; window.onresize=TINY.box.resize
17
+ }else{
18
+ j.style.display='none'; clearTimeout(p.ah); if(g.v){p.removeChild(g); g.v=0}
19
+ }
20
+ p.id=v.boxid; m.id=v.maskid; j.style.position=v.fixed?'fixed':'absolute';
21
+ if(v.html&&!v.animate){
22
+ p.style.backgroundImage='none'; b.innerHTML=v.html; b.style.display='';
23
+ p.style.width=v.width?v.width+'px':'auto'; p.style.height=v.height?v.height+'px':'auto'
24
+ }else{
25
+ b.style.display='none';
26
+ if(!v.animate&&v.width&&v.height){
27
+ p.style.width=v.width+'px'; p.style.height=v.height+'px'
28
+ }else{
29
+ p.style.width=p.style.height='100px'
30
+ }
31
+ }
32
+ if(v.mask){this.mask(); this.alpha(m,1,v.opacity)}else{this.alpha(j,1,100)}
33
+ if(v.autohide){p.ah=setTimeout(TINY.box.hide,1000*v.autohide)}else{document.onkeyup=TINY.box.esc}
34
+ },
35
+ fill:function(c,u,k,a,w,h){
36
+ if(u){
37
+ if(v.image){
38
+ var i=new Image(); i.onload=function(){w=w||i.width; h=h||i.height; TINY.box.psh(i,a,w,h)}; i.src=v.image
39
+ }else if(v.iframe){
40
+ this.psh('<iframe src="'+v.iframe+'" width="'+v.width+'" frameborder="0" height="'+v.height+'"></iframe>',a,w,h)
41
+ }else{
42
+ var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');
43
+ x.onreadystatechange=function(){
44
+ if(x.readyState==4&&x.status==200){p.style.backgroundImage=''; TINY.box.psh(x.responseText,a,w,h)}
45
+ };
46
+ if(k){
47
+ x.open('POST',c,true); x.setRequestHeader('Content-type','application/x-www-form-urlencoded'); x.send(k)
48
+ }else{
49
+ x.open('GET',c,true); x.send(null)
50
+ }
51
+ }
52
+ }else{
53
+ this.psh(c,a,w,h)
54
+ }
55
+ },
56
+ psh:function(c,a,w,h){
57
+ if(typeof c=='object'){b.appendChild(c)}else{b.innerHTML=c}
58
+ var x=p.style.width, y=p.style.height;
59
+ if(!w||!h){
60
+ p.style.width=w?w+'px':''; p.style.height=h?h+'px':''; b.style.display='';
61
+ if(!h){h=parseInt(b.offsetHeight)}
62
+ if(!w){w=parseInt(b.offsetWidth)}
63
+ b.style.display='none'
64
+ }
65
+ p.style.width=x; p.style.height=y;
66
+ this.size(w,h,a)
67
+ },
68
+ esc:function(e){e=e||window.event; if(e.keyCode==27){TINY.box.hide()}},
69
+ hide:function(){TINY.box.alpha(j,-1,0,3); document.onkeypress=null; if(v.closejs){v.closejs()}},
70
+ resize:function(){TINY.box.pos(); TINY.box.mask()},
71
+ mask:function(){m.style.height=this.total(1)+'px'; m.style.width=this.total(0)+'px'},
72
+ pos:function(){
73
+ var t;
74
+ if(typeof v.top!='undefined'){t=v.top}else{t=(this.height()/v.topsplit)-(j.offsetHeight/2); t=t<20?20:t}
75
+ if(!v.fixed&&!v.top){t+=this.top()}
76
+ j.style.top=t+'px';
77
+ j.style.left=typeof v.left!='undefined'?v.left+'px':(this.width()/2)-(j.offsetWidth/2)+'px'
78
+ },
79
+ alpha:function(e,d,a){
80
+ clearInterval(e.ai);
81
+ if(d){e.style.opacity=0; e.style.filter='alpha(opacity=0)'; e.style.display='block'; TINY.box.pos()}
82
+ e.ai=setInterval(function(){TINY.box.ta(e,a,d)},20)
83
+ },
84
+ ta:function(e,a,d){
85
+ var o=Math.round(e.style.opacity*100);
86
+ if(o==a){
87
+ clearInterval(e.ai);
88
+ if(d==-1){
89
+ e.style.display='none';
90
+ e==j?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''
91
+ }else{
92
+ if(e==m){
93
+ this.alpha(j,1,100)
94
+ }else{
95
+ j.style.filter='';
96
+ TINY.box.fill(v.html||v.url,v.url||v.iframe||v.image,v.post,v.animate,v.width,v.height)
97
+ }
98
+ }
99
+ }else{
100
+ var n=a-Math.floor(Math.abs(a-o)*.5)*d;
101
+ e.style.opacity=n/100; e.style.filter='alpha(opacity='+n+')'
102
+ }
103
+ },
104
+ size:function(w,h,a){
105
+ if(a){
106
+ clearInterval(p.si); var wd=parseInt(p.style.width)>w?-1:1, hd=parseInt(p.style.height)>h?-1:1;
107
+ p.si=setInterval(function(){TINY.box.ts(w,wd,h,hd)},20)
108
+ }else{
109
+ p.style.backgroundImage='none'; if(v.close){p.appendChild(g); g.v=1}
110
+ p.style.width=w+'px'; p.style.height=h+'px'; b.style.display=''; this.pos();
111
+ if(v.openjs){v.openjs()}
112
+ }
113
+ },
114
+ ts:function(w,wd,h,hd){
115
+ var cw=parseInt(p.style.width), ch=parseInt(p.style.height);
116
+ if(cw==w&&ch==h){
117
+ clearInterval(p.si); p.style.backgroundImage='none'; b.style.display='block'; if(v.close){p.appendChild(g); g.v=1}
118
+ if(v.openjs){v.openjs()}
119
+ }else{
120
+ if(cw!=w){p.style.width=(w-Math.floor(Math.abs(w-cw)*.6)*wd)+'px'}
121
+ if(ch!=h){p.style.height=(h-Math.floor(Math.abs(h-ch)*.6)*hd)+'px'}
122
+ this.pos()
123
+ }
124
+ },
125
+ top:function(){return document.documentElement.scrollTop||document.body.scrollTop},
126
+ width:function(){return self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth},
127
+ height:function(){return self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight},
128
+ total:function(d){
129
+ var b=document.body, e=document.documentElement;
130
+ return d?Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight)):
131
+ Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))
132
+ }
133
+ }
134
+ }();
@@ -0,0 +1,3 @@
1
+ module TinyBox2Rails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "tiny_box2_rails/version"
2
+
3
+ module TinyBox2Rails
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tiny_box2_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tiny_box2_rails"
8
+ spec.version = TinyBox2Rails::VERSION
9
+ spec.authors = ["John Chen"]
10
+ spec.email = ["cgg5207@sina.com"]
11
+ spec.summary = %q{ javascript modal windows. }
12
+ spec.description = %q{ javascript modal windows. visit http://sandbox.scriptiny.com/tinybox2/}
13
+ spec.homepage = "https://github.com/cgg5207/tiny_box2_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_box2_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - John Chen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: " javascript modal windows. visit http://sandbox.scriptiny.com/tinybox2/"
42
+ email:
43
+ - cgg5207@sina.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/images/tiny_box2/close.png
54
+ - app/assets/images/tiny_box2/preload.gif
55
+ - app/assets/javascripts/tiny_box2.js
56
+ - app/assets/javascripts/tiny_box2/tinybox.js
57
+ - app/assets/stylesheets/tiny_box2.css
58
+ - app/assets/stylesheets/tiny_box2/style.css.erb
59
+ - example/advanced.html
60
+ - example/ajax.html
61
+ - example/images/close.png
62
+ - example/images/preload.gif
63
+ - example/images/rhino.jpg
64
+ - example/index.html
65
+ - example/packed.js
66
+ - example/post.php
67
+ - example/style.css
68
+ - example/tinybox.js
69
+ - lib/tiny_box2_rails.rb
70
+ - lib/tiny_box2_rails/version.rb
71
+ - tiny_box2_rails.gemspec
72
+ homepage: https://github.com/cgg5207/tiny_box2_rails
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: javascript modal windows.
96
+ test_files: []