Working line number support - just waiting on a final color from @bridawson
[#5]
This commit is contained in:
parent
49bb449141
commit
3a6b36ebaa
4 changed files with 41 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
|||
body {
|
||||
background: #002B36;
|
||||
padding: 20px;
|
||||
padding: 20px 50px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,20 @@ textarea {
|
|||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* the line numbers */
|
||||
|
||||
#linenos {
|
||||
color: #003366;
|
||||
z-index: -1000;
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 0px;
|
||||
width: 30px; /* 30 to get 20 away from box */
|
||||
font-size: 13px;
|
||||
font-family: monospace;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* code box when locked */
|
||||
|
||||
#box {
|
||||
|
@ -27,6 +41,7 @@ textarea {
|
|||
width: 100%;
|
||||
border: 0px;
|
||||
outline: none;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
#box code {
|
||||
|
|
|
@ -32,7 +32,8 @@ haste_document.prototype.load = function(key, callback, lang) {
|
|||
callback({
|
||||
value: high.value,
|
||||
key: key,
|
||||
language: high.language || lang
|
||||
language: high.language || lang,
|
||||
lineCount: res.data.split("\n").length
|
||||
});
|
||||
},
|
||||
error: function(err) {
|
||||
|
@ -59,7 +60,8 @@ haste_document.prototype.save = function(data, callback) {
|
|||
callback({
|
||||
value: high.value,
|
||||
key: res.key,
|
||||
language: high.language
|
||||
language: high.language,
|
||||
lineCount: data.split("\n").length
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -73,6 +75,7 @@ var haste = function(appName, options) {
|
|||
this.$textarea = $('textarea');
|
||||
this.$box = $('#box');
|
||||
this.$code = $('#box code');
|
||||
this.$linenos = $('#linenos');
|
||||
this.options = options;
|
||||
this.configureShortcuts();
|
||||
this.configureButtons();
|
||||
|
@ -126,6 +129,7 @@ haste.prototype.newDocument = function(hideHistory) {
|
|||
this.$textarea.val('').show('fast', function() {
|
||||
this.focus();
|
||||
});
|
||||
this.removeLineNumbers();
|
||||
};
|
||||
|
||||
// Map of common extensions
|
||||
|
@ -156,6 +160,21 @@ haste.prototype.lookupTypeByExtension = function(ext) {
|
|||
return haste.extensionMap[ext] || ext;
|
||||
};
|
||||
|
||||
// Add line numbers to the document
|
||||
// For the specified number of lines
|
||||
haste.prototype.addLineNumbers = function(lineCount) {
|
||||
var h = '';
|
||||
for (var i = 0; i < lineCount; i++) {
|
||||
h += (i + 1).toString() + '<br/>';
|
||||
}
|
||||
$('#linenos').html(h);
|
||||
};
|
||||
|
||||
// Remove the line numbers
|
||||
haste.prototype.removeLineNumbers = function() {
|
||||
$('#linenos').html('>');
|
||||
};
|
||||
|
||||
// Load a document and show it
|
||||
haste.prototype.loadDocument = function(key) {
|
||||
// Split the key up
|
||||
|
@ -170,6 +189,7 @@ haste.prototype.loadDocument = function(key) {
|
|||
_this.fullKey();
|
||||
_this.$textarea.val('').hide();
|
||||
_this.$box.show().focus();
|
||||
_this.addLineNumbers(ret.lineCount);
|
||||
}
|
||||
else {
|
||||
_this.newDocument();
|
||||
|
@ -201,6 +221,7 @@ haste.prototype.lockDocument = function() {
|
|||
_this.fullKey();
|
||||
_this.$textarea.val('').hide();
|
||||
_this.$box.show().focus();
|
||||
_this.addLineNumbers(ret.lineCount);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
2
static/application.min.js
vendored
2
static/application.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -57,6 +57,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div id="linenos"></div>
|
||||
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
|
||||
<textarea spellcheck="false" style="display:none;"></textarea>
|
||||
|
||||
|
|
Loading…
Reference in a new issue