Merge branch 'master' of github.com:diaspora/diaspora_rails
This commit is contained in:
commit
cb23766012
3 changed files with 144 additions and 133 deletions
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,140 +1,156 @@
|
|||
/*
|
||||
* 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($){
|
||||
|
||||
$.InFieldLabels = function(label,field, options){
|
||||
// To avoid scope issues, use 'base' instead of 'this'
|
||||
// to reference this class from internal events and functions.
|
||||
var base = this;
|
||||
|
||||
// Access to jQuery and DOM versions of each element
|
||||
base.$label = $(label);
|
||||
base.label = label;
|
||||
(function ($) {
|
||||
|
||||
base.$field = $(field);
|
||||
base.field = field;
|
||||
|
||||
base.$label.data("InFieldLabels", base);
|
||||
base.showing = true;
|
||||
|
||||
base.init = function(){
|
||||
// Merge supplied options with default options
|
||||
base.options = $.extend({},$.InFieldLabels.defaultOptions, options);
|
||||
$.InFieldLabels = function (label, field, options) {
|
||||
// To avoid scope issues, use 'base' instead of 'this'
|
||||
// to reference this class from internal events and functions.
|
||||
var base = this;
|
||||
|
||||
// Access to jQuery and DOM versions of each element
|
||||
base.$label = $(label);
|
||||
base.label = label;
|
||||
|
||||
// Check if the field is already filled in
|
||||
if(base.$field.val() != ""){
|
||||
base.$label.hide();
|
||||
base.showing = false;
|
||||
};
|
||||
|
||||
base.$field.focus(function(){
|
||||
base.fadeOnFocus();
|
||||
}).blur(function(){
|
||||
base.checkForEmpty(true);
|
||||
}).bind('keydown.infieldlabel',function(e){
|
||||
// Use of a namespace (.infieldlabel) allows us to
|
||||
// unbind just this method later
|
||||
base.hideOnChange(e);
|
||||
}).change(function(e){
|
||||
base.checkForEmpty();
|
||||
}).bind('onPropertyChange', function(){
|
||||
base.checkForEmpty();
|
||||
});
|
||||
};
|
||||
base.$field = $(field);
|
||||
base.field = field;
|
||||
|
||||
// If the label is currently showing
|
||||
// then fade it down to the amount
|
||||
// specified in the settings
|
||||
base.fadeOnFocus = function(){
|
||||
if(base.showing){
|
||||
base.setOpacity(base.options.fadeOpacity);
|
||||
};
|
||||
};
|
||||
|
||||
base.setOpacity = function(opacity){
|
||||
base.$label.stop().animate({ opacity: opacity }, base.options.fadeDuration);
|
||||
base.showing = (opacity > 0.0);
|
||||
};
|
||||
|
||||
// Checks for empty as a fail safe
|
||||
// set blur to true when passing from
|
||||
// the blur event
|
||||
base.checkForEmpty = function(blur){
|
||||
if(base.$field.val() == ""){
|
||||
base.prepForShow();
|
||||
base.setOpacity( blur ? 1.0 : base.options.fadeOpacity );
|
||||
} else {
|
||||
base.setOpacity(0.0);
|
||||
};
|
||||
};
|
||||
|
||||
base.prepForShow = function(e){
|
||||
if(!base.showing) {
|
||||
// Prepare for a animate in...
|
||||
base.$label.css({opacity: 0.0}).show();
|
||||
|
||||
// Reattach the keydown event
|
||||
base.$field.bind('keydown.infieldlabel',function(e){
|
||||
base.hideOnChange(e);
|
||||
});
|
||||
};
|
||||
};
|
||||
base.$label.data("InFieldLabels", base);
|
||||
base.showing = true;
|
||||
|
||||
base.hideOnChange = function(e){
|
||||
if(
|
||||
(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');
|
||||
};
|
||||
|
||||
// Run the initialization method
|
||||
base.init();
|
||||
base.init = function () {
|
||||
// Merge supplied options with default options
|
||||
base.options = $.extend({}, $.InFieldLabels.defaultOptions, options);
|
||||
|
||||
// Check if the field is already filled in
|
||||
if (base.$field.val() !== "") {
|
||||
base.$label.hide();
|
||||
base.showing = false;
|
||||
}
|
||||
|
||||
base.$field.focus(function () {
|
||||
base.fadeOnFocus();
|
||||
}).blur(function () {
|
||||
base.checkForEmpty(true);
|
||||
}).bind('keydown.infieldlabel', function (e) {
|
||||
// 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 () {
|
||||
base.checkForEmpty();
|
||||
});
|
||||
};
|
||||
|
||||
$.InFieldLabels.defaultOptions = {
|
||||
fadeOpacity: 0.5, // Once a field has focus, how transparent should the label be
|
||||
fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity
|
||||
};
|
||||
|
||||
|
||||
$.fn.inFieldLabels = function(options){
|
||||
return this.each(function(){
|
||||
// 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
|
||||
|
||||
|
||||
// Find the referenced input or textarea element
|
||||
var $field = $(
|
||||
"input#" + for_attr + "[type='text']," +
|
||||
"input#" + for_attr + "[type='password']," +
|
||||
"textarea#" + for_attr
|
||||
);
|
||||
|
||||
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));
|
||||
// If the label is currently showing
|
||||
// then fade it down to the amount
|
||||
// specified in the settings
|
||||
base.fadeOnFocus = function () {
|
||||
if (base.showing) {
|
||||
base.setOpacity(base.options.fadeOpacity);
|
||||
}
|
||||
};
|
||||
|
||||
base.setOpacity = function (opacity) {
|
||||
base.$label.stop().animate({ opacity: opacity }, base.options.fadeDuration);
|
||||
base.showing = (opacity > 0.0);
|
||||
};
|
||||
|
||||
// Checks for empty as a fail safe
|
||||
// set blur to true when passing from
|
||||
// the blur event
|
||||
base.checkForEmpty = function (blur) {
|
||||
if (base.$field.val() === "") {
|
||||
base.prepForShow();
|
||||
base.setOpacity(blur ? 1.0 : base.options.fadeOpacity);
|
||||
} else {
|
||||
base.setOpacity(0.0);
|
||||
}
|
||||
};
|
||||
|
||||
base.prepForShow = function (e) {
|
||||
if (!base.showing) {
|
||||
// Prepare for a animate in...
|
||||
base.$label.css({opacity: 0.0}).show();
|
||||
|
||||
// Reattach the keydown event
|
||||
base.$field.bind('keydown.infieldlabel', function (e) {
|
||||
base.hideOnChange(e);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
base.hideOnChange = function (e) {
|
||||
if (
|
||||
(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');
|
||||
};
|
||||
|
||||
// Run the initialization method
|
||||
base.init();
|
||||
};
|
||||
|
||||
$.InFieldLabels.defaultOptions = {
|
||||
fadeOpacity: 0.5, // Once a field has focus, how transparent should the label be
|
||||
fadeDuration: 300 // How long should it take to animate from 1.0 opacity to the fadeOpacity
|
||||
};
|
||||
|
||||
|
||||
$.fn.inFieldLabels = function (options) {
|
||||
return this.each(function () {
|
||||
// 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'), $field;
|
||||
if (!for_attr) {
|
||||
return; // Nothing to attach, since the for field wasn't used
|
||||
}
|
||||
|
||||
// Find the referenced input or textarea element
|
||||
// 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
|
||||
}
|
||||
|
||||
// Only create object for input[text], input[password], or textarea
|
||||
(new $.InFieldLabels(this, $field[0], options));
|
||||
});
|
||||
};
|
||||
|
||||
}(jQuery));
|
||||
|
|
|
|||
Loading…
Reference in a new issue