Fixed IE9 compatibility

This commit is contained in:
benweet 2014-06-09 13:49:37 +01:00
commit 0636ad1c44
7 changed files with 997 additions and 976 deletions

View File

@ -28,7 +28,7 @@ define([], function() {
constants.SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/"; constants.SSH_PROXY_URL = "https://stackedit-ssh-proxy.herokuapp.com/";
constants.HTMLTOPDF_URL = "https://stackedit-htmltopdf.herokuapp.com/"; constants.HTMLTOPDF_URL = "https://stackedit-htmltopdf.herokuapp.com/";
// Site dependent // Site dependent
constants.BASE_URL = "http://localhost/"; constants.BASE_URL = "http://localhost/";
constants.GOOGLE_CLIENT_ID = '241271498917-lev37kef013q85avc91am1gccg5g8lrb.apps.googleusercontent.com'; constants.GOOGLE_CLIENT_ID = '241271498917-lev37kef013q85avc91am1gccg5g8lrb.apps.googleusercontent.com';
constants.GITHUB_CLIENT_ID = 'e47fef6055344579799d'; constants.GITHUB_CLIENT_ID = 'e47fef6055344579799d';

View File

@ -179,8 +179,6 @@ define([
var selection = rangy.getSelection(); var selection = rangy.getSelection();
selection.removeAllRanges(); selection.removeAllRanges();
selection.addRange(range, this.selectionStart > this.selectionEnd); selection.addRange(range, this.selectionStart > this.selectionEnd);
selection.detach();
range.detach();
}; };
this.setSelectionStartEnd = function(start, end) { this.setSelectionStartEnd = function(start, end) {
if(start === undefined) { if(start === undefined) {
@ -232,9 +230,7 @@ define([
selectionEnd = offset + (range + '').length; selectionEnd = offset + (range + '').length;
} }
} }
selectionRange.detach();
} }
selection.detach();
self.setSelectionStartEnd(selectionStart, selectionEnd); self.setSelectionStartEnd(selectionStart, selectionEnd);
} }
undoMgr.saveSelectionState(); undoMgr.saveSelectionState();

File diff suppressed because it is too large Load Diff

View File

@ -117,7 +117,7 @@ define([
}; };
DomObject.prototype.createToggler = function(backdrop) { DomObject.prototype.createToggler = function(backdrop) {
var backdropElt; var $backdropElt;
var pushedEvents = 0; var pushedEvents = 0;
this.toggle = function(show) { this.toggle = function(show) {
if(show === this.isOpen) { if(show === this.isOpen) {
@ -127,7 +127,7 @@ define([
if(this.isOpen) { if(this.isOpen) {
this.$elt.addClass('panel-open').trigger('show.layout.toggle'); this.$elt.addClass('panel-open').trigger('show.layout.toggle');
if(backdrop) { if(backdrop) {
$(backdropElt = utils.createBackdrop(wrapperL1.elt)).click(_.bind(function() { $backdropElt = $(utils.createBackdrop(wrapperL1.elt)).on('click.backdrop', _.bind(function() {
this.toggle(false); this.toggle(false);
}, this)); }, this));
this.$elt.addClass('bring-to-front'); this.$elt.addClass('bring-to-front');
@ -140,8 +140,11 @@ define([
} }
else { else {
this.$elt.trigger('hide.layout.toggle'); this.$elt.trigger('hide.layout.toggle');
backdropElt && backdropElt.removeBackdrop(); if($backdropElt) {
backdropElt = undefined; $backdropElt.off('click.backdrop');
$backdropElt[0].removeBackdrop();
$backdropElt = undefined;
}
transitionEndCallbacks.push(_.bind(function() { transitionEndCallbacks.push(_.bind(function() {
if(--pushedEvents === 0) { if(--pushedEvents === 0) {
!this.isOpen && this.$elt.removeClass('panel-open bring-to-front').trigger('hidden.layout.toggle'); !this.isOpen && this.$elt.removeClass('panel-open bring-to-front').trigger('hidden.layout.toggle');

View File

@ -91,8 +91,7 @@ define([
var syncIndex = createSyncIndex(doc.id); var syncIndex = createSyncIndex(doc.id);
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex); var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) { if(fileDesc !== undefined) {
eventMgr.onError('"' + fileDesc.title + '" was already imported.'); return eventMgr.onError('"' + fileDesc.title + '" was already imported.');
return;
} }
importIds.push(doc.id); importIds.push(doc.id);
}); });
@ -109,16 +108,14 @@ define([
var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex); var fileDesc = fileMgr.getFileFromSyncIndex(syncIndex);
if(fileDesc !== undefined) { if(fileDesc !== undefined) {
eventMgr.onError('File ID is already synchronized with "' + fileDesc.title + '".'); eventMgr.onError('File ID is already synchronized with "' + fileDesc.title + '".');
callback(true); return callback(true);
return;
} }
} }
var parentId = utils.getInputTextValue('#input-sync-export-' + providerId + '-parentid'); var parentId = utils.getInputTextValue('#input-sync-export-' + providerId + '-parentid');
var data = gdriveProvider.serializeContent(content, discussionListJSON); var data = gdriveProvider.serializeContent(content, discussionListJSON);
googleHelper.upload(fileId, parentId, title, data, undefined, undefined, accountId, function(error, result) { googleHelper.upload(fileId, parentId, title, data, undefined, undefined, accountId, function(error, result) {
if(error) { if(error) {
callback(error); return callback(error);
return;
} }
var syncAttributes = createSyncAttributes(result.id, result.etag, content, title, discussionListJSON); var syncAttributes = createSyncAttributes(result.id, result.etag, content, title, discussionListJSON);
callback(undefined, syncAttributes); callback(undefined, syncAttributes);
@ -128,7 +125,7 @@ define([
gdriveProvider.syncUp = function(content, contentCRC, title, titleCRC, discussionList, discussionListCRC, syncAttributes, callback) { gdriveProvider.syncUp = function(content, contentCRC, title, titleCRC, discussionList, discussionListCRC, syncAttributes, callback) {
if( if(
(syncAttributes.contentCRC == contentCRC) && // Content CRC hasn't changed (syncAttributes.contentCRC == contentCRC) && // Content CRC hasn't changed
(syncAttributes.titleCRC == titleCRC) && // Content CRC hasn't changed (syncAttributes.titleCRC == titleCRC) && // Title CRC hasn't changed
(syncAttributes.discussionListCRC == discussionListCRC) // Discussion list CRC hasn't changed (syncAttributes.discussionListCRC == discussionListCRC) // Discussion list CRC hasn't changed
) { ) {
return callback(undefined, false); return callback(undefined, false);
@ -144,8 +141,7 @@ define([
var data = gdriveProvider.serializeContent(content, discussionList); var data = gdriveProvider.serializeContent(content, discussionList);
googleHelper.upload(syncAttributes.id, undefined, title, data, undefined, syncAttributes.etag, accountId, function(error, result) { googleHelper.upload(syncAttributes.id, undefined, title, data, undefined, syncAttributes.etag, accountId, function(error, result) {
if(error) { if(error) {
callback(error, true); return callback(error, true);
return;
} }
syncAttributes.etag = result.etag; syncAttributes.etag = result.etag;
// Remove this deprecated flag if any // Remove this deprecated flag if any
@ -167,8 +163,7 @@ define([
var lastChangeId = parseInt(storage[accountId + ".gdrive.lastChangeId"], 10); var lastChangeId = parseInt(storage[accountId + ".gdrive.lastChangeId"], 10);
googleHelper.checkChanges(lastChangeId, accountId, function(error, changes, newChangeId) { googleHelper.checkChanges(lastChangeId, accountId, function(error, changes, newChangeId) {
if(error) { if(error) {
callback(error); return callback(error);
return;
} }
var interestingChanges = []; var interestingChanges = [];
_.each(changes, function(change) { _.each(changes, function(change) {

View File

@ -1336,7 +1336,7 @@ div.dropdown-menu, {
color: @link-hover-color; color: @link-hover-color;
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
margin: 0.8em 0; margin: 1em 0;
} }
} }

View File

@ -349,6 +349,36 @@ define([
].join("")); ].join(""));
}; };
var $windowElt = $(window);
utils.iframe = function(url, width, height) {
var $backdropElt = $(utils.createBackdrop());
var result = crel('iframe', {
src: url,
frameborder: 0,
class: 'modal-content modal-iframe'
});
document.body.appendChild(result);
function placeIframe() {
var actualWidth = window.innerWidth - 20;
actualWidth > width && (actualWidth = width);
var actualHeight = window.innerHeight - 50;
actualHeight > height && (actualHeight = height);
result.setAttribute('width', actualWidth);
result.setAttribute('height', actualHeight);
}
placeIframe();
$windowElt.on('resize.iframe', placeIframe);
function removeIframe() {
$backdropElt.off('click.backdrop');
$backdropElt[0].removeBackdrop();
$windowElt.off('resize.iframe');
result.parentNode.removeChild(result);
}
result.removeIframe = removeIframe;
$backdropElt.on('click.backdrop', removeIframe);
return result;
};
// Shows a dialog to force the user to click a button before opening oauth popup // Shows a dialog to force the user to click a button before opening oauth popup
var redirectCallbackConfirm; var redirectCallbackConfirm;
var redirectCallbackCancel; var redirectCallbackCancel;