Skip to content

Commit 2f27cf0

Browse files
committed
Work on bugs
1 parent 18a037f commit 2f27cf0

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

src/js/app.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
var runtime = function (appWindow, launchData, isRestart) {
44
appWindow.contentWindow.launchData = launchData;
5-
appWindow.contentWindow.__MGA__bRestart = isRestart;
5+
appWindow.contentWindow.__MGA__bRestart = isRestart
66
};
77

88
chrome.app.runtime.onLaunched.addListener(function (launchData) {
@@ -17,7 +17,6 @@
1717
},
1818
function (appWindow) {
1919
runtime(appWindow, launchData, false);
20-
2120
}
2221
);
2322
});

src/js/events.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,24 @@ $(document).ready(function () {
44
/// Globals and initializations
55
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
66

7-
var Editors = new EditorsHandler();
8-
var Modals = new ModalsHandler();
9-
var IdeSettings = new IdeSettingsHandler();
10-
var Sidebar = new SidebarHandler();
7+
var Editors = new EditorsHandler();
8+
var Modals = new ModalsHandler();
9+
var IdeSettings = new IdeSettingsHandler();
10+
var Sidebar = new SidebarHandler();
1111
var Notifications = new NotificationsHandler();
12-
var Files = new FilesHandler();
12+
var Files = new FilesHandler();
1313

1414
Notifications.init();
1515
Files.init(Notifications);
1616
Editors.init(IdeSettings, Notifications, Files);
1717
Sidebar.init(Notifications, Editors, Files);
1818
IdeSettings.init(Editors).then(Editors.startup());
1919

20+
chrome.app.runtime.onLaunched.addListener(function (launchData) {
21+
Editors.handleLaunchData(launchData.items);
22+
console.log('asdasd');
23+
});
24+
2025
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2126

2227

@@ -32,7 +37,7 @@ $(document).ready(function () {
3237
// Maintain correct record of the current and previous idx
3338
$(document).on('shown.bs.tab', '*[data-toggle="tab"]', function (e) {
3439
Editors.previousIdx = parseInt($(e.relatedTarget).attr('data-idx'));
35-
Editors.currentIdx = parseInt($(e.target).attr('data-idx'));
40+
Editors.currentIdx = parseInt($(e.target).attr('data-idx'));
3641
});
3742

3843
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -45,7 +50,7 @@ $(document).ready(function () {
4550
// Push the template into the modal before showing it
4651
$(document).on('show.bs.modal', '.modal', function (e) {
4752

48-
var $relTgt = $(e.relatedTarget);
53+
var $relTgt = $(e.relatedTarget);
4954
var callback = function () {
5055
};
5156

@@ -117,7 +122,7 @@ $(document).ready(function () {
117122
$(document).on('click', '.action-save', function () {
118123

119124
var attr = $(this).attr('data-idx');
120-
var idx = (typeof attr !== typeof undefined && attr !== false) ? attr : Editors.currentIdx;
125+
var idx = (typeof attr !== typeof undefined && attr !== false) ? attr : Editors.currentIdx;
121126

122127
Editors.onSaveFile(idx);
123128
});

src/js/handlers/editors.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -591,39 +591,46 @@ var EditorsHandler = function () {
591591

592592
// Launch default tab
593593
this._loadDefaults().then(function () {
594+
that.handleLaunchData(window.launchData.items);
595+
});
596+
};
594597

595-
var openFiles = function () {
596-
597-
var deferred = $.Deferred();
598-
var promises = [];
599-
var launchDataItems = window.launchData.items || [];
598+
this.handleLaunchData = function (launchDataItems) {
600599

601-
launchDataItems.forEach(function (item) {
602-
item.entry.type = typeof(item.type !== typeof undefined) ? item.type : item.entry.type;
603-
that.Files.fileOpen(item.entry).then(function (e, fileEntry) {
604-
promises.push(that.openFileEntryInAceEditor(
605-
(typeof e.target.result === typeof undefined) ? undefined : e.target.result,
606-
fileEntry
607-
));
608-
});
600+
var that = this;
601+
var openFiles = function () {
602+
603+
var deferred = $.Deferred();
604+
var promises = [];
605+
launchDataItems = typeof launchDataItems === typeof undefined
606+
? launchDataItems
607+
: [];
608+
609+
launchDataItems.forEach(function (item) {
610+
item.entry.type = (typeof item.type !== typeof undefined) ? item.type : item.entry.type;
611+
that.Files.fileOpen(item.entry).then(function (e, fileEntry) {
612+
promises.push(that.openFileEntryInAceEditor(
613+
(typeof e.target.result === typeof undefined) ? undefined : e.target.result,
614+
fileEntry
615+
));
609616
});
617+
});
610618

611-
$.when.apply($, promises).done(function () {
612-
deferred.resolve();
613-
});
619+
$.when.apply($, promises).done(function () {
620+
deferred.resolve();
621+
});
614622

615-
return deferred.promise();
616-
};
623+
return deferred.promise();
624+
};
617625

618-
openFiles().then(function () {
619-
window.setTimeout(function () {
620-
if (that.getNumTabs() === 0) {
621-
that.onAddNewTab(that.defaultFileExt);
622-
}
623-
}, 400)
624-
}).fail(function () {
625-
that.onAddNewTab(that.defaultFileExt);
626-
});
626+
openFiles().then(function () {
627+
window.setTimeout(function () {
628+
if (that.getNumTabs() === 0) {
629+
that.onAddNewTab(that.defaultFileExt);
630+
}
631+
}, 400)
632+
}).fail(function () {
633+
that.onAddNewTab(that.defaultFileExt);
627634
});
628635
};
629636

0 commit comments

Comments
 (0)