Skip to content

Commit

Permalink
Perform a big JSCS suave cleanup
Browse files Browse the repository at this point in the history
- Update to ember-suave 1.2.3
- Use default ember-suave jscs preset
- Appease, appease, appease
  • Loading branch information
chrislopresto committed Dec 22, 2015
1 parent 095970d commit d531485
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 88 deletions.
9 changes: 1 addition & 8 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{
"preset": "ember-suave",
"disallowVar": null,
"requireBlocksOnNewline": null,
"requireEnhancedObjectLiterals": null,
"requireObjectDestructuring": null,
"requireSpaceAfterBinaryOperators": null,
"requireSpaceBeforeBinaryOperators": null,
"requireTemplateStringsForConcatenation": null
"preset": "ember-suave"
}
2 changes: 1 addition & 1 deletion addon/components/modal-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const computedJoin = function(prop) {

export default Ember.Component.extend({
tagName: '',
layout: layout,
layout,
modalService: inject.service('modal-dialog'),
destinationElementId: oneWay('modalService.destinationElementId'),

Expand Down
30 changes: 17 additions & 13 deletions addon/components/positioned-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export default Ember.Component.extend({
}),

didGetPositioned: observer('isPositioned', on('didInsertElement', function() {
if (this._state !== 'inDOM') { return; }
if (this._state !== 'inDOM') {
return;
}

if (this.get('isPositioned')) {
this.updateTargetAttachment();
Expand All @@ -32,9 +34,11 @@ export default Ember.Component.extend({
}
})),

getWrappedTargetAttachmentElement: function() {
getWrappedTargetAttachmentElement() {
const target = this.get('target');
if (!target) { return null; }
if (!target) {
return null;
}

if (Ember.typeOf(target) === 'string') {
const targetSelector = target;
Expand All @@ -52,21 +56,21 @@ export default Ember.Component.extend({
return Ember.$(target);
},

updateTargetAttachment: function() {
updateTargetAttachment() {
let targetAttachment = this.get('targetAttachment');
// Convert tether-styled values like 'middle right' to 'right'
targetAttachment = targetAttachment.split(' ').slice(-1)[0];
Ember.assert(
`Positioned container supports targetAttachments of ${SUPPORTED_TARGET_ATTACHMENTS.join(', ')}`,
SUPPORTED_TARGET_ATTACHMENTS.indexOf(targetAttachment) > -1
);
const targetAttachmentMethod = 'align' + capitalize(targetAttachment);
const targetAttachmentMethod = `align${capitalize(targetAttachment)}`;
const targetAttachmentElement = this.getWrappedTargetAttachmentElement();

this[targetAttachmentMethod](targetAttachmentElement);
},

alignCenter: function() {
alignCenter() {
const elementWidth = this.$().outerWidth();
const elementHeight = this.$().outerHeight();

Expand All @@ -76,7 +80,7 @@ export default Ember.Component.extend({
.css('margin-top', elementHeight * -0.5);
},

alignLeft: function(targetAttachmentElement) {
alignLeft(targetAttachmentElement) {
Ember.assert('Left targetAttachment requires a target', targetAttachmentElement.length > 0);

const elementWidth = this.$().outerWidth();
Expand All @@ -87,7 +91,7 @@ export default Ember.Component.extend({
.css('top', originOffsetTop);
},

alignRight: function(targetAttachmentElement) {
alignRight(targetAttachmentElement) {
Ember.assert('Right targetAttachment requires a target', targetAttachmentElement.length > 0);

const targetWidth = targetAttachmentElement.outerWidth();
Expand All @@ -98,7 +102,7 @@ export default Ember.Component.extend({
.css('top', originOffsetTop);
},

alignTop: function(targetAttachmentElement) {
alignTop(targetAttachmentElement) {
Ember.assert('Top targetAttachment requires a target', targetAttachmentElement.length > 0);

const elementWidth = this.$().outerWidth();
Expand All @@ -107,11 +111,11 @@ export default Ember.Component.extend({
const originOffsetTop = originOffset.top - Ember.$(window).scrollTop();
const targetWidth = targetAttachmentElement.outerWidth();

this.$().css('left', (originOffset.left + targetWidth/2 - elementWidth/2))
this.$().css('left', (originOffset.left + targetWidth / 2 - elementWidth / 2))
.css('top', originOffsetTop - elementHeight);
},

alignBottom: function(targetAttachmentElement) {
alignBottom(targetAttachmentElement) {
Ember.assert('Bottom targetAttachment requires a target', targetAttachmentElement.length > 0);

const elementWidth = this.$().outerWidth();
Expand All @@ -120,9 +124,9 @@ export default Ember.Component.extend({
const targetWidth = targetAttachmentElement.outerWidth();
const targetHeight = targetAttachmentElement.outerHeight();

this.$().css('left', (originOffset.left + targetWidth/2 - elementWidth/2))
this.$().css('left', (originOffset.left + targetWidth / 2 - elementWidth / 2))
.css('top', originOffsetTop + targetHeight);
},

alignNone: function() {}
alignNone() {}
});
2 changes: 1 addition & 1 deletion addon/components/tether-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { computed, get } = Ember;
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent);

export default ModalDialog.extend({
layout: layout,
layout,

targetAttachmentClass: computed('targetAttachment', function() {
let targetAttachment = this.get('targetAttachment') || '';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ember-disable-proxy-controllers": "^1.0.0",
"ember-export-application-global": "^1.0.3",
"ember-legacy-views": "0.2.0",
"ember-suave": "1.2.0",
"ember-suave": "1.2.3",
"ember-tether": "^0.1.3",
"ember-truth-helpers": "1.2.0",
"ember-try": "0.0.6",
Expand All @@ -57,4 +57,4 @@
"configPath": "tests/dummy/config",
"demoURL": "http://yapplabs.github.io/ember-modal-dialog/"
}
}
}
24 changes: 12 additions & 12 deletions tests/acceptance/modal-dialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';

var application;
let application;
const modalRootElementSelector = '#modal-overlays';
const overlaySelector = '.ember-modal-overlay';
const dialogSelector = '.ember-modal-dialog';
const dialogCloseButton = [dialogSelector, 'button'].join(' ');

module('Acceptance: Display Modal Dialogs', {
beforeEach: function() {
beforeEach() {
application = startApp();
visit('/');
click('button:contains(Change to modal-dialog)');
},

afterEach: function() {
afterEach() {
Ember.run(application, 'destroy');
}
});
Expand Down Expand Up @@ -59,7 +59,7 @@ test('modal with custom styles', function(assert) {
openSelector: '#example-custom-styles button',
dialogText: 'Custom Styles',
closeSelector: overlaySelector,
whileOpen: function() {
whileOpen() {
assert.ok(Ember.$(`${modalRootElementSelector} ${overlaySelector}`).hasClass('custom-styles-modal'), 'has provided overlay-class');
assert.ok(Ember.$(`${modalRootElementSelector} ${dialogSelector}`).hasClass('custom-styles-modal-container'), 'has provided container-class');
}
Expand All @@ -77,7 +77,7 @@ test('target - selector', function(assert) {
dialogText: 'Target - Selector',
closeSelector: dialogCloseButton,
tethered: true,
whileOpen: function() {
whileOpen() {
assert.ok(Ember.$(dialogSelector).hasClass('ember-modal-dialog-target-attachment-left'), 'has targetAttachment class name');
}
});
Expand Down Expand Up @@ -106,20 +106,20 @@ test('subclassed modal', function(assert) {
openSelector: '#example-subclass button',
dialogText: 'Via Subclass',
closeSelector: overlaySelector,
whileOpen: function() {
whileOpen() {
assert.ok(Ember.$(dialogSelector).hasClass('my-cool-modal'), 'has provided containerClassNames');
}
});
});

test('in place', function(assert) {
click('#example-in-place button');
var dialogText = 'In Place';
var defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' ');
var inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place';
var inPlaceRootSelector = '#container-in-place';
var inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' ');
var inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' ');
let dialogText = 'In Place';
let defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' ');
let inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place';
let inPlaceRootSelector = '#container-in-place';
let inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' ');
let inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' ');
andThen(function() {
assert.equal(Ember.$(dialogSelector).css('position'), 'relative', 'not absolutely positioned');
assert.equal(Ember.$(dialogSelector).css('left'), 'auto', 'should not be positioned (left)');
Expand Down
22 changes: 11 additions & 11 deletions tests/acceptance/tether-dialog-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import Ember from 'ember';
import { module, test } from 'qunit';
import startApp from '../helpers/start-app';

var application;
let application;
const modalRootElementSelector = '#modal-overlays';
const overlaySelector = '.ember-modal-overlay';
const dialogSelector = '.ember-modal-dialog';
const dialogCloseButton = [dialogSelector, 'button'].join(' ');

module('Acceptance: Display Tether Dialogs', {
beforeEach: function() {
beforeEach() {
application = startApp();
visit('/');
},

afterEach: function() {
afterEach() {
Ember.run(application, 'destroy');
}
});
Expand Down Expand Up @@ -79,7 +79,7 @@ test('target - selector', function(assert) {
closeSelector: dialogCloseButton,
hasOverlay: false,
tethered: true,
whileOpen: function() {
whileOpen() {
assert.ok(Ember.$(dialogSelector).hasClass('ember-tether-target-attached-left'), 'has targetAttachment class name');
}
});
Expand Down Expand Up @@ -111,20 +111,20 @@ test('subclassed modal', function(assert) {
dialogText: 'Via Subclass',
closeSelector: overlaySelector,
hasOverlay: true,
whileOpen: function() {
whileOpen() {
assert.ok(Ember.$(dialogSelector).hasClass('my-cool-modal'), 'has provided containerClassNames');
}
});
});

test('in place', function(assert) {
click('#example-in-place button');
var dialogText = 'In Place';
var defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' ');
var inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place';
var inPlaceRootSelector = '#container-in-place';
var inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' ');
var inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' ');
let dialogText = 'In Place';
let defaultSelector = [modalRootElementSelector, dialogSelector, ':contains(' + dialogText + ')'].join(' ');
let inPlaceDialogSelector = dialogSelector + '.ember-modal-dialog-in-place';
let inPlaceRootSelector = '#container-in-place';
let inPlaceSelector = [inPlaceRootSelector, inPlaceDialogSelector, ':contains(' + dialogText + ')'].join(' ');
let inPlaceCloseButton = [inPlaceRootSelector, inPlaceDialogSelector, 'button'].join(' ');
andThen(function() {
assert.equal(Ember.$(dialogSelector).css('position'), 'relative', 'not absolutely positioned');
assert.equal(Ember.$(dialogSelector).css('left'), 'auto', 'should not be positioned');
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Resolver from 'ember/resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';

var App;
let App;

Ember.MODEL_FACTORY_INJECTIONS = true;

App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver: Resolver
Resolver
});

loadInitializers(App, config.modulePrefix);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import Ember from 'ember';
export default Ember.Component.extend({
isShowingModalDialog: false,
actions: {
openModalDialog: function() {
openModalDialog() {
this.set('isShowingModalDialog', true);
},
closeModalDialog: function() {
closeModalDialog() {
this.set('isShowingModalDialog', false);
}
}
Expand Down
Loading

0 comments on commit d531485

Please sign in to comment.