Permalink
Browse files

API doc fixes

  • Loading branch information...
1 parent 7ccdeff commit 7c009273e36d737f68091919820dca8de0a3a1ad Sebastian Werner committed Jun 1, 2012
Showing with 31 additions and 22 deletions.
  1. +16 −10 src/core/bom/Caret.js
  2. +12 −12 src/core/bom/ClassName.js
  3. +3 −0 src/ext/sugar/Object.js
View
@@ -10,35 +10,41 @@
*/
core.Module("core.bom.Caret",
{
- getPosition : function(el)
+ /**
+ * {Integer} Returns the caret position on the given @element {Element}.
+ */
+ getPosition : function(element)
{
if (document.selection)
{
- el.focus();
+ element.focus();
var sel = document.selection.createRange();
- sel.moveStart('character', -el.value.length);
+ sel.moveStart('character', -element.value.length);
return sel.text.length;
}
- else if (typeof el.selectionStart == "number")
+ else if (typeof element.selectionStart == "number")
{
- return el.selectionStart;
+ return element.selectionStart;
}
},
- setPosition : function(el, position)
+ /**
+ * Sets the caret @position {Integer} on the given @element {Element}.
+ */
+ setPosition : function(element, position)
{
if (document.selection)
{
- var range = el.createTextRange();
+ var range = element.createTextRange();
range.collapse(true);
range.moveEnd('character', position);
range.moveStart('character', position);
range.select();
}
- else if (typeof el.selectionStart == "number")
+ else if (typeof element.selectionStart == "number")
{
- el.selectionStart = position;
- el.selectionEnd = position;
+ element.selectionStart = position;
+ element.selectionEnd = position;
}
}
});
View
@@ -28,6 +28,9 @@
// Support new classList interface
if ("classList" in document.createElement("div"))
{
+ /**
+ * Adds the @className {CSSClassName} to the given @elem {Element}.
+ */
var addClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -37,6 +40,9 @@
elem.classList.add(className);
};
+ /**
+ * Removes the @className {CSSClassName} from the given @elem {Element}.
+ */
var removeClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -46,6 +52,9 @@
elem.classList.remove(className);
};
+ /**
+ * {Boolean} Returns whether @className {CSSClassName} is applied to the given @elem {Element}.
+ */
var containsClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -55,6 +64,9 @@
return elem.classList.contains(className);
};
+ /**
+ * Toggles the @className {CSSClassName} for the given @elem {Element}.
+ */
var toggleClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -69,9 +81,6 @@
var space = " ";
- /**
- * Adds the @className {CSSClassName} to the given @elem {Element}.
- */
var addClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -83,9 +92,6 @@
}
};
- /**
- * Removes the @className {CSSClassName} from the given @elem {Element}.
- */
var removeClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -95,9 +101,6 @@
elem.className = (space + elem.className + space).replace(className, "")
};
- /**
- * {Boolean} Returns whether @className {CSSClassName} is applied to the given @elem {Element}.
- */
var containsClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
@@ -107,9 +110,6 @@
return elem.className && (elem.className == className || (space + elem.className + space).indexOf(space + className + space) !== -1);
};
- /**
- * Toggles the @className {CSSClassName} for the given @elem {Element}.
- */
var toggleClass = function(elem, className)
{
if (core.Env.isSet("debug")) {
View
@@ -18,6 +18,9 @@
*/
core.Main.addStatics("Object",
{
+ /**
+ * {Integer} Returns the number of keys the given @object {Object} has.
+ */
getLength : function(object) {
return Object.keys(object).length;
},

0 comments on commit 7c00927

Please sign in to comment.