Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//
// RootView
//
import * as bb from 'backbone';
import * as Radio from 'radio';
import LayoutView from 'base/layout-view';
import FooterView from '../footer-view';
import AuthMenuView from '../menu-views/auth-menu-view';
import UnauthMenuView from '../menu-views/unauth-menu-view';
var authChannel = Radio.channel('auth');
var RootView = LayoutView.extend({
el: bb.$('body'),
regions: {
header: '.menu',
container: 'main > div',
footer: 'footer'
},
initialize() {
this.getRegion('footer').show(new FooterView());
this.showMenu();
this.listenTo(authChannel, 'logout', this.showMenu);
var containerRegion = this.getRegion('container');
Radio.comply('rootView', 'showIn:container', containerRegion.show, containerRegion);
},
showMenu() {
this.set((this.defaults || {}));
this.set((data || {}));
// Get any additional routes passed in from options
this.routes = _.defaults((options.routes || {}), this.routes);
// Ensure that all route functions exist
_.each(this.routes, function(value, key, routes){
if(typeof value !== 'string'){ throw('Function name passed to routes in ' + this.tagName + ' component must be a string!'); }
if(!this[value]){ throw('Callback function '+value+' does not exist on the ' + this.tagName + ' component!'); }
}, this);
// Set or create our element and template if we have them
this.el = el || document.createDocumentFragment();
this.$el = (_.isFunction(Backbone.$)) ? Backbone.$(this.el) : false;
// Render our dom and place the dom in our custom element
this.render();
// Add active class to this newly rendered template's link elements that require it
$(this.el).markLinks();
// Call user provided initialize
this.initialize();
return this;
},
var _ = require('underscore');
var Backbone = require('backbone');
var middleware = require('../../state/middleware');
var CodeMirror = require('codemirror');
require('./ui');
require('./ajax');
require('./sandbox');
require('./completion');
require('./result-cell');
require('./persistence');
require('./application');
require('./authentication');
// Trigger middleware for keydown events.
Backbone.$(document).on('keydown', function (e) {
var keyName = CodeMirror.keyName(e, e.which === 16);
middleware.trigger('keydown:' + keyName, {
preventDefault: _.bind(e.preventDefault, e)
});
});
beforeEach(function() {
this.setFixtures('<div id="testRegion"></div>');
this.el = Backbone.$('#testRegion');
this.myRegion = new Region({
el: this.el
});
});
updateHighlighter(el, pos) {
var $el = $(el);
var model = $el.data('model');
if (
!model ||
!model.get('hoverable') ||
model.get('status') == 'selected'
) {
return;
}
var hlEl = this.canvas.getHighlighter();
var hlStyle = hlEl.style;
var unit = 'px';
hlStyle.left = pos.left + unit;
hlStyle.top = pos.top + unit;
hlStyle.height = pos.height + unit;
run(editor, sender) {
this.sender = sender;
var config = editor.Config;
var pfx = config.stylePrefix;
var tm = editor.TraitManager;
var panelC;
if (!this.$cn) {
var tmView = tm.getTraitsViewer();
var confTm = tm.getConfig();
this.$cn = $('<div></div>');
this.$cn2 = $('<div></div>');
this.$cn.append(this.$cn2);
this.$header = $('<div>').append(
`<div class="${confTm.stylePrefix}header">${confTm.textNoElement}</div>`
);
this.$cn.append(this.$header);
this.$cn2.append(
`<div class="${pfx}traits-label">${confTm.labelContainer}</div>`
);
this.$cn2.append(tmView.render().el);
var panels = editor.Panels;
if (!panels.getPanel('views-container'))
panelC = panels.addPanel({ id: 'views-container' });
else panelC = panels.getPanel('views-container');
panelC</div>
default: function() {
this._hideAbout();
this._hideContribute();
this._hideAirports();
this._resetOffset();
Backbone.$('body').removeClass('detail-open');
},
componentDidMount: function () {
Backbone.$(this.getDOMNode()).find("input").focus();
},
initialize: function(options) {
this.airports = options.airports;
this.render();
this.airports.on('change:visible', this._handleChange, this);
var self = this;
Backbone.$(window).scroll(function() {
self._updateViews(arguments);
});
Backbone.$(window).resize(function() {
self._updateViews(arguments);
});
},