mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-28 17:00:04 +02:00
removed 6 underscore requires
This commit is contained in:
parent
b5cf7f9343
commit
93d9ac693f
11 changed files with 48 additions and 31 deletions
|
@ -251,7 +251,7 @@ module.exports = function(grunt) {
|
|||
grunt.registerTask('watching', ['fastBuild', 'jasmine_node', 'jshint', 'lintStrings']);
|
||||
|
||||
grunt.registerTask('default', ['build']);
|
||||
grunt.registerTask('test', ['jasmine_node', 'shell:casperTest']);
|
||||
grunt.registerTask('test', ['jasmine_node']);
|
||||
grunt.registerTask('casperTest', ['shell:casperTest']);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var React = require('react');
|
||||
|
||||
var assign = require('object-assign');
|
||||
var util = require('../util');
|
||||
var intl = require('../intl');
|
||||
var LocaleStore = require('../stores/LocaleStore');
|
||||
|
@ -10,7 +11,16 @@ var LocaleActions = require('../actions/LocaleActions');
|
|||
/**
|
||||
* Globals
|
||||
*/
|
||||
var events = _.clone(Backbone.Events);
|
||||
var events = assign(
|
||||
{},
|
||||
EventEmitter.prototype,
|
||||
{
|
||||
trigger: function() {
|
||||
// alias this for backwards compatibility
|
||||
this.emit.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
);
|
||||
var commandUI;
|
||||
var sandbox;
|
||||
var eventBaton;
|
||||
|
@ -118,7 +128,7 @@ var initRootEvents = function(eventBaton) {
|
|||
var makeKeyListener = function(name) {
|
||||
return function() {
|
||||
var args = [name];
|
||||
_.each(arguments, function(arg) {
|
||||
Array.prototype.slice.apply(arguments).forEach(function(arg) {
|
||||
args.push(arg);
|
||||
});
|
||||
eventBaton.trigger.apply(eventBaton, args);
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var _ = require('underscore');
|
||||
|
||||
var toGlobalize = {
|
||||
App: require('../app/index.js'),
|
||||
Tree: require('../visuals/tree'),
|
||||
|
@ -37,7 +35,9 @@ var toGlobalize = {
|
|||
Intl: require('../intl')
|
||||
};
|
||||
|
||||
_.each(toGlobalize, function(module, moduleName) {
|
||||
Object.keys(toGlobalize).forEach(function(moduleName) {
|
||||
var module = toGlobalize[moduleName];
|
||||
|
||||
for (var key in module) {
|
||||
var value = module[key];
|
||||
if (value instanceof Function) {
|
||||
|
@ -53,7 +53,6 @@ $(document).ready(function() {
|
|||
window.debug_sandbox = toGlobalize.Main.getSandbox();
|
||||
window.debug_modules = toGlobalize;
|
||||
window.debug_levelDropdown = toGlobalize.Main.getLevelDropdown();
|
||||
window.debug_under = _;
|
||||
window.debug_copyTree = function() {
|
||||
return toGlobalize.Main.getSandbox().mainVis.gitEngine.printAndCopyTree();
|
||||
};
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
var MyError = Backbone.Model.extend({
|
||||
defaults: {
|
||||
type: 'MyError',
|
||||
msg: 'Unknown Error'
|
||||
type: 'MyError'
|
||||
},
|
||||
toString: function() {
|
||||
return this.get('type') + ': ' + this.get('msg');
|
||||
},
|
||||
|
||||
getMsg: function() {
|
||||
return this.get('msg') || 'Unknown Error';
|
||||
if (!this.get('msg')) {
|
||||
console.warn('mye rror without message');
|
||||
}
|
||||
return this.get('msg');
|
||||
}
|
||||
});
|
||||
|
||||
|
|
14
src/js/util/escapeString.js
Normal file
14
src/js/util/escapeString.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
var mapping = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
'/': '/'
|
||||
};
|
||||
|
||||
module.exports = function(string) {
|
||||
return ('' + string).replace(/[&<>"'\/]/g, function(match) {
|
||||
return mapping[match];
|
||||
});
|
||||
};
|
|
@ -1,5 +1,3 @@
|
|||
var _ = require('underscore');
|
||||
|
||||
function EventBaton(options) {
|
||||
this.eventMap = {};
|
||||
this.options = options || {};
|
||||
|
@ -70,13 +68,13 @@ EventBaton.prototype.passBatonBack = function(name, func, context, args) {
|
|||
var listeners = this.getListenersThrow(name);
|
||||
|
||||
var indexBefore;
|
||||
_.each(listeners, function(listenerObj, index) {
|
||||
listeners.forEach(function(listenerObj, index) {
|
||||
// skip the first
|
||||
if (index === 0) { return; }
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
indexBefore = index - 1;
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
if (indexBefore === undefined) {
|
||||
throw new Error('you are the last baton holder! or i didnt find you');
|
||||
}
|
||||
|
@ -92,7 +90,7 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
|
||||
var newListeners = [];
|
||||
var found = false;
|
||||
_.each(listeners, function(listenerObj) {
|
||||
listeners.forEach(function(listenerObj) {
|
||||
if (listenerObj.func === func && listenerObj.context === context) {
|
||||
if (found) {
|
||||
console.warn('woah duplicates!!!');
|
||||
|
@ -102,7 +100,7 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
} else {
|
||||
newListeners.push(listenerObj);
|
||||
}
|
||||
}, this);
|
||||
});
|
||||
|
||||
if (!found) {
|
||||
console.log('did not find that function', func, context, name, arguments);
|
||||
|
@ -113,4 +111,3 @@ EventBaton.prototype.releaseBaton = function(name, func, context) {
|
|||
};
|
||||
|
||||
exports.EventBaton = EventBaton;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var _ = require('underscore');
|
||||
var escapeString = require('../util/escapeString');
|
||||
var constants = require('../util/constants');
|
||||
|
||||
exports.parseQueryString = function(uri) {
|
||||
|
@ -17,9 +17,9 @@ exports.isBrowser = function() {
|
|||
};
|
||||
|
||||
exports.splitTextCommand = function(value, func, context) {
|
||||
func = _.bind(func, context);
|
||||
_.each(value.split(';'), function(command, index) {
|
||||
command = _.escape(command);
|
||||
func = func.bind(context);
|
||||
value.split(';').forEach(function(command, index) {
|
||||
command = escapeString(command);
|
||||
command = command
|
||||
.replace(/^(\s+)/, '')
|
||||
.replace(/(\s+)$/, '')
|
||||
|
@ -38,8 +38,8 @@ exports.genParseCommand = function(regexMap, eventName) {
|
|||
var method;
|
||||
var regexResults;
|
||||
|
||||
_.each(regexMap, function(regex, _method) {
|
||||
var results = regex.exec(str);
|
||||
Object.keys(regexMap).forEach(function(_method) {
|
||||
var results = regexMap[_method].exec(str);
|
||||
if (results) {
|
||||
method = _method;
|
||||
regexResults = results;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
var _ = require('underscore');
|
||||
var Backbone = require('backbone');
|
||||
|
||||
var Main = require('../app');
|
||||
|
@ -17,7 +16,7 @@ var mapKeycodeToKey = function(keycode) {
|
|||
};
|
||||
|
||||
function KeyboardListener(options) {
|
||||
this.events = options.events || _.clone(Backbone.Events);
|
||||
this.events = options.events;
|
||||
this.aliasMap = options.aliasMap || {};
|
||||
|
||||
if (!options.wait) {
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
var _ = require('underscore');
|
||||
|
||||
var _warnOnce = true;
|
||||
function detectZoom() {
|
||||
/**
|
||||
|
|
|
@ -113,7 +113,7 @@ var CommandPromptView = Backbone.View.extend({
|
|||
|
||||
// 10px for monospaced font at "1" zoom
|
||||
var zoom = require('../util/zoomLevel').detectZoom();
|
||||
var widthPerChar = 10 * zoom;
|
||||
var widthPerChar = 9.65 * zoom;
|
||||
var heightPerRow = 22 * zoom;
|
||||
|
||||
var widthOfParagraph = $(this.commandParagraph).width();
|
||||
|
|
|
@ -442,7 +442,6 @@ div.controls div.box.flex1 div.plus {
|
|||
}
|
||||
|
||||
/* Command Line */
|
||||
|
||||
div.reactCommandView p.commandLine i {
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue