Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7 from enyojs/ENYO-662-kevinpschaaf

ENYO-662, ENYO-660: Handle wrap/nowrap with CSS whitespace, and add IE8 ...

Reviewed-By: Ben Combee (ben.combee@palm.com)
  • Loading branch information...
commit 32bd55d8213908a44a5c27714474b2c9c065aaeb 2 parents b4a1638 + 5db880a
@unwiredben unwiredben authored
Showing with 33 additions and 5 deletions.
  1. +1 −1  source/App.css
  2. +32 −4 source/App.js
View
2  source/App.css
@@ -75,7 +75,7 @@ button {
}
.nowrap {
- width:2000px;
+ white-space: pre;
}
.wrap-label {
View
36 source/App.js
@@ -23,10 +23,10 @@ enyo.kind({
{kind: "FittableRows", classes:"wide onyx", components: [
{kind: "Panels", name:"sourcePanels", fit:true, draggable:false, components: [
{kind: "Scroller", classes:"enyo-fit scroller", components: [
- {name:"sourceContent", classes:"source nowrap enyo-selectable"}
+ {kind:"SourceView", name:"sourceContent"}
]},
{kind: "Scroller", classes:"enyo-fit scroller", components: [
- {name:"cssContent", classes:"source nowrap enyo-selectable"}
+ {kind:"SourceView", name:"cssContent"}
]}
]},
{kind:"onyx.Toolbar", layoutKind: "FittableColumnsLayout", classes:"footer-toolbar", noStretch:true, components: [
@@ -290,8 +290,8 @@ enyo.kind({
}
},
wrapChanged: function(inSender, inEvent) {
- this.$.sourceContent.addRemoveClass("nowrap", !inSender.getValue());
- this.$.cssContent.addRemoveClass("nowrap", !inSender.getValue());
+ this.$.sourceContent.setWrap(inSender.getValue());
+ this.$.cssContent.setWrap(inSender.getValue());
},
getHashComponentName: function() {
return window.location.hash.slice(1);
@@ -340,6 +340,34 @@ enyo.kind({
});
enyo.kind({
+ name: "SourceView",
+ kind: "Control",
+ tag: "pre",
+ classes: "source enyo-selectable",
+ published: {
+ wrap: false
+ },
+ create: function() {
+ this.inherited(arguments);
+ this.wrapChanged();
+ },
+ // IE8 normalizes whitespace when setting innerHTML even in <pre> tags, so appending
+ // text nodes into the pre works around it (http://stackoverflow.com/a/195385)
+ contentChanged: function(inOld) {
+ var node = this.hasNode();
+ if (node) {
+ while(node.hasChildNodes()) {
+ node.removeChild(node.firstChild);
+ }
+ node.appendChild(document.createTextNode(this.content));
+ }
+ },
+ wrapChanged: function(inOld) {
+ this.addRemoveClass("nowrap", !this.wrap);
+ }
+});
+
+enyo.kind({
name: "ViewStack",
kind: "Panels",
arrangerKind: "CarouselArranger",
Please sign in to comment.
Something went wrong with that request. Please try again.