Last active
December 21, 2015 02:48
-
-
Save mpouncy-netpulse/6237418 to your computer and use it in GitHub Desktop.
File to be placed at js/jquery-plugins.js in relation to https://npjira.atlassian.net/browse/QT-1360
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*===================================================================== | |
JQUERY EXTENSIONS (CORE) | js/jquery-plugins.js | |
=====================================================================*/; | |
/** @fileOverview This file has functions related to extending jQuery. */ | |
/*-------------------------------------------------------------------*/ | |
(function($, window, undefined) { | |
"use strict"; | |
/*---------------------------------------------------*/ | |
// 1. Directly extend the jQuery library. | |
/*---------------------------------------------------*/ | |
/** | |
* @name jQuery | |
* @class See the jQuery Library (http://jquery.com/) for full details. | |
*/ | |
$.extend({ | |
}); | |
/*---------------------------------------------------*/ | |
// 1. End direct library extensions. | |
/*---------------------------------------------------*/ | |
/*---------------------------------------------------*/ | |
// 2. Extend 'jQuery.fn', the DOM/Object selector chain. | |
/*---------------------------------------------------*/ | |
/** | |
* @name fn | |
* @class See the jQuery Library (http://jquery.com/) for full details. | |
* @memberOf jQuery | |
*/ | |
$.fn.extend({ | |
/** | |
* Find the position of the cursor in an input field. | |
* @name getCursorPosition | |
* @function | |
* @memberOf jQuery.fn | |
* @returns {Number} | |
* @example | |
* var whereIsCursor = $('input#myTextField').getCursorPosition(); | |
*/ | |
getCursorPosition : function getCursorPosition() { | |
var input = (this.get(0)); | |
if (!input) { | |
return; | |
} // No (input) element found | |
if (document.selection) { | |
input.focus(); | |
} | |
return ('selectionStart' in input) ? input.selectionStart : '' || Math.abs(document.selection.createRange().moveStart('character', -input.value.length)); | |
}, | |
/** | |
* Check if an object exists. | |
* @name exists | |
* @function | |
* @memberOf jQuery.fn | |
* @returns {Boolean} | |
* @example | |
* var doesObjectExist = $('#object').exists(); | |
*/ | |
exists: function exists() { | |
return(this.length != 0); | |
} | |
}); | |
/*---------------------------------------------------*/ | |
// 2. End 'jQuery.fn' extensions. | |
/*---------------------------------------------------*/ | |
})(jQuery, window); | |
/*-------------------------------------------------------------------*/ | |
//@ sourceURL=js/jquery-plugins.js |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment