Skip to content

Commit e140ede

Browse files
author
Julien Coutinho
committed
Fix issues #158 and #125
Add an event triggered on tooltips' views to take into account the last scale factor stored into the screen's view containing the tooltips. Change css position of the container of a screen and its objects to be relative to its own container.
1 parent 27b1802 commit e140ede

4 files changed

Lines changed: 36 additions & 2 deletions

File tree

dahu/core/app/scripts/behaviors/workspace/objects/draggable.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ define([
3333
});
3434
},
3535

36+
events: {
37+
"scale:change": "onScaleChange"
38+
},
39+
3640
onDomRefresh: function() {
3741
var self = this;
3842

@@ -69,6 +73,10 @@ define([
6973
});
7074
}
7175
});
76+
},
77+
78+
onScaleChange: function(scale) {
79+
this.scale = scale;
7280
}
7381
});
7482

dahu/core/app/scripts/views/workspace/objects/tooltip.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,15 @@ define([
3131
* Tooltip view
3232
*/
3333
return ObjectView.extend({
34+
3435
template: Handlebars.default.compile(tooltipTemplate),
3536

3637
className: 'object tooltip ui-widget-content',
3738

39+
events: {
40+
"scale:change": "onScaleChange"
41+
},
42+
3843
triggers: {
3944
"dblclick": {
4045
event: 'app:workspace:tooltip:edit',
@@ -76,6 +81,15 @@ define([
7681

7782
onRender: function() {
7883
this.updateColor();
84+
},
85+
86+
onScaleChange: function(scale) {
87+
// notice to all the behaviours that the scale changed
88+
// there is no way to identify a behaviour in _behaviours
89+
// where the changement of scale is really effective
90+
for(var i in this._behaviors) {
91+
this._behaviors[i].trigger("scale:change", scale);
92+
}
7993
}
8094
});
8195
});

dahu/core/app/scripts/views/workspace/screen.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ define([
3535
MouseView,
3636
TooltipView,
3737
// templates
38-
screenTemplate){
38+
screenTemplate
39+
) {
3940

4041
/**
4142
* Workspace screen view
@@ -56,6 +57,13 @@ define([
5657
// so that we can render the collection as children
5758
// of this parent node
5859
this.collection = this.screencast.model.getScreenById(this.screenId).get('objects');
60+
61+
// we save the value to update the new tooltips
62+
this.lastScaleFactor = 1.0;
63+
},
64+
65+
onAddChild: function(view) {
66+
view.triggerMethod("scale:change", this.lastScaleFactor);
5967
},
6068

6169
// We select the ChildView depending on the object type.
@@ -72,6 +80,7 @@ define([
7280
onShow: function() {
7381
// setup UI
7482
//@remove var ctrl = reqres.request('app:screencast:controller');
83+
var self = this;
7584

7685
this.$('.container').css({
7786
//@remove width: ctrl.getScreencastWidth(),
@@ -88,8 +97,10 @@ define([
8897
}, function( transform, element ) {
8998
// scale the workspace
9099
fit.cssTransform(transform, element);
100+
// we save the value to update the new tooltips
101+
self.lastScaleFactor = transform.scale;
91102
// notify listener that workspace was scaled
92-
events.trigger('app:workspace:onScaleChanged', transform.scale);
103+
events.trigger('app:workspace:onScaleChanged', self.lastScaleFactor);
93104
});
94105
},
95106

dahu/core/app/styles/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ html, body {
9999
height: 100%;
100100

101101
.container {
102+
position: relative;
102103
// reset padding and margin added by bootstrap
103104
padding: 0px;
104105
margin: 0px;

0 commit comments

Comments
 (0)