Skip to content

Commit

Permalink
remove textarea build
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Jun 19, 2014
1 parent 966bcd1 commit 59a2005
Show file tree
Hide file tree
Showing 293 changed files with 34 additions and 137,319 deletions.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
69 changes: 33 additions & 36 deletions textarea/editor.html → demo/bookmarklet/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
var bar = true;
}</textarea><br>
SourceUrl: <br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/textarea/src/"></input><br>
<input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
<a href="https://github.com/ajaxorg/ace/">
<div class="fork_on_github" ></div>
Expand Down Expand Up @@ -49,63 +49,60 @@ <h2>How to use it:</h2>

<script>

function inject(callback) {
var baseUrl = "src/";
function inject(options, callback) {
var baseUrl = options.baseUrl || "../../src-noconflict";

var load = window.__ace_loader__ = function(path, module, callback) {
var load = function(path, callback) {
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.src = baseUrl + path;

s.src = baseUrl + "/" + path;
head.appendChild(s);

s.onload = function() {
window.__ace_shadowed__.require([module], callback);

s.onload = s.onreadystatechange = function(_, isAbort) {
if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
s = s.onload = s.onreadystatechange = null;
if (!isAbort)
callback();
}
};
};

load('ace-bookmarklet.js', "ace/ext/textarea", function() {
var ace = window.__ace_shadowed__;

ace.options.mode = "javascript";
var Event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) {
Event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) {
ace.transformTextarea(e.target, load);
}
});
}
callback && callback();
load("ace.js", function() {
ace.config.loadModule("ace/ext/textarea", function() {
var event = ace.require("ace/lib/event");
var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) {
event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) {
ace.transformTextarea(e.target, options.ace);
}
});
}
callback && callback();
});
});
}

// Call the inject function to load the ace files.
var textAce;
inject(function () {
// Transform the textarea on the page into an ace editor.
var ace = window.__ace_shadowed__;
inject({}, function () {
// Transform the textarea on the page into an ace editor.
var t = document.querySelector("textarea");
textAce = ace.transformTextarea(t, window.__ace_loader__);
textAce = ace.require("ace/ext/textarea").transformTextarea(t);
setTimeout(function(){textAce.setDisplaySettings(true)});
});


document.getElementById("buBuild").onclick = function() {
var injectSrc = inject.toString().split("\n").join("");
injectSrc = injectSrc.replace('baseUrl = "src/"', 'baseUrl="' + document.getElementById("srcURL").value + '"');

var aceOptions = textAce.getOptions();
var opt = [];
for (var option in aceOptions) {
opt.push(option + ":'" + aceOptions[option] + "'");
}
injectSrc = injectSrc.replace('ace.options.mode = "javascript"', 'ace.options = { ' + opt.join(",") + ' }');
injectSrc = injectSrc.replace(/\s+/g, " ");

var options = textAce.getOptions();
options.baseUrl = document.getElementById("srcURL").value;

var a = document.querySelector("a");
a.href = "javascript:(" + injectSrc + ")()";
a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
a.innerHTML = "Ace Bookmarklet Link";
}

Expand Down
2 changes: 0 additions & 2 deletions textarea/style.css → demo/bookmarklet/style.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono);

body {
margin:0;
padding:0;
Expand Down
Loading

0 comments on commit 59a2005

Please sign in to comment.