muu

DEPRECATED lightweight JS framework
git clone https://git.ce9e.org/muu.git

commit
660237d2d60927914bc54eebb9c2774c11209e2e
parent
c1be5407109260e4c53463c1f8613fafa38bb5ab
Author
Tobias Bengfort <tobias.bengfort@gmx.net>
Date
2015-08-28 07:53
closure compatible type annotations

Diffstat

M src/muu-directive.js 11 ++++++-----
M src/muu-dom-helpers.js 27 ++++++++++++++-------------
M src/muu-js-helpers.js 38 +++++++++++++++++++-------------------
M src/muu-location.js 6 +++---
M src/muu-registry.js 16 ++++++++--------
M src/muu-template.js 2 +-
M src/muu-update-dom.js 4 ++--

7 files changed, 53 insertions, 51 deletions


diff --git a/src/muu-directive.js b/src/muu-directive.js

@@ -7,7 +7,7 @@ define('muu-directive', ['muu-dom-helpers', 'muu-js-helpers', 'muu-update-dom'],
    7     7     "use strict";
    8     8 
    9     9     /**
   10    -1      * A directive is linked to a DOMElement and manages the DOM tree below
   -1    10      * A directive is linked to a Element and manages the DOM tree below
   11    11      * that element (excluding any isolated subtrees, e.g. those managed by
   12    12      * subdirectives).
   13    13      *
@@ -29,9 +29,9 @@ define('muu-directive', ['muu-dom-helpers', 'muu-js-helpers', 'muu-update-dom'],
   29    29      * Registry#link}.
   30    30      *
   31    31      * @constructs Directive
   32    -1      * @param {DOMElement} root
   -1    32      * @param {Element} root
   33    33      * @param {string} template
   34    -1      * @param {Muu} registry
   -1    34      * @param {Registry} registry
   35    35      */
   36    36     var Directive = function(root, template, registry) {
   37    37         var self = this;
@@ -82,7 +82,7 @@ define('muu-directive', ['muu-dom-helpers', 'muu-js-helpers', 'muu-update-dom'],
   82    82          *
   83    83          * @private
   84    84          * @param {string} selector
   85    -1          * @return {DOMElement[]} All child elements that match the given
   -1    85          * @return {Array.<Element>} All child elements that match the given
   86    86          *     selector and are not isolated.
   87    87          */
   88    88         this.querySelectorAll = function(selector) {
@@ -105,8 +105,9 @@ define('muu-directive', ['muu-dom-helpers', 'muu-js-helpers', 'muu-update-dom'],
  105   105          *
  106   106          * @private
  107   107          * @param {String} selector
  108    -1          * @return {DOMElement} First child element that matches the given
   -1   108          * @return {Element} First child element that matches the given
  109   109          *     selector and is not isolated.
   -1   110          * @suppress {missingReturn}
  110   111          */
  111   112         this.querySelector = function(selector) {
  112   113             var all = self.querySelectorAll(selector);

diff --git a/src/muu-dom-helpers.js b/src/muu-dom-helpers.js

@@ -37,7 +37,7 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
   37    37      *
   38    38      * @param {string} type
   39    39      * @param {*} detail
   40    -1      * @return {DOMEvent}
   -1    40      * @return {Event}
   41    41      * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events
   42    42      */
   43    43     $.createEvent = function(type, detail) {
@@ -53,10 +53,10 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
   53    53     };
   54    54 
   55    55     /**
   56    -1      * @param {DOMElement} element
   -1    56      * @param {EventTarget} element
   57    57      * @param {string} eventName
   58    -1      * @param {function} callback
   59    -1      * @return {Function()} An unregister function
   -1    58      * @param {Function} callback
   -1    59      * @return {function()} An unregister function
   60    60      */
   61    61     $.on = function(element, eventName, callback) {
   62    62         element.addEventListener(eventName, callback, false);
@@ -66,8 +66,8 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
   66    66     };
   67    67 
   68    68     /**
   69    -1      * @param {function} fn
   70    -1      * @return {Function()} An unregister function
   -1    69      * @param {Function} fn
   -1    70      * @return {function()} An unregister function
   71    71      */
   72    72     $.ready = function(fn) {
   73    73         var _fn = _.once(fn);
@@ -85,8 +85,8 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
   85    85     };
   86    86 
   87    87     /**
   88    -1      * @param {DOMNode} desc
   89    -1      * @param {DOMNode} root
   -1    88      * @param {Node} desc
   -1    89      * @param {Node} root
   90    90      * @return {boolean}
   91    91      */
   92    92     $.isDescendant = function(desc, root) {
@@ -100,9 +100,9 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
  100   100      * element is removed but with a slight delay. So the only way to test this
  101   101      * is to use a timeout in the test.
  102   102      *
  103    -1      * @param {DOMElement} element
  104    -1      * @param {function} fn
  105    -1      * @return {Function()} An unregister function
   -1   103      * @param {Element} element
   -1   104      * @param {Function} fn
   -1   105      * @return {function()} An unregister function
  106   106      */
  107   107     $.destroy = function(element, fn) {
  108   108         var unregister;
@@ -141,8 +141,9 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
  141   141     };
  142   142 
  143   143     /**
  144    -1      * @param {DOMElement[]} options
   -1   144      * @param {Array.<Element>} options
  145   145      * @return {string}
   -1   146      * @suppress {missingReturn}
  146   147      */
  147   148     $.getRadio = function(options) {
  148   149         for (var i = 0; i < options.length; i++) {
@@ -153,7 +154,7 @@ define("muu-dom-helpers", ['muu-js-helpers'], function(_) {
  153   154     };
  154   155 
  155   156     /**
  156    -1      * @param {DOMElement[]} options
   -1   157      * @param {Array.<Element>} options
  157   158      * @param {string} value
  158   159      */
  159   160     $.setRadio = function(options, value) {

diff --git a/src/muu-js-helpers.js b/src/muu-js-helpers.js

@@ -9,7 +9,7 @@ define('muu-js-helpers', [], function() {
    9     9     var _ = {};
   10    10 
   11    11     /**
   12    -1      * @param {object} value
   -1    12      * @param {Object} value
   13    13      * @return {string}
   14    14      */
   15    15     var objToString = function(value) {
@@ -40,8 +40,8 @@ define('muu-js-helpers', [], function() {
   40    40     };
   41    41 
   42    42     /**
   43    -1      * @param {function} fn
   44    -1      * @return {function}
   -1    43      * @param {Function} fn
   -1    44      * @return {Function}
   45    45      */
   46    46     _.once = function(fn) {
   47    47         var result;
@@ -57,7 +57,7 @@ define('muu-js-helpers', [], function() {
   57    57     };
   58    58 
   59    59     /**
   60    -1      * @param {array} array
   -1    60      * @param {Array} array
   61    61      * @param {*} value
   62    62      * @return {number}
   63    63      */
@@ -75,8 +75,8 @@ define('muu-js-helpers', [], function() {
   75    75     };
   76    76 
   77    77     /**
   78    -1      * @param {array} array
   79    -1      * @param {function} fn
   -1    78      * @param {Array} array
   -1    79      * @param {Function} fn
   80    80      */
   81    81     _.forEach = function(array, fn) {
   82    82         if ('forEach' in array) {
@@ -89,9 +89,9 @@ define('muu-js-helpers', [], function() {
   89    89     };
   90    90 
   91    91     /**
   92    -1      * @param {array} array
   93    -1      * @param {function} fn
   94    -1      * @return {array}
   -1    92      * @param {Array} array
   -1    93      * @param {Function} fn
   -1    94      * @return {Array}
   95    95      */
   96    96     _.map = function(array, fn) {
   97    97         if ('map' in array) {
@@ -106,9 +106,9 @@ define('muu-js-helpers', [], function() {
  106   106     };
  107   107 
  108   108     /**
  109    -1      * @param {array} array
  110    -1      * @param {function} fn
  111    -1      * @return {array}
   -1   109      * @param {Array} array
   -1   110      * @param {Function} fn
   -1   111      * @return {Array}
  112   112      */
  113   113     _.filter = function(array, fn) {
  114   114         if ('filter' in array) {
@@ -125,8 +125,8 @@ define('muu-js-helpers', [], function() {
  125   125     };
  126   126 
  127   127     /**
  128    -1      * @param {array[]} arrays
  129    -1      * @return {array}
   -1   128      * @param {Array.<Array>} arrays
   -1   129      * @return {Array}
  130   130      */
  131   131     _.union = function(arrays) {
  132   132         var results = [];
@@ -141,9 +141,9 @@ define('muu-js-helpers', [], function() {
  141   141     };
  142   142 
  143   143     /**
  144    -1      * @param {array} a
  145    -1      * @param {array} b
  146    -1      * @return {array}
   -1   144      * @param {Array} a
   -1   145      * @param {Array} b
   -1   146      * @return {Array}
  147   147      */
  148   148     _.difference = function(a, b) {
  149   149         var results = [];
@@ -156,8 +156,8 @@ define('muu-js-helpers', [], function() {
  156   156     };
  157   157 
  158   158     /**
  159    -1      * @param {array} a
  160    -1      * @return {array}
   -1   159      * @param {Array} a
   -1   160      * @return {Array}
  161   161      */
  162   162     _.flatten = function(a) {
  163   163         var o = [];

diff --git a/src/muu-location.js b/src/muu-location.js

@@ -89,7 +89,7 @@ define('muu-location', ['muu-search'], function(q) {
   89    89     };
   90    90 
   91    91     /**
   92    -1      * @return {object}
   -1    92      * @return {Object}
   93    93      *//**
   94    94      * @param {string|object} value
   95    95      * @return {muu-location}
@@ -136,7 +136,7 @@ define('muu-location', ['muu-search'], function(q) {
  136   136 
  137   137     /**
  138   138      * @param {string} eventName
  139    -1      * @param {function} fn
   -1   139      * @param {Function} fn
  140   140      * @return {muu-location}
  141   141      */
  142   142     loc.addEventListener = function(eventName, fn) {
@@ -148,7 +148,7 @@ define('muu-location', ['muu-search'], function(q) {
  148   148 
  149   149     /**
  150   150      * @param {string} eventName
  151    -1      * @param {function} fn
   -1   151      * @param {Function} fn
  152   152      * @return {muu-location}
  153   153      */
  154   154     loc.removeEventListener = function(eventName, fn) {

diff --git a/src/muu-registry.js b/src/muu-registry.js

@@ -8,12 +8,12 @@ define('muu-registry', ['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-
    8     8 
    9     9     /**
   10    10      * @constructs Registry
   11    -1      * @param {object} config The config object may have following properties:
   -1    11      * @param {Object} config The config object may have following properties:
   12    12      *
   13    13      * - **debug** - `{boolean}` - Enable debug mode. In debug mode,
   14    14      *   directive objects are available as properties from the DOM as
   15    15      *   `element.directive`.
   16    -1      * - **renderer** - `{Function(string, object)}` - The template renderer
   -1    16      * - **renderer** - `{function(string, Object)}` - The template renderer
   17    17      *   to be used. Defaults to {@link module:muu-template}.
   18    18      */
   19    19     var Registry = function(config) {
@@ -28,9 +28,9 @@ define('muu-registry', ['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-
   28    28          *
   29    29          * @param {string} type
   30    30          * @param {string} template
   31    -1          * @param {Function(Directive, DOMElement): function} link The link
   -1    31          * @param {function(Directive, Element): Function} link The link
   32    32          *   function is called with an instance of {@link Directive} and a
   33    -1          *   DOMElement when {@link Registry#link} is executed.
   -1    33          *   Element when {@link Registry#link} is executed.
   34    34          *
   35    35          *   It is the only place where you can access a directive and
   36    36          *   therefore the place where you define its behavior.
@@ -70,7 +70,7 @@ define('muu-registry', ['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-
   70    70          * });
   71    71          * ```
   72    72          *
   73    -1          * @param {Function(Registry)}
   -1    73          * @param {function(Registry)} module
   74    74          * @return {Registry} this
   75    75          */
   76    76         this.registerModule = function(module) {
@@ -81,7 +81,7 @@ define('muu-registry', ['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-
   81    81         /**
   82    82          * Create and initialise a {@link Directive} for `element`.
   83    83          *
   84    -1          * @param {DOMElement} element
   -1    84          * @param {Element} element
   85    85          * @param {string} type
   86    86          * @return {Directive}
   87    87          */
@@ -116,8 +116,8 @@ define('muu-registry', ['muu-template', 'muu-directive', 'muu-js-helpers', 'muu-
  116   116         /**
  117   117          * Link all directives that can be found inside `root`.
  118   118          *
  119    -1          * @param {DOMElement} root
  120    -1          * @return {Directive[]}
   -1   119          * @param {Element} root
   -1   120          * @return {Array.<Directive>}
  121   121          */
  122   122         this.linkAll = function(root) {
  123   123             // NOTE: root may be a DOM Node or a directive

diff --git a/src/muu-template.js b/src/muu-template.js

@@ -58,7 +58,7 @@
   58    58  *
   59    59  * @module muu-template
   60    60  * @param {string} template
   61    -1  * @param {object} data
   -1    61  * @param {Object} data
   62    62  * @return {string}
   63    63  */
   64    64 define('muu-template', ['muu-js-helpers', 'muu-dom-helpers'], function(_, $) {

diff --git a/src/muu-update-dom.js b/src/muu-update-dom.js

@@ -18,8 +18,8 @@
   18    18  * generated content from being overwritten.
   19    19  *
   20    20  * @module muu-update-dom
   21    -1  * @param {DOMElement} target
   22    -1  * @param {DOMElement} source
   -1    21  * @param {Element} target
   -1    22  * @param {Element} source
   23    23  */
   24    24 define('muu-update-dom', ['muu-js-helpers'], function(_) {
   25    25     "use strict";