fix textarea build

Conflicts:

	Makefile.dryice.js
This commit is contained in:
nightwing 2012-05-20 22:28:25 +04:00
commit cf23198610
4 changed files with 138 additions and 107 deletions

View file

@ -9,6 +9,7 @@
<body> <body>
<div id="wrapper"> <div id="wrapper">
<div class="content" style="width: 950px"> <div class="content" style="width: 950px">
<div class="column1" style="margin-top: 47px"> <div class="column1" style="margin-top: 47px">
<textarea id="textarea" style="width:300px; height:300px"> <textarea id="textarea" style="width:300px; height:300px">
@ -19,8 +20,11 @@ function foo() {
var bar = true; var bar = true;
}</textarea><br> }</textarea><br>
SourceUrl: <br> SourceUrl: <br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace/build/textarea/src/"></input><br> <input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
<button id="buBuild">Build Link</button> <br> <a href="#"></a> <button id="buBuild">Build Link</button> <br> <a href="#"></a>
<a href="https://github.com/ajaxorg/ace/">
<div class="fork_on_github" ></div>
</a>
</div> </div>
<div class="column2"> <div class="column2">
<h1>Ace Bookmarklet Builder</h1> <h1>Ace Bookmarklet Builder</h1>
@ -73,7 +77,7 @@ function inject(callback) {
} }
}); });
} }
callback(); callback && callback();
}); });
} }

View file

@ -74,7 +74,6 @@ PRE{
.content { .content {
width:970px; width:970px;
position:relative; position:relative;
overflow:hidden;
margin:0 auto; margin:0 auto;
} }
@ -115,7 +114,6 @@ PRE{
#wrapper .content .column1 { #wrapper .content .column1 {
position:relative; position:relative;
overflow:hidden;
float:left; float:left;
width:315px; width:315px;
margin-right:31px; margin-right:31px;

View file

@ -61,13 +61,12 @@ var Anchor = require("./anchor").Anchor;
var Document = function(text) { var Document = function(text) {
this.$lines = []; this.$lines = [];
if (Array.isArray(text)) {
this.insertLines(0, text);
}
// There has to be one line at least in the document. If you pass an empty // There has to be one line at least in the document. If you pass an empty
// string to the insert function, nothing will happen. Workaround. // string to the insert function, nothing will happen. Workaround.
else if (text.length == 0) { if (text.length == 0) {
this.$lines = [""]; this.$lines = [""];
} else if (Array.isArray(text)) {
this.insertLines(0, text);
} else { } else {
this.insert({row: 0, column:0}, text); this.insert({row: 0, column:0}, text);
} }

View file

@ -21,6 +21,7 @@
* Contributor(s): * Contributor(s):
* Kevin Dangoor (kdangoor@mozilla.com) * Kevin Dangoor (kdangoor@mozilla.com)
* Julian Viereck <julian.viereck@gmail.com> * Julian Viereck <julian.viereck@gmail.com>
* Harutyun Amirjanyan [harutyun@c9.io]
* *
* Alternatively, the contents of this file may be used under the terms of * Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or * either the GNU General Public License Version 2 or later (the "GPL"), or
@ -39,20 +40,22 @@
define(function(require, exports, module) { define(function(require, exports, module) {
"use strict"; "use strict";
var Event = require("../lib/event"); var event = require("../lib/event");
var UA = require("../lib/useragent"); var UA = require("../lib/useragent");
var net = require("../lib/net"); var net = require("../lib/net");
var ace = require("../ace"); var ace = require("../ace");
require("ace/theme/textmate"); require("ace/theme/textmate");
module.exports = exports = ace;
/* /*
* Returns the CSS property of element. * Returns the CSS property of element.
* 1) If the CSS property is on the style object of the element, use it, OR * 1) If the CSS property is on the style object of the element, use it, OR
* 2) Compute the CSS property * 2) Compute the CSS property
* *
* If the property can't get computed, is 'auto' or 'intrinsic', the former * If the property can't get computed, is 'auto' or 'intrinsic', the former
* calculated property is uesd (this can happen in cases where the textarea * calculated property is used (this can happen in cases where the textarea
* is hidden and has no dimension styles). * is hidden and has no dimension styles).
*/ */
var getCSSProperty = function(element, container, property) { var getCSSProperty = function(element, container, property) {
@ -131,7 +134,7 @@ function setupContainer(element, getValue) {
style += 'display:inline-block;'; style += 'display:inline-block;';
container.setAttribute('style', style); container.setAttribute('style', style);
}; };
Event.addListener(window, 'resize', resizeEvent); event.addListener(window, 'resize', resizeEvent);
// Call the resizeEvent once, so that the size of the container is // Call the resizeEvent once, so that the size of the container is
// calculated. // calculated.
@ -194,11 +197,13 @@ exports.transformTextarea = function(element, loader) {
right: "0px", right: "0px",
bottom: "0px", bottom: "0px",
background: "red", background: "red",
cursor: "pointer", cursor: "nw-resize",
textAlign: "center", borderStyle: "solid",
fontSize: "12px" borderWidth: "9px 8px 10px 9px",
width: "2px",
borderColor: "lightblue gray gray lightblue",
zIndex: 101
}); });
settingOpener.innerHTML = "I";
var settingDiv = document.createElement("div"); var settingDiv = document.createElement("div");
var settingDivStyles = { var settingDivStyles = {
@ -236,12 +241,41 @@ exports.transformTextarea = function(element, loader) {
editorDiv.appendChild(settingOpener); editorDiv.appendChild(settingOpener);
// Create the API. // Create the API.
var api = setupApi(editor, editorDiv, settingDiv, ace, options, loader); setupApi(editor, editorDiv, settingDiv, ace, options, loader);
// Create the setting's panel. // Create the setting's panel.
setupSettingPanel(settingDiv, settingOpener, api, options); setupSettingPanel(settingDiv, settingOpener, editor, options);
return api; var state = "";
event.addListener(settingOpener, "mousemove", function(e) {
var rect = this.getBoundingClientRect();
var x = e.clientX - rect.left, y = e.clientY - rect.top;
if (x + y < (rect.width + rect.height)/2) {
this.style.cursor = "pointer";
state = "toggle";
} else {
state = "resize";
this.style.cursor = "nw-resize";
}
});
event.addListener(settingOpener, "mousedown", function(e) {
if (state == "toggle") {
editor.setDisplaySettings();
return;
}
container.style.zIndex = 100000;
var rect = container.getBoundingClientRect();
var startX = rect.width + rect.left - e.clientX;
var startY = rect.height + rect.top - e.clientY;
event.capture(settingOpener, function(e) {
container.style.width = e.clientX - rect.left + startX + "px";
container.style.height = e.clientY - rect.top + startY + "px";
editor.resize();
}, function() {});
});
return editor;
}; };
function load(url, module, callback) { function load(url, module, callback) {
@ -259,103 +293,103 @@ function setupApi(editor, editorDiv, settingDiv, ace, options, loader) {
return value == "true"; return value == "true";
} }
var ret = { editor.setDisplaySettings = function(display) {
setDisplaySettings: function(display) { if (display == null)
settingDiv.style.display = display ? "block" : "none"; display = settingDiv.style.display == "none";
}, settingDiv.style.display = display ? "block" : "none";
};
setOption: function(key, value) { editor.setOption = function(key, value) {
if (options[key] == value) return; if (options[key] == value) return;
switch (key) { switch (key) {
case "gutter": case "gutter":
renderer.setShowGutter(toBool(value)); renderer.setShowGutter(toBool(value));
break; break;
case "mode": case "mode":
if (value != "text") { if (value != "text") {
// Load the required mode file. Files get loaded only once. // Load the required mode file. Files get loaded only once.
loader("mode-" + value + ".js", "ace/mode/" + value, function() { loader("mode-" + value + ".js", "ace/mode/" + value, function() {
var aceMode = require("../mode/" + value).Mode; var aceMode = require("../mode/" + value).Mode;
session.setMode(new aceMode()); session.setMode(new aceMode());
}); });
} else { } else {
session.setMode(new (require("../mode/text").Mode)); session.setMode(new (require("../mode/text").Mode));
} }
break; break;
case "theme": case "theme":
if (value != "textmate") { if (value != "textmate") {
// Load the required theme file. Files get loaded only once. // Load the required theme file. Files get loaded only once.
loader("theme-" + value + ".js", "ace/theme/" + value, function() { loader("theme-" + value + ".js", "ace/theme/" + value, function() {
editor.setTheme("ace/theme/" + value); editor.setTheme("ace/theme/" + value);
}); });
} else { } else {
editor.setTheme("ace/theme/textmate"); editor.setTheme("ace/theme/textmate");
} }
break; break;
case "fontSize": case "fontSize":
editorDiv.style.fontSize = value; editorDiv.style.fontSize = value;
break; break;
case "softWrap": case "softWrap":
switch (value) { switch (value) {
case "off": case "off":
session.setUseWrapMode(false); session.setUseWrapMode(false);
renderer.setPrintMarginColumn(80); renderer.setPrintMarginColumn(80);
break; break;
case "40": case "40":
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimitRange(40, 40); session.setWrapLimitRange(40, 40);
renderer.setPrintMarginColumn(40); renderer.setPrintMarginColumn(40);
break; break;
case "80": case "80":
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimitRange(80, 80); session.setWrapLimitRange(80, 80);
renderer.setPrintMarginColumn(80); renderer.setPrintMarginColumn(80);
break; break;
case "free": case "free":
session.setUseWrapMode(true); session.setUseWrapMode(true);
session.setWrapLimitRange(null, null); session.setWrapLimitRange(null, null);
renderer.setPrintMarginColumn(80); renderer.setPrintMarginColumn(80);
break; break;
} }
break; break;
case "useSoftTabs": case "useSoftTabs":
session.setUseSoftTabs(toBool(value)); session.setUseSoftTabs(toBool(value));
break; break;
case "showPrintMargin": case "showPrintMargin":
renderer.setShowPrintMargin(toBool(value)); renderer.setShowPrintMargin(toBool(value));
break; break;
case "showInvisibles": case "showInvisibles":
editor.setShowInvisibles(toBool(value)); editor.setShowInvisibles(toBool(value));
break; break;
}
options[key] = value;
},
getOption: function(key) {
return options[key];
},
getOptions: function() {
return options;
} }
options[key] = value;
};
editor.getOption = function(key) {
return options[key];
};
editor.getOptions = function() {
return options;
}; };
for (var option in exports.options) { for (var option in exports.options) {
ret.setOption(option, exports.options[option]); editor.setOption(option, exports.options[option]);
} }
return ret; return editor;
} }
function setupSettingPanel(settingDiv, settingOpener, api, options) { function setupSettingPanel(settingDiv, settingOpener, editor, options) {
var BOOL = { var BOOL = {
"true": true, "true": true,
"false": false "false": false
@ -472,7 +506,7 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
return function() { return function() {
var option = select.title; var option = select.title;
var value = select.value; var value = select.value;
api.setOption(option, value); editor.setOption(option, value);
}; };
})(); })();
selects[i].onchange = onChange; selects[i].onchange = onChange;
@ -481,14 +515,10 @@ function setupSettingPanel(settingDiv, settingOpener, api, options) {
var button = document.createElement("input"); var button = document.createElement("input");
button.type = "button"; button.type = "button";
button.value = "Hide"; button.value = "Hide";
button.onclick = function() { event.addListener(button, "click", function() {
api.setDisplaySettings(false); editor.setDisplaySettings(false);
}; });
settingDiv.appendChild(button); settingDiv.appendChild(button);
settingOpener.onclick = function() {
api.setDisplaySettings(true);
};
} }
// Default startup options. // Default startup options.