better CSS class handling
This commit is contained in:
parent
99ad78d13c
commit
09a09e8ac2
5 changed files with 34 additions and 9 deletions
|
|
@ -15,14 +15,14 @@
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor .scrollbar {
|
.editor .sb {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor .scrollbar div {
|
.editor .sb div {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 1px;
|
width: 1px;
|
||||||
left: -10px;
|
left: -10px;
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
<input type="checkbox" name="highlight_active" id="highlight_active" checked>
|
||||||
</td>
|
</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<img src="logo.png"></img>
|
<img src="logo.png">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ ace.ScrollBar = function(parent) {
|
||||||
this.$initEvents();
|
this.$initEvents();
|
||||||
|
|
||||||
this.element = document.createElement("div");
|
this.element = document.createElement("div");
|
||||||
this.element.className = "scrollbar";
|
this.element.className = "sb";
|
||||||
|
|
||||||
this.inner = document.createElement("div");
|
this.inner = document.createElement("div");
|
||||||
this.element.appendChild(this.inner);
|
this.element.appendChild(this.inner);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ ace.provide("ace.VirtualRenderer");
|
||||||
|
|
||||||
ace.VirtualRenderer = function(container) {
|
ace.VirtualRenderer = function(container) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.container.className += " editor";
|
ace.addCssClass(this.container, "editor");
|
||||||
|
|
||||||
this.scroller = document.createElement("div");
|
this.scroller = document.createElement("div");
|
||||||
this.scroller.className = "scroller";
|
this.scroller.className = "scroller";
|
||||||
|
|
@ -233,11 +233,11 @@ ace.VirtualRenderer.prototype.screenToTextCoordinates = function(pageX, pageY) {
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.VirtualRenderer.prototype.visualizeFocus = function() {
|
ace.VirtualRenderer.prototype.visualizeFocus = function() {
|
||||||
//this.container.className = "editor focus";
|
ace.addCssClass(this.container, "focus");
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.VirtualRenderer.prototype.visualizeBlur = function() {
|
ace.VirtualRenderer.prototype.visualizeBlur = function() {
|
||||||
//this.container.className = "editor";
|
ace.removeCssClass(this.container, "focus");
|
||||||
};
|
};
|
||||||
|
|
||||||
ace.VirtualRenderer.prototype.showComposition = function(position) {
|
ace.VirtualRenderer.prototype.showComposition = function(position) {
|
||||||
|
|
|
||||||
25
src/ace.js
25
src/ace.js
|
|
@ -78,6 +78,31 @@ ace.preventDefault = function(e) {
|
||||||
e.returnValue = false;
|
e.returnValue = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ace.hasCssClass = function(el, name) {
|
||||||
|
var classes = el.className.split(/\s*/g);
|
||||||
|
return ace.arrayIndexOf(classes, name) !== -1;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
ace.addCssClass = function(el, name) {
|
||||||
|
if (!ace.hasCssClass(el, name)) {
|
||||||
|
el.className += " " + name;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ace.removeCssClass = function(el, name) {
|
||||||
|
var classes = el.className.split(/\s+/g);
|
||||||
|
while (true) {
|
||||||
|
var index = ace.arrayIndexOf(classes, name);
|
||||||
|
if (index == -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
classes.splice(index, 1);
|
||||||
|
}
|
||||||
|
el.className = classes.join(" ");
|
||||||
|
};
|
||||||
|
|
||||||
ace.getInnerWidth = function(element) {
|
ace.getInnerWidth = function(element) {
|
||||||
return (parseInt(ace.computedStyle(element, "paddingLeft"))
|
return (parseInt(ace.computedStyle(element, "paddingLeft"))
|
||||||
+ parseInt(ace.computedStyle(element, "paddingRight")) + element.clientWidth);
|
+ parseInt(ace.computedStyle(element, "paddingRight")) + element.clientWidth);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue