add progress bar demo
This commit is contained in:
parent
d160699e00
commit
16ef28d260
8 changed files with 148 additions and 17 deletions
11
demos/progress/index.html
Normal file
11
demos/progress/index.html
Normal file
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>OxJS Progressbar Demo</title
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<script type="text/javascript" src="../../build/Ox.js"></script>
|
||||
<script type="text/javascript" src="js/progress.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
36
demos/progress/js/progress.js
Normal file
36
demos/progress/js/progress.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
Ox.load('UI', {debug: true, theme: 'modern'}, function() {
|
||||
|
||||
var $progressbar = Ox.Progressbar()
|
||||
.css({margin: '16px'})
|
||||
.appendTo(Ox.UI.$body)
|
||||
.start(),
|
||||
$status = Ox.Label({
|
||||
width: 256
|
||||
})
|
||||
.css({marginLeft: '16px'})
|
||||
.appendTo(Ox.UI.$body);
|
||||
$percent = $('<div>')
|
||||
.css({float: 'left', width: '60px', fontWeight: 'bold'})
|
||||
.appendTo($status);
|
||||
$remaining = $('<div>')
|
||||
.css({float: 'left', width: '180px', textAlign: 'right'})
|
||||
.appendTo($status);
|
||||
progress = 0,
|
||||
i = 0,
|
||||
interval = setInterval(function() {
|
||||
if (Math.random() < 0.25) {
|
||||
progress += 0.01;
|
||||
$progressbar.options({progress: progress});
|
||||
}
|
||||
if (i % 10 == 0 || progress >= 1) {
|
||||
var status = $progressbar.status();
|
||||
$percent.html(status.percent);
|
||||
$remaining.html('Remaining: ' + status.remaining);
|
||||
}
|
||||
if (progress >= 1) {
|
||||
clearInterval(interval);
|
||||
}
|
||||
i++;
|
||||
}, 25);
|
||||
|
||||
});
|
|
@ -70,13 +70,29 @@ Bars
|
|||
}
|
||||
|
||||
.OxProgressbar {
|
||||
height: 16px;
|
||||
height: 14px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.OxProgressbar > div {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 8px;
|
||||
margin: -1px;
|
||||
}
|
||||
.OxProgressbar > div.OxAnimate {
|
||||
-webkit-animation: move 1s linear infinite;
|
||||
}
|
||||
@-webkit-keyframes move {
|
||||
0% {
|
||||
background-position: 0 0;
|
||||
}
|
||||
100% {
|
||||
background-position: -32px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.OxResizebar {
|
||||
|
|
|
@ -8,23 +8,53 @@ Ox.Progressbar = function(options, self) {
|
|||
})
|
||||
.options(options || {})
|
||||
.addClass('OxProgressbar')
|
||||
.css({width: self.options.width});
|
||||
.css({width: self.options.width - 2 + 'px'});
|
||||
|
||||
self.$progress = $('<div>').appendTo(that);
|
||||
|
||||
setProgress();
|
||||
//setProgress();
|
||||
|
||||
function setProgress() {
|
||||
self.$progress.css({
|
||||
width: Math.round(16 + self.options.progress * (self.options.width - 16)) + 'px'
|
||||
});
|
||||
self.$progress.stop().animate({
|
||||
width: Math.round(14 + self.options.progress * (self.options.width - 16)) + 'px'
|
||||
}, 250);
|
||||
if (self.options.progress == 1) {
|
||||
self.$progress.removeClass('OxAnimate');
|
||||
$.browser.mozilla && clearInterval(self.interval);
|
||||
}
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
if (key == 'progress') {
|
||||
self.options.progress = Ox.limit(self.options.progress, 0, 1);
|
||||
setProgress();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
that.start = function() {
|
||||
self.startTime = +new Date();
|
||||
self.$progress.addClass('OxAnimate');
|
||||
if ($.browser.mozilla) {
|
||||
self.offset = 0;
|
||||
self.interval = setInterval(function() {
|
||||
self.$progress.css({backgroundPosition: --self.offset + 'px 0, 0 0'})
|
||||
}, 1000 / 32);
|
||||
}
|
||||
return that;
|
||||
};
|
||||
|
||||
that.status = function() {
|
||||
var elapsed = +new Date() - self.startTime;
|
||||
return {
|
||||
elapsed: Ox.formatDuration(Math.floor(
|
||||
elapsed / 1000
|
||||
), 'long'),
|
||||
percent: Math.round(self.options.progress * 100) + '%',
|
||||
remaining: progress ? Ox.formatDuration(Math.ceil(
|
||||
elapsed / progress * (1 - progress) / 1000
|
||||
), 'long') : 'unknown'
|
||||
};
|
||||
};
|
||||
|
||||
return that;
|
||||
|
||||
|
|
|
@ -30,12 +30,29 @@ Bars
|
|||
}
|
||||
|
||||
.OxThemeClassic .OxProgressbar {
|
||||
border-color: rgb(176, 176, 176);
|
||||
background: -moz-linear-gradient(top, rgb(208, 208, 208), rgb(255, 255, 255));
|
||||
background: -webkit-linear-gradient(top, rgb(208, 208, 208), rgb(255, 255, 255));
|
||||
}
|
||||
.OxThemeClassic .OxProgressbar > div {
|
||||
background: -moz-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
|
||||
background: -webkit-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
|
||||
border-color: rgb(176, 176, 176);
|
||||
background-image:
|
||||
-moz-repeating-linear-gradient(
|
||||
-45deg, transparent 0, transparent 25%,
|
||||
rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.05) 50%,
|
||||
transparent 50%, transparent 75%,
|
||||
rgba(0, 0, 0, 0.05) 75%, rgba(0, 0, 0, 0.05) 100%
|
||||
),
|
||||
-moz-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
|
||||
background-image:
|
||||
-webkit-repeating-linear-gradient(
|
||||
-45deg, transparent 0, transparent 25%,
|
||||
rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.05) 50%,
|
||||
transparent 50%, transparent 75%,
|
||||
rgba(0, 0, 0, 0.05) 75%, rgba(0, 0, 0, 0.05) 100%
|
||||
),
|
||||
-webkit-linear-gradient(top, rgb(224, 224, 224), rgb(192, 192, 192));
|
||||
background-size: 32px 32px, 16px 16px;
|
||||
}
|
||||
|
||||
.OxThemeClassic .OxResizebar > .OxLine {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">
|
||||
<circle cx="128" cy="128" r="104" fill="none" stroke="#404040" stroke-width="48"/>
|
||||
<line x1="40" y1="40" x2="216" y2="216" stroke="#404040" stroke-width="48"/>
|
||||
<g stroke="#404040" stroke-width="48">
|
||||
<circle cx="128" cy="128" r="104" fill="none"/>
|
||||
<line x1="40" y1="40" x2="216" y2="216"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 230 B |
|
@ -31,12 +31,29 @@ Bars
|
|||
}
|
||||
|
||||
.OxThemeModern .OxProgressbar {
|
||||
border-color: rgb(48, 48, 48);
|
||||
background: -moz-linear-gradient(top, rgb(0, 0, 0), rgb(32, 32, 32));
|
||||
background: -webkit-linear-gradient(top, rgb(0, 0, 0), rgb(32, 32, 32));
|
||||
}
|
||||
.OxThemeModern .OxProgressbar > div {
|
||||
background: -moz-linear-gradient(top, rgb(96, 96, 96), rgb(64, 64, 64));
|
||||
background: -webkit-linear-gradient(top, rgb(96, 96, 96), rgb(64, 64, 64));
|
||||
border-color: rgb(48, 48, 48);
|
||||
background-image:
|
||||
-moz-repeating-linear-gradient(
|
||||
-45deg, transparent 0, transparent 25%,
|
||||
rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.1) 50%,
|
||||
transparent 50%, transparent 75%,
|
||||
rgba(0, 0, 0, 0.05) 75%, rgba(0, 0, 0, 0.1) 100%
|
||||
),
|
||||
-moz-linear-gradient(top, rgb(96, 96, 96), rgb(64, 64, 64));
|
||||
background-image:
|
||||
-webkit-repeating-linear-gradient(
|
||||
-45deg, transparent 0, transparent 25%,
|
||||
rgba(0, 0, 0, 0.05) 25%, rgba(0, 0, 0, 0.1) 50%,
|
||||
transparent 50%, transparent 75%,
|
||||
rgba(0, 0, 0, 0.05) 75%, rgba(0, 0, 0, 0.1) 100%
|
||||
),
|
||||
-webkit-linear-gradient(top, rgb(96, 96, 96), rgb(64, 64, 64));
|
||||
background-size: 32px 32px, 16px 16px;
|
||||
}
|
||||
|
||||
.OxThemeModern .OxResizebar > .OxLine {
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256">
|
||||
<circle cx="128" cy="128" r="104" fill="none" stroke="#FFFFFF" stroke-width="48"/>
|
||||
<line x1="40" y1="40" x2="216" y2="216" stroke="#FFFFFF" stroke-width="48"/>
|
||||
<g stroke="#FFFFFF" stroke-width="48">
|
||||
<circle cx="128" cy="128" r="104" fill="none"/>
|
||||
<line x1="40" y1="40" x2="216" y2="216"/>
|
||||
</g>
|
||||
</svg>
|
Before Width: | Height: | Size: 240 B After Width: | Height: | Size: 230 B |
Loading…
Reference in a new issue