Created
November 27, 2011 19:42
Revisions
-
voidfiles revised this gist
Nov 27, 2011 . 1 changed file with 72 additions and 72 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,75 +1,75 @@ (function(A) { var registered_ids = {}, id_to_module_map = {}, interim_actions = {}, cleanup_actions = {}, clicked_ids = {}, queueing = {}; function register_id(id, callbacks, required_module) { id = id.replace('*', '.*'); registered_ids[id] = true; id_to_module_map[id] = required_module; interim_actions[id] = callbacks.interim; cleanup_actions[id] = callbacks.cleanup; } function rectify_id(actual_id) { var key_id; // this was a jslint clean up for (key_id in registered_ids) { if (registered_ids.hasOwnProperty(key_id) && actual_id.search(key_id) !== -1) { return key_id; } } return actual_id; } A.actionQueue = { register: function(id, callbacks, required_module) { var n, len; // this was a jslint cleanup if (id instanceof Array) { for (n = 0, len = id.length; n < len; n++) { register_id(id[n], callbacks, required_module); } } else { register_id(id, callbacks, required_module); } /* this is to handle multiple modules ending at there own time */ if(typeof queueing[required_module] === 'undefined'){ queueing[required_module] = true; } }, queue_click: function(id) { var id_key = rectify_id(id), required_module = id_to_module_map[id]; if (queueing[required_module] === true && id && id_key && registered_ids[id_key]) { clicked_ids[id_key] = true; if (typeof interim_actions[id_key] === 'function') { interim_actions[id_key].apply(this, arguments); } return false; } else if (queueing[required_module] === true) { return false; } return true; }, module_loaded: function(module_name, id_to_restrict_to) { var id; // jslint cleanup queueing[module_name] = false; // better handling of multiple modules for (id in id_to_module_map) { if (id_to_module_map.hasOwnProperty(id) && clicked_ids[id] && id_to_module_map[id] === module_name) { cleanup_actions[id](id_to_restrict_to ? id_to_restrict_to : id); } } }, refresh_module: function(){ /* I need to add this hook in here for testing purposes. */ registered_ids = {}; id_to_module_map = {}; interim_actions = {}; cleanup_actions = {}; clicked_ids = {}; queueing = {}; } }; }(A)); -
voidfiles revised this gist
Nov 27, 2011 . 1 changed file with 72 additions and 66 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,69 +1,75 @@ (function(A) { var registered_ids = {}, id_to_module_map = {}, interim_actions = {}, cleanup_actions = {}, clicked_ids = {}, queueing = {}; function register_id(id, callbacks, required_module) { id = id.replace('*', '.*'); registered_ids[id] = true; id_to_module_map[id] = required_module; interim_actions[id] = callbacks.interim; cleanup_actions[id] = callbacks.cleanup; } function rectify_id(actual_id) { var key_id; // this was a jslint clean up for (key_id in registered_ids) { if (registered_ids.hasOwnProperty(key_id) && actual_id.search(key_id) !== -1) { return key_id; } } return actual_id; } A.actionQueue = { register: function(id, callbacks, required_module) { var n, len; // this was a jslint cleanup if (id instanceof Array) { for (n = 0, len = id.length; n < len; n++) { register_id(id[n], callbacks, required_module); } } else { register_id(id, callbacks, required_module); } /* this is to handle multiple modules ending at there own time */ if(typeof queueing[required_module] === 'undefined'){ queueing[required_module] = true; } }, queue_click: function(id) { var id_key = rectify_id(id), required_module = id_to_module_map[id]; if (queueing[required_module] === true && id && id_key && registered_ids[id_key]) { clicked_ids[id_key] = true; if (typeof interim_actions[id_key] === 'function') { interim_actions[id_key].apply(this, arguments); } return false; } else if (queueing[required_module] === true) { return false; } return true; }, module_loaded: function(module_name, id_to_restrict_to) { var id; // jslint cleanup queueing[module_name] = false; // better handling of multiple modules for (id in id_to_module_map) { if (id_to_module_map.hasOwnProperty(id) && clicked_ids[id] && id_to_module_map[id] === module_name) { cleanup_actions[id](id_to_restrict_to ? id_to_restrict_to : id); } } }, refresh_module: function(){ /* I need to add this hook in here for testing purposes. */ registered_ids = {}; id_to_module_map = {}; interim_actions = {}; cleanup_actions = {}; clicked_ids = {}; queueing = {}; } }; }(A)); -
voidfiles revised this gist
Nov 27, 2011 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,6 +56,14 @@ cleanup_actions[id](id_to_restrict_to ? id_to_restrict_to : id); } } }, refresh_module: function(){ registered_ids = {}; id_to_module_map = {}; interim_actions = {}; cleanup_actions = {}; clicked_ids = {}; queueing = true; } }; }(A)); -
voidfiles created this gist
Nov 27, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,61 @@ (function(A) { var registered_ids = {}, id_to_module_map = {}, interim_actions = {}, cleanup_actions = {}, clicked_ids = {}, queueing = true; function register_id(id, callbacks, required_module) { id = id.replace('*', '.*'); registered_ids[id] = true; id_to_module_map[id] = required_module; interim_actions[id] = callbacks.interim; cleanup_actions[id] = callbacks.cleanup; } function rectify_id(actual_id) { var key_id; for (key_id in registered_ids) { if (registered_ids.hasOwnProperty(key_id) && actual_id.search(key_id) !== -1) { return key_id; } } return actual_id; } A.actionQueue = { register: function(id, callbacks, required_module) { var n, len; if (id instanceof Array) { for (n = 0, len = id.length; n < len; n++) { register_id(id[n], callbacks, required_module); } } else { register_id(id, callbacks, required_module); } }, queue_click: function(id) { var id_key = rectify_id(id); if (queueing && id && id_key && registered_ids[id_key]) { clicked_ids[id_key] = true; if (typeof interim_actions[id_key] === 'function') { interim_actions[id_key].apply(this, arguments); } return false; } else if (queueing) { return false; } return true; }, module_loaded: function(module_name, id_to_restrict_to) { var id; queueing = false; for (id in id_to_module_map) { if (id_to_module_map.hasOwnProperty(id) && clicked_ids[id] && id_to_module_map[id] === module_name) { cleanup_actions[id](id_to_restrict_to ? id_to_restrict_to : id); } } } }; }(A));