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

add getPositionValue methode in progress gadget

parent 8d1e93b5
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
<!-- renderjs --> <!-- renderjs -->
<script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script> <script src="../<%= copy.rsvp.relative_dest %>" type="text/javascript"></script>
<script src="../<%= copy.renderjs.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 --> <!-- custom script -->
<script src="./progress.js" type="text/javascript"></script> <script src="./progress.js" type="text/javascript"></script>
......
/*global window, rJS, RSVP, console */ /*global window, rJS, RSVP, console, $, jQuery */
/*jslint maxlen:80, nomen: true */ /*jslint nomen: true */
(function (window, rJS) { (function (window, rJS, $) {
"use strict"; "use strict";
var gk = rJS(window); var gk = rJS(window);
...@@ -17,11 +17,21 @@ ...@@ -17,11 +17,21 @@
}) })
.declareMethod('getMax', function () { .declareMethod('getMax', function () {
return this.bar.max; 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) { gk.ready(function (g) {
g.bar = g.__element.getElementsByTagName('progress')[0]; g.bar = g.__element.getElementsByTagName('progress')[0];
g.bar.value = 10; g.bar.value = 0;
g.bar.max = 100; g.bar.max = 1000;
}); });
}(window, rJS, jQuery));
}(window, rJS));
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