Merge branch 'ad_banner' of https://github.com/Rulingcom/orbit into ad_banner
This commit is contained in:
		
						commit
						1e43349eb8
					
				|  | @ -18,3 +18,11 @@ $('.quick_edit_cancel').live('click', function(){ | |||
|   $("tr#bulletin_file_" + $(this).prev().attr('value')).hide(); | ||||
|   $("tr#bulletin_link_" + $(this).prev().attr('value')).hide(); | ||||
| }); | ||||
| 
 | ||||
| $(document).on('click', '.list-remove', function(){ | ||||
| 	$('#delete_bulletins').submit(); | ||||
| }); | ||||
| 
 | ||||
| $(document).on('click', '#check_all_bulletins', function(){ | ||||
|   $('.checkbox_in_list').attr("checked", this.checked); | ||||
| }); | ||||
|  | @ -12,3 +12,5 @@ | |||
| //= require orbit-1.0
 | ||||
| //= require tinymce-jquery
 | ||||
| //= require tinymce_orbit
 | ||||
| //= require orbit-bar-search
 | ||||
| //= require side_bar_history
 | ||||
|  | @ -0,0 +1,20 @@ | |||
| $(document).on('click', '.orbit-bar-search', function (){ | ||||
| 	if ($(this).parents('.search').hasClass('visible')){ | ||||
| 		$(this).parents('.search').stop().animate({ | ||||
| 			'width':'28px', | ||||
| 		}); | ||||
| 		$(this).parents('.search').css({ | ||||
| 			'background-color': 'transparent', | ||||
| 		});	 | ||||
| 		$(this).parents('.search').removeClass('visible');	 | ||||
| 	} | ||||
| 	else{ | ||||
| 		$(this).parents('.search').stop().animate({ | ||||
| 			'width':'265px', | ||||
| 		}); | ||||
| 		$(this).parents('.search').css({ | ||||
| 			'background-color': 'rgba(0, 0, 0, 0.5)', | ||||
| 		}); | ||||
| 		$(this).parents('.search').addClass('visible'); | ||||
| 	} | ||||
| }); | ||||
|  | @ -1,4 +1,5 @@ | |||
| $(function () {  | ||||
| var history_edited = false;  | ||||
| 
 | ||||
| $('#back_sidebar a, #back_main a.nav').live('click',   | ||||
|   function () {   | ||||
|     $.getScript(this.href); | ||||
|  | @ -23,9 +24,26 @@ $(function () { | |||
|   return false; | ||||
| }); | ||||
| 
 | ||||
| $(document).on('click', '.js_history', | ||||
|   function () {  | ||||
|     $.getScript(this.href); | ||||
|     history.pushState(null, document.title, this.href); | ||||
|     history_edited = true; | ||||
|     return false; | ||||
|   } | ||||
| ); | ||||
| 
 | ||||
| $(document).on('click', '.pagination a', | ||||
|   function () {  | ||||
|     $.getScript(this.href); | ||||
|     history.pushState(null, document.title, this.href); | ||||
|     history_edited = true; | ||||
|     return false; | ||||
|   } | ||||
| ); | ||||
| 
 | ||||
| $(window).bind("popstate", function () {  | ||||
|   if (history_edited) {  | ||||
|     $.getScript(location.href);   | ||||
|   } | ||||
| }); | ||||
| }); | ||||
|  | @ -102,6 +102,14 @@ table .span1-2 { | |||
| 	float: none; | ||||
| 	margin-left: 0; | ||||
| } | ||||
| table .span1-3 { | ||||
| 	min-width: 200px; | ||||
| 	float: none; | ||||
| 	margin-left: 0; | ||||
| } | ||||
| .qe-block .form-horizontal .form-actions { | ||||
| 	text-align:right; | ||||
| } | ||||
| .modal.fade { | ||||
|     top: -50%; | ||||
| } | ||||
|  | @ -49,18 +49,21 @@ | |||
| 	*/ | ||||
| } | ||||
| #orbit-bar .navbar-search { | ||||
| 	float: none; | ||||
| 	margin: 0 auto; | ||||
| 	text-align: center; | ||||
| 	left: 28px; | ||||
| 	margin: 0; | ||||
| 	position: absolute; | ||||
| 	text-align: right; | ||||
| 	top: -1px; | ||||
| } | ||||
| #orbit-bar .nav.pull-right { | ||||
| 	margin-right: -20px; | ||||
| } | ||||
| #orbit-bar .search-query { | ||||
| 	background-image: url(<%= asset_path 'main-search.png' %>); | ||||
| 	background-repeat: no-repeat; | ||||
| 	background-position: 5px 6px; | ||||
| 	padding-left: 25px; | ||||
| 	padding: 4px 9px; | ||||
| 	height: 12px; | ||||
|     margin-top: 3px; | ||||
|     border: 1px solid #333333; | ||||
|     font-size: 11px; | ||||
| 	/*background-color: rgba(255, 255, 255, 0.8); | ||||
| 	color: #333; | ||||
| 	text-shadow: 0px 1px 0px #FFF;*/ | ||||
|  | @ -69,7 +72,7 @@ | |||
| #orbit-bar .search-query:focus { | ||||
| 	/*background-color: rgba(255, 255, 255, 0.9); | ||||
| 	text-shadow: 0px 1px 0px #FFF;*/ | ||||
| 	background-position: 6px 7px; | ||||
| 	background-position: 5px 2px; | ||||
| } | ||||
| #orbit-bar .container { | ||||
| 	width:100%; | ||||
|  | @ -104,11 +107,16 @@ | |||
| 	text-indent: -9999px; | ||||
| 	padding:6px; | ||||
| } | ||||
| #orbit-bar .nav > li.search { | ||||
| 	overflow: hidden; | ||||
| 	width: 28px; | ||||
| 	position: relative; | ||||
| } | ||||
| #orbit-bar .nav > li > a.orbit-bar-home { | ||||
| 	background-position: -10px -10px; | ||||
| } | ||||
| #orbit-bar .nav > li > a.orbit-bar-desktop { | ||||
| 	background-position: -100px -4px; | ||||
| 	background-position: -106px -9px; | ||||
| } | ||||
| #orbit-bar .nav > li > a.orbit-bar-member { | ||||
| 	background-position: -4px -37px; | ||||
|  | @ -119,6 +127,10 @@ | |||
| #orbit-bar .nav > li > a.orbit-bar-language { | ||||
| 	background-position: -42px -42px; | ||||
| } | ||||
| #orbit-bar .nav > li > a.orbit-bar-search { | ||||
| 	background-position: -75px -10px; | ||||
| 	overflow: hidden; | ||||
| } | ||||
| .language-menu .active { | ||||
|   color: #ffffff; | ||||
|   text-decoration: none; | ||||
|  | @ -143,6 +155,9 @@ | |||
| 	float: left; | ||||
| 	max-width: 22px; | ||||
| } | ||||
| #orbit-bar .clear { | ||||
| 	clear: none; | ||||
| } | ||||
| #orbit-bar .account-menu { | ||||
| 	right: 5px; | ||||
| } | ||||
|  | @ -266,6 +281,7 @@ | |||
| 	padding-top: 32px; | ||||
| 	padding-bottom: 18px; | ||||
| 	position: relative; | ||||
| 	min-height: 100%; | ||||
| } | ||||
| #main-wrap > .form-actions { | ||||
| 	background-color: #FFF; | ||||
|  | @ -349,8 +365,6 @@ | |||
| 	border-top: none; | ||||
| } | ||||
| #post-body .editor { | ||||
| 	margin: 8px 0; | ||||
| 	width: 100%; | ||||
| } | ||||
| #post-body-content { | ||||
| 	margin-right: 320px; | ||||
|  | @ -382,15 +396,15 @@ | |||
|     border-top-color: #0088CC; | ||||
|     margin-top: 6px; | ||||
| } | ||||
| .filter form { | ||||
|     margin: 5px 10px; | ||||
| } | ||||
| .filter .active { | ||||
| 	background-color: #0088CC; | ||||
| } | ||||
| .filter .active a { | ||||
| 	color: #FFF; | ||||
| } | ||||
| .filter form { | ||||
|     margin: 5px 10px; | ||||
| } | ||||
| .filters { | ||||
| 	background-color: rgba(0,0,0,0.075); | ||||
| 	-webkit-box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.2); | ||||
|  | @ -419,26 +433,6 @@ | |||
| .filters .in { | ||||
| 	/*border-bottom: 1px solid rgba(0,0,0,0.07)*/ | ||||
| } | ||||
| #tags { | ||||
| } | ||||
| #tags .tag { | ||||
| 	line-height: 32px; | ||||
|     padding: 0 10px; | ||||
| 	background-color: #FFFFFF; | ||||
| 	border-bottom: 1px solid #DDDDDD; | ||||
| 	border-top: medium none; | ||||
| } | ||||
| #tags .tag form, #tags .tag form input { | ||||
| 	margin:0; | ||||
| } | ||||
| #tags .tagitem { | ||||
| 	display: inline-block; | ||||
| 	float: left; | ||||
| } | ||||
| #tags .action { | ||||
| 	display: inline-block; | ||||
| 	float: right; | ||||
| } | ||||
| .sign-in { | ||||
| 	width: 360px; | ||||
| 	margin: 0 auto 70px; | ||||
|  | @ -531,6 +525,26 @@ | |||
| .active .web-symbol:after { | ||||
| 	content: "}"; | ||||
| } | ||||
| .img-peview { | ||||
| 	margin-left: 12px; | ||||
| } | ||||
| .popover img { | ||||
| 	max-height: 120px; | ||||
| 	max-width: 100%; | ||||
| } | ||||
| .popover-inner { | ||||
|     width: auto; | ||||
| } | ||||
| .popover-title { | ||||
|     padding: 5px; | ||||
| } | ||||
| .popover-content { | ||||
|     border-radius: 3px; | ||||
|     padding: 5px; | ||||
| } | ||||
| .popover-title { | ||||
| 	display: none; | ||||
| } | ||||
| /*icons*/ | ||||
| .the-icons i:after { | ||||
| 	content: attr(class); | ||||
|  | @ -649,6 +663,12 @@ | |||
| .icons-unlock { | ||||
| 	background-position: -192px -32px; | ||||
| } | ||||
| .icons-time { | ||||
| 	background-position: -448px -32px; | ||||
| } | ||||
| .icons-banner { | ||||
| 	background-position: -608px -32px; | ||||
| } | ||||
| /*3*/ | ||||
| .icons-content { | ||||
| 	background-position: -160px -66px; | ||||
|  |  | |||
|  | @ -102,17 +102,9 @@ module ApplicationHelper | |||
|     ' web-symbol' if params[:sort].eql?(name) | ||||
|   end | ||||
| 
 | ||||
|   def add_filter(param_name, value) | ||||
|     filter = params[:filter] rescue nil | ||||
|     if filter && filter.has_key(param_name) | ||||
|       filter[param_name] << value | ||||
|     elsif filter | ||||
|       filter.merge({param_name => [value]}) | ||||
|     else | ||||
|       {param_name => [value]} | ||||
|   def is_filter_active?(type, id) | ||||
|     ' active' if (@filter[type].include?(id.to_s) rescue nil) | ||||
|   end | ||||
|   end | ||||
| 
 | ||||
| 
 | ||||
|   def process_page(page, id) | ||||
|     parse_page_noko(page, id) | ||||
|  | @ -152,6 +144,7 @@ module ApplicationHelper | |||
|     javascripts << "<script type='text/javascript' src='/assets/jquery.tinyscrollbar.min.js'></script>\n" | ||||
|     javascripts << "<script type='text/javascript' src='/assets/jquery.isotope.min.js'></script>\n" | ||||
|     javascripts << "<script type='text/javascript' src='/assets/orbit-bar-member.js'></script>\n" | ||||
|     javascripts << "<script type='text/javascript' src='/assets/orbit-bar-search.js'></script>\n" | ||||
|     javascripts << "<script type='text/javascript' src='/assets/orbit_bar.js'></script>\n" | ||||
|     javascripts << "<script type='text/javascript' src='/assets/event.js'></script>\n" | ||||
|     page.design.javascripts.each do |js| | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| class Design | ||||
|   include Mongoid::Document | ||||
|   include Mongoid::Timestamps | ||||
|   include ParserLayout | ||||
| 
 | ||||
|   field :title | ||||
|   field :author | ||||
|  | @ -14,7 +15,7 @@ class Design | |||
|   embeds_one :reset_css, :class_name => "Stylesheet", :cascade_callbacks => true | ||||
|   embeds_many :themes, :cascade_callbacks => true | ||||
|   embeds_many :javascripts, :cascade_callbacks => true | ||||
|   embeds_many :images, :cascade_callbacks => true | ||||
|   embeds_many :images, :as => :design_image, :cascade_callbacks => true | ||||
|   # embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true | ||||
|    | ||||
|   validates_presence_of :title | ||||
|  | @ -65,9 +66,6 @@ class Design | |||
|   protected | ||||
|    | ||||
|   def parse_css_for_images | ||||
|     self.images.each do |image| | ||||
|       image.save | ||||
|     end | ||||
|     if (self.default_css && self.default_css.changed) | ||||
|       self.default_css.parse_urls | ||||
|     end | ||||
|  | @ -76,6 +74,7 @@ class Design | |||
|         theme.parse_urls | ||||
|       end | ||||
|     end | ||||
|     parse_body_for_images(self) | ||||
|   end | ||||
|    | ||||
| end | ||||
|  |  | |||
|  | @ -27,6 +27,7 @@ class Stylesheet < DesignFile | |||
|       temp_file = File.new(dir + '/' + orig_file_name, 'w+') | ||||
|       temp_file.write content.force_encoding("UTF-8") | ||||
|       self.file = temp_file | ||||
|       self.save | ||||
|     }     | ||||
|   end | ||||
|    | ||||
|  |  | |||
|  | @ -15,6 +15,7 @@ | |||
| 			</div> | ||||
| 			<ul class="nav"> | ||||
| 				<li><%= link_to t(:homepage), root_path, :class => 'orbit-bar-home' %></li> | ||||
| 				<li><a class="orbit-bar-desktop" href="#">Desktop</a></li> | ||||
| 			</ul> | ||||
| 			<ul class="nav pull-right"> | ||||
|         <li class="dropdown language"> | ||||
|  | @ -25,6 +26,13 @@ | |||
| 	          <% end %> | ||||
|           </ul> | ||||
|         </li> | ||||
| 
 | ||||
|                 <li class="search clear"> | ||||
|                     <a class="orbit-bar-search" href="#">search</a> | ||||
| 					<form class="navbar-search" action=""> | ||||
| 		        		<input class="search-query span3" type="text" placeholder="<%= t(:search_nccu) %>"> | ||||
| 		      		</form> | ||||
|                 </li> | ||||
| 				<% if user_signed_in? %> | ||||
| 					<li class="dropdown active"> | ||||
| 						<a class="orbit-bar-account" href="#" data-toggle="dropdown"> | ||||
|  | @ -94,9 +102,6 @@ | |||
| 					</li> | ||||
| 				<% end %> | ||||
| 			</ul> | ||||
| 			<form class="navbar-search span6" action=""> | ||||
|           <input class="search-query span4" type="text" placeholder="<%= t(:search_nccu) %>"> | ||||
|       </form> | ||||
| 		</div> | ||||
| 	</div> | ||||
| </header> | ||||
|  | @ -2,7 +2,7 @@ module ParserCommon | |||
|   | ||||
|   def menu_level(page, current, menu, edit = false) | ||||
|     res = '' | ||||
|     if current <= menu.levels | ||||
|     if menu.levels > 0 && current <= menu.levels | ||||
|       if current != 0 | ||||
|         res << "<div class='rc_dm'>" | ||||
|         item = rand(100000) | ||||
|  | @ -84,7 +84,7 @@ module ParserCommon | |||
|     body.css('.page_image').each do |page_image| | ||||
|       # image = page.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } | ||||
|       # image = page.design.custom_images.detect{|image| image.name.eql?(tag.attr['name']) } unless image | ||||
|       image = page.design.images.detect{|image| image.name.eql?(page_image['name']) } unless image | ||||
|       image = page.design.images.detect{|image| image.name.eql?(File.basename(page_image['src'])) } unless image | ||||
|       if image | ||||
|         res = "<img src=#{image.file.url} " | ||||
|         page_image.attributes.each do |l| | ||||
|  |  | |||
|  | @ -8,11 +8,6 @@ module ParserLayout | |||
|       layout.layout_parts.build(:name => content['name']) | ||||
|     end | ||||
| 
 | ||||
|     body.css('.page_image').each do |image| | ||||
|       image = layout.design.images.detect{ |i| i.file_identifier.eql?(parse_html_image(image.to_html)) } | ||||
|       image.update_attributes(:name => image['name'], :html_id => image['id'], :html_class => image['class']) if image | ||||
|     end | ||||
| 
 | ||||
|     body.css('.page_menu').each do |menu| | ||||
|       layout.build_menu(:levels => 0, :values => {}) unless layout.menu | ||||
|       layout.menu.levels = i = menu['level'].to_i | ||||
|  | @ -22,12 +17,14 @@ module ParserLayout | |||
|      | ||||
|   end | ||||
| 
 | ||||
|   def parse_html_image(html) | ||||
|     html.scan(/(?<=\<img)(.*?)(?=\/\>)/){ | ||||
|       $1.gsub(' ','').scan(/(?<=src=\")(.*?)(?=\")/){ | ||||
|         return File.basename($1).gsub(/[\\\"]/, '') | ||||
|       } | ||||
|     } | ||||
|   def parse_body_for_images(design) | ||||
|     body = Nokogiri::HTML(design.layout.body) | ||||
| 
 | ||||
|     body.css('.page_image').each do |page_image| | ||||
|       image = design.images.where( file: File.basename(page_image['src']))[0] | ||||
|       image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image | ||||
|     end | ||||
|      | ||||
|   end | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
|  | @ -9,11 +9,28 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
| 	  get_categorys(params[:bulletin_category_id]) | ||||
| 	  get_tags | ||||
| 
 | ||||
|     @filter = params[:filter] | ||||
|     new_filter = params[:new_filter] | ||||
| 
 | ||||
|     if @filter && params[:clear] | ||||
|       @filter.delete(params[:type]) | ||||
|     elsif @filter && new_filter | ||||
|       if @filter.has_key?(new_filter[:type]) && @filter[new_filter[:type]].include?(new_filter[:id].to_s) | ||||
|         @filter[new_filter[:type]].delete(new_filter[:id].to_s) | ||||
|       elsif @filter.has_key?(new_filter[:type]) | ||||
|         @filter[new_filter[:type]] << new_filter[:id].to_s | ||||
|       else | ||||
|         @filter.merge!({new_filter[:type] => [new_filter[:id].to_s]}) | ||||
|       end | ||||
|     elsif new_filter | ||||
|       @filter = {new_filter[:type] => [new_filter[:id].to_s]} | ||||
|     end | ||||
| 
 | ||||
|     # @bulletins = Bulletin.where("bulletin_category_id" => params[:bulletin_category_id]).desc("postdate") if params[:bulletin_category_id] | ||||
|      | ||||
|   	# @bulletins = Bulletin.search(params[:search], params[:category_id]) | ||||
|     # @bulletins = Bulletin.all.order_by([params[:sort], params[:direction]]) | ||||
|     @bulletins = params[:sort] ? get_sorted_bulletins : Bulletin.all.page(params[:page]).per(10) | ||||
|     @bulletins = (params[:sort] || @filter) ? get_sorted_and_filtered_bulletins : Bulletin.all.page(params[:page]).per(10) | ||||
|   	@bulletin_categories = BulletinCategory.all | ||||
| 
 | ||||
|     @bulletin_link = BulletinLink.new | ||||
|  | @ -24,7 +41,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
| 	 | ||||
|     respond_to do |format| | ||||
|       format.html # index.html.erb | ||||
|       format.js | ||||
|       format.js { } | ||||
|       format.xml  { render :xml => @bulletins } | ||||
|     end | ||||
|   end | ||||
|  | @ -273,6 +290,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
|     get_tags | ||||
|   end | ||||
| 
 | ||||
|   def delete | ||||
|     if params[:to_delete] | ||||
|       bulletins = Bulletin.any_in(:_id => params[:to_delete]).delete_all | ||||
|     end | ||||
|     redirect_to panel_announcement_back_end_bulletins_url(:filter => params[:filter], :direction => params[:direction], :sort => params[:sort]) | ||||
|   end | ||||
| 
 | ||||
|    | ||||
|   protected | ||||
|    | ||||
|  | @ -290,16 +314,11 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
|   	@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) | ||||
|   end | ||||
| 
 | ||||
|   def get_tags | ||||
|   	module_app = ModuleApp.first(:conditions => {:key => 'announcement'}) | ||||
|   	@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) | ||||
|   end | ||||
| 
 | ||||
|   def get_sorted_bulletins | ||||
|   def get_sorted_and_filtered_bulletins | ||||
|     bulletins = Bulletin.all | ||||
|     case params[:sort] | ||||
|       when 'postdate', 'deadline' | ||||
|         bulletins.order_by([params[:sort], params[:direction]]).page(params[:page]).per(10) | ||||
|         bulletins = bulletins.order_by([params[:sort], params[:direction]]) | ||||
|       when 'category' | ||||
|         category_ids = bulletins.distinct(:bulletin_category_id) | ||||
|         categories = BulletinCategory.find(category_ids) rescue nil | ||||
|  | @ -308,19 +327,15 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
|           categories.each { |category| h[category.i18n_variable[I18n.locale]] = category.id } | ||||
|           sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! | ||||
|           sorted_categorys = sorted.collect {|a| bulletins.where(:bulletin_category_id => a[1]).entries } | ||||
|           sorted_categorys.flatten! | ||||
|           Kaminari.paginate_array(sorted_categorys).page(params[:page]).per(10) | ||||
|         else | ||||
|           nil | ||||
|           bulletins = sorted_categorys.flatten! | ||||
|         end | ||||
|       when 'title' | ||||
|         h = Array.new  | ||||
|         bulletins.each { |bulletin| h << [bulletin.title[I18n.locale].downcase, bulletin] } | ||||
|         sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! | ||||
|         sorted_titles = sorted.collect {|a| a[1] } | ||||
|         Kaminari.paginate_array(sorted_titles).page(params[:page]).per(10) | ||||
|         bulletins = sorted.collect {|a| a[1] } | ||||
|       when 'status' | ||||
|         bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]).page(params[:page]).per(10) | ||||
|         bulletins = bulletins.order_by(:is_top, params[:direction]).order_by(:is_hot, params[:direction]).order_by(:is_hidden, params[:direction]) | ||||
|       when 'update_user_id' | ||||
|         user_ids = bulletins.distinct(:update_user_id) | ||||
|         users = User.find(user_ids) rescue nil | ||||
|  | @ -329,10 +344,7 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
|           users.each { |user| h << [user.name, user.id] } | ||||
|           sorted = params[:direction].eql?('asc') ? h.sort : h.sort.reverse! | ||||
|           sorted_users = sorted.collect {|a| bulletins.where(:update_user_id => a[1]).entries } | ||||
|           sorted_users.flatten! | ||||
|           Kaminari.paginate_array(sorted_users).page(params[:page]).per(10) | ||||
|         else | ||||
|           nil | ||||
|           bulletins = sorted_users.flatten | ||||
|         end | ||||
|       when 'tags' | ||||
|         a = Array.new | ||||
|  | @ -344,10 +356,37 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController | |||
|         sorted = params[:direction].eql?('asc') ? tmp.sort : tmp.sort.reverse! | ||||
|         sorted_titles = sorted.collect {|a| a[1] } | ||||
|         a = params[:direction].eql?('asc') ? (sorted_titles + a) : (a + sorted_titles) | ||||
|         a.flatten! | ||||
|         Kaminari.paginate_array(a).page(params[:page]).per(10) | ||||
|         bulletins = a.flatten | ||||
|      end | ||||
|     if @filter | ||||
|       @filter.each do |key, value| | ||||
|         case key | ||||
|           when 'status' | ||||
|             a = Array.new | ||||
|             bulletins.each do |bulletin| | ||||
|               value.each do |v| | ||||
|                 a << bulletin if bulletin[v] | ||||
|               end | ||||
|             end | ||||
|             bulletins = a | ||||
|           when 'categories' | ||||
|             a = Array.new | ||||
|             bulletins.each do |bulletin| | ||||
|               a << bulletin if value.include?(bulletin.bulletin_category.id.to_s) | ||||
|             end | ||||
|             bulletins = a | ||||
|           when 'tags' | ||||
|             a = Array.new | ||||
|             bulletins.each do |bulletin| | ||||
|               bulletin.tags.each do |tag| | ||||
|                 a << bulletin if value.include?(tag.id.to_s) | ||||
|               end | ||||
|             end | ||||
|             bulletins = a | ||||
|         end if value.size > 0 | ||||
|       end | ||||
|     end | ||||
|     Kaminari.paginate_array(bulletins).page(params[:page]).per(10) | ||||
|   end | ||||
|    | ||||
|    | ||||
| end | ||||
|  |  | |||
|  | @ -1,5 +1,5 @@ | |||
| <tr id="<%= dom_id bulletin %>" class="with_action"> | ||||
| 	<td><input type="checkbox"></td> | ||||
| 	<td><%= check_box_tag 'to_delete[]', bulletin.id, false, :class => "checkbox_in_list" %></td> | ||||
| 	<td> | ||||
| 		<% if bulletin.is_top? %> | ||||
| 			<span class="label label-success"><%= t(:top) %></span> | ||||
|  |  | |||
|  | @ -7,9 +7,9 @@ | |||
| 	    <th class="span1-2"></th> | ||||
| 	    <th class="span1-2"></th> | ||||
| 	    <th class="span1-2"></th> | ||||
| 	    <th class="span1-2"></th> | ||||
| 	    <th class="span1-3"></th> | ||||
| 	</tr> | ||||
| </thead> | ||||
| <tbody class="sort-holder"> | ||||
| <tbody id="tbody_bulletins" class="sort-holder"> | ||||
| 	<%= render :partial => 'bulletin', :collection => @bulletins %> | ||||
| </tbody> | ||||
|  |  | |||
|  | @ -0,0 +1,3 @@ | |||
| <div class="filter-clear"> | ||||
| 	<%= link_to content_tag(:i, nil, :class => 'icons-brush-large') + t(:clear), panel_announcement_back_end_bulletins_path(:filter => @filter, :sort => params[:sort], :direction => params[:direction], :clear => true, :type => type), :class => "btn js_history" %> | ||||
| </div> | ||||
|  | @ -18,73 +18,16 @@ | |||
| 	</ul> | ||||
| 	<div class="filters"> | ||||
| 		<div class="accordion-body collapse" id="collapse-status"> | ||||
| 			<div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 				<a href="#" class="btn">Category1</a> | ||||
| 				<a href="#" class="btn">Category2</a> | ||||
| 			</div> | ||||
| 			<div class="filter-clear"> | ||||
| 				<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a> | ||||
| 			</div> | ||||
| 			<%= render 'filter_status' %> | ||||
| 		</div> | ||||
| 		<div class="accordion-body collapse" id="collapse-category"> | ||||
| 			<div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 				<% @bulletin_categories.each do |category| -%> | ||||
| 					<%= link_to category.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => add_filter(:categories, category.id)), :class => 'btn' %> | ||||
| 				<% end -%>  | ||||
| 			</div> | ||||
| 			<div class="filter-clear"> | ||||
| 				<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a> | ||||
| 			</div> | ||||
| 			<%= render 'filter_categories' %> | ||||
| 		</div> | ||||
| 		<div class="accordion-body collapse" id="collapse-tags"> | ||||
| 			<div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 				<a href="#" class="btn">Tag1</a> | ||||
| 				<a href="#" class="btn">Tag2</a> | ||||
| 				<a href="#" class="btn">Tag3</a> | ||||
| 				<a href="#" class="btn">Tag4</a> | ||||
| 				<a href="#" class="btn">Tag5</a> | ||||
| 				<a href="#" class="btn">Tag6</a> | ||||
| 				<a href="#" class="btn">Tag7</a> | ||||
| 				<a href="#" class="btn">Tag8</a> | ||||
| 				<a href="#" class="btn">Tag9</a> | ||||
| 				<a href="#" class="btn">Tag10</a> | ||||
| 			<%= render 'filter_tags' %> | ||||
| 		</div> | ||||
| 			<div class="filter-clear"> | ||||
| 				<a href="#" class="btn"><i class="icons-brush-large"></i>Clear/重置</a> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 		<div class="table-label"> | ||||
| 			<table class="table main-list"> | ||||
| 				<thead> | ||||
| 					<tr class="sort-header"> | ||||
| 						<th class="span1 strong"> | ||||
| 							<input type="checkbox"> | ||||
| 							<a href class="list-remove"><i class="icon-trash"></i></a> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('status') %>"> | ||||
| 							<%= link_to t('bulletin.status') + content_tag(:b, nil, :class => is_sort?('status')), panel_announcement_back_end_bulletins_path(sortable('status')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('category') %>"> | ||||
| 							<%= link_to t('bulletin.category') + content_tag(:b, nil, :class => is_sort?('category')), panel_announcement_back_end_bulletins_path(sortable('category')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span7 <%= is_sort_active?('title') %>"> | ||||
| 							<%= link_to t('bulletin.title') + content_tag(:b, nil, :class => is_sort?('title')), panel_announcement_back_end_bulletins_path(sortable('title')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('postdate') %>"> | ||||
| 							<%= link_to t('bulletin.start_date') + content_tag(:b, nil, :class => is_sort?('postdate')), panel_announcement_back_end_bulletins_path(sortable('postdate')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('deadline') %>"> | ||||
| 							<%= link_to t('bulletin.end_date') + content_tag(:b, nil, :class => is_sort?('deadline')), panel_announcement_back_end_bulletins_path(sortable('deadline')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('tags') %>"> | ||||
| 							<%= link_to t('bulletin.tags') + content_tag(:b, nil, :class => is_sort?('tags')), panel_announcement_back_end_bulletins_path(sortable('tags')) %> | ||||
| 						</th> | ||||
| 						<th class="sort span1-2 <%= is_sort_active?('update_user_id') %>"> | ||||
| 							<%= link_to t('bulletin.last_modified') + content_tag(:b, nil, :class => is_sort?('update_user_id')), panel_announcement_back_end_bulletins_path(sortable('update_user_id')) %> | ||||
| 						</th> | ||||
| 				   </tr> | ||||
| 				</thead> | ||||
| 			</table> | ||||
| 		<div id="sort_headers" class="table-label"> | ||||
| 			<%= render 'sort_headers' %>  | ||||
| 		</div> | ||||
| 	</div> | ||||
| </div> | ||||
|  | @ -0,0 +1,6 @@ | |||
| <div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 	<% @bulletin_categories.each do |category| -%> | ||||
| 		<%= link_to category.i18n_variable[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'categories', :id => category.id}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('categories', category.id)}" %> | ||||
| 	<% end -%>  | ||||
| </div> | ||||
| <%= render :partial => 'clear_filters', :locals => {:type => 'categories'} %> | ||||
|  | @ -0,0 +1,7 @@ | |||
| <div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 	<%= link_to t(:is_top), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_top'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_top')}" %> | ||||
| 	<%= link_to t(:is_hot), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hot'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hot')}" %> | ||||
| 	<%= link_to t(:is_hidden), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_hidden'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_hidden')}" %> | ||||
| 	<%= link_to t(:is_checked), panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'status', :id => 'is_checked'}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('status', 'is_checked')}" %> | ||||
| </div> | ||||
| <%= render :partial => 'clear_filters', :locals => {:type => 'status'} %> | ||||
|  | @ -0,0 +1,6 @@ | |||
| <div class="accordion-inner" data-toggle="buttons-checkbox"> | ||||
| 	<% @tags.each do |tag| -%> | ||||
| 		<%= link_to tag[I18n.locale], panel_announcement_back_end_bulletins_path(:filter => @filter, :new_filter => {:type => 'tags', :id => tag.id}, :sort => params[:sort], :direction => params[:direction]), :class => "btn js_history#{is_filter_active?('tags', tag.id)}" %> | ||||
| 	<% end -%>  | ||||
| </div> | ||||
| <%= render :partial => 'clear_filters', :locals => {:type => 'tags'} %> | ||||
|  | @ -0,0 +1,31 @@ | |||
| <table class="table main-list"> | ||||
| 	<thead> | ||||
| 		<tr class="sort-header"> | ||||
| 			<th class="span1 strong"> | ||||
| 				<input id="check_all_bulletins" type="checkbox"> | ||||
| 				<a href='#' class="list-remove"><i class="icon-trash"></i></a> | ||||
| 			</th> | ||||
| 			<th class="sort span1-2 <%= is_sort_active?('status') %>"> | ||||
| 				<%= link_to t('bulletin.status') + content_tag(:b, nil, :class => is_sort?('status')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('status'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span1-2 <%= is_sort_active?('category') %>"> | ||||
| 				<%= link_to t('bulletin.category') + content_tag(:b, nil, :class => is_sort?('category')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('category'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span7 <%= is_sort_active?('title') %>"> | ||||
| 				<%= link_to t('bulletin.title') + content_tag(:b, nil, :class => is_sort?('title')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('title'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span1-2 <%= is_sort_active?('postdate') %>"> | ||||
| 				<%= link_to t('bulletin.start_date') + content_tag(:b, nil, :class => is_sort?('postdate')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('postdate'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span1-2 <%= is_sort_active?('deadline') %>"> | ||||
| 				<%= link_to t('bulletin.end_date') + content_tag(:b, nil, :class => is_sort?('deadline')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('deadline'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span1-2 <%= is_sort_active?('tags') %>"> | ||||
| 				<%= link_to t('bulletin.tags') + content_tag(:b, nil, :class => is_sort?('tags')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('tags'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 			<th class="sort span1-3 <%= is_sort_active?('update_user_id') %>"> | ||||
| 				<%= link_to t('bulletin.last_modified') + content_tag(:b, nil, :class => is_sort?('update_user_id')), panel_announcement_back_end_bulletins_path({:filter => @filter}.merge(sortable('update_user_id'))), :class => 'js_history' %> | ||||
| 			</th> | ||||
| 	   </tr> | ||||
| 	</thead> | ||||
| </table> | ||||
|  | @ -1,9 +1,13 @@ | |||
| <%= form_for :bulletins, :url => delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil), :html => {:id => 'delete_bulletins'}, :remote => true do %> | ||||
| 	<%= render 'filter' %> | ||||
| 	<table id="bulettin_sort_list" class="table main-list"> | ||||
| 		<%= render 'bulletins' %> | ||||
| 	</table> | ||||
| <% end %> | ||||
| 
 | ||||
| <%= paginate @bulletins %> | ||||
| <div id="bulletin_pagination"> | ||||
| 	<%= paginate @bulletins, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %> | ||||
| </div> | ||||
| 
 | ||||
| <div id="bulletin_link_qe"> | ||||
| 	<div id="modal-link" class="modal fade"> | ||||
|  | @ -11,12 +15,6 @@ | |||
| 	</div> | ||||
| </div> | ||||
| 		 | ||||
| <div id="bulletin_file_qe"> | ||||
| 	<div id="modal-file" class="modal fade"> | ||||
| 	<%= render :partial => "bulletin_file_qe" %> | ||||
| 		</div> | ||||
| </div> | ||||
| 		 | ||||
| <div class="form-actions"> | ||||
| 	<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary' %> | ||||
| </div> | ||||
|  | @ -24,3 +22,4 @@ | |||
| <% content_for :page_specific_javascript do %> | ||||
| 	<%= javascript_include_tag "bulletin_form" %> | ||||
| <% end %> | ||||
| 
 | ||||
|  |  | |||
|  | @ -0,0 +1,7 @@ | |||
| $("#collapse-status").html("<%= j render 'filter_status' %>"); | ||||
| $("#collapse-category").html("<%= j render 'filter_categories' %>"); | ||||
| $("#collapse-tags").html("<%= j render 'filter_tags' %>"); | ||||
| $("#delete_bulletins").attr("action", "<%= delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter]) %>"); | ||||
| $("#sort_headers").html("<%= j render 'sort_headers' %>"); | ||||
| $("#tbody_bulletins").html("<%= j render :partial => 'bulletin', :collection => @bulletins %>"); | ||||
| $("#bulletin_pagination").html("<%= j paginate @bulletins, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil} %>"); | ||||
|  | @ -6,13 +6,15 @@ Rails.application.routes.draw do | |||
|         match 'fact_check_setting' => "fact_checks#setting" ,:as => :fact_checks_setting | ||||
|         match 'update_setting' => "fact_checks#update_setting" ,:as => :fact_checks_update_setting | ||||
|          | ||||
|         root :to => "bulletins#index" | ||||
|         resources :bulletins do | ||||
|           match "link_quick_add/:bulletin_id" => "bulletins#link_quick_add" ,:as => :link_quick_add | ||||
|           match "link_quick_edit/:bulletin_id" => "bulletins#link_quick_edit" ,:as => :link_quick_edit | ||||
|           member do | ||||
|             get 'load_quick_edit' | ||||
|           end | ||||
|           collection do | ||||
|             post 'delete' | ||||
|           end | ||||
|           match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add | ||||
|           match "file_quick_edit/:bulletin_id" => "bulletins#file_quick_edit" ,:as => :file_quick_edit | ||||
|         end | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue