Lungo.Boot.Data.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * Make an analysis of Data attributes in HTML elements and creates a <markup>
  3. * based on each data type.
  4. *
  5. * @namespace LUNGO.Boot
  6. * @class Data
  7. * @requires Zepto
  8. *
  9. * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
  10. * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
  11. */
  12. LUNGO.Boot.Data = (function(lng, undefined) {
  13. /**
  14. * Initialize the <markup> data-attributes analisys
  15. *
  16. * @method init
  17. *
  18. *
  19. */
  20. var start = function() {
  21. var attributes = lng.Attributes.Data;
  22. for (var attribute in attributes) {
  23. if (lng.Core.isOwnProperty(attributes, attribute)) {
  24. _findElements(attributes[attribute]);
  25. }
  26. }
  27. };
  28. var _findElements = function(attribute) {
  29. var elements = lng.Dom.query(attribute.selector);
  30. for (var i = 0, len = elements.length; i < len; i++) {
  31. var element = lng.Dom.query(elements[i]);
  32. lng.View.Template.Binding.dataAttribute(element, attribute);
  33. }
  34. };
  35. return {
  36. start: start
  37. };
  38. })(LUNGO);