Module BoxesHelper
In: app/helpers/boxes_helper.rb

Methods

Classes and Modules

Module BoxesHelper::DontMoveBlocks

Public Instance methods

[Source]

     # File app/helpers/boxes_helper.rb, line 138
138:   def block_edit_buttons(block)
139:     buttons = []
140:     nowhere = 'javascript: return false;'
141: 
142:     if block.first?
143:       buttons << icon_button('up-disabled', _("Can't move up anymore."), nowhere)
144:     else
145:       buttons << icon_button('up', _('Move block up'), { :action => 'move_block_up', :id => block.id }, { :method => 'post' })
146:     end
147: 
148:     if block.last?
149:       buttons << icon_button('down-disabled', _("Can't move down anymore."), nowhere)
150:     else
151:       buttons << icon_button(:down, _('Move block down'), { :action => 'move_block_down' ,:id => block.id }, { :method => 'post'})
152:     end
153: 
154:     holder = block.owner
155:     # move to opposite side
156:     # FIXME too much hardcoded stuff
157:     if holder.layout_template == 'default'
158:       if block.box.position == 2 # area 2, left side => move to right side
159:         buttons << icon_button('right', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + holder.boxes[2].id.to_s, :id => block.id }, :method => 'post' )
160:       elsif block.box.position == 3 # area 3, right side => move to left side
161:         buttons << icon_button('left', _('Move to the opposite side'), { :action => 'move_block', :target => 'end-of-box-' + holder.boxes[1].id.to_s, :id => block.id }, :method => 'post' )
162:       end
163:     end
164: 
165:     if block.editable?
166:       buttons << lightbox_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id })
167:     end
168: 
169:     if !block.main?
170:       buttons << icon_button(:delete, _('Remove block'), { :action => 'remove', :id => block.id }, { :method => 'post'})
171:     end
172: 
173:     if block.respond_to?(:help)
174:       buttons << thickbox_inline_popup_icon(:help, _('Help on this block'), "help-on-box-#{block.id}") << content_tag('div', content_tag('h2', _('Help')) + content_tag('div', block.help, :style => 'margin-bottom: 1em;') + thickbox_close_button(_('Close')), :style => 'display: none;', :id => "help-on-box-#{block.id}")
175:     end
176: 
177:     content_tag('div', buttons.join("\n") + tag('br', :style => 'clear: left'), :class => 'button-bar')
178:   end

makes the given block draggable so it can be moved away.

[Source]

     # File app/helpers/boxes_helper.rb, line 131
131:   def block_handle(block)
132:     # FIXME hardcoded
133:     return '' if block.box.position == 1
134: 
135:     draggable_element("block-#{block.id}", :revert => true)
136:   end

generates a place where you can drop a block and get the block moved to there.

If block is not nil, then it means "place the dropped block before this one.". Otherwise, it means "place the dropped block at the end of the list"

box is always needed

[Source]

     # File app/helpers/boxes_helper.rb, line 116
116:   def block_target(box, block = nil)
117:     # FIXME hardcoded
118:     return '' if box.position == 1
119: 
120:     id =
121:       if block.nil?
122:         "end-of-box-#{box.id}"
123:       else
124:         "before-block-#{block.id}"
125:       end
126: 
127:     content_tag('div', '&nbsp;', :id => id, :class => 'block-target' ) + drop_receiving_element(id, :url => { :action => 'move_block', :target => id }, :accept => 'block', :hoverclass => 'block-target-hover')
128:   end

[Source]

   # File app/helpers/boxes_helper.rb, line 3
3:   def box_decorator
4:     @box_decorator || DontMoveBlocks
5:   end

[Source]

     # File app/helpers/boxes_helper.rb, line 180
180:   def current_blocks
181:     @controller.boxes_holder.boxes.map(&:blocks).flatten
182:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 53
53:   def display_block(block, main_content = nil)
54:     content = block.main? ? main_content : block.content
55:     result = extract_block_content(content)
56:     footer_content = extract_block_content(block.footer)
57:     unless footer_content.blank?
58:       footer_content = content_tag('div', footer_content, :class => 'block-footer-content' )
59:     end
60: 
61:     options = {
62:       :class => classes = ['block', block.css_class_name ].uniq.join(' '),
63:       :id => "block-#{block.id}"
64:     }
65:     if ( block.respond_to? 'help' )
66:       options[:help] = block.help
67:     end
68: 
69:     box_decorator.block_target(block.box, block) +
70:     content_tag('div', result + footer_content + box_decorator.block_edit_buttons(block),
71:                 options) +
72:     box_decorator.block_handle(block)
73:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 39
39:   def display_box(box, main_content)
40:     content_tag('div', content_tag('div', display_box_content(box, main_content), :class => 'blocks'), :class => "box box-#{box.position}", :id => "box-#{box.id}" )
41:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 49
49:   def display_box_content(box, main_content)
50:     box.blocks.map { |item| display_block(item, main_content) }.join("\n") + box_decorator.block_target(box)
51:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 21
21:   def display_boxes(holder, main_content)
22:     boxes = holder.boxes.first(holder.boxes_limit)
23:     content = boxes.reverse.map { |item| display_box(item, main_content) }.join("\n")
24:     content = main_content if (content.blank?)
25: 
26:     maybe_display_custom_element(holder, :custom_header, :id => 'profile-header') +
27:     content_tag('div', content, :class => 'boxes', :id => 'boxes' ) +
28:     maybe_display_custom_element(holder, :custom_footer, :id => 'profile-footer')
29:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 15
15:   def display_boxes_editor(holder)
16:     with_box_decorator self do
17:       content_tag('div', display_boxes(holder, '&lt;' + _('Main content') + '&gt;'), :id => 'box-organizer')
18:     end
19:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 43
43:   def display_updated_box(box)
44:     with_box_decorator self do
45:       display_box_content(box, '&lt;' + _('Main content') + '&gt;')
46:     end
47:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 75
75:   def extract_block_content(content)
76:     case content
77:     when Hash
78:       content_tag('iframe', '', :src => url_for(content))
79:     when String
80:       if content.split("\n").size == 1 and content =~ /^https?:\/\//
81:         content_tag('iframe', '', :src => content)
82:       else
83:         content
84:       end
85:     when Proc
86:       self.instance_eval(&content)
87:     when NilClass
88:       ''
89:     else
90:       raise "Unsupported content for block (#{content.class})"
91:     end
92:   end

[Source]

     # File app/helpers/boxes_helper.rb, line 184
184:   def import_blocks_stylesheets
185:     stylesheet_import( current_blocks.map{|b|'blocks/' + b.css_class_name}.uniq ) + "\n" +
186:     stylesheet_import( current_blocks.map{|b|'blocks/' + b.css_class_name}.uniq, :themed_source => true )
187:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 31
31:   def maybe_display_custom_element(holder, element, options = {})
32:     if holder.respond_to?(element)
33:       content_tag('div', holder.send(element), options)
34:     else
35:       ''
36:     end
37:   end

[Source]

    # File app/helpers/boxes_helper.rb, line 7
 7:   def with_box_decorator(dec, &block)
 8:     @box_decorator = dec
 9:     result = block.call
10:     @box_decorator = DontMoveBlocks
11: 
12:     result
13:   end

[Validate]