jscrollpane-rails 2.0.20 → 2.0.21

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -1,5 +1,5 @@
1
1
  module JScrollPane
2
2
  module Rails
3
- VERSION = "2.0.20"
3
+ VERSION = "2.0.21"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jscrollpane-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.20
4
+ version: 2.0.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Bodrov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-24 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.1'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3.1'
27
27
  description: |-
@@ -35,10 +35,10 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - LICENSE
37
37
  - README.md
38
+ - app/assets/javascripts/jquery.jscrollpane.js
39
+ - app/assets/stylesheets/jscrollpane.css
38
40
  - lib/jscrollpane-rails.rb
39
41
  - lib/jscrollpane-rails/version.rb
40
- - vendor/assets/javascripts/jquery.jscrollpane.js
41
- - vendor/assets/stylesheets/jscrollpane.css
42
42
  homepage: https://github.com/bodrovis/jscrollpane-rails
43
43
  licenses:
44
44
  - MIT
@@ -49,17 +49,17 @@ require_paths:
49
49
  - lib
50
50
  required_ruby_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - '>='
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
61
  rubyforge_project:
62
- rubygems_version: 2.4.2
62
+ rubygems_version: 2.4.6
63
63
  signing_key:
64
64
  specification_version: 4
65
65
  summary: Includes javascript and css files for the jScrollPane plugin.
@@ -1,1467 +0,0 @@
1
- /*!
2
- * jScrollPane - v2.0.20 - 2014-10-23
3
- * http://jscrollpane.kelvinluck.com/
4
- *
5
- * Copyright (c) 2014 Kelvin Luck
6
- * Dual licensed under the MIT or GPL licenses.
7
- */
8
-
9
- // Script: jScrollPane - cross browser customisable scrollbars
10
- //
11
- // *Version: 2.0.20, Last updated: 2014-10-23*
12
- //
13
- // Project Home - http://jscrollpane.kelvinluck.com/
14
- // GitHub - http://github.com/vitch/jScrollPane
15
- // Source - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.js
16
- // (Minified) - http://github.com/vitch/jScrollPane/raw/master/script/jquery.jscrollpane.min.js
17
- //
18
- // About: License
19
- //
20
- // Copyright (c) 2014 Kelvin Luck
21
- // Dual licensed under the MIT or GPL Version 2 licenses.
22
- // http://jscrollpane.kelvinluck.com/MIT-LICENSE.txt
23
- // http://jscrollpane.kelvinluck.com/GPL-LICENSE.txt
24
- //
25
- // About: Examples
26
- //
27
- // All examples and demos are available through the jScrollPane example site at:
28
- // http://jscrollpane.kelvinluck.com/
29
- //
30
- // About: Support and Testing
31
- //
32
- // This plugin is tested on the browsers below and has been found to work reliably on them. If you run
33
- // into a problem on one of the supported browsers then please visit the support section on the jScrollPane
34
- // website (http://jscrollpane.kelvinluck.com/) for more information on getting support. You are also
35
- // welcome to fork the project on GitHub if you can contribute a fix for a given issue.
36
- //
37
- // jQuery Versions - tested in 1.4.2+ - reported to work in 1.3.x
38
- // Browsers Tested - Firefox 3.6.8, Safari 5, Opera 10.6, Chrome 5.0, IE 6, 7, 8
39
- //
40
- // About: Release History
41
- //
42
- // 2.0.20 - (2014-10-23) Adds AMD support (thanks @carlosrberto) and support for overflow-x/overflow-y (thanks @darimpulso)
43
- // 2.0.19 - (2013-11-16) Changes for more reliable scroll amount with latest mousewheel plugin (thanks @brandonaaron)
44
- // 2.0.18 - (2013-10-23) Fix for issue with gutters and scrollToElement (thanks @Dubiy)
45
- // 2.0.17 - (2013-08-17) Working correctly when box-sizing is set to border-box (thanks @pieht)
46
- // 2.0.16 - (2013-07-30) Resetting left position when scroll is removed. Fixes #189
47
- // 2.0.15 - (2013-07-29) Fixed issue with scrollToElement where the destX and destY are undefined.
48
- // 2.0.14 - (2013-05-01) Updated to most recent mouse wheel plugin (see #106) and related changes for sensible scroll speed
49
- // 2.0.13 - (2013-05-01) Switched to semver compatible version name
50
- // 2.0.0beta12 - (2012-09-27) fix for jQuery 1.8+
51
- // 2.0.0beta11 - (2012-05-14)
52
- // 2.0.0beta10 - (2011-04-17) cleaner required size calculation, improved keyboard support, stickToBottom/Left, other small fixes
53
- // 2.0.0beta9 - (2011-01-31) new API methods, bug fixes and correct keyboard support for FF/OSX
54
- // 2.0.0beta8 - (2011-01-29) touchscreen support, improved keyboard support
55
- // 2.0.0beta7 - (2011-01-23) scroll speed consistent (thanks Aivo Paas)
56
- // 2.0.0beta6 - (2010-12-07) scrollToElement horizontal support
57
- // 2.0.0beta5 - (2010-10-18) jQuery 1.4.3 support, various bug fixes
58
- // 2.0.0beta4 - (2010-09-17) clickOnTrack support, bug fixes
59
- // 2.0.0beta3 - (2010-08-27) Horizontal mousewheel, mwheelIntent, keyboard support, bug fixes
60
- // 2.0.0beta2 - (2010-08-21) Bug fixes
61
- // 2.0.0beta1 - (2010-08-17) Rewrite to follow modern best practices and enable horizontal scrolling, initially hidden
62
- // elements and dynamically sized elements.
63
- // 1.x - (2006-12-31 - 2010-07-31) Initial version, hosted at googlecode, deprecated
64
-
65
- (function (plugin, window) {
66
- var factory = function($){
67
- return plugin($, window);
68
- }
69
- if ( typeof define === 'function' && define.amd ) {
70
- // AMD. Register as an anonymous module.
71
- define(['jquery'], factory);
72
- } else if (typeof exports === 'object') {
73
- // Node/CommonJS style for Browserify
74
- module.exports = factory;
75
- } else {
76
- // Browser globals
77
- factory(jQuery);
78
- }
79
- }(function($,window,undefined){
80
-
81
- $.fn.jScrollPane = function(settings)
82
- {
83
- // JScrollPane "class" - public methods are available through $('selector').data('jsp')
84
- function JScrollPane(elem, s)
85
- {
86
- var settings, jsp = this, pane, paneWidth, paneHeight, container, contentWidth, contentHeight,
87
- percentInViewH, percentInViewV, isScrollableV, isScrollableH, verticalDrag, dragMaxY,
88
- verticalDragPosition, horizontalDrag, dragMaxX, horizontalDragPosition,
89
- verticalBar, verticalTrack, scrollbarWidth, verticalTrackHeight, verticalDragHeight, arrowUp, arrowDown,
90
- horizontalBar, horizontalTrack, horizontalTrackWidth, horizontalDragWidth, arrowLeft, arrowRight,
91
- reinitialiseInterval, originalPadding, originalPaddingTotalWidth, previousContentWidth,
92
- wasAtTop = true, wasAtLeft = true, wasAtBottom = false, wasAtRight = false,
93
- originalElement = elem.clone(false, false).empty(),
94
- mwEvent = $.fn.mwheelIntent ? 'mwheelIntent.jsp' : 'mousewheel.jsp';
95
-
96
- if (elem.css('box-sizing') === 'border-box') {
97
- originalPadding = 0;
98
- originalPaddingTotalWidth = 0;
99
- } else {
100
- originalPadding = elem.css('paddingTop') + ' ' +
101
- elem.css('paddingRight') + ' ' +
102
- elem.css('paddingBottom') + ' ' +
103
- elem.css('paddingLeft');
104
- originalPaddingTotalWidth = (parseInt(elem.css('paddingLeft'), 10) || 0) +
105
- (parseInt(elem.css('paddingRight'), 10) || 0);
106
- }
107
-
108
- function initialise(s)
109
- {
110
-
111
- var /*firstChild, lastChild, */isMaintainingPositon, lastContentX, lastContentY,
112
- hasContainingSpaceChanged, originalScrollTop, originalScrollLeft,
113
- maintainAtBottom = false, maintainAtRight = false;
114
-
115
- settings = s;
116
-
117
- if (pane === undefined) {
118
- originalScrollTop = elem.scrollTop();
119
- originalScrollLeft = elem.scrollLeft();
120
-
121
- elem.css(
122
- {
123
- overflow: 'hidden',
124
- padding: 0
125
- }
126
- );
127
- // TODO: Deal with where width/ height is 0 as it probably means the element is hidden and we should
128
- // come back to it later and check once it is unhidden...
129
- paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
130
- paneHeight = elem.innerHeight();
131
-
132
- elem.width(paneWidth);
133
-
134
- pane = $('<div class="jspPane" />').css('padding', originalPadding).append(elem.children());
135
- container = $('<div class="jspContainer" />')
136
- .css({
137
- 'width': paneWidth + 'px',
138
- 'height': paneHeight + 'px'
139
- }
140
- ).append(pane).appendTo(elem);
141
-
142
- /*
143
- // Move any margins from the first and last children up to the container so they can still
144
- // collapse with neighbouring elements as they would before jScrollPane
145
- firstChild = pane.find(':first-child');
146
- lastChild = pane.find(':last-child');
147
- elem.css(
148
- {
149
- 'margin-top': firstChild.css('margin-top'),
150
- 'margin-bottom': lastChild.css('margin-bottom')
151
- }
152
- );
153
- firstChild.css('margin-top', 0);
154
- lastChild.css('margin-bottom', 0);
155
- */
156
- } else {
157
- elem.css('width', '');
158
-
159
- maintainAtBottom = settings.stickToBottom && isCloseToBottom();
160
- maintainAtRight = settings.stickToRight && isCloseToRight();
161
-
162
- hasContainingSpaceChanged = elem.innerWidth() + originalPaddingTotalWidth != paneWidth || elem.outerHeight() != paneHeight;
163
-
164
- if (hasContainingSpaceChanged) {
165
- paneWidth = elem.innerWidth() + originalPaddingTotalWidth;
166
- paneHeight = elem.innerHeight();
167
- container.css({
168
- width: paneWidth + 'px',
169
- height: paneHeight + 'px'
170
- });
171
- }
172
-
173
- // If nothing changed since last check...
174
- if (!hasContainingSpaceChanged && previousContentWidth == contentWidth && pane.outerHeight() == contentHeight) {
175
- elem.width(paneWidth);
176
- return;
177
- }
178
- previousContentWidth = contentWidth;
179
-
180
- pane.css('width', '');
181
- elem.width(paneWidth);
182
-
183
- container.find('>.jspVerticalBar,>.jspHorizontalBar').remove().end();
184
- }
185
-
186
- pane.css('overflow', 'auto');
187
- if (s.contentWidth) {
188
- contentWidth = s.contentWidth;
189
- } else {
190
- contentWidth = pane[0].scrollWidth;
191
- }
192
- contentHeight = pane[0].scrollHeight;
193
- pane.css('overflow', '');
194
-
195
- percentInViewH = contentWidth / paneWidth;
196
- percentInViewV = contentHeight / paneHeight;
197
- isScrollableV = percentInViewV > 1;
198
-
199
- isScrollableH = percentInViewH > 1;
200
-
201
- //console.log(paneWidth, paneHeight, contentWidth, contentHeight, percentInViewH, percentInViewV, isScrollableH, isScrollableV);
202
-
203
- if (!(isScrollableH || isScrollableV)) {
204
- elem.removeClass('jspScrollable');
205
- pane.css({
206
- top: 0,
207
- left: 0,
208
- width: container.width() - originalPaddingTotalWidth
209
- });
210
- removeMousewheel();
211
- removeFocusHandler();
212
- removeKeyboardNav();
213
- removeClickOnTrack();
214
- } else {
215
- elem.addClass('jspScrollable');
216
-
217
- isMaintainingPositon = settings.maintainPosition && (verticalDragPosition || horizontalDragPosition);
218
- if (isMaintainingPositon) {
219
- lastContentX = contentPositionX();
220
- lastContentY = contentPositionY();
221
- }
222
-
223
- initialiseVerticalScroll();
224
- initialiseHorizontalScroll();
225
- resizeScrollbars();
226
-
227
- if (isMaintainingPositon) {
228
- scrollToX(maintainAtRight ? (contentWidth - paneWidth ) : lastContentX, false);
229
- scrollToY(maintainAtBottom ? (contentHeight - paneHeight) : lastContentY, false);
230
- }
231
-
232
- initFocusHandler();
233
- initMousewheel();
234
- initTouch();
235
-
236
- if (settings.enableKeyboardNavigation) {
237
- initKeyboardNav();
238
- }
239
- if (settings.clickOnTrack) {
240
- initClickOnTrack();
241
- }
242
-
243
- observeHash();
244
- if (settings.hijackInternalLinks) {
245
- hijackInternalLinks();
246
- }
247
- }
248
-
249
- if (settings.autoReinitialise && !reinitialiseInterval) {
250
- reinitialiseInterval = setInterval(
251
- function()
252
- {
253
- initialise(settings);
254
- },
255
- settings.autoReinitialiseDelay
256
- );
257
- } else if (!settings.autoReinitialise && reinitialiseInterval) {
258
- clearInterval(reinitialiseInterval);
259
- }
260
-
261
- originalScrollTop && elem.scrollTop(0) && scrollToY(originalScrollTop, false);
262
- originalScrollLeft && elem.scrollLeft(0) && scrollToX(originalScrollLeft, false);
263
-
264
- elem.trigger('jsp-initialised', [isScrollableH || isScrollableV]);
265
- }
266
-
267
- function initialiseVerticalScroll()
268
- {
269
- if (isScrollableV) {
270
-
271
- container.append(
272
- $('<div class="jspVerticalBar" />').append(
273
- $('<div class="jspCap jspCapTop" />'),
274
- $('<div class="jspTrack" />').append(
275
- $('<div class="jspDrag" />').append(
276
- $('<div class="jspDragTop" />'),
277
- $('<div class="jspDragBottom" />')
278
- )
279
- ),
280
- $('<div class="jspCap jspCapBottom" />')
281
- )
282
- );
283
-
284
- verticalBar = container.find('>.jspVerticalBar');
285
- verticalTrack = verticalBar.find('>.jspTrack');
286
- verticalDrag = verticalTrack.find('>.jspDrag');
287
-
288
- if (settings.showArrows) {
289
- arrowUp = $('<a class="jspArrow jspArrowUp" />').bind(
290
- 'mousedown.jsp', getArrowScroll(0, -1)
291
- ).bind('click.jsp', nil);
292
- arrowDown = $('<a class="jspArrow jspArrowDown" />').bind(
293
- 'mousedown.jsp', getArrowScroll(0, 1)
294
- ).bind('click.jsp', nil);
295
- if (settings.arrowScrollOnHover) {
296
- arrowUp.bind('mouseover.jsp', getArrowScroll(0, -1, arrowUp));
297
- arrowDown.bind('mouseover.jsp', getArrowScroll(0, 1, arrowDown));
298
- }
299
-
300
- appendArrows(verticalTrack, settings.verticalArrowPositions, arrowUp, arrowDown);
301
- }
302
-
303
- verticalTrackHeight = paneHeight;
304
- container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').each(
305
- function()
306
- {
307
- verticalTrackHeight -= $(this).outerHeight();
308
- }
309
- );
310
-
311
-
312
- verticalDrag.hover(
313
- function()
314
- {
315
- verticalDrag.addClass('jspHover');
316
- },
317
- function()
318
- {
319
- verticalDrag.removeClass('jspHover');
320
- }
321
- ).bind(
322
- 'mousedown.jsp',
323
- function(e)
324
- {
325
- // Stop IE from allowing text selection
326
- $('html').bind('dragstart.jsp selectstart.jsp', nil);
327
-
328
- verticalDrag.addClass('jspActive');
329
-
330
- var startY = e.pageY - verticalDrag.position().top;
331
-
332
- $('html').bind(
333
- 'mousemove.jsp',
334
- function(e)
335
- {
336
- positionDragY(e.pageY - startY, false);
337
- }
338
- ).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
339
- return false;
340
- }
341
- );
342
- sizeVerticalScrollbar();
343
- }
344
- }
345
-
346
- function sizeVerticalScrollbar()
347
- {
348
- verticalTrack.height(verticalTrackHeight + 'px');
349
- verticalDragPosition = 0;
350
- scrollbarWidth = settings.verticalGutter + verticalTrack.outerWidth();
351
-
352
- // Make the pane thinner to allow for the vertical scrollbar
353
- pane.width(paneWidth - scrollbarWidth - originalPaddingTotalWidth);
354
-
355
- // Add margin to the left of the pane if scrollbars are on that side (to position
356
- // the scrollbar on the left or right set it's left or right property in CSS)
357
- try {
358
- if (verticalBar.position().left === 0) {
359
- pane.css('margin-left', scrollbarWidth + 'px');
360
- }
361
- } catch (err) {
362
- }
363
- }
364
-
365
- function initialiseHorizontalScroll()
366
- {
367
- if (isScrollableH) {
368
-
369
- container.append(
370
- $('<div class="jspHorizontalBar" />').append(
371
- $('<div class="jspCap jspCapLeft" />'),
372
- $('<div class="jspTrack" />').append(
373
- $('<div class="jspDrag" />').append(
374
- $('<div class="jspDragLeft" />'),
375
- $('<div class="jspDragRight" />')
376
- )
377
- ),
378
- $('<div class="jspCap jspCapRight" />')
379
- )
380
- );
381
-
382
- horizontalBar = container.find('>.jspHorizontalBar');
383
- horizontalTrack = horizontalBar.find('>.jspTrack');
384
- horizontalDrag = horizontalTrack.find('>.jspDrag');
385
-
386
- if (settings.showArrows) {
387
- arrowLeft = $('<a class="jspArrow jspArrowLeft" />').bind(
388
- 'mousedown.jsp', getArrowScroll(-1, 0)
389
- ).bind('click.jsp', nil);
390
- arrowRight = $('<a class="jspArrow jspArrowRight" />').bind(
391
- 'mousedown.jsp', getArrowScroll(1, 0)
392
- ).bind('click.jsp', nil);
393
- if (settings.arrowScrollOnHover) {
394
- arrowLeft.bind('mouseover.jsp', getArrowScroll(-1, 0, arrowLeft));
395
- arrowRight.bind('mouseover.jsp', getArrowScroll(1, 0, arrowRight));
396
- }
397
- appendArrows(horizontalTrack, settings.horizontalArrowPositions, arrowLeft, arrowRight);
398
- }
399
-
400
- horizontalDrag.hover(
401
- function()
402
- {
403
- horizontalDrag.addClass('jspHover');
404
- },
405
- function()
406
- {
407
- horizontalDrag.removeClass('jspHover');
408
- }
409
- ).bind(
410
- 'mousedown.jsp',
411
- function(e)
412
- {
413
- // Stop IE from allowing text selection
414
- $('html').bind('dragstart.jsp selectstart.jsp', nil);
415
-
416
- horizontalDrag.addClass('jspActive');
417
-
418
- var startX = e.pageX - horizontalDrag.position().left;
419
-
420
- $('html').bind(
421
- 'mousemove.jsp',
422
- function(e)
423
- {
424
- positionDragX(e.pageX - startX, false);
425
- }
426
- ).bind('mouseup.jsp mouseleave.jsp', cancelDrag);
427
- return false;
428
- }
429
- );
430
- horizontalTrackWidth = container.innerWidth();
431
- sizeHorizontalScrollbar();
432
- }
433
- }
434
-
435
- function sizeHorizontalScrollbar()
436
- {
437
- container.find('>.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow').each(
438
- function()
439
- {
440
- horizontalTrackWidth -= $(this).outerWidth();
441
- }
442
- );
443
-
444
- horizontalTrack.width(horizontalTrackWidth + 'px');
445
- horizontalDragPosition = 0;
446
- }
447
-
448
- function resizeScrollbars()
449
- {
450
- if (isScrollableH && isScrollableV) {
451
- var horizontalTrackHeight = horizontalTrack.outerHeight(),
452
- verticalTrackWidth = verticalTrack.outerWidth();
453
- verticalTrackHeight -= horizontalTrackHeight;
454
- $(horizontalBar).find('>.jspCap:visible,>.jspArrow').each(
455
- function()
456
- {
457
- horizontalTrackWidth += $(this).outerWidth();
458
- }
459
- );
460
- horizontalTrackWidth -= verticalTrackWidth;
461
- paneHeight -= verticalTrackWidth;
462
- paneWidth -= horizontalTrackHeight;
463
- horizontalTrack.parent().append(
464
- $('<div class="jspCorner" />').css('width', horizontalTrackHeight + 'px')
465
- );
466
- sizeVerticalScrollbar();
467
- sizeHorizontalScrollbar();
468
- }
469
- // reflow content
470
- if (isScrollableH) {
471
- pane.width((container.outerWidth() - originalPaddingTotalWidth) + 'px');
472
- }
473
- contentHeight = pane.outerHeight();
474
- percentInViewV = contentHeight / paneHeight;
475
-
476
- if (isScrollableH) {
477
- horizontalDragWidth = Math.ceil(1 / percentInViewH * horizontalTrackWidth);
478
- if (horizontalDragWidth > settings.horizontalDragMaxWidth) {
479
- horizontalDragWidth = settings.horizontalDragMaxWidth;
480
- } else if (horizontalDragWidth < settings.horizontalDragMinWidth) {
481
- horizontalDragWidth = settings.horizontalDragMinWidth;
482
- }
483
- horizontalDrag.width(horizontalDragWidth + 'px');
484
- dragMaxX = horizontalTrackWidth - horizontalDragWidth;
485
- _positionDragX(horizontalDragPosition); // To update the state for the arrow buttons
486
- }
487
- if (isScrollableV) {
488
- verticalDragHeight = Math.ceil(1 / percentInViewV * verticalTrackHeight);
489
- if (verticalDragHeight > settings.verticalDragMaxHeight) {
490
- verticalDragHeight = settings.verticalDragMaxHeight;
491
- } else if (verticalDragHeight < settings.verticalDragMinHeight) {
492
- verticalDragHeight = settings.verticalDragMinHeight;
493
- }
494
- verticalDrag.height(verticalDragHeight + 'px');
495
- dragMaxY = verticalTrackHeight - verticalDragHeight;
496
- _positionDragY(verticalDragPosition); // To update the state for the arrow buttons
497
- }
498
- }
499
-
500
- function appendArrows(ele, p, a1, a2)
501
- {
502
- var p1 = "before", p2 = "after", aTemp;
503
-
504
- // Sniff for mac... Is there a better way to determine whether the arrows would naturally appear
505
- // at the top or the bottom of the bar?
506
- if (p == "os") {
507
- p = /Mac/.test(navigator.platform) ? "after" : "split";
508
- }
509
- if (p == p1) {
510
- p2 = p;
511
- } else if (p == p2) {
512
- p1 = p;
513
- aTemp = a1;
514
- a1 = a2;
515
- a2 = aTemp;
516
- }
517
-
518
- ele[p1](a1)[p2](a2);
519
- }
520
-
521
- function getArrowScroll(dirX, dirY, ele)
522
- {
523
- return function()
524
- {
525
- arrowScroll(dirX, dirY, this, ele);
526
- this.blur();
527
- return false;
528
- };
529
- }
530
-
531
- function arrowScroll(dirX, dirY, arrow, ele)
532
- {
533
- arrow = $(arrow).addClass('jspActive');
534
-
535
- var eve,
536
- scrollTimeout,
537
- isFirst = true,
538
- doScroll = function()
539
- {
540
- if (dirX !== 0) {
541
- jsp.scrollByX(dirX * settings.arrowButtonSpeed);
542
- }
543
- if (dirY !== 0) {
544
- jsp.scrollByY(dirY * settings.arrowButtonSpeed);
545
- }
546
- scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.arrowRepeatFreq);
547
- isFirst = false;
548
- };
549
-
550
- doScroll();
551
-
552
- eve = ele ? 'mouseout.jsp' : 'mouseup.jsp';
553
- ele = ele || $('html');
554
- ele.bind(
555
- eve,
556
- function()
557
- {
558
- arrow.removeClass('jspActive');
559
- scrollTimeout && clearTimeout(scrollTimeout);
560
- scrollTimeout = null;
561
- ele.unbind(eve);
562
- }
563
- );
564
- }
565
-
566
- function initClickOnTrack()
567
- {
568
- removeClickOnTrack();
569
- if (isScrollableV) {
570
- verticalTrack.bind(
571
- 'mousedown.jsp',
572
- function(e)
573
- {
574
- if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
575
- var clickedTrack = $(this),
576
- offset = clickedTrack.offset(),
577
- direction = e.pageY - offset.top - verticalDragPosition,
578
- scrollTimeout,
579
- isFirst = true,
580
- doScroll = function()
581
- {
582
- var offset = clickedTrack.offset(),
583
- pos = e.pageY - offset.top - verticalDragHeight / 2,
584
- contentDragY = paneHeight * settings.scrollPagePercent,
585
- dragY = dragMaxY * contentDragY / (contentHeight - paneHeight);
586
- if (direction < 0) {
587
- if (verticalDragPosition - dragY > pos) {
588
- jsp.scrollByY(-contentDragY);
589
- } else {
590
- positionDragY(pos);
591
- }
592
- } else if (direction > 0) {
593
- if (verticalDragPosition + dragY < pos) {
594
- jsp.scrollByY(contentDragY);
595
- } else {
596
- positionDragY(pos);
597
- }
598
- } else {
599
- cancelClick();
600
- return;
601
- }
602
- scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
603
- isFirst = false;
604
- },
605
- cancelClick = function()
606
- {
607
- scrollTimeout && clearTimeout(scrollTimeout);
608
- scrollTimeout = null;
609
- $(document).unbind('mouseup.jsp', cancelClick);
610
- };
611
- doScroll();
612
- $(document).bind('mouseup.jsp', cancelClick);
613
- return false;
614
- }
615
- }
616
- );
617
- }
618
-
619
- if (isScrollableH) {
620
- horizontalTrack.bind(
621
- 'mousedown.jsp',
622
- function(e)
623
- {
624
- if (e.originalTarget === undefined || e.originalTarget == e.currentTarget) {
625
- var clickedTrack = $(this),
626
- offset = clickedTrack.offset(),
627
- direction = e.pageX - offset.left - horizontalDragPosition,
628
- scrollTimeout,
629
- isFirst = true,
630
- doScroll = function()
631
- {
632
- var offset = clickedTrack.offset(),
633
- pos = e.pageX - offset.left - horizontalDragWidth / 2,
634
- contentDragX = paneWidth * settings.scrollPagePercent,
635
- dragX = dragMaxX * contentDragX / (contentWidth - paneWidth);
636
- if (direction < 0) {
637
- if (horizontalDragPosition - dragX > pos) {
638
- jsp.scrollByX(-contentDragX);
639
- } else {
640
- positionDragX(pos);
641
- }
642
- } else if (direction > 0) {
643
- if (horizontalDragPosition + dragX < pos) {
644
- jsp.scrollByX(contentDragX);
645
- } else {
646
- positionDragX(pos);
647
- }
648
- } else {
649
- cancelClick();
650
- return;
651
- }
652
- scrollTimeout = setTimeout(doScroll, isFirst ? settings.initialDelay : settings.trackClickRepeatFreq);
653
- isFirst = false;
654
- },
655
- cancelClick = function()
656
- {
657
- scrollTimeout && clearTimeout(scrollTimeout);
658
- scrollTimeout = null;
659
- $(document).unbind('mouseup.jsp', cancelClick);
660
- };
661
- doScroll();
662
- $(document).bind('mouseup.jsp', cancelClick);
663
- return false;
664
- }
665
- }
666
- );
667
- }
668
- }
669
-
670
- function removeClickOnTrack()
671
- {
672
- if (horizontalTrack) {
673
- horizontalTrack.unbind('mousedown.jsp');
674
- }
675
- if (verticalTrack) {
676
- verticalTrack.unbind('mousedown.jsp');
677
- }
678
- }
679
-
680
- function cancelDrag()
681
- {
682
- $('html').unbind('dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp');
683
-
684
- if (verticalDrag) {
685
- verticalDrag.removeClass('jspActive');
686
- }
687
- if (horizontalDrag) {
688
- horizontalDrag.removeClass('jspActive');
689
- }
690
- }
691
-
692
- function positionDragY(destY, animate)
693
- {
694
- if (!isScrollableV) {
695
- return;
696
- }
697
- if (destY < 0) {
698
- destY = 0;
699
- } else if (destY > dragMaxY) {
700
- destY = dragMaxY;
701
- }
702
-
703
- // can't just check if(animate) because false is a valid value that could be passed in...
704
- if (animate === undefined) {
705
- animate = settings.animateScroll;
706
- }
707
- if (animate) {
708
- jsp.animate(verticalDrag, 'top', destY, _positionDragY);
709
- } else {
710
- verticalDrag.css('top', destY);
711
- _positionDragY(destY);
712
- }
713
-
714
- }
715
-
716
- function _positionDragY(destY)
717
- {
718
- if (destY === undefined) {
719
- destY = verticalDrag.position().top;
720
- }
721
-
722
- container.scrollTop(0);
723
- verticalDragPosition = destY || 0;
724
-
725
- var isAtTop = verticalDragPosition === 0,
726
- isAtBottom = verticalDragPosition == dragMaxY,
727
- percentScrolled = destY/ dragMaxY,
728
- destTop = -percentScrolled * (contentHeight - paneHeight);
729
-
730
- if (wasAtTop != isAtTop || wasAtBottom != isAtBottom) {
731
- wasAtTop = isAtTop;
732
- wasAtBottom = isAtBottom;
733
- elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
734
- }
735
-
736
- updateVerticalArrows(isAtTop, isAtBottom);
737
- pane.css('top', destTop);
738
- elem.trigger('jsp-scroll-y', [-destTop, isAtTop, isAtBottom]).trigger('scroll');
739
- }
740
-
741
- function positionDragX(destX, animate)
742
- {
743
- if (!isScrollableH) {
744
- return;
745
- }
746
- if (destX < 0) {
747
- destX = 0;
748
- } else if (destX > dragMaxX) {
749
- destX = dragMaxX;
750
- }
751
-
752
- if (animate === undefined) {
753
- animate = settings.animateScroll;
754
- }
755
- if (animate) {
756
- jsp.animate(horizontalDrag, 'left', destX, _positionDragX);
757
- } else {
758
- horizontalDrag.css('left', destX);
759
- _positionDragX(destX);
760
- }
761
- }
762
-
763
- function _positionDragX(destX)
764
- {
765
- if (destX === undefined) {
766
- destX = horizontalDrag.position().left;
767
- }
768
-
769
- container.scrollTop(0);
770
- horizontalDragPosition = destX ||0;
771
-
772
- var isAtLeft = horizontalDragPosition === 0,
773
- isAtRight = horizontalDragPosition == dragMaxX,
774
- percentScrolled = destX / dragMaxX,
775
- destLeft = -percentScrolled * (contentWidth - paneWidth);
776
-
777
- if (wasAtLeft != isAtLeft || wasAtRight != isAtRight) {
778
- wasAtLeft = isAtLeft;
779
- wasAtRight = isAtRight;
780
- elem.trigger('jsp-arrow-change', [wasAtTop, wasAtBottom, wasAtLeft, wasAtRight]);
781
- }
782
-
783
- updateHorizontalArrows(isAtLeft, isAtRight);
784
- pane.css('left', destLeft);
785
- elem.trigger('jsp-scroll-x', [-destLeft, isAtLeft, isAtRight]).trigger('scroll');
786
- }
787
-
788
- function updateVerticalArrows(isAtTop, isAtBottom)
789
- {
790
- if (settings.showArrows) {
791
- arrowUp[isAtTop ? 'addClass' : 'removeClass']('jspDisabled');
792
- arrowDown[isAtBottom ? 'addClass' : 'removeClass']('jspDisabled');
793
- }
794
- }
795
-
796
- function updateHorizontalArrows(isAtLeft, isAtRight)
797
- {
798
- if (settings.showArrows) {
799
- arrowLeft[isAtLeft ? 'addClass' : 'removeClass']('jspDisabled');
800
- arrowRight[isAtRight ? 'addClass' : 'removeClass']('jspDisabled');
801
- }
802
- }
803
-
804
- function scrollToY(destY, animate)
805
- {
806
- var percentScrolled = destY / (contentHeight - paneHeight);
807
- positionDragY(percentScrolled * dragMaxY, animate);
808
- }
809
-
810
- function scrollToX(destX, animate)
811
- {
812
- var percentScrolled = destX / (contentWidth - paneWidth);
813
- positionDragX(percentScrolled * dragMaxX, animate);
814
- }
815
-
816
- function scrollToElement(ele, stickToTop, animate)
817
- {
818
- var e, eleHeight, eleWidth, eleTop = 0, eleLeft = 0, viewportTop, viewportLeft, maxVisibleEleTop, maxVisibleEleLeft, destY, destX;
819
-
820
- // Legal hash values aren't necessarily legal jQuery selectors so we need to catch any
821
- // errors from the lookup...
822
- try {
823
- e = $(ele);
824
- } catch (err) {
825
- return;
826
- }
827
- eleHeight = e.outerHeight();
828
- eleWidth= e.outerWidth();
829
-
830
- container.scrollTop(0);
831
- container.scrollLeft(0);
832
-
833
- // loop through parents adding the offset top of any elements that are relatively positioned between
834
- // the focused element and the jspPane so we can get the true distance from the top
835
- // of the focused element to the top of the scrollpane...
836
- while (!e.is('.jspPane')) {
837
- eleTop += e.position().top;
838
- eleLeft += e.position().left;
839
- e = e.offsetParent();
840
- if (/^body|html$/i.test(e[0].nodeName)) {
841
- // we ended up too high in the document structure. Quit!
842
- return;
843
- }
844
- }
845
-
846
- viewportTop = contentPositionY();
847
- maxVisibleEleTop = viewportTop + paneHeight;
848
- if (eleTop < viewportTop || stickToTop) { // element is above viewport
849
- destY = eleTop - settings.horizontalGutter;
850
- } else if (eleTop + eleHeight > maxVisibleEleTop) { // element is below viewport
851
- destY = eleTop - paneHeight + eleHeight + settings.horizontalGutter;
852
- }
853
- if (!isNaN(destY)) {
854
- scrollToY(destY, animate);
855
- }
856
-
857
- viewportLeft = contentPositionX();
858
- maxVisibleEleLeft = viewportLeft + paneWidth;
859
- if (eleLeft < viewportLeft || stickToTop) { // element is to the left of viewport
860
- destX = eleLeft - settings.horizontalGutter;
861
- } else if (eleLeft + eleWidth > maxVisibleEleLeft) { // element is to the right viewport
862
- destX = eleLeft - paneWidth + eleWidth + settings.horizontalGutter;
863
- }
864
- if (!isNaN(destX)) {
865
- scrollToX(destX, animate);
866
- }
867
-
868
- }
869
-
870
- function contentPositionX()
871
- {
872
- return -pane.position().left;
873
- }
874
-
875
- function contentPositionY()
876
- {
877
- return -pane.position().top;
878
- }
879
-
880
- function isCloseToBottom()
881
- {
882
- var scrollableHeight = contentHeight - paneHeight;
883
- return (scrollableHeight > 20) && (scrollableHeight - contentPositionY() < 10);
884
- }
885
-
886
- function isCloseToRight()
887
- {
888
- var scrollableWidth = contentWidth - paneWidth;
889
- return (scrollableWidth > 20) && (scrollableWidth - contentPositionX() < 10);
890
- }
891
-
892
- function initMousewheel()
893
- {
894
- container.unbind(mwEvent).bind(
895
- mwEvent,
896
- function (event, delta, deltaX, deltaY) {
897
-
898
- if (!horizontalDragPosition) horizontalDragPosition = 0;
899
- if (!verticalDragPosition) verticalDragPosition = 0;
900
-
901
- var dX = horizontalDragPosition, dY = verticalDragPosition, factor = event.deltaFactor || settings.mouseWheelSpeed;
902
- jsp.scrollBy(deltaX * factor, -deltaY * factor, false);
903
- // return true if there was no movement so rest of screen can scroll
904
- return dX == horizontalDragPosition && dY == verticalDragPosition;
905
- }
906
- );
907
- }
908
-
909
- function removeMousewheel()
910
- {
911
- container.unbind(mwEvent);
912
- }
913
-
914
- function nil()
915
- {
916
- return false;
917
- }
918
-
919
- function initFocusHandler()
920
- {
921
- pane.find(':input,a').unbind('focus.jsp').bind(
922
- 'focus.jsp',
923
- function(e)
924
- {
925
- scrollToElement(e.target, false);
926
- }
927
- );
928
- }
929
-
930
- function removeFocusHandler()
931
- {
932
- pane.find(':input,a').unbind('focus.jsp');
933
- }
934
-
935
- function initKeyboardNav()
936
- {
937
- var keyDown, elementHasScrolled, validParents = [];
938
- isScrollableH && validParents.push(horizontalBar[0]);
939
- isScrollableV && validParents.push(verticalBar[0]);
940
-
941
- // IE also focuses elements that don't have tabindex set.
942
- pane.focus(
943
- function()
944
- {
945
- elem.focus();
946
- }
947
- );
948
-
949
- elem.attr('tabindex', 0)
950
- .unbind('keydown.jsp keypress.jsp')
951
- .bind(
952
- 'keydown.jsp',
953
- function(e)
954
- {
955
- if (e.target !== this && !(validParents.length && $(e.target).closest(validParents).length)){
956
- return;
957
- }
958
- var dX = horizontalDragPosition, dY = verticalDragPosition;
959
- switch(e.keyCode) {
960
- case 40: // down
961
- case 38: // up
962
- case 34: // page down
963
- case 32: // space
964
- case 33: // page up
965
- case 39: // right
966
- case 37: // left
967
- keyDown = e.keyCode;
968
- keyDownHandler();
969
- break;
970
- case 35: // end
971
- scrollToY(contentHeight - paneHeight);
972
- keyDown = null;
973
- break;
974
- case 36: // home
975
- scrollToY(0);
976
- keyDown = null;
977
- break;
978
- }
979
-
980
- elementHasScrolled = e.keyCode == keyDown && dX != horizontalDragPosition || dY != verticalDragPosition;
981
- return !elementHasScrolled;
982
- }
983
- ).bind(
984
- 'keypress.jsp', // For FF/ OSX so that we can cancel the repeat key presses if the JSP scrolls...
985
- function(e)
986
- {
987
- if (e.keyCode == keyDown) {
988
- keyDownHandler();
989
- }
990
- return !elementHasScrolled;
991
- }
992
- );
993
-
994
- if (settings.hideFocus) {
995
- elem.css('outline', 'none');
996
- if ('hideFocus' in container[0]){
997
- elem.attr('hideFocus', true);
998
- }
999
- } else {
1000
- elem.css('outline', '');
1001
- if ('hideFocus' in container[0]){
1002
- elem.attr('hideFocus', false);
1003
- }
1004
- }
1005
-
1006
- function keyDownHandler()
1007
- {
1008
- var dX = horizontalDragPosition, dY = verticalDragPosition;
1009
- switch(keyDown) {
1010
- case 40: // down
1011
- jsp.scrollByY(settings.keyboardSpeed, false);
1012
- break;
1013
- case 38: // up
1014
- jsp.scrollByY(-settings.keyboardSpeed, false);
1015
- break;
1016
- case 34: // page down
1017
- case 32: // space
1018
- jsp.scrollByY(paneHeight * settings.scrollPagePercent, false);
1019
- break;
1020
- case 33: // page up
1021
- jsp.scrollByY(-paneHeight * settings.scrollPagePercent, false);
1022
- break;
1023
- case 39: // right
1024
- jsp.scrollByX(settings.keyboardSpeed, false);
1025
- break;
1026
- case 37: // left
1027
- jsp.scrollByX(-settings.keyboardSpeed, false);
1028
- break;
1029
- }
1030
-
1031
- elementHasScrolled = dX != horizontalDragPosition || dY != verticalDragPosition;
1032
- return elementHasScrolled;
1033
- }
1034
- }
1035
-
1036
- function removeKeyboardNav()
1037
- {
1038
- elem.attr('tabindex', '-1')
1039
- .removeAttr('tabindex')
1040
- .unbind('keydown.jsp keypress.jsp');
1041
- }
1042
-
1043
- function observeHash()
1044
- {
1045
- if (location.hash && location.hash.length > 1) {
1046
- var e,
1047
- retryInt,
1048
- hash = escape(location.hash.substr(1)) // hash must be escaped to prevent XSS
1049
- ;
1050
- try {
1051
- e = $('#' + hash + ', a[name="' + hash + '"]');
1052
- } catch (err) {
1053
- return;
1054
- }
1055
-
1056
- if (e.length && pane.find(hash)) {
1057
- // nasty workaround but it appears to take a little while before the hash has done its thing
1058
- // to the rendered page so we just wait until the container's scrollTop has been messed up.
1059
- if (container.scrollTop() === 0) {
1060
- retryInt = setInterval(
1061
- function()
1062
- {
1063
- if (container.scrollTop() > 0) {
1064
- scrollToElement(e, true);
1065
- $(document).scrollTop(container.position().top);
1066
- clearInterval(retryInt);
1067
- }
1068
- },
1069
- 50
1070
- );
1071
- } else {
1072
- scrollToElement(e, true);
1073
- $(document).scrollTop(container.position().top);
1074
- }
1075
- }
1076
- }
1077
- }
1078
-
1079
- function hijackInternalLinks()
1080
- {
1081
- // only register the link handler once
1082
- if ($(document.body).data('jspHijack')) {
1083
- return;
1084
- }
1085
-
1086
- // remember that the handler was bound
1087
- $(document.body).data('jspHijack', true);
1088
-
1089
- // use live handler to also capture newly created links
1090
- $(document.body).delegate('a[href*=#]', 'click', function(event) {
1091
- // does the link point to the same page?
1092
- // this also takes care of cases with a <base>-Tag or Links not starting with the hash #
1093
- // e.g. <a href="index.html#test"> when the current url already is index.html
1094
- var href = this.href.substr(0, this.href.indexOf('#')),
1095
- locationHref = location.href,
1096
- hash,
1097
- element,
1098
- container,
1099
- jsp,
1100
- scrollTop,
1101
- elementTop;
1102
- if (location.href.indexOf('#') !== -1) {
1103
- locationHref = location.href.substr(0, location.href.indexOf('#'));
1104
- }
1105
- if (href !== locationHref) {
1106
- // the link points to another page
1107
- return;
1108
- }
1109
-
1110
- // check if jScrollPane should handle this click event
1111
- hash = escape(this.href.substr(this.href.indexOf('#') + 1));
1112
-
1113
- // find the element on the page
1114
- element;
1115
- try {
1116
- element = $('#' + hash + ', a[name="' + hash + '"]');
1117
- } catch (e) {
1118
- // hash is not a valid jQuery identifier
1119
- return;
1120
- }
1121
-
1122
- if (!element.length) {
1123
- // this link does not point to an element on this page
1124
- return;
1125
- }
1126
-
1127
- container = element.closest('.jspScrollable');
1128
- jsp = container.data('jsp');
1129
-
1130
- // jsp might be another jsp instance than the one, that bound this event
1131
- // remember: this event is only bound once for all instances.
1132
- jsp.scrollToElement(element, true);
1133
-
1134
- if (container[0].scrollIntoView) {
1135
- // also scroll to the top of the container (if it is not visible)
1136
- scrollTop = $(window).scrollTop();
1137
- elementTop = element.offset().top;
1138
- if (elementTop < scrollTop || elementTop > scrollTop + $(window).height()) {
1139
- container[0].scrollIntoView();
1140
- }
1141
- }
1142
-
1143
- // jsp handled this event, prevent the browser default (scrolling :P)
1144
- event.preventDefault();
1145
- });
1146
- }
1147
-
1148
- // Init touch on iPad, iPhone, iPod, Android
1149
- function initTouch()
1150
- {
1151
- var startX,
1152
- startY,
1153
- touchStartX,
1154
- touchStartY,
1155
- moved,
1156
- moving = false;
1157
-
1158
- container.unbind('touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick').bind(
1159
- 'touchstart.jsp',
1160
- function(e)
1161
- {
1162
- var touch = e.originalEvent.touches[0];
1163
- startX = contentPositionX();
1164
- startY = contentPositionY();
1165
- touchStartX = touch.pageX;
1166
- touchStartY = touch.pageY;
1167
- moved = false;
1168
- moving = true;
1169
- }
1170
- ).bind(
1171
- 'touchmove.jsp',
1172
- function(ev)
1173
- {
1174
- if(!moving) {
1175
- return;
1176
- }
1177
-
1178
- var touchPos = ev.originalEvent.touches[0],
1179
- dX = horizontalDragPosition, dY = verticalDragPosition;
1180
-
1181
- jsp.scrollTo(startX + touchStartX - touchPos.pageX, startY + touchStartY - touchPos.pageY);
1182
-
1183
- moved = moved || Math.abs(touchStartX - touchPos.pageX) > 5 || Math.abs(touchStartY - touchPos.pageY) > 5;
1184
-
1185
- // return true if there was no movement so rest of screen can scroll
1186
- return dX == horizontalDragPosition && dY == verticalDragPosition;
1187
- }
1188
- ).bind(
1189
- 'touchend.jsp',
1190
- function(e)
1191
- {
1192
- moving = false;
1193
- /*if(moved) {
1194
- return false;
1195
- }*/
1196
- }
1197
- ).bind(
1198
- 'click.jsp-touchclick',
1199
- function(e)
1200
- {
1201
- if(moved) {
1202
- moved = false;
1203
- return false;
1204
- }
1205
- }
1206
- );
1207
- }
1208
-
1209
- function destroy(){
1210
- var currentY = contentPositionY(),
1211
- currentX = contentPositionX();
1212
- elem.removeClass('jspScrollable').unbind('.jsp');
1213
- elem.replaceWith(originalElement.append(pane.children()));
1214
- originalElement.scrollTop(currentY);
1215
- originalElement.scrollLeft(currentX);
1216
-
1217
- // clear reinitialize timer if active
1218
- if (reinitialiseInterval) {
1219
- clearInterval(reinitialiseInterval);
1220
- }
1221
- }
1222
-
1223
- // Public API
1224
- $.extend(
1225
- jsp,
1226
- {
1227
- // Reinitialises the scroll pane (if it's internal dimensions have changed since the last time it
1228
- // was initialised). The settings object which is passed in will override any settings from the
1229
- // previous time it was initialised - if you don't pass any settings then the ones from the previous
1230
- // initialisation will be used.
1231
- reinitialise: function(s)
1232
- {
1233
- s = $.extend({}, settings, s);
1234
- initialise(s);
1235
- },
1236
- // Scrolls the specified element (a jQuery object, DOM node or jQuery selector string) into view so
1237
- // that it can be seen within the viewport. If stickToTop is true then the element will appear at
1238
- // the top of the viewport, if it is false then the viewport will scroll as little as possible to
1239
- // show the element. You can also specify if you want animation to occur. If you don't provide this
1240
- // argument then the animateScroll value from the settings object is used instead.
1241
- scrollToElement: function(ele, stickToTop, animate)
1242
- {
1243
- scrollToElement(ele, stickToTop, animate);
1244
- },
1245
- // Scrolls the pane so that the specified co-ordinates within the content are at the top left
1246
- // of the viewport. animate is optional and if not passed then the value of animateScroll from
1247
- // the settings object this jScrollPane was initialised with is used.
1248
- scrollTo: function(destX, destY, animate)
1249
- {
1250
- scrollToX(destX, animate);
1251
- scrollToY(destY, animate);
1252
- },
1253
- // Scrolls the pane so that the specified co-ordinate within the content is at the left of the
1254
- // viewport. animate is optional and if not passed then the value of animateScroll from the settings
1255
- // object this jScrollPane was initialised with is used.
1256
- scrollToX: function(destX, animate)
1257
- {
1258
- scrollToX(destX, animate);
1259
- },
1260
- // Scrolls the pane so that the specified co-ordinate within the content is at the top of the
1261
- // viewport. animate is optional and if not passed then the value of animateScroll from the settings
1262
- // object this jScrollPane was initialised with is used.
1263
- scrollToY: function(destY, animate)
1264
- {
1265
- scrollToY(destY, animate);
1266
- },
1267
- // Scrolls the pane to the specified percentage of its maximum horizontal scroll position. animate
1268
- // is optional and if not passed then the value of animateScroll from the settings object this
1269
- // jScrollPane was initialised with is used.
1270
- scrollToPercentX: function(destPercentX, animate)
1271
- {
1272
- scrollToX(destPercentX * (contentWidth - paneWidth), animate);
1273
- },
1274
- // Scrolls the pane to the specified percentage of its maximum vertical scroll position. animate
1275
- // is optional and if not passed then the value of animateScroll from the settings object this
1276
- // jScrollPane was initialised with is used.
1277
- scrollToPercentY: function(destPercentY, animate)
1278
- {
1279
- scrollToY(destPercentY * (contentHeight - paneHeight), animate);
1280
- },
1281
- // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
1282
- // the value of animateScroll from the settings object this jScrollPane was initialised with is used.
1283
- scrollBy: function(deltaX, deltaY, animate)
1284
- {
1285
- jsp.scrollByX(deltaX, animate);
1286
- jsp.scrollByY(deltaY, animate);
1287
- },
1288
- // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
1289
- // the value of animateScroll from the settings object this jScrollPane was initialised with is used.
1290
- scrollByX: function(deltaX, animate)
1291
- {
1292
- var destX = contentPositionX() + Math[deltaX<0 ? 'floor' : 'ceil'](deltaX),
1293
- percentScrolled = destX / (contentWidth - paneWidth);
1294
- positionDragX(percentScrolled * dragMaxX, animate);
1295
- },
1296
- // Scrolls the pane by the specified amount of pixels. animate is optional and if not passed then
1297
- // the value of animateScroll from the settings object this jScrollPane was initialised with is used.
1298
- scrollByY: function(deltaY, animate)
1299
- {
1300
- var destY = contentPositionY() + Math[deltaY<0 ? 'floor' : 'ceil'](deltaY),
1301
- percentScrolled = destY / (contentHeight - paneHeight);
1302
- positionDragY(percentScrolled * dragMaxY, animate);
1303
- },
1304
- // Positions the horizontal drag at the specified x position (and updates the viewport to reflect
1305
- // this). animate is optional and if not passed then the value of animateScroll from the settings
1306
- // object this jScrollPane was initialised with is used.
1307
- positionDragX: function(x, animate)
1308
- {
1309
- positionDragX(x, animate);
1310
- },
1311
- // Positions the vertical drag at the specified y position (and updates the viewport to reflect
1312
- // this). animate is optional and if not passed then the value of animateScroll from the settings
1313
- // object this jScrollPane was initialised with is used.
1314
- positionDragY: function(y, animate)
1315
- {
1316
- positionDragY(y, animate);
1317
- },
1318
- // This method is called when jScrollPane is trying to animate to a new position. You can override
1319
- // it if you want to provide advanced animation functionality. It is passed the following arguments:
1320
- // * ele - the element whose position is being animated
1321
- // * prop - the property that is being animated
1322
- // * value - the value it's being animated to
1323
- // * stepCallback - a function that you must execute each time you update the value of the property
1324
- // You can use the default implementation (below) as a starting point for your own implementation.
1325
- animate: function(ele, prop, value, stepCallback)
1326
- {
1327
- var params = {};
1328
- params[prop] = value;
1329
- ele.animate(
1330
- params,
1331
- {
1332
- 'duration' : settings.animateDuration,
1333
- 'easing' : settings.animateEase,
1334
- 'queue' : false,
1335
- 'step' : stepCallback
1336
- }
1337
- );
1338
- },
1339
- // Returns the current x position of the viewport with regards to the content pane.
1340
- getContentPositionX: function()
1341
- {
1342
- return contentPositionX();
1343
- },
1344
- // Returns the current y position of the viewport with regards to the content pane.
1345
- getContentPositionY: function()
1346
- {
1347
- return contentPositionY();
1348
- },
1349
- // Returns the width of the content within the scroll pane.
1350
- getContentWidth: function()
1351
- {
1352
- return contentWidth;
1353
- },
1354
- // Returns the height of the content within the scroll pane.
1355
- getContentHeight: function()
1356
- {
1357
- return contentHeight;
1358
- },
1359
- // Returns the horizontal position of the viewport within the pane content.
1360
- getPercentScrolledX: function()
1361
- {
1362
- return contentPositionX() / (contentWidth - paneWidth);
1363
- },
1364
- // Returns the vertical position of the viewport within the pane content.
1365
- getPercentScrolledY: function()
1366
- {
1367
- return contentPositionY() / (contentHeight - paneHeight);
1368
- },
1369
- // Returns whether or not this scrollpane has a horizontal scrollbar.
1370
- getIsScrollableH: function()
1371
- {
1372
- return isScrollableH;
1373
- },
1374
- // Returns whether or not this scrollpane has a vertical scrollbar.
1375
- getIsScrollableV: function()
1376
- {
1377
- return isScrollableV;
1378
- },
1379
- // Gets a reference to the content pane. It is important that you use this method if you want to
1380
- // edit the content of your jScrollPane as if you access the element directly then you may have some
1381
- // problems (as your original element has had additional elements for the scrollbars etc added into
1382
- // it).
1383
- getContentPane: function()
1384
- {
1385
- return pane;
1386
- },
1387
- // Scrolls this jScrollPane down as far as it can currently scroll. If animate isn't passed then the
1388
- // animateScroll value from settings is used instead.
1389
- scrollToBottom: function(animate)
1390
- {
1391
- positionDragY(dragMaxY, animate);
1392
- },
1393
- // Hijacks the links on the page which link to content inside the scrollpane. If you have changed
1394
- // the content of your page (e.g. via AJAX) and want to make sure any new anchor links to the
1395
- // contents of your scroll pane will work then call this function.
1396
- hijackInternalLinks: $.noop,
1397
- // Removes the jScrollPane and returns the page to the state it was in before jScrollPane was
1398
- // initialised.
1399
- destroy: function()
1400
- {
1401
- destroy();
1402
- }
1403
- }
1404
- );
1405
-
1406
- initialise(s);
1407
- }
1408
-
1409
- // Pluginifying code...
1410
- settings = $.extend({}, $.fn.jScrollPane.defaults, settings);
1411
-
1412
- // Apply default speed
1413
- $.each(['arrowButtonSpeed', 'trackClickSpeed', 'keyboardSpeed'], function() {
1414
- settings[this] = settings[this] || settings.speed;
1415
- });
1416
-
1417
- return this.each(
1418
- function()
1419
- {
1420
- var elem = $(this), jspApi = elem.data('jsp');
1421
- if (jspApi) {
1422
- jspApi.reinitialise(settings);
1423
- } else {
1424
- $("script",elem).filter('[type="text/javascript"],:not([type])').remove();
1425
- jspApi = new JScrollPane(elem, settings);
1426
- elem.data('jsp', jspApi);
1427
- }
1428
- }
1429
- );
1430
- };
1431
-
1432
- $.fn.jScrollPane.defaults = {
1433
- showArrows : false,
1434
- maintainPosition : true,
1435
- stickToBottom : false,
1436
- stickToRight : false,
1437
- clickOnTrack : true,
1438
- autoReinitialise : false,
1439
- autoReinitialiseDelay : 500,
1440
- verticalDragMinHeight : 0,
1441
- verticalDragMaxHeight : 99999,
1442
- horizontalDragMinWidth : 0,
1443
- horizontalDragMaxWidth : 99999,
1444
- contentWidth : undefined,
1445
- animateScroll : false,
1446
- animateDuration : 300,
1447
- animateEase : 'linear',
1448
- hijackInternalLinks : false,
1449
- verticalGutter : 4,
1450
- horizontalGutter : 4,
1451
- mouseWheelSpeed : 3,
1452
- arrowButtonSpeed : 0,
1453
- arrowRepeatFreq : 50,
1454
- arrowScrollOnHover : false,
1455
- trackClickSpeed : 0,
1456
- trackClickRepeatFreq : 70,
1457
- verticalArrowPositions : 'split',
1458
- horizontalArrowPositions : 'split',
1459
- enableKeyboardNavigation : true,
1460
- hideFocus : false,
1461
- keyboardSpeed : 0,
1462
- initialDelay : 300, // Delay before starting repeating
1463
- speed : 30, // Default speed when others falsey
1464
- scrollPagePercent : .8 // Percent of visible area scrolled when pageUp/Down or track area pressed
1465
- };
1466
-
1467
- },this));