fix js bugs

This commit is contained in:
did 2011-03-20 11:21:07 +01:00
parent 630577658d
commit 1e5624ce06
7 changed files with 34 additions and 11 deletions

View File

@ -20,7 +20,8 @@ gem 'inherited_resources', '~> 1.1.2'
gem 'rmagick', '2.12.2'
gem 'locomotive_carrierwave', '0.5.0.1.beta3', :require => 'carrierwave'
gem 'custom_fields', '1.0.0.beta.6'
# gem 'custom_fields', '1.0.0.beta.7'
gem 'custom_fields', '1.0.0.beta.7', :path => '../gems/custom_fields'
gem 'fog', '0.3.7'
gem 'mimetype-fu'
gem 'actionmailer-with-request'

View File

@ -11,6 +11,14 @@ GIT
xpath (0.1.2)
nokogiri (~> 1.4)
PATH
remote: ../gems/custom_fields
specs:
custom_fields (1.0.0.beta.7)
activesupport (>= 3.0.4)
locomotive_carrierwave
mongoid (~> 2.0.0.rc.7)
GEM
remote: http://rubygems.org/
specs:
@ -77,10 +85,6 @@ GEM
cucumber-rails (0.3.2)
cucumber (>= 0.8.0)
culerity (0.2.15)
custom_fields (1.0.0.beta.6)
activesupport (>= 3.0.4)
locomotive_carrierwave
mongoid (~> 2.0.0.rc.7)
daemons (1.1.0)
database_cleaner (0.6.6)
delayed_job (2.1.4)
@ -261,7 +265,7 @@ DEPENDENCIES
capybara
cucumber (= 0.8.5)
cucumber-rails
custom_fields (= 1.0.0.beta.6)
custom_fields (= 1.0.0.beta.7)!
database_cleaner
delayed_job (= 2.1.4)
delayed_job_mongoid (= 1.0.2)

View File

@ -8,12 +8,23 @@ module Admin::ContentTypesHelper
@content_types = current_site.content_types.ordered.
limit(:contents => Locomotive.config.lastest_items_nb).
only(:name, :slug, :highlighted_field_name, :updated_at).to_a
# only(:name, :slug, :highlighted_field_name, :content_custom_fields_updated_at).to_a
if @content_type && @content_type.persisted? && @content_types.index(@content_type) >= MAX_DISPLAYED_CONTENTS
@content_types.delete(@content_type)
@content_types.insert(0, @content_type)
end
# # be sure, we've got the custom klass up-to-date, otherwise it will fail miserably
# @content_types.each do |content_type|
# # puts "content_type custom_fields !!! ? #{content_type.name} / #{content_type.content_klass.try(:built_at).inspect} / #{content_type.content_custom_fields_updated_at.try(:utc)}"
# if content_type.content_klass_out_of_date?
# puts "RELOADED #{content_type.name}"
# content_type.reload
# content_type.invalidate_content_klass
# end
# end
@content_types
end

View File

@ -24,7 +24,6 @@ class ContentType
## named scopes ##
scope :ordered, :order_by => :updated_at.desc
## indexes ##
index [[:site_id, Mongo::ASCENDING], [:slug, Mongo::ASCENDING]]

View File

@ -57,7 +57,7 @@ $(document).ready(function() {
content: $(link.attr('href')).parent().html(),
padding: 0,
onComplete: function() {
$('#fancybox-wrap .actions button[type=submit]').click(function(e) {
$('#fancybox-wrap .popup-actions button[type=submit]').click(function(e) {
$.each(attributes, function(index, name) {
var val = domBoxAttrVal(name).trim();
if (val != '') domFieldVal(domField, name, val);
@ -148,7 +148,7 @@ $(document).ready(function() {
field = $.extend({
behaviour_flag: function() { return options.is_template ? 'template' : 'added' },
new_record_flag: function() { return this.new_record == true && options.is_template == false ? 'new' : '' },
errors_flag: function() { return this.errors.length > 0 ? 'error' : '' },
errors_flag: function() { return Object.size(this.errors) > 0 ? 'error' : '' },
required_flag: function() { return this.required ? 'required' : ''; },
base_name: function() { return options.is_template ? '' : baseInputName + "[" + index + "]"; },
base_dom_id: function() { return options.is_template ? 'custom_field_template' : 'custom_field_' + index; },

View File

@ -108,7 +108,7 @@ var SetupCustomFieldCategoryEditor = function(target) {
category = $.extend({
behaviour_flag: function() { return options.is_template ? 'template' : 'added' },
new_record_flag: function() { return this.new_record == true && options.is_template == false ? 'new' : '' },
errors_flag: function() { return this.errors && this.errors.length > 0 ? 'error' : '' },
errors_flag: function() { return this.errors && Object.size(this.errors) > 0 ? 'error' : '' },
base_name: function() { return options.is_template ? '' : baseInputName + "[" + index + "]"; },
base_dom_id: function() { return options.is_template ? 'category_template' : 'category_' + index; },
if_existing_record: function() { return this.new_record == false }

View File

@ -14,3 +14,11 @@ function makeSlug(val, sep) { // code largely inspired by http://www.thewebsitet
return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
}
})();
Object.size = function(obj) {
var size = 0, key;
for (key in obj) {
if (obj.hasOwnProperty(key)) size++;
}
return size;
};