Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Forgot about using live, it works better for this setup.Also fixed t…

…he collapse/delete/restore/expand links to return default preventing their default actions
  • Loading branch information...
commit 5b70d58e971dffbf23f873cd08d01bdc049025a5 1 parent a4c3bc5
Jeremy D authored
Showing with 59 additions and 37 deletions.
  1. +31 −20 assets/script_info.js
  2. +28 −17 assets/script_mod.js
View
51 assets/script_info.js
@@ -12,11 +12,25 @@ $(document).ready(function(){
instruct_count =new Array();
instruct_count[action_count] = 1;
- /* Kick things off by creating a new action. */
- create_new_action();
+ /* Bind some stuff to our actions, using live so they auto update as new stuff is added. */
+ $('.collapse_action').live('click', collapse_action);
+ $('.expand_action').live('click', expand_action);
+ $('.delete_action').live('click', delete_action);
+ $('.restore_action').live('click', restore_action);
+
+ /* Now we will bind to the actual changes, again using live. */
+ $('.collapse_change').live('click', collapse_instruct);
+ $('.expand_change').live('click', expand_instruct);
+ $('.delete_change').live('click', delete_instruct);
+ $('.restore_change').live('cick', restore_instruct);
+
+ /* Now we will bind to some toggles in those changes, again using live. */
+ $('.instruct_action').live('change', instruct_change);
+ $('.inline_check').live('change', instruct_inline);
/* Give our buttons some actions. */
$('#add_action').click(create_new_action);
+ $('.add_instruct').live('click', create_new_instruct);
$('#show_preview').click(show_instruct_preview);
/* The details and basic buttons. */
@@ -24,6 +38,9 @@ $(document).ready(function(){
$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();});
$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();});
$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();});
+
+ /* Kick things off by creating a new action. */
+ create_new_action();
});
/* Handles adding actions */
@@ -32,18 +49,9 @@ function create_new_action()
/* We have been through this before */
$('#action_container').append($('#action_template').html().replace(/#ACTIONINDEX#/g, action_count));
- /* We need to bind the new create instruct button */
- $('.add_instruct').click(create_new_instruct);
-
/* Now we pretend to click said element */
$('#action-' + action_count).find('.add_instruct').click();
- /* Now add some actions to our buttons */
- $('#action-' + action_count + ' .collapse_action').click(collapse_action);
- $('#action-' + action_count + ' .expand_action').click(expand_action);
- $('#action-' + action_count + ' .delete_action').click(delete_action);
- $('#action-' + action_count + ' .restore_action').click(restore_action);
-
/* Move the index and add defaults */
action_count++;
instruct_count[action_count] = 1;
@@ -59,16 +67,8 @@ function create_new_instruct()
$('#action-' + action_index + '-instruct_container').append($('#instruct_template').html().replace(/#ACTIONINDEX#/g, action_index).replace(/#INSTRUCTINDEX#/g, instruct_count[action_index]));
- $('#action-' + action_index + '-instruct_container .collapse_change').click(collapse_instruct);
- $('#action-' + action_index + '-instruct_container .expand_change').click(expand_instruct);
- $('#action-' + action_index + '-instruct_container .delete_change').click(delete_instruct);
- $('#action-' + action_index + '-instruct_container .restore_change').click(restore_instruct);
-
- $('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change(instruct_change);
$('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change();
- $('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-inline').change(instruct_inline);
-
instruct_count[action_index]++;
update_counter();
@@ -122,7 +122,6 @@ function instruct_change()
/* We don't know what to do here! */
console.log("Unknown instruction action selected" [this_act, action_index, instruct_index], this);
}
-
}
/* Handles clicking the inline button */
@@ -152,6 +151,8 @@ function collapse_instruct()
$('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').hide();
$('#action-' + action_index + '-instruct-' + instruct_index + ' .expand_change').show();
$(this).hide();
+
+ return false;
}
/* Handles expanding of the instruct */
@@ -164,6 +165,8 @@ function expand_instruct()
$('#action-' + action_index + '-instruct-' + instruct_index + ' .edits').show();
$('#action-' + action_index + '-instruct-' + instruct_index + ' .collapse_change').show();
$(this).hide();
+
+ return false;
}
/* Handles deleting a instruct */
@@ -181,6 +184,7 @@ function delete_instruct()
$(this).hide();
update_counter();
+ return false;
}
/* Handles restoring a instruct */
@@ -198,6 +202,7 @@ function restore_instruct()
$(this).hide();
update_counter();
+ return false;
}
/* Handles collapsing of the action */
@@ -209,6 +214,8 @@ function collapse_action()
$('#action-' + action_index + '-instruct_container').hide();
$('#action-' + action_index + ' .expand_action').show();
$(this).hide();
+
+ return false;
}
/* Handles expanding of the action */
@@ -220,6 +227,8 @@ function expand_action()
$('#action-' + action_index + '-instruct_container').show();
$('#action-' + action_index + ' .collapse_action').show();
$(this).hide();
+
+ return false;
}
/* Handles deleting a action */
@@ -236,6 +245,7 @@ function delete_action()
$(this).hide();
update_counter();
+ return false;
}
/* Handles restoring a action */
@@ -252,6 +262,7 @@ function restore_action()
$(this).hide();
update_counter();
+ return false;
}
/* This is the nasty guy */
View
45 assets/script_mod.js
@@ -12,12 +12,21 @@ $(document).ready(function(){
edit_count =new Array();
edit_count[file_count] = 1;
- /* Kick things off by creating a file. */
- create_new_file();
-
- $('#add_file').click(create_new_file);
+ /* Bind some stuff to our files, using live so they auto update as new stuff is added. */
+ $('.collapse_file').live('click', collapse_file);
+ $('.expand_file').live('click', expand_file);
+ $('.delete_file').live('click', delete_file);
+ $('.restore_file').live('click', restore_file);
+
+ /* Now we will bind to the actual edits, again using live. */
+ $('.collapse_change').live('click', collapse_edit);
+ $('.expand_change').live('click', expand_edit);
+ $('.delete_change').live('click', delete_edit);
+ $('.restore_change').live('click', restore_edit);
/* Give our buttons some actions. */
+ $('#add_file').click(create_new_file);
+ $('.add_edit').live('click', create_new_edit);
$('#show_preview').click(show_edit_preview);
/* The details and basic buttons. */
@@ -25,6 +34,9 @@ $(document).ready(function(){
$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();});
$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();});
$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();});
+
+ /* Kick things off by creating a file. */
+ create_new_file();
});
/* Handles adding files */
@@ -33,17 +45,9 @@ function create_new_file()
/* We have been through this before */
$('#file_container').append($('#file_template').html().replace(/#FILEINDEX#/g, file_count));
- /* We need to bind the new create edit button */
- $('.add_edit').click(create_new_edit);
-
/* Now we pretend to click said element */
$('#file-' + file_count).find('.add_edit').click();
- $('#file-' + file_count + ' .collapse_file').click(collapse_file);
- $('#file-' + file_count + ' .expand_file').click(expand_file);
- $('#file-' + file_count + ' .delete_file').click(delete_file);
- $('#file-' + file_count + ' .restore_file').click(restore_file);
-
/* Move the index and add defaults */
file_count++;
edit_count[file_count] = 1;
@@ -59,11 +63,6 @@ function create_new_edit()
$('#file-' + file_index + '-edit_container').append($('#edit_template').html().replace(/#FILEINDEX#/g, file_index).replace(/#EDITINDEX#/g, edit_count[file_index]));
edit_count[file_index]++;
- $('#file-' + file_index + '-edit_container .collapse_change').click(collapse_edit);
- $('#file-' + file_index + '-edit_container .expand_change').click(expand_edit);
- $('#file-' + file_index + '-edit_container .delete_change').click(delete_edit);
- $('#file-' + file_index + '-edit_container .restore_change').click(restore_edit);
-
update_counter();
}
@@ -77,6 +76,8 @@ function collapse_edit()
$('#file-' + file_index + '-edit-' + edit_index + ' .edits').hide();
$('#file-' + file_index + '-edit-' + edit_index + ' .expand_change').show();
$(this).hide();
+
+ return false;
}
/* Handles expanding of the edit */
@@ -89,6 +90,8 @@ function expand_edit()
$('#file-' + file_index + '-edit-' + edit_index + ' .edits').show();
$('#file-' + file_index + '-edit-' + edit_index + ' .collapse_change').show();
$(this).hide();
+
+ return false;
}
/* Handles deleting a edit */
@@ -106,6 +109,7 @@ function delete_edit()
$(this).hide();
update_counter();
+ return false;
}
/* Handles restoring a edit */
@@ -123,6 +127,7 @@ function restore_edit()
$(this).hide();
update_counter();
+ return false;
}
/* Handles collapsing of the file */
@@ -134,6 +139,8 @@ function collapse_file()
$('#file-' + file_index + '-edit_container').hide();
$('#file-' + file_index + ' .expand_file').show();
$(this).hide();
+
+ return false;
}
/* Handles expanding of the file */
@@ -145,6 +152,8 @@ function expand_file()
$('#file-' + file_index + '-edit_container').show();
$('#file-' + file_index + ' .collapse_file').show();
$(this).hide();
+
+ return false;
}
/* Handles deleting a file */
@@ -161,6 +170,7 @@ function delete_file()
$(this).hide();
update_counter();
+ return false;
}
/* Handles restoring a file */
@@ -177,6 +187,7 @@ function restore_file()
$(this).hide();
update_counter();
+ return false;
}
/* This is the nasty guy */
Please sign in to comment.
Something went wrong with that request. Please try again.