Merge branch 'gallery_orbit' into desktop_devin

This commit is contained in:
Harry Bomrah committed 2012-11-08 17:05:49 +08:00
commit b1d808cb86
429 files changed
+11398 -7665

No files matched your search

@@ -13,9 +13,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
@bulletin.proc_check(params[:bulletin][:is_checked],params[:bulletin][:not_checked_reason])
@bulletin.de_pending
if @bulletin.save
notice = t('bulletin.approve_bulletin_success')
notice = t('announcement.approve_bulletin_success')
else
notice = t('bulletin.approve_bulletin_fail')
notice = t('announcement.approve_bulletin_fail')
end
redirect_to(panel_announcement_back_end_bulletins_url,:notice => notice)
end
@@ -40,9 +40,9 @@ class Panel::Announcement::BackEnd::ApprovalsController < OrbitBackendControlle
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t("admin.object_auth.update_done")
flash[:notice] = t('update.success_')
else
flash[:notice] = t("admin.object_auth.update_failed")
flash[:notice] = t('update.fail')
end
end
@@ -92,8 +92,8 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
respond_to do |format|
if @bulletin_category.update_attributes(params[:bulletin_category])
# format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('bulletin_category.update_bulletin_category_success')) }
# format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('bulletin_category.update_bulletin_category_success')) }
# format.html { redirect_to(panel_announcement_back_end_bulletin_category_url(@bulletin_category), :notice => t('announcement.update_bulletin_category_success')) }
# format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url, :notice => t('announcement.update_bulletin_category_success')) }
# format.xml { head :ok }
format.js
else
@@ -112,14 +112,14 @@ class Panel::Announcement::BackEnd::BulletinCategorysController < OrbitBackendCo
if @bulletin_category.save!
respond_to do |format|
flash[:notice] = t("bulletin_category.update_success")
# flash[:error] += @bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")
flash[:notice] = t("update.success_")
# flash[:error] += @bulletin_category.disable ? t(:enable) : t(disable)
format.html { redirect_to(panel_announcement_back_end_bulletin_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("bulletin_category.update_failed")
flash[:error] = t("update.fail")
format.html { render :action => "index" }
end
end
@@ -2,15 +2,25 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
include AdminHelper
include OrbitControllerLib::DivisionForDisable
before_filter :clean_values, :only => [:create, :update]
# before_filter :for_admin_only,:only => [:]
# before_filter :for_app_manager,:only => [:index,:show,]
before_filter :force_order_for_visitor,:only=>[:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :force_order_for_user,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :for_app_sub_manager,:except => [:index,:show,:get_sorted_and_filtered_bulletins]
before_filter :only => [ :new,:create,:edit,:update,:create] do |controller|
controller.get_categorys('BulletinCategory')
end
def preview
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
bulletin = Bulletin.new params
@preview_obj = bulletin.to_preview
@preview_obj.save
render '/shared/preview/preview.html.erb',:layout=>false
end
def index
# @bulletins = Bulletin.all
@@ -68,8 +78,13 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
# GET /bulletins/new
# GET /bulletins/new.xml
def new
@bulletin = Bulletin.new(:postdate => DateTime.now)
if(session[:in_validate_object].blank?)
@bulletin = Bulletin.new(:postdate => DateTime.now)
else
@bulletin = session[:in_validate_object]
session[:in_validate_object] = {}
end
@link_url = panel_announcement_back_end_bulletins_path
get_tags
respond_to do |format|
@@ -124,18 +139,30 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
@bulletin.create_user_id = current_user.id
@bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@bulletin.de_pending
@bulletin.is_checked = true
@bulletin.is_rejected = false
@bulletin.de_pending
end
respond_to do |format|
if @bulletin.save
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('bulletin.create_bulletin_success')) }
format.html { redirect_to(panel_announcement_back_end_bulletins_url, :notice => t('announcement.create_bulletin_success')) }
format.xml { render :xml => @bulletin, :status => :created, :location => @bulletin }
format.js
# format.js
format.js {
@info = {"success"=>"true","redirect_url"=>panel_announcement_back_end_bulletins_url}
flash[:notice] = t('bulletin.create_bulletin_success')
render "/shared/preview/after_create.js.erb"
}
else
format.html { render :action => "new" }
format.xml { render :xml => @bulletin.errors, :status => :unprocessable_entity }
format.js {
@info = {"success"=>"false","redirect_url"=>new_panel_announcement_back_end_bulletin_url(:bulletin => @bulletin)}
session[:in_validate_object] = @bulletin
render "/shared/preview/after_create.js.erb"
}
end
end
@@ -337,7 +364,18 @@ class Panel::Announcement::BackEnd::BulletinsController < OrbitBackendController
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)
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end
def clean_values
if params[:bulletin]
params[:bulletin][:bulletin_links_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank?
end rescue nil
params[:bulletin][:bulletin_files_attributes].each_with_index do |link, index|
params[:bulletin][:bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank?
end rescue nil
end
end
end
@@ -30,7 +30,7 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
@search = Bulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
#order_by(:average_rating)
with(:available_lang).any_of([I18n.locale.to_s])
end
search_result = @search.results.collect{|result| result.id}
@@ -78,7 +78,8 @@ class Panel::Announcement::FrontEnd::BulletinsController < OrbitWidgetController
end
def preview_content
@bulletin = Bulletin.find params[:id]
@bulletin = Bulletin.find params[:id] rescue nil
@bulletin = Preview.find(params[:id]).get_virtual_object if @bulletin.nil?
get_categorys
end
@@ -9,8 +9,8 @@ include ActionView::Helpers::UrlHelper
bulletin_category.object_auths.new(title: type ).save
oa = bulletin_category.get_object_auth_by_title(type)
end
# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa)
link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa)
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
end
end
@@ -49,4 +49,4 @@ module Panel::Announcement::BackEnd::BulletinsHelper
end
end
end
+35 -10
View File
@@ -9,11 +9,7 @@ class Bulletin
BelongsToCategory = :bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable
# include NccuSearch
#scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false)
include OrbitCoreLib::Preview
is_impressionable :counter_cache => { :column_name => :view_count }
field :title, localize: true
@@ -36,7 +32,6 @@ class Bulletin
field :is_checked, :type => Boolean, :default => false
field :is_pending, :type => Boolean, :default => true
field :is_rejected, :type => Boolean, :default => false
field :view_count, :type => Integer, :default => 0
field :not_checked_reason
@@ -62,11 +57,10 @@ class Bulletin
validates :title, :at_least_one => true
before_save :check_deadline, :update_avliable_language, :clean_tags
before_save :check_deadline, :update_avliable_language, :clean_values
before_create :update_avliable_language
before_save :fetch_dept
after_save :save_bulletin_links
after_save :save_bulletin_files
searchable do
text :titles do
@@ -75,6 +69,11 @@ class Bulletin
text :texts do
text_translations.to_a.collect{|t| Nokogiri::HTML(t[1]).text}
end
string :available_lang , :multiple => true do
VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?}
end
# text :text do
# a = (title_translations["zh_tw"] + title_translations["en"])
# a
@@ -86,6 +85,10 @@ class Bulletin
integer :view_count
string :bulletin_category_id
end
def share_item
Item.first(conditions:{name: 'announcement'})
end
def proc_check(check,not_pass_info = "")
self.is_checked = true
@@ -202,6 +205,24 @@ class Bulletin
tags.order_by(I18n.locale, :asc)
end
def to_preview
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_announcement_front_end_bulletin_path",:object_class_type=>"Bulletin")
self.bulletin["bulletin_files_attributes"].each_with_index do |atr,idx|
preview_object.preview_files.build(:file=>self.bulletin["bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_files',:file_in_array=>true)
end unless self.bulletin["bulletin_files_attributes"].nil?
self.bulletin["bulletin_links_attributes"].each_with_index do |atr,idx|
preview_object.preview_associations.build(:object=>self.bulletin["bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'bulletin_links',:object_in_array=>true)
end unless self.bulletin["bulletin_links_attributes"].nil?
preview_object.object = self.bulletin.except("bulletin_files_attributes","bulletin_links_attributes")
preview_object
end
protected
def check_deadline
@@ -224,8 +245,12 @@ class Bulletin
self.cache_dept = (User.find(self.create_user_id).cache_dept rescue nil) if self.new_record?
end
def clean_tags
def clean_values
self.bulletin_links.each do |link|
link.delete if link.url.blank? && link.title.blank?
end
self.tag_ids.delete('')
end
end
@@ -1,14 +0,0 @@
<br />
<br />
<br />
<br />
<br />
<ul class="list">
<li><%= link_to t('bulletin.announcement_list'), panel_announcement_back_end_bulletins_path if is_manager?%></li>
<li><%= link_to t('bulletin.new_announcement_class'), panel_announcement_back_end_bulletin_categorys_path if is_manager?%></li>
<li><%= link_to t('bulletin.fact_check_for_manager'), panel_announcement_back_end_fact_checks_path if is_manager?%></li>
<li><%= link_to t('bulletin.my_announcement'), panel_announcement_back_end_list_mine_path if is_sub_manager? %></li>
<li><%= link_to t('bulletin.new_announcement'), new_panel_announcement_back_end_bulletin_path if is_sub_manager? %></li>
</ul>
@@ -1,15 +0,0 @@
<h1><%= bulletin_category.key %></h1>
<table>
<tr>
<th><%= t('bulletin.status') %></th>
<th><%= t('bulletin.category') %></th>
<th><%= t('bulletin.title') %></th>
<th><%= t('bulletin.postdate') %></th>
<th><%= t('bulletin.deadline') %></th>
<th><%= t('bulletin.action') %></th>
</tr>
<% bulletin_category.bulletins.each do |post| %>
<%= render :partial => 'panel/announcement/back_end/bulletins/bulletins', :locals => {:post => post,:fact_check_allow=>false} %>
<% end %>
</table>
@@ -1,12 +0,0 @@
<% content_for :secondary do %>
<%= render :partial => '/panel/announcement/back_end/announcement_secondary' %>
<% end -%>
<%= flash_messages %>
<br />
<br />
<br />
<br />
<br />
<%= render :partial => "list_table", :collection => @bulletin_categorys ,:as => :bulletin_category%>
@@ -19,19 +19,19 @@
<div class="modal-footer">
<%= form_for bulletin, :url => panel_announcement_back_end_bulletin_approve_path(bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
<%= f.label :approval_stat, t('approval_stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('announcement.bulletin.approval_pass') %>
<%= t('approval.pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('announcement.bulletin.approval_not_pass') %>
<%= t('approval.not_pass') %>
<% end -%>
<%= label :is_checked_false, t('announcement.bulletin.approval_not_pass_reason') %>
<%= label :is_checked_false, t('approval.not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
<%= f.submit t('announcement.bulletin.submit_approval'),:class=>"btn"%>
<%= f.submit t(:submit_approval),:class=>"btn"%>
<% end %>
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
@@ -3,7 +3,7 @@
<div class="modal hide fade in" id="bulletin_category-<%=bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.approval_user_list") %></h3>
<h3><%= t("approval.user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
@@ -6,27 +6,26 @@
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("announcement.bulletin.category") %>
<%= label_tag :category, t(:category) %>
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
<%= link_to t("approval.user_list"), panel_announcement_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_announcement_back_end_approval_setting_path do %>
<%= render :partial => "layouts/users_checkbox_ary" %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
<%= submit_tag t(:update_), :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
@@ -3,7 +3,7 @@
<div class="modal hide fade in" id="bulletin_category-<%=bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.submit_user_list") %></h3>
<h3><%= t(:submit_user_list) %></h3>
</div>
<div class="modal-body">
<div class="clear">
@@ -5,8 +5,8 @@
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(bulletin_category) , panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=> "archive_toggle" %></li>
<li><%= link_to t(:edit), edit_panel_announcement_back_end_bulletin_category_path(bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(bulletin_category) , panel_announcement_back_end_bulletin_category_path(bulletin_category), :confirm => t(:sure?), :method => :delete, :remote => true,:class=> "archive_toggle" %></li>
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_anc_cate_permission_link(bulletin_category) %></li>
@@ -2,10 +2,10 @@
<%= form_for(@bulletin_category, :remote => true, :url => @url) do |f| %>
<h2><%= (@bulletin_category.new_record? ? 'Add' : 'Edit') %></h2>
<h2><%= @bulletin_category.new_record? ? t(:add) : t(:edit) %></h2>
<div id="widget-title">
<%= f.label :key %>
<%= f.label :key, t(:key) %>
<%= f.text_field :key %>
</div>
@@ -13,7 +13,7 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (@bulletin_category.title_translations[locale] rescue nil) %>
</div>
@@ -1,4 +1,4 @@
<h1><%= t('announcement.editing_announcement_class') %></h1>
<h1><%= t('announcement.editing_announcement_category') %></h1>
<%= form_for @bulletin_category, :url => panel_announcement_back_end_bulletin_category_path(@bulletin_category) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
@@ -7,7 +7,7 @@
<table class="table main-list">
<thead>
<tr>
<th class="span2"><%= t('bulletin_category.key') %></th>
<th class="span2"><%= t(:key) %></th>
<% @site_valid_locales.each do |locale| %>
<th class="span2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
@@ -10,7 +10,7 @@
<br />
<br />
<h1><%= t('bulletin_category.new_announcement_class') %></h1>
<h1><%= t('announcement.new_bulletin_category') %></h1>
<%= form_for @bulletin_category, :url => panel_announcement_back_end_bulletin_categorys_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
@@ -34,9 +34,8 @@
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if (bulletin.create_user_id == current_or_guest_user.id) || is_manager? %>
<% if current_or_guest_user.admin? || (!bulletin.is_rejected? && !bulletin.is_checked?) %>
<li><%= link_to t('bulletin.edit'), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li><%= link_to t(:edit), edit_panel_announcement_back_end_bulletin_path(bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
@@ -44,17 +43,17 @@
<li><%#= link_to t(:picture), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'tags'), :remote => true %></li>
<li><%= link_to t(:link), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'links'), :remote => true %></li>
<li><%#= link_to t(:file), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
<li><%#= link_to t(:file_), load_quick_edit_panel_announcement_back_end_bulletin_path(bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<% end %>
<% end -%>
<% if show_delete_link(bulletin) %>
<li class="dropdown"><%= link_to t('bulletin.delete'), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t('announcement.sure?'), :method => :delete, :remote => true %></li>
<li class="dropdown"><%= link_to t(:delete), panel_announcement_back_end_bulletin_path(bulletin), :confirm => t(:sure?), :method => :delete, :remote => true %></li>
<% end %>
<% if show_approval_link(bulletin) %>
<li><%= link_to t('announcement.bulletin.approval'), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<li><%= link_to t(:approval_), panel_announcement_back_end_bulletin_approval_preview_path(bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
<% if show_reject_reason(bulletin)%>
<li><%= link_to t('rejected_reason')+truncate(bulletin.not_checked_reason, :length => 10),'#',:rel=>"tooltip" ,'data-original-title'=> (wrap_string_with(bulletin.not_checked_reason, :line_width => 24)),:class=>'reject_info' %></li>
@@ -63,7 +62,7 @@
</div>
</td>
<td><%= display_date_time(bulletin.postdate) %></td>
<td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t('bulletin.no_deadline') %></td>
<td><%= (bulletin.deadline) ? display_date_time(bulletin.deadline ): t(:no_deadline) %></td>
<td>
<div class="label-group">
<div class="label-td">
@@ -1,35 +1,33 @@
<div id='filter' class="subnav">
<div id="accordion">
<ul class="nav nav-pills filter">
<li>
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("announcement.status") %> <b class="web-symbol"></b></a>
</div>
</li>
<li>
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("announcement.categories") %> <b class="web-symbol"></b></a>
</div>
</li>
<li>
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("announcement.tags") %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="accordion-group filters">
<div class="accordion-body collapse" id="collapse-status">
<%= render 'filter_status' %>
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:status) %> <b class="web-symbol"></b></a>
</div>
<div class="accordion-body collapse" id="collapse-category">
<%= render 'filter_categories' %>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:categories) %> <b class="web-symbol"></b></a>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<%= render 'filter_tags' %>
</div>
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:tags) %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="filters">
<div class="accordion-body collapse" id="collapse-status">
<%= render 'filter_status' %>
</div>
<div class="accordion-body collapse" id="collapse-category">
<%= render 'filter_categories' %>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<%= render 'filter_tags' %>
</div>
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</div>
</div>
</div>
@@ -1,5 +1,7 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "inc/modal-preview" %>
<% end -%>
<!--Widget start-->
<%= f.error_messages %>
@@ -9,16 +11,16 @@
<div class="widget-action clear">
<a href="#" class="action"><i title="Set the announcement to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar icons-white"></i> Date</h3>
<h3 class="widget-title"><i class="icons-calendar icons-white"></i><%= t('nccu.date') %></h3>
<div class="widget-content clear">
<div class="control-group">
<label class="control-label">Start</label>
<label class="control-label"><%= t(:start) %></label>
<div class="controls">
<%= f.datetime_select :postdate, {:use_month_numbers => true, :order => [:day, :month, :year] }, {:class => 'span1'} %>
</div>
</div>
<div class="control-group">
<label class="control-label">End</label>
<label class="control-label"><%= t(:end) %></label>
<div class="controls">
<%= f.datetime_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'span1'} %>
</div>
@@ -31,7 +33,7 @@
<div class="widget-action clear">
<a class="action"><i title="Setting the announcement state" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i>Status</h3>
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i><%= t(:status) %></h3>
<div class="widget-content clear">
<div class="controls">
<%= content_tag :label,:class => "checkbox inline" do -%>
@@ -55,7 +57,7 @@
<div class="widget-action clear">
<a class="action"><i title="Rejected Report" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Approval Status</h3>
<h3 class="widget-title"><i class="icons-tag icons-white"></i><%= t('approval.stat') %></h3>
<div class="widget-content clear form-horizontal">
<%= @bulletin.not_checked_reason rescue t("rejected_reason_empty") %>
</div>
@@ -65,7 +67,7 @@
<div class="widget-action clear">
<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
<h3 class="widget-title"><i class="icons-tag icons-white"></i><%= t('nccu.tags') %></h3>
<div class="widget-content clear form-horizontal">
<p>
<% @tags.each do |tag| %>
@@ -100,7 +102,7 @@
<%#= f.label :unit_list_for_anc%>
<%#= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<%= f.label :category,t('announcement.bulletin.category')%>
<%= f.label :category,t(:category)%>
<%= f.select :bulletin_category_id, @bulletin_categorys.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<ul class="nav nav-tabs">
@@ -118,7 +120,7 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :title ,t('announcement.bulletin.title')%>
<%= f.label :title ,t(:title)%>
<%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@bulletin.title_translations[locale] rescue nil) %>
@@ -127,7 +129,7 @@
<div class="editor">
<%= f.label :text ,t('announcement.bulletin.text')%>
<%= f.label :text ,t(:text)%>
<%= f.fields_for :text_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@bulletin.text_translations[locale] rescue nil) %>
@@ -145,7 +147,7 @@
<div class="widget-action clear">
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
<h3 class="widget-title"><i class="icons-link icons-white"></i><%= t(:link) %></h3>
<div class="widget-content">
<div id='bulletin_links' class="bulletin_links_block">
@@ -153,8 +155,8 @@
<table class="table table-condensed">
<thead>
<tr>
<th>URL</th>
<th>Name</th>
<th><%= t('nccu.url') %></th>
<th><%= t('nccu.link_name') %></th>
<th class="span1"></th>
</tr>
</thead>
@@ -189,7 +191,7 @@
<div class="widget-action clear">
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i><%= t('nccu.file') %></h3>
<div class="widget-content">
<div id='bulletin_files' class="bulletin_files_block">
@@ -197,9 +199,9 @@
<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>Name</th>
<th><%= t('description') %></th>
<th><%= t('nccu.selected_file') %></th>
<th><%= t('nccu.file_name') %></th>
<th><%= t('nccu.file_description') %></th>
<th class="span1"></th>
</tr>
</thead>
@@ -277,7 +279,8 @@
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= button_tag t("preview"), :id=>"button_for_preview", :name=>"commit",:class=>'btn post_preview two_btn',:type=>:button,:url=>preview_panel_announcement_back_end_bulletins_path %>
<%= f.submit t('submit'), :class=>'btn btn-primary two_btn' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
@@ -12,7 +12,7 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<%= label_tag "title-#{locale}", "#{t(:title)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (bulletin.title_translations[locale] rescue nil) %>
</div>
@@ -16,7 +16,7 @@
<br>
<% if bulletin.image.file %>
<%= f.check_box :remove_image %>
<%= t('announcement.刪除已上傳檔案') %>
<%= t(:delete_file) %>
<% end %>
</div>
</div>
@@ -1,8 +1,8 @@
<%= render_sort_bar(true, delete_panel_announcement_back_end_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'bulletin.status'],
['category', 'bulletin_category', 'span1-2', 'bulletin.category'],
['title', 'title','span7', 'bulletin.title'],
['start_date', 'postdate', 'span1-2', 'bulletin.start_date'],
['end_date', 'deadline', 'span1-2', 'bulletin.end_date'],
['tags', 'tags', 'span1-2', 'bulletin.tags'],
['last_modified', 'update_user_id','span1-3', 'bulletin.last_modified']).html_safe %>
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status],
['category', 'bulletin_category', 'span1-2', :category],
['title', 'title','span7', :title],
['start_date', 'postdate', 'span1-2', :start_date],
['end_date', 'deadline', 'span1-2', :end_date],
['tags', 'tags', 'span1-2', :tags],
['last_modified', 'update_user_id','span1-3', 'last_modified']).html_safe %>
@@ -1,10 +1,10 @@
<ul class="breadcrumb">
<!-- <ul class="breadcrumb">
<li><span>Home</span><span class="divider">/</span></li>
<li><span>Library</span><span class="divider">/</span></li>
<li class="text-blue"><%= t('announcement.editing_announcement') %></li>
</ul>
</ul> -->
<div id="poststuff">
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear'} do |f| %>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletin_path(@bulletin), :html => {:class => 'clear nccu_ajax_form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
@@ -4,7 +4,7 @@
</table>
<div class="form-actions form-fixed pagination-right">
<%= 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 pull-right' )if (is_manager? rescue nil)%>
<%= link_to(content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_announcement_back_end_bulletin_path, :class => 'btn btn-primary pull-right' )if (is_manager? rescue nil)%>
<div id="bulletin_pagination" class="paginationFixed">
<%= paginate @bulletins, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]} %>
</div>
@@ -1,5 +1,5 @@
<div id="poststuff">
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path do |f| %>
<%= form_for @bulletin, :url => panel_announcement_back_end_bulletins_path,:html=>{ :class=>"nccu_ajax_form"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
@@ -1,14 +1,14 @@
<ul>
<li>
<b><%= t('announcement.category') %></b>
<b><%= t(:category) %></b>
<%= @bulletin.bulletin_category.title rescue nil %>
</li>
<li>
<b><%= t('announcement.postdate') %></b>
<b><%= t(:postdate) %></b>
<%= display_date_time(@bulletin.postdate) %>
</li>
<li>
<b><%= t('announcement.title') %></b>
<b><%= t(:title) %></b>
<%= @bulletin.title %>
</li>
<li>
@@ -16,32 +16,32 @@
<%= link_to image_tag(@bulletin.image.url, :size => "320x240"), @bulletin.image.url, {:target => '_blank', :title => @bulletin.image_identifier} if @bulletin.image.file %>
</li>
<li>
<b><%= t('announcement.subtitle') %></b>
<b><%= t(:subtitle) %></b>
<%= @bulletin.subtitle.html_safe rescue '' %>
</li>
<li>
<b><%= t('announcement.text') %></b>
<b><%= t(:text) %></b>
<%= @bulletin.text.html_safe rescue '' %>
</li>
<li>
<li>
<b><%= t('announcement.link') %></b>
<b><%= t(:link) %></b>
<% @bulletin.bulletin_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %>
</li>
<li>
<b><%= t('announcement.file') %></b>
<b><%= t(:file) %></b>
<% @bulletin.bulletin_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %>
</li>
<li>
<b><%= t('announcement.張貼者') %></b>
<b><%= t(:posted_by) %></b>
<%= User.find(@bulletin.create_user_id).name %>
</li>
<li>
<b><%= t('announcement.最後修改時間') %></b>
<b><%= t(:last_modified) %></b>
<%= display_date(@bulletin.updated_at) %>
</li>
@@ -228,10 +228,10 @@
<table class="table table-bordered">
<tr>
<%= content_tag (:th) do %>
<%= t('announcement.bulletin.category') %>
<%= t(:category) %>
<% end if (!params[:search_query].blank? or params[:category_id].blank?)-%>
<th><%= t('announcement.bulletin.title') %></th>
<th><%= t('announcement.bulletin.postdate') %></th>
<th><%= t(:title) %></th>
<th><%= t(:postdate) %></th>
</tr>
<% if !params[:name].blank?%>
<%= t("search.unit_get",:unit_name => params[:name],:item_num=>@bulletins.count) %>
@@ -6,14 +6,15 @@ xml.rss :version => "2.0" do
else
xml.title t('announcement.announcement')
end
xml.link panel_announcement_front_end_bulletins_path(:rss)
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
for bulletin in @bulletins
xml.item do
xml.title bulletin.title_translations[I18n.locale.to_s]
xml.pubDate bulletin.postdate.to_s(:rfc822)
xml.link panel_announcement_front_end_bulletin_path(bulletin, :rss)
xml.guid panel_announcement_front_end_bulletin_path(bulletin, :rss)
xml.link url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>bulletin ,:only_path=>false)
xml.guid url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>bulletin ,:only_path=>false)
xml.fb_share generate_fb_url(bulletin, "announcement")
end
end
end
@@ -6,14 +6,13 @@ xml.rss :version => "2.0" do
else
xml.title t('announcement.announcement')
end
xml.link panel_announcement_front_end_bulletins_path(:rss)
xml.link url_for(:action=>"index", :controller=>"panel/announcement/front_end/bulletins",:format=> :rss,:only_path=>false,:inner=>true)
xml.item do
xml.title @bulletin.title
xml.description @bulletin.text
xml.pubDate @bulletin.postdate.to_s(:rfc822)
xml.link panel_announcement_front_end_bulletin_path(@bulletin, :rss)
xml.guid panel_announcement_front_end_bulletin_path(@bulletin, :rss)
xml.link url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>@bulletin ,:format=> :rss,:only_path=>false,:inner=>true)
xml.guid url_for(:action=>"show", :controller=>"panel/announcement/front_end/bulletins", :id=>@bulletin ,:only_path=>false)
end
# end
end
@@ -1 +1,53 @@
Hello~ I am your plugin profile
<%
if @user
@bulletins = Bulletin.where(:create_user_id => @user.id).page(params[:page]).per(10)
else
@bulletins = Bulletin.all.page(params[:page]).per(10)
end
%>
<table class="table main-list">
<thead>
<tr>
<th class="span1"><%= t('bulletin.category') %></th>
<th class="span3"><%= t('bulletin.title') %></th>
<th class="span1"><%= t('bulletin.start_date') %></th>
<th class="span1"><%= t('bulletin.end_date') %></th>
<th class="span1"><%= t('bulletin.tags') %></th>
<% if not @user%>
<th class="span1"><%= t('bulletin.last_modified') %></th>
<% end %>
</tr>
</thead>
<tbody id="tbody_bulletin" class="sort-holder">
<% @bulletins.each do |bulletin| %>
<tr id="<%= dom_id bulletin%>" class="with_action">
<td><%= bulletin.bulletin_category.title%></td>
<td>
<% if bulletin.is_checked? %>
<%= link_to bulletin.title, panel_announcement_front_end_bulletin_path(bulletin, :category_id => bulletin.bulletin_category.id) rescue ''%>
<% else %>
<%= bulletin.title%>
<% end %>
</td>
<td><%= display_date_time(bulletin.postdate) %></td>
<% if not bulletin.deadline.nil?%>
<td><%= display_date_time(bulletin.deadline) %></td>
<%else%>
<td><%= t('bulletin.no_deadline') %></td>
<% end %>
<td>
<div class="label-group">
<% bulletin.sorted_tags.each do |tag| %>
<span class="label label-tags"><%= tag[I18n.locale] %></span>
<% end %>
</div>
</td>
<% if not @user%>
<td><%= User.find(bulletin.create_user_id).name %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
@@ -12,7 +12,7 @@
</div>
<div class="links_block">
<h3 class="links_title"><%= t("announcement.related_links") %></h3>
<h3 class="links_title"><%= t(:related_links) %></h3>
<ul id='bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
@@ -2,7 +2,7 @@
<%= hidden_field_tag :category_id, params[:category_id] %>
<%= hidden_field_tag :tag_id, params[:tag_id] %>
<p>
<%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder=>t("announcement.search") }%>
<%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder => t("announcement.search") }%>
<%= submit_tag "Search", name: nil %>
</p>
<% end %>
@@ -1,6 +1,6 @@
<!-- <div class="search"> <input type="text" onfocus="this.value='';this.searchClickFlag=true;" onblur="if(this.value==''){this.value='公告搜尋';this.searchClickFlag=false;}" value="公告搜尋" id="q" class="search_key" name="q"/> <input type="submit" name="sa" id="sa" class="sa" value="." /> </div> -->
<div class="category_list">
<h3 class="h3"><%= t('announcement.categories') %></h3>
<h3 class="h3"><%= t(:categories) %></h3>
<ul class="list">
<% @bulletin_categorys.each do |category| %>
<li class="<%= category.id.to_s.eql?(params[:category_id]) ? 'active' : nil %>">
@@ -10,7 +10,7 @@
</ul>
</div>
<div class="tag_cloud">
<h3 class="h3"><%= t('announcement.tag_cloud') %></h3>
<h3 class="h3"><%= t(:tag_cloud) %></h3>
<div class="cloud">
<% @tags_and_class.each do |tag| %>
<%= link_to tag[0][I18n.locale], panel_announcement_front_end_bulletins_path(:tag_id => tag[0].id, :category_id => params[:category_id]), :class => "#{tag[1]} #{(tag[0].id.to_s.eql?(params[:tag_id]) || tag[0].key.eql?(params[:tag_id])) ? 'active' : nil} " %>
+12 -195
View File
@@ -1,200 +1,17 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
_locale: English
basic: Basic
picture: Piture
tags: Tag
link: Link
file: File
add: Add
back: Back
create: Create
delete: Delete
disable: Disable
downloaded: Downloaded
download: Download
edit: Edit
enable: Enable
hide: Hide
homepage: Homepage
no_: "No"
nothing: Nothing
show: Show
sure?: Are you sure?
update: Update
yes_: "Yes"
hot: Hot
top: Top
hidden: Hidden
passed: Passed
pending: Pending
rejected: Rejected
rejected_reason: 'Reason:'
rejected_reason_empty: "Approval rejected,no referencable information"
clear: Clear
hot: Hot
top: Top
hidden: Hidden
passed: Approved
pending: Pending
rejected: Rejected
clear: Clear
hot: Hot
top: Top
hidden: Hidden
passed: Approved
pending: Pending
rejected: Rejected
clear: Clear
announcement:
all_articles: List
add_new: Add
announcement: Announcement
categories: Categories
error:
no_avilb_cate_for_posting: You need a category to submit your post,please contact admin
search: Search in announcement
sure?: Sure?
campus_news: Campus News
more: more+
approve_bulletin_fail: Announcement approval failed
approve_bulletin_success: Announcement was successfully approved
bulletins: Bulletins
related_links: Related Links
bulletin:
submit_user_list: Submit User
category: Category
list_lower: " list"
title: Title
postdate: Postdate
approval: Approval
approval_setting: Approval Setting
approval_stat: Fact Check Status
approval_not_pass: 'Not Pass'
approval_not_pass_reason: 'Reason'
approval_pending: 'Pending'
approval_pass: 'Pass'
approval_setting_window_title: 'Unit'
approval_user_list: 'Approval Users'
cate_auth: Category Authorization
submit_approval: Submit approval
tag_cloud: Tag cloud
bulletin_category:
edit: Edit
delete: Delete
update_success: Bulletin Category Updated
update_failed: Bulletin Category Failed
disable_change_to_false: Toggle to archive
disable_change_to_true: Put back from archive
# admin:
# action: Action
# add_language: Add language
# admin: Admin
# action: Action
# announcement: Announcement
# asset: Asset
# attributes: Attributes
# cant_delete_self: You can not delete yourself.
# cant_revoke_self_admin: You can not revoke your admin role yourself.
# class: Class
# content: Content
# create_error_link: Error when creating link.
# create_error_page: Error when creating page.
# create_success_home: Homepage was successfully created.
# create_success_layout: Layout was successfully created.
# create_success_link: Link was successfully created.
# create_success_page: Page was successfully created.
# create_success_snippet: Snippet was successfully created.
# create_success_user: User was successfully created.
# data: Data
# delete_language: Delete language
# description: Description
# design: Design
# disable_language: Disable language
# editing_home: Editing homepage
# editing_layout: Editing layout
# editing_link: Editing link
# editing_page: Editing page
# editing_snippet: Editing snippet
# editing_user_info: Editing user information
# editing_user_role: Editing user role
# email: Email
# enable_language: Enable language
# file_name: Filename
# file_size: File size
# format: Format
# home: Home
# id: ID
# info: Information
# is_published: Is published
# item: Item
# key: Key
# language: Language
# layout: Layout
# layout_name: Layout name
# list_assets: Assets list
# list_designs: Designs list
# list_items: Items list
# list_puchases: Purchases list
# list_snippets: Snippets list
# list_users: Users list
# list_user_infos: User information list
# list_user_roles: User roles list
# member: Member
# move_down: Move down
# move_up: Move up
# multilingual: Multilingual
# my_avatar: My Avatar
# no_home_page: You don't have a homepage
# no_layout: You don't have a layout
# name: Name
# new_asset: New asset
# new_component: New component
# new_home: New homepage
# new_layout: New layout
# new_link: New link
# new_page: New page
# new_snippet: New snippet
# new_user: New user
# new_user_info: New user information
# new_user_role: New user role
# non_multilingual: Non multilingual
# options: Options
# orig_upload_file: Original filename
# position: Position
# published?: Published?
# purchase: Purchase
# registered: Registered
# role: Role
# roles: Roles
# title: Title
# translation: Translation
# type: Type
# up_to_date: Up-to-date
# update_error_link: Error when updating link.
# update_error_page: Error when updating page.
# update_success_content: Content was successfully updated.
# update_success_home: Homepage was successfully updated.
# update_success_layout: Layout was successfully updated.
# update_success_link: Link was successfully updated.
# update_success_page: Page was successfully updated.
# update_success_snippet: Snippet was successfully updated.
# update_success_user: User was successfully updated.
# url: URL
# user: User
# user_info: User information
# user_panel: User panel
# user_role: User role
panel:
create_bulletin_success: Announcement was successfully created
create_bulletin_category_success: Announcement category successfully created
editing_announcement: Editing announcememt
editing_announcement_category: Editing announcememt category
error:
no_avilb_cate_for_posting: You need a category to submit your post,please contact admin
new_bulletin_category: New announcememt category
search: Search for Announcement
update_bulletin_success: Announcement was successfully updated
update_bulletin_category_success: Announcement category was successfully updated
+12 -396
View File
@@ -1,401 +1,17 @@
zh_tw:
_locale: 中文
basic: 基礎資訊
picture: 圖片
tags: 標籤
link: 連結
file: 檔案
add: 新增
back: 回去
create: 創造
delete: 刪除
disable: 禁用
edit: 編輯
enable: 啟用
hide: 隱藏
homepage: 首頁
no_: "No"
nothing: 無
show: 顯示
sure?: 您肯定嗎?
update: 更新
yes_: "Yes"
hot: 熱門
top: 置頂
hidden: 隱藏
passed: 審核通過
pending: 待審查
rejected: 不通過
rejected_reason_empty: 審核沒有通過,沒有相關訊息
rejected_reason: '原因:'
clear: 清除
quick_edit: 快速編輯
announcement:
add_new: 新增
all_articles: 列表
announcement: 公告
error:
no_avilb_cate_for_posting: 您目前沒有分類可以刊登公告,請聯絡系統管理員為您開通分類
tags: 標籤
categories: 分類
search: 搜尋公告
status: 狀態
sure?: 確定嗎?
campus_news: 校園新聞
more: 更多+
approve_bulletin_fail: 公告審核失敗
approve_bulletin_success: 公告成功通過審核
bulletins: 公告訊息
related_links: 相關連結
bulletin:
text: 內文
category: 分類
submit_user_list: 張貼人
list_lower: 列表
title: 標題
postdate: 張貼日期
approval: 公告審核
approval_setting: 審核設定
approval_stat: 審核狀況
approval_pending: 待審核
approval_not_pass: '不通過'
approval_pass: '通過'
approval_not_pass_reason: '不通過原因'
approval_setting_window_title: '單位'
approval_user_list: '審核者'
cate_auth: '分類授權'
submit_approval: '提交審核'
tag_cloud: 標籤雲
bulletin:
last_modified: 最後修改於
tags: 標籤
end_date: 下架時間
start_date: 上架時間
category: 分類
status: 狀態
title: 標題
fact_check: 公告審核
delete: 刪除
edit: 編輯
update_bulletin_success: 成功更新公告
create_bulletin_success: 成功新增公告
approve_bulletin_success: 成功審核公告
approve_bulletin_fail: 審核公告失敗
# action: 行動
# add_language: 新增語言
# admin: 管理
# action: 行動
# announcement: 公告
# asset: 資產
# attributes: 屬性
# cant_delete_self: 您不可以刪除自己。
# cant_revoke_self_admin: 您不可以撤銷自己的管理作用。
# class: 階級
# content: 內容
# create_error_link: 創建連接時出錯。
# create_error_page: 創建頁面時出錯。
# create_success_home: 首頁已成功創建。
# create_success_layout: 樣板已成功創建。
# create_success_link: 連結已成功創建。
# create_success_page: 頁面已成功創建。
# create_success_snippet: 片段已成功創建
# create_success_user: 用戶已成功創建。。
# data: 數據
# delete_language: 刪除語言
# description: 描述
# disable_language: 禁用語言
# editing_home: 編輯首頁
# editing_layout: 編輯樣板
# editing_link: 編輯連結
# editing_page: 編輯頁面
# editing_snippet: 編輯片段
# editing_user_info: 編輯用戶資料
# editing_user_role: 編輯用戶角色
# email: Email
# enable_language: 啟用語言
# file_name: 檔名
# file_size: 檔案大小
# format: 格式
# home: 首頁
# id: ID
# info: 資料
# is_published: 被出版
# item: 項目
# key: 關鍵
# language: 語言
# layout: 佈局
# layout_name: 佈局名字
# list_assets: 資產清單
# list_items: 項目清單
# list_layouts: 佈局清單
# list_snippets: 斷片清單
# list_users: 使用清單
# list_user_infos: 用戶資料清單
# list_user_roles: 用戶角色清單
# member: 會員
# move_down: 往下移
# move_up: 往上移
# multilingual: 多種語言
# my_avatar: 我的頭像
# no_home_page: 您沒有首頁
# no_layout: 您沒有佈局
# name: 名稱
# new_asset: 新增資產
# new_component: 新增元件
# new_home: 新增首頁
# new_layout: 新增樣板
# new_link: 新增連結
# new_page: 新增頁面
# new_snippet: 新增片段
# new_user: 新增使用
# new_user_info: 新增用戶資料
# new_user_role: 新增用戶角色
# non_multilingual: 非多種語言
# options: 選項
# orig_upload_file: 原上傳檔名
# position: 位置
# published?: 發布?
# role: 角色
# roles: 角色。
# title: 標題
# translation: 翻譯
# type: 類型
# update_error_link: 更新鏈接時出現錯誤。
# update_error_page: 更新頁面時出現錯誤。
# update_success_content: 內容已成功更新。
# update_success_home: 首頁已成功更新。
# update_success_layout: 樣板已成功更新。
# update_success_link: 連結已成功更新。
# update_success_page: 頁面已成功更新。
# update_success_snippet: 片段已成功更新。
# update_success_user: 用戶已成功更新
# url: URL
# user: 用戶
# user_info: 用戶資料
# user_panel: 用戶面板
# user_role: 用戶角色
panel:
bulletin_category:
edit: 修改
delete: 刪除
update_success: 分類更新成功
update_failed: 分類更新失敗
# Chinese (Taiwan) translations for Ruby on Rails
# by tsechingho (http://github.com/tsechingho)
date:
formats:
default: "%Y-%m-%d"
short: "%b%d日"
long: "%Y年%b%d日"
day_names: [星期日, 星期一, 星期二, 星期三, 星期四, 星期五, 星期六]
abbr_day_names: [日, 一, 二, 三, 四, 五, 六]
month_names: [~, 一月, 二月, 三月, 四月, 五月, 六月, 七月, 八月, 九月, 十月, 十一月, 十二月]
abbr_month_names: [~, 1月, 2月, 3月, 4月, 5月, 6月, 7月, 8月, 9月, 10月, 11月, 12月]
order: [ :year, :month, :day ]
time:
formats:
default: "%Y年%b%d日 %A %H:%M:%S %Z"
short: "%b%d日 %H:%M"
long: "%Y年%b%d日 %H:%M"
am: "上午"
pm: "下午"
datetime:
distance_in_words:
half_a_minute: "半分鐘"
less_than_x_seconds:
one: "不到一秒"
other: "不到 %{count} 秒"
x_seconds:
one: "一秒"
other: "%{count} 秒"
less_than_x_minutes:
one: "不到一分鐘"
other: "不到 %{count} 分鐘"
x_minutes:
one: "一分鐘"
other: "%{count} 分鐘"
about_x_hours:
one: "大約一小時"
other: "大約 %{count} 小時"
x_days:
one: "一天"
other: "%{count} 天"
about_x_months:
one: "大約一個月"
other: "大約 %{count} 個月"
x_months:
one: "一個月"
other: "%{count} 個月"
about_x_years:
one: "大約一年"
other: "大約 %{count} 年"
over_x_years:
one: "一年多"
other: "%{count} 年多"
almost_x_years:
one: "接近一年"
other: "接近 %{count} 年"
prompts:
year: "年"
month: "月"
day: "日"
hour: "時"
minute: "分"
second: "秒"
number:
format:
separator: "."
delimiter: ","
precision: 3
significant: false
strip_insignificant_zeros: false
currency:
format:
format: "%u %n"
unit: "NT$"
separator: "."
delimiter: ","
precision: 2
significant: false
strip_insignificant_zeros: false
percentage:
format:
delimiter: ""
precision:
format:
delimiter: ""
human:
format:
delimiter: ""
precision: 1
significant: false
strip_insignificant_zeros: false
storage_units:
format: "%n %u"
units:
byte:
one: "Byte"
other: "Bytes"
kb: "KB"
mb: "MB"
gb: "GB"
tb: "TB"
decimal_units:
format: "%n %u"
units:
# 10^-21 zepto, 10^-24 yocto
atto: "渺" # 10^-18
femto: "飛" # 10^-15 毫微微
pico: "漠" # 10^-12 微微
nano: "奈" # 10^-9 毫微
micro: "微" # 10^-6
mili: "毫" # 10^-3 milli
centi: "厘" # 10^-2
deci: "分" # 10^-1
unit: ""
ten:
one: "十"
other: "十" # 10^1
hundred: "百" # 10^2
thousand: "千" # 10^3 kilo
million: "百萬" # 10^6 mega
billion: "十億" # 10^9 giga
trillion: "兆" # 10^12 tera
quadrillion: "千兆" # 10^15 peta
# 10^18 exa, 10^21 zetta, 10^24 yotta
support:
array:
words_connector: ", "
two_words_connector: " 和 "
last_word_connector: ", 和 "
select:
prompt: "請選擇"
activerecord:
errors:
template: # ~ 2.3.5 backward compatible
header:
one: "有 1 個錯誤發生使得「%{model}」無法被儲存。"
other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。"
body: "以下欄位發生問題:"
full_messages:
format: "%{attribute} %{message}"
messages:
inclusion: "沒有包含在列表中"
exclusion: "是被保留的關鍵字"
invalid: "是無效的"
confirmation: "不符合確認值"
accepted: "必須是可被接受的"
empty: "不能留空"
blank: "不能是空白字元"
too_long: "過長(最長是 %{count} 個字)"
too_short: "過短(最短是 %{count} 個字)"
wrong_length: "字數錯誤(必須是 %{count} 個字)"
not_a_number: "不是數字"
not_an_integer: "必須是整數"
greater_than: "必須大於 %{count}"
greater_than_or_equal_to: "必須大於或等於 %{count}"
equal_to: "必須等於 %{count}"
less_than: "必須小於 %{count}"
less_than_or_equal_to: "必須小於或等於 %{count}"
odd: "必須是奇數"
even: "必須是偶數"
taken: "已經被使用"
record_invalid: "校驗失敗: %{errors}"
activemodel:
errors:
template:
header:
one: "有 1 個錯誤發生使得「%{model}」無法被儲存。"
other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。"
body: "以下欄位發生問題:"
errors:
format: "%{attribute} %{message}"
messages:
inclusion: "沒有包含在列表中"
exclusion: "是被保留的關鍵字"
invalid: "是無效的"
confirmation: "不符合確認值"
accepted: "必須是可被接受的"
empty: "不能留空"
blank: "不能是空白字元"
too_long: "過長(最長是 %{count} 個字)"
too_short: "過短(最短是 %{count} 個字)"
wrong_length: "字數錯誤(必須是 %{count} 個字)"
not_a_number: "不是數字"
not_an_integer: "必須是整數"
greater_than: "必須大於 %{count}"
greater_than_or_equal_to: "必須大於或等於 %{count}"
equal_to: "必須等於 %{count}"
less_than: "必須小於 %{count}"
less_than_or_equal_to: "必須小於或等於 %{count}"
odd: "必須是奇數"
even: "必須是偶數"
template:
header:
one: "有 1 個錯誤發生使得「%{model}」無法被儲存。"
other: "有 %{count} 個錯誤發生使得「%{model}」無法被儲存。"
body: "以下欄位發生問題:"
helpers:
select:
prompt: "請選擇"
submit:
create: "新增%{model}"
update: "更新%{model}"
submit: "儲存%{model}"
create_bulletin_success: 公告已成功建立
create_bulletin_category_success: 公告類別已成功建立
editing_announcement: 編輯公告
editing_announcement_category: 編輯公告類別
error:
no_avilb_cate_for_posting: 公告必需有一個類別才能發送,請與管理員聯絡
new_bulletin_category: 新增公告類別
search: 搜尋公告
update_bulletin_success: 公告已成功更新
update_bulletin_category_success: 公告類別已成功更新
+2
View File
@@ -15,6 +15,8 @@ Rails.application.routes.draw do
get 'load_quick_edit'
end
collection do
post "preview"
put "preview"
get 'delete'
end
match "file_quick_add/:bulletin_id" => "bulletins#file_quick_add" ,:as => :file_quick_add
File diff suppressed because it is too large. Load diff
@@ -10,6 +10,38 @@ namespace :nccu_data do
new_unit.build_title :en => row[4], :zh_tw => row[3]
new_unit.save
end
end
task :setup_0918_announcement => :environment do
def null_or_val(str)
if str == "NULL"
return nil
else
if str.class == "String"
return str.force_encoding("utf-8")
else
return str
end
end
end
require 'csv'
Bulletin.destroy_all
to_this_category = BulletinCategory.first({conditions:{key: 'Announcement'}})
counter = 0
CSV.foreach("vendor/built_in_modules/announcement/lib/nccu_ann20120918.csv") do |row|
#bul_h1,bul_content,bul_ENh1,bul_ENcontent,bul_date,bul_deadline
data = {:title_translations=>{:zh_tw=>(null_or_val(row[0]) rescue nil),:en=>(null_or_val(row[2]) rescue nil)},
:text_translations=>{:zh_tw=>(null_or_val(row[1]) rescue nil),:en=>(null_or_val(row[3]) rescue nil)},
:postdate=>(Date.parse(row[4]) rescue nil),
:deadline=>(Date.parse(row[5]) rescue nil),
:bulletin_category_id=>to_this_category.id }
if counter >=1
Bulletin.create!(data.merge({:is_checked=> true,:is_pending=>false}))
end
counter+=1
end
Bulletin.all.each{|t| t.save}
end
end
@@ -37,7 +37,6 @@ class Panel::Archive::BackEnd::ArchiveFileCategorysController < OrbitBackendCont
# GET /archive_files/1/edit
def edit
@archive_file_category = ArchiveFileCategory.find(params[:id])
@i18n_variable = @archive_file_category.i18n_variable
@url = panel_archive_back_end_archive_file_category_path(@archive_file_category)
@@ -55,7 +55,6 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
# POST /archive_files.xml
def create
@archive_file = ArchiveFile.new(params[:archive_file])
@archive_file.create_user_id = current_user.id
@archive_file.update_user_id = current_user.id
@@ -64,6 +63,8 @@ class Panel::Archive::BackEnd::ArchiveFilesController < OrbitBackendController
format.html { redirect_to(panel_archive_back_end_archive_files_url) }
format.xml { render :xml => @archive_file, :status => :created, :location => @archive_file }
else
get_categorys
get_tags
format.html { render :action => "new" }
format.xml { render :xml => @archive_file.errors, :status => :unprocessable_entity }
end
@@ -9,7 +9,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale]
@title = @item.title
if @item.frontend_data_count
@page_num = @item.frontend_data_count
@@ -41,7 +41,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale]
@title = @item.title
@archive_file = ArchiveFile.find(params[:id])
@@ -55,7 +55,7 @@ class Panel::Archive::FrontEnd::ArchiveFilesController < OrbitWidgetController
@item = Page.find(params[:page_id])
@title = @item.i18n_variable[I18n.locale]
@title = @item.title
if @item.frontend_data_count
@page_num = @item.frontend_data_count
+1 -1
View File
@@ -26,7 +26,7 @@ class ArchiveFile
accepts_nested_attributes_for :archive_file_multiples, :allow_destroy => true
validates_presence_of :title
validates :title, :at_least_one => true
after_save :save_archive_file_multiples
@@ -7,8 +7,10 @@ class ArchiveFileCategory
field :key
has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
field :title, localize: true
has_many :archive_files
validates :title, :at_least_one => true
end
@@ -9,8 +9,6 @@ class ArchiveFileMultiple
# field :description
field :choose_lang, :type => Array, :default => nil
# has_one :i18n_variable, :as => :language_value, :autosave => true, :dependent => :destroy
field :should_destroy, :type => Boolean
def choose_lang_display(lang)
@@ -11,6 +11,6 @@
</div>
</td>
<% @site_valid_locales.each do |locale| %>
<td><%= archive_file_category.i18n_variable[locale] rescue nil %></td>
<td><%= archive_file_category.title_translations[locale] rescue nil %></td>
<% end %>
</tr>
@@ -10,12 +10,12 @@
</div>
<div id="widget-title">
<%= f.fields_for :i18n_variable, (@archive_file_category.new_record? ? @archive_file_category.build_i18n_variable : @archive_file_category.i18n_variable) do |f| %>
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge' %>
<%= f.text_field locale, :class =>' input-xxlarge', :value => (@archive_file_category.title[locale] rescue nil) %>
</div>
</div>
<% end %>
@@ -17,7 +17,7 @@
</ul>
</div>
</td>
<td><%= post.archive_file_category.i18n_variable[I18n.locale] %></td>
<td><%= post.archive_file_category.title %></td>
<td>
<%= link_to post.title, panel_archive_front_end_archive_file_path(post) %>
</td>
@@ -43,12 +43,12 @@
<div id="post-body-content" class="clear">
<%= f.label :category %>
<%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.i18n_variable[I18n.locale], t.id ]} %>
<%= f.select :archive_file_category_id, @archive_file_categorys.collect {|t| [ t.title, t.id ]} %>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<%# site_valid_locales_default_head.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
@@ -74,7 +74,7 @@
<div>
<div id='archive_file_multiples' class="archive_file_multiples_block">
<div class="archive_file_multiples_block">
<table class="table table-condensed">
<thead>
@@ -1,219 +0,0 @@
/*
* jQuery File Upload File Processing Plugin 1.0
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'load-image',
'canvas-to-blob',
'./jquery.fileupload'
], factory);
} else {
// Browser globals:
factory(
window.jQuery,
window.loadImage
);
}
}(function ($, loadImage) {
'use strict';
// The File Upload IP version extends the basic fileupload widget
// with file processing functionality:
$.widget('blueimpFP.fileupload', $.blueimp.fileupload, {
options: {
// The list of file processing actions:
process: [
/*
{
action: 'load',
fileTypes: /^image\/(gif|jpeg|png)$/,
maxFileSize: 20000000 // 20MB
},
{
action: 'resize',
maxWidth: 1920,
maxHeight: 1200,
minWidth: 800,
minHeight: 600
},
{
action: 'save'
}
*/
],
// The add callback is invoked as soon as files are added to the
// fileupload widget (via file input selection, drag & drop or add
// API call). See the basic file upload widget for more information:
add: function (e, data) {
$(this).fileupload('process', data).done(function () {
data.submit();
});
}
},
processActions: {
// Loads the image given via data.files and data.index
// as canvas element.
// Accepts the options fileTypes (regular expression)
// and maxFileSize (integer) to limit the files to load:
load: function (data, options) {
var that = this,
file = data.files[data.index],
dfd = $.Deferred();
if (window.HTMLCanvasElement &&
window.HTMLCanvasElement.prototype.toBlob &&
($.type(options.maxFileSize) !== 'number' ||
file.size < options.maxFileSize) &&
(!options.fileTypes ||
options.fileTypes.test(file.type))) {
loadImage(
file,
function (canvas) {
data.canvas = canvas;
dfd.resolveWith(that, [data]);
},
{canvas: true}
);
} else {
dfd.rejectWith(that, [data]);
}
return dfd.promise();
},
// Resizes the image given as data.canvas and updates
// data.canvas with the resized image.
// Accepts the options maxWidth, maxHeight, minWidth and
// minHeight to scale the given image:
resize: function (data, options) {
if (data.canvas) {
var canvas = loadImage.scale(data.canvas, options);
if (canvas.width !== data.canvas.width ||
canvas.height !== data.canvas.height) {
data.canvas = canvas;
data.processed = true;
}
}
return data;
},
// Saves the processed image given as data.canvas
// inplace at data.index of data.files:
save: function (data, options) {
// Do nothing if no processing has happened:
if (!data.canvas || !data.processed) {
return data;
}
var that = this,
file = data.files[data.index],
name = file.name,
dfd = $.Deferred(),
callback = function (blob) {
if (!blob.name) {
if (file.type === blob.type) {
blob.name = file.name;
} else if (file.name) {
blob.name = file.name.replace(
/\..+$/,
'.' + blob.type.substr(6)
);
}
}
// Store the created blob at the position
// of the original file in the files list:
data.files[data.index] = blob;
dfd.resolveWith(that, [data]);
};
// Use canvas.mozGetAsFile directly, to retain the filename, as
// Gecko doesn't support the filename option for FormData.append:
if (data.canvas.mozGetAsFile) {
callback(data.canvas.mozGetAsFile(
(/^image\/(jpeg|png)$/.test(file.type) && name) ||
((name && name.replace(/\..+$/, '')) ||
'blob') + '.png',
file.type
));
} else {
data.canvas.toBlob(callback, file.type);
}
return dfd.promise();
}
},
// Resizes the file at the given index and stores the created blob at
// the original position of the files list, returns a Promise object:
_processFile: function (files, index, options) {
var that = this,
dfd = $.Deferred().resolveWith(that, [{
files: files,
index: index
}]),
chain = dfd.promise();
that._processing += 1;
$.each(options.process, function (i, settings) {
chain = chain.pipe(function (data) {
return that.processActions[settings.action]
.call(this, data, settings);
});
});
chain.always(function () {
that._processing -= 1;
if (that._processing === 0) {
that.element
.removeClass('fileupload-processing');
}
});
if (that._processing === 1) {
that.element.addClass('fileupload-processing');
}
return chain;
},
// Processes the files given as files property of the data parameter,
// returns a Promise object that allows to bind a done handler, which
// will be invoked after processing all files (inplace) is done:
process: function (data) {
var that = this,
options = $.extend({}, this.options, data);
if (options.process && options.process.length &&
this._isXHRUpload(options)) {
$.each(data.files, function (index, file) {
that._processingQueue = that._processingQueue.pipe(
function () {
var dfd = $.Deferred();
that._processFile(data.files, index, options)
.always(function () {
dfd.resolveWith(that);
});
return dfd.promise();
}
);
});
}
return this._processingQueue;
},
_create: function () {
$.blueimp.fileupload.prototype._create.call(this);
this._processing = 0;
this._processingQueue = $.Deferred().resolveWith(this)
.promise();
}
});
}));
@@ -1,736 +0,0 @@
/*
* jQuery File Upload User Interface Plugin 6.9.4
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window, document, URL, webkitURL, FileReader */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'tmpl',
'load-image',
'./jquery.fileupload-fp'
], factory);
} else {
// Browser globals:
factory(
window.jQuery,
window.tmpl,
window.loadImage
);
}
}(function ($, tmpl, loadImage) {
'use strict';
// The UI version extends the FP (file processing) version or the basic
// file upload widget and adds complete user interface interaction:
var parentWidget = ($.blueimpFP || $.blueimp).fileupload;
$.widget('blueimpUI.fileupload', parentWidget, {
options: {
// By default, files added to the widget are uploaded as soon
// as the user clicks on the start buttons. To enable automatic
// uploads, set the following option to true:
autoUpload: false,
// The following option limits the number of files that are
// allowed to be uploaded using this widget:
maxNumberOfFiles: undefined,
// The maximum allowed file size:
maxFileSize: undefined,
// The minimum allowed file size:
minFileSize: undefined,
// The regular expression for allowed file types, matches
// against either file type or file name:
acceptFileTypes: /.+$/i,
// The regular expression to define for which files a preview
// image is shown, matched against the file type:
previewSourceFileTypes: /^image\/(gif|jpeg|png)$/,
// The maximum file size of images that are to be displayed as preview:
previewSourceMaxFileSize: 5000000, // 5MB
// The maximum width of the preview images:
previewMaxWidth: 80,
// The maximum height of the preview images:
previewMaxHeight: 80,
// By default, preview images are displayed as canvas elements
// if supported by the browser. Set the following option to false
// to always display preview images as img elements:
previewAsCanvas: true,
// The ID of the upload template:
uploadTemplateId: 'template-upload',
// The ID of the download template:
downloadTemplateId: 'template-download',
// The container for the list of files. If undefined, it is set to
// an element with class "files" inside of the widget element:
filesContainer: undefined,
// By default, files are appended to the files container.
// Set the following option to true, to prepend files instead:
prependFiles: false,
// The expected data type of the upload response, sets the dataType
// option of the $.ajax upload requests:
dataType: 'json',
// The add callback is invoked as soon as files are added to the fileupload
// widget (via file input selection, drag & drop or add API call).
// See the basic file upload widget for more information:
add: function (e, data) {
var that = $(this).data('fileupload'),
options = that.options,
files = data.files;
$(this).fileupload('process', data).done(function () {
that._adjustMaxNumberOfFiles(-files.length);
data.maxNumberOfFilesAdjusted = true;
data.files.valid = data.isValidated = that._validate(files);
data.context = that._renderUpload(files).data('data', data);
options.filesContainer[
options.prependFiles ? 'prepend' : 'append'
](data.context);
that._renderPreviews(files, data.context);
that._forceReflow(data.context);
that._transition(data.context).done(
function () {
if ((that._trigger('added', e, data) !== false) &&
(options.autoUpload || data.autoUpload) &&
data.autoUpload !== false && data.isValidated) {
data.submit();
}
}
);
});
},
// Callback for the start of each file upload request:
send: function (e, data) {
var that = $(this).data('fileupload');
if (!data.isValidated) {
if (!data.maxNumberOfFilesAdjusted) {
that._adjustMaxNumberOfFiles(-data.files.length);
data.maxNumberOfFilesAdjusted = true;
}
if (!that._validate(data.files)) {
return false;
}
}
if (data.context && data.dataType &&
data.dataType.substr(0, 6) === 'iframe') {
// Iframe Transport does not support progress events.
// In lack of an indeterminate progress bar, we set
// the progress to 100%, showing the full animated bar:
data.context
.find('.progress').addClass(
!$.support.transition && 'progress-animated'
)
.attr('aria-valuenow', 100)
.find('.bar').css(
'width',
'100%'
);
}
return that._trigger('sent', e, data);
},
// Callback for successful uploads:
done: function (e, data) {
var that = $(this).data('fileupload'),
template;
if (data.context) {
data.context.each(function (index) {
var file = ($.isArray(data.result) &&
data.result[index]) || {error: 'emptyResult'};
if (file.error) {
that._adjustMaxNumberOfFiles(1);
}
that._transition($(this)).done(
function () {
var node = $(this);
template = that._renderDownload([file])
.replaceAll(node);
that._forceReflow(template);
that._transition(template).done(
function () {
data.context = $(this);
that._trigger('completed', e, data);
}
);
}
);
});
} else {
if ($.isArray(data.result)) {
$.each(data.result, function (index, file) {
if (data.maxNumberOfFilesAdjusted && file.error) {
that._adjustMaxNumberOfFiles(1);
} else if (!data.maxNumberOfFilesAdjusted &&
!file.error) {
that._adjustMaxNumberOfFiles(-1);
}
});
data.maxNumberOfFilesAdjusted = true;
}
template = that._renderDownload(data.result)
.appendTo(that.options.filesContainer);
that._forceReflow(template);
that._transition(template).done(
function () {
data.context = $(this);
that._trigger('completed', e, data);
}
);
}
},
// Callback for failed (abort or error) uploads:
fail: function (e, data) {
var that = $(this).data('fileupload'),
template;
if (data.maxNumberOfFilesAdjusted) {
that._adjustMaxNumberOfFiles(data.files.length);
}
if (data.context) {
data.context.each(function (index) {
if (data.errorThrown !== 'abort') {
var file = data.files[index];
file.error = file.error || data.errorThrown ||
true;
that._transition($(this)).done(
function () {
var node = $(this);
template = that._renderDownload([file])
.replaceAll(node);
that._forceReflow(template);
that._transition(template).done(
function () {
data.context = $(this);
that._trigger('failed', e, data);
}
);
}
);
} else {
that._transition($(this)).done(
function () {
$(this).remove();
that._trigger('failed', e, data);
}
);
}
});
} else if (data.errorThrown !== 'abort') {
data.context = that._renderUpload(data.files)
.appendTo(that.options.filesContainer)
.data('data', data);
that._forceReflow(data.context);
that._transition(data.context).done(
function () {
data.context = $(this);
that._trigger('failed', e, data);
}
);
} else {
that._trigger('failed', e, data);
}
},
// Callback for upload progress events:
progress: function (e, data) {
if (data.context) {
var progress = parseInt(data.loaded / data.total * 100, 10);
data.context.find('.progress')
.attr('aria-valuenow', progress)
.find('.bar').css(
'width',
progress + '%'
);
}
},
// Callback for global upload progress events:
progressall: function (e, data) {
var $this = $(this),
progress = parseInt(data.loaded / data.total * 100, 10),
globalProgressNode = $this.find('.fileupload-progress'),
extendedProgressNode = globalProgressNode
.find('.progress-extended');
if (extendedProgressNode.length) {
extendedProgressNode.html(
$this.data('fileupload')._renderExtendedProgress(data)
);
}
globalProgressNode
.find('.progress')
.attr('aria-valuenow', progress)
.find('.bar').css(
'width',
progress + '%'
);
},
// Callback for uploads start, equivalent to the global ajaxStart event:
start: function (e) {
var that = $(this).data('fileupload');
that._transition($(this).find('.fileupload-progress')).done(
function () {
that._trigger('started', e);
}
);
},
// Callback for uploads stop, equivalent to the global ajaxStop event:
stop: function (e) {
var that = $(this).data('fileupload');
that._transition($(this).find('.fileupload-progress')).done(
function () {
$(this).find('.progress')
.attr('aria-valuenow', '0')
.find('.bar').css('width', '0%');
$(this).find('.progress-extended').html('&nbsp;');
that._trigger('stopped', e);
}
);
},
// Callback for file deletion:
destroy: function (e, data) {
var that = $(this).data('fileupload');
if (data.url) {
$.ajax(data);
that._adjustMaxNumberOfFiles(1);
}
that._transition(data.context).done(
function () {
$(this).remove();
that._trigger('destroyed', e, data);
}
);
}
},
// Link handler, that allows to download files
// by drag & drop of the links to the desktop:
_enableDragToDesktop: function () {
var link = $(this),
url = link.prop('href'),
name = link.prop('download'),
type = 'application/octet-stream';
link.bind('dragstart', function (e) {
try {
e.originalEvent.dataTransfer.setData(
'DownloadURL',
[type, name, url].join(':')
);
} catch (err) {}
});
},
_adjustMaxNumberOfFiles: function (operand) {
if (typeof this.options.maxNumberOfFiles === 'number') {
this.options.maxNumberOfFiles += operand;
if (this.options.maxNumberOfFiles < 1) {
this._disableFileInputButton();
} else {
this._enableFileInputButton();
}
}
},
_formatFileSize: function (bytes) {
if (typeof bytes !== 'number') {
return '';
}
if (bytes >= 1000000000) {
return (bytes / 1000000000).toFixed(2) + ' GB';
}
if (bytes >= 1000000) {
return (bytes / 1000000).toFixed(2) + ' MB';
}
return (bytes / 1000).toFixed(2) + ' KB';
},
_formatBitrate: function (bits) {
if (typeof bits !== 'number') {
return '';
}
if (bits >= 1000000000) {
return (bits / 1000000000).toFixed(2) + ' Gbit/s';
}
if (bits >= 1000000) {
return (bits / 1000000).toFixed(2) + ' Mbit/s';
}
if (bits >= 1000) {
return (bits / 1000).toFixed(2) + ' kbit/s';
}
return bits + ' bit/s';
},
_formatTime: function (seconds) {
var date = new Date(seconds * 1000),
days = parseInt(seconds / 86400, 10);
days = days ? days + 'd ' : '';
return days +
('0' + date.getUTCHours()).slice(-2) + ':' +
('0' + date.getUTCMinutes()).slice(-2) + ':' +
('0' + date.getUTCSeconds()).slice(-2);
},
_formatPercentage: function (floatValue) {
return (floatValue * 100).toFixed(2) + ' %';
},
_renderExtendedProgress: function (data) {
return this._formatBitrate(data.bitrate) + ' | ' +
this._formatTime(
(data.total - data.loaded) * 8 / data.bitrate
) + ' | ' +
this._formatPercentage(
data.loaded / data.total
) + ' | ' +
this._formatFileSize(data.loaded) + ' / ' +
this._formatFileSize(data.total);
},
_hasError: function (file) {
if (file.error) {
return file.error;
}
// The number of added files is subtracted from
// maxNumberOfFiles before validation, so we check if
// maxNumberOfFiles is below 0 (instead of below 1):
if (this.options.maxNumberOfFiles < 0) {
return 'maxNumberOfFiles';
}
// Files are accepted if either the file type or the file name
// matches against the acceptFileTypes regular expression, as
// only browsers with support for the File API report the type:
if (!(this.options.acceptFileTypes.test(file.type) ||
this.options.acceptFileTypes.test(file.name))) {
return 'acceptFileTypes';
}
if (this.options.maxFileSize &&
file.size > this.options.maxFileSize) {
return 'maxFileSize';
}
if (typeof file.size === 'number' &&
file.size < this.options.minFileSize) {
return 'minFileSize';
}
return null;
},
_validate: function (files) {
var that = this,
valid = !!files.length;
$.each(files, function (index, file) {
file.error = that._hasError(file);
if (file.error) {
valid = false;
}
});
return valid;
},
_renderTemplate: function (func, files) {
if (!func) {
return $();
}
var result = func({
files: files,
formatFileSize: this._formatFileSize,
options: this.options
});
if (result instanceof $) {
return result;
}
return $(this.options.templatesContainer).html(result).children();
},
_renderPreview: function (file, node) {
var that = this,
options = this.options,
dfd = $.Deferred();
return ((loadImage && loadImage(
file,
function (img) {
node.append(img);
that._forceReflow(node);
that._transition(node).done(function () {
dfd.resolveWith(node);
});
if (!$.contains(document.body, node[0])) {
// If the element is not part of the DOM,
// transition events are not triggered,
// so we have to resolve manually:
dfd.resolveWith(node);
}
},
{
maxWidth: options.previewMaxWidth,
maxHeight: options.previewMaxHeight,
canvas: options.previewAsCanvas
}
)) || dfd.resolveWith(node)) && dfd;
},
_renderPreviews: function (files, nodes) {
var that = this,
options = this.options;
nodes.find('.preview span').each(function (index, element) {
var file = files[index];
if (options.previewSourceFileTypes.test(file.type) &&
($.type(options.previewSourceMaxFileSize) !== 'number' ||
file.size < options.previewSourceMaxFileSize)) {
that._processingQueue = that._processingQueue.pipe(function () {
var dfd = $.Deferred();
that._renderPreview(file, $(element)).done(
function () {
dfd.resolveWith(that);
}
);
return dfd.promise();
});
}
});
return this._processingQueue;
},
_renderUpload: function (files) {
return this._renderTemplate(
this.options.uploadTemplate,
files
);
},
_renderDownload: function (files) {
return this._renderTemplate(
this.options.downloadTemplate,
files
).find('a[download]').each(this._enableDragToDesktop).end();
},
_startHandler: function (e) {
e.preventDefault();
var button = $(this),
template = button.closest('.template-upload'),
data = template.data('data');
if (data && data.submit && !data.jqXHR && data.submit()) {
button.prop('disabled', true);
}
},
_cancelHandler: function (e) {
e.preventDefault();
var template = $(this).closest('.template-upload'),
data = template.data('data') || {};
if (!data.jqXHR) {
data.errorThrown = 'abort';
e.data.fileupload._trigger('fail', e, data);
} else {
data.jqXHR.abort();
}
},
_deleteHandler: function (e) {
e.preventDefault();
var button = $(this);
e.data.fileupload._trigger('destroy', e, {
context: button.closest('.template-download'),
url: button.attr('data-url'),
type: button.attr('data-type') || 'DELETE',
dataType: e.data.fileupload.options.dataType
});
},
_forceReflow: function (node) {
return $.support.transition && node.length &&
node[0].offsetWidth;
},
_transition: function (node) {
var dfd = $.Deferred();
if ($.support.transition && node.hasClass('fade')) {
node.bind(
$.support.transition.end,
function (e) {
// Make sure we don't respond to other transitions events
// in the container element, e.g. from button elements:
if (e.target === node[0]) {
node.unbind($.support.transition.end);
dfd.resolveWith(node);
}
}
).toggleClass('in');
} else {
node.toggleClass('in');
dfd.resolveWith(node);
}
return dfd;
},
_initButtonBarEventHandlers: function () {
var fileUploadButtonBar = this.element.find('.fileupload-buttonbar'),
filesList = this.options.filesContainer,
ns = this.options.namespace;
fileUploadButtonBar.find('.start')
.bind('click.' + ns, function (e) {
e.preventDefault();
filesList.find('.start button').click();
});
fileUploadButtonBar.find('.cancel')
.bind('click.' + ns, function (e) {
e.preventDefault();
filesList.find('.cancel button').click();
});
fileUploadButtonBar.find('.delete')
.bind('click.' + ns, function (e) {
e.preventDefault();
filesList.find('.delete input:checked')
.siblings('button').click();
fileUploadButtonBar.find('.toggle')
.prop('checked', false);
});
fileUploadButtonBar.find('.toggle')
.bind('change.' + ns, function (e) {
filesList.find('.delete input').prop(
'checked',
$(this).is(':checked')
);
});
},
_destroyButtonBarEventHandlers: function () {
this.element.find('.fileupload-buttonbar button')
.unbind('click.' + this.options.namespace);
this.element.find('.fileupload-buttonbar .toggle')
.unbind('change.' + this.options.namespace);
},
_initEventHandlers: function () {
parentWidget.prototype._initEventHandlers.call(this);
var eventData = {fileupload: this};
this.options.filesContainer
.delegate(
'.start button',
'click.' + this.options.namespace,
eventData,
this._startHandler
)
.delegate(
'.cancel button',
'click.' + this.options.namespace,
eventData,
this._cancelHandler
)
.delegate(
'.delete button',
'click.' + this.options.namespace,
eventData,
this._deleteHandler
);
this._initButtonBarEventHandlers();
},
_destroyEventHandlers: function () {
var options = this.options;
this._destroyButtonBarEventHandlers();
options.filesContainer
.undelegate('.start button', 'click.' + options.namespace)
.undelegate('.cancel button', 'click.' + options.namespace)
.undelegate('.delete button', 'click.' + options.namespace);
parentWidget.prototype._destroyEventHandlers.call(this);
},
_enableFileInputButton: function () {
this.element.find('.fileinput-button input')
.prop('disabled', false)
.parent().removeClass('disabled');
},
_disableFileInputButton: function () {
this.element.find('.fileinput-button input')
.prop('disabled', true)
.parent().addClass('disabled');
},
_initTemplates: function () {
var options = this.options;
options.templatesContainer = document.createElement(
options.filesContainer.prop('nodeName')
);
if (tmpl) {
if (options.uploadTemplateId) {
options.uploadTemplate = tmpl(options.uploadTemplateId);
}
if (options.downloadTemplateId) {
options.downloadTemplate = tmpl(options.downloadTemplateId);
}
}
},
_initFilesContainer: function () {
var options = this.options;
if (options.filesContainer === undefined) {
options.filesContainer = this.element.find('.files');
} else if (!(options.filesContainer instanceof $)) {
options.filesContainer = $(options.filesContainer);
}
},
_stringToRegExp: function (str) {
var parts = str.split('/'),
modifiers = parts.pop();
parts.shift();
return new RegExp(parts.join('/'), modifiers);
},
_initRegExpOptions: function () {
var options = this.options;
if ($.type(options.acceptFileTypes) === 'string') {
options.acceptFileTypes = this._stringToRegExp(
options.acceptFileTypes
);
}
if ($.type(options.previewSourceFileTypes) === 'string') {
options.previewSourceFileTypes = this._stringToRegExp(
options.previewSourceFileTypes
);
}
},
_initSpecialOptions: function () {
parentWidget.prototype._initSpecialOptions.call(this);
this._initFilesContainer();
this._initTemplates();
this._initRegExpOptions();
},
_create: function () {
parentWidget.prototype._create.call(this);
this._refreshOptionsList.push(
'filesContainer',
'uploadTemplateId',
'downloadTemplateId'
);
if (!$.blueimpFP) {
this._processingQueue = $.Deferred().resolveWith(this).promise();
this.process = function () {
return this._processingQueue;
};
}
},
enable: function () {
parentWidget.prototype.enable.call(this);
this.element.find('input, button').prop('disabled', false);
this._enableFileInputButton();
},
disable: function () {
this.element.find('input, button').prop('disabled', true);
this._disableFileInputButton();
parentWidget.prototype.disable.call(this);
}
});
}));
@@ -1,975 +0,0 @@
/*
* jQuery File Upload Plugin 5.14
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global define, window, document, Blob, FormData, location */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define([
'jquery',
'jquery.ui.widget'
], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// The FileReader API is not actually used, but works as feature detection,
// as e.g. Safari supports XHR file uploads via the FormData API,
// but not non-multipart XHR file uploads:
$.support.xhrFileUpload = !!(window.XMLHttpRequestUpload && window.FileReader);
$.support.xhrFormDataFileUpload = !!window.FormData;
// The fileupload widget listens for change events on file input fields defined
// via fileInput setting and paste or drop events of the given dropZone.
// In addition to the default jQuery Widget methods, the fileupload widget
// exposes the "add" and "send" methods, to add or directly send files using
// the fileupload API.
// By default, files added via file input selection, paste, drag & drop or
// "add" method are uploaded immediately, but it is possible to override
// the "add" callback option to queue file uploads.
$.widget('blueimp.fileupload', {
options: {
// The namespace used for event handler binding on the dropZone and
// fileInput collections.
// If not set, the name of the widget ("fileupload") is used.
namespace: undefined,
// The drop target collection, by the default the complete document.
// Set to null or an empty collection to disable drag & drop support:
dropZone: $(document),
// The file input field collection, that is listened for change events.
// If undefined, it is set to the file input fields inside
// of the widget element on plugin initialization.
// Set to null or an empty collection to disable the change listener.
fileInput: undefined,
// By default, the file input field is replaced with a clone after
// each input field change event. This is required for iframe transport
// queues and allows change events to be fired for the same file
// selection, but can be disabled by setting the following option to false:
replaceFileInput: true,
// The parameter name for the file form data (the request argument name).
// If undefined or empty, the name property of the file input field is
// used, or "files[]" if the file input name property is also empty,
// can be a string or an array of strings:
paramName: undefined,
// By default, each file of a selection is uploaded using an individual
// request for XHR type uploads. Set to false to upload file
// selections in one request each:
singleFileUploads: true,
// To limit the number of files uploaded with one XHR request,
// set the following option to an integer greater than 0:
limitMultiFileUploads: undefined,
// Set the following option to true to issue all file upload requests
// in a sequential order:
sequentialUploads: false,
// To limit the number of concurrent uploads,
// set the following option to an integer greater than 0:
limitConcurrentUploads: undefined,
// Set the following option to true to force iframe transport uploads:
forceIframeTransport: false,
// Set the following option to the location of a redirect url on the
// origin server, for cross-domain iframe transport uploads:
redirect: undefined,
// The parameter name for the redirect url, sent as part of the form
// data and set to 'redirect' if this option is empty:
redirectParamName: undefined,
// Set the following option to the location of a postMessage window,
// to enable postMessage transport uploads:
postMessage: undefined,
// By default, XHR file uploads are sent as multipart/form-data.
// The iframe transport is always using multipart/form-data.
// Set to false to enable non-multipart XHR uploads:
multipart: true,
// To upload large files in smaller chunks, set the following option
// to a preferred maximum chunk size. If set to 0, null or undefined,
// or the browser does not support the required Blob API, files will
// be uploaded as a whole.
maxChunkSize: undefined,
// When a non-multipart upload or a chunked multipart upload has been
// aborted, this option can be used to resume the upload by setting
// it to the size of the already uploaded bytes. This option is most
// useful when modifying the options object inside of the "add" or
// "send" callbacks, as the options are cloned for each file upload.
uploadedBytes: undefined,
// By default, failed (abort or error) file uploads are removed from the
// global progress calculation. Set the following option to false to
// prevent recalculating the global progress data:
recalculateProgress: true,
// Interval in milliseconds to calculate and trigger progress events:
progressInterval: 100,
// Interval in milliseconds to calculate progress bitrate:
bitrateInterval: 500,
// Additional form data to be sent along with the file uploads can be set
// using this option, which accepts an array of objects with name and
// value properties, a function returning such an array, a FormData
// object (for XHR file uploads), or a simple object.
// The form of the first fileInput is given as parameter to the function:
formData: function (form) {
return form.serializeArray();
},
// The add callback is invoked as soon as files are added to the fileupload
// widget (via file input selection, drag & drop, paste or add API call).
// If the singleFileUploads option is enabled, this callback will be
// called once for each file in the selection for XHR file uplaods, else
// once for each file selection.
// The upload starts when the submit method is invoked on the data parameter.
// The data object contains a files property holding the added files
// and allows to override plugin options as well as define ajax settings.
// Listeners for this callback can also be bound the following way:
// .bind('fileuploadadd', func);
// data.submit() returns a Promise object and allows to attach additional
// handlers using jQuery's Deferred callbacks:
// data.submit().done(func).fail(func).always(func);
add: function (e, data) {
data.submit();
},
// Other callbacks:
// Callback for the submit event of each file upload:
// submit: function (e, data) {}, // .bind('fileuploadsubmit', func);
// Callback for the start of each file upload request:
// send: function (e, data) {}, // .bind('fileuploadsend', func);
// Callback for successful uploads:
// done: function (e, data) {}, // .bind('fileuploaddone', func);
// Callback for failed (abort or error) uploads:
// fail: function (e, data) {}, // .bind('fileuploadfail', func);
// Callback for completed (success, abort or error) requests:
// always: function (e, data) {}, // .bind('fileuploadalways', func);
// Callback for upload progress events:
// progress: function (e, data) {}, // .bind('fileuploadprogress', func);
// Callback for global upload progress events:
// progressall: function (e, data) {}, // .bind('fileuploadprogressall', func);
// Callback for uploads start, equivalent to the global ajaxStart event:
// start: function (e) {}, // .bind('fileuploadstart', func);
// Callback for uploads stop, equivalent to the global ajaxStop event:
// stop: function (e) {}, // .bind('fileuploadstop', func);
// Callback for change events of the fileInput collection:
// change: function (e, data) {}, // .bind('fileuploadchange', func);
// Callback for paste events to the dropZone collection:
// paste: function (e, data) {}, // .bind('fileuploadpaste', func);
// Callback for drop events of the dropZone collection:
// drop: function (e, data) {}, // .bind('fileuploaddrop', func);
// Callback for dragover events of the dropZone collection:
// dragover: function (e) {}, // .bind('fileuploaddragover', func);
// The plugin options are used as settings object for the ajax calls.
// The following are jQuery ajax settings required for the file uploads:
processData: false,
contentType: false,
cache: false
},
// A list of options that require a refresh after assigning a new value:
_refreshOptionsList: [
'namespace',
'dropZone',
'fileInput',
'multipart',
'forceIframeTransport'
],
_BitrateTimer: function () {
this.timestamp = +(new Date());
this.loaded = 0;
this.bitrate = 0;
this.getBitrate = function (now, loaded, interval) {
var timeDiff = now - this.timestamp;
if (!this.bitrate || !interval || timeDiff > interval) {
this.bitrate = (loaded - this.loaded) * (1000 / timeDiff) * 8;
this.loaded = loaded;
this.timestamp = now;
}
return this.bitrate;
};
},
_isXHRUpload: function (options) {
return !options.forceIframeTransport &&
((!options.multipart && $.support.xhrFileUpload) ||
$.support.xhrFormDataFileUpload);
},
_getFormData: function (options) {
var formData;
if (typeof options.formData === 'function') {
return options.formData(options.form);
}
if ($.isArray(options.formData)) {
return options.formData;
}
if (options.formData) {
formData = [];
$.each(options.formData, function (name, value) {
formData.push({name: name, value: value});
});
return formData;
}
return [];
},
_getTotal: function (files) {
var total = 0;
$.each(files, function (index, file) {
total += file.size || 1;
});
return total;
},
_onProgress: function (e, data) {
if (e.lengthComputable) {
var now = +(new Date()),
total,
loaded;
if (data._time && data.progressInterval &&
(now - data._time < data.progressInterval) &&
e.loaded !== e.total) {
return;
}
data._time = now;
total = data.total || this._getTotal(data.files);
loaded = parseInt(
e.loaded / e.total * (data.chunkSize || total),
10
) + (data.uploadedBytes || 0);
this._loaded += loaded - (data.loaded || data.uploadedBytes || 0);
data.lengthComputable = true;
data.loaded = loaded;
data.total = total;
data.bitrate = data._bitrateTimer.getBitrate(
now,
loaded,
data.bitrateInterval
);
// Trigger a custom progress event with a total data property set
// to the file size(s) of the current upload and a loaded data
// property calculated accordingly:
this._trigger('progress', e, data);
// Trigger a global progress event for all current file uploads,
// including ajax calls queued for sequential file uploads:
this._trigger('progressall', e, {
lengthComputable: true,
loaded: this._loaded,
total: this._total,
bitrate: this._bitrateTimer.getBitrate(
now,
this._loaded,
data.bitrateInterval
)
});
}
},
_initProgressListener: function (options) {
var that = this,
xhr = options.xhr ? options.xhr() : $.ajaxSettings.xhr();
// Accesss to the native XHR object is required to add event listeners
// for the upload progress event:
if (xhr.upload) {
$(xhr.upload).bind('progress', function (e) {
var oe = e.originalEvent;
// Make sure the progress event properties get copied over:
e.lengthComputable = oe.lengthComputable;
e.loaded = oe.loaded;
e.total = oe.total;
that._onProgress(e, options);
});
options.xhr = function () {
return xhr;
};
}
},
_initXHRData: function (options) {
var formData,
file = options.files[0],
// Ignore non-multipart setting if not supported:
multipart = options.multipart || !$.support.xhrFileUpload,
paramName = options.paramName[0];
if (!multipart || options.blob) {
// For non-multipart uploads and chunked uploads,
// file meta data is not part of the request body,
// so we transmit this data as part of the HTTP headers.
// For cross domain requests, these headers must be allowed
// via Access-Control-Allow-Headers or removed using
// the beforeSend callback:
options.headers = $.extend(options.headers, {
'X-File-Name': file.name,
'X-File-Type': file.type,
'X-File-Size': file.size
});
if (!options.blob) {
// Non-chunked non-multipart upload:
options.contentType = file.type;
options.data = file;
} else if (!multipart) {
// Chunked non-multipart upload:
options.contentType = 'application/octet-stream';
options.data = options.blob;
}
}
if (multipart && $.support.xhrFormDataFileUpload) {
if (options.postMessage) {
// window.postMessage does not allow sending FormData
// objects, so we just add the File/Blob objects to
// the formData array and let the postMessage window
// create the FormData object out of this array:
formData = this._getFormData(options);
if (options.blob) {
formData.push({
name: paramName,
value: options.blob
});
} else {
$.each(options.files, function (index, file) {
formData.push({
name: options.paramName[index] || paramName,
value: file
});
});
}
} else {
if (options.formData instanceof FormData) {
formData = options.formData;
} else {
formData = new FormData();
$.each(this._getFormData(options), function (index, field) {
formData.append(field.name, field.value);
});
}
if (options.blob) {
formData.append(paramName, options.blob, file.name);
} else {
$.each(options.files, function (index, file) {
// File objects are also Blob instances.
// This check allows the tests to run with
// dummy objects:
if (file instanceof Blob) {
formData.append(
options.paramName[index] || paramName,
file,
file.name
);
}
});
}
}
options.data = formData;
}
// Blob reference is not needed anymore, free memory:
options.blob = null;
},
_initIframeSettings: function (options) {
// Setting the dataType to iframe enables the iframe transport:
options.dataType = 'iframe ' + (options.dataType || '');
// The iframe transport accepts a serialized array as form data:
options.formData = this._getFormData(options);
// Add redirect url to form data on cross-domain uploads:
if (options.redirect && $('<a></a>').prop('href', options.url)
.prop('host') !== location.host) {
options.formData.push({
name: options.redirectParamName || 'redirect',
value: options.redirect
});
}
},
_initDataSettings: function (options) {
if (this._isXHRUpload(options)) {
if (!this._chunkedUpload(options, true)) {
if (!options.data) {
this._initXHRData(options);
}
this._initProgressListener(options);
}
if (options.postMessage) {
// Setting the dataType to postmessage enables the
// postMessage transport:
options.dataType = 'postmessage ' + (options.dataType || '');
}
} else {
this._initIframeSettings(options, 'iframe');
}
},
_getParamName: function (options) {
var fileInput = $(options.fileInput),
paramName = options.paramName;
if (!paramName) {
paramName = [];
fileInput.each(function () {
var input = $(this),
name = input.prop('name') || 'files[]',
i = (input.prop('files') || [1]).length;
while (i) {
paramName.push(name);
i -= 1;
}
});
if (!paramName.length) {
paramName = [fileInput.prop('name') || 'files[]'];
}
} else if (!$.isArray(paramName)) {
paramName = [paramName];
}
return paramName;
},
_initFormSettings: function (options) {
// Retrieve missing options from the input field and the
// associated form, if available:
if (!options.form || !options.form.length) {
options.form = $(options.fileInput.prop('form'));
}
options.paramName = this._getParamName(options);
if (!options.url) {
options.url = options.form.prop('action') || location.href;
}
// The HTTP request method must be "POST" or "PUT":
options.type = (options.type || options.form.prop('method') || '')
.toUpperCase();
if (options.type !== 'POST' && options.type !== 'PUT') {
options.type = 'POST';
}
if (!options.formAcceptCharset) {
options.formAcceptCharset = options.form.attr('accept-charset');
}
},
_getAJAXSettings: function (data) {
var options = $.extend({}, this.options, data);
this._initFormSettings(options);
this._initDataSettings(options);
return options;
},
// Maps jqXHR callbacks to the equivalent
// methods of the given Promise object:
_enhancePromise: function (promise) {
promise.success = promise.done;
promise.error = promise.fail;
promise.complete = promise.always;
return promise;
},
// Creates and returns a Promise object enhanced with
// the jqXHR methods abort, success, error and complete:
_getXHRPromise: function (resolveOrReject, context, args) {
var dfd = $.Deferred(),
promise = dfd.promise();
context = context || this.options.context || promise;
if (resolveOrReject === true) {
dfd.resolveWith(context, args);
} else if (resolveOrReject === false) {
dfd.rejectWith(context, args);
}
promise.abort = dfd.promise;
return this._enhancePromise(promise);
},
// Uploads a file in multiple, sequential requests
// by splitting the file up in multiple blob chunks.
// If the second parameter is true, only tests if the file
// should be uploaded in chunks, but does not invoke any
// upload requests:
_chunkedUpload: function (options, testOnly) {
var that = this,
file = options.files[0],
fs = file.size,
ub = options.uploadedBytes = options.uploadedBytes || 0,
mcs = options.maxChunkSize || fs,
// Use the Blob methods with the slice implementation
// according to the W3C Blob API specification:
slice = file.webkitSlice || file.mozSlice || file.slice,
upload,
n,
jqXHR,
pipe;
if (!(this._isXHRUpload(options) && slice && (ub || mcs < fs)) ||
options.data) {
return false;
}
if (testOnly) {
return true;
}
if (ub >= fs) {
file.error = 'uploadedBytes';
return this._getXHRPromise(
false,
options.context,
[null, 'error', file.error]
);
}
// n is the number of blobs to upload,
// calculated via filesize, uploaded bytes and max chunk size:
n = Math.ceil((fs - ub) / mcs);
// The chunk upload method accepting the chunk number as parameter:
upload = function (i) {
if (!i) {
return that._getXHRPromise(true, options.context);
}
// Upload the blobs in sequential order:
return upload(i -= 1).pipe(function () {
// Clone the options object for each chunk upload:
var o = $.extend({}, options);
o.blob = slice.call(
file,
ub + i * mcs,
ub + (i + 1) * mcs
);
// Expose the chunk index:
o.chunkIndex = i;
// Expose the number of chunks:
o.chunksNumber = n;
// Store the current chunk size, as the blob itself
// will be dereferenced after data processing:
o.chunkSize = o.blob.size;
// Process the upload data (the blob and potential form data):
that._initXHRData(o);
// Add progress listeners for this chunk upload:
that._initProgressListener(o);
jqXHR = ($.ajax(o) || that._getXHRPromise(false, o.context))
.done(function () {
// Create a progress event if upload is done and
// no progress event has been invoked for this chunk:
if (!o.loaded) {
that._onProgress($.Event('progress', {
lengthComputable: true,
loaded: o.chunkSize,
total: o.chunkSize
}), o);
}
options.uploadedBytes = o.uploadedBytes +=
o.chunkSize;
});
return jqXHR;
});
};
// Return the piped Promise object, enhanced with an abort method,
// which is delegated to the jqXHR object of the current upload,
// and jqXHR callbacks mapped to the equivalent Promise methods:
pipe = upload(n);
pipe.abort = function () {
return jqXHR.abort();
};
return this._enhancePromise(pipe);
},
_beforeSend: function (e, data) {
if (this._active === 0) {
// the start callback is triggered when an upload starts
// and no other uploads are currently running,
// equivalent to the global ajaxStart event:
this._trigger('start');
// Set timer for global bitrate progress calculation:
this._bitrateTimer = new this._BitrateTimer();
}
this._active += 1;
// Initialize the global progress values:
this._loaded += data.uploadedBytes || 0;
this._total += this._getTotal(data.files);
},
_onDone: function (result, textStatus, jqXHR, options) {
if (!this._isXHRUpload(options)) {
// Create a progress event for each iframe load:
this._onProgress($.Event('progress', {
lengthComputable: true,
loaded: 1,
total: 1
}), options);
}
options.result = result;
options.textStatus = textStatus;
options.jqXHR = jqXHR;
this._trigger('done', null, options);
},
_onFail: function (jqXHR, textStatus, errorThrown, options) {
options.jqXHR = jqXHR;
options.textStatus = textStatus;
options.errorThrown = errorThrown;
this._trigger('fail', null, options);
if (options.recalculateProgress) {
// Remove the failed (error or abort) file upload from
// the global progress calculation:
this._loaded -= options.loaded || options.uploadedBytes || 0;
this._total -= options.total || this._getTotal(options.files);
}
},
_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
this._active -= 1;
options.textStatus = textStatus;
if (jqXHRorError && jqXHRorError.always) {
options.jqXHR = jqXHRorError;
options.result = jqXHRorResult;
} else {
options.jqXHR = jqXHRorResult;
options.errorThrown = jqXHRorError;
}
this._trigger('always', null, options);
if (this._active === 0) {
// The stop callback is triggered when all uploads have
// been completed, equivalent to the global ajaxStop event:
this._trigger('stop');
// Reset the global progress values:
this._loaded = this._total = 0;
this._bitrateTimer = null;
}
},
_onSend: function (e, data) {
var that = this,
jqXHR,
slot,
pipe,
options = that._getAJAXSettings(data),
send = function (resolve, args) {
that._sending += 1;
// Set timer for bitrate progress calculation:
options._bitrateTimer = new that._BitrateTimer();
jqXHR = jqXHR || (
(resolve !== false &&
that._trigger('send', e, options) !== false &&
(that._chunkedUpload(options) || $.ajax(options))) ||
that._getXHRPromise(false, options.context, args)
).done(function (result, textStatus, jqXHR) {
that._onDone(result, textStatus, jqXHR, options);
}).fail(function (jqXHR, textStatus, errorThrown) {
that._onFail(jqXHR, textStatus, errorThrown, options);
}).always(function (jqXHRorResult, textStatus, jqXHRorError) {
that._sending -= 1;
that._onAlways(
jqXHRorResult,
textStatus,
jqXHRorError,
options
);
if (options.limitConcurrentUploads &&
options.limitConcurrentUploads > that._sending) {
// Start the next queued upload,
// that has not been aborted:
var nextSlot = that._slots.shift();
while (nextSlot) {
if (!nextSlot.isRejected()) {
nextSlot.resolve();
break;
}
nextSlot = that._slots.shift();
}
}
});
return jqXHR;
};
this._beforeSend(e, options);
if (this.options.sequentialUploads ||
(this.options.limitConcurrentUploads &&
this.options.limitConcurrentUploads <= this._sending)) {
if (this.options.limitConcurrentUploads > 1) {
slot = $.Deferred();
this._slots.push(slot);
pipe = slot.pipe(send);
} else {
pipe = (this._sequence = this._sequence.pipe(send, send));
}
// Return the piped Promise object, enhanced with an abort method,
// which is delegated to the jqXHR object of the current upload,
// and jqXHR callbacks mapped to the equivalent Promise methods:
pipe.abort = function () {
var args = [undefined, 'abort', 'abort'];
if (!jqXHR) {
if (slot) {
slot.rejectWith(args);
}
return send(false, args);
}
return jqXHR.abort();
};
return this._enhancePromise(pipe);
}
return send();
},
_onAdd: function (e, data) {
var that = this,
result = true,
options = $.extend({}, this.options, data),
limit = options.limitMultiFileUploads,
paramName = this._getParamName(options),
paramNameSet,
paramNameSlice,
fileSet,
i;
if (!(options.singleFileUploads || limit) ||
!this._isXHRUpload(options)) {
fileSet = [data.files];
paramNameSet = [paramName];
} else if (!options.singleFileUploads && limit) {
fileSet = [];
paramNameSet = [];
for (i = 0; i < data.files.length; i += limit) {
fileSet.push(data.files.slice(i, i + limit));
paramNameSlice = paramName.slice(i, i + limit);
if (!paramNameSlice.length) {
paramNameSlice = paramName;
}
paramNameSet.push(paramNameSlice);
}
} else {
paramNameSet = paramName;
}
data.originalFiles = data.files;
$.each(fileSet || data.files, function (index, element) {
var newData = $.extend({}, data);
newData.files = fileSet ? element : [element];
newData.paramName = paramNameSet[index];
newData.submit = function () {
newData.jqXHR = this.jqXHR =
(that._trigger('submit', e, this) !== false) &&
that._onSend(e, this);
return this.jqXHR;
};
return (result = that._trigger('add', e, newData));
});
return result;
},
// File Normalization for Gecko 1.9.1 (Firefox 3.5) support:
_normalizeFile: function (index, file) {
if (file.name === undefined && file.size === undefined) {
file.name = file.fileName;
file.size = file.fileSize;
}
},
_replaceFileInput: function (input) {
var inputClone = input.clone(true);
$('<form></form>').append(inputClone)[0].reset();
// Detaching allows to insert the fileInput on another form
// without loosing the file input value:
input.after(inputClone).detach();
// Avoid memory leaks with the detached file input:
$.cleanData(input.unbind('remove'));
// Replace the original file input element in the fileInput
// collection with the clone, which has been copied including
// event handlers:
this.options.fileInput = this.options.fileInput.map(function (i, el) {
if (el === input[0]) {
return inputClone[0];
}
return el;
});
// If the widget has been initialized on the file input itself,
// override this.element with the file input clone:
if (input[0] === this.element[0]) {
this.element = inputClone;
}
},
_getFileInputFiles: function (fileInput) {
fileInput = $(fileInput);
var files = $.each($.makeArray(fileInput.prop('files')), this._normalizeFile),
value;
if (!files.length) {
value = fileInput.prop('value');
if (!value) {
return [];
}
// If the files property is not available, the browser does not
// support the File API and we add a pseudo File object with
// the input value as name with path information removed:
files = [{name: value.replace(/^.*\\/, '')}];
}
return files;
},
_onChange: function (e) {
var that = e.data.fileupload,
data = {
fileInput: $(e.target),
form: $(e.target.form)
};
data.files = that._getFileInputFiles(data.fileInput);
if (that.options.replaceFileInput) {
that._replaceFileInput(data.fileInput);
}
if (that._trigger('change', e, data) === false ||
that._onAdd(e, data) === false) {
return false;
}
},
_onPaste: function (e) {
var that = e.data.fileupload,
cbd = e.originalEvent.clipboardData,
items = (cbd && cbd.items) || [],
data = {files: []};
$.each(items, function (index, item) {
var file = item.getAsFile && item.getAsFile();
if (file) {
data.files.push(file);
}
});
if (that._trigger('paste', e, data) === false ||
that._onAdd(e, data) === false) {
return false;
}
},
_onDrop: function (e) {
var that = e.data.fileupload,
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer,
data = {
files: $.each(
$.makeArray(dataTransfer && dataTransfer.files),
that._normalizeFile
)
};
if (that._trigger('drop', e, data) === false ||
that._onAdd(e, data) === false) {
return false;
}
e.preventDefault();
},
_onDragOver: function (e) {
var that = e.data.fileupload,
dataTransfer = e.dataTransfer = e.originalEvent.dataTransfer;
if (that._trigger('dragover', e) === false) {
return false;
}
if (dataTransfer) {
dataTransfer.dropEffect = 'copy';
}
e.preventDefault();
},
_initEventHandlers: function () {
var ns = this.options.namespace;
if (this._isXHRUpload(this.options)) {
this.options.dropZone
.bind('dragover.' + ns, {fileupload: this}, this._onDragOver)
.bind('drop.' + ns, {fileupload: this}, this._onDrop)
.bind('paste.' + ns, {fileupload: this}, this._onPaste);
}
this.options.fileInput
.bind('change.' + ns, {fileupload: this}, this._onChange);
},
_destroyEventHandlers: function () {
var ns = this.options.namespace;
this.options.dropZone
.unbind('dragover.' + ns, this._onDragOver)
.unbind('drop.' + ns, this._onDrop)
.unbind('paste.' + ns, this._onPaste);
this.options.fileInput
.unbind('change.' + ns, this._onChange);
},
_setOption: function (key, value) {
var refresh = $.inArray(key, this._refreshOptionsList) !== -1;
if (refresh) {
this._destroyEventHandlers();
}
$.Widget.prototype._setOption.call(this, key, value);
if (refresh) {
this._initSpecialOptions();
this._initEventHandlers();
}
},
_initSpecialOptions: function () {
var options = this.options;
if (options.fileInput === undefined) {
options.fileInput = this.element.is('input:file') ?
this.element : this.element.find('input:file');
} else if (!(options.fileInput instanceof $)) {
options.fileInput = $(options.fileInput);
}
if (!(options.dropZone instanceof $)) {
options.dropZone = $(options.dropZone);
}
},
_create: function () {
var options = this.options;
// Initialize options set via HTML5 data-attributes:
$.extend(options, $(this.element[0].cloneNode(false)).data());
options.namespace = options.namespace || this.widgetName;
this._initSpecialOptions();
this._slots = [];
this._sequence = this._getXHRPromise(true);
this._sending = this._active = this._loaded = this._total = 0;
this._initEventHandlers();
},
destroy: function () {
this._destroyEventHandlers();
$.Widget.prototype.destroy.call(this);
},
enable: function () {
$.Widget.prototype.enable.call(this);
this._initEventHandlers();
},
disable: function () {
this._destroyEventHandlers();
$.Widget.prototype.disable.call(this);
},
// This method is exposed to the widget API and allows adding files
// using the fileupload API. The data parameter accepts an object which
// must have a files property and can contain additional options:
// .fileupload('add', {files: filesList});
add: function (data) {
if (!data || this.options.disabled) {
return;
}
if (data.fileInput && !data.files) {
data.files = this._getFileInputFiles(data.fileInput);
} else {
data.files = $.each($.makeArray(data.files), this._normalizeFile);
}
this._onAdd(null, data);
},
// This method is exposed to the widget API and allows sending files
// using the fileupload API. The data parameter accepts an object which
// must have a files property and can contain additional options:
// .fileupload('send', {files: filesList});
// The method returns a Promise object for the file upload call.
send: function (data) {
if (data && !this.options.disabled) {
if (data.fileInput && !data.files) {
data.files = this._getFileInputFiles(data.fileInput);
} else {
data.files = $.each($.makeArray(data.files), this._normalizeFile);
}
if (data.files.length) {
return this._onSend(null, data);
}
}
return this._getXHRPromise(false, data && data.context);
}
});
}));
@@ -1,172 +0,0 @@
/*
* jQuery Iframe Transport Plugin 1.5
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint unparam: true, nomen: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['jquery'], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// Helper variable to create unique names for the transport iframes:
var counter = 0;
// The iframe transport accepts three additional options:
// options.fileInput: a jQuery collection of file input fields
// options.paramName: the parameter name for the file form data,
// overrides the name property of the file input field(s),
// can be a string or an array of strings.
// options.formData: an array of objects with name and value properties,
// equivalent to the return data of .serializeArray(), e.g.:
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
$.ajaxTransport('iframe', function (options) {
if (options.async && (options.type === 'POST' || options.type === 'GET')) {
var form,
iframe;
return {
send: function (_, completeCallback) {
form = $('<form style="display:none;"></form>');
form.attr('accept-charset', options.formAcceptCharset);
// javascript:false as initial iframe src
// prevents warning popups on HTTPS in IE6.
// IE versions below IE8 cannot set the name property of
// elements that have already been added to the DOM,
// so we set the name along with the iframe HTML markup:
iframe = $(
'<iframe src="javascript:false;" name="iframe-transport-' +
(counter += 1) + '"></iframe>'
).bind('load', function () {
var fileInputClones,
paramNames = $.isArray(options.paramName) ?
options.paramName : [options.paramName];
iframe
.unbind('load')
.bind('load', function () {
var response;
// Wrap in a try/catch block to catch exceptions thrown
// when trying to access cross-domain iframe contents:
try {
response = iframe.contents();
// Google Chrome and Firefox do not throw an
// exception when calling iframe.contents() on
// cross-domain requests, so we unify the response:
if (!response.length || !response[0].firstChild) {
throw new Error();
}
} catch (e) {
response = undefined;
}
// The complete callback returns the
// iframe content document as response object:
completeCallback(
200,
'success',
{'iframe': response}
);
// Fix for IE endless progress bar activity bug
// (happens on form submits to iframe targets):
$('<iframe src="javascript:false;"></iframe>')
.appendTo(form);
form.remove();
});
form
.prop('target', iframe.prop('name'))
.prop('action', options.url)
.prop('method', options.type);
if (options.formData) {
$.each(options.formData, function (index, field) {
$('<input type="hidden"/>')
.prop('name', field.name)
.val(field.value)
.appendTo(form);
});
}
if (options.fileInput && options.fileInput.length &&
options.type === 'POST') {
fileInputClones = options.fileInput.clone();
// Insert a clone for each file input field:
options.fileInput.after(function (index) {
return fileInputClones[index];
});
if (options.paramName) {
options.fileInput.each(function (index) {
$(this).prop(
'name',
paramNames[index] || options.paramName
);
});
}
// Appending the file input fields to the hidden form
// removes them from their original location:
form
.append(options.fileInput)
.prop('enctype', 'multipart/form-data')
// enctype must be set as encoding for IE:
.prop('encoding', 'multipart/form-data');
}
form.submit();
// Insert the file input fields at their original location
// by replacing the clones with the originals:
if (fileInputClones && fileInputClones.length) {
options.fileInput.each(function (index, input) {
var clone = $(fileInputClones[index]);
$(input).prop('name', clone.prop('name'));
clone.replaceWith(input);
});
}
});
form.append(iframe).appendTo(document.body);
},
abort: function () {
if (iframe) {
// javascript:false as iframe src aborts the request
// and prevents warning popups on HTTPS in IE6.
// concat is used to avoid the "Script URL" JSLint error:
iframe
.unbind('load')
.prop('src', 'javascript'.concat(':false;'));
}
if (form) {
form.remove();
}
}
};
}
});
// The iframe transport returns the iframe content document as response.
// The following adds converters from iframe to text, json, html, and script:
$.ajaxSetup({
converters: {
'iframe text': function (iframe) {
return $(iframe[0].body).text();
},
'iframe json': function (iframe) {
return $.parseJSON($(iframe[0].body).text());
},
'iframe html': function (iframe) {
return $(iframe[0].body).html();
},
'iframe script': function (iframe) {
return $.globalEval($(iframe[0].body).text());
}
}
});
}));
@@ -1,29 +0,0 @@
/*
* jQuery File Upload Plugin Localization Example 6.5.1
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2012, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*global window */
window.locale = {
"fileupload": {
"errors": {
"maxFileSize": "File is too big",
"minFileSize": "File is too small",
"acceptFileTypes": "Filetype not allowed",
"maxNumberOfFiles": "Max number of files exceeded",
"uploadedBytes": "Uploaded bytes exceed file size",
"emptyResult": "Empty file upload result"
},
"error": "Error",
"start": "Start",
"cancel": "Cancel",
"destroy": "Delete"
}
};
@@ -1,78 +0,0 @@
/*
* jQuery File Upload Plugin JS Example 6.7
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2010, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint nomen: true, unparam: true, regexp: true */
/*global $, window, document */
$(function () {
'use strict';
// Initialize the jQuery File Upload widget:
$('#fileupload').fileupload();
// Enable iframe cross-domain access via redirect option:
$('#fileupload').fileupload(
'option',
'redirect',
window.location.href.replace(
/\/[^\/]*$/,
'/cors/result.html?%s'
)
);
if (window.location.hostname === 'blueimp.github.com') {
// Demo settings:
$('#fileupload').fileupload('option', {
url: '//jquery-file-upload.appspot.com/',
maxFileSize: 5000000,
acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
process: [
{
action: 'load',
fileTypes: /^image\/(gif|jpeg|png)$/,
maxFileSize: 20000000 // 20MB
},
{
action: 'resize',
maxWidth: 1440,
maxHeight: 900
},
{
action: 'save'
}
]
});
// Upload server status check for browsers with CORS support:
if ($.support.cors) {
$.ajax({
url: '//jquery-file-upload.appspot.com/',
type: 'HEAD'
}).fail(function () {
$('<span class="alert alert-error"/>')
.text('Upload server currently unavailable - ' +
new Date())
.appendTo('#fileupload');
});
}
} else {
// Load existing files:
$('#fileupload').each(function () {
var that = this;
$.getJSON(this.action, function (result) {
if (result && result.length) {
$(that).fileupload('option', 'done')
.call(that, null, {result: result});
}
});
});
}
});
@@ -9,7 +9,7 @@
<ul>
<li>
<b><%= t('announcement.category') %></b>
<%= @bulletin.bulletin_category.i18n_variable[I18n.locale] %>
<%= @bulletin.bulletin_category.title %>
</li>
<li>
<b><%= t('announcement.postdate') %></b>
@@ -10,11 +10,11 @@
<ul class="subm">
<% @archive_file_categorys.each do |afcpost| %>
<li><%= link_to afcpost.i18n_variable[I18n.locale], panel_archive_front_end_archive_files_path(:category_id => afcpost.id) %></li>
<li><%= link_to afcpost.title, panel_archive_front_end_archive_files_path(:category_id => afcpost.id) %></li>
<% end %>
</ul>
<h3><%= @archive_files.first.archive_file_category.i18n_variable[I18n.locale] rescue nil %></h3>
<h3><%= @archive_files.first.archive_file_category.title rescue nil %></h3>
<% @archive_files.each do |post| %>
@@ -4,7 +4,7 @@
<h1 class="h1"><%= @title %></h1>
<% end %>
<h3><%= @archive_file.archive_file_category.i18n_variable[I18n.locale] rescue nil %></h3>
<h3><%= @archive_file.archive_file_category.title rescue nil %></h3>
<%= @archive_file.title %>
@@ -9,7 +9,7 @@
</ul>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<!-- <form id="edit_album" action="update_album" method="post"> -->
@@ -11,7 +11,7 @@
</select>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab_content form-horizontal">
@@ -5,7 +5,7 @@
</ul>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<li <%= ( i == 0 ) ? "class=active" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<form id="edit_album" action="update_album" method="post">
@@ -13,9 +13,9 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
@news_bulletin.proc_check(params[:news_bulletin][:is_checked],params[:news_bulletin][:not_checked_reason])
@news_bulletin.de_pending
if @news_bulletin.save
notice = t('news_bulletin.approve_bulletin_success')
notice = t('approval.pass')
else
notice = t('news_bulletin.approve_bulletin_fail')
notice = t('approval.not_pass')
end
redirect_to(panel_news_back_end_news_bulletins_url,:notice => notice)
end
@@ -40,9 +40,9 @@ class Panel::News::BackEnd::NewsApprovalsController < OrbitBackendController
def update_setting
object_auth = update_setting_by_params
if object_auth.save!
flash[:notice] = t("admin.object_auth.update_done")
flash[:notice] = t('update.success_')
else
flash[:notice] = t("admin.object_auth.update_failed")
flash[:notice] = t('update.fail')
end
end
@@ -77,7 +77,7 @@ class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendContro
respond_to do |format|
if @news_bulletin_category.save
# format.html { redirect_to @news_bulletin_category, notice: 'Entry was successfully created.' }
format.html { redirect_to(panel_news_back_end_news_bulletin_categorys_url, :notice => t('news.create_news_bulletin_category_success')) }
format.html { redirect_to(panel_news_back_end_news_bulletin_categorys_url, :notice => t('news_bulletin.create_news_bulletin_category_success')) }
# format.xml { render :xml => @news_bulletin_category, :status => :created, :location => @news_bulletin_category }
format.js
else
@@ -118,14 +118,14 @@ class Panel::News::BackEnd::NewsBulletinCategorysController < OrbitBackendContro
if @news_bulletin_category.save!
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
respond_to do |format|
flash[:notice] = t("bulletin_category.update_success")
# flash[:error] += @bulletin_category.disable ? t("bulletin_category.disable_change_to_true") : t("bulletin_category.disable_change_to_false")
flash[:notice] = t("update.success_")
# flash[:error] += @bulletin_category.disable ? t(enable) : t(disable)
format.html { redirect_to(panel_announcement_back_end_news_bulletin_categorys_url) }
# format.xml { head :ok }
format.js
end
else
flash[:error] = t("bulletin_category.update_failed")
flash[:error] = t("update.fail")
format.html { render :action => "index" }
end
@@ -10,8 +10,16 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
controller.get_categorys('NewsBulletinCategory')
controller.get_unit_list
end
before_filter :clean_values, :only => [:create, :update]
def preview
#@preview_obj = Preview.create(:object=>params[:news_bulletin],:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
news_bulletin = NewsBulletin.new params
@preview_obj = news_bulletin.to_preview
@preview_obj.save
render '/shared/preview/preview.html.erb', :layout=>false
end
def index
# @news_bulletins = NewsBulletin.all
# @news_bulletins = NewsBulletin.desc("postdate desc")
@@ -86,9 +94,12 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
# GET /news_bulletins/new
# GET /news_bulletins/new.xml
def new
@news_bulletin = NewsBulletin.new
if(session[:in_validate_object].blank?)
@news_bulletin = NewsBulletin.new
else
@news_bulletin = session[:in_validate_object]
session[:in_validate_object] = {}
end
@link_url = panel_news_back_end_news_bulletins_path
# @news_bulletin.news_bulletin_files.build
@@ -150,7 +161,9 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
@news_bulletin.update_user_id = current_user.id
if(is_manager? || is_admin?)
@news_bulletin.de_pending
@news_bulletin.is_checked = true
@news_bulletin.is_rejected = false
@news_bulletin.de_pending
end
respond_to do |format|
@@ -158,7 +171,8 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news_bulletin.create_news_bulletin_success')) }
format.xml { render :xml => @news_bulletin, :status => :created, :location => @news_bulletin }
format.js
format.js
#format.json {render :json => {"success"=>"true","redirect_url"=>panel_news_back_end_news_bulletins_url,"notice" => t('news_bulletin.create_news_bulletin_success')}}
else
format.html { render :action => "new" }
format.xml { render :xml => @news_bulletin.errors, :status => :unprocessable_entity }
@@ -278,7 +292,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
end
expire_page(:controller=>'panel/news/widget/news_bulletins' , :action=>'home_banner')
# format.html { redirect_to(panel_news_back_end_news_bulletin_url(@news_bulletin), :notice => t('news_bulletin.update_news_bulletin_success')) }
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('news.news_bulletin.update_success')) }
format.html { redirect_to(panel_news_back_end_news_bulletins_url, :notice => t('update.success_')) }
format.js { render 'toggle_enable' }
format.xml { head :ok }
else
@@ -366,7 +380,7 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
# @news_bulletin_categorys = NewsBulletinCategory.all.authed_for_user(current_user,'submit')
# end
# if @news_bulletin_categorys.empty? && params[:action] != "index"
# flash[:alert] = t("news.error.no_avilb_cate_for_posting")
# flash[:alert] = t("news_bulletin.error.no_avilb_cate_for_posting")
# redirect_to :action => :index
# end
# end
@@ -376,7 +390,18 @@ class Panel::News::BackEnd::NewsBulletinsController < OrbitBackendController
def get_tags
module_app = ModuleApp.first(:conditions => {:key => 'news'})
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc)
@tags = Tag.all(:conditions => {:module_app_id => module_app.id}).order_by(I18n.locale, :asc) rescue []
end
def clean_values
if params[:news_bulletin]
params[:news_bulletin][:news_bulletin_links_attributes].each_with_index do |link, index|
params[:news_bulletin][:news_bulletin_links_attributes].delete(index.to_s) if link[1]['url'].blank? and link[1]['title'].blank?
end rescue nil
params[:news_bulletin][:news_bulletin_files_attributes].each_with_index do |link, index|
params[:news_bulletin][:news_bulletin_files_attributes].delete(index.to_s) if link[1]['file'].blank? and link[1]['title'].blank?
end rescue nil
end
end
end
@@ -19,14 +19,14 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
if !params[:search_query].blank?
# search_cond = {:is_checked=>true,:is_hidden=>false,:is_pending=>false,:is_pending=>false}
# search_cond.merge!({:news_bulletin_category_id => "#{params[:category_id]}" }) if !params[:category_id].blank?
@search = NewsBulletin.solr_search do
fulltext params[:search_query]
with(:frontend_search,true)
#order_by(:average_rating)
with(:available_lang).any_of([I18n.locale.to_s])
end
search_result = @search.results.collect{|result| result.id}
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).page( params[:page_main]).per(10)
@news_bulletins = NewsBulletin.all.available_for_lang(I18n.locale).can_display.any_in(_id:search_result).desc(:postdate).page( params[:page_main]).per(10)
else
date_now = Time.now
if !params[:category_id].blank? && !params[:tag_id].blank?
@@ -69,7 +69,8 @@ class Panel::News::FrontEnd::NewsBulletinsController < OrbitWidgetController
end
def preview_content
@news_bulletin = NewsBulletin.find params[:id]
@news_bulletin = NewsBulletin.find params[:id] rescue nil
@news_bulletin = Preview.find(params[:id]).get_virtual_object if @news_bulletin.nil?
get_categorys
end
@@ -9,8 +9,8 @@ include ActionView::Helpers::UrlHelper
news_bulletin_category.object_auths.new(title: type ).save
oa = news_bulletin_category.get_object_auth_by_title(type)
end
# link_to t('announcement.bulletin.cate_auth'), edit_admin_object_auth_path(oa)
link_to t('announcement.bulletin.cate_auth'),admin_object_auth_ob_auth_path(oa)
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
end
+31 -3
View File
@@ -9,12 +9,14 @@ class NewsBulletin
BelongsToCategory = :news_bulletin_category
include OrbitCoreLib::BelongsToCategoryMayDisable
include OrbitCoreLib::Preview
# include Tire::Model::Search
# include Tire::Model::Callbacks
# include Redis::Objects
#scope :searchable,where(:is_checked=>true,:is_hidden=>false,:is_pending=>false)
is_impressionable :counter_cache => { :column_name => :view_count }
@@ -36,7 +38,6 @@ class NewsBulletin
field :is_checked, :type => Boolean, :default => false
field :is_pending, :type => Boolean, :default => true
field :is_rejected, :type => Boolean, :default => false
field :view_count, :type => Integer, :default => 0
field :not_checked_reason
@@ -101,6 +102,10 @@ class NewsBulletin
end
integer :view_count
string :available_lang , :multiple => true do
VALID_LOCALES.collect{|t| enabled_for_lang(t.to_sym) ? t : nil}.delete_if{|t| t.nil?}
end
boolean :frontend_search do
( !is_hidden && !is_pending && is_checked && !is_rejected )
end
@@ -108,6 +113,7 @@ class NewsBulletin
string :news_bulletin_category_id
end
# redis_search_index(:title_field => :s_title,
# :alias_field => :s_title_en,
# :score_field => :view_count,
@@ -140,6 +146,9 @@ class NewsBulletin
# def s_text_zh_tw
# Nokogiri::HTML(self.text.zh_tw).text
# end
def share_item
Item.first(conditions:{name: 'news'})
end
def self.widget_datas( category_id = nil )
@@ -150,9 +159,9 @@ class NewsBulletin
# any_of({ :title => "test" },{:deadline => nil, :title => "123"})
if category_id.to_s.size > 0
find(:all, :conditions => {news_bulletin_category_id: category_id}).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate)
find(:all, :conditions => {news_bulletin_category_id: category_id}).any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).any_of(is_hot: true, is_top: true).desc(:postdate)
else
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).desc( :is_top, :postdate)
any_of( {deadline: nil,:postdate.lte => date_now} , {:deadline.gte => date_now,:postdate.lte => date_now} ).any_of(is_hot: true, is_top: true).desc(:postdate)
end
end
@@ -237,6 +246,23 @@ class NewsBulletin
def sorted_tags
tags.order_by(I18n.locale, :asc)
end
def to_preview
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_news_front_end_news_bulletin_path",:object_class_type=>"NewsBulletin")
preview_object.preview_files.build(:file=>self.news_bulletin["image"],:field_name_for_rebuild=>'image')
self.news_bulletin["news_bulletin_files_attributes"].each_with_index do |atr,idx|
preview_object.preview_files.build(:file=>self.news_bulletin["news_bulletin_files_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_files',:file_in_array=>true)
end unless self.news_bulletin["news_bulletin_files_attributes"].nil?
self.news_bulletin["news_bulletin_links_attributes"].each_with_index do |atr,idx|
preview_object.preview_associations.build(:object=>self.news_bulletin["news_bulletin_links_attributes"][idx.to_s],:field_name_for_rebuild=>'news_bulletin_links',:object_in_array=>true)
end unless self.news_bulletin["news_bulletin_links_attributes"].nil?
preview_object.object = self.news_bulletin.except("news_bulletin_files_attributes","image","news_bulletin_links_attributes")
preview_object
end
protected
@@ -260,4 +286,6 @@ class NewsBulletin
self.tag_ids.delete('')
end
end
@@ -6,20 +6,19 @@
<%= javascript_include_tag "inc/permission-checkbox" %>
<%= javascript_include_tag "inc/search" %>
<% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true) %>
<div class="subnav">
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("news.news_bulletin.category") %>
<%= label_tag :category, t(:category) %>
<%= select_tag "category_id", options_from_collection_for_select(@news_bulletin_categorys, "id", "key") %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
</div>
<%#= label_tag :role, t("admin.roles") %>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag :action => "update_setting" do %>
@@ -19,19 +19,19 @@
<div class="modal-footer">
<%= form_for news_bulletin, :url => panel_news_back_end_news_bulletin_approve_path(news_bulletin),:method => :post, :html => {:class => 'clear'} do |f| %>
<%= f.label :approval_stat, t('announcement.bulletin.approval_stat') %>
<%= f.label :approval_stat, t('approval.stat') %>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, true , {:class => 'privacy'} %>
<%= t('announcement.bulletin.approval_pass') %>
<%= t('approval.pass') %>
<% end -%>
<%= content_tag :label,:class => "radio inline" do -%>
<%= f.radio_button :is_checked, false, (!@news_bulletin.is_checked ? {:checked => true, :class => 'privacy'} : {})%>
<%= t('announcement.bulletin.approval_not_pass') %>
<%= t('approval.not_pass') %>
<% end -%>
<%= label :is_checked_false, t('announcement.bulletin.approval_not_pass_reason') %>
<%= label :is_checked_false, t('approval.not_pass_reason') %>
<%= f.text_field :not_checked_reason %>
<%= f.submit t('announcement.bulletin.submit_approval'),:class=>"btn"%>
<%= f.submit t(:submit_approval),:class=>"btn"%>
<% end %>
<a href="#" class="btn" data-dismiss="modal"><%= t("modal.close") %></a>
@@ -3,7 +3,7 @@
<div class="modal hide fade in" id="news_bulletin_category-<%=news_bulletin_category.id%>">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><%= t("announcement.bulletin.approval_user_list") %></h3>
<h3><%= t("approval.user_list") %></h3>
</div>
<div class="modal-body">
<div class="clear">
@@ -6,27 +6,26 @@
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("news.news_bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("news.news_bulletin.category") %>
<%= label_tag :category, t(:category) %>
<%= select "news_category",'id', @options_from_collection_for_select_news_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.approval_user_list"), panel_news_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
<%= link_to t("approval.user_list"), panel_news_back_end_approval_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_news_back_end_approval_setting_path do %>
<%= render :partial => "layouts/users_checkbox_ary" %>
<div class="form-actions form-fixed pagination-right">
<%= submit_tag "Update", :class => 'btn btn-primary' %>
<%= submit_tag t(:update_), :class => 'btn btn-primary' %>
</div>
<% end -%>
<% end -%>
@@ -6,23 +6,22 @@
<%= javascript_include_tag "inc/search" %>
<%= javascript_include_tag "inc/modal-preview" %>
<% end %>
<%#= label_tag :fact_check_setting, t("announcement.bulletin.fact_check_setting") %>
<%= form_tag('', :remote => true,:class => "prevent_enter_submit_form") %>
<div class="subnav clear">
<ul class="nav nav-pills filter pull-left">
<li class="accordion-group">
<div class="form-search" style="margin: 5px 10px;">
<%= label_tag :category, t("announcement.bulletin.category") %>
<%= label_tag :category, t(:category) %>
<%= select "category",'id',@options_from_collection_for_select_bulletin_categorys %>
<%= search_field_tag 'user_filter' %>
</div>
</li>
</ul>
<%= link_to t("announcement.bulletin.submit_user_list"), panel_news_back_end_news_bulletin_category_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
<%= link_to t(:submit_user_list), panel_news_back_end_news_bulletin_category_user_list_path , :class=>'preview_trigger btn btn-success pull-right'%>
</div>
<%#= label_tag :role, t("admin.roles") %>
<%#= label_tag :role, t(:roles) %>
<div class="clear">
<%= content_tag :div do -%>
<% form_tag panel_news_back_end_news_bulletin_category_setting_path do %>
@@ -2,10 +2,10 @@
<%= form_for(@news_bulletin_category, :remote => true, :url => @url) do |f| %>
<h2><%= (@news_bulletin_category.new_record? ? 'Add' : 'Edit') %></h2>
<h2><%= (@news_bulletin_category.new_record? ? t(:edit) : t(:add)) %></h2>
<div id="widget-title">
<%= f.label :key %>
<%= f.label :key, t(:key) %>
<%= f.text_field :key %>
</div>
@@ -13,7 +13,7 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "name-#{locale}", "Name-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<%= label_tag "name-#{locale}", "#{t(:name)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (@news_bulletin_category.title_translations[locale] rescue nil) %>
</div>
@@ -5,8 +5,8 @@
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if is_admin?%>
<li><%= link_to t('bulletin_category.edit'), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(news_bulletin_category), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t('announcement.sure?'), :method => :delete, :remote => true,:class=>"archive_toggle" %></li>
<li><%= link_to t(:edit), edit_panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :remote => true %></li>
<li><%= link_to show_toggle_archive_btn(news_bulletin_category), panel_news_back_end_news_bulletin_category_path(news_bulletin_category), :confirm => t(:sure?), :method => :delete, :remote => true,:class=>"archive_toggle" %></li>
<% end %>
<%if is_manager? || is_admin? %>
<li><%= show_news_cate_permission_link(news_bulletin_category) %></li>
@@ -1,4 +1,4 @@
<h1><%= t('news.editing_news_class') %></h1>
<h1><%= t('news_bulletin.editing_news_category') %></h1>
<%= form_for @news_bulletin_category, :url => panel_news_back_end_news_bulletin_category_path(@news_bulletin_category) do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
@@ -4,7 +4,7 @@
<table id="news_bulletin_categorys" class="table main-list">
<thead>
<tr>
<th class="span1-2"><%= t('news_bulletin_category.key') %></th>
<th class="span1-2"><%= t(:key) %></th>
<% @site_valid_locales.each do |locale| %>
<th class="span1-2"><%= I18nVariable.first(:conditions => {:key => locale})[I18n.locale] %></th>
<% end %>
@@ -10,7 +10,7 @@
<br />
<br />
<h1><%= t('news_bulletin_category.new_news_class') %></h1>
<h1><%= t('news_bulletin.new_news_category') %></h1>
<%= form_for @news_bulletin_category, :url => panel_news_back_end_news_bulletin_categorys_path do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
@@ -1,35 +1,33 @@
<div id='filter' class="subnav">
<div id="accordion">
<ul class="nav nav-pills filter">
<li>
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("news.status") %> <b class="web-symbol"></b></a>
</div>
</li>
<li>
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("news.categories") %> <b class="web-symbol"></b></a>
</div>
</li>
<li>
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent="#accordion" class="accordion-toggle"><%= t("news.tags") %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="accordion-group filters">
<div class="accordion-body collapse" id="collapse-status">
<%= render 'filter_status' %>
<ul class="nav nav-pills filter">
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-status" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:status) %> <b class="web-symbol"></b></a>
</div>
<div class="accordion-body collapse" id="collapse-category">
<%= render 'filter_categories' %>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-category" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:categories) %> <b class="web-symbol"></b></a>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<%= render 'filter_tags' %>
</div>
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</li>
<li class="accordion-group">
<div class="accordion-heading">
<a href="#collapse-tags" data-toggle="collapse" data-parent=".filters" class="accordion-toggle"><%= t(:tags) %> <b class="web-symbol"></b></a>
</div>
</li>
</ul>
<div class="filters">
<div class="accordion-body collapse" id="collapse-status">
<%= render 'filter_status' %>
</div>
<div class="accordion-body collapse" id="collapse-category">
<%= render 'filter_categories' %>
</div>
<div class="accordion-body collapse" id="collapse-tags">
<%= render 'filter_tags' %>
</div>
<div id="sort_headers" class="table-label">
<%= render 'sort_headers' %>
</div>
</div>
</div>
@@ -1,38 +1,36 @@
<% # encoding: utf-8 %>
<% content_for :page_specific_javascript do -%>
<%= javascript_include_tag "inc/modal-preview" %>
<% end -%>
<!--Widget start-->
<%= f.error_messages %>
<div id="sub-wiget">
<div id="widget-picture" class="widget-box">
<div class="widget-action clear">
<a class="action"><i title="Upload pictures" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-picture icons-white"></i>Picture</h3>
<h3 class="widget-title"><i class="icons-picture icons-white"></i><%= t('nccu.picture') %></h3>
<div class="widget-content clear">
<div class="control-group">
<!-- <img class="pull-left upload-picture" src="/assets/default-img.png" /> -->
<div class="upload-picture">
<!--請程式務必將圖片尺寸加入到行內裡-->
<% if @news_bulletin.image %>
<%= image_tag @news_bulletin.image rescue ''%>
<% else %>
<img class="pull-left upload-picture" src="/assets/default-img.png" />
<% end %>
</div>
<span class="alert widgetInfo"><%= t("ad.widget_info_for_ad_image_size", :best_size=> "290px x 150px") %></span>
<div class="controls file-upload input-prepend">
<label class="control-label add-on btn" for="input-upload">
<%= t(:browse) %>
<%= f.file_field :image, :id => "input-upload", :class => 'upload', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>
</label>
<span id='fu' class="file-name"></span>
<%= f.file_field :image, :id => "input-upload", :class => '', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %>
<!-- <span id='fu' class="file-name"></span>
<br>
<input name='fu' class="input-medium" type="text">
<span class="alert widgetInfo"><%= t("admin.ad.widget_info_for_ad_image_size", :best_size=> "290px x 150px") %></span>
<br>
<br> -->
<% if @news_bulletin.image.file %>
<%= f.check_box :remove_image %>
<%= t('news.刪除已上傳檔案') %>
<%= t(:delete_file) %>
<% end %>
</div>
</div>
@@ -45,16 +43,16 @@
<div class="widget-action clear">
<a href="#" class="action"><i title="Set the news to start and end dates" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-calendar icons-white"></i> Date</h3>
<h3 class="widget-title"><i class="icons-calendar icons-white"></i><%= t('nccu.date') %></h3>
<div class="widget-content clear">
<div class="control-group">
<label class="control-label">Start</label>
<label class="control-label"><%= t(:start) %></label>
<div class="controls">
<%= f.date_select :postdate, {:use_month_numbers => true, :order => [:day, :month, :year] }, {:class => 'input-small'} %>
</div>
</div>
<div class="control-group">
<label class="control-label">End</label>
<label class="control-label"><%= t(:end) %></label>
<div class="controls">
<%= f.date_select :deadline, {:use_month_numbers => true, :prompt => { :month => 'Month', :day => 'Day', :year => 'Year'}, :order => [:day, :month, :year] }, {:class => 'input-small'} %>
</div>
@@ -67,7 +65,7 @@
<div class="widget-action clear">
<a class="action"><i title="Setting the news state" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i>Status</h3>
<h3 class="widget-title"><i class="icons-star-thin icons-white"></i><%= t(:status) %></h3>
<div class="widget-content clear">
<div class="controls">
<%= content_tag :label,:class => "checkbox inline" do -%>
@@ -76,7 +74,7 @@
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hot %>
<%= t('hot') %>
<%= t('news_bulletin.hot') %>
<% end -%>
<%= content_tag :label,:class => "checkbox inline" do -%>
<%= f.check_box :is_hidden %>
@@ -90,7 +88,7 @@
<div class="widget-action clear">
<a class="action"><i title="Setting" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Tags</h3>
<h3 class="widget-title"><i class="icons-tag icons-white"></i><%= t('nccu.tags') %></h3>
<div class="widget-content clear form-horizontal">
<% @tags.each do |tag| %>
<%= content_tag :label,:class => "checkbox inline" do -%>
@@ -106,7 +104,7 @@
<div class="widget-action clear">
<a class="action"><i title="Rejected Report" class="icon-cog icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-tag icons-white"></i>Approval Status</h3>
<h3 class="widget-title"><i class="icons-tag icons-white"></i><%= t('approval.stat') %></h3>
<div class="widget-content clear form-horizontal">
<%= @news_bulletin.not_checked_reason rescue t("rejected_reason_empty") %>
</div>
@@ -130,11 +128,11 @@
<div id="post-body">
<div id="post-body-content" class="clear">
<%= alert_block_tag(t("activerecord.errors.template.body"),session[:in_validate_object].errors.messages) unless session[:in_validate_object].blank? %>
<%= f.label :unit_list_for_anc,t(:unit_name)%>
<%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {:prompt => t("news_bulletin.ut_prompt")}, :class => "input-medium" %>
<%= f.label :unit_list_for_anc,t('news.news_bulletin.unit_name')%>
<%= f.select :unit_list_for_anc_id,@unit_list_for_anc.collect{|t| [ t.title, t.id ]}, {:prompt => t("news.news_bulletin.ut_prompt")}, :class => "input-medium" %>
<%= f.label :category,t('news.news_bulletin.category') %>
<%= f.label :category,t(:category) %>
<%= f.select :news_bulletin_category_id, @news_bulletin_categorys.collect{|t| [ t.title, t.id ]}, {}, :class => "input-medium" %>
<ul class="nav nav-tabs">
@@ -152,7 +150,7 @@
<div class="<%= locale %> fade tab-pane <%= ( i == 0 ) ? "in active" : '' %>">
<div class="title">
<%= f.label :title, t('news.news_bulletin.title')%>
<%= f.label :title, t(:title)%>
<%= f.fields_for :title_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_field locale, :class=>'post-title', :value => (@news_bulletin.title_translations[locale] rescue nil) %>
@@ -160,15 +158,15 @@
</div>
<div class="editor">
<%= f.label :subtitle, t('news.news_bulletin.subtitle') %>
<%= f.label :subtitle, t(:subtitle) %>
<%= f.fields_for :subtitle_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@news_bulletin.subtitle_translations[locale] rescue nil) %>
<%= f.text_area locale, :rows => 5, :style=>"width:100%", :value => (@news_bulletin.subtitle_translations[locale] rescue nil) %>
<% end %>
</div>
<div class="editor">
<%= f.label :text, t('news.news_bulletin.text') %>
<%= f.label :text, t(:text) %>
<%= f.fields_for :text_translations do |f| %>
<%= I18nVariable.from_locale(locale) %>
<%= f.text_area locale, :style=>"width:100%", :class => 'tinymce_textarea', :value => (@news_bulletin.text_translations[locale] rescue nil) %>
@@ -186,7 +184,7 @@
<div class="widget-action clear">
<a class="action"><i title="Add a reference link" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-link icons-white"></i>Link</h3>
<h3 class="widget-title"><i class="icons-link icons-white"></i><%= t(:link) %></h3>
<div class="widget-content">
<div id='news_bulletin_links' class="news_bulletin_links_block">
@@ -194,8 +192,8 @@
<table class="table table-condensed">
<thead>
<tr>
<th>URL</th>
<th>Name</th>
<th><%= t('nccu.url') %></th>
<th><%= t('nccu.link_name') %></th>
<th class="span1"></th>
</tr>
</thead>
@@ -230,7 +228,7 @@
<div class="widget-action clear">
<a class="action"><i title="Added to the file" class="icon-exclamation-sign icon-white tip"></i></a>
</div>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i>File</h3>
<h3 class="widget-title"><i class="icons-paperclip icons-white"></i><%= t('nccu.file') %></h3>
<div class="widget-content">
<div id='news_bulletin_files' class="news_bulletin_files_block">
@@ -238,9 +236,9 @@
<table class="table table-condensed">
<thead>
<tr>
<th>File</th>
<th>Name</th>
<th><%= t('description') %></th>
<th><%= t('nccu.selected_file') %></th>
<th><%= t('nccu.file_name') %></th>
<th><%= t('nccu.file_description') %></th>
<th class="span1"></th>
</tr>
</thead>
@@ -277,9 +275,10 @@
</div>
<!--Post End-->
</div>
<div class="form-actions">
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= button_tag t("preview"), :id=>"button_for_preview", :name=>"commit", :class=>'btn post_preview two_btn',:type=>:button, :url=>preview_panel_news_back_end_news_bulletins_path %>
<%= f.submit t('submit'), :class=>'btn btn-primary two_btn' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
@@ -11,7 +11,7 @@
<span class="label label-success"><%= t(:top) %></span>
<% end %>
<% if news_bulletin.is_hot? %>
<span class="label label-important"><%= t(:hot) %></span>
<span class="label label-important"><%= t('news_bulletin.hot') %></span>
<% end %>
<% if news_bulletin.is_hidden? %>
<span class="label"><%= t(:hidden) %></span>
@@ -33,9 +33,8 @@
<div class="quick-edit">
<ul class="nav nav-pills hide">
<% if (news_bulletin.create_user_id == current_or_guest_user.id) || is_manager? %>
<% if current_or_guest_user.admin? || (!news_bulletin.is_rejected? && !news_bulletin.is_checked?) %>
<li><%= link_to t('news_bulletin.edit'), edit_panel_news_back_end_news_bulletin_path(news_bulletin) %></li>
<li><%= link_to t(:edit), edit_panel_news_back_end_news_bulletin_path(news_bulletin) %></li>
<li class="dropdown">
<a href="#" data-toggle="dropdown" class="dropdown-toggle"><%= t(:quick_edit) %><b class="caret"></b></a>
<ul class="dropdown-menu" id="menu1">
@@ -43,25 +42,25 @@
<li><%= link_to t(:picture), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'picture'), :remote => true %></li>
<li><%= link_to t(:tags), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'tags'), :remote => true %></li>
<li><%#= link_to t(:link), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'links'), :remote => true %></li>
<li><%#= link_to t(:file), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'files'), :remote => true %></li>
<li><%#= link_to t(:file_), load_quick_edit_panel_news_back_end_news_bulletin_path(news_bulletin, :type => 'files'), :remote => true %></li>
</ul>
</li>
<% end %>
<% end %>
<% if news_show_delete_link(news_bulletin) %>
<li class="dropdown"><%= link_to t('news_bulletin.delete'), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t('news.sure?'), :method => :delete, :remote => true %></li>
<li class="dropdown"><%= link_to t(:delete), panel_news_back_end_news_bulletin_path(news_bulletin), :confirm => t(:sure?), :method => :delete, :remote => true %></li>
<% end %>
<% if news_show_approval_link(news_bulletin) %>
<li><%= link_to t('news.news_bulletin.approval'), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<li><%= link_to t(:approval_), panel_news_back_end_news_bulletin_approval_preview_path(news_bulletin),:class => 'preview_trigger' %></li><%#= #TODO add ancher so user can quick access into that part %>
<% end %>
<% if news_show_reject_reason(news_bulletin)%>
<li><%= link_to t('rejected_reason')+truncate(news_bulletin.not_checked_reason, :length => 10),'#',:rel=>"tooltip" ,'data-original-title'=> (wrap_string_with(news_bulletin.not_checked_reason, :line_width => 24)),:class=>'reject_info' %></li>
<li><%= link_to t(:rejected_reason)+truncate(news_bulletin.not_checked_reason, :length => 10),'#',:rel=>"tooltip" ,'data-original-title'=> (wrap_string_with(news_bulletin.not_checked_reason, :line_width => 24)),:class=>'reject_info' %></li>
<% end %>
</ul>
</div>
</td>
<td><%= display_date(news_bulletin.postdate) %></td>
<td><%= (news_bulletin.deadline) ? display_date(news_bulletin.deadline) : t('news_bulletin.no_deadline') %></td>
<td><%= (news_bulletin.deadline) ? display_date(news_bulletin.deadline) : t(:no_deadline) %></td>
<td>
<div class="label-group">
<div class="label-td">
@@ -12,7 +12,7 @@
<%= f.fields_for :title_translations do |f| %>
<% @site_valid_locales.each do |locale| %>
<div class="control-group">
<%= label_tag "title-#{locale}", "Title-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<%= label_tag "title-#{locale}", "#{t(:title)}-#{I18nVariable.from_locale(locale)}", :class => 'control-label' %>
<div class="controls">
<%= f.text_field locale, :class => 'input-xxlarge', :value => (news_bulletin.title_translations[locale] rescue nil) %>
</div>
@@ -40,7 +40,7 @@
<div class="control-group">
<label class="control-label"><%= t(:status) %></label>
<div class="controls">
<label class="checkbox inline"><%= f.check_box :is_hot %><%= t(:hot) %></label>
<label class="checkbox inline"><%= f.check_box :is_hot %><%= t('news_bulletin.hot') %></label>
<label class="checkbox inline"><%= f.check_box :is_top %><%= t(:top) %></label>
<label class="checkbox inline"><%= f.check_box :is_hidden %><%= t(:hidden) %></label>
</div>
@@ -16,7 +16,7 @@
<br>
<% if news_bulletin.image.file %>
<%= f.check_box :remove_image %>
<%= t('news.刪除已上傳檔案') %>
<%= t(:delete_file) %>
<% end %>
</div>
</div>
@@ -1,8 +1,8 @@
<%= render_sort_bar(true, delete_panel_news_back_end_news_bulletins_path(:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]),
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', 'news_bulletin.status'],
['title', 'title','span7', 'news_bulletin.title'],
['start_date', 'postdate', 'span1-2', 'news_bulletin.start_date'],
['end_date', 'deadline', 'span1-2', 'news_bulletin.end_date'],
['tags', 'tags', 'span1-2', 'news_bulletin.tags'],
['view_count', 'view_count','span1-2', 'view_count'],
['unit_list_for_anc', 'unit_list_for_anc','span1-3', 'news.news_bulletin.unit_name']).html_safe %>
['status', ['is_top', 'is_hot', 'is_hidden', 'is_pending', 'is_checked', 'is_rejected'], 'span1-2', :status],
['title', 'title','span7', :title],
['start_date', 'postdate', 'span1-2', :start_date],
['end_date', 'deadline', 'span1-2', :end_date],
['tags', 'tags', 'span1-2', :tags],
['view_count', 'view_count','span1-2', :view_count],
['unit_list_for_anc', 'unit_list_for_anc','span1-3', :unit_name]).html_safe %>
@@ -1,10 +1,10 @@
<ul class="breadcrumb">
<!-- <ul class="breadcrumb">
<li><span>Home</span><span class="divider">/</span></li>
<li><span>Library</span><span class="divider">/</span></li>
<li class="text-blue"><%= t('news.editing_news') %></li>
</ul>
<li class="text-blue"><%= t('news_bulletin.editing_news') %></li>
</ul> -->
<div id="poststuff">
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletin_path(@news_bulletin), :html => {:class => 'clear'} do |f| %>
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletin_path(@news_bulletin), :html => {:class => 'clear nccu_ajax_form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
@@ -4,7 +4,7 @@
</table>
<div class="form-actions form-fixed pagination-right">
<%= link_to(content_tag(:i, nil, :class => 'icon-plus icon-white') + t('admin.add'), new_panel_news_back_end_news_bulletin_path, :class => 'btn btn-primary pull-right' )if (is_manager? rescue nil)%>
<%= link_to(content_tag(:i, nil, :class => 'icon-plus icon-white') + t(:add), new_panel_news_back_end_news_bulletin_path, :class => 'btn btn-primary pull-right' )if (is_manager? rescue nil)%>
<div id="news_bulletin_pagination" class="paginationFixed">
<%= paginate @news_bulletins, :params => {:direction => params[:direction], :sort => params[:sort], :filter => @filter, :new_filter => nil, :sort_options => params[:sort_options]} %>
</div>
@@ -1,5 +1,5 @@
<div id="poststuff">
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletins_path do |f| %>
<%= form_for @news_bulletin, :url => panel_news_back_end_news_bulletins_path,:html=>{ :class=>"nccu_ajax_form"} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<% end %>
</div>
@@ -1,14 +1,14 @@
<ul>
<li>
<b><%= t('news.category') %></b>
<b><%= t(:category) %></b>
<%= @news_bulletin.news_bulletin_category.title rescue nil %>
</li>
<li>
<b><%= t('news.postdate') %></b>
<b><%= t(:postdate) %></b>
<%= display_date(@news_bulletin.postdate) %>
</li>
<li>
<b><%= t('news.title') %></b>
<b><%= t(:title) %></b>
<%= @news_bulletin.title %>
</li>
<li>
@@ -16,32 +16,32 @@
<%= link_to image_tag(@news_bulletin.image.url, :size => "320x240"), @news_bulletin.image.url, {:target => '_blank', :title => @news_bulletin.image_identifier} if @news_bulletin.image.file %>
</li>
<li>
<b><%= t('news.subtitle') %></b>
<b><%= t(:subtitle) %></b>
<%= @news_bulletin.subtitle.html_safe rescue '' %>
</li>
<li>
<b><%= t('news.text') %></b>
<b><%= t(:text) %></b>
<%= @news_bulletin.text.html_safe rescue '' %>
</li>
<li>
<li>
<b><%= t('news.link') %></b>
<b><%= t(:link) %></b>
<% @news_bulletin.news_bulletin_links.each do | blink | %>
<%= link_to blink.title, blink.url, :target => '_blank' %>
<% end %>
</li>
<li>
<b><%= t('news.file') %></b>
<b><%= t(:file) %></b>
<% @news_bulletin.news_bulletin_files.each do | bfile | %>
<%= link_to bfile.title, bfile.file.url, {:target => '_blank', :title => bfile.description} if bfile.file.file %>
<% end %>
</li>
<li>
<b><%= t('news.張貼者') %></b>
<b><%= t(:posted_by) %></b>
<%= User.find(@news_bulletin.create_user_id).name %>
</li>
<li>
<b><%= t('news.最後修改時間') %></b>
<b><%= t(:last_modified) %></b>
<%= display_date(@news_bulletin.updated_at) %>
</li>
@@ -16,9 +16,9 @@
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
<th class="span2"><%= t('news_bulletin.news_bulletin.image') %></th>
<th><%= t(:text) %></th>
<th class="span2 pagination-right"><%= t('news_bulletin.news_bulletin.postdate') %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
@@ -4,17 +4,18 @@ xml.rss :version => "2.0" do
if @current_category
xml.title @current_category.title_translations[I18n.locale.to_s]
else
xml.title t('news.campus_news')
xml.title t('news_bulletin.campus_news')
end
xml.link panel_news_front_end_news_bulletins_path(:rss)
xml.link url_for(:action=>"index", :controller=>"panel/news/front_end/news_bulletins" ,:format=> :rss,:only_path=>false,:inner=>true)
for news_bulletin in @news_bulletins
xml.item do
xml.title news_bulletin.title_translations[I18n.locale.to_s]
xml.description news_bulletin.subtitle_translations[I18n.locale.to_s]
xml.pubDate news_bulletin.postdate.to_s(:rfc822)
xml.link panel_news_front_end_news_bulletin_path(news_bulletin, :rss)
xml.guid panel_news_front_end_news_bulletin_path(news_bulletin, :rss)
xml.link url_for(:action=>"show", :controller=>"panel/news/front_end/news_bulletins", :id=>news_bulletin ,:only_path=>false)
xml.guid url_for(:action=>"show", :controller=>"panel/news/front_end/news_bulletins", :id=>news_bulletin ,:only_path=>false)
xml.fb_share generate_fb_url(news_bulletin, "news")
end
end
end
@@ -2,8 +2,8 @@
<h1 class="h1"><%= @news_bulletin.title %></h1>
<div class="info">
<div class="info1">
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) %></span>
<span class="date"><%= display_date(@news_bulletin.postdate) %></span>
<span class="pull-right"><%= dislpay_view_count(@news_bulletin) rescue ""%></span>
<span class="date"><%= display_date(@news_bulletin.postdate) rescue "" %></span>
<% unit = @news_bulletin.unit_list_for_anc.title rescue nil %>
<%= " | " if unit %>
<%= link_to unit, panel_news_front_end_index_news_bulletins_by_unit_path(:name=>@news_bulletin.unit_list_for_anc_id) unless unit.blank?%>
@@ -4,17 +4,17 @@ xml.rss :version => "2.0" do
if @current_category
xml.title @current_category.title_translations[I18n.locale.to_s]
else
xml.title t('news.campus_news')
xml.title t('news_bulletin.campus_news')
end
xml.link panel_news_front_end_news_bulletins_path(:rss)
xml.link url_for(:action=>"index", :controller=>"panel/news/front_end/news_bulletins" ,:format=> :rss,:only_path=>false,:inner=>true)
# for news_bulletin in @news_bulletins
xml.item do
xml.title @news_bulletin.title
xml.description @news_bulletin.text
xml.pubDate @news_bulletin.postdate.to_s(:rfc822)
xml.link panel_news_front_end_news_bulletin_path(@news_bulletin, :rss)
xml.guid panel_news_front_end_news_bulletin_path(@news_bulletin, :rss)
xml.link url_for(:action=>"show", :controller=>"panel/news/front_end/news_bulletins", :id=>@news_bulletin ,:format=> :rss,:only_path=>false,:inner=>true)
xml.guid url_for(:action=>"show", :controller=>"panel/news/front_end/news_bulletins", :id=>@news_bulletin ,:only_path=>false)
end
# end
end
@@ -7,9 +7,9 @@
<table class="table table-bordered">
<tbody>
<tr>
<th class="span2"><%= t('news.news_bulletin.image') %></th>
<th><%= t('news.news_bulletin.title') %></th>
<th class="span2 pagination-right"><%= t('news.news_bulletin.postdate') %></th>
<th class="span2"><%= t(:image) %></th>
<th><%= t(:text) %></th>
<th class="span2 pagination-right"><%= t(:postdate) %></th>
</tr>
<% @news_bulletins.each do |post| %>
<tr>
@@ -1,9 +1,9 @@
<% if @news_bulletins and !@news_bulletins.nil? %>
<h2 class="topic_title"><%= link_to t('news.campus_news'), panel_news_front_end_news_bulletins_path %></h2>
<%#= link_to t('news.more'),panel_news_front_end_news_bulletins_path(), :class => "topic_note" %>
<h2 class="topic_title"><%= link_to t('news_bulletin.campus_news'), panel_news_front_end_news_bulletins_path %></h2>
<%#= link_to t(:more_plus),panel_news_front_end_news_bulletins_path(), :class => "topic_note" %>
<div class="btn-group topic_note">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
<%= t('news.more') %>
<%= t(:more_plus) %>
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
@@ -21,7 +21,7 @@
<li>
<div class="news_img"><%= link_to image_tag(post.image.url, :size => "290x130"), panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></div>
<h3 class="h3 news_title"><%= link_to post.title, panel_news_front_end_news_bulletin_path(post, :category_id => post.news_bulletin_category_id) %></h3>
<p class="news_wrap"><%= post.subtitle.html_safe rescue '' %></p>
<p class="news_wrap"><%= truncate((post.subtitle rescue '') ,:length => 200) %></p>
</li>
<% end %>
</ul>
@@ -5,14 +5,14 @@
</div>
<div class="news_block">
<h3 class="news_title2"><%= t("news.news_bulletins") %></h3>
<h3 class="news_title2"><%= t("news_bulletin.news_bulletins") %></h3>
<ul id='news_bulletins_web_links_news_bulletins' class="news_list">
<%= render 'news_bulletins' if @news_bulletins %>
</ul>
</div>
<div class="links_block">
<h3 class="links_title"><%= t("news.related_links") %></h3>
<h3 class="links_title"><%= t(:related_links) %></h3>
<ul id='news_bulletins_web_links_web_links' class="links_list">
<%= render 'web_links' if @web_links %>
</ul>
@@ -12,7 +12,7 @@
<% @tags.each_with_index do |tag, index| %>
<div id="news_<%= index %>" class="news_block">
<h3 class="news_title2"><%= t("news.news_bulletins") %></h3>
<h3 class="news_title2"><%= t("news_bulletin.news_bulletins") %></h3>
<div class="news_prev">prev</div>
<div class="news_next">next</div>
<ul class="news_list">
@@ -2,7 +2,7 @@
<%= hidden_field_tag :category_id, params[:category_id] %>
<%= hidden_field_tag :tag_id, params[:tag_id] %>
<p>
<%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder=>t("news.search") }%>
<%= text_field_tag :search_query, params[:search_query],{:value => (params[:search_query].blank?? '' : params[:search_query]),:placeholder=>t("news_bulletin.search") }%>
<%= hidden_field_tag :category_id, params[:category_id] %>
<%= submit_tag "Search", name: nil %>
</p>
@@ -1,6 +1,6 @@
<!-- <div class="search"> <input type="text" onfocus="this.value='';this.searchClickFlag=true;" onblur="if(this.value==''){this.value='公告搜尋';this.searchClickFlag=false;}" value="公告搜尋" id="q" class="search_key" name="q"/> <input type="submit" name="sa" id="sa" class="sa" value="." /> </div> -->
<div class="category_list">
<h3 class="h3"><%= t('announcement.categories') %></h3>
<h3 class="h3"><%= t(:categories) %></h3>
<ul class="list">
<% @news_bulletin_categorys.each do |category| %>
<li class="<%= category.id.to_s.eql?(params[:category_id]) ? 'active' : nil %>">
@@ -10,7 +10,7 @@
</ul>
</div>
<div class="tag_cloud">
<h3 class="h3"><%= t('announcement.tag_cloud') %></h3>
<h3 class="h3"><%= t(:tag_cloud) %></h3>
<div class="cloud">
<% @tags_and_class.each do |tag| %>
<%= link_to tag[0][I18n.locale], panel_news_front_end_news_bulletins_path(:tag_id => tag[0].id, :category_id => params[:category_id]),:class => "#{tag[1]} #{(tag[0].id.to_s.eql?(params[:tag_id]) || tag[0].key.eql?(params[:tag_id])) ? 'active' : nil} " %>
+13 -183
View File
@@ -1,187 +1,17 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
_locale: English
basic: Basic
picture: Piture
tags: Tag
link: Link
file: File
add: Add
back: Back
create: Create
delete: Delete
disable: Disable
downloaded: Downloaded
download: Download
edit: Edit
enable: Enable
hide: Hide
homepage: Homepage
no_: "No"
nothing: Nothing
show: Show
sure?: Are you sure?
update: Update
yes_: "Yes"
hot: Hot
top: Top
hidden: Hidden
passed: Passed
pending: Pending
rejected: Rejected
rejected_reason: 'Reason:'
rejected_reason_empty: "Approval rejected,no referencable information"
clear: Clear
hot: Hot
top: Top
hidden: Hidden
passed: Approved
pending: Pending
rejected: Rejected
clear: Clear
hot: Hot
top: Top
hidden: Hidden
passed: Approved
pending: Pending
rejected: Rejected
clear: Clear
news:
all_articles: List
add_new: Add
sure?: Sure?
search: Search in news
news_bulletin:
campus_news: Campus News
more: more+
create_news_bulletin_category_success: News category was successfully created
create_news_bulletin_success: News was successfully created
editing_news: Editing news
editing_news_category: Editing category
error:
no_avilb_cate_for_posting: You need a category to submit your post,please contact admin
hot: Hot
news_bulletins: NewsBulletins
related_links: Related Links
news: News
news_bulletin:
ut_prompt: Please select UT
category: Category
list_lower: " list"
title: Title
postdate: Postdate
approval: Approval
approval_setting: Approval Setting
approval_stat: Fact Check Status
approval_not_pass: 'Not Pass'
approval_not_pass_reason: 'Reason'
approval_pending: 'Pending'
approval_pass: 'Pass'
approval_setting_window_title: 'Unit'
update_success: Successfully Updated
unit_name: Unit name
# admin:
# action: Action
# add_language: Add language
# admin: Admin
# action: Action
# news: News
# asset: Asset
# attributes: Attributes
# cant_delete_self: You can not delete yourself.
# cant_revoke_self_admin: You can not revoke your admin role yourself.
# class: Class
# content: Content
# create_error_link: Error when creating link.
# create_error_page: Error when creating page.
# create_success_home: Homepage was successfully created.
# create_success_layout: Layout was successfully created.
# create_success_link: Link was successfully created.
# create_success_page: Page was successfully created.
# create_success_snippet: Snippet was successfully created.
# create_success_user: User was successfully created.
# data: Data
# delete_language: Delete language
# description: Description
# design: Design
# disable_language: Disable language
# editing_home: Editing homepage
# editing_layout: Editing layout
# editing_link: Editing link
# editing_page: Editing page
# editing_snippet: Editing snippet
# editing_user_info: Editing user information
# editing_user_role: Editing user role
# email: Email
# enable_language: Enable language
# file_name: Filename
# file_size: File size
# format: Format
# home: Home
# id: ID
# info: Information
# is_published: Is published
# item: Item
# key: Key
# language: Language
# layout: Layout
# layout_name: Layout name
# list_assets: Assets list
# list_designs: Designs list
# list_items: Items list
# list_puchases: Purchases list
# list_snippets: Snippets list
# list_users: Users list
# list_user_infos: User information list
# list_user_roles: User roles list
# member: Member
# move_down: Move down
# move_up: Move up
# multilingual: Multilingual
# my_avatar: My Avatar
# no_home_page: You don't have a homepage
# no_layout: You don't have a layout
# name: Name
# new_asset: New asset
# new_component: New component
# new_home: New homepage
# new_layout: New layout
# new_link: New link
# new_page: New page
# new_snippet: New snippet
# new_user: New user
# new_user_info: New user information
# new_user_role: New user role
# non_multilingual: Non multilingual
# options: Options
# orig_upload_file: Original filename
# position: Position
# published?: Published?
# purchase: Purchase
# registered: Registered
# role: Role
# roles: Roles
# title: Title
# translation: Translation
# type: Type
# up_to_date: Up-to-date
# update_error_link: Error when updating link.
# update_error_page: Error when updating page.
# update_success_content: Content was successfully updated.
# update_success_home: Homepage was successfully updated.
# update_success_layout: Layout was successfully updated.
# update_success_link: Link was successfully updated.
# update_success_page: Page was successfully updated.
# update_success_snippet: Snippet was successfully updated.
# update_success_user: User was successfully updated.
# url: URL
# user: User
# user_info: User information
# user_panel: User panel
# user_role: User role
panel:
new_news_category: New news category
search: Search for News
update_news_bulletin_category_success: News category was successfully updated
update_news_bulletin_success: News was successfully updated
ut_prompt: Please select Unit
Loaded 100 of 429 files, more files were not shown because too many files have changed in this diff. Show more