Permalink
Browse files

Improving upon the loader to accept an array, string, and object. Loa…

…ding things appropriately and moving forward with the application skeleton. Added dockblocks where necessary.
  • Loading branch information...
1 parent 6603065 commit cd5b95576669e2852a9512748cd5cae168a7dad5 @markizano committed Mar 31, 2012
Showing with 48 additions and 4 deletions.
  1. +33 −2 htdocs/assets/js/Kizano/Loader.js
  2. +15 −2 htdocs/assets/js/default.js
@@ -42,6 +42,15 @@ Kizano.Loader = (function ($) {
cache: {},
};
+ /**
+ * Checks to see if an object exists or has been defined, rather.
+ * It should return if you pass a string or the object test itself.
+ * This also checks recursively along a string of objects (e.g. document.location.href).
+ * Checks along all the global namespaces available in a browser
+ *
+ * @param target string The target to check for existance.
+ * @return boolean
+ */
self.exists = function (target) {
if ( typeof (target) === "undefined" ) { return false; }
var a, c, gl;
@@ -73,10 +82,27 @@ Kizano.Loader = (function ($) {
return false;
};
+ /**
+ * Makes a request to the server for a class and imports it into the system via eval.
+ *
+ * @param target string|array The target(s) to import.
+ * @return array The object(s) imported.
+ */
self.request = function (target) {
if ( self.exists(target) ) {
return typeof (target) === "string"? eval(target): target;
}
+ var result = [];
+
+ if ($.isArray(target)) {
+ $.each(target, function (i, cls) {
+ self.exists(cls) && result.push(typeof (cls) === "string"? eval(cls): target);
+ target.splice(i, 1);
+ return true;
+ });
+
+ target = target.join(',');
+ }
$.ajax({
url: '/assets/js/',
@@ -124,6 +150,12 @@ Kizano.Loader = (function ($) {
});
};
+ /**
+ * Loads an object into the system dynamically from the server.
+ *
+ * @param target string|array The object(s) to import to the system.
+ * @return array The object(s) loaded.
+ */
self.load = function (target) {
if (self.exists(target.replace(/\x2F/g, "."))) { return that; }
return self.request(target);
@@ -139,7 +171,6 @@ var use = function (target) {
/*
ok(use("Kizano.Registry"));
- ok(use(["Kizano.View", "Kizano.Layout"]));
+ ok(use(["Kizano.View", "Kizano.Layout"])); // @TODO!
*/
-/*jslint bitwise: true, browser: true, sloppy: false, evil: true, plusplus: true, maxerr: 50, indent: 4 */
@@ -66,8 +66,11 @@ typeof(console) !== "undefined" && console.log("OK"); //DEBUG
- Layout: Draw up the basic HTML structure that will pose as the layout for this site.
- HTML Structure from JSON-XSL translation.
- CSS Manager. I believe there are libraries that support this.
+ - Plugins: Need the ability to hook in modules to dynamically modify the page as we need
+ for custom components of projects.
+ - Controller: Load up the current controller handling this request.
- Determine the current request based on the params in the URL.
- - Fetch the request accordingly from the server.
+ - Fetch the request accordingly from the server via controller calls to request-response modules.
- Render the result on the page and return to even-based orientation.
// ...
- OnClose -
@@ -77,6 +80,16 @@ typeof(console) !== "undefined" && console.log("OK"); //DEBUG
- Close open windows.
- End session.
- End
+
+
+ Components needed:
+ Registry : Global object for persisting objects and configurations across pageloads
+ (e.g. the user leaves the site and comes back).
+ Config : Global per-request object for storing key-value config/option pairs.
+ Loader : Used for loading modules and objects dynamically from the server.
+ Binder : Base Object for managing major keybindings. It's role is similar to that of your
+ window manager; it will manage hotkeys/events dealing with the window, while each module can
+ independently hold its own hotkey overrides/additions.
+
*/
-/*jslint bitwise: true, browser: true, evil: true, plusplus: true, maxerr: 50, indent: 4 */

0 comments on commit cd5b955

Please sign in to comment.