Exemple #1
0
        render: function () {
            var emptyMsgClass = '.empty-msg',
                $listPanel;

            this.$el.append(this.addAgentFormView.render().el);
            this.$el.append(this.agentsListView.render().el);

            // wrap list view in a 'section' tag for semantic and styling purposes
            this.agentsListView.$el.wrap('<section class="list-panel"></section>');

            $listPanel = this.$el.find('.list-panel');

            // add listing header to list view
            $listPanel.prepend(this.listHeaderView.render().el);
            $listPanel.append('<p class="empty-msg hidden">Please add an agent.</p>');

            if (this.$el.find('.agent').length < 1) {
                $listPanel.find(emptyMsgClass).removeClass('hidden');
            } else {
                $listPanel.find(emptyMsgClass).addClass('hidden');
            }

            EventManager.on('agent:removed', function() {
                if (this.$el.find('.agent').length < 1) {
                    $listPanel.find(emptyMsgClass).removeClass('hidden');
                }
            }, this);

            EventManager.on('agent:added', function() {
                $listPanel.find(emptyMsgClass).addClass('hidden');
            }, this);

            return this;
        }
Exemple #2
0
    initialize: function() {
      _.bindAll(this);

      // Bind the login/logout global events
      vent.on('login', this.loginUser);
      vent.on('logout', this.logoutUser);

      // Bind to modal global events
      vent.on('show:flash', this.showFlashMessage);
      vent.on('hide:flash', this.hideFlashMessage);
    },
        panelChangeBgImage: function() {
            var self = this;

            vent.on('overlay:reset', function() {
                window.location.hash = '';
            });

            FileSelectorView.show({
                only_images: true,
                select: function(fileModel) {
                    self.saveBgImage(fileModel);
                    FileSelectorView.hide();
                    window.location.hash = '';
                }
            });
        },
		showContent: function(routeModel){
			var _this = this;
			//console.log("ModelDrivenBrowseLayout.showContent: "+routeModel.get("id"));
			// get the model collection view type
			var ContentViewType = routeModel.getCollectionViewType();
			// create a new collection instance
			var contentView = new ContentViewType({model: routeModel});
			// register for grid item events
			vent.on("ViewInTabCell:viewGridRow", function(itemModel) {
				//  get item view type for model
         	var ItemViewType = itemModel.getItemViewType();
         	console.log("ModelDrivenBrowseLayout on itemView:openGridRowInTab, ItemViewType: "+ItemViewType.getTypeName());
         	// create new item view instance with model
         	var itemView = new ItemViewType({formSchemaKey: "view", model: itemModel});
         	// TODO: register for close and return to results
         	
         	// show item view
         	_this.contentRegion.show(itemView);
         });
			//TODO reuse active view if of the same type
			this.contentRegion.show(contentView);
		}
		initialize: function() {
			var self = this;

			if(this.options.params && this.options.params.rcpt) {
				this.state = 'new';
			}
			
			this.fetchParams = {
				type: 'messages'
			};
			
			vent.on('message:openMessage', function(msgModel) {
				self.openMessage(msgModel);
			});

			vent.on('message:replySent', function(msgModel) {
				self.fetchMessages();
			});

			vent.on('message:newMessage', function(msgModel) {
				self.fetchMessages();
				self.fetchMessageThread(msgModel);
			});

			vent.on('notifications:messagesChanged', function(msgModel) {
				self.fetchMessages();
			});

			vent.on("notification:message", function() {
				self.fetchMessages();
			});

			vent.on("overlay:reset", function() {
				document.getElementById("replyBtn").scrollIntoView();
			});
		},
Exemple #6
0
var _ = require('underscore');
var $ = require('jquery');
var vent = require('vent');
var Backbone = require('backbone');
var jdu = require('jdu');
var SeriesCollection = require('../Series/SeriesCollection');
require('typeahead');


vent.on(vent.Hotkeys.NavbarSearch, function() {
    $('.x-series-search').focus();
});

var stringCleaner = function(text) {
    return jdu.replace(text.toLowerCase());
};

var substringMatcher = function() {
    return function findMatches (q, cb) {
        var matches = _.select(SeriesCollection.toJSON(), function(series) {
            return stringCleaner(series.title).indexOf(stringCleaner(q)) > -1;
        });
        cb(matches);
    };
};

$.fn.bindSearch = function() {
    $(this).typeahead({
        hint      : true,
        minLength : 1
    }, {
Exemple #7
0
 initialize : function() {
     vent.on(vent.Commands.OpenModalCommand, this._openModal, this);
     vent.on(vent.Commands.CloseModalCommand, this._closeModal, this);
     vent.on(vent.Commands.OpenModal2Command, this._openModal2, this);
     vent.on(vent.Commands.CloseModal2Command, this._closeModal2, this);
     vent.on(vent.Commands.EditSeriesCommand, this._editSeries, this);
     vent.on(vent.Commands.DeleteSeriesCommand, this._deleteSeries, this);
     vent.on(vent.Commands.ShowEpisodeDetails, this._showEpisode, this);
     vent.on(vent.Commands.ShowHistoryDetails, this._showHistory, this);
     vent.on(vent.Commands.ShowLogDetails, this._showLogDetails, this);
     vent.on(vent.Commands.ShowRenamePreview, this._showRenamePreview, this);
     vent.on(vent.Commands.ShowManualImport, this._showManualImport, this);
     vent.on(vent.Commands.ShowFileBrowser, this._showFileBrowser, this);
     vent.on(vent.Commands.CloseFileBrowser, this._closeFileBrowser, this);
 },
        onRender: function() {
            var self = this;

			globals.setBackgroundFromModel(this.model);

            this.showcaseView = new ShowcaseView(this.model.get('username'));
            this.showcase.show(this.showcaseView);

            this.bcard.show(new BusinessCardView({ model: this.model }));
            this.about_view = new AboutView({ model: this.model });
            this.connections.show(new ConnectionsView(this.model.get('username')));

            // this.availability.show(new AvailabilityView(this.model.get('username')));
            this.availability.show(new CalendarView(this.model.get('username'), 'mini'));

            // Wait for showcase files
            this.showcaseView.collection.on("files:success", function() {
                var showcaseCount = self.showcaseView.collection.models.length;
                if (showcaseCount > 0) {
                    // There is at least one showcase item - show the showreel
                    $('.tabs-profile a[href="#showreel-tab"]').tab('show');
                } else {
                    // No showcase items - show connections.
                    $('.tabs-profile a[href="#connections-tab"]').tab('show');
                }
            });

            vent.on('connection:request', function(contact) {
                self.model.set({contact: contact.attributes});
            });

            vent.on('connection:cancel', function() {
                self.model.set({contact: 'no'});
            });

            // If project was requested (by router) then load it
            if (this.options && this.options.project) {
            	this.toggleOverlay(true);
            	this.about.show(new ProjectView({ model: this.options.project }));
			}

			this.updateButtons();

			if (this.options && this.options.call) {
				this[this.options.call]();
			}

            if ( ! self.share) {
                setTimeout(function() { self.initShare(); }, 1000);
            } else {
                self.initShare();
            }

            // Hook up endorse and bookmark stuff
            self.initBookEndButtons();

            // Activate BS tooltips
            $('body').tooltip({
                selector: '.bs-tooltip',
                animation: false
            });

            $(".profile-nav").show();

            var $likeBtn = this.$el.find(".likeToggle");

            // Attach event handler to update class and text depending on liked status (gets triggered after successful like/unlike action)
            $likeBtn.on("refresh", function() {
                var $el = $(this),
                    liked = ($el.data("status") == "on"),
                    onText = 'Unlike (<%= count %>)',
                    offText = 'Like (<%= count %>)';

                if (liked) {
                    $el.text(_.template(onText, $el.data()));
                    $el.addClass("is-liked");
                } else {
                    $el.text(_.template(offText, $el.data()));
                    $el.removeClass("is-liked");
                }
            });

            $likeBtn.trigger("refresh");

        },