Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More OCD related work

  • Loading branch information...
commit fc1155beaab94b6f919a89c5a41711fbb4bc2305 1 parent 5cfdd07
@alexanderteinum alexanderteinum authored
View
8 application-grid.js
@@ -1,5 +1,5 @@
var ApplicationGrid = Element.extend({
- init: function(brevity, applicationDefinitions){
+ init: function(brevity, applicationDefinitions) {
this.brevity = brevity;
this.applicationDefinitions = applicationDefinitions;
@@ -10,7 +10,7 @@ var ApplicationGrid = Element.extend({
this.initEvents();
},
- initGrid: function(){
+ initGrid: function() {
for (var i = 0; i < this.applicationDefinitions.length; i++) {
var row = $(document.createElement('tr'));
for (var j = 0; j < this.applicationDefinitions[i].length; j++) {
@@ -23,9 +23,9 @@ var ApplicationGrid = Element.extend({
}
},
- initEvents: function(){
+ initEvents: function() {
var that = this;
- this.element.click(function(e){
+ this.element.click(function(e) {
that.deactivate();
var application = that.brevity.createApplication(
View
26 application.js
@@ -1,5 +1,5 @@
var Application = Class.extend({
- init: function(brevity, applicationDefinition, initialZIndex){
+ init: function(brevity, applicationDefinition, initialZIndex) {
this.brevity = brevity;
this.name = applicationDefinition.name;
this.url = applicationDefinition.url;
@@ -11,7 +11,7 @@ var Application = Class.extend({
this.initElements();
},
- initElements: function(){
+ initElements: function() {
this.overlay = $(document.createElement('div'))
.applicationOverlay(this.brevity, this);
@@ -23,31 +23,31 @@ var Application = Class.extend({
.documentList(this);
},
- isActive: function(){
+ isActive: function() {
return this.brevity.getActiveApplication() === this;
},
- getName: function(){
+ getName: function() {
return this.name;
},
- getUrl: function(){
+ getUrl: function() {
return this.url;
},
- getOverlay: function(){
+ getOverlay: function() {
return this.overlay;
},
- getApplicationTab: function(){
+ getApplicationTab: function() {
return this.applicationTab;
},
- getDocumentList: function(){
+ getDocumentList: function() {
return this.documentList;
},
- activate: function(zIndex){
+ activate: function(zIndex) {
this.documentList.addClass('active');
this.addClass('activeApplication');
this.overlay.addClass('activeApplication');
@@ -56,17 +56,17 @@ var Application = Class.extend({
this.setZIndexes(zIndex);
},
- addClass: function(class_){
+ addClass: function(class_) {
for (var i = 0; i < this.documents.length; i++)
this.documents[i].addClass(class_);
},
- removeClass: function(class_){
+ removeClass: function(class_) {
for (var i = 0; i < this.documents.length; i++)
this.documents[i].removeClass(class_);
},
- deactivate: function(zIndex){
+ deactivate: function(zIndex) {
this.documentList.removeClass('active');
this.removeClass('activeApplication');
this.applicationTab.removeClass('active');
@@ -75,7 +75,7 @@ var Application = Class.extend({
this.setZIndexes(zIndex);
},
- remove: function(){
+ remove: function() {
for (var i = 0; i < this.documents.length; i++)
this.documents[i].remove();
View
12 brevity.js
@@ -1,5 +1,5 @@
var Brevity = Class.extend({
- init: function(wall, documentBar, applicationBar){
+ init: function(wall, documentBar, applicationBar) {
this.wall = wall;
this.documentBar = documentBar;
this.applicationBar = applicationBar;
@@ -30,7 +30,7 @@ var Brevity = Class.extend({
},
activateApplication: function(application) {
- this.applications.sort(function(a, b){
+ this.applications.sort(function(a, b) {
return a.getZIndex() - b.getZIndex();
});
@@ -88,24 +88,24 @@ var Brevity = Class.extend({
this.resizeApplications();
},
- toggleFullscreen: function(){
+ toggleFullscreen: function() {
$('body').toggleClass('fullscreen');
this.resizeApplications();
},
- resizeApplications: function(){
+ resizeApplications: function() {
for (var i = 0; i < this.applications.length; i++)
this.applications[i].resize();
},
- toggleBars: function(){
+ toggleBars: function() {
if (this.isFullscreen() === true) {
for (var i = 0; i < this.applications.length; i++)
this.applications[i].resize();
}
},
- areBarsHidden: function(){
+ areBarsHidden: function() {
return !($('div.bar').hasClass('active'));
}
});
View
4 clock.js
@@ -1,7 +1,7 @@
-(function($){
+(function($) {
$.fn.clock = function() {
- return this.each(function(){
+ return this.each(function() {
var clock = $(this);
function updateClock() {
View
8 document-list.js
@@ -1,10 +1,10 @@
-(function($){
+(function($) {
$.fn.documentList = function(application) {
- return this.each(function(){
+ return this.each(function() {
$(this)
.addClass('documentList')
- .bind('mouseup', function(e){
+ .bind('mouseup', function(e) {
var element = $(e.target);
if (element.is('input') === true)
@@ -25,7 +25,7 @@ $.fn.documentList = function(application) {
break;
}
})
- .bind('keypress', function(e){
+ .bind('keypress', function(e) {
var element = $(e.target);
if (element.is('input') === false)
View
16 document.js
@@ -1,7 +1,7 @@
// A document is represented by an iframe and a tab.
var Document = Element.extend({
- init: function(documentTab){
+ init: function(documentTab) {
this.documentTab = documentTab;
// Set object reference to be used in the delegation event handler for
@@ -17,34 +17,34 @@ var Document = Element.extend({
this.documentTab.setTitle(url);
},
- getDocumentTab: function(){
+ getDocumentTab: function() {
return this.documentTab;
},
- remove: function(){
+ remove: function() {
this.documentTab.remove();
this.element.remove();
},
- activate: function(){
+ activate: function() {
this.documentTab.activate();
this.element.addClass('activeDocument');
},
- deactivate: function(){
+ deactivate: function() {
this.documentTab.deactivate();
this.element.removeClass('activeDocument');
},
- setZIndex: function(zIndex){
+ setZIndex: function(zIndex) {
this.element.css('zIndex', zIndex);
},
- positionScaled: function(scale, left, top){
+ positionScaled: function(scale, left, top) {
this.element.positionScaled(scale, left, top);
},
- rectangle: function(rect){
+ rectangle: function(rect) {
this.element.rectangle(rect);
}
});
View
26 main.js
@@ -1,4 +1,4 @@
-$(function(){
+$(function() {
var main = new Main();
});
@@ -54,11 +54,11 @@ var Main = Class.extend({
initWindowEvents: function() {
var that = this;
- $(window).bind('contextmenu', function(){
+ $(window).bind('contextmenu', function() {
return false;
});
- $(window).bind('resize', function(){
+ $(window).bind('resize', function() {
for (var i = 0; i < that.resizeable.length; i++)
that.resizeable[i].resize();
});
@@ -67,15 +67,15 @@ var Main = Class.extend({
initKeyEvents: function() {
var that = this;
- $(document).bind('keydown', 'ctrl+space', function(){
+ $(document).bind('keydown', 'ctrl+space', function() {
that.brevity.toggleFullscreen();
});
- $(document).bind('keydown', 'space', function(){
+ $(document).bind('keydown', 'space', function() {
that.brevity.fullscreen();
});
- $(document).bind('keydown', 'alt+f', function(){
+ $(document).bind('keydown', 'alt+f', function() {
that.applicationBar.toggle();
that.documentBar.toggle();
that.brevity.toggleBars();
@@ -85,7 +85,7 @@ var Main = Class.extend({
initMouseEvents: function() {
var that = this;
- this.wall.get().mousedown(function(e){
+ this.wall.get().mousedown(function(e) {
if (that.applicationGrid.isActive() === true) {
that.applicationGrid.deactivate();
return;
@@ -95,18 +95,18 @@ var Main = Class.extend({
that.applicationGrid.activate();
});
- this.documentBar.getNewDocumentButton().click(function(e){
+ this.documentBar.getNewDocumentButton().click(function(e) {
if (that.brevity.getActiveApplication() !== null) {
that.brevity.createDocument(that.brevity.getActiveApplication());
that.brevity.getActiveApplication().resize();
}
});
- this.documentBar.getToggleFullscreenButton().click(function(e){
+ this.documentBar.getToggleFullscreenButton().click(function(e) {
that.brevity.toggleFullscreen();
});
- this.applicationBar.getNewApplicationButton().click(function(e){
+ this.applicationBar.getNewApplicationButton().click(function(e) {
if (that.applicationGrid.isActive() === true) {
that.applicationGrid.deactivate();
return;
@@ -119,18 +119,18 @@ var Main = Class.extend({
that.applicationGrid.activate();
});
- this.applicationBar.getApplicationList().mouseover(function(e){
+ this.applicationBar.getApplicationList().mouseover(function(e) {
var element = $(e.target);
var application = element.data('application');
$('iframe').removeClass('preview');
application.addClass('preview');
});
- this.applicationBar.getApplicationList().mouseleave(function(e){
+ this.applicationBar.getApplicationList().mouseleave(function(e) {
$('iframe').removeClass('preview');
});
- this.applicationBar.getApplicationList().mousedown(function(e){
+ this.applicationBar.getApplicationList().mousedown(function(e) {
var element = $(e.target);
var application = element.data('application');
View
14 overlay.js
@@ -1,14 +1,14 @@
-(function($){
+(function($) {
// The overlay is a div-element placed on top of the active document-iframe to
// make it draggable. It's also used to remember the size of the iframe when the
// iframe is in fullscreen.
$.fn.applicationOverlay = function(brevity, application) {
- return this.each(function(){
+ return this.each(function() {
var overlay = $(this)
.addClass('applicationOverlay')
- .mouseover(function(e){
+ .mouseover(function(e) {
// This check is a workaround for what seems to be two bugs in
// WebKit.
@@ -26,10 +26,10 @@ $.fn.applicationOverlay = function(brevity, application) {
application.addClass('preview');
}
})
- .mouseleave(function(e){
+ .mouseleave(function(e) {
application.removeClass('preview');
})
- .mousedown(function(e){
+ .mousedown(function(e) {
brevity.activateApplication(application);
overlay.addClass('drag');
@@ -41,7 +41,7 @@ $.fn.applicationOverlay = function(brevity, application) {
// bound to the entire screen for drag and drop.
var document = $(document)
- .bind('mousemove.drag', function(e){
+ .bind('mousemove.drag', function(e) {
var left = overlayPosition.left +
(e.clientX - mouseDownLeft);
var top = overlayPosition.top +
@@ -50,7 +50,7 @@ $.fn.applicationOverlay = function(brevity, application) {
overlay.positionScaled(0.5, left, top);
application.positionScaled(0.5, left, top);
})
- .bind('mouseup.drag', function(e){
+ .bind('mouseup.drag', function(e) {
overlay.removeClass('drag');
document.unbind('.drag');
View
6 tests/application-test.js
@@ -1,5 +1,5 @@
TestCase('ApplicationTest', {
- setUp: function(){
+ setUp: function() {
this.brevity = new Brevity();
this.application = new Application(
@@ -9,11 +9,11 @@ TestCase('ApplicationTest', {
1);
},
- testAddDocument: function(){
+ testAddDocument: function() {
this.application.addDocument(new Document(new DocumentTab()));
},
- testResize_Overlay: function(){
+ testResize_Overlay: function() {
var halfScreenWidth = (window.innerWidth / 2) + 'px';
this.application.resize();
View
2  tests/document-tab-test.js
@@ -1,5 +1,5 @@
TestCase('DocumentTabTest', {
- setUp: function(){
+ setUp: function() {
this._documentTab = new DocumentTab();
},
View
8 utility.js
@@ -5,9 +5,9 @@ Array.prototype.remove = function(from, to) {
return this.push.apply(this, rest);
};
-(function($){
+(function($) {
-// Remove 'px' from css-value and convert to int.
+// Remove 'px' from CSS-value and convert to int.
$.removePx = function(str) {
return parseInt(str.substr(0, str.length - 2), 10);
@@ -47,7 +47,7 @@ $.fn.height_ = function() {
//
// element.positionScaled(0.5); // Returns {left:10,top:10}:
-$.fn.positionScaled = function(scale, left, top){
+$.fn.positionScaled = function(scale, left, top) {
var element = $(this);
var scaledWidth = element.width_() * scale;
@@ -90,7 +90,7 @@ $.fn.rectangle = function(rect) {
}
}
- return this.each(function(){
+ return this.each(function() {
$(this)
.css('left', rect.left)
.css('top', rect.top)

0 comments on commit fc1155b

Please sign in to comment.
Something went wrong with that request. Please try again.