qi_select mis à jour
This commit is contained in:
parent
937f0389f4
commit
9cf3f9c466
72
config/initializers/formtastic.rb
Normal file
72
config/initializers/formtastic.rb
Normal file
@ -0,0 +1,72 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
module Formtastic
|
||||
module Inputs
|
||||
|
||||
class QiCibleSelectInput
|
||||
include Base
|
||||
|
||||
def to_html
|
||||
r = rand(1000000000000000000000000000)
|
||||
|
||||
|
||||
input_wrapping do
|
||||
label_html +
|
||||
template.content_tag(:fieldset, template.text_field_tag("cible_name", (object.cible ? object.cible.cible_name : "aucuns élément séléctionné"), :id =>"name_#{r}" ) +
|
||||
self.manager_select_cible_link(method, options, r) + builder.hidden_field(method.to_s+"_id", input_html_options.merge!(:id => "input_id_"+r.to_s)) +
|
||||
builder.hidden_field(method.to_s+"_type", input_html_options.merge!(:id => "input_type_"+r.to_s)) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def manager_select_cible_link(method, options, r)
|
||||
|
||||
template.content_tag(:a, "Modifier ce lien", :href => "#", :onclick => "select_cible_from_manager('"+r.to_s+"');return false;")
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
class QiImageSelectInput
|
||||
include Base
|
||||
|
||||
def to_html
|
||||
r = rand(1000000000000000000000000000)
|
||||
|
||||
|
||||
input_wrapping do
|
||||
label_html +
|
||||
template.content_tag(:fieldset, manager_select_link(method, options, r) + template.tag(:br) + image_preview(method, options, r) + builder.hidden_field(method.to_s, input_html_options.merge!(:id => "input_"+r.to_s)) )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
def manager_select_link(method, options, r)
|
||||
template.content_tag(:a, "Modifier cette image", :href => "#", :onclick => "select_image_from_manager('"+r.to_s+"');return false;")
|
||||
end
|
||||
|
||||
def image_preview(method, options,r)
|
||||
if object.send("#{method}?") and ImageFile.exists?(object.send("#{method}"))
|
||||
template.content_tag(:span, template.image_tag(object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s), :class => "preview ")
|
||||
else
|
||||
template.content_tag(:span, template.image_tag("qi/default_image.png", :id => "img_"+r.to_s), :class => "preview ")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
end
|
@ -1 +0,0 @@
|
||||
Copyright (c) 2011 Nicolas Bally
|
11
vendor/plugins/qi_cible_select/Rakefile
vendored
11
vendor/plugins/qi_cible_select/Rakefile
vendored
@ -1,11 +0,0 @@
|
||||
require 'rake'
|
||||
require 'spec/rake/spectask'
|
||||
|
||||
desc 'Default: run all specs.'
|
||||
task :default => :spec
|
||||
|
||||
desc 'Run all specs'
|
||||
Spec::Rake::SpecTask.new(:spec) do |t|
|
||||
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
6
vendor/plugins/qi_cible_select/init.rb
vendored
6
vendor/plugins/qi_cible_select/init.rb
vendored
@ -1,6 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
if Object.const_defined?("Formtastic")
|
||||
require 'qi_cible_select'
|
||||
Formtastic::SemanticFormBuilder.send(:include, Formtastic::QiCibleSelect)
|
||||
end
|
||||
|
@ -1,37 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
|
||||
module Formtastic
|
||||
module QiCibleSelect
|
||||
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def qi_cible_select_input(method, options)
|
||||
|
||||
r = rand(1000000000000000000000000000)
|
||||
|
||||
html_options = options.delete(:input_html) || {}
|
||||
|
||||
self.label(method, options_for_label(options)) +
|
||||
template.content_tag(:fieldset, template.text_field_tag("cible_name", (object.cible ? object.cible.cible_name : "aucuns élément séléctionné"), :id =>"name_#{r}" )+ self.manager_select_cible_link(method, options, r) + self.send(:hidden_field, method.to_s+"_id", html_options.merge!(:id => "input_id_"+r.to_s))+ self.send(:hidden_field, method.to_s+"_type", html_options.merge!(:id => "input_type_"+r.to_s)))
|
||||
end
|
||||
|
||||
|
||||
def manager_select_cible_link(method, options, r)
|
||||
|
||||
template.content_tag(:a, "Modifier ce lien", :href => "#", :onclick => "select_cible_from_manager('"+r.to_s+"');return false;")
|
||||
|
||||
end
|
||||
|
||||
def image_preview(method, options,r)
|
||||
|
||||
if object.send("#{method}?")
|
||||
template.content_tag(:span, template.image_tag(object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s), :class => "preview ")
|
||||
else
|
||||
template.content_tag(:span, template.image_tag("", :id => "img_"+r.to_s), :class => "preview ")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
begin
|
||||
require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
|
||||
rescue LoadError
|
||||
puts "You need to install rspec in your base app"
|
||||
exit
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require File.dirname(__FILE__) + '/spec_helper.rb'
|
@ -1 +0,0 @@
|
||||
Copyright (c) 2011 Nicolas Bally
|
11
vendor/plugins/qi_select_image/Rakefile
vendored
11
vendor/plugins/qi_select_image/Rakefile
vendored
@ -1,11 +0,0 @@
|
||||
require 'rake'
|
||||
require 'spec/rake/spectask'
|
||||
|
||||
desc 'Default: run all specs.'
|
||||
task :default => :spec
|
||||
|
||||
desc 'Run all specs'
|
||||
Spec::Rake::SpecTask.new(:spec) do |t|
|
||||
t.spec_opts = ['--colour --format progress --loadby mtime --reverse']
|
||||
t.spec_files = FileList['spec/**/*_spec.rb']
|
||||
end
|
6
vendor/plugins/qi_select_image/init.rb
vendored
6
vendor/plugins/qi_select_image/init.rb
vendored
@ -1,6 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
if Object.const_defined?("Formtastic")
|
||||
require 'qi_image_select'
|
||||
Formtastic::SemanticFormBuilder.send(:include, Formtastic::QiImageSelect)
|
||||
end
|
||||
|
@ -1,54 +0,0 @@
|
||||
|
||||
|
||||
module Formtastic
|
||||
module QiImageSelect
|
||||
|
||||
def self.included(base)
|
||||
base.send(:extend, ClassMethods)
|
||||
end
|
||||
|
||||
module ClassMethods
|
||||
|
||||
@@image_preview_sizes = [ :preview, :thumbnail, :thumb, :small ]
|
||||
|
||||
def image_preview_sizes
|
||||
@@image_preview_sizes
|
||||
end
|
||||
|
||||
def image_preview_sizes=(value)
|
||||
@@image_preview_sizes = value
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def qi_image_select_input(method, options)
|
||||
|
||||
r = rand(1000000000000000000000000000)
|
||||
|
||||
html_options = options.delete(:input_html) || {}
|
||||
|
||||
self.label(method, options_for_label(options)) +
|
||||
template.content_tag(:fieldset, self.manager_select_link(method, options, r) + template.tag(:br) + self.image_preview(method, options, r) + self.send(:hidden_field, method, html_options.merge!(:id => "input_"+r.to_s)))
|
||||
end
|
||||
|
||||
|
||||
def manager_select_link(method, options, r)
|
||||
|
||||
template.content_tag(:a, "Modifier cette image", :href => "#", :onclick => "select_image_from_manager('"+r.to_s+"');return false;")
|
||||
|
||||
end
|
||||
|
||||
def image_preview(method, options,r)
|
||||
puts "#{method}"
|
||||
if object.send("#{method}?") and ImageFile.exists?(object.send("#{method}"))
|
||||
template.content_tag(:span, template.image_tag(object.image_file.file.large.medium.small.thumb.url, :id => "img_"+r.to_s), :class => "preview ")
|
||||
else
|
||||
template.content_tag(:span, template.image_tag("", :id => "img_"+r.to_s), :class => "preview ")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
@ -1,7 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
begin
|
||||
require File.dirname(__FILE__) + '/../../../../spec/spec_helper'
|
||||
rescue LoadError
|
||||
puts "You need to install rspec in your base app"
|
||||
exit
|
||||
end
|
@ -1,2 +0,0 @@
|
||||
# -*- encoding : utf-8 -*-
|
||||
require File.dirname(__FILE__) + '/spec_helper.rb'
|
Loading…
x
Reference in New Issue
Block a user