Merge branch 'ntu' of github.com:Rulingcom/orbit into ntu
This commit is contained in:
		
						commit
						2d8400d1cc
					
				| 
						 | 
					@ -1,3 +1,7 @@
 | 
				
			||||||
 | 
					function get_part_id(){
 | 
				
			||||||
 | 
						return $(".edit_page_part").attr("action").split('/').pop();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("div.editable").live("mouseenter mouseleave", function (event) {
 | 
					$("div.editable").live("mouseenter mouseleave", function (event) {
 | 
				
			||||||
  $(this).children('.edit_link').toggle();
 | 
					  $(this).children('.edit_link').toggle();
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
| 
						 | 
					@ -21,11 +25,11 @@ $("#page_module_app_id").live('change', function() {
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#module_app_list select").live('change', function() {
 | 
					$("#module_app_list select").live('change', function() {
 | 
				
			||||||
	$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets');
 | 
						$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widgets?part_id=' + get_part_id());
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#widget_list select").live('change', function() {
 | 
					$("#widget_list select").live('change', function() {
 | 
				
			||||||
	$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val());
 | 
						$.getScript($(this).attr('rel') + '/' + $(this).val() + '/reload_widget_styles?module_app_id=' + $("#module_app_list select").val() + '&part_id=' + get_part_id());
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$("#tag_list select").live('change', function() {
 | 
					$("#tag_list select").live('change', function() {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,6 +90,7 @@ class Admin::PagePartsController < ApplicationController
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  def reload_widgets
 | 
					  def reload_widgets
 | 
				
			||||||
 | 
					    @part = PagePart.find params[:part_id]
 | 
				
			||||||
    @categories =[]
 | 
					    @categories =[]
 | 
				
			||||||
    @module_app = ModuleApp.find(params[:id])
 | 
					    @module_app = ModuleApp.find(params[:id])
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
| 
						 | 
					@ -112,6 +113,7 @@ class Admin::PagePartsController < ApplicationController
 | 
				
			||||||
        @tags = ArchiveTag.all
 | 
					        @tags = ArchiveTag.all
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @part.widget_path = @module_app.widgets.first if @module_app.needs_to_widget_option?
 | 
				
			||||||
    respond_to do |format|
 | 
					    respond_to do |format|
 | 
				
			||||||
      format.js  {}
 | 
					      format.js  {}
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,3 +1,10 @@
 | 
				
			||||||
class OrbitWidgetController< OrbitFrontendComponentController
 | 
					class OrbitWidgetController< OrbitFrontendComponentController
 | 
				
			||||||
 | 
					before_filter :get_wiget_options
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def get_wiget_options
 | 
				
			||||||
 | 
					    @wiget_options = {}
 | 
				
			||||||
 | 
					    if params[:widget_options]
 | 
				
			||||||
 | 
					      @wiget_options = (eval('{'+ params[:widget_options] +'}') rescue {})
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,8 @@ class ModuleApp
 | 
				
			||||||
  # field :widgets ,type: Array
 | 
					  # field :widgets ,type: Array
 | 
				
			||||||
  field :widgets ,type: Hash
 | 
					  field :widgets ,type: Hash
 | 
				
			||||||
  field :widget_fields ,type: Array
 | 
					  field :widget_fields ,type: Array
 | 
				
			||||||
    
 | 
					  field :widget_options,type:Hash
 | 
				
			||||||
 | 
					  field :widget_options_fields_i18n,type:Hash
 | 
				
			||||||
  has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
 | 
					  has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
 | 
				
			||||||
  has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
 | 
					  has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
| 
						 | 
					@ -79,6 +80,14 @@ class ModuleApp
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 | 
					  def needs_to_widget_option?
 | 
				
			||||||
 | 
					    if self.widget_options
 | 
				
			||||||
 | 
					      self.widget_options.has_key? widgets.first
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      false  
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  protected
 | 
					  protected
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  def set_key
 | 
					  def set_key
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,6 +14,7 @@ class PagePart
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  field :widget_style
 | 
					  field :widget_style
 | 
				
			||||||
  field :widget_field , :type => Array
 | 
					  field :widget_field , :type => Array
 | 
				
			||||||
 | 
					  field :widget_options ,:type=>Hash
 | 
				
			||||||
  field :widget_data_count
 | 
					  field :widget_data_count
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  belongs_to :page
 | 
					  belongs_to :page
 | 
				
			||||||
| 
						 | 
					@ -22,6 +23,11 @@ class PagePart
 | 
				
			||||||
  before_save :delete_empty_widget_field
 | 
					  before_save :delete_empty_widget_field
 | 
				
			||||||
  after_save :update_parent
 | 
					  after_save :update_parent
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def widget_options_uri
 | 
				
			||||||
 | 
					    self.widget_options.map{|t| "#{t[0]}: #{t[1]}"}.join(',') rescue ''
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  protected
 | 
					  protected
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  def delete_empty_widget_field
 | 
					  def delete_empty_widget_field
 | 
				
			||||||
| 
						 | 
					@ -35,4 +41,5 @@ class PagePart
 | 
				
			||||||
    self.page.save
 | 
					    self.page.save
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					@ -46,7 +46,6 @@
 | 
				
			||||||
	<%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %>
 | 
						<%#= select_tag "page_part[widget_field][]", options_for_select(@module_app.widget_fields.collect{|widget_field| [widget_field.humanize, widget_field]}, @part.widget_field.collect{|widget_field| widget_field}), {:multiple => :multiple, :size => 6} %>
 | 
				
			||||||
</span>
 | 
					</span>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<div id="widget_data_count">
 | 
					<span id="widget_options">
 | 
				
			||||||
<%= f.label :widget_data_count %>
 | 
						<%= render 'widget_options' %>
 | 
				
			||||||
<%= f.text_field :widget_data_count %>
 | 
					</span>
 | 
				
			||||||
</div>
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,3 @@
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	<% if (@module_app && @module_app.widget_fields) %>
 | 
						<% if (@module_app && @module_app.widget_fields) %>
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	<%= label_tag('widget_field') %>
 | 
						<%= label_tag('widget_field') %>
 | 
				
			||||||
| 
						 | 
					@ -9,4 +8,6 @@
 | 
				
			||||||
		<%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %> <br />
 | 
							<%= select_tag "page_part[widget_field_type][]", options_for_select(LIST[:widget_field_type].collect{|widget_field| [widget_field.humanize, widget_field]}, (@part[:widget_field][i][1] if (@part && !@part[:widget_field].blank? && !@part[:widget_field][i].blank?)) ), :include_blank => true %> <br />
 | 
				
			||||||
	<% end %>
 | 
						<% end %>
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
 | 
							<%= label_tag :widget_data_count %>
 | 
				
			||||||
 | 
							<%= text_field_tag :widget_data_count,@part.widget_data_count %>
 | 
				
			||||||
	<% end %>	
 | 
						<% end %>	
 | 
				
			||||||
| 
						 | 
					@ -3,3 +3,5 @@ $('#widget_style_list').html("<%= escape_javascript(select 'page_part', 'widget_
 | 
				
			||||||
$('#widget_field').html("<%= j render 'widget_fields' %>");
 | 
					$('#widget_field').html("<%= j render 'widget_fields' %>");
 | 
				
			||||||
$('#widget_category').html("<%= j render 'widget_categories' %>");
 | 
					$('#widget_category').html("<%= j render 'widget_categories' %>");
 | 
				
			||||||
$('#widget_tag').html("<%= j render 'widget_tags' %>");
 | 
					$('#widget_tag').html("<%= j render 'widget_tags' %>");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					$("#widget_options").html("<%= j render 'widget_options'%>");
 | 
				
			||||||
| 
						 | 
					@ -210,7 +210,7 @@ module ParserCommon
 | 
				
			||||||
                when 'default_widget'
 | 
					                when 'default_widget'
 | 
				
			||||||
                    "/panel/orbit_app/widget/#{part.widget_style}?inner=true"
 | 
					                    "/panel/orbit_app/widget/#{part.widget_style}?inner=true"
 | 
				
			||||||
                  else
 | 
					                  else
 | 
				
			||||||
                    "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true"
 | 
					                    "/panel/#{part.module_app.key}/widget/#{part.widget_path}?inner=true&widget_options=#{part.widget_options_uri}"
 | 
				
			||||||
                end
 | 
					                end
 | 
				
			||||||
          options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
 | 
					          options = "&part_id=#{part.id}&category_id=#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=#{!part[:tag].blank? ? part[:tag] : tag}&page=#{params[:page]}&search_query=#{params[:search_query]}&part_title=#{Rack::Utils.escape(part_title).gsub("+", "%20") rescue nil}"
 | 
				
			||||||
          ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
 | 
					          ret << "<div class='dymanic_load widget' path='#{url + options}'></div>"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -114,9 +114,8 @@ module ParserFrontEnd
 | 
				
			||||||
                    when 'default_widget'
 | 
					                    when 'default_widget'
 | 
				
			||||||
                        "/panel/orbit_app/widget/\#{part.widget_style}?inner=true"
 | 
					                        "/panel/orbit_app/widget/\#{part.widget_style}?inner=true"
 | 
				
			||||||
                      else
 | 
					                      else
 | 
				
			||||||
                        "/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true"
 | 
					                        "/panel/\#{part.module_app.key}/widget/\#{part.widget_path}?inner=true&widget_options=\#{part.widget_options_uri}"
 | 
				
			||||||
                    end
 | 
					                    end
 | 
				
			||||||
          
 | 
					 | 
				
			||||||
          options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
 | 
					          options = "&part_id=\#{part.id}&category_id=\#{!part[:category].blank? ? part[:category].blank? : category}&tag_id=\#{!part[:tag].blank? ? part[:tag] : tag}&page=\#{params[:page]}&search_query=\#{params[:search_query]}&part_title=\#{Rack::Utils.escape(part_title).gsub(\"\+\", \"\%20\") rescue nil}"
 | 
				
			||||||
          ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
 | 
					          ret << "<orbit_front path='#{url + options}' part_id=#{part.id} class='dymanic_load widget'></orbit_front>"
 | 
				
			||||||
          
 | 
					          
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -319,4 +319,13 @@ namespace :migrate do
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  task :add_widget_options_to_gallery => :environment do
 | 
				
			||||||
 | 
					      a = ModuleApp.where(:key=>'gallery').first
 | 
				
			||||||
 | 
					      a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6]}}
 | 
				
			||||||
 | 
					      a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal"}}
 | 
				
			||||||
 | 
					      a.save
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,13 @@
 | 
				
			||||||
class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
 | 
					class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	def widget1
 | 
						def widget1
 | 
				
			||||||
		@settings = {"vertical"=>2,"horizontal"=>6}   #[note] horizontal has it's limitation from 2 to 6
 | 
							vertical = 2
 | 
				
			||||||
 | 
							horizontal = 6 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							vertical = @wiget_options[:vertical] if (@wiget_options.has_key?(:vertical) && @wiget_options[:vertical] < vertical)
 | 
				
			||||||
 | 
							horizontal = @wiget_options[:horizontal] if (@wiget_options.has_key?(:horizontal) && @wiget_options[:horizontal] < horizontal)	
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							@settings = {"vertical"=>vertical,"horizontal"=>horizontal}   #[note] horizontal has it's limitation from 2 to 6
 | 
				
			||||||
		@class = "c" + @settings["horizontal"].to_s
 | 
							@class = "c" + @settings["horizontal"].to_s
 | 
				
			||||||
		@total = @settings["vertical"] * @settings["horizontal"]
 | 
							@total = @settings["vertical"] * @settings["horizontal"]
 | 
				
			||||||
		@rnd = Random.new
 | 
							@rnd = Random.new
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,8 +3,6 @@
 | 
				
			||||||
  <%#= javascript_include_tag "cycle" %>
 | 
					  <%#= javascript_include_tag "cycle" %>
 | 
				
			||||||
<%# end %>
 | 
					<%# end %>
 | 
				
			||||||
<div class="four columns">
 | 
					<div class="four columns">
 | 
				
			||||||
	<h4>Gallery Widget</h4>
 | 
					 | 
				
			||||||
	<p>WIDGET 1</p>
 | 
					 | 
				
			||||||
	<div class="widget_gallery w1 <%= @class %>">
 | 
						<div class="widget_gallery w1 <%= @class %>">
 | 
				
			||||||
		<ul>
 | 
							<ul>
 | 
				
			||||||
			<% @images.each do |image| %>
 | 
								<% @images.each do |image| %>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -33,3 +33,6 @@ en:
 | 
				
			||||||
    set_cover: Set as Album Cover
 | 
					    set_cover: Set as Album Cover
 | 
				
			||||||
    sure?: "Are you sure?"
 | 
					    sure?: "Are you sure?"
 | 
				
			||||||
    no_description: Description Unavailable
 | 
					    no_description: Description Unavailable
 | 
				
			||||||
 | 
					    widget_option:
 | 
				
			||||||
 | 
					       horizontal: Horizontal Pictures
 | 
				
			||||||
 | 
					       vertical: Vertical  Pictures
 | 
				
			||||||
| 
						 | 
					@ -33,3 +33,6 @@ zh_tw:
 | 
				
			||||||
    set_cover: 設為封面
 | 
					    set_cover: 設為封面
 | 
				
			||||||
    sure?: "你確定嗎?"
 | 
					    sure?: "你確定嗎?"
 | 
				
			||||||
    no_description: 沒有描述
 | 
					    no_description: 沒有描述
 | 
				
			||||||
 | 
					    widget_option:
 | 
				
			||||||
 | 
					       horizontal: 水平圖片數量     
 | 
				
			||||||
 | 
					       vertical: 垂直圖片數量
 | 
				
			||||||
		Reference in New Issue