-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposition-client.js
81 lines (69 loc) · 2.72 KB
/
position-client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Hook in to constellation UI
var Constellation = Package["constellation:console"].API;
var initialLRvalue = localStorage.constellation_position_lr || 'left';
var initialTBvalue = localStorage.constellation_position_tb || 'bottom';
Constellation.addTab({
name: 'Position',
id: 'position',
headerContentTemplate: 'Constellation_position',
guideContentTemplate: 'Constellation_position_guide',
noOpen:true,
onClick: "positionCloseConstellation",
title: "Hide Constellation",
addBaseClass: 'constellation-position-' + initialLRvalue + '-' + initialTBvalue
});
Constellation.registerCallbacks({
positionCloseConstellation : function () {
Constellation.toggleConsole();
}
});
PositionDict = new ReactiveDict('constellation-position');
PositionDict.set('Constellation_position_lr', initialLRvalue);
PositionDict.set('Constellation_position_tb', initialTBvalue);
var resetBaseClasses = function () {
var lr = PositionDict.get('Constellation_position_lr');
var tb = PositionDict.get('Constellation_position_tb');
_.each(['left-top','left-bottom','right-top','right-bottom'], function (pos) {
Constellation.removeBaseClass('constellation-position-' + pos);
});
Constellation.addBaseClass('constellation-position-' + lr + '-' + tb);
}
Template.Constellation_position.helpers({
active: function (axis, pos) {
return (PositionDict.equals('Constellation_position_' + axis, pos)) ? 'constellation-menu-button-active' : '';
}
});
Template.Constellation_position.events({
'click .constellation-toggle-lr' : function (evt) {
evt.stopPropagation();
lrVal = PositionDict.get('Constellation_position_lr');
PositionDict.set('Constellation_position_lr', (lrVal === 'left') ? 'right' : 'left');
localStorage.constellation_position_lr = PositionDict.get('Constellation_position_lr');
resetBaseClasses();
},
'click .constellation-toggle-tb' : function (evt) {
evt.stopPropagation();
tbVal = PositionDict.get('Constellation_position_tb');
PositionDict.set('Constellation_position_tb', (tbVal === 'bottom') ? 'top' : 'bottom');
localStorage.constellation_position_tb = PositionDict.get('Constellation_position_tb');
resetBaseClasses();
}
});
Template.Constellation_trigger_target.helpers({
constellationActive : function () {
return !Constellation.isActive() && Constellation.tabVisible('position','plugin');
},
position : function (axis, pos) {
return (PositionDict.equals('Constellation_position_' + axis, pos)) ? '10px' : 'auto';
}
});
Template.Constellation_trigger_target.events({
'click .constellation-trigger-target' : function () {
Constellation.toggleConsole();
}
});
Meteor.startup(function () {
Meteor.defer(function () {
Blaze.render(Template.Constellation_trigger_target, document.body);
});
});