puffer 0.0.23 → 0.0.24
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +55 -53
- data/VERSION +1 -1
- data/app/assets/javascripts/puffer/application.js +6 -3
- data/app/assets/javascripts/puffer/paginator.js +223 -0
- data/app/assets/javascripts/puffer/puffer.js +12 -0
- data/app/assets/javascripts/puffer/rails.js +1 -0
- data/app/assets/javascripts/puffer/{right-autocompleter.js → right-autocompleter-src.js} +45 -41
- data/app/assets/javascripts/puffer/{right-calendar.js → right-calendar-src.js} +53 -50
- data/app/assets/javascripts/puffer/right-dialog-src.js +768 -0
- data/app/assets/javascripts/puffer/right-slider-src.js +507 -0
- data/app/assets/javascripts/puffer/{right.js → right-src.js} +1000 -230
- data/app/assets/stylesheets/puffer/application.css +2 -0
- data/app/assets/stylesheets/puffer/paginator.css +33 -0
- data/app/assets/stylesheets/puffer/right.css +4 -0
- data/app/components/base/form.html.erb +15 -0
- data/app/components/base_component.rb +15 -0
- data/app/components/boolean/form.html.erb +3 -0
- data/app/components/boolean/index.html.erb +3 -0
- data/app/components/boolean_component.rb +13 -0
- data/app/components/date_time/form.html.erb +5 -0
- data/app/components/date_time_component.rb +12 -0
- data/app/components/file/form.html.erb +5 -0
- data/app/components/file_component.rb +3 -0
- data/app/components/hidden/form.html.erb +1 -0
- data/app/components/hidden_component.rb +3 -0
- data/app/components/password/form.html.erb +5 -0
- data/app/components/password_component.rb +7 -0
- data/app/components/references_many/form.html.erb +1 -0
- data/app/components/references_many_component.rb +7 -0
- data/app/components/references_one/choose.html.erb +9 -0
- data/app/components/references_one/form.html.erb +28 -0
- data/app/components/references_one_component.rb +12 -0
- data/app/components/select/form.html.erb +5 -0
- data/app/components/select_component.rb +15 -0
- data/app/components/string/form.html.erb +5 -0
- data/app/components/string_component.rb +3 -0
- data/app/components/text/form.html.erb +5 -0
- data/app/components/text_component.rb +3 -0
- data/app/controllers/puffer/base.rb +4 -0
- data/app/views/puffer/base/_form.html.erb +0 -1
- data/app/views/puffer/base/_table.html.erb +25 -0
- data/app/views/puffer/base/index.html.erb +14 -28
- data/app/views/puffer/tree_base/_record.html.erb +1 -1
- data/lib/generators/puffer/component/USAGE +12 -0
- data/lib/generators/puffer/component/component_generator.rb +19 -0
- data/lib/generators/puffer/component/templates/component.rb +15 -0
- data/lib/generators/puffer/component/templates/component_spec.rb +19 -0
- data/lib/puffer/component.rb +141 -0
- data/lib/puffer/controller/dsl.rb +25 -12
- data/lib/puffer/engine.rb +5 -0
- data/lib/puffer/extensions/controller.rb +11 -9
- data/lib/puffer/extensions/form.rb +2 -1
- data/lib/puffer/extensions/mapper.rb +2 -0
- data/lib/puffer/field.rb +30 -19
- data/lib/puffer/field_set.rb +17 -2
- data/lib/puffer.rb +25 -8
- data/puffer.gemspec +59 -28
- data/spec/app/components/base_component_spec.rb +19 -0
- data/spec/app/components/boolean_component_spec.rb +36 -0
- data/spec/app/components/date_time_component_spec.rb +26 -0
- data/spec/app/components/file_component_spec.rb +25 -0
- data/spec/app/components/hidden_component_spec.rb +24 -0
- data/spec/app/components/password_component_spec.rb +37 -0
- data/spec/app/components/references_many_component_spec.rb +19 -0
- data/spec/app/components/references_one_component_spec.rb +19 -0
- data/spec/app/components/select_component_spec.rb +30 -0
- data/spec/app/components/string_component_spec.rb +25 -0
- data/spec/app/components/text_component_spec.rb +25 -0
- data/spec/dummy/app/controllers/admin/categories_controller.rb +3 -3
- data/spec/dummy/app/controllers/admin/posts_controller.rb +3 -0
- data/spec/dummy/app/controllers/{puffer → admin}/sessions_controller.rb +1 -1
- data/spec/dummy/app/controllers/admin/users_controller.rb +2 -2
- data/spec/dummy/app/models/post.rb +4 -0
- data/spec/dummy/db/migrate/20100930132656_create_posts.rb +2 -0
- data/spec/dummy/db/migrate/20100930132726_create_categories.rb +1 -0
- data/spec/dummy/db/schema.rb +3 -0
- data/spec/dummy/db/seeds.rb +6 -1
- data/spec/fabricators/categories_fabricator.rb +1 -0
- data/spec/fabricators/posts_fabricator.rb +1 -0
- data/spec/lib/component_spec.rb +7 -0
- data/spec/lib/fields_spec.rb +0 -4
- metadata +85 -56
- data/app/views/puffer/base/associated/_many.html.erb +0 -56
- data/app/views/puffer/base/associated/many.rjs +0 -1
- data/app/views/puffer/base/associated/one.js.erb +0 -13
- data/app/views/puffer/base/association/_many.html.erb +0 -7
- data/lib/puffer/controller/generated.rb +0 -65
- data/lib/puffer/customs.rb +0 -64
- data/lib/puffer/inputs/association.rb +0 -38
- data/lib/puffer/inputs/base.rb +0 -51
- data/lib/puffer/inputs/boolean.rb +0 -19
- data/lib/puffer/inputs/collection_association.rb +0 -11
- data/lib/puffer/inputs/date_time.rb +0 -16
- data/lib/puffer/inputs/file.rb +0 -11
- data/lib/puffer/inputs/hidden.rb +0 -15
- data/lib/puffer/inputs/password.rb +0 -11
- data/lib/puffer/inputs/select.rb +0 -19
- data/lib/puffer/inputs/text.rb +0 -11
@@ -0,0 +1,507 @@
|
|
1
|
+
/**
|
2
|
+
* RightJS-UI Slider v2.2.3
|
3
|
+
* http://rightjs.org/ui/slider
|
4
|
+
*
|
5
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
6
|
+
*/
|
7
|
+
var Slider = RightJS.Slider = (function(document, Math, RightJS) {
|
8
|
+
/**
|
9
|
+
* This module defines the basic widgets constructor
|
10
|
+
* it creates an abstract proxy with the common functionality
|
11
|
+
* which then we reuse and override in the actual widgets
|
12
|
+
*
|
13
|
+
* Copyright (C) 2010-2011 Nikolay Nemshilov
|
14
|
+
*/
|
15
|
+
|
16
|
+
/**
|
17
|
+
* The widget units constructor
|
18
|
+
*
|
19
|
+
* @param String tag-name or Object methods
|
20
|
+
* @param Object methods
|
21
|
+
* @return Widget wrapper
|
22
|
+
*/
|
23
|
+
function Widget(tag_name, methods) {
|
24
|
+
if (!methods) {
|
25
|
+
methods = tag_name;
|
26
|
+
tag_name = 'DIV';
|
27
|
+
}
|
28
|
+
|
29
|
+
/**
|
30
|
+
* An Abstract Widget Unit
|
31
|
+
*
|
32
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
33
|
+
*/
|
34
|
+
var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
|
35
|
+
/**
|
36
|
+
* The common constructor
|
37
|
+
*
|
38
|
+
* @param Object options
|
39
|
+
* @param String optional tag name
|
40
|
+
* @return void
|
41
|
+
*/
|
42
|
+
initialize: function(key, options) {
|
43
|
+
this.key = key;
|
44
|
+
var args = [{'class': 'rui-' + key}];
|
45
|
+
|
46
|
+
// those two have different constructors
|
47
|
+
if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
|
48
|
+
args.unshift(tag_name);
|
49
|
+
}
|
50
|
+
this.$super.apply(this, args);
|
51
|
+
|
52
|
+
if (RightJS.isString(options)) {
|
53
|
+
options = RightJS.$(options);
|
54
|
+
}
|
55
|
+
|
56
|
+
// if the options is another element then
|
57
|
+
// try to dynamically rewrap it with our widget
|
58
|
+
if (options instanceof RightJS.Element) {
|
59
|
+
this._ = options._;
|
60
|
+
if ('$listeners' in options) {
|
61
|
+
options.$listeners = options.$listeners;
|
62
|
+
}
|
63
|
+
options = {};
|
64
|
+
}
|
65
|
+
this.setOptions(options, this);
|
66
|
+
|
67
|
+
return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
|
68
|
+
},
|
69
|
+
|
70
|
+
// protected
|
71
|
+
|
72
|
+
/**
|
73
|
+
* Catches the options
|
74
|
+
*
|
75
|
+
* @param Object user-options
|
76
|
+
* @param Element element with contextual options
|
77
|
+
* @return void
|
78
|
+
*/
|
79
|
+
setOptions: function(options, element) {
|
80
|
+
if (element) {
|
81
|
+
options = RightJS.Object.merge(options, new Function("return "+(
|
82
|
+
element.get('data-'+ this.key) || '{}'
|
83
|
+
))());
|
84
|
+
}
|
85
|
+
|
86
|
+
if (options) {
|
87
|
+
RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
|
88
|
+
}
|
89
|
+
|
90
|
+
return this;
|
91
|
+
}
|
92
|
+
});
|
93
|
+
|
94
|
+
/**
|
95
|
+
* Creating the actual widget class
|
96
|
+
*
|
97
|
+
*/
|
98
|
+
var Klass = new RightJS.Class(AbstractWidget, methods);
|
99
|
+
|
100
|
+
// creating the widget related shortcuts
|
101
|
+
RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
|
102
|
+
|
103
|
+
return Klass;
|
104
|
+
}
|
105
|
+
|
106
|
+
|
107
|
+
/**
|
108
|
+
* Same as the assignable, only it doesn't work with popups
|
109
|
+
* instead it simply updates the assigned unit value/content
|
110
|
+
*
|
111
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
112
|
+
*/
|
113
|
+
var Updater = {
|
114
|
+
|
115
|
+
/**
|
116
|
+
* Assigns the unit to work with an input element
|
117
|
+
*
|
118
|
+
* @param mixed element reference
|
119
|
+
* @return Rater this
|
120
|
+
*/
|
121
|
+
assignTo: function(element) {
|
122
|
+
var assign = R(function(element, event) {
|
123
|
+
if ((element = $(element))) {
|
124
|
+
element[element.setValue ? 'setValue' : 'update'](event.target.getValue());
|
125
|
+
}
|
126
|
+
}).curry(element);
|
127
|
+
|
128
|
+
var connect = R(function(element, object) {
|
129
|
+
element = $(element);
|
130
|
+
if (element && element.onChange) {
|
131
|
+
element.onChange(R(function() {
|
132
|
+
this.setValue(element.value());
|
133
|
+
}).bind(object));
|
134
|
+
}
|
135
|
+
}).curry(element);
|
136
|
+
|
137
|
+
if ($(element)) {
|
138
|
+
assign({target: this});
|
139
|
+
connect(this);
|
140
|
+
} else {
|
141
|
+
$(document).onReady(R(function() {
|
142
|
+
assign({target: this});
|
143
|
+
connect(this);
|
144
|
+
}.bind(this)));
|
145
|
+
}
|
146
|
+
|
147
|
+
return this.onChange(assign);
|
148
|
+
}
|
149
|
+
};
|
150
|
+
|
151
|
+
|
152
|
+
/**
|
153
|
+
* The filenames to include
|
154
|
+
*
|
155
|
+
* Copyright (C) 2010 Nikolay Nemshilov
|
156
|
+
*/
|
157
|
+
var R = RightJS,
|
158
|
+
$ = RightJS.$,
|
159
|
+
$$ = RightJS.$$,
|
160
|
+
$w = RightJS.$w,
|
161
|
+
$E = RightJS.$E,
|
162
|
+
$A = RightJS.$A,
|
163
|
+
isHash = RightJS.isHash,
|
164
|
+
Element = RightJS.Element;
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
/**
|
172
|
+
* RightJS UI Slider unit
|
173
|
+
*
|
174
|
+
* Copyright (C) 2009-2011 Nikolay Nemshilov
|
175
|
+
*/
|
176
|
+
var Slider = new Widget({
|
177
|
+
include: Updater,
|
178
|
+
|
179
|
+
extend: {
|
180
|
+
version: '2.2.3',
|
181
|
+
|
182
|
+
EVENTS: $w('change'),
|
183
|
+
|
184
|
+
Options: {
|
185
|
+
min: 0, // the min value
|
186
|
+
max: 100, // the max value
|
187
|
+
snap: 0, // the values threshold
|
188
|
+
range: false, // whether a single handle slider or a range slider
|
189
|
+
value: null, // start value, if null then the min value will be used
|
190
|
+
values: null, // range values when range = true, if null then then min/max value will be used
|
191
|
+
direction: 'x', // slider direction 'x', 'y'
|
192
|
+
update: null, // reference to an element to update
|
193
|
+
round: 0 // the number of symbols after the decimal pointer
|
194
|
+
},
|
195
|
+
|
196
|
+
current: false
|
197
|
+
},
|
198
|
+
|
199
|
+
/**
|
200
|
+
* basic constructor
|
201
|
+
* USAGE:
|
202
|
+
* new Slider('element-id'[, {options}]);
|
203
|
+
* new Slider({options});
|
204
|
+
*
|
205
|
+
* @param mixed slider element reference or options
|
206
|
+
* @param Object options
|
207
|
+
*/
|
208
|
+
initialize: function() {
|
209
|
+
var args = $A(arguments).compact(), options = args.pop(), element = args.pop();
|
210
|
+
|
211
|
+
// figuring out the arguments
|
212
|
+
if (!isHash(options) || options instanceof Element) {
|
213
|
+
element = $(element || options);
|
214
|
+
options = {};
|
215
|
+
}
|
216
|
+
|
217
|
+
this.$super('slider', element).setOptions(options)
|
218
|
+
.on('selectstart', 'stopEvent'); // disable select under IE
|
219
|
+
|
220
|
+
this.level = this.first('.level') || $E('div', {'class': 'level'}).insertTo(this);
|
221
|
+
|
222
|
+
options = this.options;
|
223
|
+
this.value = options.value === null ? options.min : options.value;
|
224
|
+
|
225
|
+
if (options.range === true) {
|
226
|
+
this.handles = new Array();
|
227
|
+
this.handles[0] = this.first('.handle.from') || $E('div', {'class': 'handle.from'}).insertTo(this);
|
228
|
+
this.handles[1] = this.first('.handle.to') || $E('div', {'class': 'handle.to'}).insertTo(this);
|
229
|
+
|
230
|
+
this.values = [0, 0];
|
231
|
+
this.values[0] = options.values === null ? options.min : options.values[0];
|
232
|
+
this.values[1] = options.values === null ? options.max : options.values[1];
|
233
|
+
|
234
|
+
this.setValue(this.values[0], 'from');
|
235
|
+
this.setValue(this.values[1], 'to');
|
236
|
+
|
237
|
+
//this.offsets = [0, 0];
|
238
|
+
|
239
|
+
} else {
|
240
|
+
this.handle = this.first('.handle') || $E('div', {'class': 'handle'}).insertTo(this);
|
241
|
+
this.setValue(this.value);
|
242
|
+
}
|
243
|
+
|
244
|
+
if (options.update) { this.assignTo(options.update); }
|
245
|
+
if (options.direction === 'y') { this.addClass('rui-slider-vertical'); }
|
246
|
+
else if (this.hasClass('rui-slider-vertical')) { options.direction = 'y'; }
|
247
|
+
|
248
|
+
},
|
249
|
+
|
250
|
+
/**
|
251
|
+
* The value setter
|
252
|
+
*
|
253
|
+
* NOTE: will get snapped according to the options
|
254
|
+
*
|
255
|
+
* @param mixed string or number value, an optional type specifying 'from' or 'to' when using with range slider
|
256
|
+
* @return Slider this
|
257
|
+
*/
|
258
|
+
setValue: function(value, type) {
|
259
|
+
return this.precalc().shiftTo(value, type);
|
260
|
+
},
|
261
|
+
|
262
|
+
/**
|
263
|
+
* Returns the value
|
264
|
+
*
|
265
|
+
* @return Float number
|
266
|
+
*/
|
267
|
+
getValue: function() {
|
268
|
+
if (this.options.range === true) {
|
269
|
+
return this.values[0];
|
270
|
+
} else {
|
271
|
+
return this.value;
|
272
|
+
}
|
273
|
+
},
|
274
|
+
|
275
|
+
/**
|
276
|
+
* Returns the values that used to store the range
|
277
|
+
*
|
278
|
+
* @return An array storing the from/to float numbers
|
279
|
+
*/
|
280
|
+
getValues: function() {
|
281
|
+
return this.values;
|
282
|
+
},
|
283
|
+
|
284
|
+
/**
|
285
|
+
* Inserts the widget into the element
|
286
|
+
*
|
287
|
+
* @param mixed element reference
|
288
|
+
* @param String optional position
|
289
|
+
* @return Slider this
|
290
|
+
*/
|
291
|
+
insertTo: function(element, position) {
|
292
|
+
return this.$super(element, position).setValue(this.value);
|
293
|
+
},
|
294
|
+
|
295
|
+
// protected
|
296
|
+
|
297
|
+
// precalculates dimensions, direction and offset for further use
|
298
|
+
precalc: function() {
|
299
|
+
var horizontal = this.options.direction === 'x',
|
300
|
+
dims = this.dims = this.dimensions();
|
301
|
+
|
302
|
+
if (this.options.range === true) {
|
303
|
+
var handle_f = this.handles[0].setStyle(horizontal ? {left: 0} : {bottom: 0}).dimensions(),
|
304
|
+
handle_size = this.hSize = horizontal ? handle_f.width : handle_f.height;
|
305
|
+
// Assuming both handles are in the same size
|
306
|
+
|
307
|
+
this.offset = horizontal ? handle_f.left - dims.left : dims.top + dims.height - handle_f.top - handle_size;
|
308
|
+
this.space = (horizontal ? dims.width : dims.height) - handle_size - (this.offset * 2);
|
309
|
+
|
310
|
+
var handle_t = this.handles[1].setStyle(horizontal ? {left: this.space + 'px'} :
|
311
|
+
{bottom: this.space + 'px'}).dimensions();
|
312
|
+
|
313
|
+
} else {
|
314
|
+
var handle = this.handle.setStyle(horizontal ? {left: 0} : {bottom: 0}).dimensions(),
|
315
|
+
handle_size = this.hSize = horizontal ? handle.width : handle.height;
|
316
|
+
|
317
|
+
this.offset = horizontal ? handle.left - dims.left : dims.top + dims.height - handle.top - handle_size;
|
318
|
+
this.space = (horizontal ? dims.width : dims.height) - handle_size - this.offset * 2;
|
319
|
+
}
|
320
|
+
|
321
|
+
return this;
|
322
|
+
},
|
323
|
+
|
324
|
+
// initializes the slider drag
|
325
|
+
start: function(event, type) {
|
326
|
+
return this.precalc().e2val(event, type);
|
327
|
+
},
|
328
|
+
|
329
|
+
// processes the slider-drag
|
330
|
+
move: function(event, type) {
|
331
|
+
return this.e2val(event, type);
|
332
|
+
},
|
333
|
+
|
334
|
+
// shifts the slider to the value
|
335
|
+
shiftTo: function(value, type) {
|
336
|
+
var options = this.options, base = Math.pow(10, options.round), horizontal = options.direction === 'x';
|
337
|
+
|
338
|
+
// rounding the value up
|
339
|
+
value = Math.round(value * base) / base;
|
340
|
+
|
341
|
+
// checking the value constraings
|
342
|
+
if (value < options.min) { value = options.min; }
|
343
|
+
if (value > options.max) { value = options.max; }
|
344
|
+
|
345
|
+
// if range slider check if the "from" handle's value is larger than the "to" handle's
|
346
|
+
if (options.range === true) {
|
347
|
+
if ((type === "to") && (value < this.values[0])) {
|
348
|
+
value = this.values[0];
|
349
|
+
}
|
350
|
+
if ((type === "from") || (type === undefined)) {
|
351
|
+
if (value > this.values[1]) {
|
352
|
+
value = this.values[1];
|
353
|
+
}
|
354
|
+
}
|
355
|
+
}
|
356
|
+
|
357
|
+
if (options.snap) {
|
358
|
+
var snap = options.snap;
|
359
|
+
var diff = (value - options.min) % snap;
|
360
|
+
value = diff < snap/2 ? value - diff : value - diff + snap;
|
361
|
+
}
|
362
|
+
|
363
|
+
if (options.range === true) {
|
364
|
+
var value_f = (type === "from") ? value : this.values[0];
|
365
|
+
var value_t = (type === "to") ? value : this.values[1];
|
366
|
+
|
367
|
+
// calculating and setting the actual position
|
368
|
+
var position_f = this.space / (options.max - options.min) * (value_f - options.min);
|
369
|
+
var position_t = this.space / (options.max - options.min) * (value_t - options.min);
|
370
|
+
var length = position_t - position_f;
|
371
|
+
|
372
|
+
if (type === "to") {
|
373
|
+
this.handles[1]._.style[horizontal ? 'left' : 'bottom'] = position_t + 'px';
|
374
|
+
} else {
|
375
|
+
this.handles[0]._.style[horizontal ? 'left' : 'bottom'] = position_f + 'px';
|
376
|
+
}
|
377
|
+
|
378
|
+
this.level._.style[horizontal ? 'left': 'top'] = ((position_f > 0 ? position_f : 0) + 2) + 'px';
|
379
|
+
this.level._.style[horizontal ? 'width': 'height'] = ((length > 0 ? length : 0) + 2) + 'px';
|
380
|
+
|
381
|
+
// checking the change status
|
382
|
+
var fireEvent = false;
|
383
|
+
if ((type === "from") && (value !== this.values[0])) {
|
384
|
+
this.values[0] = value;
|
385
|
+
fireEvent = true;
|
386
|
+
}
|
387
|
+
if ((type === "to") && (value !== this.values[1])) {
|
388
|
+
this.values[1] = value;
|
389
|
+
fireEvent = true;
|
390
|
+
}
|
391
|
+
if (fireEvent) {
|
392
|
+
this.fire('change', {value: value, values: this.values});
|
393
|
+
}
|
394
|
+
|
395
|
+
} else {
|
396
|
+
// calculating and setting the actual position
|
397
|
+
var position = this.space / (options.max - options.min) * (value - options.min);
|
398
|
+
this.handle._.style[horizontal ? 'left' : 'bottom'] = position + 'px';
|
399
|
+
this.level._.style[horizontal ? 'width': 'height'] = ((position > 0 ? position : 0) + 2) + 'px';
|
400
|
+
|
401
|
+
// checking the change status
|
402
|
+
if (value !== this.value) {
|
403
|
+
this.value = value;
|
404
|
+
this.fire('change', {value: value});
|
405
|
+
}
|
406
|
+
}
|
407
|
+
|
408
|
+
|
409
|
+
return this;
|
410
|
+
},
|
411
|
+
|
412
|
+
// converts the event position into the actual value in terms of the slider measures
|
413
|
+
e2val: function(event, type) {
|
414
|
+
var options = this.options, horizontal = options.direction === 'x',
|
415
|
+
dims = this.dims, offset = this.offset, space = this.space,
|
416
|
+
cur_pos = event.position()[horizontal ? 'x' : 'y'] - offset - this.hSize/2,
|
417
|
+
min_pos = horizontal ? dims.left + offset : dims.top + offset,
|
418
|
+
value = (options.max - options.min) / space * (cur_pos - min_pos);
|
419
|
+
|
420
|
+
if (!type) {
|
421
|
+
return this.shiftTo(horizontal ? options.min + value : options.max - value);
|
422
|
+
} else if (type === "to") {
|
423
|
+
this.shiftTo(this.values[0], "from");
|
424
|
+
return this.shiftTo(horizontal ? options.min + value : options.max - value, "to");
|
425
|
+
} else {
|
426
|
+
this.shiftTo(this.values[1], "to");
|
427
|
+
return this.shiftTo(horizontal ? options.min + value : options.max - value, "from");
|
428
|
+
}
|
429
|
+
}
|
430
|
+
});
|
431
|
+
|
432
|
+
|
433
|
+
/**
|
434
|
+
* Document onReady hook for sliders
|
435
|
+
*
|
436
|
+
* Copyright (C) 2009-2010 Nikolay Nemshilov
|
437
|
+
*/
|
438
|
+
$(document).on({
|
439
|
+
// preinitializing the sliders
|
440
|
+
ready: function() {
|
441
|
+
$$('.rui-slider').each(function(element) {
|
442
|
+
if (!(element instanceof Slider)) {
|
443
|
+
element = new Slider(element);
|
444
|
+
}
|
445
|
+
});
|
446
|
+
},
|
447
|
+
|
448
|
+
// initiates the slider move
|
449
|
+
mousedown: function(event) {
|
450
|
+
var slider = event.find('.rui-slider');
|
451
|
+
if (slider) {
|
452
|
+
event.stop();
|
453
|
+
if (!(slider instanceof Slider)) {
|
454
|
+
slider = new Slider(slider);
|
455
|
+
}
|
456
|
+
var type = null;
|
457
|
+
if (event.target.hasClass('handle')) {
|
458
|
+
if (event.target.hasClass('from')) {
|
459
|
+
type = "from";
|
460
|
+
} else if (event.target.hasClass('to')) {
|
461
|
+
type = "to";
|
462
|
+
}
|
463
|
+
}
|
464
|
+
Slider.current = slider.start(event, type);
|
465
|
+
Slider.handleType = type;
|
466
|
+
}
|
467
|
+
},
|
468
|
+
|
469
|
+
// handles the slider move
|
470
|
+
mousemove: function(event) {
|
471
|
+
if (Slider.current) {
|
472
|
+
Slider.current.move(event, Slider.handleType);
|
473
|
+
}
|
474
|
+
},
|
475
|
+
|
476
|
+
// handles the slider release
|
477
|
+
mouseup: function(event) {
|
478
|
+
if (Slider.current) {
|
479
|
+
Slider.current = false;
|
480
|
+
Slider.handleType = null;
|
481
|
+
}
|
482
|
+
}
|
483
|
+
});
|
484
|
+
|
485
|
+
$(window).onBlur(function() {
|
486
|
+
if (Slider.current) {
|
487
|
+
Slider.current = false;
|
488
|
+
Slider.handleType = null;
|
489
|
+
}
|
490
|
+
});
|
491
|
+
|
492
|
+
|
493
|
+
var embed_style = document.createElement('style'),
|
494
|
+
embed_rules = document.createTextNode("div.rui-slider,div.rui-slider .handle,div.rui-slider .level{margin:0;padding:0;border:none;background:none}div.rui-slider{height:0.4em;width:20em;border:1px solid #bbb;background:#F8F8F8;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;position:relative;margin:.6em 0;display:inline-block; *display:inline; *zoom:1;vertical-align:middle;user-select:none;-moz-user-select:none;-webkit-user-select:none;cursor:pointer}div.rui-slider .handle{font-size:25%;position:absolute;left:0;top:0;width:4pt;height:10pt;margin-top:-4pt;margin-left:0.4em;background:#BBB;border:1px solid #999;border-radius:.8em;-moz-border-radius:.8em;-webkit-border-radius:.8em;z-index:20}div.rui-slider .level{font-size:25%;position:absolute;top:0;left:0;width:0;height:100%;background:#ddd;z-index:1}div.rui-slider-vertical{height:10em;width:0.4em;margin:0 .3em}div.rui-slider-vertical .handle{top:auto;bottom:0;margin:0;margin-left:-4pt;margin-bottom:0.4em;height:5pt;width:10pt}div.rui-slider-vertical .level{height:0;width:100%;top:auto;bottom:0}");
|
495
|
+
|
496
|
+
embed_style.type = 'text/css';
|
497
|
+
document.getElementsByTagName('head')[0].appendChild(embed_style);
|
498
|
+
|
499
|
+
if(embed_style.styleSheet) {
|
500
|
+
embed_style.styleSheet.cssText = embed_rules.nodeValue;
|
501
|
+
} else {
|
502
|
+
embed_style.appendChild(embed_rules);
|
503
|
+
}
|
504
|
+
|
505
|
+
|
506
|
+
return Slider;
|
507
|
+
})(document, Math, RightJS);
|