diff options
author | Halil İbrahim Kalkan <hikalkan@gmail.com> | 2013-02-10 13:05:16 +0200 |
---|---|---|
committer | Halil İbrahim Kalkan <hikalkan@gmail.com> | 2013-02-10 13:05:16 +0200 |
commit | 277c6e18d910accfe145f0b3cacb27aef437d1ac (patch) | |
tree | 1c6ebdcabb29eebacabac485b234fcabaeec14d8 /dev/jquery.jtable.utils.js | |
parent | 82df9fff9f0a1ea9b4bc8a91d4481b74f391a36f (diff) | |
download | jtable-277c6e18d910accfe145f0b3cacb27aef437d1ac.zip jtable-277c6e18d910accfe145f0b3cacb27aef437d1ac.tar.gz jtable-277c6e18d910accfe145f0b3cacb27aef437d1ac.tar.bz2 |
jTable v.2.2.0v2.2.0
Feature: Toolbar. [#188]
Feature: 'Change page size' combobox. [#1, #128]
Feature: 'Go to page' input. [#63]
Feature: Multiple sorting of columns by holding CTRL key. [#48]
Added options: multiSorting, gotoPageArea, pageSizes,
pageSizeChangeArea, pageList and toolbar.
Hungarian and Italian localizations [#179]
Fixed some issues. [#209]
Diffstat (limited to 'dev/jquery.jtable.utils.js')
-rw-r--r-- | dev/jquery.jtable.utils.js | 306 |
1 files changed, 153 insertions, 153 deletions
diff --git a/dev/jquery.jtable.utils.js b/dev/jquery.jtable.utils.js index e928107..9b92f0c 100644 --- a/dev/jquery.jtable.utils.js +++ b/dev/jquery.jtable.utils.js @@ -1,153 +1,153 @@ -/************************************************************************
-* Some UTULITY methods used by jTable *
-*************************************************************************/
-(function ($) {
-
- $.extend(true, $.hik.jtable.prototype, {
-
- /* Gets property value of an object recursively.
- *************************************************************************/
- _getPropertyOfObject: function (obj, propName) {
- if (propName.indexOf('.') < 0) {
- return obj[propName];
- } else {
- var preDot = propName.substring(0, propName.indexOf('.'));
- var postDot = propName.substring(propName.indexOf('.') + 1);
- return this._getPropertyOfObject(obj[preDot], postDot);
- }
- },
-
- /* Sets property value of an object recursively.
- *************************************************************************/
- _setPropertyOfObject: function (obj, propName, value) {
- if (propName.indexOf('.') < 0) {
- obj[propName] = value;
- } else {
- var preDot = propName.substring(0, propName.indexOf('.'));
- var postDot = propName.substring(propName.indexOf('.') + 1);
- this._setPropertyOfObject(obj[preDot], postDot, value);
- }
- },
-
- /* Inserts a value to an array if it does not exists in the array.
- *************************************************************************/
- _insertToArrayIfDoesNotExists: function (array, value) {
- if ($.inArray(value, array) < 0) {
- array.push(value);
- }
- },
-
- /* Finds index of an element in an array according to given comparision function
- *************************************************************************/
- _findIndexInArray: function (value, array, compareFunc) {
-
- //If not defined, use default comparision
- if (!compareFunc) {
- compareFunc = function (a, b) {
- return a == b;
- };
- }
-
- for (var i = 0; i < array.length; i++) {
- if (compareFunc(value, array[i])) {
- return i;
- }
- }
-
- return -1;
- },
-
- /* Normalizes a number between given bounds or sets to a defaultValue
- * if it is undefined
- *************************************************************************/
- _normalizeNumber: function (number, min, max, defaultValue) {
- if (number == undefined || number == null) {
- return defaultValue;
- }
-
- if (number < min) {
- return min;
- }
-
- if (number > max) {
- return max;
- }
-
- return number;
- },
-
- /* Formats a string just like string.format in c#.
- * Example:
- * _formatString('Hello {0}','Halil') = 'Hello Halil'
- *************************************************************************/
- _formatString: function () {
- if (arguments.length == 0) {
- return null;
- }
-
- var str = arguments[0];
- for (var i = 1; i < arguments.length; i++) {
- var placeHolder = '{' + (i - 1) + '}';
- str = str.replace(placeHolder, arguments[i]);
- }
-
- return str;
- },
-
- //Logging methods ////////////////////////////////////////////////////////
-
- _logDebug: function (text) {
- if (!window.console) {
- return;
- }
-
- console.log('jTable DEBUG: ' + text);
- },
-
- _logInfo: function (text) {
- if (!window.console) {
- return;
- }
-
- console.log('jTable INFO: ' + text);
- },
-
- _logWarn: function (text) {
- if (!window.console) {
- return;
- }
-
- console.log('jTable WARNING: ' + text);
- },
-
- _logError: function (text) {
- if (!window.console) {
- return;
- }
-
- console.log('jTable ERROR: ' + text);
- }
-
- });
-
- /* Fix for array.indexOf method in IE7.
- * This code is taken from http://www.tutorialspoint.com/javascript/array_indexof.htm */
- if (!Array.prototype.indexOf) {
- Array.prototype.indexOf = function (elt) {
- var len = this.length;
- var from = Number(arguments[1]) || 0;
- from = (from < 0)
- ? Math.ceil(from)
- : Math.floor(from);
- if (from < 0)
- from += len;
- for (; from < len; from++) {
- if (from in this &&
- this[from] === elt)
- return from;
- }
- return -1;
- };
- }
-
-})(jQuery);
+/************************************************************************ +* Some UTULITY methods used by jTable * +*************************************************************************/ +(function ($) { + + $.extend(true, $.hik.jtable.prototype, { + + /* Gets property value of an object recursively. + *************************************************************************/ + _getPropertyOfObject: function (obj, propName) { + if (propName.indexOf('.') < 0) { + return obj[propName]; + } else { + var preDot = propName.substring(0, propName.indexOf('.')); + var postDot = propName.substring(propName.indexOf('.') + 1); + return this._getPropertyOfObject(obj[preDot], postDot); + } + }, + + /* Sets property value of an object recursively. + *************************************************************************/ + _setPropertyOfObject: function (obj, propName, value) { + if (propName.indexOf('.') < 0) { + obj[propName] = value; + } else { + var preDot = propName.substring(0, propName.indexOf('.')); + var postDot = propName.substring(propName.indexOf('.') + 1); + this._setPropertyOfObject(obj[preDot], postDot, value); + } + }, + + /* Inserts a value to an array if it does not exists in the array. + *************************************************************************/ + _insertToArrayIfDoesNotExists: function (array, value) { + if ($.inArray(value, array) < 0) { + array.push(value); + } + }, + + /* Finds index of an element in an array according to given comparision function + *************************************************************************/ + _findIndexInArray: function (value, array, compareFunc) { + + //If not defined, use default comparision + if (!compareFunc) { + compareFunc = function (a, b) { + return a == b; + }; + } + + for (var i = 0; i < array.length; i++) { + if (compareFunc(value, array[i])) { + return i; + } + } + + return -1; + }, + + /* Normalizes a number between given bounds or sets to a defaultValue + * if it is undefined + *************************************************************************/ + _normalizeNumber: function (number, min, max, defaultValue) { + if (number == undefined || number == null || isNaN(number)) { + return defaultValue; + } + + if (number < min) { + return min; + } + + if (number > max) { + return max; + } + + return number; + }, + + /* Formats a string just like string.format in c#. + * Example: + * _formatString('Hello {0}','Halil') = 'Hello Halil' + *************************************************************************/ + _formatString: function () { + if (arguments.length == 0) { + return null; + } + + var str = arguments[0]; + for (var i = 1; i < arguments.length; i++) { + var placeHolder = '{' + (i - 1) + '}'; + str = str.replace(placeHolder, arguments[i]); + } + + return str; + }, + + //Logging methods //////////////////////////////////////////////////////// + + _logDebug: function (text) { + if (!window.console) { + return; + } + + console.log('jTable DEBUG: ' + text); + }, + + _logInfo: function (text) { + if (!window.console) { + return; + } + + console.log('jTable INFO: ' + text); + }, + + _logWarn: function (text) { + if (!window.console) { + return; + } + + console.log('jTable WARNING: ' + text); + }, + + _logError: function (text) { + if (!window.console) { + return; + } + + console.log('jTable ERROR: ' + text); + } + + }); + + /* Fix for array.indexOf method in IE7. + * This code is taken from http://www.tutorialspoint.com/javascript/array_indexof.htm */ + if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function (elt) { + var len = this.length; + var from = Number(arguments[1]) || 0; + from = (from < 0) + ? Math.ceil(from) + : Math.floor(from); + if (from < 0) + from += len; + for (; from < len; from++) { + if (from in this && + this[from] === elt) + return from; + } + return -1; + }; + } + +})(jQuery); |