Commits

Rufus Pollock committed 23ac348

[app.js][s]: create module CommentOnIt in module-pattern style and refactor app to attach sammy app to this module.

* index.html: move running of sammy app on document ready out of app.js into index.html so that app.js is more reusable (e.g. in tests -- see next commit)

Comments (0)

Files changed (2)

_attachments/index.html

 <script src="script/vendor/sammy/plugins/sammy.title.js" type="text/javascript" charset="utf-8"></script>
 <script src="script/vendor/showdown.js" type="text/javascript" charset="utf-8"></script>
 <script src="script/app.js" type="text/javascript" charset="utf-8"></script>
+<script type="text/javascript" charset="utf-8">
+	jQuery(function() {
+		CommentOnIt.app.run('#/');
+	});
+</script>
 </body>
 </html>

_attachments/script/app.js

-;(function($) {
+var CommentOnIt = (function($, commentOnIt) {
 	var dbname = window.location.pathname.split('/')[1] || 'commentonit',
 		db     = $.couch.db(dbname);
 
 		}
 	};
 
-
-	var app = $.sammy('.entry-content', function() {
+	commentOnIt.app = $.sammy('.entry-content', function() {
 		this.use('Mustache', 'ms');
 		this.use('Title');
 		this.setTitle(function(title) {
 
 		this.get('#/text/edit', function(context) {
 			this.title('Create - Text');
+			context.log('Create - Text');
 			context.partial('templates/text/edit.ms', {
 				pageHeading: 'Create Text (to annotate)'
 				});
 		});
 	});
 
-	$(function() {
-		app.run('#/');
-	});
-})(jQuery);
+	return commentOnIt;
+})(jQuery, CommentOnIt || {});
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.