togo 0.4.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +210 -0
- data/lib/togo/admin/admin.rb +6 -25
- data/lib/togo/admin/helpers.rb +57 -0
- data/lib/togo/admin/public/css/screen.css +329 -190
- data/lib/togo/admin/public/img/arrow-down.png +0 -0
- data/lib/togo/admin/public/img/arrows.png +0 -0
- data/lib/togo/admin/public/img/bg-header.png +0 -0
- data/lib/togo/admin/public/img/button-bg-delete.png +0 -0
- data/lib/togo/admin/public/img/button-bg-save.png +0 -0
- data/lib/togo/admin/public/img/footer-bg.png +0 -0
- data/lib/togo/admin/public/img/subhead-bg.png +0 -0
- data/lib/togo/admin/public/js/edit.js +23 -24
- data/lib/togo/admin/public/js/index.js +3 -2
- data/lib/togo/admin/public/js/togo.js +46 -14
- data/lib/togo/admin/views/_paging.erb +14 -0
- data/lib/togo/admin/views/edit.erb +6 -9
- data/lib/togo/admin/views/index.erb +44 -44
- data/lib/togo/admin/views/layout.erb +14 -16
- data/lib/togo/admin/views/new.erb +5 -2
- data/lib/togo/model/model.rb +20 -38
- data/lib/togo/model/relationship_manager/many_to_one.rb +19 -0
- data/lib/togo/model/relationship_manager/one_to_many.rb +19 -0
- data/lib/togo/model/relationship_manager/relationship_manager.rb +40 -0
- data/lib/togo/model/types/belongs_to.erb +42 -40
- data/lib/togo/model/types/has_n.erb +44 -42
- data/lib/togo/model/types/many_to_many.erb +44 -42
- metadata +17 -7
- data/README +0 -29
@@ -2,263 +2,402 @@
|
|
2
2
|
outline: none;
|
3
3
|
}
|
4
4
|
body {
|
5
|
-
|
5
|
+
background: #fdfdfd;
|
6
|
+
font: 100% helvetica, arial, sans-serif;
|
7
|
+
margin: 0;
|
6
8
|
padding: 0;
|
9
|
+
}
|
10
|
+
.error {
|
11
|
+
background: #800000 url(/img/button-bg-delete.png) repeat-x top left;
|
12
|
+
text-shadow: 0 1px 1px #710000;
|
13
|
+
border: 1px solid #a12f19;
|
14
|
+
-webkit-border-radius: 2px;
|
15
|
+
-moz-border-radius: 2px;
|
16
|
+
color: #FFF;
|
17
|
+
}
|
18
|
+
h3.error {
|
7
19
|
margin: 0;
|
20
|
+
padding: 10px;
|
21
|
+
}
|
22
|
+
#container {
|
23
|
+
background: #f5f5f5;
|
8
24
|
}
|
9
25
|
#header {
|
10
|
-
background: #
|
11
|
-
|
26
|
+
background: #586069 url(/img/bg-header.png) repeat-x top left;
|
27
|
+
}
|
28
|
+
#header h1 {
|
29
|
+
font-size: 24px;
|
12
30
|
color: #FFF;
|
13
|
-
|
14
|
-
font-
|
15
|
-
|
16
|
-
|
31
|
+
text-shadow: 1px 1px 1px #5e6a76;
|
32
|
+
font-weight: normal;
|
33
|
+
line-height: 60px;
|
34
|
+
margin: 0;
|
35
|
+
padding: 0 20px;
|
17
36
|
}
|
18
|
-
#
|
19
|
-
|
37
|
+
#header #system-menu {
|
38
|
+
background: #353c42;
|
20
39
|
position: absolute;
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
40
|
+
top: 20px;
|
41
|
+
right: 20px;
|
42
|
+
width: 150px;
|
43
|
+
color: #FFF;
|
44
|
+
-webkit-border-radius: 3px;
|
45
|
+
-moz-border-radius: 3px;
|
46
|
+
padding: 5px;
|
47
|
+
font-size: 11px;
|
26
48
|
}
|
27
|
-
#
|
49
|
+
#model-select {
|
50
|
+
font-size: 16px;
|
51
|
+
position: absolute;
|
52
|
+
left: 20px;
|
53
|
+
top: 45px;
|
54
|
+
background: #FFF;
|
55
|
+
z-index: 99;
|
56
|
+
-webkit-box-shadow: -2px 0 20px rgba(51,51,51,0.3);
|
57
|
+
-moz-box-shadow: -2px 0 20px rgba(51,51,51,0.3);
|
58
|
+
min-width: 200px;
|
59
|
+
display: none;
|
60
|
+
border: 1px solid #d4d2d2;
|
61
|
+
}
|
62
|
+
#model-select ul {
|
28
63
|
margin: 0;
|
29
64
|
padding: 0;
|
30
65
|
}
|
31
|
-
#
|
66
|
+
#model-select ul li {
|
67
|
+
list-style: none;
|
32
68
|
margin: 0;
|
33
|
-
padding: 0;
|
34
|
-
list-style-type: none;
|
35
69
|
}
|
36
|
-
#
|
37
|
-
padding: 10px 20px;
|
38
|
-
display: block;
|
39
|
-
color: #000;
|
70
|
+
#model-select ul li a {
|
40
71
|
text-decoration: none;
|
41
|
-
|
42
|
-
|
72
|
+
display: block;
|
73
|
+
padding: 10px;
|
74
|
+
color: #5e6a76;
|
75
|
+
font-weight: bold;
|
76
|
+
line-height: 16px;
|
43
77
|
}
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
78
|
+
#model-select ul li a:hover {
|
79
|
+
background: #E8E8E8;
|
80
|
+
}
|
81
|
+
h1:hover > #model-select {
|
82
|
+
display: block;
|
83
|
+
}
|
84
|
+
#model-select:hover {
|
85
|
+
display: block;
|
49
86
|
}
|
50
|
-
#
|
87
|
+
#content {
|
88
|
+
background: #FFF;
|
51
89
|
position: absolute;
|
52
|
-
top:
|
90
|
+
top: 60px;
|
53
91
|
left: 0;
|
54
92
|
right: 0;
|
55
93
|
bottom: 0;
|
56
|
-
background: #F3F3F3;
|
57
|
-
margin-left: 200px;
|
58
|
-
border-left: 1px solid #323941;
|
59
94
|
overflow: auto;
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
padding:
|
95
|
+
border-left: 1px solid #d4d2d2;
|
96
|
+
font-size: 11px;
|
97
|
+
-webkit-box-shadow: -2px 0 20px rgba(51,51,51,0.3);
|
98
|
+
}
|
99
|
+
#content #subhead {
|
100
|
+
background: #e0e0e0 url(/img/subhead-bg.png) repeat-x top left;
|
101
|
+
border-bottom: 1px solid #d4d2d2;
|
102
|
+
padding-left: 20px;
|
103
|
+
}
|
104
|
+
#content #subhead h1 {
|
105
|
+
font-size: 17px;
|
106
|
+
padding: 0 20px;
|
107
|
+
line-height: 44px;
|
68
108
|
margin: 0;
|
109
|
+
color: #5e6a76;
|
110
|
+
background-image: url(/img/arrow-down.png);
|
111
|
+
background-position: 91% 50%;
|
112
|
+
background-repeat: no-repeat;
|
113
|
+
border-right: 1px solid #d4d2d2;
|
114
|
+
border-left: 1px solid #d4d2d2;
|
115
|
+
display: inline-block;
|
116
|
+
line-height: 44px;
|
117
|
+
padding: 0 40px 0 10px;
|
118
|
+
}
|
119
|
+
#content #new-form #subhead h1,
|
120
|
+
#content #edit-form #subhead h1 {
|
121
|
+
background: transparent;
|
122
|
+
border: 0;
|
123
|
+
padding-left: 0;
|
69
124
|
}
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
z-index: 3;
|
74
|
-
width: 220px;
|
75
|
-
top: 0;
|
125
|
+
#content h1 a {
|
126
|
+
color: #61a801;
|
127
|
+
text-decoration: none;
|
76
128
|
}
|
77
|
-
#
|
78
|
-
|
129
|
+
#content #subhead h1:hover {
|
130
|
+
cursor: pointer;
|
131
|
+
background-color: #FFF;
|
79
132
|
}
|
80
|
-
#
|
81
|
-
|
133
|
+
#content div.list-table-wrapper {
|
134
|
+
margin-top: 20px;
|
135
|
+
padding: 1px;
|
136
|
+
background: #d4d2d2;
|
137
|
+
-webkit-border-radius: 3px;
|
138
|
+
-moz-border-radius: 3px;
|
139
|
+
clear: both;
|
82
140
|
}
|
83
|
-
#
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
141
|
+
#content table {
|
142
|
+
width: 100%;
|
143
|
+
border: 3px solid #f1f1f1;
|
144
|
+
border-bottom: 2px solid #f1f1f1;
|
145
|
+
-webkit-border-radius: 3px;
|
146
|
+
-moz-border-radius: 3px;
|
147
|
+
}
|
148
|
+
#content table th {
|
149
|
+
text-align: left;
|
150
|
+
padding: 5px 10px;
|
151
|
+
font-size: 13px;
|
152
|
+
background: #f1f1f1;
|
88
153
|
}
|
89
|
-
#
|
154
|
+
#content table th a {
|
155
|
+
color: #393939;
|
90
156
|
text-decoration: none;
|
91
|
-
|
157
|
+
padding-right: 15px;
|
92
158
|
}
|
93
|
-
#
|
94
|
-
|
159
|
+
#content table th a.desc {
|
160
|
+
background: transparent url(/img/arrows.png) no-repeat 2px right;
|
95
161
|
}
|
96
|
-
#
|
97
|
-
|
162
|
+
#content table th a.asc {
|
163
|
+
background: transparent url(/img/arrows.png) no-repeat right -16px;
|
164
|
+
}
|
165
|
+
#content table td {
|
166
|
+
padding: 10px;
|
167
|
+
color: #393939;
|
168
|
+
border-bottom: 1px solid #eaeaf4;
|
169
|
+
background: #FFF;
|
98
170
|
}
|
99
|
-
#
|
100
|
-
color: #000;
|
171
|
+
#content table td a {
|
101
172
|
text-decoration: none;
|
173
|
+
color: #393939;
|
174
|
+
text-decoration: none;
|
175
|
+
font-weight: bold;
|
102
176
|
}
|
103
|
-
#
|
104
|
-
|
105
|
-
padding: 10px 20px;
|
106
|
-
background: #1E1E1E url(/img/bg-nav.png) repeat-x top left;
|
107
|
-
color: #FFF;
|
177
|
+
#content table a:hover {
|
178
|
+
color: #61a801;
|
108
179
|
}
|
109
|
-
#
|
110
|
-
|
111
|
-
|
112
|
-
|
180
|
+
#content table td span.address {
|
181
|
+
display: block;
|
182
|
+
color: #5b5b5b;
|
183
|
+
}
|
184
|
+
#content table tr.disabled td {
|
185
|
+
color: #888;
|
186
|
+
background: transparent url(/img/disabled.png);
|
113
187
|
}
|
114
|
-
#
|
115
|
-
#
|
116
|
-
|
188
|
+
#content table tr.disabled td span.address,
|
189
|
+
#content table tr.disabled td a {
|
190
|
+
color: #888;
|
191
|
+
}
|
192
|
+
#content table td.checkbox {
|
117
193
|
text-align: center;
|
118
|
-
padding
|
194
|
+
padding: 5px 0 5px 10px;
|
195
|
+
width: 20px;
|
119
196
|
}
|
120
|
-
|
121
|
-
#
|
197
|
+
#content div.actions {
|
198
|
+
background: #ccc url(/img/footer-bg.png) repeat-x top left;
|
122
199
|
position: absolute;
|
123
|
-
top: 57px;
|
124
|
-
bottom: 47px;
|
125
|
-
right: 0;
|
126
200
|
left: 0;
|
201
|
+
right: 0;
|
202
|
+
bottom: 0;
|
203
|
+
height: 31px;
|
127
204
|
overflow: auto;
|
205
|
+
border-top: 1px solid #FFF;
|
206
|
+
padding: 10px 20px;
|
207
|
+
text-align: right;
|
208
|
+
}
|
209
|
+
#content div.actions button {
|
210
|
+
border: 1px solid #549300;
|
211
|
+
background: #61a801 url(/img/button-bg-save.png) repeat-x top left;
|
212
|
+
-webkit-border-radius: 4px;
|
213
|
+
-moz-border-radius: 4px;
|
214
|
+
padding: 5px 10px;
|
215
|
+
font-size: 13px;
|
216
|
+
font-weight: bold;
|
217
|
+
text-shadow: 0 1px 1px #538A00;
|
218
|
+
color: #FFF;
|
128
219
|
}
|
129
|
-
#
|
130
|
-
|
220
|
+
#content div.actions button:hover {
|
221
|
+
background: #69b802 url(/img/button-bg-save.png) repeat-x -30px left;
|
222
|
+
text-shadow: 0 1px 1px #538A00;
|
223
|
+
cursor: pointer;
|
131
224
|
}
|
132
|
-
#
|
133
|
-
|
134
|
-
|
225
|
+
#content div.actions button#delete-button {
|
226
|
+
background: #800000 url(/img/button-bg-delete.png) repeat-x top left;
|
227
|
+
text-shadow: 0 1px 1px #710000;
|
228
|
+
border: 1px solid #a12f19;
|
135
229
|
}
|
136
|
-
#
|
137
|
-
|
138
|
-
|
139
|
-
|
230
|
+
#content div.actions button#delete-button:disabled {
|
231
|
+
color: #888;
|
232
|
+
background: #EFEFEF;
|
233
|
+
border: 1px solid #BBB;
|
234
|
+
text-shadow: none;
|
140
235
|
}
|
141
|
-
#
|
142
|
-
|
143
|
-
|
144
|
-
padding: 0 0 6px 0;
|
236
|
+
#content div.actions button#delete-button:hover {
|
237
|
+
background: #910000 url(/img/button-bg-delete.png) repeat-x -30px left;
|
238
|
+
text-shadow: 0 1px 1px #A12F19;
|
145
239
|
}
|
146
|
-
#
|
240
|
+
#content div.actions button#delete-button:disabled:hover {
|
241
|
+
background: #EFEFEF;
|
242
|
+
cursor: text;
|
243
|
+
text-shadow: none;
|
244
|
+
}
|
245
|
+
|
246
|
+
#content div.actions form {
|
147
247
|
display: inline;
|
148
|
-
font-weight: normal;
|
149
248
|
}
|
150
|
-
#
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
249
|
+
#content div.actions div.filter {
|
250
|
+
float: left;
|
251
|
+
line-height: 31px;
|
252
|
+
}
|
253
|
+
|
254
|
+
#content #main {
|
255
|
+
padding: 20px;
|
256
|
+
position: absolute;
|
257
|
+
top: 44px;
|
258
|
+
left: 0;
|
259
|
+
right: 0;
|
260
|
+
bottom: 52px;
|
261
|
+
overflow: auto;
|
155
262
|
}
|
156
|
-
#
|
157
|
-
|
158
|
-
border: 1px solid #ABABAB;
|
263
|
+
#account #content #main {
|
264
|
+
bottom: 0;
|
159
265
|
}
|
160
|
-
|
161
|
-
#main
|
162
|
-
|
163
|
-
padding
|
266
|
+
|
267
|
+
#content #main fieldset {
|
268
|
+
border: 0;
|
269
|
+
padding: 10px 20px 10px 0;
|
164
270
|
}
|
165
|
-
#main
|
166
|
-
|
167
|
-
|
168
|
-
|
271
|
+
#content #main fieldset label {
|
272
|
+
font-size: 13px;
|
273
|
+
font-weight: bold;
|
274
|
+
color: #515151;
|
275
|
+
display: block;
|
276
|
+
padding-bottom: 10px;
|
169
277
|
}
|
170
|
-
#main
|
171
|
-
|
172
|
-
|
173
|
-
float: left;
|
278
|
+
#content #main fieldset label.inline {
|
279
|
+
display: inline;
|
280
|
+
font-weight: normal;
|
174
281
|
}
|
175
|
-
#main
|
176
|
-
#main
|
177
|
-
#main
|
178
|
-
|
282
|
+
#content #main fieldset textarea,
|
283
|
+
#content #main fieldset input[type=password],
|
284
|
+
#content #main fieldset input[type=text] {
|
285
|
+
border: 1px solid #d4d2d2;
|
286
|
+
border-top: 2px solid #CCC;
|
287
|
+
border-left: 2px solid #CCC;
|
288
|
+
background: #f9f9f9;
|
289
|
+
padding: 7px;
|
179
290
|
width: 100%;
|
180
|
-
|
291
|
+
margin-right: 20px;
|
292
|
+
font-size: 13px;
|
293
|
+
}
|
294
|
+
#content #main fieldset input[type=text].half-left {
|
295
|
+
width: 44%;
|
181
296
|
}
|
182
|
-
#main
|
183
|
-
#main form fieldset.belongs_to div.paging,
|
184
|
-
#main form fieldset.has_n div.paging {
|
297
|
+
#content #main fieldset input[type=text].half-right {
|
185
298
|
float: right;
|
186
|
-
|
187
|
-
|
299
|
+
width: 48%;
|
300
|
+
margin-right: -15px;
|
301
|
+
}
|
302
|
+
#content #main div.paging {
|
303
|
+
border: 1px solid #d4d2d2;
|
304
|
+
background: #f1f1f1;
|
305
|
+
padding: 15px;
|
306
|
+
color: #888;
|
307
|
+
font-weight: bold;
|
308
|
+
-webkit-border-radius: 3px;
|
309
|
+
-moz-border-radius: 3px;
|
310
|
+
position: relative;
|
311
|
+
text-align: right;
|
188
312
|
}
|
189
|
-
#main
|
190
|
-
#
|
191
|
-
#main form fieldset.has_n .checkbox {
|
192
|
-
display: none;
|
313
|
+
#content #main div.paging a {
|
314
|
+
color: #61a801;
|
193
315
|
}
|
194
|
-
|
195
|
-
#main form
|
196
|
-
|
197
|
-
|
316
|
+
|
317
|
+
#content #main div.paging form {
|
318
|
+
position: absolute;
|
319
|
+
top: 9px;
|
320
|
+
left: 12px;
|
321
|
+
text-align: right;
|
322
|
+
padding: 0;
|
198
323
|
}
|
199
|
-
#main form fieldset
|
200
|
-
|
201
|
-
|
324
|
+
#content #main div.paging form fieldset {
|
325
|
+
padding: 0;
|
326
|
+
margin: 0;
|
202
327
|
}
|
203
|
-
#main form
|
204
|
-
|
328
|
+
#content #main div.paging form input {
|
329
|
+
width: 200px;
|
330
|
+
padding: 3px;
|
331
|
+
font-size: 11px;
|
205
332
|
}
|
206
|
-
|
207
|
-
|
333
|
+
h2 {
|
334
|
+
font-size: 24px;
|
335
|
+
color: #5e6a76;
|
336
|
+
font-weight: bold;
|
208
337
|
}
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
border: 0;
|
227
|
-
cursor: pointer;
|
228
|
-
background: transparent url(/img/btn-bg.png) repeat-x top left;
|
229
|
-
font: 12px "Lucida Grande", verdana;
|
230
|
-
position: absolute;
|
231
|
-
top: 12px;
|
232
|
-
line-height: 22px;
|
233
|
-
right: 10px;
|
338
|
+
.account-item {
|
339
|
+
font-size: 24px;
|
340
|
+
color: #888;
|
341
|
+
background: #EFEFEF;
|
342
|
+
border: 1px solid #d4d2d2;
|
343
|
+
padding: 15px;
|
344
|
+
margin: 10px 0 20px 0;
|
345
|
+
}
|
346
|
+
#content #main fieldset.many_to_many,
|
347
|
+
#content #main fieldset.belongs_to,
|
348
|
+
#content #main fieldset.has_n {
|
349
|
+
padding-right: 2px;
|
350
|
+
}
|
351
|
+
#content #main fieldset.many_to_many input[type=text],
|
352
|
+
#content #main fieldset.belongs_to input[type=text],
|
353
|
+
#content #main fieldset.has_n input[type=text] {
|
354
|
+
width: 190px;
|
234
355
|
}
|
235
|
-
div.
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
overflow: hidden;
|
356
|
+
#content #main fieldset.many_to_many div.search,
|
357
|
+
#content #main fieldset.belongs_to div.search,
|
358
|
+
#content #main fieldset.has_n div.search {
|
359
|
+
display: none;
|
240
360
|
}
|
241
|
-
div.
|
242
|
-
|
361
|
+
#content #main fieldset div.paging {
|
362
|
+
margin-bottom: 17px;
|
243
363
|
}
|
244
|
-
div.
|
245
|
-
div.
|
246
|
-
|
364
|
+
#content #main fieldset.many_to_many div.paging input,
|
365
|
+
#content #main fieldset.belongs_to div.paging input,
|
366
|
+
#content #main fieldset.has_n div.paging input {
|
367
|
+
position: absolute;
|
368
|
+
top: 9px;
|
369
|
+
left: 12px;
|
370
|
+
padding: 0;
|
371
|
+
width: 200px;
|
372
|
+
padding: 3px;
|
373
|
+
font-size: 11px;
|
247
374
|
}
|
248
|
-
|
249
|
-
|
375
|
+
#content #main fieldset.many_to_many .checkbox,
|
376
|
+
#content #main fieldset.belongs_to .checkbox,
|
377
|
+
#content #main fieldset.has_n .checkbox {
|
378
|
+
display: none;
|
379
|
+
padding: 10px 0 10px 5px;
|
250
380
|
}
|
251
|
-
|
252
|
-
|
253
|
-
|
381
|
+
#content #main fieldset.many_to_many th.checkbox,
|
382
|
+
#content #main fieldset.belongs_to th.checkbox,
|
383
|
+
#content #main fieldset.has_n th.checkbox {
|
384
|
+
padding: 0;
|
254
385
|
}
|
255
|
-
|
256
|
-
|
386
|
+
#content #main fieldset.many_to_many .active,
|
387
|
+
#content #main fieldset.belongs_to .active,
|
388
|
+
#content #main fieldset.has_n .active {
|
389
|
+
display: table-cell;
|
257
390
|
}
|
258
|
-
|
259
|
-
|
260
|
-
|
391
|
+
#content #main fieldset table tfoot td {
|
392
|
+
background: #f1f1f1;
|
393
|
+
border-bottom: none;
|
394
|
+
padding: 5px;
|
261
395
|
}
|
262
|
-
|
263
|
-
|
396
|
+
#content #main fieldset table tfoot td button {
|
397
|
+
float: right;
|
398
|
+
}
|
399
|
+
#content #main fieldset.many_to_many div.list-table-wrapper,
|
400
|
+
#content #main fieldset.belongs_to div.list-table-wrapper,
|
401
|
+
#content #main fieldset.has_n div.list-table-wrapper {
|
402
|
+
margin-top: 3px;
|
264
403
|
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,35 +1,34 @@
|
|
1
|
-
var
|
1
|
+
var modifiedFields = {};
|
2
2
|
function saveBeforeLeaving(e) {
|
3
|
-
|
3
|
+
var str = 'You have made changes to this item. Are you sure you want to leave before saving?';
|
4
|
+
e = e || window.event;
|
5
|
+
e.returnValue = str;
|
6
|
+
return str;
|
4
7
|
}
|
5
|
-
function
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
function checkForModifiedInputs(e) {
|
14
|
-
if (e.target.nodeName == 'SELECT' ||
|
15
|
-
(e.target.nodeName == 'INPUT' && e.target.getAttribute('type') == 'checkbox') ||
|
16
|
-
(e.target.nodeName == 'INPUT' && e.target.getAttribute('type') == 'radio')) {
|
17
|
-
console.log('modified');
|
18
|
-
hasModified = true;
|
8
|
+
function checkForModified(e) {
|
9
|
+
var nodeName = e.target.nodeName, type = e.target.getAttribute('type');
|
10
|
+
if (!type) { return; }
|
11
|
+
var isText = (nodeName == 'INPUT' && type == 'text') || nodeName.match(/TEXTAREA|SELECT/);
|
12
|
+
var isToggle = type.match(/checkbox|radio/) != null;
|
13
|
+
if (isText || isToggle) {
|
14
|
+
var k = e.target.getAttribute('id') || e.target.getAttribute('name');
|
15
|
+
modifiedFields[k] = (isToggle || (e.target.value != e.target.defaultValue));
|
19
16
|
setBeforeLeaving();
|
20
17
|
}
|
21
18
|
}
|
22
19
|
function setBeforeLeaving() {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
for (k in modifiedFields) {
|
21
|
+
if (modifiedFields[k]) {
|
22
|
+
window.onbeforeunload = saveBeforeLeaving;
|
23
|
+
return;
|
24
|
+
}
|
27
25
|
}
|
26
|
+
window.onbeforeunload = function() { };
|
28
27
|
}
|
29
28
|
|
30
|
-
listen('keyup',
|
31
|
-
listen('click',
|
29
|
+
listen('keyup', document, checkForModified);
|
30
|
+
listen('click', document, checkForModified);
|
32
31
|
listen('submit', el('edit-form'), function() {
|
33
|
-
|
32
|
+
modifiedFields = {};
|
34
33
|
setBeforeLeaving();
|
35
|
-
});
|
34
|
+
});
|