Skip to content

Commit 1761794

Browse files
committed
place comments into special wrapper, outside source_example
1 parent fc97c4f commit 1761794

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Comments plugin for [SourceJS](http://sourcejs.com) for commenting Spec examples
55

66
![image](http://d.pr/i/kISN+)
77

8+
Compatible with SourceJS v.0.5.6+.
9+
810
___
911

1012
To install, run npm in `sourcejs/user` folder:
@@ -13,11 +15,11 @@ To install, run npm in `sourcejs/user` folder:
1315
npm install sourcejs-comments --save
1416
```
1517

16-
Then run Grunt update in SourceJS root:
18+
Then run build command in SourceJS root:
1719

1820
```
1921
cd sourcejs
20-
grunt update
22+
npm run build
2123
```
2224

2325
After installation, all your Specs pages will have "Add description" tumbler in inner menu, that will active the plugin.
@@ -28,7 +30,7 @@ After installation, all your Specs pages will have "Add description" tumbler in
2830

2931
As [MongoDB](http://www.mongodb.org/) is not essential dependency for SourceJS, you must install it separately, to work with plugins that expect data storage.
3032

31-
[Install it](http://docs.mongodb.org/manual/installation/), run locally or remotely and configure your SourceJS in `sourcejs/user/options.js`:
33+
[Install MongoDB locally](http://docs.mongodb.org/manual/installation/) or get it from [MongoLab](https://mongolab.com) and configure your SourceJS in `sourcejs/user/options.js`:
3234

3335
```json
3436
core: {
@@ -72,6 +74,6 @@ mongoose.connect(dbAdress);
7274
/* /Connect to DB */
7375
```
7476

75-
___
77+
## Legacy versions
7678

77-
Compatible with SourceJS v0.4+, for v0.3.* use [previous release](https://github.com/sourcejs/sourcejs-comments/archive/v0.0.9.zip).
79+
For SourceJS v0.3.* use older plugin version [0.0.x](https://github.com/sourcejs/sourcejs-comments/archive/v0.0.9.zip).

assets/css/bubble.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
* @author Alexey Ostrovsky, Gennady Tsarinny
55
*/
66

7+
.source-bbl_container {
8+
position: relative;
9+
z-index: 9000;
10+
}
11+
712
.source-bbl_w {
813
position: absolute;
914
z-index: 9000;

assets/index.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ define([
5353
CLASS_BBL_INFO: 'source-bbl_info',
5454
CLASS_BBL_NAME: 'source-bbl_name',
5555

56+
CLASS_BBL_CONTAINER: 'source-bbl_container',
5657
CLASS_BBL_WRAPPER: 'source-bbl_w',
5758

5859
ID_NEW_BBL: 'newBbl'
@@ -117,6 +118,23 @@ define([
117118
return this.options.pluginsOptions.bubble.demoSections.index(sec);
118119
};
119120

121+
Bubble.prototype.getSectionCommentContainer = function (num) {
122+
var opts = this.options.pluginsOptions.bubble;
123+
var $section = $(this.getSectionByNum(num));
124+
var $container;
125+
126+
if (!$section || $section.length === 0) return;
127+
128+
if ($section.prev().hasClass(opts.CLASS_BBL_CONTAINER)) {
129+
$container = $section.prev();
130+
} else {
131+
$container = $('<div class="source_clean '+ opts.CLASS_BBL_CONTAINER +'"></div>');
132+
$section.before($container);
133+
}
134+
135+
return $container;
136+
};
137+
120138
/* draw a bbl in section with coordinates and text*/
121139
Bubble.prototype.drawSingleBubble = function (id, section, x, y, timestamp, text, name, firstTimeDrawning) {
122140
var _this = this,
@@ -134,14 +152,18 @@ define([
134152
classBblHook = _this.options.pluginsOptions.bubble.CLASS_BBL_HOOK,
135153
classBblPointHook = _this.options.pluginsOptions.bubble.CLASS_BBL_POINT_HOOK;
136154

155+
var bubleContainer = _this.getSectionCommentContainer(section);
156+
157+
if (!bubleContainer) return;
158+
137159
// bbl form wrapper
138160
newBubble.css({
139161
left: x,
140162
top: y
141163
})
142164
.attr("timestamp", timestamp)
143165
.attr("id", id)
144-
.appendTo(_this.getSectionByNum(section))
166+
.appendTo(bubleContainer)
145167
;
146168

147169
if (name === "") {
@@ -215,9 +237,7 @@ define([
215237
x = bubbleEl.css("left"),
216238
y = bubbleEl.css("top"),
217239

218-
section = this.getSectionNum(bubbleEl.closest("." + classSourceExample));
219-
220-
240+
section = this.getSectionNum(bubbleEl.parent().next("." + classSourceExample));
221241

222242
// save author to local storage and plugin settings
223243
if ( name ) {

0 commit comments

Comments
 (0)