Merge branch 'master' of github.com:diaspora/diaspora_rails

This commit is contained in:
maxwell 2010-07-01 09:03:04 -07:00
commit cb23766012
3 changed files with 144 additions and 133 deletions

View file

@ -1,7 +1,7 @@
= form_for Comment.new, :remote => true do |f|
%p
%label{:for => "comment_text"} Comment
= f.text_area :text, :rows => 2
%label{:for => "comment_text_on_#{post.id}"} Comment
= f.text_area :text, :rows => 2, :id => "comment_text_on_#{post.id}"
= f.hidden_field :post_id, :value => post.id
%p
= f.submit "Comment"

View file

@ -32,12 +32,6 @@ module Diaspora
begin
object = post.name.camelize.constantize.from_xml post.to_s
object.person = parse_owner_from_xml post.to_s #if object.is_a? Post
# if object.is_a? Comment
# object.post = parse_post_
# end
objects << object
rescue
puts "Not a real type: #{object.to_s}"
@ -50,6 +44,7 @@ module Diaspora
objects = parse_objects_from_xml(xml)
objects.each do |p|
#This line checks if the sender was in the database, among other things?
p.save if p.respond_to?(:person) && !(p.person.nil?) #WTF
#p.save if p.respond_to?(:person) && !(p.person == nil) #WTF
end

View file

@ -1,13 +1,13 @@
/*
* In-Field Label jQuery Plugin
/**
* @license In-Field Label jQuery Plugin
* http://fuelyourcoding.com/scripts/infield.html
*
* Copyright (c) 2009 Doug Neiner
* Copyright (c) 2009-2010 Doug Neiner
* Dual licensed under the MIT and GPL licenses.
* Uses the same license as jQuery, see:
* http://docs.jquery.com/License
*
* @version 0.1
* @version 0.1.2
*/
(function ($) {
@ -31,10 +31,10 @@
base.options = $.extend({}, $.InFieldLabels.defaultOptions, options);
// Check if the field is already filled in
if(base.$field.val() != ""){
if (base.$field.val() !== "") {
base.$label.hide();
base.showing = false;
};
}
base.$field.focus(function () {
base.fadeOnFocus();
@ -44,6 +44,10 @@
// Use of a namespace (.infieldlabel) allows us to
// unbind just this method later
base.hideOnChange(e);
}).bind('paste', function (e) {
// Since you can not paste an empty string we can assume
// that the fieldis not empty and the label can be cleared.
base.setOpacity(0.0);
}).change(function (e) {
base.checkForEmpty();
}).bind('onPropertyChange', function () {
@ -57,7 +61,7 @@
base.fadeOnFocus = function () {
if (base.showing) {
base.setOpacity(base.options.fadeOpacity);
};
}
};
base.setOpacity = function (opacity) {
@ -69,12 +73,12 @@
// set blur to true when passing from
// the blur event
base.checkForEmpty = function (blur) {
if(base.$field.val() == ""){
if (base.$field.val() === "") {
base.prepForShow();
base.setOpacity(blur ? 1.0 : base.options.fadeOpacity);
} else {
base.setOpacity(0.0);
};
}
};
base.prepForShow = function (e) {
@ -86,19 +90,21 @@
base.$field.bind('keydown.infieldlabel', function (e) {
base.hideOnChange(e);
});
};
}
};
base.hideOnChange = function (e) {
if (
(e.keyCode == 16) || // Skip Shift
(e.keyCode == 9) // Skip Tab
) return;
(e.keyCode === 16) || // Skip Shift
(e.keyCode === 9) // Skip Tab
) {
return;
}
if (base.showing) {
base.$label.hide();
base.showing = false;
};
}
// Remove keydown event to save on CPU processing
base.$field.unbind('keydown.infieldlabel');
@ -119,22 +125,32 @@
// Find input or textarea based on for= attribute
// The for attribute on the label must contain the ID
// of the input or textarea element
var for_attr = $(this).attr('for');
if( !for_attr ) return; // Nothing to attach, since the for field wasn't used
var for_attr = $(this).attr('for'), $field;
if (!for_attr) {
return; // Nothing to attach, since the for field wasn't used
}
// Find the referenced input or textarea element
var $field = $(
// This fucking for_attr thing is some seriously dumb shit.
//
// It must be dealt with
$field = $(
"input#" + for_attr + "[type='text']," +
"input#" + for_attr + "[type='search']," +
"input#" + for_attr + "[type='tel']," +
"input#" + for_attr + "[type='url']," +
"input#" + for_attr + "[type='email']," +
"input#" + for_attr + "[type='password']," +
"textarea#" + for_attr
);
if( $field.length == 0) return; // Again, nothing to attach
if ($field.length === 0) {
return; // Again, nothing to attach
}
// Only create object for input[text], input[password], or textarea
(new $.InFieldLabels(this, $field[0], options));
});
};
})(jQuery);
}(jQuery));