Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
created create-ria skeleton project, updated dependency versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Reto Bachmann-Gmür committed Jun 14, 2012
1 parent 9b61a08 commit 3533212
Show file tree
Hide file tree
Showing 32 changed files with 1,321 additions and 21 deletions.
78 changes: 78 additions & 0 deletions create-ria/pom.xml
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>sling-stanbol</artifactId>
<groupId>org.wymiwyg.sling-stanbol</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<groupId>org.wymiwyg</groupId>
<artifactId>create-ria</artifactId>
<version>0.1-SNAPSHOT</version>
<name>JavaScript RIA</name>
<packaging>js</packaging>
<description>A JavaScript Rich Internet Application using jQuery and jQuery UI.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jquery-amd</artifactId>
<version>1.7.1-alpha-1</version>
<type>js</type>
</dependency>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jquery-ui-amd</artifactId>
<version>1.8.16-alpha-1</version>
<type>js</type>
</dependency>
</dependencies>

<build>
<extensions>
<extension>
<groupId>org.codehaus.mojo</groupId>
<artifactId>javascript-maven-plugin</artifactId>
<version>2.0.0-alpha-1</version>
</extension>
</extensions>
</build>

<!-- FIXME: Temporary declaration of Codehaus repos until this moves to Maven Central -->
<repositories>
<repository>
<id>snapshots</id>
<url>https://nexus.codehaus.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots</id>
<url>https://nexus.codehaus.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
</snapshots>
</pluginRepository>
</pluginRepositories>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
80 changes: 80 additions & 0 deletions create-ria/src/main/js/HelloWorld/HelloWorldController.js
@@ -0,0 +1,80 @@
/*global define */

define( ["jquery"], function($) {

/**
* Controls the showing of a 'Hello World' message.
*
* This is a "supervising controller" otherwise known as a "presenter".
* @see http://martinfowler.com/eaaDev/SupervisingPresenter.html
*
* @class Controls the showing of a 'Hello World' message.
* @name HelloWorldController
*/
function HelloWorldController() {
}

/**
* The HelloWorldView instance (injected)
*/
HelloWorldController.prototype.view = undefined;

/**
* The HelloWorldCommand instance (injected)
*/
HelloWorldController.prototype.command = undefined;

/**
* Success callback for the HelloWorldCommand.
* Show the 'Hello World' message using the view.
*
* @param message The message to show.
*/
HelloWorldController.prototype.getTextSuccess = function(message) {
var self = this;

self.view.setHelloWorldDivText(message);
};

/**
* Failure callback for the HelloWorldCommand.
* Show the error message using the view.
*
* @param errorMessage A description of the error
*/
HelloWorldController.prototype.getTextFailure = function(errorMessage) {
var self = this;

self.view.showError(errorMessage);
};

/**
* Initialization method for this controller.
*/
HelloWorldController.prototype.start = function() {
var self = this, text;

// Inject our helloButtonClick handler into the view
self.view.helloButtonClick = $.proxy(self.helloButtonClick, self);
// Initialize the view
self.view.initialize();

// Fetch the 'hello world' text using a command object
text = self.command.execute( $.proxy(self.getTextSuccess, self), $.proxy(self.getTextFailure, self) );
};

/**
* Handle a click on the #helloButton element.
*
* @param event The event object which triggered this handler.
*/
HelloWorldController.prototype.helloButtonClick = function(event) {
var self = this;

self.view.setHelloButtonText("Clicked");
};

// Return the function
return HelloWorldController;

});
82 changes: 82 additions & 0 deletions create-ria/src/main/js/HelloWorld/desktop/HelloWorldView.js
@@ -0,0 +1,82 @@
/*global define, window */

define( ["jquery-ui"], function($) {

/**
* User interface part of HelloWorld*.
* Shows messages to the user and reacts to user input.
* This view is part of the desktop view implementation.
*
* This is a "view" as defined by "supervising controller".
* @see http://martinfowler.com/eaaDev/SupervisingPresenter.html
*
* @class User interface part of HelloWorld*.
* @name HelloWorldView
*/
function HelloWorldView() {
}

/**
* The div used for the hello world message.
*/
HelloWorldView.prototype.div = undefined;

/**
* The event handler for a click on #helloButton.
*/
HelloWorldView.prototype.helloButtonClick = undefined;

/**
* Initialize the view.
* - Setup buttons
*/
HelloWorldView.prototype.initialize = function() {
var self = this;

// Setup #helloButton as a button and bind click to helloButtonClick event
$("#helloButton", self.div).button()
.click( function(event){
self.helloButtonClick(event);
});
};

/**
* Sets the hello world message in the #helloWorld div.
*
* @param message The message to set.
*/
HelloWorldView.prototype.setHelloWorldDivText = function(message) {
var self = this;

// Set message on the hello world div
$("#helloMessage", self.div).text(message);
};

/**
* Sets the hello world message in the #helloButton button.
*
* @param message The message to set.
*/
HelloWorldView.prototype.setHelloButtonText = function(message) {
var self = this;

// Set message on the hello world div
$("#helloButton span", self.div).text(message);
};

/**
* Show an error message.
*
* @param message The message to show.
*/
HelloWorldView.prototype.showError = function(message) {
var self = this;

// Show error message
window.alert("Error: " + message);
};

// Return the function
return HelloWorldView;

});
48 changes: 48 additions & 0 deletions create-ria/src/main/js/IndexContext.js
@@ -0,0 +1,48 @@
/*global define */

define([ "jquery", "HelloWorld/HelloWorldController", "HelloWorld/desktop/HelloWorldView", "model/HelloWorldCommand" ],
function($, HelloWorldController, HelloWorldView, HelloWorldCommand) {

/**
* Context for our index.html entry point.
*
* Sets up required objects, handles dependency injection, and starts
* the HelloWorldController.
*
* @class Context for our index.html entry point.
* @name IndexContext
*/
function IndexContext(){}

/**
* Initialize this context.
*
* Instantiates HelloWorld components, injects dependencies, and starts
* the HelloWorldController.
*/
IndexContext.prototype.initialize = function() {
var controller, view, command;

// Instantiate objects
controller = new HelloWorldController();
view = new HelloWorldView();
command = new HelloWorldCommand();

// Perform dependency injection by extending objects
$.extend(view, {
div: $("#helloWorld")
});

$.extend(controller, {
view: view,
command: command
});

// Start the HelloWorldController
controller.start();
};

// Return the function
return IndexContext;

});
14 changes: 14 additions & 0 deletions create-ria/src/main/js/index.js
@@ -0,0 +1,14 @@
/*global $, require */

// When the document is ready:
$().ready(function() {

require([ "IndexContext" ], function(IndexContext) {

// Create a new IndexContext and initialize it which will create and
// start a HelloWorldController
var indexContext = new IndexContext();
indexContext.initialize();
});

});
28 changes: 28 additions & 0 deletions create-ria/src/main/js/model/HelloWorldCommand.js
@@ -0,0 +1,28 @@
/*global define*/

define( [] ,function() {

/**
* Command object to retrieve the 'Hello World' text.
*
* @class Command object to retrieve the 'Hello World' text.
* @name HelloWorldCommand
*/
function HelloWorldCommand() {
}

/**
* Execute this command and then call the supplied success or
* failure callback as appropriate.
*
* @param success Callback function for a successful execution.
* @param failure Callback function for a failed execution.
*/
HelloWorldCommand.prototype.execute = function(success, failure) {
success("Hello World");
};

// Return the function
return HelloWorldCommand;

});
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions create-ria/src/main/resources/css/index.css
@@ -0,0 +1,26 @@
@CHARSET "UTF-8";

@import url("jquery-ui-1.8.16.custom.css");

body {
padding: 1em;
font-family: Verdana, sans-serif;
font-size: 10px;
}

h1 {
font-size: 3em;
color: #444;
}

#helloWorld {
border: 1px dashed #ddd;
padding: 1em;
margin-top: 2em;
}
#helloWorld #helloMessage {
font-size: 2em;
color: #888;
margin-bottom: 1em;
}
#helloWorld #helloButton {}

0 comments on commit 3533212

Please sign in to comment.