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.

59 lines
1.8 KiB

  1. // Generated by CoffeeScript 1.6.2
  2. var ElementsCollection, ScriptsCollection, typeChecker, _ref,
  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. ElementsCollection = require(__dirname + '/elements');
  7. ScriptsCollection = (function(_super) {
  8. __extends(ScriptsCollection, _super);
  9. function ScriptsCollection() {
  10. _ref = ScriptsCollection.__super__.constructor.apply(this, arguments);
  11. return _ref;
  12. }
  13. ScriptsCollection.prototype.add = function(values, opts) {
  14. var key, value, _i, _len, _ref1, _ref2;
  15. opts || (opts = {});
  16. if ((_ref1 = opts.defer) == null) {
  17. opts.defer = true;
  18. }
  19. if ((_ref2 = opts.async) == null) {
  20. opts.async = false;
  21. }
  22. opts.attrs || (opts.attrs = '');
  23. if (typeChecker.isArray(values)) {
  24. values = values.slice();
  25. } else {
  26. values = [values];
  27. }
  28. if (opts.defer) {
  29. opts.attrs += "defer=\"defer\" ";
  30. }
  31. if (opts.async) {
  32. opts.attrs += "async=\"async\" ";
  33. }
  34. for (key = _i = 0, _len = values.length; _i < _len; key = ++_i) {
  35. value = values[key];
  36. if (typeChecker.isString(value)) {
  37. if (value[0] === '<') {
  38. } else if (value.indexOf(' ') === -1) {
  39. values[key] = "<script " + opts.attrs + " src=\"" + value + "\"></script>";
  40. } else {
  41. values[key] = "<script " + opts.attrs + ">" + value + "</script>";
  42. }
  43. }
  44. }
  45. return ScriptsCollection.__super__.add.call(this, values, opts);
  46. };
  47. return ScriptsCollection;
  48. })(ElementsCollection);
  49. module.exports = ScriptsCollection;