]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2538: Added documentation to most of the JS methods missing it.
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 15 Mar 2011 04:40:37 +0000 (04:40 +0000)
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>
Tue, 15 Mar 2011 04:40:37 +0000 (04:40 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@8717 36083f99-b078-4883-b0ff-0f9b5a30f544

js/classes/ElggPriorityList.js
js/lib/elgglib.js
js/lib/hooks.js
js/lib/languages.js
js/lib/prototypes.js
js/lib/security.js
js/lib/session.js
js/lib/ui.js
js/lib/userpicker.js

index 7b5d164737097fb8c2df47cc53dc923f048cf13c..831342f21406972a60c50f76c938a48138c53852 100644 (file)
@@ -1,5 +1,6 @@
 /**
- *
+ * Priority lists allow you to create an indexed list that can be iterated through in a specific
+ * order.
  */
 elgg.ElggPriorityList = function() {
        this.length = 0;
@@ -7,7 +8,12 @@ elgg.ElggPriorityList = function() {
 };
 
 /**
+ * Inserts an element into the priority list at the priority specified.
  *
+ * @param {Object} obj          The object to insert
+ * @param {Number} opt_priority An optional priority to insert at.
+ * 
+ * @return {Void}
  */
 elgg.ElggPriorityList.prototype.insert = function(obj, opt_priority) {
        var priority = parseInt(opt_priority || 500, 10);
@@ -23,7 +29,13 @@ elgg.ElggPriorityList.prototype.insert = function(obj, opt_priority) {
 };
 
 /**
+ * Iterates through each element in order.
+ *
+* Unlike every, this ignores the return value of the callback.
  *
+ * @param {Function} callback The callback function to pass each element through. See
+ *                            Array.prototype.every() for details.
+ * @return {Object}
  */
 elgg.ElggPriorityList.prototype.forEach = function(callback) {
        elgg.assertTypeOf('function', callback);
@@ -40,7 +52,13 @@ elgg.ElggPriorityList.prototype.forEach = function(callback) {
 };
 
 /**
+ * Iterates through each element in order.
+ *
+ * Unlike forEach, this returns the value of the callback and will break on false.
  *
+ * @param {Function} callback The callback function to pass each element through. See
+ *                            Array.prototype.every() for details.
+ * @return {Object}
  */
 elgg.ElggPriorityList.prototype.every = function(callback) {
        elgg.assertTypeOf('function', callback);
@@ -55,7 +73,10 @@ elgg.ElggPriorityList.prototype.every = function(callback) {
 };
 
 /**
+ * Removes an element from the priority list
  *
+ * @param {Object} obj The object to remove.
+ * @return {Void}
  */
 elgg.ElggPriorityList.prototype.remove = function(obj) {
        this.priorities_.forEach(function(elems) {
index 4137c4a7a7635ec4b1254f04cda96a5ebf75673f..f6d5f51cecc6c89ff1766a98d39f06288e641e01 100644 (file)
@@ -238,7 +238,7 @@ elgg.inherit = function(Child, Parent) {
  * If the url is already absolute or protocol-relative, no change is made.
  *
  * elgg.normalize_url('');                   // 'http://my.site.com/'
- * elgg.normalize_url('dashboard');       // 'http://my.site.com/dashboard'
+ * elgg.normalize_url('dashboard');          // 'http://my.site.com/dashboard'
  * elgg.normalize_url('http://google.com/'); // no change
  * elgg.normalize_url('//google.com/');      // no change
  *
@@ -326,7 +326,7 @@ elgg.system_messages = function(msgs, delay, type) {
 
 /**
  * Wrapper function for system_messages. Specifies "messages" as the type of message
- * @param {String} msg The message to display
+ * @param {String} msg The message to display
  * @param {Number} delay How long to display the message (milliseconds)
  */
 elgg.system_message = function(msgs, delay) {
@@ -335,8 +335,8 @@ elgg.system_message = function(msgs, delay) {
 
 /**
  * Wrapper function for system_messages.  Specifies "errors" as the type of message
- * @param {String} error The error message to display
- * @param {Number} delay How long to dispaly the error message (milliseconds)
+ * @param {String} errors The error message to display
+ * @param {Number} delay  How long to dispaly the error message (milliseconds)
  */
 elgg.register_error = function(errors, delay) {
        elgg.system_messages(errors, delay, "error");
index 9c86a1fecdadf4b8c399547cb72a1f7485ea3622..aab129d6eea05ee835dc5cd6d8615dd6960c18ce 100644 (file)
@@ -70,8 +70,6 @@ elgg.trigger_hook = function(name, type, params, value) {
                returnValue = value,
                callHookHandler = function(handler) {
                        tempReturnValue = handler(name, type, params, value);
-                       // always continue through all the handlers
-                       return true;
                };
 
        elgg.provide(name + '.' + type, hooks);
@@ -85,7 +83,7 @@ elgg.trigger_hook = function(name, type, params, value) {
                hooks['all']['all']
        ].every(function(handlers) {
                if (handlers instanceof elgg.ElggPriorityList) {
-                       handlers.every(callHookHandler);
+                       handlers.forEach(callHookHandler);
                }
                return true;
        });
index 79768c471bb1f2dbad71efcc6828e20371929cff..06af1ca7f55d1dac259cf0c381e2abdfc1309381 100644 (file)
@@ -25,6 +25,7 @@ elgg.add_translation = function(lang, translations) {
  */
 elgg.reload_all_translations = function(language) {
        var lang = language || elgg.get_language();
+       // This...................vvvvv is a double encoded question mark (? -> %2f -> %252f)
        elgg.getJSON('js/languages%252f' + lang + '.js', {
                data: {
                        'viewtype': 'default',
index 0f00148184f7eb46128aeb61b3593bfe428c26aa..cb618409721e3839068bdf3fe5f7ad0473d44556 100644 (file)
@@ -1,5 +1,14 @@
 /**
+ * Interates through each element of an array and calls a callback function.
+ * The callback should accept the following arguments:
+ *     element - The current element
+ *     index   - The current index
  *
+ * This is different to Array.forEach in that if the callback returns false, the loop returns
+ * immediately without processing the remaining elements.
+ *
+ *     @param {Function} callback
+ *     @return {Bool}
  */
 if (!Array.prototype.every) {
        Array.prototype.every = function(callback) {
@@ -16,7 +25,16 @@ if (!Array.prototype.every) {
 }
 
 /**
+ * Interates through each element of an array and calls callback a function.
+ * The callback should accept the following arguments:
+ *     element - The current element
+ *     index   - The current index
+ *
+ * This is different to Array.every in that the callback's return value is ignored and every
+ * element of the array will be parsed.
  *
+ *     @param {Function} callback
+ *     @return {Void}
  */
 if (!Array.prototype.forEach) {
        Array.prototype.forEach = function(callback) {
@@ -31,7 +49,11 @@ if (!Array.prototype.forEach) {
 }
 
 /**
+ * Left trim
  *
+ * Removes a character from the left side of a string.
+ * @param {String} str The character to remove
+ * @return {String}
  */
 if (!String.prototype.ltrim) {
        String.prototype.ltrim = function(str) {
index d449d88872df7af1ab1afa3e070002b940736c34..f88c6165d637d78a40c925513d1fd91f4a32f3fa 100644 (file)
@@ -5,6 +5,12 @@ elgg.provide('elgg.security');
 
 elgg.security.token = {};
 
+/**
+ * Sets the currently active security token and updates all forms and links on the current page.
+ *
+ * @param {Object} json The json representation of a token containing __elgg_ts and __elgg_token
+ * @return {Void}
+ */
 elgg.security.setToken = function(json) {
        //update the convenience object
        elgg.security.token = json;
@@ -22,7 +28,7 @@ elgg.security.setToken = function(json) {
 };
 
 /**
- * Security tokens time out, so lets refresh those every so often
+ * Security tokens time out, so lets refresh those every so often.
  * 
  * @todo handle error and bad return data
  */
@@ -70,6 +76,7 @@ elgg.security.addToken = function(data) {
 
 elgg.security.init = function() {
        //refresh security token every 5 minutes
+       //this is set in the js/elgg PHP view.
        setInterval(elgg.security.refreshToken, elgg.security.interval);
 };
 
index a1454aa50178d0d70cb03a0919b3fdf484fc9efe..fa3d60aa9189ba69bafea4bfbad67bf71bba9970 100644 (file)
@@ -1,5 +1,5 @@
 /**
- * @todo comment
+ * Provides session methods.
  */
 elgg.provide('elgg.session');
 
@@ -8,6 +8,7 @@ elgg.provide('elgg.session');
  * @param {string} name
  * @param {string} value
  * @param {Object} options
+ * 
  *  {number|Date} options[expires]
  *     {string} options[path]
  *     {string} options[domain]
@@ -81,6 +82,8 @@ elgg.session.cookie = function (name, value, options) {
 };
 
 /**
+ * Returns the object of the user logged in.
+ *
  * @return {ElggUser} The logged in user
  */
 elgg.get_logged_in_user_entity = function() {
@@ -88,6 +91,8 @@ elgg.get_logged_in_user_entity = function() {
 };
 
 /**
+ * Returns the GUID of the logged in user or 0.
+ *
  * @return {number} The GUID of the logged in user
  */
 elgg.get_logged_in_user_guid = function() {
@@ -96,6 +101,8 @@ elgg.get_logged_in_user_guid = function() {
 };
 
 /**
+ * Returns if a user is logged in.
+ *
  * @return {boolean} Whether there is a user logged in
  */
 elgg.is_logged_in = function() {
@@ -103,6 +110,8 @@ elgg.is_logged_in = function() {
 };
 
 /**
+ * Returns if the currently logged in user is an admin.
+ *
  * @return {boolean} Whether there is an admin logged in
  */
 elgg.is_admin_logged_in = function() {
index 22475df93052ac9ae1b926a2092a9d81256b931e..0600eb0cbc25da24e0812364f3bb7ef26b68c4ea 100644 (file)
@@ -201,5 +201,4 @@ elgg.ui.likesPopupHandler = function(hook, type, params, options) {
 };
 
 elgg.register_hook_handler('init', 'system', elgg.ui.init);
-//elgg.register_hook_handler('popup', 'ui', elgg.ui.likesPopupHandler);
 elgg.register_hook_handler('getOptions', 'ui.popup', elgg.ui.likesPopupHandler);
\ No newline at end of file
index b551ea8309273ed057af8a88bc68fe9bc74c4f8b..475af150f43d1d516562c331c10de1fae9761d0e 100644 (file)
@@ -2,7 +2,7 @@ elgg.provide('elgg.userpicker');
 
 elgg.userpicker.init = function() {
        // binding autocomplete.
-       // doing this as an each so we can past this to functions.
+       // doing this as an each so we can pass this to functions.
        $('.elgg-input-user-picker').each(function() {
                
                var _this = this;