Beispiel #1
0
    newMessage: function() {
      this.setTitle(app.settings.get('global').get('project_name') + ' | Compose');

      var model = new app.messages.model({from: app.users.getCurrentUser().id}, {collection: app.messages, parse: true});

      this.v.main.setView('#content', new Messages.Views.New({model: model}));
      this.v.main.render();
    },
Beispiel #2
0
    user: function(id) {
      var user = app.users.getCurrentUser();
      var userGroup = user.get('group');

      if (!(parseInt(id,10) === user.id || userGroup.id === 1)) {
        return this.notFound();
      }

      var model;
      this.setTitle(app.settings.get('global').get('project_name') + ' | Users');

      if (id === "new") {
        model = new app.users.model({}, {collection: app.users, parse:true});
      } else {
        model = app.users.get(id);
      }
      this.v.main.setView('#content', new Users.Views.Edit({model: model}));
      this.v.main.render();
    },
Beispiel #3
0
    isMine: function() {
      var myId = parseInt(app.users.getCurrentUser().id,10),
          magicOwnerColumn = (this.collection !== null) ? this.collection.table.get('user_create_column') : null,
          magicOwnerId = this.get(magicOwnerColumn);

      //If magecownerid is model, grab the id instead
      if(magicOwnerId instanceof Backbone.Model) {
        magicOwnerId = magicOwnerId.get('id');
      }

      return myId === magicOwnerId;
    },
Beispiel #4
0
    onRoute: function(route, fragments) {
      // try to set the current active nav
      var currentPath = Backbone.history.fragment;
      var bookmarksView = this.v.main.getView('#sidebar').getView('#mainSidebar');
      bookmarksView.setActive(currentPath);

      this.lastRoute = currentPath;
      if ( this.loadedPreference ) {
        this.lastRoute += '/' + this.loadedPreference;
      }

      // update user last route
      var currentUser = app.users.getCurrentUser().clone();
      var history = _.clone(Backbone.history);
      currentUser.updateLastRoute(route, history);

      // check for a pending alert to execute
      if(!_.isEmpty(this.pendingAlert)) {
        this.openModal({type: this.pendingAlert.type, text: this.pendingAlert.message});
        this.pendingAlert = {};
      }
    },
Beispiel #5
0
    initialize: function(options) {
      this.navBlacklist = (options.navPrivileges.get('nav_blacklist') || '').split(',');
      // @todo: Allow a queue of pending alerts, maybe?
      this.pendingAlert = {};

      //Fade out and remove splash
      $('body').addClass('initial-load');
      this.tabs = options.tabs;
      this.bookmarks = app.getBookmarks();
      this.extensions = {};

      _.each(options.extensions, function(item) {
        try {
          if (typeof item !== 'undefined') {
            this.extensions[item] = ExtensionManager.getInstance(item);
          }
        } catch (e) {
          console.error('failed to load:', e.stack);
          return;
        }
        //this.extensions[item.id].bind('all', logRoute);
        this.extensions[item].on('route', function() {
          this.trigger('subroute',item);
          this.trigger('route:'+item,item);
        }, this);
        //this.tabs.add({title: app.capitalize(item.id), id: item.id, extension: true});
      }, this);

      var user = app.users.getCurrentUser();
      var tabs = new Tabs.View({collection: this.tabs});

      var bookmarks = new Bookmarks.View({collection: this.bookmarks});

      //Top
      var Navbar = Backbone.Layout.extend(
      {

        template: "navbar",

        tagName: 'div',

        serialize: function() {
          return {
            siteUrl: this.model.get('project_url'),
            messageCounter: app.messages.unread,
            cms_thumbnail_url: this.model.get('cms_thumbnail_url')
          };
        },
        beforeRender: function() {
          this.insertView('#featureSidebar', tabs);
          this.insertView('#mainSidebar', bookmarks);
        },

        keep: true
      });

      //holds references to view instances
      this.v = {};
      var nav = new Navbar({model: app.settings.get('global')});

      //var nav = new Navbar({model: app.settings.get('global'), collection: this.tabs});
      this.v.main = new Backbone.Layout({

        el: "#main",

        views: {
          '#sidebar': nav
        }

      });

      this.v.messages = new Backbone.Layout({
        el: "#messages"
      });

      this.routeHistory = {stack: [], base: '', routes: []};
      this.bind('route', this.onRoute, this);

      this.v.main.render();
    }