update package

This commit is contained in:
Fabian Jakobs 2011-02-15 18:50:09 +01:00
commit 6992efd692
3 changed files with 109 additions and 65 deletions

View file

@ -7,6 +7,25 @@
</head>
<body>
<h1>Ace Bookmarklet Builder</h1>
<p>
WARNING: Currently, this is only fully supported in non IE browsers.
</p>
<p>
How to use it:
<ul>
<li>Select the options below as you want them to be by default.</li>
<li>Enter the "SourceUrl" where you placed the source data which you find under build/textarea/src (you can also leave the default to server the scripts from GitHub).</li>
<li>Click the "Build Link" button to generate your custom Ace Bookmarklet.</li>
<li>Drag the generated link to your toolbar or store it somewhere else.</li>
<li>Go to a page with an textarea element and click the bookmarklet - wait a little bit till the files are loaded.</li>
<li>Click 3 times on the textarea you want to replace - Ace will replace it.</li>
<li>To change settings, just click the red icon in the bottom right corner.</li>
</ul>
</p>
<textarea id="textarea" style="width:300px; height:300px">
function foo() {
var bar = true;
@ -14,12 +33,12 @@
</textarea><br>
SourceUrl: <input id="srcURL" value="http://ajaxorg.github.com/ace/build/textarea/src/"></input>
<button id="buBuild">Build link</button> <br> <a href="#"></a>
<button id="buBuild">Build Link</button> <br> <a href="#"></a>
<script>
function inject() {
var baseUrl = "src/";
var load = function(path, callback) {
function load(path, module, callback) {
path = baseUrl + path;
if (!load.scripts[path]) {
load.scripts[path] = {
@ -29,14 +48,21 @@ function inject() {
var head = document.getElementsByTagName('head')[0];
var s = document.createElement('script');
s.onload = function() {
load.scripts[path].loaded = true;
load.scripts[path].callbacks.forEach(function(callback) {
callback();
});
function c() {
if (window.__ace_shadowed__ && window.__ace_shadowed__.define.modules[module]) {
load.scripts[path].loaded = true;
load.scripts[path].callbacks.forEach(function(callback) {
callback();
});
} else {
setTimeout(c, 50);
}
};
s.src = path;
head.appendChild(s);
c();
} else if (load.scripts[path].loaded) {
callback();
} else {
@ -45,18 +71,18 @@ function inject() {
};
load.scripts = {};
window.__ace_shadowed_load__ = load;
load('ace.js', function() {
load('ace.js', 'text!ace/css/editor.css', function() {
var ace = window.__ace_shadowed__;
ace.load = load;
ace.options.mode = "javascript";
var areas = document.querySelectorAll("textarea");
var Event = ace.require('pilot/event');
var areas = document.getElementsByTagName("textarea");
for (var i = 0; i < areas.length; i++) {
areas[i].addEventListener("click", function(e) {
Event.addListener(areas[i], "click", function(e) {
if (e.detail == 3) {
ace.transformTextarea(e.target);
}
}, false);
});
}
});
}