app/helpers/kryptonite/kryptonite_helper.rb in kryptonite-0.0.10 vs app/helpers/kryptonite/kryptonite_helper.rb in kryptonite-0.1.0

- old
+ new

@@ -38,37 +38,70 @@ end def kryptonite_get_access_level_array [["Administrator", $KRYPTONITE_USER_ACCESS_LEVEL_ADMIN], ["User", $KRYPTONITE_USER_ACCESS_LEVEL_USER], ["Frontend User", $KRYPTONITE_USER_ACCESS_LEVEL_FE_USER]] end + + def kryptonite_get_language_array + [['English', 'en'], ['Deutsch', 'de']] + end def kryptonite_table_cell_link contents, link, options = {} + + contents = strip_tags(contents.to_s) if options.key? :kryptonite_truncate contents = truncate(contents, :length => options[:kryptonite_truncate], :omission => "...") end link_to "#{contents}".html_safe, link, options end def kryptonite_table_cell_no_link contents, options = {} + contents = strip_tags(contents.to_s) + if options.key? :kryptonite_truncate contents = truncate(contents, :length => options[:kryptonite_truncate], :omission => "...") end "<div class='noLink'>#{contents}</div>".html_safe end def kryptonite_show_icon icon_name - "<div class='icon'><img src='/kryptonite/images/icons/#{icon_name}.png' alt='' /></div>".html_safe + "<div class='icon'><img src='/assets/kryptonite/icons/#{icon_name}.png' alt='' /></div>".html_safe end def kryptonite_show_row_icon icon_name - "<div class='iconRow'><img src='/kryptonite/images/icons/#{icon_name}.png' alt='' /></div>".html_safe + "<div class='iconRow'><img src='/assets/kryptonite/icons/#{icon_name}.png' alt='' /></div>".html_safe end # Styled form tag helpers + + def kryptonite_assets_field form, obj, attribute, options = {} + content_key = eval("obj.#{attribute}") + content_key = "#{obj.class.name.demodulize.downcase}_#{attribute}_#{rand(36**8).to_s(36)}" if !content_key + path = upload_kryptonite_asset_path(content_key) + content = "<p><label>Dateiupload</label></p><p><div id=\"uploader\"></div></p>" + content += javascript_tag("var uploader = new qq.FileUploader({ + element: $('#uploader')[0], + action: \"#{path}\", + multiple: #{options[:multiple] ? options[:multiple] : "false"}, + allowedExtensions: [#{options[:extenstions] ? options[:extenstions] : "'jpg', 'jpeg', 'png'"}], + onSubmit: function(id, fileName) {uploader.setParams({ffmultiple: #{options[:multiple] ? options[:multiple] : "false"}, ffsize: '#{options[:size] ? options[:size] : "200x200#"}', authenticity_token: $('meta[name=\"csrf-token\"]').attr('content')}); }, + onComplete: function(id, fileName, responseJSON) { } + });") + content += "<ul id=\"assets\">" + Asset.find_all_by_content_key(content_key).each do |asset| + content += "<li>" + content += link_to(asset.file_file_name, asset.file.url(:normal), :target=>"_blank") + content += link_to(kryptonite_show_row_icon("delete"), kryptonite_asset_path(asset), :method => :delete, :remote=>true, :onclick=>"$(this).parent().remove()", :class=>"delete") if @session_user.is_user? || @session_user.is_admin? + content += "</li>" + end + content += "</ul>" + content += hidden_field_tag("#{obj.class.name.demodulize.downcase}[#{attribute.to_s}]", content_key).html_safe + content.html_safe + end def kryptonite_text_field form, obj, attribute, options = {} kryptonite_form_tag_wrapper(form.text_field(attribute, strip_kryptonite_options(options_hash_with_merged_classes(options, 'kryptoniteTextField'))), form, obj, attribute, options).html_safe end \ No newline at end of file