Skip to content

Commit 4e35aa0

Browse files
authored
Sprint 9
**Made/Proposed changes:** ## New: - task npm run buildNotMinified; - Karma/Istanbul code coverage tools. To start use the following comand: `node node_modules/.bin/karma start karma.conf.js`. To see a report look at subdirectory coverage in the default location. **Warning!** Before run you need to rebuild sdk with `buildNotMinified` task. - new callback `onKickOccupant(dialogId, initiatorUserId)` to handle a case where User2 joined chat dialog and User1 removed him from occupants; TODO: Is this method describe by JSDOC? - new callbacks `onJoinOccupant(dialogId, userId)` and `onLeaveOccupant(dialogId, userId)` to handle group dialog changes; TODO: Is this method describe by JSDOC? ## Updated: - refactored API logs format; ## Fixed: - ability to use multiple QB instances; - onMessageErrorListener does not work under (Node.js); - QB.chat.privacylist.delete method does not work (Node.js); - an issue with recursion when do QB.chat.disconnect inside QB.chat.connect's callback (Node.js) - QB.users.resetPassword always returns an error; - QB.chat.privacylist.update method does not work properly when change deny-> allow; - methods to decline the use of active/privacy lists (QB.chat.privacylist.setAsDefault('', callback) and QB.chat.privacylist.setAsActive('', callback)) does not work properly. Also, now you can pass null instead of empty string '' to decline; - QB.chat.privacylist.getNames method does not return anything if a user does not have any active/default lists. - QB.chat.privacylist.getNames returns all names except active/default at names key under Node.js. Made it similar to browser env behaviour; - QB.chat.muc.listOnlineUsers method not returns an array of integers instead of array of strings. - Event handlers to be registered with Strophe multiple times.( thanks @ruffin-- ) **How should this be manually tested?** do 'npm install' and run tests; **Does the documentation need an update?** - to describe new callback functionality onKickOccupant(dialogId, initiatorUserId); - to describe new callback functionality onJoinOccupant(dialogId, userId); - to describe new callback functionality onLeaveOccupant(dialogId, userId);
1 parent 9ec34fe commit 4e35aa0

35 files changed

+3005
-1315
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ npm-debug.log
2121

2222
# Android
2323
.gradle
24-
.idea
24+
.idea
25+
26+
# karma
27+
coverage

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,26 @@ The QuickBlox JavaScript SDK provides a JavaScript library making it even easier
1515

1616
For the library to work, you need to include either [jQuery](http://jquery.com/) or [Zepto](http://zeptojs.com/) in your html before `quickblox.min.js`, like so:
1717

18-
For correct work of JS SDK you must include the library in your html before `quickblox.min.js`, like so:
19-
2018
```html
2119
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
22-
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.5.4/quickblox.min.js"></script>
20+
<script src="https://cdnjs.cloudflare.com/ajax/libs/quickblox/2.6.0/quickblox.min.js"></script>
2321
```
2422

25-
Begin with version 2.5.0 no dependencies for work correctly is not needed.
23+
Beginning with version 2.5.0, no dependencies are need for the QuickBlox SDK to work correctly.
2624

2725
## Bower and RequireJS
2826

29-
If you use bower package manager for your project, you can install JS SDK through bower:
27+
If you use the bower package manager for your project, you can install the JS SDK through bower:
3028

3129
```
3230
bower install quickblox --save
3331
```
3432

35-
When you use **RequireJS**, you are able to use quickblox as AMD module. SDK supports [UMD (Universal Module Definition)](https://github.com/umdjs/umd) pattern for JavaScript modules. So it is possible to use SDK everywhere (as browser global variable, with AMD module loader like RequireJS or as CommonJS module for Node.js environment).
33+
When you use **RequireJS**, you are able to use QuickBlox as an AMD compliant module. The SDK supports the [UMD (Universal Module Definition)](https://github.com/umdjs/umd) pattern for JavaScript modules, so it is possible to use the SDK everywhere (as a global variable in the browser via an AMD module loader like RequireJS or as a CommonJS module in a Node.js environment).
3634

3735
## Node.js and NPM integration
3836

39-
Also you can use QuickBlox JavaScript SDK with server-side applications on NodeJS through the native node package. Just install the package in your application project like that:
37+
Also you can use QuickBlox JavaScript SDK with server-side applications on NodeJS through the native node package. Just install the package in your application project like this:
4038

4139
```
4240
npm install quickblox --save

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quickblox",
33
"description": "QuickBlox JavaScript SDK",
4-
"version": "2.5.4",
4+
"version": "2.6.0",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "quickblox.js",
77
"license": "Apache 2.0",

karma.conf.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = function(config) {
2+
config.set({
3+
basePath: '',
4+
frameworks: ['jasmine'],
5+
files: [
6+
'quickblox.min.js',
7+
'spec/config.js',
8+
'spec/QB-HelpersSpec.js',
9+
'spec/QB-ChatSpec.js',
10+
"spec/QB-CoreSpec.js",
11+
"spec/QB-UsersSpec.js",
12+
"spec/QB-ContentSpec.js",
13+
"spec/QB-DataSpec.js",
14+
"spec/QB-PushnotificationsSpec.js",
15+
"spec/QB-WebRTCSpec.js"
16+
],
17+
browsers: ['PhantomJS'],
18+
singleRun: true,
19+
reporters: ['progress', 'coverage'],
20+
preprocessors: { '*.js': ['coverage'] }
21+
});
22+
};

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "quickblox",
33
"description": "QuickBlox JavaScript SDK",
4-
"version": "2.5.4",
4+
"version": "2.6.0",
55
"homepage": "https://quickblox.com/developers/Javascript",
66
"main": "src/qbMain.js",
77
"license": "(Apache-2.0)",
@@ -54,11 +54,16 @@
5454
"gulp-notify": "^2.2.0",
5555
"gulp-uglify": "^2.0.0",
5656
"jaguarjs-jsdoc": "^1.0.1",
57-
"jasmine": "^2.4.1",
57+
"jasmine": "^2.5.2",
58+
"jasmine-core": "^2.6.0",
5859
"jquery-custom": "^1.1.1",
5960
"jsdoc": "^3.4.3",
6061
"jshint": "^2.9.3",
6162
"jshint-stylish": "^2.2.1",
63+
"karma": "^1.6.0",
64+
"karma-coverage": "^1.1.1",
65+
"karma-jasmine": "^1.1.0",
66+
"karma-phantomjs-launcher": "^1.0.4",
6267
"pump": "^1.0.1",
6368
"vinyl-source-stream": "^1.1.0"
6469
},
@@ -81,8 +86,10 @@
8186
"lint": "jshint src --reporter=node_modules/jshint-stylish",
8287
"develop": "cross-env NODE_ENV=develop gulp",
8388
"build": "npm run lint && gulp build && gulp minify",
89+
"buildNotMinified": "npm run lint && gulp build",
8490
"generateBuildVersion": "gulp generate-build_version",
8591
"docs": "rimraf docs && mkdir docs && jsdoc -c ./jsdoc.conf.json",
86-
"start": "gulp connect"
92+
"start": "gulp connect",
93+
"test": "jasmine"
8794
}
8895
}

quickblox.min.js

Lines changed: 47 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/chat/css/dashboard.css

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,18 +321,31 @@
321321
align-items: center;
322322
}
323323

324-
.message__content_wrap {
324+
.message__content {
325325
flex: 1 0;
326326
flex-wrap: nowrap;
327327
overflow: hidden;
328328
}
329329

330+
.message__sender_and_status {
331+
display: flex;
332+
margin: 0 0 4px 0;
333+
}
334+
335+
.message__text_and_date {
336+
display: flex;
337+
}
338+
330339
.message__sender_name {
331340
font-size: 14px;
332341
font-weight: 500;
333342
line-height: 20px;
334343
color: #778594;
335-
margin: 0 0 4px 0;
344+
flex: 1 0;
345+
}
346+
347+
.message__text_wrap {
348+
flex: 1 0;
336349
}
337350

338351
.message__text {
@@ -342,22 +355,26 @@
342355
color: #4A4A4A;
343356
overflow: hidden;
344357
white-space: pre-line;
345-
word-break: break-all
358+
word-break: break-all;
346359
}
347360

348361
.message__text a {
349362
color: #366BA9;
350363
}
351364

352-
.message__timestamp {
353-
width: 30px;
365+
.message__timestamp,
366+
.message__status {
354367
opacity: 0.6;
355368
font-size: 12px;
356369
line-height: 14px;
357370
text-align: right;
358371
color: #4A4A4A;
359372
}
360373

374+
.message__timestamp {
375+
width: 30px;
376+
}
377+
361378
.message_attachment {
362379
width: 100%;
363380
max-width: 328px;

samples/chat/index.html

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
<div class="login__inner">
2626
<div class="login__top">
2727
<a href="https://quickblox.com/" class="login__logo">
28-
<img src="./img/qb-logo.svg" alt="QuickBlox">
28+
<img src="./img/qb-logo.svg" alt="QuickBlox">]
2929
</a>
3030
<h1>Quickblox Chat Sample</h1>
3131
<h3>Please enter your username and user group.
3232
Users within the same group will be able
3333
to communicate, create chats with each other
3434
</h3>
3535
</div>
36-
36+
3737
<form name="loginForm" class="login__form">
3838
<div class="login_form__row">
3939
<label for="userName">User name</label>
@@ -42,14 +42,13 @@ <h3>Please enter your username and user group.
4242
<div class="login_form__row">
4343
<label for="userGroup">User group</label>
4444
<input type="text" id="userGroup" name="userGroup"/>
45-
</div>
45+
</div>
4646
<div class="login__button_wrap">
4747
<button type="submit" name="login_submit" class="btn m-login__button j-login__button" disabled>
4848
login
4949
</button>
5050
</div>
5151
</form>
52-
5352
</div>
5453
<div class="login__footer">
5554
<div class="footer__logo_wrap">
@@ -72,7 +71,6 @@ <h3>Please enter your username and user group.
7271
<a href="https://quickblox.com/" class="dashboard__logo">
7372
<img src="./img/qb-logo.svg" alt="QuickBlox">
7473
</a>
75-
7674
<div class="dashboard__status_wrap">
7775
<h2 class="dashboard__title"><%- user.user_tags %></h2>
7876
<p class="dashboard__status j-dashboard_status">
@@ -96,20 +94,18 @@ <h2 class="dashboard__title"><%- user.user_tags %></h2>
9694
</li>
9795
</ul>
9896
<ul class="sidebar__dilog_list j-sidebar__dilog_list">
99-
10097
</ul>
10198
</div>
10299
</div>
103100
</div>
104101
<div class="content j-content">
105-
106102
</div>
107103
</div>
108104
</script>
109105

110106
<script type="text/template" id="tpl_welcome">
111107
<div class="content__title j-content__title j-welcome">
112-
Welcome to QuickBlox chat sample!
108+
Welcome to QuickBlox chat sample!
113109
</div>
114110
<div class="notifications j-notifications hidden"></div>
115111
<div class="content__inner j-content__inner">
@@ -120,29 +116,29 @@ <h2 class="dashboard__title"><%- user.user_tags %></h2>
120116
</script>
121117

122118
<script type="text/template" id="tpl_userConversations">
123-
<li class="dialog__item j-dialog__item" id="<%= dialog._id %>" data-name="<%- dialog.name %>">
124-
<a class="dialog__item_link" href="#!/dialog/<%= dialog._id %>">
125-
<span class="dialog__avatar m-user__img_<%= dialog.color %> m-type_<%= dialog.type === 2 ? 'group' : 'chat' %>" >
126-
<% if(dialog.type === 2) { %>
127-
<i class="material-icons">supervisor_account</i>
128-
<% } else { %>
129-
<i class="material-icons">account_circle</i>
130-
<% } %>
131-
</span>
132-
<span class="dialog__info">
133-
<span class="dialog__name"><%- dialog.name %></span>
134-
<span class="dialog__last_message j-dialog__last_message <%= dialog.attachment ? 'attachment' : ''%>"><%- dialog.last_message%></span>
119+
<li class="dialog__item j-dialog__item" id="<%= dialog._id %>" data-name="<%- dialog.name %>">
120+
<a class="dialog__item_link" href="#!/dialog/<%= dialog._id %>">
121+
<span class="dialog__avatar m-user__img_<%= dialog.color %> m-type_<%= dialog.type === 2 ? 'group' : 'chat' %>" >
122+
<% if(dialog.type === 2) { %>
123+
<i class="material-icons">supervisor_account</i>
124+
<% } else { %>
125+
<i class="material-icons">account_circle</i>
126+
<% } %>
127+
</span>
128+
<span class="dialog__info">
129+
<span class="dialog__name"><%- dialog.name %></span>
130+
<span class="dialog__last_message j-dialog__last_message <%= dialog.attachment ? 'attachment' : ''%>"><%- dialog.last_message%></span>
131+
</span>
132+
<span class="dialog_additional_info">
133+
<span class="dialog__last_message_date j-dialog__last_message_date">
134+
<%= dialog.last_message_date_sent %>
135135
</span>
136-
<span class="dialog_additional_info">
137-
<span class="dialog__last_message_date j-dialog__last_message_date">
138-
<%= dialog.last_message_date_sent %>
139-
</span>
140-
<span class="dialog_unread_counter j-dialog_unread_counter <% !dialog.unread_messages_count ? print('hidden') : '' %>">
141-
<% dialog.unread_messages_count ? print(dialog.unread_messages_count) : '' %>
142-
</span>
136+
<span class="dialog_unread_counter j-dialog_unread_counter <% !dialog.unread_messages_count ? print('hidden') : '' %>">
137+
<% dialog.unread_messages_count ? print(dialog.unread_messages_count) : '' %>
143138
</span>
144-
</a>
145-
</li>
139+
</span>
140+
</a>
141+
</li>
146142
</script>
147143

148144
<script type="text/template" id="tpl_conversationContainer">
@@ -158,8 +154,8 @@ <h1 class="dialog__title j-dialog__title"><%- title %></h1>
158154
<div class="content__inner j-content__inner">
159155
<div class=" messages j-messages"></div>
160156
<form name="send_message" class="send_message" autocomplete="off">
161-
<textarea name="message_feald" class="message_feald" id="message_feald" autocomplete="off"
162-
autocorrect="off" autocapitalize="off" placeholder="Type a message" autofocus></textarea>
157+
<textarea name="message_feald" class="message_feald" id="message_feald" autocomplete="off"
158+
autocorrect="off" autocapitalize="off" placeholder="Type a message" autofocus></textarea>
163159
<div class="message__actions">
164160
<div class="attachments_preview j-attachments_preview"></div>
165161
<label for="attach_btn" class="attach_btn">
@@ -211,33 +207,39 @@ <h1 class="dialog__title j-dialog__title"><%- title %></h1>
211207
</script>
212208

213209
<script type="text/template" id="tpl_message">
214-
<div class="message__wrap" id="<%= message._id %>">
210+
<div class="message__wrap" id="<%= message.id %>" data-status="<%= message.status %>">
215211
<span class="message__avatar m-user__img_<%= sender ? sender.color : 'not_loaded' %>">
216212
<i class="material-icons">account_circle</i>
217213
</span>
218-
<div class="message__content_wrap">
219-
<p class="message__sender_name"><%- sender ? sender.name : 'unknown user (' + message.sender_id + ')' %></p>
220-
<% if (message.message) { %>
221-
<p class="message__text"><%= message.message %></p>
222-
<% } %>
223-
224-
<% if (message.attachments.length) { %>
225-
<div class="message__attachments_wtap">
226-
<% _.each(message.attachments, function(attachment){ %>
214+
<div class="message__content">
215+
<div class="message__sender_and_status">
216+
<p class="message__sender_name"><%- sender ? sender.name : 'unknown user (' + message.sender_id + ')' %></p>
217+
<p class="message__status j-message__status"><%= message.status %></p>
218+
</div>
219+
<div class="message__text_and_date">
220+
<div class="message__text_wrap">
221+
<% if (message.message) { %>
222+
<p class="message__text"><%= message.message %></p>
223+
<% } %>
224+
<% if (message.attachments.length) { %>
225+
<div class="message__attachments_wtap">
226+
<% _.each(message.attachments, function(attachment){ %>
227227
<img src="<%= attachment.src %>" alt="attachment" class="message_attachment">
228-
<% }); %>
228+
<% }); %>
229+
</div>
230+
<% } %>
229231
</div>
230-
<% } %>
231-
</div>
232-
<div class="message__timestamp">
233-
<%= message.date_sent %>
232+
<div class="message__timestamp">
233+
<%= message.date_sent %>
234+
</div>
235+
</div>
234236
</div>
235237
</div>
236238
</script>
237239

238240
<script type="text/template" id="tpl_notificationMessage">
239241
<div class="message__wrap m-notification_message" id="<%= _id %>">
240-
<%= message || body %>
242+
<%= message || body %>
241243
</div>
242244
</script>
243245

@@ -269,7 +271,7 @@ <h1 class="group_chat__title">New Group Chat</h1>
269271
<div class="user__details">
270272
<p class="user__name"><%- user.name %></p>
271273
<% if (user.last_request_at) { %>
272-
<p class="user__last_seen"><%= user.last_request_at %></p>
274+
<p class="user__last_seen"><%= user.last_request_at %></p>
273275
<% } %>
274276
</div>
275277
</div>
@@ -283,11 +285,11 @@ <h1 class="group_chat__title">New Group Chat</h1>
283285
</span>
284286
<% }); %>
285287
<% if (users.length){ %>
286-
<div id="fountainG">
287-
<div id="fountainG_1" class="fountainG"></div>
288-
<div id="fountainG_2" class="fountainG"></div>
289-
<div id="fountainG_3" class="fountainG"></div>
290-
</div>
288+
<div id="fountainG">
289+
<div id="fountainG_1" class="fountainG"></div>
290+
<div id="fountainG_2" class="fountainG"></div>
291+
<div id="fountainG_3" class="fountainG"></div>
292+
</div>
291293
<% } %>
292294
</div>
293295
</script>

0 commit comments

Comments
 (0)