import { LayoutView } from 'backbone.marionette'; import layout from './templates/layout.hbs'; export default LayoutView.extend({ template: layout, regions: { todoDialog: '#todo-dialog', todoGridTable: '#todo-grid-table' } });
import { Model, View, Collection, Router, LocalStorage } from 'backbone'; import { ItemsView, LayoutView } from 'backbone.marionette'; //console.log(taskTemplate); export default LayoutView.extend({ template: _=>`<div><div class="list"></div><div class="form"></div></div>`, regions: { list: '.list', form: '.form' } });
import {LayoutView} from 'backbone.marionette'; import template from './template.hbs'; import {Model} from 'backbone'; import $ from 'jquery'; export default LayoutView.extend({ template: template, regions: { breadcrumb: '#breadcrumb', content: '.content_materiaStock' }, className: 'materiaStock', initialize(options = {}) { this.model = options.model; } });
module.exports = LayoutView.extend({ authorization: undefined, template: tpl, regions: { ranking: '#results-representations-ranking', details: '#results-representation-details', feedback: '#results-representation-feedback' }, contextEvents: { 'results:assessment:selected': 'empty', 'results:representation:selected': function( e ){ this.renderDetails( e ); this.renderFeedback( e ); } }, modelEvents: { "change": "renderRanking" }, onRender: function(){ debug('#onRender', this); if(this.model.has('assessment')){ this.renderRanking(); } if(this.model.getSelectedRepresentationId()){ this.renderDetails(); this.renderFeedback(); } }, empty(){ this.ranking && this.ranking.empty(); this.details && this.details.empty(); this.feedback && this.feedback.empty(); }, renderRanking: function( ){ debug('#renderRanking', this.model.get('assessment')); const assessment = this.model.get('assessmentModel'); //todo: move to navigation if( assessment && this.authorization.isAllowedToViewRanking( assessment ) ){ this.ranking.show( this.createRanking() ); } }, renderDetails: function(){ this.details.$el.addClass( 'invisible-not-empty' ); delay( () =>{ this.details.$el.removeClass( 'invisible-not-empty' ); this.details.show( this.createDetails() ); }, 250 ); }, renderFeedback: function( e ){ this.feedback.$el.addClass( 'invisible-not-empty' ); delay( () =>{ this.feedback.$el.removeClass( 'invisible-not-empty' ); this.feedback.show( this.createFeedback() ); }, 500 ); }, });
import {LayoutView} from 'backbone.marionette'; import template from './template.hbs'; import {Model} from 'backbone'; export default LayoutView.extend({ template: template, regions:{ breadcrumb:'#breadcrumb', content:'.loanM_content' }, className: 'loanM', initialize(options = {}){ this.model = options.model; } });
export default LayoutView.extend({ template: template, className: 'modal fade', attributes: { 'tabindex' : -1, 'role' : 'dialog' }, regions: { content: '.modal-content' }, initialize() { this.$el.modal({ show: false, backdrop: 'static' }); }, triggers: { 'show.bs.modal' : { preventDefault: false, event: 'before:open' }, 'shown.bs.modal' : { preventDefault: false, event: 'open' }, 'hide.bs.modal' : { preventDefault: false, event: 'before:close' }, 'hidden.bs.modal' : { preventDefault: false, event: 'close' } }, open(view) { return new Promise(resolve => { this.once('open', resolve); this.content.show(view); this.$el.modal('show'); }); }, close() { return new Promise(resolve => { this.once('close', () => { this.content.empty(); resolve(); }); this.$el.modal('hide'); }); } });
module.exports = LayoutView.extend( { className: "row", getTemplate: function(){ const phase = this.model.get( 'phase' ); const slug = (phase) ? phase.get( "slug" ) : 'busy'; return templates[ slug ]; }, ui: { aBtn: "#select-A-button", bBtn: "#select-B-button", aOtherBtn: "#select-other-A-button", bOtherBtn: "#select-other-B-button", submitFeedbackBtn: "#submit-feedback-button", feedbackInput: "#feedback-input", seqBtn: ".seq-button", submitSeqBtn: "#submit-seq-button", submitProsConsBtn: "#submit-proscons-button", submitPassFailBtn: "#submit-passfail-button", passFailRadioBtns: ".assess-passfail-phase input:radio" }, events: { 'click @ui.aBtn': "selectionMade", 'click @ui.bBtn': "selectionMade", 'click @ui.aOtherBtn': "selectOtherCompleted", 'click @ui.bOtherBtn': "selectOtherCompleted", 'click @ui.submitFeedbackBtn': 'comparativeFeedbackProvided', 'click @ui.seqBtn': 'seqValueSelected', 'click @ui.submitSeqBtn': 'saveSeq', 'click @ui.submitProsConsBtn': 'saveProsCons', 'click @ui.submitPassFailBtn': 'savePassFail', 'change @ui.passFailRadioBtns': 'determinePassfailSubmitState' }, modelEvents: { 'change:phase': 'render' }, initialize: function(){ debug( "#initialize" ); }, serializeData: function(){ const phase = this.model.get( 'phase' ); if( !phase ){ return {}; } const slug = phase.get( "slug" ); const values = []; times( 7, function( i ){ const value = i + 1; values.push( { value: value, selected: (this.seqValue === value) } ); }, this ); const representations = { a: this.model.getRepresentationByOrder('a').toJSON(), b: this.model.getRepresentationByOrder('b').toJSON() }; const feedback = { a: { enabled: representations.a.rankType === "to rank", value: this.model.getFeedbackByOrder( 'a' ).toJSON() }, b: { enabled: representations.b.rankType === "to rank", value: this.model.getFeedbackByOrder( 'b' ).toJSON() }, }; const data = { representations: representations, title: i18n.t( "assess:phase_" + slug + ".title" ), description: i18n.t( "assess:phase_" + slug + ".description" ), seq: { values: values, selected: this.seqValue }, feedback: feedback, passfail: { options: i18n.t( "assess:phase_passfail.options", { returnObjectTrees: true } ) } }; return data; }, seqValueSelected: function( event ){ this.seqValue = this.$( event.currentTarget ).data( 'value' ); this.render(); }, saveSeq: function(){ this.ui.submitSeqBtn.prop( 'disabled', 'disabled' ); this.ui.submitSeqBtn.button( 'sending' ); this.model.storeDataForCurrentPhase( this.seqValue ); this.seqValue = undefined; }, selectionMade: function( event ){ this.ui.aBtn.prop( 'disabled', 'disabled' ); this.ui.aBtn.button( 'sending' ); this.ui.bBtn.prop( 'disabled', 'disabled' ); this.ui.bBtn.button( 'sending' ); this.model.storeDataForCurrentPhase( this.$( event.currentTarget ).data( 'selection-id' ) ); }, selectOtherCompleted: function( event ){ this.ui.aOtherBtn.prop( 'disabled', 'disabled' ); this.ui.aOtherBtn.button( 'sending' ); this.ui.bOtherBtn.prop( 'disabled', 'disabled' ); this.ui.bOtherBtn.button( 'sending' ); this.model.storeDataForCurrentPhase( this.$( event.currentTarget ).data( 'selection-id' ) ); }, comparativeFeedbackProvided: function( event ){ this.ui.submitFeedbackBtn.prop( 'disabled', 'disabled' ); this.ui.submitFeedbackBtn.button( 'sending' ); this.model.storeDataForCurrentPhase( this.ui.feedbackInput.val() ); }, saveProsCons: function( event ){ this.ui.submitProsConsBtn.prop( 'disabled', 'disabled' ); this.ui.submitProsConsBtn.button( 'sending' ); this.model.storeFeedback( { a: { positive: this.$( '#a-positive' ).val(), negative: this.$( '#a-negative' ).val() }, b: { positive: this.$( '#b-positive' ).val(), negative: this.$( '#b-negative' ).val() } } ); }, determinePassfailSubmitState: function(event){ const aVal = this.$( "input:radio[name ='a-passfail-input']:checked" ).val(); const bVal = this.$( "input:radio[name ='b-passfail-input']:checked" ).val(); if(aVal && bVal){ this.ui.submitPassFailBtn.prop( 'disabled', false ); } }, savePassFail: function( event ){ this.ui.submitPassFailBtn.prop( 'disabled', 'disabled' ); this.ui.submitPassFailBtn.button( 'sending' ); this.model.storeDataForCurrentPhase( { a: this.$( "input:radio[name ='a-passfail-input']:checked" ).val(), b: this.$( "input:radio[name ='b-passfail-input']:checked" ).val() } ); } } )
module.exports = LayoutView.extend( { template: tpl, el: "#app", menuFactory : undefined, signinFactory : undefined, messagesViewFactory: undefined, welcomeFactory : undefined, tutorialFactory : undefined, assessFactory: undefined, accountFactory: undefined, resultsFactory: undefined, uploadsFactory: undefined, regions: { menuRegion: menuRegion, contentRegion: "#app-content", messagesRegion: "#app-messages" }, contextEvents: { 'router:route:completed': "handleViewRequest" }, initialize: function(){ debug( '#initialize' ); }, onRender: function(){ debug( '#render' ); this.menuRegion.show( this.menuFactory() ); this.messagesRegion.show( this.messagesViewFactory() ); }, handleViewRequest: function( request ){ debug( "#handleViewRequest", request.route ); this.showView( request.route ); }, showView: function( viewName ){ const fName = viewName+ "Factory"; if( !this[ fName ] ){ //throw new Error( viewName + ' not yet implemented!' ); return; //not all routes need a view } const view = this[ fName ](); this.contentRegion.show( view ); }, destroyContent: function( err ){ console.log( 'destroycontent', err ); if( err.fatal ){ this.contentRegion.empty(); } } } );
/* eslint no-unused-vars: [2, { "argsIgnorePattern": "unused" }] */ import { LayoutView } from 'backbone.marionette'; import grid from './templates/grid-table.hbs'; import Rx from 'rx-lite'; import todoList from '../model/TodoList'; import TodoGridRows from './TodoGridRows'; import EmptyView from './EmptyView'; export default LayoutView.extend({ template: grid, regions: { todoGridRows: '#todo-grid-rows' }, onRender() { Rx.Observable.fromPromise(todoList.fetch()) .map(unused => new TodoGridRows({ collection: todoList })) .subscribe(gridRows => { gridRows.render(); // 一度空Viewを入れてから要素を書き換える this.getRegion('todoGridRows').show(new EmptyView()); this.getRegion('todoGridRows').$el.replaceWith(gridRows.el); }); } });
export default LayoutView.extend({ template: template, className: 'colors colors--index container', regions: { list: '.colors__list' }, initialize(options) { this.state = { start: 0, limit: 20 }; this.state.start = (options.page - 1) * this.state.limit; }, onBeforeRender() { var filtered = _.chain(this.collection.models) .drop(this.state.start) .take(this.state.limit) .value(); this.filteredCollection = new Collection(filtered); }, onAttach() { this.collectionView = new CollectionView({ collection: this.filteredCollection }); this.list.show(this.collectionView); }, templateHelpers() { var total = Math.floor(this.collection.length / this.state.limit) + 1; var current = Math.floor(this.state.start / this.state.limit) + 1; var pages = _.times(total, function(index) { return { current : index + 1 === current, page : index + 1 }; }); var prev = current - 1 > 0 ? current - 1 : false; var next = current + 1 < total ? current + 1 : false; return { total : total, current : current, pages : pages, prev : prev, next : next }; } });
const tpl = require( './templates/RankingDetails.hbs' ); module.exports = LayoutView.extend( { mediaViewFactory: undefined, regions: { 'mediaplayer': '.media-viewer' }, template: tpl, initialize: function(){ debug( '#initialize' ); this.model = this.collection.selected; }, onRender: function(){ debug( '#onRender' ); ga('send', 'event', 'results', 'view representation', this.model.get('anonymized')); const view = this.mediaViewFactory.getMediaView( this.model, { video: { height: 300, aspectratio: null } } ); this.mediaplayer.show( view ); } } );
import { LayoutView } from 'backbone.marionette'; import template from '../templates/layout.hbs'; export default LayoutView.extend({ el: '.app', template, regions: { header: '.app__header', flashes: '.app__flashes', content: '.app__content', overlay: '.app__overlay' } });
export default LayoutView.extend({ template: template, className: 'ownerEquity', regions: { moduleList: '.selModule', gameGroupList_c: '.selGameGroup_c', gameGroupList_g: '.selGameGroup_g', groupList: '.selGroup', yearList_c: '.selYear_c', yearList_g: '.selYear_g', cycleList: '.selCycle' }, initialize(options = {}) { // this.gameGroupData = options.gameGroupData; // this.ownerEquity = options.ownerEquity; this.data = options.data; this.view = 'company'; }, onBeforeRender() { let gameGroup=this.data; let gGroupFiltered=[{"gameGroup":"请选择游戏组"}]; for(let i=0;i<gameGroup.length;i++){ gGroupFiltered.push({"gameGroup":gameGroup[i]['groupNames']}); } let groupFiltered=[{"group":"请选择小组"}]; let yearFiltered =[{"year":"请选择年份"}]; let cycleFiltered =[{"year":"请选择周期"}]; this.gGroupFilteredCollection_c = new Collection(gGroupFiltered); this.gGroupFilteredCollection_g = new Collection(gGroupFiltered); this.groupFilteredCollection = new Collection(groupFiltered); this.yearFilteredCollection_c = new Collection(yearFiltered); this.yearFilteredCollection_g = new Collection(yearFiltered); this.cycleFilteredCollection = new Collection(cycleFiltered); }, onAttach() { this.gGroupCollectionView_c = new CollectionView({ collection: this.gGroupFilteredCollection_c }); this.gGroupCollectionView_g = new CollectionView({ collection: this.gGroupFilteredCollection_g }); this.groupCollectionView = new CollectionView({ collection: this.groupFilteredCollection }); this.yearCollectionView_c = new CollectionView({ collection: this.yearFilteredCollection_c }); this.yearCollectionView_g = new CollectionView({ collection: this.yearFilteredCollection_g }); this.cycleCollectionView = new CollectionView({ collection: this.cycleFilteredCollection }); this.gameGroupList_c.show(this.gGroupCollectionView_c); this.gameGroupList_g.show(this.gGroupCollectionView_g); this.groupList.show(this.groupCollectionView); this.yearList_c.show(this.yearCollectionView_c); this.yearList_g.show(this.yearCollectionView_g); this.cycleList.show(this.cycleCollectionView); }, templateHelpers() {}, ui: { companyLink: '#navbar li:first', gameGroupLink: '#navbar li:last', gameGroup_c: '.selGameGroup_c select', gameGroup_g: '.selGameGroup_g select', viewOwnEquity: '.select-group button' }, events: { 'click @ui.companyLink': 'link', 'click @ui.gameGroupLink': 'link', 'change @ui.gameGroup_c': 'gameGroup', 'change @ui.gameGroup_g': 'gameGroup', 'click @ui.viewOwnEquity': 'viewOwnEquity' }, link(e){ let left_=$(window).width(); $(e.target).parent().siblings('li').removeClass('active'); $(e.target).parent().addClass('active'); let index=0; let i=1; $(e.target).text()=='按企业查看' ? index=0 : index=1; $(e.target).text()=='按企业查看' ? i=1 : i=-1; $(e.target).text()=='按企业查看' ? this.view='company' : this.view='gameGroup'; $('.select-group').children().eq(index).animate({left: 0}); $('.select-group').children().eq(index).siblings('div').animate({left: i*left_},500); }, gameGroup(e){ let index=e.target.selectedIndex-1; //第 0 个不考虑 let $$=$(e.target).parent().parent().parent(); if(index>=0){ let groups = this.data[index]['members']; let years = this.data[index]['year']; let cycles = this.data[index]['periodsOfOneYear']; if($$.find('.selGroup').size()!=0) { $('.selGroup select').html('<option>请选择小组</option>'); for(let i = 0; i < groups.length; i++) { let option = new Option(groups[i]['userID'],groups[i]['userID']); $('.selGroup select').get(0).add(option,undefined); } } if($$.find('.year').size() != 0) { $$.find('.year select').html('<option>请选择年份</option>'); for(let i = 1; i <= years; i++) { let option = new Option('第' + i + '年','第' + i + '年'); $$.find('.year select').get(0).add(option,undefined); } } if($$.find('.selCycle').size()!=0){ $$.find('.selCycle select').html('<option>请选择周期</option>'); for(let i = 1; i <= cycles ; i++){ let option = new Option('第'+ i +'周期','第'+ i +'周期'); $$.find('.selCycle select').get(0).add(option,undefined); } } } }, viewOwnEquity(){ let a = this.view==='company' ? $('#companyView select:visible') : $('#gameGroupView select:visible'); let arr = []; for(let i=0;i<a.length;i++){ if(a[i].selectedIndex === 0){ alert('请选择必要的选项'+i); return; }else{ arr.push(a[i].selectedIndex); } } let myChart = this.view==='company' ? echarts.init($('#view-company').get(0)) : echarts.init($('#view-gameGroup').get(0)); let ser = []; let series = this.ownerEquity[arr[0]-1]['series']; if(this.view === 'company'){ ser = series[arr[2]][arr[1]-1]['data']; }else{ let datas = []; for(let j=0;j<series[arr[1]].length;j++){ datas.push(series[arr[1]][j].data[arr[2]-1]); } // alert(s.data); //特定游戏组 特定年份 特定周期的 一组游戏组成员的数据 ser = datas; } let option = { title: { text: '所有者权益', left: 'left' }, legend: { data: [] }, toolbox: { show: true, feature: { dataZoom: { show: true }, dataView: { show: true }, magicType: { type: ['line','bar'] }, restore: { show: true }, saveAsImage: { show: true } } }, tooltip: { trigger: 'axis' }, xAxis: { data: this.view === 'company' ? this.gameGroupData[arr[0]-1]['cycle'] : this.gameGroupData[arr[0]-1]['group'] }, yAxis: {}, series: [{ type: 'bar', data: ser }] }; myChart.setOption(option); } });
import { LayoutView } from 'backbone.marionette'; import _ from 'underscore'; import template from './main.html'; export default LayoutView.extend({ template: _.template(template), className: 'block white', regions: { main: '.main-container', }, initialize() { // on init }, onBeforeShow() { }, });
import './styles.styl'; import {LayoutView} from 'backbone.marionette'; import template from './layout-template.jade'; export default LayoutView.extend({ template: template, className: 'container', regions: { library: '.books__library', viewer: '.books__viewer' } });
import {LayoutView} from 'backbone.marionette'; import template from '../templates/appLayout.hbs'; // a root layout for our application export default LayoutView.extend({ el: '.application', template: template, regions: { header : '.application__header', selectedConfig: '.application__selectedConfig', flashes : '.application__flashes', content : '.application__content', overlay : '.application__overlay', footer : '.application__footer' } });
export default LayoutView.extend({ /** * View instantiates against */ el: '.settings', /** * View does not use a template */ template: false, /** * Regions for view */ regions: { main: '.active-page' }, /** * UI hash for view */ ui: { nav: '.page-nav' }, /** * Set current active navigation page * @param perspective */ setActive: function(perspective) { if (this.$active) { this.$active.removeClass('active'); } this.$active = this.$el.find('#' + perspective).addClass('active'); } });
export default LayoutView.extend({ template: template, initialize(filter={}){ this.currentFilter = filter; this.listenTo(commentsChannel,{ 'filter:changed': this.onFilterChange }); }, serializeData(){ return { filterTypes: [ {name: 'Все', key: ''}, {name: 'Комментарии', key: 'comment'}, {name: 'Отзывы', key: 'product_comment'} ].map(item => { item.active = item.key == this.currentFilter.type; return item; }), sorts: [ {name: 'Новые', key: '1'}, {name: 'Старые', key: '0'}, ].map(item => { item.active = item.key == this.currentFilter.dateSort; return item; }), } }, ui: { filter: '.filter' }, events: { 'change @ui.filter': 'changeFilter' }, changeFilter() { let filter = {}; this.ui.filter.each((index, el) => { if (el.value) { filter[el.name] = el.value; } }); commentsChannel.trigger('filter:changed', filter); } });
import {LayoutView} from 'backbone.marionette'; var Root = LayoutView.extend({ el: 'body' }); export default Root;
import _ from 'underscore'; import $ from 'jquery'; import { LayoutView } from 'backbone.marionette'; import { Collection, history } from 'backbone'; import ListView from './albums-list'; import template from '../templates/albums.hbs'; export default LayoutView.extend({ className: 'albums--index container', template, regions: { list: '.albums' }, onAttach() { this.listView = new ListView({ collection: this.collection }); this.list.show(this.listView); } });
import {LayoutView} from 'backbone.marionette'; import template from './template.hbs'; export default LayoutView.extend({ template:template, className:'forest', regions:{ breadcrumb:"#breadcrumb", select:'#checked', chart:'#chart' } });
module.exports = LayoutView.extend({ template: tpl, continueComparisonsFactory: undefined, assessmentSelectionFactory: undefined, layoutFactory: undefined, comparisonMessagesFactory: undefined, regions: { contentRegion: "#assessment-content" }, //avoid the idiotic div-wrapper tagName: "div", className: "row", contextEvents: { "comparisons:continue:requested": "showContinueComparison", 'comparisons:editing:requested': 'showLayoutView', 'assessments:selection:requested': 'showAssessmentsSelection', 'comparisons:creation:failed': 'showComparisonMessage' }, initialize: function () { debug("#initialize"); }, onRender: function () { this.dispatch('assess:ui:rendered'); }, showContinueComparison: function () { this.contentRegion.show(this.continueComparisonsFactory()); }, showComparisonMessage: function (event) { this.contentRegion.show(this.comparisonMessagesFactory({ model: new Model({ assessment: event.assessment, messages: event.messages }) })); }, showAssessmentsSelection: function (eventData) { debug("#showAssessmentsSelection"); this.contentRegion.show(this.assessmentSelectionFactory()); }, showLayoutView: function () { debug("#showComparisonView"); this.contentRegion.show(this.layoutFactory()); }, onDestroy: function () { this.dispatch('assess:ui:destroyed'); } });