How to use the backbone.marionette.View function in backbone

To help you get started, we’ve selected a few backbone examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github comindware / core-ui / src / layout / HorizontalLayoutView.ts View on Github external
// @flow
import { helpers } from 'utils';
import LayoutBehavior from './behaviors/LayoutBehavior';
import Marionette from 'backbone.marionette';

const classes = {
    CLASS_NAME: 'layout__horizontal-layout',
    ITEM: 'layout__horizontal-layout-list-item',
    HIDDEN: 'layout__hidden'
};

export default Marionette.View.extend({
    initialize(options) {
        helpers.ensureOption(options, 'columns');

        this.columns = options.columns;
    },

    tagName: 'div',

    template: _.noop,

    className() {
        return `${classes.CLASS_NAME} ${this.options.class || ''}`;
    },

    behaviors: {
        LayoutBehavior: {
github RoundingWellOS / marionette.toolkit / test / unit / app.spec.js View on Github external
beforeEach(function() {
        this.myView = new View({ template: _.noop });

        const MyApp = this.MyApp.extend({
          onBeforeStart() {
            return this.getView();
          }
        });

        this.spy = this.sinon.spy(MyApp.prototype, 'onBeforeStart');

        this.myApp = new MyApp();

        this.myApp.setView(this.myView);
      });
github scott-w / reps-js / app / workouts / views / create.js View on Github external
previous.empty();
    }
  },

  onChildviewAddSet: function(attrs) {
    this.setDetails(attrs);
  },

  /** Clear the sets from localstorage.
  */
  clearSets: function() {
    this.collection.clearStored();
  }
});

export const CreateWorkout = Marionette.View.extend({
  template: require('../templates/create/layout.html'),

  events: {
    'click @ui.save': 'saveWorkout'
  },

  triggers: {
    'click @ui.cancel': 'show:list'
  },

  modelEvents: {
    sync: 'renderSetList',
    save: 'saveComplete'
  },

  ui: {
github scott-w / reps-js / app / workouts / views / workouts.js View on Github external
},

  onShowList: function() {
    Backbone.history.navigate('workout/');
  },

  onShowEdit: function() {
    Backbone.history.navigate(this._editUrl());
  },

  _editUrl: function() {
    return `${this.model.displayUrl()}/edit`;
  }
});

const WorkoutItem = Marionette.View.extend({
  className: 'col-md-6 col-lg-4 col-sm-12',

  template: require('../templates/workout/item.html'),

  templateContext: function() {
    const panelIndexes = {
      0: 'info',
      1: 'danger',
      2: 'warning',
      3: 'success',
      4: 'default'
    };
    const location = this.model.get('location');

    return {
      iterType: panelIndexes[this.getOption('index') % 5],
github marionettejs / marionette-integrations / mocha / app / components / ItemView.js View on Github external
import Marionette from 'backbone.marionette';
import template from 'templates/item';

export default Marionette.View.extend({
  template: template
});
github krausest / js-framework-benchmark / marionette-v3.5.1-keyed / src / Main.js View on Github external
},
    swapRows() {
        startMeasure("swapRows");
        if (this.length > 998) {
            const a = this.models[1];
            this.models[1] = this.models[998];
            this.models[998] = a;
            this.trigger('swap', this.models[1], this.models[998]);
        }
        stopMeasure();
    }
});

const store = new Store();

const ChildView = Mn.View.extend({
    tagName: 'tr',
    attributes() {
        return {
            'data-id': this.model.id
        };
    },
    monitorViewEvents: false,
    template: rowTemplate
});

const CollectionView = Mn.NextCollectionView.extend({
    childViewEventPrefix: false,
    monitorViewEvents: false,
    viewComparator: false,
    el: '#tbody',
    childView: ChildView,
github scott-w / reps-js / app / workouts / views / exercise.js View on Github external
import {SetList} from '../../sets/collections/sets';


export const SetView = Marionette.View.extend({
  tagName: 'li',
  className: 'list-group-item',
  template: require('../templates/workout/set.html')
});

export const SetListView = Marionette.CollectionView.extend({
  tagName: 'ol',
  className: 'list-group',
  childView: SetView
});

const SetContainerView = Marionette.View.extend({
  template: require('../templates/workout/exercise.html'),
  className: 'col-lg-3',

  regions: {
    sets: {
      selector: 'ol',
      replaceElement: true
    }
  },

  onRender: function() {
    this.showChildView('sets', new SetListView({
      collection: this.collection
    }));
  },
github krausest / js-framework-benchmark / marionette-v3.5.1-domapi-keyed / src / Main.js View on Github external
if (!selected) {
            return;
        }
        const curSelected = this.children.findByModel(selected);
        curSelected.$el.removeClass('danger');
    }
});

const collectionView = new CollectionView({
    collection: store
});

collectionView.render();

const MainView = Mn.View.extend({
    el : '.jumbotron',
    events: {
        'click #run'() { store.run(); },
        'click #runlots'() { store.runLots(); },
        'click #add'() { store.addData(); },
        'click #update'() { store.updateData(); },
        'click #clear'() { store.clear(); },
        'click #swaprows'() { store.swapRows(); },
    }
});

new MainView();
github Laverna / laverna / app / scripts / components / settings / show / View.js View on Github external
/**
 * @module components/settings/show/View
 */
import Mn from 'backbone.marionette';
import _ from 'underscore';
import Content from '../../../behaviors/Content';

/**
 * Settings layout view.
 *
 * @class
 * @extends Marionette.View
 * @license MPL-2.0
 */
export default class View extends Mn.View {

    get template() {
        const tmpl = require('./template.html');
        return _.template(tmpl);
    }

    /**
     * Behaviors.
     *
     * @see module:behaviors/Content
     * @returns {Array}
     */
    get behaviors() {
        return [Content];
    }
github Laverna / laverna / app / scripts / components / navbar / View.js View on Github external
/**
 * @module components/navbar/View
 */
import Mn from 'backbone.marionette';
import Radio from 'backbone.radio';
import _ from 'underscore';
import Sidemenu from '../../behaviors/Sidemenu';

/**
 * Navbar view.
 *
 * @class
 * @extends Marionette.View
 * @license MPL-2.0
 */
export default class View extends Mn.View {

    get template() {
        const tmpl = require('./template.html');
        return _.template(tmpl);
    }

    /**
     * Radio channel (components/navbar.)
     *
     * @returns {Object}
     */
    get channel() {
        return Radio.channel('components/navbar');
    }

    /**