|
@@ -3,7 +3,7 @@ define [
|
|
|
"ide/editor/Document"
|
|
"ide/editor/Document"
|
|
|
], (App, Document) ->
|
|
], (App, Document) ->
|
|
|
App.controller "SavingNotificationController", ["$scope", "$interval", "ide", ($scope, $interval, ide) ->
|
|
App.controller "SavingNotificationController", ["$scope", "$interval", "ide", ($scope, $interval, ide) ->
|
|
|
- $interval () ->
|
|
|
|
|
|
|
+ setInterval () ->
|
|
|
pollSavedStatus()
|
|
pollSavedStatus()
|
|
|
, 1000
|
|
, 1000
|
|
|
|
|
|
|
@@ -13,21 +13,25 @@ define [
|
|
|
$scope.docSavingStatus = {}
|
|
$scope.docSavingStatus = {}
|
|
|
pollSavedStatus = () ->
|
|
pollSavedStatus = () ->
|
|
|
oldStatus = $scope.docSavingStatus
|
|
oldStatus = $scope.docSavingStatus
|
|
|
- $scope.docSavingStatus = {}
|
|
|
|
|
|
|
+ newStatus = {}
|
|
|
|
|
|
|
|
for doc_id, doc of Document.openDocs
|
|
for doc_id, doc of Document.openDocs
|
|
|
saving = doc.pollSavedStatus()
|
|
saving = doc.pollSavedStatus()
|
|
|
if !saving
|
|
if !saving
|
|
|
if oldStatus[doc_id]?
|
|
if oldStatus[doc_id]?
|
|
|
- $scope.docSavingStatus[doc_id] = oldStatus[doc_id]
|
|
|
|
|
- $scope.docSavingStatus[doc_id].unsavedSeconds += 1
|
|
|
|
|
|
|
+ newStatus[doc_id] = oldStatus[doc_id]
|
|
|
|
|
+ newStatus[doc_id].unsavedSeconds += 1
|
|
|
else
|
|
else
|
|
|
- $scope.docSavingStatus[doc_id] = {
|
|
|
|
|
|
|
+ newStatus[doc_id] = {
|
|
|
unsavedSeconds: 0
|
|
unsavedSeconds: 0
|
|
|
doc: ide.fileTreeManager.findEntityById(doc_id)
|
|
doc: ide.fileTreeManager.findEntityById(doc_id)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if _.size(newStatus) or _.size(oldStatus)
|
|
|
|
|
+ $scope.docSavingStatus = newStatus
|
|
|
|
|
+ $scope.$apply()
|
|
|
|
|
+
|
|
|
warnAboutUnsavedChanges = () ->
|
|
warnAboutUnsavedChanges = () ->
|
|
|
if Document.hasUnsavedChanges()
|
|
if Document.hasUnsavedChanges()
|
|
|
return "You have unsaved changes. If you leave now they will not be saved."
|
|
return "You have unsaved changes. If you leave now they will not be saved."
|
|
|
- ]
|
|
|
|
|
|
|
+ ]
|