Skip to content

Commit

Permalink
Linting use before define in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
andersevenrud committed Nov 28, 2016
1 parent 78b5a9d commit 1aef9f9
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 160 deletions.
54 changes: 27 additions & 27 deletions src/build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,33 @@ function generateServerConfiguration(cli, cfg) {
});
}

/*
* Get a configuration value by path
*/
function getConfigPath(config, path, defaultValue) {
if ( typeof path === 'string' ) {
var result = null;
var ns = config;

const queue = path.split(/\./);
queue.forEach(function(k, i) {
if ( i >= queue.length - 1 ) {
result = ns[k];
} else {
ns = ns[k];
}
});

if ( typeof result === 'undefined' ) {
return defaultValue;
}

return result;
}

return config;
}

/*
* Sets a config value
*/
Expand Down Expand Up @@ -300,33 +327,6 @@ function getConfiguration() {
});
}

/*
* Get a configuration value by path
*/
function getConfigPath(config, path, defaultValue) {
if ( typeof path === 'string' ) {
var result = null;
var ns = config;

const queue = path.split(/\./);
queue.forEach(function(k, i) {
if ( i >= queue.length - 1 ) {
result = ns[k];
} else {
ns = ns[k];
}
});

if ( typeof result === 'undefined' ) {
return defaultValue;
}

return result;
}

return config;
}

///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/build/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ const TASKS = {
});

if ( (cfg.repositories || []).indexOf(repo) < 0 ) {
console.warn('The repository \'' + repo + '\' is not active.'['yellow']);
console.warn(String.color('The repository \'' + repo + '\' is not active.', 'yellow'));
}

return Promise.resolve();
Expand Down
40 changes: 20 additions & 20 deletions src/build/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,26 @@ function parsePreloads(iter) {
// API
///////////////////////////////////////////////////////////////////////////////

/*
* Checks if package is enabled
*/
function checkEnabledState(enabled, disabled, meta) {
const name = meta.path;
const shortName = meta.path.split('/')[1];

if ( String(meta.enabled) === 'false' ) {
if ( enabled.indexOf(shortName) !== -1 ) {
return true;
}
return enabled.indexOf(name) !== -1;
}

if ( disabled.indexOf(shortName) === -1 ) {
return true;
}
return disabled.indexOf(name) === -1;
}

/*
* Get Package Metadata
*/
Expand Down Expand Up @@ -173,26 +193,6 @@ function generateClientManifest(target, manifest) {
});
}

/*
* Checks if package is enabled
*/
function checkEnabledState(enabled, disabled, meta) {
const name = meta.path;
const shortName = meta.path.split('/')[1];

if ( String(meta.enabled) === 'false' ) {
if ( enabled.indexOf(shortName) !== -1 ) {
return true;
}
return enabled.indexOf(name) !== -1;
}

if ( disabled.indexOf(shortName) === -1 ) {
return true;
}
return disabled.indexOf(name) === -1;
}

///////////////////////////////////////////////////////////////////////////////
// API
///////////////////////////////////////////////////////////////////////////////
Expand Down
198 changes: 99 additions & 99 deletions src/client/javascript/core/windowmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,105 +146,6 @@
var current = null;
var newRect = {};

/**
* When mouse button is pressed
*/
function onMouseDown(ev, action, win, mousePosition) {
OSjs.API.blurMenu();
ev.preventDefault();

if ( win._state.maximized ) {
return;
}

current = new BehaviourState(win, action, mousePosition);
newRect = {};

win._focus();

if ( action === 'move' ) {
current.$element.setAttribute('data-hint', 'moving');
} else {
current.calculateDirection();
current.$element.setAttribute('data-hint', 'resizing');

newRect = current.getRect();
}

win._emit('preop');

Utils.$bind(document, 'mousemove:movewindow', _onMouseMove, false);
Utils.$bind(document, 'mouseup:movewindowstop', _onMouseUp, false);

function _onMouseMove(ev, pos) {
if ( wm._mouselock ) {
onMouseMove(ev, action, win, pos);
}
}
function _onMouseUp(ev, pos) {
onMouseUp(ev, action, win, pos);
Utils.$unbind(document, 'mousemove:movewindow');
Utils.$unbind(document, 'mouseup:movewindowstop');
}
}

/**
* When mouse button is released
*/
function onMouseUp(ev, action, win, mousePosition) {
if ( !current ) {
return;
}

if ( current.moved ) {
if ( action === 'move' ) {
win._onChange('move', true);
win._emit('moved', [win._position.x, win._position.y]);
} else if ( action === 'resize' ) {
win._onChange('resize', true);
win._emit('resized', [win._dimension.w, win._dimension.h]);
}
}

current.$element.setAttribute('data-hint', '');

win._emit('postop');

current = null;
}

/**
* When mouse is moved
*/
function onMouseMove(ev, action, win, mousePosition) {
if ( !_WM.getMouseLocked() || !action || !current ) {
return;
}

var result;
var dx = mousePosition.x - current.startX;
var dy = mousePosition.y - current.startY;

if ( action === 'move' ) {
result = onWindowMove(ev, mousePosition, dx, dy);
} else {
result = onWindowResize(ev, mousePosition, dx, dy);
}

if ( result ) {
if ( result.left !== null && result.top !== null ) {
win._move(result.left, result.top);
win._emit('move', [result.left, result.top]);
}
if ( result.width !== null && result.height !== null ) {
win._resize(result.width, result.height, true);
win._emit('resize', [result.width, result.height]);
}
}

current.moved = true;
}

/**
* Resizing action
*/
Expand Down Expand Up @@ -371,6 +272,105 @@
return {left: newLeft, top: newTop, width: newWidth, height: newHeight};
}

/**
* When mouse button is released
*/
function onMouseUp(ev, action, win, mousePosition) {
if ( !current ) {
return;
}

if ( current.moved ) {
if ( action === 'move' ) {
win._onChange('move', true);
win._emit('moved', [win._position.x, win._position.y]);
} else if ( action === 'resize' ) {
win._onChange('resize', true);
win._emit('resized', [win._dimension.w, win._dimension.h]);
}
}

current.$element.setAttribute('data-hint', '');

win._emit('postop');

current = null;
}

/**
* When mouse is moved
*/
function onMouseMove(ev, action, win, mousePosition) {
if ( !_WM.getMouseLocked() || !action || !current ) {
return;
}

var result;
var dx = mousePosition.x - current.startX;
var dy = mousePosition.y - current.startY;

if ( action === 'move' ) {
result = onWindowMove(ev, mousePosition, dx, dy);
} else {
result = onWindowResize(ev, mousePosition, dx, dy);
}

if ( result ) {
if ( result.left !== null && result.top !== null ) {
win._move(result.left, result.top);
win._emit('move', [result.left, result.top]);
}
if ( result.width !== null && result.height !== null ) {
win._resize(result.width, result.height, true);
win._emit('resize', [result.width, result.height]);
}
}

current.moved = true;
}

/**
* When mouse button is pressed
*/
function onMouseDown(ev, action, win, mousePosition) {
OSjs.API.blurMenu();
ev.preventDefault();

if ( win._state.maximized ) {
return;
}

current = new BehaviourState(win, action, mousePosition);
newRect = {};

win._focus();

if ( action === 'move' ) {
current.$element.setAttribute('data-hint', 'moving');
} else {
current.calculateDirection();
current.$element.setAttribute('data-hint', 'resizing');

newRect = current.getRect();
}

win._emit('preop');

function _onMouseMove(ev, pos) {
if ( wm._mouselock ) {
onMouseMove(ev, action, win, pos);
}
}
function _onMouseUp(ev, pos) {
onMouseUp(ev, action, win, pos);
Utils.$unbind(document, 'mousemove:movewindow');
Utils.$unbind(document, 'mouseup:movewindowstop');
}

Utils.$bind(document, 'mousemove:movewindow', _onMouseMove, false);
Utils.$bind(document, 'mouseup:movewindowstop', _onMouseUp, false);
}

/**
* Register a window
*/
Expand Down
26 changes: 13 additions & 13 deletions src/client/javascript/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,19 +464,6 @@
var startX, startY, currentX, currentY;
var dragging = false;

function _onMouseDown(ev, pos, touchDevice) {
ev.preventDefault();

startX = pos.x;
startY = pos.y;

onDown(ev, {x: startX, y: startY});
dragging = true;

Utils.$bind(window, 'mouseup:guidrag', _onMouseUp, false);
Utils.$bind(window, 'mousemove:guidrag', _onMouseMove, false);
}

function _onMouseMove(ev, pos, touchDevice) {
ev.preventDefault();

Expand All @@ -499,6 +486,19 @@
Utils.$unbind(window, 'mousemove:guidrag');
}

function _onMouseDown(ev, pos, touchDevice) {
ev.preventDefault();

startX = pos.x;
startY = pos.y;

onDown(ev, {x: startX, y: startY});
dragging = true;

Utils.$bind(window, 'mouseup:guidrag', _onMouseUp, false);
Utils.$bind(window, 'mousemove:guidrag', _onMouseMove, false);
}

Utils.$bind(el, 'mousedown', _onMouseDown, false);
};

Expand Down
1 change: 1 addition & 0 deletions src/client/javascript/utils/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
* Creates touch gestures for emulating mouse input
*/
function createGestureHandler(el, n, t, callback, useCapture) {
/*eslint no-use-before-define: "off"*/
var started;
var contextTimeout;
var dblTimeout;
Expand Down

0 comments on commit 1aef9f9

Please sign in to comment.