Permalink
Browse files

add greeting to the top of the demo with a bookmarklet

  • Loading branch information...
1 parent 360a421 commit 98dd7c9ab01be9ef67b2dab237f71fe3a74f70ff @misfo committed Sep 12, 2011
Showing with 67 additions and 1 deletion.
  1. +49 −1 index.html
  2. +18 −0 vendor/jquery-1.6.2.min.js
View
@@ -5,19 +5,33 @@
<style type="text/css" media="screen">
body {
overflow: hidden;
+ background: #E8E8E8;
+ }
+
+ #greeting {
+ font-family: Helvetica, Arial, sans-serif, Tahoma, Verdana, sans-serif;
+ font-size: 12px;
+ white-space: nowrap;
+ }
+
+ #greeting a {
+ color: #8F9D6A;
}
#editor {
margin: 0;
position: absolute;
- top: 0;
+ top: 30px;
bottom: 0;
left: 0;
right: 0;
}
</style>
</head>
<body>
+ <p id="greeting">
+ This a Vim mode for <a href="https://github.com/ajaxorg/ace">Ace</a> powered by <a href="https://github.com/misfo/jim">Jim</a>. To use Jim in Github's editor, drag this bookmarklet to your bookmarks bar: <a href="#" id="bookmarklet">Please wait...</a>
+ </p>
<div id="container">
<pre id="editor">
@@ -60,5 +74,39 @@
jim.debugMode = true;
};
</script>
+
+ <script src="vendor/jquery-1.6.2.min.js"></script>
+
+ <script>
+ $(function() {
+ var insertBookmarklet = function(minifiedJs) {
+ // remove the comment lines
+ var lines = minifiedJs.split('\n'),
+ minifiedJs = lines[lines.length - 1],
+ afterJim = $('#after_jim').text().replace(/\s+/g, ' ');
+
+ $('#bookmarklet')
+ .attr('href', 'javascript:' + minifiedJs + ';' + afterJim)
+ .html('Jimmy rig');
+ };
+
+ $.get('build/jim-ace.min.js', null, insertBookmarklet, 'text');
+ });
+ </script>
+
+ <script type="text/dontexecute" id="after_jim">
+ var aceElements = document.getElementsByClassName('ace_editor'),
+ length = aceElements.length,
+ signature = '\n\nLove,\nJim\nv' + Jim.VERSION;
+
+ for (var i = 0; i < length; i++)
+ Jim.aceInit(aceElements[i].env ? aceElements[i].env.editor : aceElements[i].host.$editor);
+
+ alert(
+ length
+ ? ('Jimmy rigged ' + length + ' editor(s)' + signature)
+ : ('No ace editors to Jimmy rig!' + signature)
+ );
+ </script>
</body>
</html>
Oops, something went wrong.

0 comments on commit 98dd7c9

Please sign in to comment.