Permalink
Browse files

attach methods to self instead of div

  • Loading branch information...
1 parent cd85be2 commit addc094eb2a4f13daec002b80d7426d42761af6e @substack committed Jul 4, 2011
Showing with 11 additions and 5 deletions.
  1. +10 −3 browser.js
  2. +1 −2 example/progress/main.js
  3. BIN images/computing.png
View
@@ -40,13 +40,14 @@ module.exports = function () {
.appendTo(remaining)
;
- div.fraction = function (n) {
+ var self = {};
+ self.fraction = function (n) {
if (n === undefined) return complete / 100;
else return div.percent(Math.floor(n * 100));
};
var complete = 0;
- div.percent = function (n) {
+ self.percent = function (n) {
if (n === undefined) return complete;
if (n < 0) n = 0;
@@ -61,5 +62,11 @@ module.exports = function () {
return div;
};
- return div;
+ self.element = div;
+ self.appendTo = function () {
+ div.appendTo.apply(div, arguments);
+ return self;
+ };
+
+ return self;
};
View
@@ -2,8 +2,7 @@ var progressify = require('progressify');
var $ = require('jquery-browserify');
$(window).ready(function () {
- var p = progressify();
- p.appendTo($('#p'));
+ var p = progressify().appendTo($('#p'));
var iv0 = setInterval(function () {
p.percent(p.percent() + 1);
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit addc094

Please sign in to comment.