raphael-rails 1.5.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,248 @@
1
+ Raphael(function () {
2
+
3
+ // TOC
4
+ (function (ol) {
5
+ if (!ol) {
6
+ return;
7
+ }
8
+ var li = document.createElement("li"),
9
+ isABBR = function (str, abbr) {
10
+ var letters = abbr.toUpperCase().split(""),
11
+ first = letters.shift(),
12
+ rg = new RegExp("^[" + first.toLowerCase() + first + "][a-z]*" + letters.join("[a-z]*") + "[a-z]*$");
13
+ return !!String(str).match(rg);
14
+ },
15
+ score = function (me, search) {
16
+ me = String(me);
17
+ search = String(search);
18
+ var score = 0,
19
+ chunk;
20
+ if (me == search) {
21
+ return 1;
22
+ }
23
+ if (!me || !search) {
24
+ return 0;
25
+ }
26
+ if (isABBR(me, search)) {
27
+ return .9;
28
+ }
29
+ score = 0;
30
+ chunk = me.toLowerCase();
31
+ for (var j, i = 0, ii = search.length; i < ii; i++) {
32
+ j = chunk.indexOf(search.charAt(i));
33
+ if (~j) {
34
+ chunk = chunk.substring(j + 1);
35
+ score += 1 / (j + 1);
36
+ }
37
+ }
38
+ score = Math.max(score / ii - Math.abs(me.length - ii) / me.length / 2, 0);
39
+ return score;
40
+ };
41
+ li.innerHTML = '<input type="search" id="dr-filter" results="0">';
42
+ var lis = ol.getElementsByTagName("span"),
43
+ names = [],
44
+ rgName = /[^\.\(]*(?=(\(\))?$)/;
45
+ for (var i = 0, ii = lis.length; i < ii; i++) {
46
+ names[i] = {
47
+ li: lis[i].parentNode.parentNode,
48
+ text: lis[i].innerHTML.match(rgName)[0]
49
+ };
50
+ }
51
+ ol.insertBefore(li, ol.firstChild);
52
+ var input = document.getElementById("dr-filter");
53
+ input.style.width = "100%";
54
+ input.style.marginTop = "10px";
55
+ input.onclick = input.onchange = input.onkeydown = input.onkeyup = function () {
56
+ var v = input.value,
57
+ res = [];
58
+ if (v.length > 1) {
59
+ for (var i = 0, ii = names.length; i < ii; i++) {
60
+ res[i] = {
61
+ li: names[i].li,
62
+ weight: score(names[i].text, v)
63
+ };
64
+ }
65
+ res.sort(function (a, b) {
66
+ return b.weight - a.weight;
67
+ });
68
+ for (i = 0, ii = res.length; i < ii; i++) {
69
+ ol.appendChild(res[i].li);
70
+ }
71
+ } else {
72
+ for (i = 0, ii = names.length; i < ii; i++) {
73
+ ol.appendChild(names[i].li);
74
+ }
75
+ }
76
+ };
77
+ })(document.getElementById("dr-toc"));
78
+
79
+ function prepare(id) {
80
+ var div = document.getElementById(id);
81
+ div.style.cssText = "float:right;padding:10px;width:99px;height:99px;background:#2C53B0 url(http://raphaeljs.com/blueprint-min.png) no-repeat";
82
+ return Raphael(div, 99, 99);
83
+ }
84
+
85
+ var line = {
86
+ stroke: "#fff",
87
+ "stroke-width": 2,
88
+ "stroke-linecap": "round",
89
+ "stroke-linejoin": "round"
90
+ },
91
+ dots = {
92
+ stroke: "#fff",
93
+ "stroke-width": 2,
94
+ "stroke-dasharray": "- ",
95
+ "stroke-linecap": "round",
96
+ "stroke-linejoin": "round"
97
+ },
98
+ fill = {
99
+ stroke: "#fff",
100
+ fill: "#fff",
101
+ "fill-opacity": .5,
102
+ "stroke-width": 2,
103
+ "stroke-linecap": "round",
104
+ "stroke-linejoin": "round"
105
+ },
106
+ none = {
107
+ fill: "#000",
108
+ opacity: 0
109
+ };
110
+ prepare("Paper.path-extra").path("M10,10R90,50 10,90").attr(line);
111
+
112
+ (function (r) {
113
+ var there;
114
+ r.circle(15, 15, 10).attr(fill).click(function () {
115
+ var clr = Raphael.hsb(Math.random(), .6, 1);
116
+ this.animate(there ? {
117
+ cx: 15,
118
+ cy: 15,
119
+ r: 10,
120
+ stroke: "#fff",
121
+ fill: "#fff"
122
+ } : {
123
+ cx: 80,
124
+ cy: 80,
125
+ r: 15,
126
+ stroke: clr,
127
+ fill: clr
128
+ }, 600, ["bounce", "<>", "elastic", ""][Math.round(Math.random() * 3)]);
129
+ there = !there;
130
+ });
131
+ })(prepare("Element.animate-extra"));
132
+
133
+ (function (r) {
134
+ var x, y;
135
+ r.circle(15, 15, 10).attr(fill).drag(function (dx, dy) {
136
+ this.attr({
137
+ cx: Math.min(Math.max(x + dx, 15), 85),
138
+ cy: Math.min(Math.max(y + dy, 15), 85)
139
+ });
140
+ }, function () {
141
+ x = this.attr("cx");
142
+ y = this.attr("cy");
143
+ });
144
+
145
+ })(prepare("Element.drag-extra"));
146
+
147
+ (function (r) {
148
+ var e = r.ellipse(50, 50, 40, 30).attr(fill).click(function () {
149
+ this.animate({
150
+ transform: "r180"
151
+ }, 1000, function () {
152
+ this.attr({
153
+ transform: ""
154
+ });
155
+ });
156
+ }),
157
+ bb = r.rect().attr(e.getBBox()).attr(dots);
158
+ eve.on("anim.frame." + e.id, function (anim) {
159
+ bb.attr(e.getBBox());
160
+ });
161
+ })(prepare("Element.getBBox-extra"));
162
+
163
+ (function (r) {
164
+ var e = r.path("M10,10R20,70 30,40 40,80 50,10 60,50 70,20 80,30 90,90").attr(line),
165
+ l = e.getTotalLength(),
166
+ to = 1;
167
+ r.customAttributes.along = function (a) {
168
+ var p = e.getPointAtLength(a * l);
169
+ return {
170
+ transform: "t" + [p.x, p.y] + "r" + p.alpha
171
+ };
172
+ };
173
+ var c = r.ellipse(0, 0, 5, 2).attr({
174
+ along: 0
175
+ }).attr(line);
176
+ r.rect(0, 0, 100, 100).attr(none).click(function () {
177
+ c.stop().animate({
178
+ along: to
179
+ }, 5000);
180
+ to = +!to;
181
+ });
182
+ })(prepare("Element.getPointAtLength-extra"));
183
+
184
+ (function (r) {
185
+ var e = r.path("M10,10R20,70 30,40 40,80 50,10 60,50 70,20 80,30 90,90").attr(line),
186
+ l = e.getTotalLength() - 10,
187
+ to = 1;
188
+ r.customAttributes.along = function (a) {
189
+ return {
190
+ path: e.getSubpath(a * l, a * l + 11)
191
+ };
192
+ };
193
+ var c = r.path().attr(line).attr({
194
+ along: 0,
195
+ stroke: "#f00",
196
+ "stroke-width": 3
197
+ });
198
+ r.rect(0, 0, 100, 100).attr(none).click(function () {
199
+ c.stop().animate({
200
+ along: to
201
+ }, 5000);
202
+ to = +!to;
203
+ });
204
+ })(prepare("Element.getSubpath-extra"));
205
+
206
+ (function (r) {
207
+ r.circle(50, 50, 40).attr(line).glow({color: "#fff"});
208
+ })(prepare("Element.glow-extra"));
209
+
210
+ (function (r) {
211
+ r.rect(10, 10, 40, 30).attr(dots);
212
+ r.rect(10, 10, 40, 30).attr(line).transform("r-30, 50, 10t10, 20s1.5");
213
+ r.text(50, 90, "r-30, 50, 10\nt10, 20s1.5").attr({fill: "#fff"});
214
+ })(prepare("Element.transform-extra"));
215
+
216
+ (function (r) {
217
+ r.circle(50, 50, 40).attr(line);
218
+ })(prepare("Paper.circle-extra"));
219
+
220
+ (function (r) {
221
+ r.ellipse(50, 50, 40, 30).attr(line);
222
+ })(prepare("Paper.ellipse-extra"));
223
+
224
+ (function (r) {
225
+ r.rect(10, 10, 50, 50).attr(line);
226
+ r.rect(40, 40, 50, 50, 10).attr(line);
227
+ })(prepare("Paper.rect-extra"));
228
+
229
+ (function (r) {
230
+ var set = r.set(
231
+ r.rect(10, 10, 50, 50).attr(fill),
232
+ r.rect(40, 40, 50, 50, 10).attr(fill)
233
+ ).hover(function () {
234
+ set.stop().animate({stroke: "#f00"}, 600, "<>");
235
+ }, function () {
236
+ set.stop().animate({stroke: "#fff"}, 600, "<>");
237
+ });
238
+ })(prepare("Paper.set-extra"));
239
+
240
+ (function (r) {
241
+ r.text(50, 50, "Raphaël\nkicks\nbutt!").attr({
242
+ fill: "#fff",
243
+ font: "italic 20px Georgia",
244
+ transform: "r-10"
245
+ });
246
+ })(prepare("Paper.text-extra"));
247
+
248
+ });
metadata CHANGED
@@ -1,87 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: raphael-rails
3
- version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
6
- segments:
7
- - 1
8
- - 5
9
- - 2
10
- version: 1.5.2
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Dmitry Baranovskiy
14
9
  - Ben Poweski
10
+ - Robert Fletcher
15
11
  autorequire:
16
12
  bindir: bin
17
13
  cert_chain: []
18
-
19
- date: 2011-05-22 00:00:00 -05:00
20
- default_executable:
14
+ date: 2012-03-26 00:00:00.000000000 Z
21
15
  dependencies: []
22
-
23
16
  description: Raphael JS as a Rubygem for use in the Rails asset pipeline
24
- email:
17
+ email:
25
18
  - bpoweski@3factors.com
26
19
  executables: []
27
-
28
20
  extensions: []
29
-
30
21
  extra_rdoc_files: []
31
-
32
- files:
22
+ files:
33
23
  - README.md
34
24
  - license.txt
35
25
  - Rakefile
36
26
  - Gemfile
37
- - lib/raphael-rails/version.rb
38
27
  - lib/raphael-rails.rb
39
- - vendor/assets/javascripts/plugins/colorpicker.js
40
- - vendor/assets/javascripts/plugins/colorwheel.js
41
- - vendor/assets/javascripts/plugins/jquery.colorpicker.js
42
- - vendor/assets/javascripts/plugins/jquery.colorwheel.js
43
- - vendor/assets/javascripts/plugins/raphael.blur.js
44
- - vendor/assets/javascripts/plugins/raphael.path.methods.js
45
- - vendor/assets/javascripts/plugins/raphael.primitives.js
46
- - vendor/assets/javascripts/plugins/raphael.shadow.js
47
- - vendor/assets/javascripts/raphael-min.js
28
+ - lib/raphael-rails/version.rb
48
29
  - vendor/assets/javascripts/raphael.js
49
- - vendor/assets/javascripts/test/image/raphael.png
50
- - vendor/assets/javascripts/test/integration.html
51
- - vendor/assets/javascripts/test/vendor/jquery.js
52
- has_rdoc: true
30
+ - vendor/assets/javascripts/history.md
31
+ - vendor/assets/javascripts/reference.js
32
+ - vendor/assets/javascripts/raphael.svg.js
33
+ - vendor/assets/javascripts/raphael.core.js
34
+ - vendor/assets/javascripts/make
35
+ - vendor/assets/javascripts/license.txt
36
+ - vendor/assets/javascripts/raphael-min.js
37
+ - vendor/assets/javascripts/reference.html
38
+ - vendor/assets/javascripts/README.markdown
39
+ - vendor/assets/javascripts/raphael.vml.js
53
40
  homepage: http://github.com/bpoweski/raphael-rails
54
41
  licenses: []
55
-
56
42
  post_install_message:
57
43
  rdoc_options: []
58
-
59
- require_paths:
44
+ require_paths:
60
45
  - lib
61
- required_ruby_version: !ruby/object:Gem::Requirement
46
+ required_ruby_version: !ruby/object:Gem::Requirement
62
47
  none: false
63
- requirements:
64
- - - ">="
65
- - !ruby/object:Gem::Version
66
- hash: 3
67
- segments:
68
- - 0
69
- version: "0"
70
- required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
53
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
54
+ requirements:
55
+ - - ! '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
79
58
  requirements: []
80
-
81
59
  rubyforge_project:
82
- rubygems_version: 1.3.7
60
+ rubygems_version: 1.8.17
83
61
  signing_key:
84
62
  specification_version: 3
85
63
  summary: Raphael JS as a Rubygem
86
64
  test_files: []
87
-
@@ -1,259 +0,0 @@
1
- /*!
2
- * Color Picker 0.1.0 - Raphael plugin
3
- *
4
- * Copyright (c) 2010 Dmitry Baranovskiy (http://raphaeljs.com)
5
- * Based on Color Wheel (http://jweir.github.com/colorwheel) by John Weir (http://famedriver.com)
6
- * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) license.
7
- */
8
-
9
- /*
10
- * Usage
11
- * var cp = Raphael.colorpicker(x, y, size, "#fff"); // #fff is optional init color
12
- * cp.color(); // returns "#fff"
13
- * cp.color("#fc0"); // sets new color
14
- * cp.onchange = function (color) {
15
- * // do something with the color when user change it
16
- * }
17
- * cp.remove(); // removes widget
18
- */
19
- (function (Raphael) {
20
- Raphael.colorpicker = function (x, y, size, initcolor, element) {
21
- return new ColorPicker(x, y, size, initcolor, element);
22
- };
23
- Raphael.fn.colorPickerIcon = function (x, y, r) {
24
- var segments = pi * r * 2 / Math.min(r / 8, 4);
25
- var a = pi / 2 - pi * 2 / segments * 1.5,
26
- path = ["M", x, y - r, "A", r, r, 0, 0, 1, r * Math.cos(a) + x, y - r * Math.sin(a), "L", x, y, "z"].join();
27
- for (var i = 0; i < segments; i++) {
28
- this.path(path).attr({
29
- stroke: "none",
30
- fill: "hsb(" + (segments - i) * (255 / segments) + ", 255, 255)",
31
- rotation: [90 + (360 / segments) * i, x, y]
32
- });
33
- }
34
- return this.circle(x, y, r).attr({
35
- fill: "r#fff-#fff",
36
- "fill-opacity": 0,
37
- "stroke-width": Math.round(r * .03),
38
- stroke: "#fff"
39
- });
40
- };
41
- var pi = Math.PI;
42
- function angle(x, y) {
43
- return (x < 0) * 180 + Math.atan(-y / -x) * 180 / pi;
44
- }
45
- var doc = document, win = window,
46
- addEvent = (function () {
47
- if (doc.addEventListener) {
48
- return function (obj, type, fn, element) {
49
- var f = function (e) {
50
- return fn.call(element, e);
51
- };
52
- obj.addEventListener(type, f, false);
53
- return function () {
54
- obj.removeEventListener(type, f, false);
55
- return true;
56
- };
57
- };
58
- } else if (doc.attachEvent) {
59
- return function (obj, type, fn, element) {
60
- var f = function (e) {
61
- return fn.call(element, e || win.event);
62
- };
63
- obj.attachEvent("on" + type, f);
64
- var detacher = function () {
65
- obj.detachEvent("on" + type, f);
66
- return true;
67
- };
68
- return detacher;
69
- };
70
- }
71
- })(),
72
- ColorPicker = function (x, y, size, initcolor, element) {
73
- size = size || 200;
74
- var w3 = 3 * size / 200,
75
- w1 = size / 200,
76
- fi = 1.6180339887,
77
- size20 = size / 20,
78
- size2 = size / 2,
79
- padding = 2 * size / 200,
80
- height = size + size20 * 2 + padding * 3,
81
- t = this,
82
- H = 1, S = 1, B = 1, s = size - (size20 * 4),
83
- r = element ? Raphael(element, size, height) : Raphael(x, y, size, height),
84
- xy = s / 6 + size20 * 2 + padding,
85
- wh = s * 2 / 3 - padding * 2;
86
- w1 < 1 && (w1 = 1);
87
- w3 < 1 && (w3 = 1);
88
-
89
-
90
- r.colorPickerIcon(size2, size2, size2 - padding);
91
-
92
- t.cursor = r.set();
93
- t.cursor.push(r.circle(size2, size2, size20 / 2).attr({
94
- stroke: "#000",
95
- opacity: .5,
96
- "stroke-width": w3
97
- }));
98
- t.cursor.push(t.cursor[0].clone().attr({
99
- stroke: "#fff",
100
- opacity: 1,
101
- "stroke-width": w1
102
- }));
103
- t.disc = r.circle(size2, size2, size2 - padding).attr({
104
- fill: "#000",
105
- "fill-opacity": 0,
106
- stroke: "none",
107
- cursor: "crosshair"
108
- });
109
- var style = t.disc.node.style;
110
- style.unselectable = "on";
111
- style.MozUserSelect = "none";
112
- style.WebkitUserSelect= "none";
113
-
114
- // brightness drawing
115
- var h = size20 * 2 + 2;
116
- t.brect = r.rect(padding + h / fi / 2, size + padding * 2, size - padding * 2 - h / fi, h - padding * 2).attr({
117
- stroke: "#fff",
118
- fill: "180-#fff-#000"
119
- });
120
- t.cursorb = r.set();
121
- t.cursorb.push(r.rect(size - padding - h / fi, size + padding, ~~(h / fi), h, w3).attr({
122
- stroke: "#000",
123
- opacity: .5,
124
- "stroke-width": w3
125
- }));
126
- t.cursorb.push(t.cursorb[0].clone().attr({
127
- stroke: "#fff",
128
- opacity: 1,
129
- "stroke-width": w1
130
- }));
131
- t.btop = t.brect.clone().attr({
132
- stroke: "#000",
133
- fill: "#000",
134
- opacity: 0
135
- });
136
- style = t.btop.node.style;
137
- style.unselectable = "on";
138
- style.MozUserSelect = "none";
139
- style.WebkitUserSelect= "none";
140
-
141
- t.bwidth = ~~(h / fi) / 2;
142
- t.minx = padding + t.bwidth;
143
- t.maxx = size - h / fi - padding + t.bwidth;
144
-
145
- t.H = t.S = t.B = 1;
146
- t.padding = padding;
147
- t.raphael = r;
148
- t.size2 = size2;
149
- t.size20 = size20;
150
- t.x = x;
151
- t.y = y;
152
-
153
- // events
154
- t.hson = addEvent(t.disc.node, "mousedown", function (e) {
155
- var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
156
- scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
157
- this.hsOnTheMove = true;
158
- this.setHS(e.clientX + scrollX - this.x, e.clientY + scrollY - this.y);
159
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
160
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
161
- }, t);
162
- t.bon = addEvent(t.btop.node, "mousedown", function (e) {
163
- var scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
164
- this.bOnTheMove = true;
165
- this.setB(e.clientX + scrollX - this.x);
166
- this.docmove = addEvent(doc, "mousemove", this.docOnMove, this);
167
- this.docup = addEvent(doc, "mouseup", this.docOnUp, this);
168
- }, t);
169
- t.winunload = addEvent(win, "unload", function () {
170
- this.hson();
171
- this.bon();
172
- this.docmove && this.docmove();
173
- this.docup && this.docup();
174
- this.winunload();
175
- }, t);
176
-
177
- t.color(initcolor || "#fff");
178
- this.onchanged && this.onchanged(this.color());
179
- };
180
- ColorPicker.prototype.setB = function (x) {
181
- x < this.minx && (x = this.minx);
182
- x > this.maxx && (x = this.maxx);
183
- this.cursorb.attr({x: x - this.bwidth});
184
- this.B = (x - this.minx) / (this.maxx - this.minx);
185
- this.onchange && this.onchange(this.color());
186
- };
187
- ColorPicker.prototype.setHS = function (x, y) {
188
- var X = x - this.size2,
189
- Y = y - this.size2,
190
- R = this.size2 - this.size20 / 2 - this.padding,
191
- d = angle(X, Y),
192
- rd = d * pi / 180;
193
- isNaN(d) && (d = 0);
194
- if (X * X + Y * Y > R * R) {
195
- x = R * Math.cos(rd) + this.size2;
196
- y = R * Math.sin(rd) + this.size2;
197
- }
198
- this.cursor.attr({cx: x, cy: y});
199
- this.H = (1 - d / 360) % 1;
200
- this.S = Math.min((X * X + Y * Y) / R / R, 1);
201
- this.brect.attr({fill: "180-hsb(" + [this.H, this.S] + ",1)-#000"});
202
- this.onchange && this.onchange(this.color());
203
- };
204
- ColorPicker.prototype.docOnMove = function (e) {
205
- var scrollY = doc.documentElement.scrollTop || doc.body.scrollTop,
206
- scrollX = doc.documentElement.scrollLeft || doc.body.scrollLeft;
207
- if (this.hsOnTheMove) {
208
- this.setHS(e.clientX + scrollX - this.x, e.clientY + scrollY - this.y);
209
- }
210
- if (this.bOnTheMove) {
211
- this.setB(e.clientX + scrollX - this.x);
212
- }
213
- e.preventDefault && e.preventDefault();
214
- e.returnValue = false;
215
- return false;
216
- };
217
- ColorPicker.prototype.docOnUp = function (e) {
218
- this.hsOnTheMove = this.bOnTheMove = false;
219
- this.docmove();
220
- delete this.docmove;
221
- this.docup();
222
- delete this.docup;
223
- this.onchanged && this.onchanged(this.color());
224
- e.preventDefault && e.preventDefault();
225
- e.stopPropagation && e.stopPropagation();
226
- e.returnValue = false;
227
- return false;
228
- };
229
- ColorPicker.prototype.remove = function () {
230
- this.raphael.remove();
231
- this.color = function () {
232
- return false;
233
- };
234
- };
235
- ColorPicker.prototype.color = function (color) {
236
- if (color) {
237
- color = Raphael.getRGB(color);
238
- var hex = color.hex;
239
- color = Raphael.rgb2hsb(color.r, color.g, color.b);
240
- d = color.h * 360;
241
- this.H = color.h;
242
- this.S = color.s;
243
- this.B = color.b;
244
-
245
- this.cursorb.attr({x: this.B * (this.maxx - this.minx) + this.minx - this.bwidth});
246
- this.brect.attr({fill: "180-hsb(" + [this.H, this.S] + ",1)-#000"});
247
-
248
- var d = (1 - this.H) * 360,
249
- rd = d * pi / 180,
250
- R = (this.size2 - this.size20 / 2 - this.padding) * this.S,
251
- x = Math.cos(rd) * R + this.size2,
252
- y = Math.sin(rd) * R + this.size2;
253
- this.cursor.attr({cx: x, cy: y});
254
- return this;
255
- } else {
256
- return Raphael.hsb2rgb(this.H, this.S, this.B).hex;
257
- }
258
- };
259
- })(window.Raphael);