right-rails 1.0.3 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/CHANGELOG +8 -2
  2. data/Rakefile +28 -28
  3. data/lib/right_rails/java_script_generator.rb +59 -51
  4. data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
  5. data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
  6. data/public/javascripts/right-olds-src.js +47 -46
  7. data/public/javascripts/right-safe-src.js +103 -102
  8. data/public/javascripts/right-safe.js +1 -1
  9. data/public/javascripts/right-src.js +611 -541
  10. data/public/javascripts/right.js +86 -85
  11. data/public/javascripts/right/autocompleter-src.js +81 -77
  12. data/public/javascripts/right/autocompleter.js +1 -1
  13. data/public/javascripts/right/calendar-src.js +209 -197
  14. data/public/javascripts/right/calendar.js +6 -6
  15. data/public/javascripts/right/colorpicker-src.js +127 -117
  16. data/public/javascripts/right/colorpicker.js +6 -6
  17. data/public/javascripts/right/dnd-src.js +63 -63
  18. data/public/javascripts/right/dnd.js +2 -2
  19. data/public/javascripts/right/in-edit-src.js +53 -48
  20. data/public/javascripts/right/in-edit.js +2 -2
  21. data/public/javascripts/right/lightbox-src.js +107 -99
  22. data/public/javascripts/right/lightbox.js +2 -2
  23. data/public/javascripts/right/rater-src.js +48 -46
  24. data/public/javascripts/right/rater.js +3 -3
  25. data/public/javascripts/right/resizable-src.js +53 -61
  26. data/public/javascripts/right/resizable.js +4 -4
  27. data/public/javascripts/right/selectable-src.js +97 -95
  28. data/public/javascripts/right/selectable.js +2 -2
  29. data/public/javascripts/right/slider-src.js +47 -45
  30. data/public/javascripts/right/slider.js +8 -8
  31. data/public/javascripts/right/sortable-src.js +54 -52
  32. data/public/javascripts/right/tabs-src.js +181 -171
  33. data/public/javascripts/right/tooltip-src.js +39 -37
  34. data/public/javascripts/right/uploader-src.js +21 -19
  35. data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
  36. metadata +9 -7
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Selectable unit for RightJS
2
+ * Selectable unit for RightJS
3
3
  * http://rightjs.org/ui/selectable
4
4
  *
5
5
  * Copyright (C) 2009-2010 Nikolay Nemshilov
@@ -10,7 +10,7 @@ if(g(a)){b({target:this});d(this)}else g(h).onReady(e(function(){b({target:this}
10
10
  o(arguments).compact(),b=a.pop();a=a.pop();var d;if(!r(b)||b instanceof n){a=g(a||b);b={}}if(a&&a instanceof u)a=b=this.harvestOptions(d=a);this.$super("selectable",a).setOptions(b).on({mousedown:this._mousedown,mouseover:this._mouseover,mouseout:this._mouseout,mouseup:this._mouseup,click:this._click,select:this._change,unselect:this._change});this.empty()&&this.build();b=this.options;if(!b.multiple||this.hasClass("rui-selectable-single")){this.isSingle=true;this.addClass("rui-selectable-single");
11
11
  this.buildSingle();b.selected===null&&this.select(this.items()[0])}b.disabled&&this.disable(b.disabled);b.selected&&this.select(b.selected);b.update&&this.assignTo(b.update);if(d){this.assignTo(d).insertTo(d,"before");d.wrap(i("div",{style:"position:absolute;z-index:-1;visibility:hidden;width:0;height:0;overflow:hidden"}))}},setValue:function(a){if(m(a))a=a.split(",").map("trim").filter(function(b){return!b.blank()});this.items().each("removeClass","rui-selectable-selected");return this.select(a)},
12
12
  getValue:function(){if(this.isSingle){var a=this.items().first("hasClass","rui-selectable-selected");return a?this.itemValue(a):null}else return this.items().filter("hasClass","rui-selectable-selected").map(function(b){return this.itemValue(b)},this)},disable:function(a){this.mapOrAll(a).each(function(b){this.fire("disable",b.addClass("rui-selectable-disabled"))},this);return this},enable:function(a){this.mapOrAll(a).each(function(b){this.fire("enable",b.removeClass("rui-selectable-disabled"))},this);
13
- return this},disabled:function(a){return this.mapOrAll(a).every("hasClass","rui-selectable-disabled")},select:function(a){a=this.mapEnabled(a);if(this.isSingle&&a){this.items().each("removeClass","rui-selectable-selected");a=e([a[0]])}if(!this.isSingle&&this.options.limit){for(var b=this.items().filter("hasClass","rui-selectable-selected"),d=[];a.length&&b.length+d.length<this.options.limit;){var c=a.shift();b.include(c)||d.push(c)}a=d}a.each(function(f){this.fire("select",f.addClass("rui-selectable-selected"))},
13
+ return this},disabled:function(a){return this.mapOrAll(a).every("hasClass","rui-selectable-disabled")},select:function(a){a=this.mapEnabled(a);if(this.isSingle&&a){this.items().each("removeClass","rui-selectable-selected");a=e([a[0]])}if(!this.isSingle&&this.options.limit){for(var b=this.items().filter("hasClass","rui-selectable-selected"),d=[];a.length&&b.length+d.length<this.options.limit;){var c=a.shift();b.include(c)||d.push(c)}a=d}a.compact().each(function(f){this.fire("select",f.addClass("rui-selectable-selected"))},
14
14
  this);return this},unselect:function(a){this.getValue();this.mapEnabled(a).each(function(b){this.fire("unselect",b.removeClass("rui-selectable-selected"))},this);return this},selected:function(a){return this.mapEnabled(a).every("hasClass","rui-selectable-selected")},insertTo:function(a,b){n.prototype.insertTo.call(this.isSingle?this.container:this,a,b);return this},fire:function(a,b){b&&b instanceof n?this.$super(a,{item:b,index:this.items().indexOf(b)}):this.$super.apply(this,arguments);return this},
15
15
  itemValue:function(a){var b=a.get("id")||a.get("val");return b?this.options.parseIds?b.match(/\d+/):b:this.items().indexOf(a)},items:function(){return this.find("li")},mapOrAll:function(a){var b=this.items();if(t(a)){l(a)||(a=[a]);b=e(a).map(function(d){var c=m(d)&&/^\d+$/.test(d)?parseInt(d,10):d,f=d;if(s(c))f=b[c];else if(m(d))f=b.first(function(j){return j.id==d||j.val==d});return f},this).compact()}return b},mapEnabled:function(a){return this.mapOrAll(a).filter(function(b){return!b.hasClass("rui-selectable-disabled")},
16
16
  this)},_mousedown:function(a){a.stop();var b=a.target,d=this.items();if(!this.disabled(b)){if(this.isSingle)this.select(b);else if(this.selected(b)){this.unselect(b);this._massRemove=true}else{this.select(b);this._massSelect=true}if((a.shiftKey||a.metaKey)&&this._prevItem){var c=d.indexOf(this._prevItem);a=d.indexOf(b);if(c!=a){if(c>a)a=c=a;for(c=c;c<a;c++)this[this._prevItem.hasClass("rui-selectable-selected")?"select":"unselect"](d[c])}}this._prevItem=b}},_mouseup:function(a){a.stop();this._massRemove=
@@ -1,5 +1,5 @@
1
1
  /**
2
- * RightJS UI Slider unit
2
+ * RightJS UI Slider unit
3
3
  * http://rightjs.org/ui/slider
4
4
  *
5
5
  * Copyright (C) 2009-2010 Nikolay Nemshilov
@@ -38,13 +38,13 @@ var R = RightJS,
38
38
  * @param String tag-name or Object methods
39
39
  * @param Object methods
40
40
  * @return Widget wrapper
41
- */
41
+ */
42
42
  function Widget(tag_name, methods) {
43
43
  if (!methods) {
44
44
  methods = tag_name;
45
45
  tag_name = 'DIV';
46
46
  }
47
-
47
+
48
48
  /**
49
49
  * An Abstract Widget Unit
50
50
  *
@@ -61,17 +61,17 @@ function Widget(tag_name, methods) {
61
61
  initialize: function(key, options) {
62
62
  this.key = key;
63
63
  var args = [{'class': 'rui-' + key}];
64
-
64
+
65
65
  // those two have different constructors
66
66
  if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
67
67
  args.unshift(tag_name);
68
68
  }
69
69
  this.$super.apply(this, args);
70
-
70
+
71
71
  if (RightJS.isString(options)) {
72
72
  options = RightJS.$(options);
73
73
  }
74
-
74
+
75
75
  // if the options is another element then
76
76
  // try to dynamically rewrap it with our widget
77
77
  if (options instanceof RightJS.Element) {
@@ -104,16 +104,16 @@ function Widget(tag_name, methods) {
104
104
  return this;
105
105
  }
106
106
  });
107
-
107
+
108
108
  /**
109
109
  * Creating the actual widget class
110
110
  *
111
111
  */
112
112
  var Klass = new RightJS.Wrapper(AbstractWidget, methods);
113
-
113
+
114
114
  // creating the widget related shortcuts
115
115
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
116
-
116
+
117
117
  return Klass;
118
118
  }
119
119
 
@@ -125,7 +125,7 @@ function Widget(tag_name, methods) {
125
125
  * Copyright (C) 2010 Nikolay Nemshilov
126
126
  */
127
127
  var Updater = {
128
-
128
+
129
129
  /**
130
130
  * Assigns the unit to work with an input element
131
131
  *
@@ -138,7 +138,7 @@ var Updater = {
138
138
  element[element.setValue ? 'setValue' : 'update'](event.target.getValue());
139
139
  }
140
140
  }).curry(element);
141
-
141
+
142
142
  var connect = R(function(element, object) {
143
143
  element = $(element);
144
144
  if (element && element.onChange) {
@@ -147,7 +147,7 @@ var Updater = {
147
147
  }).bind(object));
148
148
  }
149
149
  }).curry(element);
150
-
150
+
151
151
  if ($(element)) {
152
152
  assign({target: this});
153
153
  connect(this);
@@ -157,7 +157,7 @@ var Updater = {
157
157
  connect(this);
158
158
  }.bind(this)));
159
159
  }
160
-
160
+
161
161
  return this.onChange(assign);
162
162
  }
163
163
  };
@@ -170,12 +170,12 @@ var Updater = {
170
170
  */
171
171
  var Slider = new Widget({
172
172
  include: Updater,
173
-
173
+
174
174
  extend: {
175
175
  version: '2.0.0',
176
-
176
+
177
177
  EVENTS: $w('change'),
178
-
178
+
179
179
  Options: {
180
180
  min: 0, // the min value
181
181
  max: 100, // the max value
@@ -185,10 +185,10 @@ var Slider = new Widget({
185
185
  update: null, // reference to an element to update
186
186
  round: 0 // the number of symbols after the decimal pointer
187
187
  },
188
-
188
+
189
189
  current: false
190
190
  },
191
-
191
+
192
192
  /**
193
193
  * basic constructor
194
194
  * USAGE:
@@ -200,29 +200,29 @@ var Slider = new Widget({
200
200
  */
201
201
  initialize: function() {
202
202
  var args = $A(arguments).compact(), options = args.pop(), element = args.pop();
203
-
203
+
204
204
  // figuring out the arguments
205
205
  if (!isHash(options) || options instanceof Element) {
206
206
  element = $(element || options);
207
207
  options = {};
208
208
  }
209
-
209
+
210
210
  this.$super('slider', element).setOptions(options)
211
211
  .on('selectstart', 'stopEvent'); // disable select under IE
212
-
212
+
213
213
  this.level = this.first('.level') || $E('div', {'class': 'level'}).insertTo(this);
214
214
  this.handle = this.first('.handle') || $E('div', {'class': 'handle'}).insertTo(this);
215
-
215
+
216
216
  options = this.options;
217
217
  this.value = options.value === null ? options.min : options.value;
218
-
218
+
219
219
  if (options.update) { this.assignTo(options.update); }
220
220
  if (options.direction === 'y') { this.addClass('rui-slider-vertical'); }
221
221
  else if (this.hasClass('rui-slider-vertical')) { options.direction = 'y'; }
222
-
222
+
223
223
  this.setValue(this.value);
224
224
  },
225
-
225
+
226
226
  /**
227
227
  * The value setter
228
228
  *
@@ -234,7 +234,7 @@ var Slider = new Widget({
234
234
  setValue: function(value) {
235
235
  return this.precalc().shiftTo(value);
236
236
  },
237
-
237
+
238
238
  /**
239
239
  * Returns the value
240
240
  *
@@ -243,7 +243,7 @@ var Slider = new Widget({
243
243
  getValue: function() {
244
244
  return this.value;
245
245
  },
246
-
246
+
247
247
  /**
248
248
  * Inserts the widget into the element
249
249
  *
@@ -254,7 +254,7 @@ var Slider = new Widget({
254
254
  insertTo: function(element, position) {
255
255
  return this.$super(element, position).setValue(this.value);
256
256
  },
257
-
257
+
258
258
  // protected
259
259
 
260
260
  // precalculates dimensions, direction and offset for further use
@@ -263,10 +263,10 @@ var Slider = new Widget({
263
263
  handle = this.handle.setStyle(horizontal ? {left: 0} : {bottom: 0}).dimensions(),
264
264
  handle_size = this.hSize = horizontal ? handle.width : handle.height,
265
265
  dims = this.dims = this.dimensions();
266
-
266
+
267
267
  this.offset = horizontal ? handle.left - dims.left : dims.top + dims.height - handle.top - handle_size;
268
268
  this.space = (horizontal ? dims.width - handle_size - this.offset * 2 : dims.height - handle_size) - this.offset * 2;
269
-
269
+
270
270
  return this;
271
271
  },
272
272
 
@@ -274,19 +274,19 @@ var Slider = new Widget({
274
274
  start: function(event) {
275
275
  return this.precalc().e2val(event);
276
276
  },
277
-
277
+
278
278
  // processes the slider-drag
279
279
  move: function(event) {
280
280
  return this.e2val(event);
281
281
  },
282
-
282
+
283
283
  // shifts the slider to the value
284
284
  shiftTo: function(value) {
285
285
  var options = this.options, base = Math.pow(10, options.round), horizontal = options.direction === 'x';
286
-
286
+
287
287
  // rounding the value up
288
288
  value = Math.round(value * base) / base;
289
-
289
+
290
290
  // checking the value constraings
291
291
  if (value < options.min) { value = options.min; }
292
292
  if (value > options.max) { value = options.max; }
@@ -295,22 +295,22 @@ var Slider = new Widget({
295
295
  var diff = value % snap;
296
296
  value = diff < snap/2 ? value - diff : value - diff + snap;
297
297
  }
298
-
298
+
299
299
  // calculating and setting the actual position
300
300
  var position = this.space / (options.max - options.min) * (value - options.min);
301
-
301
+
302
302
  this.handle._.style[horizontal ? 'left' : 'bottom'] = position + 'px';
303
303
  this.level._.style[horizontal ? 'width': 'height'] = ((position > 0 ? position : 0) + 2) + 'px';
304
-
304
+
305
305
  // checking the change status
306
306
  if (value !== this.value) {
307
307
  this.value = value;
308
- this.fire('change');
308
+ this.fire('change', {value: value});
309
309
  }
310
-
310
+
311
311
  return this;
312
312
  },
313
-
313
+
314
314
  // converts the event position into the actual value in terms of the slider measures
315
315
  e2val: function(event) {
316
316
  var options = this.options, horizontal = options.direction === 'x',
@@ -318,11 +318,12 @@ var Slider = new Widget({
318
318
  cur_pos = event.position()[horizontal ? 'x' : 'y'] - offset - this.hSize/2,
319
319
  min_pos = horizontal ? dims.left + offset : dims.top + offset,
320
320
  value = (options.max - options.min) / space * (cur_pos - min_pos);
321
-
321
+
322
322
  return this.shiftTo(horizontal ? options.min + value : options.max - value);
323
323
  }
324
324
  });
325
325
 
326
+
326
327
  /**
327
328
  * Document onReady hook for sliders
328
329
  *
@@ -337,7 +338,7 @@ $(document).on({
337
338
  }
338
339
  });
339
340
  },
340
-
341
+
341
342
  // initiates the slider move
342
343
  mousedown: function(event) {
343
344
  var slider = event.find('.rui-slider');
@@ -349,14 +350,14 @@ $(document).on({
349
350
  Slider.current = slider.start(event);
350
351
  }
351
352
  },
352
-
353
+
353
354
  // handles the slider move
354
355
  mousemove: function(event) {
355
356
  if (Slider.current) {
356
357
  Slider.current.move(event);
357
358
  }
358
359
  },
359
-
360
+
360
361
  // handles the slider release
361
362
  mouseup: function(event) {
362
363
  if (Slider.current) {
@@ -371,7 +372,8 @@ $(window).onBlur(function() {
371
372
  }
372
373
  });
373
374
 
375
+
374
376
  document.write("<style type=\"text/css\">div.rui-slider,div.rui-slider .handle div.rui-slider .level{margin:0;padding:0;border:none;background:none}div.rui-slider{height:0.4em;width:20em;border:1px solid #bbb;background:#F8F8F8;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;position:relative;margin:.6em 0;display:inline-block; *display:inline; *zoom:1;vertical-align:middle;user-select:none;-moz-user-select:none;-webkit-user-select:none;cursor:pointer}div.rui-slider .handle{font-size:25%;position:absolute;left:0;top:0;width:4pt;height:4em;margin-top:-1.6em;margin-left:0.4em;background:#BBB;border:1px solid #999;border-radius:.8em;-moz-border-radius:.8em;-webkit-border-radius:.8em;z-index:20}div.rui-slider .level{font-size:25%;position:absolute;top:0;left:0;width:0;height:100%;background:#ddd;z-index:1}div.rui-slider-vertical{height:10em;width:0.4em;margin:0 .3em}div.rui-slider-vertical .handle{top:auto;bottom:0;margin:0;margin-left:-1.6em;margin-bottom:0.4em;height:4pt;width:4em}div.rui-slider-vertical .level{height:0;width:100%;top:auto;bottom:0}</style>");
375
377
 
376
378
  return Slider;
377
- })(document, Math, RightJS);
379
+ })(document, Math, RightJS);
@@ -1,14 +1,14 @@
1
1
  /**
2
- * RightJS UI Slider unit
2
+ * RightJS UI Slider unit
3
3
  * http://rightjs.org/ui/slider
4
4
  *
5
5
  * Copyright (C) 2009-2010 Nikolay Nemshilov
6
6
  */
7
- var Slider=RightJS.Slider=function(j,k,e){var h=e.$,m=e.$$,n=e.$w,l=e.$E,o=e.$A,p=e.isHash,q=e.Element,g=new (function(b,a){if(!a){a=b;b="DIV"}var f=new e.Wrapper(e.Element.Wrappers[b]||e.Element,{initialize:function(c,d){this.key=c;var i=[{"class":"rui-"+c}];this instanceof e.Input||this instanceof e.Form||i.unshift(b);this.$super.apply(this,i);if(e.isString(d))d=e.$(d);if(d instanceof e.Element){this._=d._;if("$listeners"in d)d.$listeners=d.$listeners;d={}}this.setOptions(d,this);return this},setOptions:function(c,
8
- d){d=d||this;e.Options.setOptions.call(this,e.Object.merge(c,eval("("+(d.get("data-"+this.key)||"{}")+")")));return this}});f=new e.Wrapper(f,a);e.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})({include:{assignTo:function(b){var a=e(function(c,d){if(c=h(c))c[c.setValue?"setValue":"update"](d.target.getValue())}).curry(b),f=e(function(c,d){(c=h(c))&&c.onChange&&c.onChange(e(function(){this.setValue(c.value())}).bind(d))}).curry(b);if(h(b)){a({target:this});f(this)}else h(j).onReady(e(function(){a({target:this});
9
- f(this)}.bind(this)));return this.onChange(a)}},extend:{version:"2.0.0",EVENTS:n("change"),Options:{min:0,max:100,snap:0,value:null,direction:"x",update:null,round:0},current:false},initialize:function(){var b=o(arguments).compact(),a=b.pop();b=b.pop();if(!p(a)||a instanceof q){b=h(b||a);a={}}this.$super("slider",b).setOptions(a).on("selectstart","stopEvent");this.level=this.first(".level")||l("div",{"class":"level"}).insertTo(this);this.handle=this.first(".handle")||l("div",{"class":"handle"}).insertTo(this);
10
- a=this.options;this.value=a.value===null?a.min:a.value;a.update&&this.assignTo(a.update);if(a.direction==="y")this.addClass("rui-slider-vertical");else if(this.hasClass("rui-slider-vertical"))a.direction="y";this.setValue(this.value)},setValue:function(b){return this.precalc().shiftTo(b)},getValue:function(){return this.value},insertTo:function(b,a){return this.$super(b,a).setValue(this.value)},precalc:function(){var b=this.options.direction==="x",a=this.handle.setStyle(b?{left:0}:{bottom:0}).dimensions(),
11
- f=this.hSize=b?a.width:a.height,c=this.dims=this.dimensions();this.offset=b?a.left-c.left:c.top+c.height-a.top-f;this.space=(b?c.width-f-this.offset*2:c.height-f)-this.offset*2;return this},start:function(b){return this.precalc().e2val(b)},move:function(b){return this.e2val(b)},shiftTo:function(b){var a=this.options,f=k.pow(10,a.round),c=a.direction==="x";b=k.round(b*f)/f;if(b<a.min)b=a.min;if(b>a.max)b=a.max;if(a.snap){f=a.snap;var d=b%f;b=d<f/2?b-d:b-d+f}a=this.space/(a.max-a.min)*(b-a.min);this.handle._.style[c?
12
- "left":"bottom"]=a+"px";this.level._.style[c?"width":"height"]=(a>0?a:0)+2+"px";if(b!==this.value){this.value=b;this.fire("change")}return this},e2val:function(b){var a=this.options,f=a.direction==="x",c=this.dims,d=this.offset,i=this.space;b=b.position()[f?"x":"y"]-d-this.hSize/2;c=(a.max-a.min)/i*(b-(f?c.left+d:c.top+d));return this.shiftTo(f?a.min+c:a.max-c)}});h(j).on({ready:function(){m(".rui-slider").each(function(b){b instanceof g||new g(b)})},mousedown:function(b){var a=b.find(".rui-slider");
13
- if(a){b.stop();a instanceof g||(a=new g(a));g.current=a.start(b)}},mousemove:function(b){g.current&&g.current.move(b)},mouseup:function(){if(g.current)g.current=false}});h(window).onBlur(function(){if(g.current)g.current=false});j.write('<style type="text/css">div.rui-slider,div.rui-slider .handle div.rui-slider .level{margin:0;padding:0;border:none;background:none}div.rui-slider{height:0.4em;width:20em;border:1px solid #bbb;background:#F8F8F8;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;position:relative;margin:.6em 0;display:inline-block; *display:inline; *zoom:1;vertical-align:middle;user-select:none;-moz-user-select:none;-webkit-user-select:none;cursor:pointer}div.rui-slider .handle{font-size:25%;position:absolute;left:0;top:0;width:4pt;height:4em;margin-top:-1.6em;margin-left:0.4em;background:#BBB;border:1px solid #999;border-radius:.8em;-moz-border-radius:.8em;-webkit-border-radius:.8em;z-index:20}div.rui-slider .level{font-size:25%;position:absolute;top:0;left:0;width:0;height:100%;background:#ddd;z-index:1}div.rui-slider-vertical{height:10em;width:0.4em;margin:0 .3em}div.rui-slider-vertical .handle{top:auto;bottom:0;margin:0;margin-left:-1.6em;margin-bottom:0.4em;height:4pt;width:4em}div.rui-slider-vertical .level{height:0;width:100%;top:auto;bottom:0}</style>');
7
+ var Slider=RightJS.Slider=function(j,k,e){var h=e.$,m=e.$$,n=e.$w,l=e.$E,o=e.$A,p=e.isHash,q=e.Element,g=new (function(a,b){if(!b){b=a;a="DIV"}var f=new e.Wrapper(e.Element.Wrappers[a]||e.Element,{initialize:function(c,d){this.key=c;var i=[{"class":"rui-"+c}];this instanceof e.Input||this instanceof e.Form||i.unshift(a);this.$super.apply(this,i);if(e.isString(d))d=e.$(d);if(d instanceof e.Element){this._=d._;if("$listeners"in d)d.$listeners=d.$listeners;d={}}this.setOptions(d,this);return this},setOptions:function(c,
8
+ d){d=d||this;e.Options.setOptions.call(this,e.Object.merge(c,eval("("+(d.get("data-"+this.key)||"{}")+")")));return this}});f=new e.Wrapper(f,b);e.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})({include:{assignTo:function(a){var b=e(function(c,d){if(c=h(c))c[c.setValue?"setValue":"update"](d.target.getValue())}).curry(a),f=e(function(c,d){(c=h(c))&&c.onChange&&c.onChange(e(function(){this.setValue(c.value())}).bind(d))}).curry(a);if(h(a)){b({target:this});f(this)}else h(j).onReady(e(function(){b({target:this});
9
+ f(this)}.bind(this)));return this.onChange(b)}},extend:{version:"2.0.0",EVENTS:n("change"),Options:{min:0,max:100,snap:0,value:null,direction:"x",update:null,round:0},current:false},initialize:function(){var a=o(arguments).compact(),b=a.pop();a=a.pop();if(!p(b)||b instanceof q){a=h(a||b);b={}}this.$super("slider",a).setOptions(b).on("selectstart","stopEvent");this.level=this.first(".level")||l("div",{"class":"level"}).insertTo(this);this.handle=this.first(".handle")||l("div",{"class":"handle"}).insertTo(this);
10
+ b=this.options;this.value=b.value===null?b.min:b.value;b.update&&this.assignTo(b.update);if(b.direction==="y")this.addClass("rui-slider-vertical");else if(this.hasClass("rui-slider-vertical"))b.direction="y";this.setValue(this.value)},setValue:function(a){return this.precalc().shiftTo(a)},getValue:function(){return this.value},insertTo:function(a,b){return this.$super(a,b).setValue(this.value)},precalc:function(){var a=this.options.direction==="x",b=this.handle.setStyle(a?{left:0}:{bottom:0}).dimensions(),
11
+ f=this.hSize=a?b.width:b.height,c=this.dims=this.dimensions();this.offset=a?b.left-c.left:c.top+c.height-b.top-f;this.space=(a?c.width-f-this.offset*2:c.height-f)-this.offset*2;return this},start:function(a){return this.precalc().e2val(a)},move:function(a){return this.e2val(a)},shiftTo:function(a){var b=this.options,f=k.pow(10,b.round),c=b.direction==="x";a=k.round(a*f)/f;if(a<b.min)a=b.min;if(a>b.max)a=b.max;if(b.snap){f=b.snap;var d=a%f;a=d<f/2?a-d:a-d+f}b=this.space/(b.max-b.min)*(a-b.min);this.handle._.style[c?
12
+ "left":"bottom"]=b+"px";this.level._.style[c?"width":"height"]=(b>0?b:0)+2+"px";if(a!==this.value){this.value=a;this.fire("change",{value:a})}return this},e2val:function(a){var b=this.options,f=b.direction==="x",c=this.dims,d=this.offset,i=this.space;a=a.position()[f?"x":"y"]-d-this.hSize/2;c=(b.max-b.min)/i*(a-(f?c.left+d:c.top+d));return this.shiftTo(f?b.min+c:b.max-c)}});h(j).on({ready:function(){m(".rui-slider").each(function(a){a instanceof g||new g(a)})},mousedown:function(a){var b=a.find(".rui-slider");
13
+ if(b){a.stop();b instanceof g||(b=new g(b));g.current=b.start(a)}},mousemove:function(a){g.current&&g.current.move(a)},mouseup:function(){if(g.current)g.current=false}});h(window).onBlur(function(){if(g.current)g.current=false});j.write('<style type="text/css">div.rui-slider,div.rui-slider .handle div.rui-slider .level{margin:0;padding:0;border:none;background:none}div.rui-slider{height:0.4em;width:20em;border:1px solid #bbb;background:#F8F8F8;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;position:relative;margin:.6em 0;display:inline-block; *display:inline; *zoom:1;vertical-align:middle;user-select:none;-moz-user-select:none;-webkit-user-select:none;cursor:pointer}div.rui-slider .handle{font-size:25%;position:absolute;left:0;top:0;width:4pt;height:4em;margin-top:-1.6em;margin-left:0.4em;background:#BBB;border:1px solid #999;border-radius:.8em;-moz-border-radius:.8em;-webkit-border-radius:.8em;z-index:20}div.rui-slider .level{font-size:25%;position:absolute;top:0;left:0;width:0;height:100%;background:#ddd;z-index:1}div.rui-slider-vertical{height:10em;width:0.4em;margin:0 .3em}div.rui-slider-vertical .handle{top:auto;bottom:0;margin:0;margin-left:-1.6em;margin-bottom:0.4em;height:4pt;width:4em}div.rui-slider-vertical .level{height:0;width:100%;top:auto;bottom:0}</style>');
14
14
  return g}(document,Math,RightJS);
@@ -36,13 +36,13 @@ var R = RightJS,
36
36
  * @param String tag-name or Object methods
37
37
  * @param Object methods
38
38
  * @return Widget wrapper
39
- */
39
+ */
40
40
  function Widget(tag_name, methods) {
41
41
  if (!methods) {
42
42
  methods = tag_name;
43
43
  tag_name = 'DIV';
44
44
  }
45
-
45
+
46
46
  /**
47
47
  * An Abstract Widget Unit
48
48
  *
@@ -59,17 +59,17 @@ function Widget(tag_name, methods) {
59
59
  initialize: function(key, options) {
60
60
  this.key = key;
61
61
  var args = [{'class': 'rui-' + key}];
62
-
62
+
63
63
  // those two have different constructors
64
64
  if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
65
65
  args.unshift(tag_name);
66
66
  }
67
67
  this.$super.apply(this, args);
68
-
68
+
69
69
  if (RightJS.isString(options)) {
70
70
  options = RightJS.$(options);
71
71
  }
72
-
72
+
73
73
  // if the options is another element then
74
74
  // try to dynamically rewrap it with our widget
75
75
  if (options instanceof RightJS.Element) {
@@ -102,16 +102,16 @@ function Widget(tag_name, methods) {
102
102
  return this;
103
103
  }
104
104
  });
105
-
105
+
106
106
  /**
107
107
  * Creating the actual widget class
108
108
  *
109
109
  */
110
110
  var Klass = new RightJS.Wrapper(AbstractWidget, methods);
111
-
111
+
112
112
  // creating the widget related shortcuts
113
113
  RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
114
-
114
+
115
115
  return Klass;
116
116
  }
117
117
 
@@ -124,29 +124,29 @@ function Widget(tag_name, methods) {
124
124
  var Sortable = new Widget('UL', {
125
125
  extend: {
126
126
  version: '2.0.0',
127
-
127
+
128
128
  EVENTS: $w('change'),
129
-
129
+
130
130
  Options: {
131
131
  url: null, // the Xhr requests url address, might contain the '%{id}' placeholder
132
132
  method: 'put', // the Xhr requests method
133
-
133
+
134
134
  Xhr: {}, // additional Xhr options
135
-
135
+
136
136
  idParam: 'id', // the id value name
137
137
  posParam: 'position', // the position value name
138
138
  parseId: true, // if the id attribute should be converted into an integer before sending
139
-
139
+
140
140
  dragClass: 'dragging', // the in-process class name
141
141
  accept: null, // a reference or a list of references to the other sortables between which you can drag the items
142
142
  minLength: 1, // minimum number of items on the list when the feature works
143
-
143
+
144
144
  cssRule: '*[data-sortable]' // css-rule for automatically initializable sortables
145
145
  },
146
-
146
+
147
147
  current: false // a reference to the currently active sortable
148
148
  },
149
-
149
+
150
150
  /**
151
151
  * basic constructor
152
152
  *
@@ -161,7 +161,7 @@ var Sortable = new Widget('UL', {
161
161
  .on('change', this._tryXhr)
162
162
  .on('selectstart', 'stopEvent'); // disable select under IE
163
163
  },
164
-
164
+
165
165
  /**
166
166
  * some additional options processing
167
167
  *
@@ -171,35 +171,35 @@ var Sortable = new Widget('UL', {
171
171
  */
172
172
  setOptions: function(options, context) {
173
173
  this.$super(options, context);
174
-
174
+
175
175
  options = this.options;
176
-
176
+
177
177
  // Preprocessing the acceptance list
178
178
  var list = options.accept || [];
179
179
  if (!isArray(list)) { list = [list]; }
180
-
180
+
181
181
  options.accept = R([this].concat(list)).map($).uniq();
182
-
182
+
183
183
  return this;
184
184
  },
185
185
 
186
186
  // protected
187
-
187
+
188
188
  // starts the drag
189
189
  startDrag: function(event) {
190
190
  // don't let to drag out the last item
191
191
  if (this.children().length <= this.options.minLength) { return; }
192
-
192
+
193
193
  // trying to find the list-item upon which the user pressed the mouse
194
194
  var target = event.target, targets = R([target].concat(target.parents())),
195
195
  item = targets[targets.indexOf(this) - 1], event_pos = event.position();
196
-
196
+
197
197
  if (item) {
198
198
  this._initDrag(item, event_pos);
199
199
  Sortable.current = this;
200
200
  }
201
201
  },
202
-
202
+
203
203
  // moves the item
204
204
  moveItem: function(event) {
205
205
  var event_pos = event.position(),
@@ -208,11 +208,11 @@ var Sortable = new Widget('UL', {
208
208
  left = event_pos.x - this.xRDiff,
209
209
  right = left + this.cloneWidth,
210
210
  bottom = top + this.cloneHeight;
211
-
211
+
212
212
  // moving the clone
213
213
  item.top = (event_pos.y - this.yDiff) + 'px';
214
214
  item.left = (event_pos.x - this.xDiff) + 'px';
215
-
215
+
216
216
  // checking for an overlaping item
217
217
  var over_item = this.suspects.first(function(suspect) {
218
218
  return (
@@ -223,19 +223,19 @@ var Sortable = new Widget('UL', {
223
223
  (right < suspect.right && right > suspect.leftHalf)
224
224
  );
225
225
  });
226
-
226
+
227
227
  if (over_item) {
228
228
  item = over_item.item;
229
229
  item.insert(this.item, item.prevSiblings().include(this.item) ? 'after' : 'before');
230
230
  this._findSuspects();
231
-
231
+
232
232
  // sending the event
233
233
  var list = item.parent();
234
-
234
+
235
235
  if (!(list instanceof Sortable)) {
236
236
  list = new Sortable(list);
237
237
  }
238
-
238
+
239
239
  this.fire('change', {
240
240
  list: list,
241
241
  item: this.item,
@@ -243,7 +243,7 @@ var Sortable = new Widget('UL', {
243
243
  });
244
244
  }
245
245
  },
246
-
246
+
247
247
  // finalizes the drag
248
248
  finishDrag: function() {
249
249
  if (this.itemClone) {
@@ -252,10 +252,10 @@ var Sortable = new Widget('UL', {
252
252
  }
253
253
  Sortable.current = false;
254
254
  },
255
-
255
+
256
256
  _initDrag: function(item, event_pos) {
257
257
  var dims = this.dimensions(), item_dims = item.dimensions();
258
-
258
+
259
259
  // creating the draggable clone
260
260
  var clone = item.clone().setStyle({
261
261
  margin: 0,
@@ -267,27 +267,27 @@ var Sortable = new Widget('UL', {
267
267
  .addClass(this.options.dragClass).insertTo(this)
268
268
  .setHeight(this.cloneHeight = item_dims.height)
269
269
  .setWidth(this.cloneWidth = item_dims.width);
270
-
270
+
271
271
  // adjusting the clone position to compensate relative fields and margins
272
272
  var clone_pos = clone.position(),
273
273
  real_x = item_dims.left - clone_pos.x,
274
274
  real_y = item_dims.top - clone_pos.y;
275
-
275
+
276
276
  clone.moveTo(real_x, real_y);
277
-
277
+
278
278
  this.item = item.setStyle('visibility:hidden');
279
279
  this.itemClone = clone;
280
-
280
+
281
281
  // mouse event-position diffs
282
282
  this.xDiff = event_pos.x - real_x;
283
283
  this.yDiff = event_pos.y - real_y;
284
284
  this.xRDiff = event_pos.x - clone.position().x;
285
285
  this.yRDiff = event_pos.y - clone.position().y;
286
-
286
+
287
287
  // collecting the list of interchangable items with their positions
288
288
  this._findSuspects();
289
289
  },
290
-
290
+
291
291
  // collects the precached list of suspects
292
292
  _findSuspects: function() {
293
293
  var suspects = this.suspects = R([]), item = this.item, clone = this.itemClone;
@@ -295,7 +295,7 @@ var Sortable = new Widget('UL', {
295
295
  list.children().each(function(element) {
296
296
  if (element !== item && element !== clone) {
297
297
  var dims = element.dimensions();
298
-
298
+
299
299
  // caching the sizes
300
300
  suspects.push({
301
301
  item: element,
@@ -310,24 +310,24 @@ var Sortable = new Widget('UL', {
310
310
  });
311
311
  });
312
312
  },
313
-
313
+
314
314
  // tries to send an Xhr request about the element relocation
315
315
  _tryXhr: function(event) {
316
316
  if (this.options.url) {
317
317
  var url = R(this.options.url), params = {}, item = event.item, position = event.index + 1;
318
-
318
+
319
319
  // building the Xhr request options
320
320
  var options = Object.merge({
321
321
  method: this.options.method,
322
322
  params: {}
323
323
  }, this.options.Xhr);
324
-
324
+
325
325
  // grabbing the id
326
326
  var id = item.get('id') || '';
327
327
  if (this.options.parseId && id) {
328
328
  id = (id.match(/\d+/) || [''])[0];
329
329
  }
330
-
330
+
331
331
  // assigning the parameters
332
332
  if (url.include('%{id}')) {
333
333
  url = url.replace('%{id}', id);
@@ -335,20 +335,21 @@ var Sortable = new Widget('UL', {
335
335
  params[this.options.idParam] = id;
336
336
  }
337
337
  params[this.options.posParam] = position;
338
-
338
+
339
339
  // merging the params with possible Xhr params
340
340
  if (isString(options.params)) {
341
341
  options.params += '&'+Object.toQueryString(params);
342
342
  } else {
343
343
  options.params = Object.merge(options.params, params);
344
344
  }
345
-
345
+
346
346
  // calling the server
347
347
  RightJS.Xhr.load(url, options);
348
348
  }
349
349
  }
350
350
  });
351
351
 
352
+
352
353
  /**
353
354
  * Document level hooks for sortables
354
355
  *
@@ -357,22 +358,22 @@ var Sortable = new Widget('UL', {
357
358
  $(document).on({
358
359
  mousedown: function(event) {
359
360
  var element = event.find(Sortable.Options.cssRule);
360
-
361
+
361
362
  if (element) {
362
363
  if (!(element instanceof Sortable)) {
363
364
  element = new Sortable(element);
364
365
  }
365
-
366
+
366
367
  element.startDrag(event);
367
368
  }
368
369
  },
369
-
370
+
370
371
  mousemove: function(event) {
371
372
  if (Sortable.current) {
372
373
  Sortable.current.moveItem(event);
373
374
  }
374
375
  },
375
-
376
+
376
377
  mouseup: function() {
377
378
  if (Sortable.current) {
378
379
  Sortable.current.finishDrag();
@@ -386,7 +387,8 @@ $(window).onBlur(function() {
386
387
  }
387
388
  });
388
389
 
390
+
389
391
  document.write("<style type=\"text/css\">.rui-sortable{user-select:none;-moz-user-select:none;-webkit-user-select:none}</style>");
390
392
 
391
393
  return Sortable;
392
- })(document, RightJS);
394
+ })(document, RightJS);