Exemplo n.º 1
0
 Object.keys( config.templates ).forEach( function ( _templateName ) {
   self.__templates[ _templateName ] = minstache( config.templates[ _templateName ], {
     config: config,
     cid: "",
     key: ""
   } );
 } );
Exemplo n.º 2
0
Attribute.prototype.select = function() {
  var dom = domify(minstache(templates.select, this))[0];
  this.node = dom.querySelector('select');

  val(this.node).options(this.options);
  return dom;
};
Exemplo n.º 3
0
 results.forEach( function ( _item ) {
   _item.key = _item[ config.defaults.itemLabelKey ];
   itemsMarkup += minstache( config.templates.listItem, merge( {
     config: config,
     cid: _item.__cid
   }, _item ) );
 } );
Exemplo n.º 4
0
Attribute.prototype.repeats = function() {

  // set this.el to array
  this.attributes = [];
  this.value = arrayValue.bind(this);

  // render array dom
  var dom = domify(minstache(templates.repeats, this))[0];

  // set container for repeats
  this.repeatContainer = dom.querySelector('.repeats');

  // bind click events
  var add = dom.querySelector('.add');
  event.bind(add, 'click', this.addRepeat.bind(this));

  // set repeat count
  this.repeatCount = 0;

  // set repeat max by checking if Integer
  if (max = parseInt(this.repeat)) {
    this.repeatMax = max;
  }

  return dom;
}
Exemplo n.º 5
0
 Project.get(id, function (project) {
   var html = minstache(template, project.attrs);
   var el = this.el = domify(html);
   this.events = events(el, this);
   context.parent.appendChild(el);
   this.events.bind('click [type="submit"]', 'post');
   this.initUsers(id);
 }.bind(this));
Exemplo n.º 6
0
module.exports = function (user) {
  var html = minstache(template, user);
  var el = domify(html);
  document.body.appendChild(el);
  var a = document.getElementById('changepass');
  event.bind(a, 'click', changepass);
  return el;
}
Exemplo n.º 7
0
Attribute.prototype.checkbox = function() {
  var dom = domify(minstache(templates.checkbox, this))[0];
  var input = this.node = dom.querySelector('input');

  this.value = function(data){
    return val(input).checked(data)
  }
  return dom;
}
Exemplo n.º 8
0
    fs.readFile(__dirname + '/completion.mustache.sh', 'utf8', function handleScript (err, completionTemplate) {
      // If there was an error, callback with it
      if (err) {
        return cb(err);
      }

      // Otherwise, generate our completion script and callback with it
      var completionScript = minstache(completionTemplate, {name: that.name});
      cb(null, completionScript);
    });
Exemplo n.º 9
0
function parseTemplate(extension, data, fileName) {

  var tpl;
  var ext = '.' + (extension || 'html');
  var name = fileName || '_template';

  tpl = fs.readFileSync(path.join(__dirname, name + ext), 'utf-8');
  return minstache(tpl, data);

}
Exemplo n.º 10
0
const elements = gridData.map(item => {
  item.title = item.title || item.name
  const el = domify(minstache(gridHtml, item))
  const src = `assets/work/${item.name}.jpg`
  const imageContainer = el.querySelector('.image')
  imageLoader(src, imageContainer)

  el.addEventListener('click', ev => {
    ev.preventDefault()
    demos.show(item)
  }, false)
  return container.appendChild(el)
})
Exemplo n.º 11
0
  fs.readFile(template_path, function(err, source) {
    if (err) return cb(err);

    var result = template(source.toString(), data);

    if (result === source.toString() || result.match('{{'))
      return cb(new Error('Unable to replace variables in plist template!'))

    fs.writeFile(dest, result, function(err) {
      if (err) return cb(err);

      cb(null, dest);
    });
  });
Exemplo n.º 12
0
function createEl() {
  // NodeList of all img elements
  var imgs = document.querySelectorAll('img');

  // Array of img src's that are larget than minimum threashold
  var list = [].slice.call(imgs).filter(function (img, i) {
    return img.width >= minMediaWidth;
  }).map(function (img, i) {
    return img.src;
  });

  list = unique(list).map(function (src, i) {
    return minstache(listItemTemplate, { src: src });
  });

  return domify(minstache(template, { list: list.join('') }));
};
Exemplo n.º 13
0
Attribute.prototype.object = function() {
  var dom = domify(minstache(templates.object, this))[0]
  this.node = dom.querySelector('.nested');

  this.attributes = {};

  for (var property in this.properties) {
    var subParams = this.properties[property]
      , subName = this.name + '.' + property
      , subAttribute = new Attribute(subName, subParams);

    this.node.appendChild(subAttribute.render().view);
    this.attributes[property] = subAttribute;
  }

  this.value = objectValue.bind(this);
  return dom;
}
Exemplo n.º 14
0
var List = function ( _filter ) {
  var self = this,
    config;

  Object.defineProperties( self, {
    "__activeItemIndex": {
      value: 0,
      writable: true
    },
    "__destroyed": {
      value: false,
      writable: true
    },
    "__templates": {
      value: {}
    },
    "__visible": {
      value: false,
      writable: true
    },
    "activeItemIndex": {
      get: helpers.activeItemIndexGet.bind( self ),
      set: helpers.activeItemIndexSet.bind( self )
    },
    "filter": {
      value: _filter
    }
  } );

  config = self.filter.__config;

  Object.keys( config.templates ).forEach( function ( _templateName ) {
    self.__templates[ _templateName ] = minstache( config.templates[ _templateName ], {
      config: config,
      cid: "",
      key: ""
    } );
  } );

  self.$el = $( minstache( self.__templates.listWrapper, {
    config: merge( config, {
      templates: self.__templates
    } )
  } ) );

  self.$el.width( config.defaults.width );

  self.$input = self.$el.find( "." + config.className + "-input" );
  self.$header = self.$el.find( "." + config.className + "-header" );
  self.$list = self.$el.find( "." + config.className + "-items" );
  self.$sortToggle = self.$el.find( "." + config.className + "-sort-toggle" );

  self.$input.on( "change." + config.name + " keydown." + config.name, helpers.filterChanged.bind( self ) );
  self.$sortToggle.on( "click." + config.name, helpers.sortToggleClicked.bind( self ) );
  self.filter.on( "filterChanged", self.redraw.bind( self ) );
  self.filter.on( "itemFocus", helpers.putFocussedItemInView.bind( self ) );
  self.filter.$el.after( self.$el );

  self.filter.once( config.name + "-ready", function () {
    if ( config.defaults.sort ) {
      self.filter.sort = config.defaults.sort;
    }
  } );
};
Exemplo n.º 15
0
Attribute.prototype.textbox = function() {
  var dom = domify(minstache(templates.textbox, this))[0];
  this.node = dom.querySelector('input');

  return dom;
}
Exemplo n.º 16
0
 list = unique(list).map(function (src, i) {
   return minstache(listItemTemplate, { src: src });
 });