Permalink
Browse files

v2.1.0 - amd, bower, separate repos

  • Loading branch information...
0 parents commit 48f3405d9679d95b4b4897433d3b2550b60a46bd @wjbryant committed Oct 2, 2012
@@ -0,0 +1,2 @@
+# Auto detect text files and perform LF normalization
+* text=auto
@@ -0,0 +1,8 @@
+# Tab Override jQuery Plugin Changelog
+
+## 2.1.0 (????-??-??)
+* Added AMD support
+* Added component.json for Bower support (registered as `jquery.taboverride`)
+* Separated core and jQuery plugin into individual projects
+* jquery.taboverride.js no longer includes the core dependency (see [README](jquery.taboverride/README.md))
+* Made style changes to better conform with the jQuery Core Style Guidelines
108 README.md
@@ -0,0 +1,108 @@
+# Tab Override jQuery Plugin
+
+This plugin makes it easy to use [Tab Override](https://github.com/wjbryant/taboverride "Tab Override")
+with jQuery by providing jQuery methods for the Tab Override API. Code
+documentation is available at
+[wjbryant.github.com/jquery.taboverride/](http://wjbryant.github.com/jquery.taboverride/ "Tab Override jQuery Plugin Documentation").
+
+## Dependencies
+
+The Tab Override jQuery plugin requires jQuery version 1.7.0 or newer and
+[Tab Override](https://github.com/wjbryant/taboverride "Tab Override")
+version 2.1.0 or newer.
+
+**Important:** The `jquery.taboverride.js` file no longer includes the taboverride
+core dependency. The `taboverride.js` file must be included in the page before
+`jquery.taboverride.js`. Alternatively, the files may be concatenated together.
+
+### Bower
+
+This plugin is registered as `jquery.taboverride` in the global [Bower](http://twitter.github.com/bower/)
+registry. Install Bower via NPM and then run this command from the root directory
+of your project to install `jquery.taboverride`:
+
+```
+bower install jquery.taboverride
+```
+
+This will download the `jquery.taboverride` plugin and all of its dependencies
+(`jquery` and `taboverride`) into a `components` directory in your project.
+
+### AMD
+
+This plugin is AMD compatible and can be loaded using a script loader such as
+[RequireJS](http://requirejs.org/). This is convenient since it will automatically
+load the taboverride core dependency for you.
+
+#### Optimization
+
+The plugin is defined as a named module to allow for easy concatenation with the
+taboverride core module. Using the RequireJS optimization tool, [r.js](https://github.com/jrburke/r.js),
+is not strictly necessary in this case, but may still be used like so:
+
+```
+r.js -o name=jquery.taboverride out=jquery.taboverride.all.min.js paths.jquery=empty:
+```
+
+*Note: The above command assumes both files are in the same directory. On Windows,
+you may have to use `r.js.cmd` instead.*
+
+## Usage
+
+The jQuery plugin is simply a wrapper for the Tab Override API with the addition
+of a method to easily enable or disable the plugin for certain elements.
+
+### Enable/Disable Tab Override
+
+```javascript
+// enable Tab Override by calling tabOverride() with no arguments
+$('textarea').tabOverride();
+
+// or any truthy argument
+$('textarea').tabOverride(true);
+```
+
+```javascript
+// disable Tab Override using any falsy argument
+$('textarea').tabOverride(false);
+```
+
+### Get/Set Tab Size
+
+```javascript
+// get the current tab size (0 represents the tab character)
+var tabSize = $.fn.tabOverride.tabSize();
+```
+
+```javascript
+// set the tab size to the tab character (default)
+$.fn.tabOverride.tabSize(0);
+
+// set the tab size to 4 spaces
+$.fn.tabOverride.tabSize(4);
+```
+
+### Enable/Disable Auto Indent
+
+```javascript
+// enable auto indent
+$.fn.tabOverride.autoIndent(true);
+```
+
+```javascript
+// disable auto indent (default)
+$.fn.tabOverride.autoIndent(false);
+```
+
+### Additional Notes
+
+Calls to the settings functions can be chained together:
+
+```javascript
+// set up Tab Override
+$.fn.tabOverride.tabSize(4).autoIndent(true);
+```
+
+## License
+
+MIT license - http://opensource.org/licenses/mit
@@ -0,0 +1,131 @@
+/*! jquery.taboverride v2.1.0 | https://github.com/wjbryant/jquery.taboverride
+Copyright (c) 2012 Bill Bryant | http://opensource.org/licenses/mit */
+
+/**
+ * @fileOverview Tab Override jQuery plugin
+ * @author Bill Bryant
+ * @version 2.1.0
+ */
+
+/*jslint white: true */
+/*jshint white: false */
+/*global define, jQuery, TABOVERRIDE */
+
+/**
+ * the global jQuery object
+ *
+ * @name jQuery
+ * @namespace
+ */
+
+/**
+ * the jQuery function "namespace"
+ *
+ * @name fn
+ * @namespace
+ * @memberOf jQuery
+ */
+
+// Use AMD if available
+(function ( factory ) {
+ "use strict";
+
+ if ( typeof define === "function" && define.amd ) {
+ // AMD - Register as a named module
+ // Using a named module allows for non-AMD-aware concatenation
+ define( "jquery.taboverride", [ "jquery", "taboverride" ], factory );
+ } else {
+ // No AMD - Use global variables instead
+ factory( jQuery, TABOVERRIDE );
+ }
+}(function ( $, TABOVERRIDE ) {
+ "use strict";
+
+ /**
+ * the tabOverride method - Tabs will be overridden if enable is true.
+ *
+ * @param {Boolean} [enable=true] whether Tab Override should be enabled
+ * for the element(s)
+ * @return {Object} the jQuery object
+ *
+ * @name tabOverride
+ * @memberOf jQuery.fn
+ * @function
+ * @namespace
+ */
+ var tabOverride = $.fn.tabOverride = function ( enable ) {
+
+ // Unbind the tabOverride event handlers so they are not bound
+ // more than once
+ var $textareas = this.filter("textarea").off(".tabOverride");
+
+ // Only bind the tabOverride event handlers if the enable
+ // argument is not specified or is truthy
+ if ( !arguments.length || enable ) {
+ $textareas
+ .on( "keydown.tabOverride", TABOVERRIDE.overrideKeyDown )
+ .on( "keypress.tabOverride", TABOVERRIDE.overrideKeyPress );
+ }
+
+ // Return the original jQuery object
+ return this;
+ };
+
+ /**
+ * 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
+ *
+ * @name tabSize
+ * @function
+ * @memberOf jQuery.fn.tabOverride
+ */
+ tabOverride.tabSize = TABOVERRIDE.tabSize;
+
+ /**
+ * Returns the current tab size. 0 represents the tab character.
+ *
+ * @return {Number} the size (length) of the tab string or 0 for the tab
+ * character
+ *
+ * @name getTabSize
+ * @function
+ * @memberOf jQuery.fn.tabOverride
+ * @deprecated since 2.0 - use tabSize() instead
+ */
+ tabOverride.getTabSize = function () {
+ return this.tabSize();
+ };
+
+ /**
+ * Sets the tab size for all elements that have Tab Override enabled.
+ * 0 represents the tab character. The initial value is 0.
+ *
+ * @param {Number} [size=0] the tab size
+ * @return {Function} the tabOverride function
+ *
+ * @name setTabSize
+ * @function
+ * @memberOf jQuery.fn.tabOverride
+ * @deprecated since 2.0 - use tabSize() instead
+ */
+ tabOverride.setTabSize = function ( size ) {
+ return this.tabSize( size || 0 );
+ };
+
+ /**
+ * 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
+ *
+ * @name autoIndent
+ * @function
+ * @memberOf jQuery.fn.tabOverride
+ */
+ tabOverride.autoIndent = TABOVERRIDE.autoIndent;
+}));
Oops, something went wrong.
@@ -0,0 +1,9 @@
+{
+ "name": "jquery.taboverride",
+ "version": "2.1.0",
+ "main": "./build/jquery.taboverride.js",
+ "dependencies": {
+ "jquery": "~1.7",
+ "taboverride": "~2.1"
+ }
+}
Oops, something went wrong.

0 comments on commit 48f3405

Please sign in to comment.