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

Updated Modal Buttons To Have State #187

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b313bf0
updated modal template
ritesh83 Oct 21, 2014
fff1e6c
updated modal buttons
ritesh83 Oct 29, 2014
970e1dc
compiled changes - updated dist directory
ritesh83 Oct 29, 2014
fca6d71
updated button component script
ritesh83 Oct 29, 2014
adf78bf
fixed modal close issue
ritesh83 Oct 30, 2014
d2f13f1
added fail state to modal buttons
ritesh83 Oct 30, 2014
87afa3f
added fail state to modal buttons
ritesh83 Oct 30, 2014
9a9613a
added default text for fail and success states
ritesh83 Oct 30, 2014
ffb3100
fixed issue with modal buttons
ritesh83 Oct 30, 2014
a5e3091
fixed modal hide action issue
ritesh83 Oct 30, 2014
9e51f46
updated showcase modals page with loading buttons example
ritesh83 Oct 31, 2014
a4e29f2
reverted content to model change
ritesh83 Oct 31, 2014
edc62c3
Add Ember.run and check for destroyed or destroying to remove errors …
Nov 6, 2014
cd4a3d0
Replace setTimeout with Ember.run.later
Nov 18, 2014
87f57e7
added type attribute to button
Nov 25, 2014
f7a9438
Merge branch 'master' of https://github.com/ritesh83/bootstrap-for-ember
Nov 25, 2014
6b53a1a
fixed popover underscore issue
Dec 2, 2014
386def2
fixed popover template issue
Dec 2, 2014
72b4bd3
fixed popover template issue
Dec 2, 2014
04e788b
updated close action
Dec 3, 2014
eea0a99
updated close action
Dec 3, 2014
efc6084
added option to specify action on close
Dec 4, 2014
064729b
added option to specify action on close
Dec 4, 2014
127bbcc
removed close popover on mouse leave feature
Dec 4, 2014
b0e17ec
Fix so removes observer on willClearRender for manual display
Jan 14, 2015
aac9c89
Revert "Fix so removes observer on willClearRender for manual display"
Feb 19, 2015
39ecb89
Minimize the changes for willClearRender on manual display and remove…
Feb 19, 2015
44073d1
Put alert's dismiss inside and Ember.run loop to make tests happy
Feb 19, 2015
2e1b05f
upgraded to ember 1.10
Mar 4, 2015
f940e08
fixed popover
Mar 10, 2015
eb74d79
testing
Mar 10, 2015
840ab04
Fix for timeouts not closing. Needed target param for Ember.run
cristinawithout Mar 21, 2015
f13f8a5
upgraded to ember 1.11.1
Apr 7, 2015
3c8e6e4
Fix asynch errors on test for BsPopover
cristinawithout May 6, 2015
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
27 changes: 13 additions & 14 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ module.exports = function (grunt) {
files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
tasks: ['compass:server']
},
ember_handlebars: {
emberTemplates: {
files: '<%= yeoman.app %>/templates/**/*.hbs',
tasks: ['ember_handlebars']
tasks: ['emberTemplates']
},
markdown: {
files: '<%= yeoman.app %>/templates/**/*.md',
Expand Down Expand Up @@ -309,7 +309,7 @@ module.exports = function (grunt) {
server: [
'compass',
'markdown',
'ember_handlebars',
'emberTemplates',
'coffee:dist'
],
test: [
Expand All @@ -318,21 +318,21 @@ module.exports = function (grunt) {
dist: [
'coffee',
'markdown',
'ember_handlebars',
'emberTemplates',
'compass',
'imagemin',
'svgmin',
'htmlmin'
]
},
ember_handlebars: {
emberTemplates: {
compile_components: {
options: {
processName: function(filename) {
var fromComponent = filename.substring(filename.lastIndexOf('/components/')+1,filename.length);
return fromComponent.substring(0,fromComponent.length-4);
templateName: function(filename) {
return filename.substring(filename.lastIndexOf('/components/')+1,filename.length);
},
namespace: "Ember.TEMPLATES"
templateCompilerPath: 'app/bower_components/ember/ember-template-compiler.js',
handlebarsPath: 'app/bower_components/handlebars/handlebars.js'
},
files: {
'.tmp/scripts/bs-core.js': '<%= yeoman.app %>/templates/views/item-pane.hbs',
Expand All @@ -356,11 +356,11 @@ module.exports = function (grunt) {
},
compile_showcase: {
options: {
processName: function(filename) {
var fromShowcase = filename.substring(filename.lastIndexOf('/showcase/')+1,filename.length)
return fromShowcase.substring(fromShowcase.indexOf('/')+1,fromShowcase.length-4);
templateName: function(filename) {
return filename.substring(filename.lastIndexOf('/showcase/')+1,filename.length).replace('showcase/', '');
},
namespace: "Ember.TEMPLATES"
templateCompilerPath: 'app/bower_components/ember/ember-template-compiler.js',
handlebarsPath: 'app/bower_components/handlebars/handlebars.js'
},
files: {
'.tmp/scripts/showcase-templates.js': '<%= yeoman.app %>/templates/showcase/**/*.hbs'
Expand Down Expand Up @@ -445,7 +445,6 @@ module.exports = function (grunt) {
'concat',
'copy:unminified',
'cssmin',
'uglify',
'copy:dist',
'rev',
'usemin'
Expand Down
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/handlebars/handlebars.js"></script>
<script src="bower_components/ember/ember.js"></script>
<script src="bower_components/ember/ember-template-compiler.js"></script>
<script src="bower_components/highlightjs/highlight.pack.js"></script>
<script src="bower_components/bootstrap/docs-assets/js/holder.js"></script>
<script src="bower_components/bootstrap/docs-assets/js/application.js"></script>
Expand Down
3 changes: 2 additions & 1 deletion app/scripts/components/BsAlertComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ Bootstrap.BsAlertComponent = Ember.Component.extend(Bootstrap.TypeSupport,
)

dismiss: () ->
Ember.$("##{@elementId}").alert('close')
Ember.run this, () ->
Ember.$("##{@elementId}").alert('close')

)

Expand Down
8 changes: 5 additions & 3 deletions app/scripts/components/BsButtonComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ Bootstrap.BsButtonComponent = Ember.Component.extend(Bootstrap.TypeSupport, Boot
classTypePrefix: 'btn'
clickedParam: null
block: null
attributeBindings: ['disabled', 'dismiss:data-dismiss', '_type:type', 'style']
attributeBindings: ['disabled', 'dismiss:data-dismiss', '_type:type', 'style', 'loadingText:data-loading-text', 'failText:data-fail-text', 'successText:data-success-text', 'loading', 'clicked']
_type: 'button'
bubbles: true
allowedProperties: ['title', 'type', 'size', 'block', 'disabled', 'clicked', 'dismiss', 'class']
allowedProperties: ['title', '_type', 'type', 'size', 'block', 'disabled', 'clicked', 'dismiss', 'class', 'loadingText', 'failText', 'successText', 'loading']
icon_active: undefined
icon_inactive: undefined
successText: 'Saved!'
failText: 'Failed!'

init: ->
@_super()
Expand All @@ -26,7 +28,7 @@ Bootstrap.BsButtonComponent = Ember.Component.extend(Bootstrap.TypeSupport, Boot

blockClass: ( ->
if @block then "#{@classTypePrefix}-block" else null
).property('block').cacheable()
).property('block')

click: (evt) ->
evt.stopPropagation() unless @get('bubbles')
Expand Down
24 changes: 13 additions & 11 deletions app/scripts/components/BsModalComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented,
isVis: false
fullSizeButtons: false
fade: true
allowClose: true
loadingState: null

didInsertElement: ->
@._super()
Expand Down Expand Up @@ -49,18 +51,19 @@ Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented,
show: ->
@set 'isVisible', true
current = this
setTimeout (->
Ember.run.later (->
if current.get('isDestroyed') or current.get('isDestroying')
return
current.set 'isVis', true
return
), 15
return

hide: ->
@set 'isVis', false
current = this
@$().one 'webkitTransitionEnd', (e) ->
current.set 'isVisible', false
return
#@$().one 'webkitTransitionEnd', (e) ->
current.set 'isVisible', false
# return
false

toggle: ->
Expand All @@ -79,12 +82,9 @@ Bootstrap.BsModalComponent = Ember.Component.extend(Ember.Evented,

close: (event) ->
@set 'isVis', false
current = this
@$().one 'webkitTransitionEnd', (e) ->
if current.get('manual') then current.destroy() else current.hide()
return
@trigger 'closed'

current = this
if current.get('manual') then current.destroy() else current.hide()
@trigger 'closed'

#Invoked automatically by ember when the view is destroyed, giving us a chance to perform cleanups
willDestroyElement: ->
Expand Down Expand Up @@ -195,6 +195,8 @@ Bootstrap.ModalManager = Ember.Object.create(
)

modalComponent.appendTo(controller.namespace.rootElement)

return modalComponent
)


Expand Down
84 changes: 35 additions & 49 deletions app/scripts/components/BsPopover.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,9 @@ Bootstrap.BsPopoverComponent = Ember.Component.extend(
@set "html", @get("data.html") or false
@set "template", @get("data.template") isnt `undefined`
if @get("template")
name = "components/bs-popover/_partial-content-" + @get("tip_id")
name = "components/bs-popover/partial-content-" + @get("tip_id")
tpl = @get("data.template")
if typeof tpl is "function"
Ember.TEMPLATES[name] = tpl
else
Ember.TEMPLATES[name] = Ember.Handlebars.compile(tpl)
@set "partialTemplateName", name
@set "partialTemplateName", tpl

didInsertElement: ->
@$tip = @$()
Expand All @@ -125,16 +121,17 @@ Bootstrap.BsPopoverComponent = Ember.Component.extend(

if @get("data.trigger") is "hover" and @get("data.sticky")
@$().on "mouseenter", ->
clearTimeout Bootstrap.TooltipBoxManager.timeout
Ember.run.cancel Bootstrap.TooltipBoxManager.timeout

@$().on "mouseleave", =>
Bootstrap.TooltipBoxManager.removeTip @get("tip_id")
# @$().on "mouseleave", =>
# Bootstrap.TooltipBoxManager.removeTip @get("tip_id")

@$().find("img").load =>
@afterRender()

afterRender: ->
@notifyPropertyChange "content"
Ember.run @, ->
@notifyPropertyChange "content"

realPlacement: (->
return null unless @$tip
Expand Down Expand Up @@ -187,8 +184,10 @@ Bootstrap.BsPopoverComponent = Ember.Component.extend(
left: pos.left + pos.width

actions:
close: ->
Bootstrap.TooltipBoxManager.removeTip @get("tip_id")
close: (selectedItem) ->
@sendAction "action", selectedItem
Bootstrap.TooltipBoxManager.removeTip @get("tip_id")

)

Ember.Handlebars.helper 'bs-popover', Bootstrap.BsPopoverComponent
Expand Down Expand Up @@ -229,6 +228,7 @@ template = "" +
" {{bs-popover" +
" tip_id=pop.tip_id" +
" data=pop.data" +
" action=pop.data.action" +
" }}" +
"{{/each}}" +
"{{#each pop in tooltips}}" +
Expand Down Expand Up @@ -281,6 +281,9 @@ Bootstrap.TooltipBoxManager = Ember.Object.create(
return

options.data.view.on "willClearRender", ->
pop = self.registeredTips[id]
if pop.eventName is 'manual'
pop.data.removeObserver "show", pop
Bootstrap.TooltipBoxManager.removeTip id
$("[" + self.attribute + "='" + id + "']").unbind()
delete Bootstrap.TooltipBoxManager.registeredTips[id]
Expand Down Expand Up @@ -353,9 +356,8 @@ Bootstrap.TooltipBoxManager = Ember.Object.create(
return

timedRemove: (id) ->
self = this
@timeout = setTimeout(->
self.removeTip id
@timeout = Ember.run.later(@, ->
this.removeTip id
return
, 100)
return
Expand Down Expand Up @@ -397,47 +399,31 @@ Bootstrap.TooltipBoxManager = Ember.Object.create(
#strings and variables are supported!!
if path instanceof Object
object = Ember.Object.create({})
for name of path.hash
value = path.hash[name]
type = options.hashTypes[name]

#set string directrly
if type is "STRING"
object.set name, value
else if type is "ID"

#is variable to which we can bind
#get context from keywords -> the each helper defines it
p = value.split(".")
keyword = p[0]
o = options.data.keywords[keyword]
unless o

#no context in keywords, assuming current context
o = this
else
p.removeAt 0
object._bindings = o unless object._bindings
p.insertAt 0, "_bindings"
p = p.join(".")
object[name] = ""
binding = Ember.Binding.from(p).to(name)
binding.connect object
else
object.set name, value
for name of path
value = path[name]
object.set name, value
object
)

Ember.Handlebars.registerHelper "bs-bind-popover", (path) ->
options = arguments[arguments.length - 1]
Ember.HTMLBars._registerHelper "bs-bind-popover", (params, hash, options, env) ->
object = this
object = Bootstrap.TooltipBoxManager.helper.call(this, path, object, options)
object = Bootstrap.TooltipBoxManager.helper.call(this, hash, object, options)
if params instanceof Array and params.length > 0
object = params[0].value()
options = env
else
options = arguments[arguments.length - 1]
id = Bootstrap.TooltipBoxManager.registerTip("popover", object, options)
new Ember.Handlebars.SafeString(Bootstrap.TooltipBoxManager.attribute + "='" + id + "'")

Ember.Handlebars.registerHelper "bs-bind-tooltip", (path) ->
options = arguments[arguments.length - 1]
Ember.HTMLBars._registerHelper "bs-bind-tooltip", (params, hash, options, env) ->
object = this
object = Bootstrap.TooltipBoxManager.helper.call(this, path, object, options)
object = Bootstrap.TooltipBoxManager.helper.call(this, hash, object, options)
if params instanceof Array and params.length > 0
object = params[0].value()
options = env
else
options = arguments[arguments.length - 1]

id = Bootstrap.TooltipBoxManager.registerTip("tooltip", object, options)
new Ember.Handlebars.SafeString(Bootstrap.TooltipBoxManager.attribute + "='" + id + "'")
4 changes: 2 additions & 2 deletions app/scripts/components/BsProgressbarComponent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ Bootstrap.BsProgressbarComponent = Ember.Component.extend(Bootstrap.TypeSupport,

style: ( ->
"width:#{@progress}%;"
).property('progress').cacheable()
).property('progress')

ariaValueNow: ( ->
@progress
).property('progress').cacheable()
).property('progress')
)

Ember.Handlebars.helper 'bs-progressbar', Bootstrap.BsProgressbarComponent
2 changes: 1 addition & 1 deletion app/scripts/components/Notifications.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ Notification(s) are added into the NotificationQueue by the pushNotification fun
Bootstrap.Notification = Ember.Object.extend(
classType: (->
if @type? then "alert-#{@type}" else null
).property('type').cacheable()
).property('type')
)
2 changes: 1 addition & 1 deletion app/scripts/mixins/ItemSelection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Bootstrap.ItemSelection = Ember.Mixin.create(Bootstrap.ItemValue, Bootstrap.With
return false

selected is value
).property('value', 'parentView.selected', 'content.linkTo').cacheable()
).property('value', 'parentView.selected', 'content.linkTo')

###
Handle selection by click event.
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/mixins/ItemValue.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ Bootstrap.ItemValue = Ember.Mixin.create(

value = @get('content')
value
).property('content').cacheable()
).property('content')
)
2 changes: 1 addition & 1 deletion app/scripts/mixins/Nav.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Bootstrap.Nav = Ember.Mixin.create(

navTypeClass: ( ->
if @navType? then "nav-#{@navType}" else null
).property('navType').cacheable()
).property('navType')
)
8 changes: 4 additions & 4 deletions app/scripts/mixins/Size.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ Bootstrap.SizeSupport = Ember.Mixin.create(
extraSmallSizeClass: ( ->
pref = @get 'classTypePrefix'
if @xs then "#{pref}-xs" else null
).property('xs').cacheable()
).property('xs')

smallSizeClass: ( ->
pref = @get 'classTypePrefix'
if @small then "#{pref}-sm" else null
).property('small').cacheable()
).property('small')

largeSizeClass: ( ->
pref = @get 'classTypePrefix'
if @large then "#{pref}-lg" else null
).property('large').cacheable()
).property('large')

sizeClass: ( ->
size = @get 'size'
pref = @get 'classTypePrefix'

if size then "#{pref}-#{size}" else null
).property('size').cacheable()
).property('size')
)
Loading