end
end
- def scroll
- @scroll = Scroll.show(params[:id], [@user, @admin])
- cnt = ScrollPanel.count(:conditions => ['scroll_id = ?', @scroll.id]).to_i
- @offset = ScrollPanel.offset cnt, params[:offset]
- @panel_count = ScrollPanel.panel_count cnt, params[:count]
- @scroll_panels = ScrollPanel.play_list(@scroll, @author, @offset, @panel_count)
- respond_to do |format|
- format.html {
- @prev_offset = if @offset > 0
- if @offset - @panel_count < 0
- 0
- else
- @offset - @panel_count
- end
- else
- nil
- end
- @next_offset = if @offset + @panel_count > cnt
- nil
- else
- @offset + @panel_count
- end
- if @author
- @new_panels = Panel.mylist(@author, 1, 5)
- end
- }
- format.json {render text: ScrollPanel.list_as_json_text(@scroll_panels, @author)}
- format.jsonp {
- render :json => "callback(" + @scroll_panels.to_json_list + ");"
- }
- end
- end
-
def list
@scroll_panels = ScrollPanel.all
respond_to do |format|
if @scroll_panel.store
flash[:notice] = I18n.t('flash.notice.created', :model => ScrollPanel.model_name.human)
- format.html { redirect_to action: :scroll, id: @scroll_panel.scroll_id }
+ format.html { redirect_to play_scroll_path(@scroll) }
format.json { render json: @scroll_panel.scroll_panel_as_json(@author) }
else
flash[:notice] = I18n.t('flash.notice.not_created', :model => ScrollPanel.model_name.human)
ot = @scroll_panel.t
@scroll_panel.attributes = params[:scroll_panel]
@scroll_panel.overwrite @author
+ @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
respond_to do |format|
if @scroll_panel.store ot
flash[:notice] = I18n.t('flash.notice.updated', :model => ScrollPanel.model_name.human)
- format.html { redirect_to action: :scroll, id: @scroll_panel.scroll_id }
+ format.html { redirect_to play_scroll_path(@scroll) }
format.json { head :ok }
else
flash[:notice] = I18n.t('flash.notice.not_updated', :model => ScrollPanel.model_name.human)
def destroy
@scroll_panel = ScrollPanel.edit(params[:id], @author)
+ @scroll = Scroll.edit(@scroll_panel.scroll_id, @author) if @scroll_panel.scroll_id
respond_to do |format|
if @scroll_panel.destroy_and_shorten
flash[:notice] = I18n.t('flash.notice.destroyed', :model => ScrollPanel.model_name.human)
- format.html { redirect_to :controller => 'scroll_panels', :action => :scroll, :id => @scroll_panel.scroll_id }
+ format.html { redirect_to play_scroll_path(@scroll) }
format.json { head :ok }
else
flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => ScrollPanel.model_name.human)