Commits

Mark Vasilkov  committed aa90d03

ICanHaz.js

  • Participants
  • Parent commits 2aad44d

Comments (0)

Files changed (9)

 	baseUrl: '',
 	paths: {
 		backbone: 'lib/backbone/backbone',
+		backbone_super: 'lib/misato/backbone_super',
 		bootstrap: 'lib/bootstrap/bootstrap',
+		icanhaz: 'lib/icanhaz/icanhaz',
 		jquery: 'lib/jquery/jquery',
 		lodash: 'lib/lodash/lodash',
 		mustache: 'lib/mustache/mustache',
-		text: 'lib/require/text'
+		text: 'lib/require/text',
+		// app
+		base: 'app/views/base'
 	},
 	shim: {
 		backbone: {
 			deps: ['lodash', 'jquery'],
 			exports: 'Backbone'
+		},
+		icanhaz: {
+			deps: ['mustache', 'jquery'],
+			exports: 'ich'
 		}
 	}
 })

File app/modules.js

Empty file removed.

File app/modules/ui/ui.js

Empty file removed.

File app/router.js

-define(['backbone'], function(Backbone) {
+define(['backbone', 'base'], function(Backbone, BaseView) {
 	return Backbone.Router.extend({
 		routes: {
 			'': 'default'
 		},
 
 		default: function() {
-			console.log('default route')
+			if (!this._base)
+				this._base = new BaseView
 		}
 	})
 })

File app/views/base.js

+define(['jquery', 'backbone', 'icanhaz'], function($, Backbone, ich) {
+	return Backbone.View.extend({
+		el: '#base',
+
+		initialize: function() {
+			ich.grabTemplates()
+			this.render()
+		},
+
+		render: function() {
+			$('.modal').remove()
+			ich.base_t().appendTo(this.el)
+		}
+	})
+})

File bin/update.py

     'backbone/backbone.js': {
         'url': 'http://backbonejs.org/backbone.js',
     },
+    'icanhaz/icanhaz.js': {
+        'url': 'https://raw.github.com/mvasilkov/ICanHaz.js/master/ICanHaz-no-mustache.js',
+    },
     'jquery/jquery.js': {
         'url': 'http://code.jquery.com/jquery-%s.js',
         'version': '1.8.1',
 		<meta charset="utf-8">
 		<title>Misato</title>
 		<link rel="stylesheet" href="lib/bootstrap/bootstrap.css">
+		<style>body {padding-top: 60px}</style>
 		<link rel="stylesheet" href="lib/bootstrap/bootstrap-responsive.css">
 		<link rel="stylesheet" href="media/main.css">
 	</head>
 			</div>
 			<div class="modal-footer">Programmed by Rei Ayanami.</div>
 		</div>
+		<div class="navbar navbar-fixed-top navbar-inverse">
+			<div class="navbar-inner">
+				<div class="container-fluid">
+					<a href="javascript:;" class="brand">Misato <i class="icon-star"></i> <small>v0.0.1</small></a>
+				</div>
+			</div>
+		</div>
 		<div class="container-fluid" id="base"></div>
+		<script type="text/html" id="base_t">
+			<div class="span3">
+				<div class="sidebar-nav">
+					<ul class="nav nav-list" id="tasks">
+						<li class="nav-header">Tasks</li>
+					</ul>
+				</div>
+			</div>
+		</script>
 		<script data-main="app/main" src="lib/require/require.js"></script>
 	</body>
 </html>

File lib/icanhaz/icanhaz.js

+/*!
+ICanHaz.js version 0.10.1p1 -- by @HenrikJoreteg
+More info at: http://icanhazjs.com
+*/
+(function () {
+/*!
+  ICanHaz.js -- by @HenrikJoreteg
+*/
+/*global  */
+(function () {
+    function trim(stuff) {
+        if (''.trim) return stuff.trim();
+        else return stuff.replace(/^\s+/, '').replace(/\s+$/, '');
+    }
+
+    // Establish the root object, `window` in the browser, or `global` on the server.
+    var root = this;
+
+    var ich = {
+        VERSION: "0.10.1p1",
+        templates: {},
+
+        // grab jquery or zepto if it's there
+        $: (typeof window !== 'undefined') ? window.jQuery || window.Zepto || null : null,
+
+        // grab mustache from require.js (if any) or global var
+        mustache: Mustache || (typeof require === 'function'? require('mustache'): null),
+
+        // public function for adding templates
+        // can take a name and template string arguments
+        // or can take an object with name/template pairs
+        // We're enforcing uniqueness to avoid accidental template overwrites.
+        // If you want a different template, it should have a different name.
+        addTemplate: function (name, templateString) {
+            if (typeof name === 'object') {
+                for (var template in name) {
+                    this.addTemplate(template, name[template]);
+                }
+                return;
+            }
+            if (ich[name]) {
+                console.error("Invalid name: " + name + ".");
+            } else if (ich.templates[name]) {
+                console.error("Template \"" + name + "  \" exists");
+            } else {
+                ich.templates[name] = templateString;
+                ich[name] = function (data, raw) {
+                    data = data || {};
+                    var result = ich.mustache.to_html(ich.templates[name], data, ich.templates);
+                    return (ich.$ && !raw) ? ich.$(result) : result;
+                };
+            }
+        },
+
+        // clears all retrieval functions and empties cache
+        clearAll: function () {
+            for (var key in ich.templates) {
+                delete ich[key];
+            }
+            ich.templates = {};
+        },
+
+        // clears/grabs
+        refresh: function () {
+            ich.clearAll();
+            ich.grabTemplates();
+        },
+
+        // grabs templates from the DOM and caches them.
+        // Loop through and add templates.
+        // Whitespace at beginning and end of all templates inside <script> tags will
+        // be trimmed. If you want whitespace around a partial, add it in the parent,
+        // not the partial. Or do it explicitly using <br/> or &nbsp;
+        grabTemplates: function () {
+            var i,
+                l,
+                scripts = document.getElementsByTagName('script'),
+                script,
+                trash = [];
+            for (i = 0, l = scripts.length; i < l; i++) {
+                script = scripts[i];
+                if (script && script.innerHTML && script.id && (script.type === "text/html" || script.type === "text/x-icanhaz")) {
+                    ich.addTemplate(script.id, trim(script.innerHTML));
+                    trash.unshift(script);
+                }
+            }
+            for (i = 0, l = trash.length; i < l; i++) {
+                trash[i].parentNode.removeChild(trash[i]);
+            }
+        }
+    };
+
+    // Export the ICanHaz object for **Node.js**, with
+    // backwards-compatibility for the old `require()` API. If we're in
+    // the browser, add `ich` as a global object via a string identifier,
+    // for Closure Compiler "advanced" mode.
+    if (typeof exports !== 'undefined') {
+        if (typeof module !== 'undefined' && module.exports) {
+            exports = module.exports = ich;
+        }
+        exports.ich = ich;
+    } else {
+        root['ich'] = ich;
+    }
+
+    if (typeof document !== 'undefined') {
+        if (ich.$) {
+            ich.$(function () {
+                ich.grabTemplates();
+            });
+        } else {
+            document.addEventListener('DOMContentLoaded', function () {
+                ich.grabTemplates();
+            }, true);
+        }
+    }
+
+})();
+})();

File media/main.css

 	background: #fbfbfb;
 }
 
+.navbar .brand {
+	color: #cf6;
+}
+
+.navbar .brand:hover {
+	color: #6cf;
+}
+
 h3, .modal-footer {
 	font-weight: 300;
 }