From 7eb340ec589acd56ad960a020969822636c2bc54 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sun, 27 Nov 2011 17:31:12 -0800 Subject: add code to reset data for collapsed element so that item can be intitialized with correct options --- js/bootstrap-alert.js | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 js/bootstrap-alert.js (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js new file mode 100644 index 000000000..210512a8b --- /dev/null +++ b/js/bootstrap-alert.js @@ -0,0 +1,76 @@ +/* ========================================================== + * bootstrap-alert.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#alerts + * ========================================================== + * Copyright 2011 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================================================== */ + + +!function( $ ){ + + "use strict" + + /* ALERT CLASS DEFINITION + * ====================== */ + + var dismiss = '[data-dismiss="alert"]' + , Alert = function ( el ) { + $(el).delegate(dismiss, 'click', this.close) + } + + Alert.prototype = { + + close: function ( e ) { + var $element = $(this) + + $element = $element.hasClass('alert-message') ? $element : $element.parent() + e && e.preventDefault() + $element.removeClass('in') + + function removeElement() { + $element.remove() + } + + $.support.transition && $element.hasClass('fade') ? + $element.bind($.support.transition.end, removeElement) : + removeElement() + } + + } + + + /* ALERT PLUGIN DEFINITION + * ======================= */ + + $.fn.alert = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('alert') + if (!data) $this.data('alert', (data = new Alert(this))) + if (typeof option == 'string') data[option].call($this) + }) + } + + $.fn.alert.Alert = Alert + + + /* ALERT DATA-API + * ============== */ + + $(function () { + $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close) + }) + +}( window.jQuery || window.ender ) \ No newline at end of file -- cgit v1.2.3 From cee2f61898f4807311402fed747a93ee68a31f8f Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Wed, 30 Nov 2011 22:42:22 -0800 Subject: define constructor on prototypes --- js/bootstrap-alert.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 210512a8b..069130080 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -32,7 +32,9 @@ Alert.prototype = { - close: function ( e ) { + constructor: Alert + + , close: function ( e ) { var $element = $(this) $element = $element.hasClass('alert-message') ? $element : $element.parent() -- cgit v1.2.3 From 1ef5fa7d6b4e50230c0c12919b0a06a9a2ac07f1 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 20 Dec 2011 18:02:47 -0800 Subject: giant refactor - all spec passing again... --- js/bootstrap-alert.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 069130080..db9116f76 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -27,7 +27,7 @@ var dismiss = '[data-dismiss="alert"]' , Alert = function ( el ) { - $(el).delegate(dismiss, 'click', this.close) + $(el).on('click', dismiss, this.close) } Alert.prototype = { @@ -72,7 +72,7 @@ * ============== */ $(function () { - $('body').delegate(dismiss, 'click.alert.data-api', Alert.prototype.close) + $('body').on('click.alert.data-api', dismiss, Alert.prototype.close) }) -}( window.jQuery || window.ender ) \ No newline at end of file +}( window.jQuery ) \ No newline at end of file -- cgit v1.2.3 From 0980a33b4703677e1aaf3cd949c0437512fa6f33 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 20 Dec 2011 19:37:41 -0800 Subject: update all to new on api + add animation support to tabs --- js/bootstrap-alert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index db9116f76..af15cbd7b 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -46,7 +46,7 @@ } $.support.transition && $element.hasClass('fade') ? - $element.bind($.support.transition.end, removeElement) : + $element.on($.support.transition.end, removeElement) : removeElement() } -- cgit v1.2.3 From f72a94ae2879ebfc5206dd40d5db175e13113850 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Tue, 20 Dec 2011 23:28:48 -0800 Subject: update more readme changes - introduce target specificty convention to more plugins --- js/bootstrap-alert.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index af15cbd7b..90961cdd3 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -35,18 +35,22 @@ constructor: Alert , close: function ( e ) { - var $element = $(this) + var $this = $(this) + , selector = $this.attr('data-target') || $this.attr('href') + , $parent = $(selector) - $element = $element.hasClass('alert-message') ? $element : $element.parent() e && e.preventDefault() - $element.removeClass('in') + + $parent.length || ($parent = $this.hasClass('alert-message') ? $this : $this.parent()) + + $parent.removeClass('in') function removeElement() { - $element.remove() + $parent.remove() } - $.support.transition && $element.hasClass('fade') ? - $element.on($.support.transition.end, removeElement) : + $.support.transition && $parent.hasClass('fade') ? + $parent.on($.support.transition.end, removeElement) : removeElement() } @@ -65,7 +69,7 @@ }) } - $.fn.alert.Alert = Alert + $.fn.alert.Constructor = Alert /* ALERT DATA-API -- cgit v1.2.3 From 5de1e39a8fba831faa170f46e868068fa069dd0e Mon Sep 17 00:00:00 2001 From: Jonathan Ingram Date: Thu, 22 Dec 2011 16:41:26 +1100 Subject: From #822 --- js/bootstrap-alert.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 90961cdd3..1ce8f01bf 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -39,6 +39,8 @@ , selector = $this.attr('data-target') || $this.attr('href') , $parent = $(selector) + $parent.trigger('close') + e && e.preventDefault() $parent.length || ($parent = $this.hasClass('alert-message') ? $this : $this.parent()) @@ -47,6 +49,8 @@ function removeElement() { $parent.remove() + + $parent.trigger('closed') } $.support.transition && $parent.hasClass('fade') ? -- cgit v1.2.3 From 16eccc43d9fa6317818b5d1621d0477150214488 Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Sat, 14 Jan 2012 23:28:48 -0800 Subject: dates updated to 2012 --- js/bootstrap-alert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 1ce8f01bf..96b9786aa 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -2,7 +2,7 @@ * bootstrap-alert.js v2.0.0 * http://twitter.github.com/bootstrap/javascript.html#alerts * ========================================================== - * Copyright 2011 Twitter, Inc. + * Copyright 2012 Twitter, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. -- cgit v1.2.3 From 3ed836b19888215fe5ad9539898502d203712021 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Fri, 20 Jan 2012 13:50:36 -0800 Subject: should check for alert class not alertmessage --- js/bootstrap-alert.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 96b9786aa..d6d2108f9 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -43,13 +43,12 @@ e && e.preventDefault() - $parent.length || ($parent = $this.hasClass('alert-message') ? $this : $this.parent()) + $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent()) $parent.removeClass('in') function removeElement() { $parent.remove() - $parent.trigger('closed') } -- cgit v1.2.3 From 5844aa550d5a2d22d527d80cfa42443914d28c1f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Thu, 26 Jan 2012 15:00:59 -0800 Subject: consistent new lines at ends of files --- js/bootstrap-alert.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index d6d2108f9..2df64c6e1 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -82,4 +82,4 @@ $('body').on('click.alert.data-api', dismiss, Alert.prototype.close) }) -}( window.jQuery ) \ No newline at end of file +}( window.jQuery ) -- cgit v1.2.3 From e61164e67a048c20c512e99335e3adfcc3b63604 Mon Sep 17 00:00:00 2001 From: Jacob Thornton Date: Sat, 28 Jan 2012 01:35:13 -0800 Subject: all unit tests passing in ie7 --- js/bootstrap-alert.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'js/bootstrap-alert.js') diff --git a/js/bootstrap-alert.js b/js/bootstrap-alert.js index 2df64c6e1..4a65b135a 100644 --- a/js/bootstrap-alert.js +++ b/js/bootstrap-alert.js @@ -36,9 +36,15 @@ , close: function ( e ) { var $this = $(this) - , selector = $this.attr('data-target') || $this.attr('href') - , $parent = $(selector) + , selector = $this.attr('data-target') + , $parent + if (!selector) { + selector = $this.attr('href') + selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 + } + + $parent = $(selector) $parent.trigger('close') e && e.preventDefault() -- cgit v1.2.3