Commit 0a294037 authored by Xiaowu Zhang's avatar Xiaowu Zhang

add getPositionValue methode in progress gadget

parent 8d1e93b5
......@@ -8,6 +8,7 @@
<!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.relative_dest %>" type="text/javascript"></script>
<script src="../<%= curl.jquery.relative_dest %>" type="text/javascript"></script>
<!-- custom script -->
<script src="./progress.js" type="text/javascript"></script>
......
/*global window, rJS, RSVP, console */
/*jslint maxlen:80, nomen: true */
/*global window, rJS, RSVP, console, $, jQuery */
/*jslint nomen: true */
(function (window, rJS) {
(function (window, rJS, $) {
"use strict";
var gk = rJS(window);
......@@ -17,11 +17,21 @@
})
.declareMethod('getMax', function () {
return this.bar.max;
})
.declareMethod('getPositionValue', function (e) {
var posX = e.clientX,
targetLeft = $(this.bar).offset().left;
posX = ((posX - targetLeft) / $(this.bar).width());
return posX * this.bar.max;
})
.declareMethod('setAction', function (type, action) {
this.bar[type] = function (e) {
action.call(this, e);
};
});
gk.ready(function (g) {
g.bar = g.__element.getElementsByTagName('progress')[0];
g.bar.value = 10;
g.bar.max = 100;
g.bar.value = 0;
g.bar.max = 1000;
});
}(window, rJS));
}(window, rJS, jQuery));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment