Changeset 2782
- Timestamp:
- 08/19/07 11:56:42 (1 year ago)
- Files:
-
- 1 modified
-
trunk/plugins/jScrollPane/demo/jquery.em.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/jScrollPane/demo/jquery.em.js
r2763 r2782 2 2 * @projectDescription Monitor Font Size Changes with jQuery 3 3 * 4 * @version 1.0 a4 * @version 1.0 5 5 * @author Dave Cardwell 6 6 * 7 * jQuery-Em - r$Revision: 8 $ ($Date: 2007-08-17 16:49:19 +0100 (Fri, 17Aug 2007) $)7 * jQuery-Em - $Revision: 24 $ ($Date: 2007-08-19 11:24:56 +0100 (Sun, 19 Aug 2007) $) 8 8 * http://davecardwell.co.uk/javascript/jquery/plugins/jquery-em/ 9 9 * 10 10 * Copyright ©2007 Dave Cardwell <http://davecardwell.co.uk/> 11 * Dual licensed under the MIT (MIT-LICENSE.txt) and 12 * GPL (GPL-LICENSE.txt) licenses. 11 * 12 * Released under the MIT licence: 13 * http://www.opensource.org/licenses/mit-license.php 13 14 */ 14 15 15 16 // Upon $(document).ready()… 16 17 jQuery(function($) { 18 // Configuration… 19 var eventName = 'emchange'; 20 21 17 22 // Set up default options. 18 23 $.em = $.extend({ 24 /** 25 * The jQuery-Em version string. 26 * 27 * @example $.em.version; 28 * @desc '1.0a' 29 * 30 * @property 31 * @name version 32 * @type String 33 * @cat Plugins/Em 34 */ 35 version: '1.0', 36 19 37 /** 20 38 * The number of milliseconds to wait when polling for changes to the … … 22 40 * 23 41 * @example $.em.delay = 400; 24 * @desc Defaults to 200 ms.42 * @desc Defaults to 200. 25 43 * 26 44 * @property … … 46 64 position: 'absolute', 47 65 width: '100em' }) 48 .prependTo( document.body)[0],66 .prependTo('body')[0], 49 67 50 68 /** … … 54 72 * @desc The default action is to trigger a global “emchange” event. 55 73 * You probably shouldn’t change this behaviour as other plugins may 56 * rely on it .74 * rely on it, but the option is here for completion. 57 75 * 58 76 * @example $(document).bind('emchange', function(e, cur, prev) {...}) … … 74 92 if ( currentWidth != $.em.current ) { 75 93 /** 76 * The previous value of the user agent’s font size. See 77 * $.em.current for caveats. 94 * The previous pixel value of the user agent’s font size. See 95 * $.em.current for caveats. Will initially be undefined until 96 * the “emchange” event is triggered. 78 97 * 79 98 * @example $.em.previous; … … 89 108 90 109 /** 91 * The current value of the user agent’s font size. As with92 * $.em.previous, this value may be subject to minor browser93 * rounding errors that mean it should not be relied upon as94 * an absolute value.110 * The current pixel value of the user agent’s font size. As 111 * with $.em.previous, this value *may* be subject to minor 112 * browser rounding errors that mean you might not want to 113 * rely upon it as an absolute value. 95 114 * 96 115 * @example $.em.current; … … 105 124 $.em.current = currentWidth; 106 125 107 $.event.trigger( 'emchange', [$.em.current, $.em.previous]);126 $.event.trigger(eventName, [$.em.current, $.em.previous]); 108 127 } 109 128 } 110 129 }, $.em ); 111 130 131 132 /** 133 * Bind a function to the emchange event of each matched element. 134 * 135 * @example $("p").emchange( function() { alert("Hello"); } ); 136 * 137 * @name emchange 138 * @type jQuery 139 * @param Function fn A function to bind to the emchange event. 140 * @cat Plugins/Em 141 */ 142 143 /** 144 * Trigger the emchange event of each matched element. 145 * 146 * @example $("p").emchange() 147 * 148 * @name emchange 149 * @type jQuery 150 * @cat Plugins/Em 151 */ 152 $.fn[eventName] = function(fn) { return fn ? this.bind(eventName, fn) 153 : this.trigger(eventName); }; 154 155 112 156 // Store the initial pixel value of the user agent’s font size. 113 157 $.em.current = $.em.element.offsetWidth / 100; 114 158 115 // Try to use Internet Explorer’s proprietary “setExpression” method… 116 try { 117 $.em.element.style.setExpression( 118 'width', 'function() {jQuery.em.action(); return "100em";}()' 119 ); 120 } 121 // …otherwise fall back to polling for changes. 122 catch(e) { 123 /** 124 * When the polling method is being used, $.em.iid stores the 125 * intervalID should you want to cancel with clearInterval(). 126 * 127 * @example window.clearInterval( $.em.iid ); 128 * 129 * @property 130 * @name iid 131 * @type Number 132 * @cat Plugins/Em 133 */ 134 $.em.iid = window.setInterval( $.em.action, $.em.delay ); 135 } 159 /** 160 * While polling for font-size changes, $.em.iid stores the intervalID in 161 * case you should want to cancel with clearInterval(). 162 * 163 * @example window.clearInterval( $.em.iid ); 164 * 165 * @property 166 * @name iid 167 * @type Number 168 * @cat Plugins/Em 169 */ 170 $.em.iid = setInterval( $.em.action, $.em.delay ); 136 171 });
