Skip to content

Instantly share code, notes, and snippets.

@onestepcreative
Last active August 29, 2015 13:58
Show Gist options
  • Save onestepcreative/9984635 to your computer and use it in GitHub Desktop.
Save onestepcreative/9984635 to your computer and use it in GitHub Desktop.
/**
* Returns the docked position of the given
* stage element by reading the "dock-xxxx" class.
* Possible matches: left, right, top bottom.
* @param jQuery Object
* @returns {String}
* @public
*/
var getDirection = function(element) {
var direction;
var classes = element.attr('class').split(/\s+/);
var count = classes.length;
var i = 0;
for(i; i < count; i++) {
var className = classes[i];
if(className.indexOf('dock-') === 0) {
direction = className.match(/[^-]+$/gm).toString();
}
}
// @return string
return direction;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment