Пример #1
0
define(function(require) {
    
    var $ = require('jquery');
    var _ = require('underscore');
    var Backbone = require('backbone');
    var Thorax = require('thorax');
    var template = require('text!templates/page/index.handlebars');
    var Common = require('common');

    return Thorax.View.extend({
        // In a require.js application the name is primarily for
        // consistency and debugging purposes
        name: 'page',
        template: Handlebars.compile(template),
        // Delegated events
        events: {
        },
        // Setup app view
        initialize: function() {           
        },
        changeTo: function(page) {

        }

    });

});
Пример #2
0
define(function (require) {
  var Thorax = require('thorax');
  var template = require('hbs!templates/hourly');

  var Forecast = Thorax.View.extend({
    name: 'Hourly',
    

    initialize: function () {
      this.render(
        console.log(this.collection.models.length),
        this.collection.models.splice(12, 37)
        );
    }, 

    template: template

    // render: function () {
    //   var self = this;
    //   this.$el.html('');
 
    //   this.collection.each(function (model) {
    //     self.$el.append('<div class="pure-u-1-8"><h3>' + model.getFormattedTime() + model.getFormattedHour() + '</h3><canvas id="' + model.get('icon') + '" width="35" height="35"></canvas><br />' + model.get('summary') + '<br />' + ' High: ' + model.get('temperatureMax') + '<br /> Low: ' + model.get('temperatureMin') + '</div>'  );

    //   });

    //   return this;
    // }

  });
      
      return Forecast;
})
Пример #3
0
define(function (require) {
  var Thorax = require('thorax');
  var weatherTemplate = require('hbs!templates/all-weather');

  var AllWeatherView= Thorax.View.extend({
    el: '#canvas',
    initialize: function () {
      
      this.render();
    },

    template: weatherTemplate

  });
  return AllWeatherView;
});
Пример #4
0
define(function (require) {
  var Thorax = require('thorax');
  var template = require('hbs!templates/current-weather');

  var CurrentWeather = Thorax.View.extend({
    el: '#current-conditions',

    initialize: function () {
      this.render();
    },

    template: template
    
  });

  return CurrentWeather;
})
Пример #5
0
define(function(require){

    var Thorax = require('thorax');

    var ScoresView = Thorax.View.extend({
      el: "#scores-table",

      initialize: function(){
        var self = this;
        //var count = 10;  // get the real count variable w/o breaking the quiz view
        this.collection.on('newScore', function(params){
          if(params.topScore){
            self.collection.pushScores({name: params.name, score: params.score});
            self.$el.find('#yourScore').html("Your score:  " + params.score + " out of " + params.count);
            self.$el.find('#yourScore').removeClass('inactive');
          } else {
            self.$el.find('#yourScore').html("Your score:  " + params.score + " out of " + params.count);
            self.$el.find('#yourScore').removeClass('inactive');
          }
          
          self.render();
      });


        this.render();

      },

      render: function(){
        var body = '';
        var self = this;
        this.$el.find("tbody").html('');
        this.collection.each(function(model){
          self.$el.find("tbody").prepend('<tr><td>'+model.attributes.name+'</td><td>'+model.attributes.score+'</td></tr>');
        });

      },

    });


  return ScoresView;

});