-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spin-button component & implement it
closes #3928 - adds spin-button component & styles - implements spin-button in places where buttons trigger async tasks
- Loading branch information
Showing
32 changed files
with
286 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
tagName: 'button', | ||
buttonText: '', | ||
submitting: false, | ||
autoWidth: true, | ||
|
||
// Disable Button when isLoading equals true | ||
attributeBindings: ['disabled'], | ||
|
||
// Must be set on the controller | ||
disabled: Ember.computed.equal('submitting', true), | ||
|
||
click: function () { | ||
if (this.get('action')) { | ||
this.sendAction('action'); | ||
return false; | ||
} | ||
return true; | ||
}, | ||
|
||
setSize: function () { | ||
if (!this.get('submitting') && this.get('autoWidth')) { | ||
// this exists so that the spinner doesn't change the size of the button | ||
this.$().width(this.$().width()); // sets width of button | ||
this.$().height(this.$().height()); // sets height of button | ||
} | ||
}, | ||
|
||
width: Ember.observer('buttonText', 'autoWidth', function () { | ||
this.setSize(); | ||
}), | ||
|
||
didInsertElement: function () { | ||
this.setSize(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import Ember from 'ember'; | ||
import SettingsSaveMixin from 'ghost/mixins/settings-save'; | ||
|
||
export default Ember.Controller.extend({ | ||
export default Ember.Controller.extend(SettingsSaveMixin, { | ||
notifications: Ember.inject.service(), | ||
|
||
actions: { | ||
save: function () { | ||
var notifications = this.get('notifications'); | ||
save: function () { | ||
var notifications = this.get('notifications'); | ||
|
||
return this.get('model').save().then(function (model) { | ||
return model; | ||
}).catch(function (error) { | ||
notifications.showAPIError(error); | ||
}); | ||
} | ||
return this.get('model').save().catch(function (error) { | ||
notifications.showAPIError(error); | ||
}); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.