mirror of
https://github.com/SunRed/haste-server.git
synced 2024-11-23 17:50:19 +01:00
Fixes for Firefox
This commit is contained in:
parent
9638baffdb
commit
9fa99fe69d
4 changed files with 31 additions and 17 deletions
3
TODO
3
TODO
|
@ -4,6 +4,9 @@ test in other browsers and add note to README
|
||||||
maximum size of a haste
|
maximum size of a haste
|
||||||
fix any annoying visual quirks
|
fix any annoying visual quirks
|
||||||
add FAVICON
|
add FAVICON
|
||||||
|
cache static in memory
|
||||||
|
bug in ^n while editing
|
||||||
|
|
||||||
# shared version only
|
# shared version only
|
||||||
some way to do announcements easily (and use for ads)
|
some way to do announcements easily (and use for ads)
|
||||||
|
copy URL to clipboard button
|
||||||
|
|
|
@ -19,6 +19,7 @@ textarea {
|
||||||
|
|
||||||
#box {
|
#box {
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ var haste = function(appName, options) {
|
||||||
this.$textarea = $('textarea');
|
this.$textarea = $('textarea');
|
||||||
this.$box = $('#box');
|
this.$box = $('#box');
|
||||||
this.$code = $('#box code');
|
this.$code = $('#box code');
|
||||||
this.configureShortcuts();
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
this.configureShortcuts();
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the page title - include the appName
|
// Set the page title - include the appName
|
||||||
|
@ -120,7 +120,7 @@ haste.prototype.loadDocument = function(key) {
|
||||||
_this.setTitle(title);
|
_this.setTitle(title);
|
||||||
_this.fullKey();
|
_this.fullKey();
|
||||||
_this.$textarea.val('').hide();
|
_this.$textarea.val('').hide();
|
||||||
_this.$box.show();
|
_this.$box.show().focus();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_this.newDocument();
|
_this.newDocument();
|
||||||
|
@ -151,7 +151,7 @@ haste.prototype.lockDocument = function() {
|
||||||
_this.fullKey();
|
_this.fullKey();
|
||||||
window.history.pushState(null, _this.appName + '-' + ret.key, '/' + ret.key);
|
window.history.pushState(null, _this.appName + '-' + ret.key, '/' + ret.key);
|
||||||
_this.$textarea.val('').hide();
|
_this.$textarea.val('').hide();
|
||||||
_this.$box.show();
|
_this.$box.show().focus();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -159,7 +159,7 @@ haste.prototype.lockDocument = function() {
|
||||||
// Configure keyboard shortcuts for the textarea
|
// Configure keyboard shortcuts for the textarea
|
||||||
haste.prototype.configureShortcuts = function() {
|
haste.prototype.configureShortcuts = function() {
|
||||||
var _this = this;
|
var _this = this;
|
||||||
$('body').keydown(function(evt) {
|
$(document.body).keydown(function(evt) {
|
||||||
// ^L or ^S for lock
|
// ^L or ^S for lock
|
||||||
if (evt.ctrlKey && (evt.keyCode === 76 || evt.keyCode === 83)) {
|
if (evt.ctrlKey && (evt.keyCode === 76 || evt.keyCode === 83)) {
|
||||||
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
|
if (_this.$textarea.val().replace(/^\s+|\s+$/g, '') !== '') {
|
||||||
|
|
|
@ -12,11 +12,9 @@
|
||||||
<script type="text/javascript" src="application.js"></script>
|
<script type="text/javascript" src="application.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
var app = null;
|
||||||
// Set up
|
|
||||||
var app = new haste('haste', { twitter: true });
|
|
||||||
// Handle pops
|
// Handle pops
|
||||||
window.onpopstate = function(evt) {
|
var handlePop = function(evt) {
|
||||||
var path = evt.target.location.pathname;
|
var path = evt.target.location.pathname;
|
||||||
if (path === '/') {
|
if (path === '/') {
|
||||||
app.newDocument(true);
|
app.newDocument(true);
|
||||||
|
@ -25,6 +23,18 @@
|
||||||
app.loadDocument(path.substring(1, path.length));
|
app.loadDocument(path.substring(1, path.length));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
// If pop before loading jquery, delay load
|
||||||
|
window.onpopstate = function(evt) {
|
||||||
|
try {
|
||||||
|
handlePop(evt);
|
||||||
|
} catch(err) {
|
||||||
|
// not loaded yet
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// Construct app and load if not loaded
|
||||||
|
$(function() {
|
||||||
|
app = new haste('haste', { twitter: true });
|
||||||
|
handlePop({ target: window });
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -33,7 +43,7 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="key"></div>
|
<div id="key"></div>
|
||||||
<pre id="box" style="display:none;"><code></code></pre>
|
<pre id="box" style="display:none;" tabindex="0"><code></code></pre>
|
||||||
<textarea spellcheck="false" style="display:none;"></textarea>
|
<textarea spellcheck="false" style="display:none;"></textarea>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue