module.exports = BaseView.extend({

	className: 'social_tumblr_component',
  template: require('../templates/socialTumblr.hbs'),
  events: {
  	'mouseenter .social_tumblr_item': 'socialHover',
  	'mouseleave .social_tumblr_item': 'socialUnHover'
  },

  initialize: function() {
    this.$el.html( this.template( this.model.toJSON() ));
    this.render();
  },

  render: function() {
    // console.log('tumblr this.model',this.model.toJSON())
    // this.getIdsForLike(); // REENABLE FOR LIKING --------------
    return this;
  },

  socialHover: function(e) {
  	$(e.currentTarget).addClass('hover');
  },

  socialUnHover: function(e) {
  	$(e.currentTarget).removeClass('hover');
  },

  getIdsForLike: function() {
    // var newElemIds = [];
    // for var post in @gridPosts
    //   var id = post.id
    //   newElemIds.push(id)
    // Tumblr.LikeButton.get_status_by_post_ids(newElemIds)

    console.log('like  this.model',this.model);
    var newElemIds = [];
    newElemIds.push(this.model.get('id'));
    console.log('newElemIds',newElemIds)
    Tumblr.LikeButton.get_status_by_post_ids(newElemIds);
  }
    



});
Example #2
0
'use strict';

var BaseView = require('base/baseView');


module.exports = BaseView.extend({

  tagName: 'div',
  className: 'about_container main_comp',
  attributes: {
    'data-page': 'about'
  },
  template: require('../templates/about.hbs'),
  events: {},

  initialize: function () {
    this.attachTo('.main_container');
  },

  render: function () {
    this.$el.html(this.template( this.model.toJSON()));
    // console.log('about view render')
    // Backbone.pubSub.trigger('viewRendered', 'helloooo payload');

    return this;
  }
  
});

module.exports = BaseView.extend({

  template: require('../templates/site.hbs'),


  initialize: function() {
    var _this = this;

    setTimeout(function(){ _this.resizeMain(); }, 100);
    $(window).on("resize", this.resizeMain);

    this.$el.html( this.template );
    var headerView = new HeaderView({el: $('.header_container')});
    // var footerView = new FooterView({el: $('.footer_container')});
    var coverCollection = new SiteCollection([], {tag: 'cover', type: 'carousel', limit: 10});
    var postsCollection = new SiteCollection([], {tag: 'featured', type: 'posts', limit: 20});

    this.layout = new LayoutController();

  },

  render: function() {
    // this.$el.html(this.template({ posts: this.collection.toJSON() }));
    
  },

  gotoView: function(view) {
    // $('#app').addClass('fade_view');
    $('#app').addClass('slide_view');
    
    this.layout.slideView(view)
  },

  resizeMain: function() {
    var wh = $(window).height();
    var mainCompH = $('.main_comp').height();
    var app = $('#app');

    app.height(wh-50)
    
  }


});
module.exports = BaseView.extend({

  tagName: 'div',
  className: 'section_content',
  template: require('../templates/scrollSection1.hbs'),
  events: {},

  initialize: function (options) {
    // this.options = options;
    this.attachTo('.scroll_section.sectionone');
    this.$el.html(this.template( this.model.toJSON()));
    this.setUp(options.dir);
  },

  render: function () {
    // this.$el.html(this.template( this.model.toJSON()));

    return this;
  },

  setUp: function(startingDir) {
    var startingPos;

    if (startingDir == 'animUp') {
      startingPos = 'below';
    } else if (startingDir == 'animDown') {
      startingPos = 'above';
    } else {
      startingPos = 'center';
    }

    this.$el.addClass(startingPos);
  },

  animIn:function() {
    var _this = this;
    setTimeout(function(){
      _this.$el.addClass('center');
      _this.$el.removeClass('above below')
    }, 0);
  },

  animOut: function(animDir) {
    this.listenToOnce(Backbone.pubSub, 'sectionAnimEnd', this.animEnd);

    this.$el.removeClass('above below center')
    this.$el.addClass(animDir);

    var transitionEvent = TransEnd.whichTransitionEvent();

    this.$el.one(transitionEvent, function(event) {
      Backbone.pubSub.trigger('sectionAnimEnd');
    });

  },

  animEnd: function() {
    console.log('scrollSection1 animation DONE')
    this.dispose();
  }
  
});
Example #5
0
var ContentAreaView = BaseView.extend({

    template: require("./hbtemplates/content-area.handlebars"),

    initialize: function() {
        this.model = new Backbone.Model();
        this.render();

        this.content_rating_collection = new ContentRatingCollection();
        var self = this;
        this.content_rating_collection.url = function() {
            return sessionModel.get("CONTENT_RATING_LIST_URL") + "/?" + $.param({
                "user": window.statusModel.get("user_id"),
                "content_kind": self.model.get("kind"),
                "content_id": self.model.get("id")
            });
        };
        this.listenTo(window.statusModel, "change:user_id", this.show_rating);
        _.bindAll(this, "show_rating");
    },

    render: function() {
        this.$el.html(this.template(this.model.attributes));
        return this;
    },

    show_view: function(view) {
        // hide any messages being shown for the old view
        messages.clear_messages();

        this.close();
        // set the new view as the current view
        this.currently_shown_view = view;

        // show the view
        this.$(".content").html("").append(view.$el);
    },

    should_show_rating: function() {
        /*
        This function determines whether a rating should be shown for the content item.
        returns: true or false
        */
        var entry_available = (typeof this.model !== "undefined") && !!this.model.get("available");
        var logged_in = window.statusModel.has("user_id");
        return logged_in && entry_available;
    },

    remove_rating_view: function() {
        // Remove the rating view if it exists.
        if (typeof this.rating_view !== "undefined") {
            this.rating_view.remove();
            delete this.rating_view;
        }
    },

    show_rating: function() {
        // First, determine whether we should show the rating at all.
        // If it should not be shown, be sure to remove the rating_view; subsequent logic depends on that.
        if ( !this.should_show_rating() ) {
            this.remove_rating_view();
            return;
        }

        // Secondly, if the rating_view is previously deleted or never shown before at all, then define it.
        if( typeof this.rating_view === "undefined" ) {
            this.rating_view = this.add_subview(RatingView, {});
            this.$("#rating-container-wrapper").append(this.rating_view.el);
        }

        // Finally, handle the actual display logic
        if( this.rating_view.model === null || this.rating_view.model.get("content_id") !== this.model.get("id") ) {
            var self = this;
            this.content_rating_collection.fetch().done(function(){
                // Queue up a save on the model we're about to switch out, in case it hasn't been synced.
                if (self.rating_view.model !== null && self.rating_view.model.hasChanged()) {
                    self.rating_view.model.debounced_save();
                }
                if(self.content_rating_collection.models.length === 1) {
                    self.rating_view.model = self.content_rating_collection.pop();
                    self.rating_view.render();
                } else if ( self.content_rating_collection.models.length === 0 ) {
                    self.rating_view.model = new RatingModel({
                            "user": window.statusModel.get("user_uri"),
                            "content_kind": self.model.get("kind"),
                            "content_id": self.model.get("id")
                    });
                    self.rating_view.render();
                } else {
                    messages.show_message("error", "Server Error: More than one rating found for this user and content item!", "too-many-ratings-msg");
                    self.remove_rating_view();
                }
            }).error(function(){
                console.log("content rating collection failed to fetch");
            });
        }
    },

    close: function() {
        // This does not actually close this view. If you *really* want to get rid of this view,
        // you should call .remove()!
        // This is to allow the child view currently_shown_view to act consistently with other
        // inner_views for the sidebar InnerTopicsView.
        if (this.currently_shown_view) {
            // try calling the close method if available, otherwise remove directly
            if (_.isFunction(this.currently_shown_view.close)) {
                this.currently_shown_view.close();
            } else {
                this.currently_shown_view.remove();
            }
        }
    }

});
Example #6
0
var ContentWrapperView = BaseView.extend({

    events: {
        "click .download-link": "set_full_progress"
    },

    template: require("./hbtemplates/content-wrapper.handlebars"),

    initialize: function(options) {

        _.bindAll(this, "user_data_loaded", "set_full_progress", "render", "add_content_view", "setup_content_environment");

        var self = this;

        // load the info about the content itself
        if (options.kind == "Exercise") {
            this.data_model = new ExerciseModels.ExerciseDataModel({id: options.id, channel: options.channel});
        } else {
            this.data_model = new Models.ContentDataModel({id: options.id, channel: options.channel});
        }

        if (this.data_model.get("id")) {
            this.data_model.fetch().then(function() {
                window.statusModel.loaded.then(self.setup_content_environment);
            });
        }
    },

    setup_content_environment: function() {

        // This is a hack to support the legacy VideoLog, separate from other ContentLog
        // TODO-BLOCKER (rtibbles) 0.14: Remove this

        if (this.data_model.get("kind") == "Video") {
            LogCollection = VideoModels.VideoLogCollection;
        } else if (this.data_model.get("kind") == "Exercise") {
            LogCollection = ExerciseModels.ExerciseLogCollection;
        } else {
            LogCollection = Models.ContentLogCollection;
        }

        this.log_collection = new LogCollection([], {content_model: this.data_model});

        if (window.statusModel.get("is_logged_in")) {

            this.log_collection.fetch().then(this.user_data_loaded);

        } else {
            this.user_data_loaded();
        }

        this.listenToOnce(window.statusModel, "change:is_logged_in", this.setup_content_environment);

    },

    user_data_loaded: function() {
        this.log_model = this.log_collection.get_first_log_or_new_log();
        this.render();
    },

    set_full_progress: function() {
        if (this.data_model.get("kind") === "Document" && !("PDFJS" in window)) {
            this.content_view.set_progress(1);
            this.content_view.log_model.save();
        }
    },

    render: function() {

        this.$el.html(this.template(this.data_model.attributes));

        // Do this to prevent browserify from bundling what we want to be external dependencies.
        var external = require;

        var self = this;

        switch(this.data_model.get("kind")) {

            case "Audio":
                $script(window.sessionModel.get("STATIC_URL") + "js/distributed/bundles/bundle_audio.js", function(){
                    self.add_content_view(external("audio").AudioPlayerView);
                });
                break;

            case "Document":
                if ("PDFJS" in window) {
                    $script(window.sessionModel.get("STATIC_URL") + "js/distributed/bundles/bundle_document.js", function(){
                        self.add_content_view(external("document").PDFViewerView);
                    });
                } else {
                    self.add_content_view(ContentBaseView);
                }
                break;

            case "Video":
                $script(window.sessionModel.get("STATIC_URL") + "js/distributed/bundles/bundle_video.js", function(){
                    self.add_content_view(external("video").VideoPlayerView);
                });
                break;

            case "Exercise":
                $script(window.sessionModel.get("STATIC_URL") + "js/distributed/bundles/bundle_exercise.js", function(){
                    self.add_content_view(external("exercise").ExercisePracticeView);
                });
                break;

        }
    },

    add_content_view: function(ContentView) {

        this.content_view = this.add_subview(ContentView, {
            data_model: this.data_model,
            log_model: this.log_model
        });

        this.content_view.render();

        this.$(".content-player-container").append(this.content_view.el);

        this.points_view = this.add_subview(ContentPointsView, {
            model: this.log_model
        });

        this.points_view.render();

        this.$(".points-wrapper").append(this.points_view.el);

        this.log_model.set("views", this.log_model.get("views") + 1);
    }

});
module.exports = BaseView.extend({

  tagName: 'div',
  className: 'home_container main_comp',
  attributes: {'data-page': 'home'},
  template: require('../templates/home.hbs'),
  events: {
    'click .home_title': 'clickHandler'
  },

  initialize: function() {
    // this.listenTo(Backbone.pubSub, 'collectionDone', this.render);
    this.listenTo(this.model, 'change', this.render);
    this.attachTo('.main_container');

    this.buildPage();
  },

  buildPage: function() {
    this.carouselView = new CarouselView({el: $('.carousel_container')});
    this.barView = new BarView({el: $('.bar_container')});
    this.postsView = new PostsView({el: $('.posts_container')});
  },

  render: function() {
    // this.$el.html( this.template({collection: this.coverCollection.toJSON()}) );
    this.$el.html( this.template() );

    // Backbone.pubSub.trigger('viewRendered', 'helloooo payload');
    return this;
  },

  attachTo: function(arg) {
    BaseView.prototype.attachTo.apply(this, arguments);
  },

  clickHandler: function() {
    this.model.set({title: 'changed title'})
  },

  dispose: function(arg) {
    this.carouselView.dispose();
    this.barView.dispose();
    this.postsView.dispose();
    BaseView.prototype.dispose.apply(this, arguments);
    
  }

});
Example #8
0
var TimeSetView = BaseView.extend({
    template: require("./hbtemplates/datepicker.handlebars"),

    events: {
        "click .setrange:not([disabled])": "set_range"
    },

    initialize: function () {
        var server_date_now = new Date(new Date().getTime() - window.statusModel.get("client_server_time_diff"));
        var default_start_date = new Date(server_date_now.getTime());
        default_start_date = new Date(default_start_date.setDate(default_start_date.getDate()-ds.coachreports.default_coach_report_day_range));

        this.model.set({
            "start_date": default_start_date,
            "end_date": server_date_now
        });
        this.render();
    },

    render: function() {
        this.$el.html(this.template({
            start_date: icu.getDateFormat("SHORT").format(this.model.get("start_date")),
            end_date: icu.getDateFormat("SHORT").format(this.model.get("end_date"))
        }));

        var format = icu.getDateFormatSymbols().order_short;

        format = format[0] + "/" + format[1] + "/" + format[2];

        format = format.toLowerCase().replace("y", "yy");

        var self = this;

        this.datepicker = this.$('.date-range').each(function(){
            $(this).datepicker({
                format: format,
                endDate: "0d",
                todayBtn: "linked",
                todayHighlight: true
            });
            $(this).datepicker().on('changeDate', function() {
                self.$(".setrange").removeAttr("disabled");
            });
        });
    },

    set_range: function() {
        this.model.set({
            start_date: this.$("#start").datepicker("getDate"),
            end_date: this.$("#end").datepicker("getDate")
        });
        this.model.trigger("set_time");
        this.$(".setrange").attr("disabled", "disabled");
        return false;
    }
});
module.exports = BaseView.extend({


  showView: function(view) {
    $('#app').addClass('show_view');

    if (this.currentView) {
      this.currentView.dispose();
      console.log('disposing', this.currentView.el)
    }

    this.currentView = view;
    this.currentView.attach(); // Might want to swap render and attached
  },


  slideView: function(view) {
    // console.log('App.site',App.site)
    if (App.site.get('currentPage')) {
      App.site.set({'newPage': view.model.get('page')});
      App.site.set({'oldPage': App.site.get('currentPage')});
      App.site.set({'oldView': App.site.get('currView')});

      var incomingDirection = NavState.getSlideDir(App.site.get('currentPage'),App.site.get('newPage'));
      $('.'+App.site.get('newPage')+'_container').addClass(incomingDirection);

      this.listenToOnce(Backbone.pubSub, 'animEnd', this.animEnd);
      // this.listenToOnce(Backbone.pubSub, 'viewRendered', this.animateView);
      this.animateView();
      // view.render();

    } else {
      App.site.set({'currentPage': view.model.get('page')});
      $('.'+App.site.get('currentPage')+'_container').addClass('show');
      // view.render();

    }

    App.site.set({'currView': view});

  },

  animateView: function(payload) {
    var _this = this;
    var animEl = $('.'+App.site.get('newPage')+'_container');
    var transitionEvent = TransEnd.whichTransitionEvent();
    // App.site.set('isTransitioning', false);

    animEl.one(transitionEvent, function(event) {
      // console.log('transition END')
      Backbone.pubSub.trigger('animEnd', 'eeeeeennnnndddd');
    });

    setTimeout(function(){
      animEl.addClass('show');
      App.site.set('isTransitioning', true);
      // console.log('isTransitioning',App.site.get('isTransitioning'))
    }, 100);

    App.site.set({'currentPage': App.site.get('newPage')})
  },

  animEnd: function(payload) {
    App.site.set('isTransitioning', false);
    // console.log('isTransitioning',App.site.get('isTransitioning'))
    App.site.get('oldView').dispose();

  }


});
module.exports = BaseView.extend({

  tagName: 'div',
  className: function() {
    return 'perma_post ' + this.model.get('position_order')
  },
  template: require('../templates/permalinkContent.hbs'),
  events: {
    'click .cover_copy': 'zoom'
  },

  initialize: function () {
    // this.permaCollection = new SiteCollection([], {tag: 'featured', type: 'perma'});
    // console.log('this.model',this.model)
    // this.attachTo('.permalink_content');
    
  },

  zoom: function() {
    console.log('zoom')
    $('.cover_copy').addClass('zoom')
  },

  render: function () {
    // console.log('render permalink')
    this.$el.html( this.template( this.model.toJSON() ));

    var socialTumblr = new SocialTumblr({model: this.model});
    socialTumblr.attachTo('.perma_wrap', this.$el);
    // this.$el.find('.perma_wrap').append(socialTumblr)

    var socialShare = new SocialShare({model: this.model});
    socialShare.attachTo('.perma_wrap', this.$el);
    // this.$el.find('.perma_wrap').append(socialShare)

    return this;
  }

  



});
Example #11
0
var TimeSetView = BaseView.extend({
    template: require("./hbtemplates/datepicker.handlebars"),

    events: {
        "click .setrange:not([disabled])": "set_range"
    },

    initialize: function () {
        var server_date_now = new Date(new Date().getTime() - window.statusModel.get("client_server_time_diff"));
        var default_start_date = new Date(server_date_now.getTime());
        default_start_date = new Date(default_start_date.setDate(default_start_date.getDate()-ds.coachreports.default_coach_report_day_range));

        this.model.set({
            "start_date": default_start_date,
            "end_date": server_date_now
        });
        
        // Bad architecture:
        // Store a single instance of this.model to be accessed by tabular_reports.views
        $("html").data("main_coachreport_model", this.model);
        this.render();
    },

    render: function() {
        this.$el.html(this.template({
            start_date: icu.getDateFormat("SHORT").format(this.model.get("start_date")),
            end_date: icu.getDateFormat("SHORT").format(this.model.get("end_date"))
        }));

        var format = icu.getDateFormatSymbols().order_short;

        format = format[0] + "/" + format[1] + "/" + format[2];

        format = format.toLowerCase().replace("y", "yy");

        var self = this;

        this.datepicker = this.$('.date-range').each(function(){
            $(this).datepicker({
                format: format,
                endDate: "0d",
                todayBtn: "linked",
                todayHighlight: true
            });
            $(this).datepicker().on('changeDate', function() {
                self.$(".setrange").removeAttr("disabled");
            });
        });
    },

    set_range: function() {
        this.model.set({
            start_date: this.$("#start").datepicker("getDate"),
            end_date: this.$("#end").datepicker("getDate")
        });
        this.model.trigger("set_time");
        this.$(".setrange").attr("disabled", "disabled");
        return false;
    }
});
'use strict';

var BaseView = require('base/baseView');


module.exports = BaseView.extend({

  tagName: 'div',
  className: 'about_section sec2',
  template: require('../templates/aboutSection2.hbs'),
  events: {},

  initialize: function () {
    this.attachTo('.about_container .section_wrap');
  },

  render: function () {
    this.$el.html(this.template( this.model.toJSON()));

    return this;
  }
  
});

module.exports = BaseView.extend({

  className: 'post_item_container',
  template: require('../templates/postItem.hbs'),
  events: {
    'mouseenter': 'sizeCopyContainer',
    'click': 'gotoPerma'
  },

  initialize: function() {
    // console.log('this.model',this.model)
    this.$el.html(this.template( this.model.toJSON()));
  },

  sizeCopyContainer: function(e) {
    var copyH = $(e.currentTarget).find('.copy_container').innerHeight();
    $(e.currentTarget).find('.copy_content').css('height', copyH)
  },

  render: function() {
  	// this.$el.html(this.template( this.model.toJSON()));
    return this;
  },

  gotoPerma: function() {
    var currId = this.model.get('id');
    var url = document.domain;
    var permaUrl = '#!/post/' +currId+ '/' +this.model.get('slug');
    window.location = permaUrl;

    // Backbone.history.navigate(permaUrl, true);
  },

  dispose: function(arg) {
    // console.log('postItem dispose')
    
    BaseView.prototype.dispose.apply(this, arguments);
    
  }


});