Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added some files

Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
  • Loading branch information...
commit c78e55a875f35e43c60c74a98529a81459ac0ca7 1 parent 5a86ae4
@evensoul evensoul authored committed
View
3  app/models/color.rb
@@ -0,0 +1,3 @@
+class Color < ActiveRecord::Base
+ belongs_to :task
+end
View
7 app/views/projects/_color.html.erb
@@ -0,0 +1,7 @@
+<div class="color">
+ <p>
+ <%= f.label :name, "Color:" %>
+ <%= f.text_field :name %>
+ <%= remove_link_unless_new_record(f) -%>
+ </p>
+</div>
View
13 db/migrate/20090307211956_create_colors.rb
@@ -0,0 +1,13 @@
+class CreateColors < ActiveRecord::Migration
+ def self.up
+ create_table :colors do |t|
+ t.string :name
+ t.references :task
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :colors
+ end
+end
View
111 public/javascripts/delegate.js
@@ -0,0 +1,111 @@
+// Delegate functions for prototype.js version 1.6
+// ©2008 Ken Snyder (ken d snyder ~at~ gmail ~dot~ com)
+// under the creative commons attribution license v3.0 (http://creativecommons.org/licenses/by/3.0/)
+Object.extend(Event, (function() {
+ // Cache our delegates to allow removal.
+ // handlers are stored in nested objects indexed thus:
+ // element.id => eventName => array of rules objects with selector : handler pairs
+ var cache = { };
+ return {
+ // Add a delegate or set of delegate rules.
+ // 3rd and 4th arguments can be rule, handler
+ // or 3rd argument can be rule-handler object property-value pairs.
+ // (At least 3 arguments are required.)
+ delegate: function(element, eventName) {
+ // get the passed rules object
+ if (arguments[3]) {
+ // we have rule, handler in two arguments
+ var rules = { };
+ rules[arguments[2]] = arguments[3];
+ } else {
+ // we have a rule object
+ var rules = Object.extend({ }, arguments[2]);
+ }
+ var el = $(element), ev = eventName, id = el.identify ? el.identify() : 'document';
+ // set up our caching space if not defined
+ if (!cache[id]) {
+ // define observer function for each element
+ cache[id] = {'$observer': function(event) {
+ // function uses 'id' from scope above
+ var el = event.element();
+ if (cache[id][event.type])
+ for (var i = 0, len = cache[id][event.type].length; i < len; i++)
+ for (var selector in cache[id][event.type][i])
+ if (cache[id][event.type][i][selector][1].match(el))
+ cache[id][event.type][i][selector][0](event);
+ }};
+ // observe element
+ }
+ if (!cache[id][ev]) {
+ cache[id][ev] = [];
+ el.observe(ev, cache[id]['$observer']);
+ }
+ // cache the compiled Selector for each selector string
+ for (var selectorStr in rules)
+ rules[selectorStr] = [rules[selectorStr], new Selector(selectorStr)];
+ // cache the rules
+ cache[id][ev].push(rules);
+ return el;
+ },
+ // Cancel a delegate or set of delegate rules.
+ // 3rd argument can be a string rule
+ // or 3rd argument can be rule-handler object property-value pairs.
+ // Without 3rd argument, all event rules for the event will be stopped.
+ // Without eventName, all event rules for element will be stopped
+ // Without element, all event rules ever defined will be stopped
+ stopDelegating: function(element, eventName) {
+ if (element === undefined) {
+ // no element given, stop delegating everything
+ for (var id in cache)
+ Event.stopDelegating(id == '$document' ? document : id);
+ cache = { };
+ return true;
+ }
+ // get the passed rules object
+ if (Object.isString(arguments[2])) {
+ var rules = { };
+ rules[arguments[2]] = true;
+ } else if (arguments[2]) {
+ var rules = arguments[2];
+ } else {
+ var rules = false;
+ }
+ var el = $(element), ev = eventName, id = el.identify ? el.identify() : '$document';
+ // do we have such an id cached?
+ if (cache[id]) {
+ // do we have such an event cached
+ if (ev && cache[id][ev]) {
+ // check each rules set registered to this element for this event
+ for (var i = 0, len = cache[id][ev].length; i < len; i++) {
+ if (rules) {
+ // we have one or more rules to stop
+ for (var selector in rules)
+ delete cache[id][ev][i][selector];
+ // check if all rules are now stopped
+ }
+ if (!rules || $H(cache[id][ev][i]).any() == false) {
+ // stop observing if we have no rules for this event
+ el.stopObserving(ev, cache[id]['$observer']);
+ cache[id][ev][i] = 'r';
+ }
+ }
+ // remove all the entries that have just had their rules deleted
+ cache[id][ev] = cache[id][ev].without('r');
+ } else {
+ // remove all entries for this whole element
+ for (var evName in cache[id])
+ if (evName != '$observer')
+ el.stopObserving(evName, cache[id]['$observer']);
+ delete cache[id];
+ }
+ }
+ return el;
+ }
+ };
+})());
+
+// add our methods to elements and to the document
+Element.addMethods({delegate: Event.delegate, stopDelegating: Event.stopDelegating});
+document.delegate = Event.delegate.curry(document);
+document.stopDelegating = Event.stopDelegating.curry(document);
+Event.observe(window, 'unload', Event.stopDelegating);
View
54 public/stylesheets/scaffold.css
@@ -0,0 +1,54 @@
+body { background-color: #fff; color: #333; }
+
+body, p, ol, ul, td {
+ font-family: verdana, arial, helvetica, sans-serif;
+ font-size: 13px;
+ line-height: 18px;
+}
+
+pre {
+ background-color: #eee;
+ padding: 10px;
+ font-size: 11px;
+}
+
+a { color: #000; }
+a:visited { color: #666; }
+a:hover { color: #fff; background-color:#000; }
+
+.fieldWithErrors {
+ padding: 2px;
+ background-color: red;
+ display: table;
+}
+
+#errorExplanation {
+ width: 400px;
+ border: 2px solid red;
+ padding: 7px;
+ padding-bottom: 12px;
+ margin-bottom: 20px;
+ background-color: #f0f0f0;
+}
+
+#errorExplanation h2 {
+ text-align: left;
+ font-weight: bold;
+ padding: 5px 5px 5px 15px;
+ font-size: 12px;
+ margin: -7px;
+ background-color: #c00;
+ color: #fff;
+}
+
+#errorExplanation p {
+ color: #333;
+ margin-bottom: 0;
+ padding: 5px;
+}
+
+#errorExplanation ul li {
+ font-size: 12px;
+ list-style: square;
+}
+
View
7 test/fixtures/colors.yml
@@ -0,0 +1,7 @@
+# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
+
+one:
+ name: MyString
+
+two:
+ name: MyString
View
45 test/functional/colors_controller_test.rb
@@ -0,0 +1,45 @@
+require 'test_helper'
+
+class ColorsControllerTest < ActionController::TestCase
+ test "should get index" do
+ get :index
+ assert_response :success
+ assert_not_nil assigns(:colors)
+ end
+
+ test "should get new" do
+ get :new
+ assert_response :success
+ end
+
+ test "should create color" do
+ assert_difference('Color.count') do
+ post :create, :color => { }
+ end
+
+ assert_redirected_to color_path(assigns(:color))
+ end
+
+ test "should show color" do
+ get :show, :id => colors(:one).to_param
+ assert_response :success
+ end
+
+ test "should get edit" do
+ get :edit, :id => colors(:one).to_param
+ assert_response :success
+ end
+
+ test "should update color" do
+ put :update, :id => colors(:one).to_param, :color => { }
+ assert_redirected_to color_path(assigns(:color))
+ end
+
+ test "should destroy color" do
+ assert_difference('Color.count', -1) do
+ delete :destroy, :id => colors(:one).to_param
+ end
+
+ assert_redirected_to colors_path
+ end
+end
View
8 test/unit/color_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class ColorTest < ActiveSupport::TestCase
+ # Replace this with your real tests.
+ test "the truth" do
+ assert true
+ end
+end
View
4 test/unit/helpers/colors_helper_test.rb
@@ -0,0 +1,4 @@
+require 'test_helper'
+
+class ColorsHelperTest < ActionView::TestCase
+end
Please sign in to comment.
Something went wrong with that request. Please try again.