Skip to content

Commit 17788ec

Browse files
committed
translate code comments and fix comments author caching
1 parent 6e3374c commit 17788ec

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

js/bubble.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ define([
2626
godMode: false, //temporary
2727
pointRadius: 7,
2828
bubbleTemplate: $( template ),
29-
authorName: localStorage.getItem('authorName') || 'Anonymus',
29+
authorName: localStorage.getItem('authorName') || '',
3030
pathName: window.location.pathname,
3131

3232
getDataInited: false,
@@ -61,7 +61,7 @@ define([
6161
}, this.options.pluginsOptions.bubble);
6262

6363
$(function(){
64-
_this.init();
64+
_this.init();
6565
});
6666

6767
}
@@ -79,7 +79,7 @@ define([
7979
this.addMenuItem();
8080
};
8181

82-
/* Добавляет пункт меню */
82+
/* add item to sidebar menu */
8383
Bubble.prototype.addMenuItem = function(){
8484
var _this = this,
8585
resMenuLink = _this.options.pluginsOptions.bubble.RES_MENU_LINK,
@@ -108,22 +108,24 @@ define([
108108
);
109109
};
110110

111-
/* возвращает n-й по счету section, начиная с нуля */
111+
/* return N-section starting from zero */
112112
Bubble.prototype.getSectionByNum = function (num) {
113113
return this.options.pluginsOptions.bubble.demoSections[num];
114114
};
115115

116-
/* возвращает порядковый номер section-а по элементу */
116+
/* return index of section */
117117
Bubble.prototype.getSectionNum = function (sec) {
118118
return this.options.pluginsOptions.bubble.demoSections.index(sec);
119119
};
120120

121-
/* рисует один бабл в заданом блоке, с заданными координатами и текстом */
121+
/* draw a bbl in section with coordinates and text*/
122122
Bubble.prototype.drawSingleBubble = function (id, section, x, y, timestamp, text, name, firstTimeDrawning) {
123123
var _this = this,
124124
newBubble = _this.options.pluginsOptions.bubble.bubbleTemplate.clone(true),
125+
authorName = _this.options.pluginsOptions.bubble.authorName,
125126
classBblShow = _this.options.pluginsOptions.bubble.CLASS_BBL_SHOW,
126127
classBblAuthor = _this.options.pluginsOptions.bubble.CLASS_BBL_AUTHOR,
128+
classBblName = _this.options.pluginsOptions.bubble.CLASS_BBL_NAME,
127129
classBblTxt = _this.options.pluginsOptions.bubble.CLASS_BBL_TXT,
128130
classBblInput = _this.options.pluginsOptions.bubble.CLASS_BBL_INPUT,
129131
classBblForm = _this.options.pluginsOptions.bubble.CLASS_BBL_FORM,
@@ -144,7 +146,8 @@ define([
144146
;
145147

146148
if (name === "") {
147-
name = _this.options.pluginsOptions.bubble.authorName;
149+
$('.' + classBblName).val( authorName );
150+
name = authorName;
148151
}
149152

150153
if ( !firstTimeDrawning ) {
@@ -166,7 +169,7 @@ define([
166169
}
167170
};
168171

169-
/* рисует один бабл в заданом блоке, с заданными координатами и текстом */
172+
/* draw a bbl in section with coordinates and text */
170173
Bubble.prototype.createBubble = function (id, section, x, y, timestamp, text, name, firstTimeDrawning) {
171174
var idNewBbbl = this.options.pluginsOptions.bubble.ID_NEW_BBL;
172175

@@ -189,11 +192,11 @@ define([
189192
}, 0);
190193
};
191194

192-
/* сабмит бабла */
193195
Bubble.prototype.submitBubble = function () {
194196
var _this = this,
195197

196198
idNewBbbl = _this.options.pluginsOptions.bubble.ID_NEW_BBL,
199+
authorName = _this.options.pluginsOptions.bubble.authorName,
197200
classBblShow = _this.options.pluginsOptions.bubble.CLASS_BBL_SHOW,
198201
classBblAuthor = _this.options.pluginsOptions.bubble.CLASS_BBL_AUTHOR,
199202
classBblTxt = _this.options.pluginsOptions.bubble.CLASS_BBL_TXT,
@@ -208,10 +211,7 @@ define([
208211
timestamp = bubbleEl.attr("timestamp"),
209212
text = bubbleEl.find("." + classBblInput).val(),
210213

211-
//temp
212-
name = bubbleEl.find("." + classBblName).val() ||
213-
localStorage.getItem('authorName') ||
214-
'Anonymus',
214+
name = bubbleEl.find("." + classBblName).val() || authorName,
215215

216216
x = bubbleEl.css("left"),
217217
y = bubbleEl.css("top"),
@@ -224,7 +224,13 @@ define([
224224
bubbleEl.find("." + classBblInfo).addClass( classBblShow );
225225
bubbleEl.addClass( classBblShow );
226226

227-
if ( name ) localStorage.setItem('authorName', name);
227+
// save author to local storage and plugin settings
228+
if ( name ) {
229+
localStorage.setItem('authorName', name);
230+
231+
// need for showing existing author name in second bubbles
232+
_this.options.pluginsOptions.bubble.authorName = name;
233+
}
228234

229235
this.pushBubbleData({
230236
section: section,
@@ -248,7 +254,7 @@ define([
248254
this.setBubble(bbl, bubbleEl);
249255
};
250256

251-
/* рисует все бабблы из массива бабблов */
257+
/* draw all bbl from array of bubbles */
252258
Bubble.prototype.drawBubblesArray = function (bubbles) {
253259
if(typeof bubbles === 'undefined') {
254260
bubbles = this.options.pluginsOptions.bubble.bubbleData;

0 commit comments

Comments
 (0)