c80_map 0.1.0.2 → 0.1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/app/assets/javascripts/buttons/admin_buttons/button_area_link.js +88 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_back_to_map.js +2 -4
- data/app/assets/javascripts/buttons/admin_buttons/button_cancel_remove.js +23 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_edit.js +16 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_remove.js +23 -0
- data/app/assets/javascripts/buttons/admin_buttons/button_save.js +32 -4
- data/app/assets/javascripts/c80_map.js.coffee +4 -1
- data/app/assets/javascripts/map_objects/area.js +20 -9
- data/app/assets/javascripts/map_objects/building.js +2 -3
- data/app/assets/javascripts/src/main.js +74 -10
- data/app/assets/javascripts/src/state_controller.js +97 -23
- data/app/assets/javascripts/src/utils/map_utils.js +23 -0
- data/app/assets/javascripts/src/utils/opacity_buttons_utils.js +15 -0
- data/app/assets/javascripts/src/{utils.js → utils/utils.js} +13 -0
- data/app/assets/javascripts/svg_elements/area_label.js +25 -0
- data/app/assets/javascripts/svg_elements/polygon.js +3 -1
- data/app/assets/stylesheets/map.scss +148 -66
- data/app/assets/stylesheets/view/modal_window.scss +13 -0
- data/app/controllers/c80_map/map_ajax_controller.rb +5 -1
- data/app/models/c80_map/area.rb +1 -0
- data/app/models/c80_map/area_representator.rb +75 -0
- data/app/models/c80_map/map_json.rb +28 -14
- data/app/views/c80_map/_map_row_index.html.erb +1 -0
- data/app/views/c80_map/shared/_modal_window.html.erb +28 -0
- data/db/migrate/{20160620040202_create_c80_map_areas.rb → 20160620040225_create_c80_map_areas.rb} +4 -1
- data/lib/c80_map/version.rb +1 -1
- metadata +14 -5
- /data/db/migrate/{20160620040206_create_c80_map_buildings.rb → 20160620040217_create_c80_map_buildings.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b43c74930a6f28b01f695dc6d5dbc1c4e204bf7
|
4
|
+
data.tar.gz: c8bafb47d3dd2a5302596c55640e6f41b3718ffc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a60ce784ef3a4e3ba833b91e246ac00564b807ff0b40bf88f835e9068bd80597fc380cc93ea6a1d27c93cfa45958a3115fef5e82af21b9a7619372e2e60361d8
|
7
|
+
data.tar.gz: 5a21d16436b114a496a796e7f0738cfb50dbcbfc46ef43a3b864c8ef4c4c5becb77ca3f65b86f77c4fd53203a49d34e3f13c2863c8ffd3cbd777ede5743afedb
|
data/README.md
CHANGED
@@ -22,7 +22,25 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
0. Requires:
|
26
|
+
|
27
|
+
```
|
28
|
+
#= require bootstrap/alert
|
29
|
+
#= require bootstrap/dropdown
|
30
|
+
#= require bootstrap-select
|
31
|
+
```
|
32
|
+
|
33
|
+
2. Add this:
|
34
|
+
|
35
|
+
```
|
36
|
+
@import "c80_map";
|
37
|
+
```
|
38
|
+
|
39
|
+
```
|
40
|
+
#= require c80_map
|
41
|
+
```
|
42
|
+
|
43
|
+
1. Start (Host application script):
|
26
44
|
|
27
45
|
```
|
28
46
|
$(document).ready(function() {
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
// при клике на эту кнопку произойдет показ модального окна _modal_window.html.erb
|
4
|
+
|
5
|
+
function AreaLinkButton() {
|
6
|
+
|
7
|
+
var _map = null;
|
8
|
+
var _this = this;
|
9
|
+
_this.el = null;
|
10
|
+
|
11
|
+
var show_modal_window = function () {
|
12
|
+
|
13
|
+
//var $dialog = $('#modal_window');
|
14
|
+
//$dialog.find("h4").text($t.data("wtitle"));
|
15
|
+
//$dialog.find("#form_comment").css('display','block');
|
16
|
+
//$dialog.find("input#comment_part_id").val(partid);
|
17
|
+
//$dialog.find("input#comment_author").val(author);
|
18
|
+
|
19
|
+
var $m = $('#modal_window');
|
20
|
+
var $cc = $m.find('.modal-body');
|
21
|
+
$m.find('.modal-title').text('Укажите площадь, соответствующую полигону на карте');
|
22
|
+
|
23
|
+
setTimeout(function () {
|
24
|
+
$("select#unlinked_areas").selectpicker({size: 50, tickIcon: 'hidden'});
|
25
|
+
}, 1);
|
26
|
+
|
27
|
+
setTimeout(function () {
|
28
|
+
//console.log($cc.find("button"));
|
29
|
+
$cc.find("button").on('click', function () {
|
30
|
+
if ($(this).attr('id') == "submit_area_link") {
|
31
|
+
_map.link_area();
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}, 1000);
|
35
|
+
|
36
|
+
$link_show_modal_window.click();
|
37
|
+
|
38
|
+
};
|
39
|
+
|
40
|
+
var fetch_free_areas = function () {
|
41
|
+
$.ajax({
|
42
|
+
url:'/ajax/fetch_unlinked_areas',
|
43
|
+
type:'POST',
|
44
|
+
data: {building_id:"building_id"},
|
45
|
+
dataType:'script'
|
46
|
+
}).done(fetch_free_areas_done);
|
47
|
+
};
|
48
|
+
var fetch_free_areas_done = function (data, result) {
|
49
|
+
_map.save_preloader_klass.hide();
|
50
|
+
show_modal_window();
|
51
|
+
};
|
52
|
+
|
53
|
+
var $link_show_modal_window = null;
|
54
|
+
|
55
|
+
_this.onClick = function (e) {
|
56
|
+
if (_this.el.hasClass('disabled')) return;
|
57
|
+
e.preventDefault();
|
58
|
+
|
59
|
+
console.log("<AreaLinkButton.click>");
|
60
|
+
|
61
|
+
_map.save_preloader_klass.show();
|
62
|
+
|
63
|
+
fetch_free_areas();
|
64
|
+
};
|
65
|
+
|
66
|
+
_this.init = function (button_css_selector, link_to_map) {
|
67
|
+
_map = link_to_map;
|
68
|
+
_this.el = $(button_css_selector);
|
69
|
+
_this.el.on('click', _this.onClick);
|
70
|
+
_this.hide();
|
71
|
+
|
72
|
+
// найдем кнопку, клик по которой покажет окно [_modal_window.html.erb]
|
73
|
+
$link_show_modal_window = $('.show_modal_window');
|
74
|
+
|
75
|
+
//console.log("<AreaLinkButton.init>");
|
76
|
+
//console.log(this.el);
|
77
|
+
};
|
78
|
+
|
79
|
+
_this.hide = function () {
|
80
|
+
_this.el.css('display','none');
|
81
|
+
};
|
82
|
+
|
83
|
+
_this.show = function () {
|
84
|
+
console.log("<AreaLinkButton.show>");
|
85
|
+
_this.el.css('display','block');
|
86
|
+
};
|
87
|
+
|
88
|
+
}
|
@@ -11,19 +11,17 @@ function BackToMapButton() {
|
|
11
11
|
var _onClick = function () {
|
12
12
|
_map.setMode('viewing');
|
13
13
|
|
14
|
-
_map.current_area = null;
|
15
|
-
|
16
14
|
if (_map.current_building) {
|
17
15
|
_map.current_building.exit();
|
16
|
+
_map.current_building = null;
|
18
17
|
}
|
19
18
|
|
20
19
|
if (_map.current_area) {
|
21
20
|
_map.current_area.exit();
|
21
|
+
_map.current_area = null;
|
22
22
|
}
|
23
23
|
|
24
24
|
_map.svgRemoveAllNodes();
|
25
|
-
|
26
|
-
|
27
25
|
_map.draw_childs(_map.data["childs"]);
|
28
26
|
|
29
27
|
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function CancelRemoveButton() {
|
4
|
+
|
5
|
+
var _map = null;
|
6
|
+
var _this = this;
|
7
|
+
_this.el = null;
|
8
|
+
|
9
|
+
_this.onClick = function (e) {
|
10
|
+
if (_this.el.hasClass('disabled')) return;
|
11
|
+
e.preventDefault();
|
12
|
+
|
13
|
+
console.log("<CancelRemoveButton.onClick> Выходим из режима удаления полигона.");
|
14
|
+
_map.setMode('editing');
|
15
|
+
|
16
|
+
};
|
17
|
+
|
18
|
+
_this.init = function (button_css_selector, link_to_map) {
|
19
|
+
_map = link_to_map;
|
20
|
+
_this.el = $(button_css_selector);
|
21
|
+
_this.el.on('click', _this.onClick);
|
22
|
+
};
|
23
|
+
}
|
@@ -25,6 +25,7 @@ function EditButton() {
|
|
25
25
|
_this.state = state;
|
26
26
|
_this.el.removeClass('editing');
|
27
27
|
_this.el.removeClass('viewing');
|
28
|
+
_this.el.removeClass('removing');
|
28
29
|
_this.el.removeClass('view_building');
|
29
30
|
_this.el.removeClass('edit_building');
|
30
31
|
_this.el.removeClass('view_area');
|
@@ -40,6 +41,9 @@ function EditButton() {
|
|
40
41
|
this.onClick = function (e) {
|
41
42
|
e.preventDefault();
|
42
43
|
|
44
|
+
// если после исполнения switch..case эта перменная будет true - значит надо будет вызвать кое-какой код
|
45
|
+
var mark_restore_svg_overlay = false;
|
46
|
+
|
43
47
|
switch (_this.state) {
|
44
48
|
case 'editing':
|
45
49
|
_this.setState('viewing');
|
@@ -53,20 +57,32 @@ function EditButton() {
|
|
53
57
|
_this.setState('edit_building');
|
54
58
|
break;
|
55
59
|
|
60
|
+
// находились в режиме редактирования здания, и перешли в режим просмотра здания
|
56
61
|
case 'edit_building':
|
57
62
|
_this.setState('view_building');
|
63
|
+
mark_restore_svg_overlay = true;
|
58
64
|
break;
|
59
65
|
|
60
66
|
case 'view_area':
|
61
67
|
_this.setState('edit_area');
|
68
|
+
// спрячем от клика мышки все полигоны из svg_overlay, кроме редактируемого полигона
|
69
|
+
MapUtils.svgOverlayHideAllExcept(_map.last_clicked_g);
|
62
70
|
break;
|
63
71
|
|
72
|
+
// находились в режиме редактирования площади, и перешли в режим просмотра площади
|
64
73
|
case 'edit_area':
|
65
74
|
_this.setState('view_area');
|
75
|
+
mark_restore_svg_overlay = true;
|
66
76
|
break;
|
67
77
|
|
68
78
|
}
|
69
79
|
|
80
|
+
// покажем для клика мышкой все полигоны из svg_overlay
|
81
|
+
if (mark_restore_svg_overlay) {
|
82
|
+
MapUtils.svgOverlayRestore(_map.last_clicked_g);
|
83
|
+
_map.last_clicked_g = null;
|
84
|
+
}
|
85
|
+
|
70
86
|
};
|
71
87
|
|
72
88
|
this.init = function (button_css_selector, link_to_map) {
|
@@ -0,0 +1,23 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
function RemoveButton() {
|
4
|
+
|
5
|
+
var _map = null;
|
6
|
+
var _this = this;
|
7
|
+
_this.el = null;
|
8
|
+
|
9
|
+
_this.onClick = function (e) {
|
10
|
+
if (_this.el.hasClass('disabled')) return;
|
11
|
+
e.preventDefault();
|
12
|
+
|
13
|
+
console.log("<RemoveButton.onClick> Переходим в режим удаления полигона.");
|
14
|
+
_map.setMode('removing');
|
15
|
+
|
16
|
+
};
|
17
|
+
|
18
|
+
_this.init = function (button_css_selector, link_to_map) {
|
19
|
+
_map = link_to_map;
|
20
|
+
_this.el = $(button_css_selector);
|
21
|
+
_this.el.on('click', _this.onClick);
|
22
|
+
};
|
23
|
+
}
|
@@ -40,10 +40,38 @@ function SaveChangesButton() {
|
|
40
40
|
};
|
41
41
|
|
42
42
|
var sendDataToServerDone = function (data, result) {
|
43
|
-
|
44
|
-
console.log(data);
|
45
|
-
console.log(
|
46
|
-
|
43
|
+
|
44
|
+
//console.log("<ButtonSave.sendDataToServerDone> data,result:");
|
45
|
+
//console.log(data);
|
46
|
+
// => Object
|
47
|
+
// areas: Array[1]
|
48
|
+
// 0: Object:
|
49
|
+
// id: 16,
|
50
|
+
// old_temp_id: "76400",
|
51
|
+
// buildings: Array,
|
52
|
+
// updated_locations_json: null
|
53
|
+
//console.log(result);
|
54
|
+
// => success
|
55
|
+
|
56
|
+
_map.save_preloader_klass.hide();
|
57
|
+
|
58
|
+
_map.data = data["updated_locations_json"];
|
59
|
+
|
60
|
+
//var i;
|
61
|
+
//var iarea_resp_params;
|
62
|
+
//var idrawn_area;
|
63
|
+
//for (i = 0; i< data["areas"].length; i++) {
|
64
|
+
// iarea_resp_params = data["areas"][i];
|
65
|
+
// найдем в массиве drawn_areas область, данные о которой сохранили на сервере
|
66
|
+
//idrawn_area = utils.getById(iarea["old_temp_id"], _map.drawn_areas);
|
67
|
+
//idrawn_area["id"] = iarea["id"];
|
68
|
+
//
|
69
|
+
//}
|
70
|
+
|
71
|
+
_map.drawn_areas = [];
|
72
|
+
_map.drawn_buildings = [];
|
73
|
+
_this.check_and_enable();
|
74
|
+
|
47
75
|
};
|
48
76
|
|
49
77
|
_this.onClick = function (e) {
|
@@ -1,11 +1,14 @@
|
|
1
1
|
#= require ./svg_elements/helper.js
|
2
2
|
#= require ./svg_elements/polygon.js
|
3
|
+
#= require ./svg_elements/area_label.js
|
3
4
|
|
4
5
|
#= require_directory ./events
|
5
6
|
#= require_directory ./map_objects
|
6
7
|
#= require_directory ./view
|
7
8
|
#= require_tree ./buttons
|
8
9
|
|
9
|
-
#= require ./src/utils.js
|
10
|
+
#= require ./src/utils/utils.js
|
11
|
+
#= require ./src/utils/opacity_buttons_utils.js
|
12
|
+
#= require ./src/utils/map_utils.js
|
10
13
|
#= require ./src/state_controller.js
|
11
14
|
#= require ./src/main.js
|
@@ -4,6 +4,8 @@ function Area() {
|
|
4
4
|
|
5
5
|
var _map = null;
|
6
6
|
var _this = this;
|
7
|
+
_this.id = null;
|
8
|
+
|
7
9
|
//var _polygon = null;
|
8
10
|
//var _polygon_overlay = null;
|
9
11
|
|
@@ -50,6 +52,7 @@ function Area() {
|
|
50
52
|
|
51
53
|
_map = pself;
|
52
54
|
_this._options = options;
|
55
|
+
_this.id = options["id"];
|
53
56
|
|
54
57
|
// [4ddl5df]
|
55
58
|
if (_this._options["id"] == undefined) {
|
@@ -70,6 +73,10 @@ function Area() {
|
|
70
73
|
_this._polygon.parent_building_hash = parent_building_hash;
|
71
74
|
_this._polygon = $(_this._polygon.polygon);
|
72
75
|
|
76
|
+
// подпись над полигоном показываем только админам
|
77
|
+
if (IS_ADMIN) {
|
78
|
+
_this._label = new AreaLabel(options, _map);
|
79
|
+
}
|
73
80
|
|
74
81
|
_this._polygon_overlay = Polygon.createFromSaved(options, true, _map);
|
75
82
|
_this._polygon_overlay.area = _this;
|
@@ -77,10 +84,13 @@ function Area() {
|
|
77
84
|
_this._polygon_overlay.hover(_this._mouse_in, _this._mouse_out);
|
78
85
|
_this._calcBBox();
|
79
86
|
|
80
|
-
var k = '
|
87
|
+
var k = 'unassigned';
|
81
88
|
if (options.area_hash != undefined) {
|
82
|
-
if (
|
83
|
-
k = '
|
89
|
+
if (typeof options.area_hash.id !== 'undefined') {
|
90
|
+
k = 'free';
|
91
|
+
if (!options.area_hash.is_free) {
|
92
|
+
k = 'busy';
|
93
|
+
}
|
84
94
|
}
|
85
95
|
}
|
86
96
|
_this._polygon.parent().attr("class", k);
|
@@ -94,7 +104,7 @@ function Area() {
|
|
94
104
|
};
|
95
105
|
|
96
106
|
_this.enter = function () {
|
97
|
-
|
107
|
+
console.log("<Area.enter>");
|
98
108
|
//clog(_this._options);
|
99
109
|
|
100
110
|
/* рассчитаем масштаб, при котором можно вписать прямоугольник дома в прямоугольник рабочей области */
|
@@ -108,8 +118,8 @@ function Area() {
|
|
108
118
|
_map.x = _map.normalizeX(_map.CX - _map.scale * _cx - _map.container.offset().left);
|
109
119
|
_map.y = _map.normalizeY(_map.CY - _map.scale * _cy - _map.container.offset().top);
|
110
120
|
|
111
|
-
clog("<Area.enter> [qq] moveTo: " + _map.x + ", " + _map.y);
|
112
|
-
clog("<Area.enter> Call moveTo.");
|
121
|
+
//clog("<Area.enter> [qq] moveTo: " + _map.x + ", " + _map.y);
|
122
|
+
//clog("<Area.enter> Call moveTo.");
|
113
123
|
_map.moveTo(_map.x, _map.y, _map.scale, 400, 'easeInOutCubic');
|
114
124
|
|
115
125
|
setTimeout(timeoutEnter, 400);
|
@@ -122,6 +132,7 @@ function Area() {
|
|
122
132
|
_map.current_area._polygon.parent().attr("class", k);
|
123
133
|
}
|
124
134
|
|
135
|
+
// <g class='busy viewing_area'>..<polygon >.</g>
|
125
136
|
k = _this._polygon.parent().attr("class");
|
126
137
|
k += " viewing_area";
|
127
138
|
_this._polygon.parent().attr("class", k);
|
@@ -134,7 +145,7 @@ function Area() {
|
|
134
145
|
};
|
135
146
|
|
136
147
|
_this.exit = function () {
|
137
|
-
|
148
|
+
console.log('<Area.exit>');
|
138
149
|
};
|
139
150
|
|
140
151
|
this.invalidateAnimationMask = function () {
|
@@ -182,9 +193,9 @@ function Area() {
|
|
182
193
|
_cx = xmin + (xmax - xmin) / 2;
|
183
194
|
_cy = ymin + (ymax - ymin) / 2;
|
184
195
|
|
185
|
-
clog("<Area._calcBBox> " +
|
196
|
+
//clog("<Area._calcBBox> " +
|
186
197
|
//xmin + "," + ymin + "; " + xmax + "," + ymax +
|
187
|
-
"; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
|
198
|
+
//"; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
|
188
199
|
};
|
189
200
|
|
190
201
|
_this._mouse_in = function () {
|
@@ -245,7 +245,6 @@ function Building() {
|
|
245
245
|
_image_bg = null;
|
246
246
|
_image_overlay = null;
|
247
247
|
_zoomToMe();
|
248
|
-
_map.current_building = null;
|
249
248
|
};
|
250
249
|
|
251
250
|
// выдать центр дома в логических координатах
|
@@ -289,9 +288,9 @@ function Building() {
|
|
289
288
|
_cx = xmin + (xmax - xmin) / 2;
|
290
289
|
_cy = ymin + (ymax - ymin) / 2;
|
291
290
|
|
292
|
-
console.log("<Building._calcBBox> " +
|
291
|
+
//console.log("<Building._calcBBox> " +
|
293
292
|
//xmin + "," + ymin + "; " + xmax + "," + ymax +
|
294
|
-
"; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
|
293
|
+
//"; center logical: " + _cx + "," + _cy + ", center screen: " + _map.rightX(_cx) + ", " + _map.rightY(_cy));
|
295
294
|
};
|
296
295
|
|
297
296
|
// при редактировании здания (т.е. изменении полигонов и holer-ов площадей)
|
@@ -1,5 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
var IS_ADMIN = false;
|
4
|
+
var map_on_index_page = null;
|
5
|
+
|
3
6
|
var InitMap = function () {
|
4
7
|
|
5
8
|
// - to delete start -----------------------------------------------------------------------------------------------------------------------
|
@@ -16,7 +19,7 @@ var InitMap = function () {
|
|
16
19
|
var y = (window_height - image_height)/2;
|
17
20
|
// - to delete end -----------------------------------------------------------------------------------------------------------------------
|
18
21
|
|
19
|
-
$('#map_wrapper').beMap(
|
22
|
+
map_on_index_page = $('#map_wrapper').beMap(
|
20
23
|
{
|
21
24
|
source:LOCS_HASH,
|
22
25
|
scale: scale,
|
@@ -61,10 +64,11 @@ var clog = function () {
|
|
61
64
|
self.mode = 'viewing';
|
62
65
|
self.prev_mode = null;
|
63
66
|
self.setMode = null;
|
64
|
-
self.selected_area = null;
|
67
|
+
self.selected_area = null; // ссылка на полигон из #svg_overlay
|
65
68
|
self.drawing_poligon = null;
|
66
69
|
self.events = [];
|
67
70
|
self.edit_type = null;
|
71
|
+
self.remove_button_klass = null;
|
68
72
|
self.new_button_klass = null;
|
69
73
|
self.edit_button_klass = null;
|
70
74
|
self.complete_creating_button_klass = null;
|
@@ -73,9 +77,11 @@ var clog = function () {
|
|
73
77
|
self.current_area = null;
|
74
78
|
self.is_draw = false;
|
75
79
|
self.save_button_klass = null;
|
80
|
+
self.area_link_button_klass = null;
|
76
81
|
self.drawn_areas = []; // если имеются нарисованные но несохранённые Площади - они хранятся тут
|
77
82
|
self.drawn_buildings = []; // если имеются нарисованные но несохранённые Здания - они хранятся тут
|
78
83
|
self.save_preloader_klass = null;
|
84
|
+
self.last_clicked_g = null; // начали просматривать area\building (запустили сессию), и здесь храним ссылку на последний кликнутый полигон из svg_overlay в течение сессии
|
79
85
|
|
80
86
|
// true, если:
|
81
87
|
//- юзер не кликал по кнопкам zoom
|
@@ -194,6 +200,13 @@ var clog = function () {
|
|
194
200
|
e.init('.mapplic-new-button', self);
|
195
201
|
self.new_button_klass = e;
|
196
202
|
|
203
|
+
e = new RemoveButton();
|
204
|
+
e.init('.mapplic-remove-button', self);
|
205
|
+
self.remove_button_klass = e;
|
206
|
+
|
207
|
+
e = new CancelRemoveButton();
|
208
|
+
e.init('#cancelRemoving', self);
|
209
|
+
|
197
210
|
e = new CancelCreatingButton();
|
198
211
|
e.init("#cancelCreating", self);
|
199
212
|
|
@@ -203,6 +216,12 @@ var clog = function () {
|
|
203
216
|
self.save_button_klass = new SaveChangesButton();
|
204
217
|
self.save_button_klass.init('.mapplic-save-button', self);
|
205
218
|
|
219
|
+
// при клике на эту кнопку произойдет показ модального окна
|
220
|
+
self.area_link_button_klass = new AreaLinkButton();
|
221
|
+
self.area_link_button_klass.init('.mapplic-area-link-button', self);
|
222
|
+
|
223
|
+
$('[data-toggle="tooltip"]').tooltip();
|
224
|
+
|
206
225
|
});
|
207
226
|
|
208
227
|
// Controls
|
@@ -306,7 +325,7 @@ var clog = function () {
|
|
306
325
|
|
307
326
|
//app.deselectAll();
|
308
327
|
|
309
|
-
// поменяем внешний вид - добавим класс .selected
|
328
|
+
// поменяем внешний вид полигона - добавим класс .selected
|
310
329
|
self.selected_area.select();
|
311
330
|
|
312
331
|
// запомним начальные координаты кликаы
|
@@ -376,8 +395,8 @@ var clog = function () {
|
|
376
395
|
x = self.normalizeX(x);
|
377
396
|
y = self.normalizeY(y);
|
378
397
|
|
379
|
-
clog("<Map.mousemove> x = " + x + "; y = " + y);
|
380
|
-
clog("<Map.mousemove> Call moveTo.");
|
398
|
+
//clog("<Map.mousemove> x = " + x + "; y = " + y);
|
399
|
+
//clog("<Map.mousemove> Call moveTo.");
|
381
400
|
self.moveTo(x, y);
|
382
401
|
map.data('lastX', x);
|
383
402
|
map.data('lastY', y);
|
@@ -478,13 +497,24 @@ var clog = function () {
|
|
478
497
|
/* если находится в режиме просмотра площади - переключаемся на другую площадь */
|
479
498
|
else if (self.mode == 'view_building' || self.mode == 'view_area') {
|
480
499
|
|
500
|
+
//console.log($(event.target).parent());
|
501
|
+
// => g, который живёт в #svg_overlay, или, другими словами,
|
502
|
+
// тот g, по которому кликнули последний раз,
|
503
|
+
// просматривая либо здание, либо площадь
|
504
|
+
var $viewing_g_from_svg_overlay = $(event.target).parent();
|
505
|
+
|
481
506
|
// добираемся до объекта класса Area, который обслуживает полигон
|
482
|
-
p = $
|
507
|
+
p = $viewing_g_from_svg_overlay[0];
|
483
508
|
//clog($(event.target).parent()[0].obj.area_hash);
|
484
509
|
|
485
510
|
if (p.obj && p.obj.area) {
|
511
|
+
|
512
|
+
// запомним последний кликнутый полигон
|
513
|
+
self.last_clicked_g = $viewing_g_from_svg_overlay;
|
514
|
+
|
486
515
|
var area = p.obj.area;
|
487
|
-
clog("<mouseup> Входим в площадь.");
|
516
|
+
clog("<mouseup> Входим в площадь. self.last_clicked_g = ");
|
517
|
+
clog(self.last_clicked_g);
|
488
518
|
area.enter();
|
489
519
|
}
|
490
520
|
|
@@ -528,7 +558,7 @@ var clog = function () {
|
|
528
558
|
|
529
559
|
// какой должен быть минимальный масштаб, чтобы вписать отрезок [min,max] в отрезок [p1,p2]
|
530
560
|
self.calcScale = function (min, max, p1, p2) {
|
531
|
-
clog("<calcScale> [" + min + "," + max + '] to [' + p1 + "," + p2 + "]");
|
561
|
+
//clog("<calcScale> [" + min + "," + max + '] to [' + p1 + "," + p2 + "]");
|
532
562
|
return (p2 - p1) / (max - min);
|
533
563
|
};
|
534
564
|
|
@@ -647,6 +677,7 @@ var clog = function () {
|
|
647
677
|
|
648
678
|
self.svgRemoveAllNodes = function () {
|
649
679
|
self.svg.empty();
|
680
|
+
self.svg_overlay.empty();
|
650
681
|
};
|
651
682
|
|
652
683
|
self.draw_childs = function (childs, parent_hash) {
|
@@ -840,7 +871,9 @@ var clog = function () {
|
|
840
871
|
|
841
872
|
};
|
842
873
|
var __moveToTimeout = function () {
|
843
|
-
|
874
|
+
if (self.mode === 'edit_area'|| self.mode === 'view_area') {
|
875
|
+
$("#masked").removeClass('hiddn');
|
876
|
+
}
|
844
877
|
};
|
845
878
|
var __moveToAnimate = function () {
|
846
879
|
if (self.tooltip) self.tooltip.position();
|
@@ -848,7 +881,8 @@ var clog = function () {
|
|
848
881
|
|
849
882
|
// x,y - экранные координаты
|
850
883
|
self.moveTo = function (x, y, scale, d, easing) {
|
851
|
-
clog("<self.moveTo> x = " + x + "; y = " + y + "; scale = " + scale);
|
884
|
+
//clog("<self.moveTo> x = " + x + "; y = " + y + "; scale = " + scale);
|
885
|
+
clog('<self.moveTo>');
|
852
886
|
|
853
887
|
// если подан аргумент scale(масштаб)
|
854
888
|
// перемещаемся анимированно
|
@@ -974,6 +1008,36 @@ var clog = function () {
|
|
974
1008
|
|
975
1009
|
self.rightY = function(y) {
|
976
1010
|
return (y - self.y - self.container.offset().top) / self.scale
|
1011
|
+
};
|
1012
|
+
|
1013
|
+
// взять C80Map::current_area и назначить ей Rent::area.id,
|
1014
|
+
// выбранный в окне _modal_window.html.erb
|
1015
|
+
self.link_area = function () {
|
1016
|
+
|
1017
|
+
var $m = $('#modal_window');
|
1018
|
+
var $b = $m.find('.modal-footer').find('.btn');
|
1019
|
+
var $s = $m.find('select');
|
1020
|
+
|
1021
|
+
var rent_area_id = $s.val();
|
1022
|
+
var map_area_id = self.current_area.id;
|
1023
|
+
console.log("<Map.link_area> rent_area_id = " + rent_area_id + "; map_area_id = " + map_area_id);
|
1024
|
+
|
1025
|
+
$b.click();
|
1026
|
+
self.save_preloader_klass.show();
|
1027
|
+
|
1028
|
+
$.ajax({
|
1029
|
+
url:'/ajax/link_area',
|
1030
|
+
type:'POST',
|
1031
|
+
data: {
|
1032
|
+
rent_area_id: rent_area_id,
|
1033
|
+
map_area_id: map_area_id
|
1034
|
+
},
|
1035
|
+
dataType:"json"
|
1036
|
+
}).done(function (data, result) {
|
1037
|
+
self.save_preloader_klass.hide();
|
1038
|
+
self.data = data["updated_locations_json"];
|
1039
|
+
});
|
1040
|
+
|
977
1041
|
}
|
978
1042
|
|
979
1043
|
};
|