Skip to content

Commit

Permalink
Add some JSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
sinelaw committed Dec 24, 2013
1 parent 9392ee8 commit 2828282
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/simple-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

link: function (scope, elem, attrs) {

/**
* @param {boolean} editable
* @returns {boolean}
*/
function isEditable(editable) {
//$log.debug('isEditable');
if (angular.isUndefined(editable)) {
Expand All @@ -20,6 +24,11 @@
return editable || false;
}

/**
* @param {jQuery.event} event
* @param {number} targetRowIndex
* @param {number} colIndex
*/
function setFocusedCell(event, targetRowIndex, colIndex) {
var elem = null, elems;
if (null !== targetRowIndex) {
Expand Down Expand Up @@ -88,6 +97,10 @@
}
};

/**
* @param {string} str
* @returns {string}
*/
scope.capitalize = function (str) {
//$log.debug('capitalize');
if (!str) {
Expand All @@ -112,12 +125,22 @@
}
};

/**
* @param {number} rowIndex
* @returns {boolean}
*/
scope.isInvalid = function (rowIndex) {
//$log.debug('isInvalid', rowIndex);
var formCtrl = scope.$eval(scope.formName(rowIndex));
return formCtrl.$error;
};


/**
* @param {jQuery.event} event
* @param {number} rowIndex
* @param {number} colIndex
*/
scope.keydown = function (event, rowIndex, colIndex) {
var elem = null, elems,
targetRowIndex = null;
Expand All @@ -128,10 +151,19 @@
case 38: //up
targetRowIndex = rowIndex - 1;
break;
case 13:
event.currentTarget.blur();
event.preventDefault();
return;
}
setFocusedCell(event, targetRowIndex, colIndex);
};

/**
* @param row
* @param column
* @returns {string}
*/
scope.getCellText = function (row, column) {
//$log.debug('getCellText');//, row, column);
var cellValue = row[column.field];
Expand All @@ -144,6 +176,11 @@
return cellValue;
};

/**
* @param options
* @param value
* @returns {string}
*/
scope.getOptionTitleByValue = function (options, value) {
//$log.debug('getOptionTitleByValue');//, options, value);
// TODO: Highly ineffecient.
Expand Down Expand Up @@ -225,6 +262,13 @@
}
};

/**
* @param {jQuery.event} event
* @param {number} rowIndex
* @param {number} columnIndex
* @param row
* @param column
*/
scope.startEditingCell = function (event, rowIndex, columnIndex, row, column) {
row.$editable = true;
$timeout(function() {
Expand All @@ -244,6 +288,9 @@
scope.formName = (function () {
// memoize
var formNames = {};
/**
* @returns {string}
*/
return function (rowIndex) {
var existing = formNames[rowIndex];
if (!existing) {
Expand All @@ -254,6 +301,9 @@
};
}());

/**
* @returns {boolean}
*/
scope.isOrderByReverse = function () {
if (scope.simpleGrid && !angular.isUndefined(scope.simpleGrid.options.reverseOrder)) {
return scope.simpleGrid.options.reverseOrder;
Expand Down

0 comments on commit 2828282

Please sign in to comment.