Skip to content
Browse files

use best_in_place's new :type => :date

  • Loading branch information...
1 parent 27d92dc commit 6fad3de3ec4168f8375ad480fdf4fcd05db6b641 @taavo taavo committed Jan 3, 2012
View
8 Gemfile.lock
@@ -33,7 +33,7 @@ GEM
arel (2.2.1)
bcrypt-ruby (3.0.1)
bcrypt-ruby (3.0.1-x86-mingw32)
- best_in_place (1.0.3)
+ best_in_place (1.0.4)
jquery-rails
rails (~> 3.1.0)
builder (3.0.0)
@@ -120,7 +120,7 @@ GEM
jquery-rails (1.0.19)
railties (~> 3.0)
thor (~> 0.14)
- json (1.6.3)
+ json (1.6.4)
json_pure (1.6.2)
launchy (2.0.5)
addressable (~> 2.2.6)
@@ -137,7 +137,7 @@ GEM
pg (0.11.0)
pg (0.11.0-x86-mingw32)
polyglot (0.3.3)
- rack (1.3.5)
+ rack (1.3.6)
rack-cache (1.1)
rack (>= 0.4)
rack-mount (0.8.3)
@@ -164,7 +164,7 @@ GEM
rake (0.9.2.2)
rb-appscript (0.6.1)
rb-fsevent (0.4.3.1)
- rdoc (3.11)
+ rdoc (3.12)
json (~> 1.4)
rspec (2.7.0)
rspec-core (~> 2.7.0)
View
4 app/assets/javascripts/application.js
@@ -12,6 +12,8 @@
//= require best_in_place
//= require_tree .
+$.datepicker.setDefaults({dateFormat: 'yy-mm-dd'});
+
function show_dialog(id, title, body, options) {
var selector = '#' + id;
@@ -105,6 +107,6 @@ function recalculateTotalHours() {
}
$(function(){
- $(".datepicker").datepicker({dateFormat: "yy-mm-dd"});
+ $(".datepicker").datepicker();
$(".best_in_place").best_in_place();
});
View
36 app/assets/javascripts/best_in_place.custom.js
@@ -1,36 +0,0 @@
-// copypasta from the default, modified to do initialize and show the datepicker if we have inner_class 'datepicker'
-BestInPlaceEditor.forms.input.activateForm = function() {
- var that = this,
- output = '<form class="form_in_place" action="javascript:void(0)" style="display:inline;">';
- output += '<input type="text" name="'+ this.attributeName + '" value="' + this.sanitizeValue(this.display_value) + '"';
- if (this.inner_class != null) {
- output += ' class="' + this.inner_class + '"';
- }
- output += '></form>'
- this.element.html(output);
- this.setHtmlAttributes();
-
- if(this.inner_class == 'datepicker') {
- this.element.find('.datepicker')
- .datepicker({
- dateFormat: 'yy-mm-dd',
- onClose: function() {
- that.update();
- }
- })
- .datepicker('show');
- }
-
- this.element.find('input')[0].select();
- this.element.find("form").bind('submit', {editor: this}, BestInPlaceEditor.forms.input.submitHandler);
- this.element.find("input").bind('blur', {editor: this}, BestInPlaceEditor.forms.input.inputBlurHandler);
- this.element.find("input").bind('keyup', {editor: this}, BestInPlaceEditor.forms.input.keyupHandler);
-};
-
-// copypasta from the default, modified to do nothing if we have a datepicker
-BestInPlaceEditor.forms.input.inputBlurHandler = function(event) {
- if(!$(this).hasClass('hasDatepicker')) {
- event.data.editor.update();
- }
-};
-
View
2 app/views/time_entries/_time_entry.html.haml
@@ -20,7 +20,7 @@
%td= in_hour_log? ? time_entry.public_description : time_entry.description
- else
- %td= best_in_place time_entry, in_hour_log? ? :public_date : :date, :inner_class => 'datepicker'
+ %td= best_in_place time_entry, in_hour_log? ? :public_date : :date, :type => :date
%td.company= best_in_place time_entry, in_hour_log? ? :public_company_id : :company_id, :type => :select, :collection => Company.all.map {|c| [c.id, c.name] }
- if in_hour_log?
%td= best_in_place time_entry, :public_user_id, :type => :select, :collection => User.active.employees.map { |u| [u.id, u.name] }

0 comments on commit 6fad3de

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