diff --git a/Guardfile b/Guardfile
new file mode 100644
index 00000000..4f561da0
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,22 @@
+guard 'livereload' do
+ watch(%r{app/.+\.(erb|haml)})
+ watch(%r{app/helpers/.+\.rb})
+ watch(%r{public/.+\.(css|js|html)})
+ watch(%r{config/locales/.+\.yml})
+end
+
+guard 'rspec', :version => 2 do
+ watch(%r{^spec/.+_spec\.rb})
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch('spec/spec_helper.rb') { "spec" }
+
+ # Rails example
+ watch('spec/spec_helper.rb') { "spec" }
+ watch('config/routes.rb') { "spec/routing" }
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
+ watch(%r{^spec/.+_spec\.rb})
+ watch(%r{^app/(.+)\.rb}) { |m| "spec/#{m[1]}_spec.rb" }
+ watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
+ watch(%r{^app/controllers/(.+)_(controller)\.rb}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
+ watch(%r{^app/views/(.+)/}) { |m| "spec/requests/#{m[1]}_spec.rb" }
+end
\ No newline at end of file
diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js
index 17b14841..2b4eb629 100755
--- a/app/assets/javascripts/orbitdesktop.js
+++ b/app/assets/javascripts/orbitdesktop.js
@@ -332,9 +332,9 @@ var orbitDesktop = function(dom){
if(j==0)$group.attr("id",tile.group_id);
if(tile.data_category == "app")
- $li = $('
'+tile.title+' ');
+ $li = $(''+tile.title+' ');
else
- $li = $(''+tile.title+' Loading...
');
+ $li = $(''+tile.title+' Loading...
');
$group.find('.col'+colindex).append($li);
}
@@ -1557,10 +1557,10 @@ var orbitDesktop = function(dom){
var widget = $(this);
if(widget.attr("data-category")=="widget"){
var widgename = widget.attr("data-content");
- $.getScript("/desktop_widgets/"+widgename+"/"+widgename+".js",function(){
- widget.find("div.appholder").load("/desktop_widgets/"+widgename+"/index.html.erb");
+ $.getScript(widget.attr("js-link"),function(){
+ widget.find("div.appholder").load(widget.attr("data-content"));
});
- // $(this).find("div.appholder").append( $(' ').attr('href', "/desktop_widgets/"+widgename+"/css/"+widgename+".css"));
+ $(this).find("div.appholder").append( ' ')
}
})
@@ -1697,3 +1697,4 @@ orbitDesktop.prototype.currentUsername = "Harry";
var uselessfunction = function(){
$.post("/desktop/temp_func",{sectionid:"4f83e7bbbd98eb041600001d"});
}
+
diff --git a/app/assets/stylesheets/member.css b/app/assets/stylesheets/member.css
index 436a9b6a..add8774a 100644
--- a/app/assets/stylesheets/member.css
+++ b/app/assets/stylesheets/member.css
@@ -287,36 +287,42 @@
padding: 0 20px 0 150px !important;
margin: 20px 0 0;
}
-.user-role .user-info {
+.role-block .user-info {
top: 23px;
margin-left: -135px;
width: 100px;
border-right: none;
box-shadow: none;
}
-.user-role .map-block h4 .gender {
+.role-block .map-block h4 .gender {
top: -1px;
bottom: auto;
left: -1px;
right: auto;
border-radius: 4px 0 0 0;
}
-.user-role .teacher h4 .gender {
+.role-block .teacher h4 .gender {
border-color: #186AB6 transparent transparent #186AB6;
}
-.user-role .student h4 .gender {
+.role-block .student h4 .gender {
border-color: #F38C08 transparent transparent #F38C08;
}
-.user-role .staff h4 .gender {
+.role-block .staff h4 .gender {
border-color: #139E2F transparent transparent #139E2F;
}
-.user-role .tab-content, .user-role .nav-pills {
+.role-block .tab-content, .role-block .nav-pills {
float: left;
}
-.user-role .nav-pills {
- margin-left: 10px;
+.role-block .nav-pills {
+ margin-bottom: 0;g
}
-.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input {
+.role-block .nav-pills > li > a {
+ margin-top: 0;
+}
+/*.role-block .control-group .inline {
+ float:
+}*/
+.plural .input-append input, .plural .input-append select, .plural .input-append .uneditable-input, .unRadius input {
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
@@ -338,4 +344,8 @@
-webkit-border-radius: 0 3px 3px 0;
-moz-border-radius: 0 3px 3px 0;
border-radius: 0 3px 3px 0;
+}
+.language-swich .tab-pane {
+ margin-bottom: 5px;
+ margin-right: 10px;
}
\ No newline at end of file
diff --git a/app/assets/stylesheets/site-map.css b/app/assets/stylesheets/site-map.css
index d7d3cda6..53e94c1f 100644
--- a/app/assets/stylesheets/site-map.css
+++ b/app/assets/stylesheets/site-map.css
@@ -81,37 +81,60 @@
background-color: #5EB92B;
font-size: 9px;
padding: 0px 10px;
- border-radius: 8px;
- line-height: 16px;
- height: 15px;
+ border-radius: 11px;
+ line-height: 20px;
+ height: 19px;
color: #FFF;
- width: 38px;
+ width: 40px;
border: none;
box-shadow: 0px 1px 0px rgba(255, 255, 255, 0.5), 0 0 5px rgba(13, 75, 23, 0.5) inset;
- margin-top: 2px;
+ margin-top: 1px;
}
/* for mamber role */
-
-.user-role .form-horizontal {
+.role-block .form-horizontal {
padding: 20px 10px 10px;
background-color: #FFF;
margin-bottom: 0;
border-radius: 0 0 4px 4px;
}
-.user-role .form-horizontal .control-label {
+.role-block [class*="type"] {
+ background-color: #F1F1F1;
+ padding: 20px 0 10px;
+ border-radius: 5px;
+ margin: -25px 0 40px;
+ /*box-shadow: 0px 1px 3px rgba(100,100,100,.4)*/
+}
+.role-block .form-horizontal .control-label {
width: 100px;
}
-.user-role .form-horizontal .controls {
+.role-block .form-horizontal .controls {
margin-left: 120px;
}
-.user-role .form-horizontal .controls>.input-append {
+.role-block .form-horizontal .controls>.input-append {
margin-bottom: 10px;
}
-.user-role .map-block {
+.role-block .form-horizontal legend .onoff {
+ margin-top: 4px;
+}
+.role-block .form-horizontal legend .btn-danger {
+ margin-right: 20px;
+}
+.role-block .form-horizontal legend>.clear {
+ margin-right: 150px;
+ min-width: 350px;
+}
+.role-block .map-block {
min-width: 440px;
}
-.user-role .map-block legend {
+.role-block .map-block .form-actions {
+ margin: 0;
+ padding: 10px 20px;
+}
+.role-block .map-block legend {
font-size: 18px;
line-height: 25px;
}
+.role-block .map-block legend .nav {
+ font-size: 12px;
+}
diff --git a/app/controllers/admin/infos_controller.rb b/app/controllers/admin/infos_controller.rb
index 5ffa6a06..cec5c5f4 100644
--- a/app/controllers/admin/infos_controller.rb
+++ b/app/controllers/admin/infos_controller.rb
@@ -1,10 +1,11 @@
class Admin::InfosController < ApplicationController
- layout "admin"
+ layout "new_admin"
before_filter :authenticate_user!
before_filter :is_admin?
before_filter :set_attribute, :only => [:index, :show, :new, :edit]
-
+ helper Admin::AttributeValuesViewHelper
+
def index
@attributes = Info.all.entries
render :template => 'admin/attributes/index'
@@ -32,8 +33,8 @@ class Admin::InfosController < ApplicationController
def update
@attribute = Info.find(params[:id])
- # binding.pry
@attribute.update_attributes(params[:info])
+ @attribute.attribute_fields.each{|t| t.destroy if t["to_delete"] == true}
respond_to do |format|
format.html { redirect_to :action => :index }
format.js { render 'admin/attributes/toggle_enable' }
@@ -47,10 +48,10 @@ class Admin::InfosController < ApplicationController
end
def add_attribute_field
- @attribute = Info.find(params[:id]) rescue nil
- if !@attribute
- @attribute = Info.new
- end
+ attribute = Info.find(params[:info_id]) rescue nil
+ @attribute_field_counter = attribute.attribute_fields.count
+ @attribute_field = attribute.attribute_fields.build
+ @attribute_field.save
end
protected
diff --git a/app/controllers/admin/users_new_interface_controller.rb b/app/controllers/admin/users_new_interface_controller.rb
index faf14f3a..95be536e 100644
--- a/app/controllers/admin/users_new_interface_controller.rb
+++ b/app/controllers/admin/users_new_interface_controller.rb
@@ -33,14 +33,10 @@ class Admin::UsersNewInterfaceController < ApplicationController
@student_data = []
@staff_data = []
-
- attribute_values = @user.attribute_values.reject{|att_val|
- # binding.pry if(att_val.id.to_s == '507fa1295789b52a540000e0')
- !att_val.attribute_field.locale and (att_val.attribute_field.neutral_for != I18n.locale.to_s)
- }
-
+ attribute_values = @user.attribute_values
attribute_values.each{|att_val|
- @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale)}) if att_val.attribute_field.attribute.key=="profile" rescue false
+ binding.pry if att_val.id.to_s == '5052dab52b5c49ae9d000006'
+ @profile_data.push({:name => att_val.attribute_field.title,:value =>att_val.get_value_by_locale(I18n.locale.to_s)}) if att_val.attribute_field.attribute.key=="profile" rescue false
}
@@ -75,7 +71,6 @@ class Admin::UsersNewInterfaceController < ApplicationController
end
def create
- binding.pry
puts params.to_yaml
# attribute_values_key = params[:user].has_key?('new_attribute_values') ? 'new_attribute_values' : 'attribute_values'
# attribute_values = params[:user].delete(attribute_values_key)
@@ -84,6 +79,7 @@ class Admin::UsersNewInterfaceController < ApplicationController
# @user.attribute_values.build(value)
# }
# @user.rebuild_sub_roles_from_attribute_values!(attribute_values)
+ binding.pry
if @user.save
flash[:notice] = t('create.success.user')
redirect_to :action => :index
diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb
index 286ec1c4..ff657441 100644
--- a/app/controllers/desktop_controller.rb
+++ b/app/controllers/desktop_controller.rb
@@ -103,11 +103,41 @@ class DesktopController< ApplicationController
def getgroups
@section = Section.find(params["sectionid"])
@groups = @section.groups
- a = Array.new
+
+ gr = Array.new
@groups.each do |group|
- a << group.tiles
+ a = Array.new
+ t = group.tiles
+ t.each do |tile|
+ data_content = ""
+ jsfile = []
+ cssfile = ""
+ shape = "w1 h1"
+ if tile.data_category == "widget"
+ widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
+ # data_content = widge.widget_layout.file
+ data_content = "desktop/widget_layout?id="+tile.desktop_widget_id.to_s
+ jsfile = widge.javascripts.collect{|js| js.file}
+ cssfile = widge.css_default.file
+ shape = widge.shape
+ title = widge.name
+ else
+ data_content = tile.data_content
+ title = tile.title
+ end
+ a << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title}
+ end
+ gr << a
end
- render :json =>a.to_json
+ render :json =>gr.to_json
+ end
+
+ def widget_layout
+ widget = DesktopWidget.find(params[:id])
+ link = ' '
+ content = widget.widget_layout.body
+ dhtml = link + content
+ render :text => dhtml.html_safe
end
def getsectionlist
diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb
index 14307022..fc3f36ab 100644
--- a/app/controllers/desktop_publications_controller.rb
+++ b/app/controllers/desktop_publications_controller.rb
@@ -8,6 +8,7 @@ class DesktopPublicationsController< ApplicationController
end
def journal_p_add
+ debugger
render "desktop/journal_pages/add", :layout => false
end
diff --git a/app/controllers/desktop_widgets_controller.rb b/app/controllers/desktop_widgets_controller.rb
new file mode 100644
index 00000000..2605f367
--- /dev/null
+++ b/app/controllers/desktop_widgets_controller.rb
@@ -0,0 +1,62 @@
+class DesktopWidgetsController < OrbitBackendController
+ require "net/http"
+ require "uri"
+ require 'zip/zip'
+
+ def index
+ end
+
+ def upload
+ if !params[:desktop_widget].nil?
+ temp_file = Tempfile.new("temp_file")
+ original_file = params[:desktop_widget][:package_file]
+ #if original_file.content_type == 'application/zip'
+ temp_file.write(original_file.read.force_encoding('UTF-8'))
+ temp_file.rewind
+ filename = File.basename(original_file.original_filename,".zip")
+ unzip_widget(temp_file, filename)
+ #else
+ # flash[:error] = "Upload file should be in zip format"
+ #end
+ temp_file.close
+ end
+ end
+
+ def unzip_widget(file, zip_name)
+ Zip::ZipFile.open(file) { |zip_file|
+ dw = DesktopWidget.new.from_json(zip_file.read("#{zip_name}/settings.json"))
+ Dir.mktmpdir('f_path') { |dir|
+ javascripts_entries = []
+ images_entries = []
+
+ zip_file.entries.each do |entry|
+ case (path = entry.to_s)
+ when /\A(#{zip_name})\/(default\.css)\z/
+ #for default css
+ dw.build_css_default(:file => get_temp_file(zip_file, dir, entry))
+ when /\A(#{zip_name})\/(widget\.html)\z/ #for layout html
+ dw.build_widget_layout(:file => get_temp_file(zip_file, dir, entry))
+ when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
+ javascripts_entries << entry
+ when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
+ images_entries << entry
+ end
+ end
+
+ ['javascripts', 'images'].each do |type|
+ eval("#{type}_entries").each do |entry|
+ eval("dw.#{type}").build(:file => get_temp_file(zip_file, dir, entry))
+ end
+ end
+ }
+ dw.save
+ }
+ end
+ def get_temp_file(zip_file, dir, entry)
+ filename = File.basename(entry.to_s)
+ temp_file = File.new(dir + '/' + filename, 'w+')
+ temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
+ temp_file
+ end
+
+end
\ No newline at end of file
diff --git a/app/controllers/otheraccounts_controller.rb b/app/controllers/otheraccounts_controller.rb
index 454f108e..d946bd3c 100644
--- a/app/controllers/otheraccounts_controller.rb
+++ b/app/controllers/otheraccounts_controller.rb
@@ -1,4 +1,4 @@
-class OtheraccountsController< ApplicationController
+class Desktop::OtheraccountsController< ApplicationController
require 'open-uri'
require 'rexml/document'
require 'net/http'
diff --git a/app/helpers/admin/attribute_values_view_helper.rb b/app/helpers/admin/attribute_values_view_helper.rb
new file mode 100644
index 00000000..9a724c96
--- /dev/null
+++ b/app/helpers/admin/attribute_values_view_helper.rb
@@ -0,0 +1,16 @@
+module Admin::AttributeValuesViewHelper
+ OPT = [
+ ["YYYY / MM / DD hh : mm","format1"],
+ ["YYYY / MM / DD","format2"],
+ ["YYYY / MM","format3"],
+ ["YYYY","format4"]
+ ]
+ def show_type_panel(attribute_field,type)
+ markup = attribute_field.markup
+ LIST[:markups][markup]["panel"] == type ? type : [type,'hide'].join(" ")
+ end
+
+ def name_to_id(str)
+ str.gsub(/\]/,'').gsub(/\[/,"_")
+ end
+end
\ No newline at end of file
diff --git a/app/helpers/attribute_fields_helper.rb b/app/helpers/attribute_fields_helper.rb
index af805daa..9050b9e6 100644
--- a/app/helpers/attribute_fields_helper.rb
+++ b/app/helpers/attribute_fields_helper.rb
@@ -9,14 +9,18 @@ module AttributeFieldsHelper
include ActionView::Helpers::RenderingHelper
def block_helper(user,index,disable = false)
- @index = index
- @markup_options = markup_options.merge(:disabled=>disable)
- @user = user
- @attribute_value = @user.get_value_from_field_id(id)
- @new_attribute = @attribute_value.nil?
- @attribute_value = @attribute_value || @user.attribute_values.build(attribute_field_id: id)
- @prefiled_value = @attribute_value.get_values
- return instance_eval("render_#{markup}") #rescue ""
+ unless self.disabled
+ @index = index
+ @markup_options = markup_options.merge(:disabled=>disable,:func=>"input_unit")
+ @user = user
+ @attribute_value = @user.get_value_from_field_id(id)
+ @new_attribute = @attribute_value.nil?
+ @attribute_value = @attribute_value || @user.attribute_values.build( attribute_field_id: id )
+ @prefiled_value = @attribute_value.value
+ @panel_setting = self.get_data
+ return instance_eval("render_#{markup}") #rescue ""
+
+ end
end
def lang_tab(str,lang)
@@ -24,6 +28,7 @@ module AttributeFieldsHelper
end
def render_address
+ #NP
control_group_wrapper do |key,value|
result = ''.html_safe
@@ -44,36 +49,55 @@ module AttributeFieldsHelper
end
def render_checkbox
+
@prefiled_value ||=[]
- markup_value = eval(self.markup_value) rescue {}
+ # begin
+ # markup_value = eval(self.markup_value)
+ # rescue
+ # markup_value = self.markup_value
+ # ensure
+ # markup_value ||= {}
+ # end
+
control_group_wrapper do
- markup_value.collect do |key,value|
- label_tag(key,check_box_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
+ a = self[:option_list].collect do |key,value|
+ label_tag(key,check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
end.join rescue ""
end
end
def render_date
- control_group_wrapper{date_select(get_field_name_base+"[value]",nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
+ #NP
+ control_group_wrapper{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
end
def render_date_durnation #Need re-write low priority
-
+
end
def render_radio_button
@prefiled_value ||=[]
- markup_value = eval(self.markup_value) rescue {}
+ # begin
+ # markup_value = eval(self.markup_value)
+ # rescue
+ # markup_value = self.markup_value
+ # ensure
+ # markup_value ||= {}
+ # end
control_group_wrapper do
- markup_value.collect do |key,value|
- label_tag(key,radio_button_tag(get_field_name_base+"[value][#{key}]", value[I18n.locale.to_s], (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
- end.join rescue ""
+ self[:option_list].collect do |key,value|
+ label_tag(key,radio_button_tag(get_field_name_base, key , (@prefiled_value.include?(key) ? true : false), {})+value[I18n.locale.to_s],@markup_options.merge(:class=>"control-label"))
+ end.join
end
end
def render_select
- markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
- control_group_wrapper{select_tag( get_field_name_base+"[value]",options_for_select(markup_value.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
+
+ prompt = @panel_setting[:prompt][I18n.locale] rescue nil
+ @markup_options.merge!(:prompt => prompt) unless prompt.nil?
+ # markup_value = (self.markup_value.is_a?(Hash) ? self.markup_value : eval(self.markup_value) )rescue {}
+ # check self[:option_list].collect{|p| [p[1][I18n.locale.to_s],p[0]]}
+ control_group_wrapper{select_tag( get_field_name_base,options_for_select(self.option_list.collect{|p| [p[1][I18n.locale.to_s],p[0]]},@prefiled_value),@markup_options)} rescue ""
end
def render_text_area
@@ -81,28 +105,35 @@ module AttributeFieldsHelper
if(add_more and value.is_a?(Hash))
values = value
values.each_with_index.collect do |value,index|
- text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
+ place_holder= @panel_setting["placeholder"][key]
+ text_area_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder))
end.join.html_safe
else
value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
- key = can_muti_lang_input ? "[#{key}]" : "[value]"
- text_area_tag(get_field_name_base + key, value,@markup_options)
+ key = can_muti_lang_input ? "[#{key}]" : ""
+ place_holder= @panel_setting["placeholder"][I18n.locale.to_s] rescue ''
+ text_area_tag(get_field_name_base + key, value,@markup_options.merge(:placeholder=>place_holder))
end
end
end
def render_text_field
control_group_wrapper do |key,value|
- if(add_more and value.is_a?(Hash))
+ if(add_more)
values = value
- values.each_with_index.collect do |value,index|
-
- text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options)
- end.join.html_safe
+ result = ""
+ unless values.nil?
+ result = values.each_with_index.collect do |value,index|
+ place_holder= @panel_setting["placeholder"][key]
+ text_field_tag(get_field_name_base + (key.nil? ? '' : "[#{key}][#{index}]"), value.last,@markup_options.merge(:placeholder=>place_holder))
+ end.join.html_safe
+ end
+ result
else
- value = can_muti_lang_input ? @prefiled_value[key] : @prefiled_value
- key = can_muti_lang_input ? "[#{key}]" : "[value]"
- text_field_tag(get_field_name_base + key, value,@markup_options)
+ value = (can_muti_lang_input ? @prefiled_value[key] : @prefiled_value) rescue nil
+ key_field = can_muti_lang_input ? "[#{key}]" : ""
+ place_holder= @panel_setting["placeholder"][key] rescue ''
+ text_field_tag(get_field_name_base + key_field, value,@markup_options.merge(:placeholder=>place_holder))
end
end
end
@@ -121,12 +152,14 @@ protected
if can_muti_lang_input
result << "
"
result << "
"
+
VALID_LOCALES.collect do |key|
value = @prefiled_value[key.to_s] rescue nil
div_class = ["tab-pane" ,"fade"].join(" ")
div_class << (key == I18n.locale.to_s ? " active in" : '')
result << content_tag(:div,yield(key,value),:class=>div_class,:id=>"tab"+id.to_s+"_#{key}")
end
+
result << "
"
result << "
"
VALID_LOCALES.each do |key|
@@ -161,15 +194,13 @@ protected
def end_block
if @new_attribute
- hidden_field_tag(get_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}")
+ hidden_field_tag(get_basic_field_name_base+"[attribute_field_id]",id,:for=>"field_#{@index}")
else
- hidden_field_tag(get_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}")
+ hidden_field_tag(get_basic_field_name_base+"[id]",@attribute_value.id,:for=>"field_#{@index}")
end
end
- def get_field_name_base
- # "user[#{self.attribute._type.downcase.pluralize}][#{self.attribute._id.to_s}][attribute_values][#{attribute_value.id}]"
- # binding.pry if @attribute_value[:key] == 'status'
+ def get_basic_field_name_base
if @new_attribute
"user[new_attribute_values][#{@index}]"
else
@@ -177,12 +208,16 @@ protected
end
end
+ def get_field_name_base
+ get_basic_field_name_base + "[value]"
+ end
+
def label
- label_tag(key,title,:class=>"control-label")
+ label_tag(key,title,:class=>"control-label",:func => "field_label")
end
def can_muti_lang_input
- locale and LIST[:markups][markup]["muti_lang_input_supprt"]
+ LIST[:markups][markup]["muti_lang_input_supprt"] #and locale
end
def can_add_more
diff --git a/app/models/design/css_default.rb b/app/models/design/css_default.rb
index 3ee5a58c..bd4baa8c 100644
--- a/app/models/design/css_default.rb
+++ b/app/models/design/css_default.rb
@@ -1,5 +1,8 @@
class CssDefault < Stylesheet
- belongs_to :design
+ # belongs_to :design
+ # belongs_to :desktop_widget
+
+ belongs_to :css, polymorphic: true
end
diff --git a/app/models/design/design.rb b/app/models/design/design.rb
index c9d87982..54870a89 100644
--- a/app/models/design/design.rb
+++ b/app/models/design/design.rb
@@ -8,11 +8,11 @@ class Design
field :title, :type => String
field :version, :type => String
- has_one :css_default, :autosave => true, :dependent => :destroy
+ has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :layout, :autosave => true, :dependent => :destroy
has_one :css_reset, :autosave => true, :dependent => :destroy
- has_many :images, :autosave => true, :dependent => :destroy
- has_many :javascripts, :autosave => true, :dependent => :destroy
+ has_many :images,as: :imgs, :autosave => true, :dependent => :destroy
+ has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
has_many :pages
has_many :themes, :autosave => true, :dependent => :destroy
diff --git a/app/models/design/image.rb b/app/models/design/image.rb
index 91c4a733..d1a57d7f 100644
--- a/app/models/design/image.rb
+++ b/app/models/design/image.rb
@@ -10,7 +10,10 @@ class Image
mount_uploader :file, ImageUploader
- belongs_to :design
+ # belongs_to :design
+ # belongs_to :desktop_widget
+
+ belongs_to :imgs, polymorphic: true
before_save :set_name
diff --git a/app/models/design/javascript.rb b/app/models/design/javascript.rb
index 439e3b98..808679d7 100644
--- a/app/models/design/javascript.rb
+++ b/app/models/design/javascript.rb
@@ -1,3 +1,6 @@
class Javascript < DesignFile
- belongs_to :design
+ # belongs_to :design
+ # belongs_to :desktop_widget
+
+ belongs_to :js, polymorphic: true
end
diff --git a/app/models/design/stylesheet.rb b/app/models/design/stylesheet.rb
index 525e40f3..5e9a5775 100644
--- a/app/models/design/stylesheet.rb
+++ b/app/models/design/stylesheet.rb
@@ -1,36 +1,40 @@
-class Stylesheet < DesignFile
- belongs_to :design
- mount_uploader :file_orig, AssetUploader
-
- def parse_urls
- orig_content = content = self.file.read.force_encoding("UTF-8")
- # self.remove_file!
- # self.remove_file_orig!
- names = []
- images = self.design.images
- content.scan(/(?<=url)(.*?)(?=\))/){
- css_name = $1.gsub(' ','').gsub('(','')
- name = File.basename(css_name).gsub(/[\\\"]/, '')
- image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil
- image.update_attribute(:in_css, true) if image
- file_name = image.file_url rescue nil
- names << [css_name, file_name]
- }
- names.each do |name|
- content.gsub!(name[0], name[1]) if name[1]
- end
- Dir.mktmpdir('f_path') { |dir|
- orig_file_name = self.file_identifier
-
- temp_file = File.new(dir + '/' + orig_file_name, 'w+')
- temp_file.write orig_content.force_encoding("UTF-8")
- self.file_orig = temp_file
-
- temp_file = File.new(dir + '/' + orig_file_name, 'w+')
- temp_file.write content.force_encoding("UTF-8")
- self.file = temp_file
- self.save
- }
- end
-
-end
+class Stylesheet < DesignFile
+ # belongs_to :design
+ mount_uploader :file_orig, AssetUploader
+
+ def parse_urls
+ orig_content = content = self.file.read.force_encoding("UTF-8")
+ # self.remove_file!
+ # self.remove_file_orig!
+ names = {}
+ images = self.css.images
+ content.scan(/(?<=url)(.*?)(?=\))/){
+ css_name = $1.gsub(' ','').gsub('(','')
+ unless names.has_key?(css_name)
+ name = File.basename(css_name).gsub(/[\\\"]/, '')
+ image = images.detect{ |i| i.file_identifier.eql?(name) } rescue nil
+ if image
+ image.update_attribute(:in_css, true)
+ file_name = image.file_url
+ names.merge!({css_name => file_name})
+ end
+ end
+ }
+ names.each_pair do |key, value|
+ content.gsub!(key, value)
+ end
+ Dir.mktmpdir('f_path') { |dir|
+ orig_file_name = self.file_identifier
+
+ temp_file = File.new(dir + '/' + orig_file_name, 'w+')
+ temp_file.write orig_content.force_encoding("UTF-8")
+ self.file_orig = temp_file
+
+ temp_file = File.new(dir + '/' + orig_file_name, 'w+')
+ temp_file.write content.force_encoding("UTF-8")
+ self.file = temp_file
+ self.save
+ }
+ end
+
+end
diff --git a/app/models/desktop.rb b/app/models/desktop/desktop.rb
similarity index 70%
rename from app/models/desktop.rb
rename to app/models/desktop/desktop.rb
index e8c1e9c4..6633005f 100644
--- a/app/models/desktop.rb
+++ b/app/models/desktop/desktop.rb
@@ -2,14 +2,15 @@ class Desktop
include Mongoid::Document
include Mongoid::Timestamps
- field :theme, default: "4f8d3f493b67fcd05f086359"
+ field :theme, default: "4f8d3f533b67fcd05f08635a"
field :customtheme
field :wallpaper
belongs_to :user
+ has_and_belongs_to_many :desktop_widgets, :autosave => true
has_many :sections, :autosave => true, :dependent => :destroy
- has_many :desktop_widgets, :autosave => true, :dependent => :destroy
+ # has_many :desktop_widgets, :autosave => true, :dependent => :destroy
before_create :initialize_section
diff --git a/app/models/desktop_theme.rb b/app/models/desktop/desktop_theme.rb
similarity index 100%
rename from app/models/desktop_theme.rb
rename to app/models/desktop/desktop_theme.rb
diff --git a/app/models/desktop/desktop_widget.rb b/app/models/desktop/desktop_widget.rb
new file mode 100644
index 00000000..feb40aa7
--- /dev/null
+++ b/app/models/desktop/desktop_widget.rb
@@ -0,0 +1,33 @@
+class DesktopWidget
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ include ParserLayoutWidget
+
+ field :name
+ field :author
+ field :shape
+ field :version, :type => String
+
+ has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
+ has_one :widget_layout, :autosave => true, :dependent => :destroy
+ has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
+ has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
+ has_and_belongs_to_many :desktops, :autosave => true
+ belongs_to :tiles, :autosave => true
+
+ accepts_nested_attributes_for :images, :allow_destroy => true
+ accepts_nested_attributes_for :javascripts, :allow_destroy => true
+
+ after_save :parse_css_for_images
+
+ # belongs_to :desktop
+
+
+ protected
+
+ def parse_css_for_images
+ self.css_default.parse_urls
+ parse_widget_for_images(self)
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/desktop/group.rb b/app/models/desktop/group.rb
new file mode 100644
index 00000000..2c1992f0
--- /dev/null
+++ b/app/models/desktop/group.rb
@@ -0,0 +1,18 @@
+class Group
+ include Mongoid::Document
+ include Mongoid::Timestamps
+
+ belongs_to :section
+ has_many :tiles, :autosave => true, :dependent => :destroy
+ before_create :initialize_tile
+
+ def initialize_tile
+ self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes")
+ self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word")
+ widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id}
+ for i in 0..3
+ self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: widgets[i])
+ end
+ end
+end
+
\ No newline at end of file
diff --git a/app/models/other_account.rb b/app/models/desktop/other_account.rb
similarity index 100%
rename from app/models/other_account.rb
rename to app/models/desktop/other_account.rb
diff --git a/app/models/section.rb b/app/models/desktop/section.rb
similarity index 100%
rename from app/models/section.rb
rename to app/models/desktop/section.rb
diff --git a/app/models/tile.rb b/app/models/desktop/tile.rb
similarity index 86%
rename from app/models/tile.rb
rename to app/models/desktop/tile.rb
index 70066d1b..91840d8a 100644
--- a/app/models/tile.rb
+++ b/app/models/desktop/tile.rb
@@ -9,6 +9,6 @@ class Tile
field :title
belongs_to :group
-
-
+ has_one :desktop_widget
+
end
diff --git a/app/models/desktop/widget_layout.rb b/app/models/desktop/widget_layout.rb
new file mode 100644
index 00000000..5bf24805
--- /dev/null
+++ b/app/models/desktop/widget_layout.rb
@@ -0,0 +1,18 @@
+class WidgetLayout < DesignFile
+
+ attr_reader :content
+
+ field :body
+
+ belongs_to :desktop_widget
+
+
+ def content
+ self.file.read.force_encoding("UTF-8") rescue ''
+ end
+
+ def self.exist_one?
+ WidgetLayout.count > 0
+ end
+
+end
diff --git a/app/models/desktop_widget.rb b/app/models/desktop_widget.rb
deleted file mode 100644
index eb0446de..00000000
--- a/app/models/desktop_widget.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-class DesktopWidget
- include Mongoid::Document
- include Mongoid::Timestamps
-
- field :name
- field :author
- field :shape
- field :desktop_id
- field :status
- field :section
-
- belongs_to :desktop
-end
\ No newline at end of file
diff --git a/app/models/group.rb b/app/models/group.rb
deleted file mode 100644
index 7346ad1e..00000000
--- a/app/models/group.rb
+++ /dev/null
@@ -1,19 +0,0 @@
-class Group
- include Mongoid::Document
- include Mongoid::Timestamps
-
- belongs_to :section
- has_many :tiles, :autosave => true, :dependent => :destroy
- before_create :initialize_tile
-
- def initialize_tile
- self.tiles.build(data_category: "widget", data_content: "timetable", position: 1, shape: "w2 h2", title: "Tiime Table")
- self.tiles.build(data_category: "app", data_content: "quotes", position: 2, shape: "w1 h1", title: "Quotes")
- self.tiles.build(data_category: "widget", data_content: "weather", position: 3, shape: "w2 h2", title: "Weather")
- self.tiles.build(data_category: "widget", data_content: "clock", position: 4, shape: "w2 h1", title: "Clock")
- self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 5, shape: "w1 h1", title: "Daily English Word")
- self.tiles.build(data_category: "widget", data_content: "school_events", position: 6, shape: "w2 h1", title: "School Events")
- end
-
-end
-
\ No newline at end of file
diff --git a/app/models/user/attribute.rb b/app/models/user/attribute.rb
index faa5876a..c0970863 100644
--- a/app/models/user/attribute.rb
+++ b/app/models/user/attribute.rb
@@ -11,6 +11,7 @@ class Attribute
has_many :attribute_fields, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :attribute_fields, :allow_destroy => true
+
def is_built_in?
self.built_in
end
diff --git a/app/models/user/attribute_field.rb b/app/models/user/attribute_field.rb
index 0d9999b3..a94a38a2 100644
--- a/app/models/user/attribute_field.rb
+++ b/app/models/user/attribute_field.rb
@@ -5,26 +5,43 @@ class AttributeField
include ::AttributeFieldsHelper
field :key
- field :markup
- field :markup_value ,:type => Hash
+ field :markup ,:default=>"text_field"
+ field :option_list ,:type => Hash,:default => {}
field :markup_options,:type => Hash
- field :locale, :type => Boolean, :default => true
+ # field :locale, :type => Boolean, :default => true
# field :list_options, :type => Array
field :built_in, :type => Boolean, :default => false
field :disabled, :type => Boolean, :default => false
- field :add_more,:type => Boolean, :default => false
+ field :to_delete,:type=> Boolean,:default => false
+ field :typeA,:type=> Hash,:default=>{}
+ field :typeB,:type=> Hash,:default=>{}
+ field :typeC,:type=> Hash,:default=>{:claendar=>"west_claendar"}
+ field :typeD,:type=> Hash,:default=>{}
+ field :typeE,:type=> Hash,:default=>{}
+
#field :title, localize: true
- field :locale_title, localize: true
- field :neutral_title
- field :neutral_for
+ field :title, localize: true
+
belongs_to :attribute
# belongs_to :role
has_many :attribute_values,:autosave => true, :dependent => :destroy
-
+ before_save :check_option_list
# validates_uniqueness_of :key
+ def add_more
+ (get_data["add_more"] == "true" ? true : false) rescue false
+ end
+
+ def locale
+ default = true
+ if get_data["locale"].nil?
+ return default
+ else
+ (get_data["locale"] == "true" ? true : false) rescue default
+ end
+ end
def self_defined_markup_options?
(self.attribute.role.method(self[:key].pluralize.to_sym) && self.attribute.role.method(self[:key].pluralize+"_for_"+markup)) rescue false
@@ -36,16 +53,16 @@ class AttributeField
end
end
- def markup_value
+ def option_list
if self_defined_markup_options?
#Class need to have corresponding field and value agent
# Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function
method = self.attribute.role.method(self[:key].pluralize+"_for_"+markup)
return (method.call rescue {})
- elsif self[:markup_value].nil? || (self[:markup_value].empty?)
+ elsif self[:option_list].nil? || (self[:option_list].empty?)
return {}
else
- return self[:markup_value]
+ return self[:option_list]
end
end
@@ -68,36 +85,49 @@ class AttributeField
self.attribute.role
end
- def title_translations
- if locale
- return locale_title_translations
- else
- return Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
- end
+ def panel
+ panel = LIST[:markups][self[:markup]]["panel"]
end
- def title_translations=(var)
- if locale
- self.locale_title_translations = var
- end
+ def get_data
+ self[panel]
end
- def title
- if locale
- return self.locale_title
- else
- return self.neutral_title
- end
- end
- def title=(var)
- # binding.pry
- if locale
- self.locale_title = var
- else
- self.neutral_title = var
- end
- end
+ # def title_translations
+ # if locale
+ # return self.locale_title_translations
+ # else
+ # return self[:neutral_title] #Hash[VALID_LOCALES.map{|d| [d,neutral_title]}]
+ # end
+ # end
+
+ # def title_translations=(var)
+ # if locale
+ # self.locale_title_translations = var
+ # end
+ # end
+
+ # def title
+ # if locale
+ # return self.locale_title
+ # else
+ # return self.neutral_title
+ # end
+ # end
+
+ # def check_title
+ # if locale
+ # self.locale_title_translations = self[:temp_title]
+ # else
+ # self.neutral_title = self[:temp_title]
+ # end
+ # self.unset("temp_title")
+ # end
+
+ # def title=(var)
+ # self["temp_title"] = var
+ # end
# # Convert the string list_options into an array
# def select_list_options=(var)
@@ -117,4 +147,9 @@ class AttributeField
self.disabled
end
+protected
+ def check_option_list
+ self[:option_list] = self[panel]["option_list"]
+ end
+
end
diff --git a/app/models/user/attribute_value.rb b/app/models/user/attribute_value.rb
index a1eb5466..d6500fbf 100644
--- a/app/models/user/attribute_value.rb
+++ b/app/models/user/attribute_value.rb
@@ -10,11 +10,56 @@ class AttributeValue
belongs_to :user
before_save :check_key
-
+ before_save :data_proc
# NO_MULTI_TAG = ["select","date","radio_button","checkbox","date_durnation"]
+
+ def data_proc
+ # binding.pry
+ # binding.pry if self.attribute_field.markup == 'radio_button'
+ # if self.attribute_field
+ case self.attribute_field.markup
+ when 'text_field','text_area'
+ # binding.pry
+ self[:temp_data].each{|key,val|
+ self[key] = val
+ } unless self[:temp_data].nil?
+ when 'select','date','radio_button'
+ self["val"] = self[:temp_data]
+ when 'checkbox'
+ self["val"] = self[:temp_data].keys rescue {}
+ end #end of case
+ else # if not locale
+ case self.attribute_field.markup
+ when 'text_field','text_area'
+ self["val"] = self[:temp_data]
+ when 'select','date','radio_button'
+ self["val"] = self[:temp_data]
+ when 'checkbox'
+ self["val"] = self[:temp_data].keys rescue {}
+ end #end of case
+ # end #of if self.attribute_field
+ self.unset('temp_data')
+ end
+
+ def value
+
+ result=""
+ if self.attribute_field.locale && (self.attribute_field.markup == "text_field" || self.attribute_field.markup == "text_area")
+ result= Hash[VALID_LOCALES.collect{|lang| [lang,self[lang.to_sym]]}]
+ else
+ result = self["val"]
+ end
+ result
+ end
+
+ def value=(value)
+ #save everything to temp_data waiting for futher process
+ # binding
+ self[:temp_data] = value
+ end
+
def check_key
- binding.pry if attribute_field.nil?
self.key = attribute_field.key
end
@@ -27,45 +72,46 @@ class AttributeValue
end
def get_value_by_locale(locale)
+
case self.attribute_field.markup
when "text_field"
- self.attribute_field.locale ? self[locale] : self[:value]
+ self.attribute_field.locale ? self[locale.to_s] : self.value
when "select"
markup_values = self.attribute_field.self_defined_markup_options? ? self.attribute_field.markup_value : eval(self.attribute_field.markup_value)
- markup_values[self[:value]][locale.to_s] rescue 'NoData'
+ markup_values[self.value][locale.to_s] rescue 'NoData'
when "text_area"
- self.attribute_field.locale ? self[locale] : self[:value]
+ self.attribute_field.locale ? self[locale.to_s] : self.value
when "date"
- Date.new(self[:value]["(1i)"].to_i,self[:value]["(2i)"].to_i,self[:value]["(3i)"].to_i) rescue nil
+ Date.new(self[:val]["(1i)"].to_i,self[:val]["(2i)"].to_i,self[:val]["(3i)"].to_i) rescue nil
when "addr"
- self[:value]
+ self.value
when "radio_button"
markup_values = eval(self.attribute_field.markup_value)
- markup_values[self[:value].first[0]][locale.to_s]
- when "checkbox"
- markup_values = eval(self.attribute_field.markup_value)
- self[:value].keys.collect{|key| markup_values[key][locale.to_s] }.join(",")
+ markup_values[:value][locale.to_s]
+ when "checkbox"
+ markup_values = self.attribute_field.markup_value
+ self[:value].keys.collect{|key| markup_values[key][locale.to_s]}.join(",")
when "date_durnation"
- self[:value]
+ self.value
else
- self.attribute_field.locale ? self[locale] : self[:value]
+ self.attribute_field.locale ? self[locale.to_s] : self.value
end
end
- def get_values
- unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup )
- if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
- return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}]
- else
- return get_value_by_locale("")
- end
- else
- if self.attribute_field.markup == "select"
- self[:value]
- else
- self[:value].keys rescue self[:value]
- end
- end
- end
+ # def get_values
+ # unless ['select','checkbox','radio_button'].include?(self.attribute_field.markup )
+ # if self.attribute_field.locale && LIST[:markups][self.attribute_field.markup]["muti_lang_input_supprt"]
+ # return Hash[VALID_LOCALES.collect{|lang| [lang,get_value_by_locale(lang.to_sym)]}]
+ # else
+ # return get_value_by_locale("")
+ # end
+ # else
+ # if self.attribute_field.markup == "select"
+ # self[:value]
+ # else
+ # self[:value].keys rescue self[:value]
+ # end
+ # end
+ # end
end
diff --git a/app/models/user/user.rb b/app/models/user/user.rb
index 5893dae2..4f645f3b 100644
--- a/app/models/user/user.rb
+++ b/app/models/user/user.rb
@@ -35,7 +35,8 @@ class User
before_save :save_roles
scope :remote_account, where(:nccu_id.ne => nil)
- validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
+ # validates_uniqueness_of :email,:message=> I18n.t("devise.registrations.email_not_unique")
+
# def new_attribute_values=(vars)
# binding.pry
# end
@@ -176,7 +177,7 @@ class User
end
def initialize_desktop
- self.build_desktop
+ self.build_desktop(desktop_widget_ids: DesktopWidget.all.collect{|widget| widget.id})
end
protected
diff --git a/app/views/admin/attributes/edit.html.erb b/app/views/admin/attributes/edit.html.erb
index d45382f6..da159134 100644
--- a/app/views/admin/attributes/edit.html.erb
+++ b/app/views/admin/attributes/edit.html.erb
@@ -1,14 +1,139 @@
-<% content_for :secondary do %>
- <%= render 'admin/users/side_bar' %>
+ <%= form_for @attribute,:url => admin_info_path(@attribute) ,:class=> "form-horizontal" do |f| %>
+
+
+
<%= t("admin.info")%>
+
+
+
+
<%= t("admin.attributes")%>
+ <%= render :partial=>"attribute_field",:collection=>@attribute.attribute_fields%>
+
+
+
+ <% end %>
+<% content_for :page_specific_css do -%>
+ <%= stylesheet_link_tag "member" %>
+ <%= stylesheet_link_tag "site-map" %>
<% end %>
-
- <%= form_for @attribute, :url => eval("admin_#{@attribute_type}_path(@attribute)") do |f| %>
- <%= f.error_messages %>
- <%= render :partial => "admin/#{@attribute_type}s/form", :locals => { :f => f, :is_new => false } %>
-
- <%= link_back %>
- <%= link_to t('update'), "#", :onclick=>"$('#edit_#{@attribute_type}_#{@attribute.id}').submit()" %>
-
- <% end %>
-
\ No newline at end of file
+<% content_for :page_specific_javascript do -%>
+
+<% end -%>
diff --git a/app/views/admin/infos/_attribute_field.html.erb b/app/views/admin/infos/_attribute_field.html.erb
index 12ed7828..95d60268 100644
--- a/app/views/admin/infos/_attribute_field.html.erb
+++ b/app/views/admin/infos/_attribute_field.html.erb
@@ -1,3 +1,100 @@
-<%= f.fields_for :attribute_fields, attribute_field do |f| %>
- <%= render :partial => 'admin/attributes/attribute_field', :object => attribute_field, :locals => {:f => f} %>
-<% end %>
\ No newline at end of file
+
diff --git a/app/views/admin/infos/_list_block.html.erb b/app/views/admin/infos/_list_block.html.erb
new file mode 100644
index 00000000..3c351418
--- /dev/null
+++ b/app/views/admin/infos/_list_block.html.erb
@@ -0,0 +1,45 @@
+ <% temp_field_name = field_name.gsub /\[\D*\]$/,'[temp]'%>
+
+ <%= hidden_field_tag "#{temp_field_name}[count]",((values.keys.collect{|t| t.to_i}.max rescue nil) || 0 ),:class=>"list_count"%>
+ <%= hidden_field_tag "#{temp_field_name}[name]",field_name,:class=>"field_name"%>
+
<%= t("admin.infos.list")%>
+
+
+
diff --git a/app/views/admin/infos/_placeholder_block.html.erb b/app/views/admin/infos/_placeholder_block.html.erb
new file mode 100644
index 00000000..9417e055
--- /dev/null
+++ b/app/views/admin/infos/_placeholder_block.html.erb
@@ -0,0 +1,25 @@
+ <% values ||=[]%>
+ <%= content_tag :div,:class=>"control-group language-swich #{class_ext rescue "" }" do%>
+ <%= (defined? label_ext) ? label_ext : t("admin.infos.placeholder") %>
+
+
+
+ <% @site_valid_locales.each do |locale| %>
+ <% active = (locale == @site_valid_locales.first ? "active in" : "'") %>
+ <%= content_tag :div,:class=>"tab-pane fade #{active}",:id=>"#{name_to_id(field_name)}_#{locale}" do%>
+ <% value = values[locale.to_s] rescue nil%>
+ <%= text_field(field_name, locale,:value=>value,:placeholder=>t("langs.#{locale}")) %>
+ <% end %>
+ <% end %>
+
+
+ <% @site_valid_locales.each do |locale| %>
+ <% active = (locale == @site_valid_locales.first ? "active" : "'") %>
+ <%=content_tag :li,:class=>active do %>
+ <%= link_to t("langs.#{locale}"),"##{name_to_id(field_name)}_#{locale}",:data=>{:toggle=>"tab"}%>
+ <% end %>
+ <% end %>
+
+
+
+ <% end %>
\ No newline at end of file
diff --git a/app/views/admin/infos/add_attribute_field.js.erb b/app/views/admin/infos/add_attribute_field.js.erb
new file mode 100644
index 00000000..693835e5
--- /dev/null
+++ b/app/views/admin/infos/add_attribute_field.js.erb
@@ -0,0 +1,6 @@
+$(".attributes").append('<%= escape_javascript(render :partial=>"attribute_field",:locals=>{:attribute_field=>@attribute_field,:attribute_field_counter=>@attribute_field_counter} )%>');
+ $(".dataType").change(function () {
+ $(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
+ $(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
+
+ })
\ No newline at end of file
diff --git a/app/views/admin/users_new_interface/edit.html.erb b/app/views/admin/users_new_interface/edit.html.erb
index d61886df..1e169520 100644
--- a/app/views/admin/users_new_interface/edit.html.erb
+++ b/app/views/admin/users_new_interface/edit.html.erb
@@ -14,7 +14,7 @@
<% end -%>
-<%= content_tag :div,:class=>"user-role site-map" do%>
+<%= content_tag :div,:class=>"user-role site-map role-block" do%>
<%= form_for @user, :url => admin_users_new_interface_path(@user), :html => { :multipart => true } do |f| %>
<%= f.error_messages %>
diff --git a/app/views/desktop/journal_pages/list.html.erb b/app/views/desktop/journal_pages/list.html.erb
index e32e4d6c..3d396711 100644
--- a/app/views/desktop/journal_pages/list.html.erb
+++ b/app/views/desktop/journal_pages/list.html.erb
@@ -61,6 +61,18 @@
+
@@ -72,4 +84,19 @@
-
\ No newline at end of file
+
+Panel::PersonalJournal::Plugin::WritingJournals
+
diff --git a/app/views/desktop_widgets/upload.html.erb b/app/views/desktop_widgets/upload.html.erb
new file mode 100644
index 00000000..19d3ff1a
--- /dev/null
+++ b/app/views/desktop_widgets/upload.html.erb
@@ -0,0 +1,12 @@
+Upload Widget Package
+
+ <%= form_tag '',:multipart => true,:action=>"post" do |f| %>
+
+
+ <%= file_field :desktop_widget,:package_file %>
+
+ <%= submit_tag %>
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/layouts/_side_bar_content.html.erb b/app/views/layouts/_side_bar_content.html.erb
index 61888acc..66e4542d 100644
--- a/app/views/layouts/_side_bar_content.html.erb
+++ b/app/views/layouts/_side_bar_content.html.erb
@@ -81,7 +81,7 @@
<% end -%>
<% end %>
-<%= content_tag :li, :class => active_for_controllers('archive_files', 'tags', 'archive_file_categorys') do -%>
+<%= content_tag :li, :class => active_for_controllers('archive_files', 'panel/archive/back_end/tags', 'archive_file_categorys') do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-asset') + content_tag(:span, t('admin.archive')), panel_archive_back_end_archive_files_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('archive_files', 'tags', 'archive_file_categorys')) do -%>
<%= content_tag :li, link_to((t('admin.all_articles') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, panel_archive_back_end_archive_files_path), :class => active_for_action('archive_file', 'index') %>
@@ -91,14 +91,14 @@
<% end -%>
<% end -%>
-<%= content_tag :li, :class => active_for_controllers('cals') || active_for_app_auth("calendar") do -%>
+<%= content_tag :li, :class => active_for_controllers('cals','panel/calendar/back_end/tags') || active_for_app_auth("calendar") do -%>
<%= link_to content_tag(:i, nil, :class => 'icons-calendar') + content_tag(:span, t('admin.calendar')), panel_calendar_back_end_cals_path %>
<%= content_tag :ul, :class => ("nav nav-list " + visible_for_controllers('cals','calendar_categories') ) do -%>
<%#= content_tag :li, link_to(t('admin.ad.all_banners'), admin_ad_banners_path), :class => active_for_action('ad_banners', 'index') %>
<%#= content_tag :li, link_to(t('admin.ad.new_banner'), new_admin_ad_banner_path), :class => active_for_action('ad_banners', 'new') %>
<%#= content_tag :li, link_to(t('admin.ad.new_image'), new_ad_image_admin_ad_banners_path), :class => active_for_action('ad_images', 'new') %>
- <%= content_tag :li, link_to((t('calendar.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %>
- <%#= content_tag :li, link_to(t('gallery.tags'), panel_gallery_back_end_tags_path), :class => active_for_action('/panel/gallery/back_end/tags', 'index') %>
+ <%= content_tag :li, link_to((t('admin.calendars') + content_tag(:i, nil, :class => 'icon-chevron-right')).html_safe, new_panel_calendar_back_end_cal_path), :class => active_for_action('cals','new') %>
+ <%= content_tag :li, link_to(t('admin.tags'), panel_calendar_back_end_tags_path), :class => active_for_action('/panel/calendar/back_end/tags', 'index') %>
<%#= content_tag :li, link_to(t('admin.module.authorization'),admin_module_app_manager_auth_proc_path(ModuleApp.first(conditions: {key: "gallery"}))), :class => active_for_app_auth('gallery') if (is_admin? rescue nil) %>
<% end -%>
<% end %>
diff --git a/app/views/shared/_address_modal_dialog.html.erb b/app/views/shared/_address_modal_dialog.html.erb
new file mode 100644
index 00000000..6e241074
--- /dev/null
+++ b/app/views/shared/_address_modal_dialog.html.erb
@@ -0,0 +1,13 @@
+
\ No newline at end of file
diff --git a/config/application.rb b/config/application.rb
index ccc4a65e..f0e40fcc 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -33,6 +33,7 @@ module Orbit
config.autoload_paths += %W(#{config.root}/app/models/meta)
config.autoload_paths += %W(#{config.root}/app/models/purchase)
config.autoload_paths += %W(#{config.root}/app/models/user)
+ config.autoload_paths += %W(#{config.root}/app/models/desktop)
# Include all helpers
# 'helper :all' must be removed in ApplicationController
diff --git a/config/list.yml b/config/list.yml
index b0cf253f..ebfff364 100644
--- a/config/list.yml
+++ b/config/list.yml
@@ -9,21 +9,27 @@ markups:
text_field:
muti_lang_input_supprt: true
ext_support: true
+ panel: typeA
select:
muti_lang_input_supprt: false
ext_support: false
+ panel: typeB
date:
muti_lang_input_supprt: false
ext_support: false
+ panel: typeC
text_area:
muti_lang_input_supprt: true
ext_support: false
+ panel: typeD
radio_button:
muti_lang_input_supprt: false
ext_support: false
+ panel: typeE
checkbox:
muti_lang_input_supprt: false
ext_support: false
+ panel: typeE
# date_durnation:
# muti_lang_input_supprt: false
# ext_support: false
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 621987ee..041e03d7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -158,6 +158,14 @@ en:
user: Users list
list_: List
list_lower: list
+ lists:
+ markups:
+ text_field: Text Field
+ select: Select
+ date: Date
+ text_area: Text Area
+ radio_button: Radio button
+ checkbox: Checkbox
login: Login
logout: Logout
mail:
@@ -407,7 +415,7 @@ en:
attributes: Attributes
author: Author
calendar: Calendar
- gprs: GPRS
+ gprs: GPS
cant_delete_self: You can not delete yourself.
cant_revoke_self_admin: You can not revoke your admin role yourself.
category: Category
diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml
index ec2b34f3..efa69994 100644
--- a/config/locales/zh_tw.yml
+++ b/config/locales/zh_tw.yml
@@ -158,6 +158,14 @@ zh_tw:
user: 使用者列表
list_: 列表
list_lower: 列表
+ lists:
+ markups:
+ text_field: 文字輸入框
+ select: 下拉選單
+ date: 日期
+ text_area: 文字輸入方塊
+ radio_button: 單選
+ checkbox: 多選
login: 登入
logout: 登出
mail:
@@ -342,8 +350,30 @@ zh_tw:
# : =======
errors:
at_least_one: 必須至少有一個值
-
admin:
+ infos:
+ add_attribute_field: 新增
+ save: 儲存
+ initial: 起始值
+ markup: 輸入模式
+ item_name: 資料表名稱
+ name: 名稱
+ options: 選項
+ multilingual: 多語言輸入
+ add_more: 使用者可自行延伸欄位
+ add: 新增
+ placeholder: 輸入協助
+ type: 類型
+ placeholder: 提示內容
+ list: 自定選單
+ is_range: 是
+ not_range: 否
+ date:
+ claendar: 紀年法
+ range: 本欄為時間區段
+ format: 格式
+ tw_claendar: 民國
+ west_claendar: 西元
access:
denied:
app:
diff --git a/config/routes.rb b/config/routes.rb
index 72841be5..27b87d90 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -141,7 +141,17 @@ Orbit::Application.routes.draw do
resources :users
end
- match '/desktop/'=>'desktop#index'
+ resources :desktop_widgets do
+ collection do
+ get 'upload'
+ get 'delete'
+ post 'upload'
+ end
+ end
+
+namespace :desktop do
+
+ match "/"=>"desktop#index"
# Sinatra Routes start
@@ -176,46 +186,50 @@ Orbit::Application.routes.draw do
# Sinatra Routes end
- match '/desktop/desktop'=>'desktop#desktop'
- match '/desktop/app_manager'=>'desktop#app_manager'
- match '/desktop/sections'=>'desktop#sections'
- match '/desktop/settings'=>'desktop#settings'
- match '/desktop/get_desktop_settings/'=>'desktop#get_desktop_settings'
- match '/desktop/save_desktop_settings/'=>'desktop#save_desktop_settings'
- match '/desktop/getgroups/'=>'desktop#getgroups'
- match '/desktop/getsectionlist/'=>'desktop#getsectionlist'
- match '/desktop/settingthemes/'=>'desktop#settingthemes'
- match '/desktop/settingsections/'=>'desktop#settingsections'
- match '/desktop/getapplist/'=>'desktop#getapplist'
- match '/desktop/newpositions/'=>'desktop#newpositions'
- match '/desktop/settingconnection/'=>'desktop#settingconnection'
+ match '/desktop'=>'desktop#desktop'
+ match '/app_manager'=>'desktop#app_manager'
+ match '/sections'=>'desktop#sections'
+ match '/settings'=>'desktop#settings'
+ match '/get_desktop_settings/'=>'desktop#get_desktop_settings'
+ match '/save_desktop_settings/'=>'desktop#save_desktop_settings'
+ match '/getgroups/'=>'desktop#getgroups'
+ match '/getsectionlist/'=>'desktop#getsectionlist'
+ match '/settingthemes/'=>'desktop#settingthemes'
+ match '/settingsections/'=>'desktop#settingsections'
+ match '/getapplist/'=>'desktop#getapplist'
+ match '/newpositions/'=>'desktop#newpositions'
+ match '/settingconnection/'=>'desktop#settingconnection'
+ match '/widget_layout' => 'desktop#widget_layout'
- match '/desktop/journal_p/'=>'desktop_publications#journal_p'
- match '/desktop/journal_p_list/'=>'desktop_publications#journal_p_list'
- match '/desktop/journal_p_add/'=>'desktop_publications#journal_p_add'
- match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
- match '/desktop/books' => 'desktop_publications#books'
- match '/desktop/books_list/'=>'desktop_publications#books_list'
- match '/desktop/books_add/'=>'desktop_publications#books_add'
+ match '/journal_p/'=>'desktop_publications#journal_p'
+ match '/journal_p_list/'=>'desktop_publications#journal_p_list'
+ match '/journal_p_add/'=>'desktop_publications#journal_p_add'
+ match '/books' => 'desktop_publications#books'
+ match '/books_list/'=>'desktop_publications#books_list'
+ match '/books_add/'=>'desktop_publications#books_add'
- match '/desktop/seminar_p' => 'desktop_publications#seminar_p'
- match '/desktop/seminar_p_list/'=>'desktop_publications#seminar_p_list'
- match '/desktop/seminar_p_add/'=>'desktop_publications#seminar_p_add'
+ match '/seminar_p' => 'desktop_publications#seminar_p'
+ match '/seminar_p_list/'=>'desktop_publications#seminar_p_list'
+ match '/seminar_p_add/'=>'desktop_publications#seminar_p_add'
- match '/desktop/research_d' => 'desktop_research#research_d'
- match '/desktop/research_d_list/' => 'desktop_research#research_d_list'
- match '/desktop/research_d_add' => 'desktop_research#research_d_add'
+ match '/research_d' => 'desktop_research#research_d'
+ match '/research_d_list/' => 'desktop_research#research_d_list'
+ match '/research_d_add' => 'desktop_research#research_d_add'
- match '/desktop/research_p' => 'desktop_research#research_p'
- match '/desktop/research_p_list/' => 'desktop_research#research_p_list'
- match '/desktop/research_p_add' => 'desktop_research#research_p_add'
+ match '/research_p' => 'desktop_research#research_p'
+ match '/research_p_list/' => 'desktop_research#research_p_list'
+ match '/research_p_add' => 'desktop_research#research_p_add'
- match '/desktop/twitter/'=>'otheraccounts#twitter'
- match '/desktop/forgmail/'=>'otheraccounts#gmail'
- match '/desktop/getaccounts'=>'otheraccounts#getaccounts'
- match '/desktop/save_account_info/'=>'otheraccounts#saveaccountinfo'
+
+ match '/temp_func/'=>'desktop#temp_func'
+end
+
+ match '/twitter/'=>'otheraccounts#twitter'
+ match '/forgmail/'=>'otheraccounts#gmail'
+ match '/getaccounts'=>'otheraccounts#getaccounts'
+ match '/save_account_info/'=>'otheraccounts#saveaccountinfo'
match '/desktop_appstore/appstore'=>'desktop_appstore#appstore'
match '/desktop_appstore/widgets'=>'desktop_appstore#widgets'
@@ -226,13 +240,14 @@ Orbit::Application.routes.draw do
match '/desktop_orbit/eventajaxload'=> 'desktop_orbit#eventajaxload'
match '/desktop_orbit/gettimelinespan' => 'desktop_orbit#gettimelinespan'
+ match '/desktop_publications/getjournals' => 'desktop_publications#getjournals'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#create_journal'
#match '/desktop_orbit/eventajaxload' => 'desktop_publications#delete_journal'
# match '/desktop_orbit/eventajaxload' => 'desktop_publications#update_journal'
- match '/desktop/temp_func/'=>'desktop#temp_func'
+
match '/panel/:app_name/front_end/:app_action/:id(/:controller_action)' => 'pages#show_from_link', :constraints => lambda { |request|
!request.query_string.include?("inner=true")
diff --git a/lib/parsers/parser_layout_widget.rb b/lib/parsers/parser_layout_widget.rb
new file mode 100644
index 00000000..382657d8
--- /dev/null
+++ b/lib/parsers/parser_layout_widget.rb
@@ -0,0 +1,22 @@
+module ParserLayoutWidget
+ require 'nokogiri'
+
+ def parse_widget_for_images(widget)
+ content = widget.widget_layout.file.read.force_encoding("UTF-8")
+ widge = Nokogiri::HTML(content)
+ a = []
+ b = []
+ widge.css('.widget_image').each do |page_image|
+ image = widget.images.where( file: File.basename(page_image['src']))[0]
+ a << page_image['src']
+ b << image.file
+ image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image
+ end
+ a.each_with_index do |img,i|
+ content = content.gsub(img,b[i].to_s)
+ end
+ widget.widget_layout.update_attributes(:body => content)
+ end
+
+
+end
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png
deleted file mode 100755
index ea275d1b..00000000
Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_blue.png and /dev/null differ
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png
deleted file mode 100755
index 393618c2..00000000
Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_green.png and /dev/null differ
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png
deleted file mode 100755
index 84d32207..00000000
Binary files a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/bg_orange.png and /dev/null differ
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css b/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css
deleted file mode 100755
index 8790b137..00000000
--- a/public/desktop_widgets/4fa7810ac88514014d7c59bc/temp/clock.css
+++ /dev/null
@@ -1,69 +0,0 @@
-.clock{
- /* The .clock div. Created dynamically by jQuery */
- /*background-color:#252525;*/
- height:200px;
- width:200px;
- position:relative;
- overflow:hidden;
- float:left;
-}
-
-.clock .rotate{
- /* There are two .rotate divs - one for each half of the background */
- position:absolute;
- width:200px;
- height:200px;
- top:0;
- left:0;
-}
-
-.rotate.right{
- display:none;
- z-index:11;
-}
-
-.clock .bg, .clock .front{
- width:100px;
- height:200px;
- /*background-color:#252525;*/
- position:absolute;
- top:0;
-}
-
-.clock .display{
- /* Holds the number of seconds, minutes or hours respectfully */
- position:absolute;
- width:200px;
- font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
- z-index:20;
- color:#F5F5F5;
- font-size:60px;
- text-align:center;
- top:65px;
- left:0;
-
- /* CSS3 text shadow: */
- text-shadow:4px 4px 5px #333333;
-}
-
-/* The left part of the background: */
-
-.clock .bg.left{ left:0; }
-
-/* Individual styles for each color: */
-.orange .bg.left{ background:url(bg_orange.png) no-repeat left top; }
-.green .bg.left{ background:url(bg_green.png) no-repeat left top; }
-.blue .bg.left{ background:url(bg_blue.png) no-repeat left top; }
-
-/* The right part of the background: */
-.clock .bg.right{ left:100px; }
-
-.orange .bg.right{ background:url(bg_orange.png) no-repeat right top; }
-.green .bg.right{ background:url(bg_green.png) no-repeat right top; }
-.blue .bg.right{ background:url(bg_blue.png) no-repeat right top; }
-
-
-.clock .front.left{
- left:0;
- z-index:10;
-}
diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb b/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb
deleted file mode 100644
index 9862a505..00000000
--- a/public/desktop_widgets/4fa7817cc88514014d7c59c2/index.html.erb
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
- 29 °C
-
-
Sunny
-
-
- weekly report
-
-
Hsin-Chu
-
> Weekly Report
-
-
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html.erb b/public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html
similarity index 100%
rename from public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html.erb
rename to public/desktop_widgets/4fa7818cc88514014d7c59c3/index.html
diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/4fa78153c88514014d7c59bf.js b/public/desktop_widgets/509091e6bd98eb0352000009/509091e6bd98eb0352000009.js
similarity index 100%
rename from public/desktop_widgets/4fa78153c88514014d7c59bf/4fa78153c88514014d7c59bf.js
rename to public/desktop_widgets/509091e6bd98eb0352000009/509091e6bd98eb0352000009.js
diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/events.json b/public/desktop_widgets/509091e6bd98eb0352000009/events.json
similarity index 100%
rename from public/desktop_widgets/4fa78153c88514014d7c59bf/events.json
rename to public/desktop_widgets/509091e6bd98eb0352000009/events.json
diff --git a/public/desktop_widgets/4fa78153c88514014d7c59bf/index.html.erb b/public/desktop_widgets/509091e6bd98eb0352000009/index.html
similarity index 100%
rename from public/desktop_widgets/4fa78153c88514014d7c59bf/index.html.erb
rename to public/desktop_widgets/509091e6bd98eb0352000009/index.html
diff --git a/public/desktop_widgets/browser/default.css b/public/desktop_widgets/browser/default.css
new file mode 100755
index 00000000..fe1e395e
--- /dev/null
+++ b/public/desktop_widgets/browser/default.css
@@ -0,0 +1 @@
+/* No Css */
\ No newline at end of file
diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js b/public/desktop_widgets/browser/javascripts/browser.js
similarity index 100%
rename from public/desktop_widgets/4fba4bf36f4fea8095e389eb/4fba4bf36f4fea8095e389eb.js
rename to public/desktop_widgets/browser/javascripts/browser.js
diff --git a/public/desktop_widgets/browser/settings.json b/public/desktop_widgets/browser/settings.json
new file mode 100644
index 00000000..3ce3df02
--- /dev/null
+++ b/public/desktop_widgets/browser/settings.json
@@ -0,0 +1,6 @@
+{
+ "author" : "Harry",
+ "name" : "Browser",
+ "shape" : "w2 h1",
+ "version" : "1.0"
+}
diff --git a/public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb b/public/desktop_widgets/browser/widget.html
similarity index 100%
rename from public/desktop_widgets/4fba4bf36f4fea8095e389eb/index.html.erb
rename to public/desktop_widgets/browser/widget.html
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb b/public/desktop_widgets/clock/default.css
similarity index 86%
rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb
rename to public/desktop_widgets/clock/default.css
index 2a69e24c..24125313 100755
--- a/public/desktop_widgets/4fa7810ac88514014d7c59bc/index.html.erb
+++ b/public/desktop_widgets/clock/default.css
@@ -1,81 +1,74 @@
-
-
-
-
\ No newline at end of file
+.clock{
+ /* The .clock div. Created dynamically by jQuery */
+ background-color:#111;
+ height:75px;
+ width:75px;
+ position:relative;
+ overflow:hidden;
+ float:left;
+}
+
+.clock .rotate{
+ /* There are two .rotate divs - one for each half of the background */
+ position:absolute;
+ width:75px;
+ height:75px;
+ top:0;
+ left:0;
+}
+
+.rotate.right{
+ display:none;
+ z-index:9;
+}
+
+.clock .bg, .clock .front{
+ width:37.5px;
+ height:75px;
+ background-color:#111;
+ position:absolute;
+ top:0;
+}
+
+.clock .display{
+ /* Holds the number of seconds, minutes or hours respectfully */
+ position:absolute;
+ width:75px;
+ font-family: Orbitron, sans-serif;
+ z-index:17;
+ color:#F5F5F5;
+ font-size:21px;
+ text-align:center;
+ top:27.5px;
+ left:0px;
+
+}
+
+/* The left part of the background: */
+
+.clock .bg.left{ left:0px; }
+
+/* Individual styles for each color: */
+.orange .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat left top; }
+.green .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat left top; }
+.blue .bg.left{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat left top; }
+
+/* The right part of the background: */
+.clock .bg.right{ left:37.5px; }
+
+.orange .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png) no-repeat right top; }
+.green .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png) no-repeat right top; }
+.blue .bg.right{ background:url(desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png) no-repeat right top; }
+
+
+.clock .front.left{
+ left:0;
+ z-index:15;
+}
+#fancyClock {
+ position: absolute;
+ overflow: hidden;
+ top: 50%;
+ left: 50%;
+ margin: -36px 0 0 -114px;
+}
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png b/public/desktop_widgets/clock/images/bg_blue.png
similarity index 100%
rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_blue.png
rename to public/desktop_widgets/clock/images/bg_blue.png
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png b/public/desktop_widgets/clock/images/bg_green.png
similarity index 100%
rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_green.png
rename to public/desktop_widgets/clock/images/bg_green.png
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png b/public/desktop_widgets/clock/images/bg_orange.png
similarity index 100%
rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/img/bg_orange.png
rename to public/desktop_widgets/clock/images/bg_orange.png
diff --git a/public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js b/public/desktop_widgets/clock/javascripts/clock.js
similarity index 100%
rename from public/desktop_widgets/4fa7810ac88514014d7c59bc/4fa7810ac88514014d7c59bc.js
rename to public/desktop_widgets/clock/javascripts/clock.js
diff --git a/public/desktop_widgets/clock/settings.json b/public/desktop_widgets/clock/settings.json
new file mode 100644
index 00000000..8aa41d20
--- /dev/null
+++ b/public/desktop_widgets/clock/settings.json
@@ -0,0 +1,7 @@
+{
+ "author" : "Harry",
+ "name" : "Clock",
+ "shape" : "w2 h1",
+ "version" : "1.0"
+
+}
diff --git a/public/desktop_widgets/clock/widget.html b/public/desktop_widgets/clock/widget.html
new file mode 100755
index 00000000..aeb6a444
--- /dev/null
+++ b/public/desktop_widgets/clock/widget.html
@@ -0,0 +1,5 @@
+
+
+
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb b/public/desktop_widgets/googlesearch/default.css
old mode 100644
new mode 100755
similarity index 59%
rename from public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb
rename to public/desktop_widgets/googlesearch/default.css
index 341b8d81..1aede945
--- a/public/desktop_widgets/4fa78140c88514014d7c59be/index.html.erb
+++ b/public/desktop_widgets/googlesearch/default.css
@@ -1,4 +1,3 @@
-
-
-
-
-
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png b/public/desktop_widgets/googlesearch/images/google_64.png
similarity index 100%
rename from public/desktop_widgets/4fa78140c88514014d7c59be/img/google_64.png
rename to public/desktop_widgets/googlesearch/images/google_64.png
diff --git a/public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js b/public/desktop_widgets/googlesearch/javascripts/google.js
similarity index 100%
rename from public/desktop_widgets/4fa78140c88514014d7c59be/4fa78140c88514014d7c59be.js
rename to public/desktop_widgets/googlesearch/javascripts/google.js
diff --git a/public/desktop_widgets/googlesearch/settings.json b/public/desktop_widgets/googlesearch/settings.json
new file mode 100644
index 00000000..ddb52727
--- /dev/null
+++ b/public/desktop_widgets/googlesearch/settings.json
@@ -0,0 +1,7 @@
+{
+ "author" : "Eric",
+ "name" : "Google Search",
+ "shape" : "w2 h1",
+ "version" : "1.0"
+
+}
diff --git a/public/desktop_widgets/googlesearch/widget.html b/public/desktop_widgets/googlesearch/widget.html
new file mode 100644
index 00000000..df5c715b
--- /dev/null
+++ b/public/desktop_widgets/googlesearch/widget.html
@@ -0,0 +1,13 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa78161c88514014d7c59c0/4fa78161c88514014d7c59c0.js b/public/desktop_widgets/timetable/4fa78161c88514014d7c59c0.js
similarity index 100%
rename from public/desktop_widgets/4fa78161c88514014d7c59c0/4fa78161c88514014d7c59c0.js
rename to public/desktop_widgets/timetable/4fa78161c88514014d7c59c0.js
diff --git a/public/desktop_widgets/4fa78161c88514014d7c59c0/index.html.erb b/public/desktop_widgets/timetable/index.html.erb
similarity index 100%
rename from public/desktop_widgets/4fa78161c88514014d7c59c0/index.html.erb
rename to public/desktop_widgets/timetable/index.html.erb
diff --git a/public/desktop_widgets/weather/default.css b/public/desktop_widgets/weather/default.css
new file mode 100644
index 00000000..ef65207d
--- /dev/null
+++ b/public/desktop_widgets/weather/default.css
@@ -0,0 +1,26 @@
+.g_weather { position: relative; height: 198px; }
+ .g_weather img { float: left; display: block; margin: 0; padding: 12px; }
+ .g_weather .gw_recent {
+ overflow: hidden;
+ height: 96%;
+ padding-top: 4%;
+ }
+ .g_weather .gw_weekly { display: none; }
+ .g_weather .gw_location {
+ position: absolute;
+ left: 0;
+ bottom: 0;
+ font-size: 15px;
+ line-height: 20px;
+ }
+ .g_weather .gw_condition_des { font-size: 22px; }
+ .g_weather .gw_temp { margin-top: 26px; }
+ .g_weather .gw_temp_num { font-size: 56px; }
+ .g_weather .gw_temp_unit { font-size: 26px; }
+ .g_weather .gw_forecast {
+ position: absolute;
+ right: 0;
+ bottom: 0;
+ font-size: 13px;
+ line-height: 20px;
+}
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png b/public/desktop_widgets/weather/images/sunny.png
similarity index 100%
rename from public/desktop_widgets/4fa7817cc88514014d7c59c2/img/sunny.png
rename to public/desktop_widgets/weather/images/sunny.png
diff --git a/public/desktop_widgets/4fa7817cc88514014d7c59c2/4fa7817cc88514014d7c59c2.js b/public/desktop_widgets/weather/javascripts/weather.js
similarity index 100%
rename from public/desktop_widgets/4fa7817cc88514014d7c59c2/4fa7817cc88514014d7c59c2.js
rename to public/desktop_widgets/weather/javascripts/weather.js
diff --git a/public/desktop_widgets/weather/settings.json b/public/desktop_widgets/weather/settings.json
new file mode 100644
index 00000000..67e5a378
--- /dev/null
+++ b/public/desktop_widgets/weather/settings.json
@@ -0,0 +1,7 @@
+{
+ "author" : "Devin",
+ "name" : "Weather",
+ "shape" : "w2 h2",
+ "version" : "0.0"
+
+}
diff --git a/public/desktop_widgets/weather/widget.html b/public/desktop_widgets/weather/widget.html
new file mode 100644
index 00000000..8cc412f2
--- /dev/null
+++ b/public/desktop_widgets/weather/widget.html
@@ -0,0 +1,17 @@
+
+
+
+
+ 29 °C
+
+
Sunny
+
+
+ weekly report
+
+
Hsin-Chu
+
> Weekly Report
+
+
\ No newline at end of file
diff --git a/public/desktop_widgets/4fa78197c88514014d7c59c4/4fa78197c88514014d7c59c4.js b/public/desktop_widgets/youtube/4fa78197c88514014d7c59c4.js
similarity index 100%
rename from public/desktop_widgets/4fa78197c88514014d7c59c4/4fa78197c88514014d7c59c4.js
rename to public/desktop_widgets/youtube/4fa78197c88514014d7c59c4.js
diff --git a/public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb b/public/desktop_widgets/youtube/index.html
similarity index 100%
rename from public/desktop_widgets/4fa78197c88514014d7c59c4/index.html.erb
rename to public/desktop_widgets/youtube/index.html
diff --git a/spec/helpers/attribute_fields_helper_spec.rb b/spec/helpers/attribute_fields_helper_spec.rb
new file mode 100644
index 00000000..84be036a
--- /dev/null
+++ b/spec/helpers/attribute_fields_helper_spec.rb
@@ -0,0 +1,78 @@
+#encoding: UTF-8
+require 'spec_helper'
+
+describe AttributeFieldsHelper do
+ describe "#attribute_field" do
+ context "In the HTML,there should always be 'value' tag in it's name"
+
+ before(:all) do
+ @user = User.where(email:'chris@rulingcom.com').first
+ end #end before
+ # binding.pry
+ LIST[:markups].each do |markup|
+ it "should have 'value' when it's #{markup[0]} (no locale)" do
+ title = "標題"
+ pre_set_markup_value = case markup[0]
+ when "select","checkbox","radio_button"
+ '{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}'
+ else
+ nil
+ end
+
+ attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title)
+
+ html = attribute_field.block_helper(@user,1)
+
+ nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]')
+
+ nodes.each do |input|
+ attri = input.attributes["name"]
+ attri = input.children().first.attributes["name"] if (markup[0] == 'checkbox' || markup[0] == 'radio_button' )
+ attri.to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/
+ # user[attribute_values][1][id]
+ # user[attribute_values][1][value][en]
+ end #end of input loop
+ end # end of it
+ end #end markups
+
+ LIST[:markups].each do |markup|
+ if markup[1]["muti_lang_input_supprt"]
+ [true,false].each do |locale_sat|
+ title = locale_sat ? {"en"=>"Title", "zh_tw"=>"標題"} : "標題"
+ it "should have 'value' when it's #{markup[0]} for locale => #{locale_sat}" do
+ pre_set_markup_value = case markup[0]
+ when "select","checkbox","radio_button"
+ '{"1"=>{"en"=>"Male", "zh_tw"=>"男性"}, "2"=>{"en"=>"Female", "zh_tw"=>"女性"}, "3"=>{"en"=>"Not public", "zh_tw"=>"不公開"}}'
+ else
+ nil
+ end
+ if (markup[0] == "text_field" || markup[0] == "text_area") && (locale_sat == false)
+ # binding.pry
+ end
+ attribute_field=AttributeField.find_or_create_by(key:'Test',markup: markup[0],markup_value: pre_set_markup_value,:title=>title,:locale => locale_sat)
+
+ html = attribute_field.block_helper(@user,1)
+
+ # p html
+ nodes = Nokogiri::HTML.fragment(html).search('*[@func="input_unit"]')
+ nodes.each do |input|
+ input.attributes["name"].to_s.should match /user\[.*attribute_values\]\[\d*\]\[value\].*/
+ # user[attribute_values][1][id]
+ # user[attribute_values][1][value][en]
+ end #end of input loop
+ nodes = Nokogiri::HTML.fragment(html).search('*[@func="field_label"]')
+
+ nodes.each do |input|
+ # p input.to_s
+ # binding.pry if
+
+ input.children.text.should match "標題"
+ end # end of field_label loop
+ end # end of it
+ end # end of T/F
+ end# end of if support
+ end #end markups
+
+
+ end
+end
\ No newline at end of file
diff --git a/spec/models/app_auth_basic.rb b/spec/models/app_auth_basic.rb
index 0f629119..0f8549b7 100644
--- a/spec/models/app_auth_basic.rb
+++ b/spec/models/app_auth_basic.rb
@@ -1,218 +1,218 @@
-require 'spec_helper'
-require 'ruby-debug'
+# require 'spec_helper'
+# require 'ruby-debug'
-describe AppAuth do
+# describe AppAuth do
- before do
- User.all.destroy
- Role.all.destroy
- SubRole.all.destroy
- AppAuth.all.destroy
- ModuleApp.all.destroy
+# before do
+# User.all.destroy
+# Role.all.destroy
+# SubRole.all.destroy
+# AppAuth.all.destroy
+# ModuleApp.all.destroy
- #Create some fixtures of Main Role
- main_role_key = ["Stud","Teacher","Staff"]
- @new_main_role_list = main_role_key.each do |role|
- new_role = Role.new :key => role
- new_role.save
- end
- #Create Some SubRoles
- sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"]
- @new_main_role_list = sub_role_key.each do |role|
- new_role = SubRole.new :key => role
- new_role.save
- end
+# #Create some fixtures of Main Role
+# main_role_key = ["Stud","Teacher","Staff"]
+# @new_main_role_list = main_role_key.each do |role|
+# new_role = Role.new :key => role
+# new_role.save
+# end
+# #Create Some SubRoles
+# sub_role_key = ["graduated_school","undergraduated_school","TA","Senior"]
+# @new_main_role_list = sub_role_key.each do |role|
+# new_role = SubRole.new :key => role
+# new_role.save
+# end
- #Create some users of User
- user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"]
- user_emails.each do |user_email|
- email=user_email+"@rulingcom.com"
- new_user = User.new :email=> email
- new_user.save
- end
- #MRK = Member Role Key SRK=Sub Role Key
- @stud_MRK = Role.first(conditions:{key:"Stud"})
- @teacher_MRK = Role.first(conditions:{key:"Teacher"})
- @staff_MRK = Role.first(conditions:{key:"Staff"})
+# #Create some users of User
+# user_emails = ["a_good_ug_stud_1","a_good_ug_stud_2","a_bad_ug_stud","a_good_g_stud","a_bad_g_stud","a_teacher","a_staff"]
+# user_emails.each do |user_email|
+# email=user_email+"@rulingcom.com"
+# new_user = User.new :email=> email
+# new_user.save
+# end
+# #MRK = Member Role Key SRK=Sub Role Key
+# @stud_MRK = Role.first(conditions:{key:"Stud"})
+# @teacher_MRK = Role.first(conditions:{key:"Teacher"})
+# @staff_MRK = Role.first(conditions:{key:"Staff"})
- @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"})
- @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"})
- @ta_SRK = SubRole.first(conditions:{key:"TA"})
- @senior_SRK = SubRole.first(conditions:{key:"Senior"})
+# @graduated_SRK = SubRole.first(conditions:{key:"graduated_school"})
+# @under_graduated_SRK = SubRole.first(conditions:{key:"undergraduated_school"})
+# @ta_SRK = SubRole.first(conditions:{key:"TA"})
+# @senior_SRK = SubRole.first(conditions:{key:"Senior"})
- @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta]
- @stud_MRK.save!
+# @stud_MRK.sub_roles += [@graduated,@under_graduated,@ta]
+# @stud_MRK.save!
- @teacher_MRK.sub_roles = [@senior]
- @teacher_MRK.save!
+# @teacher_MRK.sub_roles = [@senior]
+# @teacher_MRK.save!
- @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"})
- @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"})
- @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"})
+# @good_ug_stu_1 = User.first(conditions:{email:"a_good_ug_stud_1@rulingcom.com"})
+# @good_ug_stu_2 = User.first(conditions:{email:"a_good_ug_stud_2@rulingcom.com"})
+# @bad_ug_stu = User.first(conditions:{email:"a_bad_ug_stud@rulingcom.com"})
- @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
- @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
- @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
- @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
+# @good_g_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
+# @bad_g_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
+# @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
+# @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
- #setting Roles for users
- @good_g_stu.role = @stud_MRK
- @bad_g_stu.role = @stud_MRK
- @good_ug_stu_1.role = @stud_MRK
- @good_ug_stu_2.role = @stud_MRK
- @bad_ug_stu.role = @stud_MRK
+# #setting Roles for users
+# @good_g_stu.role = @stud_MRK
+# @bad_g_stu.role = @stud_MRK
+# @good_ug_stu_1.role = @stud_MRK
+# @good_ug_stu_2.role = @stud_MRK
+# @bad_ug_stu.role = @stud_MRK
- @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK]
- @bad_g_stu.sub_roles << @graduated_SRK
- @good_ug_stu_1.sub_roles << @under_graduated_SRK
- @good_ug_stu_2.sub_roles << @under_graduated_SRK
- @bad_ug_stu.sub_roles << @under_graduated_SRK
+# @good_g_stu.sub_roles = [@graduated_SRK,@ta_SRK]
+# @bad_g_stu.sub_roles << @graduated_SRK
+# @good_ug_stu_1.sub_roles << @under_graduated_SRK
+# @good_ug_stu_2.sub_roles << @under_graduated_SRK
+# @bad_ug_stu.sub_roles << @under_graduated_SRK
- @teacher.role = @teacher_MRK
- @staff.role = @staff_MRK
+# @teacher.role = @teacher_MRK
+# @staff.role = @staff_MRK
- @good_g_stu.save!
- @bad_g_stu.save!
- @good_ug_stu_1.save!
- @good_ug_stu_2.save!
- @bad_ug_stu.save!
+# @good_g_stu.save!
+# @bad_g_stu.save!
+# @good_ug_stu_1.save!
+# @good_ug_stu_2.save!
+# @bad_ug_stu.save!
- @teacher.save!
- @staff.save!
+# @teacher.save!
+# @staff.save!
- end
- describe "Starting a ClassBulletin Auth for teacher , staff and ta" do
- before do
- @bulletin_app_auth = AppAuth.new()
- #all teacher and staff has access right
- @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK]
- #all person with TA sub_role has access right
- @bulletin_app_auth.sub_roles << @ta_SRK
+# end
+# describe "Starting a ClassBulletin Auth for teacher , staff and ta" do
+# before do
+# @bulletin_app_auth = AppAuth.new()
+# #all teacher and staff has access right
+# @bulletin_app_auth.roles = [@teacher_MRK,@staff_MRK]
+# #all person with TA sub_role has access right
+# @bulletin_app_auth.sub_roles << @ta_SRK
- #a_bad_ug_stud add to block to bulletin_app_auth
- #@bulletin_app_auth.blocked_users << @bad_ug_stu
+# #a_bad_ug_stud add to block to bulletin_app_auth
+# #@bulletin_app_auth.blocked_users << @bad_ug_stu
- #all teacher has access right
- # @bulletin_app_auth.roles << @teacher_MRK
+# #all teacher has access right
+# # @bulletin_app_auth.roles << @teacher_MRK
- # @bulletin_app_auth.privilege_users << @staff
- @bulletin_app_auth.save!
- end
- context "Should just initialize all obj that is needed" do
+# # @bulletin_app_auth.privilege_users << @staff
+# @bulletin_app_auth.save!
+# end
+# context "Should just initialize all obj that is needed" do
- it "Testing @bulletin_app_auth init result" do
- @bulletin_app_auth.roles.should have(2).item #teacher staff
- @bulletin_app_auth.sub_roles.should have(1).item #ta
- end
+# it "Testing @bulletin_app_auth init result" do
+# @bulletin_app_auth.roles.should have(2).item #teacher staff
+# @bulletin_app_auth.sub_roles.should have(1).item #ta
+# end
- it "@bulletin_app_auth should have Roles: Staff , Teacher " do
- key_ary = @bulletin_app_auth.roles.collect do |role|
- role.key
- end
- key_ary.sort.should == ["Staff","Teacher"].sort
- end
+# it "@bulletin_app_auth should have Roles: Staff , Teacher " do
+# key_ary = @bulletin_app_auth.roles.collect do |role|
+# role.key
+# end
+# key_ary.sort.should == ["Staff","Teacher"].sort
+# end
- it "bulletin_app_auth should have 3 auth users" do
- user_ary = [@teacher,@staff,@good_g_stu]
- @bulletin_app_auth.auth_users.sort.should == user_ary.sort
- check_user_has_app user_ary
- end
+# it "bulletin_app_auth should have 3 auth users" do
+# user_ary = [@teacher,@staff,@good_g_stu]
+# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
+# check_user_has_app user_ary
+# end
- it "Adding a undergraduate stud into app_auth by privilege list" do
- user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1]
- @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1
- @bulletin_app_auth.auth_users.sort.should == user_ary.sort
- check_user_has_app user_ary
- end
+# it "Adding a undergraduate stud into app_auth by privilege list" do
+# user_ary = [@teacher,@staff,@good_g_stu,@good_ug_stu_1]
+# @bulletin_app_auth.add_user_to_privilege_list @good_ug_stu_1
+# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
+# check_user_has_app user_ary
+# end
- it "Adding all graudated-stud into app_auth" do
- user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu]
- @bulletin_app_auth.add_sub_role @graduated_SRK
- @bulletin_app_auth.auth_users.sort.should == user_ary.sort
- check_user_has_app user_ary
- end
+# it "Adding all graudated-stud into app_auth" do
+# user_ary = [@teacher,@staff,@good_g_stu,@bad_g_stu]
+# @bulletin_app_auth.add_sub_role @graduated_SRK
+# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
+# check_user_has_app user_ary
+# end
- it "Blocking bad-graduate student" do
- user_ary =[@teacher,@staff,@good_g_stu]
- @bulletin_app_auth.add_sub_role @graduated_SRK
- @bulletin_app_auth.add_user_to_black_list @bad_g_stu
- @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort
- check_user_has_app user_ary
- end
+# it "Blocking bad-graduate student" do
+# user_ary =[@teacher,@staff,@good_g_stu]
+# @bulletin_app_auth.add_sub_role @graduated_SRK
+# @bulletin_app_auth.add_user_to_black_list @bad_g_stu
+# @bulletin_app_auth.auth_users_after_block_list.sort.should == user_ary.sort
+# check_user_has_app user_ary
+# end
- it "Removing all graudated-stud from app_auth" do
- user_ary =[@teacher,@staff,@good_g_stu]
- @bulletin_app_auth.add_sub_role @graduated_SRK
- @bulletin_app_auth.remove_sub_role @graduated_SRK
- @bulletin_app_auth.auth_users.sort.should == user_ary.sort
- check_user_has_app user_ary
- end
+# it "Removing all graudated-stud from app_auth" do
+# user_ary =[@teacher,@staff,@good_g_stu]
+# @bulletin_app_auth.add_sub_role @graduated_SRK
+# @bulletin_app_auth.remove_sub_role @graduated_SRK
+# @bulletin_app_auth.auth_users.sort.should == user_ary.sort
+# check_user_has_app user_ary
+# end
- # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do
- # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user|
- # p_user.roles.key
- # end
- # p_user_ary.should include("Staff")
- # end
+# # it "@bulletin_app_auth should have one Privialage user which is belongs to Staff" do
+# # p_user_ary = @bulletin_app_auth.privilege_users.collect do |p_user|
+# # p_user.roles.key
+# # end
+# # p_user_ary.should include("Staff")
+# # end
- # it "@bulletin_app_auth should have one student listed at blocklist" do
- # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
- # @bulletin_app_auth.blocked_users.should have(1).item
- # @bulletin_app_auth.blocked_users.should include(@bad_stu)
- # end
+# # it "@bulletin_app_auth should have one student listed at blocklist" do
+# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
+# # @bulletin_app_auth.blocked_users.should have(1).item
+# # @bulletin_app_auth.blocked_users.should include(@bad_stu)
+# # end
- # it "[Development #1]-1.Authorizing roles: roles + blocklist" do
- # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
- # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
- # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
- # ary = [@good_stu,@teacher,@staff]
- # @bulletin_app_auth.auth_users_after_block_list.should == ary
- # end
- #
- # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
- # user_emails = ["new_user1","new_user2","new_user3","new_user4"]
- # user_emails.each do |user_email|
- # email=user_email+"@rulingcom.com"
- # new_user = User.new :email=> email
- # new_user.save
- # end
- # user1= User.first(conditions:{email:"new_user1@rulingcom.com"})
- # user2= User.first(conditions:{email:"new_user2@rulingcom.com"})
- # user3= User.first(conditions:{email:"new_user3@rulingcom.com"})
- # user4= User.first(conditions:{email:"new_user4@rulingcom.com"})
- #
- # @bulletin_app_auth.privilege_users << user1
- # @bulletin_app_auth.privilege_users << user2
- #
- # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2)
- # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4)
- #
- # end
- #
- # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
- # @bulletin_app_auth.auth_users.should have(7).item
- # end
- #
- # it "[Development #1]-4.Authorizing all: blocklist" do
- # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
- # @new_bulletin_app_auth = (AppAuth.new :all => true)
- # @new_bulletin_app_auth.blocked_users << @bad_stu
- #
- # @new_bulletin_app_auth.auth_users.should == User.all.entries
- # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
- # @new_bulletin_app_auth.save!
- # end
- def check_user_has_app(user_ary)
- user_ary.each do |user|
- user.avb_apps.should include(@bulletin_app_auth)
- end
- end
- end
+# # it "[Development #1]-1.Authorizing roles: roles + blocklist" do
+# # @good_stu = User.first(conditions:{email:"a_good_g_stud@rulingcom.com"})
+# # @teacher = User.first(conditions:{email:"a_teacher@rulingcom.com"})
+# # @staff = User.first(conditions:{email:"a_staff@rulingcom.com"})
+# # ary = [@good_stu,@teacher,@staff]
+# # @bulletin_app_auth.auth_users_after_block_list.should == ary
+# # end
+# #
+# # it "[Development #1]-2.Authorizing single users: list of users [new_user1~2]" do
+# # user_emails = ["new_user1","new_user2","new_user3","new_user4"]
+# # user_emails.each do |user_email|
+# # email=user_email+"@rulingcom.com"
+# # new_user = User.new :email=> email
+# # new_user.save
+# # end
+# # user1= User.first(conditions:{email:"new_user1@rulingcom.com"})
+# # user2= User.first(conditions:{email:"new_user2@rulingcom.com"})
+# # user3= User.first(conditions:{email:"new_user3@rulingcom.com"})
+# # user4= User.first(conditions:{email:"new_user4@rulingcom.com"})
+# #
+# # @bulletin_app_auth.privilege_users << user1
+# # @bulletin_app_auth.privilege_users << user2
+# #
+# # @bulletin_app_auth.auth_users_after_block_list.should include(user1,user2)
+# # @bulletin_app_auth.auth_users_after_block_list.should_not include(user3,user4)
+# #
+# # end
+# #
+# # it "[Development #1]-3.Authorizing roles and single users: roles + blocklist + list of users" do
+# # @bulletin_app_auth.auth_users.should have(7).item
+# # end
+# #
+# # it "[Development #1]-4.Authorizing all: blocklist" do
+# # @bad_stu = User.first(conditions:{email:"a_bad_g_stud@rulingcom.com"})
+# # @new_bulletin_app_auth = (AppAuth.new :all => true)
+# # @new_bulletin_app_auth.blocked_users << @bad_stu
+# #
+# # @new_bulletin_app_auth.auth_users.should == User.all.entries
+# # @new_bulletin_app_auth.auth_users_after_block_list.should_not include(@bad_stu)
+# # @new_bulletin_app_auth.save!
+# # end
+# def check_user_has_app(user_ary)
+# user_ary.each do |user|
+# user.avb_apps.should include(@bulletin_app_auth)
+# end
+# end
+# end
- end
+# end
-end
\ No newline at end of file
+# end
\ No newline at end of file
diff --git a/spec/models/app_auth_spec.rb b/spec/models/app_auth_spec.rb
index 7353f29d..4080250a 100644
--- a/spec/models/app_auth_spec.rb
+++ b/spec/models/app_auth_spec.rb
@@ -1,81 +1,81 @@
-require 'spec_helper'
-require 'ruby-debug'
+# require 'spec_helper'
+# require 'ruby-debug'
-describe AppAuth do
+# describe AppAuth do
- before(:all) do
- @app_ary = [
- {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]},
- {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]},
- {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []}
- ]
+# before(:all) do
+# @app_ary = [
+# {"name" => "G_app_1" , "all" => false,"blockusers" => ["a_bad_stud@rulingcom.com"]},
+# {"name" => "G_app_2" , "all" => true,"blockusers" => ["a_bad_stud@rulingcom.com"]},
+# {"name" => "G_app_3_for_bad" , "all" => true,"blockusers" => []}
+# ]
- @app_ary.each do |t|
- a = ModuleApp.new :title => t["name"]
- blocked_users = t["blockusers"].collect do |b_user|
- User.first(conditions:{email:b_user})
- end
- a.create_app_auth :all=> t["all"],:blocked_users => blocked_users
- a.save!
- end
- @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"})
- @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
- @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"})
- @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"})
- @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"})
- end
+# @app_ary.each do |t|
+# a = ModuleApp.new :title => t["name"]
+# blocked_users = t["blockusers"].collect do |b_user|
+# User.first(conditions:{email:b_user})
+# end
+# a.create_app_auth :all=> t["all"],:blocked_users => blocked_users
+# a.save!
+# end
+# @good_stud_become_bad = User.first(conditions:{email:"a_good_stud@rulingcom.com"})
+# @bad_stud_become_good = User.first(conditions:{email:"a_bad_stud@rulingcom.com"})
+# @g_app_1 = ModuleApp.first(conditions:{title:"G_app_1"})
+# @g_app_2 = ModuleApp.first(conditions:{title:"G_app_2"})
+# @g_app_3 = ModuleApp.first(conditions:{title:"G_app_3_for_bad"})
+# end
- describe "[Init status check]" do
- it "bad_stud_become_good status " do
- @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
- @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth
- @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth
- end
+# describe "[Init status check]" do
+# it "bad_stud_become_good status " do
+# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
+# @bad_stud_become_good.avb_apps.should_not include @g_app_2.app_auth
+# @bad_stud_become_good.avb_apps.should include @g_app_3.app_auth
+# end
- it "good_stud_become_bad status " do
- @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
- @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth
- @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth
- end
- end
+# it "good_stud_become_bad status " do
+# @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
+# @good_stud_become_bad.avb_apps.should include @g_app_2.app_auth
+# @good_stud_become_bad.avb_apps.should include @g_app_3.app_auth
+# end
+# end
- describe ".add_user_to_black_list sutd" do
- it "When good stud is blocked with app1 and app2" do
- @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad
- @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad
- @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
- @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth
- end
- end
+# describe ".add_user_to_black_list sutd" do
+# it "When good stud is blocked with app1 and app2" do
+# @g_app_1.app_auth.add_user_to_black_list @good_stud_become_bad
+# @g_app_2.app_auth.add_user_to_black_list @good_stud_become_bad
+# @good_stud_become_bad.avb_apps.should_not include @g_app_1.app_auth
+# @good_stud_become_bad.avb_apps.should_not include @g_app_2.app_auth
+# end
+# end
- describe ".remove_user_from_black_list sutd" do
- it "When bad stud is authed with app1 and app2" do
- @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good
- @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good
- #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth
- @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth
- end
- end
+# describe ".remove_user_from_black_list sutd" do
+# it "When bad stud is authed with app1 and app2" do
+# @g_app_1.app_auth.remove_user_from_black_list @bad_stud_become_good
+# @g_app_2.app_auth.remove_user_from_black_list @bad_stud_become_good
+# #@bad_stud_become_good.avb_apps.should include @g_app_1.app_auth
+# @bad_stud_become_good.avb_apps.should include @g_app_2.app_auth
+# end
+# end
- describe ".add_user_to_privilege_list sutd" do
- it "When bad stud is auth for one more app" do
- @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all
- @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status
- @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check
- end
- end
+# describe ".add_user_to_privilege_list sutd" do
+# it "When bad stud is auth for one more app" do
+# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth #shouldn't have at first time since app1 is not sat for all
+# @g_app_1.app_auth.add_user_to_privilege_list @bad_stud_become_good #change status
+# @bad_stud_become_good.avb_apps.should include @g_app_1.app_auth #check
+# end
+# end
- describe ".remove_user_from_privilege_list sutd" do
- it "admin mistake. remove user from privilege list" do
- @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good
- @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
- end
- end
+# describe ".remove_user_from_privilege_list sutd" do
+# it "admin mistake. remove user from privilege list" do
+# @g_app_1.app_auth.remove_user_from_privilege_list @bad_stud_become_good
+# @bad_stud_become_good.avb_apps.should_not include @g_app_1.app_auth
+# end
+# end
- after(:all) do
- @app_ary.each do |item|
- ModuleApp.first(conditions: {title: item["name"]}).destroy
- end
- end
+# after(:all) do
+# @app_ary.each do |item|
+# ModuleApp.first(conditions: {title: item["name"]}).destroy
+# end
+# end
-end
\ No newline at end of file
+# end
\ No newline at end of file
diff --git a/spec/models/attribute_field_spec.rb b/spec/models/attribute_field_spec.rb
new file mode 100644
index 00000000..6fb01ba8
--- /dev/null
+++ b/spec/models/attribute_field_spec.rb
@@ -0,0 +1,12 @@
+require 'spec_helper'
+describe AttributeField do
+ describe "#list field" do
+ context "when field is in type text_field(without add more)" do
+ before(:each) do
+ @attribute_field = AttributeField.new(:key=>'test',:markup=>"text_field")
+
+
+ end
+ end
+ end
+end
\ No newline at end of file
diff --git a/spec/models/attribute_value_spec.rb b/spec/models/attribute_value_spec.rb
new file mode 100644
index 00000000..a9a741db
--- /dev/null
+++ b/spec/models/attribute_value_spec.rb
@@ -0,0 +1,63 @@
+#encoding: UTF-8
+require 'spec_helper'
+
+describe AttributeValue do
+ describe "#attribute_value" do
+ context "Data should be able to input and out put as aspect"
+
+ before do
+ @af = AttributeField.find '5052cf9f2b5c49a742000005'
+ @user = User.where(email:'chris@rulingcom.com').first
+ @av = AttributeValue.last
+ end #end before
+
+ [true,false].each do |locale_sat|
+ LIST[:markups].each do |markup|
+ @av = nil
+ it "[#{markup[0]}]Input: should save data at right way when local is set to #{locale_sat}" do
+ @af.markup = markup[0]
+ @av = nil
+ @input_value = assume_result = case markup[0]
+ when 'text_field','text_area'
+ (locale_sat ? {"en"=> "lalala","zh_tw"=>"拉拉拉"} : "hahaha")
+ when 'select','radio_button'
+ "1"
+ when 'date'
+ {"(1i)"=>Date.today.year.to_s,"(2i)"=>Date.today.month.to_s,"(3i)"=>Date.today.day.to_s}
+ when 'checkbox'
+ {"1"=>"true", "3"=>"true"}
+ end #end of case
+ assume_result = ["1","3"] if markup[0] == 'checkbox'
+ @af.locale = locale_sat
+ @af.save
+ @data_hash = {"attribute_field_id" => @af.id,"value" => @input_value}
+ @av = @user.attribute_values.build(@data_hash)
+ @av.save
+
+ @av.value.should == assume_result
+ # @av.destroy
+ end
+
+ it "[#{markup[0]}]Output(just for show): should output data at right way when local is set to #{locale_sat}" do
+ locale = I18n.locale
+ assume_result = case markup[0]
+ when 'text_area'
+ (locale_sat ? "拉拉拉" : "hahaha")
+ when 'text_field'
+ (locale_sat ? "拉拉拉" : "hahaha")
+ when 'select','radio_button'
+ (locale_sat ? "男性" : "男性")
+ when 'date'
+ Date.today
+ when 'checkbox'
+ (locale_sat ? "男性,不公開" : "男性,不公開")
+ end #end of case
+
+ @av.get_value_by_locale(locale).should == assume_result
+ end
+
+ end #end of LIST loop
+ end
+
+ end
+end
\ No newline at end of file
diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb
index a58799b4..0d8d2fe9 100644
--- a/spec/models/role_spec.rb
+++ b/spec/models/role_spec.rb
@@ -1,113 +1,113 @@
-require 'spec_helper'
+ # require 'spec_helper'
-describe Role do
- before do
- @role = Role.create(:key => 'teacher',
- :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
- :sub_roles => [{:key => 'undergrad',
- :i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'},
- :attribute_fields => [{:key => 'department'},
- {:key => 'room'}]},
- {:key => 'master',
- :attribute_fields => [{:key => 'department'}]}])
- end
- describe 'New role' do
- describe '#Role' do
- it 'should have :built_in false' do
- @role.built_in.should be false
- end
- it 'should have :disabled false' do
- @role.disabled.should be false
- end
- it 'should have a i18n_variable' do
- @role.i18n_variable.should be_an_instance_of I18nVariable
- end
- it 'should create sub_roles' do
- @role.should have(2).sub_roles
- end
- it 'should create attribute_fields' do
- @role.sub_roles[1].should have(1).attribute_fields
- end
- end
- describe '#SubRole' do
- it 'should have :built_in false' do
- @role.sub_roles[0].built_in.should be false
- end
- it 'should have :disabled false' do
- @role.sub_roles[0].disabled.should be false
- end
- it 'should have a i18n_variable' do
- @role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable
- end
- end
- describe '#AttributeField' do
- it 'should have :built_in false' do
- @role.sub_roles[0].attribute_fields[0].built_in.should be false
- end
- it 'should have :disabled false' do
- @role.sub_roles[0].attribute_fields[0].disabled.should be false
- end
- end
- end
- describe 'Edit role' do
- describe '#Role' do
- before do
- @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'},
- :sub_roles => [{:key => 'new',
- :attribute_fields => [{:key => 'bob'},
- {:key => 'great'}]},
- {:id => @role.sub_roles[0].id},
- {:id => @role.sub_roles[1].id}]})
- end
- it 'should not be the old :key' do
- @role.key.should_not == 'teacher'
- end
- it 'should be the new :key' do
- @role.key.should == 'student'
- end
- it 'should not be the old :i18n_variable[:en]' do
- @role.i18n_variable[:en].should_not == 'Teacher'
- end
- it 'should be the new :i18n_variable[:en]' do
- @role.i18n_variable[:en].should == 'Student'
- end
- it 'should have one more SubRole' do
- @role.should have(3).sub_roles
- end
- end
- end
- describe 'Destroy' do
- describe '#AttributeField' do
- before do
- @role.update_attributes(:key => 'teacher',
- :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
- :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id,
- :key => 'undergrad',
- :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id,
- :key => 'department'},
- '1' => {:id => @role.sub_roles[0].attribute_fields[1].id,
- :key => 'room', :_destroy => true}}}})
- end
- it 'should have only one AttributeField for the first SubRole' do
- @role.sub_roles[0].should have(1).attribute_fields
- end
- end
- describe '#I18nVariable' do
- before do
- @role.update_attributes(:key => 'teacher',
- :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true})
- end
- it 'should not have a I18nVariable' do
- @role.i18n_variable.should_not be_an_instance_of I18nVariable
- end
- end
- describe '#Role' do
- it 'should destroy the I18nVariable' do
- id = @role.i18n_variable.id
- @role.destroy
- lambda {I18nVariable.find(id)}.should raise_error
- end
- end
- end
+# describe Role do
+# before do
+# @role = Role.create(:key => 'teacher',
+# :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
+# :sub_roles => [{:key => 'undergrad',
+# :i18n_variable => {:key => 'yeah', :en => 'Yeah', :zh_tw => 'Yeah', :document_class => 'Role'},
+# :attribute_fields => [{:key => 'department'},
+# {:key => 'room'}]},
+# {:key => 'master',
+# :attribute_fields => [{:key => 'department'}]}])
+# end
+# describe 'New role' do
+# describe '#Role' do
+# it 'should have :built_in false' do
+# @role.built_in.should be false
+# end
+# it 'should have :disabled false' do
+# @role.disabled.should be false
+# end
+# it 'should have a i18n_variable' do
+# @role.i18n_variable.should be_an_instance_of I18nVariable
+# end
+# it 'should create sub_roles' do
+# @role.should have(2).sub_roles
+# end
+# it 'should create attribute_fields' do
+# @role.sub_roles[1].should have(1).attribute_fields
+# end
+# end
+# describe '#SubRole' do
+# it 'should have :built_in false' do
+# @role.sub_roles[0].built_in.should be false
+# end
+# it 'should have :disabled false' do
+# @role.sub_roles[0].disabled.should be false
+# end
+# it 'should have a i18n_variable' do
+# @role.sub_roles[0].i18n_variable.should be_an_instance_of I18nVariable
+# end
+# end
+# describe '#AttributeField' do
+# it 'should have :built_in false' do
+# @role.sub_roles[0].attribute_fields[0].built_in.should be false
+# end
+# it 'should have :disabled false' do
+# @role.sub_roles[0].attribute_fields[0].disabled.should be false
+# end
+# end
+# end
+# describe 'Edit role' do
+# describe '#Role' do
+# before do
+# @role.update_attributes({:key => 'student', :i18n_variable => {:en => 'Student'},
+# :sub_roles => [{:key => 'new',
+# :attribute_fields => [{:key => 'bob'},
+# {:key => 'great'}]},
+# {:id => @role.sub_roles[0].id},
+# {:id => @role.sub_roles[1].id}]})
+# end
+# it 'should not be the old :key' do
+# @role.key.should_not == 'teacher'
+# end
+# it 'should be the new :key' do
+# @role.key.should == 'student'
+# end
+# it 'should not be the old :i18n_variable[:en]' do
+# @role.i18n_variable[:en].should_not == 'Teacher'
+# end
+# it 'should be the new :i18n_variable[:en]' do
+# @role.i18n_variable[:en].should == 'Student'
+# end
+# it 'should have one more SubRole' do
+# @role.should have(3).sub_roles
+# end
+# end
+# end
+# describe 'Destroy' do
+# describe '#AttributeField' do
+# before do
+# @role.update_attributes(:key => 'teacher',
+# :i18n_variable => {:key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role'},
+# :sub_roles_attributes => {'0' => {:id => @role.sub_roles[0].id,
+# :key => 'undergrad',
+# :attribute_fields_attributes => {'0' => {:id => @role.sub_roles[0].attribute_fields[0].id,
+# :key => 'department'},
+# '1' => {:id => @role.sub_roles[0].attribute_fields[1].id,
+# :key => 'room', :_destroy => true}}}})
+# end
+# it 'should have only one AttributeField for the first SubRole' do
+# @role.sub_roles[0].should have(1).attribute_fields
+# end
+# end
+# describe '#I18nVariable' do
+# before do
+# @role.update_attributes(:key => 'teacher',
+# :i18n_variable_attributes => {:id => @role.i18n_variable.id, :key => 'teacher', :en => 'Teacher', :zh_tw => 'Teacher in Chinese', :document_class => 'Role', :_destroy => true})
+# end
+# it 'should not have a I18nVariable' do
+# @role.i18n_variable.should_not be_an_instance_of I18nVariable
+# end
+# end
+# describe '#Role' do
+# it 'should destroy the I18nVariable' do
+# id = @role.i18n_variable.id
+# @role.destroy
+# lambda {I18nVariable.find(id)}.should raise_error
+# end
+# end
+# end
-end
\ No newline at end of file
+# end
\ No newline at end of file
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 2529da0f..cd0b93ad 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -38,6 +38,7 @@ Spork.prefork do
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false
+
end
end
diff --git a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
index 7e36a22d..31e08fb4 100644
--- a/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
+++ b/vendor/built_in_modules/announcement/app/helpers/panel/announcement/back_end/bulletins_helper.rb
@@ -49,4 +49,4 @@ module Panel::Announcement::BackEnd::BulletinsHelper
end
-end
\ No newline at end of file
+end
diff --git a/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb b/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb
index 54b2428e..2cb15a65 100644
--- a/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb
+++ b/vendor/built_in_modules/announcement/app/views/panel/announcement/plugin/_profile.html.erb
@@ -1 +1,53 @@
-Hello~ I am your plugin profile
\ No newline at end of file
+<%
+ 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
+
+%>
+
+
+
+
+ <%= t('bulletin.category') %>
+ <%= t('bulletin.title') %>
+ <%= t('bulletin.start_date') %>
+ <%= t('bulletin.end_date') %>
+ <%= t('bulletin.tags') %>
+ <% if not @user%>
+ <%= t('bulletin.last_modified') %>
+ <% end %>
+
+
+
+ <% @bulletins.each do |bulletin| %>
+
+ <%= bulletin.bulletin_category.title%>
+
+ <% 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 %>
+
+ <%= display_date_time(bulletin.postdate) %>
+ <% if not bulletin.deadline.nil?%>
+ <%= display_date_time(bulletin.deadline) %>
+ <%else%>
+ <%= t('bulletin.no_deadline') %>
+ <% end %>
+
+
+ <% bulletin.sorted_tags.each do |tag| %>
+ <%= tag[I18n.locale] %>
+ <% end %>
+
+
+ <% if not @user%>
+ <%= User.find(bulletin.create_user_id).name %>
+ <% end %>
+
+ <% end %>
+
+
diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb
index f9aba371..beed6b8a 100644
--- a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb
+++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_file_categorys_controller.rb
@@ -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)
diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb
index a4804bb5..0336c11b 100644
--- a/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb
+++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/back_end/archive_files_controller.rb
@@ -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
diff --git a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb
index 594b7348..a436f5a9 100644
--- a/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb
+++ b/vendor/built_in_modules/archive/app/controllers/panel/archive/front_end/archive_files_controller.rb
@@ -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
diff --git a/vendor/built_in_modules/archive/app/models/archive_file.rb b/vendor/built_in_modules/archive/app/models/archive_file.rb
index 9cf2eedd..2d53e7ff 100644
--- a/vendor/built_in_modules/archive/app/models/archive_file.rb
+++ b/vendor/built_in_modules/archive/app/models/archive_file.rb
@@ -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
diff --git a/vendor/built_in_modules/archive/app/models/archive_file_category.rb b/vendor/built_in_modules/archive/app/models/archive_file_category.rb
index abb08bd3..f3d2fcd9 100644
--- a/vendor/built_in_modules/archive/app/models/archive_file_category.rb
+++ b/vendor/built_in_modules/archive/app/models/archive_file_category.rb
@@ -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
\ No newline at end of file
diff --git a/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb
index 0ac3070b..9dc83363 100644
--- a/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb
+++ b/vendor/built_in_modules/archive/app/models/archive_file_multiple.rb
@@ -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)
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb
index c6bf4616..d8c5e8e1 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_archive_file_category.html.erb
@@ -11,6 +11,6 @@
<% @site_valid_locales.each do |locale| %>
- <%= archive_file_category.i18n_variable[locale] rescue nil %>
+ <%= archive_file_category.title_translations[locale] rescue nil %>
<% end %>
\ No newline at end of file
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_form.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_form.html.erb
index f79bbab0..345390df 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_form.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_file_categorys/_form.html.erb
@@ -10,12 +10,12 @@
- <%= post.archive_file_category.i18n_variable[I18n.locale] %>
+ <%= post.archive_file_category.title %>
<%= link_to post.title, panel_archive_front_end_archive_file_path(post) %>
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb
index e6c93f1f..bd080e1e 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/_form.html.erb
@@ -43,7 +43,7 @@
<%= 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 ]} %>
<% @site_valid_locales.each_with_index do |locale, i| %>
@@ -74,7 +74,7 @@
-
+
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-fp.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-fp.js
deleted file mode 100644
index 634fb5e4..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-fp.js
+++ /dev/null
@@ -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();
- }
-
- });
-
-}));
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-ui.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-ui.js
deleted file mode 100644
index 4c36f008..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload-ui.js
+++ /dev/null
@@ -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(' ');
- 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);
- }
-
- });
-
-}));
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload.js
deleted file mode 100644
index c9375294..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.fileupload.js
+++ /dev/null
@@ -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 && $(' ').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);
- $('').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);
- }
-
- });
-
-}));
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.iframe-transport.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.iframe-transport.js
deleted file mode 100644
index 4749f469..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/jquery.iframe-transport.js
+++ /dev/null
@@ -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.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 = $(
- ''
- ).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):
- $('')
- .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) {
- $(' ')
- .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());
- }
- }
- });
-
-}));
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/locale.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/locale.js
deleted file mode 100644
index ea64b0a8..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/locale.js
+++ /dev/null
@@ -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"
- }
-};
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/main.js b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/main.js
deleted file mode 100644
index 01c86feb..00000000
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/js/main.js
+++ /dev/null
@@ -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 () {
- $(' ')
- .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});
- }
- });
- });
- }
-
-});
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/show.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/show.html.erb
index f02d9156..db321af9 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/show.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/back_end/archive_files/show.html.erb
@@ -9,7 +9,7 @@
<%= t('announcement.category') %>
- <%= @bulletin.bulletin_category.i18n_variable[I18n.locale] %>
+ <%= @bulletin.bulletin_category.title %>
<%= t('announcement.postdate') %>
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb
index ba70d365..cfcf47f9 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/index.html.erb
@@ -10,11 +10,11 @@
<% @archive_file_categorys.each do |afcpost| %>
- <%= link_to afcpost.i18n_variable[I18n.locale], panel_archive_front_end_archive_files_path(:category_id => afcpost.id) %>
+ <%= link_to afcpost.title, panel_archive_front_end_archive_files_path(:category_id => afcpost.id) %>
<% end %>
- <%= @archive_files.first.archive_file_category.i18n_variable[I18n.locale] rescue nil %>
+ <%= @archive_files.first.archive_file_category.title rescue nil %>
<% @archive_files.each do |post| %>
diff --git a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/show.html.erb b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/show.html.erb
index 08028554..6051eb4c 100644
--- a/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/show.html.erb
+++ b/vendor/built_in_modules/archive/app/views/panel/archive/front_end/archive_files/show.html.erb
@@ -4,7 +4,7 @@
<%= @title %>
<% end %>
-<%= @archive_file.archive_file_category.i18n_variable[I18n.locale] rescue nil %>
+<%= @archive_file.archive_file_category.title rescue nil %>
<%= @archive_file.title %>
diff --git a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
index d023a0fa..181a757b 100644
--- a/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
+++ b/vendor/built_in_modules/calendar/app/assets/javascripts/calendarAPI.js.erb
@@ -6,8 +6,7 @@ Date.prototype.getWeek = function (dowOffset) {
var newYear = new Date(this.getFullYear(),0,1);
var day = newYear.getDay() - dowOffset; //the day of week the year begins on
day = (day >= 0 ? day : day + 7);
- var daynum = Math.floor((this.getTime() - newYear.getTime() -
- (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
+ var daynum = Math.floor((this.getTime() - newYear.getTime() - (this.getTimezoneOffset()-newYear.getTimezoneOffset())*60000)/86400000) + 1;
var weeknum;
//if the year starts before the middle of a week
if(day < 4) {
@@ -45,12 +44,17 @@ var calendarAPI = function(){
this.cur_week = c.today.getWeek();
this.cur_date = c.today.getDate();
this.view = null;
+ this.calendars = new Array();
this.monthlist = ["","January","February","March","April","May","June","July","August","September","October","November","December"];
this.initialize = function(){
$(window).load(function(){
// c.loadMonthView(c.cur_month,c.cur_year);
// c.loadWeekView(c.cur_week,c.cur_year);
- c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
+ // c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
+ c.loadAgendaView();
+ $(".calendar-filter-btn").each(function(){
+ c.calendars.push($(this).attr("href"));
+ })
bindHandlers();
})
var bindHandlers = function(){
@@ -61,16 +65,56 @@ var calendarAPI = function(){
$("#create_event_btn").click(function(){
if(!$(this).hasClass("active")){
- c.newEvent($(this).attr("href"),$(this).attr("ref"),c.today.getDate(),c.today.getMonth()+1,c.today.getFullYear());
+ c.newEvent($(this).attr("href"),$(this).attr("ref"),c.today.getDate(),c.today.getMonth()+1,c.today.getFullYear(),10.5,"AM");
}else{
c.event_create_div.hide().empty();
}
$(this).toggleClass("active");
return false;
})
- $("td.click_event").live("click",function(){
- c.newEvent($(this).attr("link"),$(this).attr("ref"),$(this).attr("date"),c.cur_month,c.cur_year);
+ $(".click_event").live("click",function(e){
+ var dt = $(this).attr("date");
+ if(!dt){
+ var w = $("td.week_day_body").width();
+ var parentOffset = $("table.cell_map").offset();
+ var relX = e.pageX - parentOffset.left;
+ var t = 60;
+ for (var i = 0; i <= 6; i++) {
+ if(relX > t && relX < (t + w)){
+ console.log(i);
+ dt = $("td.week_day_body").eq(i).attr("date");
+ break;
+ }
+ t = t + w;
+ };
+ }
+ var time = $(this).attr("time");
+ var ses = $(this).attr("ses");
+ if (!time)
+ time = 10.5;
+ if(!ses)
+ ses = "AM";
+
+ c.newEvent($(this).attr("link"),$(this).attr("ref"),dt,c.cur_month,c.cur_year,time,ses);
$("#create_event_btn").toggleClass("active");
+ e.stopPropagation();
+ })
+ $(".calendar-filter-btn").click(function(){
+ $(this).toggleClass("active");
+ c.calendars = [];
+ $(".calendar-filter-btn").each(function(){
+ if($(this).hasClass("active"))
+ c.calendars.push($(this).attr("href"));
+ })
+ c.refresh();
+ })
+
+ $("#edit_event_btn").live("ajax:success",function(evt,form){
+ c.event_quick_view_div.empty().hide();
+ c.updateEvent(form);
+ })
+ $("#refresh_btn").click(function(){
+ c.refresh();
})
$('.mode_switch').click(function(){
@@ -196,6 +240,10 @@ var calendarAPI = function(){
}
}
this.loadMonthView = function(month,year){
+ $("#range_selection").hide();
+ $("#navigation").show();
+ $("#sec1").removeClass("span8").addClass("span3");
+ $("#sec2").show();
c.view = "month";
if(!month){
var dt = new Date();
@@ -236,7 +284,7 @@ var calendarAPI = function(){
this.getEventsForMonth = function(month,year){
- $.getJSON("cals/getMonthEvents",{"month":month,"year":year},function(events){
+ $.getJSON("cals/getMonthEvents",{"month":month,"year":year,"calendars":c.calendars},function(events){
makerow(events);
})
var doneEventArray = new Array();
@@ -262,7 +310,7 @@ var calendarAPI = function(){
curparent.append($eventrow);
}
$eventrow = null;
- $eventrow = $(" ");
+ $eventrow = $(" ");
allow = true;
}else if(evnt.start_date > curdate){
allow = true;
@@ -272,7 +320,7 @@ var calendarAPI = function(){
if(allow){
if(evnt.title=="Navratri")
- console.log(pos);
+ //console.log(pos);
if(pos == 1){
var colspan = 0;
if(evnt.total_days>7){
@@ -338,6 +386,10 @@ var calendarAPI = function(){
}
this.loadWeekView = function(week,year){
+ $("#range_selection").hide();
+ $("#navigation").show();
+ $("#sec1").removeClass("span8").addClass("span3");
+ $("#sec2").show();
c.view = "week";
if(!week){
var dt = new Date();
@@ -354,11 +406,11 @@ var calendarAPI = function(){
})
}
this.getEventsForWeek = function(week,year){
- $.getJSON("cals/getWeekEvents",{"week":week,"year":year},function(events){
+ $.getJSON("cals/getWeekEvents",{"week":week,"year":year,"calendars":c.calendars},function(events){
var height = 15;
var full_day_count = 0;
var rowcount = 7;
- var tr = $(" ");
+ var tr = $(" ");
var pre = true;
$.each(events,function(i,evnt){
// console.log("rowcount: "+rowcount);
@@ -371,7 +423,7 @@ var calendarAPI = function(){
$("table.all_day_event_holder").append(tr);
}
tr = null;
- tr = $(' ');
+ tr = $(' ');
pre = true;
}
@@ -440,7 +492,7 @@ var calendarAPI = function(){
if(h == 0.5)
halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1;
- var eventdom = $(''+displaystarttime+' - '+displayendtime+' '+evnt.title+' ');
+ var eventdom = $(''+displaystarttime+' - '+displayendtime+' '+evnt.title+' ');
$(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom);
}
if(full_day_count == 0){
@@ -458,6 +510,10 @@ var calendarAPI = function(){
})
}
this.loadDayView = function(day,month,year){
+ $("#range_selection").hide();
+ $("#navigation").show();
+ $("#sec1").removeClass("span8").addClass("span3");
+ $("#sec2").show();
c.view = "day";
if(!day){
var dt = new Date();
@@ -477,10 +533,10 @@ var calendarAPI = function(){
})
}
this.getEventsForDay = function(day,month,year){
- $.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){
+ $.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year,"calendars":c.calendars},function(events){
$.each(events,function(i,evnt){
if(evnt.all_day){
- $(".all_day_event").append(''+evnt.title+'
')
+ $(".all_day_event").append(''+evnt.title+'
')
}else{
var starttime,endtime,displaystarttime,displayendtime;
if(evnt.start_am_pm == "AM"){
@@ -521,7 +577,7 @@ var calendarAPI = function(){
if(h == 0.5)
halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1;
- var eventdom = $(''+displaystarttime+' - '+displayendtime+' '+evnt.title+' ');
+ var eventdom = $(''+displaystarttime+' - '+displayendtime+' '+evnt.title+' ');
$(".event_holder").append(eventdom);
}
@@ -529,12 +585,37 @@ var calendarAPI = function(){
})
}
- this.loadAgendaView = function(){
- $('#view_holder').load("cals/agenda_view", function() {
- $('.current_day_title').text('September 2, 2012');
+ this.loadAgendaView = function(start_month,start_year,end_month,end_year){
+ c.view = "agenda";
+ var url = "cals/agenda_view";
+ if(start_month && start_year && end_month && end_year)
+ var url = "cals/agenda_view?s_month="+start_month+"&s_year="+start_year+"&e_month="+end_month+"&e_year="+end_year ;
+
+ $('#view_holder').load(url, function() {
+ $("#navigation").hide();
+ $("#range_selection").html($("#agenda_date_range").html()).show();
+ $("#sec1").removeClass("span3").addClass("span8");
+ $("#sec2").hide();
+ bindHandlers();
})
+ var bindHandlers = function(){
+ $("select[name=start_year]").change(function(){
+ var x = parseInt($(this).val()) - parseInt($(this).find("option").eq(0).val());
+ $("select[name=end_year] option").removeAttr("disabled");
+ for(i=0;i 0){
$('.color-picker').miniColors(); // just in category view
@@ -586,8 +725,26 @@ var calendarAPI = function(){
c.event_quick_view_div.find(".event-close-btn").click(function(){
c.event_quick_view_div.empty().hide();
})
+ c.event_quick_view_div.find(".bt-del").bind("ajax:success",function(){
+ c.event_quick_view_div.empty().hide();
+ dom.remove();
+ })
})
}
+ this.refresh = function(){
+ $(".destroy").remove();
+ switch (c.view){
+ case "week":
+ c.loadWeekView(c.cur_week,c.cur_year);
+ break;
+ case "month":
+ c.loadMonthView(c.cur_month,c.cur_year);
+ break;
+ case "day":
+ c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
+ break;
+ }
+ }
c.initialize();
}
diff --git a/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js b/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js
new file mode 100644
index 00000000..f4b7b96c
--- /dev/null
+++ b/vendor/built_in_modules/calendar/app/assets/javascripts/cals.js
@@ -0,0 +1,9 @@
+// This is a manifest file that'll be compiled into including all the files listed below.
+// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
+// be included in the compiled file accessible from http://example.com/assets/application.js
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+//= require jquery-ui
+//= require bootstrap
+//= require calendarAPI
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
index 874904a5..8fa88b91 100644
--- a/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
+++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/calendar.css
@@ -18,7 +18,6 @@
line-height: 28px;
}
.calendar_mode {
- float: right;
z-index: 2;
}
.mode_switch {
@@ -37,6 +36,9 @@
-webkit-box-shadow: inset 0 0 1px black;
-moz-box-shadow: inset 0 0 1px black;
}
+.modal-body {
+ max-height: 450px;
+}
.event_list_wrapper {
position: relative;
}
@@ -71,7 +73,7 @@
}
#calendar_day .event_holder {
width: 100%;
- height: 100%;
+ /*height: 100%;*/
position: absolute;
top: 0;
z-index: 1;
@@ -164,19 +166,48 @@
/* agenda view */
#calendar_agenda {
- border-bottom: solid 1px #ddd;
+ margin-top: 20px;
}
#calendar_agenda .table {
margin-bottom: 0;
}
+#calendar_agenda .tiny_calendar {
+ border: solid 1px #eee;
+}
+#calendar_agenda .tiny_calendar .table th {
+ border-top: 0;
+}
+#calendar_agenda .tiny_calendar .table td {
+ text-align: center;
+}
#calendar_agenda .event {
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
+#calendar_agenda .row-fluid {
+ margin-top: 20px;
+ padding-top: 20px;
+ border-top: dashed 1px #ddd;
+}
+#calendar_agenda .row-fluid:first-child {
+ border-top: 0;
+ padding-top: 0;
+ margin-top: 0;
+}
+#calendar_agenda .table.event_list .span2, #calendar_agenda .table.event_list thead th {
+ min-height: 0 !important;
+ height: 0 !important;
+ line-height: 0;
+ padding: 0;
+}
.event_time {
font-family: Tahoma, sans-serif;
}
+.has_event {
+ background-color: #08c;
+ color: #fff;
+}
/* day view */
#calendar_day .header {
@@ -305,4 +336,25 @@
.miniColors-selector {
float: none;
margin: 4px 0 0 0;
+}
+
+/* create / edit event panel */
+#tags_panel {
+ top: auto;
+ bottom: 34px;
+ width: 258px;
+ height: 170px;
+ padding: 8px 0;
+ overflow: hidden;
+ position: absolute;
+ clear: none;
+}
+#tags_panel .viewport {
+ height: 170px;
+}
+#tags_panel .scrollbar {
+ top: 8px;
+}
+#tags_list {
+ padding: 8px;
}
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css b/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css
new file mode 100644
index 00000000..f07975b5
--- /dev/null
+++ b/vendor/built_in_modules/calendar/app/assets/stylesheets/cals.css
@@ -0,0 +1,8 @@
+/*
+ *This is a manifest file that'll automatically include all the stylesheets available in this directory
+ *and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
+ *the top of the compiled file, but it's generally better to create a new file per style scope.
+ *= font-awesome
+ *= calendar
+ *= bootstrap-responsive
+*/
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
index fdf712aa..9a414378 100644
--- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
+++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/cals_controller.rb
@@ -1,9 +1,9 @@
class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
include AdminHelper
include Panel::Calendar::BackEnd::CalsHelper
-
+ before_filter :force_order_for_user
def index
-
+ @calendars = Cal.all
end
def new
@@ -39,10 +39,10 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
def day_view
- date = params[:date].to_i
+ @date = params[:date].to_i
month = params[:month].to_i
year = params[:year].to_i
- @cur_day = getDayName(date,month,year) + " " + month.to_s + "/" + date.to_s + " - " + year.to_s
+ @cur_day = getDayName(@date,month,year) + " " + month.to_s + "/" + @date.to_s + " - " + year.to_s
@hours = getHours(12)
render :layout => false
end
@@ -79,17 +79,133 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
cur_month_days = getMonthDays(year)
@post_disabled_days = @pre_disabled_days + cur_month_days[month]
- @dateset = getDateSet(month,year)
+ @dateset = getDateSet(month,year,true)
render :layout => false
end
def agenda_view
+ @start_year = params[:s_year].to_i
+ @start_month = params[:s_month].to_i
+ @end_year = params[:e_year].to_i
+ @end_month = params[:e_month].to_i
+ t = Time.now
+ if !params[:s_year]
+ @start_year = t.year
+ end
+ if !params[:s_month]
+ @start_month = t.month
+ @end_month = t.month + 3
+ if @end_month > 12
+ @end_month = @end_month - 12
+ @end_year = @start_year + 1
+ end
+ end
+
+ startdt = Date.new(@start_year,@start_month,1)
+ temp = getMonthDays(@end_year)
+ enddt = Date.new(@end_year,@end_month,temp[@end_month])
+ diff = enddt - startdt
+ diff = diff.to_i / 30
+
+
+ @d_s_year = @start_year - 5
+ @datesets = Array.new
+ @calendartitle = Array.new
+ @events = Array.new
+ events = Event.all.asc(:start_date).desc(:total_days)
+ @calevents = Array.new
+ y = @start_year
+ m = @start_month
+ for i in 0..diff-1
+ if m == 13
+ m = 1
+ y = y + 1
+ end
+ @calendartitle << [m,y]
+ @datesets << getDateSet(m,y,false)
+ e = Array.new
+ h = Array.new
+ events.each_with_index do |event,i|
+ # @temp = Array.new
+ startdt = Date.new(event.start_year,event.start_month)
+ enddt = Date.new(event.end_year,event.end_month)
+ range = startdt..enddt
+ dt = Date.new(y,m)
+ if range === dt
+ no_of_days = event.total_days
+ start_date = event.start_date
+
+ if event.start_year < y
+ no_of_days = temp[m] - event.start_date
+ no_of_days += 1
+ temp = m + 12
+ if event.start_month < temp
+ start_date = 1
+ end
+ end
+ if event.end_year > y
+ no_of_days = temp[m] - event.start_date
+ no_of_days += 1
+ temp = m + 12
+ end
+ if event.end_month > m
+ no_of_days = temp[m] - event.start_date
+ no_of_days += 1
+ elsif event.end_month == m
+ no_of_days = event.end_date
+ end
+
+ if event.start_month == m && event.end_month == m
+ no_of_days = event.total_days
+ no_of_days += 1
+ end
+
+ if event.start_month < m
+ start_date = 1
+ end
+
+ if event.start_date == event.end_date
+ display_date = getDayName(event.start_date,event.start_month,event.start_year) + ", " + Date::ABBR_MONTHNAMES[event.start_month] + " " + event.start_date.to_s
+ else
+ display_date = getDayName(event.start_date,event.start_month,event.start_year) + ", " + Date::ABBR_MONTHNAMES[event.start_month].to_s + " " + event.start_date.to_s + " - " + getDayName(event.end_date,event.end_month,event.end_year) + ", " + Date::ABBR_MONTHNAMES[event.end_month] + " " + event.end_date.to_s
+ end
+ if event.all_day
+ display_time = "All Day"
+ else
+ x = event.start_time.to_i
+ if event.start_time > x
+ est = x.to_s + ":30"
+ else
+ est = x.to_s
+ end
+ x = event.end_time.to_i
+ if event.end_time > x
+ eet = x.to_s + ":30"
+ else
+ eet = x.to_s
+ end
+ display_time = est + " " + event.start_am_pm + " - " + eet + " " + event.end_am_pm
+ end
+ for c in start_date..(start_date + no_of_days)
+ if h.index(c) == nil
+ h << c
+ end
+ end
+ color = Cal.find(event.cal_id).color
+ e << {"display_date"=>display_date,"show_link"=>panel_calendar_back_end_event_path(event), "display_time"=>display_time, "start_date"=>start_date,"end_date"=>event.end_date,"start_month"=>event.start_month,"end_month"=>event.end_month,"title" => event.title,"color"=>color}
+ end
+ end
+ @events << e
+ @calevents << h
+ m = m + 1
+ end
render :layout => false
end
def get_month_events
month = params[:month].to_i
year = params[:year].to_i
+ fromcalendars = params[:calendars]
# events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days)
@events = Array.new
@@ -121,7 +237,7 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
# color = Cal.find(event.cal_id).color
# @events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
# end
- events = Event.all.asc(:start_date).desc(:total_days)
+ events = Event.where(:cal_id.in=>fromcalendars).asc(:start_date).desc(:total_days)
events.each_with_index do |event,i|
# @temp = Array.new
startdt = Date.new(event.start_year,event.start_month)
@@ -174,8 +290,9 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
def get_week_events
week = params[:week].to_i
year = params[:year].to_i
+ fromcalendars = params[:calendars]
@d = getWeekDataSet(week,year)
- events = Event.where(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year).asc(:start_week).asc(:start_date)
+ events = Event.where(:cal_id.in=>fromcalendars).and(:start_week.lte => week).and(:start_year => year).and(:end_week.gte => week).and(:start_year => year).asc(:start_week).asc(:start_date)
@events = Array.new
events.each_with_index do |event,i|
# @temp = Array.new
@@ -230,6 +347,7 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
day = params[:date].to_i
month = params[:month].to_i
year = params[:year].to_i
+ fromcalendars = params[:calendars]
dt = Date.new(year,month,day)
week = dt.strftime("%U")
events = Event.where(:start_month.lte => month).and(:start_year => year).and(:end_month.gte => month)
diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
index 41ffa151..4e477ded 100644
--- a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
+++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/events_controller.rb
@@ -8,10 +8,47 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
else
@all_day_disabled = false
end
- @placeholder = params[:date]+"/"+params[:month]+"/"+params[:year]
+ @hours = getHoursForForm
+ if params[:time]
+
+ @hours.each_with_index do |h,i|
+ if h['val'].to_s == params[:time].to_s
+ @sindex = i
+ @eindex = i + 2
+ break
+ end
+ end
+ else
+ @sindex = 16
+ @eindex = 18
+ end
+ @ampm = Array.new
+ @ampm << "AM"
+ @ampm << "PM"
+ if params[:ses]
+ @sampm = params[:ses]
+ @eampm = params[:ses]
+ if @eindex >= 22
+ @eampm = "PM"
+ end
+ end
+ @placeholder = params[:month]+"/"+params[:date]+"/"+params[:year]
render :layout => false
end
-
+ def edit
+ @calendars = Cal.all
+ @event = Event.find(params[:id])
+ if @event.all_day
+ @all_day_disabled = true
+ else
+ @all_day_disabled = false
+ end
+ @hours = getHoursForForm
+ @ampm = Array.new
+ @ampm << "AM"
+ @ampm << "PM"
+ render :layout => false
+ end
def create
title = params[:event][:title]
note = params[:event][:note]
@@ -21,14 +58,14 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
$endtime = params[:end_time]
temp = $start.split("/")
- start_date = temp[0]
- start_month = temp[1]
+ start_month = temp[0]
+ start_date = temp[1]
start_year = temp[2]
@m = start_month
@y = start_year
temp = $end.split("/")
- end_date = temp[0]
- end_month = temp[1]
+ end_month = temp[0]
+ end_date = temp[1]
end_year = temp[2]
start_am_pm = params[:start_am_pm]
@@ -81,6 +118,78 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
h.js
end
end
+
+ def update
+
+ title = params[:event][:title]
+ note = params[:event][:note]
+ $start = params[:start_date]
+ $end = params[:end_date]
+ $starttime = params[:start_time]
+ $endtime = params[:end_time]
+
+ temp = $start.split("/")
+ start_month = temp[0]
+ start_date = temp[1]
+ start_year = temp[2]
+ @m = start_month
+ @y = start_year
+ temp = $end.split("/")
+ end_month = temp[0]
+ end_date = temp[1]
+ end_year = temp[2]
+
+ start_am_pm = params[:start_am_pm]
+ end_am_pm = params[:end_am_pm]
+
+ cal_id = params[:event][:cal_id]
+
+ # if start_am_pm == "PM"
+ # temp_start_time = $starttime + 12
+ # end
+ # if end_am_pm == "PM"
+ # temp_end_time = $endtime + 12
+ # end
+ if params[:all_day]
+ all_day = true
+ $starttime = 0
+ $endtime = 0
+ else
+ all_day = false
+ end
+
+ final_start_time = Date.new(start_year.to_i,start_month.to_i,start_date.to_i)
+ final_end_time = Date.new(end_year.to_i,end_month.to_i,end_date.to_i)
+ start_week = final_start_time.strftime("%U")
+ end_week = final_end_time.strftime("%U")
+ total_days = final_end_time - final_start_time
+ @event = Event.find(params[:id])
+ @event.title = title
+ @event.note = note
+ @event.start_year = start_year
+ @event.end_year = end_year
+ @event.start_month = start_month
+ @event.end_month = end_month
+ @event.start_date = start_date
+ @event.end_date = end_date
+ @event.start_time = $starttime
+ @event.start_am_pm = start_am_pm
+ @event.end_time = $endtime
+ @event.end_am_pm = end_am_pm
+ @event.cal_id = cal_id
+ @event.final_start_time = final_start_time
+ @event.final_end_time = final_end_time
+ @event.total_days = total_days
+ @event.start_week = start_week
+ @event.end_week = end_week
+ @event.all_day = all_day
+ @event.save!
+
+ respond_to do |h|
+ h.js
+ end
+ end
+
def show
@event = Event.find(params[:id])
@start_month_name = Date::ABBR_MONTHNAMES[@event.start_month]
diff --git a/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/tags_controller.rb b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/tags_controller.rb
new file mode 100644
index 00000000..46596250
--- /dev/null
+++ b/vendor/built_in_modules/calendar/app/controllers/panel/calendar/back_end/tags_controller.rb
@@ -0,0 +1,6 @@
+class Panel::Calendar::BackEnd::TagsController < Admin::TagsController
+ def initialize
+ super
+ @app_title = 'calendar'
+ end
+end
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
index fc349ecd..17760629 100644
--- a/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
+++ b/vendor/built_in_modules/calendar/app/helpers/panel/calendar/back_end/cals_helper.rb
@@ -6,7 +6,7 @@ module Panel::Calendar::BackEnd::CalsHelper
return startday
end
- def getDateSet(month,year)
+ def getDateSet(month,year,prepost)
dateset = Array.new
startday = monthStartDay(month,year)
monthsdays = getMonthDays(year)
@@ -20,7 +20,11 @@ module Panel::Calendar::BackEnd::CalsHelper
i = prev_month_days_to_add
while i > 0 do
i -= 1
- dateset << prev_month_days - i
+ if prepost
+ dateset << prev_month_days - i
+ else
+ dateset << "NaN"
+ end
end
i = 0
@@ -29,11 +33,21 @@ module Panel::Calendar::BackEnd::CalsHelper
i += 1
end
- next_month_days_to_add = 42 - (prev_month_days_to_add + cur_month_days)
+ total_days = 42
+ if !prepost
+ if (prev_month_days_to_add + cur_month_days) < 35
+ total_days = 35
+ end
+ end
+ next_month_days_to_add = total_days - (prev_month_days_to_add + cur_month_days)
i = 0
while i < next_month_days_to_add do
- dateset << i + 1
+ if prepost
+ dateset << i + 1
+ else
+ dateset << "NaN"
+ end
i += 1
end
@@ -180,6 +194,15 @@ module Panel::Calendar::BackEnd::CalsHelper
end
hours
end
+
+ def getHoursForForm
+ hours = Array.new
+ for i in 1..12
+ hours << {"val"=>i,"title"=>i.to_s+":00"}
+ hours << {"val"=>i+0.5,"title"=>i.to_s+":30"}
+ end
+ hours
+ end
end
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
index 57bb1bf9..0a57ae8c 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/agenda_view.html.erb
@@ -1,267 +1,110 @@
+
+ From
+ <% for i in 1..12 %>
+ <% if i == @start_month %>
+ <%= Date::MONTHNAMES[i] %>
+ <% else %>
+ <%= Date::MONTHNAMES[i] %>
+ <% end %>
+ <% end %>
+
+
+ <% for i in 1..10 %>
+ <% if (@d_s_year + i) == @start_year %>
+ <%= @d_s_year + i %>
+ <% else %>
+ <%= @d_s_year + i %>
+ <% end %>
+ <% end %>
+
+ To
+ <% for i in 1..12 %>
+ <% if i == @end_month %>
+ <%= Date::MONTHNAMES[i] %>
+ <% else %>
+ <%= Date::MONTHNAMES[i] %>
+ <% end %>
+ <% end %>
+
+
+ <% for i in 1..10 %>
+ <% if (@d_s_year + i) == @end_year %>
+ <%= @d_s_year + i %>
+ <% elsif (@d_s_year + i) <= @start_year %>
+ <%= @d_s_year + i %>
+ <% else %>
+ <%= @d_s_year + i %>
+ <% end %>
+ <% end %>
+
+ Show Events
+
-
-
-
-
-
-
-
-
-
-
- Thu, Sep 6
- 9:00am - 9:30am
-
- Commuting time, from home to RD
-
-
-
-
- 9:30am - 12:00am
-
- Work on Thu project, and ask ika for help if possible
-
-
-
-
- 13:30pm - 18:00pm
-
- Template design, at least finish 2 template
-
-
-
- Fri, Sep 7
- 9:00am - 18:00pm
-
- Take a day off
-
-
-
- Sat, Sep 8
- 7:00am - 7:50pm
-
- Work out with Joseph
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <% lastday = "" %>
+ <% if @events[i].count > 0 %>
+ <% @events[i].each do |event| %>
+
+
+ <% if event['display_date'] != lastday %>
+ <%= event['display_date'] %>
+ <% end %>
+
+ <%= event['display_time'] %>
+
+ <%= event['title'] %>
+
+
+ <% lastday = event['display_date'] %>
+ <% end %>
+ <% else %>
-
-
-
-
-
-
-
-
+ No events for this month.
-
-
-
-
-
-
-
- 10:30am - template
-
-
-
-
-
-
-
-
-
-
- 10:30am - template
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 12am
- 1am
- 2am
- 3am
- 4am
- 5am
- 6am
- 7am
- 8am
- 9am
- 10am
- 11am
- 12am
- 1pm
- 2pm
- 3pm
- 4pm
- 5pm
- 6pm
- 7pm
- 8pm
- 9pm
- 10pm
- 11pm
-
-
-
-
-
-
-
-
-
-
-
-
- 10:30am - 11:00am
- template
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ <% end %>
+
+
+
-
- -->
\ No newline at end of file
+ <% end %>
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb
index 709437c7..2edd9e7c 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/day_view.html.erb
@@ -28,11 +28,13 @@
<% @hours.each do |hour| %>
-
-
+
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="AM">
+
-
-
+ <% end %>
+ <% @hours.each do |hour| %>
+
" ref="add-btn" link="<%= new_panel_calendar_back_end_event_path %>" date="<%= @date.to_s %>" ses="PM">
+
<% end %>
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb
index 791cfe19..eea0e647 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/index.html.erb
@@ -1,10 +1,8 @@
<%= stylesheet_link_tag "font-awesome" %>
-<%= stylesheet_link_tag "calendar" %>
<%= stylesheet_link_tag "bootstrap-responsive" %>
-<% content_for :page_specific_javascript do %>
- <%= javascript_include_tag "calendarAPI" %>
-<% end %>
-
+<%= stylesheet_link_tag "calendar" %>
+<%= javascript_include_tag "cals" %>
+
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb
index 98703270..a07068ca 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/create.js.erb
@@ -1,4 +1,14 @@
$("#event_create").empty().hide();
$("#create_event_btn").removeClass("active");
-$("#calendar_month tr.event_row").remove();
-calendar.getEventsForMonth(<%= @m %>,<%= @y %>);
\ No newline at end of file
+$(".destroy").remove();
+switch (c.view){
+ case "week":
+ c.loadWeekView(c.cur_week,c.cur_year);
+ break;
+ case "month":
+ c.loadMonthView(c.cur_month,c.cur_year);
+ break;
+ case "day":
+ c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
+ break;
+}
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb
new file mode 100644
index 00000000..3db09901
--- /dev/null
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/edit.html.erb
@@ -0,0 +1,133 @@
+
+
+
+ <%= form_for @event, :url =>panel_calendar_back_end_event_path(@event), :class=>"form-horizontal", :remote => true do |f| %>
+
+ ×
+
+
+ <%= f.text_field :title, :class=>"span12", :placeholder => "Event Name",:value=>@event.title %>
+
+
+
+ > All day
+
+
+ Repeat
+
+
+ <% if !@event.all_day %>
+
+
+
From
+
+ " name="start_date">
+
+ <% @hours.each_with_index do |hour,i| %>
+ <% if hour['val'] == @event.start_time %>
+ <%= hour['title'] %>
+ <% else %>
+ <%= hour['title'] %>
+ <% end %>
+ <% end %>
+
+
+ <% @ampm.each do |a| %>
+ <% if @event.start_am_pm == a %>
+ <%= a %>
+ <% else %>
+ <%= a %>
+ <% end %>
+ <% end %>
+
+
+
+
+
To
+
+ " name="end_date">
+
+ <% @hours.each_with_index do |hour,i| %>
+ <% if hour['val'] == @event.end_time %>
+ <%= hour['title'] %>
+ <% else %>
+ <%= hour['title'] %>
+ <% end %>
+ <% end %>
+
+
+ <% @ampm.each do |a| %>
+ <% if @event.end_am_pm == a %>
+ <%= a %>
+ <% else %>
+ <%= a %>
+ <% end %>
+ <% end %>
+
+
+
+
+ <% else %>
+
+
+
From
+
+
+
+ <% @hours.each_with_index do |hour,i| %>
+ <% if i == 16 %>
+ <%= hour['title'] %>
+ <% else %>
+ <%= hour['title'] %>
+ <% end %>
+ <% end %>
+
+
+ AM
+ PM
+
+
+
+
+
To
+
+
+
+ <% @hours.each_with_index do |hour,i| %>
+ <% if i == 18 %>
+ <%= hour['title'] %>
+ <% else %>
+ <%= hour['title'] %>
+ <% end %>
+ <% end %>
+
+
+ AM
+ PM
+
+
+
+
+ <% end %>
+
+
Calendars
+
+ <%= f.select(:cal_id, Cal.all.collect {|p| [ p.name, p.id ] },{:prompt => t("calendar.select_calendar")},:class => "validate", :selected => @event.cal_id) %>
+
+
+
+
Note
+
+ <%= f.text_area :note, :class=>"span12", :cols=>"30", :rows=>"3", :value => @event.note %>
+
+
+
+
+ Cancel
+ <%= f.submit t("calendar.save"), :class=>"btn" %>
+
+
+<% end %>
+
+
+
\ No newline at end of file
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb
index 5fd5870e..713eebc5 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/new.html.erb
@@ -22,72 +22,48 @@
@@ -98,6 +74,35 @@
<%= f.select(:cal_id, Cal.all.collect {|p| [ p.name, p.id ] },{:prompt => t("calendar.select_calendar")},:class => "validate") %>
+
+
Tags
+
+ Choose Tags
+
+
+
Note
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb
index 6f731784..a52b9f35 100644
--- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/show.html.erb
@@ -13,6 +13,6 @@
diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb
new file mode 100644
index 00000000..8875d214
--- /dev/null
+++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/events/update.js.erb
@@ -0,0 +1,15 @@
+$("#event_create").empty().hide();
+$("#create_event_btn").removeClass("active");
+$(".destroy").remove();
+$("#create_event_btn").show();
+switch (c.view){
+ case "week":
+ c.loadWeekView(c.cur_week,c.cur_year);
+ break;
+ case "month":
+ c.loadMonthView(c.cur_month,c.cur_year);
+ break;
+ case "day":
+ c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
+ break;
+}
diff --git a/vendor/built_in_modules/calendar/config/routes.rb b/vendor/built_in_modules/calendar/config/routes.rb
index 85091807..b975c548 100644
--- a/vendor/built_in_modules/calendar/config/routes.rb
+++ b/vendor/built_in_modules/calendar/config/routes.rb
@@ -13,7 +13,7 @@ Rails.application.routes.draw do
resources :cals
resources :events
-
+ resources :tags
end
end
end
diff --git a/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/back_end/writing_books_controller.rb b/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/back_end/writing_books_controller.rb
index 3e0dc5ea..48ebf333 100644
--- a/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/back_end/writing_books_controller.rb
+++ b/vendor/built_in_modules/personal_book/app/controllers/panel/personal_book/back_end/writing_books_controller.rb
@@ -179,12 +179,23 @@ class Panel::PersonalBook::BackEnd::WritingBooksController < OrbitBackendControl
@writing_book = WritingBook.new(params[:writing_book])
- @writing_book.create_user_id = current_user.id
- @writing_book.update_user_id = current_user.id
+ if params[:writing_book][:user_id]
+ @writing_book.create_user_id = params[:writing_book][:user_id]
+ @writing_book.update_user_id = params[:writing_book][:user_id]
+ else
+ @writing_book.create_user_id = current_user.id
+ @writing_book.update_user_id = current_user.id
+ end
respond_to do |format|
if @writing_book.save
- format.html { redirect_to(panel_personal_book_back_end_writing_books_url) }
+
+ if params[:writing_book][:user_id]
+ format.html { redirect_to(admin_users_new_interface_url(:id=>params[:writing_book][:user_id],:show_plugin_profile=>'Book')) }
+ else
+ format.html { redirect_to(panel_personal_book_back_end_writing_books_url) }
+ end
+
format.xml { render :xml => @writing_book, :status => :created, :location => @writing_book }
else
format.html { render :action => "new" }
diff --git a/vendor/built_in_modules/personal_book/app/models/writing_book.rb b/vendor/built_in_modules/personal_book/app/models/writing_book.rb
index 7547d0db..bc5fbdb3 100644
--- a/vendor/built_in_modules/personal_book/app/models/writing_book.rb
+++ b/vendor/built_in_modules/personal_book/app/models/writing_book.rb
@@ -32,8 +32,8 @@ class WritingBook
field :publication_date, :type => Date
field :url
field :note
- field :create_user_id
- field :update_user_id
+ field :create_user_id, :type => BSON::ObjectId
+ field :update_user_id, :type => BSON::ObjectId
# field :is_top, :type => Boolean, :default => false
# field :is_hot, :type => Boolean, :default => false
diff --git a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/back_end/writing_books/_form.html.erb b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/back_end/writing_books/_form.html.erb
index 8b0d0132..7cec450f 100644
--- a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/back_end/writing_books/_form.html.erb
+++ b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/back_end/writing_books/_form.html.erb
@@ -47,6 +47,15 @@
+
+ <% if !params[:user_id].blank? %>
+
+
+ <%= t("著作人")%>
+ <%= User.from_id(params[:user_id]).name rescue ''%>
+
+
+ <% end %>
<%= f.label :year ,t("personal_book.year")%>
@@ -218,6 +227,7 @@
+ <%= f.hidden_field :user_id, :value => params[:user_id] if !params[:user_id].blank? %>
<%= f.submit t('submit'), :class=>'btn btn-primary' %>
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
diff --git a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/plugin/_profile.html.erb b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/plugin/_profile.html.erb
index 5fd23486..7905433e 100644
--- a/vendor/built_in_modules/personal_book/app/views/panel/personal_book/plugin/_profile.html.erb
+++ b/vendor/built_in_modules/personal_book/app/views/panel/personal_book/plugin/_profile.html.erb
@@ -50,6 +50,9 @@
+<%= link_to content_tag(:i, nil, :class => 'icon-plus icon-white') + t('announcement.add_new'), new_panel_personal_book_back_end_writing_book_path(:user_id => @user.id), :class => 'btn btn-primary pull-right' %>
+
+