Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

some refactoring for performance issues

  • Loading branch information...
commit 0fb742541bfad881df733715003d931f4afd706b 1 parent 07cbbe3
Acaz Souza authored
2  src/index.html
@@ -74,7 +74,7 @@
74 74 progressBar.progressBar('start');
75 75 }
76 76
77   - applyNewExpression();
  77 + //applyNewExpression();
78 78 });
79 79 </script>
80 80 </body>
44 src/jquery.progressbar.js
@@ -5,42 +5,54 @@
5 5 'done': null
6 6 };
7 7
8   - var decreaseBar = function (progressBar) {
9   - insertCSSTransitions(progressBar);
10   - $(progressBar).find('.bar').width(0);
  8 + var $progressBar, $bar;
11 9
12   - if ($.isFunction(settings.done)) {
13   - $(progressBar).find('.bar').bind('transitionEnd', settings.done);
14   - }
  10 + var decreaseBar = function () {
  11 + insertCSSTransitions();
  12 + $bar.width(0);
15 13 }
16 14
17   - var insertCSSTransitions = function (progressBar) {
18   - var timeBar = settings.timeBar;
19   - $(progressBar).find('.bar').attr('style', 'transition:width ' + timeBar + 's; -moz-transition:width ' + timeBar + 's; -webkit-transition:width ' + timeBar + 's; -o-transition:width ' + timeBar + 's');
  15 + var insertCSSTransitions = function () {
  16 + $bar.attr('style', 'transition:width ' + settings.timeBar + 's; -moz-transition:width ' + settings.timeBar + 's; -webkit-transition:width ' + settings.timeBar + 's; -o-transition:width ' + settings.timeBar + 's');
20 17 }
21 18
22   - var removeCSSTransitions = function (progressBar) {
23   - $(progressBar).find('.bar').removeAttr('style');
  19 + var removeCSSTransitions = function () {
  20 + $bar.removeAttr('style');
24 21 }
25 22
26 23 var methods = {
27 24 init: function (options) {
28 25 settings = $.extend(settings, options);
29 26
30   - return this.each(function () {
31   - $(this).find('.bar').live('webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd', function () {
32   - $(this).trigger('transitionEnd');
  27 + $progressBar = $(this);
  28 + $bar = $progressBar.find('.bar');
  29 +
  30 + if ($.isFunction(settings.done))
  31 + $bar.bind('transitionEnd', function () {
  32 + var now = new Date();
  33 + console.log(now);
  34 +
  35 + settings.done;
33 36 });
  37 +
  38 + $bar.bind('webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd', function () {
  39 + $bar.trigger('transitionEnd');
  40 +
34 41 });
  42 +
  43 + return $progressBar;
35 44 },
36 45 start: function () {
37 46 return this.each(function () {
38   - decreaseBar(this);
  47 + decreaseBar();
  48 +
  49 + var now = new Date();
  50 + console.log(now);
39 51 });
40 52 },
41 53 reset: function () {
42 54 return this.each(function () {
43   - removeCSSTransitions(this);
  55 + removeCSSTransitions();
44 56 });
45 57 }
46 58 };
18 tests/jQuery.ProgressBarTests.html
@@ -118,17 +118,11 @@
118 118 </script>
119 119 </head>
120 120 <body>
121   - <h1 id="qunit-header">
122   - jQuery.ProgressBar Tests</h1>
123   - <h2 id="qunit-banner">
124   - </h2>
125   - <div id="qunit-testrunner-toolbar">
126   - </div>
127   - <h2 id="qunit-userAgent">
128   - </h2>
129   - <ol id="qunit-tests">
130   - </ol>
131   - <div id="qunit-fixture">
132   - test markup, will be hidden</div>
  121 + <h1 id="qunit-header">jQuery.ProgressBar Tests</h1>
  122 + <h2 id="qunit-banner"></h2>
  123 + <div id="qunit-testrunner-toolbar"></div>
  124 + <h2 id="qunit-userAgent"></h2>
  125 + <ol id="qunit-tests"></ol>
  126 + <div id="qunit-fixture">test markup, will be hidden</div>
133 127 </body>
134 128 </html>

0 comments on commit 0fb7425

Please sign in to comment.
Something went wrong with that request. Please try again.