Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating modal to allow bindable fade and backdrop #139

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ bower install ember-addons.bs_for_ember --save
### Dependencies

* Bootstrap 3 css.
* Bootstrap 3 js.
* Fontawesome 4.
* Ember.js 1.3.1 or higher.

Expand Down
35 changes: 23 additions & 12 deletions app/scripts/components/BsModalComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ Modal component.
Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented,
layoutName: 'components/bs-modal'
classNames: ['modal']
#classNameBindings: ['fade']
attributeBindings: ['role', 'aria-labelledby', 'isAriaHidden:aria-hidden', "ariaLabelledBy:aria-labelledby"]
classNameBindings:[
'fade'
'isVisible:in'
]

attributeBindings:[
'role'
'aria-labelledby'
'isAriaHidden:aria-hidden'
'ariaLabelledBy:aria-labelledby'
'backdrop:data-backdrop'
]

isAriaHidden: (->
"#{@get('isVisible')}"
!"#{@get('isVisible')}"
).property('isVisible')
modalBackdrop: '<div class="modal-backdrop fade in"></div>'
role: 'dialog'
Expand All @@ -32,25 +43,25 @@ Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented,
@show()

becameVisible: ->
Em.$('body').addClass('modal-open')
@appendBackdrop() if @get("backdrop")
# Em.$('body').addClass('modal-open')
# @appendBackdrop() if @get("backdrop")

becameHidden: ->
Em.$('body').removeClass('modal-open')
@_backdrop.remove() if @_backdrop
# Em.$('body').removeClass('modal-open')
# @_backdrop.remove() if @_backdrop

appendBackdrop: ->
parentElement = @$().parent()
@_backdrop = Em.$(@modalBackdrop).appendTo(parentElement)
# parentElement = @$().parent()
# @_backdrop = Em.$(@modalBackdrop).appendTo(parentElement)

show: ->
@set 'isVisible', true
this.$().modal 'show'

hide: ->
@set 'isVisible', false
this.$().modal 'hide'

toggle: ->
@toggleProperty 'isVisible'
this.$().modal 'toggle'

click: (event) ->
target = event.target
Expand Down
48 changes: 19 additions & 29 deletions dist/js/bs-modal.max.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
Modal component.
*/

*/

(function() {
Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented, {
layoutName: 'components/bs-modal',
classNames: ['modal'],
attributeBindings: ['role', 'aria-labelledby', 'isAriaHidden:aria-hidden', "ariaLabelledBy:aria-labelledby"],
classNameBindings: ['fade', 'isVisible:in'],
attributeBindings: ['role', 'aria-labelledby', 'isAriaHidden:aria-hidden', 'ariaLabelledBy:aria-labelledby', 'backdrop:data-backdrop'],
isAriaHidden: (function() {
return "" + (this.get('isVisible'));
return !("" + (this.get('isVisible')));
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seemed to be a small bug wherein the isAriaHidden was returning the opposite of the visual state.

}).property('isVisible'),
modalBackdrop: '<div class="modal-backdrop fade in"></div>',
role: 'dialog',
Expand All @@ -32,29 +32,17 @@ Modal component.
return this.show();
}
},
becameVisible: function() {
if (this.get("backdrop")) {
return this.appendBackdrop();
}
},
becameHidden: function() {
if (this._backdrop) {
return this._backdrop.remove();
}
},
appendBackdrop: function() {
var parentElement;
parentElement = this.$().parent();
return this._backdrop = Em.$(this.modalBackdrop).appendTo(parentElement);
},
becameVisible: function() {},
becameHidden: function() {},
appendBackdrop: function() {},
show: function() {
return this.set('isVisible', true);
return this.$().modal('show');
},
hide: function() {
return this.set('isVisible', false);
return this.$().modal('hide');
},
toggle: function() {
return this.toggleProperty('isVisible');
return this.$().modal('toggle');
},
click: function(event) {
var target, targetDismiss;
Expand All @@ -79,6 +67,7 @@ Modal component.
},
willDestroyElement: function() {
var name;
Em.$('body').removeClass('modal-open');
this.removeHandlers();
name = this.get('name');
if (name == null) {
Expand All @@ -93,16 +82,18 @@ Modal component.
return jQuery(window.document).unbind("keyup", this._keyUpHandler);
},
setupBinders: function() {
var handler,
_this = this;
handler = function(event) {
return _this.keyPressed(event);
};
var handler;
handler = (function(_this) {
return function(event) {
return _this.keyPressed(event);
};
})(this);
jQuery(window.document).bind("keyup", handler);
return this._keyUpHandler = handler;
}
});


/*
Bootstrap.BsModalComponent = Bootstrap.BsModalComponent.reopenClass(
build: (options) ->
Expand All @@ -111,8 +102,7 @@ Modal component.
modalPane = @create(options)
modalPane.append()
)
*/

*/

Bootstrap.ModalManager = Ember.Object.create({
add: function(name, modalInstance) {
Expand Down