Don't wait for onload.
This commit is contained in:
@@ -133,7 +133,7 @@ $.save = function( commitMessage ) {
|
|||||||
} // end else
|
} // end else
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function() {
|
|
||||||
/* Load markdown from /data/page into the ace editor. */
|
/* Load markdown from /data/page into the ace editor. */
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
@@ -182,7 +182,32 @@ window.onload = function() {
|
|||||||
|
|
||||||
// onChange calls applyTimeout which rate limits the calling of makePreviewHtml based on render time.
|
// onChange calls applyTimeout which rate limits the calling of makePreviewHtml based on render time.
|
||||||
editor.on('change', applyTimeout);
|
editor.on('change', applyTimeout);
|
||||||
makePreviewHtml(); // preview default text on load
|
|
||||||
|
var cssTextSet = function( element, css ){
|
||||||
|
element.style.cssText = css;
|
||||||
|
};
|
||||||
|
|
||||||
|
var cssAttrSet = function( element, css ){
|
||||||
|
element.setAttribute( 'style', css );
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
Redefine the function based on browser support.
|
||||||
|
element - the element to set the css on
|
||||||
|
css - a fully formed css string. ex: "top: 0; left: 0;"
|
||||||
|
|
||||||
|
Avoid reflow by batching CSS changes.
|
||||||
|
http://dev.opera.com/articles/view/efficient-javascript/?page=3#stylechanges
|
||||||
|
*/
|
||||||
|
var cssSet = function( element, css ) {
|
||||||
|
if( typeof( element.style.cssText ) != 'undefined' ) {
|
||||||
|
cssTextSet( element, css );
|
||||||
|
cssSet = cssTextSet;
|
||||||
|
} else {
|
||||||
|
cssAttrSet( element, css );
|
||||||
|
cssSet = cssAttrSet;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function resize() {
|
function resize() {
|
||||||
var width = $(window).width();
|
var width = $(window).width();
|
||||||
@@ -250,7 +275,6 @@ window.onload = function() {
|
|||||||
|
|
||||||
// resize for the intial page load
|
// resize for the intial page load
|
||||||
resize();
|
resize();
|
||||||
};
|
|
||||||
|
|
||||||
var elapsedTime;
|
var elapsedTime;
|
||||||
var oldInputText = "";
|
var oldInputText = "";
|
||||||
@@ -276,32 +300,6 @@ var ieSafePreviewSet = function (text) {
|
|||||||
parent.insertBefore(content, sibling);
|
parent.insertBefore(content, sibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
var cssTextSet = function( element, css ){
|
|
||||||
element.style.cssText = css;
|
|
||||||
}
|
|
||||||
|
|
||||||
var cssAttrSet = function( element, css ){
|
|
||||||
element.setAttribute( 'style', css );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
Redefine the function based on browser support.
|
|
||||||
element - the element to set the css on
|
|
||||||
css - a fully formed css string. ex: "top: 0; left: 0;"
|
|
||||||
|
|
||||||
Avoid reflow by batching CSS changes.
|
|
||||||
http://dev.opera.com/articles/view/efficient-javascript/?page=3#stylechanges
|
|
||||||
*/
|
|
||||||
var cssSet = function( element, css ) {
|
|
||||||
if( typeof( element.style.cssText ) != 'undefined' ) {
|
|
||||||
cssTextSet( element, css );
|
|
||||||
cssSet = cssTextSet;
|
|
||||||
} else {
|
|
||||||
cssAttrSet( element, css );
|
|
||||||
cssSet = cssAttrSet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var previewSet = function( text ) {
|
var previewSet = function( text ) {
|
||||||
try {
|
try {
|
||||||
nonSuckyBrowserPreviewSet( text );
|
nonSuckyBrowserPreviewSet( text );
|
||||||
@@ -379,6 +377,9 @@ var makePreviewHtml = function () {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// preview default text on load
|
||||||
|
makePreviewHtml();
|
||||||
|
|
||||||
// setTimeout is already used. Used as an event listener.
|
// setTimeout is already used. Used as an event listener.
|
||||||
var applyTimeout = function () {
|
var applyTimeout = function () {
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
|
|||||||
Reference in New Issue
Block a user