Class: ActionView::Helpers::FormBuilder
- Inherits:
-
Object
- Object
- ActionView::Helpers::FormBuilder
- Includes:
- ActionView::Helpers
- Defined in:
- app/helpers/gluttonberg/admin.rb,
app/helpers/gluttonberg/asset_library.rb
Direct Known Subclasses
Instance Method Summary collapse
- #asset_browser(field_id, opts = {}) ⇒ Object
- #asset_tag(asset, thumbnail_type = nil) ⇒ Object
- #clear_asset(field_id, opts = {}) ⇒ Object
- #datetime_field(field_name, date_field_html_opts = {}, time_field_html_opts = {}) ⇒ Object
- #publisable_dropdown ⇒ Object
Instance Method Details
#asset_browser(field_id, opts = {}) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 |
# File 'app/helpers/gluttonberg/asset_library.rb', line 192 def asset_browser( field_id , opts = {} ) asset_id = self.object.send(field_id.to_s) filter = opts[:filter].blank? ? "all" : opts[:filter] opts[:id] = "#{field_id}_#{asset_id}" if opts[:id].blank? html_id = opts[:id] # Find the asset so we can get the name asset_info = "" asset_name = "Nothing selected" unless asset_id.blank? asset = Gluttonberg::Asset.find(:first , :conditions => {:id => asset_id}) asset_name = asset.name if asset if asset if asset.category && asset.category.to_s.downcase == "image" asset_info = asset_tag(asset , :small_thumb).html_safe end else asset_name = "Asset missing!" end end asset_name = content_tag(:h5, asset_name) if asset_name #hack for url admin_asset_browser_url = "/admin/browser" thumbnail_contents = "" thumbnail_contents << asset_info = "" << asset_name unless asset_name.blank? << hidden_field_tag("filter_#{html_id}" , value=filter ) << self.hidden_field(field_id , { :id => html_id , :class => "choose_asset_hidden_field" } ) thumbnail_p = "" thumbnail_p << link_to("Select", admin_asset_browser_url + "?filter=#{filter}" , { :class =>"btn button choose_button #{opts[:button_class]}" , :rel => html_id, :style => "margin-right:5px;" }) if opts[:remove_button] != false thumbnail_p << self.clear_asset( field_id , opts ) end << content_tag(:p, thumbnail_p.html_safe) thumbnail_contents << content_tag(:div, .html_safe, :class => "caption") thumbnail = content_tag(:div, thumbnail_contents.html_safe, :class => "thumbnail asset_selector_wrapper") li_content = content_tag(:li, thumbnail, :class => "span4") content_tag(:ul , li_content , :id => "title_thumb_#{opts[:id]}", :class => "thumbnails") end |
#asset_tag(asset, thumbnail_type = nil) ⇒ Object
241 242 243 244 245 246 |
# File 'app/helpers/gluttonberg/asset_library.rb', line 241 def asset_tag(asset , thumbnail_type = nil) unless asset.blank? path = thumbnail_type.blank? ? asset.url : asset.url_for(thumbnail_type) tag(:img , "", :class => asset.name , :alt => asset.name , :src => path) end end |
#clear_asset(field_id, opts = {}) ⇒ Object
248 249 250 251 252 253 254 255 |
# File 'app/helpers/gluttonberg/asset_library.rb', line 248 def clear_asset( field_id , opts = {} ) asset_id = self.object.send(field_id.to_s) opts[:id] = "#{field_id}_#{asset_id}" if opts[:id].blank? html_id = opts[:id] = opts[:button_text].blank? ? "Browse" : opts[:button_text] opts[:button_class] = "" if opts[:button_class].blank? link_to("Remove", "Javascript:;" , { :class => "btn btn-danger button remove #{opts[:button_class]}" , :onclick => "$('##{html_id}').val('');$('#title_thumb_#{opts[:id]} h5').html('');$('#title_thumb_#{opts[:id]} img').remove();" }) end |
#datetime_field(field_name, date_field_html_opts = {}, time_field_html_opts = {}) ⇒ Object
410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'app/helpers/gluttonberg/admin.rb', line 410 def datetime_field(field_name,date_field_html_opts = {},time_field_html_opts = {}) date_field_html_opts["data-datepicker"] = "bsdatepicker" date_field_html_opts[:onblur] = "checkDateFormat(this,'.#{field_name}_error');combine_datetime('#{field_name}');" if date_field_html_opts[:class].blank? date_field_html_opts[:class] = "small datefield" else date_field_html_opts[:class] += " small datefield" end if time_field_html_opts[:class].blank? time_field_html_opts[:class] = "timefield" else time_field_html_opts[:class] += " timefield" end time_field_html_opts[:onblur] = "checkTimeFormat(this,'.#{field_name}_error');combine_datetime('#{field_name}')" html = "" date = "" time = "" unless self.object.send(field_name).blank? date = self.object.send(field_name).strftime("%d/%m/%Y") time = self.object.send(field_name).strftime("%I:%M %p") end html += text_field_tag("#{field_name}_date" , date , date_field_html_opts ) html += "<span class='date'>DD/MM/YYYY</span>" html += " " html += text_field_tag("#{field_name}_time" , time , time_field_html_opts ) html += "<span class='date time'>HH:MM AM/PM</span>" html += self.hidden_field("#{field_name}" , :class => "#{field_name}") html += "<label class='error #{field_name}_error'></label>" html += "<div class='clear'></div>" html += "<script type='text/javascript'>$(document).ready(function() { combine_datetime('#{field_name}'); }); </script>" html.html_safe end |
#publisable_dropdown ⇒ Object
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
# File 'app/helpers/gluttonberg/admin.rb', line 390 def publisable_dropdown object = self.object val = object.state if val == "not_ready" val = "ready" else val = "published" end @@workflow_states = [ ['Published' , "published" ] ,[ 'Draft' , 'ready' ] , [ "Archived" , 'archived' ] ] object.published_at = Time.zone.now if object.published_at.blank? html = "<fieldset id='publish_meta'><div class='publishing_block' > " html += select( :state, (@@workflow_states , val), {} , :class => "publishing_state" ) # html += content_tag(:p , self.datetime_select("published_at" , {:prompt => {:day => 'Day', :month => 'Month', :year => 'Year'} , :order => [:day , :month , :year] }, :class => "span2") , :class => "published_at" ) # html += datetime_field("published_at") html += "</div></fieldset>" html.html_safe end |