Skip to content

Commit

Permalink
changes in edit info are protected when leaving page
Browse files Browse the repository at this point in the history
  • Loading branch information
zalun committed Aug 24, 2010
1 parent 9ab3ccb commit ac12dac
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 0 additions & 3 deletions flightdeck/jetpack/media/js/FlightDeck.Bespin.js
Expand Up @@ -15,7 +15,6 @@ var FDBespin = new Class({
self.element = env.editor;
self.ready();
});
$log('FD: bespin instantiated');
window.addEvent('resize', function() {
if (!self.element) {
$log('FD: resizing window: fd.bespin.element undefined')
Expand All @@ -30,7 +29,6 @@ var FDBespin = new Class({
this.fireEvent('ready');
var self = this;
this.element.textChanged.add(function() {
$log('FD: bespin text changed');
self.fireEvent('change');
});
},
Expand Down Expand Up @@ -102,7 +100,6 @@ Class.refactor(FlightDeck, {
}.bind(this),
'ready': function() {
this.bespinLoaded = true;
$log('FD: firing bespinLoadEvent');
this.fireEvent('bespinLoad');
}.bind(this)
});
Expand Down
15 changes: 8 additions & 7 deletions flightdeck/jetpack/media/js/FlightDeck.Editor.js
Expand Up @@ -15,7 +15,6 @@ FlightDeck = Class.refactor(FlightDeck,{
this.edited = false;
window.addEvent('beforeunload', function(e) {
if (fd.edited) {
alert('edited');
e.stop();
e.returnValue = "You've got unsaved changes.";
} else {
Expand All @@ -25,12 +24,14 @@ FlightDeck = Class.refactor(FlightDeck,{
this.assignModeSwitch('.{file_listing_class} li'.substitute(this.options));
this.enableMenuButtons();

this.addEvent('change', function() {
this.edited = true;
});
this.addEvent('save', function() {
this.edited = false;
});
this.addEvent('change', this.onChanged);
this.addEvent('save', this.onSaved);
},
onChanged: function() {
this.edited = true;
},
onSaved: function() {
this.edited = false;
},
assignModeSwitch: function(selector) {
// connect click to all children of all file_listing_classes
Expand Down
7 changes: 7 additions & 0 deletions flightdeck/jetpack/media/js/Package.js
Expand Up @@ -606,6 +606,12 @@ Package.Edit = new Class({
this.savenow = false;
fd.editPackageInfoModal = fd.displayModal(settings.edit_package_info_template.substitute(this.data || this.options));
$('package-info_form').addEvent('submit', this.boundSubmitInfo);

// XXX: this will change after moving the content to other forms
$('version_name').addEvent('change', function() { fd.fireEvent('change'); });
$('full_name').addEvent('change', function() { fd.fireEvent('change'); });
$('package_description').addEvent('change', function() { fd.fireEvent('change'); });

if ($('savenow')) {
$('savenow').addEvent('click', function() {
this.savenow = true;
Expand Down Expand Up @@ -674,6 +680,7 @@ Package.Edit = new Class({
// only one add-on of the same id should be allowed on the Helper side
this.installAddon();
}
fd.fireEvent('save');
}.bind(this)
}).send();
},
Expand Down

0 comments on commit ac12dac

Please sign in to comment.