Merge branch 'new_member' of github.com:Rulingcom/orbit into new_member

Conflicts:
	vendor/built_in_modules/personal_patent/app - %BDƻs/assets/images/personal_patent/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/assets/javascripts/personal_patent/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/assets/stylesheets/personal_patent/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/application_controller.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/tags_controller.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patent_categorys_controller.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.00.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/back_end/writing_patents_controller.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/controllers/panel/personal_patent/plugin/writing_patents_controller.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/helpers/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/mailers/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/models/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/models/personal_patent_tag.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_category.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/models/writing_patent_file.rb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/.gitkeep
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/_form.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/_writing_patent_category.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/create.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/destroy.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/edit.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/index.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/new.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patent_categorys/update.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_filter.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_form.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_form_file.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_list_writing_patent_category.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_sort_headers.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_writing_patent.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/_writing_patent_category_qe.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/create_writing_patent_setting.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/destroy.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/edit.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/index.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/index.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/new.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/show.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/toggle_enable.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/update_writing_patent_setting.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/writing_patent_category_quick_add.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/writing_patent_category_quick_edit.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/back_end/writing_patents/writing_patent_setting.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_filter.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_form.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_form_file.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_sort_headers.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/_writing_patent.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/destroy.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/edit.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/index.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/index.js.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/new.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/show.html.erb
	vendor/built_in_modules/personal_patent/app - %BDƻs/views/panel/personal_patent/plugin/writing_patents/toggle_enable.js.erb
This commit is contained in:
Matthew K. Fu JuYuan 2012-10-30 10:11:51 +08:00
commit 664c6d2f61
68 changed files with 1393 additions and 572 deletions

22
Guardfile Normal file
View File

@ -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

View File

@ -1,111 +1,7 @@
<%#= encoding: utf-8 %>
$(document).on('click', '#ajax_form_submit', function(){
// $('#ajaxForm').ajaxSubmit({
// beforeSubmit: function(a,f,o) {
// o.dataType = 'script';
// if (o.dataType == 'script') {
// o.url = o.url.split('?'); // split on GET params
// if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
// o.url = o.url.join('?'); // join on GET params
// }
// },
// success: function(response,status,xhr){
// alert(response);
// alert(status);
// alert(xhr);
// },
// error:function(){
// alert("error");
// }
// });
var o = {
// dataType: 'script',
dataType: 'html',
url:$("#ajaxForm").attr("action"),
beforeSubmit: function(){
var sub = true;
$("span.error").remove();
$("#dyn_error").empty();
$("#ajaxForm input").each(function(){
if($(this).val() == ""){
$("<span class='error'> *</span>").insertAfter($(this));
sub = false;
}
})
if(!sub){
$("#dyn_error").text("Cannot be empty.");
$("#dyn_error").text("<%= I18n.t('cant_empty_star') %>");
return false;
}
$('#ajaxForm').ajaxForm({
beforeSubmit: function(a,f,o) {
o.dataType = 'script';
},
success: function(response,status,xhr){
if(typeof tinyMCEPopup != "undefined"){
var x = response.split("#");
var returnurl = x[0],
returntitle = x[1],
returndescription = x[2];
var win = tinyMCEPopup.getWindowArg("window");
win.document.getElementById(tinyMCEPopup.getWindowArg("input")).value = returnurl;
win.document.getElementById(tinyMCEPopup.getWindowArg("alt")).value = returndescription;
win.document.getElementById(tinyMCEPopup.getWindowArg("title")).value = returntitle;
if (typeof(win.ImageDialog) != "undefined") {
// we are, so update image dimensions...
if (win.ImageDialog.getImageData)
win.ImageDialog.getImageData();
// ... and preview if necessary
if (win.ImageDialog.showPreviewImage)
win.ImageDialog.showPreviewImage(returnurl);
success: function(data) {
}
tinyMCEPopup.close();
}else{
//incase if we want to do something for quick edit file upload
// var modalvalues = "";
// var r = "";
// if(rcom.getInternetExplorerVersion() > -1){
// r = "<tr><td>" + response + "</td></tr>";
// r = r.replace("**","</td><td>");
// r = r.replace("**","</td><td>");
// r = $(r);
// modalvalues = r.find("span").attr("data-content").split("#");
// r.attr("id",r.find("span").attr("for"));
// var table=document.getElementById(modalvalues[0]);
// //var tbody = table.getElementsByTagName("tbody");
// var row = table.insertRow(table.rows.length-1);
// var c1 = row.insertCell(0),
// c2 = row.insertCell(1),
// c3 = row.insertCell(2);
// c1.innerHTML = r.find("td").eq(0).html();
// c2.innerHTML = r.find("td").eq(1).html();
// c3.innerHTML = r.find("td").eq(2).html();
// var trow = $("#bulletin_files tfoot").find("tr").eq(0);
// $("#bulletin_files tbody").append(trow);
// }else{
// response = response.replace("**","");
// response = response.replace("**","");
// r = $(response);
// modalvalues = r.find("span").attr("data-content").split("#");
// $('#' + modalvalues[0]+ ' tbody').append(r);
// }
// console.log(modalvalues[1]);
// $("#"+modalvalues[1]).modal('hide');
//$('#bulletin_files tbody').append(r);
//$(response).fadeIn();
}
},
error:function(){
alert("error");
}
}
if (o.dataType == 'script') {
o.url = o.url.split('?'); // split on GET params
if (o.url[0].substr(-3) != '.js') o.url[0] += '.js'; // force rails to respond to respond to the request with :format = js
o.url = o.url.join('?'); // join on GET params
}
$('#ajaxForm').ajaxSubmit(o);
});

View File

@ -267,6 +267,12 @@
#post-body-content {
padding: 8px 0 8px 6px;
}
#post-body-content .middle {
width: 100%;
padding: 0;
border: none;
box-shadow: none;
}
.filter .accordion-group {
margin-bottom: 0;
border: none;

View File

@ -34,14 +34,37 @@ class Admin::DesignsController < OrbitBackendController
def update
@design = Design.find(params[:id])
if @design.update_attributes(params[:design])
flash[:notice] = "Successfully updated design and tasks."
redirect_to admin_designs_url(@design)
else
render :action => 'edit'
@design.update_attributes(params[:design])
# if @design.update_attributes(params[:design])
# flash[:notice] = "Successfully updated design and tasks."
# redirect_to admin_designs_url(@design)
# else
# render :action => 'edit'
# end
respond_to do |format|
format.js {nil}
end
end
def update_file
@design = Design.find(params[:id])
case params[:type]
when 'layout', 'css_default', 'css_reset'
@object = @design.send(params[:type])
when 'image', 'javascript', 'theme'
@object = @design.send(params[:type]).find(params[:object_id])
end
Dir.mktmpdir('f_path') { |dir|
temp_file = File.new(dir + '/' + File.basename(@object.file.url), 'w+')
temp_file.write(params[:file][:content].force_encoding('UTF-8'))
@object.remove_file!
@object.file = temp_file
@object.save
}
end
def edit_file
@design = Design.find(params[:id])
filename = params[:filename]
@ -92,13 +115,19 @@ class Admin::DesignsController < OrbitBackendController
redirect_to admin_designs_url(:direction => params[:direction], :sort => params[:sort], :sort_options => params[:sort_options])
end
def upload_image
@design = Design.find(params[:id])
@image = @design.images.build(params[:image])
@image.save
render :layout => false
end
protected
def unzip_design(file, zip_name)
Zip::ZipFile.open(file) { |zip_file|
design = Design.new.from_json(zip_file.read("#{zip_name}/info.json"))
Dir.mktmpdir('f_path') { |dir|
design.build_layout
themes_entries = []
javascripts_entries = []
images_entries = []
@ -106,25 +135,11 @@ class Admin::DesignsController < OrbitBackendController
zip_file.entries.each do |entry|
case (path = entry.to_s)
when /\A(#{zip_name})\/(default\.css)\z/ #for default css
filename = File.basename(entry.to_s)
temp_file = File.new(dir + '/' + filename, 'w+')
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
default_css = design.build_default_css
default_css.file = temp_file
default_css.to_save = true
design.build_css_default(:file => get_temp_file(zip_file, dir, entry))
when /\A(#{zip_name})\/(reset\.css)\z/ #for reset css
filename = File.basename(entry.to_s)
temp_file = File.new(dir + '/' + filename, 'w+')
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
reset_css = design.build_reset_css
reset_css.file = temp_file
reset_css.to_save = true
design.build_css_reset(:file => get_temp_file(zip_file, dir, entry))
when /\A(#{zip_name})\/(layout\.html)\z/ #for layout html
filename = File.basename(entry.to_s)
temp_file = File.new(dir + '/' + filename, 'w+')
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
design.layout.file = temp_file
design.layout.to_save=true
design.build_layout(:file => get_temp_file(zip_file, dir, entry))
when /\A(#{zip_name})\/(themes)\/.*(\.css)\z/ #for themes css
themes_entries << entry
when /\A(#{zip_name})\/(javascripts)\/.*(\.js)\z/ #for js
@ -136,12 +151,7 @@ class Admin::DesignsController < OrbitBackendController
['themes', 'javascripts', 'images'].each do |type|
eval("#{type}_entries").each do |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')
build_and_store = eval("design.#{type}").build
build_and_store.file = temp_file
build_and_store.to_save = true
eval("design.#{type}").build(:file => get_temp_file(zip_file, dir, entry))
end
end
}
@ -149,4 +159,11 @@ class Admin::DesignsController < OrbitBackendController
}
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

View File

@ -71,8 +71,8 @@ class Admin::PurchasesController < ApplicationController
Dir.mktmpdir('f_path') { |dir|
build_file(orig_zip, zip_name, dir, design.layout) if design.layout
build_file(orig_zip, zip_name, dir, design.default_css) if design.default_css
build_file(orig_zip, zip_name, dir, design.reset_css) if design.reset_css
build_file(orig_zip, zip_name, dir, design.css_default) if design.css_default
build_file(orig_zip, zip_name, dir, design.css_reset) if design.css_reset
['themes', 'javascripts', 'images'].each do |type|
design.send(type).each do |object|

View File

@ -7,7 +7,7 @@ class SessionsController < Devise::SessionsController
# login_password = params[:user][:password]
# login_uid = params[:user][:nccu_ldap_uid]
login_password = params[:user][:password]
login_email = params[:user][:login]
login_email = params[:user][:email]
result = false
resource = User.first(conditions:{ email: login_email })
set_flash_message(:notice, :signed_in) if is_navigational_format?

View File

@ -181,13 +181,13 @@ module ApplicationHelper
stylesheets << "<link href='/assets/bootstrap-orbit.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/style.css' rel='stylesheet' type='text/css' />\n"
end
stylesheets << "<link href='#{page.design.reset_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.reset_css
stylesheets << "<link href='#{page.design.css_reset.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_reset
stylesheets << "<link href='/assets/bootstrap.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/font-awesome.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/orbit-bar.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='/assets/social-share-button.css' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{asset_path 'banner_nav.css'}' rel='stylesheet' type='text/css' />\n"
stylesheets << "<link href='#{page.design.default_css.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.default_css
stylesheets << "<link href='#{page.design.css_default.file.url}' rel='stylesheet' type='text/css' />\n" if page.design.css_default
theme = page.design.themes.detect{ |d| d.id == page.theme_id }
stylesheets << "<link href='#{theme.file.url}' rel='stylesheet' type='text/css' />\n" if theme
stylesheets

View File

@ -0,0 +1,5 @@
class CssDefault < Stylesheet
belongs_to :design
end

View File

@ -0,0 +1,5 @@
class CssReset < Stylesheet
belongs_to :design
end

View File

@ -3,26 +3,28 @@ class Design
include Mongoid::Timestamps
include ParserLayout
field :title, :type => String
field :author, :type => String
field :intro, :type => String
field :title, :type => String
field :version, :type => String
has_one :css_default, :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 :pages
has_many :themes, :autosave => true, :dependent => :destroy
embeds_one :layout, :cascade_callbacks => true
embeds_one :default_css, :class_name => "Stylesheet", :cascade_callbacks => true
embeds_one :reset_css, :class_name => "Stylesheet", :cascade_callbacks => true
embeds_many :themes, :cascade_callbacks => true
embeds_many :javascripts, :cascade_callbacks => true
embeds_many :images, :as => :design_image, :cascade_callbacks => true
# embeds_many :custom_images, :class_name => 'Image', :cascade_callbacks => true
accepts_nested_attributes_for :images, :allow_destroy => true
accepts_nested_attributes_for :javascripts, :allow_destroy => true
accepts_nested_attributes_for :themes, :allow_destroy => true
validates_presence_of :title
validates_presence_of :author
validates_presence_of :author, :title
after_save :parse_css_for_images
def new_files=(*attrs)
attrs[0].map do |key,items_ary| #Loop by JSs,Themes,Imgs
self.files=([items_ary, key])
@ -66,14 +68,10 @@ class Design
protected
def parse_css_for_images
if (self.default_css && self.default_css.changed)
self.default_css.parse_urls
end
self.css_default.parse_urls
self.themes.each do |theme|
if theme.changed?
theme.parse_urls
end
end
parse_body_for_images(self)
end

View File

@ -4,7 +4,14 @@ class DesignFile
mount_uploader :file, AssetUploader
field :to_save, :type => Boolean
field :to_destroy, :type => Boolean
field :name
before_save :set_name
protected
def set_name
self.name = self.file_identifier
end
end

View File

@ -1,11 +1,23 @@
class Image < DesignFile
class Image
include Mongoid::Document
include Mongoid::Timestamps
field :in_css, :type => Boolean
field :name
field :html_id
field :html_class
embedded_in :design_image, polymorphic: true
field :in_css, :type => Boolean, :default => false
field :in_html, :type => Boolean, :default => false
field :name
mount_uploader :file, ImageUploader
belongs_to :design
before_save :set_name
protected
def set_name
self.name = self.file_identifier
end
end

View File

@ -1,3 +1,3 @@
class Javascript < DesignFile
embedded_in :design
belongs_to :design
end

View File

@ -6,7 +6,7 @@ class Layout < DesignFile
field :body
embeds_one :menu
embedded_in :design
belongs_to :design
embeds_many :layout_parts
before_save :parse_layout

View File

@ -1,5 +1,5 @@
class Stylesheet < DesignFile
embedded_in :design
belongs_to :design
mount_uploader :file_orig, AssetUploader
def parse_urls
@ -11,7 +11,9 @@ class Stylesheet < DesignFile
content.scan(/(?<=url)(.*?)(?=\))/){
css_name = $1.gsub(' ','').gsub('(','')
name = File.basename(css_name).gsub(/[\\\"]/, '')
file_name = images.detect{ |i| i.file_identifier.eql?(name) }.file_url rescue nil
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|

View File

@ -1,14 +1,11 @@
class Theme < Stylesheet
field :name
embedded_in :design
before_save :set_name
belongs_to :design
protected
def set_name
self.name = File.basename(self.file_identifier,".css")
self.name = File.basename(self.file_identifier, ".css")
end
end

View File

@ -29,7 +29,7 @@ class Page < Item
protected
def create_parts
if self.new_record? || self.design.changed?
if self.new_record? || self.design_id_changed?
page_design = self.design
parent = self.parent
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent

View File

@ -24,7 +24,7 @@ class ImageUploader < CarrierWave::Uploader::Base
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"image/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
"#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
@ -48,7 +48,7 @@ class ImageUploader < CarrierWave::Uploader::Base
# end
version :thumb do
process :resize_to_fit => [200, 200]
process :resize_to_limit => [200, 200]
end
# Add a white list of extensions which are allowed to be uploaded.

View File

@ -1,60 +1,24 @@
<% content_for :page_specific_css do %>
<%= stylesheet_link_tag "design" %>
<% end %>
<% content_for :page_specific_javascript do %>
<%= javascript_include_tag "design" %>
<%= form_for @design, :url => admin_design_path(@design), :html => {:class => 'form-horizontal'}, :remote => true do |f| %>
<%= f.error_messages %>
<div class="control-group">
<%= f.label :title, t('admin.title'), :class => "control-label" %>
<div class="controls">
<%= f.text_field :title %>
</div>
</div>
<div class="control-group">
<%= f.label :author, t('admin.author'), :class => "control-label" %>
<div class="controls">
<%= f.text_field :author %>
</div>
</div>
<div class="control-group">
<%= f.label :intro, t('admin.intro'), :class => "control-label" %>
<div class="controls">
<%= f.text_field :intro %>
</div>
</div>
<%= f.submit t('update') %>
<% end %>
<p>
<%= f.label :title, t('admin.title') %>
<%= f.text_field :title, :class => 'text' %>
</p>
<p>
<%= f.label :author, t('admin.author') %>
<%= f.text_field :author, :class => 'text' %>
</p>
<p>
<%= f.label :intro, t('admin.intro') %>
<%= f.text_field :intro, :class => 'text' %>
</p>
<p>
<%= f.label "layout", t('admin.layout') %>
<% if @design.layout.blank? %>
<%= fields_for 'design[layout]' do |f| %>
<%= f.file_field :file %>
<%#= f.hidden_field :to_save, :value => true %>
<% end %>
<% else %>
<%= File.basename (@design.layout.file.url) %>
<% end %>
</p>
<p>
<%= f.label "default_css", t('admin.default_css') %>
<% if @design.default_css.blank? %>
<%= fields_for 'design[default_css]' do |f| %>
<%= f.file_field :file %>
<%#= f.hidden_field :to_save, :value => true %>
<% end %>
<% else %>
<%= File.basename (@design.default_css.file.url) rescue "" %>
<% end %>
</p>
<p>
<%= f.label :themes, t('admin.themes') %>
<ul>
<% @design.themes.each do |theme| %>
<%= render :partial => 'design_file', :object => theme, :locals => { :field_name => "themes", :f => f, :classes => "r_destroy, r_edit" } %>
<% end %>
</ul>
<%= render :partial => 'new_design_file', :object => @design.themes.build, :locals => { :field_name => "themes", :f => f, :classes => "r_destroy" } %>
</p>
<p>
<%#= render :partial => 'design_file', :locals => { :object => @design, :field_name => "javascripts", :f => f, :classes => "r_destroy, r_edit" } %>
</p>
<p>
<%#= render :partial => 'design_file', :locals => { :object => @design, :field_name => "images", :f => f, :classes => "r_destroy, r_snapshot" } %>
</p>

View File

@ -0,0 +1,6 @@
<tr>
<td><%= image.name %></td>
<td><%= image_tag image.file.thumb %></td>
<td><%= number_to_human_size(image.file.file.file_length) %></td>
<td><%= image.file.url %></td>
</tr>

View File

@ -0,0 +1,40 @@
<table id='image_list' class="table table-striped">
<thead>
<tr>
<th class="span1"><%= t(:name) %></th>
<th class="span1"><%= t(:image) %></th>
<th class="span1"><%= t(:size) %></th>
<th class="span4"><%= t(:url) %></th>
</tr>
</thead>
<tbody id="tbody_assets" class="sort-holder">
<%= render :partial => 'image', :collection => @design.images %>
</tbody>
</table>
<div class="modal hide fade" id="imageModal" tabindex="-1" role="dialog" aria-labelledby="imageModalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="imageModalLabel">Add image</h3>
</div>
<%= form_for :image, :url => upload_image_admin_design_path, :html => {:id => 'ajaxForm', :class => 'form-horizontal'}, :method => :post do |f| %>
<div class="modal-body">
<div class="control-group">
<%= f.label :image, t('admin.image'), :class => "control-label" %>
<div class="controls">
<%= f.file_field :file %>
</div>
</div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<%= f.submit t(:add), :class => "btn btn-primary" %>
</div>
<% end %>
</div>
<div class="form-actions form-fixed pagination-right">
<button class="btn btn-primary" href="#imageModal" data-toggle="modal"><%= t(:add) %></button>
</div>

View File

@ -0,0 +1,8 @@
<%= form_for :file, :url => update_file_admin_design_path(:type => type, :object_id => object.id), :remote => true, :method => :post do |f| %>
<div id='post-body-content'>
<%= f.text_area :content, :class => 'middle', :value => object.file.read.force_encoding('UTF-8') %>
</div>
<div class="form-actions form-fixed pagination-right">
<button class="btn btn-primary"><%= t(:save) %></button>
</div>
<% end %>

View File

@ -4,10 +4,40 @@
<h1><%= t('admin.editing_design') %></h1>
<%= form_for @design, :url => admin_design_path(@design),:html => {:multipart => true} do |f| %>
<%= f.error_messages %>
<%= render :partial => "form", :locals => { :f => f } %>
<p>
<%= f.submit t('update') %> <%= link_back %>
</p>
<% end %>
<ul class="nav nav-tabs" id="myTab">
<li class="active"><a href="#info" data-toggle="tab"><%= t('design.info') %></a></li>
<li><a href="#layout" data-toggle="tab"><%= @design.layout.name %></a></li>
<li><a href="#css_default" data-toggle="tab"><%= @design.css_default.name %></a></li>
<li><a href="#css_reset" data-toggle="tab"><%= @design.css_reset.name %></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t('design.themes') %> <b class="caret"></b></a>
<ul class="dropdown-menu">
<% @design.themes.each do |theme| %>
<li><a href="#<%= dom_id theme %>" data-toggle="tab"><%= theme.name %></a></li>
<% end %>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><%= t('design.javascripts') %> <b class="caret"></b></a>
<ul class="dropdown-menu">
<% @design.javascripts.each do |js| %>
<li><a href="#<%= dom_id js %>" data-toggle="tab"><%= js.name %></a></li>
<% end %>
</ul>
</li>
<li><a href="#images" data-toggle="tab"><%= t('design.images') %></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="info"><%= render :partial => 'form' %></div>
<div class="tab-pane" id="layout"><%= render :partial => 'tab_form', :locals => {:type => :layout, :object => @design.layout} %></div>
<div class="tab-pane" id="css_default"><%= render :partial => 'tab_form', :locals => {:type => :css_default, :object => @design.css_default} %></div>
<div class="tab-pane" id="css_reset"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => @design.css_reset} %></div>
<% @design.themes.each do |theme| %>
<div class="tab-pane" id="<%= dom_id theme %>"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => theme} %></div>
<% end %>
<% @design.javascripts.each do |js| %>
<div class="tab-pane" id="<%= dom_id js %>"><%= render :partial => 'tab_form', :locals => {:type => :css_reset, :object => js} %></div>
<% end %>
<div class="tab-pane" id="images"><%= render :partial => 'images' %></div>
</div>

View File

@ -0,0 +1 @@
// $('.modal').modal('hide')

View File

@ -0,0 +1,9 @@
<% if !request.xhr? %>
<textarea>
<% end %>
$('#image_list').append("<%= j render :partial => 'image', :object => @image %>");
$('#imageModal').modal('hide');
$('#ajaxForm').resetForm();
<% if !request.xhr? %>
</textarea>
<% end %>

View File

@ -0,0 +1,8 @@
<table>
address
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
checkbox
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
date
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
date durnation
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
radio_button
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
select
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
text_area
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -0,0 +1,8 @@
<table>
text_field
<tr>
<td> markup_value</td>
<td> markup_options</td>
</tr>
<tr>other's options</tr>
</table>

View File

@ -11,8 +11,8 @@
<p class="alert hide">You need to sign in or sign up before continuing.</p>
<div class="main">
<div class="control-group clear">
<%= f.label :login ,t("admin.user_new_interface.email")%>
<%= f.text_field :login, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %>
<%= f.label :email ,t("admin.user_new_interface.email")%>
<%= f.text_field :email, :placeholder => t("admin.user_new_interface.email"), :style => "width: 330px;" %>
<span class="help-inline">Please correct the error</span>
</div>
<div class="control-group clear">

View File

@ -0,0 +1,13 @@
<div class="modal hide fade" id="address-edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none; ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="myModalLabel">Modal header</h3>
</div>
<div class="modal-body">
<p>One fine body…</p>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
<button class="btn btn-primary">Save changes</button>
</div>
</div>

View File

@ -58,6 +58,8 @@ Orbit::Application.routes.draw do
end
member do
post 'edit_file' => 'designs#edit_file'
post 'update_file' => 'designs#update_file'
post 'upload_image' => 'designs#upload_image'
end
end
resources :infos do

View File

@ -22,7 +22,7 @@ module ParserLayout
body.css('.page_image').each do |page_image|
image = design.images.where( file: File.basename(page_image['src']))[0]
image.update_attributes(:name => File.basename(page_image['src']), :html_id => page_image['id'], :html_class => page_image['class']) if image
image.update_attributes(:html_id => page_image['id'], :html_class => page_image['class'], :in_html => true) if image
end
end

View File

@ -71,7 +71,7 @@ namespace :dev do
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
@ -89,7 +89,7 @@ namespace :dev do
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#

View File

@ -13,7 +13,7 @@ namespace :pages do
design = Design.new(:title => "Fraisier", :author => "Paul", :intro => "Strawberry cake")
design.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
design.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#
@ -37,7 +37,7 @@ namespace :pages do
design_1 = Design.new(:title => "Bob", :author => "Me", :intro => "Moran")
design_1.build_default_css(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
design_1.build_css_default(:file => File.open("#{Rails.root}/lib/fraisier/default.css"))
# image = design.images.build(:file => File.open("#{Rails.root}/lib/fraisier/img/buttons.gif"))
#

View File

@ -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

View File

@ -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(:each) 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

View File

@ -27,6 +27,13 @@ Date.prototype.getWeek = function (dowOffset) {
return weeknum;
};
Date.prototype.daysInMonth = function(){
var daysArray = [31,28,31,30,31,30,31,31,30,31,30,31];
if(this.getFullYear()%4 == 0)
daysArray[1] = 29;
return daysArray[this.getMonth()];
}
var calendarAPI = function(){
c = this;
@ -36,17 +43,20 @@ var calendarAPI = function(){
this.cur_month = c.today.getMonth()+1;
this.cur_year = c.today.getFullYear();
this.cur_week = c.today.getWeek();
this.cur_date = c.today.getDate();
this.view = null;
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.loadWeekView(c.cur_week,c.cur_year);
c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
bindHandlers();
})
var bindHandlers = function(){
$(".event").live("click",function(){
c.displayEvent($(this));
$(".event").live("click",function(e){
var pos = {"x":e.clientX,"y":e.clientY};
c.displayEvent($(this),pos);
})
$("#create_event_btn").click(function(){
@ -73,7 +83,7 @@ var calendarAPI = function(){
c.loadWeekView(c.cur_week,c.cur_year);
break;
case 'day':
c.loadDayView();
c.loadDayView(c.cur_date,c.cur_month,c.cur_year);
break;
case 'agenda':
c.loadAgendaView();
@ -104,6 +114,22 @@ var calendarAPI = function(){
}
c.loadWeekView(w,y);
break;
case "day":
var d,w,y;
d = c.cur_date - 1;
m = c.cur_month;
y = c.cur_year;
if(d == 0){
var dx = new Date(c.cur_year,c.cur_month-2);
d = dx.daysInMonth();
m--;
}
if(m == 0){
m = 12;
y = y - 1;
}
c.loadDayView(d,m,y);
break;
}
})
@ -132,10 +158,40 @@ var calendarAPI = function(){
}
c.loadWeekView(w,y);
break;
case "day":
var d,w,y;
var dx = new Date(c.cur_year,c.cur_month-1);
if(c.cur_date == dx.daysInMonth()){
d = 1;
m = c.cur_month + 1;
}else{
d = c.cur_date + 1;
m = c.cur_month;
}
if(m == 13){
m = 1;
y = c.cur_year + 1;
}else{
y = c.cur_year;
}
c.loadDayView(d,m,y);
break;
}
})
$("button#today_btn").click(function(){
switch (c.view){
case "week":
c.loadWeekView();
break;
case "month":
c.loadMonthView();
break;
case "day":
c.loadDayView();
break;
}
})
}
}
@ -156,7 +212,7 @@ var calendarAPI = function(){
if($('#calendar_month').length > 0){
var $c_table = $('#calendar_month');
var sum_h = 0;
var context_h = $('#main-sidebar').outerHeight();
var context_h = $(window).height() - $('#orbit-bar').height();
$('#main-wrap > *').not('#orbit_calendar, .modal').each(function(){
sum_h += $(this).outerHeight();
});
@ -215,6 +271,8 @@ var calendarAPI = function(){
var recordcurdate = true;
if(allow){
if(evnt.title=="Navratri")
console.log(pos);
if(pos == 1){
var colspan = 0;
if(evnt.total_days>7){
@ -231,13 +289,13 @@ var calendarAPI = function(){
$eventrow.html('<td colspan="'+colspan+'" class="main_td" pos="'+pos+'"><div class="event" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';">'+evnt.title+'</div></td>');
}else{
if($eventrow.html()==""){
$eventrow.append('<td colspan="'+(pos-1)+'">');
$eventrow.append('<td colspan="'+(pos-1)+'"></td>');
}else{
if((lastno+1)!=thisno){
var inposition = parseInt($eventrow.find("td.main_td:last").attr("pos"));
var curcolspan = $eventrow.find("td.main_td:last").attr("colspan");
var colspan = pos - (inposition+parseInt(curcolspan));
$eventrow.append('<td colspan="'+colspan+'">');
$eventrow.append('<td colspan="'+colspan+'"></td>');
}
}
var colspan = 0;
@ -297,16 +355,182 @@ var calendarAPI = function(){
}
this.getEventsForWeek = function(week,year){
$.getJSON("cals/getWeekEvents",{"week":week,"year":year},function(events){
var height = 15;
var full_day_count = 0;
var rowcount = 7;
var tr = $("<tr></tr>");
var pre = true;
$.each(events,function(i,evnt){
// console.log("rowcount: "+rowcount);
// console.log("start:"+evnt.start);
if(rowcount >= (7 - evnt.total_days)){
if(tr.html()!=""){
if(rowcount != 7){
tr.append("<td colspan='"+(7-rowcount)+"'></td>");
}
$("table.all_day_event_holder").append(tr);
}
tr = null;
tr = $('<tr></tr>');
pre = true;
}
if(evnt.all_day){
full_day_count++;
var precountspan = 7 - evnt.total_days;
if(pre){
height+=20;
$(".head_event_wrapper").height(height);
$(".head_event_wrapper table").eq(0).height(height);
tr.append('<td rowspan="1" style="width:60px;">&nbsp;</td>');
if(precountspan != 0){
tr.append('<td colspan="'+precountspan+'"></td>');
pre = false;
}
}
var colcount = evnt.total_days;
if(evnt.colcount != 0){
colcount = evnt.colcount;
}
rowcount = precountspan + colcount;
tr.append('<td colspan="'+colcount+'" class="all_day_event week_day" ><div class="event half" style="background-color: '+evnt.color+' ;color:#fff;" link="'+evnt.show_link+'"><dl><dt>'+evnt.title+'</dt><dd></dd></dl></div></td>');
// $(".week_day_header[date="+evnt.start_date+"]").append('<div class="event half" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;"><dl><dt>'+evnt.title+'</dt><dd></dd></dl></div>');
}else{
var starttime,endtime,displaystarttime,displayendtime;
if(evnt.start_am_pm == "AM"){
starttime = evnt.start_time;
if(starttime == 12)
starttime = 0;
if(starttime == 12.5)
starttime = 0.5;
}else
starttime = evnt.start_time + 12;
if(evnt.end_am_pm == "AM"){
endtime = evnt.end_time;
if(endtime == 12)
endtime = 0;
if(endtime == 12.5)
endtime = 0.5;
}else
endtime = evnt.end_time + 12;
var temp = parseInt(evnt.start_time);
if (evnt.start_time > temp)
displaystarttime = temp + ":30 " + evnt.start_am_pm;
else
displaystarttime = temp + ":00 " + evnt.start_am_pm;
temp = parseInt(evnt.end_time);
if (evnt.end_time > temp)
displayendtime = temp + ":30 " + evnt.end_am_pm;
else
displayendtime = temp + ":00 " + evnt.end_am_pm;
var toppx = ((starttime * 2) * 20) + 1;
var h = endtime - starttime;
var halfhour = "";
if(h == 0.5)
halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1;
var eventdom = $('<div class="event '+halfhour+'" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div>');
$(".week_day_body[date="+evnt.start_date+"] .inner").append(eventdom);
}
if(full_day_count == 0){
tr.append('<td rowspan="1" style="width:60px;">');
$("table.all_day_event_holder").append(tr);
}
})
if(tr.html()!=""){
if(rowcount != 7){
tr.append("<td colspan='"+(7-rowcount)+"'></td>");
}
$("table.all_day_event_holder").append(tr);
}
})
}
this.loadDayView = function(day,month,year){
c.view = "day";
if(!day){
var dt = new Date();
week = dt.getWeek();
year = dt.getFullYear();
day = dt.getDate();
month = dt.getMonth()+1;
}
c.cur_date = day;
c.cur_month = month;
c.cur_year = year;
$('#view_holder').load("cals/day_view?date="+day+"&month="+month+"&year="+year, function() {
$('.current_day_title').text($("#day_header").text());
c.getEventsForDay(day,month,year);
})
}
this.getEventsForDay = function(day,month,year){
$.getJSON("cals/getDayEvents",{"date":day,"month":month,"year":year},function(events){
$.each(events,function(i,evnt){
if(evnt.all_day){
$(".all_day_event").append('<div class="event" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff;">'+evnt.title+'</div>')
}else{
var starttime,endtime,displaystarttime,displayendtime;
if(evnt.start_am_pm == "AM"){
starttime = evnt.start_time;
if(starttime == 12)
starttime = 0;
if(starttime == 12.5)
starttime = 0.5;
}else
starttime = evnt.start_time + 12;
if(evnt.end_am_pm == "AM"){
endtime = evnt.end_time;
if(endtime == 12)
endtime = 0;
if(endtime == 12.5)
endtime = 0.5;
}else
endtime = evnt.end_time + 12;
var temp = parseInt(evnt.start_time);
if (evnt.start_time > temp)
displaystarttime = temp + ":30 " + evnt.start_am_pm;
else
displaystarttime = temp + ":00 " + evnt.start_am_pm;
temp = parseInt(evnt.end_time);
if (evnt.end_time > temp)
displayendtime = temp + ":30 " + evnt.end_am_pm;
else
displayendtime = temp + ":00 " + evnt.end_am_pm;
var toppx = ((starttime * 2) * 20) + 1;
var h = endtime - starttime;
var halfhour = "";
if(h == 0.5)
halfhour = "half";
h = 17 + 20 + (((h-1) * 2) * 20) + 1;
var eventdom = $('<div class="inner"><div class="event '+halfhour+'" link="'+evnt.show_link+'" style="background-color: '+evnt.color+';color:#fff; top:'+toppx+'px; height:'+h+'px;"><dl><dt>'+displaystarttime+' - '+displayendtime+'</dt><dd>'+evnt.title+'</dd></dl></div></div>');
$(".event_holder").append(eventdom);
}
})
})
}
this.loadDayView = function(){
$('#view_holder').load("cals/day_view", function() {
$('.current_day_title').text('September 2, 2012');
})
}
this.loadAgendaView = function(){
$('#view_holder').load("cals/week_view", function() {
$('#view_holder').load("cals/agenda_view", function() {
$('.current_day_title').text('September 2, 2012');
})
}
@ -338,11 +562,27 @@ var calendarAPI = function(){
var domfor = $(this).attr("data-content");
$("tr[for="+domfor+"]").remove();
})
$(".btn-edit-a").live("ajax:success",function(evt,form){
$("#edit_area_" + $(this).attr("for")).html(form).slideDown();
$("#edit_area_" + $(this).attr("for")).find(".color-picker").miniColors();
})
$(".bt-cancel").live("click",function(){
$("#edit_area_" + $(this).attr("for")).html("").slideUp();
})
}
this.displayEvent = function(dom){
this.displayEvent = function(dom,pos){
var url = dom.attr("link");
c.event_quick_view_div.load(url,function(){
c.event_quick_view_div.show()
var x = pos.x;
var y = pos.y;
var winheight = $(window).height()
if((x+c.event_quick_view_div.width()) > $(window).width()){
x = x - c.event_quick_view_div.width();
}
if((y+c.event_quick_view_div.height()) > winheight){
y = y - c.event_quick_view_div.height();
}
c.event_quick_view_div.css({"left":x+"px","top":y+"px"}).show()
c.event_quick_view_div.find(".event-close-btn").click(function(){
c.event_quick_view_div.empty().hide();
})

View File

@ -32,22 +32,26 @@
border-radius: 3px;
cursor: pointer;
padding: 1px 3px;
font-weight: bold;
box-shadow: inset 0 0 1px black;
-webkit-box-shadow: inset 0 0 1px black;
-moz-box-shadow: inset 0 0 1px black;
}
.event_list_wrapper {
position: relative;
}
.event_list .cell {
height: 38px;
height: 39px;
border: solid 1px #ddd;
border-top: 0;
}
.event_list .divide {
height: 18px;
height: 19px;
margin-bottom: 18px;
border-bottom: solid 1px #eee;
}
.event_list .day_time {
height: 30px;
height: 31px;
border-bottom: solid 1px #ddd;
border-left: solid 1px #ddd;
text-align: right;
@ -189,7 +193,7 @@
}
#calendar_day .all_day_event {
background: #eee;
border: solid 1px #ddd
border: solid 1px #ddd;
}
#calendar_day .event_list .table {
border-top: solid 1px #ddd;
@ -223,14 +227,14 @@
}
#calendar_week .header td {
border: solid 1px #ddd;
background-color: #eee;
/*background-color: #eee;*/
}
#calendar_week .week_day {
padding: 0 2px;
border: solid 1px #ddd;
}
#calendar_week .header .week_day {
padding: 1px 2px 10px 2px;
padding: 2px 4px 0px 2px;
}
#calendar_week .event_list .event {
position: absolute;
@ -250,7 +254,18 @@
#calendar_week .event_holder .inner {
margin: 0 8px 0 0;
}
#calendar_week .all_day_event_holder {
position: relative;
width: 100%;
table-layout: fixed;
}
#calendar_week .all_day_event_holder td {
border: 0;
background-color: transparent;
}
#calendar_week .all_day_event {
background: #eee;
}

View File

@ -11,6 +11,19 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
@calendars = Cal.all
end
def edit
@calendar = Cal.find(params[:id])
render :layout=>false
end
def update
@calendar = Cal.find(params[:id])
@calendar.update_attributes(params[:cal])
respond_to do |h|
h.js
end
end
def create
@calendar = Cal.new(params[:cal])
@calendar.save!
@ -26,14 +39,30 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
def day_view
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
@hours = getHours(12)
render :layout => false
end
def week_view
week = params[:week]
year = params[:year]
week = params[:week].to_i
year = params[:year].to_i
@dates = week_dates(week,year)
@range = week_range(week,year)
@d = getWeekDataSet(week,year)
t = Time.now
dt = Date.new(t.year,t.month,t.day)
today_cur_week = dt.strftime("%U").to_i
if week == today_cur_week && t.year == year
@today = @d.index(t.day.to_s)
else
@today = 20
end
@hours = getHours(12)
render :layout => false
end
@ -59,48 +88,172 @@ class Panel::Calendar::BackEnd::CalsController < OrbitBackendController
end
def get_month_events
month = params[:month]
year = params[:year]
month = month.to_i
year = year.to_i
events = Event.where(:start_month.lt => month).and(:start_year => year).and(:end_month.gte => month).asc(:start_date).desc(:total_days)
month = params[:month].to_i
year = params[:year].to_i
# 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
no_of_days_in_month = getMonthDays(year)
events.each_with_index do |event,i|
no_of_days = event.total_days
# events.each_with_index do |event,i|
# no_of_days = event.total_days
# if event.end_month > month
# no_of_days = no_of_days_in_month[month]
# elsif event.end_month == month
# no_of_days = event.end_date
# end
# no_of_days = no_of_days.to_i
# color = Cal.find(event.cal_id).color
# @events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
# end
# events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days)
# events.each_with_index do |event,i|
# # @temp = Array.new
# no_of_days = event.total_days
# if event.end_month > month
# no_of_days = no_of_days_in_month[month] - event.start_date
# end
# no_of_days = no_of_days.to_i
# no_of_days += 1
# 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.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(year,month)
if range === dt
no_of_days = event.total_days
start_date = event.start_date
if event.start_year < year
no_of_days = no_of_days_in_month[month] - event.start_date
no_of_days += 1
temp = month + 12
if event.start_month < temp
start_date = 1
end
end
if event.end_year > year
no_of_days = no_of_days_in_month[month] - event.start_date
no_of_days += 1
temp = month + 12
end
if event.end_month > month
no_of_days = no_of_days_in_month[month]
no_of_days = no_of_days_in_month[month] - event.start_date
no_of_days += 1
elsif event.end_month == month
no_of_days = event.end_date
end
no_of_days = no_of_days.to_i
if event.start_month == month && event.end_month == month
no_of_days = event.total_days
no_of_days += 1
end
if event.start_month < month
start_date = 1
end
color = Cal.find(event.cal_id).color
@events << {"id"=>event.id,"index"=>i,"start_date"=>"1", "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
@events << {"start_year"=>event.start_year, "id"=>event.id,"index"=>i,"start_date"=>start_date, "total_days" => no_of_days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event)}
end
events = Event.where(:start_month => month).and(:start_year => year).asc(:start_date).desc(:total_days)
events.each_with_index do |event,i|
# @temp = Array.new
no_of_days = event.total_days
if event.end_month > month
no_of_days = no_of_days_in_month[month] - event.start_date
end
no_of_days = no_of_days.to_i
no_of_days += 1
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
render :json => @events.to_json
end
def get_week_events
week = params[:week]
year = params[:year]
events = Event.where(:start_week => week).and(:start_year => year)
render :json => events.to_json
week = params[:week].to_i
year = params[:year].to_i
@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 = Array.new
events.each_with_index do |event,i|
# @temp = Array.new
days = event.total_days.to_i + 1
colcount = 0
startdt = event.start_date
all_day = event.all_day
if days > 1
all_day = true
end
if event.end_week > week && event.start_week < week
days = 7
end
if event.end_week == week
days = @d.index(event.end_date.to_s).to_i
end
if event.start_week == week
days = 7 - @d.index(event.start_date.to_s).to_i
end
if event.start_week == week && event.end_week == week
x = @d.index(event.end_date.to_s).to_i
y = @d.index(event.start_date.to_s).to_i
colcount = x - y
colcount+=1
end
if event.start_week < week
startdt = @d[0].to_i
event.all_day = true
if event.end_week == week
colcount = 7 - @d.index(event.end_date.to_s).to_i
days = 7;
startdt = event.start_date
end
end
color = Cal.find(event.cal_id).color
@events << {"id"=>event.id,"index"=>i,"start_date"=>startdt,"end_date"=>event.end_date ,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm,"colcount"=>colcount}
end
render :json => @events.to_json
end
def get_day_events
day = params[:date].to_i
month = params[:month].to_i
year = params[:year].to_i
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)
@events = Array.new
events.each_with_index do |event,i|
days = event.total_days.to_i + 1
colcount = 0
all_day = event.all_day
if days > 1
all_day = true
end
startdt = Date.new(event.start_year,event.start_month,event.start_date)
enddt = Date.new(event.end_year,event.end_month,event.end_date)
range = startdt..enddt
if range === dt
color = Cal.find(event.cal_id).color
@events << {"id"=>event.id,"index"=>i,"start_date"=>event.start_date,"end_date"=>event.end_date ,"all_day"=>all_day, "start_week" => event.start_week, "end_week" => event.end_week, "total_days" => days, "title" => event.title,"color"=>color,"show_link"=>panel_calendar_back_end_event_path(event),"start_time"=>event.start_time,"end_time"=>event.end_time,"start_am_pm"=>event.start_am_pm,"end_am_pm"=>event.end_am_pm}
end
end
render :json => @events.to_json
end
def week_number_test

View File

@ -42,6 +42,13 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
# 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)
@ -67,6 +74,7 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
@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|
@ -81,6 +89,12 @@ class Panel::Calendar::BackEnd::EventsController < OrbitBackendController
@end_day_name = getDayName(@event.end_date,@event.end_month,@event.end_year)
render :layout=>false
end
def destroy
event = Event.find(params[:id])
event.delete
render :json => {"success"=>"true"}.to_json
end
end

View File

@ -131,6 +131,55 @@ module Panel::Calendar::BackEnd::CalsHelper
end
range
end
def getWeekDataSet(week_num,year)
year = year.to_i
week_num = week_num.to_i
dates = Array.new
if week_num == 1
weekstartday = monthStartDay(1,year)
d = 31
x = 0
for i in d - (weekstartday - 2)..d
dates << i.to_s
x = x + 1
end
for i in 1..8 - weekstartday
dates << i.to_s
x = x + 1
end
else
week_start = Date.commercial(year, week_num-1, 7)
month = week_start.strftime("%m")
month_days = getMonthDays(year)
date = week_start.strftime("%d")
x = date.to_i
for i in 0..6
d = x + i
if d > month_days[month.to_i]
d = d - month_days[month.to_i]
end
dates << d.to_s
end
end
dates
end
def getHours(format)
hours = Array.new
if format == 12
hours << 12
for i in 1..11
hours << i
end
elsif format == 24
for i in 0..23
hours << i
end
end
hours
end
end

View File

@ -19,6 +19,7 @@ class Event
field :final_start_time, type: Date
field :final_end_time, type: Date
field :total_days, type: Integer
field :all_day, type: Boolean
belongs_to :cal

View File

@ -1,10 +1,12 @@
<tr class="with_action" for="<%= calendar.id.to_s %>">
<td>
<span class="calendars_color_tag" style="background-color: <%= calendar.color %>"></span>
<div id="edit_area_<%= calendar.id %>" style="display:hidden;"></div>
<div class="quick-edit">
<ul class="nav nav-pills hide">
<li><a href="">Edit</a></li>
<li><%= link_to t("calendar.delete"), panel_calendar_back_end_cal_path(calendar), :method => "delete",:remote => true, :confirm => t("gallery.sure?"),:class=>"btn-del-a", "data-content"=>calendar.id.to_s %></li>
<li><%= link_to t("calendar.edit"), edit_panel_calendar_back_end_cal_path(calendar), :remote => true, :class=>"btn-edit-a", :for => calendar.id %></li>
<li><%= link_to t("calendar.delete"), panel_calendar_back_end_cal_path(calendar), :method => "delete",:remote => true, :confirm => t("calendar.sure?"),:class=>"btn-del-a", "data-content"=>calendar.id.to_s %></li>
</ul>
</div>
</td>

View File

@ -46,3 +46,222 @@
</tbody>
</table>
</div>
<!-- <div id="calendar_week">
<table class="table header">
<tr>
<th style="width: 44px;"></th>
<th>Sun 9/11</th>
<th>Mon 9/12</th>
<th class="today">Tue 9/13</th>
<th>Wed 9/14</th>
<th>Thu 9/15</th>
<th>Fri 9/16</th>
<th>Sat 9/17</th>
</tr>
<tr>
<td colspan="8" style="border:0;">
<div class="event_list_wrapper" style="height:50px;">
<table style="position: absolute; width: 100%; height: 50px; top: 0;">
<tr>
<td style="border: 0; background: none; width: 60px;"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
</tr>
</table>
<table class="all_day_event_holder">
<tr>
<td rowspan="2" style="width:60px;"></td>
<td colspan="7" class="all_day_event week_day">
<div class="event half" style="background-color: #ccffee;">
<dl>
<dt>10:30am - template</dt>
<dd></dd>
</dl>
</div>
</td>
</tr>
<tr>
<td colspan="1"></td>
<td colspan="2" class="all_day_event week_day">
<div class="event half" style="background-color: #ccffee;">
<dl>
<dt>10:30am - template</dt>
<dd></dd>
</dl>
</div>
</td>
<td colspan="4"></td>
</tr>
</table>
</div>
</td>
</tr>
</table>
<div class="event_list">
<table class="table cell_map">
<tr height="0">
<td style="width: 60px;"></td>
<td colspan="7">
<div class="event_list_wrapper">
<div class="cell_wrapper">
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="day_time">12am</div>
<div class="day_time">1am</div>
<div class="day_time">2am</div>
<div class="day_time">3am</div>
<div class="day_time">4am</div>
<div class="day_time">5am</div>
<div class="day_time">6am</div>
<div class="day_time">7am</div>
<div class="day_time">8am</div>
<div class="day_time">9am</div>
<div class="day_time">10am</div>
<div class="day_time">11am</div>
<div class="day_time">12am</div>
<div class="day_time">1pm</div>
<div class="day_time">2pm</div>
<div class="day_time">3pm</div>
<div class="day_time">4pm</div>
<div class="day_time">5pm</div>
<div class="day_time">6pm</div>
<div class="day_time">7pm</div>
<div class="day_time">8pm</div>
<div class="day_time">9pm</div>
<div class="day_time">10pm</div>
<div class="day_time">11pm</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day today">
<div class="event_holder">
<div class="inner">
<div class="event" style="background-color: #ccffee; top: 117px;">
<dl>
<dt>10:30am - 11:00am</dt>
<dd>template</dd>
</dl>
</div>
</div>
</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
</tr>
</table>
</div>
</div>
-->

View File

@ -3,14 +3,14 @@
<tr>
<th class="span1"></th>
<th>
<h2>Sunday 9/2</h2>
<h2 id="day_header" style="display:none;"><%= @cur_day %></h2>
</th>
</tr>
<tr>
<td></td>
<td class="all_day_event">
<div class="event" style="background-color: #ffcc00;">event1</div>
<div class="event" style="background-color: #ffcc00;">event2</div>
<!-- <div class="event" style="background-color: #ffcc00;">event1</div>
<div cla ss="event" style="background-color: #ffcc00;">event2</div> -->
</td>
</tr>
</table>
@ -18,106 +18,25 @@
<table class="table">
<tr>
<td style="width: 60px;">
<div class="day_time">12am</div>
<div class="day_time">1am</div>
<div class="day_time">2am</div>
<div class="day_time">3am</div>
<div class="day_time">4am</div>
<div class="day_time">5am</div>
<div class="day_time">6am</div>
<div class="day_time">7am</div>
<div class="day_time">8am</div>
<div class="day_time">9am</div>
<div class="day_time">10am</div>
<div class="day_time">11am</div>
<div class="day_time">12am</div>
<div class="day_time">1pm</div>
<div class="day_time">2pm</div>
<div class="day_time">3pm</div>
<div class="day_time">4pm</div>
<div class="day_time">5pm</div>
<div class="day_time">6pm</div>
<div class="day_time">7pm</div>
<div class="day_time">8pm</div>
<div class="day_time">9pm</div>
<div class="day_time">10pm</div>
<div class="day_time">11pm</div>
<% @hours.each do |hour| %>
<div class="day_time"><%= hour %>am</div>
<% end %>
<% @hours.each do |hour| %>
<div class="day_time"><%= hour %>pm</div>
<% end %>
</td>
<td style="position: relative;">
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<td>
<div class="event_list_wrapper">
<% @hours.each do |hour| %>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<% end %>
<div class="event_holder">
<div class="inner">
<!-- <div class="inner">
<div class="event" style="background-color: #66cc00; top: 0;">
<dl>
<dt>10:30am - 11:00am</dt>
@ -148,6 +67,7 @@
<dd>template</dd>
</dl>
</div>
</div> -->
</div>
</div>
</td>

View File

@ -0,0 +1,26 @@
<%= form_for @calendar, :url => panel_calendar_back_end_cal_path(@calendar), :remote => true do |f| %>
<h4>Edit</h4>
<div class="row-fluid">
<div class="span2">
<%= label_tag("color", t("calendar.color")) %>
<%= f.text_field :color, :class => "color-picker miniColors", :size => "5", :maxlength => "5", :autocomplete=>"off",:value=>@calendar.color %>
</div>
</div>
<div>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each_with_index do |locale, i| %>
<div class="control-group">
<%= label_tag(locale, t("calendar.name")+"-"+I18nVariable.from_locale(locale)) %>
<div class="controls">
<%= name.text_field locale, :class => "input-xxlarge", :size=>"30", :value=>@calendar.name_translations[locale] %>
</div>
</div>
<% end %>
<% end %>
</div>
<div class="">
<%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
<button class="btn btn-primary bt-cancel" for="<%= @calendar.id %>">Cancel</button>
</div>
<% end %>

View File

@ -64,7 +64,7 @@
</div>
<div id="event_create" class="modal" style="right: 8px; bottom: 50px; left: auto; top: auto; width: 380px; margin: 0;display:none;"></div>
<div id="event_quick_view" class="modal" style="width: 300px; top: 60%;display:none"></div>
<div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>
<script type="text/javascript">
var calendar = new calendarAPI();

View File

@ -0,0 +1,2 @@
var tr = $("<%= j render :partial=>'calendar', :object=>@calendar %>");
$("#calendar_list tr[for=<%= @calendar.id %>]").empty().html(tr.html());

View File

@ -3,120 +3,85 @@
<table class="table header">
<tr>
<th style="width: 44px;"></th>
<% @dates.each do |day| %>
<% @dates.each_with_index do |day,i| %>
<% if @today == i %>
<th class='today'><%= day %></th>
<% else %>
<th><%= day %></th>
<% end %>
<% end %>
</tr>
<tr>
<td style="border: 0; background: none;"></td>
<td class="all_day_event week_day">
<td colspan="8" style="border:0;">
<div class="event_list_wrapper head_event_wrapper" style="height:50px;">
<table style="position: absolute; width: 100%; height: 50px; top: 0;">
<tr>
<td style="border: 0; background: none; width: 60px;"></td>
<% @d.each_with_index do |dt,i| %>
<% if @today == i %>
<td class="all_day_event week_day week_day_header today" date='<%= dt %>'></td>
<% else %>
<td class="all_day_event week_day week_day_header" date='<%= dt %>'></td>
<% end %>
<% end %>
</tr>
</table>
<table class="all_day_event_holder">
</table>
</div>
</td>
<!-- <div class="event half" style="background-color: #ccffee;">
<dl>
<dt>10:30am - template</dt>
<dd></dd>
</dl>
</div> -->
</td>
<td class="all_day_event week_day">
<!-- <td class="all_day_event week_day">
</td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day">
<!-- <div class="event half" style="background-color: #ccffee;">
<div class="event half" style="background-color: #ccffee;">
<dl>
<dt>10:30am - template</dt>
<dd></dd>
</dl>
</div> -->
</div>
</td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td>
<td class="all_day_event week_day"></td> -->
</tr>
</table>
<div class="event_list">
<table class="table cell_map">
<tr height="1">
<tr height="0">
<td style="width: 60px;"></td>
<td colspan="7" style="position: relative;">
<td colspan="7">
<div class="event_list_wrapper">
<div class="cell_wrapper">
<% @hours.each do |hour| %>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
</div>
<div class="cell">
<div class="divide"></div>
<% end %>
</div>
</div>
</td>
</tr>
<tr>
<td>
<div class="day_time">12am</div>
<% @hours.each do |hour| %>
<div class="day_time"><%= hour %>am</div>
<% end %>
<% @hours.each do |hour| %>
<div class="day_time"><%= hour %>pm</div>
<% end %>
<!-- <div class="day_time">12am</div>
<div class="day_time">1am</div>
<div class="day_time">2am</div>
<div class="day_time">3am</div>
@ -128,7 +93,7 @@
<div class="day_time">9am</div>
<div class="day_time">10am</div>
<div class="day_time">11am</div>
<div class="day_time">12am</div>
<div class="day_time">12pm</div>
<div class="day_time">1pm</div>
<div class="day_time">2pm</div>
<div class="day_time">3pm</div>
@ -139,15 +104,22 @@
<div class="day_time">8pm</div>
<div class="day_time">9pm</div>
<div class="day_time">10pm</div>
<div class="day_time">11pm</div>
<div class="day_time">11pm</div> -->
</td>
<td class="week_day">
<% @d.each_with_index do |dt,i| %>
<% if i == @today %>
<td class="week_day today week_day_body" date='<%= dt %>'>
<% else %>
<td class="week_day week_day_body" date='<%= dt %>'>
<% end %>
<div class="event_holder">
<div class="inner">
</div>
</div>
</td>
<td class="week_day">
<% end %>
<!-- <td class="week_day">
<div class="event_holder">
<div class="inner">
</div>
@ -188,7 +160,7 @@
<div class="inner">
</div>
</div>
</td>
</td> -->
</tr>
</table>
</div>

View File

@ -11,7 +11,7 @@
<div class="row-fluid">
<% if !@all_day_disabled %>
<label class="checkbox inline">
<input type="checkbox" for="all_day"> All day
<input type="checkbox" name="all_day" for="all_day"> All day
</label>
<% end %>
<label class="checkbox inline">
@ -25,29 +25,29 @@
<input class="span5" type="text" value="<%= @placeholder %>" name="start_date" placeholder="<%= @placeholder %>">
<select name="start_time" class="span4">
<option value="1.00">1:00</option>
<option value="1.30">1:30</option>
<option value="1.50">1:30</option>
<option value="2.00">2:00</option>
<option value="2.30">2:30</option>
<option value="2.50">2:30</option>
<option value="3.00">3:00</option>
<option value="3.30">3:30</option>
<option value="3.50">3:30</option>
<option value="4.00">4:00</option>
<option value="4.30">4:30</option>
<option value="4.50">4:30</option>
<option value="5.00">5:00</option>
<option value="5.30">5:30</option>
<option value="5.50">5:30</option>
<option value="6.00">6:00</option>
<option value="6.30">6:30</option>
<option value="6.50">6:30</option>
<option value="7.00">7:00</option>
<option value="7.30">7:30</option>
<option value="7.50">7:30</option>
<option value="8.00">8:00</option>
<option value="8.30">8:30</option>
<option value="8.50">8:30</option>
<option value="9.00">9:00</option>
<option value="9.30">9:30</option>
<option value="9.50">9:30</option>
<option value="10.00">10:00</option>
<option value="10.30">10:30</option>
<option value="10.50">10:30</option>
<option value="11.00">11:00</option>
<option value="11.30">11:30</option>
<option value="11.50">11:30</option>
<option value="12.00">12:00</option>
<option value="12.30">12:30</option>
<option value="12.50">12:30</option>
</select>
<select name="start_am_pm" class="span3">
<option value="AM">AM</option>
@ -61,29 +61,29 @@
<input class="span5" type="text" name="end_date" value="<%= @placeholder %>" placeholder="<%= @placeholder %>">
<select name="end_time" class="span4">
<option value="1.00">1:00</option>
<option value="1.30">1:30</option>
<option value="1.50">1:30</option>
<option value="2.00">2:00</option>
<option value="2.30">2:30</option>
<option value="2.50">2:30</option>
<option value="3.00">3:00</option>
<option value="3.30">3:30</option>
<option value="3.50">3:30</option>
<option value="4.00">4:00</option>
<option value="4.30">4:30</option>
<option value="4.50">4:30</option>
<option value="5.00">5:00</option>
<option value="5.30">5:30</option>
<option value="5.50">5:30</option>
<option value="6.00">6:00</option>
<option value="6.30">6:30</option>
<option value="6.50">6:30</option>
<option value="7.00">7:00</option>
<option value="7.30">7:30</option>
<option value="7.50">7:30</option>
<option value="8.00">8:00</option>
<option value="8.30">8:30</option>
<option value="8.50">8:30</option>
<option value="9.00">9:00</option>
<option value="9.30">9:30</option>
<option value="9.50">9:30</option>
<option value="10.00">10:00</option>
<option value="10.30">10:30</option>
<option value="10.50">10:30</option>
<option value="11.00">11:00</option>
<option value="11.30">11:30</option>
<option value="11.50">11:30</option>
<option value="12.00">12:00</option>
<option value="12.30">12:30</option>
<option value="12.50">12:30</option>
</select>
<select name="end_am_pm" class="span3">
<option value="AM">AM</option>

View File

@ -13,6 +13,6 @@
</div>
</div>
<div class="modal-footer">
<a href="#" class="btn">Delete</a>
<%= link_to "Delete", panel_calendar_back_end_event_path(@event),:class => "btn", :method => :delete, :remote => true %>
<a href="#" class="btn btn-primary">Edit</a>
</div>

View File

@ -7,3 +7,5 @@ en:
delete: Delete
select_calendar: "Select Calendar"
create: Create
sure?: "Are you sure?"
edit: Edit

View File

@ -1,4 +1,11 @@
zh_tw:
calendar:
calendars: Calendars
color: Color
name: Name
save: Save
delete: Delete
select_calendar: "Select Calendar"
create: Create
sure?: "Are you sure?"
edit: Edit

View File

@ -9,6 +9,7 @@ Rails.application.routes.draw do
match 'cals/week_view' => 'cals#week_view', :via => :get
match 'cals/getMonthEvents' => 'cals#get_month_events', :via => :get
match 'cals/getWeekEvents' => 'cals#get_week_events', :via => :get
match 'cals/getDayEvents' => 'cals#get_day_events', :via => :get
resources :cals
resources :events

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -55,7 +55,7 @@ var galleryAPI = function(){
}
this.makeNewAlbum = function(path){
$.get(path,function(html){
rcom.modalWindow({loadHtml:html,width:400,height:320,"closeBtn":false},function(dom){
rcom.modalWindow({loadHtml:html,width:320,height:320,"closeBtn":false},function(dom){
$("form#new_gallery_album").submit(function(){
var validated = true;
$(this).find(".error").removeClass("error");

View File

@ -270,8 +270,8 @@
.slidelist a {
border: solid 2px #fff;
display: block;
width: 120px;
height: 90px;
width: 150px;
height: 120px;
position: relative;
box-shadow: 0 0 6px rgba(0,0,0,0.7);

View File

@ -4,10 +4,10 @@
</div>
<%= form_for @album, :url => {:action => "create"}, :remote => true do |f| %>
<div class="modal-body add-album">
<div> <%= f.select(:gallery_category_id, GalleryCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("gallery.select_category")},:class => "validate") %> </div>
<div> <%= f.select(:gallery_category_id, GalleryCategory.all.collect {|p| [ p.name, p.id ] },{:prompt => t("gallery.select_category")},:class => "validate input-xlarge") %> </div>
<ul class="nav nav-tabs">
<% @site_valid_locales.each_with_index do |locale, i| %>
<li <%= ( i == 0 ) ? " class='active'" : '' %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<li class=<%= ( i == 0 ) ? "active" : "" %>><a data-toggle="tab" href=".<%= locale %>"><%= I18nVariable.from_locale(locale) %></a></li>
<% end %>
</ul>
<div class="tab_content form-horizontal">
@ -20,7 +20,7 @@
<% end %>
<p class="control-group">
<%= label_tag(locale, t("gallery.album_name")) %>
<%= name.text_field locale, :class => "validate" %>
<%= name.text_field locale, :class => "validate input-xlarge" %>
</p>
</div>
<% end %>
@ -34,7 +34,7 @@
<% end %>
<p class="control-group">
<%= label_tag(locale, t("gallery.album_desc")) %>
<%= desc.text_field locale %>
<%= desc.text_field locale, :class => "input-xlarge" %>
</p>
</div>
<% end %>

View File

@ -1,8 +1,7 @@
<div id="tags" class="clear">
<%= render :partial => 'category', :collection => @categorylist %>
</div>
<div class="form-actions form-fixed pagination-right">
<div style="margin:0;padding:0;display:inline">
<div class="form-actions form-fixed form-inline pagination-right">
<%= form_for @new_category, :url => {:action => "create"}, :remote => true do |f| %>
<%= f.fields_for :name_translations do |name| %>
<% @site_valid_locales.each do |locale| %>
@ -13,7 +12,6 @@
<%= f.submit t("gallery.save"), :class=> "btn btn-primary" %>
<% end %>
</div>
</div>
<script type="text/javascript">
var deleteCategory = function(a){
var parent = a.parent().parent();

View File

@ -30,3 +30,5 @@ zh_tw:
search_tags: 搜尋標籤
cover: 封面
set_cover: 設為封面
sure?: "你確定嗎?"
no_description: 沒有描述

View File

@ -1,3 +1,4 @@
<!-- <form class="form-horizontal"> -->
<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %>
<div class="control-group">

View File

@ -0,0 +1,18 @@
module Panel::PageContent::BackEnd::PageContextsHelper
include ActionView::Helpers::UrlHelper
def show_page_context_edit_auth_link(page_context)
type = 'Edit'
# debugger
# a=1
oa = page_context.get_object_auth_by_title(type)
if oa.nil?
page_context.object_auths.new(title: type ).save rescue
oa = page_context.get_object_auth_by_title(type)
end
# link_to t(:category_auth), edit_admin_object_auth_path(oa)
link_to t(:category_auth),admin_object_auth_ob_auth_path(oa)
end
end