diff --git a/vendor/plugins/qi_cible_select/README.markdown b/vendor/plugins/qi_cible_select/README.markdown new file mode 100644 index 0000000..08d7b60 --- /dev/null +++ b/vendor/plugins/qi_cible_select/README.markdown @@ -0,0 +1 @@ +Copyright (c) 2011 Nicolas Bally \ No newline at end of file diff --git a/vendor/plugins/qi_cible_select/Rakefile b/vendor/plugins/qi_cible_select/Rakefile new file mode 100644 index 0000000..7092162 --- /dev/null +++ b/vendor/plugins/qi_cible_select/Rakefile @@ -0,0 +1,11 @@ +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 \ No newline at end of file diff --git a/vendor/plugins/qi_cible_select/init.rb b/vendor/plugins/qi_cible_select/init.rb new file mode 100644 index 0000000..27f50f4 --- /dev/null +++ b/vendor/plugins/qi_cible_select/init.rb @@ -0,0 +1,6 @@ +# -*- encoding : utf-8 -*- +if Object.const_defined?("Formtastic") + require 'qi_cible_select' + Formtastic::SemanticFormBuilder.send(:include, Formtastic::QiCibleSelect) +end + diff --git a/vendor/plugins/qi_cible_select/lib/qi_cible_select.rb b/vendor/plugins/qi_cible_select/lib/qi_cible_select.rb new file mode 100644 index 0000000..76734cd --- /dev/null +++ b/vendor/plugins/qi_cible_select/lib/qi_cible_select.rb @@ -0,0 +1,37 @@ +# -*- 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 \ No newline at end of file diff --git a/vendor/plugins/qi_cible_select/spec/spec_helper.rb b/vendor/plugins/qi_cible_select/spec/spec_helper.rb new file mode 100644 index 0000000..49302f2 --- /dev/null +++ b/vendor/plugins/qi_cible_select/spec/spec_helper.rb @@ -0,0 +1,7 @@ +# -*- 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 diff --git a/vendor/plugins/qi_cible_select/spec/to_slug_spec.rb b/vendor/plugins/qi_cible_select/spec/to_slug_spec.rb new file mode 100644 index 0000000..498e09b --- /dev/null +++ b/vendor/plugins/qi_cible_select/spec/to_slug_spec.rb @@ -0,0 +1,2 @@ +# -*- encoding : utf-8 -*- +require File.dirname(__FILE__) + '/spec_helper.rb'