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.
- data/CHANGELOG +8 -2
- data/Rakefile +28 -28
- data/lib/right_rails/java_script_generator.rb +59 -51
- data/public/images/{colorpicker.png → rightjs-ui/colorpicker.png} +0 -0
- data/public/images/{resizable.png → rightjs-ui/resizable.png} +0 -0
- data/public/javascripts/right-olds-src.js +47 -46
- data/public/javascripts/right-safe-src.js +103 -102
- data/public/javascripts/right-safe.js +1 -1
- data/public/javascripts/right-src.js +611 -541
- data/public/javascripts/right.js +86 -85
- data/public/javascripts/right/autocompleter-src.js +81 -77
- data/public/javascripts/right/autocompleter.js +1 -1
- data/public/javascripts/right/calendar-src.js +209 -197
- data/public/javascripts/right/calendar.js +6 -6
- data/public/javascripts/right/colorpicker-src.js +127 -117
- data/public/javascripts/right/colorpicker.js +6 -6
- data/public/javascripts/right/dnd-src.js +63 -63
- data/public/javascripts/right/dnd.js +2 -2
- data/public/javascripts/right/in-edit-src.js +53 -48
- data/public/javascripts/right/in-edit.js +2 -2
- data/public/javascripts/right/lightbox-src.js +107 -99
- data/public/javascripts/right/lightbox.js +2 -2
- data/public/javascripts/right/rater-src.js +48 -46
- data/public/javascripts/right/rater.js +3 -3
- data/public/javascripts/right/resizable-src.js +53 -61
- data/public/javascripts/right/resizable.js +4 -4
- data/public/javascripts/right/selectable-src.js +97 -95
- data/public/javascripts/right/selectable.js +2 -2
- data/public/javascripts/right/slider-src.js +47 -45
- data/public/javascripts/right/slider.js +8 -8
- data/public/javascripts/right/sortable-src.js +54 -52
- data/public/javascripts/right/tabs-src.js +181 -171
- data/public/javascripts/right/tooltip-src.js +39 -37
- data/public/javascripts/right/uploader-src.js +21 -19
- data/spec/lib/right_rails/java_script_generator_spec.rb +61 -56
- metadata +9 -7
@@ -6,7 +6,7 @@
|
|
6
6
|
*/
|
7
7
|
var Lightbox=RightJS.Lightbox=function(p,d){var q=d.$,r=d.$$,u=d.$w,h=d.$E,v=d.$ext,w=d.Xhr,x=d.Class,y=d.Object,s=d.Wrapper,j=d.Element,i=d.Browser;i.IE6=i.OLD&&navigator.userAgent.indexOf("MSIE 6")>0;var z=new d.Wrapper(d.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"});this.dots=[];for(var b=0;b<(a||4);b++)this.dots.push(new d.Element("div"));this.dots[0].addClass("glowing");this.insert(this.dots);d(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=
|
8
8
|
this.dots.pop();this.dots.unshift(a);this.insert(a,"top")}}}),f=new (function(a,b){if(!b){b=a;a="DIV"}var c=new d.Wrapper(d.Element.Wrappers[a]||d.Element,{initialize:function(e,g){this.key=e;var k=[{"class":"rui-"+e}];this instanceof d.Input||this instanceof d.Form||k.unshift(a);this.$super.apply(this,k);if(d.isString(g))g=d.$(g);if(g instanceof d.Element){this._=g._;if("$listeners"in g)g.$listeners=g.$listeners;g={}}this.setOptions(g,this);return this},setOptions:function(e,g){g=g||this;d.Options.setOptions.call(this,
|
9
|
-
d.Object.merge(e,eval("("+(g.get("data-"+this.key)||"{}")+")")));return this}});c=new d.Wrapper(c,b);d.Observer.createShortcuts(c.prototype,c.EVENTS||[]);return c})({extend:{version:"2.0.0",EVENTS:u("show hide load"),Options:{fxName:"fade",fxDuration:
|
9
|
+
d.Object.merge(e,eval("("+(g.get("data-"+this.key)||"{}")+")")));return this}});c=new d.Wrapper(c,b);d.Observer.createShortcuts(c.prototype,c.EVENTS||[]);return c})({extend:{version:"2.0.0",EVENTS:u("show hide load"),Options:{fxName:"fade",fxDuration:200,group:null,hideOnEsc:true,hideOnOutClick:true,showCloseButton:true,cssRule:"a[data-lightbox]",mediaWidth:425,mediaHeight:350},i18n:{Close:"Close",Prev:"Previous Image",Next:"Next Image"},Images:/\.(jpg|jpeg|gif|png|bmp)/,Medias:[[/(http:\/\/.*?youtube\.[a-z]+)\/watch\?v=([^&]+)/,
|
10
10
|
"$1/v/$2","swf"],[/(http:\/\/video.google.com)\/videoplay\?docid=([^&]+)/,"$1/googleplayer.swf?docId=$2","swf"],[/(http:\/\/vimeo\.[a-z]+)\/([0-9]+).*?/,"$1/moogaloop.swf?clip_id=$2","swf"]]},initialize:function(a,b){this.$super("lightbox",{}).setOptions(a,b).insert([this.locker=new A(this.options),this.dialog=new B(this.options)]).on({close:this._close,next:this._next,prev:this._prev})},setOptions:function(a,b){this.$super(a,b);if(b){var c=b.get("rel");if(c&&(c=c.match(/lightbox\[(.+?)\]/)))this.options.group=
|
11
11
|
c[1]}return this},setTitle:function(a){this.dialog.setTitle(a);return this},show:function(a){return this._showAnd(function(){this.dialog.show(a,!a)})},hide:function(){f.current=null;return this.$super(this.options.fxName,{duration:this.options.fxDuration/3,onFinish:d(function(){this.fire("hide");this.remove()}).bind(this)})},load:function(a,b){return this._showAnd(function(){this.dialog.load(a,b)})},resize:function(a){this.dialog.resize(a);return this},_close:function(a){a.stop();this.hide()},_prev:function(a){a.stop();
|
12
12
|
l.prev()},_next:function(a){a.stop();l.next()},_showAnd:function(a){if(f.current!==this){f.current=this;r("div.rui-lightbox").each("remove");this.insertTo(p.body);this.dialog.show("",true);if(i.OLD){this.reposition();j.prototype.show.call(this);a.call(this)}else{this.setStyle("display:none");j.prototype.show.call(this,this.options.fxName,{duration:this.options.fxDuration/2,onFinish:d(function(){a.call(this);this.fire("show")}).bind(this)})}}else a.call(this);return this},reposition:function(){if(i.IE6){var a=
|
@@ -20,5 +20,5 @@ this.img=h("img")._;c.onload=function(){b(c)};c.src=a;return true}},isMedia:func
|
|
20
20
|
'" height="'+e.mediaHeight+'"';return'<object classid="clsid:'+c[b][0]+'" codebase="'+c[b][1]+'"'+e+'><param name="src" value="'+a+'" /><embed src="'+a+'" type="'+c[b][2]+'"'+e+" /></object>"}}),l={show:function(a,b){if(a.options.group){this.dialog=a;this.links=this.find(a.options.group);this.link=this.links.first(function(g){return g.get("href")===b});var c=this.links.indexOf(this.link),e=this.links.length;a.prevLink[e&&c>0?"show":"hide"]();a.nextLink[e&&c<e-1?"show":"hide"]()}else this.dialog=null},
|
21
21
|
prev:function(){if(this.dialog&&!this.timer){var a=this.links[this.links.indexOf(this.link)-1];if(a){this.dialog.load(a);this.timeout()}}},next:function(){if(this.dialog&&!this.timer){var a=this.links[this.links.indexOf(this.link)+1];if(a){this.dialog.load(a);this.timeout()}}},find:function(a){return r("a").filter(function(b){var c=b.get("data-lightbox");b=b.get("rel");return c&&eval("("+c+")").group===a||b&&b.indexOf("lightbox["+a+"]")>-1})},timeout:function(){this.timer=d(function(){l.timer=null}).delay(300)}};
|
22
22
|
q(p).on({click:function(a){var b=a.find(f.Options.cssRule)||a.find("a[rel^=lightbox]");if(b){a.stop();(new f({},b)).load(b)}},mousewheel:function(a){if(f.current){a.stop();f.current.fire((a._.detail||-a._.wheelDelta)<0?"prev":"next")}},keydown:function(a){var b=f.current,c={27:"close",33:"prev",37:"prev",38:"prev",39:"next",40:"next",34:"next"}[a.keyCode];if(b&&c)if(c!=="close"||b.options.hideOnEsc){a.stop();b.fire(c)}}});q(window).on({resize:function(){if(f.current){f.current.reposition();f.current.dialog.resize()}},
|
23
|
-
scroll:function(){f.current&&i.IE6&&f.current.reposition()}});p.write('<style type="text/css">div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-lightbox{position:fixed;top:0;left:0;z-index:9999;float:none;width:100%;height:100%;margin:0;padding:0;background:none;border:none;text-align:center}div.rui-lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);cursor:default}div.rui-lightbox-dialog{display:inline-block; *display:inline; *zoom:1;position:relative;text-align:left}div.rui-lightbox-title{height:1.2em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica;text-shadow:#000 .05em .1em .2em}div.rui-lightbox-body{background-color:white;padding:1em;border-radius:.5em;-moz-border-radius:.5em;-webkit-border-radius:.5em
|
23
|
+
scroll:function(){f.current&&i.IE6&&f.current.reposition()}});p.write('<style type="text/css">div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-lightbox{position:fixed;top:0;left:0;z-index:9999;float:none;width:100%;height:100%;margin:0;padding:0;background:none;border:none;text-align:center}div.rui-lightbox-locker{position:absolute;top:0px;left:0px;width:100%;height:100%;background-color:#000;opacity:0.8;filter:alpha(opacity=80);cursor:default}div.rui-lightbox-dialog{display:inline-block; *display:inline; *zoom:1;position:relative;text-align:left}div.rui-lightbox-title{height:1.2em;margin-bottom:.1em;white-space:nowrap;color:#DDD;font-weight:bold;font-size:1.6em;font-family:Helvetica;text-shadow:#000 .05em .1em .2em}div.rui-lightbox-body{background-color:white;padding:1em;border-radius:.5em;-moz-border-radius:.5em;-webkit-border-radius:.5em}div.rui-lightbox-body-inner{position:relative}div.rui-lightbox-scroller{overflow:hidden}div.rui-lightbox-content{display:inline-block; *display:inline; *zoom:1;min-height:10em;min-width:10em;_height:10em;_width:10em}div.rui-lightbox-body-locker{background-color:white;position:absolute;left:0px;top:0px;width:100%;height:100%;z-index:999;opacity:0;filter:alpha(opacity=0)}div.rui-lightbox-body-locker div.rui-spinner{position:absolute;right:0;bottom:0;border:none;background:none;font-size:150%}div.rui-lightbox-navigation{color:#888;font-size:150%;font-family:Arial;height:1em;user-select:none;-moz-user-select:none;-webkit-user-select:none}div.rui-lightbox-navigation div{cursor:pointer;position:absolute}div.rui-lightbox-navigation div:hover{color:white}div.rui-lightbox-navigation div.next{left:2em}div.rui-lightbox-navigation div.close{right:0}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body{padding:0;border:1px solid #777;border-radius:0px;-moz-border-radius:0px;-webkit-border-radius:0px}div.rui-lightbox-image div.rui-lightbox-content,div.rui-lightbox-media div.rui-lightbox-content{min-height:12em;min-width:12em;_height:12em;_width:12em}div.rui-lightbox-image div.rui-lightbox-content img{vertical-align:middle}div.rui-lightbox-image div.rui-lightbox-body,div.rui-lightbox-image div.rui-lightbox-body-locker,div.rui-lightbox-media div.rui-lightbox-body,div.rui-lightbox-media div.rui-lightbox-body-locker{background-color:#D8D8D8}div.rui-lightbox-image div.rui-lightbox-body-locker div.rui-spinner,div.rui-lightbox-media div.rui-lightbox-body-locker div.rui-spinner{bottom:.5em;right:.5em}</style>');
|
24
24
|
return f}(document,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
|
|
@@ -123,7 +123,7 @@ function Widget(tag_name, methods) {
|
|
123
123
|
* Copyright (C) 2010 Nikolay Nemshilov
|
124
124
|
*/
|
125
125
|
var Updater = {
|
126
|
-
|
126
|
+
|
127
127
|
/**
|
128
128
|
* Assigns the unit to work with an input element
|
129
129
|
*
|
@@ -136,7 +136,7 @@ var Updater = {
|
|
136
136
|
element[element.setValue ? 'setValue' : 'update'](event.target.getValue());
|
137
137
|
}
|
138
138
|
}).curry(element);
|
139
|
-
|
139
|
+
|
140
140
|
var connect = R(function(element, object) {
|
141
141
|
element = $(element);
|
142
142
|
if (element && element.onChange) {
|
@@ -145,7 +145,7 @@ var Updater = {
|
|
145
145
|
}).bind(object));
|
146
146
|
}
|
147
147
|
}).curry(element);
|
148
|
-
|
148
|
+
|
149
149
|
if ($(element)) {
|
150
150
|
assign({target: this});
|
151
151
|
connect(this);
|
@@ -155,7 +155,7 @@ var Updater = {
|
|
155
155
|
connect(this);
|
156
156
|
}.bind(this)));
|
157
157
|
}
|
158
|
-
|
158
|
+
|
159
159
|
return this.onChange(assign);
|
160
160
|
}
|
161
161
|
};
|
@@ -168,28 +168,28 @@ var Updater = {
|
|
168
168
|
*/
|
169
169
|
var Rater = new Widget({
|
170
170
|
include: Updater,
|
171
|
-
|
171
|
+
|
172
172
|
extend: {
|
173
173
|
version: '2.0.0',
|
174
|
-
|
174
|
+
|
175
175
|
EVENTS: $w('change hover send'),
|
176
|
-
|
176
|
+
|
177
177
|
Options: {
|
178
178
|
html: '★', // the dot html code
|
179
|
-
|
179
|
+
|
180
180
|
size: 5, // number of stars in the line
|
181
181
|
value: null, // default value
|
182
182
|
update: null, // an element to update
|
183
|
-
|
183
|
+
|
184
184
|
disabled: false, // if it should be disabled
|
185
185
|
disableOnVote: false, // if it should be disabled when user clicks a value
|
186
|
-
|
186
|
+
|
187
187
|
url: null, // an url to send results with AJAX
|
188
|
-
param: 'rate', // the value param name
|
188
|
+
param: 'rate', // the value param name
|
189
189
|
Xhr: null // additional Xhr options
|
190
190
|
}
|
191
191
|
},
|
192
|
-
|
192
|
+
|
193
193
|
/**
|
194
194
|
* basic constructor
|
195
195
|
*
|
@@ -204,30 +204,30 @@ var Rater = new Widget({
|
|
204
204
|
mouseover: this._hovered,
|
205
205
|
mouseout: this._left
|
206
206
|
});
|
207
|
-
|
207
|
+
|
208
208
|
if (this.empty()) {
|
209
209
|
for (var i=0; i < this.options.size; i++) {
|
210
210
|
this.insert('<div>'+ this.options.html + '</div>');
|
211
211
|
}
|
212
212
|
}
|
213
|
-
|
213
|
+
|
214
214
|
options = this.options;
|
215
|
-
|
215
|
+
|
216
216
|
if (options.value === null) {
|
217
217
|
options.value = this.find('.active').length;
|
218
218
|
}
|
219
|
-
|
219
|
+
|
220
220
|
this.setValue(options.value);
|
221
|
-
|
221
|
+
|
222
222
|
if (options.disabled) {
|
223
223
|
this.disable();
|
224
224
|
}
|
225
|
-
|
225
|
+
|
226
226
|
if (options.update) {
|
227
227
|
this.assignTo(options.update);
|
228
228
|
}
|
229
229
|
},
|
230
|
-
|
230
|
+
|
231
231
|
/**
|
232
232
|
* Sets the element value
|
233
233
|
*
|
@@ -239,22 +239,22 @@ var Rater = new Widget({
|
|
239
239
|
// converting the type and rounding the value
|
240
240
|
value = isString(value) ? R(value).toInt() : value;
|
241
241
|
value = isNumber(value) ? R(value).round() : 0;
|
242
|
-
|
242
|
+
|
243
243
|
// checking constraints
|
244
244
|
value = R(value).max(this.options.size);
|
245
245
|
value = R(value).min(0);
|
246
|
-
|
246
|
+
|
247
247
|
// highlighting the value
|
248
248
|
this.highlight(value);
|
249
|
-
|
249
|
+
|
250
250
|
if (this.value != value) {
|
251
|
-
this.fire('change', this.value = value
|
251
|
+
this.fire('change', {value: this.value = value});
|
252
252
|
}
|
253
253
|
}
|
254
|
-
|
254
|
+
|
255
255
|
return this;
|
256
256
|
},
|
257
|
-
|
257
|
+
|
258
258
|
/**
|
259
259
|
* Returns the current value of the rater
|
260
260
|
*
|
@@ -263,7 +263,7 @@ var Rater = new Widget({
|
|
263
263
|
getValue: function() {
|
264
264
|
return this.value;
|
265
265
|
},
|
266
|
-
|
266
|
+
|
267
267
|
/**
|
268
268
|
* Sends an Xhr request with the current value to the options.url address
|
269
269
|
*
|
@@ -273,11 +273,11 @@ var Rater = new Widget({
|
|
273
273
|
if (this.options.url) {
|
274
274
|
this.request = new Xhr(this.options.url, this.options.Xhr)
|
275
275
|
.send(this.options.param+"="+this.value);
|
276
|
-
this.fire('send', this.value
|
276
|
+
this.fire('send', {value: this.value});
|
277
277
|
}
|
278
278
|
return this;
|
279
279
|
},
|
280
|
-
|
280
|
+
|
281
281
|
/**
|
282
282
|
* Disables the instance
|
283
283
|
*
|
@@ -286,7 +286,7 @@ var Rater = new Widget({
|
|
286
286
|
disable: function() {
|
287
287
|
return this.addClass('rui-rater-disabled');
|
288
288
|
},
|
289
|
-
|
289
|
+
|
290
290
|
/**
|
291
291
|
* Enables this instance
|
292
292
|
*
|
@@ -295,7 +295,7 @@ var Rater = new Widget({
|
|
295
295
|
enable: function() {
|
296
296
|
return this.removeClass('rui-rater-disabled');
|
297
297
|
},
|
298
|
-
|
298
|
+
|
299
299
|
/**
|
300
300
|
* Checks if the instance is disabled
|
301
301
|
*
|
@@ -304,7 +304,7 @@ var Rater = new Widget({
|
|
304
304
|
disabled: function() {
|
305
305
|
return this.hasClass('rui-rater-disabled');
|
306
306
|
},
|
307
|
-
|
307
|
+
|
308
308
|
// protected
|
309
309
|
|
310
310
|
// callback for 'hover' event
|
@@ -312,10 +312,10 @@ var Rater = new Widget({
|
|
312
312
|
var index = this.children().indexOf(event.target);
|
313
313
|
if (!this.disabled() && index > -1) {
|
314
314
|
this.highlight(index + 1);
|
315
|
-
this.fire('hover', index + 1
|
315
|
+
this.fire('hover', {value: index + 1});
|
316
316
|
}
|
317
317
|
},
|
318
|
-
|
318
|
+
|
319
319
|
// callback for user-click
|
320
320
|
_clicked: function(event) {
|
321
321
|
var index = this.children().indexOf(event.target);
|
@@ -327,12 +327,12 @@ var Rater = new Widget({
|
|
327
327
|
this.send();
|
328
328
|
}
|
329
329
|
},
|
330
|
-
|
330
|
+
|
331
331
|
// callback when user moves the mouse out
|
332
332
|
_left: function() {
|
333
333
|
this.setValue(this.value);
|
334
334
|
},
|
335
|
-
|
335
|
+
|
336
336
|
// visually highlights the value
|
337
337
|
highlight: function(value) {
|
338
338
|
this.children().each(function(element, i) {
|
@@ -341,6 +341,7 @@ var Rater = new Widget({
|
|
341
341
|
}
|
342
342
|
});
|
343
343
|
|
344
|
+
|
344
345
|
/**
|
345
346
|
* Document level on-demand auto-initialization
|
346
347
|
*
|
@@ -348,11 +349,11 @@ var Rater = new Widget({
|
|
348
349
|
*/
|
349
350
|
$(document).onMouseover(function(event) {
|
350
351
|
var target = event.target, element = event.find('.rui-rater');
|
351
|
-
|
352
|
+
|
352
353
|
if (element) {
|
353
354
|
if (!(element instanceof Rater)) {
|
354
355
|
element = new Rater(element);
|
355
|
-
|
356
|
+
|
356
357
|
if (target.parent() === element) {
|
357
358
|
target.fire('mouseover');
|
358
359
|
}
|
@@ -360,7 +361,8 @@ $(document).onMouseover(function(event) {
|
|
360
361
|
}
|
361
362
|
});
|
362
363
|
|
364
|
+
|
363
365
|
document.write("<style type=\"text/css\">div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}</style>");
|
364
366
|
|
365
367
|
return Rater;
|
366
|
-
})(document, RightJS);
|
368
|
+
})(document, RightJS);
|
@@ -7,7 +7,7 @@
|
|
7
7
|
var Rater=RightJS.Rater=function(h,b){var g=b.$,k=b.$w,l=b.Xhr,m=b.isString,n=b.isNumber,i=new (function(a,e){if(!e){e=a;a="DIV"}var f=new b.Wrapper(b.Element.Wrappers[a]||b.Element,{initialize:function(d,c){this.key=d;var j=[{"class":"rui-"+d}];this instanceof b.Input||this instanceof b.Form||j.unshift(a);this.$super.apply(this,j);if(b.isString(c))c=b.$(c);if(c instanceof b.Element){this._=c._;if("$listeners"in c)c.$listeners=c.$listeners;c={}}this.setOptions(c,this);return this},setOptions:function(d,
|
8
8
|
c){c=c||this;b.Options.setOptions.call(this,b.Object.merge(d,eval("("+(c.get("data-"+this.key)||"{}")+")")));return this}});f=new b.Wrapper(f,e);b.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})({include:{assignTo:function(a){var e=b(function(d,c){if(d=g(d))d[d.setValue?"setValue":"update"](c.target.getValue())}).curry(a),f=b(function(d,c){(d=g(d))&&d.onChange&&d.onChange(b(function(){this.setValue(d.value())}).bind(c))}).curry(a);if(g(a)){e({target:this});f(this)}else g(h).onReady(b(function(){e({target:this});
|
9
9
|
f(this)}.bind(this)));return this.onChange(e)}},extend:{version:"2.0.0",EVENTS:k("change hover send"),Options:{html:"★",size:5,value:null,update:null,disabled:false,disableOnVote:false,url:null,param:"rate",Xhr:null}},initialize:function(a){this.$super("rater",a).on({click:this._clicked,mouseover:this._hovered,mouseout:this._left});if(this.empty())for(a=0;a<this.options.size;a++)this.insert("<div>"+this.options.html+"</div>");a=this.options;if(a.value===null)a.value=this.find(".active").length;
|
10
|
-
this.setValue(a.value);a.disabled&&this.disable();a.update&&this.assignTo(a.update)},setValue:function(a){if(!this.disabled()){a=m(a)?b(a).toInt():a;a=n(a)?b(a).round():0;a=b(a).max(this.options.size);a=b(a).min(0);this.highlight(a);if(this.value!=a)this.fire("change",this.value=a
|
11
|
-
|
12
|
-
|
10
|
+
this.setValue(a.value);a.disabled&&this.disable();a.update&&this.assignTo(a.update)},setValue:function(a){if(!this.disabled()){a=m(a)?b(a).toInt():a;a=n(a)?b(a).round():0;a=b(a).max(this.options.size);a=b(a).min(0);this.highlight(a);if(this.value!=a)this.fire("change",{value:this.value=a})}return this},getValue:function(){return this.value},send:function(){if(this.options.url){this.request=(new l(this.options.url,this.options.Xhr)).send(this.options.param+"="+this.value);this.fire("send",{value:this.value})}return this},
|
11
|
+
disable:function(){return this.addClass("rui-rater-disabled")},enable:function(){return this.removeClass("rui-rater-disabled")},disabled:function(){return this.hasClass("rui-rater-disabled")},_hovered:function(a){a=this.children().indexOf(a.target);if(!this.disabled()&&a>-1){this.highlight(a+1);this.fire("hover",{value:a+1})}},_clicked:function(a){a=this.children().indexOf(a.target);if(!this.disabled()&&a>-1){this.setValue(a+1);this.options.disableOnVote&&this.disable();this.send()}},_left:function(){this.setValue(this.value)},
|
12
|
+
highlight:function(a){this.children().each(function(e,f){e[a-1<f?"removeClass":"addClass"]("active")})}});g(h).onMouseover(function(a){var e=a.target;if(a=a.find(".rui-rater"))if(!(a instanceof i)){a=new i(a);e.parent()===a&&e.fire("mouseover")}});h.write('<style type="text/css">div.rui-rater,div.rui-rater div{margin:0;padding:0;background:none;border:none;display:inline-block; *display:inline; *zoom:1;font-family:Arial;font-size:110%}div.rui-rater{width:6em;height:1em;vertical-align:middle}div.rui-rater div{float:left;width:1em;height:1em;line-height:1em;text-align:center;cursor:pointer;color:#888}div.rui-rater div.active{color:brown;text-shadow:#666 .05em .05em .15em}div.rui-rater-disabled div{cursor:default}</style>');
|
13
13
|
return i}(document,RightJS);
|
@@ -24,7 +24,7 @@ var R = RightJS,
|
|
24
24
|
$E = RightJS.$E,
|
25
25
|
Wrapper = RightJS.Wrapper,
|
26
26
|
Element = RightJS.Element;
|
27
|
-
|
27
|
+
|
28
28
|
|
29
29
|
|
30
30
|
|
@@ -34,13 +34,13 @@ var R = RightJS,
|
|
34
34
|
* @param String tag-name or Object methods
|
35
35
|
* @param Object methods
|
36
36
|
* @return Widget wrapper
|
37
|
-
*/
|
37
|
+
*/
|
38
38
|
function Widget(tag_name, methods) {
|
39
39
|
if (!methods) {
|
40
40
|
methods = tag_name;
|
41
41
|
tag_name = 'DIV';
|
42
42
|
}
|
43
|
-
|
43
|
+
|
44
44
|
/**
|
45
45
|
* An Abstract Widget Unit
|
46
46
|
*
|
@@ -57,17 +57,17 @@ function Widget(tag_name, methods) {
|
|
57
57
|
initialize: function(key, options) {
|
58
58
|
this.key = key;
|
59
59
|
var args = [{'class': 'rui-' + key}];
|
60
|
-
|
60
|
+
|
61
61
|
// those two have different constructors
|
62
62
|
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
63
63
|
args.unshift(tag_name);
|
64
64
|
}
|
65
65
|
this.$super.apply(this, args);
|
66
|
-
|
66
|
+
|
67
67
|
if (RightJS.isString(options)) {
|
68
68
|
options = RightJS.$(options);
|
69
69
|
}
|
70
|
-
|
70
|
+
|
71
71
|
// if the options is another element then
|
72
72
|
// try to dynamically rewrap it with our widget
|
73
73
|
if (options instanceof RightJS.Element) {
|
@@ -100,16 +100,16 @@ function Widget(tag_name, methods) {
|
|
100
100
|
return this;
|
101
101
|
}
|
102
102
|
});
|
103
|
-
|
103
|
+
|
104
104
|
/**
|
105
105
|
* Creating the actual widget class
|
106
106
|
*
|
107
107
|
*/
|
108
108
|
var Klass = new RightJS.Wrapper(AbstractWidget, methods);
|
109
|
-
|
109
|
+
|
110
110
|
// creating the widget related shortcuts
|
111
111
|
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
112
|
-
|
112
|
+
|
113
113
|
return Klass;
|
114
114
|
}
|
115
115
|
|
@@ -122,19 +122,19 @@ function Widget(tag_name, methods) {
|
|
122
122
|
var Resizable = new Widget({
|
123
123
|
extend: {
|
124
124
|
version: '2.0.0',
|
125
|
-
|
125
|
+
|
126
126
|
EVENTS: $w('resize start release'),
|
127
|
-
|
127
|
+
|
128
128
|
Options: {
|
129
129
|
direction: null, // 'top', 'left', 'right', 'bottom', null for bidrectional
|
130
|
-
|
130
|
+
|
131
131
|
minWidth: null,
|
132
132
|
maxWidth: null,
|
133
133
|
minHeight: null,
|
134
134
|
maxHeight: null
|
135
135
|
}
|
136
136
|
},
|
137
|
-
|
137
|
+
|
138
138
|
/**
|
139
139
|
* Basic constructor
|
140
140
|
*
|
@@ -146,20 +146,20 @@ var Resizable = new Widget({
|
|
146
146
|
this
|
147
147
|
.$super('resizable', this.old_inst = $(element))
|
148
148
|
.setOptions(options);
|
149
|
-
|
149
|
+
|
150
150
|
if (this.options.direction) {
|
151
151
|
this.addClass('rui-resizable-'+ this.options.direction);
|
152
152
|
} else {
|
153
153
|
this.addClass('rui-resizable');
|
154
154
|
}
|
155
|
-
|
155
|
+
|
156
156
|
// initializing the inner structure
|
157
157
|
this.content = this.first('.rui-resizable-content') ||
|
158
158
|
$E('div', {'class': 'rui-resizable-content'}).insert(this._.childNodes).insertTo(this);
|
159
159
|
this.handle = this.first('.rui-resizable-handle') ||
|
160
160
|
$E('div', {'class': 'rui-resizable-handle'}).insertTo(this);
|
161
161
|
},
|
162
|
-
|
162
|
+
|
163
163
|
/**
|
164
164
|
* destructor
|
165
165
|
*
|
@@ -173,18 +173,18 @@ var Resizable = new Widget({
|
|
173
173
|
.removeClass('rui-resizable-right')
|
174
174
|
.removeClass('rui-resizable-bottom')
|
175
175
|
.insert(this.content._.childNodes);
|
176
|
-
|
176
|
+
|
177
177
|
this.content.remove();
|
178
178
|
this.handle.remove();
|
179
|
-
|
179
|
+
|
180
180
|
// swapping the old element back
|
181
181
|
if (this.old_inst) {
|
182
182
|
Wrapper.Cache[$uid(this._)] = this.old_inst;
|
183
183
|
}
|
184
|
-
|
184
|
+
|
185
185
|
return this;
|
186
186
|
},
|
187
|
-
|
187
|
+
|
188
188
|
/**
|
189
189
|
* Overriding the method to recognize the direction
|
190
190
|
* option from the element class-name
|
@@ -194,17 +194,17 @@ var Resizable = new Widget({
|
|
194
194
|
*/
|
195
195
|
setOptions: function(options, context) {
|
196
196
|
options = options || {};
|
197
|
-
|
197
|
+
|
198
198
|
// trying to recognize the direction
|
199
199
|
$w('top left right bottom').each(function(direction) {
|
200
200
|
if (this.hasClass('rui-resizable-'+ direction)) {
|
201
201
|
options.direction = direction;
|
202
202
|
}
|
203
203
|
}, this);
|
204
|
-
|
204
|
+
|
205
205
|
return this.$super(options, context);
|
206
206
|
},
|
207
|
-
|
207
|
+
|
208
208
|
/**
|
209
209
|
* Starts the resizing process
|
210
210
|
*
|
@@ -213,19 +213,19 @@ var Resizable = new Widget({
|
|
213
213
|
start: function(event) {
|
214
214
|
this.prevSizes = this.size();
|
215
215
|
this.prevEvPos = event.position();
|
216
|
-
|
216
|
+
|
217
217
|
// used later during the resize process
|
218
218
|
this.contXDiff = this.size().x - this.content.size().x;
|
219
219
|
this.contYDiff = this.size().y - this.content.size().y;
|
220
|
-
|
220
|
+
|
221
221
|
// trying to recognize the boundaries
|
222
222
|
$w('minWidth maxWidth minHeight maxHeight').each(function(dimension) {
|
223
223
|
this[dimension] = this.findDim(dimension);
|
224
224
|
}, this);
|
225
|
-
|
226
|
-
return this.fire('start', event);
|
225
|
+
|
226
|
+
return this.fire('start', {original: event});
|
227
227
|
},
|
228
|
-
|
228
|
+
|
229
229
|
/**
|
230
230
|
* Tracks the event during the resize process
|
231
231
|
*
|
@@ -243,17 +243,17 @@ var Resizable = new Widget({
|
|
243
243
|
max_y = this.maxHeight,
|
244
244
|
options = this.options,
|
245
245
|
direction = options.direction;
|
246
|
-
|
246
|
+
|
247
247
|
// calculating the new size
|
248
248
|
width += (direction === 'left' ? 1 : -1) * x_diff;
|
249
249
|
height += (direction === 'top' ? 1 : -1) * y_diff;
|
250
|
-
|
250
|
+
|
251
251
|
// applying the boundaries
|
252
252
|
if (width < min_x) { width = min_x; }
|
253
253
|
if (width > max_x) { width = max_x; }
|
254
254
|
if (height < min_y) { height = min_y; }
|
255
255
|
if (height > max_y) { height = max_y; }
|
256
|
-
|
256
|
+
|
257
257
|
// applying the sizes
|
258
258
|
if (prev_size.x !== width && direction !== 'top' && direction !== 'bottom') {
|
259
259
|
this.setWidth(width);
|
@@ -261,7 +261,7 @@ var Resizable = new Widget({
|
|
261
261
|
if (prev_size.y !== height && direction !== 'left' && direction !== 'right') {
|
262
262
|
this.setHeight(height);
|
263
263
|
}
|
264
|
-
|
264
|
+
|
265
265
|
// adjusting the previous cursor position so that it didn't had a shift
|
266
266
|
if (width == min_x || width == max_x) {
|
267
267
|
event_pos.x = handle.left + handle.width / 2;
|
@@ -269,13 +269,13 @@ var Resizable = new Widget({
|
|
269
269
|
if (height == min_y || height == max_y) {
|
270
270
|
event_pos.y = handle.top + handle.height / 2;
|
271
271
|
}
|
272
|
-
|
272
|
+
|
273
273
|
this.prevEvPos = event_pos;
|
274
274
|
this.prevSizes = this.size();
|
275
|
-
|
276
|
-
this.fire('resize', event);
|
275
|
+
|
276
|
+
this.fire('resize', {original: event});
|
277
277
|
},
|
278
|
-
|
278
|
+
|
279
279
|
/**
|
280
280
|
* Sets the width of the widget
|
281
281
|
*
|
@@ -286,7 +286,7 @@ var Resizable = new Widget({
|
|
286
286
|
this.content.setWidth(width - this.contXDiff);
|
287
287
|
return this.$super(width);
|
288
288
|
},
|
289
|
-
|
289
|
+
|
290
290
|
/**
|
291
291
|
* Sets the height of the widget
|
292
292
|
*
|
@@ -297,33 +297,22 @@ var Resizable = new Widget({
|
|
297
297
|
this.content.setHeight(height - this.contYDiff);
|
298
298
|
return this.$super(height);
|
299
299
|
},
|
300
|
-
|
300
|
+
|
301
301
|
/**
|
302
302
|
* Marks it the end of the action
|
303
303
|
*
|
304
304
|
* @return Resizable this
|
305
305
|
*/
|
306
306
|
release: function(event) {
|
307
|
-
return this.fire('release', event);
|
308
|
-
},
|
309
|
-
|
310
|
-
/**
|
311
|
-
* Overloading the standard method so that it was sending
|
312
|
-
* current instance as an argument
|
313
|
-
*
|
314
|
-
* @param String event name
|
315
|
-
* @return Resizable this
|
316
|
-
*/
|
317
|
-
fire: function(event, dom_event) {
|
318
|
-
return this.$super(event, this, dom_event);
|
307
|
+
return this.fire('release', {original: event});
|
319
308
|
},
|
320
|
-
|
309
|
+
|
321
310
|
// protected
|
322
311
|
|
323
312
|
// finds dimensions of the element
|
324
313
|
findDim: function(dimension) {
|
325
314
|
var style = this.options[dimension] || this.getStyle(dimension);
|
326
|
-
|
315
|
+
|
327
316
|
if (style && /\d+/.test(style) && parseFloat(style) > 0) {
|
328
317
|
var what = R(dimension).include('Width') ? 'width' : 'height',
|
329
318
|
dummy = (this._dummy || (this._dummy = $E('div', {
|
@@ -331,15 +320,16 @@ var Resizable = new Widget({
|
|
331
320
|
})))
|
332
321
|
.setStyle(what, style)
|
333
322
|
.insertTo(this, 'before');
|
334
|
-
|
323
|
+
|
335
324
|
var size = dummy._['offset' + R(what).capitalize()];
|
336
325
|
dummy.remove();
|
337
|
-
|
326
|
+
|
338
327
|
return size;
|
339
328
|
}
|
340
329
|
}
|
341
330
|
});
|
342
331
|
|
332
|
+
|
343
333
|
/**
|
344
334
|
* Document level hooks for resizables
|
345
335
|
*
|
@@ -350,25 +340,25 @@ $(document).on({
|
|
350
340
|
var handle = event.find('.rui-resizable-handle');
|
351
341
|
if (handle) {
|
352
342
|
var resizable = handle.parent();
|
353
|
-
|
343
|
+
|
354
344
|
if (resizable instanceof Element) {
|
355
345
|
resizable = new Resizable(resizable);
|
356
346
|
}
|
357
|
-
|
347
|
+
|
358
348
|
Resizable.current = resizable.start(event.stop());
|
359
349
|
}
|
360
350
|
},
|
361
|
-
|
351
|
+
|
362
352
|
mousemove: function(event) {
|
363
353
|
var resizable = Resizable.current;
|
364
354
|
if (resizable) {
|
365
355
|
resizable.track(event);
|
366
356
|
}
|
367
357
|
},
|
368
|
-
|
358
|
+
|
369
359
|
mouseup: function(event) {
|
370
360
|
var resizable = Resizable.current;
|
371
|
-
|
361
|
+
|
372
362
|
if (resizable) {
|
373
363
|
resizable.release(event);
|
374
364
|
Resizable.current = null;
|
@@ -384,6 +374,7 @@ $(window).onBlur(function(event) {
|
|
384
374
|
}
|
385
375
|
});
|
386
376
|
|
377
|
+
|
387
378
|
/**
|
388
379
|
* Element level hook to make things resizable
|
389
380
|
*
|
@@ -400,7 +391,7 @@ Element.include({
|
|
400
391
|
new Resizable(this, options);
|
401
392
|
return this;
|
402
393
|
},
|
403
|
-
|
394
|
+
|
404
395
|
/**
|
405
396
|
* Destroys a resizable functionality
|
406
397
|
*
|
@@ -414,7 +405,8 @@ Element.include({
|
|
414
405
|
}
|
415
406
|
});
|
416
407
|
|
408
|
+
|
417
409
|
document.write("<style type=\"text/css\">.rui-resizable,.rui-resizable-top,.rui-resizable-left,.rui-resizable-right,.rui-resizable-bottom,.rui-resizable-content .rui-resizable-handle{margin:0;padding:0;overflow:none;border:none;background:none;width:auto;height:auto;min-width:none;max-width:none;min-height:none;max-height:none}.rui-resizable,.rui-resizable-top,.rui-resizable-left,.rui-resizable-right,.rui-resizable-bottom{position:relative;min-width:8em;min-height:8em;border:1px solid #DDD}.rui-resizable-content{overflow:auto;padding:.5em;position:relative}.rui-resizable-handle{position:absolute;background-image:url(/images/rightjs-ui/resizable.png);background-repeat:no-repeat;background-color:#DDD;cursor:move}.rui-resizable .rui-resizable-handle{right:0;bottom:0;background-position:-2px -2px;background-color:transparent;width:16px;height:16px}.rui-resizable-top .rui-resizable-handle,.rui-resizable-bottom .rui-resizable-handle{height:8px;width:100%;background-position:center -26px;cursor:row-resize}.rui-resizable-left .rui-resizable-handle,.rui-resizable-right .rui-resizable-handle{top:0px;width:8px;height:100%;background-position:-26px center;cursor:col-resize}.rui-resizable-top .rui-resizable-content{padding-top:1em}.rui-resizable-top .rui-resizable-handle{top:0}.rui-resizable-bottom .rui-resizable-content{padding-bottom:1em}.rui-resizable-bottom .rui-resizable-handle{bottom:0}.rui-resizable-left .rui-resizable-content{padding-left:1em}.rui-resizable-left .rui-resizable-handle{left:0}.rui-resizable-right .rui-resizable-content{padding-right:1em}.rui-resizable-right .rui-resizable-handle{right:0}</style>");
|
418
410
|
|
419
411
|
return Resizable;
|
420
|
-
})(document, RightJS);
|
412
|
+
})(document, RightJS);
|