Add native compatibility with jQuery 2.0
Jeremy D

Jeremy D commited on 2013-04-22 20:01:51
Showing 2 changed files, with 34 additions and 35 deletions.

... ...
@@ -15,24 +15,23 @@ $j(document).ready(function($){
15 15
 
16 16
 	/* Bind some stuff to our actions, using live so they auto update as new stuff is added. */
17 17
 	$j(document).on('click', '.collapse_action', collapse_action);
18
-//	$j('.collapse_action').live('click', collapse_action);
19
-	$j('.expand_action').live('click', expand_action);
20
-	$j('.delete_action').live('click', delete_action);
21
-	$j('.restore_action').live('click', restore_action);
18
+	$j(document).on('click', '.expand_action', expand_action);
19
+	$j(document).on('click', '.delete_action', delete_action);
20
+	$j(document).on('click', '.restore_action', restore_action);
22 21
 
23 22
 	/* Now we will bind to the actual changes, again using live. */
24
-	$j('.collapse_change').live('click', collapse_instruct);
25
-	$j('.expand_change').live('click', expand_instruct);
26
-	$j('.delete_change').live('click', delete_instruct);
27
-	$j('.restore_change').live('cick', restore_instruct);
23
+	$j(document).on('click', '.collapse_change', collapse_instruct);
24
+	$j(document).on('click', '.expand_change', expand_instruct);
25
+	$j(document).on('click', '.delete_change', delete_instruct);
26
+	$j(document).on('click', '.restore_change', restore_instruct);
28 27
 
29 28
 	/* Now we will bind to some toggles in those changes, again using live. */
30
-	$j('.instruct_action').live('change', instruct_change);
31
-	$j('.inline_check').live('change', instruct_inline);
29
+	$j(document).on('click', '.instruct_action', instruct_change);
30
+	$j(document).on('click', '.inline_check', instruct_inline);
32 31
 
33 32
 	/* Give our buttons some actions. */
34 33
 	$j('#add_action').click(create_new_action);
35
-	$j('.add_instruct').live('click', create_new_instruct);
34
+	$j(document).on('click', '.add_instruct', create_new_instruct);
36 35
 	$j('#show_preview').click(show_instruct_preview);
37 36
 
38 37
 	/* The details and basic buttons. */
... ...
@@ -93,7 +92,7 @@ function instruct_change()
93 92
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').show();
94 93
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
95 94
 	}
96
-	else if ($.inArray(this_act, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
95
+	else if ($j.inArray(this_act, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
97 96
 	{
98 97
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
99 98
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
... ...
@@ -102,7 +101,7 @@ function instruct_change()
102 101
 
103 102
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').show();
104 103
 	}
105
-	else if ($.inArray(this_act, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
104
+	else if ($j.inArray(this_act, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
106 105
 	{
107 106
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
108 107
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').hide();
... ...
@@ -111,7 +110,7 @@ function instruct_change()
111 110
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
112 111
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').show();
113 112
 	}
114
-	else if ($.inArray(this_act, ["code", "database", "readme"]) > -1)
113
+	else if ($j.inArray(this_act, ["code", "database", "readme"]) > -1)
115 114
 	{
116 115
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .reverse').hide();
117 116
 		$j('#action-' + action_index + '-instruct-' + instruct_index + ' .destination').hide();
... ...
@@ -299,7 +298,7 @@ function show_instruct_preview()
299 298
 		action_smf_versions = $j('#action-' + i + '-smf_versions').val();
300 299
 
301 300
 		/* We only want valid actions */
302
-		if ($.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
301
+		if ($j.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
303 302
 		{
304 303
 			preview += "\n" + '\
305 304
 	<' + action_type;
... ...
@@ -335,7 +334,7 @@ function show_instruct_preview()
335 334
 			instruct_block		=	$j('#action-' + i + '-instruct-' + j + '-block').val().replace('<' + '?php', '').replace('?' + '>', '');
336 335
 
337 336
 			/* Try to make it easier to handle these */
338
-			if ($.inArray(instruct_action, ["modification", "code", "database", "readme"]) > -1)
337
+			if ($j.inArray(instruct_action, ["modification", "code", "database", "readme"]) > -1)
339 338
 			{
340 339
 				preview += "\n" + '\
341 340
 		<' + instruct_action;
... ...
@@ -347,7 +346,7 @@ function show_instruct_preview()
347 346
 					preview += ' reverse="true"';
348 347
 				}
349 348
 
350
-				if (instruct_inline && $.inArray(instruct_action, ["code", "database", "readme"]) > -1)
349
+				if (instruct_inline && $j.inArray(instruct_action, ["code", "database", "readme"]) > -1)
351 350
 				{
352 351
 					preview += ' inline="true">' + "\n" + instruct_block + "\n" + '\
353 352
 		</' + instruct_action + '>';
... ...
@@ -357,7 +356,7 @@ function show_instruct_preview()
357 356
 					preview += '>' + instruct_source + '</' + instruct_action + ">\n";
358 357
 				}
359 358
 			}
360
-			else if ($.inArray(instruct_action, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
359
+			else if ($j.inArray(instruct_action, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
361 360
 			{
362 361
 				/* It may seem confusing to use destination here as name while the others use source.
363 362
 					Logic is just easier to follow from the GUI to think of destination as what happens to the SMF install,
... ...
@@ -365,7 +364,7 @@ function show_instruct_preview()
365 364
 				preview += "\n" + '\
366 365
 		<' + instruct_action + ' name="' + instruct_destination + '" />';
367 366
 			}
368
-			else if ($.inArray(instruct_action, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
367
+			else if ($j.inArray(instruct_action, ["require-dir", "require-file", "move-dir", "move-file"]) > -1)
369 368
 			{
370 369
 				/* We use source and destination correctly here, see note above for those actions. */
371 370
 				preview += "\n" + '\
... ...
@@ -380,7 +379,7 @@ function show_instruct_preview()
380 379
 		}
381 380
 
382 381
 		/* Close up the action instruct */
383
-		if ($.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
382
+		if ($j.inArray(action_type, ["install", "upgrade", "uninstall"]) > -1)
384 383
 		{
385 384
 			preview += "\n" + '\
386 385
 	</' + action_type + '>';
... ...
@@ -403,7 +402,7 @@ function download_action_generate()
403 402
 {
404 403
 	show_instruct_preview();
405 404
 
406
-	$.generateFile({
405
+	$j.generateFile({
407 406
 		filename	: 'package-info.xml',
408 407
 		content		: $j('#preview').text(),
409 408
 		script		: $j('#downloadername').val() + '?download'
... ...
@@ -414,7 +413,7 @@ function download_action_data()
414 413
 {
415 414
 	show_instruct_preview();
416 415
 
417
-	data = $.base64.encode($j('#preview').text());
416
+	data = $j.base64.encode($j('#preview').text());
418 417
 
419 418
 	/* No actionname can be specified by a data URI */
420 419
 	window.location = 'data:application/octet-stream;charset=utf-8;base64,' + data;
... ...
@@ -14,20 +14,20 @@ jQuery(document).ready(function(){
14 14
 	edit_count[file_count] = 1;
15 15
 
16 16
 	/* Bind some stuff to our files, using live so they auto update as new stuff is added. */
17
-	$j('.collapse_file').live('click', collapse_file);
18
-	$j('.expand_file').live('click', expand_file);
19
-	$j('.delete_file').live('click', delete_file);
20
-	$j('.restore_file').live('click', restore_file);
17
+	$j(document).on('click', '.collapse_file', collapse_file);
18
+	$j(document).on('click', '.expand_file', expand_file);
19
+	$j(document).on('click', '.delete_file', delete_file);
20
+	$j(document).on('click', '.restore_file', restore_file);
21 21
 
22 22
 	/* Now we will bind to the actual edits, again using live. */
23
-	$j('.collapse_change').live('click', collapse_edit);
24
-	$j('.expand_change').live('click', expand_edit);
25
-	$j('.delete_change').live('click', delete_edit);
26
-	$j('.restore_change').live('click', restore_edit);
23
+	$j(document).on('click', '.collapse_change', collapse_edit);
24
+	$j(document).on('click', '.expand_change', expand_edit);
25
+	$j(document).on('click', '.delete_change', delete_edit);
26
+	$j(document).on('click', '.restore_change', restore_edit);
27 27
 
28 28
 	/* Give our buttons some actions. */
29 29
 	$j('#add_file').click(create_new_file);
30
-	$j('.add_edit').live('click', create_new_edit);
30
+	$j(document).on('click', '.add_edit', create_new_edit);
31 31
 	$j('#show_preview').click(show_edit_preview);
32 32
 
33 33
 	/* The details and basic buttons. */
... ...
@@ -229,7 +229,7 @@ function show_edit_preview()
229 229
 	<file name="' + file_type + '/' + file_name + '"';
230 230
 
231 231
 		/* We don't need to define the default error type. */
232
-		if ($.inArray(file_fail, ["ignore", "skip"]) > -1)
232
+		if ($j.inArray(file_fail, ["ignore", "skip"]) > -1)
233 233
 		{
234 234
 			preview += ' error="' + file_fail + '"';
235 235
 		}
... ...
@@ -256,7 +256,7 @@ function show_edit_preview()
256 256
 		<operation";
257 257
 
258 258
 			/* We only need to add error handling for non default */
259
-			if ($.inArray(edit_error, ["ignore", "required"]) > -1)
259
+			if ($j.inArray(edit_error, ["ignore", "required"]) > -1)
260 260
 			{
261 261
 				preview += ' error="' + file_fail + '"';
262 262
 			}
... ...
@@ -306,7 +306,7 @@ function download_file_generate()
306 306
 {
307 307
 	show_edit_preview();
308 308
 
309
-	$.generateFile({
309
+	$j.generateFile({
310 310
 		filename	: 'install.xml',
311 311
 		content		: $j('#preview').text(),
312 312
 		script		: $j('#downloadername').val() + '?download'
... ...
@@ -317,7 +317,7 @@ function download_file_data()
317 317
 {
318 318
 	show_edit_preview();
319 319
 
320
-	data = $.base64.encode($j('#preview').text());
320
+	data = $j.base64.encode($j('#preview').text());
321 321
 
322 322
 	/* No filename can be specified by a data URI */
323 323
 	window.location = 'data:application/octet-stream;charset=utf-8;base64,' + data;
324 324