pushnote 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -3
  3. data/.pushnote.yml +1 -0
  4. data/README.md +30 -11
  5. data/Rakefile +0 -20
  6. data/bin/pushnote +2 -19
  7. data/bin/pushnoted +58 -0
  8. data/lib/pushnote.rb +3 -0
  9. data/lib/pushnote/cli.rb +40 -0
  10. data/lib/pushnote/configuration.rb +12 -0
  11. data/lib/pushnote/note.rb +36 -0
  12. data/lib/pushnote/version.rb +1 -1
  13. data/pushnote.gemspec +5 -15
  14. metadata +10 -192
  15. data/.rspec +0 -3
  16. data/config.codekit +0 -1005
  17. data/config.ru +0 -2
  18. data/config/database.yml +0 -17
  19. data/db/migrate/20150131202537_create_notes_table.rb +0 -9
  20. data/db/schema.rb +0 -23
  21. data/lib/pushnote/adapters.rb +0 -1
  22. data/lib/pushnote/adapters/base.rb +0 -7
  23. data/lib/pushnote/adapters/local.rb +0 -17
  24. data/lib/pushnote/app.rb +0 -50
  25. data/lib/pushnote/models/note.rb +0 -4
  26. data/lib/pushnote/public/css/foundation.css +0 -6139
  27. data/lib/pushnote/public/css/foundation.min.css +0 -1
  28. data/lib/pushnote/public/css/normalize.css +0 -427
  29. data/lib/pushnote/public/humans.txt +0 -8
  30. data/lib/pushnote/public/img/.gitkeep +0 -1
  31. data/lib/pushnote/public/index.html +0 -166
  32. data/lib/pushnote/public/js/foundation.min.js +0 -5960
  33. data/lib/pushnote/public/js/foundation/foundation.abide.js +0 -318
  34. data/lib/pushnote/public/js/foundation/foundation.accordion.js +0 -67
  35. data/lib/pushnote/public/js/foundation/foundation.alert.js +0 -43
  36. data/lib/pushnote/public/js/foundation/foundation.clearing.js +0 -558
  37. data/lib/pushnote/public/js/foundation/foundation.dropdown.js +0 -439
  38. data/lib/pushnote/public/js/foundation/foundation.equalizer.js +0 -73
  39. data/lib/pushnote/public/js/foundation/foundation.interchange.js +0 -348
  40. data/lib/pushnote/public/js/foundation/foundation.joyride.js +0 -924
  41. data/lib/pushnote/public/js/foundation/foundation.js +0 -690
  42. data/lib/pushnote/public/js/foundation/foundation.magellan.js +0 -198
  43. data/lib/pushnote/public/js/foundation/foundation.offcanvas.js +0 -152
  44. data/lib/pushnote/public/js/foundation/foundation.orbit.js +0 -472
  45. data/lib/pushnote/public/js/foundation/foundation.reveal.js +0 -449
  46. data/lib/pushnote/public/js/foundation/foundation.slider.js +0 -267
  47. data/lib/pushnote/public/js/foundation/foundation.tab.js +0 -217
  48. data/lib/pushnote/public/js/foundation/foundation.tooltip.js +0 -300
  49. data/lib/pushnote/public/js/foundation/foundation.topbar.js +0 -445
  50. data/lib/pushnote/public/js/vendor/fastclick.js +0 -9
  51. data/lib/pushnote/public/js/vendor/jquery.cookie.js +0 -8
  52. data/lib/pushnote/public/js/vendor/jquery.js +0 -26
  53. data/lib/pushnote/public/js/vendor/modernizr.js +0 -8
  54. data/lib/pushnote/public/js/vendor/placeholder.js +0 -2
  55. data/lib/pushnote/public/robots.txt +0 -4
  56. data/lib/pushnote/views/index.erb +0 -15
  57. data/lib/pushnote/views/layout.erb +0 -48
  58. data/lib/pushnote/views/show.erb +0 -8
  59. data/spec/lib/controllers/notes_spec.rb +0 -21
  60. data/spec/spec_helper.rb +0 -16
@@ -1,449 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs.reveal = {
5
- name : 'reveal',
6
-
7
- version : '5.5.0',
8
-
9
- locked : false,
10
-
11
- settings : {
12
- animation: 'fadeAndPop',
13
- animation_speed: 250,
14
- close_on_background_click: true,
15
- close_on_esc: true,
16
- dismiss_modal_class: 'close-reveal-modal',
17
- bg_class: 'reveal-modal-bg',
18
- bg_root_element: 'body',
19
- root_element: 'body',
20
- open: function(){},
21
- opened: function(){},
22
- close: function(){},
23
- closed: function(){},
24
- bg : $('.reveal-modal-bg'),
25
- css : {
26
- open : {
27
- 'opacity': 0,
28
- 'visibility': 'visible',
29
- 'display' : 'block'
30
- },
31
- close : {
32
- 'opacity': 1,
33
- 'visibility': 'hidden',
34
- 'display': 'none'
35
- }
36
- }
37
- },
38
-
39
- init : function (scope, method, options) {
40
- $.extend(true, this.settings, method, options);
41
- this.bindings(method, options);
42
- },
43
-
44
- events : function (scope) {
45
- var self = this,
46
- S = self.S;
47
-
48
- S(this.scope)
49
- .off('.reveal')
50
- .on('click.fndtn.reveal', '[' + this.add_namespace('data-reveal-id') + ']:not([disabled])', function (e) {
51
- e.preventDefault();
52
-
53
- if (!self.locked) {
54
- var element = S(this),
55
- ajax = element.data(self.data_attr('reveal-ajax'));
56
-
57
- self.locked = true;
58
-
59
- if (typeof ajax === 'undefined') {
60
- self.open.call(self, element);
61
- } else {
62
- var url = ajax === true ? element.attr('href') : ajax;
63
-
64
- self.open.call(self, element, {url: url});
65
- }
66
- }
67
- });
68
-
69
- S(document)
70
- .on('click.fndtn.reveal', this.close_targets(), function (e) {
71
-
72
- e.preventDefault();
73
-
74
- if (!self.locked) {
75
- var settings = S('[' + self.attr_name() + '].open').data(self.attr_name(true) + '-init') || self.settings,
76
- bg_clicked = S(e.target)[0] === S('.' + settings.bg_class)[0];
77
-
78
- if (bg_clicked) {
79
- if (settings.close_on_background_click) {
80
- e.stopPropagation();
81
- } else {
82
- return;
83
- }
84
- }
85
-
86
- self.locked = true;
87
- self.close.call(self, bg_clicked ? S('[' + self.attr_name() + '].open') : S(this).closest('[' + self.attr_name() + ']'));
88
- }
89
- });
90
-
91
- if(S('[' + self.attr_name() + ']', this.scope).length > 0) {
92
- S(this.scope)
93
- // .off('.reveal')
94
- .on('open.fndtn.reveal', this.settings.open)
95
- .on('opened.fndtn.reveal', this.settings.opened)
96
- .on('opened.fndtn.reveal', this.open_video)
97
- .on('close.fndtn.reveal', this.settings.close)
98
- .on('closed.fndtn.reveal', this.settings.closed)
99
- .on('closed.fndtn.reveal', this.close_video);
100
- } else {
101
- S(this.scope)
102
- // .off('.reveal')
103
- .on('open.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.open)
104
- .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.opened)
105
- .on('opened.fndtn.reveal', '[' + self.attr_name() + ']', this.open_video)
106
- .on('close.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.close)
107
- .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.settings.closed)
108
- .on('closed.fndtn.reveal', '[' + self.attr_name() + ']', this.close_video);
109
- }
110
-
111
- return true;
112
- },
113
-
114
- // PATCH #3: turning on key up capture only when a reveal window is open
115
- key_up_on : function (scope) {
116
- var self = this;
117
-
118
- // PATCH #1: fixing multiple keyup event trigger from single key press
119
- self.S('body').off('keyup.fndtn.reveal').on('keyup.fndtn.reveal', function ( event ) {
120
- var open_modal = self.S('[' + self.attr_name() + '].open'),
121
- settings = open_modal.data(self.attr_name(true) + '-init') || self.settings ;
122
- // PATCH #2: making sure that the close event can be called only while unlocked,
123
- // so that multiple keyup.fndtn.reveal events don't prevent clean closing of the reveal window.
124
- if ( settings && event.which === 27 && settings.close_on_esc && !self.locked) { // 27 is the keycode for the Escape key
125
- self.close.call(self, open_modal);
126
- }
127
- });
128
-
129
- return true;
130
- },
131
-
132
- // PATCH #3: turning on key up capture only when a reveal window is open
133
- key_up_off : function (scope) {
134
- this.S('body').off('keyup.fndtn.reveal');
135
- return true;
136
- },
137
-
138
-
139
- open : function (target, ajax_settings) {
140
- var self = this,
141
- modal;
142
-
143
- if (target) {
144
- if (typeof target.selector !== 'undefined') {
145
- // Find the named node; only use the first one found, since the rest of the code assumes there's only one node
146
- modal = self.S('#' + target.data(self.data_attr('reveal-id'))).first();
147
- } else {
148
- modal = self.S(this.scope);
149
-
150
- ajax_settings = target;
151
- }
152
- } else {
153
- modal = self.S(this.scope);
154
- }
155
-
156
- var settings = modal.data(self.attr_name(true) + '-init');
157
- settings = settings || this.settings;
158
-
159
-
160
- if (modal.hasClass('open') && target.attr('data-reveal-id') == modal.attr('id')) {
161
- return self.close(modal);
162
- }
163
-
164
- if (!modal.hasClass('open')) {
165
- var open_modal = self.S('[' + self.attr_name() + '].open');
166
-
167
- if (typeof modal.data('css-top') === 'undefined') {
168
- modal.data('css-top', parseInt(modal.css('top'), 10))
169
- .data('offset', this.cache_offset(modal));
170
- }
171
-
172
- this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open
173
- modal.trigger('open').trigger('open.fndtn.reveal');
174
-
175
- if (open_modal.length < 1) {
176
- this.toggle_bg(modal, true);
177
- }
178
-
179
- if (typeof ajax_settings === 'string') {
180
- ajax_settings = {
181
- url: ajax_settings
182
- };
183
- }
184
-
185
- if (typeof ajax_settings === 'undefined' || !ajax_settings.url) {
186
- if (open_modal.length > 0) {
187
- this.hide(open_modal, settings.css.close);
188
- }
189
-
190
- this.show(modal, settings.css.open);
191
- } else {
192
- var old_success = typeof ajax_settings.success !== 'undefined' ? ajax_settings.success : null;
193
-
194
- $.extend(ajax_settings, {
195
- success: function (data, textStatus, jqXHR) {
196
- if ( $.isFunction(old_success) ) {
197
- var result = old_success(data, textStatus, jqXHR);
198
- if (typeof result == 'string') data = result;
199
- }
200
-
201
- modal.html(data);
202
- self.S(modal).foundation('section', 'reflow');
203
- self.S(modal).children().foundation();
204
-
205
- if (open_modal.length > 0) {
206
- self.hide(open_modal, settings.css.close);
207
- }
208
- self.show(modal, settings.css.open);
209
- }
210
- });
211
-
212
- $.ajax(ajax_settings);
213
- }
214
- }
215
- self.S(window).trigger('resize');
216
- },
217
-
218
- close : function (modal) {
219
- var modal = modal && modal.length ? modal : this.S(this.scope),
220
- open_modals = this.S('[' + this.attr_name() + '].open'),
221
- settings = modal.data(this.attr_name(true) + '-init') || this.settings;
222
-
223
- if (open_modals.length > 0) {
224
- this.locked = true;
225
- this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open
226
- modal.trigger('close').trigger('close.fndtn.reveal');
227
- this.toggle_bg(modal, false);
228
- this.hide(open_modals, settings.css.close, settings);
229
- }
230
- },
231
-
232
- close_targets : function () {
233
- var base = '.' + this.settings.dismiss_modal_class;
234
-
235
- if (this.settings.close_on_background_click) {
236
- return base + ', .' + this.settings.bg_class;
237
- }
238
-
239
- return base;
240
- },
241
-
242
- toggle_bg : function (el, modal, state) {
243
- var settings = el.data(this.attr_name(true) + '-init') || this.settings,
244
- bg_root_element = settings.bg_root_element; // Adding option to specify the background root element fixes scrolling issue
245
-
246
- if (this.S('.' + this.settings.bg_class).length === 0) {
247
- this.settings.bg = $('<div />', {'class': this.settings.bg_class})
248
- .appendTo(bg_root_element).hide();
249
- }
250
-
251
- var visible = this.settings.bg.filter(':visible').length > 0;
252
- if ( state != visible ) {
253
- if ( state == undefined ? visible : !state ) {
254
- this.hide(this.settings.bg);
255
- } else {
256
- this.show(this.settings.bg);
257
- }
258
- }
259
- },
260
-
261
- show : function (el, css) {
262
- // is modal
263
- if (css) {
264
- var settings = el.data(this.attr_name(true) + '-init') || this.settings,
265
- root_element = settings.root_element;
266
-
267
- if (el.parent(root_element).length === 0) {
268
- var placeholder = el.wrap('<div style="display: none;" />').parent();
269
-
270
- el.on('closed.fndtn.reveal.wrapped', function() {
271
- el.detach().appendTo(placeholder);
272
- el.unwrap().unbind('closed.fndtn.reveal.wrapped');
273
- });
274
-
275
- el.detach().appendTo(root_element);
276
- }
277
-
278
- var animData = getAnimationData(settings.animation);
279
- if (!animData.animate) {
280
- this.locked = false;
281
- }
282
- if (animData.pop) {
283
- css.top = $(root_element).scrollTop() - el.data('offset') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
284
- var end_css = {
285
- top: $(root_element).scrollTop() + el.data('css-top') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
286
- opacity: 1
287
- };
288
-
289
- return setTimeout(function () {
290
- return el
291
- .css(css)
292
- .animate(end_css, settings.animation_speed, 'linear', function () {
293
- this.locked = false;
294
- el.trigger('opened').trigger('opened.fndtn.reveal');
295
- }.bind(this))
296
- .addClass('open');
297
- }.bind(this), settings.animation_speed / 2);
298
- }
299
-
300
- if (animData.fade) {
301
- css.top = $(root_element).scrollTop() + el.data('css-top') + 'px'; //adding root_element instead of window for scrolling offset if modal trigger is below the fold
302
- var end_css = {opacity: 1};
303
-
304
- return setTimeout(function () {
305
- return el
306
- .css(css)
307
- .animate(end_css, settings.animation_speed, 'linear', function () {
308
- this.locked = false;
309
- el.trigger('opened').trigger('opened.fndtn.reveal');
310
- }.bind(this))
311
- .addClass('open');
312
- }.bind(this), settings.animation_speed / 2);
313
- }
314
-
315
- return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened').trigger('opened.fndtn.reveal');
316
- }
317
-
318
- var settings = this.settings;
319
-
320
- // should we animate the background?
321
- if (getAnimationData(settings.animation).fade) {
322
- return el.fadeIn(settings.animation_speed / 2);
323
- }
324
-
325
- this.locked = false;
326
-
327
- return el.show();
328
- },
329
-
330
- hide : function (el, css) {
331
- // is modal
332
- if (css) {
333
- var settings = el.data(this.attr_name(true) + '-init') || this.settings,
334
- root_element = settings.root_element;
335
-
336
- var animData = getAnimationData(settings.animation);
337
- if (!animData.animate) {
338
- this.locked = false;
339
- }
340
- if (animData.pop) {
341
- var end_css = {
342
- top: - $(root_element).scrollTop() - el.data('offset') + 'px', //adding root_element instead of window for scrolling offset if modal trigger is below the fold
343
- opacity: 0
344
- };
345
-
346
- return setTimeout(function () {
347
- return el
348
- .animate(end_css, settings.animation_speed, 'linear', function () {
349
- this.locked = false;
350
- el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
351
- }.bind(this))
352
- .removeClass('open');
353
- }.bind(this), settings.animation_speed / 2);
354
- }
355
-
356
- if (animData.fade) {
357
- var end_css = {opacity: 0};
358
-
359
- return setTimeout(function () {
360
- return el
361
- .animate(end_css, settings.animation_speed, 'linear', function () {
362
- this.locked = false;
363
- el.css(css).trigger('closed').trigger('closed.fndtn.reveal');
364
- }.bind(this))
365
- .removeClass('open');
366
- }.bind(this), settings.animation_speed / 2);
367
- }
368
-
369
- return el.hide().css(css).removeClass('open').trigger('closed').trigger('closed.fndtn.reveal');
370
- }
371
-
372
- var settings = this.settings;
373
-
374
- // should we animate the background?
375
- if (getAnimationData(settings.animation).fade) {
376
- return el.fadeOut(settings.animation_speed / 2);
377
- }
378
-
379
- return el.hide();
380
- },
381
-
382
- close_video : function (e) {
383
- var video = $('.flex-video', e.target),
384
- iframe = $('iframe', video);
385
-
386
- if (iframe.length > 0) {
387
- iframe.attr('data-src', iframe[0].src);
388
- iframe.attr('src', iframe.attr('src'));
389
- video.hide();
390
- }
391
- },
392
-
393
- open_video : function (e) {
394
- var video = $('.flex-video', e.target),
395
- iframe = video.find('iframe');
396
-
397
- if (iframe.length > 0) {
398
- var data_src = iframe.attr('data-src');
399
- if (typeof data_src === 'string') {
400
- iframe[0].src = iframe.attr('data-src');
401
- } else {
402
- var src = iframe[0].src;
403
- iframe[0].src = undefined;
404
- iframe[0].src = src;
405
- }
406
- video.show();
407
- }
408
- },
409
-
410
- data_attr: function (str) {
411
- if (this.namespace.length > 0) {
412
- return this.namespace + '-' + str;
413
- }
414
-
415
- return str;
416
- },
417
-
418
- cache_offset : function (modal) {
419
- var offset = modal.show().height() + parseInt(modal.css('top'), 10);
420
-
421
- modal.hide();
422
-
423
- return offset;
424
- },
425
-
426
- off : function () {
427
- $(this.scope).off('.fndtn.reveal');
428
- },
429
-
430
- reflow : function () {}
431
- };
432
-
433
- /*
434
- * getAnimationData('popAndFade') // {animate: true, pop: true, fade: true}
435
- * getAnimationData('fade') // {animate: true, pop: false, fade: true}
436
- * getAnimationData('pop') // {animate: true, pop: true, fade: false}
437
- * getAnimationData('foo') // {animate: false, pop: false, fade: false}
438
- * getAnimationData(null) // {animate: false, pop: false, fade: false}
439
- */
440
- function getAnimationData(str) {
441
- var fade = /fade/i.test(str);
442
- var pop = /pop/i.test(str);
443
- return {
444
- animate: fade || pop,
445
- pop: pop,
446
- fade: fade
447
- };
448
- }
449
- }(jQuery, window, window.document));
@@ -1,267 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs.slider = {
5
- name : 'slider',
6
-
7
- version : '5.5.0',
8
-
9
- settings: {
10
- start: 0,
11
- end: 100,
12
- step: 1,
13
- precision: null,
14
- initial: null,
15
- display_selector: '',
16
- vertical: false,
17
- trigger_input_change: false,
18
- on_change: function(){}
19
- },
20
-
21
- cache : {},
22
-
23
- init : function (scope, method, options) {
24
- Foundation.inherit(this,'throttle');
25
- this.bindings(method, options);
26
- this.reflow();
27
- },
28
-
29
- events : function() {
30
- var self = this;
31
-
32
- $(this.scope)
33
- .off('.slider')
34
- .on('mousedown.fndtn.slider touchstart.fndtn.slider pointerdown.fndtn.slider',
35
- '[' + self.attr_name() + ']:not(.disabled, [disabled]) .range-slider-handle', function(e) {
36
- if (!self.cache.active) {
37
- e.preventDefault();
38
- self.set_active_slider($(e.target));
39
- }
40
- })
41
- .on('mousemove.fndtn.slider touchmove.fndtn.slider pointermove.fndtn.slider', function(e) {
42
- if (!!self.cache.active) {
43
- e.preventDefault();
44
- if ($.data(self.cache.active[0], 'settings').vertical) {
45
- var scroll_offset = 0;
46
- if (!e.pageY) {
47
- scroll_offset = window.scrollY;
48
- }
49
- self.calculate_position(self.cache.active, self.get_cursor_position(e, 'y') + scroll_offset);
50
- } else {
51
- self.calculate_position(self.cache.active, self.get_cursor_position(e, 'x'));
52
- }
53
- }
54
- })
55
- .on('mouseup.fndtn.slider touchend.fndtn.slider pointerup.fndtn.slider', function(e) {
56
- self.remove_active_slider();
57
- })
58
- .on('change.fndtn.slider', function(e) {
59
- self.settings.on_change();
60
- });
61
-
62
- self.S(window)
63
- .on('resize.fndtn.slider', self.throttle(function(e) {
64
- self.reflow();
65
- }, 300));
66
- },
67
-
68
- get_cursor_position : function(e, xy) {
69
- var pageXY = 'page' + xy.toUpperCase(),
70
- clientXY = 'client' + xy.toUpperCase(),
71
- position;
72
-
73
- if (typeof e[pageXY] !== 'undefined') {
74
- position = e[pageXY];
75
- }
76
- else if (typeof e.originalEvent[clientXY] !== 'undefined') {
77
- position = e.originalEvent[clientXY];
78
- }
79
- else if (e.originalEvent.touches && e.originalEvent.touches[0] && typeof e.originalEvent.touches[0][clientXY] !== 'undefined') {
80
- position = e.originalEvent.touches[0][clientXY];
81
- }
82
- else if(e.currentPoint && typeof e.currentPoint[xy] !== 'undefined') {
83
- position = e.currentPoint[xy];
84
- }
85
- return position;
86
- },
87
-
88
- set_active_slider : function($handle) {
89
- this.cache.active = $handle;
90
- },
91
-
92
- remove_active_slider : function() {
93
- this.cache.active = null;
94
- },
95
-
96
- calculate_position : function($handle, cursor_x) {
97
- var self = this,
98
- settings = $.data($handle[0], 'settings'),
99
- handle_l = $.data($handle[0], 'handle_l'),
100
- handle_o = $.data($handle[0], 'handle_o'),
101
- bar_l = $.data($handle[0], 'bar_l'),
102
- bar_o = $.data($handle[0], 'bar_o');
103
-
104
- requestAnimationFrame(function(){
105
- var pct;
106
-
107
- if (Foundation.rtl && !settings.vertical) {
108
- pct = self.limit_to(((bar_o+bar_l-cursor_x)/bar_l),0,1);
109
- } else {
110
- pct = self.limit_to(((cursor_x-bar_o)/bar_l),0,1);
111
- }
112
-
113
- pct = settings.vertical ? 1-pct : pct;
114
-
115
- var norm = self.normalized_value(pct, settings.start, settings.end, settings.step, settings.precision);
116
-
117
- self.set_ui($handle, norm);
118
- });
119
- },
120
-
121
- set_ui : function($handle, value) {
122
- var settings = $.data($handle[0], 'settings'),
123
- handle_l = $.data($handle[0], 'handle_l'),
124
- bar_l = $.data($handle[0], 'bar_l'),
125
- norm_pct = this.normalized_percentage(value, settings.start, settings.end),
126
- handle_offset = norm_pct*(bar_l-handle_l)-1,
127
- progress_bar_length = norm_pct*100,
128
- $handle_parent = $handle.parent(),
129
- $hidden_inputs = $handle.parent().children('input[type=hidden]');
130
-
131
- if (Foundation.rtl && !settings.vertical) {
132
- handle_offset = -handle_offset;
133
- }
134
-
135
- handle_offset = settings.vertical ? -handle_offset + bar_l - handle_l + 1 : handle_offset;
136
- this.set_translate($handle, handle_offset, settings.vertical);
137
-
138
- if (settings.vertical) {
139
- $handle.siblings('.range-slider-active-segment').css('height', progress_bar_length + '%');
140
- } else {
141
- $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%');
142
- }
143
-
144
- $handle_parent.attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider');
145
-
146
- $hidden_inputs.val(value);
147
- if (settings.trigger_input_change) {
148
- $hidden_inputs.trigger('change');
149
- }
150
-
151
- if (!$handle[0].hasAttribute('aria-valuemin')) {
152
- $handle.attr({
153
- 'aria-valuemin': settings.start,
154
- 'aria-valuemax': settings.end
155
- });
156
- }
157
- $handle.attr('aria-valuenow', value);
158
-
159
- if (settings.display_selector != '') {
160
- $(settings.display_selector).each(function(){
161
- if (this.hasOwnProperty('value')) {
162
- $(this).val(value);
163
- } else {
164
- $(this).text(value);
165
- }
166
- });
167
- }
168
-
169
- },
170
-
171
- normalized_percentage : function(val, start, end) {
172
- return Math.min(1, (val - start)/(end - start));
173
- },
174
-
175
- normalized_value : function(val, start, end, step, precision) {
176
- var range = end - start,
177
- point = val*range,
178
- mod = (point-(point%step)) / step,
179
- rem = point % step,
180
- round = ( rem >= step*0.5 ? step : 0);
181
- return ((mod*step + round) + start).toFixed(precision);
182
- },
183
-
184
- set_translate : function(ele, offset, vertical) {
185
- if (vertical) {
186
- $(ele)
187
- .css('-webkit-transform', 'translateY('+offset+'px)')
188
- .css('-moz-transform', 'translateY('+offset+'px)')
189
- .css('-ms-transform', 'translateY('+offset+'px)')
190
- .css('-o-transform', 'translateY('+offset+'px)')
191
- .css('transform', 'translateY('+offset+'px)');
192
- } else {
193
- $(ele)
194
- .css('-webkit-transform', 'translateX('+offset+'px)')
195
- .css('-moz-transform', 'translateX('+offset+'px)')
196
- .css('-ms-transform', 'translateX('+offset+'px)')
197
- .css('-o-transform', 'translateX('+offset+'px)')
198
- .css('transform', 'translateX('+offset+'px)');
199
- }
200
- },
201
-
202
- limit_to : function(val, min, max) {
203
- return Math.min(Math.max(val, min), max);
204
- },
205
-
206
-
207
-
208
- initialize_settings : function(handle) {
209
- var settings = $.extend({}, this.settings, this.data_options($(handle).parent())),
210
- decimal_places_match_result;
211
-
212
- if (settings.precision === null) {
213
- decimal_places_match_result = ('' + settings.step).match(/\.([\d]*)/);
214
- settings.precision = decimal_places_match_result && decimal_places_match_result[1] ? decimal_places_match_result[1].length : 0;
215
- }
216
-
217
- if (settings.vertical) {
218
- $.data(handle, 'bar_o', $(handle).parent().offset().top);
219
- $.data(handle, 'bar_l', $(handle).parent().outerHeight());
220
- $.data(handle, 'handle_o', $(handle).offset().top);
221
- $.data(handle, 'handle_l', $(handle).outerHeight());
222
- } else {
223
- $.data(handle, 'bar_o', $(handle).parent().offset().left);
224
- $.data(handle, 'bar_l', $(handle).parent().outerWidth());
225
- $.data(handle, 'handle_o', $(handle).offset().left);
226
- $.data(handle, 'handle_l', $(handle).outerWidth());
227
- }
228
-
229
- $.data(handle, 'bar', $(handle).parent());
230
- $.data(handle, 'settings', settings);
231
- },
232
-
233
- set_initial_position : function($ele) {
234
- var settings = $.data($ele.children('.range-slider-handle')[0], 'settings'),
235
- initial = ((typeof settings.initial == 'number' && !isNaN(settings.initial)) ? settings.initial : Math.floor((settings.end-settings.start)*0.5/settings.step)*settings.step+settings.start),
236
- $handle = $ele.children('.range-slider-handle');
237
- this.set_ui($handle, initial);
238
- },
239
-
240
- set_value : function(value) {
241
- var self = this;
242
- $('[' + self.attr_name() + ']', this.scope).each(function(){
243
- $(this).attr(self.attr_name(), value);
244
- });
245
- if (!!$(this.scope).attr(self.attr_name())) {
246
- $(this.scope).attr(self.attr_name(), value);
247
- }
248
- self.reflow();
249
- },
250
-
251
- reflow : function() {
252
- var self = this;
253
- self.S('[' + this.attr_name() + ']').each(function() {
254
- var handle = $(this).children('.range-slider-handle')[0],
255
- val = $(this).attr(self.attr_name());
256
- self.initialize_settings(handle);
257
-
258
- if (val) {
259
- self.set_ui($(handle), parseFloat(val));
260
- } else {
261
- self.set_initial_position($(this));
262
- }
263
- });
264
- }
265
- };
266
-
267
- }(jQuery, window, window.document));