Skip to content

Commit

Permalink
Merge pull request #6881 from epixa/uiletconst1
Browse files Browse the repository at this point in the history
[internal] Replace var with const/let in the root of ui/public
  • Loading branch information
epixa committed Apr 13, 2016
2 parents 721eb2d + 3ae0909 commit 68d46d4
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/ui/public/bound_to_config_obj.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export default function BoundToConfigObjProvider($rootScope, config) {
* @return {Object}
*/
function BoundToConfigObj(input) {
var self = this;
const self = this;

_.forOwn(input, function (val, prop) {
if (!_.isString(val) || val.charAt(0) !== '=') {
self[prop] = val;
return;
}

var configKey = val.substr(1);
const configKey = val.substr(1);

update();
$rootScope.$on('init:config', update);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/public/compile_recursive_directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ uiModules
}

// Break the recursion loop by removing the contents
var contents = element.contents().remove();
const contents = element.contents().remove();
let compiledContents;
return {
pre: (link && link.pre) ? link.pre : null,
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/elastic_textarea.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import _ from 'lodash';
import uiModules from 'ui/modules';
var NL_RE = /\n/g;
var events = 'keydown keypress keyup change';
const NL_RE = /\n/g;
const events = 'keydown keypress keyup change';

uiModules.get('kibana')
.directive('elasticTextarea', function () {
Expand Down
10 changes: 5 additions & 5 deletions src/ui/public/errors.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import _ from 'lodash';
import angular from 'angular';

var canStack = (function () {
var err = new Error();
const canStack = (function () {
const err = new Error();
return !!err.stack;
}());

var errors = {};
const errors = {};

// abstract error class
function KbnError(msg, constructor) {
Expand Down Expand Up @@ -119,7 +119,7 @@ _.class(errors.MappingConflict).inherits(KbnError);
* @param {String} field - the fields which contains the conflict
*/
errors.RestrictedMapping = function RestrictedMapping(field, index) {
var msg = field + ' is a restricted field name';
let msg = field + ' is a restricted field name';
if (index) msg += ', found it while attempting to fetch mapping for index pattern: ' + index;

KbnError.call(this, msg, errors.RestrictedMapping);
Expand Down Expand Up @@ -165,7 +165,7 @@ _.class(errors.DuplicateField).inherits(KbnError);
errors.SavedObjectNotFound = function SavedObjectNotFound(type, id) {
this.savedObjectType = type;
this.savedObjectId = id;
var idMsg = id ? ' (id: ' + id + ')' : '';
const idMsg = id ? ' (id: ' + id + ')' : '';
KbnError.call(this,
'Could not locate that ' + type + idMsg,
errors.SavedObjectNotFound);
Expand Down
8 changes: 4 additions & 4 deletions src/ui/public/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Notifier from 'ui/notify/notifier';
import SimpleEmitter from 'ui/utils/simple_emitter';

export default function EventsProvider(Private, Promise) {
var notify = new Notifier({ location: 'EventEmitter' });
const notify = new Notifier({ location: 'EventEmitter' });

_.class(Events).inherits(SimpleEmitter);
function Events() {
Expand All @@ -23,7 +23,7 @@ export default function EventsProvider(Private, Promise) {
this._listeners[name] = [];
}

var listener = {
const listener = {
handler: handler
};
this._listeners[name].push(listener);
Expand Down Expand Up @@ -75,8 +75,8 @@ export default function EventsProvider(Private, Promise) {
* @returns {Promise}
*/
Events.prototype.emit = function (name) {
var self = this;
var args = _.rest(arguments);
const self = this;
const args = _.rest(arguments);

if (!self._listeners[name]) {
return self._emitChain;
Expand Down
22 changes: 11 additions & 11 deletions src/ui/public/fixed_scroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import $ from 'jquery';
import _ from 'lodash';
import uiModules from 'ui/modules';

var SCROLLER_HEIGHT = 20;
const SCROLLER_HEIGHT = 20;

uiModules
.get('kibana')
.directive('fixedScroll', function ($timeout) {
return {
restrict: 'A',
link: function ($scope, $el) {
var $window = $(window);
var $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);
let $window = $(window);
let $scroller = $('<div class="fixed-scroll-scroller">').height(SCROLLER_HEIGHT);


/**
* Remove the listeners bound in listen()
* @type {function}
*/
var unlisten = _.noop;
let unlisten = _.noop;

/**
* Listen for scroll events on the $scroller and the $el, sets unlisten()
Expand Down Expand Up @@ -74,15 +74,15 @@ uiModules
function setup() {
cleanUp();

var containerWidth = $el.width();
var contentWidth = $el.prop('scrollWidth');
var containerHorizOverflow = contentWidth - containerWidth;
const containerWidth = $el.width();
const contentWidth = $el.prop('scrollWidth');
const containerHorizOverflow = contentWidth - containerWidth;

var elTop = $el.offset().top - $window.scrollTop();
var elBottom = elTop + $el.height();
var windowVertOverflow = elBottom - $window.height();
const elTop = $el.offset().top - $window.scrollTop();
const elBottom = elTop + $el.height();
const windowVertOverflow = elBottom - $window.height();

var requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
const requireScroller = containerHorizOverflow > 0 && windowVertOverflow > 0;
if (!requireScroller) return;

// push the content away from the scroller
Expand Down
10 changes: 5 additions & 5 deletions src/ui/public/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import _ from 'lodash';
* "kibana" module's injector.
*
*/
var existingModules = {};
var links = [];
const existingModules = {};
const links = [];

/**
* Take an angular module and extends the dependencies for that module to include all of the modules
Expand Down Expand Up @@ -79,7 +79,7 @@ function link(module) {
* @return {AngularModule}
*/
function get(moduleName, requires) {
var module = existingModules[moduleName];
let module = existingModules[moduleName];

if (module === void 0) {
// create the module
Expand All @@ -102,13 +102,13 @@ function get(moduleName, requires) {
}

function close(moduleName) {
var module = existingModules[moduleName];
const module = existingModules[moduleName];

// already closed
if (!module) return;

// if the module is currently linked, unlink it
var i = links.indexOf(module);
const i = links.indexOf(module);
if (i > -1) links.splice(i, 1);

// remove from linked modules list of required modules
Expand Down

0 comments on commit 68d46d4

Please sign in to comment.