right-rails 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/CHANGELOG +5 -0
  2. data/lib/right_rails/helpers/forms.rb +81 -47
  3. data/lib/right_rails/helpers.rb +9 -0
  4. data/public/javascripts/right/autocompleter-src.js +1 -1
  5. data/public/javascripts/right/autocompleter.js +1 -1
  6. data/public/javascripts/right/billboard-src.js +1 -1
  7. data/public/javascripts/right/billboard.js +1 -1
  8. data/public/javascripts/right/calendar-src.js +1 -1
  9. data/public/javascripts/right/calendar.js +1 -1
  10. data/public/javascripts/right/casting-src.js +183 -0
  11. data/public/javascripts/right/casting.js +7 -0
  12. data/public/javascripts/right/colorpicker-src.js +1 -1
  13. data/public/javascripts/right/colorpicker.js +1 -1
  14. data/public/javascripts/right/dialog-src.js +1 -1
  15. data/public/javascripts/right/dialog.js +1 -1
  16. data/public/javascripts/right/dnd-src.js +20 -20
  17. data/public/javascripts/right/dnd.js +2 -2
  18. data/public/javascripts/right/in-edit-src.js +1 -1
  19. data/public/javascripts/right/in-edit.js +1 -1
  20. data/public/javascripts/right/lightbox-src.js +24 -5
  21. data/public/javascripts/right/lightbox.js +2 -2
  22. data/public/javascripts/right/rails-src.js +1 -1
  23. data/public/javascripts/right/rails.js +1 -1
  24. data/public/javascripts/right/rater-src.js +1 -1
  25. data/public/javascripts/right/rater.js +1 -1
  26. data/public/javascripts/right/resizable-src.js +29 -3
  27. data/public/javascripts/right/resizable.js +2 -2
  28. data/public/javascripts/right/selectable-src.js +1 -1
  29. data/public/javascripts/right/selectable.js +1 -1
  30. data/public/javascripts/right/slider-src.js +5 -5
  31. data/public/javascripts/right/slider.js +2 -2
  32. data/public/javascripts/right/sortable-src.js +1 -1
  33. data/public/javascripts/right/sortable.js +1 -1
  34. data/public/javascripts/right/tabs-src.js +8 -6
  35. data/public/javascripts/right/tabs.js +2 -2
  36. data/public/javascripts/right/tags-src.js +745 -0
  37. data/public/javascripts/right/tags.js +7 -0
  38. data/public/javascripts/right/tooltips-src.js +1 -1
  39. data/public/javascripts/right/tooltips.js +1 -1
  40. data/public/javascripts/right/uploader-src.js +4 -3
  41. data/public/javascripts/right/uploader.js +2 -2
  42. data/public/javascripts/right-safe-src.js +2 -2
  43. data/public/javascripts/right-safe.js +2 -2
  44. data/public/javascripts/right-src.js +60 -47
  45. data/public/javascripts/right.js +2 -2
  46. data/spec/lib/right_rails/helpers/forms_spec.rb +67 -40
  47. metadata +10 -15
@@ -0,0 +1,183 @@
1
+ /**
2
+ * Dynamic Elements Casting v2.2.0
3
+ * http://rightjs.org/plugins/casting
4
+ *
5
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
6
+ */
7
+ (function(RightJS) {
8
+ /**
9
+ * Casting plugin initialization script
10
+ *
11
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
12
+ */
13
+
14
+ RightJS.Casting = {
15
+ version: '2.2.0'
16
+ };
17
+
18
+
19
+
20
+ /**
21
+ * Advanced Elements typecasting feature.
22
+ * Basically it allows you to handle all sorts of css-rules with dom-wrappers
23
+ *
24
+ * USAGE:
25
+ *
26
+ * var MyClass = Element.Wrappers.add('div#boo', new Class(Element, {
27
+ * // some methods in here
28
+ * }));
29
+ * var MyClass = Element.Wrappers.add('div.hoo', new Class(Input, {
30
+ * // some methods in here
31
+ * }));
32
+ *
33
+ * Element.Wrappers.remove('div#boo');
34
+ * Element.Wrappers.remove(MyClass);
35
+ *
36
+ *
37
+ * Copyright (C) 2010-2011 Alexey Dubinin <LemmingKing at ya dot ru>
38
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
39
+ */
40
+
41
+ var id_matchers = null,
42
+ class_matchers = null,
43
+ Wrappers = RightJS.Element.Wrappers;
44
+
45
+ RightJS.$ext(Wrappers, {
46
+
47
+ /**
48
+ * Register a new wrapper for given css-rule
49
+ *
50
+ * @param String css-rule
51
+ * @param RightJS.Element subclass
52
+ * @return Element.Wrappers object
53
+ */
54
+ set: function(css_rule, klass) {
55
+ var match = css_rule.match(/^[a-z]+$/i);
56
+
57
+ if (match) { // Tag-name
58
+ Wrappers[css_rule.toUpperCase()] = klass;
59
+ } else if ((match = css_rule.match(/^([a-z]*)\#[a-z0-9_\-]+$/i))) {
60
+ if (id_matchers === null) { id_matchers = {}; }
61
+ id_matchers[css_rule] = klass;
62
+ } else if ((match = css_rule.match(/^([a-z]*)\.[a-z0-9_\-]+$/i))) {
63
+ if (class_matchers === null) { class_matchers = {}; }
64
+ class_matchers[css_rule] = klass;
65
+ }
66
+
67
+ return klass;
68
+ },
69
+
70
+ /**
71
+ * Returns a registered wrapper by a css-rule
72
+ *
73
+ * @param String css_rule
74
+ * @return RightJS.Element or null
75
+ */
76
+ get: function(css_rule) {
77
+ var result = null;
78
+
79
+ if (typeof css_rule === 'string') {
80
+ if (css_rule.toUpperCase() in Wrappers) {
81
+ result = Wrappers[css_rule.toUpperCase()];
82
+ } else if (id_matchers !== null && css_rule in id_matchers) {
83
+ result = id_matchers[css_rule];
84
+ } else if (class_matchers !== null && css_rule in class_matchers) {
85
+ result = class_matchers[css_rule];
86
+ }
87
+ } else {
88
+ result = RightJS([]);
89
+ RightJS([Wrappers, id_matchers || {}, class_matchers || {}]).each(function(hash) {
90
+ for (var key in hash) {
91
+ if (hash[key] === css_rule) {
92
+ result.push(key);
93
+ }
94
+ }
95
+ });
96
+
97
+ result = result.compact();
98
+
99
+ if (result.empty()) {
100
+ result = null;
101
+ }
102
+ }
103
+
104
+ return result;
105
+ },
106
+
107
+ /**
108
+ * Checks if the css-rule is registered
109
+ *
110
+ * @param String css_rule
111
+ * @return Boolean check result
112
+ */
113
+ has: function(css_rule) {
114
+ return Wrappers.get(css_rule) !== null;
115
+ },
116
+
117
+ /**
118
+ * Removes the dom-wrapper
119
+ *
120
+ * @param String css-rule or RightJS.Element class
121
+ * @return Element.Wrappers object
122
+ */
123
+ remove: function(css_rule) {
124
+ RightJS([Wrappers, id_matchers || {}, class_matchers || {}]).each(function(object) {
125
+ for (var key in object) {
126
+ if (css_rule === key.toLowerCase() || object[key] === css_rule) {
127
+ delete(object[key]);
128
+ }
129
+ }
130
+ });
131
+
132
+ return Wrappers;
133
+ }
134
+ });
135
+
136
+
137
+ /**
138
+ * Replacing the original casting method
139
+ * with a new one that supporst all the other types of casting
140
+ *
141
+ * @param HTMLElement raw dom-element
142
+ * @return Function wrapper class or undefined
143
+ */
144
+ RightJS.Wrapper.Cast = function(element) {
145
+ var key, tag = element.tagName;
146
+
147
+ if (id_matchers !== null && element.id) {
148
+ key = tag.toLowerCase() + '#'+ element.id;
149
+ if (key in id_matchers) {
150
+ return id_matchers[key];
151
+ }
152
+
153
+ key = '#'+ element.id;
154
+ if (key in id_matchers) {
155
+ return id_matchers[key];
156
+ }
157
+ }
158
+
159
+ if (class_matchers !== null && element.className) {
160
+ var classes = element.className.split(/\s+/), i=0,
161
+ l_tag = tag.toLowerCase();
162
+
163
+ for (; i < classes.length; i++) {
164
+ key = l_tag + "." + classes[i];
165
+ if (key in class_matchers) {
166
+ return class_matchers[key];
167
+ }
168
+
169
+ key = "." + classes[i];
170
+ if (key in class_matchers) {
171
+ return class_matchers[key];
172
+ }
173
+ }
174
+ }
175
+
176
+ if (tag in Wrappers) {
177
+ return Wrappers[tag];
178
+ }
179
+
180
+ return undefined;
181
+ };
182
+
183
+ })(RightJS);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Dynamic Elements Casting v2.2.0
3
+ * http://rightjs.org/plugins/casting
4
+ *
5
+ * Copyright (C) 2010-2011 Nikolay Nemshilov
6
+ */
7
+ (function(a){a.Casting={version:"2.2.0"};var b=null,c=null,d=a.Element.Wrappers;a.$ext(d,{set:function(a,e){var f=a.match(/^[a-z]+$/i);if(f)d[a.toUpperCase()]=e;else if(f=a.match(/^([a-z]*)\#[a-z0-9_\-]+$/i))b===null&&(b={}),b[a]=e;else if(f=a.match(/^([a-z]*)\.[a-z0-9_\-]+$/i))c===null&&(c={}),c[a]=e;return e},get:function(e){var f=null;typeof e==="string"?e.toUpperCase()in d?f=d[e.toUpperCase()]:b!==null&&e in b?f=b[e]:c!==null&&e in c&&(f=c[e]):(f=a([]),a([d,b||{},c||{}]).each(function(a){for(var b in a)a[b]===e&&f.push(b)}),f=f.compact(),f.empty()&&(f=null));return f},has:function(a){return d.get(a)!==null},remove:function(e){a([d,b||{},c||{}]).each(function(a){for(var b in a)(e===b.toLowerCase()||a[b]===e)&&delete a[b]});return d}}),a.Wrapper.Cast=function(a){var e,f=a.tagName;if(b!==null&&a.id){e=f.toLowerCase()+"#"+a.id;if(e in b)return b[e];e="#"+a.id;if(e in b)return b[e]}if(c!==null&&a.className){var g=a.className.split(/\s+/),h=0,i=f.toLowerCase();for(;h<g.length;h++){e=i+"."+g[h];if(e in c)return c[e];e="."+g[h];if(e in c)return c[e]}}if(f in d)return d[f];return undefined}})(RightJS)
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
98
98
  var Klass = new RightJS.Class(AbstractWidget, methods);
99
99
 
100
100
  // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
101
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
102
 
103
103
  return Klass;
104
104
  }
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * Copyright (C) 2010-2011 Nikolay Nemshilov
6
6
  */
7
- var Colorpicker=RightJS.Colorpicker=function(a,b,c,d){function i(a,b,e){var f=this.reAnchor||(this.reAnchor=new d.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=c(a.getStyle("borderTopWidth")),k=c(a.getStyle("borderLeftWidth")),l=c(a.getStyle("borderRightWidth")),m=c(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),b==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(b==="left"||b==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function h(a,b,c,e){d.Fx&&(c===undefined&&(c=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:d(a.fire).bind(a,b)},b==="hide"&&(e.duration=(d.Fx.Durations[e.duration]||e.duration)/2)))),(!d.Fx||!c)&&a.fire(b);return a.$super(c,e)}function e(a,b){b||(b=a,a="DIV");var c=new d.Class(d.Element.Wrappers[a]||d.Element,{initialize:function(b,c){this.key=b;var e=[{"class":"rui-"+b}];this instanceof d.Input||this instanceof d.Form||e.unshift(a),this.$super.apply(this,e),d.isString(c)&&(c=d.$(c)),c instanceof d.Element&&(this._=c._,"$listeners"in c&&(c.$listeners=c.$listeners),c={}),this.setOptions(c,this);return d.Wrapper.Cache[d.$uid(this._)]=this},setOptions:function(a,b){b&&(a=d.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&d.Options.setOptions.call(this,d.Object.merge(this.options,a));return this}}),e=new d.Class(c,b);d.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var f=new d.Class(d.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),g={show:function(a,b){this.constructor.current=this;return h(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return h(this,"show",a,b)},showAt:function(a,b,c){this.hide(null).shownAt=a=d.$(a),i.call(this,a,b,c);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},j={assignTo:function(a,b){a=d.$(a),b=d.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var c=d(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:c,change:c}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=d,l=d.$,m=d.$w,n=d.$$,o=d.$E,p=d.$A,q=d.isArray,r=d.Class,s=d.Element,t=d.Input,u=new e({include:[g,j],extend:{version:"2.2.0",EVENTS:m("change show hide done"),Options:{format:"hex",update:null,updateBg:null,trigger:null,fxName:"fade",fxDuration:"short",cssRule:"*[data-colorpicker]"},i18n:{Done:"Done"},hideAll:function(){n("div.rui-colorpicker").each(function(a){a instanceof u&&!a.inlined()&&a.hide()})}},initialize:function(a){this.$super("colorpicker",a).addClass("rui-panel").insert([this.field=new v,this.colors=new w,this.controls=new x]).on({mousedown:this.startTrack,keyup:this.recalc,blur:this.update,focus:this.cancelTimer,done:this.done}),this.options.update&&this.assignTo(this.options.update,this.options.trigger),this.options.updateBg&&this.updateBg(this.options.updateBg),this.tint=k([1,0,0]),this.satur=0,this.bright=1,this.color=k([255,255,255]),this.recalc().update()},setValue:function(a){var b=q(a)?a:this.toColor(a);b&&b.length===3&&(b=b.map(function(a){return this.bound(c(""+a),0,255)},this),this.color=b,this.color2tint().update(),this.colors.size().y||this.update.bind(this).delay(20));return this},getValue:function(a){return a?this.color:this[this.options.format==="rgb"?"toRgb":"toHex"]()},updateBg:function(a){var b=l(a);b&&this.onChange(k(function(a){b._.style.backgroundColor=this.toRgb()}).bind(this));return this},insertTo:function(a,b){return this.$super(a,b).addClass("rui-colorpicker-inline")},inlined:function(){return this.hasClass("rui-colorpicker-inline")},done:function(){this.inlined()||this.hide();return this},setOptions:function(a){a=a||{},this.$super(a,l(a.trigger||a.update))},update:function(){this.field._.style.backgroundColor="rgb("+this.tint.map(function(a){return b.round(a*255)})+")";var a=this.color,c=this.controls;c.preview._.style.backgroundColor=c.display._.value=this.toHex(),c.rDisplay._.value=a[0],c.gDisplay._.value=a[1],c.bDisplay._.value=a[2];var d=this.field.pointer._.style,e=this.field.size(),f=e.y-this.bright*e.y-2,g=this.satur*e.x-2;d.top=this.bound(f,0,e.y-5)+"px",d.left=this.bound(g,0,e.x-5)+"px";var h=this.tint,i;e=this.colors.size(),h[1]==0?i=h[0]==1?h[2]:2-h[0]:h[0]==0?i=2+(h[2]==1?h[1]:2-h[2]):i=4+(h[1]==1?h[0]:2-h[1]),i=i/6*e.y,this.colors.pointer._.style.top=this.bound(i,0,e.y-4)+"px",this.prevColor!==""+this.color&&(this.fire("change",{value:this.color}),this.prevColor=""+this.color);return this},recalc:function(a){if(a){var b=a.target,c=b._.value,d=p(this.color),e=!1;b===this.controls.display&&/#\w{6}/.test(c)?e=d=this.toColor(c):/^\d+$/.test(c)&&(d[b._.cIndex]=c,e=!0),e&&this.setValue(d)}else this.tint2color();return this},startTrack:function(a){this.stopTrack(),this.cancelTimer(),a.target===this.field.pointer?a.target=this.field:a.target===this.colors.pointer&&(a.target=this.colors);if(a.target===this.field||a.target===this.colors)a.stop(),u.tracking=this,a.target.tracking=!0,this.trackMove(a)},stopTrack:function(){u.tracking=!1,this.field.tracking=!1,this.colors.tracking=!1},trackMove:function(a){var b,c=a.position(),d,e;this.field.tracking?b=this.field.dimensions():this.colors.tracking&&(b=this.colors.dimensions());if(b){d=this.bound(c.y-b.top,0,b.height),e=this.bound(c.x-b.left,0,b.width);if(this.field.tracking)this.satur=e/b.width,this.bright=1-d/b.height;else if(this.colors.tracking){d==b.height&&(d=b.height-.1);var f=b.height/6,g=this.tint=[0,0,0],h=d%f/f,i=1-h;d<f?(g[0]=1,g[2]=h):d<f*2?(g[0]=i,g[2]=1):d<f*3?(g[2]=1,g[1]=h):d<f*4?(g[2]=i,g[1]=1):d<f*5?(g[1]=1,g[0]=h):(g[1]=i,g[0]=1)}this.recalc().update()}},cancelTimer:function(a){k(function(){this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}).bind(this).delay(10)}}),v=new r(s,{initialize:function(a){this.$super("div",{"class":"field"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),w=new r(s,{initialize:function(){this.$super("div",{"class":"colors"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),x=new r(s,{initialize:function(){this.$super("div",{"class":"controls"}),this.insert([this.preview=o("div",{"class":"preview",html:"&nbsp;"}),this.display=o("input",{type:"text","class":"display",maxlength:7}),o("div",{"class":"rgb-display"}).insert([o("div").insert([o("label",{html:"R:"}),this.rDisplay=o("input",{maxlength:3,cIndex:0})]),o("div").insert([o("label",{html:"G:"}),this.gDisplay=o("input",{maxlength:3,cIndex:1})]),o("div").insert([o("label",{html:"B:"}),this.bDisplay=o("input",{maxlength:3,cIndex:2})])]),this.button=(new f(u.i18n.Done)).onClick("fire","done")])}});u.include({toRgb:function(a){return"rgb("+this.color.join(",")+")"},toHex:function(a){return"#"+this.color.map(function(a){return(a<16?"0":"")+a.toString(16)}).join("")},toColor:function(a){var b=a.toLowerCase(),d;if(d=/rgb\((\d+),(\d+),(\d+)\)/.exec(b))return[d[1],d[2],d[3]].map(c);if(/#[\da-f]+/.test(b)){if(d=/^#([\da-f])([\da-f])([\da-f])$/.exec(b))b="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3];if(d=/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(b))return[d[1],d[2],d[3]].map(function(a){return c(a,16)})}},color2tint:function(){var a=p(this.color).sort(function(a,b){return a-b}),b=a[0],c=a[2];this.bright=c/255,this.satur=1-b/(c||1),this.tint.each(function(a,d){this.tint[d]=!b&&!c||b==c?d==0?1:0:(this.color[d]-b)/(c-b);return this.tint[d]},this);return this},tint2color:function(){var a=this.tint,c=this.color;for(var d=0;d<3;d++)c[d]=1+this.satur*(a[d]-1),c[d]=b.round(255*c[d]*this.bright);return this},bound:function(a,b,c){var d=a;b<c?d=d<b?b:d>c?c:d:(d>c&&(d=c),d<b&&(d=b));return d}}),l(a).on({mouseup:function(){u.tracking&&u.tracking.stopTrack()},mousemove:function(a){u.tracking&&u.tracking.trackMove(a)},focus:function(a){var b=a.target instanceof t?a.target:null;u.hideAll(),b&&(b.colorpicker||b.match(u.Options.cssRule))&&(b.colorpicker||new u({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.colorpicker;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof s?a.target:null;b&&(b.colorpicker||b.match(u.Options.cssRule))?b instanceof t||(a.stop(),(b.colorpicker||new u({trigger:b})).hide(null).toggleAt(b.assignedInput)):a.find("div.rui-colorpicker")||u.hideAll()},keydown:function(a){var b=u.current,c=({27:"hide",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),b[c]())}});var y=a.createElement("style"),z=a.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default}div.rui-colorpicker .field,div.rui-colorpicker .field *,div.rui-colorpicker .colors,div.rui-colorpicker .colors *{border:none;background:none;width:auto;height:auto;position:static;float:none;top:none;left:none;right:none;bottom:none;margin:0;padding:0;display:block;font-weight:normal;vertical-align:center}div.rui-colorpicker div.field,div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors,div.rui-colorpicker div.colors div.pointer{background:url(/images/rightjs-ui/colorpicker.png) no-repeat 0 0}div.rui-colorpicker div.field,div.rui-colorpicker div.colors,div.rui-colorpicker div.controls{display:inline-block; *display:inline; *zoom:1;position:relative;vertical-align:top;height:150px}div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors div.pointer{position:absolute;top:0px;left:0;width:9px;height:9px}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display,div.rui-colorpicker input.rui-ui-button{font-size:100%;display:block;width:auto;padding:0 .2em}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display input,div.rui-colorpicker input.rui-ui-button{border:1px solid #AAA;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-colorpicker div.field{width:150px;background-color:red;cursor:crosshair;margin-right:1.2em}div.rui-colorpicker div.field div.pointer{background-position:-170px 0;margin-left:-2px;margin-top:-2px}div.rui-colorpicker div.colors{width:16px;background-position:-150px 0;border-color:#EEE;cursor:pointer;margin-right:.6em}div.rui-colorpicker div.colors div.pointer{cursor:default;background-position:-170px -20px;margin-left:-8px;margin-top:-3px}div.rui-colorpicker div.controls{width:5em}div.rui-colorpicker div.preview{height:2em;background:white;border-color:#BBB}div.rui-colorpicker input.display{margin-top:.5em;background:#FFF;width:4.5em}div.rui-colorpicker div.rgb-display{padding:0;text-align:right;margin-top:.5em}div.rui-colorpicker div.rgb-display label{display:inline}div.rui-colorpicker div.rgb-display label:after{content:none}div.rui-colorpicker div.rgb-display input{vertical-align:top;font-size:100%;width:2em;text-align:right;margin-left:.2em;padding:0 .2em;background:#FFF;margin-bottom:1px;display:inline}div.rui-colorpicker div.rui-button{cursor:pointer;position:absolute;bottom:0;right:0;width:4em}div.rui-colorpicker-inline{display:inline-block; *display:inline; *zoom:1;position:relative;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;z-index:auto}");y.type="text/css",a.getElementsByTagName("head")[0].appendChild(y),y.styleSheet?y.styleSheet.cssText=z.nodeValue:y.appendChild(z);return u}(document,Math,parseInt,RightJS)
7
+ var Colorpicker=RightJS.Colorpicker=function(a,b,c,d){function i(a,b,e){var f=this.reAnchor||(this.reAnchor=new d.Element("div",{"class":"rui-re-anchor"})).insert(this),g=f.insertTo(a,"after").position(),h=a.dimensions(),i=this,j=c(a.getStyle("borderTopWidth")),k=c(a.getStyle("borderLeftWidth")),l=c(a.getStyle("borderRightWidth")),m=c(a.getStyle("borderBottomWidth")),n=h.top-g.y+j,o=h.left-g.x+k,p=h.width-k-l,q=h.height-j-m;i.setStyle("visibility:hidden").show(null),b==="right"?o+=p-i.size().x:n+=q,i.moveTo(o,n),e&&(b==="left"||b==="right"?i.setHeight(q):i.setWidth(p)),i.setStyle("visibility:visible").hide(null)}function h(a,b,c,e){d.Fx&&(c===undefined&&(c=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:d(a.fire).bind(a,b)},b==="hide"&&(e.duration=(d.Fx.Durations[e.duration]||e.duration)/2)))),(!d.Fx||!c)&&a.fire(b);return a.$super(c,e)}function e(a,b){b||(b=a,a="DIV");var c=new d.Class(d.Element.Wrappers[a]||d.Element,{initialize:function(b,c){this.key=b;var e=[{"class":"rui-"+b}];this instanceof d.Input||this instanceof d.Form||e.unshift(a),this.$super.apply(this,e),d.isString(c)&&(c=d.$(c)),c instanceof d.Element&&(this._=c._,"$listeners"in c&&(c.$listeners=c.$listeners),c={}),this.setOptions(c,this);return d.Wrapper.Cache[d.$uid(this._)]=this},setOptions:function(a,b){b&&(a=d.Object.merge(a,(new Function("return "+(b.get("data-"+this.key)||"{}")))())),a&&d.Options.setOptions.call(this,d.Object.merge(this.options,a));return this}}),e=new d.Class(c,b);d.Observer.createShortcuts(e.prototype,e.EVENTS||d([]));return e}var f=new d.Class(d.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),g={show:function(a,b){this.constructor.current=this;return h(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return h(this,"show",a,b)},showAt:function(a,b,c){this.hide(null).shownAt=a=d.$(a),i.call(this,a,b,c);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},j={assignTo:function(a,b){a=d.$(a),b=d.$(b),b?(b[this.key]=this,b.assignedInput=a):a[this.key]=this;var c=d(function(){this.visible()&&(!this.showAt||this.shownAt===a)&&this.setValue(a.value())}).bind(this);a.on({keyup:c,change:c}),this.onChange(function(){(!this.showAt||this.shownAt===a)&&a.setValue(this.getValue())});return this}},k=d,l=d.$,m=d.$w,n=d.$$,o=d.$E,p=d.$A,q=d.isArray,r=d.Class,s=d.Element,t=d.Input,u=new e({include:[g,j],extend:{version:"2.2.0",EVENTS:m("change show hide done"),Options:{format:"hex",update:null,updateBg:null,trigger:null,fxName:"fade",fxDuration:"short",cssRule:"*[data-colorpicker]"},i18n:{Done:"Done"},hideAll:function(){n("div.rui-colorpicker").each(function(a){a instanceof u&&!a.inlined()&&a.hide()})}},initialize:function(a){this.$super("colorpicker",a).addClass("rui-panel").insert([this.field=new v,this.colors=new w,this.controls=new x]).on({mousedown:this.startTrack,keyup:this.recalc,blur:this.update,focus:this.cancelTimer,done:this.done}),this.options.update&&this.assignTo(this.options.update,this.options.trigger),this.options.updateBg&&this.updateBg(this.options.updateBg),this.tint=k([1,0,0]),this.satur=0,this.bright=1,this.color=k([255,255,255]),this.recalc().update()},setValue:function(a){var b=q(a)?a:this.toColor(a);b&&b.length===3&&(b=b.map(function(a){return this.bound(c(""+a),0,255)},this),this.color=b,this.color2tint().update(),this.colors.size().y||this.update.bind(this).delay(20));return this},getValue:function(a){return a?this.color:this[this.options.format==="rgb"?"toRgb":"toHex"]()},updateBg:function(a){var b=l(a);b&&this.onChange(k(function(a){b._.style.backgroundColor=this.toRgb()}).bind(this));return this},insertTo:function(a,b){return this.$super(a,b).addClass("rui-colorpicker-inline")},inlined:function(){return this.hasClass("rui-colorpicker-inline")},done:function(){this.inlined()||this.hide();return this},setOptions:function(a){a=a||{},this.$super(a,l(a.trigger||a.update))},update:function(){this.field._.style.backgroundColor="rgb("+this.tint.map(function(a){return b.round(a*255)})+")";var a=this.color,c=this.controls;c.preview._.style.backgroundColor=c.display._.value=this.toHex(),c.rDisplay._.value=a[0],c.gDisplay._.value=a[1],c.bDisplay._.value=a[2];var d=this.field.pointer._.style,e=this.field.size(),f=e.y-this.bright*e.y-2,g=this.satur*e.x-2;d.top=this.bound(f,0,e.y-5)+"px",d.left=this.bound(g,0,e.x-5)+"px";var h=this.tint,i;e=this.colors.size(),h[1]==0?i=h[0]==1?h[2]:2-h[0]:h[0]==0?i=2+(h[2]==1?h[1]:2-h[2]):i=4+(h[1]==1?h[0]:2-h[1]),i=i/6*e.y,this.colors.pointer._.style.top=this.bound(i,0,e.y-4)+"px",this.prevColor!==""+this.color&&(this.fire("change",{value:this.color}),this.prevColor=""+this.color);return this},recalc:function(a){if(a){var b=a.target,c=b._.value,d=p(this.color),e=!1;b===this.controls.display&&/#\w{6}/.test(c)?e=d=this.toColor(c):/^\d+$/.test(c)&&(d[b._.cIndex]=c,e=!0),e&&this.setValue(d)}else this.tint2color();return this},startTrack:function(a){this.stopTrack(),this.cancelTimer(),a.target===this.field.pointer?a.target=this.field:a.target===this.colors.pointer&&(a.target=this.colors);if(a.target===this.field||a.target===this.colors)a.stop(),u.tracking=this,a.target.tracking=!0,this.trackMove(a)},stopTrack:function(){u.tracking=!1,this.field.tracking=!1,this.colors.tracking=!1},trackMove:function(a){var b,c=a.position(),d,e;this.field.tracking?b=this.field.dimensions():this.colors.tracking&&(b=this.colors.dimensions());if(b){d=this.bound(c.y-b.top,0,b.height),e=this.bound(c.x-b.left,0,b.width);if(this.field.tracking)this.satur=e/b.width,this.bright=1-d/b.height;else if(this.colors.tracking){d==b.height&&(d=b.height-.1);var f=b.height/6,g=this.tint=[0,0,0],h=d%f/f,i=1-h;d<f?(g[0]=1,g[2]=h):d<f*2?(g[0]=i,g[2]=1):d<f*3?(g[2]=1,g[1]=h):d<f*4?(g[2]=i,g[1]=1):d<f*5?(g[1]=1,g[0]=h):(g[1]=i,g[0]=1)}this.recalc().update()}},cancelTimer:function(a){k(function(){this._hide_delay&&(this._hide_delay.cancel(),this._hide_delay=null)}).bind(this).delay(10)}}),v=new r(s,{initialize:function(a){this.$super("div",{"class":"field"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),w=new r(s,{initialize:function(){this.$super("div",{"class":"colors"}),this.insert(this.pointer=o("div",{"class":"pointer"}))}}),x=new r(s,{initialize:function(){this.$super("div",{"class":"controls"}),this.insert([this.preview=o("div",{"class":"preview",html:"&nbsp;"}),this.display=o("input",{type:"text","class":"display",maxlength:7}),o("div",{"class":"rgb-display"}).insert([o("div").insert([o("label",{html:"R:"}),this.rDisplay=o("input",{maxlength:3,cIndex:0})]),o("div").insert([o("label",{html:"G:"}),this.gDisplay=o("input",{maxlength:3,cIndex:1})]),o("div").insert([o("label",{html:"B:"}),this.bDisplay=o("input",{maxlength:3,cIndex:2})])]),this.button=(new f(u.i18n.Done)).onClick("fire","done")])}});u.include({toRgb:function(a){return"rgb("+this.color.join(",")+")"},toHex:function(a){return"#"+this.color.map(function(a){return(a<16?"0":"")+a.toString(16)}).join("")},toColor:function(a){var b=a.toLowerCase(),d;if(d=/rgb\((\d+),(\d+),(\d+)\)/.exec(b))return[d[1],d[2],d[3]].map(c);if(/#[\da-f]+/.test(b)){if(d=/^#([\da-f])([\da-f])([\da-f])$/.exec(b))b="#"+d[1]+d[1]+d[2]+d[2]+d[3]+d[3];if(d=/#([\da-f]{2})([\da-f]{2})([\da-f]{2})/.exec(b))return[d[1],d[2],d[3]].map(function(a){return c(a,16)})}},color2tint:function(){var a=p(this.color).sort(function(a,b){return a-b}),b=a[0],c=a[2];this.bright=c/255,this.satur=1-b/(c||1),this.tint.each(function(a,d){this.tint[d]=!b&&!c||b==c?d==0?1:0:(this.color[d]-b)/(c-b);return this.tint[d]},this);return this},tint2color:function(){var a=this.tint,c=this.color;for(var d=0;d<3;d++)c[d]=1+this.satur*(a[d]-1),c[d]=b.round(255*c[d]*this.bright);return this},bound:function(a,b,c){var d=a;b<c?d=d<b?b:d>c?c:d:(d>c&&(d=c),d<b&&(d=b));return d}}),l(a).on({mouseup:function(){u.tracking&&u.tracking.stopTrack()},mousemove:function(a){u.tracking&&u.tracking.trackMove(a)},focus:function(a){var b=a.target instanceof t?a.target:null;u.hideAll(),b&&(b.colorpicker||b.match(u.Options.cssRule))&&(b.colorpicker||new u({update:b})).setValue(b.value()).showAt(b)},blur:function(a){var b=a.target,c=b.colorpicker;c&&(c._hide_delay=k(function(){c.hide()}).delay(200))},click:function(a){var b=a.target instanceof s?a.target:null;b&&(b.colorpicker||b.match(u.Options.cssRule))?b instanceof t||(a.stop(),(b.colorpicker||new u({trigger:b})).hide(null).toggleAt(b.assignedInput)):a.find("div.rui-colorpicker")||u.hideAll()},keydown:function(a){var b=u.current,c=({27:"hide",13:"done"})[a.keyCode];c&&b&&b.visible()&&(a.stop(),b[c]())}});var y=a.createElement("style"),z=a.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-panel{margin:0;padding:.5em;position:relative;background-color:#EEE;border:1px solid #BBB;border-radius:.3em;-moz-border-radius:.3em;-webkit-border-radius:.3em;box-shadow:.15em .3em .5em #BBB;-moz-box-shadow:.15em .3em .5em #BBB;-webkit-box-shadow:.15em .3em .5em #BBB;cursor:default}div.rui-colorpicker .field,div.rui-colorpicker .field *,div.rui-colorpicker .colors,div.rui-colorpicker .colors *{border:none;background:none;width:auto;height:auto;position:static;float:none;top:none;left:none;right:none;bottom:none;margin:0;padding:0;display:block;font-weight:normal;vertical-align:center}div.rui-colorpicker div.field,div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors,div.rui-colorpicker div.colors div.pointer{background:url(/images/rightjs-ui/colorpicker.png) no-repeat 0 0}div.rui-colorpicker div.field,div.rui-colorpicker div.colors,div.rui-colorpicker div.controls{display:inline-block; *display:inline; *zoom:1;position:relative;vertical-align:top;height:150px}div.rui-colorpicker div.field div.pointer,div.rui-colorpicker div.colors div.pointer{position:absolute;top:0px;left:0;width:9px;height:9px}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display,div.rui-colorpicker input.rui-ui-button{font-size:100%;display:block;width:auto;padding:0 .2em}div.rui-colorpicker input.display,div.rui-colorpicker div.preview,div.rui-colorpicker div.rgb-display input,div.rui-colorpicker input.rui-ui-button{border:1px solid #AAA;-moz-border-radius:.2em;-webkit-border-radius:.2em}div.rui-colorpicker div.field{width:150px;background-color:red;cursor:crosshair;margin-right:1.2em}div.rui-colorpicker div.field div.pointer{background-position:-170px 0;margin-left:-2px;margin-top:-2px}div.rui-colorpicker div.colors{width:16px;background-position:-150px 0;border-color:#EEE;cursor:pointer;margin-right:.6em}div.rui-colorpicker div.colors div.pointer{cursor:default;background-position:-170px -20px;margin-left:-8px;margin-top:-3px}div.rui-colorpicker div.controls{width:5em}div.rui-colorpicker div.preview{height:2em;background:white;border-color:#BBB}div.rui-colorpicker input.display{margin-top:.5em;background:#FFF;width:4.5em}div.rui-colorpicker div.rgb-display{padding:0;text-align:right;margin-top:.5em}div.rui-colorpicker div.rgb-display label{display:inline}div.rui-colorpicker div.rgb-display label:after{content:none}div.rui-colorpicker div.rgb-display input{vertical-align:top;font-size:100%;width:2em;text-align:right;margin-left:.2em;padding:0 .2em;background:#FFF;margin-bottom:1px;display:inline}div.rui-colorpicker div.rui-button{cursor:pointer;position:absolute;bottom:0;right:0;width:4em}div.rui-colorpicker-inline{display:inline-block; *display:inline; *zoom:1;position:relative;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none;z-index:auto}");y.type="text/css",a.getElementsByTagName("head")[0].appendChild(y),y.styleSheet?y.styleSheet.cssText=z.nodeValue:y.appendChild(z);return u}(document,Math,parseInt,RightJS)
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
98
98
  var Klass = new RightJS.Class(AbstractWidget, methods);
99
99
 
100
100
  // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
101
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
102
 
103
103
  return Klass;
104
104
  }
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * Copyright (C) 2010-2011 Nikolay Nemshilov
6
6
  */
7
- var Dialog=RightJS.Dialog=function(a){function b(b,c){c||(c=b,b="DIV");var d=new a.Class(a.Element.Wrappers[b]||a.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof a.Input||this instanceof a.Form||e.unshift(b),this.$super.apply(this,e),a.isString(d)&&(d=a.$(d)),d instanceof a.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return a.Wrapper.Cache[a.$uid(this._)]=this},setOptions:function(b,c){c&&(b=a.Object.merge(b,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),b&&a.Options.setOptions.call(this,a.Object.merge(this.options,b));return this}}),e=new a.Class(d,c);a.Observer.createShortcuts(e.prototype,e.EVENTS||[]);return e}var c=new a.Class(a.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),d=new a.Class(a.Element,{initialize:function(b){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(b||4);c++)this.dots.push(new a.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),a(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=a,f=a.$,g=a.$w,h=a.$E,i=a.Class,j=a.Object,k=a.Element,l=new b({extend:{version:"2.2.0",EVENTS:g("ok cancel help expand collapse resize load"),Options:{lockScreen:!0,fxDuration:"short",draggable:!0,closeable:!0,expandable:!1,showHelp:!1,showIcon:null,title:null,html:null,url:null},i18n:{Ok:"Ok",Close:"Close",Cancel:"Cancel",Help:"Help",Expand:"Expand",Collapse:"Collapse",Alert:"Warning!",Confirm:"Confirm",Prompt:"Enter"},current:!1,dragged:!1},initialize:function(a){this.$super("dialog",a).append(this.head=new l.Head(this),this.body=new l.Body(this),this.foot=new l.Foot(this)).onCancel(this.hide),this.locker=h("div",{"class":"rui-screen-locker"}),this.options.title&&this.title(this.options.title),this.options.html&&this.html(this.options.html),this.options.url&&this.load(this.options.url)},show:function(){this.options.lockScreen&&this.locker.insertTo(document.body),this.setStyle("visibility:hidden").insertTo(document.body).resize().setStyle("visibility:visible;opacity:0"),this.options.fxDuration?this.morph({opacity:1},{duration:this.options.fxDuration}):this.setStyle("opacity:1");return l.current=this},hide:function(){this.locker.remove(),this.remove(),l.current=!1;return this},resize:function(){arguments.length&&this.$super.apply(this,arguments);var a=this.size(),b=f(window).size();this.expanded&&(a.x=b.x-20,a.y=b.y-10,this.$super.call(this,a)),this.setStyle({top:(b.y-a.y)/2+f(window).scrolls().y+"px",left:(b.x-a.x-16)/2+"px"});return this.fire("resize")},title:function(a){if(arguments.length){this.head.title.html(a);return this}return this.head.title.html()},update:function(a){this.body.update(a);return this.resize()},html:function(){return arguments.length?this.$super.apply(this,arguments):this.body.html()},load:function(a,b){this.show(),this.body.load(a,b);return this},expand:function(){this.expanded||(this._prevSize=this.size(),this.resize({x:f(window).size().x-20,y:f(window).size().y-10}),this.expanded=!0,this.fire("expand"));return this},collapse:function(){this.expanded&&(this.expanded=!1,this.resize(this._prevSize),this.fire("collapse"));return this}});l.Head=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-head"}),this.append(this.icon=h("div",{"class":"icon"}),this.title=h("div",{"class":"title",html:"&nbsp;"}),this.tools=h("div",{"class":"tools"})),this.fsButton=h("div",{"class":"expand",html:"&equiv;",title:l.i18n.Expand}).onClick(function(){a.expanded?(a.collapse(),this.html("&equiv;").set("title",l.i18n.Expand)):(a.expand(),this.html("_").set("title",l.i18n.Collapse))}),this.closeButton=h("div",{"class":"close",html:"&times;",title:l.i18n.Close}).onClick(function(){a.fire("cancel")}),this.options.expandable&&this.tools.insert(this.fsButton),this.options.closeable&&this.tools.insert(this.closeButton),this.on({selectstart:function(a){a.stop()},mousedown:this.dragStart}),this.options.draggable||this.dialog.addClass("rui-dialog-nodrag")},dragStart:function(a){if(this.options.draggable&&!a.find("div.tools div")){var b=this.dialog.dimensions(),c=a.position();this.xDiff=b.left-c.x,this.yDiff=b.top-c.y,this.maxX=f(window).size().x-b.width-20,this.dlgStyle=this.dialog.get("style"),l.dragged=this.dialog,a.stop()}},dragMove:function(a){var b=a.position(),c=b.x+this.xDiff,d=b.y+this.yDiff;c<0?c=0:c>this.maxX&&(c=this.maxX),d<0&&(d=0),this.dlgStyle.top=d+"px",this.dlgStyle.left=c+"px"},dragStop:function(a){l.dragged=!1}}),l.Body=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-body"}),this.locker=h("div",{"class":"rui-dialog-body-locker"}).insert(new d)},load:function(a,b){this.insert(this.locker,"top"),this.xhr=(new Xhr(a,j.merge({method:"get"},b))).onComplete(e(function(a){this.update(a.text),this.dialog.resize().fire("load")}).bind(this)).send();return this},update:function(a){this.$super(a),this.options.showIcon&&this.insert('<div class="rui-dialog-body-icon">'+this.options.showIcon+"</div>","top");return this}}),l.Foot=new i(k,{initialize:function(a){this.$super("div",{"class":"rui-dialog-foot"}),this.dialog=a,a.okButton=(new c(l.i18n.Ok,{"class":"ok"})).onClick(function(){a.fire("ok")}),a.helpButton=(new c(l.i18n.Help,{"class":"help"})).onClick(function(){a.fire("help")}),a.cancelButton=(new c(l.i18n.Cancel,{"class":"cancel"})).onClick(function(){a.fire("cancel")}),a.options.showHelp&&this.insert(a.helpButton),a.options.closeable&&this.insert(a.cancelButton),this.insert(a.okButton)}}),l.Alert=new i(l,{initialize:function(a){a=j.merge({showIcon:"!",title:l.i18n.Alert},a),this.$super(a),this.addClass("rui-dialog-alert"),this.on("ok","hide")}}),l.Confirm=new i(l,{initialize:function(a){a=j.merge({showIcon:"?",title:l.i18n.Confirm},a),this.$super(a),this.addClass("rui-dialog-confirm"),this.on("ok","hide")}}),l.Prompt=new i(l,{initialize:function(b){b=j.merge({showIcon:"&#x27A5;",title:l.i18n.Prompt,label:l.i18n.Prompt},b),this.$super(b),this.addClass("rui-dialog-prompt"),this.html([h("label",{html:this.options.label}),this.input=new a.Input(this.options.input||{})]),this.input.get("type")!=="textarea"&&this.input.onKeydown(e(function(a){a.keyCode===13&&this.fire("ok")}).bind(this))},show:function(){this.$super.apply(this,arguments),this.input.select();return this}}),f(document).on({keydown:function(a){a.keyCode===27&&l.current?l.current.options.closeable&&l.current.fire("cancel"):a.keyCode===13&&l.current&&(l.current instanceof l.Prompt||(a.stop(),l.current.fire("ok")))},mousemove:function(a){l.dragged&&l.dragged.head.dragMove(a)},mouseup:function(a){l.dragged&&l.dragged.head.dragStop(a)}}),f(window).onResize(function(){l.current&&l.current.resize()});var m=document.createElement("style"),n=document.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}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-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}");m.type="text/css",document.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(RightJS)
7
+ var Dialog=RightJS.Dialog=function(a){function b(b,c){c||(c=b,b="DIV");var d=new a.Class(a.Element.Wrappers[b]||a.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof a.Input||this instanceof a.Form||e.unshift(b),this.$super.apply(this,e),a.isString(d)&&(d=a.$(d)),d instanceof a.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return a.Wrapper.Cache[a.$uid(this._)]=this},setOptions:function(b,c){c&&(b=a.Object.merge(b,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),b&&a.Options.setOptions.call(this,a.Object.merge(this.options,b));return this}}),e=new a.Class(d,c);a.Observer.createShortcuts(e.prototype,e.EVENTS||a([]));return e}var c=new a.Class(a.Element,{initialize:function(a,b){this.$super("div",b),this._.innerHTML=a,this.addClass("rui-button"),this.on("selectstart","stopEvent")},disable:function(){return this.addClass("rui-button-disabled")},enable:function(){return this.removeClass("rui-button-disabled")},disabled:function(){return this.hasClass("rui-button-disabled")},enabled:function(){return!this.disabled()},fire:function(){this.enabled()&&this.$super.apply(this,arguments);return this}}),d=new a.Class(a.Element,{initialize:function(b){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(b||4);c++)this.dots.push(new a.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),a(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=a,f=a.$,g=a.$w,h=a.$E,i=a.Class,j=a.Object,k=a.Element,l=new b({extend:{version:"2.2.0",EVENTS:g("ok cancel help expand collapse resize load"),Options:{lockScreen:!0,fxDuration:"short",draggable:!0,closeable:!0,expandable:!1,showHelp:!1,showIcon:null,title:null,html:null,url:null},i18n:{Ok:"Ok",Close:"Close",Cancel:"Cancel",Help:"Help",Expand:"Expand",Collapse:"Collapse",Alert:"Warning!",Confirm:"Confirm",Prompt:"Enter"},current:!1,dragged:!1},initialize:function(a){this.$super("dialog",a).append(this.head=new l.Head(this),this.body=new l.Body(this),this.foot=new l.Foot(this)).onCancel(this.hide),this.locker=h("div",{"class":"rui-screen-locker"}),this.options.title&&this.title(this.options.title),this.options.html&&this.html(this.options.html),this.options.url&&this.load(this.options.url)},show:function(){this.options.lockScreen&&this.locker.insertTo(document.body),this.setStyle("visibility:hidden").insertTo(document.body).resize().setStyle("visibility:visible;opacity:0"),this.options.fxDuration?this.morph({opacity:1},{duration:this.options.fxDuration}):this.setStyle("opacity:1");return l.current=this},hide:function(){this.locker.remove(),this.remove(),l.current=!1;return this},resize:function(){arguments.length&&this.$super.apply(this,arguments);var a=this.size(),b=f(window).size();this.expanded&&(a.x=b.x-20,a.y=b.y-10,this.$super.call(this,a)),this.setStyle({top:(b.y-a.y)/2+f(window).scrolls().y+"px",left:(b.x-a.x-16)/2+"px"});return this.fire("resize")},title:function(a){if(arguments.length){this.head.title.html(a);return this}return this.head.title.html()},update:function(a){this.body.update(a);return this.resize()},html:function(){return arguments.length?this.$super.apply(this,arguments):this.body.html()},load:function(a,b){this.show(),this.body.load(a,b);return this},expand:function(){this.expanded||(this._prevSize=this.size(),this.resize({x:f(window).size().x-20,y:f(window).size().y-10}),this.expanded=!0,this.fire("expand"));return this},collapse:function(){this.expanded&&(this.expanded=!1,this.resize(this._prevSize),this.fire("collapse"));return this}});l.Head=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-head"}),this.append(this.icon=h("div",{"class":"icon"}),this.title=h("div",{"class":"title",html:"&nbsp;"}),this.tools=h("div",{"class":"tools"})),this.fsButton=h("div",{"class":"expand",html:"&equiv;",title:l.i18n.Expand}).onClick(function(){a.expanded?(a.collapse(),this.html("&equiv;").set("title",l.i18n.Expand)):(a.expand(),this.html("_").set("title",l.i18n.Collapse))}),this.closeButton=h("div",{"class":"close",html:"&times;",title:l.i18n.Close}).onClick(function(){a.fire("cancel")}),this.options.expandable&&this.tools.insert(this.fsButton),this.options.closeable&&this.tools.insert(this.closeButton),this.on({selectstart:function(a){a.stop()},mousedown:this.dragStart}),this.options.draggable||this.dialog.addClass("rui-dialog-nodrag")},dragStart:function(a){if(this.options.draggable&&!a.find("div.tools div")){var b=this.dialog.dimensions(),c=a.position();this.xDiff=b.left-c.x,this.yDiff=b.top-c.y,this.maxX=f(window).size().x-b.width-20,this.dlgStyle=this.dialog.get("style"),l.dragged=this.dialog,a.stop()}},dragMove:function(a){var b=a.position(),c=b.x+this.xDiff,d=b.y+this.yDiff;c<0?c=0:c>this.maxX&&(c=this.maxX),d<0&&(d=0),this.dlgStyle.top=d+"px",this.dlgStyle.left=c+"px"},dragStop:function(a){l.dragged=!1}}),l.Body=new i(k,{initialize:function(a){this.dialog=a,this.options=a.options,this.$super("div",{"class":"rui-dialog-body"}),this.locker=h("div",{"class":"rui-dialog-body-locker"}).insert(new d)},load:function(a,b){this.insert(this.locker,"top"),this.xhr=(new Xhr(a,j.merge({method:"get"},b))).onComplete(e(function(a){this.update(a.text),this.dialog.resize().fire("load")}).bind(this)).send();return this},update:function(a){this.$super(a),this.options.showIcon&&this.insert('<div class="rui-dialog-body-icon">'+this.options.showIcon+"</div>","top");return this}}),l.Foot=new i(k,{initialize:function(a){this.$super("div",{"class":"rui-dialog-foot"}),this.dialog=a,a.okButton=(new c(l.i18n.Ok,{"class":"ok"})).onClick(function(){a.fire("ok")}),a.helpButton=(new c(l.i18n.Help,{"class":"help"})).onClick(function(){a.fire("help")}),a.cancelButton=(new c(l.i18n.Cancel,{"class":"cancel"})).onClick(function(){a.fire("cancel")}),a.options.showHelp&&this.insert(a.helpButton),a.options.closeable&&this.insert(a.cancelButton),this.insert(a.okButton)}}),l.Alert=new i(l,{initialize:function(a){a=j.merge({showIcon:"!",title:l.i18n.Alert},a),this.$super(a),this.addClass("rui-dialog-alert"),this.on("ok","hide")}}),l.Confirm=new i(l,{initialize:function(a){a=j.merge({showIcon:"?",title:l.i18n.Confirm},a),this.$super(a),this.addClass("rui-dialog-confirm"),this.on("ok","hide")}}),l.Prompt=new i(l,{initialize:function(b){b=j.merge({showIcon:"&#x27A5;",title:l.i18n.Prompt,label:l.i18n.Prompt},b),this.$super(b),this.addClass("rui-dialog-prompt"),this.html([h("label",{html:this.options.label}),this.input=new a.Input(this.options.input||{})]),this.input.get("type")!=="textarea"&&this.input.onKeydown(e(function(a){a.keyCode===13&&this.fire("ok")}).bind(this))},show:function(){this.$super.apply(this,arguments),this.input.select();return this}}),f(document).on({keydown:function(a){a.keyCode===27&&l.current?l.current.options.closeable&&l.current.fire("cancel"):a.keyCode===13&&l.current&&(l.current instanceof l.Prompt||(a.stop(),l.current.fire("ok")))},mousemove:function(a){l.dragged&&l.dragged.head.dragMove(a)},mouseup:function(a){l.dragged&&l.dragged.head.dragStop(a)}}),f(window).onResize(function(){l.current&&l.current.resize()});var m=document.createElement("style"),n=document.createTextNode("*.rui-button{display:inline-block; *display:inline; *zoom:1;height:1em;line-height:1em;margin:0;padding:.2em .5em;text-align:center;border:1px solid #CCC;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;cursor:pointer;color:#333;background-color:#FFF;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-button:hover{color:#111;border-color:#999;background-color:#DDD;box-shadow:#888 0 0 .1em;-moz-box-shadow:#888 0 0 .1em;-webkit-box-shadow:#888 0 0 .1em} *.rui-button:active{color:#000;border-color:#777;text-indent:1px;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none} *.rui-button-disabled, *.rui-button-disabled:hover, *.rui-button-disabled:active{color:#888;background:#DDD;border-color:#CCC;cursor:default;text-indent:0;box-shadow:none;-moz-box-shadow:none;-webkit-box-shadow:none}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-screen-locker{position:fixed;top:0;left:0;width:100%;height:100%;margin:0;padding:0;background:#000;opacity:.5;filter:alpha(opacity=50);z-index:99999;cursor:default}div.rui-dialog{position:absolute;z-index:99999;background:white;margin:0;padding:0;padding-top:2.5em;padding-bottom:2.8em;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border:1px solid #ccc}div.rui-dialog-body{min-width:20em;min-height:4.5em;margin:0;padding:0 1em;height:100%;overflow:auto;position:relative}div.rui-dialog-body-locker{position:absolute;z-index:9999;left:0;top:0;width:100%;height:100%;text-align:center;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-body-locker div.rui-spinner{border:none;background:none;font-size:150%;margin-top:8%}div.rui-dialog-body-icon{float:left;background:#eee;font-size:360%;font-family:Arial;border:2px solid gray;border-radius:.1em;-moz-border-radius:.1em;-webkit-border-radius:.1em;width:1em;line-height:1em;text-align:center;margin-right:.2em;margin-top:.05em;cursor:default;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head{position:absolute;top:0;left:0;margin:0;padding:0;width:100%;line-height:2em;background:#ccc;border-radius:.35em;-moz-border-radius:.35em;-webkit-border-radius:.35em;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;-webkit-border-bottom-left-radius:0;-webkit-border-bottom-right-radius:0;cursor:move;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-dialog-head div.icon{float:left;height:1.4em;width:1.4em;margin-left:1em;margin-top:.3em;margin-right:.3em;display:none}div.rui-dialog-head div.title{margin-left:1em;color:#444}div.rui-dialog-head div.tools{position:absolute;right:.3em;top:.3em}div.rui-dialog-head div.tools div{float:left;width:1.4em;line-height:1.4em;text-align:center;margin-left:.15em;cursor:pointer;background:#aaa;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;font-family:Verdana;opacity:.6;filter:alpha(opacity=60)}div.rui-dialog-head div.tools div:hover{opacity:1;filter:alpha(opacity=100);box-shadow:#444 0 0 .1em;-moz-box-shadow:#444 0 0 .1em;-webkit-box-shadow:#444 0 0 .1em}div.rui-dialog-head div.tools div.close:hover{background:#daa}div.rui-dialog-nodrag div.rui-dialog-head{cursor:default}div.rui-dialog-foot{position:absolute;bottom:0;left:0;width:100%;text-align:right}div.rui-dialog-foot div.rui-button{margin:.6em 1em;background:#eee;width:4em}div.rui-dialog-foot div.help{float:left}div.rui-dialog-foot div.cancel{margin-right:-.5em}div.rui-dialog-foot div.ok:hover{background-color:#ded}div.rui-dialog-foot div.cancel:hover{background-color:#ecc}div.rui-dialog-alert div.rui-dialog-foot{text-align:center}div.rui-dialog-alert div.rui-dialog-foot div.cancel{display:none}div.rui-dialog-alert div.rui-dialog-body-icon{color:brown;background:#FEE;border-color:brown}div.rui-dialog-confirm div.rui-dialog-body-icon{color:#44A;background:#EEF;border-color:#44a}div.rui-dialog-prompt div.rui-dialog-body-icon{color:#333}div.rui-dialog-prompt div.rui-dialog-body label{display:block;font-weight:bold;font-size:120%;color:#444;margin-bottom:.5em}div.rui-dialog-prompt div.rui-dialog-body input,div.rui-dialog-prompt div.rui-dialog-body textarea{border:1px solid #aaa;font-size:1em;display:block;width:16em;margin:0;padding:.2em;margin-left:4.7em;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;outline:none}div.rui-dialog-prompt div.rui-dialog-body textarea{width:24em;height:8em}");m.type="text/css",document.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(RightJS)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Drag'n'Drop module v2.2.0
2
+ * Drag'n'Drop module v2.2.2
3
3
  * http://rightjs.org/plugins/drag-n-drop
4
4
  *
5
5
  * Copyright (C) 2009-2011 Nikolay Nemshilov
@@ -28,7 +28,7 @@ var R = RightJS,
28
28
  */
29
29
  var Draggable = new Class(Observer, {
30
30
  extend: {
31
- version: '2.2.0',
31
+ version: '2.2.2',
32
32
 
33
33
  EVENTS: $w('before start drag stop drop'),
34
34
 
@@ -79,7 +79,10 @@ var Draggable = new Class(Observer, {
79
79
  this.element = $(element);
80
80
  this.$super(options);
81
81
 
82
- this.element.draggable = this.init();
82
+ this._dragStart = R(this.dragStart).bind(this);
83
+ this.handle.onMousedown(this._dragStart);
84
+
85
+ this.element.draggable = this;
83
86
  },
84
87
 
85
88
  /**
@@ -139,17 +142,10 @@ var Draggable = new Class(Observer, {
139
142
 
140
143
  // protected
141
144
 
142
- init: function() {
143
- // caching the callback so that we could detach it later
144
- this._dragStart = R(this.dragStart).bind(this);
145
-
146
- this.handle.onMousedown(this._dragStart);
147
-
148
- return this;
149
- },
150
-
151
145
  // handles the event start
152
146
  dragStart: function(event) {
147
+ if (this._drag) { return false; } else { this._drag = true; }
148
+
153
149
  this.fire('before', this, event.stop());
154
150
 
155
151
  // calculating the positions diff
@@ -158,14 +154,16 @@ var Draggable = new Class(Observer, {
158
154
  this.xDiff = event.pageX - position.x;
159
155
  this.yDiff = event.pageY - position.y;
160
156
 
161
- // grabbing the relative position diffs
162
- var relative_position = {
163
- y: R(this.element.getStyle('top')).toFloat(),
164
- x: R(this.element.getStyle('left')).toFloat()
165
- };
157
+ // grabbing the relative position diffs for nested spaces
158
+ this.rxDiff = this.ryDiff = 0;
159
+ this.element.parents().reverse().each(function(parent) {
160
+ if (parent.getStyle('position') !== 'static') {
161
+ parent = parent.position();
166
162
 
167
- this.rxDiff = isNaN(relative_position.x) ? 0 : (relative_position.x - position.x);
168
- this.ryDiff = isNaN(relative_position.y) ? 0 : (relative_position.y - position.y);
163
+ this.rxDiff = - parent.x;
164
+ this.ryDiff = - parent.y;
165
+ }
166
+ }, this);
169
167
 
170
168
  // preserving the element sizes
171
169
  var size = {
@@ -197,7 +195,6 @@ var Draggable = new Class(Observer, {
197
195
  this.element.insertTo(document.body);
198
196
  }
199
197
 
200
-
201
198
  // caching the window scrolls
202
199
  this.winScrolls = $(window).scrolls();
203
200
  this.winSizes = $(window).size();
@@ -266,6 +263,8 @@ var Draggable = new Class(Observer, {
266
263
 
267
264
  if (this.options.revert) {
268
265
  this.revert();
266
+ } else {
267
+ this._drag = false;
269
268
  }
270
269
 
271
270
  Draggable.current = null;
@@ -285,6 +284,7 @@ var Draggable = new Class(Observer, {
285
284
  })
286
285
  );
287
286
  }
287
+ this._drag = false;
288
288
  },
289
289
 
290
290
  // calculates the constraints
@@ -1,7 +1,7 @@
1
1
  /**
2
- * Drag'n'Drop module v2.2.0
2
+ * Drag'n'Drop module v2.2.2
3
3
  * http://rightjs.org/plugins/drag-n-drop
4
4
  *
5
5
  * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- (function(a,b,c){var d=c,e=c.$,f=c.$w,g=c.Class,h=c.isHash,i=c.isArray,j=c.Element,k=c.Observer,l=new g(k,{extend:{version:"2.2.0",EVENTS:f("before start drag stop drop"),Options:{handle:null,snap:0,axis:null,range:null,dragClass:"dragging",clone:!1,revert:!1,revertDuration:"normal",scroll:!0,scrollSensitivity:32,zIndex:1e7,moveOut:!1,relName:"draggable"},current:null,rescan:function(a){var c=this.Options.relName,d=this===l?"draggable":"droppable";(e(a)||e(b)).find('*[rel^="'+c+'"]').each(function(a){a[d]||new this(a,(new Function("return "+a.get("data-"+c)))()||{})},this)}},initialize:function(a,b){this.element=e(a),this.$super(b),this.element.draggable=this.init()},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart),delete this.element.draggable;return this},setOptions:function(a){this.$super(a),this.handle=this.options.handle?e(this.options.handle):this.element,i(this.options.snap)?(this.snapX=this.options.snap[0],this.snapY=this.options.snap[1]):this.snapX=this.snapY=this.options.snap;return this},revert:function(){var a=this.clone.position(),b={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};this.options.revertDuration&&this.element.morph?this.element.morph(b,{duration:this.options.revertDuration,onFinish:d(this.swapBack).bind(this)}):(this.element.setStyle(b),this.swapBack());return this},init:function(){this._dragStart=d(this.dragStart).bind(this),this.handle.onMousedown(this._dragStart);return this},dragStart:function(c){this.fire("before",this,c.stop());var f=this.element.position();this.xDiff=c.pageX-f.x,this.yDiff=c.pageY-f.y;var g={y:d(this.element.getStyle("top")).toFloat(),x:d(this.element.getStyle("left")).toFloat()};this.rxDiff=isNaN(g.x)?0:g.x-f.x,this.ryDiff=isNaN(g.y)?0:g.y-f.y;var h={x:this.element.getStyle("width"),y:this.element.getStyle("height")};h.x=="auto"&&(h.x=this.element._.offsetWidth+"px"),h.y=="auto"&&(h.y=this.element._.offsetHeight+"px");if(this.options.clone||this.options.revert)this.clone=(new j(this.element._.cloneNode(!0))).setStyle({visibility:this.options.clone?"visible":"hidden"}).insertTo(this.element,"before");this.element.setStyle({position:"absolute",zIndex:l.Options.zIndex++,top:f.y+this.ryDiff+"px",left:f.x+this.rxDiff+"px",width:h.x,height:h.y}).addClass(this.options.dragClass),this.options.moveOut&&this.element.insertTo(b.body),this.winScrolls=e(a).scrolls(),this.winSizes=e(a).size(),l.current=this.calcConstraints().fire("start",this,c),this.style=this.element._.style},dragProcess:function(b){var c=b.pageX,d=b.pageY,f=c-this.xDiff,g=d-this.yDiff;this.ranged&&(this.minX>f&&(f=this.minX),this.maxX<f&&(f=this.maxX),this.minY>g&&(g=this.minY),this.maxY<g&&(g=this.maxY));if(this.options.scroll){var h={x:this.winScrolls.x,y:this.winScrolls.y},i=this.options.scrollSensitivity;d-h.y<i?h.y=d-i:h.y+this.winSizes.y-d<i&&(h.y=d-this.winSizes.y+i),c-h.x<i?h.x=c-i:h.x+this.winSizes.x-c<i&&(h.x=c-this.winSizes.x+i),h.y<0&&(h.y=0),h.x<0&&(h.x=0),(h.y<this.winScrolls.y||h.y>this.winScrolls.y||h.x<this.winScrolls.x||h.x>this.winScrolls.x)&&e(a).scrollTo(this.winScrolls=h)}this.snapX&&(f=f-f%this.snapX),this.snapY&&(g=g-g%this.snapY),this.axisY||(this.style.left=f+this.rxDiff+"px"),this.axisX||(this.style.top=g+this.ryDiff+"px"),this.fire("drag",this,b)},dragStop:function(a){this.element.removeClass(this.options.dragClass),m.checkDrop(a,this),this.options.revert&&this.revert(),l.current=null,this.fire("stop",this,a)},swapBack:function(){this.clone&&this.clone.replace(this.element.setStyle({width:this.clone.getStyle("width"),height:this.clone.getStyle("height"),position:this.clone.getStyle("position"),zIndex:this.clone.getStyle("zIndex")||""}))},calcConstraints:function(){var a=this.options.axis;this.axisX=d(["x","horizontal"]).include(a),this.axisY=d(["y","vertical"]).include(a),this.ranged=!1;var b=this.options.range;if(b){this.ranged=!0;var c=e(b);if(c instanceof j){var f=c.dimensions();b={x:[f.left,f.left+f.width],y:[f.top,f.top+f.height]}}if(h(b)){var g=this.element.size();b.x&&(this.minX=b.x[0],this.maxX=b.x[1]-g.x),b.y&&(this.minY=b.y[0],this.maxY=b.y[1]-g.y)}}return this}}),m=new g(k,{extend:{EVENTS:f("drop hover leave"),Options:{accept:"*",containment:null,overlap:null,overlapSize:.5,allowClass:"droppable-allow",denyClass:"droppable-deny",relName:"droppable"},rescan:l.rescan,checkHover:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkHover(a,b)},checkDrop:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkDrop(a,b)},active:[]},initialize:function(a,b){this.element=e(a),this.$super(b),m.active.push(this.element._droppable=this)},destroy:function(){m.active=m.active.without(this),delete this.element.droppable;return this},checkHover:function(a,b){this.hoveredBy(a,b)?this._hovered||(this._hovered=!0,this.element.addClass(this.options[this.allows(b)?"allowClass":"denyClass"]),this.fire("hover",b,this,a)):this._hovered&&(this._hovered=!1,this.reset().fire("leave",b,this,a))},checkDrop:function(a,b){this.reset(),this.hoveredBy(a,b)&&this.allows(b)&&(b.fire("drop",this,b,a),this.fire("drop",b,this,a))},reset:function(){this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);return this},hoveredBy:function(a,b){var c=this.element.dimensions(),d=c.top,e=c.left,f=c.left+c.width,g=c.top+c.height,h=a.pageX,i=a.pageY;if(!this.options.overlap)return h>e&&h<f&&i>d&&i<g;var j=b.element.dimensions(),k=this.options.overlapSize,l=j.top,m=j.left,n=j.left+j.width,o=j.top+j.height;switch(this.options.overlap){case"x":case"horizontal":return(l>d&&l<g||o>d&&o<g)&&(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k);case"y":case"vertical":return(m>e&&m<f||n>e&&n<f)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k);default:return(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k)}},allows:function(a){this.options.containment&&!this._scanned&&(this.options.containment=d(this.options.containment).map(e),this._scanned=!0);var b=this.options.containment?this.options.containment.includes(a.element):!0;return b&&(this.options.accept=="*"?!0:a.element.match(this.options.accept))}});e(b).on({ready:function(){l.rescan(),m.rescan()},mousemove:function(a){l.current!==null&&(l.current.dragProcess(a),m.checkHover(a,l.current))},mouseup:function(a){l.current!==null&&l.current.dragStop(a)}}),j.include({makeDraggable:function(a){new l(this,a);return this},undoDraggable:function(){"draggable"in this&&this.draggable.destroy();return this},makeDroppable:function(a){new m(this,a);return this},undoDroppable:function(){"droppable"in this&&this.droppable.destroy();return this}}),a.Draggable=c.Draggable=l,a.Droppable=c.Droppable=m})(window,document,RightJS)
7
+ (function(a,b,c){var d=c,e=c.$,f=c.$w,g=c.Class,h=c.isHash,i=c.isArray,j=c.Element,k=c.Observer,l=new g(k,{extend:{version:"2.2.2",EVENTS:f("before start drag stop drop"),Options:{handle:null,snap:0,axis:null,range:null,dragClass:"dragging",clone:!1,revert:!1,revertDuration:"normal",scroll:!0,scrollSensitivity:32,zIndex:1e7,moveOut:!1,relName:"draggable"},current:null,rescan:function(a){var c=this.Options.relName,d=this===l?"draggable":"droppable";(e(a)||e(b)).find('*[rel^="'+c+'"]').each(function(a){a[d]||new this(a,(new Function("return "+a.get("data-"+c)))()||{})},this)}},initialize:function(a,b){this.element=e(a),this.$super(b),this._dragStart=d(this.dragStart).bind(this),this.handle.onMousedown(this._dragStart),this.element.draggable=this},destroy:function(){this.handle.stopObserving("mousedown",this._dragStart),delete this.element.draggable;return this},setOptions:function(a){this.$super(a),this.handle=this.options.handle?e(this.options.handle):this.element,i(this.options.snap)?(this.snapX=this.options.snap[0],this.snapY=this.options.snap[1]):this.snapX=this.snapY=this.options.snap;return this},revert:function(){var a=this.clone.position(),b={top:a.y+this.ryDiff+"px",left:a.x+this.rxDiff+"px"};this.options.revertDuration&&this.element.morph?this.element.morph(b,{duration:this.options.revertDuration,onFinish:d(this.swapBack).bind(this)}):(this.element.setStyle(b),this.swapBack());return this},dragStart:function(c){if(this._drag)return!1;this._drag=!0,this.fire("before",this,c.stop());var d=this.element.position();this.xDiff=c.pageX-d.x,this.yDiff=c.pageY-d.y,this.rxDiff=this.ryDiff=0,this.element.parents().reverse().each(function(a){a.getStyle("position")!=="static"&&(a=a.position(),this.rxDiff=-a.x,this.ryDiff=-a.y)},this);var f={x:this.element.getStyle("width"),y:this.element.getStyle("height")};f.x=="auto"&&(f.x=this.element._.offsetWidth+"px"),f.y=="auto"&&(f.y=this.element._.offsetHeight+"px");if(this.options.clone||this.options.revert)this.clone=(new j(this.element._.cloneNode(!0))).setStyle({visibility:this.options.clone?"visible":"hidden"}).insertTo(this.element,"before");this.element.setStyle({position:"absolute",zIndex:l.Options.zIndex++,top:d.y+this.ryDiff+"px",left:d.x+this.rxDiff+"px",width:f.x,height:f.y}).addClass(this.options.dragClass),this.options.moveOut&&this.element.insertTo(b.body),this.winScrolls=e(a).scrolls(),this.winSizes=e(a).size(),l.current=this.calcConstraints().fire("start",this,c),this.style=this.element._.style},dragProcess:function(b){var c=b.pageX,d=b.pageY,f=c-this.xDiff,g=d-this.yDiff;this.ranged&&(this.minX>f&&(f=this.minX),this.maxX<f&&(f=this.maxX),this.minY>g&&(g=this.minY),this.maxY<g&&(g=this.maxY));if(this.options.scroll){var h={x:this.winScrolls.x,y:this.winScrolls.y},i=this.options.scrollSensitivity;d-h.y<i?h.y=d-i:h.y+this.winSizes.y-d<i&&(h.y=d-this.winSizes.y+i),c-h.x<i?h.x=c-i:h.x+this.winSizes.x-c<i&&(h.x=c-this.winSizes.x+i),h.y<0&&(h.y=0),h.x<0&&(h.x=0),(h.y<this.winScrolls.y||h.y>this.winScrolls.y||h.x<this.winScrolls.x||h.x>this.winScrolls.x)&&e(a).scrollTo(this.winScrolls=h)}this.snapX&&(f=f-f%this.snapX),this.snapY&&(g=g-g%this.snapY),this.axisY||(this.style.left=f+this.rxDiff+"px"),this.axisX||(this.style.top=g+this.ryDiff+"px"),this.fire("drag",this,b)},dragStop:function(a){this.element.removeClass(this.options.dragClass),m.checkDrop(a,this),this.options.revert?this.revert():this._drag=!1,l.current=null,this.fire("stop",this,a)},swapBack:function(){this.clone&&this.clone.replace(this.element.setStyle({width:this.clone.getStyle("width"),height:this.clone.getStyle("height"),position:this.clone.getStyle("position"),zIndex:this.clone.getStyle("zIndex")||""})),this._drag=!1},calcConstraints:function(){var a=this.options.axis;this.axisX=d(["x","horizontal"]).include(a),this.axisY=d(["y","vertical"]).include(a),this.ranged=!1;var b=this.options.range;if(b){this.ranged=!0;var c=e(b);if(c instanceof j){var f=c.dimensions();b={x:[f.left,f.left+f.width],y:[f.top,f.top+f.height]}}if(h(b)){var g=this.element.size();b.x&&(this.minX=b.x[0],this.maxX=b.x[1]-g.x),b.y&&(this.minY=b.y[0],this.maxY=b.y[1]-g.y)}}return this}}),m=new g(k,{extend:{EVENTS:f("drop hover leave"),Options:{accept:"*",containment:null,overlap:null,overlapSize:.5,allowClass:"droppable-allow",denyClass:"droppable-deny",relName:"droppable"},rescan:l.rescan,checkHover:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkHover(a,b)},checkDrop:function(a,b){for(var c=0,d=this.active.length;c<d;c++)this.active[c].checkDrop(a,b)},active:[]},initialize:function(a,b){this.element=e(a),this.$super(b),m.active.push(this.element._droppable=this)},destroy:function(){m.active=m.active.without(this),delete this.element.droppable;return this},checkHover:function(a,b){this.hoveredBy(a,b)?this._hovered||(this._hovered=!0,this.element.addClass(this.options[this.allows(b)?"allowClass":"denyClass"]),this.fire("hover",b,this,a)):this._hovered&&(this._hovered=!1,this.reset().fire("leave",b,this,a))},checkDrop:function(a,b){this.reset(),this.hoveredBy(a,b)&&this.allows(b)&&(b.fire("drop",this,b,a),this.fire("drop",b,this,a))},reset:function(){this.element.removeClass(this.options.allowClass).removeClass(this.options.denyClass);return this},hoveredBy:function(a,b){var c=this.element.dimensions(),d=c.top,e=c.left,f=c.left+c.width,g=c.top+c.height,h=a.pageX,i=a.pageY;if(!this.options.overlap)return h>e&&h<f&&i>d&&i<g;var j=b.element.dimensions(),k=this.options.overlapSize,l=j.top,m=j.left,n=j.left+j.width,o=j.top+j.height;switch(this.options.overlap){case"x":case"horizontal":return(l>d&&l<g||o>d&&o<g)&&(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k);case"y":case"vertical":return(m>e&&m<f||n>e&&n<f)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k);default:return(m>e&&m<f-c.width*k||n<f&&n>e+c.width*k)&&(l>d&&l<g-c.height*k||o<g&&o>d+c.height*k)}},allows:function(a){this.options.containment&&!this._scanned&&(this.options.containment=d(this.options.containment).map(e),this._scanned=!0);var b=this.options.containment?this.options.containment.includes(a.element):!0;return b&&(this.options.accept=="*"?!0:a.element.match(this.options.accept))}});e(b).on({ready:function(){l.rescan(),m.rescan()},mousemove:function(a){l.current!==null&&(l.current.dragProcess(a),m.checkHover(a,l.current))},mouseup:function(a){l.current!==null&&l.current.dragStop(a)}}),j.include({makeDraggable:function(a){new l(this,a);return this},undoDraggable:function(){"draggable"in this&&this.draggable.destroy();return this},makeDroppable:function(a){new m(this,a);return this},undoDroppable:function(){"droppable"in this&&this.droppable.destroy();return this}}),a.Draggable=c.Draggable=l,a.Droppable=c.Droppable=m})(window,document,RightJS)
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
98
98
  var Klass = new RightJS.Class(AbstractWidget, methods);
99
99
 
100
100
  // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
101
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
102
 
103
103
  return Klass;
104
104
  }
@@ -4,4 +4,4 @@
4
4
  *
5
5
  * Copyright (C) 2009-2011 Nikolay Nemshilov
6
6
  */
7
- var InEdit=RightJS.InEdit=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=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=b,f=b.$,g=b.$w,h=b.Xhr,i=b.Object,j=b.Element,k=b.Input,l=new c("FORM",{extend:{version:"2.2.0",EVENTS:g("show hide send update"),Options:{url:null,name:"text",method:"put",type:"text",toggle:null,update:!0,Xhr:{}},i18n:{Save:"Save",Cancel:"Cancel"},current:null},initialize:function(a,b){this.element=f(a),this.$super("in-edit",b).set("action",this.options.url).insert([this.field=new k({type:this.options.type,name:this.options.name,"class":"field"}),this.spinner=new d(4),this.submit=new k({type:"submit","class":"submit",value:l.i18n.Save}),this.cancel=new j("a",{"class":"cancel",href:"#",html:l.i18n.Cancel})]).onClick(this.clicked).onSubmit(this.send)},show:function(){l.current!==this&&(l.current&&l.current.hide(),this.oldContent=this.element.html(),e(["file","password"]).include(this.options.type)||this.field.setValue(this.oldContent),this.element.update(this),this.spinner.hide(),this.submit.show(),this.options.toggle&&f(this.options.toggle).hide()),this.options.type!=="file"&&this.field.focus(),l.current=this;return this.fire("show")},hide:function(){this.element._.innerHTML=this.oldContent,this.xhr&&this.xhr.cancel();return this.finish()},send:function(a){a&&a.stop(),this.spinner.show().resize(this.submit.size()),this.submit.hide(),this.xhr=(new h(this.options.url,i.merge(this.options.Xhr,{method:this.options.method,spinner:this.spinner,onComplete:e(this.receive).bind(this)}))).send(this);return this.fire("send")},finish:function(){this.options.toggle&&f(this.options.toggle).show(),l.current=null;return this.fire("hide")},receive:function(){this.options.update&&(this.element.update(this.xhr.text),this.fire("update")),this.xhr=null,this.finish()},clicked:function(a){a.target===this.cancel&&(a.stop(),this.hide())}});f(a).onKeydown(function(a){a.keyCode===27&&l.current&&l.current.hide()}),j.include({inEdit:function(a){return(new l(this,a)).show()}});var m=a.createElement("style"),n=a.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}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");m.type="text/css",a.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(document,RightJS)
7
+ var InEdit=RightJS.InEdit=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||b([]));return e}var d=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e=b,f=b.$,g=b.$w,h=b.Xhr,i=b.Object,j=b.Element,k=b.Input,l=new c("FORM",{extend:{version:"2.2.0",EVENTS:g("show hide send update"),Options:{url:null,name:"text",method:"put",type:"text",toggle:null,update:!0,Xhr:{}},i18n:{Save:"Save",Cancel:"Cancel"},current:null},initialize:function(a,b){this.element=f(a),this.$super("in-edit",b).set("action",this.options.url).insert([this.field=new k({type:this.options.type,name:this.options.name,"class":"field"}),this.spinner=new d(4),this.submit=new k({type:"submit","class":"submit",value:l.i18n.Save}),this.cancel=new j("a",{"class":"cancel",href:"#",html:l.i18n.Cancel})]).onClick(this.clicked).onSubmit(this.send)},show:function(){l.current!==this&&(l.current&&l.current.hide(),this.oldContent=this.element.html(),e(["file","password"]).include(this.options.type)||this.field.setValue(this.oldContent),this.element.update(this),this.spinner.hide(),this.submit.show(),this.options.toggle&&f(this.options.toggle).hide()),this.options.type!=="file"&&this.field.focus(),l.current=this;return this.fire("show")},hide:function(){this.element._.innerHTML=this.oldContent,this.xhr&&this.xhr.cancel();return this.finish()},send:function(a){a&&a.stop(),this.spinner.show().resize(this.submit.size()),this.submit.hide(),this.xhr=(new h(this.options.url,i.merge(this.options.Xhr,{method:this.options.method,spinner:this.spinner,onComplete:e(this.receive).bind(this)}))).send(this);return this.fire("send")},finish:function(){this.options.toggle&&f(this.options.toggle).show(),l.current=null;return this.fire("hide")},receive:function(){this.options.update&&(this.element.update(this.xhr.text),this.fire("update")),this.xhr=null,this.finish()},clicked:function(a){a.target===this.cancel&&(a.stop(),this.hide())}});f(a).onKeydown(function(a){a.keyCode===27&&l.current&&l.current.hide()}),j.include({inEdit:function(a){return(new l(this,a)).show()}});var m=a.createElement("style"),n=a.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}form.rui-in-edit,form.rui-in-edit .cancel{margin:0;padding:0;float:none;position:static}form.rui-in-edit{display:inline-block; *display:inline; *zoom:1;border:none;background:none}form.rui-in-edit div.rui-spinner{margin-right:.2em}form.rui-in-edit div.rui-spinner div{margin-top:.2em}form.rui-in-edit textarea.field{width:100%;margin-bottom:.5em}form.rui-in-edit .field,form.rui-in-edit .submit{margin-right:.2em}form.rui-in-edit,form.rui-in-edit .field,form.rui-in-edit .submit,form.rui-in-edit div.rui-spinner,form.rui-in-edit .cancel{vertical-align:middle}");m.type="text/css",a.getElementsByTagName("head")[0].appendChild(m),m.styleSheet?m.styleSheet.cssText=n.nodeValue:m.appendChild(n);return l}(document,RightJS)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * RightJS-UI Lightbox v2.2.2
2
+ * RightJS-UI Lightbox v2.2.3
3
3
  * http://rightjs.org/ui/lightbox
4
4
  *
5
5
  * Copyright (C) 2009-2011 Nikolay Nemshilov
@@ -98,7 +98,7 @@ function Widget(tag_name, methods) {
98
98
  var Klass = new RightJS.Class(AbstractWidget, methods);
99
99
 
100
100
  // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
101
+ RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
102
 
103
103
  return Klass;
104
104
  }
@@ -179,7 +179,7 @@ Browser.IE6 = Browser.OLD && navigator.userAgent.indexOf("MSIE 6") > 0;
179
179
  var Lightbox = new Widget({
180
180
 
181
181
  extend: {
182
- version: '2.2.2',
182
+ version: '2.2.3',
183
183
 
184
184
  EVENTS: $w('show hide load'),
185
185
 
@@ -522,8 +522,27 @@ var Dialog = new Class(Element, {
522
522
 
523
523
  // checking the constraints
524
524
  var threshold = 100; // px
525
- if ((end_size.x + threshold) > win_size.x) { end_size.x = win_size.x - threshold; }
526
- if ((end_size.y + threshold) > win_size.y) { end_size.y = win_size.y - threshold; }
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
+ }
527
546
 
528
547
  // the actual resize and reposition
529
548
  var end_top = (cur_top * 2 + cur_size.y - end_size.y) / 2;