-
Notifications
You must be signed in to change notification settings - Fork 382
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* #7274: [java] add Foldout widget * #7325: Remove the text "Downloaded: " from the progress. * #7274 add Foldout widget * #7274 Foldout js widget implementation * #7274: add header to foldout * #7274 fix lab missing FoldoutModel
- Loading branch information
1 parent
018fed9
commit a19c307
Showing
17 changed files
with
249 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const widgets = require('./widgets'); | ||
const DEFAULT_LABEL_TEXT = 'Output'; | ||
const DEFAULT_CONTENT_PADDING = 14; | ||
const DEFAULT_CONTENT_MIN_LINE_HEIGHT = 16; | ||
const ANIMATION_DURATION = 500; | ||
|
||
class FoldoutModel extends widgets.HTMLModel { | ||
defaults() { | ||
return { | ||
...super.defaults(), | ||
_view_name: "FoldoutView", | ||
_model_name: "FoldoutModel", | ||
_model_module: 'beakerx', | ||
_view_module: 'beakerx', | ||
_model_module_version: BEAKERX_MODULE_VERSION, | ||
_view_module_version: BEAKERX_MODULE_VERSION | ||
}; | ||
} | ||
} | ||
|
||
class FoldoutView extends widgets.HTMLView { | ||
render() { | ||
super.render(); | ||
|
||
let active = false; | ||
let hiddenContainer: HTMLElement = document.createElement('div'); | ||
let minHeight = 2 * DEFAULT_CONTENT_PADDING + DEFAULT_CONTENT_MIN_LINE_HEIGHT; | ||
let timeoutId; | ||
|
||
hiddenContainer.innerHTML = this.content.outerHTML; | ||
let original = hiddenContainer.firstChild as HTMLElement; | ||
|
||
hiddenContainer.style.visibility = 'hidden'; | ||
hiddenContainer.style.position = 'fixed'; | ||
hiddenContainer.style.zIndex = '-1'; | ||
original.style.whiteSpace = 'normal'; | ||
original.style.height = 'auto'; | ||
|
||
this.el.classList.add('foldout-widget'); | ||
this.el.appendChild(hiddenContainer); | ||
|
||
this.content.style.whiteSpace = 'nowrap'; | ||
|
||
if (!this.label.innerText) { | ||
this.label.innerText = DEFAULT_LABEL_TEXT; | ||
this.label.style.display = 'block' | ||
} | ||
|
||
this.label.addEventListener('click', () => { | ||
clearTimeout(timeoutId); | ||
active = !active; | ||
this.el.classList.toggle('active', active); | ||
|
||
if (active) { | ||
hiddenContainer.style.width = `${this.el.clientWidth}px`; | ||
this.content.style.whiteSpace = 'normal'; | ||
this.content.style.height = `${ original.clientHeight }px`; | ||
} else { | ||
this.content.style.height = `${minHeight}px`; | ||
timeoutId = setTimeout( | ||
() => { this.content.style.whiteSpace = 'nowrap'; }, | ||
ANIMATION_DURATION | ||
); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export default { | ||
FoldoutModel, | ||
FoldoutView | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
kernel/base/src/main/java/com/twosigma/beakerx/widget/Foldout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2018 TWO SIGMA OPEN SOURCE, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.twosigma.beakerx.widget; | ||
|
||
import com.twosigma.beakerx.message.Message; | ||
|
||
public class Foldout extends StringWidget { | ||
|
||
public static final String VIEW_NAME_VALUE = "FoldoutView"; | ||
public static final String MODEL_NAME_VALUE = "FoldoutModel"; | ||
|
||
public Foldout(Message parent) { | ||
super(); | ||
openComm(parent); | ||
} | ||
|
||
@Override | ||
public String getModelNameValue() { | ||
return MODEL_NAME_VALUE; | ||
} | ||
|
||
@Override | ||
public String getViewNameValue() { | ||
return VIEW_NAME_VALUE; | ||
} | ||
|
||
@Override | ||
public String getModelModuleValue() { | ||
return BeakerxWidget.MODEL_MODULE_VALUE; | ||
} | ||
|
||
@Override | ||
public String getViewModuleValue() { | ||
return BeakerxWidget.VIEW_MODULE_VALUE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.