Skip to content

Commit

Permalink
Add documentation for $helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Voles committed Mar 7, 2014
1 parent b364f9c commit df9c15e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 2 deletions.
57 changes: 56 additions & 1 deletion source/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,61 @@
'use strict';

angular.module('ui.nestedSortable')


/**
* @ngdoc service
* @name ui.nestedSortable.service:$helper
* @requires ng.$document
* @requires ng.$window
*
* @description
* Angular-NestedSortable.
*/
.factory('$helper', ['$document', '$window',
function ($document, $window) {
return {

/**
* @ngdoc method
* @name hippo.theme#height
* @methodOf ui.nestedSortable.service:$helper
*
* @description
* Get the height of an element.
*
* @param {Object} element Angular element.
* @returns {String} Height
*/
height: function (element) {
return element.prop('scrollHeight');
},

/**
* @ngdoc method
* @name hippo.theme#width
* @methodOf ui.nestedSortable.service:$helper
*
* @description
* Get the width of an element.
*
* @param {Object} element Angular element.
* @returns {String} Width
*/
width: function (element) {
return element.prop('scrollWidth');
},

/**
* @ngdoc method
* @name hippo.theme#offset
* @methodOf ui.nestedSortable.service:$helper
*
* @description
* Get the offset values of an element.
*
* @param {Object} element Angular element.
* @returns {Object} Object with properties width, height, top and left
*/
offset: function (element) {
var boundingClientRect = element[0].getBoundingClientRect();

Expand All @@ -25,6 +68,18 @@
};
},

/**
* @ngdoc method
* @name hippo.theme#positionStarted
* @methodOf ui.nestedSortable.service:$helper
*
* @description
* Get the start position of the target element according to the provided event properties.
*
* @param {Object} e Event
* @param {Object} target Target element
* @returns {Object} Object with properties offsetX, offsetY, startX, startY, nowX and dirX.
*/
positionStarted: function (e, target) {
var pos = {};
pos.offsetX = e.pageX - this.offset(target).left;
Expand Down
1 change: 0 additions & 1 deletion source/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
'use strict';

angular.module('ui.nestedSortable', [])

.constant('nestedSortableConfig', {
listClass: 'nestedSortable-list',
itemClass: 'nestedSortable-item',
Expand Down

0 comments on commit df9c15e

Please sign in to comment.