Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[backport] PR #6881 to 4.5 #6905

Merged
merged 1 commit into from
Apr 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/ui/public/ConfigTemplate.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
define(function (require) {
var _ = require('lodash');
const _ = require('lodash');

function ConfigTemplate(templates) {
var template = this;
const template = this;
template.current = null;
template.toggle = _.partial(update, null);
template.open = _.partial(update, true);
template.close = _.partial(update, false);

function update(newState, name) {
var toUpdate = templates[name];
var curState = template.is(name);
const toUpdate = templates[name];
const curState = template.is(name);
if (newState == null) newState = !curState;

if (newState) {
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/bound_to_config_obj.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
return function BoundToConfigObjProvider($rootScope, config) {
var _ = require('lodash');
const _ = require('lodash');

/**
* Create an object with properties that may be bound to config values.
Expand All @@ -17,15 +17,15 @@ define(function (require) {
* @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
4 changes: 2 additions & 2 deletions src/ui/public/compile_recursive_directive.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var _ = require('lodash');
const _ = require('lodash');

/**
* Angular can't render directives that render themselves recursively:
Expand All @@ -25,7 +25,7 @@ define(function (require) {
}

// 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
6 changes: 3 additions & 3 deletions src/ui/public/elastic_textarea.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
define(function (require) {
var _ = require('lodash');
var NL_RE = /\n/g;
var events = 'keydown keypress keyup change';
const _ = require('lodash');
const NL_RE = /\n/g;
const events = 'keydown keypress keyup change';

require('ui/modules').get('kibana')
.directive('elasticTextarea', function () {
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/errors.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
define(function (require) {
var _ = require('lodash');
var angular = require('angular');
const _ = require('lodash');
const angular = require('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 @@ -120,7 +120,7 @@ define(function (require) {
* @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 @@ -166,7 +166,7 @@ define(function (require) {
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
2 changes: 1 addition & 1 deletion src/ui/public/es.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(function (require) {
require('elasticsearch-browser/elasticsearch.angular.js');
var _ = require('lodash');
const _ = require('lodash');

let es; // share the client amoungst all apps
require('ui/modules')
Expand Down
14 changes: 7 additions & 7 deletions src/ui/public/events.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
define(function (require) {
var _ = require('lodash');
var Notifier = require('ui/notify/notifier');
const _ = require('lodash');
const Notifier = require('ui/notify/notifier');

return function EventsProvider(Private, Promise) {
var SimpleEmitter = require('ui/utils/SimpleEmitter');
var notify = new Notifier({ location: 'EventEmitter' });
const SimpleEmitter = require('ui/utils/SimpleEmitter');
const notify = new Notifier({ location: 'EventEmitter' });

_.class(Events).inherits(SimpleEmitter);
function Events() {
Expand All @@ -24,7 +24,7 @@ define(function (require) {
this._listeners[name] = [];
}

var listener = {
const listener = {
handler: handler
};
this._listeners[name].push(listener);
Expand Down Expand Up @@ -76,8 +76,8 @@ define(function (require) {
* @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
26 changes: 13 additions & 13 deletions src/ui/public/fixedScroll.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
define(function (require) {
var $ = require('jquery');
var _ = require('lodash');
const $ = require('jquery');
const _ = require('lodash');

var SCROLLER_HEIGHT = 20;
const SCROLLER_HEIGHT = 20;

require('ui/modules')
.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 @@ define(function (require) {
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
14 changes: 7 additions & 7 deletions src/ui/public/modules.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
define(function (require) {
var angular = require('angular');
var existingModules = {};
var _ = require('lodash');
var links = [];
const angular = require('angular');
const existingModules = {};
const _ = require('lodash');
const links = [];

function link(module) {
// as modules are defined they will be set as requirements for this app
Expand All @@ -13,7 +13,7 @@ define(function (require) {
}

function get(moduleName, requires) {
var module = existingModules[moduleName];
let module = existingModules[moduleName];

if (module === void 0) {
// create the module
Expand All @@ -36,13 +36,13 @@ define(function (require) {
}

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
2 changes: 1 addition & 1 deletion src/ui/public/validateDateInterval.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
var parseInterval = require('ui/utils/parse_interval');
const parseInterval = require('ui/utils/parse_interval');

require('ui/modules')
.get('kibana')
Expand Down