Project

General

Profile

« Previous | Next » 

Revision faf4f771

Added by Andreas Kohlbecker almost 8 years ago

removing js library jquery.scrollTo

View differences:

modules/cdm_dataportal/cdm_dataportal.module
290 290

  
291 291

  
292 292
  drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/jquery.cdm.taxonomic_children.js');
293
  _add_js_lib_scrollTo();
294

  
293
  
295 294
  drupal_add_js('jQuery(document).ready(function() {
296 295
        jQuery(\'' . $jquery_selector . '\').taxonomic_children({
297 296
          hoverClass: "fa-rotate-90",
......
314 313
    drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/domEvent.js');
315 314
  }
316 315

  
317
  function _add_js_lib_scrollTo() {
318
    drupal_add_js(drupal_get_path('module', 'cdm_dataportal') . '/js/jquery.scrollTo-1.4.3.1'
319
      . (variable_get('cdm_js_devel_mode', FALSE) ? '-min' : '') . '.js');
320
  }
321

  
322 316
  function _add_jquery_ui()
323 317
  {
324 318
    drupal_add_css(drupal_get_path('module',
modules/cdm_dataportal/cdm_taxontree/cdm_taxontree.module
821 821
  drupal_add_js($path_preferred_module . '/js/jquery.dimensions.pack.js');
822 822
  drupal_add_js($path_cdm_taxontree . '/js/cdm_taxontree.js');
823 823

  
824
  _add_js_lib_scrollTo();
825

  
826 824
  drupal_add_js('
827 825
      jQuery(document).ready(function()
828 826
      {
modules/cdm_dataportal/cdm_taxontree/js/cdm_taxontree.js
164 164
            var lineHeight = focusedElement.css('line-height');
165 165
            lineHeight = lineHeight.replace('px', '');
166 166
            lineHeight = lineHeight.length == 0 ? 18 : lineHeight;
167
            cdm_taxontree_parent.find('div.' + vertical_scroller_selector).scrollTo(focusedElement, {duration: 400, axis:'y', offset:-2 * lineHeight});
167
            cdm_taxontree_parent.find('div.' + vertical_scroller_selector).scrollTop(focusedElement.position().top - (4 * lineHeight));
168 168
        }
169 169

  
170 170
    }
modules/cdm_dataportal/js/jquery.scrollTo-1.4.3.1-min.js
1
/**
2
 * Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
3
 * Dual licensed under MIT and GPL.
4
 * @author Ariel Flesler
5
 * @version 1.4.3.1
6
 */
7
;(function($){var h=$.scrollTo=function(a,b,c){$(window).scrollTo(a,b,c)};h.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1,limit:true};h.window=function(a){return $(window)._scrollable()};$.fn._scrollable=function(){return this.map(function(){var a=this,isWin=!a.nodeName||$.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!isWin)return a;var b=(a.contentWindow||a).document||a.ownerDocument||a;return/webkit/i.test(navigator.userAgent)||b.compatMode=='BackCompat'?b.body:b.documentElement})};$.fn.scrollTo=function(e,f,g){if(typeof f=='object'){g=f;f=0}if(typeof g=='function')g={onAfter:g};if(e=='max')e=9e9;g=$.extend({},h.defaults,g);f=f||g.duration;g.queue=g.queue&&g.axis.length>1;if(g.queue)f/=2;g.offset=both(g.offset);g.over=both(g.over);return this._scrollable().each(function(){if(e==null)return;var d=this,$elem=$(d),targ=e,toff,attr={},win=$elem.is('html,body');switch(typeof targ){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ)){targ=both(targ);break}targ=$(targ,this);if(!targ.length)return;case'object':if(targ.is||targ.style)toff=(targ=$(targ)).offset()}$.each(g.axis.split(''),function(i,a){var b=a=='x'?'Left':'Top',pos=b.toLowerCase(),key='scroll'+b,old=d[key],max=h.max(d,a);if(toff){attr[key]=toff[pos]+(win?0:old-$elem.offset()[pos]);if(g.margin){attr[key]-=parseInt(targ.css('margin'+b))||0;attr[key]-=parseInt(targ.css('border'+b+'Width'))||0}attr[key]+=g.offset[pos]||0;if(g.over[pos])attr[key]+=targ[a=='x'?'width':'height']()*g.over[pos]}else{var c=targ[pos];attr[key]=c.slice&&c.slice(-1)=='%'?parseFloat(c)/100*max:c}if(g.limit&&/^\d+$/.test(attr[key]))attr[key]=attr[key]<=0?0:Math.min(attr[key],max);if(!i&&g.queue){if(old!=attr[key])animate(g.onAfterFirst);delete attr[key]}});animate(g.onAfter);function animate(a){$elem.animate(attr,f,g.easing,a&&function(){a.call(this,e,g)})}}).end()};h.max=function(a,b){var c=b=='x'?'Width':'Height',scroll='scroll'+c;if(!$(a).is('html,body'))return a[scroll]-$(a)[c.toLowerCase()]();var d='client'+c,html=a.ownerDocument.documentElement,body=a.ownerDocument.body;return Math.max(html[scroll],body[scroll])-Math.min(html[d],body[d])};function both(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
modules/cdm_dataportal/js/jquery.scrollTo-1.4.3.1.js
1
/*!
2
 * jQuery.ScrollTo
3
 * Copyright (c) 2007-2012 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
4
 * Dual licensed under MIT and GPL.
5
 * Date: 4/09/2012
6
 *
7
 * @projectDescription Easy element scrolling using jQuery.
8
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
9
 * @author Ariel Flesler
10
 * @version 1.4.3.1
11
 *
12
 * @id jQuery.scrollTo
13
 * @id jQuery.fn.scrollTo
14
 * @param {String, Number, DOMElement, jQuery, Object} target Where to scroll the matched elements.
15
 *	  The different options for target are:
16
 *		- A number position (will be applied to all axes).
17
 *		- A string position ('44', '100px', '+=90', etc ) will be applied to all axes
18
 *		- A jQuery/DOM element ( logically, child of the element to scroll )
19
 *		- A string selector, that will be relative to the element to scroll ( 'li:eq(2)', etc )
20
 *		- A hash { top:x, left:y }, x and y can be any kind of number/string like above.
21
 *		- A percentage of the container's dimension/s, for example: 50% to go to the middle.
22
 *		- The string 'max' for go-to-end. 
23
 * @param {Number, Function} duration The OVERALL length of the animation, this argument can be the settings object instead.
24
 * @param {Object,Function} settings Optional set of settings or the onAfter callback.
25
 *	 @option {String} axis Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'.
26
 *	 @option {Number, Function} duration The OVERALL length of the animation.
27
 *	 @option {String} easing The easing method for the animation.
28
 *	 @option {Boolean} margin If true, the margin of the target element will be deducted from the final position.
29
 *	 @option {Object, Number} offset Add/deduct from the end position. One number for both axes or { top:x, left:y }.
30
 *	 @option {Object, Number} over Add/deduct the height/width multiplied by 'over', can be { top:x, left:y } when using both axes.
31
 *	 @option {Boolean} queue If true, and both axis are given, the 2nd axis will only be animated after the first one ends.
32
 *	 @option {Function} onAfter Function to be called after the scrolling ends. 
33
 *	 @option {Function} onAfterFirst If queuing is activated, this function will be called after the first scrolling ends.
34
 * @return {jQuery} Returns the same jQuery object, for chaining.
35
 *
36
 * @desc Scroll to a fixed position
37
 * @example $('div').scrollTo( 340 );
38
 *
39
 * @desc Scroll relatively to the actual position
40
 * @example $('div').scrollTo( '+=340px', { axis:'y' } );
41
 *
42
 * @desc Scroll using a selector (relative to the scrolled element)
43
 * @example $('div').scrollTo( 'p.paragraph:eq(2)', 500, { easing:'swing', queue:true, axis:'xy' } );
44
 *
45
 * @desc Scroll to a DOM element (same for jQuery object)
46
 * @example var second_child = document.getElementById('container').firstChild.nextSibling;
47
 *			$('#container').scrollTo( second_child, { duration:500, axis:'x', onAfter:function(){
48
 *				alert('scrolled!!');																   
49
 *			}});
50
 *
51
 * @desc Scroll on both axes, to different values
52
 * @example $('div').scrollTo( { top: 300, left:'+=200' }, { axis:'xy', offset:-20 } );
53
 */
54

  
55
;(function( $ ){
56
	
57
	var $scrollTo = $.scrollTo = function( target, duration, settings ){
58
		$(window).scrollTo( target, duration, settings );
59
	};
60

  
61
	$scrollTo.defaults = {
62
		axis:'xy',
63
		duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1,
64
		limit:true
65
	};
66

  
67
	// Returns the element that needs to be animated to scroll the window.
68
	// Kept for backwards compatibility (specially for localScroll & serialScroll)
69
	$scrollTo.window = function( scope ){
70
		return $(window)._scrollable();
71
	};
72

  
73
	// Hack, hack, hack :)
74
	// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
75
	$.fn._scrollable = function(){
76
		return this.map(function(){
77
			var elem = this,
78
				isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;
79

  
80
				if( !isWin )
81
					return elem;
82

  
83
			var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
84
			
85
			return /webkit/i.test(navigator.userAgent) || doc.compatMode == 'BackCompat' ?
86
				doc.body : 
87
				doc.documentElement;
88
		});
89
	};
90

  
91
	$.fn.scrollTo = function( target, duration, settings ){
92
		if( typeof duration == 'object' ){
93
			settings = duration;
94
			duration = 0;
95
		}
96
		if( typeof settings == 'function' )
97
			settings = { onAfter:settings };
98
			
99
		if( target == 'max' )
100
			target = 9e9;
101
			
102
		settings = $.extend( {}, $scrollTo.defaults, settings );
103
		// Speed is still recognized for backwards compatibility
104
		duration = duration || settings.duration;
105
		// Make sure the settings are given right
106
		settings.queue = settings.queue && settings.axis.length > 1;
107
		
108
		if( settings.queue )
109
			// Let's keep the overall duration
110
			duration /= 2;
111
		settings.offset = both( settings.offset );
112
		settings.over = both( settings.over );
113

  
114
		return this._scrollable().each(function(){
115
			// Null target yields nothing, just like jQuery does
116
			if (target == null) return;
117

  
118
			var elem = this,
119
				$elem = $(elem),
120
				targ = target, toff, attr = {},
121
				win = $elem.is('html,body');
122

  
123
			switch( typeof targ ){
124
				// A number will pass the regex
125
				case 'number':
126
				case 'string':
127
					if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
128
						targ = both( targ );
129
						// We are done
130
						break;
131
					}
132
					// Relative selector, no break!
133
					targ = $(targ,this);
134
					if (!targ.length) return;
135
				case 'object':
136
					// DOMElement / jQuery
137
					if( targ.is || targ.style )
138
						// Get the real position of the target 
139
						toff = (targ = $(targ)).offset();
140
			}
141
			$.each( settings.axis.split(''), function( i, axis ){
142
				var Pos	= axis == 'x' ? 'Left' : 'Top',
143
					pos = Pos.toLowerCase(),
144
					key = 'scroll' + Pos,
145
					old = elem[key],
146
					max = $scrollTo.max(elem, axis);
147

  
148
				if( toff ){// jQuery / DOMElement
149
					attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
150

  
151
					// If it's a dom element, reduce the margin
152
					if( settings.margin ){
153
						attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
154
						attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
155
					}
156
					
157
					attr[key] += settings.offset[pos] || 0;
158
					
159
					if( settings.over[pos] )
160
						// Scroll to a fraction of its width/height
161
						attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
162
				}else{ 
163
					var val = targ[pos];
164
					// Handle percentage values
165
					attr[key] = val.slice && val.slice(-1) == '%' ? 
166
						parseFloat(val) / 100 * max
167
						: val;
168
				}
169

  
170
				// Number or 'number'
171
				if( settings.limit && /^\d+$/.test(attr[key]) )
172
					// Check the limits
173
					attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
174

  
175
				// Queueing axes
176
				if( !i && settings.queue ){
177
					// Don't waste time animating, if there's no need.
178
					if( old != attr[key] )
179
						// Intermediate animation
180
						animate( settings.onAfterFirst );
181
					// Don't animate this axis again in the next iteration.
182
					delete attr[key];
183
				}
184
			});
185

  
186
			animate( settings.onAfter );			
187

  
188
			function animate( callback ){
189
				$elem.animate( attr, duration, settings.easing, callback && function(){
190
					callback.call(this, target, settings);
191
				});
192
			};
193

  
194
		}).end();
195
	};
196
	
197
	// Max scrolling position, works on quirks mode
198
	// It only fails (not too badly) on IE, quirks mode.
199
	$scrollTo.max = function( elem, axis ){
200
		var Dim = axis == 'x' ? 'Width' : 'Height',
201
			scroll = 'scroll'+Dim;
202
		
203
		if( !$(elem).is('html,body') )
204
			return elem[scroll] - $(elem)[Dim.toLowerCase()]();
205
		
206
		var size = 'client' + Dim,
207
			html = elem.ownerDocument.documentElement,
208
			body = elem.ownerDocument.body;
209

  
210
		return Math.max( html[scroll], body[scroll] ) 
211
			 - Math.min( html[size]  , body[size]   );
212
	};
213

  
214
	function both( val ){
215
		return typeof val == 'object' ? val : { top:val, left:val };
216
	};
217

  
218
})( jQuery );

Also available in: Unified diff