Merge branch 'develop-feature'
This commit is contained in:
commit
ca9be9cd81
48 files changed
+1719
-197
No files matched your search
+1
-1
@@ -17,4 +17,4 @@ app/tmp/main.go
|
||||
.settings
|
||||
.project
|
||||
public/config.codekit
|
||||
|
||||
files
|
||||
@@ -0,0 +1,212 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
// "encoding/json"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
"io"
|
||||
"archive/tar"
|
||||
"compress/gzip"
|
||||
)
|
||||
|
||||
// 附件
|
||||
type Attach struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// 上传附件
|
||||
func (c Attach) UploadAttach(noteId string) revel.Result {
|
||||
re := c.uploadAttach(noteId)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
func (c Attach) uploadAttach(noteId string) (re info.Re) {
|
||||
var fileId = ""
|
||||
var resultMsg = "error" // 错误信息
|
||||
var Ok = false
|
||||
var fileInfo info.Attach
|
||||
|
||||
re = info.NewRe()
|
||||
|
||||
defer func() {
|
||||
re.Id = fileId // 只是id, 没有其它信息
|
||||
re.Msg = resultMsg
|
||||
re.Ok = Ok
|
||||
re.Item = fileInfo
|
||||
}()
|
||||
|
||||
// 判断是否有权限为笔记添加附件
|
||||
if !shareService.HasUpdateNotePerm(noteId, c.GetUserId()) {
|
||||
return re
|
||||
}
|
||||
|
||||
file, handel, err := c.Request.FormFile("file")
|
||||
if err != nil {
|
||||
return re
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
data, err := ioutil.ReadAll(file)
|
||||
if err != nil {
|
||||
return re
|
||||
}
|
||||
// > 5M?
|
||||
if(len(data) > 5 * 1024 * 1024) {
|
||||
resultMsg = "File is bigger than 5M"
|
||||
return re
|
||||
}
|
||||
|
||||
// 生成上传路径
|
||||
filePath := "files/" + c.GetUserId() + "/attachs"
|
||||
dir := revel.BasePath + "/" + filePath
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return re
|
||||
}
|
||||
// 生成新的文件名
|
||||
filename := handel.Filename
|
||||
_, ext := SplitFilename(filename) // .doc
|
||||
filename = NewGuid() + ext
|
||||
toPath := dir + "/" + filename;
|
||||
err = ioutil.WriteFile(toPath, data, 0777)
|
||||
if err != nil {
|
||||
return re
|
||||
}
|
||||
|
||||
// add File to db
|
||||
fileType := ""
|
||||
if ext != "" {
|
||||
fileType = strings.ToLower(ext[1:])
|
||||
}
|
||||
filesize := GetFilesize(toPath)
|
||||
fileInfo = info.Attach{Name: filename,
|
||||
Title: handel.Filename,
|
||||
NoteId: bson.ObjectIdHex(noteId),
|
||||
UploadUserId: c.GetObjectUserId(),
|
||||
Path: filePath + "/" + filename,
|
||||
Type: fileType,
|
||||
Size: filesize}
|
||||
|
||||
id := bson.NewObjectId();
|
||||
fileInfo.AttachId = id
|
||||
fileId = id.Hex()
|
||||
Ok = attachService.AddAttach(fileInfo)
|
||||
|
||||
fileInfo.Path = ""; // 不要返回
|
||||
resultMsg = "success"
|
||||
|
||||
return re
|
||||
}
|
||||
|
||||
// 删除附件
|
||||
func (c Attach) DeleteAttach(attachId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok, re.Msg = attachService.DeleteAttach(attachId, c.GetUserId())
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// get all attachs by noteId
|
||||
func (c Attach) GetAttachs(noteId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = true
|
||||
re.List = attachService.ListAttachs(noteId, c.GetUserId())
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 下载附件
|
||||
// 权限判断
|
||||
func (c Attach) Download(attachId string) revel.Result {
|
||||
attach := attachService.GetAttach(attachId, c.GetUserId()); // 得到路径
|
||||
path := attach.Path
|
||||
if path == "" {
|
||||
return c.RenderText("")
|
||||
}
|
||||
fn := revel.BasePath + "/" + strings.TrimLeft(path, "/")
|
||||
file, _ := os.Open(fn)
|
||||
return c.RenderBinary(file, attach.Title, revel.Attachment, time.Now()) // revel.Attachment
|
||||
// return c.RenderFile(file, revel.Attachment) // revel.Attachment
|
||||
}
|
||||
|
||||
func (c Attach) DownloadAll(noteId string) revel.Result {
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.NoteId == "" {
|
||||
return c.RenderText("")
|
||||
}
|
||||
// 得到文件列表
|
||||
attachs := attachService.ListAttachs(noteId, c.GetUserId())
|
||||
if attachs == nil || len(attachs) == 0 {
|
||||
return c.RenderText("")
|
||||
}
|
||||
|
||||
/*
|
||||
dir := revel.BasePath + "/files/tmp"
|
||||
err := os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return c.RenderText("")
|
||||
}
|
||||
*/
|
||||
|
||||
filename := note.Title + ".tar.gz"
|
||||
if note.Title == "" {
|
||||
filename = "all.tar.gz"
|
||||
}
|
||||
|
||||
// file write
|
||||
fw, err := os.Create(revel.BasePath + "/files/" + filename)
|
||||
if err != nil {
|
||||
return c.RenderText("")
|
||||
}
|
||||
// defer fw.Close() // 不需要关闭, 还要读取给用户下载
|
||||
|
||||
// gzip write
|
||||
gw := gzip.NewWriter(fw)
|
||||
defer gw.Close()
|
||||
|
||||
// tar write
|
||||
tw := tar.NewWriter(gw)
|
||||
defer tw.Close()
|
||||
|
||||
// 遍历文件列表
|
||||
for _, attach := range attachs {
|
||||
fn := revel.BasePath + "/" + strings.TrimLeft(attach.Path, "/")
|
||||
fr, err := os.Open(fn)
|
||||
fileInfo, _ := fr.Stat()
|
||||
if err != nil {
|
||||
return c.RenderText("")
|
||||
}
|
||||
defer fr.Close()
|
||||
|
||||
// 信息头
|
||||
h := new(tar.Header)
|
||||
h.Name = attach.Title
|
||||
h.Size = fileInfo.Size()
|
||||
h.Mode = int64(fileInfo.Mode())
|
||||
h.ModTime = fileInfo.ModTime()
|
||||
|
||||
// 写信息头
|
||||
err = tw.WriteHeader(h)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// 写文件
|
||||
_, err = io.Copy(tw, fr)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
} // for
|
||||
|
||||
// tw.Close()
|
||||
// gw.Close()
|
||||
// fw.Close()
|
||||
// file, _ := os.Open(dir + "/" + filename)
|
||||
// fw.Seek(0, 0)
|
||||
return c.RenderBinary(fw, filename, revel.Attachment, time.Now()) // revel.Attachment
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@ package controllers
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
// "encoding/json"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 首页
|
||||
@@ -15,7 +17,7 @@ type File struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// 上传图片 editor
|
||||
// 过时 已弃用!
|
||||
func (c File) UploadImage(renderHtml string) revel.Result {
|
||||
if renderHtml == "" {
|
||||
renderHtml = "file/image.html"
|
||||
@@ -30,36 +32,60 @@ func (c File) UploadImage(renderHtml string) revel.Result {
|
||||
return c.RenderTemplate(renderHtml)
|
||||
}
|
||||
|
||||
// 已弃用
|
||||
func (c File) UploadImageJson(from, noteId string) revel.Result {
|
||||
re := c.uploadImage(from, "");
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
|
||||
// 上传的是博客logo
|
||||
// TODO logo不要设置权限, 另外的目录
|
||||
func (c File) UploadBlogLogo() revel.Result {
|
||||
return c.UploadImage("file/blog_logo.html");
|
||||
}
|
||||
|
||||
// 拖拉上传, pasteImage
|
||||
func (c File) UploadImageJson(renderHtml, from string) revel.Result {
|
||||
re := c.uploadImage(from, "");
|
||||
re.Id = siteUrl + re.Id
|
||||
// re.Id = re.Id
|
||||
// noteId 是为了判断是否是协作的note, 如果是则需要复制一份到note owner中
|
||||
func (c File) PasteImage(noteId string) revel.Result {
|
||||
re := c.uploadImage("pasteImage", "");
|
||||
|
||||
userId := c.GetUserId()
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.UserId != "" {
|
||||
noteUserId := note.UserId.Hex()
|
||||
if noteUserId != userId {
|
||||
// 是否是有权限协作的
|
||||
if shareService.HasUpdatePerm(noteUserId, userId, noteId) {
|
||||
// 复制图片之, 图片复制给noteUserId
|
||||
_, re.Id = fileService.CopyImage(userId, re.Id, noteUserId)
|
||||
} else {
|
||||
// 怎么可能在这个笔记下paste图片呢?
|
||||
// 正常情况下不会
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// leaui image plugin
|
||||
// leaui image plugin upload image
|
||||
func (c File) UploadImageLeaui(albumId string) revel.Result {
|
||||
re := c.uploadImage("", albumId);
|
||||
re.Id = siteUrl + re.Id
|
||||
// re.Id = re.Id
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// 上传图片, 公用方法
|
||||
// upload image common func
|
||||
func (c File) uploadImage(from, albumId string) (re info.Re) {
|
||||
var fileUrlPath = ""
|
||||
var fileId = ""
|
||||
var resultCode = 0 // 1表示正常
|
||||
var resultMsg = "内部错误" // 错误信息
|
||||
var Ok = false
|
||||
|
||||
defer func() {
|
||||
re.Id = fileUrlPath
|
||||
re.Id = fileId // 只是id, 没有其它信息
|
||||
re.Code = resultCode
|
||||
re.Msg = resultMsg
|
||||
re.Ok = Ok
|
||||
@@ -71,11 +97,10 @@ func (c File) uploadImage(from, albumId string) (re info.Re) {
|
||||
}
|
||||
defer file.Close()
|
||||
// 生成上传路径
|
||||
fileUrlPath = "/upload/" + c.GetUserId() + "/images"
|
||||
dir := revel.BasePath + "/public/" + fileUrlPath
|
||||
fileUrlPath = "files/" + c.GetUserId() + "/images"
|
||||
dir := revel.BasePath + "/" + fileUrlPath
|
||||
err = os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
Log(err)
|
||||
return re
|
||||
}
|
||||
// 生成新的文件名
|
||||
@@ -126,8 +151,12 @@ func (c File) uploadImage(from, albumId string) (re info.Re) {
|
||||
Path: fileUrlPath,
|
||||
Size: filesize}
|
||||
|
||||
id := bson.NewObjectId();
|
||||
fileInfo.FileId = id
|
||||
fileId = id.Hex()
|
||||
Ok = fileService.AddImage(fileInfo, albumId, c.GetUserId())
|
||||
|
||||
fileInfo.Path = ""; // 不要返回
|
||||
re.Item = fileInfo
|
||||
|
||||
return re
|
||||
@@ -198,3 +227,26 @@ func (c File) UpgradeLeauiImage() revel.Result {
|
||||
re.Msg = msg
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
//-----------
|
||||
|
||||
// 输出image
|
||||
// 权限判断
|
||||
func (c File) OutputImage(noteId, fileId string) revel.Result {
|
||||
path := fileService.GetFile(c.GetUserId(), fileId); // 得到路径
|
||||
if path == "" {
|
||||
return c.RenderText("")
|
||||
}
|
||||
fn := revel.BasePath + "/" + strings.TrimLeft(path, "/")
|
||||
file, _ := os.Open(fn)
|
||||
return c.RenderFile(file, revel.Inline) // revel.Attachment
|
||||
}
|
||||
|
||||
// 协作时复制图片到owner
|
||||
func (c File) CopyImage(userId, fileId, toUserId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
|
||||
re.Ok, re.Id = fileService.CopyImage(userId, fileId, toUserId)
|
||||
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
@@ -117,7 +117,6 @@ type NoteOrContent struct {
|
||||
// 这里不能用json, 要用post
|
||||
func (c Note) UpdateNoteOrContent(noteOrContent NoteOrContent) revel.Result {
|
||||
// 新添加note
|
||||
LogJ(noteOrContent)
|
||||
if noteOrContent.IsNew {
|
||||
userId := c.GetObjectUserId();
|
||||
myUserId := userId
|
||||
|
||||
@@ -25,6 +25,7 @@ var suggestionService *service.SuggestionService
|
||||
|
||||
var albumService *service.AlbumService
|
||||
var fileService *service.FileService
|
||||
var attachService *service.AttachService
|
||||
|
||||
var pageSize = 1000
|
||||
var defaultSortField = "UpdatedTime"
|
||||
@@ -56,12 +57,13 @@ var commonUrl = map[string]map[string]bool{"Index": map[string]bool{"Index": tru
|
||||
"User": map[string]bool{"UpdateEmail": true,
|
||||
"ActiveEmail":true,
|
||||
},
|
||||
"oauth": map[string]bool{"githubCallback": true},
|
||||
"Oauth": map[string]bool{"GithubCallback": true},
|
||||
"File": map[string]bool{"OutputImage": true, "OutputFile": true},
|
||||
}
|
||||
func needValidate(controller, method string) bool {
|
||||
// 在里面
|
||||
if v, ok := commonUrl[controller]; ok {
|
||||
// 不在commonUrl里
|
||||
// 在commonUrl里
|
||||
if _, ok2 := v[method]; ok2 {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -36,6 +36,9 @@ var Suggestions *mgo.Collection
|
||||
// Album & file(image)
|
||||
var Albums *mgo.Collection
|
||||
var Files *mgo.Collection
|
||||
var Attachs *mgo.Collection
|
||||
|
||||
var NoteImages *mgo.Collection
|
||||
|
||||
// 初始化时连接数据库
|
||||
func Init() {
|
||||
@@ -104,6 +107,9 @@ func Init() {
|
||||
// Album & file
|
||||
Albums = Session.DB(dbname).C("albums")
|
||||
Files = Session.DB(dbname).C("files")
|
||||
Attachs = Session.DB(dbname).C("attachs")
|
||||
|
||||
NoteImages = Session.DB(dbname).C("note_images")
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Attach belongs to note
|
||||
type Attach struct {
|
||||
AttachId bson.ObjectId `bson:"_id,omitempty"` //
|
||||
NoteId bson.ObjectId `bson:"NoteId"` //
|
||||
UploadUserId bson.ObjectId `bson:"UploadUserId"` // 可以不是note owner, 协作者userId
|
||||
Name string `Name` // file name, md5, such as 13232312.doc
|
||||
Title string `Title` // raw file name
|
||||
Size int64 `Size` // file size (byte)
|
||||
Type string `Type` // file type, "doc" = word
|
||||
Path string `Path` // the file path such as: files/userId/attachs/adfadf.doc
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
|
||||
// FromFileId bson.ObjectId `bson:"FromFileId,omitempty"` // copy from fileId, for collaboration
|
||||
}
|
||||
@@ -12,8 +12,10 @@ type File struct {
|
||||
Name string `Name` // file name
|
||||
Title string `Title` // file name or user defined for search
|
||||
Size int64 `Size` // file size (byte)
|
||||
Type string `Type` // file type, such as image/jpg
|
||||
Path string `Path` // the file path, based on /upload
|
||||
Type string `Type` // file type, "" = image, "doc" = word
|
||||
Path string `Path` // the file path
|
||||
IsDefaultAlbum bool `IsDefaultAlbum`
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
|
||||
FromFileId bson.ObjectId `bson:"FromFileId,omitempty"` // copy from fileId, for collaboration
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package info
|
||||
|
||||
import (
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
)
|
||||
|
||||
// 笔记内部图片
|
||||
type NoteImage struct {
|
||||
NoteImageId bson.ObjectId `bson:"_id,omitempty"` // 必须要设置bson:"_id" 不然mgo不会认为是主键
|
||||
NoteId bson.ObjectId `bson:"NoteId"` // 笔记
|
||||
ImageId bson.ObjectId `bson:"ImageId"` // 图片fileId
|
||||
}
|
||||
@@ -24,6 +24,8 @@ type Note struct {
|
||||
|
||||
IsMarkdown bool `IsMarkdown` // 是否是markdown笔记, 默认是false
|
||||
|
||||
AttachNum int `AttachNum` // 2014/9/21, attachments num
|
||||
|
||||
CreatedTime time.Time `CreatedTime`
|
||||
UpdatedTime time.Time `UpdatedTime`
|
||||
UpdatedUserId bson.ObjectId `bson:"UpdatedUserId"` // 如果共享了, 并可写, 那么可能是其它他修改了
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"os"
|
||||
"io"
|
||||
)
|
||||
|
||||
// 分离文件名与扩展名(包含.)
|
||||
@@ -63,3 +64,17 @@ func ListDir(dir string) []string {
|
||||
names, _ := f.Readdirnames(0)
|
||||
return names
|
||||
}
|
||||
|
||||
func CopyFile(srcName, dstName string) (written int64, err error) {
|
||||
src, err := os.Open(srcName)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer src.Close()
|
||||
dst, err := os.OpenFile(dstName, os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer dst.Close()
|
||||
return io.Copy(dst, src)
|
||||
}
|
||||
@@ -267,3 +267,15 @@ func RandomPwd(num int) string {
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
func InArray(arr []string, str string) bool {
|
||||
if arr == nil {
|
||||
return false
|
||||
}
|
||||
for _, v := range arr {
|
||||
if v == str {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/revel/revel"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AttachService struct {
|
||||
}
|
||||
|
||||
// add attach
|
||||
func (this *AttachService) AddAttach(attach info.Attach) bool {
|
||||
attach.CreatedTime = time.Now()
|
||||
ok := db.Insert(db.Attachs, attach)
|
||||
|
||||
if ok {
|
||||
// 更新笔记的attachs num
|
||||
this.updateNoteAttachNum(attach.NoteId, 1)
|
||||
}
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// 更新笔记的附件个数
|
||||
// addNum 1或-1
|
||||
func (this *AttachService) updateNoteAttachNum(noteId bson.ObjectId, addNum int) bool {
|
||||
num := db.Count(db.Attachs, bson.M{"NoteId": noteId})
|
||||
/*
|
||||
note := info.Note{}
|
||||
note = noteService.GetNoteById(noteId.Hex())
|
||||
note.AttachNum += addNum
|
||||
if note.AttachNum < 0 {
|
||||
note.AttachNum = 0
|
||||
}
|
||||
Log(note.AttachNum)
|
||||
*/
|
||||
return db.UpdateByQField(db.Notes, bson.M{"_id": noteId}, "AttachNum", num)
|
||||
}
|
||||
|
||||
// list attachs
|
||||
func (this *AttachService) ListAttachs(noteId, userId string) []info.Attach {
|
||||
attachs := []info.Attach{}
|
||||
// 判断是否有权限为笔记添加附件
|
||||
if !shareService.HasUpdateNotePerm(noteId, userId) {
|
||||
return attachs
|
||||
}
|
||||
|
||||
db.ListByQ(db.Attachs, bson.M{"NoteId": bson.ObjectIdHex(noteId)}, &attachs)
|
||||
|
||||
return attachs
|
||||
}
|
||||
|
||||
func (this *AttachService) UpdateImageTitle(userId, fileId, title string) bool {
|
||||
return db.UpdateByIdAndUserIdField(db.Files, fileId, userId, "Title", title)
|
||||
}
|
||||
|
||||
|
||||
// Delete note to delete attas firstly
|
||||
func (this *AttachService) DeleteAllAttachs(noteId, userId string) bool {
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.UserId.Hex() == userId {
|
||||
attachs := []info.Attach{}
|
||||
db.ListByQ(db.Attachs, bson.M{"NoteId": bson.ObjectIdHex(noteId)}, &attachs)
|
||||
for _, attach := range attachs {
|
||||
attach.Path = strings.TrimLeft(attach.Path, "/")
|
||||
os.Remove(revel.BasePath + "/" + attach.Path)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// delete attach
|
||||
func (this *AttachService) DeleteAttach(attachId, userId string) (bool, string) {
|
||||
attach := info.Attach{}
|
||||
db.Get(db.Attachs, attachId, &attach)
|
||||
|
||||
if(attach.AttachId != "") {
|
||||
// 判断是否有权限为笔记添加附件
|
||||
if !shareService.HasUpdateNotePerm(attach.NoteId.Hex(), userId) {
|
||||
return false, "No Perm"
|
||||
}
|
||||
|
||||
if db.Delete(db.Attachs, bson.M{"_id": bson.ObjectIdHex(attachId)}) {
|
||||
this.updateNoteAttachNum(attach.NoteId, -1)
|
||||
attach.Path = strings.TrimLeft(attach.Path, "/")
|
||||
err := os.Remove(revel.BasePath + "/" + attach.Path)
|
||||
if err == nil {
|
||||
return true, "delete file error"
|
||||
}
|
||||
return false, "delete file error"
|
||||
}
|
||||
return false, "db error"
|
||||
}
|
||||
return false, "no such item"
|
||||
}
|
||||
|
||||
// 获取文件路径
|
||||
// 要判断是否具有权限
|
||||
// userId是否具有attach的访问权限
|
||||
func (this *AttachService) GetAttach(attachId, userId string) (attach info.Attach) {
|
||||
if attachId == "" {
|
||||
return
|
||||
}
|
||||
|
||||
attach = info.Attach{}
|
||||
db.Get(db.Attachs, attachId, &attach)
|
||||
path := attach.Path
|
||||
if path == "" {
|
||||
return
|
||||
}
|
||||
|
||||
note := noteService.GetNoteById(attach.NoteId.Hex())
|
||||
|
||||
// 判断权限
|
||||
|
||||
// 笔记是否是公开的
|
||||
if note.IsBlog {
|
||||
return
|
||||
}
|
||||
|
||||
// 笔记是否是我的
|
||||
if note.UserId.Hex() == userId {
|
||||
return
|
||||
}
|
||||
|
||||
// 我是否有权限查看或协作
|
||||
if shareService.HasReadNotePerm(attach.NoteId.Hex(), userId) {
|
||||
return
|
||||
}
|
||||
|
||||
attach = info.Attach{}
|
||||
return
|
||||
}
|
||||
|
||||
// 复制笔记时需要复制附件
|
||||
// noteService调用, 权限已判断
|
||||
func (this *AttachService) CopyAttachs(noteId, toNoteId, toUserId string) bool {
|
||||
attachs := []info.Attach{}
|
||||
db.ListByQ(db.Attachs, bson.M{"NoteId": bson.ObjectIdHex(noteId)}, &attachs)
|
||||
|
||||
// 复制之
|
||||
toNoteIdO := bson.ObjectIdHex(toNoteId)
|
||||
for _, attach := range attachs {
|
||||
attach.AttachId = ""
|
||||
attach.NoteId = toNoteIdO
|
||||
|
||||
// 文件复制一份
|
||||
_, ext := SplitFilename(attach.Name)
|
||||
newFilename := NewGuid() + ext
|
||||
dir := "files/" + toUserId + "/attachs"
|
||||
filePath := dir + "/" + newFilename
|
||||
err := os.MkdirAll(revel.BasePath + "/" + dir, 0755)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
_, err = CopyFile(revel.BasePath + "/" + attach.Path, revel.BasePath + "/" + filePath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
attach.Name = newFilename
|
||||
attach.Path = filePath
|
||||
|
||||
this.AddAttach(attach)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
+124
-2
@@ -1,7 +1,7 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
// . "github.com/leanote/leanote/app/lea"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"github.com/revel/revel"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
@@ -35,7 +35,7 @@ func (this *FileService) ListImagesWithPage(userId, albumId, key string, pageNum
|
||||
skipNum, sortFieldR := parsePageAndSort(pageNumber, pageSize, "CreatedTime", false)
|
||||
files := []info.File{}
|
||||
|
||||
q := bson.M{"UserId": bson.ObjectIdHex(userId)}
|
||||
q := bson.M{"UserId": bson.ObjectIdHex(userId), "Type": ""} // life
|
||||
if albumId != "" {
|
||||
q["AlbumId"] = bson.ObjectIdHex(albumId);
|
||||
} else {
|
||||
@@ -89,6 +89,7 @@ func (this *FileService) DeleteImage(userId, fileId string) (bool, string) {
|
||||
if(file.FileId != "") {
|
||||
if db.DeleteByIdAndUserId(db.Files, fileId, userId) {
|
||||
// delete image
|
||||
// TODO
|
||||
err := os.Remove(revel.BasePath + "/public/" + file.Path)
|
||||
if err == nil {
|
||||
return true, ""
|
||||
@@ -104,3 +105,124 @@ func (this *FileService) DeleteImage(userId, fileId string) (bool, string) {
|
||||
func (this *FileService) UpdateImage(userId, fileId, title string) bool {
|
||||
return db.UpdateByIdAndUserIdField(db.Files, fileId, userId, "Title", title)
|
||||
}
|
||||
|
||||
// 获取文件路径
|
||||
// 要判断是否具有权限
|
||||
// userId是否具有fileId的访问权限
|
||||
func (this *FileService) GetFile(userId, fileId string) string {
|
||||
if fileId == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
file := info.File{}
|
||||
db.Get(db.Files, fileId, &file)
|
||||
path := file.Path
|
||||
if path == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// 1. 判断权限
|
||||
|
||||
// 是否是我的文件
|
||||
if userId != "" && file.UserId.Hex() == userId {
|
||||
return path
|
||||
}
|
||||
|
||||
// 得到使用过该fileId的所有笔记NoteId
|
||||
// 这些笔记是否有public的, 若有则ok
|
||||
// 这些笔记(笔记本)是否有共享给我的, 若有则ok
|
||||
|
||||
noteIds := noteImageService.GetNoteIds(fileId)
|
||||
if noteIds != nil && len(noteIds) > 0 {
|
||||
// 这些笔记是否有public的
|
||||
if db.Has(db.Notes, bson.M{"_id": bson.M{"$in": noteIds}, "IsBlog": true}) {
|
||||
return path
|
||||
}
|
||||
|
||||
// 若有共享给我的笔记?
|
||||
if db.Has(db.ShareNotes, bson.M{"ToUserId": bson.ObjectIdHex(userId), "NoteId": bson.M{"$in": noteIds}}) {
|
||||
return path
|
||||
}
|
||||
|
||||
// 笔记本是否共享给我?
|
||||
// 通过笔记得到笔记本
|
||||
notes := []info.Note{}
|
||||
db.ListByQWithFields(db.Notes, bson.M{"_id": bson.M{"$in": noteIds}}, []string{"NotebookId"}, ¬es)
|
||||
if notes != nil && len(notes) > 0 {
|
||||
notebookIds := make([]bson.ObjectId, len(notes))
|
||||
for i := 0; i < len(notes); i++ {
|
||||
notebookIds[i] = notes[i].NotebookId
|
||||
}
|
||||
|
||||
if db.Has(db.ShareNotebooks, bson.M{"ToUserId": bson.ObjectIdHex(userId), "NotebookId": bson.M{"$in": notebookIds}}) {
|
||||
return path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 可能是刚复制到owner上, 但内容又没有保存, 所以没有note->imageId的映射, 此时看是否有fromFileId
|
||||
if file.FromFileId != "" {
|
||||
fromFile := info.File{}
|
||||
db.Get2(db.Files, file.FromFileId, &fromFile)
|
||||
if fromFile.UserId.Hex() == userId {
|
||||
return fromFile.Path
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// 复制图片
|
||||
func (this *FileService) CopyImage(userId, fileId, toUserId string) (bool, string) {
|
||||
// 是否已经复制过了
|
||||
file2 := info.File{}
|
||||
db.GetByQ(db.Files, bson.M{"UserId": bson.ObjectIdHex(toUserId), "FromFileId": bson.ObjectIdHex(fileId)}, &file2)
|
||||
if file2.FileId != "" {
|
||||
return true, file2.FileId.Hex();
|
||||
}
|
||||
|
||||
// 复制之
|
||||
|
||||
file := info.File{}
|
||||
db.GetByIdAndUserId(db.Files, fileId, userId, &file)
|
||||
|
||||
if file.FileId == "" || file.UserId.Hex() != userId {
|
||||
return false, ""
|
||||
}
|
||||
|
||||
_, ext := SplitFilename(file.Name)
|
||||
newFilename := NewGuid() + ext
|
||||
|
||||
dir := "files/" + toUserId + "/images"
|
||||
filePath := dir + "/" + newFilename
|
||||
err := os.MkdirAll(dir, 0755)
|
||||
if err != nil {
|
||||
return false, ""
|
||||
}
|
||||
|
||||
_, err = CopyFile(revel.BasePath + "/" + file.Path, revel.BasePath + "/" + filePath)
|
||||
if err != nil {
|
||||
Log(err)
|
||||
return false, ""
|
||||
}
|
||||
|
||||
fileInfo := info.File{Name: newFilename,
|
||||
Title: file.Title,
|
||||
Path: filePath,
|
||||
Size: file.Size,
|
||||
FromFileId: file.FileId}
|
||||
id := bson.NewObjectId();
|
||||
fileInfo.FileId = id
|
||||
fileId = id.Hex()
|
||||
Ok := this.AddImage(fileInfo, "", toUserId)
|
||||
|
||||
if Ok {
|
||||
return Ok, id.Hex()
|
||||
}
|
||||
return false, ""
|
||||
}
|
||||
|
||||
// 是否是我的文件
|
||||
func (this *FileService) IsMyFile(userId, fileId string) bool {
|
||||
return db.Has(db.Files, bson.M{"UserId": bson.ObjectIdHex(userId), "_id": bson.ObjectIdHex(fileId)})
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"regexp"
|
||||
// "time"
|
||||
)
|
||||
|
||||
type NoteImageService struct {
|
||||
}
|
||||
|
||||
// 通过id, userId得到noteIds
|
||||
func (this *NoteImageService) GetNoteIds(imageId string) ([]bson.ObjectId) {
|
||||
noteImages := []info.NoteImage{}
|
||||
db.ListByQWithFields(db.NoteImages, bson.M{"ImageId": bson.ObjectIdHex(imageId)}, []string{"NoteId"}, ¬eImages)
|
||||
|
||||
if noteImages != nil && len(noteImages) > 0 {
|
||||
noteIds := make([]bson.ObjectId, len(noteImages))
|
||||
cnt := len(noteImages)
|
||||
for i := 0; i < cnt; i++ {
|
||||
noteIds[i] = noteImages[i].NoteId
|
||||
}
|
||||
return noteIds
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// 解析内容中的图片, 建立图片与note的关系
|
||||
// <img src="/file/outputImage?fileId=12323232" />
|
||||
// 图片必须是我的, 不然不添加
|
||||
func (this *NoteImageService) UpdateNoteImages(userId, noteId, content string) bool {
|
||||
reg, _ := regexp.Compile("outputImage\\?fileId=([a-z0-9A-Z]{24})")
|
||||
find := reg.FindAllStringSubmatch(content, -1) // 查找所有的
|
||||
|
||||
// 删除旧的
|
||||
db.DeleteAll(db.NoteImages, bson.M{"NoteId": bson.ObjectIdHex(noteId)})
|
||||
|
||||
// 添加新的
|
||||
var fileId string
|
||||
noteImage := info.NoteImage{NoteId: bson.ObjectIdHex(noteId)}
|
||||
hasAdded := make(map[string]bool)
|
||||
if find != nil && len(find) > 0 {
|
||||
for _, each := range find {
|
||||
if each != nil && len(each) == 2 {
|
||||
fileId = each[1]
|
||||
// 之前没能添加过的
|
||||
if _, ok := hasAdded[fileId]; !ok {
|
||||
Log(fileId)
|
||||
// 判断是否是我的文件
|
||||
if fileService.IsMyFile(userId, fileId) {
|
||||
noteImage.ImageId = bson.ObjectIdHex(fileId)
|
||||
db.Insert(db.NoteImages, noteImage)
|
||||
}
|
||||
hasAdded[fileId] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 复制图片, 把note的图片都copy给我, 且修改noteContent图片路径
|
||||
func (this *NoteImageService) CopyNoteImages(fromNoteId, fromUserId, newNoteId, content, toUserId string) string {
|
||||
// 得到fromNoteId的noteImages, 如果为空, 则直接返回content
|
||||
noteImages := []info.NoteImage{}
|
||||
db.ListByQWithFields(db.NoteImages, bson.M{"NoteId": bson.ObjectIdHex(fromNoteId)}, []string{"ImageId"}, ¬eImages)
|
||||
|
||||
if len(noteImages) == 0 {
|
||||
return content;
|
||||
}
|
||||
|
||||
// <img src="/file/outputImage?fileId=12323232" />
|
||||
// 把fileId=1232替换成新的
|
||||
replaceMap := map[string]string{}
|
||||
for _, noteImage := range noteImages {
|
||||
imageId := noteImage.ImageId.Hex()
|
||||
ok, newImageId := fileService.CopyImage(fromUserId, imageId, toUserId)
|
||||
if ok {
|
||||
replaceMap[imageId] = newImageId
|
||||
}
|
||||
}
|
||||
|
||||
if len(replaceMap) > 0 {
|
||||
// 替换之
|
||||
reg, _ := regexp.Compile("outputImage\\?fileId=([a-z0-9A-Z]{24})")
|
||||
content = reg.ReplaceAllStringFunc(content, func(each string) string {
|
||||
// each=outputImage?fileId=541bd2f599c37b4f3r000003
|
||||
fileId := each[len(each)-24:] // 得到后24位, 也即id
|
||||
if replaceFileId, ok := replaceMap[fileId]; ok {
|
||||
return "outputImage?fileId=" + replaceFileId
|
||||
}
|
||||
return each
|
||||
});
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
+39
-10
@@ -17,6 +17,12 @@ func (this *NoteService) GetNote(noteId, userId string) (note info.Note) {
|
||||
db.GetByIdAndUserId(db.Notes, noteId, userId, ¬e)
|
||||
return
|
||||
}
|
||||
// fileService调用
|
||||
func (this *NoteService) GetNoteById(noteId string) (note info.Note) {
|
||||
note = info.Note{}
|
||||
db.Get(db.Notes, noteId, ¬e)
|
||||
return
|
||||
}
|
||||
// 得到blog, blogService用
|
||||
// 不要传userId, 因为是公开的
|
||||
func (this *NoteService) GetBlogNote(noteId string) (note info.Note) {
|
||||
@@ -148,6 +154,10 @@ func (this *NoteService) AddNoteContent(noteContent info.NoteContent) info.NoteC
|
||||
noteContent.UpdatedTime = noteContent.CreatedTime
|
||||
noteContent.UpdatedUserId = noteContent.UserId
|
||||
db.Insert(db.NoteContents, noteContent)
|
||||
|
||||
// 更新笔记图片
|
||||
noteImageService.UpdateNoteImages(noteContent.UserId.Hex(), noteContent.NoteId.Hex(), noteContent.Content)
|
||||
|
||||
return noteContent;
|
||||
}
|
||||
|
||||
@@ -237,11 +247,23 @@ func (this *NoteService) UpdateNoteContent(userId, updatedUserId, noteId, conten
|
||||
Content: content,
|
||||
UpdatedTime: time.Now(),
|
||||
})
|
||||
|
||||
// 更新笔记图片
|
||||
noteImageService.UpdateNoteImages(userId, noteId, content)
|
||||
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// ?????
|
||||
// 这种方式太恶心, 改动很大
|
||||
// 通过content修改笔记的imageIds列表
|
||||
// src="http://localhost:9000/file/outputImage?fileId=541ae75499c37b6b79000005¬eId=541ae63c19807a4bb9000000"
|
||||
func (this *NoteService) updateNoteImages(noteId string, content string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// 更新tags
|
||||
// [ok] [del]
|
||||
func (this *NoteService) UpdateTags(noteId string, userId string, tags []string) bool {
|
||||
@@ -316,9 +338,12 @@ func (this *NoteService) CopyNote(noteId, notebookId, userId string) info.Note {
|
||||
}
|
||||
|
||||
// 复制别人的共享笔记给我
|
||||
// TODO 判断是否共享了给我
|
||||
// 将别人可用的图片转为我的图片, 复制图片
|
||||
func (this *NoteService) CopySharedNote(noteId, notebookId, fromUserId, myUserId string) info.Note {
|
||||
if notebookService.IsMyNotebook(notebookId, myUserId) {
|
||||
Log(shareService.HasSharedNote(noteId, myUserId) || shareService.HasSharedNotebook(noteId, myUserId, fromUserId))
|
||||
// 判断是否共享了给我
|
||||
if notebookService.IsMyNotebook(notebookId, myUserId) &&
|
||||
(shareService.HasSharedNote(noteId, myUserId) || shareService.HasSharedNotebook(noteId, myUserId, fromUserId)) {
|
||||
note := this.GetNote(noteId, fromUserId)
|
||||
if note.NoteId == "" {
|
||||
return info.Note{}
|
||||
@@ -332,10 +357,18 @@ func (this *NoteService) CopySharedNote(noteId, notebookId, fromUserId, myUserId
|
||||
note.IsTop = false
|
||||
note.IsBlog = false // 别人的可能是blog
|
||||
|
||||
note.ImgSrc = "" // 为什么清空, 因为图片需要复制, 先清空
|
||||
|
||||
// content
|
||||
noteContent.NoteId = note.NoteId
|
||||
noteContent.UserId = note.UserId
|
||||
|
||||
// 复制图片, 把note的图片都copy给我, 且修改noteContent图片路径
|
||||
noteContent.Content = noteImageService.CopyNoteImages(noteId, fromUserId, note.NoteId.Hex(), noteContent.Content, myUserId)
|
||||
|
||||
// 复制附件
|
||||
attachService.CopyAttachs(noteId, note.NoteId.Hex(), myUserId)
|
||||
|
||||
// 添加之
|
||||
note = this.AddNoteAndContent(note, noteContent, note.UserId);
|
||||
|
||||
@@ -353,8 +386,10 @@ func (this *NoteService) CopySharedNote(noteId, notebookId, fromUserId, myUserId
|
||||
// shareService call
|
||||
// [ok]
|
||||
func (this *NoteService) GetNotebookId(noteId string) bson.ObjectId {
|
||||
note := &info.Note{}
|
||||
db.Get(db.Notes, noteId, note)
|
||||
note := info.Note{}
|
||||
// db.Get(db.Notes, noteId, ¬e)
|
||||
// LogJ(note)
|
||||
db.GetByQWithFields(db.Notes, bson.M{"_id": bson.ObjectIdHex(noteId)}, []string{"NotebookId"}, ¬e)
|
||||
return note.NotebookId
|
||||
}
|
||||
|
||||
@@ -396,7 +431,6 @@ func (this *NoteService) searchNoteFromContent(notes []info.Note, userId, key st
|
||||
for i, note := range notes {
|
||||
noteIds[i] = note.NoteId
|
||||
}
|
||||
LogJ(noteIds)
|
||||
noteContents := []info.NoteContent{}
|
||||
query := bson.M{"_id": bson.M{"$nin": noteIds}, "UserId": bson.ObjectIdHex(userId), "Content": bson.M{"$regex": bson.RegEx{".*?" + key + ".*", "i"}}}
|
||||
if isBlog {
|
||||
@@ -419,9 +453,6 @@ func (this *NoteService) searchNoteFromContent(notes []info.Note, userId, key st
|
||||
noteIds2[i] = content.NoteId
|
||||
}
|
||||
|
||||
// Log(" content search ")
|
||||
// Log(lenContent)
|
||||
|
||||
// 得到notes
|
||||
notes2 := this.ListNotesByNoteIds(noteIds2)
|
||||
|
||||
@@ -446,8 +477,6 @@ func (this *NoteService) SearchNoteByTags(tags []string, userId string, pageNumb
|
||||
// 总记录数
|
||||
count, _ = q.Count()
|
||||
|
||||
Log(count)
|
||||
|
||||
q.Sort(sortFieldR).
|
||||
Skip(skipNum).
|
||||
Limit(pageSize).
|
||||
|
||||
@@ -3,7 +3,7 @@ package service
|
||||
import (
|
||||
"github.com/leanote/leanote/app/info"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
// . "github.com/leanote/leanote/app/lea"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"time"
|
||||
"sort"
|
||||
@@ -286,6 +286,28 @@ func (this *ShareService) AddShareNote(noteId string, perm int, userId, email st
|
||||
return db.Insert(db.ShareNotes, shareNote), "", toUserId
|
||||
}
|
||||
|
||||
// updatedUserId是否有查看userId noteId的权限?
|
||||
func (this *ShareService) HasReadPerm(userId, updatedUserId, noteId string) bool {
|
||||
if !db.Has(db.ShareNotes,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NoteId": bson.ObjectIdHex(noteId)}) {
|
||||
// noteId的notebookId是否被共享了?
|
||||
notebookId := noteService.GetNotebookId(noteId)
|
||||
if notebookId.Hex() == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 判断notebook是否被共享
|
||||
if !db.Has(db.ShareNotebooks,
|
||||
bson.M{"UserId": bson.ObjectIdHex(userId), "ToUserId": bson.ObjectIdHex(updatedUserId), "NotebookId": notebookId}) {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// updatedUserId是否有修改userId noteId的权限?
|
||||
func (this *ShareService) HasUpdatePerm(userId, updatedUserId, noteId string) bool {
|
||||
// 1. noteId是否被共享了?
|
||||
@@ -334,14 +356,14 @@ func (this *ShareService) AddHasShareNote(userId, toUserId string) bool {
|
||||
}
|
||||
|
||||
// userId是否被共享了noteId
|
||||
func (this *ShareService) hasSharedNote(noteId, myUserId string) bool {
|
||||
func (this *ShareService) HasSharedNote(noteId, myUserId string) bool {
|
||||
return db.Has(db.ShareNotes, bson.M{"ToUserId": bson.ObjectIdHex(myUserId), "NoteId": bson.ObjectIdHex(noteId)})
|
||||
}
|
||||
// noteId的notebook是否共享了给我
|
||||
func (this *ShareService) hasSharedNotebook(noteId, myUserId, sharedUserId string) bool {
|
||||
note := noteService.GetNote(noteId, sharedUserId)
|
||||
if note.NoteId != "" {
|
||||
return db.Has(db.ShareNotebooks, bson.M{"NotebookId": note.NotebookId,
|
||||
func (this *ShareService) HasSharedNotebook(noteId, myUserId, sharedUserId string) bool {
|
||||
notebookId := noteService.GetNotebookId(noteId)
|
||||
if notebookId != "" {
|
||||
return db.Has(db.ShareNotebooks, bson.M{"NotebookId": notebookId,
|
||||
"UserId": bson.ObjectIdHex(sharedUserId),
|
||||
"ToUserId": bson.ObjectIdHex(myUserId),
|
||||
})
|
||||
@@ -355,7 +377,7 @@ func (this *ShareService) GetShareNoteContent(noteId, myUserId, sharedUserId str
|
||||
noteContent = info.NoteContent{}
|
||||
// 是否单独共享了该notebook
|
||||
// 或者, 其notebook共享了我
|
||||
if this.hasSharedNote(noteId, myUserId) || this.hasSharedNotebook(noteId, myUserId, sharedUserId) {
|
||||
if this.HasSharedNote(noteId, myUserId) || this.HasSharedNotebook(noteId, myUserId, sharedUserId) {
|
||||
db.Get(db.NoteContents, noteId, ¬eContent)
|
||||
} else {
|
||||
}
|
||||
@@ -508,3 +530,50 @@ func (this *ShareService) DeleteUserShareNoteAndNotebook(userId, toUserId string
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// 用户userId是否有修改noteId的权限
|
||||
func (this *ShareService) HasUpdateNotePerm(noteId, userId string) bool {
|
||||
if noteId == "" || userId == "" {
|
||||
return false;
|
||||
}
|
||||
note := noteService.GetNoteById(noteId)
|
||||
LogJ(note);
|
||||
if note.UserId != "" {
|
||||
noteUserId := note.UserId.Hex()
|
||||
if noteUserId != userId {
|
||||
// 是否是有权限协作的
|
||||
if this.HasUpdatePerm(noteUserId, userId, noteId) {
|
||||
return true
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 用户userId是否有修改noteId的权限
|
||||
func (this *ShareService) HasReadNotePerm(noteId, userId string) bool {
|
||||
if noteId == "" || userId == "" {
|
||||
return false;
|
||||
}
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.UserId != "" {
|
||||
noteUserId := note.UserId.Hex()
|
||||
if noteUserId != userId {
|
||||
// 是否是有权限协作的
|
||||
if this.HasReadPerm(noteUserId, userId, noteId) {
|
||||
return true
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -53,7 +53,15 @@ func (this *TrashService) recoverNote(noteId, notebookId, userId string) bool {
|
||||
|
||||
// 删除trash
|
||||
func (this *TrashService) DeleteTrash(noteId, userId string) bool {
|
||||
return db.DeleteByIdAndUserId(db.Notes, noteId, userId)
|
||||
// delete note's attachs
|
||||
ok := attachService.DeleteAllAttachs(noteId, userId)
|
||||
|
||||
// delete note
|
||||
ok = db.DeleteByIdAndUserId(db.Notes, noteId, userId)
|
||||
// delete content
|
||||
ok = db.DeleteByIdAndUserId(db.NoteContents, noteId, userId)
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
// 列出note, 排序规则, 还有分页
|
||||
|
||||
@@ -17,6 +17,9 @@ var userService *UserService
|
||||
var tagService *TagService
|
||||
var blogService *BlogService
|
||||
var tokenService *TokenService
|
||||
var noteImageService *NoteImageService
|
||||
var fileService *FileService
|
||||
var attachService *AttachService
|
||||
|
||||
func init() {
|
||||
notebookService = &NotebookService{}
|
||||
@@ -28,4 +31,7 @@ func init() {
|
||||
tagService = &TagService{}
|
||||
blogService = &BlogService{}
|
||||
tokenService = &TokenService{}
|
||||
fileService = &FileService{}
|
||||
attachService = &AttachService{}
|
||||
noteImageService = &NoteImageService{}
|
||||
}
|
||||
@@ -353,6 +353,7 @@ function log(o) {
|
||||
</i>Sort <i class="fa fa-angle-down"></i>
|
||||
-->
|
||||
</a>
|
||||
<!--
|
||||
<ul class="dropdown-menu" role="menu"
|
||||
aria-labelledby="dropdownMenu1"
|
||||
style="right: 3px; ! important; left: -100px; min-width: 100px;">
|
||||
@@ -366,6 +367,7 @@ function log(o) {
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1"
|
||||
href="#">Separated </a></li>
|
||||
</ul>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -466,6 +468,38 @@ function log(o) {
|
||||
<ul class="pull-right" id="editorTool">
|
||||
<li><a class="ios7-a " id="saveBtn" title="ctrl+s"
|
||||
data-toggle="dropdown">{{msg . "save"}}</a></li>
|
||||
|
||||
<li class="dropdown" id="attachDropdown">
|
||||
<a class="ios7-a dropdown-toggle" data-toggle="dropdown" id="showAttach">
|
||||
<!--
|
||||
<span class="fa fa-upload"></span>
|
||||
-->
|
||||
{{msg . "attachments"}}<span id="attachNum"></span>
|
||||
</a>
|
||||
<div class="dropdown-menu" id="attachMenu">
|
||||
<ul id="attachList">
|
||||
</ul>
|
||||
<form id="uploadAttach" method="post" action="/attach/UploadAttach" enctype="multipart/form-data">
|
||||
<div id="dropAttach">
|
||||
<a class="btn btn-success btn-choose-file">
|
||||
Choose File to Upload
|
||||
</a>
|
||||
<a class="btn btn-default" id="downloadAllBtn">
|
||||
<i class="fa fa-download"></i>
|
||||
Download All
|
||||
</a>
|
||||
<a class="btn btn-default" id="linkAllBtn">
|
||||
<i class="fa fa-link"></i>
|
||||
Link All
|
||||
</a>
|
||||
<input type="file" name="file" multiple/>
|
||||
</div>
|
||||
<div id="attachUploadMsg">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li><a class="ios7-a " id="tipsBtn"
|
||||
data-toggle="dropdown">{{msg . "editorTips"}}</a></li>
|
||||
<li><a class="ios7-a " id="contentHistory"
|
||||
@@ -498,7 +532,7 @@ function log(o) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- leaui image -->
|
||||
<!-- leaui image drop image to editor-->
|
||||
<form id="upload" method="post" action="/file/uploadImageLeaui" enctype="multipart/form-data" style="margin-top: 5px;">
|
||||
<div id="drop">
|
||||
Drop images to here
|
||||
@@ -1001,7 +1035,7 @@ initSlimScroll();
|
||||
<!-- context-menu -->
|
||||
<link rel="stylesheet" href="/js/contextmenu/css/contextmenu.css" type="text/css" />
|
||||
|
||||
<!-- version 2.0 -->
|
||||
<!-- js version 2.0 use require.js -->
|
||||
<script src="/js/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
@@ -1009,14 +1043,18 @@ require.config({
|
||||
paths: {
|
||||
// 'jquery': 'js/jquery-1.9.0.min',
|
||||
'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor',
|
||||
'attachment_upload': 'js/app/attachment_upload',
|
||||
'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget',
|
||||
'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload'
|
||||
},
|
||||
shim: {
|
||||
'fileupload': {deps: ['jquery.ui.widget']}
|
||||
}
|
||||
});
|
||||
require(['leaui_image'], function(leaui_image) {
|
||||
});
|
||||
require(['attachment_upload'], function(attachment_upload) {
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -353,6 +353,7 @@ function log(o) {
|
||||
</i>Sort <i class="fa fa-angle-down"></i>
|
||||
-->
|
||||
</a>
|
||||
<!--
|
||||
<ul class="dropdown-menu" role="menu"
|
||||
aria-labelledby="dropdownMenu1"
|
||||
style="right: 3px; ! important; left: -100px; min-width: 100px;">
|
||||
@@ -366,6 +367,7 @@ function log(o) {
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1"
|
||||
href="#">Separated </a></li>
|
||||
</ul>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -466,6 +468,38 @@ function log(o) {
|
||||
<ul class="pull-right" id="editorTool">
|
||||
<li><a class="ios7-a " id="saveBtn" title="ctrl+s"
|
||||
data-toggle="dropdown">{{msg . "save"}}</a></li>
|
||||
|
||||
<li class="dropdown" id="attachDropdown">
|
||||
<a class="ios7-a dropdown-toggle" data-toggle="dropdown" id="showAttach">
|
||||
<!--
|
||||
<span class="fa fa-upload"></span>
|
||||
-->
|
||||
{{msg . "attachments"}}<span id="attachNum"></span>
|
||||
</a>
|
||||
<div class="dropdown-menu" id="attachMenu">
|
||||
<ul id="attachList">
|
||||
</ul>
|
||||
<form id="uploadAttach" method="post" action="/attach/UploadAttach" enctype="multipart/form-data">
|
||||
<div id="dropAttach">
|
||||
<a class="btn btn-success btn-choose-file">
|
||||
Choose File to Upload
|
||||
</a>
|
||||
<a class="btn btn-default" id="downloadAllBtn">
|
||||
<i class="fa fa-download"></i>
|
||||
Download All
|
||||
</a>
|
||||
<a class="btn btn-default" id="linkAllBtn">
|
||||
<i class="fa fa-link"></i>
|
||||
Link All
|
||||
</a>
|
||||
<input type="file" name="file" multiple/>
|
||||
</div>
|
||||
<div id="attachUploadMsg">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<li><a class="ios7-a " id="tipsBtn"
|
||||
data-toggle="dropdown">{{msg . "editorTips"}}</a></li>
|
||||
<li><a class="ios7-a " id="contentHistory"
|
||||
@@ -498,7 +532,7 @@ function log(o) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- leaui image -->
|
||||
<!-- leaui image drop image to editor-->
|
||||
<form id="upload" method="post" action="/file/uploadImageLeaui" enctype="multipart/form-data" style="margin-top: 5px;">
|
||||
<div id="drop">
|
||||
Drop images to here
|
||||
@@ -982,7 +1016,7 @@ initSlimScroll();
|
||||
<link href="/public/mdeditor/editor/editor.css" rel="stylesheet">
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Converter-min.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Sanitizer-min.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Editor-min.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/Markdown.Editor.js"></script>
|
||||
<script src="/public/mdeditor/editor/pagedown/local/Markdown.local.zh-min.js"></script>
|
||||
<script src="/public/mdeditor/editor/Markdown.Extra-min.js"></script>
|
||||
<script src="/public/mdeditor/editor/underscore-min.js"></script>
|
||||
@@ -1001,7 +1035,7 @@ initSlimScroll();
|
||||
<!-- context-menu -->
|
||||
<link rel="stylesheet" href="/js/contextmenu/css/contextmenu.css" type="text/css" />
|
||||
|
||||
<!-- version 2.0 -->
|
||||
<!-- js version 2.0 use require.js -->
|
||||
<script src="/js/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
@@ -1009,14 +1043,18 @@ require.config({
|
||||
paths: {
|
||||
// 'jquery': 'js/jquery-1.9.0.min',
|
||||
'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor',
|
||||
'attachment_upload': 'js/app/attachment_upload',
|
||||
'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget',
|
||||
'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload'
|
||||
},
|
||||
shim: {
|
||||
'fileupload': {deps: ['jquery.ui.widget']}
|
||||
}
|
||||
});
|
||||
require(['leaui_image'], function(leaui_image) {
|
||||
});
|
||||
require(['attachment_upload'], function(attachment_upload) {
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -132,5 +132,8 @@ discussion=Discussion
|
||||
download=Download
|
||||
howToInstallLeanote=How to install leanote
|
||||
|
||||
#
|
||||
attachments = Attachments
|
||||
|
||||
# error
|
||||
notFound=This page cann't found.
|
||||
@@ -136,6 +136,9 @@ discussion=社区讨论
|
||||
download=下载
|
||||
howToInstallLeanote=leanote安装步骤
|
||||
|
||||
#
|
||||
attachments = 附件
|
||||
|
||||
|
||||
# 必须要加这个, 奇怪
|
||||
[CN]
|
||||
@@ -38,6 +38,13 @@
|
||||
|
||||
/*"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, "Microsoft Yahei", Verdana, Simsun, "Segoe UI", "Segoe UI Web Regular", "Segoe UI Symbol", "BBAlpha Sans", "S60 Sans", Arial, sans-serif;*/
|
||||
|
||||
.btn {
|
||||
border-radius: 2px;
|
||||
}
|
||||
.alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#logo {
|
||||
font-family: "leanoteregular";
|
||||
font-size: 36px;
|
||||
@@ -320,3 +327,97 @@
|
||||
.ztree {
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
// leaui image drop drag
|
||||
#upload {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
#upload #drop {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 100px;
|
||||
}
|
||||
#drop.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#drop.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#uploadMsg {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
bottom: 10px;
|
||||
overflow: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
// upload attach
|
||||
#uploadAttach {
|
||||
position: relative;
|
||||
margin-top: 5px;
|
||||
}
|
||||
#dropAttach {
|
||||
text-align: center;
|
||||
input {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
#dropAttach.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#dropAttach.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
|
||||
#attachUploadMsg{
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-height: 240px;
|
||||
overflow: scroll;
|
||||
z-index: 3;
|
||||
.alert {
|
||||
margin: 0;
|
||||
padding: 0 3px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
#attachMenu {
|
||||
width: 450px;
|
||||
padding: 10px 5px;
|
||||
}
|
||||
#attachList {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-height: 450px;
|
||||
overflow-y: scroll;
|
||||
li {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0 3px;
|
||||
border-radius: 3px;
|
||||
border-bottom: 1px dashed #eee;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
div {
|
||||
float: left;
|
||||
}
|
||||
.attach-title {
|
||||
width: 300px;
|
||||
white-space: nowrap;text-overflow:ellipsis; overflow:hidden;
|
||||
}
|
||||
.attach-process {
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@
|
||||
font-style: normal;
|
||||
}
|
||||
/*"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, "Microsoft Yahei", Verdana, Simsun, "Segoe UI", "Segoe UI Web Regular", "Segoe UI Symbol", "BBAlpha Sans", "S60 Sans", Arial, sans-serif;*/
|
||||
.btn {
|
||||
border-radius: 2px;
|
||||
}
|
||||
.alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#logo {
|
||||
font-family: "leanoteregular";
|
||||
font-size: 36px;
|
||||
@@ -285,6 +291,96 @@
|
||||
.ztree {
|
||||
padding: 0px;
|
||||
}
|
||||
#upload {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
#upload #drop {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 100px;
|
||||
}
|
||||
#drop.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#drop.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#uploadMsg {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
bottom: 10px;
|
||||
overflow: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
#uploadAttach {
|
||||
position: relative;
|
||||
margin-top: 5px;
|
||||
}
|
||||
#dropAttach {
|
||||
text-align: center;
|
||||
}
|
||||
#dropAttach input {
|
||||
display: none;
|
||||
}
|
||||
#dropAttach.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#dropAttach.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#attachUploadMsg {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-height: 240px;
|
||||
overflow: scroll;
|
||||
z-index: 3;
|
||||
}
|
||||
#attachUploadMsg .alert {
|
||||
margin: 0;
|
||||
padding: 0 3px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
#attachMenu {
|
||||
width: 450px;
|
||||
padding: 10px 5px;
|
||||
}
|
||||
#attachList {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
max-height: 450px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
#attachList li {
|
||||
display: block;
|
||||
margin: 0;
|
||||
padding: 0 3px;
|
||||
border-radius: 3px;
|
||||
border-bottom: 1px dashed #eee;
|
||||
height: 45px;
|
||||
line-height: 45px;
|
||||
}
|
||||
#attachList li div {
|
||||
float: left;
|
||||
}
|
||||
#attachList li .attach-title {
|
||||
width: 300px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
}
|
||||
#attachList li .attach-process {
|
||||
float: right;
|
||||
}
|
||||
::selection {
|
||||
background: #000000;
|
||||
color: #ffffff;
|
||||
@@ -1265,12 +1361,6 @@ background-position:-1px -670px
|
||||
.tab-pane {
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
.alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.btn {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
#notebookNavForNewNote li,
|
||||
#notebookNavForNewSharedNote > li {
|
||||
padding-left: 0;
|
||||
@@ -1313,36 +1403,6 @@ background-position:-1px -670px
|
||||
#toggleEditorMode {
|
||||
margin: 0 10px !important;
|
||||
}
|
||||
#upload {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
#upload #drop {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 100px;
|
||||
}
|
||||
#drop.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#drop.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#uploadMsg {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
bottom: 10px;
|
||||
overflow: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
#searchNotebookForList {
|
||||
color: #ccc;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
@@ -1075,13 +1075,6 @@ background-position:-1px -670px
|
||||
.tab-pane {
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
.alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.mce-container-body iframe {
|
||||
//overflow-x: hidden; // firefox 不能要
|
||||
@@ -1137,38 +1130,6 @@ background-position:-1px -670px
|
||||
margin: 0 10px !important;
|
||||
}
|
||||
|
||||
// leaui image drop drag
|
||||
#upload {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
#upload #drop {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 100px;
|
||||
}
|
||||
#drop.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#drop.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#uploadMsg {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
bottom: 10px;
|
||||
overflow: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
//----------------------
|
||||
#searchNotebookForList {
|
||||
color: #ccc;
|
||||
|
||||
@@ -1 +1 @@
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:30px}.notebook-setting:before{content:"\f013"}.ztLine truncated
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}.btn{border-radius:2px}.alert{margin-bottom:10px}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:Line truncated
|
||||
@@ -1024,13 +1024,7 @@ background-position:-1px -670px
|
||||
.tab-pane {
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
.alert {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.mce-container-body iframe {
|
||||
//overflow-x: hidden;
|
||||
@@ -1087,37 +1081,6 @@ background-position:-1px -670px
|
||||
}
|
||||
|
||||
|
||||
// leaui image drop drag
|
||||
#upload {
|
||||
position: absolute;
|
||||
z-index: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0px;
|
||||
padding: 0;
|
||||
background-color: #fff;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
#upload #drop {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding-top: 100px;
|
||||
}
|
||||
#drop.in {
|
||||
border: 1px solid #000000;
|
||||
}
|
||||
#drop.hover {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#uploadMsg {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 3px;
|
||||
bottom: 10px;
|
||||
overflow: scroll;
|
||||
list-style: none;
|
||||
}
|
||||
#notebookList {
|
||||
border-top: 1px dashed #eee;
|
||||
}
|
||||
@@ -1 +1 @@
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:30px}.notebook-setting:before{content:"\f013"}.ztLine truncated
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}.btn{border-radius:2px}.alert{margin-bottom:10px}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:Line truncated
|
||||
@@ -1 +1 @@
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:30px}.notebook-setting:before{content:"\f013"}.ztLine truncated
|
||||
@font-face{font-family:'Open Sans';font-style:normal;font-weight:300;src:local('Open Sans Light'),local('OpenSans-Light'),url(../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:400;src:local('Open Sans'),local('OpenSans'),url(../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:normal;font-weight:700;src:local('Open Sans Bold'),local('OpenSans-Bold'),url(../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff) format('woff')}@font-face{font-family:'Open Sans';font-style:italic;font-weight:400;src:local('Open Sans Italic'),local('OpenSans-Italic'),url(../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff) format('woff')}@font-face{font-family:leanoteregular;src:url(../../fonts/leanote/leanote-regular-webfont.eot);src:url(../../fonts/leanote/leanote-regular-webfont.eot?#iefix) format('embedded-opentype'),url(../../fonts/leanote/leanote-regular-webfont.woff) format('woff'),url(../../fonts/leanote/leanote-regular-webfont.ttf) format('truetype'),url(../../fonts/leanote/leanote-regular-webfont.svg#leanoteregular) format('svg');font-weight:400;font-style:normal}.btn{border-radius:2px}.alert{margin-bottom:10px}#logo{font-family:leanoteregular;font-size:36px}#logo:before{content:"a"}#switcher span{font-family:leanoteregular;border-radius:5px;display:inline-block;cursor:pointer;font-size:18px;height:34px;line-height:34px;margin-top:8px;padding:0 5px}#switcher span:before{content:"b"}.dropdown-menu{border-radius:3px;margin:0;border:1px solid #0fb264;box-shadow:rgba(0,0,0,.172549)0 6px 12px 0}.dropdown-menu li{list-style:none;padding-left:10px;width:100%;height:30px;line-height:30px}.dropdown-menu li>a{color:#000;display:block;padding-right:20px}.dropdown-menu>li>a{padding:3px 20px 3px 0}#notebookNavForNewNote li:hover{background:0 0}#noteList{position:absolute;bottom:0;top:0}.dropdown-submenu{position:relative}.dropdown-submenu>ul.dropdown-menu{top:0;left:100%;margin-left:-3px!important;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding-top:10px!important}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropdown-submenu:after{display:block;content:" ";position:absolute;right:0;top:10px;width:0;height:0;border-color:transparent;border-style:solid;border-width:5px 0 5px 5px;border-left-color:#666}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.open>.dropdown-menu,.dropdown-submenu:hover>.dropdown-menu{opacity:1;transform:scale(1,1);-webkit-transform:scale(1,1);-moz-transform:scale(1,1);-o-transform:scale(1,1)}.dropdown-menu{opacity:0;display:block;-webkit-transform:scale(0,0);-webkit-transform-origin:top;-webkit-animation-fill-mode:forwards;-webkit-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-o-transform:scale(0,0);-o-transform-origin:top;-o-animation-fill-mode:forwards;-o-transition:all .2s cubic-bezier(0.34,1.21,.4,1);-moz-transform:scale(0,0);-moz-transform-origin:top;-moz-animation-fill-mode:forwards;-moz-transition:all .2s cubic-bezier(0.34,1.21,.4,1);transform:scale(0,0);transform-origin:top;animation-fill-mode:forwards;transition:all .2s cubic-bezier(0.34,1.21,.4,1)}.dropdown-list{width:530px;border-radius:3px}.dropdown-list ul{margin:0;padding:0}.dropdown-list ul li{float:left;width:120px;margin-left:10px;margin-bottom:10px;border:1px dashed #ccc}.new-note-right{padding:0 5px;padding-left:3px}#leanoteMsg{line-height:40px;margin-top:10px;margin-left:10px}#newNoteWrap{line-height:40px;margin-top:10px}#searchNotebookForAddDropdownList{left:-200px}#searchNotebookForAdd{line-height:normal;width:200px;margin:0 10px;margin-bottom:10px;height:30px;border-color:#ebeff2;box-shadow:none}#myNotebooks .folderBody{padding-top:3px}#searchNotebookForList{height:30px;width:90%;margin:3px auto;margin-top:0;border-color:#ebeff2;box-shadow:none}#noteItemList .item-setting,#noteItemList .item-blog{position:absolute;right:1px;font-size:10px;z-index:2;padding:3px;border-radius:5px;cursor:pointer;width:20px;text-align:center;opacity:.5;background-color:#464C5E}#noteItemList .item-setting .fa,#noteItemList .item-blog .fa{color:#fff!important}#noteItemList .item-setting:hover,#noteItemList .item-blog:hover{opacity:.8}#noteItemList .item-blog{top:1px}#noteItemList .item-setting{bottom:0;display:none}#noteItemList .item:hover .item-setting{display:block}.friend-header{position:relative}.friend-header .notebook-setting{display:none}.friend-header:hover .notebook-setting{display:block}.each-user{margin-bottom:5px;margin-left:5px;margin-right:5px;margin-top:3px;border:1px solid #eee;border-radius:3px}.notebook-setting{display:none;position:absolute;right:3px;top:0;bottom:0;line-height:Line truncated
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{factory(jQuery)}})(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{s=decodeURIComponent(s.replace(pluses," "));return config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==="number"){var days=options.expires,t=options.expires=new Date;t.setTime(+t+days*864e5)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}var result=key?undefined:{};var cookies=document.cookie?document.cookie.split("; "):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split("=");var name=decode(parts.shift());var cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie}}return result};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false}$.cookie(key,"",$.extend({},options,{expires:-1}));return!$.cookie(key)}});if(typeof jQuery==="undefined"){throw new Error("Bootstrap requires jQuery")}+function($){"use strict";function transitionEnd(){var el=document.createElement("bootstrap");var transEndEventNames={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var name in transEndEventNames){if(el.style[name]!==undefined){return{end:transEndEventNames[name]}}}}$.fn.emulateTransitionEnd=function(duration){var called=false,$el=this;$(this).one($.support.transition.end,function(){called=true});var callback=function(){if(!called)$($el).trigger($.support.transition.end)};setTimeout(callback,duration);return this};$(function(){$.support.transition=transitionEnd()})}(jQuery);+function($){"use strict";var dismiss='[data-dismiss="alert"]';var Alert=function(el){$(el).on("click",dismiss,this.close)};Alert.prototype.close=function(e){var $this=$(this);var selector=$this.attr("data-target");if(!selector){selector=$this.attr("href");selector=selector&&selector.replace(/.*(?=#[^\s]*$)/,"")}var $parent=$(selector);if(e)e.preventDefault();if(!$parent.length){$parent=$this.hasClass("alert")?$this:$this.parent()}$parent.trigger(e=$.Event("close.bs.alert"));if(e.isDefaultPrevented())return;$parent.removeClass("in");function removeElement(){$parent.trigger("closed.bs.alert").remove()}$.support.transition&&$parent.hasClass("fade")?$parent.one($.support.transition.end,removeElement).emulateTransitionEnd(150):removeElement()};var old=$.fn.alert;$.fn.alert=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.alert");if(!data)$this.data("bs.alert",data=new Alert(this));if(typeof option=="string")data[option].call($this)})};$.fn.alert.Constructor=Alert;$.fn.alert.noConflict=function(){$.fn.alert=old;return this};$(document).on("click.bs.alert.data-api",dismiss,Alert.prototype.close)}(jQuery);+function($){"use strict";var Button=function(element,options){this.$element=$(element);this.options=$.extend({},Button.DEFAULTS,options)};Button.DEFAULTS={loadingText:"loading..."};Button.prototype.setState=function(state){var d="disabled";var $el=this.$element;var val=$el.is("input")?"val":"html";var data=$el.data();state=state+"Text";if(!data.resetText)$el.data("resetText",$el[val]());$el[val](data[state]||this.options[state]);setTimeout(function(){state=="loadingText"?$el.addClass(d).attr(d,d):$el.removeClass(d).removeAttr(d)},0)};Button.prototype.toggle=function(){var $parent=this.$element.closest('[data-toggle="buttons"]');if($parent.length){var $input=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");if($input.prop("type")==="radio")$parent.find(".active").removeClass("active")}this.$element.toggleClass("active")};var old=$.fn.button;$.fn.button=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.button");var options=typeof option=="object"&&option;if(!data)$this.data("bs.button",data=new Button(this,options));if(option=="toggle")data.toggle();else if(option)data.setState(option)})};$.fn.button.Constructor=Button;$.fn.button.noConflict=function(){$.fn.button=old;return this};$(document).on("click.bs.button.data-api","[data-toggle^=button]",function(e){var $btn=$(Line truncated
|
||||
})};$.fn.tab.Constructor=Tab;$.fn.tab.noConflict=function(){$.fn.tab=old;return this};$(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault();$(this).tab("show")})}(jQuery);+function($){"use strict";var Affix=function(element,options){this.options=$.extend({},Affix.DEFAULTS,options);this.$window=$(window).on("scroll.bs.affix.data-api",$.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",$.proxy(this.checkPositionWithEventLoop,this));this.$element=$(element);this.affixed=this.unpin=null;this.checkPosition()};Affix.RESET="affix affix-top affix-bottom";Affix.DEFAULTS={offset:0};Affix.prototype.checkPositionWithEventLoop=function(){setTimeout($.proxy(this.checkPosition,this),1)};Affix.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var scrollHeight=$(document).height();var scrollTop=this.$window.scrollTop();var position=this.$element.offset();var offset=this.options.offset;var offsetTop=offset.top;var offsetBottom=offset.bottom;if(typeof offset!="object")offsetBottom=offsetTop=offset;if(typeof offsetTop=="function")offsetTop=offset.top();if(typeof offsetBottom=="function")offsetBottom=offset.bottom();var affix=this.unpin!=null&&scrollTop+this.unpin<=position.top?false:offsetBottom!=null&&position.top+this.$element.height()>=scrollHeight-offsetBottom?"bottom":offsetTop!=null&&scrollTop<=offsetTop?"top":false;if(this.affixed===affix)return;if(this.unpin)this.$element.css("top","");this.affixed=affix;this.unpin=affix=="bottom"?position.top-scrollTop:null;this.$element.removeClass(Affix.RESET).addClass("affix"+(affix?"-"+affix:""));if(affix=="bottom"){this.$element.offset({top:document.body.offsetHeight-offsetBottom-this.$element.height()})}};var old=$.fn.affix;$.fn.affix=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.affix");var options=typeof option=="object"&&option;if(!data)$this.data("bs.affix",data=new Affix(this,options));if(typeof option=="string")data[option]()})};$.fn.affix.Constructor=Affix;$.fn.affix.noConflict=function(){$.fn.affix=old;return this};$(window).on("load",function(){$('[data-spy="affix"]').each(function(){var $spy=$(this);var data=$spy.data();data.offset=data.offset||{};if(data.offsetBottom)data.offset.bottom=data.offsetBottom;if(data.offsetTop)data.offset.top=data.offsetTop;$spy.affix(data)})})}(jQuery);var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failLine truncated
|
||||
})};$.fn.tab.Constructor=Tab;$.fn.tab.noConflict=function(){$.fn.tab=old;return this};$(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(e){e.preventDefault();$(this).tab("show")})}(jQuery);+function($){"use strict";var Affix=function(element,options){this.options=$.extend({},Affix.DEFAULTS,options);this.$window=$(window).on("scroll.bs.affix.data-api",$.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",$.proxy(this.checkPositionWithEventLoop,this));this.$element=$(element);this.affixed=this.unpin=null;this.checkPosition()};Affix.RESET="affix affix-top affix-bottom";Affix.DEFAULTS={offset:0};Affix.prototype.checkPositionWithEventLoop=function(){setTimeout($.proxy(this.checkPosition,this),1)};Affix.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var scrollHeight=$(document).height();var scrollTop=this.$window.scrollTop();var position=this.$element.offset();var offset=this.options.offset;var offsetTop=offset.top;var offsetBottom=offset.bottom;if(typeof offset!="object")offsetBottom=offsetTop=offset;if(typeof offsetTop=="function")offsetTop=offset.top();if(typeof offsetBottom=="function")offsetBottom=offset.bottom();var affix=this.unpin!=null&&scrollTop+this.unpin<=position.top?false:offsetBottom!=null&&position.top+this.$element.height()>=scrollHeight-offsetBottom?"bottom":offsetTop!=null&&scrollTop<=offsetTop?"top":false;if(this.affixed===affix)return;if(this.unpin)this.$element.css("top","");this.affixed=affix;this.unpin=affix=="bottom"?position.top-scrollTop:null;this.$element.removeClass(Affix.RESET).addClass("affix"+(affix?"-"+affix:""));if(affix=="bottom"){this.$element.offset({top:document.body.offsetHeight-offsetBottom-this.$element.height()})}};var old=$.fn.affix;$.fn.affix=function(option){return this.each(function(){var $this=$(this);var data=$this.data("bs.affix");var options=typeof option=="object"&&option;if(!data)$this.data("bs.affix",data=new Affix(this,options));if(typeof option=="string")data[option]()})};$.fn.affix.Constructor=Affix;$.fn.affix.noConflict=function(){$.fn.affix=old;return this};$(window).on("load",function(){$('[data-spy="affix"]').each(function(){var $spy=$(this);var data=$spy.data();data.offset=data.offset||{};if(data.offsetBottom)data.offset.bottom=data.offsetBottom;if(data.offsetTop)data.offset.top=data.offsetTop;$spy.affix(data)})})}(jQuery);var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failLine truncated
|
||||
@@ -0,0 +1,134 @@
|
||||
// upload attachment
|
||||
// 依赖note
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
// var editor = tinymce.activeEditor;
|
||||
// var dom = editor.dom;
|
||||
|
||||
var initUploader = function() {
|
||||
var $msg = $('#attachUploadMsg');
|
||||
|
||||
$('#dropAttach .btn-choose-file').click(function() {
|
||||
// trigger to show file select
|
||||
$(this).parent().find('input').click();
|
||||
});
|
||||
|
||||
// Initialize the jQuery File Upload plugin
|
||||
$('#uploadAttach').fileupload({
|
||||
dataType: 'json',
|
||||
maxFileSize: 210000,
|
||||
// This element will accept file drag/drop uploading
|
||||
dropZone: $('#dropAttach'),
|
||||
formData: function(form) {
|
||||
return [{name: 'noteId', value: Note.curNoteId}] // 传递笔记本过去
|
||||
},
|
||||
// This function is called when a file is added to the queue;
|
||||
// either via the browse button, or via drag/drop:
|
||||
add: function(e, data) {
|
||||
var note = Note.getCurNote();
|
||||
if(!note || note.IsNew) {
|
||||
alert("This note hasn't saved, please save it firstly!")
|
||||
return;
|
||||
}
|
||||
var tpl = $('<div class="alert alert-info"><img class="loader" src="/tinymce/plugins/leaui_image/public/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div>');
|
||||
|
||||
// Append the file name and file size
|
||||
tpl.append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
|
||||
|
||||
// Add the HTML to the UL element
|
||||
tpl.appendTo($msg);
|
||||
data.context = $msg;
|
||||
|
||||
// Automatically upload the file once it is added to the queue
|
||||
var jqXHR;
|
||||
setTimeout(function() {
|
||||
jqXHR = data.submit();
|
||||
}, 0);
|
||||
},
|
||||
|
||||
done: function(e, data) {
|
||||
if (data.result.Ok == true) {
|
||||
data.context.remove();
|
||||
Attach.addAttach(data.result.Item);
|
||||
} else {
|
||||
var re = data.result;
|
||||
data.context.empty();
|
||||
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
|
||||
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
|
||||
data.context.html(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
}
|
||||
$("#uploadAttachMsg").scrollTop(1000);
|
||||
},
|
||||
fail: function(e, data) {
|
||||
data.context.empty();
|
||||
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
|
||||
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
|
||||
data.context.html(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
|
||||
$("#uploadAttachMsg").scrollTop(1000);
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent the default action when a file is dropped on the window
|
||||
$(document).on('drop dragover', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Helper function that formats the file sizes
|
||||
function formatFileSize(bytes) {
|
||||
if (typeof bytes !== 'number') {
|
||||
return '';
|
||||
}
|
||||
if (bytes >= 1000000000) {
|
||||
return (bytes / 1000000000).toFixed(2) + ' GB';
|
||||
}
|
||||
if (bytes >= 1000000) {
|
||||
return (bytes / 1000000).toFixed(2) + ' MB';
|
||||
}
|
||||
return (bytes / 1000).toFixed(2) + ' KB';
|
||||
}
|
||||
|
||||
// drag css
|
||||
$(document).bind('dragover', function (e) {
|
||||
var dropZone = $('#dropAttach'),
|
||||
timeout = window.dropZoneTimeout;
|
||||
if (!timeout) {
|
||||
dropZone.addClass('in');
|
||||
showUpload();
|
||||
} else {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
var found = false,
|
||||
node = e.target;
|
||||
do {
|
||||
if (node === dropZone[0]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
} while (node != null);
|
||||
if (found) {
|
||||
dropZone.addClass('hover');
|
||||
} else {
|
||||
dropZone.removeClass('hover');
|
||||
}
|
||||
window.dropZoneTimeout = setTimeout(function () {
|
||||
window.dropZoneTimeout = null;
|
||||
dropZone.removeClass('in hover');
|
||||
hideUpload();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
initUploader();
|
||||
});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Note.curNoteId="";Note.interval="";Note.itemIsBlog='<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';Note.itemTplNoImg='<div href="#" class="item ?" noteId="?">';Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc" style="right: 0;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.itemTpl='<div href="#" class="item ?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';Note.itemTpl+=Note.itemIsBlog+'<div class="item-desc" style=""><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.newItemTpl='<div href="#" class="item item-active ?" fromUserId="?" noteId="?">';Note.newItemTpl+=Note.itemIsBlog+'<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></div>';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}notes.sort(function(a,b){var t1=a[sortBy];var t2=b[sortBy];if(isAsc){if(t1<t2){return-1}else if(t1>t2){return 1}}else{if(t1<t2){return 1}else if(t1>t2){return-1}}return 0});Note.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNote(ret[0].NoteId)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&$(cacheNote.Content).text()!=contentText){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}var token="ALEALE";content=content.replace(/<\/p>/g,token);content=content.replace(/<\/div>/g,token);content=content.replace(/<\/?.+?>/g," ");pattern=new RegExp(token,"g");content=content.replace(pattern,"<br />");content=content.replace(/<br \/>( *)<br \/>/g,"<br />");content=content.replaLine truncated
|
||||
Note.curNoteId="";Note.interval="";Note.itemIsBlog='<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';Note.itemTplNoImg='<div href="#" class="item ?" noteId="?">';Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc" style="right: 0;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.itemTpl='<div href="#" class="item ?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';Note.itemTpl+=Note.itemIsBlog+'<div class="item-desc" style=""><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.newItemTpl='<div href="#" class="item item-active ?" fromUserId="?" noteId="?">';Note.newItemTpl+=Note.itemIsBlog+'<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></div>';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.getCurNote=function(){var self=this;if(self.curNoteId==""){return null}return self.cache[self.curNoteId]};Note.getNote=function(noteId){var self=this;return self.cache[noteId]};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}notes.sort(function(a,b){var t1=a[sortBy];var t2=b[sortBy];if(isAsc){if(t1<t2){return-1}else if(t1>t2){return 1}}else{if(t1<t2){return 1}else if(t1>t2){return-1}}return 0});Note.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNote(ret[0].NoteId)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&$(cacheNote.Content).text()!=contentText){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}var token="ALEALE";content=content.replace(/<\/p>/g,token);content=content.replace(/<\/div>/g,token);content=Line truncated
|
||||
@@ -71,6 +71,19 @@ Note.setNoteCache = function(content, clear) {
|
||||
}
|
||||
}
|
||||
|
||||
// 得到当前的笔记
|
||||
Note.getCurNote = function() {
|
||||
var self = this;
|
||||
if(self.curNoteId == "") {
|
||||
return null;
|
||||
}
|
||||
return self.cache[self.curNoteId];
|
||||
}
|
||||
Note.getNote = function(noteId) {
|
||||
var self = this;
|
||||
return self.cache[noteId];
|
||||
}
|
||||
|
||||
// 每当有notebookId相应的note改变时都要重新清空之
|
||||
// 并设置该notebookId有值
|
||||
Note.clearCacheByNotebookId = function(notebookId) {
|
||||
@@ -432,6 +445,8 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
Note.renderNoteReadOnly(cacheNote);
|
||||
}
|
||||
|
||||
Attach.renderNoteAttachNum(selectNoteId, true);
|
||||
|
||||
function setContent(ret) {
|
||||
Note.setNoteCache(ret, false);
|
||||
// 把其它信息也带上
|
||||
@@ -695,6 +710,9 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
// 添加到缓存中
|
||||
Note.addNoteCache(note);
|
||||
|
||||
// 清空附件数
|
||||
Attach.clearNoteAttachNum();
|
||||
|
||||
// 是否是为共享的notebook添加笔记, 如果是, 则还要记录fromUserId
|
||||
var newItem = "";
|
||||
|
||||
@@ -1278,8 +1296,209 @@ Note.initContextmenu = function() {
|
||||
Note.contextmenu = $("#noteItemList .item-my").contextmenu(noteListMenu);
|
||||
}
|
||||
|
||||
// 附件
|
||||
// 笔记的附件需要ajax获取
|
||||
// 建一张附件表? attachId, noteId, 其它信息
|
||||
// note里有attach_nums字段记录个数
|
||||
// [ok]
|
||||
var Attach = {
|
||||
loadedNoteAttachs: {}, // noteId => [attch1Info, attach2Info...] // 按笔记
|
||||
attachsMap: {}, // attachId => attachInfo
|
||||
init: function() {
|
||||
var self = this;
|
||||
// 显示attachs
|
||||
$("#showAttach").click(function(){
|
||||
self.renderAttachs(Note.curNoteId);
|
||||
});
|
||||
// 防止点击隐藏
|
||||
self.attachListO.click(function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
// 删除
|
||||
self.attachListO.on("click", ".delete-attach", function(e) {
|
||||
e.stopPropagation();
|
||||
var attachId = $(this).closest('li').data("id");
|
||||
var t = this;
|
||||
if(confirm("Are you sure to delete it ?")) {
|
||||
$(t).button("loading");
|
||||
ajaxPost("/attach/deleteAttach", {attachId: attachId}, function(re) {
|
||||
$(t).button("reset");
|
||||
if(reIsOk(re)) {
|
||||
self.deleteAttach(attachId);
|
||||
} else {
|
||||
alert(re.Msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// 下载
|
||||
self.attachListO.on("click", ".download-attach", function(e) {
|
||||
e.stopPropagation();
|
||||
var attachId = $(this).closest('li').data("id");
|
||||
window.open("/attach/download?attachId=" + attachId);
|
||||
// location.href = "/attach/download?attachId=" + attachId;
|
||||
});
|
||||
// 下载全部
|
||||
self.downloadAllBtnO.click(function() {
|
||||
window.open("/attach/downloadAll?noteId=" + Note.curNoteId);
|
||||
// location.href = "/attach/downloadAll?noteId=" + Note.curNoteId;
|
||||
});
|
||||
|
||||
// make link
|
||||
self.attachListO.on("click", ".link-attach", function(e) {
|
||||
e.stopPropagation();
|
||||
var attachId = $(this).closest('li').data("id");
|
||||
var attach = self.attachsMap[attachId];
|
||||
var src = "/attach/download?attachId=" + attachId;
|
||||
|
||||
if(LEA.isMarkdownEditor() && MarkdownEditor) {
|
||||
MarkdownEditor.insertLink(src, attach.Title);
|
||||
} else {
|
||||
tinymce.activeEditor.insertContent('<a target="_blank" href="' + src + '">' + attach.Title + '</a>');
|
||||
}
|
||||
});
|
||||
|
||||
// make all link
|
||||
self.linkAllBtnO.on("click",function(e) {
|
||||
e.stopPropagation();
|
||||
var note = Note.getCurNote();
|
||||
if(!note) {
|
||||
return;
|
||||
}
|
||||
var src = "/attach/downloadAll?noteId=" + Note.curNoteId
|
||||
var title = note.Title ? note.Title + ".tar.gz" : "all.tar.gz";
|
||||
|
||||
if(LEA.isMarkdownEditor() && MarkdownEditor) {
|
||||
MarkdownEditor.insertLink(src, title);
|
||||
} else {
|
||||
tinymce.activeEditor.insertContent('<a target="_blank" href="' + src + '">' + title + '</a>');
|
||||
}
|
||||
});
|
||||
},
|
||||
attachListO: $("#attachList"),
|
||||
attachNumO: $("#attachNum"),
|
||||
attachDropdownO: $("#attachDropdown"),
|
||||
downloadAllBtnO: $("#downloadAllBtn"),
|
||||
linkAllBtnO: $("#linkAllBtn"),
|
||||
// 添加笔记时
|
||||
clearNoteAttachNum: function() {
|
||||
var self = this;
|
||||
self.attachNumO.html("").hide();
|
||||
},
|
||||
renderNoteAttachNum: function(noteId, needHide) {
|
||||
var self = this;
|
||||
var note = Note.getNote(noteId);
|
||||
if(note.AttachNum) {
|
||||
self.attachNumO.html("(" + note.AttachNum + ")").show();
|
||||
self.downloadAllBtnO.show();
|
||||
self.linkAllBtnO.show();
|
||||
} else {
|
||||
self.attachNumO.hide();
|
||||
self.downloadAllBtnO.hide();
|
||||
self.linkAllBtnO.hide();
|
||||
}
|
||||
|
||||
// 隐藏掉
|
||||
if(needHide) {
|
||||
self.attachDropdownO.removeClass("open");
|
||||
}
|
||||
},
|
||||
_renderAttachs: function(attachs) {
|
||||
var self = this;
|
||||
// foreach 循环之
|
||||
/*
|
||||
<li class="clearfix">
|
||||
<div class="attach-title">leanote官abcefedafadfadfadfadfad方文档.doc</div>
|
||||
<div class="attach-process">
|
||||
<button class="btn btn-sm btn-warning">Delete</button>
|
||||
<button class="btn btn-sm btn-deafult">Download</button>
|
||||
</div>
|
||||
</li>
|
||||
*/
|
||||
var html = "";
|
||||
var attachNum = attachs.length;
|
||||
for(var i = 0; i < attachNum; ++i) {
|
||||
var each = attachs[i];
|
||||
html += '<li class="clearfix" data-id="' + each.AttachId + '">' +
|
||||
'<div class="attach-title">' + each.Title + '</div>' +
|
||||
'<div class="attach-process"> ' +
|
||||
' <button class="btn btn-sm btn-warning delete-attach"><i class="fa fa-trash-o"></i></button> ' +
|
||||
' <button type="button" class="btn btn-sm btn-primary download-attach"><i class="fa fa-download"></i></button> ' +
|
||||
' <button type="button" class="btn btn-sm btn-default link-attach" title="Insert link into content"><i class="fa fa-link"></i></button> ' +
|
||||
'</div>' +
|
||||
'</li>';
|
||||
self.attachsMap[each.AttachId] = each;
|
||||
}
|
||||
self.attachListO.html(html);
|
||||
|
||||
// 设置数量
|
||||
var note = Note.getCurNote();
|
||||
if(note) {
|
||||
note.AttachNum = attachNum;
|
||||
self.renderNoteAttachNum(note.NoteId, false);
|
||||
}
|
||||
},
|
||||
// 渲染noteId的附件
|
||||
// 当点击"附件"时加载,
|
||||
// TODO 判断是否已loaded
|
||||
renderAttachs: function(noteId) {
|
||||
var self = this;
|
||||
if(self.loadedNoteAttachs[noteId]) {
|
||||
self._renderAttachs(self.loadedNoteAttachs[noteId]);
|
||||
return;
|
||||
}
|
||||
// ajax获取noteAttachs
|
||||
ajaxGet("/attach/getAttachs", {noteId: noteId}, function(ret) {
|
||||
var list = [];
|
||||
if(ret.Ok) {
|
||||
list = ret.List;
|
||||
if(!list) {
|
||||
list = [];
|
||||
}
|
||||
}
|
||||
// 添加到缓存中
|
||||
self.loadedNoteAttachs[noteId] = list;
|
||||
self._renderAttachs(list);
|
||||
});
|
||||
},
|
||||
// 添加附件, attachment_upload上传调用
|
||||
addAttach: function(attachInfo) {
|
||||
var self = this;
|
||||
if(!self.loadedNoteAttachs[attachInfo.NoteId]) {
|
||||
self.loadedNoteAttachs[attachInfo.NoteId] = [];
|
||||
}
|
||||
self.loadedNoteAttachs[attachInfo.NoteId].push(attachInfo);
|
||||
self.renderAttachs(attachInfo.NoteId);
|
||||
},
|
||||
// 删除
|
||||
deleteAttach: function(attachId) {
|
||||
var self = this;
|
||||
var noteId = Note.curNoteId;
|
||||
var attachs = self.loadedNoteAttachs[noteId];
|
||||
for(var i = 0; i < attachs.length; ++i) {
|
||||
if(attachs[i].AttachId == attachId) {
|
||||
// 删除之, 并render之
|
||||
attachs.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
// self.loadedNoteAttachs[noteId] = attachs;
|
||||
self.renderAttachs(noteId);
|
||||
},
|
||||
|
||||
// 下载
|
||||
downloadAttach: function(fileId) {
|
||||
var self = this;
|
||||
},
|
||||
downloadAll: function() {
|
||||
}
|
||||
}
|
||||
|
||||
//------------------- 事件
|
||||
$(function() {
|
||||
// 附件初始化
|
||||
Attach.init();
|
||||
|
||||
//-----------------
|
||||
// for list nav
|
||||
$("#noteItemList").on("click", ".item", function(event) {
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Share.defaultNotebookId="share0";Share.defaultNotebookTitle="Default Share";Share.sharedUserInfos={};Share.userNavs={};Share.notebookCache={};Share.cache={};Share.dialogIsNote=true;Share.setCache=function(note){if(!note||!note.NoteId){return}Share.cache[note.NoteId]=note};Share.getNotebooksForNew=function(userId,notebooks){var self=this;var navForNewNote="";var len=notebooks.length;for(var i=0;i<len;++i){var notebook=notebooks[i];notebook.IsShared=true;notebook.UserId=userId;self.notebookCache[notebook.NotebookId]=notebook;Notebook.cache[notebook.NotebookId]=notebook;var classes="";var subs=false;if(!isEmpty(notebook.Subs)){log(11);log(notebook.Subs);var subs=self.getNotebooksForNew(userId,notebook.Subs);if(subs){classes="dropdown-submenu"}}var eachForNew="";if(notebook.Perm){var eachForNew=t('<li role="presentation" class="clearfix ?" userId="?" notebookId="?"><div class="new-note-left pull-left" title="为该笔记本新建笔记" href="#">?</div><div title="为该笔记本新建markdown笔记" class="new-note-right pull-left">M</div>',classes,userId,notebook.NotebookId,notebook.Title);if(subs){eachForNew+="<ul class='dropdown-menu'>";eachForNew+=subs;eachForNew+="</ul>"}eachForNew+="</li>"}navForNewNote+=eachForNew}return navForNewNote};Share.trees={};Share.renderShareNotebooks=function(sharedUserInfos,shareNotebooks){var self=Share;if(isEmpty(sharedUserInfos)){return}if(!shareNotebooks||typeof shareNotebooks!="object"||shareNotebooks.length<0){return}var $shareNotebooks=$("#shareNotebooks");for(var i in sharedUserInfos){var userInfo=sharedUserInfos[i];var userNotebooksPre=shareNotebooks[userInfo.UserId]||[];userNotebooks=[{NotebookId:self.defaultNotebookId,Title:Share.defaultNotebookTitle}].concat(userNotebooksPre);self.notebookCache[self.defaultNotebookId]=userNotebooks[0];var username=userInfo.Username||userInfo.Email;userInfo.Username=username;Share.sharedUserInfos[userInfo.UserId]=userInfo;var userId=userInfo.UserId;var header=t('<li class="each-user"><div class="friend-header" fromUserId="?"><i class="fa fa-angle-down"></i><span>?</span> <span class="fa notebook-setting" title="setting"></span> </div>',userInfo.UserId,username);var friendId="friendContainer_"+userId;var body='<ul class="friend-notebooks ztree" id="'+friendId+'" fromUserId="'+userId+'"></ul>';$shareNotebooks.append(header+body+"</li>");self.trees[userId]=$.fn.zTree.init($("#"+friendId),Notebook.getTreeSetting(true,true),userNotebooks);self.userNavs[userId]={forNew:self.getNotebooksForNew(userId,userNotebooksPre)};log(self.userNavs)}$(".friend-notebooks").hover(function(){if(!$(this).hasClass("showIcon")){$(this).addClass("showIcon")}},function(){$(this).removeClass("showIcon")});$(".friend-header i").click(function(){var $this=$(this);var $tree=$(this).parent().next();if($tree.is(":hidden")){$tree.slideDown("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-down")}else{$tree.slideUp("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-right")}});var shareNotebookMenu={width:150,items:[{text:"删除共享笔记本",icon:"",faIcon:"fa-trash-o",action:Share.deleteShareNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#shareNotebooks",children:".notebook-item"};function applyrule(menu){return}function beforeContextMenu(){var notebookId=$(this).attr("notebookId");return!Share.isDefaultNotebookId(notebookId)}var menuNotebooks=$("#shareNotebooks").contextmenu(shareNotebookMenu);var shareUserMenu={width:150,items:[{text:"删除所有共享",icon:"",faIcon:"fa-trash-o",action:Share.deleteUserShareNoteAndNotebook}],parent:"#shareNotebooks",children:".friend-header"};var menuUser=$("#shareNotebooks").contextmenu(shareUserMenu);$(".friend-header").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuUser.showMenu(e,$p)});$("#shareNotebooks .notebook-item").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuNotebooks.showMenu(e,$p)})};Share.isDefaultNotebookId=function(notebookId){return Share.defaultNotebookId==notebookId};Share.toggleToSharedNav=function(userId,notebookId){var self=this;$("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title+"("+Share.sharedUserInfos[userId].Username+")");var forNew=Share.userNavs[userId].forNew;if(forNew){$("#notebookNavForNewSharedNote").html(forNew);var curNotebookId="";var curNotebookTitle="";if(Share.notebookCache[notebookId].Perm){curNotebookId=notebookId;curNotebookTitle=Share.notebookCache[notebookId].Title}else{var $f=$("#notebookNavForNewSharedNote li").eq(0);curNotebookId=$f.attr("notebookId");curNotebookTitle=$f.find(".new-note-left").text()}$("#curNotebookForNewSharedNote").html(curNotebookTitle+"("+Share.sharedUserInfos[userId].Username+")");$("#curNotebookForNewSharedNote").attr("notebookId",curNotebookId);$("#curNotebookForNewSharedNote").attr("userId",userId);$("#newSharedNote").show();$("#newMyNLine truncated
|
||||
Share.defaultNotebookId="share0";Share.defaultNotebookTitle="Default Share";Share.sharedUserInfos={};Share.userNavs={};Share.notebookCache={};Share.cache={};Share.dialogIsNote=true;Share.setCache=function(note){if(!note||!note.NoteId){return}Share.cache[note.NoteId]=note};Share.getNotebooksForNew=function(userId,notebooks){var self=this;var navForNewNote="";var len=notebooks.length;for(var i=0;i<len;++i){var notebook=notebooks[i];notebook.IsShared=true;notebook.UserId=userId;self.notebookCache[notebook.NotebookId]=notebook;Notebook.cache[notebook.NotebookId]=notebook;var classes="";var subs=false;if(!isEmpty(notebook.Subs)){log(11);log(notebook.Subs);var subs=self.getNotebooksForNew(userId,notebook.Subs);if(subs){classes="dropdown-submenu"}}var eachForNew="";if(notebook.Perm){var eachForNew=t('<li role="presentation" class="clearfix ?" userId="?" notebookId="?"><div class="new-note-left pull-left" title="为该笔记本新建笔记" href="#">?</div><div title="为该笔记本新建markdown笔记" class="new-note-right pull-left">M</div>',classes,userId,notebook.NotebookId,notebook.Title);if(subs){eachForNew+="<ul class='dropdown-menu'>";eachForNew+=subs;eachForNew+="</ul>"}eachForNew+="</li>"}navForNewNote+=eachForNew}return navForNewNote};Share.trees={};Share.renderShareNotebooks=function(sharedUserInfos,shareNotebooks){var self=Share;if(isEmpty(sharedUserInfos)){return}if(!shareNotebooks||typeof shareNotebooks!="object"||shareNotebooks.length<0){shareNotebooks={}}var $shareNotebooks=$("#shareNotebooks");for(var i in sharedUserInfos){var userInfo=sharedUserInfos[i];var userNotebooksPre=shareNotebooks[userInfo.UserId]||[];userNotebooks=[{NotebookId:self.defaultNotebookId,Title:Share.defaultNotebookTitle}].concat(userNotebooksPre);self.notebookCache[self.defaultNotebookId]=userNotebooks[0];var username=userInfo.Username||userInfo.Email;userInfo.Username=username;Share.sharedUserInfos[userInfo.UserId]=userInfo;var userId=userInfo.UserId;var header=t('<li class="each-user"><div class="friend-header" fromUserId="?"><i class="fa fa-angle-down"></i><span>?</span> <span class="fa notebook-setting" title="setting"></span> </div>',userInfo.UserId,username);var friendId="friendContainer_"+userId;var body='<ul class="friend-notebooks ztree" id="'+friendId+'" fromUserId="'+userId+'"></ul>';$shareNotebooks.append(header+body+"</li>");self.trees[userId]=$.fn.zTree.init($("#"+friendId),Notebook.getTreeSetting(true,true),userNotebooks);self.userNavs[userId]={forNew:self.getNotebooksForNew(userId,userNotebooksPre)};log(self.userNavs)}$(".friend-notebooks").hover(function(){if(!$(this).hasClass("showIcon")){$(this).addClass("showIcon")}},function(){$(this).removeClass("showIcon")});$(".friend-header i").click(function(){var $this=$(this);var $tree=$(this).parent().next();if($tree.is(":hidden")){$tree.slideDown("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-down")}else{$tree.slideUp("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-right")}});var shareNotebookMenu={width:150,items:[{text:"删除共享笔记本",icon:"",faIcon:"fa-trash-o",action:Share.deleteShareNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#shareNotebooks",children:".notebook-item"};function applyrule(menu){return}function beforeContextMenu(){var notebookId=$(this).attr("notebookId");return!Share.isDefaultNotebookId(notebookId)}var menuNotebooks=$("#shareNotebooks").contextmenu(shareNotebookMenu);var shareUserMenu={width:150,items:[{text:"删除所有共享",icon:"",faIcon:"fa-trash-o",action:Share.deleteUserShareNoteAndNotebook}],parent:"#shareNotebooks",children:".friend-header"};var menuUser=$("#shareNotebooks").contextmenu(shareUserMenu);$(".friend-header").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuUser.showMenu(e,$p)});$("#shareNotebooks .notebook-item").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuNotebooks.showMenu(e,$p)})};Share.isDefaultNotebookId=function(notebookId){return Share.defaultNotebookId==notebookId};Share.toggleToSharedNav=function(userId,notebookId){var self=this;$("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title+"("+Share.sharedUserInfos[userId].Username+")");var forNew=Share.userNavs[userId].forNew;if(forNew){$("#notebookNavForNewSharedNote").html(forNew);var curNotebookId="";var curNotebookTitle="";if(Share.notebookCache[notebookId].Perm){curNotebookId=notebookId;curNotebookTitle=Share.notebookCache[notebookId].Title}else{var $f=$("#notebookNavForNewSharedNote li").eq(0);curNotebookId=$f.attr("notebookId");curNotebookTitle=$f.find(".new-note-left").text()}$("#curNotebookForNewSharedNote").html(curNotebookTitle+"("+Share.sharedUserInfos[userId].Username+")");$("#curNotebookForNewSharedNote").attr("notebookId",curNotebookId);$("#curNotebookForNewSharedNote").attr("userId",userId);$("#newSharedNote").show()Line truncated
|
||||
@@ -94,7 +94,7 @@ Share.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
|
||||
}
|
||||
|
||||
if(!shareNotebooks || typeof shareNotebooks != "object" || shareNotebooks.length < 0) {
|
||||
return;
|
||||
shareNotebooks = {};
|
||||
}
|
||||
|
||||
var $shareNotebooks = $("#shareNotebooks");
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failureFunc,async){_ajax("POST",url,param,successFunc,failureFunc,async)}function ajaxPostJson(url,param,successFunc,failureFunc,async){log("-------------------ajaxPostJson:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({url:url,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:async,data:JSON.stringify(param),success:function(ret,stats){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function findParents(target,selector){if($(target).is(selector)){return $(target)}var parents=$(target).parents();for(var i=0;i<parents.length;++i){log(parents.eq(i));if(parents.eq(i).is(selector)){return parents.seq(i)}}return null}function editorIframeTabindex(index){var $i=$("#editorContent_ifr");if($i.size()==0){setTimeout(function(){editorIframeTabindex(index)},100)}else{$i.attr("tabindex",index)}}function switchEditor(isMarkdown){if(!isMarkdown){$("#editor").show();$("#mdEditor").css("z-index",1);editorIframeTabindex(2);$("#wmd-input").attr("tabindex",3);$("#leanoteNav").show()}else{$("#mdEditor").css("z-index",3).show();editorIframeTabindex(3);$("#wmd-input").attr("tabindex",2);$("#leanoteNav").hide()}}var previewToken="<div style='display: none'>FORTOKEN</div>";function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(!isMarkdown){$("#editorContent").html(content);var editor=tinymce.activeEditor;if(editor){editor.setContent(content);editor.undoManager.clear()}else{setTimeout(function(){setEditorContent(content,false)},100)}}else{$("#wmd-input").val(content);$("#wmd-preview").html("");if(!content||preview){$("#wmd-preview").html(preview).css("height","auto");if(ScrollLink){ScrollLink.onPreviewFinished()}}else{if(MarkdownEditor){$("#wmd-preview").html(previewToken+"<div style='text-align:center; padding: 10px 0;'><img src='http://leanote.com/images/loading-24.gif' /> 正在转换...</div>");MarkdownEditor.refreshPreview()}else{setTimeout(function(){setEditorContent(content,true,preview)},200)}}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBody());content.find("pinit").remove();content.find(".thunderpin").remove();content.fLine truncated
|
||||
var LEA={};var Notebook={cache:{}};var Note={cache:{}};var Tag={};var Notebook={};var Share={};var Converter;var MarkdownEditor;var ScrollLink;function trimLeft(str,substr){if(!substr||substr==" "){return $.trim(str)}while(str.indexOf(substr)==0){str=str.substring(substr.length)}return str}function json(str){return eval("("+str+")")}function t(){var args=arguments;if(args.length<=1){return args[0]}var text=args[0];if(!text){return text}var pattern="LEAAEL";text=text.replace(/\?/g,pattern);for(var i=1;i<=args.length;++i){text=text.replace(pattern,args[i])}return text}function arrayEqual(a,b){a=a||[];b=b||[];return a.join(",")==b.join(",")}function isArray(obj){return Object.prototype.toString.call(obj)==="[object Array]"}function isEmpty(obj){if(!obj){return true}if(isArray(obj)){if(obj.length==0){return true}}return false}function getFormJsonData(formId){var data=formArrDataToJson($("#"+formId).serializeArray());return data}function formArrDataToJson(arrData){var datas={};var arrObj={};for(var i in arrData){var attr=arrData[i].name;var value=arrData[i].value;if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function formSerializeDataToJson(formSerializeData){var arr=formSerializeData.split("&");var datas={};var arrObj={};for(var i=0;i<arr.length;++i){var each=arr[i].split("=");var attr=decodeURI(each[0]);var value=decodeURI(each[1]);if(attr.substring(attr.length-2,attr.length)=="[]"){attr=attr.substring(0,attr.length-2);if(arrObj[attr]==undefined){arrObj[attr]=[value]}else{arrObj[attr].push(value)}continue}datas[attr]=value}return $.extend(datas,arrObj)}function _ajaxCallback(ret,successFunc,failureFunc){if(ret===true||ret=="true"||typeof ret=="object"){if(ret&&typeof ret=="object"){if(ret.Msg=="NOTLOGIN"){alert("你还没有登录, 请先登录!");return}}if(typeof successFunc=="function"){successFunc(ret)}}else{if(typeof failureFunc=="function"){failureFunc(ret)}else{alert("error!")}}}function _ajax(type,url,param,successFunc,failureFunc,async){log("-------------------ajax:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({type:type,url:url,data:param,async:async,success:function(ret){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function ajaxGet(url,param,successFunc,failureFunc,async){_ajax("GET",url,param,successFunc,failureFunc,async)}function ajaxPost(url,param,successFunc,failureFunc,async){_ajax("POST",url,param,successFunc,failureFunc,async)}function ajaxPostJson(url,param,successFunc,failureFunc,async){log("-------------------ajaxPostJson:");log(url);log(param);if(typeof async=="undefined"){async=true}else{async=false}$.ajax({url:url,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:async,data:JSON.stringify(param),success:function(ret,stats){_ajaxCallback(ret,successFunc,failureFunc)},error:function(ret){_ajaxCallback(ret,successFunc,failureFunc)}})}function findParents(target,selector){if($(target).is(selector)){return $(target)}var parents=$(target).parents();for(var i=0;i<parents.length;++i){log(parents.eq(i));if(parents.eq(i).is(selector)){return parents.seq(i)}}return null}function editorIframeTabindex(index){var $i=$("#editorContent_ifr");if($i.size()==0){setTimeout(function(){editorIframeTabindex(index)},100)}else{$i.attr("tabindex",index)}}LEA.isM=false;LEA.isMarkdownEditor=function(){return LEA.isM};function switchEditor(isMarkdown){LEA.isM=isMarkdown;if(!isMarkdown){$("#editor").show();$("#mdEditor").css("z-index",1);editorIframeTabindex(2);$("#wmd-input").attr("tabindex",3);$("#leanoteNav").show()}else{$("#mdEditor").css("z-index",3).show();editorIframeTabindex(3);$("#wmd-input").attr("tabindex",2);$("#leanoteNav").hide()}}var previewToken="<div style='display: none'>FORTOKEN</div>";function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(!isMarkdown){$("#editorContent").html(content);var editor=tinymce.activeEditor;if(editor){editor.setContent(content);editor.undoManager.clear()}else{setTimeout(function(){setEditorContent(content,false)},100)}}else{$("#wmd-input").val(content);$("#wmd-preview").html("");if(!content||preview){$("#wmd-preview").html(preview).css("height","auto");if(ScrollLink){ScrollLink.onPreviewFinished()}}else{if(MarkdownEditor){$("#wmd-preview").html(previewToken+"<div style='text-align:center; padding: 10px 0;'><img src='http://leanote.com/images/loading-24.gif' /> 正在转换...</div>");MarkdownEditor.refreshPreview()}else{setTimeout(function(){setEditorContent(content,true,preview)},200)}}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBodyLine truncated
|
||||
@@ -288,7 +288,12 @@ function editorIframeTabindex(index) {
|
||||
}
|
||||
}
|
||||
//切换编辑器
|
||||
LEA.isM = false;
|
||||
LEA.isMarkdownEditor = function() {
|
||||
return LEA.isM;
|
||||
}
|
||||
function switchEditor(isMarkdown) {
|
||||
LEA.isM = isMarkdown;
|
||||
// 富文本永远是2
|
||||
if(!isMarkdown) {
|
||||
$("#editor").show();
|
||||
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
(function(){var util={},position={},ui={},doc=window.document,re=window.RegExp,nav=window.navigator,SETTINGS={lineLength:72},uaSniffed={isIE:/msie/.test(nav.userAgent.toLowerCase()),isIE_5or6:/msie 6/.test(nav.userAgent.toLowerCase())||/msie 5/.test(nav.userAgent.toLowerCase()),isOpera:/opera/.test(nav.userAgent.toLowerCase())};var defaultsStrings={bold:"Strong <strong> Ctrl+B",boldexample:"strong text",italic:"Emphasis <em> Ctrl+I",italicexample:"emphasized text",link:"Hyperlink <a> Ctrl+L",linkdescription:"enter link description here",linkdialog:'<p><b>Insert Hyperlink</b></p><p>http://example.com/ "optional title"</p>',quote:"Blockquote <blockquote> Ctrl+Q",quoteexample:"Blockquote",code:"Code Sample <pre><code> Ctrl+K",codeexample:"enter code here",image:"Image <img> Ctrl+G",imagedescription:"enter image description here",imagedialog:"<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>",olist:"Numbered List <ol> Ctrl+O",ulist:"Bulleted List <ul> Ctrl+U",litem:"List item",heading:"Heading <h1>/<h2> Ctrl+H",headingexample:"Heading",hr:"Horizontal Rule <hr> Ctrl+R",undo:"Undo - Ctrl+Z",redo:"Redo - Ctrl+Y",redomac:"Redo - Ctrl+Shift+Z",help:"Markdown Editing Help"};var imageDefaultText="http://";var linkDefaultText="http://";Markdown.Editor=function(markdownConverter,idPostfix,options){options=options||{};if(typeof options.handler==="function"){options={helpButton:options}}options.strings=options.strings||{};if(options.helpButton){options.strings.help=options.strings.help||options.helpButton.title}var getString=function(identifier){return options.strings[identifier]||defaultsStrings[identifier]};idPostfix=idPostfix||"";var hooks=this.hooks=new Markdown.HookCollection;hooks.addNoop("onPreviewRefresh");hooks.addNoop("postBlockquoteCreation");hooks.addFalse("insertImageDialog");hooks.addFalse("insertLinkDialog");this.getConverter=function(){return markdownConverter};var that=this,panels;this.run=function(previewWrapper){if(panels)return;panels=new PanelCollection(idPostfix);var commandManager=new CommandManager(hooks,getString);var previewManager=new PreviewManager(markdownConverter,panels,function(){hooks.onPreviewRefresh()},previewWrapper);var undoManager,uiManager;if(!/\?noundo/.test(doc.location.href)){undoManager=new UndoManager(function(){previewManager.refresh();if(uiManager)uiManager.setUndoRedoButtonStates()},panels);this.textOperation=function(f){undoManager.setCommandMode();f();that.refreshPreview()}}uiManager=new UIManager(idPostfix,panels,undoManager,previewManager,commandManager,options.helpButton,getString);uiManager.setUndoRedoButtonStates();var forceRefresh=that.refreshPreview=function(){previewManager.refresh(true)};forceRefresh()}};function Chunks(){}Chunks.prototype.findTags=function(startRegex,endRegex){var chunkObj=this;var regex;if(startRegex){regex=util.extendRegExp(startRegex,"","$");this.before=this.before.replace(regex,function(match){chunkObj.startTag=chunkObj.startTag+match;return""});regex=util.extendRegExp(startRegex,"^","");this.selection=this.selection.replace(regex,function(match){chunkObj.startTag=chunkObj.startTag+match;return""})}if(endRegex){regex=util.extendRegExp(endRegex,"","$");this.selection=this.selection.replace(regex,function(match){chunkObj.endTag=match+chunkObj.endTag;return""});regex=util.extendRegExp(endRegex,"^","");this.after=this.after.replace(regex,function(match){chunkObj.endTag=match+chunkObj.endTag;return""})}};Chunks.prototype.trimWhitespace=function(remove){var beforeReplacer,afterReplacer,that=this;if(remove){beforeReplacer=afterReplacer=""}else{beforeReplacer=function(s){that.before+=s;return""};afterReplacer=function(s){that.after=s+that.after;return""}}this.selection=this.selection.replace(/^(\s*)/,beforeReplacer).replace(/(\s*)$/,afterReplacer)};Chunks.prototype.skipLines=function(nLinesBefore,nLinesAfter,findExtraNewlines){if(nLinesBefore===undefined){nLinesBefore=1}if(nLinesAfter===undefined){nLinesAfter=1}nLinesBefore++;nLinesAfter++;var regexText;var replacementText;if(navigator.userAgent.match(/Chrome/)){"X".match(/()./)}this.selection=this.selection.replace(/(^\n*)/,"");this.startTag=this.startTag+re.$1;this.selection=this.selection.replace(/(\n*$)/,"");this.endTag=this.endTag+re.$1;this.startTag=this.startTag.replace(/(^\n*)/,"");this.before=this.before+re.$1;this.endTag=this.endTag.replace(/(\n*$)/,"");this.after=this.after+re.$1;if(this.before){regexText=replacementText="";while(nLinesBefore--){regexText+="\\n?";replacementText+="\n"}if(findExtraNewlines){regexText="\\n*"}this.before=this.before.replace(new re(regexText+"$",""),replacementText)}if(this.after){regexText=replacementText="";while(nLinesAfter--){regexText+="\\n?";replacementText+="\n"}if(findExtraNewlines){regexText="\\n*"}this.after=this.after.replace(new re(regexText,""),replacementText)}};function PanelCollection(postfix){tLine truncated
|
||||
line=lines[i];inChain=inChain&&line.length>0;if(/^>/.test(line)){good=true;if(!inChain&&line.length>1)inChain=true}else if(/^[ \t]*$/.test(line)){good=true}else{good=inChain}if(good){match+=line+"\n"}else{leftOver+=match+line;match="\n"}}if(!/(^|\n)>/.test(match)){leftOver+=match;match=""}}chunk.startTag=match;chunk.before=leftOver;if(chunk.after){chunk.after=chunk.after.replace(/^\n?/,"\n")}chunk.after=chunk.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(totalMatch){chunk.endTag=totalMatch;return""});var replaceBlanksInTags=function(useBracket){var replacement=useBracket?"> ":"";if(chunk.startTag){chunk.startTag=chunk.startTag.replace(/\n((>|\s)*)\n$/,function(totalMatch,markdown){return"\n"+markdown.replace(/^[ ]{0,3}>?[ \t]*$/gm,replacement)+"\n"})}if(chunk.endTag){chunk.endTag=chunk.endTag.replace(/^\n((>|\s)*)\n/,function(totalMatch,markdown){return"\n"+markdown.replace(/^[ ]{0,3}>?[ \t]*$/gm,replacement)+"\n"})}};if(/^(?![ ]{0,3}>)/m.test(chunk.selection)){this.wrap(chunk,SETTINGS.lineLength-2);chunk.selection=chunk.selection.replace(/^/gm,"> ");replaceBlanksInTags(true);chunk.skipLines()}else{chunk.selection=chunk.selection.replace(/^[ ]{0,3}> ?/gm,"");this.unwrap(chunk);replaceBlanksInTags(false);if(!/^(\n|^)[ ]{0,3}>/.test(chunk.selection)&&chunk.startTag){chunk.startTag=chunk.startTag.replace(/\n{0,2}$/,"\n\n")}if(!/(\n|^)[ ]{0,3}>.*$/.test(chunk.selection)&&chunk.endTag){chunk.endTag=chunk.endTag.replace(/^\n{0,2}/,"\n\n")}}chunk.selection=this.hooks.postBlockquoteCreation(chunk.selection);if(!/\n/.test(chunk.selection)){chunk.selection=chunk.selection.replace(/^(> *)/,function(wholeMatch,blanks){chunk.startTag+=blanks;return""})}};commandProto.doCode=function(chunk,postProcessing){var hasTextBefore=/\S[ ]*$/.test(chunk.before);var hasTextAfter=/^[ ]*\S/.test(chunk.after);if(!hasTextAfter&&!hasTextBefore||/\n/.test(chunk.selection)){chunk.before=chunk.before.replace(/[ ]{4}$/,function(totalMatch){chunk.selection=totalMatch+chunk.selection;return""});var nLinesBack=1;var nLinesForward=1;if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(chunk.before)){nLinesBack=0}if(/^\n(\t|[ ]{4,})/.test(chunk.after)){nLinesForward=0}chunk.skipLines(nLinesBack,nLinesForward);if(!chunk.selection){chunk.startTag=" ";chunk.selection=this.getString("codeexample")}else{if(/^[ ]{0,3}\S/m.test(chunk.selection)){if(/\n/.test(chunk.selection))chunk.selection=chunk.selection.replace(/^/gm," ");else chunk.before+=" "}else{chunk.selection=chunk.selection.replace(/^(?:[ ]{4}|[ ]{0,3}\t)/gm,"")}}}else{chunk.trimWhitespace();chunk.findTags(/`/,/`/);if(!chunk.startTag&&!chunk.endTag){chunk.startTag=chunk.endTag="`";if(!chunk.selection){chunk.selection=this.getString("codeexample")}}else if(chunk.endTag&&!chunk.startTag){chunk.before+=chunk.endTag;chunk.endTag=""}else{chunk.startTag=chunk.endTag=""}}};commandProto.doList=function(chunk,postProcessing,isNumberedList){var previousItemsRegex=/(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/;var nextItemsRegex=/^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;var bullet="-";var num=1;var getItemPrefix=function(){var prefix;if(isNumberedList){prefix=" "+num+". ";num++}else{prefix=" "+bullet+" "}return prefix};var getPrefixedItem=function(itemText){if(isNumberedList===undefined){isNumberedList=/^\s*\d/.test(itemText)}itemText=itemText.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(_){return getItemPrefix()});return itemText};chunk.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);if(chunk.before&&!/\n$/.test(chunk.before)&&!/^\n/.test(chunk.startTag)){chunk.before+=chunk.startTag;chunk.startTag=""}if(chunk.startTag){var hasDigits=/\d+[.]/.test(chunk.startTag);chunk.startTag="";chunk.selection=chunk.selection.replace(/\n[ ]{4}/g,"\n");this.unwrap(chunk);chunk.skipLines();if(hasDigits){chunk.after=chunk.after.replace(nextItemsRegex,getPrefixedItem)}if(isNumberedList==hasDigits){return}}var nLinesUp=1;chunk.before=chunk.before.replace(previousItemsRegex,function(itemText){if(/^\s*([*+-])/.test(itemText)){bullet=re.$1}nLinesUp=/[^\n]\n\n[^\n]/.test(itemText)?1:0;return getPrefixedItem(itemText)});if(!chunk.selection){chunk.selection=this.getString("litem")}var prefix=getItemPrefix();var nLinesDown=1;chunk.after=chunk.after.replace(nextItemsRegex,function(itemText){nLinesDown=/[^\n]\n\n[^\n]/.test(itemText)?1:0;return getPrefixedItem(itemText)});chunk.trimWhitespace(true);chunk.skipLines(nLinesUp,nLinesDown,true);chunk.startTag=prefix;var spaces=prefix.replace(/./g," ");this.wrap(chunk,SETTINGS.lineLength-spaces.length);chunk.selection=chunk.selection.replace(/\n/g,"\n"+spaces)};commandProto.doHeading=function(chunk,postProcessing){chunk.selection=chunk.selection.replace(/\s+/g," ");chunk.selection=chunk.selection.replace(/(^\s+|\s+$)/g,"");if(!chunk.selection){chunk.startTag="## ";chunk.selection=this.getString("headingexample");chunk.endTag=" ##";return}var headerLevel=0;cLine truncated
|
||||
(function(){var util={},position={},ui={},doc=window.document,re=window.RegExp,nav=window.navigator,SETTINGS={lineLength:72},uaSniffed={isIE:/msie/.test(nav.userAgent.toLowerCase()),isIE_5or6:/msie 6/.test(nav.userAgent.toLowerCase())||/msie 5/.test(nav.userAgent.toLowerCase()),isOpera:/opera/.test(nav.userAgent.toLowerCase())};var defaultsStrings={bold:"Strong <strong> Ctrl+B",boldexample:"strong text",italic:"Emphasis <em> Ctrl+I",italicexample:"emphasized text",link:"Hyperlink <a> Ctrl+L",linkdescription:"enter link description here",linkdialog:'<p><b>Insert Hyperlink</b></p><p>http://example.com/ "optional title"</p>',quote:"Blockquote <blockquote> Ctrl+Q",quoteexample:"Blockquote",code:"Code Sample <pre><code> Ctrl+K",codeexample:"enter code here",image:"Image <img> Ctrl+G",imagedescription:"enter image description here",imagedialog:"<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br><br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>",olist:"Numbered List <ol> Ctrl+O",ulist:"Bulleted List <ul> Ctrl+U",litem:"List item",heading:"Heading <h1>/<h2> Ctrl+H",headingexample:"Heading",hr:"Horizontal Rule <hr> Ctrl+R",undo:"Undo - Ctrl+Z",redo:"Redo - Ctrl+Y",redomac:"Redo - Ctrl+Shift+Z",help:"Markdown Editing Help"};var imageDefaultText="http://";var linkDefaultText="http://";Markdown.Editor=function(markdownConverter,idPostfix,options){options=options||{};if(typeof options.handler==="function"){options={helpButton:options}}options.strings=options.strings||{};if(options.helpButton){options.strings.help=options.strings.help||options.helpButton.title}var getString=function(identifier){return options.strings[identifier]||defaultsStrings[identifier]};idPostfix=idPostfix||"";var hooks=this.hooks=new Markdown.HookCollection;hooks.addNoop("onPreviewRefresh");hooks.addNoop("postBlockquoteCreation");hooks.addFalse("insertImageDialog");hooks.addFalse("insertLinkDialog");this.getConverter=function(){return markdownConverter};var that=this,panels;this.run=function(previewWrapper){if(panels)return;panels=new PanelCollection(idPostfix);var commandManager=new CommandManager(hooks,getString);var previewManager=new PreviewManager(markdownConverter,panels,function(){hooks.onPreviewRefresh()},previewWrapper);var undoManager,uiManager;if(!/\?noundo/.test(doc.location.href)){undoManager=new UndoManager(function(){previewManager.refresh();if(uiManager)uiManager.setUndoRedoButtonStates()},panels);this.textOperation=function(f){undoManager.setCommandMode();f();that.refreshPreview()}}uiManager=new UIManager(idPostfix,panels,undoManager,previewManager,commandManager,options.helpButton,getString);uiManager.setUndoRedoButtonStates();var forceRefresh=that.refreshPreview=function(){previewManager.refresh(true)};forceRefresh()}};function Chunks(){}Chunks.prototype.findTags=function(startRegex,endRegex){var chunkObj=this;var regex;if(startRegex){regex=util.extendRegExp(startRegex,"","$");this.before=this.before.replace(regex,function(match){chunkObj.startTag=chunkObj.startTag+match;return""});regex=util.extendRegExp(startRegex,"^","");this.selection=this.selection.replace(regex,function(match){chunkObj.startTag=chunkObj.startTag+match;return""})}if(endRegex){regex=util.extendRegExp(endRegex,"","$");this.selection=this.selection.replace(regex,function(match){chunkObj.endTag=match+chunkObj.endTag;return""});regex=util.extendRegExp(endRegex,"^","");this.after=this.after.replace(regex,function(match){chunkObj.endTag=match+chunkObj.endTag;return""})}};Chunks.prototype.trimWhitespace=function(remove){var beforeReplacer,afterReplacer,that=this;if(remove){beforeReplacer=afterReplacer=""}else{beforeReplacer=function(s){that.before+=s;return""};afterReplacer=function(s){that.after=s+that.after;return""}}this.selection=this.selection.replace(/^(\s*)/,beforeReplacer).replace(/(\s*)$/,afterReplacer)};Chunks.prototype.skipLines=function(nLinesBefore,nLinesAfter,findExtraNewlines){if(nLinesBefore===undefined){nLinesBefore=1}if(nLinesAfter===undefined){nLinesAfter=1}nLinesBefore++;nLinesAfter++;var regexText;var replacementText;if(navigator.userAgent.match(/Chrome/)){"X".match(/()./)}this.selection=this.selection.replace(/(^\n*)/,"");this.startTag=this.startTag+re.$1;this.selection=this.selection.replace(/(\n*$)/,"");this.endTag=this.endTag+re.$1;this.startTag=this.startTag.replace(/(^\n*)/,"");this.before=this.before+re.$1;this.endTag=this.endTag.replace(/(\n*$)/,"");this.after=this.after+re.$1;if(this.before){regexText=replacementText="";while(nLinesBefore--){regexText+="\\n?";replacementText+="\n"}if(findExtraNewlines){regexText="\\n*"}this.before=this.before.replace(new re(regexText+"$",""),replacementText)}if(this.after){regexText=replacementText="";while(nLinesAfter--){regexText+="\\n?";replacementText+="\n"}if(findExtraNewlines){regexText="\\n*"}this.after=this.after.replace(new re(regexText,""),replacementText)}};function PanelCollection(postfix){tLine truncated
|
||||
chunk.before=chunk.before.replace(/(\n|^)[ \t]+\n$/,"\n\n");if(!chunk.selection&&!/^[ \t]*(?:\n|$)/.test(chunk.after)){chunk.after=chunk.after.replace(/^[^\n]*/,function(wholeMatch){chunk.selection=wholeMatch;return""});fakeSelection=true}if(/(\n|^)[ ]{0,3}([*+-]|\d+[.])[ \t]+.*\n$/.test(chunk.before)){if(commandMgr.doList){commandMgr.doList(chunk)}}if(/(\n|^)[ ]{0,3}>[ \t]+.*\n$/.test(chunk.before)){if(commandMgr.doBlockquote){commandMgr.doBlockquote(chunk)}}if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(chunk.before)){if(commandMgr.doCode){commandMgr.doCode(chunk)}}if(fakeSelection){chunk.after=chunk.selection+chunk.after;chunk.selection=""}};commandProto.doBlockquote=function(chunk,postProcessing){chunk.selection=chunk.selection.replace(/^(\n*)([^\r]+?)(\n*)$/,function(totalMatch,newlinesBefore,text,newlinesAfter){chunk.before+=newlinesBefore;chunk.after=newlinesAfter+chunk.after;return text});chunk.before=chunk.before.replace(/(>[ \t]*)$/,function(totalMatch,blankLine){chunk.selection=blankLine+chunk.selection;return""});chunk.selection=chunk.selection.replace(/^(\s|>)+$/,"");chunk.selection=chunk.selection||this.getString("quoteexample");var match="",leftOver="",line;if(chunk.before){var lines=chunk.before.replace(/\n$/,"").split("\n");var inChain=false;for(var i=0;i<lines.length;i++){var good=false;line=lines[i];inChain=inChain&&line.length>0;if(/^>/.test(line)){good=true;if(!inChain&&line.length>1)inChain=true}else if(/^[ \t]*$/.test(line)){good=true}else{good=inChain}if(good){match+=line+"\n"}else{leftOver+=match+line;match="\n"}}if(!/(^|\n)>/.test(match)){leftOver+=match;match=""}}chunk.startTag=match;chunk.before=leftOver;if(chunk.after){chunk.after=chunk.after.replace(/^\n?/,"\n")}chunk.after=chunk.after.replace(/^(((\n|^)(\n[ \t]*)*>(.+\n)*.*)+(\n[ \t]*)*)/,function(totalMatch){chunk.endTag=totalMatch;return""});var replaceBlanksInTags=function(useBracket){var replacement=useBracket?"> ":"";if(chunk.startTag){chunk.startTag=chunk.startTag.replace(/\n((>|\s)*)\n$/,function(totalMatch,markdown){return"\n"+markdown.replace(/^[ ]{0,3}>?[ \t]*$/gm,replacement)+"\n"})}if(chunk.endTag){chunk.endTag=chunk.endTag.replace(/^\n((>|\s)*)\n/,function(totalMatch,markdown){return"\n"+markdown.replace(/^[ ]{0,3}>?[ \t]*$/gm,replacement)+"\n"})}};if(/^(?![ ]{0,3}>)/m.test(chunk.selection)){this.wrap(chunk,SETTINGS.lineLength-2);chunk.selection=chunk.selection.replace(/^/gm,"> ");replaceBlanksInTags(true);chunk.skipLines()}else{chunk.selection=chunk.selection.replace(/^[ ]{0,3}> ?/gm,"");this.unwrap(chunk);replaceBlanksInTags(false);if(!/^(\n|^)[ ]{0,3}>/.test(chunk.selection)&&chunk.startTag){chunk.startTag=chunk.startTag.replace(/\n{0,2}$/,"\n\n")}if(!/(\n|^)[ ]{0,3}>.*$/.test(chunk.selection)&&chunk.endTag){chunk.endTag=chunk.endTag.replace(/^\n{0,2}/,"\n\n")}}chunk.selection=this.hooks.postBlockquoteCreation(chunk.selection);if(!/\n/.test(chunk.selection)){chunk.selection=chunk.selection.replace(/^(> *)/,function(wholeMatch,blanks){chunk.startTag+=blanks;return""})}};commandProto.doCode=function(chunk,postProcessing){var hasTextBefore=/\S[ ]*$/.test(chunk.before);var hasTextAfter=/^[ ]*\S/.test(chunk.after);if(!hasTextAfter&&!hasTextBefore||/\n/.test(chunk.selection)){chunk.before=chunk.before.replace(/[ ]{4}$/,function(totalMatch){chunk.selection=totalMatch+chunk.selection;return""});var nLinesBack=1;var nLinesForward=1;if(/(\n|^)(\t|[ ]{4,}).*\n$/.test(chunk.before)){nLinesBack=0}if(/^\n(\t|[ ]{4,})/.test(chunk.after)){nLinesForward=0}chunk.skipLines(nLinesBack,nLinesForward);if(!chunk.selection){chunk.startTag=" ";chunk.selection=this.getString("codeexample")}else{if(/^[ ]{0,3}\S/m.test(chunk.selection)){if(/\n/.test(chunk.selection))chunk.selection=chunk.selection.replace(/^/gm," ");else chunk.before+=" "}else{chunk.selection=chunk.selection.replace(/^(?:[ ]{4}|[ ]{0,3}\t)/gm,"")}}}else{chunk.trimWhitespace();chunk.findTags(/`/,/`/);if(!chunk.startTag&&!chunk.endTag){chunk.startTag=chunk.endTag="`";if(!chunk.selection){chunk.selection=this.getString("codeexample")}}else if(chunk.endTag&&!chunk.startTag){chunk.before+=chunk.endTag;chunk.endTag=""}else{chunk.startTag=chunk.endTag=""}}};commandProto.doList=function(chunk,postProcessing,isNumberedList){var previousItemsRegex=/(\n|^)(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*$/;var nextItemsRegex=/^\n*(([ ]{0,3}([*+-]|\d+[.])[ \t]+.*)(\n.+|\n{2,}([*+-].*|\d+[.])[ \t]+.*|\n{2,}[ \t]+\S.*)*)\n*/;var bullet="-";var num=1;var getItemPrefix=function(){var prefix;if(isNumberedList){prefix=" "+num+". ";num++}else{prefix=" "+bullet+" "}return prefix};var getPrefixedItem=function(itemText){if(isNumberedList===undefined){isNumberedList=/^\s*\d/.test(itemText)}itemText=itemText.replace(/^[ ]{0,3}([*+-]|\d+[.])\s/gm,function(_){return getItemPrefix()});return itemText};chunk.findTags(/(\n|^)*[ ]{0,3}([*+-]|\d+[.])\s+/,null);if(chunk.before&&!/\n$/.test(chunk.before)&&!/^\n/.test(chunk.startTag)){chunk.before+=chunk.startTag;chLine truncated
|
||||
@@ -1318,6 +1318,36 @@
|
||||
});
|
||||
}
|
||||
|
||||
// life 新添加函数
|
||||
// life
|
||||
function insertLinkLife(link, text) {
|
||||
inputBox.focus();
|
||||
if (undoManager) {
|
||||
undoManager.setCommandMode();
|
||||
}
|
||||
|
||||
var state = new TextareaState(panels);
|
||||
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
|
||||
var chunks = state.getChunks(); // 得到chunk
|
||||
var fixupInputArea = function () {
|
||||
inputBox.focus();
|
||||
|
||||
if (chunks) {
|
||||
state.setChunks(chunks);
|
||||
}
|
||||
|
||||
state.restore();
|
||||
previewManager.refresh();
|
||||
};
|
||||
|
||||
var a = commandProto.insertLink(chunks, fixupInputArea, link, text);
|
||||
if(!a) fixupInputArea();
|
||||
}
|
||||
MarkdownEditor.insertLink = insertLinkLife;
|
||||
|
||||
// Perform the button's action.
|
||||
function doClick(button) {
|
||||
@@ -1369,6 +1399,7 @@
|
||||
|
||||
var noCleanup = button.textOp(chunks, fixupInputArea);
|
||||
|
||||
// 这里生成
|
||||
if (!noCleanup) {
|
||||
fixupInputArea();
|
||||
}
|
||||
@@ -1378,6 +1409,7 @@
|
||||
if (button.execute) {
|
||||
button.execute(undoManager);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
function setupButton(button, isEnabled) {
|
||||
@@ -1708,6 +1740,68 @@
|
||||
});
|
||||
}
|
||||
|
||||
// life 添加
|
||||
commandProto.insertLink = function (chunk, postProcessing, link, text) {
|
||||
isImage = false;
|
||||
chunk.trimWhitespace();
|
||||
chunk.findTags(/\s*!?\[/, /\][ ]?(?:\n[ ]*)?(\[.*?\])?/);
|
||||
var background;
|
||||
|
||||
if (chunk.endTag.length > 1 && chunk.startTag.length > 0) {
|
||||
|
||||
chunk.startTag = chunk.startTag.replace(/!?\[/, "");
|
||||
chunk.endTag = "";
|
||||
this.addLinkDef(chunk, null);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
// We're moving start and end tag back into the selection, since (as we're in the else block) we're not
|
||||
// *removing* a link, but *adding* one, so whatever findTags() found is now back to being part of the
|
||||
// link text. linkEnteredCallback takes care of escaping any brackets.
|
||||
chunk.selection = chunk.startTag + chunk.selection + chunk.endTag;
|
||||
chunk.startTag = chunk.endTag = "";
|
||||
|
||||
if (/\n\n/.test(chunk.selection)) {
|
||||
this.addLinkDef(chunk, null);
|
||||
return;
|
||||
}
|
||||
var that = this;
|
||||
// The function to be executed when you enter a link and press OK or Cancel.
|
||||
// Marks up the link and adds the ref.
|
||||
var linkEnteredCallback = function (link) {
|
||||
|
||||
background.parentNode.removeChild(background);
|
||||
|
||||
if (link !== null) {
|
||||
chunk.selection = (" " + chunk.selection).replace(/([^\\](?:\\\\)*)(?=[[\]])/g, "$1\\").substr(1);
|
||||
|
||||
var linkDef = " [999]: " + properlyEncoded(link);
|
||||
|
||||
var num = that.addLinkDef(chunk, linkDef);
|
||||
chunk.startTag = isImage ? "![" : "[";
|
||||
chunk.endTag = "][" + num + "]";
|
||||
chunk.selection = text;
|
||||
}
|
||||
postProcessing();
|
||||
};
|
||||
|
||||
background = ui.createBackground();
|
||||
linkEnteredCallback(link);
|
||||
/*
|
||||
if (isImage) {
|
||||
if (!this.hooks.insertImageDialog(linkEnteredCallback))
|
||||
ui.prompt(this.getString("imagedialog"), imageDefaultText, linkEnteredCallback);
|
||||
}
|
||||
else {
|
||||
if (!this.hooks.insertLinkDialog(linkEnteredCallback)) // jiawzhang
|
||||
ui.prompt(this.getString("linkdialog"), linkDefaultText, linkEnteredCallback);
|
||||
}
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
commandProto.doLinkOrImage = function (chunk, postProcessing, isImage) {
|
||||
|
||||
chunk.trimWhitespace();
|
||||
|
||||
@@ -104,21 +104,7 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
}
|
||||
data.src = trueSrc;
|
||||
|
||||
/*
|
||||
var width = "", height="", title="";
|
||||
if(data.width) {
|
||||
width = 'width="' + data.width +'" ';
|
||||
}
|
||||
if(data.height) {
|
||||
height = 'height="' + data.height +'" ';
|
||||
}
|
||||
if(data.title) {
|
||||
title = 'title="' + data.title +'" ';
|
||||
}
|
||||
var attrs = width + height + title;
|
||||
editor.insertContent('<img ' + attrs + ' data-src="' + src + '" src="' + trueSrc + '" />');
|
||||
*/
|
||||
|
||||
var renderImage = function(data) {
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var back = (function(data2, i) {
|
||||
var d = {};
|
||||
@@ -129,7 +115,6 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
imgElm = dom.createHTML('img', d);
|
||||
editor.insertContent(imgElm);
|
||||
imgElm = dom.get(d.id);
|
||||
log(imgElm)
|
||||
|
||||
return function(wh) {
|
||||
if(wh && wh.width) {
|
||||
@@ -147,6 +132,35 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
})(data, i);
|
||||
getImageSize(data.src, back);
|
||||
}
|
||||
|
||||
// outputImage?fileId=123232323
|
||||
var fileId = "";
|
||||
fileIds = trueSrc.split("fileId=")
|
||||
if(fileIds.length == 2 && fileIds[1].length == "53aecf8a8a039a43c8036282".length) {
|
||||
fileId = fileIds[1];
|
||||
}
|
||||
if(fileId) {
|
||||
// 得到fileId, 如果这个笔记不是我的, 那么肯定是协作的笔记, 那么需要将图片copy给原note owner
|
||||
var curNote = Note.getCurNote();
|
||||
if(curNote && curNote.UserId != UserInfo.UserId) {
|
||||
(function(data) {
|
||||
ajaxPost("/file/copyImage", {userId: UserInfo.UserId, fileId: fileId, toUserId: curNote.UserId}, function(re) {
|
||||
if(reIsOk(re) && re.Id) {
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
data.src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
}
|
||||
renderImage(data);
|
||||
});
|
||||
})(data);
|
||||
} else {
|
||||
renderImage(data);
|
||||
}
|
||||
} else {
|
||||
renderImage(data);
|
||||
}
|
||||
|
||||
} // end for
|
||||
|
||||
this.parent().parent().close();
|
||||
}
|
||||
},
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(t,e){function i(t,e){function i(t,i){n.parentNode.removeChild(n),e({width:t,height:i})}var n=document.createElement("img");n.onload=function(){i(n.clientWidth,n.clientHeight)},n.onerror=function(){i()},n.src=t;var r=n.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(n)}function n(){function n(){var t='<iframe id="leauiIfr" src="'+e+"/index.html?"+(new Date).getTime()+'" frameborder="0"></iframe>';return t}var r=t.dom,a=t.selection.getContent(),o=/<img.*?\/>/g,d=a.match(o),c=document.createElement("p"),g=[];for(var h in d){c.innerHTML=d[h];var l=c.firstChild;if(l&&"IMG"==l.nodeName){var s={};s.src=r.getAttrib(l,"data-src")||r.getAttrib(l,"src"),s.width=r.getAttrib(l,"width"),s.height=r.getAttrib(l,"height"),s.title=r.getAttrib(l,"title"),g.push(s)}}LEAUI_DATAS=g,win=t.windowManager.open({title:"Manage Image",width:885,height:475,html:n(),buttons:[{text:"Insert Image",subtype:"primary",onclick:function(n){for(var a=document.getElementById("leauiIfr").contentWindow,o=a.document.getElementById("preview"),d=o.childNodes,c=[],g=0;g<d.length;++g){var n=d[g];if(n.firstChild&&"IMG"==n.firstChild.nodeName){var h=n.firstChild,l={};l.src=h.getAttribute("src"),l.width=h.getAttribute("data-width"),l.height=h.getAttribute("data-height"),l.title=h.getAttribute("data-title"),c.push(l)}}for(var g in c){var s,m=c[g],u=m.src;s=-1!=u.indexOf("http://")||-1!=u.indexOf("https://")?u:e+"/"+u,m.src=s;var f=function(e,i){var n,a={};return a.id="__mcenew"+i,a.src="http://leanote.com/images/loading-24.gif",n=r.createHTML("img",a),t.insertContent(n),n=r.get(a.id),log(n),function(t){t&&t.width&&(t.width>600&&(t.width=600),e.width=t.width),r.setAttrib(n,"src",e.src),r.setAttrib(n,"width",e.width),r.setAttrib(n,"title",e.title),r.setAttrib(n,"id",null)}}(m,g);i(m.src,f)}this.parent().parent().close()}},{text:"Cancel",onclick:function(){this.parent().parent().close()}}]})}t.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:n,stateSelector:"img:not([data-mce-object])"}),t.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:n,context:"insert",prependToContext:!0});var r=!1;t.on("dragstart",function(){r=!0}),t.on("dragend",function(){r=!1}),t.on("dragover",function(){r||$("body").trigger("dragover")})});
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(t,e){function i(t,e){function i(t,i){n.parentNode.removeChild(n),e({width:t,height:i})}var n=document.createElement("img");n.onload=function(){i(n.clientWidth,n.clientHeight)},n.onerror=function(){i()},n.src=t;var r=n.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(n)}function n(){function n(){var t='<iframe id="leauiIfr" src="'+e+"/index.html?"+(new Date).getTime()+'" frameborder="0"></iframe>';return t}var r=t.dom,o=t.selection.getContent(),a=/<img.*?\/>/g,d=o.match(a),c=document.createElement("p"),l=[];for(var s in d){c.innerHTML=d[s];var g=c.firstChild;if(g&&"IMG"==g.nodeName){var h={};h.src=r.getAttrib(g,"data-src")||r.getAttrib(g,"src"),h.width=r.getAttrib(g,"width"),h.height=r.getAttrib(g,"height"),h.title=r.getAttrib(g,"title"),l.push(h)}}LEAUI_DATAS=l,win=t.windowManager.open({title:"Manage Image",width:885,height:475,html:n(),buttons:[{text:"Insert Image",subtype:"primary",onclick:function(n){for(var o=document.getElementById("leauiIfr").contentWindow,a=o.document.getElementById("preview"),d=a.childNodes,c=[],l=0;l<d.length;++l){var n=d[l];if(n.firstChild&&"IMG"==n.firstChild.nodeName){var s=n.firstChild,g={};g.src=s.getAttribute("src"),g.width=s.getAttribute("data-width"),g.height=s.getAttribute("data-height"),g.title=s.getAttribute("data-title"),c.push(g)}}for(var l in c){var h,f=c[l],u=f.src;h=-1!=u.indexOf("http://")||-1!=u.indexOf("https://")?u:e+"/"+u,f.src=h;var m=function(e){var n=function(e,i){var n,o={};return o.id="__mcenew"+i,o.src="http://leanote.com/images/loading-24.gif",n=r.createHTML("img",o),t.insertContent(n),n=r.get(o.id),function(t){t&&t.width&&(t.width>600&&(t.width=600),e.width=t.width),r.setAttrib(n,"src",e.src),r.setAttrib(n,"width",e.width),r.setAttrib(n,"title",e.title),r.setAttrib(n,"id",null)}}(e,l);i(e.src,n)},I="";if(fileIds=h.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(I=fileIds[1]),I){var p=Note.getCurNote();p&&p.UserId!=UserInfo.UserId?!function(t){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:I,toUserId:p.UserId},function(e){if(reIsOk(e)&&e.Id){var i=window.location.protocol+"//"+window.location.host;t.src=i+"/file/outputImage?fileId="+e.Id}m(t)})}(f):m(f)}else m(f)}this.parent().parent().close()}},{text:"Cancel",onclick:function(){this.parent().parent().close()}}]})}t.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:n,stateSelector:"img:not([data-mce-object])"}),t.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:n,context:"insert",prependToContext:!0});var r=!1;t.on("dragstart",function(){r=!0}),t.on("dragend",function(){r=!1}),t.on("dragover",function(){r||$("body").trigger("dragover")})});
|
||||
@@ -1,7 +1,7 @@
|
||||
// for editor.
|
||||
// drag image to editor
|
||||
// Copyright leaui
|
||||
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
var editor = tinymce.activeEditor;
|
||||
var dom = editor.dom;
|
||||
@@ -35,7 +35,8 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
}
|
||||
|
||||
var i = 1;
|
||||
function insertImage(data2) {
|
||||
function insertImage(data) {
|
||||
var renderImage = function(data2) {
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var d = {};
|
||||
var imgElm;
|
||||
@@ -61,7 +62,35 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
|
||||
dom.setAttrib(imgElm, 'id', null);
|
||||
};
|
||||
getImageSize(data2.src, callback);
|
||||
getImageSize(data.src, callback);
|
||||
}
|
||||
|
||||
//-------------
|
||||
// outputImage?fileId=123232323
|
||||
var fileId = "";
|
||||
fileIds = data.src.split("fileId=")
|
||||
if(fileIds.length == 2 && fileIds[1].length == "53aecf8a8a039a43c8036282".length) {
|
||||
fileId = fileIds[1];
|
||||
}
|
||||
if(fileId) {
|
||||
// 得到fileId, 如果这个笔记不是我的, 那么肯定是协作的笔记, 那么需要将图片copy给原note owner
|
||||
var curNote = Note.getCurNote();
|
||||
if(curNote && curNote.UserId != UserInfo.UserId) {
|
||||
(function(data) {
|
||||
ajaxPost("/file/copyImage", {userId: UserInfo.UserId, fileId: fileId, toUserId: curNote.UserId}, function(re) {
|
||||
if(reIsOk(re) && re.Id) {
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
data.src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
}
|
||||
renderImage(data);
|
||||
});
|
||||
})(data);
|
||||
} else {
|
||||
renderImage(data);
|
||||
}
|
||||
} else {
|
||||
renderImage(data);
|
||||
}
|
||||
}
|
||||
|
||||
var initUploader = function() {
|
||||
@@ -103,7 +132,8 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
done: function(e, data) {
|
||||
if (data.result.Ok == true) {
|
||||
data.context.remove();
|
||||
var data2 = {src: data.result.Id}
|
||||
// life
|
||||
var data2 = {src: urlPrefix + "/file/outputImage?fileId=" + data.result.Id}
|
||||
insertImage(data2);
|
||||
} else {
|
||||
data.context.empty();
|
||||
|
||||
@@ -260,7 +260,13 @@ var o = {
|
||||
for(var i in datas){
|
||||
var each = datas[i];
|
||||
var classes = "";
|
||||
// life edit
|
||||
// 之前的
|
||||
if(each.Path != "" && each.Path.substr(0, 7) == "/upload") {
|
||||
var src = urlPrefix + each.Path;
|
||||
} else {
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + each.FileId;
|
||||
}
|
||||
// log(src);
|
||||
if(selectedMap[src]) {
|
||||
classes = 'class="selected"';
|
||||
@@ -348,10 +354,11 @@ var o = {
|
||||
return false;
|
||||
}
|
||||
|
||||
// life 为了图片安全
|
||||
if(typeof $li == "object") {
|
||||
var src = $li.find("img").attr('src');
|
||||
} else {
|
||||
src = $li;
|
||||
src = urlPrefix + "/file/outputImage?fileId=" + $li;
|
||||
}
|
||||
this.selectedImages.push(src);
|
||||
this.reRenderSelectedImages(false, src);
|
||||
|
||||
@@ -287,6 +287,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
var c = new FormData;
|
||||
c.append("from", "pasteImage");
|
||||
c.append("file", blob);
|
||||
c.append("noteId", Note.curNoteId); // life
|
||||
// var d;
|
||||
// d = $.ajaxSettings.xhr();
|
||||
// d.withCredentials = i;var d = {};
|
||||
@@ -296,10 +297,10 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
var dom = editor.dom;
|
||||
var d = {};
|
||||
d.id = '__mcenew';
|
||||
d.src = "http://leanote.com/images/loading-24.gif";
|
||||
d.src = "http://leanote.com/images/loading-24.gif"; // 写死了
|
||||
editor.insertContent(dom.createHTML('img', d));
|
||||
var imgElm = dom.get('__mcenew');
|
||||
$.ajax({url: "/file/uploadImageJson", contentType:false, processData:false , data: c, type: "POST"}
|
||||
$.ajax({url: "/file/pasteImage", contentType:false, processData:false , data: c, type: "POST"}
|
||||
).done(function(re) {
|
||||
if(!re || typeof re != "object" || !re.Ok) {
|
||||
// 删除
|
||||
@@ -307,7 +308,9 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return;
|
||||
}
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
getImageSize(re.Id, function(wh) {
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
getImageSize(src, function(wh) {
|
||||
// life 4/25
|
||||
if(wh && wh.width) {
|
||||
if(wh.width > 600) {
|
||||
@@ -316,7 +319,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
d.width = wh.width;
|
||||
dom.setAttrib(imgElm, 'width', d.width);
|
||||
}
|
||||
dom.setAttrib(imgElm, 'src', re.Id);
|
||||
dom.setAttrib(imgElm, 'src', src);
|
||||
});
|
||||
dom.setAttrib(imgElm, 'id', null);
|
||||
});
|
||||
|
||||
@@ -117,4 +117,4 @@
|
||||
writeScripts();
|
||||
})(this);
|
||||
|
||||
// $hash: cbcf61872b3ecc41bd22dcf691e2e4dd
|
||||
// $hash: 3d47d6168ca064ff0c3f626e575ff2e8
|
||||
@@ -472,6 +472,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
var c = new FormData;
|
||||
c.append("from", "pasteImage");
|
||||
c.append("file", blob);
|
||||
c.append("noteId", Note.curNoteId); // life
|
||||
// var d;
|
||||
// d = $.ajaxSettings.xhr();
|
||||
// d.withCredentials = i;var d = {};
|
||||
@@ -481,10 +482,10 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
var dom = editor.dom;
|
||||
var d = {};
|
||||
d.id = '__mcenew';
|
||||
d.src = "http://leanote.com/images/loading-24.gif";
|
||||
d.src = "http://leanote.com/images/loading-24.gif"; // 写死了
|
||||
editor.insertContent(dom.createHTML('img', d));
|
||||
var imgElm = dom.get('__mcenew');
|
||||
$.ajax({url: "/file/uploadImageJson", contentType:false, processData:false , data: c, type: "POST"}
|
||||
$.ajax({url: "/file/pasteImage", contentType:false, processData:false , data: c, type: "POST"}
|
||||
).done(function(re) {
|
||||
if(!re || typeof re != "object" || !re.Ok) {
|
||||
// 删除
|
||||
@@ -492,7 +493,9 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return;
|
||||
}
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
getImageSize(re.Id, function(wh) {
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
getImageSize(src, function(wh) {
|
||||
// life 4/25
|
||||
if(wh && wh.width) {
|
||||
if(wh.width > 600) {
|
||||
@@ -501,7 +504,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
d.width = wh.width;
|
||||
dom.setAttrib(imgElm, 'width', d.width);
|
||||
}
|
||||
dom.setAttrib(imgElm, 'src', re.Id);
|
||||
dom.setAttrib(imgElm, 'src', src);
|
||||
});
|
||||
dom.setAttrib(imgElm, 'id', null);
|
||||
});
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
!function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r<e.length;++r){if(n=s[e[r]]||a(e[r]),!n)throw"module definition dependecy not found: "+e[r];i.push(n)}t.apply(null,i)}function i(e,i,r){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=r.apply(null,arguments)})}function r(e){return!!s[e]}function a(t){for(var n=e,i=t.split(/[.\/]/),r=0;r<i.length;++r){if(!n[i[r]])return;n=n[i[r]]}return n}function o(n){for(var i=0;i<n.length;i++){for(var r=e,a=n[i],o=a.split(/[.\/]/),l=0;l<o.length-1;++l)r[o[l]]===t&&(r[o[l]]={}),r=r[o[l]];r[o[o.length-1]]=s[a]}}var s={},l="tinymce/pasteplugin/Utils",c="tinymce/util/Tools",d="tinymce/html/DomParser",p="tinymce/html/Schema",u="tinymce/pasteplugin/Clipboard",f="tinymce/Env",g="tinymce/util/VK",m="tinymce/pasteplugin/WordFilter",v="tinymce/html/Serializer",h="tinymce/html/Node",y="tinymce/pasteplugin/Quirks",b="tinymce/pasteplugin/Plugin",w="tinymce/PluginManager";i(l,[c,d,p],function(e,t,n){function i(t,n){return e.each(n,function(e){t=e.constructor==RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}function r(i){function r(e){var t=e.name,n=e;if("br"===t)return void(s+="\n");if(l[t]&&(s+=" "),c[t])return void(s+=" ");if(3==e.type&&(s+=e.value),!e.shortEnded&&(e=e.firstChild))do r(e);while(e=e.next);d[t]&&n.next&&(s+="\n","p"==t&&(s+="\n"))}var a=new n,o=new t({},a),s="",l=a.getShortEndedElements(),c=e.makeMap("script noscript style textarea video audio iframe object"," "),d=a.getBlockElements();return r(o.parse(i)),s}return{filter:i,innerText:r}}),i(u,[f,g,l],function(e,t,n){return function(i){function r(e,t){var n,r=i.dom;if(i.settings.paste_data_images||(e=e.replace(/<img[^>]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var a=r.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:a}),r.remove(a),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var o=i.selection.getNode();if("PRE"==o.nodeName){if(!t)try{t=$(e).text()}catch(s){}t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),i.insertRawContent(t)}else i.insertContent(e)}}}function a(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var a=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),a&&/^(PRE|DIV)$/.test(a.nodeName)||!o?e=n.filter(e,[[/\n/g,"<br>"]]):(e=n.filter(e,[[/\n\n/g,"</p>"+s],[/^(.*<\/p>)(<p>)$/,s+"$1"],[/\n/g,"<br />"]]),-1!=e.indexOf("<p>")&&(e=s+e)),r(e,t)}function o(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),r=i.inline?t.scrollTop:n.y,a=i.inline?t.clientHeight:n.h;s(),f=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(r+20)+"px;width: 10px; height: "+(a-40)+"px; overflow: hidden; opacity: 0"},v),e.setStyle(f,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(f,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),f.focus(),i.selection.select(f,!0)}function s(){f&&(i.dom.unbind(f),i.dom.remove(f),g&&i.selection.setRng(g)),h=!1,f=g=null}function l(){return f?f.innerHTML:v}function c(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var r=0;r<n.types.length;r++){var a=n.types[r];t[a]=n.getData(a)}}return t}function d(e,t){function n(e,n){i.parentNode.removeChild(i),t({width:e,height:n})}var i=document.createElement("img");i.onload=function(){n(i.clientWidth,i.clientHeight)},i.onerror=function(){n()},i.src=e;var r=i.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(i)}function p(e){var t=(e.clipboardData||e.originalEvent.clipboardData).items;log(JSON.stringify(t));for(var n,i=0;i<t.length;i++)0===t[i].type.indexOf("image")&&(n=t[i].getAsFile());if(n){var r=new FileReader;return r.onload=function(e){var t=new FormData;t.append("from","pasteImage"),t.append("file",n);var i=tinymce.EditorManager.activeEditor,r=i.dom,a={};a.id="__mcenew",a.src="http://leanote.com/images/loading-24.gif",i.insertContent(r.createHTML("img",a));var o=r.get("__mcenew");$.ajax({url:"/file/uploadImageJson",contentType:!1,processData:!1,data:t,type:"POST"}).done(function(e){return e&&"object"==typeof e&&e.Ok?(d(e.Id,function(t){t&&t.width&&(t.width>600&&(t.width=600),a.width=t.width,r.setAttrib(o,"width",a.width)),r.setAttrib(o,"src",e.Id)}),void r.setAttrib(o,"id",null)):void r.remove(o)})},r.readAsDataURL(n),!0}return!1}var u=this,f,g,m=0,v="%MCEPASTEBIN%",h;i.on("keydown",function(n){if(!n.isDefaultPrevented()&&(t.metaKeyPressed(n)&&Line truncated
|
||||
!function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r<e.length;++r){if(n=s[e[r]]||a(e[r]),!n)throw"module definition dependecy not found: "+e[r];i.push(n)}t.apply(null,i)}function i(e,i,r){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=r.apply(null,arguments)})}function r(e){return!!s[e]}function a(t){for(var n=e,i=t.split(/[.\/]/),r=0;r<i.length;++r){if(!n[i[r]])return;n=n[i[r]]}return n}function o(n){for(var i=0;i<n.length;i++){for(var r=e,a=n[i],o=a.split(/[.\/]/),l=0;l<o.length-1;++l)r[o[l]]===t&&(r[o[l]]={}),r=r[o[l]];r[o[o.length-1]]=s[a]}}var s={},l="tinymce/pasteplugin/Utils",c="tinymce/util/Tools",d="tinymce/html/DomParser",p="tinymce/html/Schema",u="tinymce/pasteplugin/Clipboard",f="tinymce/Env",g="tinymce/util/VK",m="tinymce/pasteplugin/WordFilter",v="tinymce/html/Serializer",h="tinymce/html/Node",y="tinymce/pasteplugin/Quirks",b="tinymce/pasteplugin/Plugin",w="tinymce/PluginManager";i(l,[c,d,p],function(e,t,n){function i(t,n){return e.each(n,function(e){t=e.constructor==RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}function r(i){function r(e){var t=e.name,n=e;if("br"===t)return void(s+="\n");if(l[t]&&(s+=" "),c[t])return void(s+=" ");if(3==e.type&&(s+=e.value),!e.shortEnded&&(e=e.firstChild))do r(e);while(e=e.next);d[t]&&n.next&&(s+="\n","p"==t&&(s+="\n"))}var a=new n,o=new t({},a),s="",l=a.getShortEndedElements(),c=e.makeMap("script noscript style textarea video audio iframe object"," "),d=a.getBlockElements();return r(o.parse(i)),s}return{filter:i,innerText:r}}),i(u,[f,g,l],function(e,t,n){return function(i){function r(e,t){var n,r=i.dom;if(i.settings.paste_data_images||(e=e.replace(/<img[^>]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var a=r.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:a}),r.remove(a),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var o=i.selection.getNode();if("PRE"==o.nodeName){if(!t)try{t=$(e).text()}catch(s){}t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),i.insertRawContent(t)}else i.insertContent(e)}}}function a(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var a=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),a&&/^(PRE|DIV)$/.test(a.nodeName)||!o?e=n.filter(e,[[/\n/g,"<br>"]]):(e=n.filter(e,[[/\n\n/g,"</p>"+s],[/^(.*<\/p>)(<p>)$/,s+"$1"],[/\n/g,"<br />"]]),-1!=e.indexOf("<p>")&&(e=s+e)),r(e,t)}function o(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),r=i.inline?t.scrollTop:n.y,a=i.inline?t.clientHeight:n.h;s(),f=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(r+20)+"px;width: 10px; height: "+(a-40)+"px; overflow: hidden; opacity: 0"},v),e.setStyle(f,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(f,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),f.focus(),i.selection.select(f,!0)}function s(){f&&(i.dom.unbind(f),i.dom.remove(f),g&&i.selection.setRng(g)),h=!1,f=g=null}function l(){return f?f.innerHTML:v}function c(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var r=0;r<n.types.length;r++){var a=n.types[r];t[a]=n.getData(a)}}return t}function d(e,t){function n(e,n){i.parentNode.removeChild(i),t({width:e,height:n})}var i=document.createElement("img");i.onload=function(){n(i.clientWidth,i.clientHeight)},i.onerror=function(){n()},i.src=e;var r=i.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(i)}function p(e){var t=(e.clipboardData||e.originalEvent.clipboardData).items;log(JSON.stringify(t));for(var n,i=0;i<t.length;i++)0===t[i].type.indexOf("image")&&(n=t[i].getAsFile());if(n){var r=new FileReader;return r.onload=function(e){var t=new FormData;t.append("from","pasteImage"),t.append("file",n),t.append("noteId",Note.curNoteId);var i=tinymce.EditorManager.activeEditor,r=i.dom,a={};a.id="__mcenew",a.src="http://leanote.com/images/loading-24.gif",i.insertContent(r.createHTML("img",a));var o=r.get("__mcenew");$.ajax({url:"/file/pasteImage",contentType:!1,processData:!1,data:t,type:"POST"}).done(function(e){if(!e||"object"!=typeof e||!e.Ok)return void r.remove(o);var t=window.location.protocol+"//"+window.location.host,n=t+"/file/outputImage?fileId="+e.Id;d(n,function(e){e&&e.width&&(e.width>600&&(e.width=600),a.width=e.width,r.setAttrib(o,"width",a.width)),r.setAttrib(o,"src",n)}),r.setAttrib(o,"id",null)})},r.readAsDataURL(n),!0}return!1}vLine truncated
|
||||
Reference in new issue
Block a user