typus 0.9.18 → 0.9.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/README.rdoc +50 -1
  2. data/VERSION +1 -1
  3. data/app/helpers/admin/table_helper.rb +40 -40
  4. data/generators/typus/templates/config/initializers/typus.rb +1 -1
  5. data/generators/typus/templates/config/typus/README +0 -1
  6. data/generators/typus/templates/config/typus/typus.yml +1 -3
  7. data/generators/typus/templates/public/images/admin/fancyzoom/bl.gif +0 -0
  8. data/generators/typus/templates/public/images/admin/fancyzoom/bl.png +0 -0
  9. data/generators/typus/templates/public/images/admin/fancyzoom/bm.gif +0 -0
  10. data/generators/typus/templates/public/images/admin/fancyzoom/bm.png +0 -0
  11. data/generators/typus/templates/public/images/admin/fancyzoom/br.gif +0 -0
  12. data/generators/typus/templates/public/images/admin/fancyzoom/br.png +0 -0
  13. data/generators/typus/templates/public/images/admin/fancyzoom/closebox.gif +0 -0
  14. data/generators/typus/templates/public/images/admin/fancyzoom/closebox.png +0 -0
  15. data/generators/typus/templates/public/images/admin/fancyzoom/ml.gif +0 -0
  16. data/generators/typus/templates/public/images/admin/fancyzoom/ml.png +0 -0
  17. data/generators/typus/templates/public/images/admin/fancyzoom/mr.gif +0 -0
  18. data/generators/typus/templates/public/images/admin/fancyzoom/mr.png +0 -0
  19. data/generators/typus/templates/public/images/admin/fancyzoom/tl.gif +0 -0
  20. data/generators/typus/templates/public/images/admin/fancyzoom/tl.png +0 -0
  21. data/generators/typus/templates/public/images/admin/fancyzoom/tm.gif +0 -0
  22. data/generators/typus/templates/public/images/admin/fancyzoom/tm.png +0 -0
  23. data/generators/typus/templates/public/images/admin/fancyzoom/tr.gif +0 -0
  24. data/generators/typus/templates/public/images/admin/fancyzoom/tr.png +0 -0
  25. data/generators/typus/templates/public/images/admin/ui-icons.png +0 -0
  26. data/generators/typus/templates/public/javascripts/admin/builder.js +136 -0
  27. data/generators/typus/templates/public/javascripts/admin/controls.js +963 -0
  28. data/generators/typus/templates/public/javascripts/admin/dragdrop.js +973 -0
  29. data/generators/typus/templates/public/javascripts/admin/effects.js +1128 -0
  30. data/generators/typus/templates/public/javascripts/admin/fancyzoom.js +221 -0
  31. data/generators/typus/templates/public/javascripts/admin/prototype.js +4320 -0
  32. data/generators/typus/templates/public/javascripts/admin/scriptaculous.js +58 -0
  33. data/generators/typus/templates/public/javascripts/admin/slider.js +275 -0
  34. data/generators/typus/templates/public/javascripts/admin/sound.js +55 -0
  35. data/generators/typus/templates/public/stylesheets/admin/screen.css +163 -524
  36. data/generators/typus/typus_generator.rb +10 -4
  37. data/generators/typus_update_schema_to_01/templates/config/typus.yml +1 -3
  38. data/lib/typus/configuration.rb +1 -1
  39. data/lib/typus/generator.rb +9 -9
  40. data/lib/typus/preview.rb +13 -0
  41. data/lib/typus.rb +1 -0
  42. data/test/config/default/typus.yml +1 -3
  43. data/test/config/working/typus.yml +1 -3
  44. data/test/functional/admin/comments_controller_test.rb +2 -2
  45. data/test/helpers/admin/form_helper_test.rb +2 -2
  46. data/test/helpers/admin/table_helper_test.rb +14 -14
  47. data/test/lib/configuration_test.rb +1 -1
  48. data/typus.gemspec +31 -8
  49. metadata +31 -8
  50. data/generators/typus/templates/public/images/admin/arrow_down.gif +0 -0
  51. data/generators/typus/templates/public/images/admin/arrow_up.gif +0 -0
  52. data/generators/typus/templates/public/images/admin/spinner.gif +0 -0
  53. data/generators/typus/templates/public/images/admin/status_false.gif +0 -0
  54. data/generators/typus/templates/public/images/admin/status_true.gif +0 -0
  55. data/generators/typus/templates/public/images/admin/trash.gif +0 -0
@@ -0,0 +1,221 @@
1
+ Object.extend(String.prototype, {
2
+ // if a string doesn't end with str it appends it
3
+ ensureEndsWith: function(str) {
4
+ return this.endsWith(str) ? this : this + str;
5
+ },
6
+
7
+ // makes sure that string ends with px (for setting widths and heights)
8
+ px: function() {
9
+ return this.ensureEndsWith('px');
10
+ }
11
+ });
12
+
13
+ Object.extend(Number.prototype, {
14
+ // makes sure that number ends with px (for setting widths and heights)
15
+ px: function() {
16
+ return this.toString().px();
17
+ }
18
+ });
19
+
20
+ var Window = {
21
+ // returns correct dimensions for window, had issues with prototype's sometimes. this was ganked from apple.
22
+ size: function() {
23
+ var width = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
24
+ var height = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
25
+ var x = window.pageXOffset || (window.document.documentElement.scrollLeft || window.document.body.scrollLeft);
26
+ var y = window.pageYOffset || (window.document.documentElement.scrollTop || window.document.body.scrollTop);
27
+ return {'width':width, 'height':height, 'x':x, 'y':y}
28
+ }
29
+ }
30
+
31
+ var FancyZoomBox = {
32
+ directory : 'images',
33
+ zooming : false,
34
+ setup : false,
35
+
36
+ init: function(directory) {
37
+ if (FancyZoomBox.setup) return;
38
+ FancyZoomBox.setup = true;
39
+
40
+ var ie = navigator.userAgent.match(/MSIE\s(\d)+/);
41
+ if (ie) {
42
+ var version = parseInt(ie[1]);
43
+ Prototype.Browser['IE' + version.toString()] = true;
44
+ Prototype.Browser.ltIE7 = (version < 7) ? true : false;
45
+ }
46
+
47
+ var html = '<div id="zoom" style="display:none;"> \
48
+ <table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;"> \
49
+ <tbody> \
50
+ <tr> \
51
+ <td class="tl" style="background:url(' + FancyZoomBox.directory + '/tl.png) 0 0 no-repeat; width:20px; height:20px; overflow:hidden;" /> \
52
+ <td class="tm" style="background:url(' + FancyZoomBox.directory + '/tm.png) 0 0 repeat-x; height:20px; overflow:hidden;" /> \
53
+ <td class="tr" style="background:url(' + FancyZoomBox.directory + '/tr.png) 100% 0 no-repeat; width:20px; height:20px; overflow:hidden;" /> \
54
+ </tr> \
55
+ <tr> \
56
+ <td class="ml" style="background:url(' + FancyZoomBox.directory + '/ml.png) 0 0 repeat-y; width:20px; overflow:hidden;" /> \
57
+ <td class="mm" style="background:#fff; vertical-align:top; padding:10px;"> \
58
+ <div id="zoom_content"> \
59
+ </div> \
60
+ </td> \
61
+ <td class="mr" style="background:url(' + FancyZoomBox.directory + '/mr.png) 100% 0 repeat-y; width:20px; overflow:hidden;" /> \
62
+ </tr> \
63
+ <tr> \
64
+ <td class="bl" style="background:url(' + FancyZoomBox.directory + '/bl.png) 0 100% no-repeat; width:20px; height:20px; overflow:hidden;" /> \
65
+ <td class="bm" style="background:url(' + FancyZoomBox.directory + '/bm.png) 0 100% repeat-x; height:20px; overflow:hidden;" /> \
66
+ <td class="br" style="background:url(' + FancyZoomBox.directory + '/br.png) 100% 100% no-repeat; width:20px; height:20px; overflow:hidden;" /> \
67
+ </tr> \
68
+ </tbody> \
69
+ </table> \
70
+ <a href="#" title="Close" id="zoom_close" style="position:absolute; top:0; left:0;"> \
71
+ <img src="' + FancyZoomBox.directory + '/closebox.png" alt="Close" style="border:none; margin:0; padding:0;" /> \
72
+ </a> \
73
+ </div>';
74
+
75
+ var body = $$('body').first();
76
+ body.insert(html);
77
+
78
+ FancyZoomBox.zoom = $('zoom');
79
+ FancyZoomBox.zoom_table = $('zoom_table');
80
+ FancyZoomBox.zoom_close = $('zoom_close');
81
+ FancyZoomBox.zoom_content = $('zoom_content');
82
+ FancyZoomBox.zoom_close.observe('click', FancyZoomBox.hide);
83
+ FancyZoomBox.middle_row = $A([$$('td.ml'), $$('td.mm'), $$('td.mr')]).flatten();
84
+ FancyZoomBox.cells = FancyZoomBox.zoom_table.select('td');
85
+
86
+ // hide zoom if click fired is not inside zoom
87
+ $$('html').first().observe('click', function(e) {
88
+ var click_in_zoom = e.findElement('#zoom'),
89
+ zoom_display = FancyZoomBox.zoom.getStyle('display');
90
+ if (zoom_display == 'block' && !click_in_zoom) {
91
+ FancyZoomBox.hide(e);
92
+ }
93
+ });
94
+
95
+ // esc to close zoom box
96
+ $(document).observe('keyup', function(e) {
97
+ var zoom_display = FancyZoomBox.zoom.getStyle('display');
98
+ if (e.keyCode == Event.KEY_ESC && zoom_display == 'block') {
99
+ FancyZoomBox.hide(e);
100
+ }
101
+ });
102
+
103
+ // just use gifs as ie6 and below suck
104
+ if (Prototype.Browser.ltIE7) {
105
+ FancyZoomBox.switchBackgroundImagesTo('gif');
106
+ }
107
+ },
108
+
109
+ show: function(e) {
110
+ e.stop();
111
+ if (FancyZoomBox.zooming) return;
112
+ FancyZoomBox.zooming = true;
113
+ var element = e.findElement('a');
114
+ var related_div = element.content_div;
115
+ var width = (element.zoom_width || related_div.getWidth()) + 60;
116
+ var height = (element.zoom_height || related_div.getHeight()) + 60;
117
+ var d = Window.size();
118
+ var yOffset = document.viewport.getScrollOffsets()[1];
119
+ // ensure that newTop is at least 0 so it doesn't hide close button
120
+ var newTop = Math.max((d.height/2) - (height/2) + yOffset, 0);
121
+ var newLeft = (d.width/2) - (width/2);
122
+ FancyZoomBox.curTop = e.pointerY();
123
+ FancyZoomBox.curLeft = e.pointerX();
124
+ FancyZoomBox.moveX = -(FancyZoomBox.curLeft - newLeft);
125
+ FancyZoomBox.moveY = -(FancyZoomBox.curTop - newTop);
126
+ FancyZoomBox.zoom.hide().setStyle({
127
+ position : 'absolute',
128
+ top : FancyZoomBox.curTop.px(),
129
+ left : FancyZoomBox.curLeft.px()
130
+ });
131
+
132
+ new Effect.Parallel([
133
+ new Effect.Appear(FancyZoomBox.zoom, {sync:true}),
134
+ new Effect.Move(FancyZoomBox.zoom, {x: FancyZoomBox.moveX, y: FancyZoomBox.moveY, sync: true}),
135
+ new Effect.Morph(FancyZoomBox.zoom, {
136
+ style: {
137
+ width: width.px(),
138
+ height: height.px()
139
+ },
140
+ sync: true,
141
+ beforeStart: function(effect) {
142
+ // middle row height must be set for IE otherwise it tries to be "logical" with the height
143
+ if (Prototype.Browser.IE) {
144
+ FancyZoomBox.middle_row.invoke('setStyle', {height:(height-40).px()});
145
+ }
146
+ FancyZoomBox.fixBackgroundsForIE();
147
+ },
148
+ afterFinish: function(effect) {
149
+ FancyZoomBox.zoom_content.innerHTML = related_div.innerHTML;
150
+ FancyZoomBox.unfixBackgroundsForIE();
151
+ FancyZoomBox.zoom_close.show();
152
+ FancyZoomBox.zooming = false;
153
+ }
154
+ })
155
+ ], { duration: 0.5 });
156
+ },
157
+
158
+ hide: function(e) {
159
+ e.stop();
160
+ if (FancyZoomBox.zooming) return;
161
+ FancyZoomBox.zooming = true;
162
+ new Effect.Parallel([
163
+ new Effect.Move(FancyZoomBox.zoom, {x: FancyZoomBox.moveX*-1, y: FancyZoomBox.moveY*-1, sync: true}),
164
+ new Effect.Morph(FancyZoomBox.zoom, {
165
+ style: {
166
+ width: '1'.px(),
167
+ height: '1'.px()
168
+ },
169
+ sync : true,
170
+ beforeStart: function(effect) {
171
+ FancyZoomBox.fixBackgroundsForIE();
172
+ FancyZoomBox.zoom_content.innerHTML = '';
173
+ FancyZoomBox.zoom_close.hide();
174
+ },
175
+ afterFinish: function(effect) {
176
+ FancyZoomBox.unfixBackgroundsForIE();
177
+ FancyZoomBox.zooming = false;
178
+ }
179
+ }),
180
+ new Effect.Fade(FancyZoomBox.zoom, {sync:true})
181
+ ], { duration: 0.5 });
182
+ },
183
+
184
+ // switches the backgrounds of the cells and the close image to png's or gif's
185
+ // fixes ie's issues with fading and appearing transparent png's with
186
+ // no background and ie6's craptacular handling of transparent png's
187
+ switchBackgroundImagesTo: function(to) {
188
+ FancyZoomBox.cells.each(function(td) {
189
+ var bg = td.getStyle('background-image').gsub(/\.(png|gif|none)\)$/, '.' + to + ')');
190
+ td.setStyle('background-image: ' + bg);
191
+ });
192
+ var close_img = FancyZoomBox.zoom_close.firstDescendant();
193
+ var new_img = close_img.readAttribute('src').gsub(/\.(png|gif|none)$/, '.' + to);
194
+ close_img.writeAttribute('src', new_img);
195
+ },
196
+
197
+ // prevents the thick black border that happens when appearing or fading png in IE
198
+ fixBackgroundsForIE: function() {
199
+ if (Prototype.Browser.IE7) { FancyZoomBox.switchBackgroundImagesTo('gif'); }
200
+ },
201
+
202
+ // swaps back to png's for prettier shadows
203
+ unfixBackgroundsForIE: function() {
204
+ if (Prototype.Browser.IE7) { FancyZoomBox.switchBackgroundImagesTo('png'); }
205
+ }
206
+ }
207
+
208
+ var FancyZoom = Class.create({
209
+ initialize: function(element) {
210
+ this.options = arguments.length > 1 ? arguments[1] : {};
211
+ FancyZoomBox.init();
212
+ this.element = $(element);
213
+ if (this.element) {
214
+ this.element.content_div = $(this.element.readAttribute('href').gsub(/^#/, ''));
215
+ this.element.content_div.hide();
216
+ this.element.zoom_width = this.options.width;
217
+ this.element.zoom_height = this.options.height;
218
+ this.element.observe('click', FancyZoomBox.show);
219
+ }
220
+ }
221
+ });