|
|
@@ -9,12 +9,15 @@
|
|
|
|
|
|
LUNGO.View.Element = (function(lng, undefined) {
|
|
|
|
|
|
+ var ATTRIBUTE = lng.Constants.ATTRIBUTE;
|
|
|
+ var BINDING = lng.Constants.BINDING;
|
|
|
var SELECTORS = {
|
|
|
- BUBBLE: '.bubble.count'
|
|
|
+ BUBBLE: '.bubble.count',
|
|
|
+ PROGRESS_VALUE: ' .value',
|
|
|
+ PROGRESS_PERCENTAGE: ' .labels span:last-child',
|
|
|
+ PROGRESS_DESCRIPTION: ' .labels span:first-child'
|
|
|
};
|
|
|
|
|
|
- var BINDING = lng.Constants.BINDING;
|
|
|
-
|
|
|
/**
|
|
|
* Set a counter to the element
|
|
|
*
|
|
|
@@ -26,7 +29,7 @@ LUNGO.View.Element = (function(lng, undefined) {
|
|
|
var count = function(selector, count) {
|
|
|
var element = lng.dom(selector);
|
|
|
|
|
|
- if (element ) {
|
|
|
+ if (element) {
|
|
|
if (count > 0) {
|
|
|
_setBubble(element, count);
|
|
|
} else {
|
|
|
@@ -35,6 +38,29 @@ LUNGO.View.Element = (function(lng, undefined) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ /**
|
|
|
+ * Set a progress to the element
|
|
|
+ *
|
|
|
+ * @method progress
|
|
|
+ *
|
|
|
+ * @param {string} Element query selector
|
|
|
+ * @param {number} Percentage
|
|
|
+ * @param {boolean} Show the labels: description and current percentage
|
|
|
+ * @param {string} Description
|
|
|
+ */
|
|
|
+ var progress = function(selector, percentage, with_labels, description) {
|
|
|
+ var element = lng.dom(selector);
|
|
|
+
|
|
|
+ if (element) {
|
|
|
+ percentage += ATTRIBUTE.PERCENT;
|
|
|
+
|
|
|
+ lng.dom(selector + SELECTORS.PROGRESS_VALUE).style(ATTRIBUTE.WIDTH, percentage);
|
|
|
+
|
|
|
+ _setProgressLabel(selector + SELECTORS.PROGRESS_PERCENTAGE, with_labels, percentage);
|
|
|
+ _setProgressLabel(selector + SELECTORS.PROGRESS_DESCRIPTION, with_labels, description);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
var _setBubble = function(element, count) {
|
|
|
var bubbles = element.children(SELECTORS.BUBBLE);
|
|
|
var total_bubbles = bubbles.length;
|
|
|
@@ -49,8 +75,13 @@ LUNGO.View.Element = (function(lng, undefined) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ var _setProgressLabel = function(selector, with_labels, attribute) {
|
|
|
+ lng.dom(selector).html((with_labels) ? attribute : ATTRIBUTE.EMPTY);
|
|
|
+ };
|
|
|
+
|
|
|
return {
|
|
|
- count: count
|
|
|
+ count: count,
|
|
|
+ progress: progress
|
|
|
};
|
|
|
|
|
|
})(LUNGO);
|