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
@@ -8,8 +8,8 @@ var Resizable=RightJS.Resizable=function(r,c){var k=c.$,l=c.$w,m=c.$E,t=c.Wrappe
|
|
8
8
|
d){d=d||this;c.Options.setOptions.call(this,c.Object.merge(h,eval("("+(d.get("data-"+this.key)||"{}")+")")));return this}});f=new c.Wrapper(f,b);c.Observer.createShortcuts(f.prototype,f.EVENTS||[]);return f})({extend:{version:"2.0.0",EVENTS:l("resize start release"),Options:{direction:null,minWidth:null,maxWidth:null,minHeight:null,maxHeight:null}},initialize:function(a,b){this.$super("resizable",this.old_inst=k(a)).setOptions(b);this.options.direction?this.addClass("rui-resizable-"+this.options.direction):
|
9
9
|
this.addClass("rui-resizable");this.content=this.first(".rui-resizable-content")||m("div",{"class":"rui-resizable-content"}).insert(this._.childNodes).insertTo(this);this.handle=this.first(".rui-resizable-handle")||m("div",{"class":"rui-resizable-handle"}).insertTo(this)},destroy:function(){this.removeClass("rui-resizable").removeClass("rui-resizable-top").removeClass("rui-resizable-left").removeClass("rui-resizable-right").removeClass("rui-resizable-bottom").insert(this.content._.childNodes);this.content.remove();
|
10
10
|
this.handle.remove();if(this.old_inst)t.Cache[$uid(this._)]=this.old_inst;return this},setOptions:function(a,b){a=a||{};l("top left right bottom").each(function(f){if(this.hasClass("rui-resizable-"+f))a.direction=f},this);return this.$super(a,b)},start:function(a){this.prevSizes=this.size();this.prevEvPos=a.position();this.contXDiff=this.size().x-this.content.size().x;this.contYDiff=this.size().y-this.content.size().y;l("minWidth maxWidth minHeight maxHeight").each(function(b){this[b]=this.findDim(b)},
|
11
|
-
this);return this.fire("start",a)},track:function(a){var b=a.position(),f=this.prevEvPos,h=this.handle.dimensions(),d=this.prevSizes,e=d.x,i=d.y,u=f.y-b.y,n=this.minWidth,o=this.maxWidth,p=this.minHeight,q=this.maxHeight,j=this.options.direction;e+=(j==="left"?1:-1)*(f.x-b.x);i+=(j==="top"?1:-1)*u;if(e<n)e=n;if(e>o)e=o;if(i<p)i=p;if(i>q)i=q;d.x!==e&&j!=="top"&&j!=="bottom"&&this.setWidth(e);d.y!==i&&j!=="left"&&j!=="right"&&this.setHeight(i);if(e==n||e==o)b.x=h.left+h.width/2;if(i==p||
|
12
|
-
h.height/2;this.prevEvPos=b;this.prevSizes=this.size();this.fire("resize",a)},setWidth:function(a){this.content.setWidth(a-this.contXDiff);return this.$super(a)},setHeight:function(a){this.content.setHeight(a-this.contYDiff);return this.$super(a)},release:function(a){return this.fire("release",a
|
13
|
-
|
14
|
-
|
11
|
+
this);return this.fire("start",{original:a})},track:function(a){var b=a.position(),f=this.prevEvPos,h=this.handle.dimensions(),d=this.prevSizes,e=d.x,i=d.y,u=f.y-b.y,n=this.minWidth,o=this.maxWidth,p=this.minHeight,q=this.maxHeight,j=this.options.direction;e+=(j==="left"?1:-1)*(f.x-b.x);i+=(j==="top"?1:-1)*u;if(e<n)e=n;if(e>o)e=o;if(i<p)i=p;if(i>q)i=q;d.x!==e&&j!=="top"&&j!=="bottom"&&this.setWidth(e);d.y!==i&&j!=="left"&&j!=="right"&&this.setHeight(i);if(e==n||e==o)b.x=h.left+h.width/2;if(i==p||
|
12
|
+
i==q)b.y=h.top+h.height/2;this.prevEvPos=b;this.prevSizes=this.size();this.fire("resize",{original:a})},setWidth:function(a){this.content.setWidth(a-this.contXDiff);return this.$super(a)},setHeight:function(a){this.content.setHeight(a-this.contYDiff);return this.$super(a)},release:function(a){return this.fire("release",{original:a})},findDim:function(a){var b=this.options[a]||this.getStyle(a);if(b&&/\d+/.test(b)&&parseFloat(b)>0){a=c(a).include("Width")?"width":"height";b=(this._dummy||(this._dummy=
|
13
|
+
m("div",{style:"visibility:hidden;z-index:-1"}))).setStyle(a,b).insertTo(this,"before");a=b._["offset"+c(a).capitalize()];b.remove();return a}}});k(r).on({mousedown:function(a){var b=a.find(".rui-resizable-handle");if(b){b=b.parent();if(b instanceof s)b=new g(b);g.current=b.start(a.stop())}},mousemove:function(a){var b=g.current;b&&b.track(a)},mouseup:function(a){var b=g.current;if(b){b.release(a);g.current=null}}});k(window).onBlur(function(a){var b=g.current;if(b){b.release(a);g.current=null}});
|
14
|
+
s.include({makeResizable:function(a){new g(this,a);return this},undoResizable:function(){this instanceof g&&this.destroy();return this}});r.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>');
|
15
15
|
return g}(document,RightJS);
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* Selectable unit for RightJS
|
2
|
+
* Selectable unit for RightJS
|
3
3
|
* http://rightjs.org/ui/selectable
|
4
4
|
*
|
5
5
|
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
@@ -45,13 +45,13 @@ var R = RightJS,
|
|
45
45
|
* @param String tag-name or Object methods
|
46
46
|
* @param Object methods
|
47
47
|
* @return Widget wrapper
|
48
|
-
*/
|
48
|
+
*/
|
49
49
|
function Widget(tag_name, methods) {
|
50
50
|
if (!methods) {
|
51
51
|
methods = tag_name;
|
52
52
|
tag_name = 'DIV';
|
53
53
|
}
|
54
|
-
|
54
|
+
|
55
55
|
/**
|
56
56
|
* An Abstract Widget Unit
|
57
57
|
*
|
@@ -68,17 +68,17 @@ function Widget(tag_name, methods) {
|
|
68
68
|
initialize: function(key, options) {
|
69
69
|
this.key = key;
|
70
70
|
var args = [{'class': 'rui-' + key}];
|
71
|
-
|
71
|
+
|
72
72
|
// those two have different constructors
|
73
73
|
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
74
74
|
args.unshift(tag_name);
|
75
75
|
}
|
76
76
|
this.$super.apply(this, args);
|
77
|
-
|
77
|
+
|
78
78
|
if (RightJS.isString(options)) {
|
79
79
|
options = RightJS.$(options);
|
80
80
|
}
|
81
|
-
|
81
|
+
|
82
82
|
// if the options is another element then
|
83
83
|
// try to dynamically rewrap it with our widget
|
84
84
|
if (options instanceof RightJS.Element) {
|
@@ -111,16 +111,16 @@ function Widget(tag_name, methods) {
|
|
111
111
|
return this;
|
112
112
|
}
|
113
113
|
});
|
114
|
-
|
114
|
+
|
115
115
|
/**
|
116
116
|
* Creating the actual widget class
|
117
117
|
*
|
118
118
|
*/
|
119
119
|
var Klass = new RightJS.Wrapper(AbstractWidget, methods);
|
120
|
-
|
120
|
+
|
121
121
|
// creating the widget related shortcuts
|
122
122
|
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || []);
|
123
|
-
|
123
|
+
|
124
124
|
return Klass;
|
125
125
|
}
|
126
126
|
|
@@ -132,7 +132,7 @@ function Widget(tag_name, methods) {
|
|
132
132
|
* Copyright (C) 2010 Nikolay Nemshilov
|
133
133
|
*/
|
134
134
|
var Updater = {
|
135
|
-
|
135
|
+
|
136
136
|
/**
|
137
137
|
* Assigns the unit to work with an input element
|
138
138
|
*
|
@@ -145,7 +145,7 @@ var Updater = {
|
|
145
145
|
element[element.setValue ? 'setValue' : 'update'](event.target.getValue());
|
146
146
|
}
|
147
147
|
}).curry(element);
|
148
|
-
|
148
|
+
|
149
149
|
var connect = R(function(element, object) {
|
150
150
|
element = $(element);
|
151
151
|
if (element && element.onChange) {
|
@@ -154,7 +154,7 @@ var Updater = {
|
|
154
154
|
}).bind(object));
|
155
155
|
}
|
156
156
|
}).curry(element);
|
157
|
-
|
157
|
+
|
158
158
|
if ($(element)) {
|
159
159
|
assign({target: this});
|
160
160
|
connect(this);
|
@@ -164,7 +164,7 @@ var Updater = {
|
|
164
164
|
connect(this);
|
165
165
|
}.bind(this)));
|
166
166
|
}
|
167
|
-
|
167
|
+
|
168
168
|
return this.onChange(assign);
|
169
169
|
}
|
170
170
|
};
|
@@ -177,30 +177,30 @@ var Updater = {
|
|
177
177
|
*/
|
178
178
|
var Selectable = new Widget('UL', {
|
179
179
|
include: Updater,
|
180
|
-
|
180
|
+
|
181
181
|
extend: {
|
182
182
|
version: '2.0.0',
|
183
|
-
|
183
|
+
|
184
184
|
EVENTS: $w('change select unselect disable enable hover leave show hide'),
|
185
|
-
|
185
|
+
|
186
186
|
Options: {
|
187
187
|
options: null, // a hash of key-value pairs
|
188
188
|
selected: null, // an array of selected keys
|
189
189
|
disabled: null, // an array of disabled keys
|
190
|
-
|
190
|
+
|
191
191
|
multiple: true, // a flag if it shoulde a multiselect or a single select widget
|
192
|
-
|
192
|
+
|
193
193
|
fxName: 'slide', // the drop-down options list fx-name null, 'slide', 'fade'
|
194
194
|
fxDuration: 'short', // the drop-down options list fx-duration
|
195
|
-
|
195
|
+
|
196
196
|
update: null, // a field to be assigned to
|
197
197
|
parseIds: false, // if it should parse integer ids out of the keys
|
198
|
-
|
198
|
+
|
199
199
|
limit: null, // put some number if you'd like to limit the number of selected items
|
200
|
-
|
200
|
+
|
201
201
|
hCont : '•' // single-selectable handle content
|
202
202
|
},
|
203
|
-
|
203
|
+
|
204
204
|
// converting normal select boxes into selectables
|
205
205
|
rescan: function(context) {
|
206
206
|
$(context||document).find('.rui-selectable').each(function(element) {
|
@@ -210,7 +210,7 @@ var Selectable = new Widget('UL', {
|
|
210
210
|
});
|
211
211
|
}
|
212
212
|
},
|
213
|
-
|
213
|
+
|
214
214
|
/**
|
215
215
|
* Basic constructor
|
216
216
|
*
|
@@ -220,19 +220,19 @@ var Selectable = new Widget('UL', {
|
|
220
220
|
initialize: function() {
|
221
221
|
var args = $A(arguments).compact(), options = args.pop(),
|
222
222
|
element = args.pop(), selectbox;
|
223
|
-
|
223
|
+
|
224
224
|
// figuring out the arguments
|
225
225
|
if (!isHash(options) || options instanceof Element) {
|
226
226
|
element = $(element || options);
|
227
227
|
options = {};
|
228
228
|
}
|
229
|
-
|
229
|
+
|
230
230
|
// converting the selectboxes
|
231
231
|
if (element && element instanceof Input) {
|
232
232
|
options = this.harvestOptions(selectbox = element);
|
233
233
|
element = options;
|
234
234
|
}
|
235
|
-
|
235
|
+
|
236
236
|
// main initialization
|
237
237
|
this
|
238
238
|
.$super('selectable', element)
|
@@ -243,42 +243,42 @@ var Selectable = new Widget('UL', {
|
|
243
243
|
mouseout: this._mouseout,
|
244
244
|
mouseup: this._mouseup,
|
245
245
|
click: this._click,
|
246
|
-
|
246
|
+
|
247
247
|
select: this._change,
|
248
248
|
unselect: this._change
|
249
249
|
});
|
250
|
-
|
250
|
+
|
251
251
|
if (this.empty()) { this.build(); }
|
252
|
-
|
252
|
+
|
253
253
|
// applying the rest of the options
|
254
254
|
options = this.options;
|
255
|
-
|
255
|
+
|
256
256
|
// single-select options additional features
|
257
257
|
if (!options.multiple || this.hasClass('rui-selectable-single')) {
|
258
258
|
this.isSingle = true;
|
259
259
|
this.addClass('rui-selectable-single');
|
260
260
|
this.buildSingle();
|
261
|
-
|
261
|
+
|
262
262
|
if (options.selected === null) {
|
263
263
|
this.select(this.items()[0]);
|
264
264
|
}
|
265
265
|
}
|
266
|
-
|
266
|
+
|
267
267
|
if (options.disabled) { this.disable(options.disabled); }
|
268
268
|
if (options.selected) { this.select(options.selected); }
|
269
269
|
if (options.update) { this.assignTo(options.update); }
|
270
|
-
|
270
|
+
|
271
271
|
// replacing the selectboxes with the selectables
|
272
272
|
if (selectbox) {
|
273
273
|
this.assignTo(selectbox).insertTo(selectbox, 'before');
|
274
|
-
|
274
|
+
|
275
275
|
// hidding it in the hidden layer so it was sent with the form
|
276
276
|
selectbox.wrap($E('div', {
|
277
277
|
style: 'position:absolute;z-index:-1;visibility:hidden;width:0;height:0;overflow:hidden'
|
278
278
|
}));
|
279
279
|
}
|
280
280
|
},
|
281
|
-
|
281
|
+
|
282
282
|
/**
|
283
283
|
* Sets the value
|
284
284
|
*
|
@@ -291,13 +291,13 @@ var Selectable = new Widget('UL', {
|
|
291
291
|
value = value.split(',').map('trim')
|
292
292
|
.filter(function(s) { return !s.blank(); });
|
293
293
|
}
|
294
|
-
|
294
|
+
|
295
295
|
// resetting the selections
|
296
296
|
this.items().each('removeClass', 'rui-selectable-selected');
|
297
|
-
|
297
|
+
|
298
298
|
return this.select(value);
|
299
299
|
},
|
300
|
-
|
300
|
+
|
301
301
|
/**
|
302
302
|
* Returns the list of selected items
|
303
303
|
*
|
@@ -313,7 +313,7 @@ var Selectable = new Widget('UL', {
|
|
313
313
|
}, this);
|
314
314
|
}
|
315
315
|
},
|
316
|
-
|
316
|
+
|
317
317
|
/**
|
318
318
|
* disables the given key or keys
|
319
319
|
* NOTE: if no keys specified, then all the items will be disabled
|
@@ -327,7 +327,7 @@ var Selectable = new Widget('UL', {
|
|
327
327
|
}, this);
|
328
328
|
return this;
|
329
329
|
},
|
330
|
-
|
330
|
+
|
331
331
|
/**
|
332
332
|
* disables the given key or keys
|
333
333
|
* NOTE: if no keys specified, then all the items will be enabled
|
@@ -341,7 +341,7 @@ var Selectable = new Widget('UL', {
|
|
341
341
|
}, this);
|
342
342
|
return this;
|
343
343
|
},
|
344
|
-
|
344
|
+
|
345
345
|
/**
|
346
346
|
* Checks if the given key or keys are disabled
|
347
347
|
* NOTE: if no keys specified, then will check if all the items are disabled
|
@@ -352,7 +352,7 @@ var Selectable = new Widget('UL', {
|
|
352
352
|
disabled: function(keys) {
|
353
353
|
return this.mapOrAll(keys).every('hasClass', 'rui-selectable-disabled');
|
354
354
|
},
|
355
|
-
|
355
|
+
|
356
356
|
/**
|
357
357
|
* selects item(s) that refers to the given key or keys
|
358
358
|
*
|
@@ -361,12 +361,12 @@ var Selectable = new Widget('UL', {
|
|
361
361
|
*/
|
362
362
|
select: function(keys) {
|
363
363
|
var items = this.mapEnabled(keys), selected_class = 'rui-selectable-selected';
|
364
|
-
|
364
|
+
|
365
365
|
if (this.isSingle && items) {
|
366
366
|
this.items().each('removeClass', selected_class);
|
367
367
|
items = R([items[0]]);
|
368
368
|
}
|
369
|
-
|
369
|
+
|
370
370
|
// applying the selection limit if ncessary
|
371
371
|
if (!this.isSingle && this.options.limit) {
|
372
372
|
var selected = this.items().filter('hasClass', selected_class), clean = [];
|
@@ -378,14 +378,14 @@ var Selectable = new Widget('UL', {
|
|
378
378
|
}
|
379
379
|
items = clean;
|
380
380
|
}
|
381
|
-
|
382
|
-
items.each(function(item) {
|
381
|
+
|
382
|
+
items.compact().each(function(item) {
|
383
383
|
this.fire('select', item.addClass(selected_class));
|
384
384
|
}, this);
|
385
|
-
|
385
|
+
|
386
386
|
return this;
|
387
387
|
},
|
388
|
-
|
388
|
+
|
389
389
|
/**
|
390
390
|
* Unselects item(s) that refers to the given key or keys
|
391
391
|
*
|
@@ -394,14 +394,14 @@ var Selectable = new Widget('UL', {
|
|
394
394
|
*/
|
395
395
|
unselect: function(keys) {
|
396
396
|
var prev_value = this.getValue();
|
397
|
-
|
397
|
+
|
398
398
|
this.mapEnabled(keys).each(function(item) {
|
399
399
|
this.fire('unselect', item.removeClass('rui-selectable-selected'));
|
400
400
|
}, this);
|
401
|
-
|
401
|
+
|
402
402
|
return this;
|
403
403
|
},
|
404
|
-
|
404
|
+
|
405
405
|
/**
|
406
406
|
* Checks if item(s) are selected
|
407
407
|
*
|
@@ -411,7 +411,7 @@ var Selectable = new Widget('UL', {
|
|
411
411
|
selected: function(keys) {
|
412
412
|
return this.mapEnabled(keys).every('hasClass', 'rui-selectable-selected');
|
413
413
|
},
|
414
|
-
|
414
|
+
|
415
415
|
/**
|
416
416
|
* Overloading the method so it worked nicely with the single versions
|
417
417
|
*
|
@@ -423,10 +423,10 @@ var Selectable = new Widget('UL', {
|
|
423
423
|
Element.prototype.insertTo.call(
|
424
424
|
(this.isSingle ? this.container : this), target, where
|
425
425
|
);
|
426
|
-
|
426
|
+
|
427
427
|
return this;
|
428
428
|
},
|
429
|
-
|
429
|
+
|
430
430
|
// protected
|
431
431
|
|
432
432
|
// wrapping the events trigger to feed it with some more options
|
@@ -438,7 +438,7 @@ var Selectable = new Widget('UL', {
|
|
438
438
|
}
|
439
439
|
return this;
|
440
440
|
},
|
441
|
-
|
441
|
+
|
442
442
|
// finds out the value for the item
|
443
443
|
itemValue: function(item) {
|
444
444
|
var value = item.get('id') || item.get('val');
|
@@ -449,11 +449,11 @@ var Selectable = new Widget('UL', {
|
|
449
449
|
items: function() {
|
450
450
|
return this.find('li');
|
451
451
|
},
|
452
|
-
|
452
|
+
|
453
453
|
// returns matching items or all of them if there's no key
|
454
454
|
mapOrAll: function(keys) {
|
455
455
|
var items = this.items();
|
456
|
-
|
456
|
+
|
457
457
|
if (defined(keys)) {
|
458
458
|
if (!isArray(keys)) { keys = [keys]; }
|
459
459
|
|
@@ -471,22 +471,22 @@ var Selectable = new Widget('UL', {
|
|
471
471
|
return item;
|
472
472
|
}, this).compact();
|
473
473
|
}
|
474
|
-
|
474
|
+
|
475
475
|
return items;
|
476
476
|
},
|
477
|
-
|
477
|
+
|
478
478
|
// maps and filters only enabled items
|
479
479
|
mapEnabled: function(keys) {
|
480
480
|
return this.mapOrAll(keys).filter(function(item) {
|
481
481
|
return !item.hasClass('rui-selectable-disabled');
|
482
482
|
}, this);
|
483
483
|
},
|
484
|
-
|
484
|
+
|
485
485
|
// onmousedown callback
|
486
486
|
_mousedown: function(event) {
|
487
487
|
event.stop();
|
488
488
|
var item = event.target, items = this.items();
|
489
|
-
|
489
|
+
|
490
490
|
if (!this.disabled(item)) {
|
491
491
|
if (this.isSingle) { // single-selects are always select
|
492
492
|
this.select(item);
|
@@ -497,40 +497,40 @@ var Selectable = new Widget('UL', {
|
|
497
497
|
this.select(item);
|
498
498
|
this._massSelect = true; // mass-selection start
|
499
499
|
}
|
500
|
-
|
500
|
+
|
501
501
|
// mass-selection with a shift/meta key
|
502
502
|
if ((event.shiftKey || event.metaKey) && this._prevItem) {
|
503
503
|
var index1 = items.indexOf(this._prevItem);
|
504
504
|
var index2 = items.indexOf(item);
|
505
|
-
|
505
|
+
|
506
506
|
if (index1 != index2) {
|
507
507
|
if (index1 > index2) {
|
508
508
|
var t = index1;
|
509
509
|
index1 = index2;
|
510
510
|
index2 = index1;
|
511
511
|
}
|
512
|
-
|
512
|
+
|
513
513
|
for (var i=index1; i < index2; i++) {
|
514
514
|
this[this._prevItem.hasClass('rui-selectable-selected') ? 'select' : 'unselect'](items[i]);
|
515
515
|
}
|
516
516
|
}
|
517
517
|
}
|
518
|
-
|
518
|
+
|
519
519
|
this._prevItem = item;
|
520
520
|
}
|
521
521
|
},
|
522
|
-
|
522
|
+
|
523
523
|
// onmouseup callback
|
524
524
|
_mouseup: function(event) {
|
525
525
|
event.stop();
|
526
526
|
this._massRemove = this._massSelect = false; // mass-selection stop
|
527
527
|
},
|
528
|
-
|
528
|
+
|
529
529
|
// mouseover callback
|
530
530
|
_mouseover: function(event) {
|
531
531
|
var item = event.target;
|
532
532
|
this.fire('hover', item);
|
533
|
-
|
533
|
+
|
534
534
|
if (!this.isSingle) {
|
535
535
|
if (this._massSelect) {
|
536
536
|
this.select(item);
|
@@ -539,17 +539,17 @@ var Selectable = new Widget('UL', {
|
|
539
539
|
}
|
540
540
|
}
|
541
541
|
},
|
542
|
-
|
542
|
+
|
543
543
|
// mouseout callback
|
544
544
|
_mouseout: function(event) {
|
545
545
|
this.fire('leave', event.target);
|
546
546
|
},
|
547
|
-
|
547
|
+
|
548
548
|
// mouseclick callback
|
549
549
|
_click: function(event) {
|
550
550
|
event.stop();
|
551
551
|
},
|
552
|
-
|
552
|
+
|
553
553
|
// select/unselect listener fires the onchange events
|
554
554
|
_change: function() {
|
555
555
|
if (''+this.value != ''+this.getValue()) {
|
@@ -557,11 +557,11 @@ var Selectable = new Widget('UL', {
|
|
557
557
|
this.fire('change');
|
558
558
|
}
|
559
559
|
},
|
560
|
-
|
560
|
+
|
561
561
|
// builds the widget programmatically
|
562
562
|
build: function() {
|
563
563
|
var options = this.options.options, items = R([]);
|
564
|
-
|
564
|
+
|
565
565
|
if (isArray(options)) {
|
566
566
|
options.each(function(option) {
|
567
567
|
items.push(isArray(option) ? option : [option, option]);
|
@@ -575,10 +575,10 @@ var Selectable = new Widget('UL', {
|
|
575
575
|
items.each(function(option) {
|
576
576
|
this.insert($E('li', {val: option[1], html: option[0]}));
|
577
577
|
}, this);
|
578
|
-
|
578
|
+
|
579
579
|
return this;
|
580
580
|
},
|
581
|
-
|
581
|
+
|
582
582
|
// builds a container for a single-select
|
583
583
|
buildSingle: function() {
|
584
584
|
this.container = $E('div', {'class': 'rui-selectable-container'})
|
@@ -587,35 +587,35 @@ var Selectable = new Widget('UL', {
|
|
587
587
|
this.display = $E('ul', {'class': 'rui-selectable-display'})
|
588
588
|
])
|
589
589
|
.onClick(R(this.toggleList).bind(this));
|
590
|
-
|
590
|
+
|
591
591
|
if (this.parent()) {
|
592
592
|
this.container.insertTo(this, 'instead');
|
593
593
|
}
|
594
|
-
|
594
|
+
|
595
595
|
this.container.insert(this);
|
596
|
-
|
596
|
+
|
597
597
|
$(document).onClick(R(this.hideList).bind(this));
|
598
|
-
|
598
|
+
|
599
599
|
return this
|
600
600
|
.onSelect('showItem')
|
601
601
|
.onSelect('hideList')
|
602
602
|
.addClass('rui-dd-menu');
|
603
603
|
},
|
604
|
-
|
604
|
+
|
605
605
|
// toggles the single-selects list
|
606
606
|
toggleList: function(event) {
|
607
607
|
event.stop();
|
608
608
|
return this.visible() ? this.hideList() : this.showList(event);
|
609
609
|
},
|
610
|
-
|
610
|
+
|
611
611
|
// shows list for the single-selects
|
612
612
|
showList: function(event) {
|
613
613
|
event.stop();
|
614
|
-
|
614
|
+
|
615
615
|
$$('.rui-selectable-single').without(this).each('hide');
|
616
|
-
|
616
|
+
|
617
617
|
var dims = this.container.dimensions(), pos = this.container.position();
|
618
|
-
|
618
|
+
|
619
619
|
this.setStyle({
|
620
620
|
top: (dims.top + dims.height - pos.y - 1) + 'px',
|
621
621
|
left: (dims.left - pos.x) + 'px',
|
@@ -624,12 +624,12 @@ var Selectable = new Widget('UL', {
|
|
624
624
|
duration: this.options.fxDuration,
|
625
625
|
onFinish: this.fire.bind(this, 'show', this)
|
626
626
|
});
|
627
|
-
|
627
|
+
|
628
628
|
if (!this.options.fxName) {
|
629
629
|
this.fire('show', this);
|
630
630
|
}
|
631
631
|
},
|
632
|
-
|
632
|
+
|
633
633
|
// hides the list for the single-selects
|
634
634
|
hideList: function() {
|
635
635
|
if (this.isSingle && this.visible()) {
|
@@ -637,41 +637,42 @@ var Selectable = new Widget('UL', {
|
|
637
637
|
duration: this.options.fxDuration,
|
638
638
|
onFinish: this.fire.bind(this, 'hide')
|
639
639
|
});
|
640
|
-
|
640
|
+
|
641
641
|
if (!this.options.fxName) {
|
642
642
|
this.fire('hide');
|
643
643
|
}
|
644
644
|
}
|
645
645
|
},
|
646
|
-
|
646
|
+
|
647
647
|
// shows the item in the main view of a single-selector
|
648
648
|
showItem: function() {
|
649
649
|
var item = this.items().first('hasClass', 'rui-selectable-selected') || this.items().first();
|
650
650
|
this.display.html('<li>'+(item ? item.html() : ' ')+'</li>');
|
651
651
|
},
|
652
|
-
|
652
|
+
|
653
653
|
// harvests options from a selectbox element
|
654
654
|
harvestOptions: function(selectbox) {
|
655
655
|
var options = {};
|
656
|
-
|
656
|
+
|
657
657
|
options.multiple = selectbox.has('multiple');
|
658
658
|
options.options = R([]);
|
659
659
|
options.selected = R([]);
|
660
660
|
options.disabled = R([]);
|
661
|
-
|
661
|
+
|
662
662
|
$A(selectbox._.getElementsByTagName('OPTION')).each(function(option, index) {
|
663
663
|
options.options.push([option.innerHTML, $(option).get('value') || option.innerHTML]);
|
664
|
-
|
664
|
+
|
665
665
|
if (option.selected && !selectbox._.disabled) { options.selected.push(index); }
|
666
666
|
if (option.disabled || selectbox._.disabled) { options.disabled.push(index); }
|
667
667
|
});
|
668
|
-
|
668
|
+
|
669
669
|
if (options.selected.empty()) { options.selected = 0; }
|
670
|
-
|
670
|
+
|
671
671
|
return options;
|
672
672
|
}
|
673
673
|
});
|
674
674
|
|
675
|
+
|
675
676
|
/**
|
676
677
|
* The document on-load for Selectable
|
677
678
|
*
|
@@ -681,7 +682,8 @@ $(document).onReady(function() {
|
|
681
682
|
Selectable.rescan();
|
682
683
|
});
|
683
684
|
|
685
|
+
|
684
686
|
document.write("<style type=\"text/css\"> *.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em} *.rui-selectable, *.rui-selectable li, *.rui-selectable dt, *.rui-selectable dd, *.rui-selectable ul,div.rui-selectable-container ul.rui-selectable-display,div.rui-selectable-container ul.rui-selectable-display li{margin:0;padding:0;border:none;background:none;list-style:none} *.rui-selectable{border:1px solid #CCC;border-bottom:none;display:inline-block; *display:inline; *zoom:1;min-width:10em;-moz-border-radius:.2em;-webkit-border-radius:.2em;user-select:none;-moz-user-select:none;-webkit-user-select:none} *.rui-selectable li{padding:.3em 1em;cursor:pointer;border-bottom:1px solid #CCC} *.rui-selectable li:hover{background:#EEE} *.rui-selectable li.rui-selectable-selected{font-weight:bold;background:#DDD} *.rui-selectable li.rui-selectable-disabled, *.rui-selectable li.rui-selectable-disabled:hover{background:#CCC;color:#777;cursor:default}dl.rui-selectable dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE;border-bottom:1px solid #CCC}dl.rui-selectable dd li{padding-left:1.5em} *.rui-selectable-single{background:#FFF;display:none}div.rui-selectable-container{border:1px solid #CCC;-moz-border-radius:.2em;-webkit-border-radius:.2em;display:inline-block; *display:inline; *zoom:1; *width:10em;vertical-align:middle;min-width:10em;cursor:pointer;height:1.6em;position:relative}div.rui-selectable-container div.rui-selectable-handle{font-family:Arial;float:right;width:0.8em;background:#DDD;text-align:center;height:100%;line-height:0.8em;font-size:200%;color:#888;border-left:1px solid #CCC}div.rui-selectable-container:hover div.rui-selectable-handle{color:#666}div.rui-selectable-container ul.rui-selectable-display{display:block;width:auto;margin-right:2em;overflow:hidden}div.rui-selectable-container ul.rui-selectable-display li{line-height:1.6em;padding:0 .5em}select.rui-selectable{visibility:hidden}</style>");
|
685
687
|
|
686
688
|
return Selectable;
|
687
|
-
})(document, RightJS);
|
689
|
+
})(document, RightJS);
|