You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.6 KiB

  1. // Generated by CoffeeScript 1.6.2
  2. var Collection, ElementsCollection, Model, typeChecker, _ref, _ref1,
  3. __hasProp = {}.hasOwnProperty,
  4. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
  5. typeChecker = require('typechecker');
  6. _ref = require(__dirname + '/../base'), Collection = _ref.Collection, Model = _ref.Model;
  7. ElementsCollection = (function(_super) {
  8. __extends(ElementsCollection, _super);
  9. function ElementsCollection() {
  10. _ref1 = ElementsCollection.__super__.constructor.apply(this, arguments);
  11. return _ref1;
  12. }
  13. ElementsCollection.prototype.model = Model;
  14. ElementsCollection.prototype.add = function(values, opts) {
  15. var key, value, _i, _len;
  16. if (typeChecker.isArray(values)) {
  17. values = values.slice();
  18. } else {
  19. values = [values];
  20. }
  21. for (key = _i = 0, _len = values.length; _i < _len; key = ++_i) {
  22. value = values[key];
  23. if (typeChecker.isString(value)) {
  24. values[key] = new Model({
  25. html: value
  26. });
  27. }
  28. }
  29. return ElementsCollection.__super__.add.call(this, values, opts);
  30. };
  31. ElementsCollection.prototype.toHTML = function() {
  32. var html;
  33. html = '';
  34. this.forEach(function(item) {
  35. return html += item.get('html') || '';
  36. });
  37. return html;
  38. };
  39. ElementsCollection.prototype.join = function() {
  40. return this.toHTML();
  41. };
  42. return ElementsCollection;
  43. })(Collection);
  44. module.exports = ElementsCollection;