define( function( require ) {
	'use strict';

	var Marionette = require( 'marionette' );

	return Marionette.ItemView.extend({
		template: '#item-template'
		, tagName: 'div'
		, className: 'col-md-3 col-sm-6 repo'
		, templateHelpers: function() {
			return {
				name: this.model.get( 'displayName' ) || this.model.get( 'name' )
			};
		}
	});
});
Example #2
0
define(function (require) {

    var Marionette = require('marionette');
    //var EntryTemplate = require('app/Modules/Home/Templates/Entry.html');

    var Content = Marionette.ItemView.extend({
        template: "#single_post_content_template",
        className: 'content_view',

        initialize: function(){

        }
    });

    return Content;
});
Example #3
0
define( function( require ) {

	var Marionette 		= require( 'marionette' );

	var tmplAside = require( 'text!templates/aside.html' );

	var AsideView = Marionette.ItemView.extend({
		template: _.template( tmplAside )
		, render: function() {
			this.$el.html( this.template( options ) );
			console.log("Aside Rendered!");
			return this;
		}
	});
	return AsideView;
});
Example #4
0
define(function(require) {
  var
  $ = require('jquery'),
    _ = require('underscore'),
    Backbone = require('backbone'),
    Marionette = require('marionette'),
    createGistItemTemplate = require('hbs!templates/createGistItemTemplate'),
    CreateGistItemView = Marionette.ItemView.extend({
      template: createGistItemTemplate,
      tagName: 'div',
      className: 'item'

    });

  return CreateGistItemView;
});
            it("should work with Handelbars templates", function () {
                var TestItemView = Marionette.ItemView.extend({
                    template: Handlebars.compile("<span>{{this.value}}</span>"),
                    tagName: "li"
                });
                var TestCollectionView = Marionette.CollectionView.extend({
                    itemView: TestItemView,
                    tagName: "ul"
                });
                var col = new ListCollection(["a", "b", "c"]);

                var view = new TestCollectionView({collection: col});
                dom.show(view);

                expect(dom.el.html()).toBe("<ul><li><span>a</span></li><li><span>b</span></li><li><span>c</span></li></ul>");
            });
define(function(require) {
    'use strict';

    var _ = require('underscore'),
        Marionette = require('marionette'),
        Utils = require('utils/utils'),

        NumResultsView,

        numResultsTemplate = require('text!components/generic-list/list/templates/num-results.underscore');

    NumResultsView = Marionette.ItemView.extend({
        template: _.template(numResultsTemplate),

        initialize: function(options) {
            this.options = options || {};
            if (this.options.collection.mode === 'client') {
                this.listenTo(this.options.collection, 'backgrid:refresh', this.renderIfNotDestroyed);
            } else {
                this.listenTo(this.options.collection, 'sync', this.renderIfNotDestroyed);
            }
        },

        templateHelpers: function() {
            // Note that search is included in 'activeFilters'
            var numResults = this.options.collection.getResultCount();
            return {
                numResults: _.template(
                    // Translators: 'count' refers to the number of results contained in the table.
                    gettext('Number of results: <%= count %>')
                )({
                    count: Utils.localizeNumber(numResults, 0)
                })
            };
        },

        renderIfNotDestroyed: function() {
            if (this.isDestroyed) {
                return;
            } else {
                this.render();
            }
        }
    });

    return NumResultsView;
});
Example #7
0
define(function(require, exports, module) {

	var marionette     = require('marionette');
	var keys           = require('built/app/keys');

	var Task           = require('app/list/models/task');
	var TemplateHeader = require('hbs!app/list/templates/header');

	// adding a new task
	var HeaderView = marionette.ItemView.extend({

		template: TemplateHeader,

		ui: {
			'newTask': '.task-name'
		},

		events: {
			'keydown .task-name': 'keyDown'
		},

		keyDown: function(e) {
			//if user pressed enter and input is in focus
			if(e.which == 13) {
				this.addNewTask();
			}
		},

		addNewTask: function() {

			var taskText = this.ui.newTask.val();

			// if input is not empty, add to collection
			if(taskText) {
				var newTask = new Task({ text: taskText });
				this.collection.add(newTask);
				newTask.save();
				this.ui.newTask.val('');
			}

		}

	});

	return HeaderView;

});
Example #8
0
define(function (require) {
    "use strict";

    // load external dependencies
    var Marionette = require("marionette"),
        template = require("text!templates/admin/views/index.html");

    var artifact = "index";

    var IndexView = Marionette.ItemView.extend({
        artifact: artifact,
        template: template,
        id: artifact + "AdminView"
    });

    return IndexView;
});
Example #9
0
define(function(require){
	var Marionette = require("marionette")
	var template = require("hbs!./templates/navigator.template")
	var channel = require("backbone.radio").channel("app")
	var navView = Marionette.ItemView.extend({
		template: template,
		events: {
			"click #new-message-link": function(e){
				e.preventDefault()
				Backbone.history.navigate("message/new",{trigger: true})
				channel.trigger("view:show:new-message")
			}
		}
	})

	return navView
})
define(function(require) {
    'use strict';

    var _ = require('underscore'),
        Marionette = require('marionette');

    return Marionette.ItemView.extend({
        template: _.template(require('text!learners/detail/templates/return-to-learners.underscore')),

        templateHelpers: function() {
            return {
                returnText: gettext('Return to Learners'),
                queryString: this.options.queryString
            };
        }
    });
});
  describe('CompositeView', function(){

    // Setup view factory w/ a basic html view.
    var HtmlView = Marionette.ItemView.extend({
      template: _.template('<div><%= html %></div>')
    });
    var viewFactory = new ViewFactory();
    viewFactory.addHandler('html', function(options){
      return new HtmlView(options)
    });
    viewFactory.addHandler('composite', function(options){
      return new CompositeView(options)
    });

    // Setup model for each test.
    var compositeModel;
    beforeEach(function(){
      compositeModel = new Backbone.Model({
        title: 'the composite model',
        children: new Backbone.Collection(
          [
          new Backbone.Model({type: 'html', html: 'one'}),
          new Backbone.Model({type: 'composite', children: new Backbone.Collection([
            new Backbone.Model({type: 'html', html: 'two.one'}),
            new Backbone.Model({type: 'html', html: 'two.twow'}),
          ])})
        ])
      });
    });
    afterEach(function(){
      compositeModel = undefined;
    });

    it('should render subviews for each child', function(){
      var view = new CompositeView({
        model: compositeModel,
        viewFactory: viewFactory
      });
      view.render();
      var viewContent = view.$el.html();
      expect(viewContent).toContain('one');
      expect(viewContent).toContain('two.one');
      expect(viewContent).toContain('two.two');
    });
  });
Example #12
0
define(function (require) {
  var Marionette = require('marionette'),
      template = require('hgn!modules/menu/menuItem/menuItem.view'),
      appChannel = require('app.channel'),
      MenuItemView;

  MenuItemView = Marionette.ItemView.extend({
    
    template: template,
    tagName: 'li',

    ui: {
      link: 'a'
    },

    initialize: function () {
      this.serviceKey = this.options.serviceKey;
    },

    serializeData: function () {
      var data = this.model.toJSON();
      data.serviceKey = this.serviceKey;
      return data;
    },

    onSelect: function () {
      var disabledMessage;
      this.ui.link.addClass('types-selected');

      if (disabledMessage = this.model.get('disabledMessage')) {
        var alert = {
          title: this.model.get('disabledTitle'),
          message: disabledMessage,
          state: 'info',
          uniqueGroup: 'endpoint',
          uniqueValue: this.model.get('endpointKey')
        };

        appChannel.commands.execute('add:alert', alert);
      }
    }
  });

  return MenuItemView;
});
define( function ( require ) {
	'use strict';

	var Marionette = require( 'marionette' );
	var _          = require( 'underscore' );

	var template   = require( 'text!templates/components/menu/menuItem.html' );

	return Marionette.ItemView.extend( {
		'template'  : _.template( template ),
		'tagName'   : 'li',

		'triggers'  : {
			'click a' : 'click'
		}
	} );

} );
Example #14
0
define(function(require) {

	var Marionette = require('marionette')
	  , ControlItemViewTemplate = require('text!app/templates/control_item_view_template.html')
	  , Config = require('app/data/config')
	  ;

	var ControlItemView = Marionette.ItemView.extend({

		template: _.template(ControlItemViewTemplate),

		triggers: {
			'click #control_play': 'control:play',
			'click #control_auto-play': 'control:autoPlay',
		},

		events: {
			'change #control_players-count': 'changePlayers',
			'click #control_new-game': 'changePlayers',
			'change #control_debug': 'changeDebugMode'
		},

		ui: {
			playersCount: '#control_players-count',
			debug: '#control_debug'
		},

		onRender: function() {
			this.ui.debug.prop('checked', Config.debug);
		},

		changePlayers: function(ev) {
			this.trigger('control:changePlayers', this.ui.playersCount.val())
		},

		changeDebugMode: function(ev) {
			Config.debug = this.ui.debug.prop('checked');
		}

	});

	return ControlItemView;

});
define(function(require) {

    var Marionette = require('marionette'),
        userItemTemplate = require('hbs!users/templates/userItem'),
        Example = window.Example,

        UserItemView = Marionette.ItemView.extend({

            template: userItemTemplate,

            tagName: 'tr'
        });

    Example.Users = Example.Users || {};
    Example.Users.Views = Example.Users.Views || {};
    Example.Users.Views.UserItem = UserItemView;

    return UserItemView;
});
Example #16
0
define(function(require, exports, module) {

var marionette = require('marionette');
var models = require('app/models/task');
var keys = require('built/app/keys');
var templateHeader = require('hbs!app/templates/input');

var InputView = marionette.ItemView.extend({

    template: templateHeader,

	ui: {
		input: '#new-todo'
	},

    events: {
        'keypress @ui.input': 'onKeypress'
    },

    initialize: function() {
        keys.initialize();
    },

    onKeypress: function(e){
        //check for enter key
		var todoText = this.ui.input.val().trim();
        var key = keys.getKeyFromEvent(e);
        var newItem;

		if( key == '\r' && todoText ) {
		    newItem = new models.Task({ title: todoText });
            this.collection.create(newItem);

			//clear input
			this.ui.input.val('');
		}
    }

});

exports.InputView = InputView;

});
Example #17
0
define(function (require) {

  "use strict";

  var $                   = require('jquery'),
      _                   = require('underscore'),
      Backbone            = require('backbone'),
      Marionette          = require('marionette'),
      Ladda               = require('ladda'),
      IframeTransport     = require('jquery.iframe-transport'),
      Mission             = require('app/models/mission'),
      tpl                 = require('text!tpl/missions/upload.html');

  return Marionette.ItemView.extend({
    template: _.template(tpl),

    events: {
      'click form button': 'submit',
    },

    submit: function () {
      var self = this;
      var $form = this.$el.find('form');

      var $uploadBtn = $form.find('button[type=submit]');
      var laddaBtn = Ladda.create($uploadBtn.get(0));
      laddaBtn.start();

      $.ajax("/api/missions", {
        success: function(data) {
          laddaBtn.stop();
          self.render();
        },
        error: function () {
          laddaBtn.stop();
        },
        files: $form.find(":file"),
        iframe: true
      });
    },
  });
});
Example #18
0
define(function (require) {
    "use strict";

    // load external dependencies
    var $ = require("jquery"),
        Marionette = require("marionette"),
        DataGrid = require("modules/api/components/data_grids/data_grid"),
        template = require("text!templates/admin/views/user_action_log.html");

    var artifact = "userActionLog";

    var UserActionLogView = Marionette.ItemView.extend({
        artifact: artifact,
        template: template,
        id: artifact + "View",
        ui: {
            userActionLogTable: "#userActionLogTable"
        },
        onShow: function () {
            var that = this;
            $.getJSON("assets/data/admin.json")
                .done(function (data) {
                    var userActionLogData = data["user_action_log"];
                    showUserActionLogTable.call(that, userActionLogData["user_action_log_table_datum"]);
                });
        }
    });

    function showUserActionLogTable(data) {
        new DataGrid(this.ui.userActionLogTable, data, {
            height: 500,
            colModel: [
                { display: '用户名称', name: 'username', dataField: "username", sortable: true, width: 120},
                { display: '角色', name: 'role', dataField: "role", sortable: true, width: 150},
                { display: '菜单', name: 'menu', dataField: "menu", sortable: true, width: 200},
                { display: '访问时间', name: 'access_time', dataField: "access_time", sortable: true, width: 120, align: "center"}
            ]
        }).render();
    }

    return UserActionLogView;
});
define(function(require) {
    'use strict';

    var _ = require('underscore'),
        Marionette = require('marionette');

    return Marionette.ItemView.extend({
        template: _.template(require('learners/detail/templates/learner-names.underscore')),
        events: {
            'click .learner-email a': 'onEmailClick'
        },
        modelEvents: {
            change: 'render',
            'change:email': 'render'
        },
        onEmailClick: function() {
            this.options.trackingModel.trigger('segment:track', 'edx.bi.learner.email_link_clicked', {});
        }
    });
});
define(function (require) {
    'use strict';

    var Marionette = require('marionette');

    return Marionette.ItemView.extend({

		template : require('text!./../templates/DemoCollectionEmptyView.hbs'),

		initialize: function() {
			console.info('init view for ', this.model.id);
		},

		onRender: function() {
			console.info('render view for ', this.model.id);

		}
    });

});
Example #21
0
define(function(require){

	var Marionette = require('marionette');
	var UserModel = require('models/user');
	var mock = require('mock');

	require('bootstrap');

	var RegisterView = Marionette.ItemView.extend({
		template: '#UserTemplate',
		events: {
			'click .save' : 'save'
		},
		save: function(e) {
			e.preventDefault();
			var data = this.getFormValues();
			var user = new UserModel();
			$.when(user.save(data))
			.then(function(data){
				$('.alert.create').show().alert();
				window.scrollTo(0, 0);
			});
			mock.respond();
		},
		getFormValues: function() {
			var data = {};
			data.username = this.$el.find('[name=username]').val();
			data.firstName = this.$el.find('[name=firstName]').val();
			data.lastName = this.$el.find('[name=lastName]').val();
			data.password = this.$el.find('[name=password]').val();
			data.phoneNumber = this.$el.find('[name=phoneNumber]').val();
			data.age = this.$el.find('[name=age]').val();
			data.genderIsFemale = (this.$el.find('[name=genderIsFemale]').val() === 'on') ? true : false;
			data.notes = this.$el.find('[name=notes]').val();
			return data;
		}
	});

	return RegisterView;

});
Example #22
0
define(function(require) {

 var Marionette = require('marionette'),
     Jqueryiu = require('jqueryUi'),
    Template = require('jst!./index.html');


 var View = Marionette.ItemView.extend({

    template:Template,
    className:'programcounterlayout industrialcontrollayout container',

     onShow: function(){
      this.$el.effect( "slide", "slow" );
    },

  });

  return View;

});
define(function(require){
  var Backbone = require('backbone');
  var Marionette = require('marionette');
  var Handlebars = require('handlebars');

  var PathItemViewTemplate = require('text!./templates/PathItemView.html');


  var PathItemView = Marionette.ItemView.extend({
    className: 'path-item',
    template: Handlebars.compile(PathItemViewTemplate),
    templateHelpers: function(){
      return {
        title: this.model.get('title') || 'untitled',
        url: Backbone.history.root + '#/path/' + this.model.id + '/'
      }
    }
  });

  return PathItemView;
});
            it("should allow template helpers", function () {
                var TestItemView = Marionette.ItemView.extend({
                    template: Handlebars.compile("<span>{{this.value}}{{isA this}}</span>"),
                    tagName: "li",
                    templateHelpers: {
                        isA: function () {
                            return this.value === "a" ? " is A" : "";
                        }
                    }
                });
                var TestCollectionView = Marionette.CollectionView.extend({
                    itemView: TestItemView,
                    tagName: "ul"
                });
                var col = new ListCollection(["a", "b", "c"]);

                var view = new TestCollectionView({collection: col});
                dom.show(view);

                expect(dom.el.html()).toBe("<ul><li><span>a is A</span></li><li><span>b</span></li><li><span>c</span></li></ul>");
            });
Example #25
0
define(function (require) {
    "use strict";

    var Marionette = require('marionette');
    var vent = require('modules/common/vent');

    var AppData = require('modules/common/app_data');

    var LoginView = Marionette.ItemView.extend({
        template: 'login/login',

        initialize: function () {
            if (this.$el.hasClass('hidden')) {
                this.$el.removeClass('hidden');
            }
        }
    });

    return LoginView;

});
Example #26
0
define( function ( require ){

	var App = require ( 'collection' );
	var Marionette = require( 'marionette' );
	var _ = require( 'underscore' );
	var template = require( 'text!modules/Collection/marion/templates/resultView.html' );
	
	var resultView = Marionette.ItemView.extend({
		template : _.template( template ),
		tagName : 'tr',
		'events' : {
			'click #test' : 'addToSelected'
		},
		'addToSelected' : function(){
			App.trigger('collections:add-selected',this.model);
		}
	});
	
	return resultView;

}) 
define(function( require ) {
    "use strict";

        //libs
    var Marionette = require('marionette'),
        tmpl = require('text!../templates/Template.MainContent.html'),
        Handlebars = require('handlebars');


    var Appview = Marionette.ItemView.extend({
      className: 'hella',
      template: tmpl,
      initialize: function(){
        console.log("App initialize");
      },
      onRender: function(){
      }
    });

    return Appview;
  }
define(function (require)
{
	var Marionette = require('marionette');
	var $ = require('jquery');
	
	var App = require('app');
	
	var Item_Template = require('tpl!templates/items/portfolio-item-expanded');	
	
	
	_class = Marionette.ItemView.extend(
	{
		template : Item_Template,
		className : 'portfolio-item',
		tagName : 'section',	
		
		events : 
		{
			'click .expand-btn' : function(ev)
			{
				ev.preventDefault();
				
				this.$('.expanded-content').slideToggle();
				$(ev.currentTarget).toggleClass('open closed');
				
				return false;
			}
		},
		
		initialize : function()	 { },
		
		onRender : function() 
		{
			
		},
		
	});
	
	return _class;
});
define(function (require){
    'use strict';

    var Marionette = require('marionette');

    return Marionette.ItemView.extend({

        /** @private */
        template: require('text!./../templates/ContactsView.hbs'),

        /** @private */
        ui: {},

        events: {},

        /** @private */
        initialize: function (){

        },

        
        onShow: function (){
        },


        /** @private */
        onRender: function (){


        },

        /** @private */
        onDestroy: function (){


        }

    });

});
Example #30
0
define(function(require) {
	var $ = require("jquery");
	var Radio = require("radio");
	var Mn = require("marionette");
	var Handlebars = require("handlebars");
	
	var tmpl = require("text!web/index/lxr/show/lxr_show_template.html");
	
	var LxrShowView = Mn.ItemView.extend({
		id: "lxr_show",
		template: Handlebars.compile(tmpl),
		events: {
			"click .delBtn": "delLxr"
		},
		delLxr: function(e) {
			e.preventDefault();
			var $btn = $(e.target);
			var id = $btn.data("id");
			
			$.getJSON("delAddrBook.psp", JSON.stringify({
				recordId: id
			})).done(function(res) {
				if(res.code === 0) {
					$btn.parents("li").remove();
				} else {
					alert("删除联系人失败!");	
				}
			}).fail(function() {
				alert("删除联系人失败!");
			});
			
		},
		
		onAttach: function() {
			Radio.channel("index").command("activeLink");
		}
	});
	
	return LxrShowView;
});