Initial commit of the Modello Dashboard app
[profile/ivi/Modello_Dashboard.git] / components / statusBox / statusBox.js
1 /**
2  * @module DashboardApplication
3  */
4
5 (function ($) {
6         "use strict";
7         /**
8          * Class which provides methods to fill content of status box for JQuery plugin.
9          * @class statusBoxPluginObj
10          * @static
11          */
12         var statusBoxPluginObj = {
13                         /**
14                          * Method is initializing bottom panel.
15                          * @method init
16                          * @param caption {String} Caption of status box.
17                          * @param title {String} Title of status box.
18                          * @param status {String} Status info of status box.
19                          */
20                         init: function (caption, title, status) {
21                                 this.empty();
22                                 var appendText = '<div id="leftTopCorner" class="corner leftTopCorner"></div>';
23                                 appendText += '<div id="leftBottomCorner" class="corner leftBottomCorner"></div>';
24                                 appendText += '<div id="rightTopCorner" class="corner rightTopCorner"></div>';
25                                 appendText += '<div id="rightBottomCorner" class="corner rightBottomCorner"></div>';
26                                 appendText += '<div id="captionIndicator' + this[0].id + '" class="boxIconText captionIndicator"></div>';
27                                 appendText += '<div id="textIndicator" class="fontSizeSmall fontWeightBold fontColorNormal textIndicator">' + title.toUpperCase() + '</div>';
28                                 appendText += '<div id="statusIndicator" class="fontSizeXSmall fontWeightBold fontColorDimmed statusIndicator">' + status.toUpperCase() + '</div>';
29                                 this.append(appendText);
30                                 $("#captionIndicator" + this[0].id).boxCaptionPlugin('initSmall', caption);
31                         }
32                 };
33         /**
34          * Class which provides acces to {{#crossLink "statusBoxPluginObj"}}{{/crossLink}} methods.
35          * @class statusBoxPlugin
36          * @constructor
37          * @param method {Object} Identificator (name) of method.
38          * @return Result of called method.
39          */
40         $.fn.statusBoxPlugin = function (method) {
41                 // Method calling logic
42                 if (statusBoxPluginObj[method]) {
43                         return statusBoxPluginObj[method].apply(this, Array.prototype.slice.call(arguments, 1));
44                 } else if (typeof method === 'object' || !method) {
45                         return statusBoxPluginObj.init.apply(this, arguments);
46                 } else {
47                         $.error('Method ' + method + ' does not exist on jQuery.boxCaptionPlugin ');
48                 }
49         };
50 }(jQuery));