Jeremy D commited on 2012-01-22 12:13:17
Showing 2 changed files, with 59 additions and 36 deletions.
... | ... |
@@ -12,11 +12,25 @@ $(document).ready(function(){ |
12 | 12 |
instruct_count =new Array(); |
13 | 13 |
instruct_count[action_count] = 1; |
14 | 14 |
|
15 |
- /* Kick things off by creating a new action. */ |
|
16 |
- create_new_action(); |
|
15 |
+ /* Bind some stuff to our actions, using live so they auto update as new stuff is added. */ |
|
16 |
+ $('.collapse_action').live('click', collapse_action); |
|
17 |
+ $('.expand_action').live('click', expand_action); |
|
18 |
+ $('.delete_action').live('click', delete_action); |
|
19 |
+ $('.restore_action').live('click', restore_action); |
|
20 |
+ |
|
21 |
+ /* Now we will bind to the actual changes, again using live. */ |
|
22 |
+ $('.collapse_change').live('click', collapse_instruct); |
|
23 |
+ $('.expand_change').live('click', expand_instruct); |
|
24 |
+ $('.delete_change').live('click', delete_instruct); |
|
25 |
+ $('.restore_change').live('cick', restore_instruct); |
|
26 |
+ |
|
27 |
+ /* Now we will bind to some toggles in those changes, again using live. */ |
|
28 |
+ $('.instruct_action').live('change', instruct_change); |
|
29 |
+ $('.inline_check').live('change', instruct_inline); |
|
17 | 30 |
|
18 | 31 |
/* Give our buttons some actions. */ |
19 | 32 |
$('#add_action').click(create_new_action); |
33 |
+ $('.add_instruct').live('click', create_new_instruct); |
|
20 | 34 |
$('#show_preview').click(show_instruct_preview); |
21 | 35 |
|
22 | 36 |
/* The details and basic buttons. */ |
... | ... |
@@ -24,6 +38,9 @@ $(document).ready(function(){ |
24 | 38 |
$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();}); |
25 | 39 |
$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();}); |
26 | 40 |
$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();}); |
41 |
+ |
|
42 |
+ /* Kick things off by creating a new action. */ |
|
43 |
+ create_new_action(); |
|
27 | 44 |
}); |
28 | 45 |
|
29 | 46 |
/* Handles adding actions */ |
... | ... |
@@ -32,18 +49,9 @@ function create_new_action() |
32 | 49 |
/* We have been through this before */ |
33 | 50 |
$('#action_container').append($('#action_template').html().replace(/#ACTIONINDEX#/g, action_count)); |
34 | 51 |
|
35 |
- /* We need to bind the new create instruct button */ |
|
36 |
- $('.add_instruct').click(create_new_instruct); |
|
37 |
- |
|
38 | 52 |
/* Now we pretend to click said element */ |
39 | 53 |
$('#action-' + action_count).find('.add_instruct').click(); |
40 | 54 |
|
41 |
- /* Now add some actions to our buttons */ |
|
42 |
- $('#action-' + action_count + ' .collapse_action').click(collapse_action); |
|
43 |
- $('#action-' + action_count + ' .expand_action').click(expand_action); |
|
44 |
- $('#action-' + action_count + ' .delete_action').click(delete_action); |
|
45 |
- $('#action-' + action_count + ' .restore_action').click(restore_action); |
|
46 |
- |
|
47 | 55 |
/* Move the index and add defaults */ |
48 | 56 |
action_count++; |
49 | 57 |
instruct_count[action_count] = 1; |
... | ... |
@@ -59,16 +67,8 @@ function create_new_instruct() |
59 | 67 |
|
60 | 68 |
$('#action-' + action_index + '-instruct_container').append($('#instruct_template').html().replace(/#ACTIONINDEX#/g, action_index).replace(/#INSTRUCTINDEX#/g, instruct_count[action_index])); |
61 | 69 |
|
62 |
- $('#action-' + action_index + '-instruct_container .collapse_change').click(collapse_instruct); |
|
63 |
- $('#action-' + action_index + '-instruct_container .expand_change').click(expand_instruct); |
|
64 |
- $('#action-' + action_index + '-instruct_container .delete_change').click(delete_instruct); |
|
65 |
- $('#action-' + action_index + '-instruct_container .restore_change').click(restore_instruct); |
|
66 |
- |
|
67 |
- $('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change(instruct_change); |
|
68 | 70 |
$('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change(); |
69 | 71 |
|
70 |
- $('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-inline').change(instruct_inline); |
|
71 |
- |
|
72 | 72 |
instruct_count[action_index]++; |
73 | 73 |
|
74 | 74 |
update_counter(); |
... | ... |
@@ -152,6 +151,8 @@ function collapse_instruct() |
152 | 151 |
$('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').hide(); |
153 | 152 |
$('#action-' + action_index + '-instruct-' + instruct_index + ' .expand_change').show(); |
154 | 153 |
$(this).hide(); |
154 |
+ |
|
155 |
+ return false; |
|
155 | 156 |
} |
156 | 157 |
|
157 | 158 |
/* Handles expanding of the instruct */ |
... | ... |
@@ -164,6 +165,8 @@ function expand_instruct() |
164 | 165 |
$('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').show(); |
165 | 166 |
$('#action-' + action_index + '-instruct-' + instruct_index + ' .collapse_change').show(); |
166 | 167 |
$(this).hide(); |
168 |
+ |
|
169 |
+ return false; |
|
167 | 170 |
} |
168 | 171 |
|
169 | 172 |
/* Handles deleting a instruct */ |
... | ... |
@@ -181,6 +184,7 @@ function delete_instruct() |
181 | 184 |
$(this).hide(); |
182 | 185 |
|
183 | 186 |
update_counter(); |
187 |
+ return false; |
|
184 | 188 |
} |
185 | 189 |
|
186 | 190 |
/* Handles restoring a instruct */ |
... | ... |
@@ -198,6 +202,7 @@ function restore_instruct() |
198 | 202 |
$(this).hide(); |
199 | 203 |
|
200 | 204 |
update_counter(); |
205 |
+ return false; |
|
201 | 206 |
} |
202 | 207 |
|
203 | 208 |
/* Handles collapsing of the action */ |
... | ... |
@@ -209,6 +214,8 @@ function collapse_action() |
209 | 214 |
$('#action-' + action_index + '-instruct_container').hide(); |
210 | 215 |
$('#action-' + action_index + ' .expand_action').show(); |
211 | 216 |
$(this).hide(); |
217 |
+ |
|
218 |
+ return false; |
|
212 | 219 |
} |
213 | 220 |
|
214 | 221 |
/* Handles expanding of the action */ |
... | ... |
@@ -220,6 +227,8 @@ function expand_action() |
220 | 227 |
$('#action-' + action_index + '-instruct_container').show(); |
221 | 228 |
$('#action-' + action_index + ' .collapse_action').show(); |
222 | 229 |
$(this).hide(); |
230 |
+ |
|
231 |
+ return false; |
|
223 | 232 |
} |
224 | 233 |
|
225 | 234 |
/* Handles deleting a action */ |
... | ... |
@@ -236,6 +245,7 @@ function delete_action() |
236 | 245 |
$(this).hide(); |
237 | 246 |
|
238 | 247 |
update_counter(); |
248 |
+ return false; |
|
239 | 249 |
} |
240 | 250 |
|
241 | 251 |
/* Handles restoring a action */ |
... | ... |
@@ -252,6 +262,7 @@ function restore_action() |
252 | 262 |
$(this).hide(); |
253 | 263 |
|
254 | 264 |
update_counter(); |
265 |
+ return false; |
|
255 | 266 |
} |
256 | 267 |
|
257 | 268 |
/* This is the nasty guy */ |
... | ... |
@@ -12,12 +12,21 @@ $(document).ready(function(){ |
12 | 12 |
edit_count =new Array(); |
13 | 13 |
edit_count[file_count] = 1; |
14 | 14 |
|
15 |
- /* Kick things off by creating a file. */ |
|
16 |
- create_new_file(); |
|
17 |
- |
|
18 |
- $('#add_file').click(create_new_file); |
|
15 |
+ /* Bind some stuff to our files, using live so they auto update as new stuff is added. */ |
|
16 |
+ $('.collapse_file').live('click', collapse_file); |
|
17 |
+ $('.expand_file').live('click', expand_file); |
|
18 |
+ $('.delete_file').live('click', delete_file); |
|
19 |
+ $('.restore_file').live('click', restore_file); |
|
20 |
+ |
|
21 |
+ /* Now we will bind to the actual edits, again using live. */ |
|
22 |
+ $('.collapse_change').live('click', collapse_edit); |
|
23 |
+ $('.expand_change').live('click', expand_edit); |
|
24 |
+ $('.delete_change').live('click', delete_edit); |
|
25 |
+ $('.restore_change').live('click', restore_edit); |
|
19 | 26 |
|
20 | 27 |
/* Give our buttons some actions. */ |
28 |
+ $('#add_file').click(create_new_file); |
|
29 |
+ $('.add_edit').live('click', create_new_edit); |
|
21 | 30 |
$('#show_preview').click(show_edit_preview); |
22 | 31 |
|
23 | 32 |
/* The details and basic buttons. */ |
... | ... |
@@ -25,6 +34,9 @@ $(document).ready(function(){ |
25 | 34 |
$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();}); |
26 | 35 |
$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();}); |
27 | 36 |
$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();}); |
37 |
+ |
|
38 |
+ /* Kick things off by creating a file. */ |
|
39 |
+ create_new_file(); |
|
28 | 40 |
}); |
29 | 41 |
|
30 | 42 |
/* Handles adding files */ |
... | ... |
@@ -33,17 +45,9 @@ function create_new_file() |
33 | 45 |
/* We have been through this before */ |
34 | 46 |
$('#file_container').append($('#file_template').html().replace(/#FILEINDEX#/g, file_count)); |
35 | 47 |
|
36 |
- /* We need to bind the new create edit button */ |
|
37 |
- $('.add_edit').click(create_new_edit); |
|
38 |
- |
|
39 | 48 |
/* Now we pretend to click said element */ |
40 | 49 |
$('#file-' + file_count).find('.add_edit').click(); |
41 | 50 |
|
42 |
- $('#file-' + file_count + ' .collapse_file').click(collapse_file); |
|
43 |
- $('#file-' + file_count + ' .expand_file').click(expand_file); |
|
44 |
- $('#file-' + file_count + ' .delete_file').click(delete_file); |
|
45 |
- $('#file-' + file_count + ' .restore_file').click(restore_file); |
|
46 |
- |
|
47 | 51 |
/* Move the index and add defaults */ |
48 | 52 |
file_count++; |
49 | 53 |
edit_count[file_count] = 1; |
... | ... |
@@ -59,11 +63,6 @@ function create_new_edit() |
59 | 63 |
$('#file-' + file_index + '-edit_container').append($('#edit_template').html().replace(/#FILEINDEX#/g, file_index).replace(/#EDITINDEX#/g, edit_count[file_index])); |
60 | 64 |
edit_count[file_index]++; |
61 | 65 |
|
62 |
- $('#file-' + file_index + '-edit_container .collapse_change').click(collapse_edit); |
|
63 |
- $('#file-' + file_index + '-edit_container .expand_change').click(expand_edit); |
|
64 |
- $('#file-' + file_index + '-edit_container .delete_change').click(delete_edit); |
|
65 |
- $('#file-' + file_index + '-edit_container .restore_change').click(restore_edit); |
|
66 |
- |
|
67 | 66 |
update_counter(); |
68 | 67 |
} |
69 | 68 |
|
... | ... |
@@ -77,6 +76,8 @@ function collapse_edit() |
77 | 76 |
$('#file-' + file_index + '-edit-' + edit_index + ' .edits').hide(); |
78 | 77 |
$('#file-' + file_index + '-edit-' + edit_index + ' .expand_change').show(); |
79 | 78 |
$(this).hide(); |
79 |
+ |
|
80 |
+ return false; |
|
80 | 81 |
} |
81 | 82 |
|
82 | 83 |
/* Handles expanding of the edit */ |
... | ... |
@@ -89,6 +90,8 @@ function expand_edit() |
89 | 90 |
$('#file-' + file_index + '-edit-' + edit_index + ' .edits').show(); |
90 | 91 |
$('#file-' + file_index + '-edit-' + edit_index + ' .collapse_change').show(); |
91 | 92 |
$(this).hide(); |
93 |
+ |
|
94 |
+ return false; |
|
92 | 95 |
} |
93 | 96 |
|
94 | 97 |
/* Handles deleting a edit */ |
... | ... |
@@ -106,6 +109,7 @@ function delete_edit() |
106 | 109 |
$(this).hide(); |
107 | 110 |
|
108 | 111 |
update_counter(); |
112 |
+ return false; |
|
109 | 113 |
} |
110 | 114 |
|
111 | 115 |
/* Handles restoring a edit */ |
... | ... |
@@ -123,6 +127,7 @@ function restore_edit() |
123 | 127 |
$(this).hide(); |
124 | 128 |
|
125 | 129 |
update_counter(); |
130 |
+ return false; |
|
126 | 131 |
} |
127 | 132 |
|
128 | 133 |
/* Handles collapsing of the file */ |
... | ... |
@@ -134,6 +139,8 @@ function collapse_file() |
134 | 139 |
$('#file-' + file_index + '-edit_container').hide(); |
135 | 140 |
$('#file-' + file_index + ' .expand_file').show(); |
136 | 141 |
$(this).hide(); |
142 |
+ |
|
143 |
+ return false; |
|
137 | 144 |
} |
138 | 145 |
|
139 | 146 |
/* Handles expanding of the file */ |
... | ... |
@@ -145,6 +152,8 @@ function expand_file() |
145 | 152 |
$('#file-' + file_index + '-edit_container').show(); |
146 | 153 |
$('#file-' + file_index + ' .collapse_file').show(); |
147 | 154 |
$(this).hide(); |
155 |
+ |
|
156 |
+ return false; |
|
148 | 157 |
} |
149 | 158 |
|
150 | 159 |
/* Handles deleting a file */ |
... | ... |
@@ -161,6 +170,7 @@ function delete_file() |
161 | 170 |
$(this).hide(); |
162 | 171 |
|
163 | 172 |
update_counter(); |
173 |
+ return false; |
|
164 | 174 |
} |
165 | 175 |
|
166 | 176 |
/* Handles restoring a file */ |
... | ... |
@@ -177,6 +187,7 @@ function restore_file() |
177 | 187 |
$(this).hide(); |
178 | 188 |
|
179 | 189 |
update_counter(); |
190 |
+ return false; |
|
180 | 191 |
} |
181 | 192 |
|
182 | 193 |
/* This is the nasty guy */ |
183 | 194 |