right-rails 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/CHANGELOG +7 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -1
  4. data/init.rb +1 -0
  5. data/lib/generators/right_rails/right_rails_generator.rb +15 -6
  6. data/lib/right_rails.rb +1 -1
  7. data/lib/right_rails/controller_extensions.rb +28 -15
  8. data/lib/right_rails/helpers/misc.rb +38 -38
  9. data/lib/right_rails/helpers/rails.rb +50 -7
  10. data/lib/rjs_renderer.rb +26 -0
  11. data/spec/lib/right_rails/controller_extensions_spec.rb +25 -14
  12. data/spec/lib/right_rails/helpers/forms_spec.rb +6 -6
  13. data/spec/lib/right_rails/helpers/rails_spec.rb +44 -45
  14. data/vendor/assets/images/rightjs-ui/rte.png +0 -0
  15. data/vendor/assets/javascripts/right-safe-src.js +2 -2
  16. data/vendor/assets/javascripts/right-safe.js +2 -2
  17. data/vendor/assets/javascripts/right-src.js +386 -100
  18. data/vendor/assets/javascripts/right.js +2 -2
  19. data/vendor/assets/javascripts/right/calendar-src.js +19 -3
  20. data/vendor/assets/javascripts/right/calendar.js +2 -2
  21. data/vendor/assets/javascripts/right/colorpicker-src.js +59 -20
  22. data/vendor/assets/javascripts/right/colorpicker.js +2 -2
  23. data/vendor/assets/javascripts/right/i18n/de.js +43 -42
  24. data/vendor/assets/javascripts/right/i18n/es.js +1 -0
  25. data/vendor/assets/javascripts/right/i18n/fi.js +1 -0
  26. data/vendor/assets/javascripts/right/i18n/fr.js +1 -0
  27. data/vendor/assets/javascripts/right/i18n/hu.js +1 -0
  28. data/vendor/assets/javascripts/right/i18n/it.js +1 -0
  29. data/vendor/assets/javascripts/right/i18n/jp.js +1 -0
  30. data/vendor/assets/javascripts/right/i18n/lt.js +96 -0
  31. data/vendor/assets/javascripts/right/i18n/nl.js +1 -0
  32. data/vendor/assets/javascripts/right/i18n/pt-br.js +1 -0
  33. data/vendor/assets/javascripts/right/i18n/ru.js +1 -0
  34. data/vendor/assets/javascripts/right/i18n/ua.js +1 -0
  35. data/vendor/assets/javascripts/right/jquerysh-src.js +4 -4
  36. data/vendor/assets/javascripts/right/jquerysh.js +2 -2
  37. data/vendor/assets/javascripts/right/rails-src.js +51 -15
  38. data/vendor/assets/javascripts/right/rails.js +2 -2
  39. data/vendor/assets/javascripts/right/resizable-src.js +11 -11
  40. data/vendor/assets/javascripts/right/rte-src.js +33 -13
  41. data/vendor/assets/javascripts/right/rte.js +2 -2
  42. data/vendor/assets/javascripts/right/slider-src.js +137 -28
  43. data/vendor/assets/javascripts/right/slider.js +2 -2
  44. metadata +24 -126
  45. data/generators/right_rails/right_rails_generator.rb +0 -46
  46. data/generators/right_rails/templates/iframed.html.erb +0 -10
  47. data/generators/right_scaffold/right_scaffold_generator.rb +0 -53
  48. data/generators/right_scaffold/templates/controller.rb +0 -99
  49. data/generators/right_scaffold/templates/helper.rb +0 -2
  50. data/generators/right_scaffold/templates/layout.html.erb +0 -18
  51. data/generators/right_scaffold/templates/style.css +0 -54
  52. data/generators/right_scaffold/templates/view__form.html.erb +0 -16
  53. data/generators/right_scaffold/templates/view__item.html.erb +0 -13
  54. data/generators/right_scaffold/templates/view_edit.html.erb +0 -6
  55. data/generators/right_scaffold/templates/view_index.html.erb +0 -9
  56. data/generators/right_scaffold/templates/view_new.html.erb +0 -5
  57. data/generators/right_scaffold/templates/view_show.html.erb +0 -10
  58. data/lib/generators/right_rails/templates/iframed.html.erb +0 -10
  59. data/public/images/rightjs-ui/colorpicker.png +0 -0
  60. data/public/images/rightjs-ui/resizable.png +0 -0
  61. data/public/images/rightjs-ui/rte.png +0 -0
  62. data/public/javascripts/right-olds-src.js +0 -652
  63. data/public/javascripts/right-olds.js +0 -9
  64. data/public/javascripts/right-safe-src.js +0 -68
  65. data/public/javascripts/right-safe.js +0 -7
  66. data/public/javascripts/right-src.js +0 -6014
  67. data/public/javascripts/right.js +0 -7
  68. data/public/javascripts/right/autocompleter-src.js +0 -625
  69. data/public/javascripts/right/autocompleter.js +0 -7
  70. data/public/javascripts/right/billboard-src.js +0 -564
  71. data/public/javascripts/right/billboard.js +0 -7
  72. data/public/javascripts/right/calendar-src.js +0 -1464
  73. data/public/javascripts/right/calendar.js +0 -7
  74. data/public/javascripts/right/casting-src.js +0 -183
  75. data/public/javascripts/right/casting.js +0 -7
  76. data/public/javascripts/right/colorpicker-src.js +0 -981
  77. data/public/javascripts/right/colorpicker.js +0 -7
  78. data/public/javascripts/right/dialog-src.js +0 -768
  79. data/public/javascripts/right/dialog.js +0 -7
  80. data/public/javascripts/right/dnd-src.js +0 -591
  81. data/public/javascripts/right/dnd.js +0 -7
  82. data/public/javascripts/right/effects-src.js +0 -508
  83. data/public/javascripts/right/effects.js +0 -7
  84. data/public/javascripts/right/i18n/de.js +0 -95
  85. data/public/javascripts/right/i18n/en-us.js +0 -11
  86. data/public/javascripts/right/i18n/es.js +0 -95
  87. data/public/javascripts/right/i18n/fi.js +0 -96
  88. data/public/javascripts/right/i18n/fr.js +0 -95
  89. data/public/javascripts/right/i18n/hu.js +0 -100
  90. data/public/javascripts/right/i18n/it.js +0 -95
  91. data/public/javascripts/right/i18n/jp.js +0 -99
  92. data/public/javascripts/right/i18n/nl.js +0 -95
  93. data/public/javascripts/right/i18n/pt-br.js +0 -95
  94. data/public/javascripts/right/i18n/ru.js +0 -95
  95. data/public/javascripts/right/i18n/ua.js +0 -99
  96. data/public/javascripts/right/in-edit-src.js +0 -373
  97. data/public/javascripts/right/in-edit.js +0 -7
  98. data/public/javascripts/right/jquerysh-src.js +0 -362
  99. data/public/javascripts/right/jquerysh.js +0 -7
  100. data/public/javascripts/right/json-src.js +0 -147
  101. data/public/javascripts/right/json.js +0 -7
  102. data/public/javascripts/right/keys-src.js +0 -87
  103. data/public/javascripts/right/keys.js +0 -7
  104. data/public/javascripts/right/lightbox-src.js +0 -931
  105. data/public/javascripts/right/lightbox.js +0 -7
  106. data/public/javascripts/right/rails-src.js +0 -402
  107. data/public/javascripts/right/rails.js +0 -7
  108. data/public/javascripts/right/rater-src.js +0 -384
  109. data/public/javascripts/right/rater.js +0 -7
  110. data/public/javascripts/right/resizable-src.js +0 -465
  111. data/public/javascripts/right/resizable.js +0 -7
  112. data/public/javascripts/right/rte-src.js +0 -2685
  113. data/public/javascripts/right/rte.js +0 -7
  114. data/public/javascripts/right/selectable-src.js +0 -725
  115. data/public/javascripts/right/selectable.js +0 -7
  116. data/public/javascripts/right/sizzle-src.js +0 -1132
  117. data/public/javascripts/right/sizzle.js +0 -7
  118. data/public/javascripts/right/slider-src.js +0 -395
  119. data/public/javascripts/right/slider.js +0 -7
  120. data/public/javascripts/right/sortable-src.js +0 -430
  121. data/public/javascripts/right/sortable.js +0 -7
  122. data/public/javascripts/right/table-src.js +0 -176
  123. data/public/javascripts/right/table.js +0 -7
  124. data/public/javascripts/right/tabs-src.js +0 -1157
  125. data/public/javascripts/right/tabs.js +0 -7
  126. data/public/javascripts/right/tags-src.js +0 -745
  127. data/public/javascripts/right/tags.js +0 -7
  128. data/public/javascripts/right/tooltips-src.js +0 -331
  129. data/public/javascripts/right/tooltips.js +0 -7
  130. data/public/javascripts/right/uploader-src.js +0 -302
  131. data/public/javascripts/right/uploader.js +0 -7
@@ -1,7 +0,0 @@
1
- /**
2
- * JSON support module v2.2.1
3
- * http://rightjs.org/plugins/json
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- var JSON=function(a,b){function h(a){return(a<10?"0":"")+a}function g(a){return a.replace(f,function(a){return e[a]||"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}a.JSON=b.JSON||{},a.JSON.version="2.2.1";var c=a.JSON,d=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},f=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;"stringify"in c||(c.stringify=function(a){if(a===null)return"null";if(a.toJSON)return a.toJSON();switch(typeof a){case"boolean":return String(a);case"number":return String(a+0);case"string":return'"'+g(a)+'"';case"object":if(a instanceof Array)return"["+a.map(c.stringify).join(",")+"]";if(a instanceof Date)return'"'+a.getUTCFullYear()+"-"+h(a.getUTCMonth()+1)+"-"+h(a.getUTCDate())+"T"+h(a.getUTCHours())+":"+h(a.getUTCMinutes())+":"+h(a.getUTCSeconds())+"."+h(a.getMilliseconds())+'Z"';var b=[];for(var d in a)b.push(c.encode(d)+":"+c.encode(a[d]));return"{"+b.join(",")+"}"}}),"parse"in c||(c.parse=function(a){if(isString(a)&&a){a=a.replace(d,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)});if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return(new Function("return "+a))()}throw"JSON parse error: "+a}),a.$alias(c,{encode:"stringify",decode:"parse"});if(a.Cookie){var i=a.Cookie.prototype.set,j=a.Cookie.prototype.get;a.Cookie.include({set:function(a){return i.call(this,c.stringify(a))},get:function(){return c.parse(j.call(this)||"null")}})}return c}(RightJS,window)
@@ -1,87 +0,0 @@
1
- /**
2
- * Pretty Keyboard Events v2.2.1
3
- * http://rightjs.org/plugins/keys
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- (function(RightJS) {
8
- /**
9
- * The keys plugin initialization
10
- *
11
- * Copyright (C) 2010-2011 Nikolay Nemshilov
12
- */
13
- RightJS.Keys = {
14
- version: '2.2.1'
15
- };
16
-
17
-
18
-
19
- /**
20
- * The Event level keyboard keycodes and stuff
21
- *
22
- * Copyright (C) 2010 Nikolay Nemshilov
23
- */
24
- RightJS.Event.Keys = {
25
- BACKSPACE: 8,
26
- TAB: 9,
27
- ENTER: 13,
28
- ESC: 27,
29
- SPACE: 32,
30
- PAGEUP: 33,
31
- PAGEDOWN: 34,
32
- END: 35,
33
- HOME: 36,
34
- LEFT: 37,
35
- UP: 38,
36
- RIGHT: 39,
37
- DOWN: 40,
38
- INSERT: 45,
39
- DELETE: 46
40
- };
41
-
42
-
43
- /**
44
- * Overloading the Element#on method to handle those fancy names
45
- *
46
- * Copyright (C) 2010-2011 Nikolay Nemshilov
47
- */
48
- [RightJS.Document, RightJS.Element, RightJS.Window].each('include', {
49
- on: function() {
50
- var args = RightJS.$A(arguments), name = args[0];
51
-
52
- if (typeof(name) === 'string') {
53
- var key = name.split(/[\+\-\_ ]+/);
54
- key = (key[key.length - 1] || '').toUpperCase();
55
-
56
- if (key in RightJS.Event.Keys || /^[A-Z0-9]$/.test(key)) {
57
- var meta = /(^|\+|\-| )(meta|alt)(\+|\-| )/i.test(name),
58
- ctrl = /(^|\+|\-| )(ctl|ctrl)(\+|\-| )/i.test(name),
59
- shift = /(^|\+|\-| )(shift)(\+|\-| )/i.test(name),
60
- code = RightJS.Event.Keys[key] || key.charCodeAt(0),
61
- orig = args.slice(1),
62
- method = orig.shift();
63
-
64
- if (typeof(method) === 'string') {
65
- method = this[method] || function() {};
66
- }
67
-
68
- // replacing the arguments
69
- args = ['keydown', function(event) {
70
- var raw = event._;
71
- if (
72
- (raw.keyCode === code) &&
73
- (!meta || raw.metaKey || raw.altKey) &&
74
- (!ctrl || raw.ctrlKey) &&
75
- (!shift || raw.shiftKey)
76
- ) {
77
- return method.call(this, [event].concat(orig));
78
- }
79
- }];
80
- }
81
- }
82
-
83
- return this.$super.apply(this, args);
84
- }
85
- });
86
-
87
- })(RightJS);
@@ -1,7 +0,0 @@
1
- /**
2
- * Pretty Keyboard Events v2.2.1
3
- * http://rightjs.org/plugins/keys
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- (function(a){a.Keys={version:"2.2.1"},a.Event.Keys={BACKSPACE:8,TAB:9,ENTER:13,ESC:27,SPACE:32,PAGEUP:33,PAGEDOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,INSERT:45,DELETE:46},[a.Document,a.Element,a.Window].each("include",{on:function(){var b=a.$A(arguments),c=b[0];if(typeof c==="string"){var d=c.split(/[\+\-\_ ]+/);d=(d[d.length-1]||"").toUpperCase();if(d in a.Event.Keys||/^[A-Z0-9]$/.test(d)){var e=/(^|\+|\-| )(meta|alt)(\+|\-| )/i.test(c),f=/(^|\+|\-| )(ctl|ctrl)(\+|\-| )/i.test(c),g=/(^|\+|\-| )(shift)(\+|\-| )/i.test(c),h=a.Event.Keys[d]||d.charCodeAt(0),i=b.slice(1),j=i.shift();typeof j==="string"&&(j=this[j]||function(){}),b=["keydown",function(a){var b=a._;if(b.keyCode===h&&(!e||b.metaKey||b.altKey)&&(!f||b.ctrlKey)&&(!g||b.shiftKey))return j.call(this,[a].concat(i))}]}}return this.$super.apply(this,b)}})})(RightJS)
@@ -1,931 +0,0 @@
1
- /**
2
- * RightJS-UI Lightbox v2.2.3
3
- * http://rightjs.org/ui/lightbox
4
- *
5
- * Copyright (C) 2009-2011 Nikolay Nemshilov
6
- */
7
- var Lightbox = RightJS.Lightbox = (function(document, RightJS) {
8
- /**
9
- * This module defines the basic widgets constructor
10
- * it creates an abstract proxy with the common functionality
11
- * which then we reuse and override in the actual widgets
12
- *
13
- * Copyright (C) 2010-2011 Nikolay Nemshilov
14
- */
15
-
16
- /**
17
- * The widget units constructor
18
- *
19
- * @param String tag-name or Object methods
20
- * @param Object methods
21
- * @return Widget wrapper
22
- */
23
- function Widget(tag_name, methods) {
24
- if (!methods) {
25
- methods = tag_name;
26
- tag_name = 'DIV';
27
- }
28
-
29
- /**
30
- * An Abstract Widget Unit
31
- *
32
- * Copyright (C) 2010 Nikolay Nemshilov
33
- */
34
- var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
35
- /**
36
- * The common constructor
37
- *
38
- * @param Object options
39
- * @param String optional tag name
40
- * @return void
41
- */
42
- initialize: function(key, options) {
43
- this.key = key;
44
- var args = [{'class': 'rui-' + key}];
45
-
46
- // those two have different constructors
47
- if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
48
- args.unshift(tag_name);
49
- }
50
- this.$super.apply(this, args);
51
-
52
- if (RightJS.isString(options)) {
53
- options = RightJS.$(options);
54
- }
55
-
56
- // if the options is another element then
57
- // try to dynamically rewrap it with our widget
58
- if (options instanceof RightJS.Element) {
59
- this._ = options._;
60
- if ('$listeners' in options) {
61
- options.$listeners = options.$listeners;
62
- }
63
- options = {};
64
- }
65
- this.setOptions(options, this);
66
-
67
- return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
68
- },
69
-
70
- // protected
71
-
72
- /**
73
- * Catches the options
74
- *
75
- * @param Object user-options
76
- * @param Element element with contextual options
77
- * @return void
78
- */
79
- setOptions: function(options, element) {
80
- if (element) {
81
- options = RightJS.Object.merge(options, new Function("return "+(
82
- element.get('data-'+ this.key) || '{}'
83
- ))());
84
- }
85
-
86
- if (options) {
87
- RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
88
- }
89
-
90
- return this;
91
- }
92
- });
93
-
94
- /**
95
- * Creating the actual widget class
96
- *
97
- */
98
- var Klass = new RightJS.Class(AbstractWidget, methods);
99
-
100
- // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
-
103
- return Klass;
104
- }
105
-
106
-
107
- /**
108
- * A shared module to create textual spinners
109
- *
110
- * Copyright (C) 2010-2011 Nikolay Nemshilov
111
- */
112
- var Spinner = new RightJS.Class(RightJS.Element, {
113
- /**
114
- * Constructor
115
- *
116
- * @param Number optional spinner size (4 by default)
117
- * @return void
118
- */
119
- initialize: function(size) {
120
- this.$super('div', {'class': 'rui-spinner'});
121
- this.dots = [];
122
-
123
- for (var i=0; i < (size || 4); i++) {
124
- this.dots.push(new RightJS.Element('div'));
125
- }
126
-
127
- this.dots[0].addClass('glowing');
128
- this.insert(this.dots);
129
- RightJS(this.shift).bind(this).periodical(300);
130
- },
131
-
132
- /**
133
- * Shifts the spinner elements
134
- *
135
- * @return void
136
- */
137
- shift: function() {
138
- if (this.visible()) {
139
- var dot = this.dots.pop();
140
- this.dots.unshift(dot);
141
- this.insert(dot, 'top');
142
- }
143
- }
144
- });
145
-
146
-
147
- /**
148
- * The filenames to include
149
- *
150
- * Copyright (C) 2010-2011 Nikolay Nemshilov
151
- */
152
- var R = RightJS,
153
- $ = RightJS.$,
154
- $$ = RightJS.$$,
155
- $w = RightJS.$w,
156
- $E = RightJS.$E,
157
- $ext = RightJS.$ext,
158
- Xhr = RightJS.Xhr,
159
- Class = RightJS.Class,
160
- Object = RightJS.Object,
161
- Element = RightJS.Element,
162
- Browser = RightJS.Browser;
163
-
164
- // IE6 doesn't support position:fixed so it needs a crunch
165
- Browser.IE6 = Browser.OLD && navigator.userAgent.indexOf("MSIE 6") > 0;
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
- /**
175
- * The lightbox widget
176
- *
177
- * Copyright (C) 2009-2011 Nikolay Nemshilov
178
- */
179
- var Lightbox = new Widget({
180
-
181
- extend: {
182
- version: '2.2.3',
183
-
184
- EVENTS: $w('show hide load'),
185
-
186
- Options: {
187
- fxName: 'fade',
188
- fxDuration: 300,
189
-
190
- group: null, // a group marker
191
-
192
- hideOnEsc: true,
193
- hideOnOutClick: true,
194
- showCloseButton: true,
195
-
196
- cssRule: "a[data-lightbox]", // all lightbox links css-rule
197
-
198
- // video links default size
199
- mediaWidth: 425,
200
- mediaHeight: 350
201
- },
202
-
203
- i18n: {
204
- Close: 'Close',
205
- Prev: 'Previous Image',
206
- Next: 'Next Image'
207
- },
208
-
209
- // the supported image-urls regexp
210
- Images: /\.(jpg|jpeg|gif|png|bmp)/i,
211
-
212
- // media content sources
213
- Medias: [
214
- [/(http:\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)/i, '$1/v/$2', 'swf'],
215
- [/(http:\/\/video.google.com)\/videoplay\?docid=([^&]+)/i, '$1/googleplayer.swf?docId=$2', 'swf'],
216
- [/(http:\/\/vimeo\.[a-z]+)\/([0-9]+).*?/i, '$1/moogaloop.swf?clip_id=$2', 'swf']
217
- ]
218
- },
219
-
220
- /**
221
- * basic constructor
222
- *
223
- * @param Object options override
224
- * @param Element optional options holder
225
- * @return void
226
- */
227
- initialize: function(options, context) {
228
- this
229
- .$super('lightbox', {})
230
- .setOptions(options, context)
231
- .insert([
232
- this.locker = new Locker(this.options),
233
- this.dialog = new Dialog(this.options)
234
- ])
235
- .on({
236
- close: this._close,
237
- next: this._next,
238
- prev: this._prev
239
- });
240
- },
241
-
242
- /**
243
- * Extracting the rel="lightbox[groupname]" attributes
244
- *
245
- * @param Object options
246
- * @param Element link with options
247
- * @return Dialog this
248
- */
249
- setOptions: function(options, context) {
250
- this.$super(options, context);
251
-
252
- if (context) {
253
- var rel = context.get('rel');
254
- if (rel && (rel = rel.match(/lightbox\[(.+?)\]/))) {
255
- this.options.group = rel[1];
256
- }
257
- }
258
-
259
- return this;
260
- },
261
-
262
- /**
263
- * Sets the popup's title
264
- *
265
- * @param mixed string or element or somethin'
266
- * @return Lighbox self
267
- */
268
- setTitle: function(text) {
269
- this.dialog.setTitle(text);
270
-
271
- return this;
272
- },
273
-
274
- /**
275
- * Shows the lightbox
276
- *
277
- * @param String/Array... content
278
- * @return Lightbox this
279
- */
280
- show: function(content) {
281
- return this._showAnd(function() {
282
- this.dialog.show(content, !content);
283
- });
284
- },
285
-
286
- /**
287
- * Hides the lightbox
288
- *
289
- * @return Lightbox this
290
- */
291
- hide: function() {
292
- Lightbox.current = null;
293
-
294
- return this.$super(this.options.fxName, {
295
- duration: this.options.fxDuration/3,
296
- onFinish: R(function() {
297
- this.fire('hide');
298
- this.remove();
299
- }).bind(this)
300
- });
301
- },
302
-
303
- /**
304
- * Loads up the data from url or a link
305
- *
306
- * @param String address or a link element
307
- * @param Object Xhr options
308
- * @return Lightbox this
309
- */
310
- load: function(link, options) {
311
- return this._showAnd(function() {
312
- this.dialog.load(link, options);
313
- });
314
- },
315
-
316
- /**
317
- * Resizes the content block to the given size
318
- *
319
- * @param Hash size
320
- * @return Lightbox this
321
- */
322
- resize: function(size) {
323
- this.dialog.resize(size);
324
- return this;
325
- },
326
-
327
- // protected
328
-
329
- // handles the 'close' event
330
- _close: function(event) {
331
- event.stop();
332
- this.hide();
333
- },
334
-
335
- // handles the 'prev' event
336
- _prev: function(event) {
337
- event.stop();
338
- Pager.prev();
339
- },
340
-
341
- // handles the 'next' event
342
- _next: function(event) {
343
- event.stop();
344
- Pager.next();
345
- },
346
-
347
- // shows the lightbox element and then calls back
348
- _showAnd: function(callback) {
349
- if (Lightbox.current !== this) {
350
- Lightbox.current = this;
351
-
352
- // hidding all the hanging around lightboxes
353
- $$('div.rui-lightbox').each('remove');
354
-
355
- this.insertTo(document.body);
356
- this.dialog.show('', true);
357
-
358
- if (Browser.OLD) { // IE's get screwed by the transparency tricks
359
- this.reposition();
360
- Element.prototype.show.call(this);
361
- callback.call(this);
362
- } else {
363
- this.setStyle('display:none');
364
- Element.prototype.show.call(this, this.options.fxName, {
365
- duration: this.options.fxDuration/2,
366
- onFinish: R(function() {
367
- callback.call(this);
368
- this.fire('show');
369
- }).bind(this)
370
- });
371
- }
372
- } else {
373
- callback.call(this);
374
- }
375
-
376
- return this;
377
- },
378
-
379
- // manually repositioning under IE6 browser
380
- reposition: function() {
381
- if (Browser.IE6) {
382
- var win = $(window);
383
-
384
- this.setStyle({
385
- top: win.scrolls().y + 'px',
386
- width: win.size().x + 'px',
387
- height: win.size().y + 'px',
388
- position: "absolute"
389
- });
390
- }
391
- }
392
- });
393
-
394
-
395
- /**
396
- * The class level interface
397
- *
398
- * @copyright (C) 2009 Nikolay Nemshilov
399
- */
400
- Lightbox.extend({
401
- hide: function() {
402
- if (Lightbox.current) {
403
- Lightbox.current.hide();
404
- }
405
- },
406
-
407
- show: function() {
408
- return this.inst('show', arguments);
409
- },
410
-
411
- load: function() {
412
- return this.inst('load', arguments);
413
- },
414
-
415
- // private
416
-
417
- inst: function(name, args) {
418
- var inst = new Lightbox();
419
- return inst[name].apply(inst, args);
420
- }
421
- });
422
-
423
-
424
- /**
425
- * Lightbox background locker element
426
- *
427
- * Copyright (C) 2010-2011 Nikolay Nemshilov
428
- */
429
- var Locker = new Class(Element, {
430
- initialize: function(options) {
431
- this.$super('div', {'class': 'rui-lightbox-locker'});
432
-
433
- if (options.hideOnOutClick) {
434
- this.onClick('fire', 'close');
435
- }
436
- }
437
- });
438
-
439
-
440
- /**
441
- * The dialog element wrapper
442
- *
443
- * Copyright (C) 2010-2011 Nikolay Nemshilov
444
- */
445
- var Dialog = new Class(Element, {
446
- /**
447
- * Constructor
448
- *
449
- * @param Object options
450
- * @return void
451
- */
452
- initialize: function(options) {
453
- var i18n = Lightbox.i18n;
454
-
455
- this.options = options;
456
- this.$super('div', {'class': 'rui-lightbox-dialog'});
457
-
458
- // building up the
459
- this.insert([
460
- this.title = $E('div', {'class': 'rui-lightbox-title'}),
461
-
462
- $E('div', {'class': 'rui-lightbox-body'}).insert(
463
- $E('div', {'class': 'rui-lightbox-body-inner'}).insert([
464
- this.locker = $E('div', {'class': 'rui-lightbox-body-locker'}).insert(new Spinner(4)),
465
- this.scroller = $E('div', {'class': 'rui-lightbox-scroller'}).insert(
466
- this.content = $E('div', {'class': 'rui-lightbox-content'})
467
- )
468
- ])
469
- ),
470
-
471
- $E('div', {'class': 'rui-lightbox-navigation'}).insert([
472
- this.closeButton = $E('div', {'class': 'close', html: '&times;', title: i18n.Close}).onClick('fire', 'close'),
473
- this.prevLink = $E('div', {'class': 'prev', html: '&larr;', title: i18n.Prev}).onClick('fire', 'prev'),
474
- this.nextLink = $E('div', {'class': 'next', html: '&rarr;', title: i18n.Next}).onClick('fire', 'next')
475
- ])
476
- ]);
477
-
478
- // presetting the navigation state
479
- this.prevLink.hide();
480
- this.nextLink.hide();
481
-
482
- if (!options.showCloseButton) {
483
- this.closeButton.hide();
484
- }
485
- },
486
-
487
- /**
488
- * Sets the dialogue caption
489
- *
490
- * @param String title
491
- * @return Dialog this
492
- */
493
- setTitle: function(title) {
494
- this.title.update(title||'');
495
- },
496
-
497
- /**
498
- * Nicely resize the dialog box
499
- *
500
- * @param Object the end size
501
- * @param Boolean use fx (false by default)
502
- * @return Dialog this
503
- */
504
- resize: function(end_size, with_fx) {
505
- var win_size = this.parent().size(),
506
- cur_size = this.scroller.size(),
507
- cur_top = (win_size.y - this.size().y)/2,
508
- dlg_diff = this.size().x - cur_size.x; // <- use for IE6 fixes
509
-
510
- if (end_size) {
511
- // getting the actual end-size
512
- end_size = this.scroller.setStyle(end_size).size();
513
-
514
- this.scroller.setStyle({
515
- width: cur_size.x + 'px',
516
- height: cur_size.y + 'px'
517
- });
518
- } else {
519
- // using the content block size
520
- end_size = this.content.size();
521
- }
522
-
523
- // checking the constraints
524
- var threshold = 100; // px
525
-
526
- if ((/^<img [^>]+>/img).test(this.content.html())) {
527
- // adjusting the sizes propoprtinally for images
528
- R([['x', 'y'], ['y', 'x']]).each(function(set) {
529
- var dim1 = set[0], dim2 = set[1], old_size = end_size[dim1];
530
-
531
- if ((end_size[dim1] + threshold) > win_size[dim1]) {
532
- end_size[dim1] = win_size[dim1] - threshold;
533
- end_size[dim2] = Math.floor(end_size[dim2] * end_size[dim1] / old_size);
534
- }
535
- });
536
-
537
- this.content.first('img').setStyle({
538
- width: end_size.x + 'px',
539
- height: end_size.y + 'px'
540
- });
541
- } else {
542
- // adjusting the sizes in case of any other content
543
- if ((end_size.x + threshold) > win_size.x) { end_size.x = win_size.x - threshold; }
544
- if ((end_size.y + threshold) > win_size.y) { end_size.y = win_size.y - threshold; }
545
- }
546
-
547
- // the actual resize and reposition
548
- var end_top = (cur_top * 2 + cur_size.y - end_size.y) / 2;
549
- var dialog = this._.style, content = this.scroller._.style;
550
-
551
- if (RightJS.Fx && with_fx && (end_size.x != cur_size.x || end_size.y != cur_size.y)) {
552
-
553
- $ext(new RightJS.Fx(this, {duration: this.options.fxDuration}), {
554
- render: function(delta) {
555
- content.width = (cur_size.x + (end_size.x - cur_size.x) * delta) + 'px';
556
- content.height = (cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
557
- dialog.top = (cur_top + (end_top - cur_top) * delta) + 'px';
558
-
559
- if (Browser.IE6) {
560
- dialog.width = (dlg_diff + cur_size.y + (end_size.y - cur_size.y) * delta) + 'px';
561
- }
562
- }
563
- }).onFinish(R(this.unlock).bind(this)).start();
564
-
565
- } else {
566
- // no-fx direct assignment
567
- content.width = end_size.x + 'px';
568
- content.height = end_size.y + 'px';
569
- dialog.top = end_top + 'px';
570
-
571
- if (Browser.IE6) {
572
- dialog.width = (dlg_diff + end_size.x) + 'px';
573
- }
574
-
575
- if (!this.request) { this.unlock(); }
576
- }
577
-
578
- return this;
579
- },
580
-
581
- /**
582
- * Shows the content
583
- *
584
- * @param mixed content String/Element/Array and so one
585
- * @return Dialog this
586
- */
587
- show: function(content, no_fx) {
588
- this.content.update(content || '');
589
- this.resize(null, !no_fx);
590
- },
591
-
592
- /**
593
- * Loads up the data from the link
594
- *
595
- * @param mixed String url address or a link element
596
- * @param Object xhr-options
597
- * @return void
598
- */
599
- load: function(url, options) {
600
- if (url instanceof Element) {
601
- this.setTitle(url.get('title'));
602
- url = url.get('href');
603
- }
604
-
605
- Pager.show(this, url);
606
- this.lock().cancel();
607
-
608
- // defined in the loader.js file
609
- this.request = new Loader(url, options, R(function(content, no_fx) {
610
- this.request = null;
611
- this.show(content, no_fx);
612
- }).bind(this));
613
-
614
- return this.resize(); // the look might be changed for a media-type
615
- },
616
-
617
- /**
618
- * Cancels a currently loading request
619
- *
620
- * @return Dialog this
621
- */
622
- cancel: function() {
623
- if (this.request) {
624
- this.request.cancel();
625
- }
626
-
627
- return this;
628
- },
629
-
630
- /**
631
- * Shows the loading lock
632
- *
633
- * @return Dialog this
634
- */
635
- lock: function() {
636
- this.locker.setStyle('opacity:1;display:block').insertTo(this.scroller, 'before');
637
- return this;
638
- },
639
-
640
- /**
641
- * Hides the loading lock
642
- *
643
- * @return Dialog this
644
- */
645
- unlock: function() {
646
- this.locker.remove(R(this.content.html()).blank() ? null : 'fade', {
647
- duration: this.options.fxDuration * 2/3
648
- });
649
-
650
- return this;
651
- }
652
- });
653
-
654
-
655
- /**
656
- * Xhr/images/medias loading module
657
- *
658
- * Copyright (C) 2009-2010 Nikolay Nemshilov
659
- */
660
- var Loader = new Class({
661
- /**
662
- * Constructor
663
- *
664
- * @param String url address
665
- * @param Object Xhr options
666
- * @param Function on-finish callback
667
- */
668
- initialize: function(url, options, on_finish) {
669
- // adjusting the dialog look for different media-types
670
- if (this.isImage(url, on_finish)) {
671
- Lightbox.current.addClass('rui-lightbox-image');
672
- } else if (this.isMedia(url, on_finish)) {
673
- Lightbox.current.addClass('rui-lightbox-media');
674
- } else {
675
- this.xhr = new Xhr(url,
676
- Object.merge({method: 'get'}, options)
677
- ).onComplete(function() {
678
- on_finish(this.text);
679
- }).send();
680
- }
681
- },
682
-
683
- /**
684
- * Cancels the request
685
- *
686
- * @return Loader this
687
- */
688
- cancel: function() {
689
- if (this.xhr) {
690
- this.xhr.cancel();
691
- } else if (this.img) {
692
- this.img.onload = function() {};
693
- }
694
- },
695
-
696
- // protected
697
-
698
- // tries to initialize it as an image loading
699
- isImage: function(url, on_finish) {
700
- if (url.match(Lightbox.Images)) {
701
- var img = this.img = $E('img')._;
702
- img.onload = function() {
703
- on_finish(img);
704
- };
705
- img.src = url;
706
- return true;
707
- }
708
- },
709
-
710
- // tries to initialize it as a flash-element
711
- isMedia: function(url, on_finish) {
712
- var media = R(Lightbox.Medias).map(function(desc) {
713
- return url.match(desc[0]) ? this.buildEmbed(
714
- url.replace(desc[0], desc[1]), desc[2]) : null;
715
- }, this).compact()[0];
716
-
717
- if (media) {
718
- on_finish(media, true);
719
- return true;
720
- }
721
- },
722
-
723
- // builds an embedded media block
724
- buildEmbed: function(url, type) {
725
- var media_types = {
726
- swf: [
727
- 'D27CDB6E-AE6D-11cf-96B8-444553540000',
728
- 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
729
- 'application/x-shockwave-flash'
730
- ]
731
- },
732
- options = Lightbox.current ? Lightbox.current.options : Lightbox.Options,
733
- sizes = ' width="'+ options.mediaWidth + '" height="'+ options.mediaHeight + '"';
734
-
735
- return '<object classid="clsid:' + media_types[type][0] +
736
- '" codebase="' + media_types[type][1] + '"'+ sizes + '>' +
737
- '<param name="src" value="'+ url +'" />'+
738
- '<embed src="'+ url +'" type="'+ media_types[type][2]+'"'+ sizes + ' />' +
739
- '</object>';
740
- }
741
-
742
- });
743
-
744
-
745
- /**
746
- * Processes the link-groups showing things in a single Lightbox
747
- *
748
- * Copyright (C) 2010 Nikolay Nemshilov
749
- */
750
- var Pager = {
751
- /**
752
- * Checks and shows the pager links on the dialog
753
- *
754
- * @param Dialog dialog
755
- * @param String url-address
756
- * @return void
757
- */
758
- show: function(dialog, url) {
759
- if (dialog.options.group) {
760
- this.dialog = dialog;
761
- this.links = this.find(dialog.options.group);
762
- this.link = this.links.first(function(link) {
763
- return link.get('href') === url;
764
- });
765
-
766
- var index = this.links.indexOf(this.link), size = this.links.length;
767
-
768
- dialog.prevLink[size && index > 0 ? 'show' : 'hide']();
769
- dialog.nextLink[size && index < size - 1 ? 'show' : 'hide']();
770
- } else {
771
- this.dialog = null;
772
- }
773
- },
774
-
775
- /**
776
- * Shows the prev link
777
- *
778
- * @return void
779
- */
780
- prev: function() {
781
- if (this.dialog && !this.timer) {
782
- var id = this.links.indexOf(this.link),
783
- link = this.links[id - 1];
784
-
785
- if (link) {
786
- this.dialog.load(link);
787
- this.timeout();
788
- }
789
- }
790
- },
791
-
792
- /**
793
- * Shows the next link
794
- *
795
- * @return void
796
- */
797
- next: function() {
798
- if (this.dialog && !this.timer) {
799
- var id = this.links.indexOf(this.link),
800
- link = this.links[id + 1];
801
-
802
- if (link) {
803
- this.dialog.load(link);
804
- this.timeout();
805
- }
806
- }
807
- },
808
-
809
- // private
810
-
811
- // finding the links list
812
- find: function(group) {
813
- return $$('a').filter(function(link) {
814
- var data = link.get('data-lightbox');
815
- var rel = link.get('rel');
816
-
817
- return (data && new Function("return "+ data)().group === group) ||
818
- (rel && rel.indexOf('lightbox['+ group + ']') > -1);
819
- });
820
- },
821
-
822
- // having a little nap to prevent ugly quick scrolling
823
- timeout: function() {
824
- this.timer = R(function() {
825
- Pager.timer = null;
826
- }).delay(300);
827
- }
828
- };
829
-
830
-
831
- /**
832
- * document level hooks
833
- *
834
- * Copyright (C) 2009-2010 Nikolay Nemshilov
835
- */
836
-
837
- $(document).on({
838
- /**
839
- * Catches clicks on the target links (respecting
840
- * native behavior when modifier keys are pressed,
841
- * e.g. opt+click must download clicked link)
842
- *
843
- * @param Event click
844
- * @return void
845
- */
846
- click: function(event) {
847
- var target = event.find(Lightbox.Options.cssRule) || event.find('a[rel^=lightbox]'),
848
- e = event._;
849
-
850
- if (target && !(e.shiftKey || e.altKey || e.ctrlKey || e.metaKey)) {
851
- event.stop();
852
- new Lightbox({}, target).load(target);
853
- }
854
- },
855
-
856
- /**
857
- * Catches the mousewheel event and tries to scroll
858
- * the list of objects on the lightbox
859
- *
860
- * @param Event mousewheel
861
- * @return void
862
- */
863
- mousewheel: function(event) {
864
- if (Lightbox.current) {
865
- var target = event.target, box = target.parent('div.rui-lightbox-content');
866
-
867
- if (!box || target.getStyle('overflow') === 'visible') {
868
- event.stop();
869
- }
870
-
871
- Lightbox.current.fire((event._.detail || -event._.wheelDelta) < 0 ? 'prev' : 'next');
872
- }
873
- },
874
-
875
- /**
876
- * Handles the navigation form a keyboard
877
- *
878
- * @param Event keydown
879
- * @return void
880
- */
881
- keydown: function(event) {
882
- var lightbox = Lightbox.current, name = ({
883
- 27: 'close', // Esc
884
- 33: 'prev', // PageUp
885
- 37: 'prev', // Left
886
- 38: 'prev', // Up
887
- 39: 'next', // Right
888
- 40: 'next', // Down
889
- 34: 'next' // PageDown
890
- })[event.keyCode];
891
-
892
- if (lightbox && name) {
893
- if (name !== 'close' || lightbox.options.hideOnEsc) {
894
- event.stop();
895
- lightbox.fire(name);
896
- }
897
- }
898
- }
899
- });
900
-
901
- $(window).on({
902
- resize: function() {
903
- if (Lightbox.current) {
904
- Lightbox.current.reposition();
905
- Lightbox.current.dialog.resize();
906
- }
907
- },
908
-
909
- scroll: function(event) {
910
- if (Lightbox.current && Browser.IE6) {
911
- Lightbox.current.reposition();
912
- }
913
- }
914
- });
915
-
916
-
917
- var embed_style = document.createElement('style'),
918
- embed_rules = document.createTextNode("div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-lightbox{position:fixed;top:0;left:0;float:none;width:100%;height:100%;margin:0;padding:0;background:none;border:none;text-align:center;z-index:9999;z-index/*\\**/:auto\\9}div.rui-lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);cursor:default;z-index/*\\**/:9990\\9}div.rui-lightbox-dialog{display:inline-block; *display:inline; *zoom:1;position:relative;text-align:left;z-index/*\\**/:9999\\9}div.rui-lightbox-title{height:1.2em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica}div.rui-lightbox-body{background-color:#FFF;padding:1em;border-radius:.5em;-moz-border-radius:.5em;-webkit-border-radius:.5em}div.rui-lightbox-body-inner{position:relative}div.rui-lightbox-scroller{overflow:hidden}div.rui-lightbox-content{display:inline-block; *display:inline; *zoom:1;min-height:10em;min-width:10em;_height:10em;_width:10em}div.rui-lightbox-body-locker{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;opacity:0;filter:alpha(opacity=0)}div.rui-lightbox-body-locker div.rui-spinner{position:absolute;right:0;bottom:0;border:none;background:none;font-size:150%}div.rui-lightbox-navigation{color:#888;font-size:160%;font-family:Arial;height:1em;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-lightbox-navigation div{cursor:pointer;position:absolute}div.rui-lightbox-navigation div:hover{color:white}div.rui-lightbox-navigation div.next{left:2em}div.rui-lightbox-navigation div.close{right:0}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.rui-lightbox-image div.rui-lightbox-content,div.rui-lightbox-media div.rui-lightbox-content{min-height:12em;min-width:12em;_height:12em;_width:12em}div.rui-lightbox-image div.rui-lightbox-content img{vertical-align:middle}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-image div.rui-lightbox-body-locker,div.rui-lightbox-media div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body-locker{background-color:#D8D8D8}div.rui-lightbox-image div.rui-lightbox-body-locker div.rui-spinner,div.rui-lightbox-media div.rui-lightbox-body-locker div.rui-spinner{bottom:.5em;right:.5em}");
919
-
920
- embed_style.type = 'text/css';
921
- document.getElementsByTagName('head')[0].appendChild(embed_style);
922
-
923
- if(embed_style.styleSheet) {
924
- embed_style.styleSheet.cssText = embed_rules.nodeValue;
925
- } else {
926
- embed_style.appendChild(embed_rules);
927
- }
928
-
929
-
930
- return Lightbox;
931
- })(document, RightJS);