1 //audio time progress bar JQuery Plugin
3 * @module MultimediaPlayerApplication
8 * Class which provides methods to fill content of time progress bar for JQuery plugin.
9 * @class TimeProgressBarObj
12 var TimeProgressBarObj = {
14 * Holds current object of this JQuery plugin.
15 * @property thisObj {Object}
19 * Holds current object of position indicator.
20 * @property positionIndicator {Object}
22 positionIndicator: null,
24 * Holds current text of top right caption.
25 * @property rightText {String}
29 * Holds current text of top left caption.
30 * @property leftText {String}
34 * Holds current count of songs in playlist.
35 * @property count {Integer}
39 * Holds current index of song from playlist.
40 * @property index {Integer}
44 * Holds current estimation of song from playlist.
45 * @property estimation {String}
49 * Holds current position of song from playlist.
50 * @property position {Integer}
54 * Method is initializing time progress bar.
59 this.append('<div id="songIndex" class="leftText fontColorNormal fontSizeLarge fontWeightBold">' +
62 '<div id="songTime" class="rightText fontColorTheme fontSizeLarge fontWeightBold">' +
65 '<div id="songProgress" class="progressBar borderColorTheme">' +
66 '<div id="songSeek" class="progressPot bgColorTheme boxShadow3"></div>' +
69 TimeProgressBarObj.positionIndicator = $('#songProgress #songSeek');
70 TimeProgressBarObj.leftText = $('#songIndex');
71 TimeProgressBarObj.rightText = $('#songTime');
72 TimeProgressBarObj.positionIndicator.css({width: '0 %'});
73 TimeProgressBarObj.thisObj = this;
75 $("#songProgress").click(function (e) {
76 var elWidth = $(this).width(),
77 parentOffset = $(this).parent().offset(),
78 relativeXPosition = (e.pageX - parentOffset.left), //offset -> method allows you to retrieve the current position of an element 'relative' to the document
81 progress = relativeXPosition / elWidth;
83 TimeProgressBarObj.thisObj.trigger('positionChanged', {position: (progress * 100)});
87 * Method is rendering position bar and position information from song.
90 show: function (objSong) {
91 $("#songIndex").empty();
92 $("#songIndex").append(objSong.index + '/' + objSong.count);
93 $("#songTime").empty();
94 $("#songTime").append(objSong.estimation);
95 TimeProgressBarObj.count = objSong.count;
96 TimeProgressBarObj.index = objSong.index;
97 TimeProgressBarObj.estimation = objSong.estimation;
98 TimeProgressBarObj.positionIndicator.css({width: objSong.position + '%'});
99 TimeProgressBarObj.position = objSong.position;
103 * Class which provides acces to TimeProgressBarObj methods.
104 * @class timeProgressBar
106 * @param method {Object} Identificator (name) of method.
107 * @return Result of called method.
109 $.fn.timeProgressBar = function (method) {
110 // Method calling logic
111 if (TimeProgressBarObj[method]) {
112 return TimeProgressBarObj[method].apply(this, Array.prototype.slice.call(arguments, 1));
113 } else if (typeof method === 'object' || !method) {
114 return TimeProgressBarObj.init.apply(this, arguments);
116 $.error('Method ' + method + ' does not exist on jQuery.infoPanelAPI');