right-rails 1.0.10 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/README.rdoc +4 -4
  2. data/Rakefile +4 -4
  3. data/lib/right_rails.rb +1 -1
  4. data/public/javascripts/right/autocompleter-src.js +115 -106
  5. data/public/javascripts/right/autocompleter.js +3 -14
  6. data/public/javascripts/right/billboard-src.js +58 -38
  7. data/public/javascripts/right/billboard.js +3 -13
  8. data/public/javascripts/right/calendar-src.js +136 -133
  9. data/public/javascripts/right/calendar.js +4 -33
  10. data/public/javascripts/right/colorpicker-src.js +128 -125
  11. data/public/javascripts/right/colorpicker.js +4 -23
  12. data/public/javascripts/right/dialog-src.js +67 -37
  13. data/public/javascripts/right/dialog.js +3 -17
  14. data/public/javascripts/right/dnd-src.js +44 -43
  15. data/public/javascripts/right/dnd.js +3 -16
  16. data/public/javascripts/right/effects-src.js +125 -98
  17. data/public/javascripts/right/effects.js +3 -13
  18. data/public/javascripts/right/in-edit-src.js +54 -38
  19. data/public/javascripts/right/in-edit.js +4 -10
  20. data/public/javascripts/right/jquerysh-src.js +344 -20
  21. data/public/javascripts/right/jquerysh.js +3 -3
  22. data/public/javascripts/right/json-src.js +22 -35
  23. data/public/javascripts/right/json.js +4 -7
  24. data/public/javascripts/right/keys-src.js +87 -0
  25. data/public/javascripts/right/keys.js +7 -0
  26. data/public/javascripts/right/lightbox-src.js +76 -58
  27. data/public/javascripts/right/lightbox.js +3 -20
  28. data/public/javascripts/right/rails-src.js +108 -107
  29. data/public/javascripts/right/rails.js +4 -11
  30. data/public/javascripts/right/rater-src.js +47 -31
  31. data/public/javascripts/right/rater.js +3 -9
  32. data/public/javascripts/right/resizable-src.js +60 -33
  33. data/public/javascripts/right/resizable.js +3 -11
  34. data/public/javascripts/right/selectable-src.js +87 -51
  35. data/public/javascripts/right/selectable.js +3 -18
  36. data/public/javascripts/right/sizzle-src.js +15 -10
  37. data/public/javascripts/right/sizzle.js +4 -27
  38. data/public/javascripts/right/slider-src.js +49 -33
  39. data/public/javascripts/right/slider.js +3 -10
  40. data/public/javascripts/right/sortable-src.js +46 -32
  41. data/public/javascripts/right/sortable.js +4 -13
  42. data/public/javascripts/right/table-src.js +19 -10
  43. data/public/javascripts/right/table.js +4 -6
  44. data/public/javascripts/right/tabs-src.js +69 -47
  45. data/public/javascripts/right/tabs.js +4 -26
  46. data/public/javascripts/right/tooltips-src.js +78 -56
  47. data/public/javascripts/right/tooltips.js +4 -9
  48. data/public/javascripts/right/uploader-src.js +50 -34
  49. data/public/javascripts/right/uploader.js +3 -9
  50. data/public/javascripts/right-olds-src.js +528 -355
  51. data/public/javascripts/right-olds.js +4 -13
  52. data/public/javascripts/right-safe-src.js +4 -99
  53. data/public/javascripts/right-safe.js +3 -4
  54. data/public/javascripts/right-src.js +1618 -1245
  55. data/public/javascripts/right.js +4 -91
  56. metadata +8 -6
@@ -1,20 +1,14 @@
1
1
  /**
2
- * The Ruby On Rails plugin for RightJS
3
- * http://github.com/MadRabbit/right-rails
2
+ * RubyOnRails Support Module v2.2.1
3
+ * http://rightjs.org/plugins/rails
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
7
  (function(window, document, RightJS) {
8
- /**
9
- * Underscored aliases for Ruby On Rails
10
- *
11
- * Copyright (C) 2009-2010 Nikolay Nemshilov
12
- */
13
-
14
8
  /**
15
9
  * The Rails plugin initialization script
16
10
  *
17
- * Copyright (C) 2010 Nikolay Nemshilov
11
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
18
12
  */
19
13
 
20
14
  var R = RightJS,
@@ -24,8 +18,18 @@ var R = RightJS,
24
18
  Xhr = RightJS.Xhr,
25
19
  Object = RightJS.Object;
26
20
 
21
+ RightJS.Rails = {
22
+ version: '2.2.1'
23
+ };
24
+
27
25
 
28
26
 
27
+ /**
28
+ * Underscored aliases for Ruby On Rails
29
+ *
30
+ * Copyright (C) 2009-2010 Nikolay Nemshilov
31
+ */
32
+
29
33
  // the language and window level aliases
30
34
  R([
31
35
  RightJS.String.prototype,
@@ -96,79 +100,76 @@ RightJS.$alias(RightJS.Array.prototype, {
96
100
  /**
97
101
  * Rails 3 UJS support module
98
102
  *
99
- * Copyright (C) 2010 Nikolay Nemshilov
103
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
100
104
  */
101
- (function() {
102
- // tries to cancel the event via confirmation
103
- var user_cancels = function(event, element) {
104
- var message = element.get('data-confirm');
105
- if (message && !confirm(message)) {
106
- event.stop();
107
- return true;
108
- }
109
- };
110
-
111
- // adds XHR events to the element
112
- var add_xhr_events = function(element, options) {
113
- return Object.merge({
114
- onCreate: function() { element.fire('ajax:loading', this); },
115
- onComplete: function() { element.fire('ajax:complete', this); },
116
- onSuccess: function() { element.fire('ajax:success', this); },
117
- onFailure: function() { element.fire('ajax:failure', this); }
118
- }, options);
119
- };
120
-
121
- // processes link clicks
122
- var try_link_submit = function(event) {
123
- var link = event.target,
124
- method = link.get('data-method'),
125
- remote = link.get('data-remote'),
126
- url = link.get('href');
127
-
128
- if (user_cancels(event, link)) { return; }
129
- if (method || remote) { event.stop(); }
130
-
131
- if (remote) {
132
- Xhr.load(url, add_xhr_events(link, {
133
- method: method || 'get',
134
- spinner: link.get('data-spinner')
135
- }));
136
-
137
- } else if (method) {
138
- var param = $$('meta[name=csrf-param]')[0],
139
- token = $$('meta[name=csrf-token]')[0],
140
- form = $E('form', {action: url, method: 'post'});
141
-
142
- if (param && token) {
143
- form.insert('<input type="hidden" name="'+param.get('content')+'" value="'+token.get('content')+'" />');
144
- }
145
-
146
- form.insert('<input type="hidden" name="_method" value="'+method+'"/>')
147
- .insertTo(document.body).submit();
105
+ // tries to cancel the event via confirmation
106
+ var user_cancels = function(event, element) {
107
+ var message = element.get('data-confirm');
108
+ if (message && !confirm(message)) {
109
+ event.stop();
110
+ return true;
111
+ }
112
+ };
113
+
114
+ // adds XHR events to the element
115
+ var add_xhr_events = function(element, options) {
116
+ return Object.merge({
117
+ onCreate: function() { element.fire('ajax:loading', {xhr: this}); },
118
+ onComplete: function() { element.fire('ajax:complete', {xhr: this}); },
119
+ onSuccess: function() { element.fire('ajax:success', {xhr: this}); },
120
+ onFailure: function() { element.fire('ajax:failure', {xhr: this}); }
121
+ }, options);
122
+ };
123
+
124
+ // processes link clicks
125
+ var try_link_submit = function(event) {
126
+ var link = event.target,
127
+ method = link.get('data-method'),
128
+ remote = link.get('data-remote'),
129
+ url = link.get('href');
130
+
131
+ if (user_cancels(event, link)) { return; }
132
+ if (method || remote) { event.stop(); }
133
+
134
+ if (remote) {
135
+ Xhr.load(url, add_xhr_events(link, {
136
+ method: method || 'get',
137
+ spinner: link.get('data-spinner')
138
+ }));
139
+
140
+ } else if (method) {
141
+ var param = $$('meta[name=csrf-param]')[0],
142
+ token = $$('meta[name=csrf-token]')[0],
143
+ form = $E('form', {action: url, method: 'post'});
144
+
145
+ if (param && token) {
146
+ form.insert('<input type="hidden" name="'+param.get('content')+'" value="'+token.get('content')+'" />');
148
147
  }
149
- };
150
-
151
- // global events listeners
152
- $(document).on({
153
- click: function(event) {
154
- var tag = event.target._.tagName;
155
- if (tag === 'A' || tag === 'BUTTON') {
156
- try_link_submit(event);
157
- }
158
- },
159
-
160
- submit: function(event) {
161
- var form = event.target;
162
- if (form.has('data-remote') && !user_cancels(event, form)) {
163
- event.stop();
164
- form.send(add_xhr_events(form, {
165
- spinner: form.get('data-spinner') || form.first('.spinner')
166
- }));
167
- }
148
+
149
+ form.insert('<input type="hidden" name="_method" value="'+method+'"/>')
150
+ .insertTo(document.body).submit();
151
+ }
152
+ };
153
+
154
+ // global events listeners
155
+ $(document).on({
156
+ click: function(event) {
157
+ var tag = event.target._.tagName;
158
+ if (tag === 'A' || tag === 'BUTTON') {
159
+ try_link_submit(event);
168
160
  }
169
- });
170
- })();
161
+ },
171
162
 
163
+ submit: function(event) {
164
+ var form = event.target;
165
+ if (form.has('data-remote') && !user_cancels(event, form)) {
166
+ event.stop();
167
+ form.send(add_xhr_events(form, {
168
+ spinner: form.get('data-spinner') || form.first('.spinner')
169
+ }));
170
+ }
171
+ }
172
+ });
172
173
 
173
174
  /**
174
175
  * RR is the common ajax operations wrapper for ruby on rails
@@ -184,24 +185,24 @@ var RR = {
184
185
  */
185
186
  Options: {
186
187
  format: 'js', // the working format for remote requests over the application
187
-
188
+
188
189
  flashId: 'flashes', // the flashes element id
189
190
  flashHideFx: 'slide', // use null if you don't want any fx in here
190
191
  flashHideDelay: 3200, // use -1 to disable the flash element hidding
191
-
192
+
192
193
  highlightUpdates: true,
193
-
194
+
194
195
  removeFx: 'fade', // blocks removing fx
195
196
  insertFx: 'fade', // blocks insertion fx
196
-
197
+
197
198
  insertPosition: 'bottom', // default insert position
198
-
199
+
199
200
  linkToAjaxEdit: '.ajax_edit',
200
201
  linkToAjaxDelete: '.ajax_delete',
201
-
202
+
202
203
  rescanWithScopes: true // if it should rescan only updated elements
203
204
  },
204
-
205
+
205
206
  /**
206
207
  * Updates the flashes block with the source
207
208
  *
@@ -215,7 +216,7 @@ var RR = {
215
216
  }
216
217
  return this;
217
218
  },
218
-
219
+
219
220
  /**
220
221
  * Initializes the delayed flashes hide call
221
222
  *
@@ -230,10 +231,10 @@ var RR = {
230
231
  }
231
232
  return this;
232
233
  },
233
-
234
+
234
235
  /**
235
236
  * Highlights the element according to the options
236
- *
237
+ *
237
238
  * @param String element id
238
239
  * @return RR this
239
240
  */
@@ -243,7 +244,7 @@ var RR = {
243
244
  }
244
245
  return this;
245
246
  },
246
-
247
+
247
248
  /**
248
249
  * Inserts the content into the given element
249
250
  *
@@ -255,7 +256,7 @@ var RR = {
255
256
  insert: function(where, what, in_position) {
256
257
  var position = in_position || this.Options.insertPosition, new_element,
257
258
  container = $(where).insert(what, position);
258
-
259
+
259
260
  // trying to find the new block
260
261
  switch (position) {
261
262
  case 'bottom': new_element = container.children().last(); break;
@@ -263,7 +264,7 @@ var RR = {
263
264
  case 'before': new_element = container.prev(); break;
264
265
  case 'after': new_element = container.next(); break;
265
266
  }
266
-
267
+
267
268
  // necely displaying the new block
268
269
  if (new_element && this.Options.insertFx) {
269
270
  new_element.hide().show(this.Options.insertFx, {
@@ -272,10 +273,10 @@ var RR = {
272
273
  } else {
273
274
  this.highlight(new_element);
274
275
  }
275
-
276
+
276
277
  return this.rescan(where);
277
278
  },
278
-
279
+
279
280
  /**
280
281
  * Replaces the given element with a new content
281
282
  *
@@ -287,7 +288,7 @@ var RR = {
287
288
  $(id).replace(source);
288
289
  return this.highlight(id).rescan(id);
289
290
  },
290
-
291
+
291
292
  /**
292
293
  * removes the element by id
293
294
  *
@@ -299,7 +300,7 @@ var RR = {
299
300
  $(id).remove(this.Options.removeFx);
300
301
  }
301
302
  },
302
-
303
+
303
304
  /**
304
305
  * Makes a remote form out of the form
305
306
  *
@@ -313,7 +314,7 @@ var RR = {
313
314
  }
314
315
  return this;
315
316
  },
316
-
317
+
317
318
  /**
318
319
  * Replaces the form with new content and makes it remote
319
320
  *
@@ -327,10 +328,10 @@ var RR = {
327
328
  form.replace(source);
328
329
  this.remotize_form(id);
329
330
  }
330
-
331
+
331
332
  return this.rescan(id);
332
333
  },
333
-
334
+
334
335
  /**
335
336
  * Inserts the form source into the given element
336
337
  *
@@ -339,12 +340,12 @@ var RR = {
339
340
  * @return RR this
340
341
  */
341
342
  show_form_for: function(id, source) {
342
- $(id).select('form').each('remove'); // removing old forms
343
+ $(id).find('form').each('remove'); // removing old forms
343
344
  $(id).insert(source);
344
-
345
+
345
346
  return this.remotize_form($(id).first('form')).rescan(id);
346
347
  },
347
-
348
+
348
349
  /**
349
350
  * watches link clicks and processes the ajax edit/delete operations
350
351
  *
@@ -352,16 +353,16 @@ var RR = {
352
353
  */
353
354
  process_click: function(event) {
354
355
  var link;
355
-
356
+
356
357
  if ((link = event.find('a'+ this.Options.linkToAjaxEdit))) {
357
358
  event.stop();
358
359
  Xhr.load(link.get('href') + '.' + this.Options.format);
359
360
  } else if ((link = event.find('a'+ this.Options.linkToAjaxDelete)) && link.has('onclick')) {
360
361
  event.stop();
361
- eval('({f:'+ link.onclick.toString().replace('.submit', '.send')+'})').f.call(link);
362
+ new Function('return '+ link.onclick.toString().replace('.submit', '.send'))().call(link);
362
363
  }
363
364
  },
364
-
365
+
365
366
  /**
366
367
  * Scans for updated elements
367
368
  *
@@ -373,8 +374,8 @@ var RR = {
373
374
  window[name].rescan(this.Options.rescanWithScopes ? scope : null);
374
375
  }
375
376
  }, this);
376
-
377
-
377
+
378
+
378
379
  return this;
379
380
  }
380
381
  };
@@ -1,14 +1,7 @@
1
1
  /**
2
- * The Ruby On Rails plugin for RightJS
3
- * http://github.com/MadRabbit/right-rails
2
+ * RubyOnRails Support Module v2.2.1
3
+ * http://rightjs.org/plugins/rails
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- (function(i,j,e){var f=e.$,l=e.$$,o=e.$E,m=e.Xhr,p=e.Object;e([e.String.prototype,e.Array.prototype,e.Function.prototype,e.Object,e.Options,e.Observer,e.Observer.prototype,i,j]).each(function(a){for(var b in a)try{if(/[A-Z]/.test(b)&&typeof a[b]==="function"){var c=e(b).underscored();if(a[c]===null||a[c]===undefined)a[c]=a[b]}}catch(d){}});e([e.Element,e.Event,e.Form,e.Input]).each(function(a){if(a){var b=a.prototype;for(var c in b)if(/[A-Z]/.test(c)&&typeof b[c]==="function")a.prototype[e(c).underscored()]=
8
- b[c]}});e.$alias(e.String.prototype,{index_of:"indexOf",last_index_of:"lastIndexOf",to_f:"toFloat",to_i:"toInt",gsub:"replace",downcase:"toLowerCase",upcase:"toUpperCase",index:"indexOf",rindex:"lastIndexOf",strip:"trim"});e.$alias(e.Array.prototype,{collect:"map",detect:"filter",index_of:"indexOf",last_index_of:"lastIndexOf",index:"indexOf",rindex:"lastIndexOf"});(function(){var a=function(c,d){var g=d.get("data-confirm");if(g&&!confirm(g)){c.stop();return true}},b=function(c,d){return p.merge({onCreate:function(){c.fire("ajax:loading",
9
- this)},onComplete:function(){c.fire("ajax:complete",this)},onSuccess:function(){c.fire("ajax:success",this)},onFailure:function(){c.fire("ajax:failure",this)}},d)};f(j).on({click:function(c){var d=c.target._.tagName;if(d==="A"||d==="BUTTON"){var g=c.target;d=g.get("data-method");var n=g.get("data-remote"),h=g.get("href");if(!a(c,g)){if(d||n)c.stop();if(n)m.load(h,b(g,{method:d||"get",spinner:g.get("data-spinner")}));else if(d){c=l("meta[name=csrf-param]")[0];g=l("meta[name=csrf-token]")[0];h=o("form",
10
- {action:h,method:"post"});c&&g&&h.insert('<input type="hidden" name="'+c.get("content")+'" value="'+g.get("content")+'" />');h.insert('<input type="hidden" name="_method" value="'+d+'"/>').insertTo(j.body).submit()}}}},submit:function(c){var d=c.target;if(d.has("data-remote")&&!a(c,d)){c.stop();d.send(b(d,{spinner:d.get("data-spinner")||d.first(".spinner")}))}}})})();var k={Options:{format:"js",flashId:"flashes",flashHideFx:"slide",flashHideDelay:3200,highlightUpdates:true,removeFx:"fade",insertFx:"fade",
11
- insertPosition:"bottom",linkToAjaxEdit:".ajax_edit",linkToAjaxDelete:".ajax_delete",rescanWithScopes:true},update_flash:function(a){var b=f(this.Options.flashId);b&&this.replace(b,a).hide_flash();return this},hide_flash:function(){if(this.Options.flashHideDelay>-1){var a=f(this.Options.flashId);a&&a.visible()&&a.hide.bind(a,this.Options.flashHideFx).delay(this.Options.flashHideDelay)}return this},highlight:function(a){f(a)&&this.Options.highlightUpdates&&f(a).highlight();return this},insert:function(a,
12
- b,c){c=c||this.Options.insertPosition;var d;b=f(a).insert(b,c);switch(c){case "bottom":d=b.children().last();break;case "top":d=b.first();break;case "before":d=b.prev();break;case "after":d=b.next();break}d&&this.Options.insertFx?d.hide().show(this.Options.insertFx,{onFinish:this.highlight.bind(this,d)}):this.highlight(d);return this.rescan(a)},replace:function(a,b){f(a).replace(b);return this.highlight(a).rescan(a)},remove:function(a){f(a)&&f(a).remove(this.Options.removeFx)},remotize_form:function(a){if(a=
13
- f(a))a.remotize().enable()._.action+="."+this.Options.format;return this},replace_form:function(a,b){var c=f(a);if(c){c.replace(b);this.remotize_form(a)}return this.rescan(a)},show_form_for:function(a,b){f(a).select("form").each("remove");f(a).insert(b);return this.remotize_form(f(a).first("form")).rescan(a)},process_click:function(a){var b;if(b=a.find("a"+this.Options.linkToAjaxEdit)){a.stop();m.load(b.get("href")+"."+this.Options.format)}else if((b=a.find("a"+this.Options.linkToAjaxDelete))&&b.has("onclick")){a.stop();
14
- eval("({f:"+b.onclick.toString().replace(".submit",".send")+"})").f.call(b)}},rescan:function(a){$w("Draggable Droppable Tabs Slider Selectable").each(function(b){if(b in i)i[b].rescan(this.Options.rescanWithScopes?a:null)},this);return this}};f(j).on({ready:function(){k.hide_flash()},click:function(a){k.process_click(a)}});i.RR=k})(window,document,RightJS);
7
+ (function(a,b,c){var d=c,e=c.$,f=c.$$,g=c.$E,h=c.Xhr,i=c.Object;c.Rails={version:"2.2.1"},d([c.String.prototype,c.Array.prototype,c.Function.prototype,c.Object,c.Options,c.Observer,c.Observer.prototype,a,b]).each(function(a){for(var b in a)try{if(/[A-Z]/.test(b)&&typeof a[b]==="function"){var c=d(b).underscored();if(a[c]===null||a[c]===undefined)a[c]=a[b]}}catch(e){}}),d([c.Element,c.Event,c.Form,c.Input]).each(function(a){if(a){var b={},c=a.prototype;for(var e in c)/[A-Z]/.test(e)&&typeof c[e]==="function"&&(a.prototype[d(e).underscored()]=c[e])}}),c.$alias(c.String.prototype,{index_of:"indexOf",last_index_of:"lastIndexOf",to_f:"toFloat",to_i:"toInt",gsub:"replace",downcase:"toLowerCase",upcase:"toUpperCase",index:"indexOf",rindex:"lastIndexOf",strip:"trim"}),c.$alias(c.Array.prototype,{collect:"map",detect:"filter",index_of:"indexOf",last_index_of:"lastIndexOf",index:"indexOf",rindex:"lastIndexOf"});var j=function(a,b){var c=b.get("data-confirm");if(c&&!confirm(c)){a.stop();return!0}},k=function(a,b){return i.merge({onCreate:function(){a.fire("ajax:loading",{xhr:this})},onComplete:function(){a.fire("ajax:complete",{xhr:this})},onSuccess:function(){a.fire("ajax:success",{xhr:this})},onFailure:function(){a.fire("ajax:failure",{xhr:this})}},b)},l=function(a){var c=a.target,d=c.get("data-method"),e=c.get("data-remote"),i=c.get("href");if(!j(a,c)){(d||e)&&a.stop();if(e)h.load(i,k(c,{method:d||"get",spinner:c.get("data-spinner")}));else if(d){var l=f("meta[name=csrf-param]")[0],m=f("meta[name=csrf-token]")[0],n=g("form",{action:i,method:"post"});l&&m&&n.insert('<input type="hidden" name="'+l.get("content")+'" value="'+m.get("content")+'" />'),n.insert('<input type="hidden" name="_method" value="'+d+'"/>').insertTo(b.body).submit()}}};e(b).on({click:function(a){var b=a.target._.tagName;(b==="A"||b==="BUTTON")&&l(a)},submit:function(a){var b=a.target;b.has("data-remote")&&!j(a,b)&&(a.stop(),b.send(k(b,{spinner:b.get("data-spinner")||b.first(".spinner")})))}});var m={Options:{format:"js",flashId:"flashes",flashHideFx:"slide",flashHideDelay:3200,highlightUpdates:!0,removeFx:"fade",insertFx:"fade",insertPosition:"bottom",linkToAjaxEdit:".ajax_edit",linkToAjaxDelete:".ajax_delete",rescanWithScopes:!0},update_flash:function(a){var b=e(this.Options.flashId);b&&this.replace(b,a).hide_flash();return this},hide_flash:function(){if(this.Options.flashHideDelay>-1){var a=e(this.Options.flashId);a&&a.visible()&&a.hide.bind(a,this.Options.flashHideFx).delay(this.Options.flashHideDelay)}return this},highlight:function(a){e(a)&&this.Options.highlightUpdates&&e(a).highlight();return this},insert:function(a,b,c){var d=c||this.Options.insertPosition,f,g=e(a).insert(b,d);switch(d){case"bottom":f=g.children().last();break;case"top":f=g.first();break;case"before":f=g.prev();break;case"after":f=g.next()}f&&this.Options.insertFx?f.hide().show(this.Options.insertFx,{onFinish:this.highlight.bind(this,f)}):this.highlight(f);return this.rescan(a)},replace:function(a,b){e(a).replace(b);return this.highlight(a).rescan(a)},remove:function(a){e(a)&&e(a).remove(this.Options.removeFx)},remotize_form:function(a){var b=e(a);b&&(b.remotize().enable()._.action+="."+this.Options.format);return this},replace_form:function(a,b){var c=e(a);c&&(c.replace(b),this.remotize_form(a));return this.rescan(a)},show_form_for:function(a,b){e(a).find("form").each("remove"),e(a).insert(b);return this.remotize_form(e(a).first("form")).rescan(a)},process_click:function(a){var b;(b=a.find("a"+this.Options.linkToAjaxEdit))?(a.stop(),h.load(b.get("href")+"."+this.Options.format)):(b=a.find("a"+this.Options.linkToAjaxDelete))&&b.has("onclick")&&(a.stop(),(new Function("return "+b.onclick.toString().replace(".submit",".send")))().call(b))},rescan:function(b){$w("Draggable Droppable Tabs Slider Selectable").each(function(c){c in a&&a[c].rescan(this.Options.rescanWithScopes?b:null)},this);return this}};e(b).on({ready:function(){m.hide_flash()},click:function(a){m.process_click(a)}}),a.RR=m})(window,document,RightJS)
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Rating widget for RightJS
2
+ * RightJS-UI Rater v2.2.0
3
3
  * http://rightjs.org/ui/rater
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
7
  var Rater = RightJS.Rater = (function(document, RightJS) {
8
8
  /**
@@ -10,26 +10,9 @@ var Rater = RightJS.Rater = (function(document, RightJS) {
10
10
  * it creates an abstract proxy with the common functionality
11
11
  * which then we reuse and override in the actual widgets
12
12
  *
13
- * Copyright (C) 2010 Nikolay Nemshilov
13
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
14
14
  */
15
15
 
16
- /**
17
- * The init script for Rater
18
- *
19
- * Copyright (C) 2010 Nikolay Nemshilov
20
- */
21
- var R = RightJS,
22
- $ = RightJS.$,
23
- $w = RightJS.$w,
24
- Xhr = RightJS.Xhr,
25
- isString = RightJS.isString,
26
- isNumber = RightJS.isNumber;
27
-
28
-
29
-
30
-
31
-
32
-
33
16
  /**
34
17
  * The widget units constructor
35
18
  *
@@ -48,7 +31,7 @@ function Widget(tag_name, methods) {
48
31
  *
49
32
  * Copyright (C) 2010 Nikolay Nemshilov
50
33
  */
51
- var AbstractWidget = new RightJS.Wrapper(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
34
+ var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
52
35
  /**
53
36
  * The common constructor
54
37
  *
@@ -80,7 +63,8 @@ function Widget(tag_name, methods) {
80
63
  options = {};
81
64
  }
82
65
  this.setOptions(options, this);
83
- return this;
66
+
67
+ return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
84
68
  },
85
69
 
86
70
  // protected
@@ -93,12 +77,16 @@ function Widget(tag_name, methods) {
93
77
  * @return void
94
78
  */
95
79
  setOptions: function(options, element) {
96
- element = element || this;
97
- RightJS.Options.setOptions.call(this,
98
- RightJS.Object.merge(options, eval("("+(
80
+ if (element) {
81
+ options = RightJS.Object.merge(options, new Function("return "+(
99
82
  element.get('data-'+ this.key) || '{}'
100
- )+")"))
101
- );
83
+ ))());
84
+ }
85
+
86
+ if (options) {
87
+ RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
88
+ }
89
+
102
90
  return this;
103
91
  }
104
92
  });
@@ -107,7 +95,7 @@ function Widget(tag_name, methods) {
107
95
  * Creating the actual widget class
108
96
  *
109
97
  */
110
- var Klass = new RightJS.Wrapper(AbstractWidget, methods);
98
+ var Klass = new RightJS.Class(AbstractWidget, methods);
111
99
 
112
100
  // creating the widget related shortcuts
113
101
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
@@ -161,16 +149,33 @@ var Updater = {
161
149
  };
162
150
 
163
151
 
152
+ /**
153
+ * The init script for Rater
154
+ *
155
+ * Copyright (C) 2010 Nikolay Nemshilov
156
+ */
157
+ var R = RightJS,
158
+ $ = RightJS.$,
159
+ $w = RightJS.$w,
160
+ Xhr = RightJS.Xhr,
161
+ isString = RightJS.isString,
162
+ isNumber = RightJS.isNumber;
163
+
164
+
165
+
166
+
167
+
168
+
164
169
  /**
165
170
  * The Rating widget
166
171
  *
167
- * Copyright (C) 2009-2010 Nikolay Nemshilov
172
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
168
173
  */
169
174
  var Rater = new Widget({
170
175
  include: Updater,
171
176
 
172
177
  extend: {
173
- version: '2.0.0',
178
+ version: '2.2.0',
174
179
 
175
180
  EVENTS: $w('change hover send'),
176
181
 
@@ -362,7 +367,18 @@ $(document).onMouseover(function(event) {
362
367
  });
363
368
 
364
369
 
365
- document.write("<style type=\"text/css\">div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}</style>");
370
+ var embed_style = document.createElement('style'),
371
+ embed_rules = document.createTextNode("div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}");
372
+
373
+ embed_style.type = 'text/css';
374
+ document.getElementsByTagName('head')[0].appendChild(embed_style);
375
+
376
+ if(embed_style.styleSheet) {
377
+ embed_style.styleSheet.cssText = embed_rules.nodeValue;
378
+ } else {
379
+ embed_style.appendChild(embed_rules);
380
+ }
381
+
366
382
 
367
383
  return Rater;
368
384
  })(document, RightJS);
@@ -1,13 +1,7 @@
1
1
  /**
2
- * Rating widget for RightJS
2
+ * RightJS-UI Rater v2.2.0
3
3
  * http://rightjs.org/ui/rater
4
4
  *
5
- * Copyright (C) 2009-2010 Nikolay Nemshilov
5
+ * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- var Rater=RightJS.Rater=function(h,b){var g=b.$,k=b.$w,l=b.Xhr,m=b.isString,n=b.isNumber,i=new (function(a,e){if(!e){e=a;a="DIV"}var f=new b.Wrapper(b.Element.Wrappers[a]||b.Element,{initialize:function(d,c){this.key=d;var j=[{"class":"rui-"+d}];this instanceof b.Input||this instanceof b.Form||j.unshift(a);this.$super.apply(this,j);if(b.isString(c))c=b.$(c);if(c instanceof b.Element){this._=c._;if("$listeners"in c)c.$listeners=c.$listeners;c={}}this.setOptions(c,this);return this},setOptions:function(d,
8
- c){c=c||this;b.Options.setOptions.call(this,b.Object.merge(d,eval("("+(c.get("data-"+this.key)||"{}")+")")));return this}});f=new b.Wrapper(f,e);b.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})({include:{assignTo:function(a){var e=b(function(d,c){if(d=g(d))d[d.setValue?"setValue":"update"](c.target.getValue())}).curry(a),f=b(function(d,c){(d=g(d))&&d.onChange&&d.onChange(b(function(){this.setValue(d.value())}).bind(c))}).curry(a);if(g(a)){e({target:this});f(this)}else g(h).onReady(b(function(){e({target:this});
9
- f(this)}.bind(this)));return this.onChange(e)}},extend:{version:"2.0.0",EVENTS:k("change hover send"),Options:{html:"&#9733;",size:5,value:null,update:null,disabled:false,disableOnVote:false,url:null,param:"rate",Xhr:null}},initialize:function(a){this.$super("rater",a).on({click:this._clicked,mouseover:this._hovered,mouseout:this._left});if(this.empty())for(a=0;a<this.options.size;a++)this.insert("<div>"+this.options.html+"</div>");a=this.options;if(a.value===null)a.value=this.find(".active").length;
10
- this.setValue(a.value);a.disabled&&this.disable();a.update&&this.assignTo(a.update)},setValue:function(a){if(!this.disabled()){a=m(a)?b(a).toInt():a;a=n(a)?b(a).round():0;a=b(a).max(this.options.size);a=b(a).min(0);this.highlight(a);if(this.value!=a)this.fire("change",{value:this.value=a})}return this},getValue:function(){return this.value},send:function(){if(this.options.url){this.request=(new l(this.options.url,this.options.Xhr)).send(this.options.param+"="+this.value);this.fire("send",{value:this.value})}return this},
11
- disable:function(){return this.addClass("rui-rater-disabled")},enable:function(){return this.removeClass("rui-rater-disabled")},disabled:function(){return this.hasClass("rui-rater-disabled")},_hovered:function(a){a=this.children().indexOf(a.target);if(!this.disabled()&&a>-1){this.highlight(a+1);this.fire("hover",{value:a+1})}},_clicked:function(a){a=this.children().indexOf(a.target);if(!this.disabled()&&a>-1){this.setValue(a+1);this.options.disableOnVote&&this.disable();this.send()}},_left:function(){this.setValue(this.value)},
12
- highlight:function(a){this.children().each(function(e,f){e[a-1<f?"removeClass":"addClass"]("active")})}});g(h).onMouseover(function(a){var e=a.target;if(a=a.find(".rui-rater"))if(!(a instanceof i)){a=new i(a);e.parent()===a&&e.fire("mouseover")}});h.write('<style type="text/css">div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}</style>');
13
- return i}(document,RightJS);
7
+ var Rater=RightJS.Rater=function(a,b){function c(a,c){c||(c=a,a="DIV");var d=new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof b.Input||this instanceof b.Form||e.unshift(a),this.$super.apply(this,e),b.isString(d)&&(d=b.$(d)),d instanceof b.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(a,c){c&&(a=b.Object.merge(a,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),a&&b.Options.setOptions.call(this,b.Object.merge(this.options,a));return this}}),e=new b.Class(d,c);b.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var d={assignTo:function(b){var c=e(function(a,b){(a=f(a))&&a[a.setValue?"setValue":"update"](b.target.getValue())}).curry(b),d=e(function(a,b){a=f(a),a&&a.onChange&&a.onChange(e(function(){this.setValue(a.value())}).bind(b))}).curry(b);f(b)?(c({target:this}),d(this)):f(a).onReady(e(function(){c({target:this}),d(this)}.bind(this)));return this.onChange(c)}},e=b,f=b.$,g=b.$w,h=b.Xhr,i=b.isString,j=b.isNumber,k=new c({include:d,extend:{version:"2.2.0",EVENTS:g("change hover send"),Options:{html:"&#9733;",size:5,value:null,update:null,disabled:!1,disableOnVote:!1,url:null,param:"rate",Xhr:null}},initialize:function(a){this.$super("rater",a).on({click:this._clicked,mouseover:this._hovered,mouseout:this._left});if(this.empty())for(var b=0;b<this.options.size;b++)this.insert("<div>"+this.options.html+"</div>");a=this.options,a.value===null&&(a.value=this.find(".active").length),this.setValue(a.value),a.disabled&&this.disable(),a.update&&this.assignTo(a.update)},setValue:function(a){this.disabled()||(a=i(a)?e(a).toInt():a,a=j(a)?e(a).round():0,a=e(a).max(this.options.size),a=e(a).min(0),this.highlight(a),this.value!=a&&this.fire("change",{value:this.value=a}));return this},getValue:function(){return this.value},send:function(){this.options.url&&(this.request=(new h(this.options.url,this.options.Xhr)).send(this.options.param+"="+this.value),this.fire("send",{value:this.value}));return this},disable:function(){return this.addClass("rui-rater-disabled")},enable:function(){return this.removeClass("rui-rater-disabled")},disabled:function(){return this.hasClass("rui-rater-disabled")},_hovered:function(a){var b=this.children().indexOf(a.target);!this.disabled()&&b>-1&&(this.highlight(b+1),this.fire("hover",{value:b+1}))},_clicked:function(a){var b=this.children().indexOf(a.target);!this.disabled()&&b>-1&&(this.setValue(b+1),this.options.disableOnVote&&this.disable(),this.send())},_left:function(){this.setValue(this.value)},highlight:function(a){this.children().each(function(b,c){b[a-1<c?"removeClass":"addClass"]("active")})}});f(a).onMouseover(function(a){var b=a.target,c=a.find(".rui-rater");c&&(c instanceof k||(c=new k(c),b.parent()===c&&b.fire("mouseover")))});var l=a.createElement("style"),m=a.createTextNode("div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}");l.type="text/css",a.getElementsByTagName("head")[0].appendChild(l),l.styleSheet?l.styleSheet.cssText=m.nodeValue:l.appendChild(m);return k}(document,RightJS)