Skip to content

Commit f681225

Browse files
author
Philip Guo
committed
buh
1 parent 692a255 commit f681225

2 files changed

Lines changed: 42 additions & 4 deletions

File tree

‎v3/commentary-bubbles-demo.css‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,16 @@ textarea.bubbleInputText {
88
resize: none;
99
width: 200px;
1010
max-width: 200px;
11-
height: 60px;
12-
max-height: 60px;
11+
height: 45px;
12+
max-height: 45px;
1313
}
1414

1515

1616
.ui-tooltip-pgbootstrap,
1717
textarea.bubbleInputText {
18+
font-family: verdana, arial, helvetica, sans-serif;
1819
font-size: 9pt;
1920
line-height: 1.3em;
20-
21-
font-family: verdana, arial, helvetica, sans-serif;
2221
}
2322

2423

‎v3/commentary-bubbles-demo.js‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ AnnotationBubble.prototype.showStub = function() {
100100
assert(this.state == 'hidden' || this.state == 'edit');
101101
assert(this.text == '');
102102

103+
var myBubble = this; // to avoid name clashes with 'this' in inner scopes
104+
103105
// destroy then create a new tip:
104106
this.destroyQTip();
105107
$(this.hashID).qtip($.extend({}, qtipShared, {
@@ -115,12 +117,21 @@ AnnotationBubble.prototype.showStub = function() {
115117
}
116118
}));
117119

120+
121+
$(this.qTipID())
122+
.unbind('click') // unbind all old handlers
123+
.click(function() {
124+
myBubble.showEditor();
125+
});
126+
118127
this.state = 'stub';
119128
}
120129

121130
AnnotationBubble.prototype.showEditor = function() {
122131
assert(this.state == 'stub' || this.state == 'view');
123132

133+
var myBubble = this; // to avoid name clashes with 'this' in inner scopes
134+
124135
var ta = '<textarea class="bubbleInputText">' + this.text + '</textarea>';
125136

126137
// destroy then create a new tip:
@@ -135,6 +146,20 @@ AnnotationBubble.prototype.showEditor = function() {
135146
}
136147
}));
137148

149+
150+
$(this.qTipContentID()).find('textarea.bubbleInputText')
151+
.blur(function() { // set handler when the textarea loses focus
152+
myBubble.text = $(this).val().trim(); // strip all leading and trailing spaces
153+
154+
if (myBubble.text) {
155+
myBubble.showViewer();
156+
}
157+
else {
158+
myBubble.showStub();
159+
}
160+
})
161+
.focus(); // grab focus so that the user can start typing right away!
162+
138163
this.state = 'edit';
139164
}
140165

@@ -169,6 +194,19 @@ AnnotationBubble.prototype.restoreViewer = function() {
169194
this.state = 'view';
170195
}
171196

197+
AnnotationBubble.prototype.enterHiddenMode = function() {
198+
assert(this.state == 'stub' || this.state == 'edit');
199+
this.destroyQTip();
200+
this.state = 'hidden';
201+
}
202+
203+
AnnotationBubble.prototype.qTipContentID = function() {
204+
return '#ui-tooltip-' + this.domID + '-content';
205+
}
206+
207+
AnnotationBubble.prototype.qTipID = function() {
208+
return '#ui-tooltip-' + this.domID;
209+
}
172210

173211
AnnotationBubble.prototype.destroyQTip = function() {
174212
$(this.hashID).qtip('destroy');
@@ -222,4 +260,5 @@ $(document).ready(function() {
222260
*/
223261

224262
x = new AnnotationBubble('frame', 'v1__stack2');
263+
x.showStub();
225264
});

0 commit comments

Comments
 (0)