-
Notifications
You must be signed in to change notification settings - Fork 3
/
jquery.taboverride.js.html
245 lines (207 loc) · 7.84 KB
/
jquery.taboverride.js.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: jquery.taboverride.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: jquery.taboverride.js</h1>
<section>
<article>
<pre class="prettyprint source"><code>/*! jquery.taboverride v4.0.0 | https://github.com/wjbryant/jquery.taboverride
Copyright (c) 2013 Bill Bryant | http://opensource.org/licenses/mit */
/**
* @fileOverview Tab Override jQuery plugin
* @author Bill Bryant
* @version 4.0.0
*/
/*global exports, require, define, jQuery, tabOverride */
/**
* The jQuery plugin namespace
*
* @external "jQuery.fn"
*/
// Use CommonJS or AMD if available
(function ( factory ) {
"use strict";
if ( typeof exports === "object" && typeof require === "function" ) {
// Node.js/CommonJS
factory( require( "jquery" ), require( "taboverride" ) );
} else if ( typeof define === "function" && define.amd ) {
// AMD - Register as an anonymous module
// Files must be concatenated using an AMD-aware tool such as r.js
define( [ "jquery", "taboverride" ], factory );
} else {
// No module format - Use global variables instead
factory( jQuery, tabOverride );
}
}(function ( $, tabOverride ) {
"use strict";
var $fnTabOverride;
/**
* Helper function to remove the delegated listeners. This is only used in
* the removeDelegatedListeners and addDelegatedListeners functions.
*
* @see external:"jQuery.fn".tabOverride.utils.removeDelegatedListeners
* @private
*/
function removeDelegatedListenersHelper( $container, selector ) {
$container.off({
"keydown.tabOverride": tabOverride.handlers.keydown,
"keypress.tabOverride": tabOverride.handlers.keypress
}, selector );
}
/**
* Removes the Tab Override event listeners on the container element
* using jQuery delegated events.
*
* Hooks: removeDelegatedListeners - passed the jQuery object for the
* container element(s) and the selector string
*
* @param {Object} $container the jQuery object for the container element
* @param {string} selector the selector string to use for the delegated events
*
* @method external:"jQuery.fn".tabOverride.utils.removeDelegatedListeners
*/
function removeDelegatedListeners( $container, selector ) {
tabOverride.utils.executeExtensions( "removeDelegatedListeners", [ $container, selector ] );
removeDelegatedListenersHelper( $container, selector );
}
/**
* Adds the Tab Override event listeners to the container element using
* jQuery delegated events.
*
* Hooks: addDelegatedListeners - passed the jQuery object for the
* container element(s) and the selector string
*
* @param {Object} $container the jQuery object for the container element
* @param {string} selector the selector string to use for the delegated events
*
* @method external:"jQuery.fn".tabOverride.utils.addDelegatedListeners
*/
function addDelegatedListeners( $container, selector ) {
tabOverride.utils.executeExtensions( "addDelegatedListeners", [ $container, selector ] );
removeDelegatedListenersHelper( $container, selector );
$container.on({
"keydown.tabOverride": tabOverride.handlers.keydown,
"keypress.tabOverride": tabOverride.handlers.keypress
}, selector );
}
/**
* The tabOverride method namespace
*
* @namespace external:"jQuery.fn".tabOverride
*/
/**
* Enables/disables Tab Override. If enabled, tabs (or spaces) will be
* inserted in the selected textarea elements when the tab key is pressed.
*
* Hooks: setDelegated - fired when delegated events are used, passed the
* jQuery object for the container element(s), the selector string, and a
* boolean indicating whether Tab Override was enabled or disabled.
*
* @param {boolean} [enable=true] whether Tab Override should be enabled
* for the element(s)
* @param {string} [selector] the selector string for delegated events
* @return {Object} the jQuery object
*
* @method external:"jQuery.fn".tabOverride(2)
*/
$fnTabOverride = $.fn.tabOverride = function ( enable, selector ) {
var enablePlugin = !arguments.length || enable,
isDelegated = typeof selector === "string",
$container;
if ( isDelegated ) {
$container = this;
tabOverride.utils.executeExtensions( "setDelegated", [ $container, selector, enable ] );
if ( enablePlugin ) {
addDelegatedListeners( $container, selector );
} else {
removeDelegatedListeners( $container, selector );
}
} else {
// The jQuery object acts as an array of elements, so it can be passed
// to tabOverride.set()
tabOverride.set( this, enablePlugin );
}
// Return the jQuery object
return this;
};
/**
* Namespace for utility methods
*
* @namespace external:"jQuery.fn".tabOverride.utils
*/
$fnTabOverride.utils = {
addDelegatedListeners: addDelegatedListeners,
removeDelegatedListeners: removeDelegatedListeners
};
/**
* Gets or sets the tab size for all elements that have Tab Override enabled.
* 0 represents the tab character.
*
* @param {number} [size] the tab size
* @return {number|Function} the tab size or the tabOverride function
*
* @method external:"jQuery.fn".tabOverride.tabSize
*/
$fnTabOverride.tabSize = tabOverride.tabSize;
/**
* Gets or sets the auto indent setting. True if each line should be
* automatically indented (default = false).
*
* @param {boolean} [enable] whether auto indent should be enabled
* @return {boolean|Function} whether auto indent is enabled or the
* tabOverride function
*
* @method external:"jQuery.fn".tabOverride.autoIndent
*/
$fnTabOverride.autoIndent = tabOverride.autoIndent;
/**
* Gets or sets the tab key combination.
*
* @param {number} keyCode the key code of the key to use for tab
* @param {string[]} [modifierKeyNames] the modifier key names - valid names are
* 'alt', 'ctrl', 'meta', and 'shift'
* @return {string|Function} the current tab key combination or the
* tabOverride function
*
* @method external:"jQuery.fn".tabOverride.tabKey
*/
$fnTabOverride.tabKey = tabOverride.tabKey;
/**
* Gets or sets the untab key combination.
*
* @param {number} keyCode the key code of the key to use for untab
* @param {string[]} [modifierKeyNames] the modifier key names - valid names are
* 'alt', 'ctrl', 'meta', and 'shift'
* @return {string|Function} the current untab key combination or the
* tabOverride function
*
* @method external:"jQuery.fn".tabOverride.untabKey
*/
$fnTabOverride.untabKey = tabOverride.untabKey;
}));
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Index</a></h2><h3>Externals</h3><ul><li><a href="_.html">jQuery.fn</a></li></ul><h3>Namespaces</h3><ul><li><a href="tabOverride.html">tabOverride</a></li><li><a href="tabOverride.utils.html">utils</a></li></ul>
</nav>
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.0</a> on Tue Aug 27 2013 13:47:55 GMT-0400 (EDT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>