How to use the backbone.Marionette 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 pilwon / ultimate-seed / client / js / setup / backbone / marionette / application.js View on Github external
/*
 * client/js/setup/backbone/marionette/application.js
 */

/* global app */

'use strict';

var path = require('path'),
    url = require('url');

var _ = require('lodash'),
    Backbone = require('backbone');

_.extend(Backbone.Marionette.Application.prototype, {
  deregisterController: function (controller) {
    delete this._controllers[controller._id];
  },

  getControllers: function () {
    return _.values(this._controllers);
  },

  getParsedUrl: function () {
    return url.parse(location.href);
  },

  getRoute: function () {
    return path.join('/', Backbone.history.fragment);
  },
github apache / ranger / security-admin / src / main / webapp / scripts / views / users / AddUsersOrGroupsList.js View on Github external
var that = this;
            this.ui.isRoleAdmin.attr('checked', this.model.get('isAdmin'));
        },

        evClickTD : function(e){
            var $el = $(e.currentTarget);
            this.model.set('isAdmin', $el.is(':checked'));
        },

        evDelete : function(){
            var that = this;
            this.collection.remove(this.model);
        },
    });

    var AddUserOrGroupsList =  Backbone.Marionette.CompositeView.extend({

        _msvName : 'AddUserOrGroupsList',

        template : require('hbs!tmpl/users/AddUserOrGroupsList_tmpl'),

        templateHelpers :function(){
            var headerName = this.fieldName === 'users' ? "User Name" : this.fieldName === 'groups' ? "Group Name" : "Role Name",
            btnLable = this.fieldName === 'users' ? 'Add Users' : this.fieldName === 'groups' ? "Add Group" : "Add Role";
            return {
                headerName : headerName,
                btnLable : btnLable
            };
        },

        getItemView : function(item){
            if(!item){
github OutbreakInc / oban / client / views / error-list.js View on Github external
tagName: "li",

	template: "#errorItemTemplate",

	events:
	{
		"click .view": "onClick"
	},

	onClick: function()
	{
		this.trigger("click", this.model);
	}
});

var ErrorListView = Backbone.Marionette.CollectionView.extend(
{
	itemView: ErrorItemView,
	tagName: "ul",
	className: "errorList",
	itemViewEventPrefix: "error",

	appendHtml: function(collectionView, itemView)
	{
		collectionView.$el.append(itemView.el);
	}
});

return ErrorListView;

});
github apache / ranger / security-admin / src / main / webapp / scripts / views / policies / RangerPolicyCreate.js View on Github external
define(function(require){
    'use strict';

	var Backbone		= require('backbone');
	var App				= require('App');
	var XAEnums			= require('utils/XAEnums');
	var XAUtil			= require('utils/XAUtils');
	var XALinks 		= require('modules/XALinks');
	var localization	= require('utils/XALangSupport');
	
	var RangerPolicycreateTmpl = require('hbs!tmpl/policies/RangerPolicyCreate_tmpl');
	var RangerPolicyForm = require('views/policies/RangerPolicyForm');
	var RangerServiceDef	= require('models/RangerServiceDef');

	var RangerPolicyCreate = Backbone.Marionette.Layout.extend(
	/** @lends RangerPolicyCreate */
	{
		_viewName : 'RangerPolicyCreate',
		
    	template : RangerPolicycreateTmpl,
    	templateHelpers : function(){
    		return {
    			editPolicy : this.editPolicy
    		};
    	},
    	breadCrumbs :function(){
	    	
    		if(this.model.isNew())
    			return [XALinks.get('ServiceManager'),XALinks.get('ManagePolicies',{model : this.rangerService}),XALinks.get('PolicyCreate')];
    		else
    			return [XALinks.get('ServiceManager'),XALinks.get('ManagePolicies',{model : this.rangerService}),XALinks.get('PolicyEdit')];
github joyent / sdc-adminui / www / js / views / monitoring / select-probe-type.js View on Github external
var Backbone = require('backbone');
var ProbeSelectionTemplate  = require('../../tpl/probe-selection.hbs');

module.exports = Backbone.Marionette.ItemView.extend({
    template: ProbeSelectionTemplate,
    events: {
        'click a': 'selectedProbeType'
    },
    selectedProbeType: function(e) {
        var elm = $(e.currentTarget);
        var probe = elm.attr('data-probe-type');
        this.trigger('select', probe);
        this.$el.modal('hide');
    }
});
github joyent / sdc-adminui / www / js / views / user-vms-filter.js View on Github external
* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * Copyright (c) 2014, Joyent, Inc.
 */

var Backbone = require('backbone');
var React = require('react');
var _ = require('underscore');

var PackageSelect = React.createFactory(require('../components/package-select'));

var UserVmsFilter = Backbone.Marionette.ItemView.extend({
    attributes: {
        'class': 'vms-filter'
    },
    template: require('../tpl/user-vms-filter.hbs'),
    events: {
        'submit form': 'onSubmit'
    },
    onSubmit: function(e) {
        e.preventDefault();

        var data = Backbone.Syphon.serialize(this);
        _.each(data, function(v, k) {
            if (typeof(data[k]) === 'string' && data[k].length === 0) {
                delete data[k];
            }
        });
github apache / ranger / security-admin / src / main / webapp / scripts / views / permissions / ModulePermsTableLayout.js View on Github external
var XAGlobals 		= require('utils/XAGlobals');
	var SessionMgr 		= require('mgrs/SessionMgr');
	var XAUtil			= require('utils/XAUtils');
	var localization	= require('utils/XALangSupport');

	var XABackgrid		= require('views/common/XABackgrid');
	var XATableLayout	= require('views/common/XATableLayout');
	var RangerServiceDef	= require('models/RangerServiceDef');
	var UserPermission 		= require('models/UserPermission');
	var ModulePermsTableLayoutTmpl = require('hbs!tmpl/permissions/ModulePermsTableLayout_tmpl');

	require('backgrid-filter');
	require('backgrid-paginator');
	require('bootbox');

	var ModulePermsTableLayout = Backbone.Marionette.Layout.extend(
	/** @lends ModulePermsTableLayout */
	{
		_viewName : 'ModulePermsTableLayout',

		template: ModulePermsTableLayoutTmpl,

		templateHelpers : function(){
		},

		breadCrumbs : function(){
			return [XALinks.get('ModulePermissions')];
		},

		/** Layout sub regions */
		regions: {
			'rTableList'	: 'div[data-id="r_table"]',
github apache / ranger / security-admin / src / main / webapp / scripts / views / knox / KnoxTableLayout.js View on Github external
var Backbone		= require('backbone');
	var XAEnums 		= require('utils/XAEnums');
	var XALinks 		= require('modules/XALinks');
	var XAGlobals 		= require('utils/XAGlobals');
	var SessionMgr 		= require('mgrs/SessionMgr');
	var XAUtil			= require('utils/XAUtils');

	var VXResource = require('models/VXResource');
	
	var XABackgrid		= require('views/common/XABackgrid');
	var XATableLayout	= require('views/common/XATableLayout');
	var localization	= require('utils/XALangSupport');
	var vFolderInfo 		= require('views/folders/FolderInfo');
	var KnoxTableLayoutTmpl = require('hbs!tmpl/knox/KnoxTableLayout_tmpl');

	var KnoxTableLayout = Backbone.Marionette.Layout.extend(
	/** @lends KnoxTableLayout */
	{
		_viewName : 'KnoxTableLayout',
		
    	template: KnoxTableLayoutTmpl,
    	templateHelpers :function(){
    		return {
    			isSysAdmin :this.isSysAdmin,
    			assetId		  : this.assetModel.id,
    			assetModel : this.assetModel,
    			version : XAGlobals.version
    		};
    	},
    	breadCrumbs : function(){
    		return [XALinks.get('RepositoryManager'),XALinks.get('ManageKnoxPolicies',{model : this.assetModel})];
   		},
github joyent / sdc-adminui / www / js / views / servers.js View on Github external
close: function () {
        var view = this.currentView;
        var self = this;
        if (!view || view.isClosed) {
            return;
        }

        var close = Backbone.Marionette.Region.prototype.close;
        this.currentView.$el.slideUp('fast', function () {
            close.apply(self);
        });
    }
});
github CodeForPhilly / philly-ward-leaders / js / views / ward-leader-item.js View on Github external
var Backbone = require('backbone'),
  Marionette = require('backbone.marionette'),
  _ = require('underscore'),
  Template = require('../templates/ward-leader-item.html');

module.exports = Backbone.Marionette.ItemView.extend({
  tagName: 'li',
  template: Template,
  className: 'flip-container',
  initialize: function() {
    _.bindAll(this, 'onFlip');
  },
  onFlip: function(e) {
    this.$('.stats').toggle();
  }
});