Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop
@ -0,0 +1 @@
|
|||||||
|
{"access_token":"7MBMEBoE6sSC15bIHZYAZSxj47yCKlbWEVjrkUgEJxPP3K083tbhc1RIWmxGu3WoB5dAXxK_yd4l1jrcvt6YrsTcOfFGRirOHVfzrpvhsQgxOoxcdc7YljfO_dnwUtWgFTAcAIALZG","expires_in":7200,"got_token_at":1460189856}
|
@ -0,0 +1,63 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Activities< Grape::API
|
||||||
|
resources :activities do
|
||||||
|
|
||||||
|
desc "get user activities"
|
||||||
|
|
||||||
|
params do
|
||||||
|
requires :page, type: Integer
|
||||||
|
requires :openid, type: String
|
||||||
|
end
|
||||||
|
post do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
=begin
|
||||||
|
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||||
|
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||||
|
page = params[:page] ? params[:page] : 0
|
||||||
|
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||||
|
user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||||
|
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||||
|
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||||
|
principal_types = "JournalsForMessage"
|
||||||
|
|
||||||
|
blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")"
|
||||||
|
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||||
|
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||||
|
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||||
|
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||||
|
=end
|
||||||
|
|
||||||
|
shield_project_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
|
||||||
|
shield_course_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
|
||||||
|
page = params[:page] ? params[:page] : 0
|
||||||
|
user_project_ids = (user.projects.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||||
|
user_course_ids = (user.courses.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||||
|
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||||
|
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||||
|
principal_types = "JournalsForMessage"
|
||||||
|
watched_user_ids = User.watched_by(user.id).count == 0 ? " " : ("," + User.watched_by(user.id).map{|u| u.id.to_s }.join(','))
|
||||||
|
user_ids = "(" + user.id.to_s + watched_user_ids + ")"
|
||||||
|
watched_user_blog_ids = Blog.select("id").where("author_id in #{user_ids}").map { |blog| blog.id}.join(",")
|
||||||
|
blog_ids = "(" + watched_user_blog_ids + ")"
|
||||||
|
|
||||||
|
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||||
|
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||||
|
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
|
||||||
|
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc')
|
||||||
|
|
||||||
|
all_count = activities.count
|
||||||
|
activities = activities.limit(10).offset(page * 10)
|
||||||
|
count = activities.count
|
||||||
|
present :data, activities, with: Mobile::Entities::Activity,user: user
|
||||||
|
present :all_count, all_count
|
||||||
|
present :count, count
|
||||||
|
present :page, page
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,19 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class BlogComments< Grape::API
|
||||||
|
resources :blog_comments do
|
||||||
|
|
||||||
|
desc "get special topic"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
blog = BlogComment.find params[:id]
|
||||||
|
present :data, blog, with: Mobile::Entities::BlogComment,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Issues< Grape::API
|
||||||
|
resources :issues do
|
||||||
|
include IssuesHelper
|
||||||
|
|
||||||
|
desc "get special issuse"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
issue = Issue.find params[:id]
|
||||||
|
present :data, issue, with: Mobile::Entities::Issue,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,18 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class JournalForMessages< Grape::API
|
||||||
|
resources :journal_for_messages do
|
||||||
|
|
||||||
|
desc "get special journal"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
jour = JournalsForMessage.find params[:id]
|
||||||
|
present :data, jour, with: Mobile::Entities::Jours,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,18 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Messages< Grape::API
|
||||||
|
resources :messages do
|
||||||
|
|
||||||
|
desc "get special topic"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
message = Message.find params[:id]
|
||||||
|
present :data, message, with: Mobile::Entities::Message,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,105 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class NewComment< Grape::API
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
resources :new_comment do
|
||||||
|
|
||||||
|
desc "add a new comment"
|
||||||
|
params do
|
||||||
|
requires :type, type: String
|
||||||
|
requires :content, type: String
|
||||||
|
requires :openid, type: String
|
||||||
|
end
|
||||||
|
post ':id' do
|
||||||
|
type = params[:type]
|
||||||
|
result = 1
|
||||||
|
current_user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
if params[:content]!="" && current_user
|
||||||
|
case type
|
||||||
|
when "HomeworkCommon"
|
||||||
|
homework_common = HomeworkCommon.find(params[:id])
|
||||||
|
feedback = HomeworkCommon.add_homework_jour(current_user, params[:content], params[:id])
|
||||||
|
if (feedback.errors.empty?)
|
||||||
|
homework_common.update_column(:updated_at, Time.now)
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
when "News"
|
||||||
|
news = News.find(params[:id])
|
||||||
|
comment = Comment.new
|
||||||
|
comment.comments = params[:content]
|
||||||
|
comment.author = current_user
|
||||||
|
if news.comments << comment
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
when "Message"
|
||||||
|
message = Message.find(params[:id])
|
||||||
|
board = Board.find(message.board_id)
|
||||||
|
topic = message.root
|
||||||
|
reply = Message.new
|
||||||
|
reply.author = current_user
|
||||||
|
reply.board = board
|
||||||
|
reply.content = params[:content]
|
||||||
|
reply.parent_id = params[:id]
|
||||||
|
reply.subject = "RE: #{topic.subject}"
|
||||||
|
if topic.children << reply
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
when "JournalsForMessage"
|
||||||
|
jour = JournalsForMessage.find params[:id]
|
||||||
|
parent_id = params[:id]
|
||||||
|
author_id = current_user.id
|
||||||
|
reply_user_id = jour.user_id
|
||||||
|
reply_id = params[:id]
|
||||||
|
content = params[:content]
|
||||||
|
options = {:user_id => author_id,
|
||||||
|
:status => true,
|
||||||
|
:m_parent_id => parent_id,
|
||||||
|
:m_reply_id => reply_id,
|
||||||
|
:reply_id => reply_user_id,
|
||||||
|
:notes => content,
|
||||||
|
:is_readed => false}
|
||||||
|
jfm = jour.user.add_jour(nil, nil, nil, options)
|
||||||
|
if jfm.errors.empty?
|
||||||
|
(JournalsForMessage.find parent_id).update_attribute(:updated_on,Time.now)
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
when 'Issue'
|
||||||
|
issue = Issue.find params[:id]
|
||||||
|
is_jour = Journal.new
|
||||||
|
is_jour.user_id = current_user.id
|
||||||
|
is_jour.notes = params[:content]
|
||||||
|
is_jour.journalized = issue
|
||||||
|
if is_jour.save
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
when 'BlogComment'
|
||||||
|
blog = BlogComment.find(params[:id]).root
|
||||||
|
blogComment = BlogComment.new
|
||||||
|
blogComment.author = current_user
|
||||||
|
blogComment.blog = blog.blog
|
||||||
|
blogComment.content = params[:content]
|
||||||
|
blogComment.title = "RE: #{blog.title}"
|
||||||
|
if blog.children << blogComment
|
||||||
|
result = 2
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if result == 2
|
||||||
|
update_course_activity_api(type,params[:id])
|
||||||
|
update_user_activity_api(type,params[:id])
|
||||||
|
update_org_activity_api(type,params[:id])
|
||||||
|
update_forge_activity_api(type,params[:id])
|
||||||
|
update_principal_activity_api(type,params[:id])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
result = 3
|
||||||
|
end
|
||||||
|
present :result, result
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,18 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Newss< Grape::API
|
||||||
|
resources :newss do
|
||||||
|
|
||||||
|
desc "get special news"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
news = News.find params[:id]
|
||||||
|
present :data, news, with: Mobile::Entities::News,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,41 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Praise< Grape::API
|
||||||
|
include ApiHelper
|
||||||
|
resources :praise do
|
||||||
|
desc "praise an activity"
|
||||||
|
|
||||||
|
params do
|
||||||
|
requires :type, type: String
|
||||||
|
requires :openid, type: String
|
||||||
|
end
|
||||||
|
post ':id' do
|
||||||
|
obj_id = params[:id]
|
||||||
|
obj_type = params[:type]
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
pts = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",obj_id,obj_type.to_s,user.id).first
|
||||||
|
if pts.blank?
|
||||||
|
praise_or_cancel(obj_type,obj_id,user,1)
|
||||||
|
obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
|
||||||
|
num = get_activity_praise_num(obj) if !obj.blank?
|
||||||
|
else
|
||||||
|
pts.destroy if !pts.blank?
|
||||||
|
#再更新praise_tread_cache表 使相应的记录减1 当为0时删除
|
||||||
|
ptc = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
|
||||||
|
ptc.praise_minus(1) if !ptc.blank?
|
||||||
|
if ptc.praise_num == 0
|
||||||
|
ptc.delete
|
||||||
|
end
|
||||||
|
obj = PraiseTreadCache.where("object_id=? and object_type=?",obj_id,obj_type.to_s).first
|
||||||
|
num = !obj.blank? ? get_activity_praise_num(obj) : 0
|
||||||
|
end
|
||||||
|
|
||||||
|
present :data, num
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,18 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Whomeworks< Grape::API
|
||||||
|
resources :whomeworks do
|
||||||
|
|
||||||
|
desc "get one homework"
|
||||||
|
get ':id' do
|
||||||
|
user = UserWechat.find_by_openid(params[:openid]).user
|
||||||
|
homework = HomeworkCommon.find params[:id]
|
||||||
|
present :data, homework, with: Mobile::Entities::Whomework,user: user
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,146 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Activity <Grape::Entity
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
def self.act_expose(f)
|
||||||
|
expose f do |ac,opt|
|
||||||
|
if ac.is_a?(Hash) && ac.key?(f)
|
||||||
|
ac[f]
|
||||||
|
elsif ac.is_a?(::UserActivity)
|
||||||
|
if ac.respond_to?(f)
|
||||||
|
ac.send(f)
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :user_act
|
||||||
|
if ac.act_type == "ProjectCreateInfo"
|
||||||
|
ac unless ac.nil?
|
||||||
|
else
|
||||||
|
ac.act unless ac.nil? || ac.act.nil?
|
||||||
|
end
|
||||||
|
when :reply_count
|
||||||
|
if ac.act_type == "HomeworkCommon"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
|
||||||
|
elsif ac.act_type == "News"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
|
||||||
|
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
|
||||||
|
elsif ac.act_type == "Issue"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
|
||||||
|
end
|
||||||
|
when :subject
|
||||||
|
if ac.act_type == "HomeworkCommon"
|
||||||
|
ac.act.name unless ac.nil? || ac.act.nil?
|
||||||
|
elsif ac.act_type == "News" || ac.act_type == "BlogComment"
|
||||||
|
ac.act.title unless ac.nil? || ac.act.nil?
|
||||||
|
elsif ac.act_type == "Message" || ac.act_type == "Issue"
|
||||||
|
ac.act.subject unless ac.nil? || ac.act.nil?
|
||||||
|
elsif ac.act_type == "JournalsForMessage"
|
||||||
|
ac.act.private == 0 ? "留言" : "私信" unless ac.nil? || ac.act.nil?
|
||||||
|
end
|
||||||
|
when :description
|
||||||
|
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
|
||||||
|
ac.act.description unless ac.nil? || ac.act.nil?
|
||||||
|
elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
|
||||||
|
ac.act.content unless ac.nil? || ac.act.nil?
|
||||||
|
elsif ac.act_type == "JournalsForMessage"
|
||||||
|
ac.act.notes unless ac.nil? || ac.act.nil?
|
||||||
|
end
|
||||||
|
when :latest_update
|
||||||
|
time_from_now ac.updated_at unless ac.nil?
|
||||||
|
when :praise_count
|
||||||
|
if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
|
||||||
|
end
|
||||||
|
#when :homework_common_detail_manual
|
||||||
|
# if ac.act_type == "HomeworkCommon"
|
||||||
|
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
|
||||||
|
# end
|
||||||
|
when :course_project_name
|
||||||
|
if ac.container_type == "Course"
|
||||||
|
name = (get_course(ac.container_id)).name
|
||||||
|
name
|
||||||
|
elsif ac.container_type == "Project"
|
||||||
|
name = (get_project(ac.container_id)).name
|
||||||
|
name
|
||||||
|
elsif ac.container_type == "Blog"
|
||||||
|
"发表博客"
|
||||||
|
end
|
||||||
|
when :activity_type_name
|
||||||
|
if ac.container_type == "Course"
|
||||||
|
case ac.act_type
|
||||||
|
when "HomeworkCommon"
|
||||||
|
"课程作业"
|
||||||
|
when "News"
|
||||||
|
"课程通知"
|
||||||
|
when "Message"
|
||||||
|
"课程问答区"
|
||||||
|
when "Poll"
|
||||||
|
"课程问卷"
|
||||||
|
when "Course"
|
||||||
|
"课程"
|
||||||
|
end
|
||||||
|
elsif ac.container_type == "Project"
|
||||||
|
case ac.act_type
|
||||||
|
when "Issue"
|
||||||
|
"项目缺陷"
|
||||||
|
when "Message"
|
||||||
|
"项目讨论区"
|
||||||
|
when "ProjectCreateInfo"
|
||||||
|
"项目"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :act_type #缺陷/作业/讨论区/留言等类型
|
||||||
|
expose :act_id
|
||||||
|
expose :container_type #课程/项目/博客/个人
|
||||||
|
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
|
||||||
|
if a.is_a? ::UserActivity
|
||||||
|
if a.act_type == "ProjectCreateInfo"
|
||||||
|
get_user(get_project(a.act_id).user_id)
|
||||||
|
elsif !a.act.nil?
|
||||||
|
if a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
|
||||||
|
a.act.author
|
||||||
|
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
|
||||||
|
a.act.user
|
||||||
|
elsif a.act_type == 'Course'
|
||||||
|
a.act.teacher
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
|
||||||
|
if a.act_type == "HomeworkCommon"
|
||||||
|
a.act
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
|
||||||
|
if a.act_type == "Issue"
|
||||||
|
a.act
|
||||||
|
end
|
||||||
|
end
|
||||||
|
act_expose :reply_count #回复数
|
||||||
|
act_expose :praise_count #点赞数
|
||||||
|
#act_expose :user_act #某个动态
|
||||||
|
act_expose :subject #标题
|
||||||
|
act_expose :description #描述
|
||||||
|
act_expose :latest_update #最新更新时间
|
||||||
|
act_expose :course_project_name #课程/项目名字
|
||||||
|
act_expose :activity_type_name #课程问答区/项目缺陷等
|
||||||
|
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
if instance.act_type == "HomeworkCommon" || instance.act_type == "News" || instance.act_type == "Message" || instance.act_type == "BlogComment" || instance.act_type == "JournalsForMessage" || instance.act_type == "Issue"
|
||||||
|
has_praise = false
|
||||||
|
current_user = options[:user]
|
||||||
|
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.act_id,instance.act_type.to_s,current_user.id)
|
||||||
|
has_praise = obj.empty? ? false : true
|
||||||
|
has_praise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,65 @@
|
|||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class BlogComment < Grape::Entity
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
def self.blog_comment_expose(f)
|
||||||
|
expose f do |u,opt|
|
||||||
|
if u.is_a?(Hash) && u.key?(f)
|
||||||
|
u[f]
|
||||||
|
elsif u.is_a?(::BlogComment)
|
||||||
|
if u.respond_to?(f)
|
||||||
|
if f == :created_at
|
||||||
|
format_time( u.send(f))
|
||||||
|
else
|
||||||
|
u.send(f)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :praise_count
|
||||||
|
get_activity_praise_num(u)
|
||||||
|
when :lasted_comment
|
||||||
|
time_from_now(u.created_at)
|
||||||
|
when :act_type
|
||||||
|
'BlogComment'
|
||||||
|
when :act_id
|
||||||
|
u.id
|
||||||
|
when :comment_count
|
||||||
|
u.children.count
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :user, using: Mobile::Entities::User do |c, opt|
|
||||||
|
if c.is_a?(::BlogComment)
|
||||||
|
c.author
|
||||||
|
end
|
||||||
|
end
|
||||||
|
blog_comment_expose :act_type
|
||||||
|
blog_comment_expose :act_id
|
||||||
|
blog_comment_expose :blog_id
|
||||||
|
blog_comment_expose :title
|
||||||
|
blog_comment_expose :content
|
||||||
|
blog_comment_expose :comment_count
|
||||||
|
blog_comment_expose :created_at
|
||||||
|
blog_comment_expose :lasted_comment
|
||||||
|
blog_comment_expose :id
|
||||||
|
blog_comment_expose :praise_count
|
||||||
|
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
|
||||||
|
if c.is_a? (::BlogComment)
|
||||||
|
c.children.reverse
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :has_praise, if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
has_praise = false
|
||||||
|
current_user = options[:user]
|
||||||
|
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
|
||||||
|
has_praise = obj.empty? ? false : true
|
||||||
|
has_praise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,67 @@
|
|||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Issue <Grape::Entity
|
||||||
|
include ApiHelper
|
||||||
|
include Redmine::I18n
|
||||||
|
def self.issue_expose(f)
|
||||||
|
expose f do |issue, opt|
|
||||||
|
if issue.is_a?(Hash) && issue.key?(f)
|
||||||
|
issue[f]
|
||||||
|
elsif issue.is_a?(::Issue)
|
||||||
|
if issue.respond_to?(f)
|
||||||
|
if f == :created_on
|
||||||
|
format_time(issue.send(f))
|
||||||
|
else
|
||||||
|
issue.send(f)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :issue_priority
|
||||||
|
get_issue_priority_api issue.priority_id
|
||||||
|
when :issue_assigned_to
|
||||||
|
(get_user(issue.assigned_to_id)).login
|
||||||
|
when :issue_status
|
||||||
|
IssueStatus.find(issue.status_id).name
|
||||||
|
when :journals_count
|
||||||
|
issue.journals.where("notes is not null and notes != ''").count
|
||||||
|
when :project_name
|
||||||
|
issue.project.name
|
||||||
|
when :praise_count
|
||||||
|
get_activity_praise_num(issue)
|
||||||
|
when :act_type
|
||||||
|
'Issue'
|
||||||
|
when :act_id
|
||||||
|
issue.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :subject
|
||||||
|
expose :description
|
||||||
|
expose :author, using: Mobile::Entities::User
|
||||||
|
expose :done_ratio
|
||||||
|
issue_expose :act_type
|
||||||
|
issue_expose :act_id
|
||||||
|
issue_expose :created_on
|
||||||
|
issue_expose :issue_priority
|
||||||
|
issue_expose :issue_assigned_to
|
||||||
|
issue_expose :issue_status
|
||||||
|
issue_expose :journals_count
|
||||||
|
issue_expose :project_name
|
||||||
|
issue_expose :praise_count
|
||||||
|
expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
|
||||||
|
if f.is_a?(::Issue)
|
||||||
|
f.journals.where("notes is not null and notes != ''").reverse
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
has_praise = false
|
||||||
|
current_user = options[:user]
|
||||||
|
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
|
||||||
|
has_praise = obj.empty? ? false : true
|
||||||
|
has_praise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,44 @@
|
|||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Journal <Grape::Entity
|
||||||
|
include Redmine::I18n
|
||||||
|
=begin
|
||||||
|
include Redmine::I18n
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
include IssuesHelper
|
||||||
|
include ActionView::Helpers::TagHelper
|
||||||
|
include ActionView::Helpers::UrlHelper
|
||||||
|
=end
|
||||||
|
def self.journal_expose(f)
|
||||||
|
expose f do |journal, opt|
|
||||||
|
if journal.is_a?(Hash) && journal.key?(f)
|
||||||
|
journal[f]
|
||||||
|
elsif journal.is_a?(::Journal)
|
||||||
|
if journal.respond_to?(f)
|
||||||
|
if f == :created_on
|
||||||
|
time_from_now(journal.send(f))
|
||||||
|
else
|
||||||
|
journal.send(f)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :detail_journal
|
||||||
|
if journal.details.any?
|
||||||
|
details_to_strings(journal.details)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :notes
|
||||||
|
journal_expose :created_on
|
||||||
|
expose :user,using: Mobile::Entities::User do |f, opt|
|
||||||
|
f.user
|
||||||
|
end
|
||||||
|
#journal_expose :detail_journal
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,85 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Whomework <Grape::Entity
|
||||||
|
include ApiHelper
|
||||||
|
include ApplicationHelper
|
||||||
|
include Redmine::I18n
|
||||||
|
def self.whomework_expose(f)
|
||||||
|
expose f do |wh, opt|
|
||||||
|
if wh.is_a?(Hash) && wh.key?(f)
|
||||||
|
wh[f]
|
||||||
|
elsif wh.is_a?(::HomeworkCommon)
|
||||||
|
if wh.respond_to?(f)
|
||||||
|
if f == :created_at
|
||||||
|
format_time(wh.send(f))
|
||||||
|
else
|
||||||
|
wh.send(f)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :absence_penalty
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
|
||||||
|
when :evaluation_start
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
|
||||||
|
when :evaluation_end
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
|
||||||
|
when :praise_count
|
||||||
|
get_activity_praise_num(wh)
|
||||||
|
when :whomework_journal_count
|
||||||
|
wh.journals_for_messages.count
|
||||||
|
when :course_name
|
||||||
|
wh.course.name
|
||||||
|
when :act_type
|
||||||
|
'HomeworkCommon'
|
||||||
|
when :act_id
|
||||||
|
wh.id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expose :author, using: Mobile::Entities::User do |w, opt|
|
||||||
|
if w.is_a?(::HomeworkCommon)
|
||||||
|
w.user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :current_user, using: Mobile::Entities::User do |w, opt|
|
||||||
|
current_user
|
||||||
|
end
|
||||||
|
expose :name
|
||||||
|
expose :description
|
||||||
|
expose :publish_time
|
||||||
|
expose :end_time
|
||||||
|
expose :homework_type
|
||||||
|
expose :late_penalty
|
||||||
|
expose :course_id
|
||||||
|
expose :anonymous_comment
|
||||||
|
expose :quotes
|
||||||
|
expose :is_open
|
||||||
|
whomework_expose :act_type
|
||||||
|
whomework_expose :act_id
|
||||||
|
whomework_expose :course_name
|
||||||
|
whomework_expose :created_at
|
||||||
|
whomework_expose :absence_penalty
|
||||||
|
whomework_expose :evaluation_start
|
||||||
|
whomework_expose :evaluation_end
|
||||||
|
whomework_expose :praise_count
|
||||||
|
whomework_expose :whomework_journal_count
|
||||||
|
expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt|
|
||||||
|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
|
||||||
|
if f.is_a?(::HomeworkCommon)
|
||||||
|
f.journals_for_messages.reverse
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :has_praise , if: lambda { |instance, options| options[:user] } do |instance, options|
|
||||||
|
has_praise = false
|
||||||
|
current_user = options[:user]
|
||||||
|
obj = PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",instance.id,instance.class.to_s,current_user.id)
|
||||||
|
has_praise = obj.empty? ? false : true
|
||||||
|
has_praise
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,235 @@
|
|||||||
|
#coding=utf-8
|
||||||
|
class WechatsController < ActionController::Base
|
||||||
|
wechat_responder
|
||||||
|
|
||||||
|
include ApplicationHelper
|
||||||
|
|
||||||
|
# default text responder when no other match
|
||||||
|
on :text do |request, content|
|
||||||
|
request.reply.text "您的意见已收到" # Just echo
|
||||||
|
end
|
||||||
|
|
||||||
|
# When receive 'help', will trigger this responder
|
||||||
|
on :text, with: 'help' do |request|
|
||||||
|
request.reply.text 'help content'
|
||||||
|
end
|
||||||
|
|
||||||
|
# When receive '<n>news', will match and will got count as <n> as parameter
|
||||||
|
on :text, with: /^(\d+) news$/ do |request, count|
|
||||||
|
# Wechat article can only contain max 10 items, large than 10 will dropped.
|
||||||
|
news = (1..count.to_i).each_with_object([]) { |n, memo| memo << { title: 'News title', content: "No. #{n} news content" } }
|
||||||
|
request.reply.news(news) do |article, n, index| # article is return object
|
||||||
|
article.item title: "#{index} #{n[:title]}", description: n[:content], pic_url: 'http://www.baidu.com/img/bdlogo.gif', url: 'http://www.baidu.com/'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
on :event, with: 'subscribe' do |request|
|
||||||
|
default_msg(request)
|
||||||
|
end
|
||||||
|
|
||||||
|
# When unsubscribe user scan qrcode qrscene_xxxxxx to subscribe in public account
|
||||||
|
# notice user will subscribe public account at same time, so wechat won't trigger subscribe event any more
|
||||||
|
on :scan, with: 'qrscene_xxxxxx' do |request, ticket|
|
||||||
|
request.reply.text "Unsubscribe user #{request[:FromUserName]} Ticket #{ticket}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When subscribe user scan scene_id in public account
|
||||||
|
on :scan, with: 'scene_id' do |request, ticket|
|
||||||
|
request.reply.text "Subscribe user #{request[:FromUserName]} Ticket #{ticket}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When no any on :scan responder can match subscribe user scaned scene_id
|
||||||
|
on :event, with: 'scan' do |request|
|
||||||
|
if request[:EventKey].present?
|
||||||
|
request.reply.text "event scan got EventKey #{request[:EventKey]} Ticket #{request[:Ticket]}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# When enterprise user press menu BINDING_QR_CODE and success to scan bar code
|
||||||
|
on :scan, with: 'BINDING_QR_CODE' do |request, scan_result, scan_type|
|
||||||
|
request.reply.text "User #{request[:FromUserName]} ScanResult #{scan_result} ScanType #{scan_type}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Except QR code, wechat can also scan CODE_39 bar code in enterprise account
|
||||||
|
on :scan, with: 'BINDING_BARCODE' do |message, scan_result|
|
||||||
|
if scan_result.start_with? 'CODE_39,'
|
||||||
|
message.reply.text "User: #{message[:FromUserName]} scan barcode, result is #{scan_result.split(',')[1]}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user click the menu button
|
||||||
|
on :click, with: 'BOOK_LUNCH' do |request, key|
|
||||||
|
request.reply.text "User: #{request[:FromUserName]} click #{key}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user view URL in the menu button
|
||||||
|
on :view, with: 'http://wechat.somewhere.com/view_url' do |request, view|
|
||||||
|
request.reply.text "#{request[:FromUserName]} view #{view}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user sent the imsage
|
||||||
|
on :image do |request|
|
||||||
|
request.reply.image(request[:MediaId]) # Echo the sent image to user
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user sent the voice
|
||||||
|
on :voice do |request|
|
||||||
|
request.reply.voice(request[:MediaId]) # Echo the sent voice to user
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user sent the video
|
||||||
|
on :video do |request|
|
||||||
|
nickname = wechat.user(request[:FromUserName])['nickname'] # Call wechat api to get sender nickname
|
||||||
|
request.reply.video(request[:MediaId], title: 'Echo', description: "Got #{nickname} sent video") # Echo the sent video to user
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user sent location
|
||||||
|
on :location do |request|
|
||||||
|
request.reply.text("Latitude: #{message[:Latitude]} Longitude: #{message[:Longitude]} Precision: #{message[:Precision]}")
|
||||||
|
end
|
||||||
|
|
||||||
|
on :event, with: 'unsubscribe' do |request|
|
||||||
|
request.reply.success # user can not receive this message
|
||||||
|
end
|
||||||
|
|
||||||
|
# When user enter the app / agent app
|
||||||
|
on :event, with: 'enter_agent' do |request|
|
||||||
|
request.reply.text "#{request[:FromUserName]} enter agent app now"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When batch job create/update user (incremental) finished.
|
||||||
|
on :batch_job, with: 'sync_user' do |request, batch_job|
|
||||||
|
request.reply.text "sync_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When batch job replace user (full sync) finished.
|
||||||
|
on :batch_job, with: 'replace_user' do |request, batch_job|
|
||||||
|
request.reply.text "replace_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When batch job invent user finished.
|
||||||
|
on :batch_job, with: 'invite_user' do |request, batch_job|
|
||||||
|
request.reply.text "invite_user job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# When batch job replace department (full sync) finished.
|
||||||
|
on :batch_job, with: 'replace_party' do |request, batch_job|
|
||||||
|
request.reply.text "replace_party job #{batch_job[:JobId]} finished, return code #{batch_job[:ErrCode]}, return message #{batch_job[:ErrMsg]}"
|
||||||
|
end
|
||||||
|
|
||||||
|
# Any not match above will fail to below
|
||||||
|
on :fallback, respond: 'fallback message'
|
||||||
|
|
||||||
|
on :click, with: 'FEEDBACK' do |request, key|
|
||||||
|
request.reply.text "如有反馈问题,请直接切入至输入框,发微信给我们即可"
|
||||||
|
end
|
||||||
|
|
||||||
|
on :click, with: 'MY_NEWS' do |request, key|
|
||||||
|
default_msg(request)
|
||||||
|
end
|
||||||
|
|
||||||
|
def default_msg(request)
|
||||||
|
uw = user_binded?(request[:FromUserName])
|
||||||
|
if uw && uw.user
|
||||||
|
request.reply.text "欢迎回来, #{uw.user.show_name}"
|
||||||
|
else
|
||||||
|
sendBind(request)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def sendBind(request)
|
||||||
|
news = (1..1).each_with_object([]) { |n, memo| memo << { title: '绑定登录', content: "您还未绑定确实的用户,请先绑定." } }
|
||||||
|
request.reply.news(news) do |article, n, index| # article is return object
|
||||||
|
url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=#{Wechat.config.appid}&redirect_uri=#{login_wechat_url}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect"
|
||||||
|
article.item title: "#{n[:title]}",
|
||||||
|
description: n[:content],
|
||||||
|
pic_url: 'http://wechat.trustie.net/images/trustie_logo2.png',
|
||||||
|
url: url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def get_open_id
|
||||||
|
begin
|
||||||
|
raise "非法操作, code不存在" unless params[:code]
|
||||||
|
openid = get_openid_from_code(params[:code])
|
||||||
|
raise "无法获取到openid" unless openid
|
||||||
|
render :json => {status:0, openid: openid}
|
||||||
|
rescue Exception=>e
|
||||||
|
render :json => {status: -1, msg: e.message}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def bind
|
||||||
|
begin
|
||||||
|
raise "非法操作, code不存在" unless params[:code]
|
||||||
|
openid = get_openid_from_code(params[:code])
|
||||||
|
raise "无法获取到openid" unless openid
|
||||||
|
raise "此微信号已绑定用户, 不能得复绑定" if user_binded?(openid)
|
||||||
|
|
||||||
|
user, last_login_on = User.try_to_login(params[:username], params[:password])
|
||||||
|
raise "用户名或密码错误,请重新登录" unless user
|
||||||
|
#补全用户信息
|
||||||
|
|
||||||
|
raise "此用户已经绑定了公众号" if user.user_wechat
|
||||||
|
|
||||||
|
UserWechat.create!(
|
||||||
|
openid: openid,
|
||||||
|
user: user
|
||||||
|
)
|
||||||
|
render :json => {status:0, msg: "绑定成功"}
|
||||||
|
rescue Exception=>e
|
||||||
|
render :json => {status: -1, msg: e.message}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def login
|
||||||
|
@code = params[:code] #TODO 安全性
|
||||||
|
render 'wechats/login', layout: 'base_wechat'
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def get_openid_from_code(code)
|
||||||
|
url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=#{Wechat.config.appid}&secret=#{Wechat.config.secret}&code=#{code}&grant_type=authorization_code"
|
||||||
|
logger.debug url
|
||||||
|
body = URI.parse(url).read
|
||||||
|
logger.debug body
|
||||||
|
JSON.parse(body)["openid"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_binded?(openid)
|
||||||
|
uw = UserWechat.where(openid: openid).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def user_activity(user)
|
||||||
|
@user = user
|
||||||
|
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Project'").map(&:shield_id)
|
||||||
|
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{@user.id} and shield_type='Course'").map(&:shield_id)
|
||||||
|
@page = params[:page] ? params[:page].to_i + 1 : 0
|
||||||
|
user_project_ids = (@user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (@user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
|
||||||
|
user_course_ids = (@user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (@user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
|
||||||
|
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||||
|
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||||
|
principal_types = "JournalsForMessage"
|
||||||
|
|
||||||
|
blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
|
||||||
|
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
|
||||||
|
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
|
||||||
|
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
|
||||||
|
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def process_activity(user_activity)
|
||||||
|
act= user_activity.act
|
||||||
|
case user_activity.container_type.to_s
|
||||||
|
when 'Course'
|
||||||
|
when 'Project'
|
||||||
|
case user_activity.act_type.to_s
|
||||||
|
when 'Issue'
|
||||||
|
[act.project.name.to_s+" | 项目问题", act.subject.to_s, url_to_avatar(act.author),"http://wechat.trustie.net/app.html#/issue/#{act.id}"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class UserWechat < ActiveRecord::Base
|
||||||
|
attr_accessible :subscribe, :openid, :nickname, :sex, :language, :city, :province, :country,
|
||||||
|
:headimgurl, :subscribe_time, :unionid, :remark, :groupid, :user, :user_id
|
||||||
|
|
||||||
|
belongs_to :user
|
||||||
|
end
|
@ -0,0 +1,32 @@
|
|||||||
|
<span class="add_attachment" data-containerid="<%= container.id %>">
|
||||||
|
<button name="button" class="sub_btn" onclick="_file<%=container.id %>.click()" onmouseover="this.focus()" style="<%= ie8? ? 'display:none' : ''%>" type="button" ><%= l(:label_browse_org) %></button>
|
||||||
|
<%= file_field_tag 'attachments[dummy][file]',
|
||||||
|
:id => "_file#{container.id}",
|
||||||
|
:class => ie8? ? '':'file_selector',
|
||||||
|
:multiple => true,
|
||||||
|
:onchange => "addInputFiles_board(this, '#{container.id}','"+"submit_resource"+"');",
|
||||||
|
:style => ie8? ? '': 'display:none',
|
||||||
|
:data => {
|
||||||
|
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
|
||||||
|
:max_file_size_message => l(:error_attachment_too_big, :max_size => number_to_human_size(Setting.attachment_max_size.to_i.kilobytes)),
|
||||||
|
:max_concurrent_uploads => Redmine::Configuration['max_concurrent_ajax_uploads'].to_i,
|
||||||
|
:upload_path => uploads_path(:format => 'js'),
|
||||||
|
:description_placeholder => l(:label_optional_description),
|
||||||
|
:field_is_public => l(:field_is_public),
|
||||||
|
:are_you_sure => l(:text_are_you_sure),
|
||||||
|
:file_count => l(:label_file_count),
|
||||||
|
:delete_all_files => l(:text_are_you_sure_all),
|
||||||
|
:lebel_file_uploding => l(:lebel_file_uploding),
|
||||||
|
:containerid => "#{container.id}"
|
||||||
|
} %>
|
||||||
|
</span>
|
||||||
|
<!--<input type="submit" name="" value="上传文件" class="f_l ml10" style="width:80px; height:26px;">-->
|
||||||
|
|
||||||
|
<span id="upload_file_count<%=container.id %>">
|
||||||
|
建议上传 长度:1920px 高度:313px 的图片
|
||||||
|
</span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div>
|
||||||
|
<span id="attachments_fields<%= container.id %>" data-containerid="<%= container.id %>" xmlns="http://www.w3.org/1999/html">
|
||||||
|
</span>
|
||||||
|
</div>
|
@ -0,0 +1,25 @@
|
|||||||
|
<div id="popbox_upload" class="mb10" style="margin-top: -30px;color:#15bccf; font-size:16px;">
|
||||||
|
<div class="upload_con">
|
||||||
|
<h2 style="text-align: center">更换背景图片</h2>
|
||||||
|
<div class="upload_box">
|
||||||
|
<%= error_messages_for 'attachment' %>
|
||||||
|
<div id="network_issue" style="color: red; display: none;"><%= l(:label_file_upload_error_messages)%></div>
|
||||||
|
<%= form_tag(organization_files_path(org, :in_org => params[:in_org]), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
|
||||||
|
<!--<input type="hidden" name="org_subfield_attachment_type" value="<%#= org_subfield_attachment_type%>">-->
|
||||||
|
<%= render :partial => 'files/org_upload_attachment_list_banner', :locals => {:container => org}%>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<a href="javascript:void(0);" class=" fr grey_btn mr40" onclick="hideModal();"><%= l(:button_cancel)%></a>
|
||||||
|
<a id="submit_org_resource" href="javascript:void(0);" class="blue_btn fr" onclick="submit_resource();"><%= l(:button_confirm)%></a>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function submit_resource()
|
||||||
|
{
|
||||||
|
$('#submit_org_resource').parent().submit();
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,44 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<%= csrf_meta_tag %>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
|
||||||
|
<title>绑定用户</title>
|
||||||
|
<link rel="stylesheet" href="/stylesheets/weui/weui.min.css"/>
|
||||||
|
<script src="/javascripts/jquery.min.js"></script>
|
||||||
|
<script src="/javascripts/wechat/alert.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<%= yield %>
|
||||||
|
|
||||||
|
<!--BEGIN dialog2-->
|
||||||
|
<div class="weui_dialog_alert" id="dialog2" style="display: none;">
|
||||||
|
<div class="weui_mask"></div>
|
||||||
|
<div class="weui_dialog">
|
||||||
|
<div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
|
||||||
|
<div class="weui_dialog_bd"><span class="weui_dialog_info">弹窗内容,告知当前页面信息等</span></div>
|
||||||
|
<div class="weui_dialog_ft">
|
||||||
|
<a href="javascript:;" class="weui_btn_dialog primary">确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--END dialog2-->
|
||||||
|
|
||||||
|
<!--BEGIN dialog1-->
|
||||||
|
<div class="weui_dialog_confirm" id="dialog1" style="display: none;">
|
||||||
|
<div class="weui_mask"></div>
|
||||||
|
<div class="weui_dialog">
|
||||||
|
<div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
|
||||||
|
<div class="weui_dialog_bd"><span class="weui_dialog_info">自定义弹窗内容,居左对齐显示,告知需要确认的信息等</span></div>
|
||||||
|
<div class="weui_dialog_ft">
|
||||||
|
<a href="javascript:;" class="weui_btn_dialog default cancel">取消</a>
|
||||||
|
<a href="javascript:;" class="weui_btn_dialog primary confirm">确定</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!--END dialog1-->
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,34 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
|
||||||
|
<title>绑定用户</title>
|
||||||
|
<link rel="stylesheet" href="/stylesheets/weui/weui.min.css"/>
|
||||||
|
<script type="text/javascript">
|
||||||
|
function close(){
|
||||||
|
WeixinJSBridge.call('closeWindow');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="page">
|
||||||
|
<div class="weui_msg">
|
||||||
|
<div class="weui_icon_area"><i class="weui_icon_success weui_icon_msg"></i></div>
|
||||||
|
<div class="weui_text_area">
|
||||||
|
<h2 class="weui_msg_title">操作成功</h2>
|
||||||
|
<p class="weui_msg_desc">您已成功绑定微信</p>
|
||||||
|
</div>
|
||||||
|
<div class="weui_opr_area">
|
||||||
|
<p class="weui_btn_area">
|
||||||
|
<a href="javascript:close();" class="weui_btn weui_btn_primary">确定</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,68 @@
|
|||||||
|
|
||||||
|
<div class="loginIn">
|
||||||
|
<div>
|
||||||
|
<p class="weui_cells_title wechat-error">
|
||||||
|
<%= @wechat_bind_errors %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<%= form_tag(bind_wechat_path,:id=>'main_login_form',:method=>'post') do %>
|
||||||
|
<div class="weui_cells weui_cells_form">
|
||||||
|
<div class="weui_cell">
|
||||||
|
<div class="weui_cell_hd"><label class="weui_label">用户名</label></div>
|
||||||
|
<div class="weui_cell_bd weui_cell_primary">
|
||||||
|
<input class="weui_input" autocapitalize="off" type="text" name="username" placeholder="请输入邮箱地址或昵称"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="weui_cell">
|
||||||
|
<div class="weui_cell_hd"><label class="weui_label">用户名</label></div>
|
||||||
|
<div class="weui_cell_bd weui_cell_primary">
|
||||||
|
<input class="weui_input" type="password" name="password" placeholder="请输密码"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="hidden" value="<%=@code%>" name="code">
|
||||||
|
|
||||||
|
<div class="weui_btn_area">
|
||||||
|
<a class="weui_btn weui_btn_primary" id="submitForm">确定</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function(){
|
||||||
|
console.log("started.");
|
||||||
|
$("#submitForm").click(function(){
|
||||||
|
|
||||||
|
var data = {};
|
||||||
|
$("#main_login_form").serializeArray().map(function(x){data[x.name] = x.value;});
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: $("#main_login_form").attr("action"),
|
||||||
|
data:data,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data){
|
||||||
|
console.log(data);
|
||||||
|
if(data.status == 0){
|
||||||
|
byConfirm(data.msg, function(){
|
||||||
|
window.closeWindow();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
byAlert(data.msg, "绑定失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
@ -0,0 +1,3 @@
|
|||||||
|
class ActiveRecord::ConnectionAdapters::Mysql2Adapter
|
||||||
|
NATIVE_DATABASE_TYPES[:primary_key] = "int(11) auto_increment PRIMARY KEY"
|
||||||
|
end
|
@ -0,0 +1,20 @@
|
|||||||
|
button:
|
||||||
|
-
|
||||||
|
type: "view"
|
||||||
|
name: "最新动态"
|
||||||
|
url: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxc09454f171153c2d&redirect_uri=http://wechat.trustie.net/assets/wechat/app.html#/activities?response_type=code&scope=snsapi_base&state=123#wechat_redirect"
|
||||||
|
-
|
||||||
|
type: "click"
|
||||||
|
name: "意见返馈"
|
||||||
|
key: "FEEDBACK"
|
||||||
|
-
|
||||||
|
name: "更多"
|
||||||
|
sub_button:
|
||||||
|
-
|
||||||
|
type: "view"
|
||||||
|
name: "进入网站"
|
||||||
|
url: "http://www.trustie.net/"
|
||||||
|
-
|
||||||
|
type: "view"
|
||||||
|
name: "使用手册"
|
||||||
|
url: "https://www.trustie.net/organizations/1/downloads"
|
@ -0,0 +1,21 @@
|
|||||||
|
default: &default
|
||||||
|
# corpid: "corpid"
|
||||||
|
# corpsecret: "corpsecret"
|
||||||
|
# agentid: 1
|
||||||
|
# Or if using public account, only need above two line
|
||||||
|
appid: "wxc09454f171153c2d"
|
||||||
|
secret: "dff5b606e34dcafe24163ec82c2715f8"
|
||||||
|
token: "123456"
|
||||||
|
access_token: "1234567"
|
||||||
|
encrypt_mode: false # if true must fill encoding_aes_key
|
||||||
|
encoding_aes_key: "QyocNOkRmrT5HzBpCG54EVPUQjk86nJapXNVDQm6Yy6"
|
||||||
|
jsapi_ticket: "C:/Users/[user_name]/wechat_jsapi_ticket"
|
||||||
|
|
||||||
|
production:
|
||||||
|
<<: *default
|
||||||
|
|
||||||
|
development:
|
||||||
|
<<: *default
|
||||||
|
|
||||||
|
test:
|
||||||
|
<<: *default
|
@ -0,0 +1,11 @@
|
|||||||
|
class CreateWechatLogs < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :wechat_logs do |t|
|
||||||
|
t.string :openid, null: false, index: true
|
||||||
|
t.text :request_raw
|
||||||
|
t.text :response_raw
|
||||||
|
t.text :session_raw
|
||||||
|
t.datetime :created_at, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,21 @@
|
|||||||
|
class CreateUserWechats < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :user_wechats do |t|
|
||||||
|
t.integer :subscribe
|
||||||
|
t.string :openid
|
||||||
|
t.string :nickname
|
||||||
|
t.integer :sex
|
||||||
|
t.string :language
|
||||||
|
t.string :city
|
||||||
|
t.string :province
|
||||||
|
t.string :country
|
||||||
|
t.string :headimgurl
|
||||||
|
t.string :subscribe_time
|
||||||
|
t.string :unionid
|
||||||
|
t.string :remark
|
||||||
|
t.integer :groupid
|
||||||
|
t.references :user
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,21 @@
|
|||||||
|
class DeleteBlogUserActivity < ActiveRecord::Migration
|
||||||
|
def up
|
||||||
|
UserActivity.all.each do |activity|
|
||||||
|
if activity.act_type == 'BlogComment'
|
||||||
|
if activity.act
|
||||||
|
unless activity.act.parent_id.nil?
|
||||||
|
parent_act = UserActivity.where("act_id = #{activity.act.parent.id} and act_type='BlogComment'").first
|
||||||
|
parent_act.created_at = activity.act.parent.children.maximum("created_on")
|
||||||
|
parent_act.save
|
||||||
|
activity.destroy
|
||||||
|
end
|
||||||
|
else
|
||||||
|
activity.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>react js</title>
|
||||||
|
<meta charset='utf-8' />
|
||||||
|
<meta name="keywords" content="" />
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="no">
|
||||||
|
<meta content='True' name='HandheldFriendly' />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
|
||||||
|
|
||||||
|
<script src="/javascripts/wechat/react.js"></script>
|
||||||
|
<script src="/javascripts/wechat/JSXTransformer.js"></script>
|
||||||
|
<script src="/javascripts/wechat/ReactRouter.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container"></div>
|
||||||
|
<script src="/javascripts/wechat/jquery.min.js"></script>
|
||||||
|
<script type="text/jsx" src="/javascripts/wechat/wechat.jsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
@ -0,0 +1,27 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html ng-app="wechat">
|
||||||
|
<head>
|
||||||
|
<title>最新动态</title>
|
||||||
|
<meta charset='utf-8' />
|
||||||
|
<meta name="keywords" content="" />
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="no">
|
||||||
|
<meta content='True' name='HandheldFriendly' />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div ng-view></div>
|
||||||
|
|
||||||
|
|
||||||
|
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.js"></script>
|
||||||
|
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-route.js"></script>
|
||||||
|
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-sanitize.min.js"></script>
|
||||||
|
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular-cookies.js"></script>
|
||||||
|
<script src="/javascripts/jquery-1.3.2.js"></script>
|
||||||
|
<script src="/javascripts/wechat/app.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 171 KiB |
After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 28 KiB |
@ -0,0 +1,108 @@
|
|||||||
|
/**
|
||||||
|
* Created by guange on 16/3/19.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var CommentBox = React.createClass({
|
||||||
|
|
||||||
|
loadFromServer: function(){
|
||||||
|
$.ajax({
|
||||||
|
url: this.props.url,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data){
|
||||||
|
this.setState({data: data});
|
||||||
|
}.bind(this),
|
||||||
|
error: function(xhr,status,err){
|
||||||
|
console.error(this.props.url, status, err.toString());
|
||||||
|
}.bind(this)
|
||||||
|
});
|
||||||
|
},
|
||||||
|
onCommentSubmit: function(comment){
|
||||||
|
console.log(comment);
|
||||||
|
},
|
||||||
|
getInitialState: function(){
|
||||||
|
return {data: []};
|
||||||
|
},
|
||||||
|
componentDidMount: function(){
|
||||||
|
this.loadFromServer();
|
||||||
|
setInterval(this.loadFromServer, 2000);
|
||||||
|
},
|
||||||
|
render: function(){
|
||||||
|
return(
|
||||||
|
<div className="commentBox">
|
||||||
|
<CommentForm onCommentSubmit={this.onCommentSubmit}/>
|
||||||
|
<CommentList data={this.state.data}/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var CommentList = React.createClass({
|
||||||
|
render: function(){
|
||||||
|
|
||||||
|
var commentNodes = this.props.data.map(function(comment){
|
||||||
|
return (
|
||||||
|
<Comment author={comment.author}>
|
||||||
|
{comment.text}
|
||||||
|
</Comment>
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="commentList">
|
||||||
|
{commentNodes}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var CommentForm = React.createClass({
|
||||||
|
handleSubmit: function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
var author = this.refs.author.value.trim();
|
||||||
|
var text = this.refs.text.value.trim();
|
||||||
|
if(!text || !author){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.props.onCommentSubmit({author: author, text: text});
|
||||||
|
|
||||||
|
this.refs.author.value = '';
|
||||||
|
this.refs.text.value = '';
|
||||||
|
return;
|
||||||
|
},
|
||||||
|
render: function(){
|
||||||
|
return (
|
||||||
|
<form className="commentForm" onSubmit={this.handleSubmit}>
|
||||||
|
<input type="text" placeholder="Your name" ref="author" />
|
||||||
|
<input type="text" placeholder="Say something..." ref="text" />
|
||||||
|
<input type="submit" value="Post" />
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
var Comment = React.createClass({
|
||||||
|
|
||||||
|
rawMarkup: function() {
|
||||||
|
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
|
||||||
|
return { __html: rawMarkup };
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function(){
|
||||||
|
return (
|
||||||
|
<div className="comment">
|
||||||
|
<h2 className="commentAuthor">
|
||||||
|
{this.props.author}
|
||||||
|
</h2>
|
||||||
|
<span dangerouslySetInnerHTML={this.rawMarkup()}></span>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
React.render(<CommentBox url="api/comment.json"/>, document.getElementById("example"));
|
@ -0,0 +1,43 @@
|
|||||||
|
$(function(){
|
||||||
|
window.byAlert = function(info, title){
|
||||||
|
if(typeof title === 'undefined'){
|
||||||
|
title = '提示';
|
||||||
|
}
|
||||||
|
$('.weui_dialog_alert .weui_dialog_title').text(title);
|
||||||
|
$('.weui_dialog_alert .weui_dialog_info').text(info);
|
||||||
|
|
||||||
|
var $dialog = $('#dialog2');
|
||||||
|
$dialog.show();
|
||||||
|
$dialog.find('.weui_btn_dialog').one('click', function () {
|
||||||
|
$dialog.hide();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
window.byConfirm = function(info, cb){
|
||||||
|
var title;
|
||||||
|
if(typeof title === 'undefined'){
|
||||||
|
title = '提示';
|
||||||
|
}
|
||||||
|
$('.weui_dialog_confirm .weui_dialog_title').text(title);
|
||||||
|
$('.weui_dialog_confirm .weui_dialog_info').text(info);
|
||||||
|
|
||||||
|
var $dialog = $('#dialog1');
|
||||||
|
$dialog.show();
|
||||||
|
$dialog.find('.weui_btn_dialog.confirm').one('click', function () {
|
||||||
|
$dialog.hide();
|
||||||
|
if(typeof cb === 'function'){
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$dialog.find('.weui_btn_dialog.cancel').one('click', function () {
|
||||||
|
$dialog.hide();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.closeWindow = function(){
|
||||||
|
WeixinJSBridge.call('closeWindow');
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,439 @@
|
|||||||
|
var app = angular.module('wechat', ['ngRoute','ngCookies']);
|
||||||
|
var apiUrl = 'http://wechat.trustie.net/api/v1/';
|
||||||
|
var debug = false; //调试标志,如果在本地请置为true
|
||||||
|
|
||||||
|
if(debug===true){
|
||||||
|
apiUrl = 'http://localhost:3000/api/v1/';
|
||||||
|
}
|
||||||
|
|
||||||
|
app.factory('auth', function($http,$routeParams, $cookies, $q){
|
||||||
|
var _openid = '';
|
||||||
|
|
||||||
|
if(debug===true){
|
||||||
|
_openid = "3";
|
||||||
|
}
|
||||||
|
|
||||||
|
var getOpenId = function() {
|
||||||
|
var deferred = $q.defer();
|
||||||
|
if (typeof _openid !== 'undefined' && _openid.length > 0){
|
||||||
|
deferred.resolve(_openid);
|
||||||
|
} else {
|
||||||
|
var code = $routeParams.code;
|
||||||
|
$http({
|
||||||
|
url: '/wechat/get_open_id',
|
||||||
|
data: {code: code},
|
||||||
|
method: 'POST'
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
_openid = response.data.openid;
|
||||||
|
if(typeof _openid !== 'undefined' && _openid.length>0){
|
||||||
|
if(debug !== true){ //如果是生产环境,就存到cookies中
|
||||||
|
$cookies.put("openid", _openid);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(debug!==true){//考虑从cookies中取出
|
||||||
|
_openid = $cookies.get('openid');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deferred.resolve(_openid);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
deferred.reject(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return deferred.promise;
|
||||||
|
};
|
||||||
|
var openid = function(){
|
||||||
|
return _openid;
|
||||||
|
};
|
||||||
|
return {getOpenId: getOpenId, openid: openid};
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.factory('rms', function(){
|
||||||
|
var _saveStorage = {};
|
||||||
|
var save = function(key, value){
|
||||||
|
_saveStorage[key] = value;
|
||||||
|
};
|
||||||
|
|
||||||
|
var get = function(key){
|
||||||
|
return _saveStorage[key];
|
||||||
|
};
|
||||||
|
|
||||||
|
return {save: save, get: get};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('ActivityController',function($scope, $http, auth, rms, common){
|
||||||
|
$scope.replaceUrl = function(url){
|
||||||
|
return "http://www.trustie.net/" + url;
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log("ActivityController load");
|
||||||
|
$scope.activities = rms.get("activities") || [];
|
||||||
|
$scope.page = 0;
|
||||||
|
|
||||||
|
var loadActData = function(page){
|
||||||
|
$scope.page = page;
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl+ "activities",
|
||||||
|
data: {openid: auth.openid(), page: page}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
$scope.current_page = 0;
|
||||||
|
console.log($scope.current_page);
|
||||||
|
console.log(response.data.page);
|
||||||
|
if($scope.current_page < response.data.page) {
|
||||||
|
$scope.activities = $scope.activities.concat(response.data.data);
|
||||||
|
} else {
|
||||||
|
$scope.activities = response.data.data;
|
||||||
|
}
|
||||||
|
$scope.current_page = response.data.page;
|
||||||
|
$scope.all_count = response.data.all_count;
|
||||||
|
$scope.count = response.data.count;
|
||||||
|
console.log(response.data);
|
||||||
|
rms.save('activities', $scope.activities);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
auth.getOpenId().then(
|
||||||
|
function successCallback(response){
|
||||||
|
loadActData($scope.page);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
alert("获取openid出错:"+response);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$scope.loadActData = loadActData;
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
app.factory('common', function($http, auth, $routeParams){
|
||||||
|
var addCommonReply = function(id, type, data, cb){
|
||||||
|
|
||||||
|
if(!data.comment || data.comment.length<=0){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var userInfo = {
|
||||||
|
type: type,
|
||||||
|
content: data.comment,
|
||||||
|
openid: auth.openid()
|
||||||
|
};
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl+ "new_comment/"+id,
|
||||||
|
data: userInfo
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
alert("提交成功");
|
||||||
|
if(typeof cb === 'function'){
|
||||||
|
cb();
|
||||||
|
}
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
var loadCommonData = function(id, type){
|
||||||
|
return $http({
|
||||||
|
method: 'GET',
|
||||||
|
url: apiUrl+ type + "/" + id+"?openid="+auth.openid()
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
var addCommonPraise = function(act){
|
||||||
|
act.praise_count += 1;
|
||||||
|
act.has_praise = true;
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
|
data:{openid:auth.openid(),type:act.act_type}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
var decreaseCommonPraise = function(act){
|
||||||
|
act.praise_count -= 1;
|
||||||
|
act.has_praise = false;
|
||||||
|
|
||||||
|
$http({
|
||||||
|
method: 'POST',
|
||||||
|
url: apiUrl + "praise/" + act.act_id,
|
||||||
|
data:{openid:auth.openid(),type:act.act_type}
|
||||||
|
}).then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return {addCommonReply: addCommonReply, loadCommonData: loadCommonData, addCommonPraise: addCommonPraise, decreaseCommonPraise: decreaseCommonPraise};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('IssueController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'issues').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.issue = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addIssueReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'Issue', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('HomeworkController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'whomeworks').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.homework = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addHomeworkReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'HomeworkCommon', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('CourseNoticeController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'newss').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.news = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addNoticeReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'News', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('DiscussionController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'messages').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.discussion = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addDiscussionReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'Message', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('JournalsController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'journal_for_messages').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.message = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addJournalReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'JournalsForMessage', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
console.log(act);
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
console.log(act);
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('BlogController', function($scope, $http, $routeParams, auth, common){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
|
||||||
|
var loadData = function(id){
|
||||||
|
common.loadCommonData(id, 'blog_comments').then(function successCallback(response) {
|
||||||
|
console.log(response.data);
|
||||||
|
$scope.blog = response.data.data;
|
||||||
|
}, function errorCallback(response) {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
loadData($routeParams.id);
|
||||||
|
|
||||||
|
$scope.addBlogReply = function(data){
|
||||||
|
console.log(data.comment);
|
||||||
|
common.addCommonReply($routeParams.id, 'BlogComment', data, function(){
|
||||||
|
$scope.formData = {comment: ''};
|
||||||
|
loadData($routeParams.id);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.addPraise = function(act){
|
||||||
|
console.log(act);
|
||||||
|
common.addCommonPraise(act);
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.decreasePraise = function(act){
|
||||||
|
console.log(act);
|
||||||
|
common.decreaseCommonPraise(act);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.filter('safeHtml', function ($sce) {
|
||||||
|
return function (input) {
|
||||||
|
return $sce.trustAsHtml(input);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.directive('textAutoHeight', function($timeout){
|
||||||
|
return {
|
||||||
|
restrict: 'A',
|
||||||
|
scope: {},
|
||||||
|
link: function(scope, element, attr){
|
||||||
|
scope.text = '点击展开';
|
||||||
|
$timeout(function(){
|
||||||
|
var e = element.parent().children().eq(4);
|
||||||
|
var height = e[0].scrollHeight;
|
||||||
|
var offsetHeight = e[0].offsetHeight;
|
||||||
|
if(height>90){
|
||||||
|
element.css('display', 'block');
|
||||||
|
element.on('click', function(){
|
||||||
|
if(element.text() == "点击展开"){
|
||||||
|
e.css("height", height+'px');
|
||||||
|
element.text("点击隐藏");
|
||||||
|
} else {
|
||||||
|
e.css("height", '90px');
|
||||||
|
element.text("点击展开");
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.config(['$routeProvider',function ($routeProvider) {
|
||||||
|
$routeProvider
|
||||||
|
.when('/activities', {
|
||||||
|
templateUrl: 'activities.html',
|
||||||
|
controller: 'ActivityController'
|
||||||
|
})
|
||||||
|
.when('/issues/:id', {
|
||||||
|
templateUrl: 'issue_detail.html',
|
||||||
|
controller: 'IssueController'
|
||||||
|
})
|
||||||
|
.when('/project_discussion/:id', {
|
||||||
|
templateUrl: 'project_discussion.html',
|
||||||
|
controller: 'DiscussionController'
|
||||||
|
})
|
||||||
|
.when('/homework/:id', {
|
||||||
|
templateUrl: 'homework_detail.html',
|
||||||
|
controller: 'HomeworkController'
|
||||||
|
})
|
||||||
|
.when('/course_notice/:id', {
|
||||||
|
templateUrl: 'course_notice.html',
|
||||||
|
controller: 'CourseNoticeController'
|
||||||
|
})
|
||||||
|
.when('/course_discussion/:id', {
|
||||||
|
templateUrl: 'course_discussion.html',
|
||||||
|
controller: 'DiscussionController'
|
||||||
|
})
|
||||||
|
.when('/journal_for_message/:id', {
|
||||||
|
templateUrl: 'jour_message_detail.html',
|
||||||
|
controller: 'JournalsController'
|
||||||
|
})
|
||||||
|
.when('/blog_comment/:id', {
|
||||||
|
templateUrl: 'blog_detail.html',
|
||||||
|
controller: 'BlogController'
|
||||||
|
})
|
||||||
|
.otherwise({
|
||||||
|
redirectTo: '/activities'
|
||||||
|
});
|
||||||
|
}]);
|
@ -0,0 +1,36 @@
|
|||||||
|
$(function(){
|
||||||
|
//获取url中的参数
|
||||||
|
function getUrlParam(name) {
|
||||||
|
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
|
||||||
|
var r = window.location.search.substr(1).match(reg); //匹配目标参数
|
||||||
|
if (r != null) return unescape(r[2]); return null; //返回参数值
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var debug = false;
|
||||||
|
|
||||||
|
var g_openid = "";
|
||||||
|
if(debug){
|
||||||
|
g_openid = "填写要调试的openid即可";
|
||||||
|
}
|
||||||
|
|
||||||
|
window.getOpenId = function(cb){
|
||||||
|
if (g_openid.length>0){
|
||||||
|
cb(g_openid);
|
||||||
|
}
|
||||||
|
var code = getUrlParam("code");
|
||||||
|
$.ajax({
|
||||||
|
url: '/wechat/get_open_id',
|
||||||
|
data: {code: code},
|
||||||
|
type: 'post',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data){
|
||||||
|
g_openid = data.openid;
|
||||||
|
cb(g_openid);
|
||||||
|
},
|
||||||
|
error: function(xhr,err){
|
||||||
|
alert("认证失败: "+err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* Created by root on 3/25/16.
|
||||||
|
*/
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
var bt=baidu.template;
|
||||||
|
bt.LEFT_DELIMITER='<!';
|
||||||
|
bt.RIGHT_DELIMITER='!>';
|
||||||
|
|
||||||
|
var apiUrl = '/api/v1/';
|
||||||
|
var loadDataFromServer = function(id, page){
|
||||||
|
getOpenId(function(openid){
|
||||||
|
$.ajax({
|
||||||
|
url: apiUrl + 'activities',
|
||||||
|
data: {openid: openid, page: page},
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data){
|
||||||
|
setTemplate(data.data, data.all_count, data.count, data.page);
|
||||||
|
},
|
||||||
|
error: function(xhr,status,err){
|
||||||
|
console.log(err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
|
};
|
||||||
|
var setTemplate = function(data, all_count, count, page){
|
||||||
|
console.log(data);
|
||||||
|
var html=bt('t:result-list',{activities: data, all_count: all_count, count: count, page: page});
|
||||||
|
if (page == 0) {
|
||||||
|
$('#container').prepend(html);
|
||||||
|
} else {
|
||||||
|
$("#more_activities").remove();
|
||||||
|
$('#container').append(html);
|
||||||
|
}
|
||||||
|
descToggle();
|
||||||
|
};
|
||||||
|
//内容全部显示与部分隐藏
|
||||||
|
var descToggle = function(){
|
||||||
|
$(".post-all-content").each(function(){
|
||||||
|
var postHeight = $(this).height();
|
||||||
|
if (postHeight > 90){
|
||||||
|
$(this).parent().next().css("display","block");
|
||||||
|
$(this).parent().next().toggle(function(){
|
||||||
|
$(this).text("点击隐藏");
|
||||||
|
$(this).prev().css("height",postHeight);
|
||||||
|
},function(){
|
||||||
|
$(this).text("点击展开");
|
||||||
|
$(this).prev().css("height",90);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
loadDataFromServer(8686, 0);
|
||||||
|
});
|
@ -1,354 +1,354 @@
|
|||||||
/*
|
/*
|
||||||
# Code Review plugin for Redmine
|
# Code Review plugin for Redmine
|
||||||
# Copyright (C) 2009-2013 Haruyuki Iida
|
# Copyright (C) 2009-2013 Haruyuki Iida
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var topZindex = 1000;
|
var topZindex = 1000;
|
||||||
var action_type = '';
|
var action_type = '';
|
||||||
var rev = '';
|
var rev = '';
|
||||||
var rev_to = '';
|
var rev_to = '';
|
||||||
var path = '';
|
var path = '';
|
||||||
var urlprefix = '';
|
var urlprefix = '';
|
||||||
var review_form_dialog = null;
|
var review_form_dialog = null;
|
||||||
var add_form_title = null;
|
var add_form_title = null;
|
||||||
var review_dialog_title = null;
|
var review_dialog_title = null;
|
||||||
var repository_id = null;
|
var repository_id = null;
|
||||||
var filenames = [];
|
var filenames = [];
|
||||||
|
|
||||||
var ReviewCount = function(total, open, progress){
|
var ReviewCount = function(total, open, progress){
|
||||||
this.total = total;
|
this.total = total;
|
||||||
this.open = open;
|
this.open = open;
|
||||||
this.closed = total - open;
|
this.closed = total - open;
|
||||||
this.progress = progress
|
this.progress = progress
|
||||||
};
|
};
|
||||||
|
|
||||||
var CodeReview = function(id) {
|
var CodeReview = function(id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.path = '';
|
this.path = '';
|
||||||
this.line = 0;
|
this.line = 0;
|
||||||
this.url = '';
|
this.url = '';
|
||||||
this.is_closed = false;
|
this.is_closed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
var review_counts = new Array();
|
var review_counts = new Array();
|
||||||
var code_reviews_map = new Array();
|
var code_reviews_map = new Array();
|
||||||
var code_reviews_dialog_map = new Array();
|
var code_reviews_dialog_map = new Array();
|
||||||
|
|
||||||
function UpdateRepositoryView(title) {
|
function UpdateRepositoryView(title) {
|
||||||
var header = $("table.changesets thead tr:first");
|
var header = $("table.changesets thead tr:first");
|
||||||
var th = $('<th></th>');
|
var th = $('<th></th>');
|
||||||
th.html(title);
|
th.html(title);
|
||||||
header.append(th);
|
header.append(th);
|
||||||
$('tr.changeset td.id a').each(function(i){
|
$('tr.changeset td.id a').each(function(i){
|
||||||
var revision = this.getAttribute("href");
|
var revision = this.getAttribute("href");
|
||||||
revision = revision.substr(revision.lastIndexOf("/") + 1);
|
revision = revision.substr(revision.lastIndexOf("/") + 1);
|
||||||
var review = review_counts['revision_' + revision];
|
var review = review_counts['revision_' + revision];
|
||||||
var td = $('<td/>',{
|
var td = $('<td/>',{
|
||||||
'class':'progress'
|
'class':'progress'
|
||||||
});
|
});
|
||||||
td.html(review.progress);
|
td.html(review.progress);
|
||||||
$(this.parentNode.parentNode).append(td);
|
$(this.parentNode.parentNode).append(td);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
//add function $.down
|
//add function $.down
|
||||||
if(! $.fn.down)
|
if(! $.fn.down)
|
||||||
(function($) {
|
(function($) {
|
||||||
$.fn.down = function() {
|
$.fn.down = function() {
|
||||||
var el = this[0] && this[0].firstChild;
|
var el = this[0] && this[0].firstChild;
|
||||||
while (el && el.nodeType != 1)
|
while (el && el.nodeType != 1)
|
||||||
el = el.nextSibling;
|
el = el.nextSibling;
|
||||||
return $(el);
|
return $(el);
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
function UpdateRevisionView() {
|
function UpdateRevisionView() {
|
||||||
$('li.change').each(function(){
|
$('li.change').each(function(){
|
||||||
var li = $(this);
|
var li = $(this);
|
||||||
if (li.hasClass('folder')) return;
|
if (li.hasClass('folder')) return;
|
||||||
|
|
||||||
var a = li.down('a');
|
var a = li.down('a');
|
||||||
if (a.size() == 0) return;
|
if (a.size() == 0) return;
|
||||||
var path = a.attr('href').replace(urlprefix, '').replace(/\?.*$/, '');
|
var path = a.attr('href').replace(urlprefix, '').replace(/\?.*$/, '');
|
||||||
|
|
||||||
var reviewlist = code_reviews_map[path];
|
var reviewlist = code_reviews_map[path];
|
||||||
if (reviewlist == null) return;
|
if (reviewlist == null) return;
|
||||||
|
|
||||||
var ul = $('<ul></ul>');
|
var ul = $('<ul></ul>');
|
||||||
for (var j = 0; j < reviewlist.length; j++) {
|
for (var j = 0; j < reviewlist.length; j++) {
|
||||||
var review = reviewlist[j];
|
var review = reviewlist[j];
|
||||||
var icon = review.is_closed? 'icon-closed-review': 'icon-review';
|
var icon = review.is_closed? 'icon-closed-review': 'icon-review';
|
||||||
var item = $('<li></li>', {
|
var item = $('<li></li>', {
|
||||||
'class': 'icon ' + icon + ' code_review_summary'
|
'class': 'icon ' + icon + ' code_review_summary'
|
||||||
});
|
});
|
||||||
item.html(review.url);
|
item.html(review.url);
|
||||||
ul.append(item);
|
ul.append(item);
|
||||||
}
|
}
|
||||||
li.append(ul);
|
li.append(ul);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id){
|
function setAddReviewButton(url, change_id, image_tag, is_readonly, is_diff, attachment_id){
|
||||||
var filetables = [];
|
var filetables = [];
|
||||||
var j = 0;
|
var j = 0;
|
||||||
$('table').each(function(){
|
$('table').each(function(){
|
||||||
if($(this).hasClass('filecontent')){
|
if($(this).hasClass('filecontent')){
|
||||||
filetables[j++] = this;
|
filetables[j++] = this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
j = 0;
|
j = 0;
|
||||||
$('table.filecontent th.filename').each(function(){
|
$('table.filecontent th.filename').each(function(){
|
||||||
filenames[j] = $.trim($(this).text());
|
filenames[j] = $.trim($(this).text());
|
||||||
j++;
|
j++;
|
||||||
});
|
});
|
||||||
addReviewUrl = url + '?change_id=' + change_id + '&action_type=' + action_type +
|
addReviewUrl = url + '?change_id=' + change_id + '&action_type=' + action_type +
|
||||||
'&rev=' + rev + '&rev_to=' + rev_to +
|
'&rev=' + rev + '&rev_to=' + rev_to +
|
||||||
'&attachment_id=' + attachment_id + '&repository_id=' + encodeURIComponent(repository_id);
|
'&attachment_id=' + attachment_id + '&repository_id=' + encodeURIComponent(repository_id);
|
||||||
if (path != null && path.length > 0) {
|
if (path != null && path.length > 0) {
|
||||||
addReviewUrl = addReviewUrl + '&path=' + encodeURIComponent(path);
|
addReviewUrl = addReviewUrl + '&path=' + encodeURIComponent(path);
|
||||||
}
|
}
|
||||||
var num = 0;
|
var num = 0;
|
||||||
if (is_diff) {
|
if (is_diff) {
|
||||||
num = 1;
|
num = 1;
|
||||||
}
|
}
|
||||||
var i, l, tl;
|
var i, l, tl;
|
||||||
for (i = 0, tl = filetables.length; i < tl; i++) {
|
for (i = 0, tl = filetables.length; i < tl; i++) {
|
||||||
var table = filetables[i];
|
var table = filetables[i];
|
||||||
var trs = table.getElementsByTagName('tr');
|
var trs = table.getElementsByTagName('tr');
|
||||||
|
|
||||||
for (j = 0,l = trs.length; j < l; j++) {
|
for (j = 0,l = trs.length; j < l; j++) {
|
||||||
var tr = trs[j];
|
var tr = trs[j];
|
||||||
var ths = tr.getElementsByTagName('th');
|
var ths = tr.getElementsByTagName('th');
|
||||||
|
|
||||||
var th = ths[num];
|
var th = ths[num];
|
||||||
if (th == null) {
|
if (th == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var th_html = th.innerHTML;
|
var th_html = th.innerHTML;
|
||||||
|
|
||||||
var line = th_html.match(/[0-9]+/);
|
var line = th_html.match(/[0-9]+/);
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var span_html = '<span white-space="nowrap" id="review_span_' + line + '_' + i + '">';
|
var span_html = '<span white-space="nowrap" id="review_span_' + line + '_' + i + '">';
|
||||||
|
|
||||||
if (!is_readonly) {
|
if (!is_readonly) {
|
||||||
span_html += image_tag;
|
span_html += image_tag;
|
||||||
}
|
}
|
||||||
span_html += '</span>';
|
span_html += '</span>';
|
||||||
th.innerHTML = th_html + span_html;
|
th.innerHTML = th_html + span_html;
|
||||||
|
|
||||||
var img = th.getElementsByTagName('img')[0];
|
var img = th.getElementsByTagName('img')[0];
|
||||||
if (img != null ) {
|
if (img != null ) {
|
||||||
img.id = 'add_revew_img_' + line + '_' + i;
|
img.id = 'add_revew_img_' + line + '_' + i;
|
||||||
$(img).click(clickPencil);
|
$(img).click(clickPencil);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickPencil(e)
|
function clickPencil(e)
|
||||||
{
|
{
|
||||||
// alert('$(e.target).attr("id") = ' + $(e.target).attr("id"));
|
// alert('$(e.target).attr("id") = ' + $(e.target).attr("id"));
|
||||||
var result = $(e.target).attr("id").match(/([0-9]+)_([0-9]+)/);
|
var result = $(e.target).attr("id").match(/([0-9]+)_([0-9]+)/);
|
||||||
var line = result[1];
|
var line = result[1];
|
||||||
var file_count = eval(result[2]);
|
var file_count = eval(result[2]);
|
||||||
var url = addReviewUrl + '&line=' + line + '&file_count=' + file_count;
|
var url = addReviewUrl + '&line=' + line + '&file_count=' + file_count;
|
||||||
|
|
||||||
if (path == null || path.length == 0) {
|
if (path == null || path.length == 0) {
|
||||||
url = url + '&path=' + encodeURIComponent(filenames[file_count]) + '&diff_all=true';
|
url = url + '&path=' + encodeURIComponent(filenames[file_count]) + '&diff_all=true';
|
||||||
}
|
}
|
||||||
addReview(url);
|
addReview(url);
|
||||||
formPopup(e.pageX, e.pageY);
|
formPopup(e.pageX, e.pageY);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
var addReviewUrl = null;
|
var addReviewUrl = null;
|
||||||
var showReviewUrl = null;
|
var showReviewUrl = null;
|
||||||
var showReviewImageTag = null;
|
var showReviewImageTag = null;
|
||||||
var showClosedReviewImageTag = null;
|
var showClosedReviewImageTag = null;
|
||||||
|
|
||||||
function setShowReviewButton(line, review_id, is_closed, file_count) {
|
function setShowReviewButton(line, review_id, is_closed, file_count) {
|
||||||
//alert('file_count = ' + file_count);
|
//alert('file_count = ' + file_count);
|
||||||
var span = $('#review_span_' + line + '_' + file_count);
|
var span = $('#review_span_' + line + '_' + file_count);
|
||||||
if (span.size() == 0) {
|
if (span.size() == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var innerSpan = $('<span></span>',{id: 'review_' + review_id});
|
var innerSpan = $('<span></span>',{id: 'review_' + review_id});
|
||||||
span.append(innerSpan);
|
span.append(innerSpan);
|
||||||
innerSpan.html(is_closed? showClosedReviewImageTag : showReviewImageTag);
|
innerSpan.html(is_closed? showClosedReviewImageTag : showReviewImageTag);
|
||||||
var div = $('<div></div>', {
|
var div = $('<div></div>', {
|
||||||
'class':'draggable',
|
'class':'draggable',
|
||||||
id: 'show_review_' + review_id
|
id: 'show_review_' + review_id
|
||||||
});
|
});
|
||||||
$('#code_review').append(div);
|
$('#code_review').append(div);
|
||||||
innerSpan.down('img').click(function(e) {
|
innerSpan.down('img').click(function(e) {
|
||||||
var review_id = $(e.target).parent().attr('id').match(/[0-9]+/)[0];
|
var review_id = $(e.target).parent().attr('id').match(/[0-9]+/)[0];
|
||||||
var span = $('#review_' + review_id); // span element of view review button
|
var span = $('#review_' + review_id); // span element of view review button
|
||||||
var pos = span.offset();
|
var pos = span.offset();
|
||||||
showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top + 25);
|
showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top + 25);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function popupReview(review_id) {
|
function popupReview(review_id) {
|
||||||
var span = $('#review_' + review_id); // span element of view review button
|
var span = $('#review_' + review_id); // span element of view review button
|
||||||
var pos = span.offset();
|
var pos = span.offset();
|
||||||
$('html,body').animate({ scrollTop: pos.top },
|
$('html,body').animate({ scrollTop: pos.top },
|
||||||
{duration: 'fast',
|
{duration: 'fast',
|
||||||
complete: function(){showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top)}});
|
complete: function(){showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top)}});
|
||||||
// position and show popup dialog
|
// position and show popup dialog
|
||||||
// create popup dialog
|
// create popup dialog
|
||||||
//var win = showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top);
|
//var win = showReview(showReviewUrl, review_id, pos.left + 10 + 5, pos.top);
|
||||||
// win.toFront();
|
// win.toFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showReview(url, review_id, x, y) {
|
function showReview(url, review_id, x, y) {
|
||||||
if (code_reviews_dialog_map[review_id] != null) {
|
if (code_reviews_dialog_map[review_id] != null) {
|
||||||
var cur_win = code_reviews_dialog_map[review_id];
|
var cur_win = code_reviews_dialog_map[review_id];
|
||||||
cur_win.hide();
|
cur_win.hide();
|
||||||
code_reviews_dialog_map[review_id] = null;
|
code_reviews_dialog_map[review_id] = null;
|
||||||
}
|
}
|
||||||
$('#show_review_' + review_id).load(url, {review_id: review_id});
|
$('#show_review_' + review_id).load(url, {review_id: review_id});
|
||||||
var review = getReviewObjById(review_id);
|
var review = getReviewObjById(review_id);
|
||||||
|
|
||||||
var win = $('#show_review_' + review_id).dialog({
|
var win = $('#show_review_' + review_id).dialog({
|
||||||
show: {effect:'scale'},// ? 'top-left'
|
show: {effect:'scale'},// ? 'top-left'
|
||||||
//position: [x, y + 5],
|
//position: [x, y + 5],
|
||||||
width:640,
|
width:640,
|
||||||
zIndex: topZindex,
|
zIndex: topZindex,
|
||||||
title: review_dialog_title
|
title: review_dialog_title
|
||||||
});
|
});
|
||||||
// win.getContent().style.color = "#484848";
|
// win.getContent().style.color = "#484848";
|
||||||
// win.getContent().style.background = "#ffffff";
|
// win.getContent().style.background = "#ffffff";
|
||||||
topZindex++;
|
topZindex++;
|
||||||
code_reviews_dialog_map[review_id] = win;
|
code_reviews_dialog_map[review_id] = win;
|
||||||
return win
|
return win
|
||||||
}
|
}
|
||||||
|
|
||||||
function getReviewObjById(review_id) {
|
function getReviewObjById(review_id) {
|
||||||
for (var reviewlist in code_reviews_map) {
|
for (var reviewlist in code_reviews_map) {
|
||||||
for (var i = 0; i < reviewlist.length; i++) {
|
for (var i = 0; i < reviewlist.length; i++) {
|
||||||
var review = reviewlist[i];
|
var review = reviewlist[i];
|
||||||
if (review.id == review_id) {
|
if (review.id == review_id) {
|
||||||
return review;
|
return review;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formPopup(x, y){
|
function formPopup(x, y){
|
||||||
//@see http://docs.jquery.com/UI/Effects/Scale
|
//@see http://docs.jquery.com/UI/Effects/Scale
|
||||||
var win = $('#review-form-frame').dialog({
|
var win = $('#review-form-frame').dialog({
|
||||||
show: {effect:'scale', direction: 'both'},// ? 'top-left'
|
show: {effect:'scale', direction: 'both'},// ? 'top-left'
|
||||||
// position: [x, y + 5],
|
// position: [x, y + 5],
|
||||||
width:640,
|
width:640,
|
||||||
zIndex: topZindex,
|
zIndex: topZindex,
|
||||||
title: add_form_title
|
title: add_form_title
|
||||||
});
|
});
|
||||||
// win.getContent().style.background = "#ffffff";
|
// win.getContent().style.background = "#ffffff";
|
||||||
if (review_form_dialog != null) {
|
if (review_form_dialog != null) {
|
||||||
review_form_dialog.destroy();
|
review_form_dialog.destroy();
|
||||||
review_form_dialog = null;
|
review_form_dialog = null;
|
||||||
}
|
}
|
||||||
review_form_dialog = win;
|
review_form_dialog = win;
|
||||||
topZindex += 10;
|
topZindex += 10;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function hideForm() {
|
function hideForm() {
|
||||||
if (review_form_dialog == null) {
|
if (review_form_dialog == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
review_form_dialog.dialog('close');
|
review_form_dialog.dialog('close');
|
||||||
review_form_dialog = null;
|
review_form_dialog = null;
|
||||||
$('#review-form').html('');
|
$('#review-form').html('');
|
||||||
}
|
}
|
||||||
function addReview(url) {
|
function addReview(url) {
|
||||||
$('#review-form').load(url);
|
$('#review-form').load(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteReview(review_id) {
|
function deleteReview(review_id) {
|
||||||
$('show_review_' + review_id).remove();
|
$('show_review_' + review_id).remove();
|
||||||
$('review_' + review_id).remove();
|
$('review_' + review_id).remove();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeImage(review_id, is_closed) {
|
function changeImage(review_id, is_closed) {
|
||||||
var span = $('review_' + review_id);
|
var span = $('review_' + review_id);
|
||||||
var new_image = null;
|
var new_image = null;
|
||||||
var dummy = new Element('span');
|
var dummy = new Element('span');
|
||||||
if (is_closed) {
|
if (is_closed) {
|
||||||
dummy.insert(showClosedReviewImageTag);
|
dummy.insert(showClosedReviewImageTag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dummy.insert(showReviewImageTag);
|
dummy.insert(showReviewImageTag);
|
||||||
}
|
}
|
||||||
new_image = dummy.down().getAttribute('src');
|
new_image = dummy.down().getAttribute('src');
|
||||||
//alert(new_image);
|
//alert(new_image);
|
||||||
span.down('img').setAttribute('src', new_image);
|
span.down('img').setAttribute('src', new_image);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function make_addreview_link(project, link) {
|
function make_addreview_link(project, link) {
|
||||||
var alist = $('#content p a');
|
var alist = $('#content p a');
|
||||||
if (alist == null) {
|
if (alist == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var a = alist[0];
|
var a = alist[0];
|
||||||
var p = a.parentNode;
|
var p = a.parentNode;
|
||||||
p.innerHTML = p.innerHTML + " | " + link;
|
p.innerHTML = p.innerHTML + " | " + link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function call_update_revisions(url) {
|
function call_update_revisions(url) {
|
||||||
var changeset_ids = '';
|
var changeset_ids = '';
|
||||||
var links = $$('table.changesets tbody tr.changeset td.id a');
|
var links = $$('table.changesets tbody tr.changeset td.id a');
|
||||||
for (var i = 0; i < links.length; i++) {
|
for (var i = 0; i < links.length; i++) {
|
||||||
var link = links[i];
|
var link = links[i];
|
||||||
var href = link.getAttribute('href');
|
var href = link.getAttribute('href');
|
||||||
var id = href.replace(/^.*\/revisions\//, '');
|
var id = href.replace(/^.*\/revisions\//, '');
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
changeset_ids += ',';
|
changeset_ids += ',';
|
||||||
}
|
}
|
||||||
changeset_ids += id;
|
changeset_ids += id;
|
||||||
}
|
}
|
||||||
new Ajax.Updater('code_review_revisions', url,
|
new Ajax.Updater('code_review_revisions', url,
|
||||||
{
|
{
|
||||||
evalScripts:true,
|
evalScripts:true,
|
||||||
method:'get',
|
method:'get',
|
||||||
parameters: 'changeset_ids=' + encodeURI(changeset_ids)
|
parameters: 'changeset_ids=' + encodeURI(changeset_ids)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$.fn.serialize2json = function()
|
$.fn.serialize2json = function()
|
||||||
{
|
{
|
||||||
var o = {};
|
var o = {};
|
||||||
var a = this.serializeArray();
|
var a = this.serializeArray();
|
||||||
$.each(a, function() {
|
$.each(a, function() {
|
||||||
if (o[this.name]) {
|
if (o[this.name]) {
|
||||||
if (!o[this.name].push) {
|
if (!o[this.name].push) {
|
||||||
o[this.name] = [o[this.name]];
|
o[this.name] = [o[this.name]];
|
||||||
}
|
}
|
||||||
o[this.name].push(this.value || '');
|
o[this.name].push(this.value || '');
|
||||||
} else {
|
} else {
|
||||||
o[this.name] = this.value || '';
|
o[this.name] = this.value || '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return o;
|
return o;
|
||||||
};
|
};
|
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
dt.code_review {
|
dt.code_review {
|
||||||
background-image: url(../images/review.png);
|
background-image: url(../images/review.png);
|
||||||
}
|
}
|
@ -1,97 +1,97 @@
|
|||||||
/*
|
/*
|
||||||
# Code Review plugin for Redmine
|
# Code Review plugin for Redmine
|
||||||
# Copyright (C) 2009 Haruyuki Iida
|
# Copyright (C) 2009 Haruyuki Iida
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# modify it under the terms of the GNU General Public License
|
||||||
# as published by the Free Software Foundation; either version 2
|
# as published by the Free Software Foundation; either version 2
|
||||||
# of the License, or (at your option) any later version.
|
# of the License, or (at your option) any later version.
|
||||||
#
|
#
|
||||||
# This program is distributed in the hope that it will be useful,
|
# This program is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program; if not, write to the Free Software
|
# along with this program; if not, write to the Free Software
|
||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
*/
|
*/
|
||||||
#review-form-frame {
|
#review-form-frame {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.autoscroll table.filecontent th.line-num {
|
.autoscroll table.filecontent th.line-num {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
text-align:left;
|
text-align:left;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.filecontent th.line-num img{
|
table.filecontent th.line-num img{
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.code-review-form-title {
|
.code-review-form-title {
|
||||||
background-color: #002059;
|
background-color: #002059;
|
||||||
color: white;
|
color: white;
|
||||||
padding-left: 2px;
|
padding-left: 2px;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
cursor: default;
|
cursor: default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.code_review_viewer {
|
.code_review_viewer {
|
||||||
|
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
/*
|
/*
|
||||||
max-width: 60%;
|
max-width: 60%;
|
||||||
*/
|
*/
|
||||||
/* max-height: 400px; */
|
/* max-height: 400px; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.code_review_viewer .issue{
|
.code_review_viewer .issue{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.code_review_body {
|
.code_review_body {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
|
|
||||||
padding:2px;
|
padding:2px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_review_list table.list td {
|
#code_review_list table.list td {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_review_list table.list td.path {
|
#code_review_list table.list td.path {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
#code_review_list table.list td.subject {
|
#code_review_list table.list td.subject {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-review {
|
.icon-review {
|
||||||
background-image: url(../images/review.png);
|
background-image: url(../images/review.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-closed-review {
|
.icon-closed-review {
|
||||||
background-image: url(../images/closed_review.png);
|
background-image: url(../images/closed_review.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
.icon-settings {
|
.icon-settings {
|
||||||
background-image: url(../../../images/changeset.png);
|
background-image: url(../../../images/changeset.png);
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
li.code_review_summary {
|
li.code_review_summary {
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
@ -1,19 +1,19 @@
|
|||||||
Copyright (c) 2006 Sébastien Gruhier (http://xilinus.com, http://itseb.com)
|
Copyright (c) 2006 Sébastien Gruhier (http://xilinus.com, http://itseb.com)
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
"Software"), to deal in the Software without restriction, including
|
"Software"), to deal in the Software without restriction, including
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
the following conditions:
|
the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
The above copyright notice and this permission notice shall be
|
||||||
included in all copies or substantial portions of the Software.
|
included in all copies or substantial portions of the Software.
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
@ -1,119 +1,119 @@
|
|||||||
.overlay_alert {
|
.overlay_alert {
|
||||||
background-color: #85BBEF;
|
background-color: #85BBEF;
|
||||||
filter:alpha(opacity=60);
|
filter:alpha(opacity=60);
|
||||||
-moz-opacity: 0.6;
|
-moz-opacity: 0.6;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_nw {
|
.alert_nw {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/top_left.gif) no-repeat bottom left;
|
background: transparent url(alert/top_left.gif) no-repeat bottom left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_n {
|
.alert_n {
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/top.gif) repeat-x bottom left;
|
background: transparent url(alert/top.gif) repeat-x bottom left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_ne {
|
.alert_ne {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/top_right.gif) no-repeat bottom left
|
background: transparent url(alert/top_right.gif) no-repeat bottom left
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_e {
|
.alert_e {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
background: transparent url(alert/right.gif) repeat-y 0 0;
|
background: transparent url(alert/right.gif) repeat-y 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_w {
|
.alert_w {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
background: transparent url(alert/left.gif) repeat-y 0 0;
|
background: transparent url(alert/left.gif) repeat-y 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_sw {
|
.alert_sw {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/bottom_left.gif) no-repeat 0 0;
|
background: transparent url(alert/bottom_left.gif) no-repeat 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_s {
|
.alert_s {
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/bottom.gif) repeat-x 0 0;
|
background: transparent url(alert/bottom.gif) repeat-x 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_se, .alert_sizer {
|
.alert_se, .alert_sizer {
|
||||||
width: 5px;
|
width: 5px;
|
||||||
height: 5px;
|
height: 5px;
|
||||||
background: transparent url(alert/bottom_right.gif) no-repeat 0 0;
|
background: transparent url(alert/bottom_right.gif) no-repeat 0 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_close {
|
.alert_close {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_minimize {
|
.alert_minimize {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_maximize {
|
.alert_maximize {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_title {
|
.alert_title {
|
||||||
float:left;
|
float:left;
|
||||||
height:1px;
|
height:1px;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_content {
|
.alert_content {
|
||||||
overflow:visible;
|
overflow:visible;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-family: Tahoma, Arial, sans-serif;
|
font-family: Tahoma, Arial, sans-serif;
|
||||||
font: 12px arial;
|
font: 12px arial;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For alert/confirm dialog */
|
/* For alert/confirm dialog */
|
||||||
.alert_window {
|
.alert_window {
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
padding:20px;
|
padding:20px;
|
||||||
margin-left:auto;
|
margin-left:auto;
|
||||||
margin-right:auto;
|
margin-right:auto;
|
||||||
width:400px;
|
width:400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_message {
|
.alert_message {
|
||||||
font: 12px arial;
|
font: 12px arial;
|
||||||
width:100%;
|
width:100%;
|
||||||
color:#F00;
|
color:#F00;
|
||||||
padding-bottom:10px;
|
padding-bottom:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_buttons {
|
.alert_buttons {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_buttons input {
|
.alert_buttons input {
|
||||||
width:20%;
|
width:20%;
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_progress {
|
.alert_progress {
|
||||||
float:left;
|
float:left;
|
||||||
margin:auto;
|
margin:auto;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:16px;
|
height:16px;
|
||||||
background: #FFF url('alert/progress.gif') no-repeat center center
|
background: #FFF url('alert/progress.gif') no-repeat center center
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,88 +1,88 @@
|
|||||||
.overlay_alert_lite {
|
.overlay_alert_lite {
|
||||||
background-color: #85BBEF;
|
background-color: #85BBEF;
|
||||||
filter:alpha(opacity=60);
|
filter:alpha(opacity=60);
|
||||||
-moz-opacity: 0.6;
|
-moz-opacity: 0.6;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_sizer {
|
.alert_lite_sizer {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_close {
|
.alert_lite_close {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_minimize {
|
.alert_lite_minimize {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_maximize {
|
.alert_lite_maximize {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_title {
|
.alert_lite_title {
|
||||||
width:0px;
|
width:0px;
|
||||||
height:0px;
|
height:0px;
|
||||||
display:none;
|
display:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_content {
|
.alert_lite_content {
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-family: Tahoma, Arial, sans-serif;
|
font-family: Tahoma, Arial, sans-serif;
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* For alert/confirm dialog */
|
/* For alert/confirm dialog */
|
||||||
.alert_lite_window {
|
.alert_lite_window {
|
||||||
border:1px solid #F00;
|
border:1px solid #F00;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
padding:20px;
|
padding:20px;
|
||||||
margin-left:auto;
|
margin-left:auto;
|
||||||
margin-right:auto;
|
margin-right:auto;
|
||||||
width:400px;
|
width:400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_message {
|
.alert_lite_message {
|
||||||
font-size:16px;
|
font-size:16px;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
color:#F00;
|
color:#F00;
|
||||||
padding-bottom:10px;
|
padding-bottom:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_buttons {
|
.alert_lite_buttons {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_buttons input {
|
.alert_lite_buttons input {
|
||||||
width:20%;
|
width:20%;
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert_lite_progress {
|
.alert_lite_progress {
|
||||||
float:left;
|
float:left;
|
||||||
margin:auto;
|
margin:auto;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:16px;
|
height:16px;
|
||||||
background: #FFF url('alert/progress.gif') no-repeat center center
|
background: #FFF url('alert/progress.gif') no-repeat center center
|
||||||
}
|
}
|
||||||
|
|
||||||
table.alert_lite_header {
|
table.alert_lite_header {
|
||||||
border:1px solid #F00;
|
border:1px solid #F00;
|
||||||
background:#FFF
|
background:#FFF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,150 +1,150 @@
|
|||||||
.overlay_alphacube {
|
.overlay_alphacube {
|
||||||
background-color: #85BBEF;
|
background-color: #85BBEF;
|
||||||
filter:alpha(opacity=60);
|
filter:alpha(opacity=60);
|
||||||
-moz-opacity: 0.6;
|
-moz-opacity: 0.6;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_nw {
|
.alphacube_nw {
|
||||||
background: transparent url(alphacube/left-top.gif) no-repeat 0 0;
|
background: transparent url(alphacube/left-top.gif) no-repeat 0 0;
|
||||||
width:10px;
|
width:10px;
|
||||||
height:25px;
|
height:25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_n {
|
.alphacube_n {
|
||||||
background: transparent url(alphacube/top-middle.gif) repeat-x 0 0;
|
background: transparent url(alphacube/top-middle.gif) repeat-x 0 0;
|
||||||
height:25px;
|
height:25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_ne {
|
.alphacube_ne {
|
||||||
background: transparent url(alphacube/right-top.gif) no-repeat 0 0;
|
background: transparent url(alphacube/right-top.gif) no-repeat 0 0;
|
||||||
width:10px;
|
width:10px;
|
||||||
height:25px;
|
height:25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_w {
|
.alphacube_w {
|
||||||
background: transparent url(alphacube/frame-left.gif) repeat-y top left;
|
background: transparent url(alphacube/frame-left.gif) repeat-y top left;
|
||||||
width:7px;
|
width:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_e {
|
.alphacube_e {
|
||||||
background: transparent url(alphacube/frame-right.gif) repeat-y top right;
|
background: transparent url(alphacube/frame-right.gif) repeat-y top right;
|
||||||
width:7px;
|
width:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_sw {
|
.alphacube_sw {
|
||||||
background: transparent url(alphacube/bottom-left-c.gif) no-repeat 0 0;
|
background: transparent url(alphacube/bottom-left-c.gif) no-repeat 0 0;
|
||||||
width:7px;
|
width:7px;
|
||||||
height:7px;
|
height:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_s {
|
.alphacube_s {
|
||||||
background: transparent url(alphacube/bottom-middle.gif) repeat-x 0 0;
|
background: transparent url(alphacube/bottom-middle.gif) repeat-x 0 0;
|
||||||
height:7px;
|
height:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_se, .alphacube_sizer {
|
.alphacube_se, .alphacube_sizer {
|
||||||
background: transparent url(alphacube/bottom-right-c.gif) no-repeat 0 0;
|
background: transparent url(alphacube/bottom-right-c.gif) no-repeat 0 0;
|
||||||
width:7px;
|
width:7px;
|
||||||
height:7px;
|
height:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_sizer {
|
.alphacube_sizer {
|
||||||
cursor:se-resize;
|
cursor:se-resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_close {
|
.alphacube_close {
|
||||||
width: 23px;
|
width: 23px;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
background: transparent url(alphacube/button-close-focus.gif) no-repeat 0 0;
|
background: transparent url(alphacube/button-close-focus.gif) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:11px;
|
right:11px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_minimize {
|
.alphacube_minimize {
|
||||||
width: 23px;
|
width: 23px;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
background: transparent url(alphacube/button-min-focus.gif) no-repeat 0 0;
|
background: transparent url(alphacube/button-min-focus.gif) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:55px;
|
right:55px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_maximize {
|
.alphacube_maximize {
|
||||||
width: 23px;
|
width: 23px;
|
||||||
height: 23px;
|
height: 23px;
|
||||||
background: transparent url(alphacube/button-max-focus.gif) no-repeat 0 0;
|
background: transparent url(alphacube/button-max-focus.gif) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:33px;
|
right:33px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_title {
|
.alphacube_title {
|
||||||
float:left;
|
float:left;
|
||||||
height:14px;
|
height:14px;
|
||||||
font-size:14px;
|
font-size:14px;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
margin-top:2px;
|
margin-top:2px;
|
||||||
width:100%;
|
width:100%;
|
||||||
color:#123456;
|
color:#123456;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_content {
|
.alphacube_content {
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
color: #000;
|
color: #000;
|
||||||
font-family: Tahoma, Arial, sans-serif;
|
font-family: Tahoma, Arial, sans-serif;
|
||||||
font: 12px arial;
|
font: 12px arial;
|
||||||
background:#FDFDFD;
|
background:#FDFDFD;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* For alert/confirm dialog */
|
/* For alert/confirm dialog */
|
||||||
.alphacube_window {
|
.alphacube_window {
|
||||||
border:1px solid #F00;
|
border:1px solid #F00;
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
padding:20px;
|
padding:20px;
|
||||||
margin-left:auto;
|
margin-left:auto;
|
||||||
margin-right:auto;
|
margin-right:auto;
|
||||||
width:400px;
|
width:400px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_message {
|
.alphacube_message {
|
||||||
font: 12px arial;
|
font: 12px arial;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
padding-bottom:10px;
|
padding-bottom:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_buttons {
|
.alphacube_buttons {
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_buttons input {
|
.alphacube_buttons input {
|
||||||
width:20%;
|
width:20%;
|
||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_progress {
|
.alphacube_progress {
|
||||||
float:left;
|
float:left;
|
||||||
margin:auto;
|
margin:auto;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:16px;
|
height:16px;
|
||||||
background: #FFF url('alert/progress.gif') no-repeat center center
|
background: #FFF url('alert/progress.gif') no-repeat center center
|
||||||
}
|
}
|
||||||
|
|
||||||
.alphacube_wired_frame {
|
.alphacube_wired_frame {
|
||||||
background: #FFF;
|
background: #FFF;
|
||||||
filter:alpha(opacity=60);
|
filter:alpha(opacity=60);
|
||||||
-moz-opacity: 0.6;
|
-moz-opacity: 0.6;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
<public:component>
|
<public:component>
|
||||||
<public:attach event="onpropertychange" onevent="propertyChanged()" />
|
<public:attach event="onpropertychange" onevent="propertyChanged()" />
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
var supported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";
|
var supported = /MSIE (5\.5)|[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";
|
||||||
var realSrc;
|
var realSrc;
|
||||||
var blankSrc = "blank.gif";
|
var blankSrc = "blank.gif";
|
||||||
|
|
||||||
if (supported) fixImage();
|
if (supported) fixImage();
|
||||||
|
|
||||||
function propertyChanged() {
|
function propertyChanged() {
|
||||||
if (!supported) return;
|
if (!supported) return;
|
||||||
|
|
||||||
var pName = event.propertyName;
|
var pName = event.propertyName;
|
||||||
if (pName != "src") return;
|
if (pName != "src") return;
|
||||||
// if not set to blank
|
// if not set to blank
|
||||||
if ( ! new RegExp(blankSrc).test(src))
|
if ( ! new RegExp(blankSrc).test(src))
|
||||||
fixImage();
|
fixImage();
|
||||||
};
|
};
|
||||||
|
|
||||||
function fixImage() {
|
function fixImage() {
|
||||||
// get src
|
// get src
|
||||||
var src = element.src;
|
var src = element.src;
|
||||||
|
|
||||||
// check for real change
|
// check for real change
|
||||||
if (src == realSrc) {
|
if (src == realSrc) {
|
||||||
element.src = blankSrc;
|
element.src = blankSrc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! new RegExp(blankSrc).test(src)) {
|
if ( ! new RegExp(blankSrc).test(src)) {
|
||||||
// backup old src
|
// backup old src
|
||||||
realSrc = src;
|
realSrc = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
// test for png
|
// test for png
|
||||||
if ( /\.png$/.test( realSrc.toLowerCase() ) ) {
|
if ( /\.png$/.test( realSrc.toLowerCase() ) ) {
|
||||||
// set blank image
|
// set blank image
|
||||||
element.src = blankSrc;
|
element.src = blankSrc;
|
||||||
// set filter
|
// set filter
|
||||||
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
|
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
|
||||||
src + "',sizingMethod='scale')";
|
src + "',sizingMethod='scale')";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// remove filter
|
// remove filter
|
||||||
element.runtimeStyle.filter = "";
|
element.runtimeStyle.filter = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</public:component>
|
</public:component>
|
@ -1,121 +1,121 @@
|
|||||||
.overlay_darkX {
|
.overlay_darkX {
|
||||||
background-color: #85BBEF;
|
background-color: #85BBEF;
|
||||||
filter:alpha(opacity=60);
|
filter:alpha(opacity=60);
|
||||||
-moz-opacity: 0.6;
|
-moz-opacity: 0.6;
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_nw {
|
.darkX_nw {
|
||||||
background: transparent url(darkX/titlebar-left-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/titlebar-left-focused.png) no-repeat 0 0;
|
||||||
width:6px;
|
width:6px;
|
||||||
height:21px;
|
height:21px;
|
||||||
}
|
}
|
||||||
.darkX_n {
|
.darkX_n {
|
||||||
background: transparent url(darkX/titlebar-mid-focused.png) repeat-x 0 0;
|
background: transparent url(darkX/titlebar-mid-focused.png) repeat-x 0 0;
|
||||||
height:21px;
|
height:21px;
|
||||||
}
|
}
|
||||||
.darkX_ne {
|
.darkX_ne {
|
||||||
background: transparent url(darkX/titlebar-right-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/titlebar-right-focused.png) no-repeat 0 0;
|
||||||
width:6px;
|
width:6px;
|
||||||
height:21px;
|
height:21px;
|
||||||
}
|
}
|
||||||
.darkX_w {
|
.darkX_w {
|
||||||
background: transparent url(darkX/frame-left-focused.png) repeat-y top left;
|
background: transparent url(darkX/frame-left-focused.png) repeat-y top left;
|
||||||
width:3px;
|
width:3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_e {
|
.darkX_e {
|
||||||
background: transparent url(darkX/frame-right-focused.png) repeat-y top right;
|
background: transparent url(darkX/frame-right-focused.png) repeat-y top right;
|
||||||
width:3px;
|
width:3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_sw {
|
.darkX_sw {
|
||||||
background: transparent url(darkX/frame-bottom-left-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/frame-bottom-left-focused.png) no-repeat 0 0;
|
||||||
width:5px;
|
width:5px;
|
||||||
height:3px;
|
height:3px;
|
||||||
}
|
}
|
||||||
.darkX_s {
|
.darkX_s {
|
||||||
background: transparent url(darkX/frame-bottom-mid-focused.png) repeat-x 0 0;
|
background: transparent url(darkX/frame-bottom-mid-focused.png) repeat-x 0 0;
|
||||||
height:3px;
|
height:3px;
|
||||||
}
|
}
|
||||||
.darkX_se, .darkX_sizer {
|
.darkX_se, .darkX_sizer {
|
||||||
background: transparent url(darkX/frame-bottom-right-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/frame-bottom-right-focused.png) no-repeat 0 0;
|
||||||
width:5px;
|
width:5px;
|
||||||
height:3px;
|
height:3px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_sizer {
|
.darkX_sizer {
|
||||||
cursor:se-resize;
|
cursor:se-resize;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_close {
|
.darkX_close {
|
||||||
width: 21px;
|
width: 21px;
|
||||||
height: 21px;
|
height: 21px;
|
||||||
background: transparent url(darkX/button-close-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/button-close-focused.png) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:5px;
|
right:5px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_minimize {
|
.darkX_minimize {
|
||||||
width: 21px;
|
width: 21px;
|
||||||
height: 21px;
|
height: 21px;
|
||||||
background: transparent url(darkX/button-minimize-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/button-minimize-focused.png) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:26px;
|
right:26px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_maximize {
|
.darkX_maximize {
|
||||||
width: 21px;
|
width: 21px;
|
||||||
height: 21px;
|
height: 21px;
|
||||||
background: transparent url(darkX/button-maximize-focused.png) no-repeat 0 0;
|
background: transparent url(darkX/button-maximize-focused.png) no-repeat 0 0;
|
||||||
position:absolute;
|
position:absolute;
|
||||||
top:0px;
|
top:0px;
|
||||||
right:47px;
|
right:47px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:1000;
|
z-index:1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.darkX_title {
|
.darkX_title {
|
||||||
float:left;
|
float:left;
|
||||||
height:14px;
|
height:14px;
|
||||||
font-size:12px;
|
font-size:12px;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
margin-top:2px;
|
margin-top:2px;
|
||||||
width:100%;
|
width:100%;
|
||||||
color:#FFF;
|
color:#FFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
.darkX_content {
|
.darkX_content {
|
||||||
overflow:auto;
|
overflow:auto;
|
||||||
color: #E6DF2A;
|
color: #E6DF2A;
|
||||||
font-family: Tahoma, Arial, sans-serif;
|
font-family: Tahoma, Arial, sans-serif;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
background:#5E5148;
|
background:#5E5148;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* FOR IE */
|
/* FOR IE */
|
||||||
* html .darkX_minimize {
|
* html .darkX_minimize {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-image: none;
|
background-image: none;
|
||||||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-minimize-focused.png", sizingMethod="crop");
|
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-minimize-focused.png", sizingMethod="crop");
|
||||||
}
|
}
|
||||||
|
|
||||||
* html .darkX_maximize {
|
* html .darkX_maximize {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-image: none;
|
background-image: none;
|
||||||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-maximize-focused.png", sizingMethod="scale");
|
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-maximize-focused.png", sizingMethod="scale");
|
||||||
}
|
}
|
||||||
|
|
||||||
* html .darkX_close {
|
* html .darkX_close {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
background-image: none;
|
background-image: none;
|
||||||
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-close-focused.png", sizingMethod="crop");
|
filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/darkX/button-close-focused.png", sizingMethod="crop");
|
||||||
}
|
}
|
||||||
|