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

Added ability to toggle the visibility of happy-split-views #9

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
18 changes: 10 additions & 8 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
bower_components/
tests/
tmp/
dist/

/bower_components
/config/ember-try.js
/dist
/tests
/tmp
**/.gitkeep
.bowerrc
.editorconfig
.ember-cli
.gitignore
.jshintrc
.watchmanconfig
.travis.yml
.npmignore
**/.gitkeep
bower.json
Brocfile.js
ember-cli-build.js
testem.json
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ matrix:
fast_finish: true
allow_failures:
- env: EMBER_TRY_SCENARIO=ember-canary
- env: EMBER_TRY_SCENARIO=ember-beta

before_install:
- export PATH=/usr/local/phantomjs-2.0.0/bin:$PATH
Expand Down
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
23 changes: 0 additions & 23 deletions Brocfile.js

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015
Copyright (c) 2016

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
26 changes: 24 additions & 2 deletions addon/components/happy-split-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export default Ember.Component.extend({
isDragging: false,
isVertical: true,
splitterWidth: 6,
leadingVisible: true,
trailingVisible: true,

_splitLine: undefined,
_leading: undefined,
_trailing: undefined,

classNames: ['happy-split-container'],
classNameBindings: ['isVertical:vertical:horizontal', 'isResizing:dragging', 'isDragging:disable-select'],
classNameBindings: ['isVertical:vertical:horizontal', 'isResizing:dragging', 'isDragging:disable-select', 'leadingVisible::lead-hidden', 'trailingVisible::trail-hidden'],

teardownSplitContainer: Ember.on('willDestroyElement', function () {
this.set('isDragging', false);
Expand Down Expand Up @@ -100,16 +102,18 @@ export default Ember.Component.extend({
this.set('isDragging', true);
},

addView: function (view) {
addView: function (view, visible) {
if (view === undefined || view === null) {
return;
}

if (this._leading === undefined) {
this._leading = view;
this.set('leadingVisible', visible);
}
else if (this._trailing === undefined) {
this._trailing = view;
this.set('trailingVisible', visible);
}
},

Expand All @@ -120,6 +124,24 @@ export default Ember.Component.extend({
else if (this._trailing === view) {
this._trailing = undefined;
}
},

hideView: function(view){
if (this._leading === view){
this.set('leadingVisible', false);
}
else if (this._trailing === view){
this.set('trailingVisible', false);
}
},

showView: function(view){
if (this._leading === view){
this.set('leadingVisible', true);
}
else if (this._trailing === view){
this.set('trailingVisible', true);
}
}
}
});
22 changes: 16 additions & 6 deletions addon/components/happy-split-view.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Ember from 'ember';

export default Ember.Component.extend({
isVertical: Ember.computed.readOnly('parentView.isVertical'),
splitterWidth: Ember.computed.readOnly('parentView.splitterWidth'),
splitContainer: null,
isVertical: Ember.computed.readOnly('splitContainer.isVertical'),
splitterWidth: Ember.computed.readOnly('splitContainer.splitterWidth'),
siblingsVisible: Ember.computed.and('splitContainer.leadingVisible', 'splitContainer.trailingVisible'),

minimumPercentage: 10,

Expand All @@ -20,21 +22,29 @@ export default Ember.Component.extend({
}
}),

initSplitView: Ember.on('init', function(){
this.get('splitContainer').send('addView', this, this.get('isVisible'));
}),

setupSplitView: Ember.on('didInsertElement', function () {
this.updateDimensions();
this.get('parentView').send('addView', this);
this.get('splitContainer').send('addView', this);
}),

teardownSplitView: Ember.on('willDestroyElement', function () {
this.get('parentView').send('removeView', this);
this.get('splitContainer').send('removeView', this);
}),

updateSplitVisible: Ember.observer('isVisible', function(){
this.get('splitContainer').send(this.get('isVisible') ? 'showView' : 'hideView', this);
}),

updateDimensions: Ember.observer('splitPercentage', 'splitterWidth', 'isVertical', function () {
updateDimensions: Ember.observer('splitPercentage', 'splitterWidth', 'isVertical','siblingsVisible', function () {
var percentage = this.get('splitPercentage'),
// split the width of the splitter between the left/right or top/bottom views
splitterWidth = this.get('splitterWidth') / 2,
style = this.element.style,
dimension = `calc(${percentage}% - ${splitterWidth}px)`;
dimension = this.get('siblingsVisible') ? `calc(${percentage}% - ${splitterWidth}px)` : 'calc(100%)';

if (this.get('isVertical')) {
style.width = dimension;
Expand Down
9 changes: 5 additions & 4 deletions addon/components/happy-splitter-bar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Ember from 'ember';

export default Ember.Component.extend({
splitContainer: null,
classNameBindings: ['isVertical:vertical:horizontal', 'isDragging:dragging'],
classNames: ['happy-splitter'],

isDragging: Ember.computed.readOnly('parentView.isDragging'),
isVertical: Ember.computed.readOnly('parentView.isVertical'),
splitterWidth: Ember.computed.readOnly('parentView.splitterWidth'),
isDragging: Ember.computed.readOnly('splitContainer.isDragging'),
isVertical: Ember.computed.readOnly('splitContainer.isVertical'),
splitterWidth: Ember.computed.readOnly('splitContainer.splitterWidth'),

setupSplitterBar: Ember.on('didInsertElement', function () {
this.updateDimensions();
Expand All @@ -27,7 +28,7 @@ export default Ember.Component.extend({

mouseDown (event) {
if (!event.button && !event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) {
this.get('parentView').send('dragSplitter', this.$());
this.get('splitContainer').send('dragSplitter', this.$());
}
}
});
1 change: 1 addition & 0 deletions app/templates/components/happy-split-container.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{yield this}}
14 changes: 4 additions & 10 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
{
"name": "ember-cli-happy-splitter",
"dependencies": {
"ember": "^1.12.0",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "ember-cli-test-loader#0.1.3",
"ember-load-initializers": "ember-cli/ember-load-initializers#0.1.4",
"ember-qunit": "0.3.3",
"ember-qunit-notifications": "0.0.7",
"ember-resolver": "~0.1.15",
"jquery": "^1.11.1",
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1"
"ember": "~2.3.1",
"ember-cli-shims": "0.1.0",
"ember-cli-test-loader": "0.2.2",
"ember-qunit-notifications": "0.1.0"
},
"devDependencies": {
"normalize.css": "~3.0.2"
Expand Down
41 changes: 25 additions & 16 deletions config/ember-try.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,43 @@
/*jshint node:true*/
module.exports = {
scenarios: [
{
name: 'default',
dependencies: { }
bower: {
dependencies: { }
}
},
{
name: 'ember-release',
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
bower: {
dependencies: {
'ember': 'components/ember#release'
},
resolutions: {
'ember': 'release'
}
}
},
{
name: 'ember-beta',
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
bower: {
dependencies: {
'ember': 'components/ember#beta'
},
resolutions: {
'ember': 'beta'
}
}
},
{
name: 'ember-canary',
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
bower: {
dependencies: {
'ember': 'components/ember#canary'
},
resolutions: {
'ember': 'canary'
}
}
}
]
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/*jshint node:true*/
'use strict';

module.exports = function(/* environment, appConfig */) {
Expand Down
19 changes: 19 additions & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*jshint node:true*/
/* global require, module */
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function(defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});

/*
This build file specifies the options for the dummy test app of this
addon, located in `/tests/dummy`
This build file does *not* influence how the addon or the app using it
behave. You most likely want to be modifying `./index.js` or app's build file
*/
app.import(app.bowerDirectory + '/normalize.css/normalize.css');

return app.toTree();
};
36 changes: 21 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,26 @@
"homepage": "https://github.com/ZebraFlesh/ember-cli-happy-splitter",
"license": "MIT",
"devDependencies": {
"broccoli-asset-rev": "^2.0.2",
"ember-cli": "0.2.5",
"ember-cli-app-version": "0.3.3",
"ember-cli-content-security-policy": "0.4.0",
"ember-cli-dependency-checker": "^1.0.0",
"ember-cli-inject-live-reload": "^1.3.0",
"ember-cli-lorem-ipsum": "^0.0.2",
"ember-cli-qunit": "0.3.13",
"ember-cli-sass": "^3.3.1",
"ember-cli-uglify": "^1.0.1",
"ember-disable-prototype-extensions": "^1.0.0",
"ember-disable-proxy-controllers": "^0.7.0",
"ember-export-application-global": "^1.0.2",
"ember-try": "0.0.4"
"ember-cli-sass": "^5.5.1",
"broccoli-asset-rev": "^2.2.0",
"ember-cli": "2.3.0",
"ember-cli-app-version": "^1.0.0",
"ember-cli-dependency-checker": "^1.2.0",
"ember-cli-htmlbars": "^1.0.1",
"ember-cli-htmlbars-inline-precompile": "^0.3.1",
"ember-cli-inject-live-reload": "^1.3.1",
"ember-cli-qunit": "^1.2.1",
"ember-cli-release": "0.2.8",
"ember-cli-sri": "^2.0.0",
"ember-cli-uglify": "^1.2.0",
"ember-disable-prototype-extensions": "^1.1.0",
"ember-disable-proxy-controllers": "^1.0.1",
"ember-export-application-global": "^1.0.4",
"ember-load-initializers": "^0.5.0",
"ember-resolver": "^2.0.3",
"ember-try": "^0.1.2",
"loader.js": "^4.0.0"
},
"keywords": [
"ember-addon",
Expand All @@ -50,8 +56,8 @@
"split panel"
],
"dependencies": {
"ember-cli-babel": "^5.0.0",
"ember-cli-htmlbars": "^0.7.6"
"ember-cli-babel": "^5.1.5",
"ember-cli-htmlbars": "^1.0.3"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down
5 changes: 3 additions & 2 deletions tests/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"node": false,
"browser": false,
"boss": true,
"curly": false,
"curly": true,
"debug": false,
"devel": false,
"eqeqeq": true,
Expand All @@ -47,5 +47,6 @@
"strict": false,
"white": false,
"eqnull": true,
"esnext": true
"esnext": true,
"unused": true
}
Loading