Compare commits
11
Commits
1.1
...
feature-pdf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
716fbeae0c | ||
|
|
103891e0c0 | ||
|
|
638b5b51e0 | ||
|
|
90fea722aa | ||
|
|
90ce35327f | ||
|
|
60e3b9446a | ||
|
|
16a726223c | ||
|
|
dfe45f39bb | ||
|
|
413be4a6d0 | ||
|
|
6a35f98f89 | ||
|
|
ad295d97c8 |
No files matched your search
+35
-1
@@ -139,6 +139,7 @@ gulp.task('i18n', function() {
|
||||
ls(base + '/blog');
|
||||
ls(base + '/dist');
|
||||
ls(base + '/js');
|
||||
ls(base + '/album');
|
||||
ls(base + '/libs');
|
||||
ls(base + '/member');
|
||||
ls(base + '/tinymce');
|
||||
@@ -202,6 +203,39 @@ gulp.task('i18n', function() {
|
||||
});
|
||||
|
||||
|
||||
// 合并album需要的js
|
||||
gulp.task('concatAlbumJs', function() {
|
||||
/*
|
||||
gulp.src(base + '/album/js/main.js')
|
||||
.pipe(uglify()) // 压缩
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest(base + '/album/js/'));
|
||||
*/
|
||||
|
||||
gulp.src(base + '/album/css/style.css')
|
||||
.pipe(rename({suffix: '-min'}))
|
||||
.pipe(minifycss())
|
||||
.pipe(gulp.dest(base + '/album/css'));
|
||||
|
||||
var jss = [
|
||||
'js/jquery-1.9.0.min.js',
|
||||
'js/bootstrap-min.js',
|
||||
'js/plugins/libs-min/fileupload.js',
|
||||
'js/jquery.pagination.js',
|
||||
'album/js/main.js',
|
||||
];
|
||||
|
||||
for(var i in jss) {
|
||||
jss[i] = base + '/' + jss[i];
|
||||
}
|
||||
|
||||
return gulp
|
||||
.src(jss)
|
||||
.pipe(uglify()) // 压缩
|
||||
.pipe(concat('main.all.js'))
|
||||
.pipe(gulp.dest(base + '/album/js'));
|
||||
});
|
||||
|
||||
// plugins压缩
|
||||
gulp.task('plugins', function() {
|
||||
gulp.src(base + '/js/plugins/libs/*.js')
|
||||
@@ -308,4 +342,4 @@ gulp.task('concatCss', function() {
|
||||
|
||||
gulp.task('concat', ['concatDepJs', 'concatAppJs', 'concatMarkdownJs']);
|
||||
gulp.task('html', ['devToProHtml']);
|
||||
gulp.task('default', ['concat', 'plugins', 'minifycss', 'i18n', 'html']);
|
||||
gulp.task('default', ['concat', 'plugins', 'minifycss', 'i18n', 'concatAlbumJs', 'html']);
|
||||
@@ -14,6 +14,12 @@ type Album struct {
|
||||
BaseController
|
||||
}
|
||||
|
||||
// 图片管理, iframe
|
||||
func (c Album) Index() revel.Result {
|
||||
c.SetLocale();
|
||||
return c.RenderTemplate("album/index.html")
|
||||
}
|
||||
|
||||
// all albums by userId
|
||||
func (c Album) GetAlbums() revel.Result {
|
||||
re := albumService.GetAlbums(c.GetUserId())
|
||||
|
||||
@@ -2,17 +2,20 @@ package controllers
|
||||
|
||||
import (
|
||||
"github.com/revel/revel"
|
||||
// "encoding/json"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
// "encoding/json"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
// "time"
|
||||
// "github.com/leanote/leanote/app/types"
|
||||
// "io/ioutil"
|
||||
// "fmt"
|
||||
// "bytes"
|
||||
// "os"
|
||||
"time"
|
||||
"fmt"
|
||||
// "github.com/leanote/leanote/app/types"
|
||||
// "io/ioutil"
|
||||
// "bytes"
|
||||
// "os"
|
||||
)
|
||||
|
||||
type Note struct {
|
||||
@@ -293,6 +296,165 @@ func (c Note) SearchNoteByTags(tags []string) revel.Result {
|
||||
return c.RenderJson(blogs)
|
||||
}
|
||||
|
||||
// 生成PDF
|
||||
func (c Note) ToPdf(noteId, appKey string) revel.Result {
|
||||
// 虽然传了cookie但是这里还是不能得到userId, 所以还是通过appKey来验证之
|
||||
appKeyTrue, _ := revel.Config.String("app.secret")
|
||||
if appKeyTrue != appKey {
|
||||
return c.RenderText("error")
|
||||
}
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.NoteId == "" {
|
||||
return c.RenderText("error")
|
||||
}
|
||||
|
||||
noteUserId := note.UserId.Hex()
|
||||
content := noteService.GetNoteContent(noteId, noteUserId)
|
||||
userInfo := userService.GetUserInfo(noteUserId)
|
||||
|
||||
//------------------
|
||||
// 将content的图片转换为base64
|
||||
contentStr := content.Content
|
||||
|
||||
siteUrlPattern := configService.GetSiteUrl()
|
||||
if strings.Contains(siteUrlPattern, "https") {
|
||||
siteUrlPattern = strings.Replace(siteUrlPattern, "https", "https*", 1)
|
||||
} else {
|
||||
siteUrlPattern = strings.Replace(siteUrlPattern, "http", "https*", 1)
|
||||
}
|
||||
|
||||
regImage, _ := regexp.Compile(`<img .*?(src=('|")` + siteUrlPattern + `/(file/outputImage|api/file/getImage)\?fileId=([a-z0-9A-Z]{24})("|'))`)
|
||||
|
||||
findsImage := regImage.FindAllStringSubmatch(contentStr, -1) // 查找所有的
|
||||
// [<img src="http://leanote.com/api/getImage?fileId=3354672e8d38f411286b000069" alt="" width="692" height="302" data-mce-src="http://leanote.com/file/outputImage?fileId=54672e8d38f411286b000069" src="http://leanote.com/file/outputImage?fileId=54672e8d38f411286b000069" " file/outputImage 54672e8d38f411286b000069 "]
|
||||
for _, eachFind := range findsImage {
|
||||
if len(eachFind) == 6 {
|
||||
fileId := eachFind[4]
|
||||
// 得到base64编码文件
|
||||
fileBase64 := fileService.GetImageBase64(noteUserId, fileId)
|
||||
if fileBase64 == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// 1
|
||||
// src="http://leanote.com/file/outputImage?fileId=54672e8d38f411286b000069"
|
||||
allFixed := strings.Replace(eachFind[0], eachFind[1], "src=\""+fileBase64+"\"", -1)
|
||||
contentStr = strings.Replace(contentStr, eachFind[0], allFixed, -1)
|
||||
}
|
||||
}
|
||||
|
||||
// markdown
|
||||
if note.IsMarkdown {
|
||||
// 
|
||||
regImageMarkdown, _ := regexp.Compile(`!\[.*?\]\(` + siteUrlPattern + `/(file/outputImage|api/file/getImage)\?fileId=([a-z0-9A-Z]{24})\)`)
|
||||
findsImageMarkdown := regImageMarkdown.FindAllStringSubmatch(contentStr, -1) // 查找所有的
|
||||
for _, eachFind := range findsImageMarkdown {
|
||||
if len(eachFind) == 3 {
|
||||
fileId := eachFind[2]
|
||||
// 得到base64编码文件
|
||||
fileBase64 := fileService.GetImageBase64(noteUserId, fileId)
|
||||
if fileBase64 == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
// 1
|
||||
// src="http://leanote.com/file/outputImage?fileId=54672e8d38f411286b000069"
|
||||
allFixed := ""
|
||||
contentStr = strings.Replace(contentStr, eachFind[0], allFixed, -1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if note.Tags != nil && len(note.Tags) > 0 && note.Tags[0] != "" {
|
||||
} else {
|
||||
note.Tags = nil
|
||||
}
|
||||
c.RenderArgs["blog"] = note
|
||||
c.RenderArgs["content"] = contentStr
|
||||
c.RenderArgs["userInfo"] = userInfo
|
||||
userBlog := blogService.GetUserBlog(noteUserId)
|
||||
c.RenderArgs["userBlog"] = userBlog
|
||||
|
||||
return c.RenderTemplate("file/pdf.html")
|
||||
}
|
||||
|
||||
// 导出成PDF
|
||||
func (c Note) ExportPdf(noteId string) revel.Result {
|
||||
re := info.NewRe()
|
||||
userId := c.GetUserId()
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.NoteId == "" {
|
||||
re.Msg = "No Note"
|
||||
return c.RenderText("error")
|
||||
}
|
||||
|
||||
noteUserId := note.UserId.Hex()
|
||||
// 是否有权限
|
||||
if noteUserId != userId {
|
||||
// 是否是有权限协作的
|
||||
if !note.IsBlog && !shareService.HasReadPerm(noteUserId, userId, noteId) {
|
||||
re.Msg = "No Perm"
|
||||
return c.RenderText("error")
|
||||
}
|
||||
}
|
||||
|
||||
// path 判断是否需要重新生成之
|
||||
guid := NewGuid()
|
||||
fileUrlPath := "files/" + Digest3(noteUserId) + "/" + noteUserId + "/" + Digest2(guid) + "/images/pdf"
|
||||
dir := revel.BasePath + "/" + fileUrlPath
|
||||
if !MkdirAll(dir) {
|
||||
return c.RenderText("error, no dir")
|
||||
}
|
||||
filename := guid + ".pdf"
|
||||
path := dir + "/" + filename
|
||||
|
||||
// leanote.com的secret
|
||||
appKey, _ := revel.Config.String("app.secretLeanote")
|
||||
if appKey == "" {
|
||||
appKey, _ = revel.Config.String("app.secret")
|
||||
}
|
||||
|
||||
// 生成之
|
||||
binPath := configService.GetGlobalStringConfig("exportPdfBinPath")
|
||||
// 默认路径
|
||||
if binPath == "" {
|
||||
binPath = "/usr/local/bin/wkhtmltopdf"
|
||||
}
|
||||
|
||||
url := configService.GetSiteUrl() + "/note/toPdf?noteId=" + noteId + "&appKey=" + appKey
|
||||
// cc := binPath + " --no-stop-slow-scripts --javascript-delay 10000 \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
// cc := binPath + " \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
// 等待--window-status为done的状态
|
||||
// http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html
|
||||
// wkhtmltopdf参数大全
|
||||
var cc string
|
||||
if note.IsMarkdown {
|
||||
cc = binPath + " --window-status done \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
} else {
|
||||
cc = binPath + " \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
}
|
||||
|
||||
cmd := exec.Command("/bin/sh", "-c", cc)
|
||||
_, err := cmd.Output()
|
||||
if err != nil {
|
||||
return c.RenderText("export pdf error. " + fmt.Sprintf("%v", err))
|
||||
}
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
return c.RenderText("export pdf error. " + fmt.Sprintf("%v", err))
|
||||
}
|
||||
// http://stackoverflow.com/questions/8588818/chrome-pdf-display-duplicate-headers-received-from-the-server
|
||||
// filenameReturn = strings.Replace(filenameReturn, ",", "-", -1)
|
||||
filenameReturn := note.Title
|
||||
filenameReturn = FixFilename(filenameReturn)
|
||||
if filenameReturn == "" {
|
||||
filenameReturn = "Untitled.pdf"
|
||||
} else {
|
||||
filenameReturn += ".pdf"
|
||||
}
|
||||
return c.RenderBinary(file, filenameReturn, revel.Attachment, time.Now()) // revel.Attachment
|
||||
}
|
||||
|
||||
// 设置/取消Blog; 置顶
|
||||
func (c Note) SetNote2Blog(noteId string, isBlog, isTop bool) revel.Result {
|
||||
re := noteService.ToBlog(c.GetUserId(), noteId, isBlog, isTop)
|
||||
|
||||
@@ -73,15 +73,9 @@ func (c AdminSetting) DoDemo(demoUsername, demoPassword string) revel.Result {
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
// ToImage
|
||||
// 长微博的bin路径phantomJs
|
||||
func (c AdminSetting) ToImage() revel.Result {
|
||||
c.RenderArgs["toImageBinPath"] = configService.GetGlobalStringConfig("toImageBinPath")
|
||||
return c.RenderTemplate("admin/setting/toImage.html");
|
||||
}
|
||||
func (c AdminSetting) DoToImage(toImageBinPath string) revel.Result {
|
||||
func (c AdminSetting) ExportPdf(path string) revel.Result {
|
||||
re := info.NewRe()
|
||||
re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "toImageBinPath", toImageBinPath)
|
||||
re.Ok = configService.UpdateGlobalStringConfig(c.GetUserId(), "exportPdfBinPath", path)
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"os/exec"
|
||||
"os"
|
||||
// "github.com/leanote/leanote/app/types"
|
||||
// "io/ioutil"
|
||||
// "fmt"
|
||||
@@ -580,3 +582,83 @@ func (c ApiNote) GetHistories(noteId string) revel.Result {
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
*/
|
||||
|
||||
// 0.2 新增
|
||||
// 导出成PDF
|
||||
// test localhost:9000/api/note/exportPdf?noteId=554f07bf05fcd15fa9000000&token=562211dc99c37ba6a7000001
|
||||
func (c ApiNote) ExportPdf(noteId string) revel.Result {
|
||||
re := info.NewApiRe()
|
||||
userId := c.getUserId()
|
||||
if noteId == "" {
|
||||
re.Msg = "noteNotExists"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
note := noteService.GetNoteById(noteId)
|
||||
if note.NoteId == "" {
|
||||
re.Msg = "noteNotExists"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
noteUserId := note.UserId.Hex()
|
||||
// 是否有权限
|
||||
if noteUserId != userId {
|
||||
// 是否是有权限协作的
|
||||
if !note.IsBlog && !shareService.HasReadPerm(noteUserId, userId, noteId) {
|
||||
re.Msg = "noteNotExists"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
}
|
||||
|
||||
// path 判断是否需要重新生成之
|
||||
guid := NewGuid()
|
||||
fileUrlPath := "files/" + Digest3(noteUserId) + "/" + noteUserId + "/" + Digest2(guid) + "/images/pdf"
|
||||
dir := revel.BasePath + "/" + fileUrlPath
|
||||
if !MkdirAll(dir) {
|
||||
re.Msg = "noDir"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
filename := guid + ".pdf"
|
||||
path := dir + "/" + filename
|
||||
|
||||
appKey, _ := revel.Config.String("app.secretLeanote")
|
||||
if appKey == "" {
|
||||
appKey, _ = revel.Config.String("app.secret")
|
||||
}
|
||||
|
||||
// 生成之
|
||||
binPath := configService.GetGlobalStringConfig("exportPdfBinPath")
|
||||
// 默认路径
|
||||
if binPath == "" {
|
||||
binPath = "/usr/local/bin/wkhtmltopdf"
|
||||
}
|
||||
|
||||
url := configService.GetSiteUrl() + "/note/toPdf?noteId=" + noteId + "&appKey=" + appKey
|
||||
var cc string
|
||||
if(note.IsMarkdown) {
|
||||
cc = binPath + " --window-status done \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
} else {
|
||||
cc = binPath + " \"" + url + "\" \"" + path + "\"" // \"" + cookieDomain + "\" \"" + cookieName + "\" \"" + cookieValue + "\""
|
||||
}
|
||||
|
||||
cmd := exec.Command("/bin/sh", "-c", cc)
|
||||
_, err := cmd.Output()
|
||||
if err != nil {
|
||||
re.Msg = "sysError"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
file, err := os.Open(path)
|
||||
if err != nil {
|
||||
re.Msg = "sysError"
|
||||
return c.RenderJson(re)
|
||||
}
|
||||
|
||||
filenameReturn := note.Title
|
||||
filenameReturn = FixFilename(filenameReturn)
|
||||
if filenameReturn == "" {
|
||||
filenameReturn = "Untitled.pdf"
|
||||
} else {
|
||||
filenameReturn += ".pdf"
|
||||
}
|
||||
return c.RenderBinary(file, filenameReturn, revel.Attachment, time.Now()) // revel.Attachment
|
||||
}
|
||||
@@ -48,7 +48,7 @@ var commonUrl = map[string]map[string]bool{"Index": map[string]bool{"Index": tru
|
||||
"FindPasswordUpdate": true,
|
||||
"Suggestion": true,
|
||||
},
|
||||
"Note": map[string]bool{"ToImage": true},
|
||||
"Note": map[string]bool{"ToPdf": true},
|
||||
"Blog": map[string]bool{"Index": true,
|
||||
"View": true,
|
||||
"AboutMe": true,
|
||||
@@ -146,9 +146,10 @@ func init() {
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Note{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Share{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &User{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Album{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &File{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Attach{})
|
||||
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Blog{})
|
||||
// revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &Blog{})
|
||||
revel.InterceptFunc(AuthInterceptor, revel.BEFORE, &NoteContentHistory{})
|
||||
|
||||
revel.OnAppStart(func() {
|
||||
|
||||
+10
@@ -180,6 +180,16 @@ func init() {
|
||||
return template.HTML(tagStr)
|
||||
}
|
||||
|
||||
// 不用revel的msg
|
||||
revel.TemplateFuncs["leaMsg"] = func(renderArgs map[string]interface{}, key string) template.HTML {
|
||||
locale, _ := renderArgs[revel.CurrentLocaleRenderArg].(string)
|
||||
str := revel.Message(locale, key)
|
||||
if strings.HasPrefix(str, "???") {
|
||||
str = key
|
||||
}
|
||||
return template.HTML(str);
|
||||
}
|
||||
|
||||
// lea++
|
||||
revel.TemplateFuncs["blogTagsLea"] = func(renderArgs map[string]interface{}, tags []string, typeStr string) template.HTML {
|
||||
if tags == nil || len(tags) == 0 {
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/leanote/leanote/app/db"
|
||||
"github.com/leanote/leanote/app/info"
|
||||
. "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"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const DEFAULT_ALBUM_ID = "52d3e8ac99c37b7f0d000001"
|
||||
@@ -115,6 +119,53 @@ func (this *FileService) UpdateImage(userId, fileId, title string) bool {
|
||||
return db.UpdateByIdAndUserIdField(db.Files, fileId, userId, "Title", title)
|
||||
}
|
||||
|
||||
func (this *FileService) GetFileBase64(userId, fileId string) (str string, mine string) {
|
||||
defer func() { // 必须要先声明defer,否则不能捕获到panic异常
|
||||
if err := recover(); err != nil {
|
||||
fmt.Println(err) // 这里的err其实就是panic传入的内容,55
|
||||
}
|
||||
}()
|
||||
|
||||
path := this.GetFile(userId, fileId)
|
||||
|
||||
if path == "" {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
path = revel.BasePath + "/" + strings.TrimLeft(path, "/")
|
||||
|
||||
ff, err := ioutil.ReadFile(path)
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
|
||||
e64 := base64.StdEncoding
|
||||
maxEncLen := e64.EncodedLen(len(ff))
|
||||
encBuf := make([]byte, maxEncLen)
|
||||
|
||||
e64.Encode(encBuf, ff)
|
||||
|
||||
mime := http.DetectContentType(ff)
|
||||
|
||||
str = string(encBuf)
|
||||
return str, mime
|
||||
}
|
||||
|
||||
// 得到图片base64, 图片要在之前添加data:image/png;base64,
|
||||
func (this *FileService) GetImageBase64(userId, fileId string) string {
|
||||
|
||||
str, mime := this.GetFileBase64(userId, fileId)
|
||||
if str == "" {
|
||||
return ""
|
||||
}
|
||||
switch mime {
|
||||
case "image/gif", "image/jpeg", "image/pjpeg", "image/png", "image/tiff":
|
||||
return fmt.Sprintf("data:%s;base64,%s", mime, str)
|
||||
default:
|
||||
}
|
||||
return "data:image/png;base64," + str
|
||||
}
|
||||
|
||||
// 获取文件路径
|
||||
// 要判断是否具有权限
|
||||
// userId是否具有fileId的访问权限
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
</a>
|
||||
</li>
|
||||
|
||||
|
||||
<li id="adminUserNav">
|
||||
<a href="#">
|
||||
<i class="fa fa-users icon">
|
||||
@@ -157,7 +156,7 @@
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/shareNote">
|
||||
<a href="/admin/t?t=setting/share_note">
|
||||
<span>
|
||||
Register Share Note
|
||||
</span>
|
||||
@@ -171,6 +170,15 @@
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a href="/admin/t?t=setting/export_pdf">
|
||||
<span>
|
||||
Export PDF
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
{{template "admin/top.html" .}}
|
||||
<div class="m-b-md"> <h3 class="m-b-none">Export PDF</h3></div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-6">
|
||||
<form id="add_user_form">
|
||||
<section class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="form-group">
|
||||
<label>Wkhtmltopdf Binary Path</label>
|
||||
<input type="text" class="form-control" placeholder="/usr/local/bin/wkhtmltopdf" name="path" value="{{.str.exportPdfBinPath}}">
|
||||
Leanote use <a target="_blank" href="http://wkhtmltopdf.org">wkhtmltopdf</a> to export pdf. You should install it on your server.
|
||||
<br />
|
||||
Please input the path that wkhtmltopdf installed, e.g. <code>/usr/local/bin/wkhtmltopdf</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="panel-footer text-right bg-light lter">
|
||||
<button type="submit" id="submit" class="btn btn-success btn-s-xs">Submit</button>
|
||||
</footer>
|
||||
</section>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "admin/footer.html" .}}
|
||||
<script src="/public/admin/js/jquery-validation-1.13.0/jquery.validate.js"></script>
|
||||
<script>
|
||||
$(function() {
|
||||
init_validator("#add_user_form");
|
||||
|
||||
$("#submit").click(function(e){
|
||||
e.preventDefault();
|
||||
var t = this;
|
||||
if($("#add_user_form").valid()) {
|
||||
$(t).button('loading');
|
||||
ajaxPost("/adminSetting/exportPdf", getFormJsonData("add_user_form"), function(ret){
|
||||
$(t).button('reset')
|
||||
if(!ret.Ok) {
|
||||
art.alert(ret.Msg)
|
||||
} else {
|
||||
art.tips("Success");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
{{template "admin/end.html" .}}
|
||||
File renamed without changes.
@@ -0,0 +1,166 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<title>
|
||||
Leanote Album Image Manager
|
||||
</title>
|
||||
|
||||
<link href="/css/bootstrap-min.css" rel="stylesheet" />
|
||||
<link href="/css/font-awesome-4.2.0/css/font-awesome-min.css" rel="stylesheet" />
|
||||
<link href="/public/album/css/style-min.css" rel="stylesheet" />
|
||||
|
||||
</head>
|
||||
<body class="md" id="body">
|
||||
<div style="margin: 3px;">
|
||||
<div class="holder"></div>
|
||||
|
||||
<div class="tabs">
|
||||
<ul id="myTab" class="nav nav-tabs">
|
||||
<li class="active"><a href="#images" data-toggle="tab">{{leaMsg . "Images"}}</a></li>
|
||||
<li class=""><a href="#uploadTab" data-toggle="tab">{{leaMsg . "Upload"}}</a></li>
|
||||
<li class=""><a href="#url" data-toggle="tab">{{leaMsg . "Image URL"}}</a></li>
|
||||
</ul>
|
||||
<div id="myTabContent" class="tab-content">
|
||||
<div class="tab-pane fade active in" id="images">
|
||||
<!-- tools -->
|
||||
<div>
|
||||
<form class="form-inline" role="form">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="albums">{{leaMsg . "Albums"}}:</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<select class="form-control" id="albumsForList">
|
||||
<option value="">{{leaMsg . "Default"}}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input class="form-control" type="text" id="key" placeholder="{{leaMsg . "File title search"}}"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<a href="javascript:;" title="refresh" id="refresh"><span class="fa fa-refresh"></span></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="imagePage">
|
||||
<ul id="imageList" class="clearfix">
|
||||
</ul>
|
||||
|
||||
<!-- pagination -->
|
||||
<div id="paginationContainer">
|
||||
<ul class="pagination">
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div id="imageMask">
|
||||
<div id="noImages">
|
||||
<p>{{msg . "No Images"}}!</p>
|
||||
<btn class="btn btn-default" id="goAddImageBtn">{{leaMsg . "Go to upload images"}}</btn>
|
||||
</div>
|
||||
<div id="loading">
|
||||
loading....
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab-pane fade" id="uploadTab">
|
||||
<div>
|
||||
<form class="form-inline" role="form">
|
||||
<div class="form-group" id="albumSelect">
|
||||
<label class="control-label" for="albums">{{leaMsg . "Albums"}}:</label>
|
||||
|
||||
<select class="form-control" id="albumsForUpload">
|
||||
<option value="">{{leaMsg . "Default"}}</option>
|
||||
</select>
|
||||
|
||||
<a href="javascript:;" id="deleteAlbumBtn">{{leaMsg . "Delete"}}</a> |
|
||||
<a href="javascript:;" id="renameAlbumBtn">{{leaMsg . "Rename"}}</a> |
|
||||
<a href="javascript:;" id="addAlbumBtn">{{leaMsg . "Add"}}</a>
|
||||
</div>
|
||||
|
||||
<!-- rename or add album -->
|
||||
<div class="form-group" style="display: none" id="addOrUpdateAlbumForm">
|
||||
<input type="text" class="form-control" style="width: 150px" id="albumName">
|
||||
<button class="btn btn-success" type="button" id="addOrUpdateAlbumBtn">{{leaMsg . "Add Album"}}</button>
|
||||
<button class="btn btn-default" type="button" id="cancelAlbumBtn">{{leaMsg . "Cancel"}}</button>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<span id="msg" class="alert alert-success" style="padding: 3px; display: none"></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<form id="upload" method="post" action="/file/uploadImageLeaui" enctype="multipart/form-data" style="margin-top: 5px;">
|
||||
<div id="drop">
|
||||
<a class="btn btn-default">
|
||||
{{leaMsg . "Click to upload images Or Drop images to here"}}
|
||||
</a>
|
||||
<input type="file" name="file" multiple />
|
||||
</div>
|
||||
<ul id="upload-msg">
|
||||
</ul>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="url">
|
||||
<form class="form-inline" id="imageUrlForm" style="">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="imageUrl">{{leaMsg . "Image URL"}}:</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" id="imageUrl" size="51"/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button class="btn btn-success" id="addImageUrlBtn">{{leaMsg . "Add Image"}}</button>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="alert alert-danger" id="msgForUrl"
|
||||
style="display: none; padding: 5px; width: 150px;">
|
||||
{{leaMsg . "Can't load this url"}}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ul id="preview" class="clearfix">
|
||||
</ul>
|
||||
|
||||
<!--
|
||||
<div id="previewAttrs" style="margin-left: 10px">
|
||||
<form class="form-inline" role="form">
|
||||
<div class="form-group">
|
||||
<input class="form-control" id="attrTitle" placeholder="title" size="20" disabled/>
|
||||
<input class="form-control" id="attrWidth" placeholder="width" size="5" disabled/> X
|
||||
<input class="form-control" id="attrHeight" placeholder="height" size="5" disabled/>
|
||||
<label><input type="checkbox" value="1" id="attrConstrain" disabled/> Constrain proportions</label>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
// javascript global configration
|
||||
var G = {};
|
||||
G.imageSrcPrefix = 'upload';
|
||||
G.perPageItems = 12;
|
||||
G.maxSelected = 1;
|
||||
var UrlPrefix = '{{.siteUrl}}';
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<script src="/js/jquery-1.9.0.min.js"></script>
|
||||
<script src="/js/bootstrap-min.js"></script>
|
||||
<script src="/js/plugins/libs-min/fileupload.js"></script>
|
||||
<script src="/js/jquery.pagination.js"></script>
|
||||
<script src="/public/album/js/main.js"></script>
|
||||
-->
|
||||
|
||||
<script src="/public/album/js/main.all.js"></script>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,124 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{.title}}</title>
|
||||
<link href="/css/bootstrap.css" rel="stylesheet">
|
||||
<link id="styleLink" href="/css/pdf.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
margin-top: 30px;
|
||||
}
|
||||
table {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
table th, table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
table th {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
table tr:nth-child(2n) {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
.mce-item-table, .mce-item-table td, .mce-item-table th, .mce-item-table caption {
|
||||
border: 1px solid #ddd;
|
||||
border-collapse: collapse;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
<h1 class="title tex2jax_ignore">
|
||||
{{if .blog.Title}}
|
||||
{{.blog.Title}}
|
||||
{{else}}
|
||||
Untitled
|
||||
{{end}}
|
||||
</h1>
|
||||
<div class="created-time">
|
||||
<!--
|
||||
{{ if .userBlog.Logo}}
|
||||
<img src="{{.userBlog.Logo}}" id="logo">
|
||||
{{else}}
|
||||
<img src="{{$.siteUrl}}/images/blog/default_avatar.png" id="logo">
|
||||
{{end}}
|
||||
{{.userInfo.Username}}
|
||||
-->
|
||||
{{if .blog.Tags}}
|
||||
<img src="{{$.siteUrl}}/images/blog/tag.png" id="tag">
|
||||
{{blogTagsForExport $ .blog.Tags}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="desc">
|
||||
{{if .blog.IsMarkdown }}
|
||||
<div id="markdownContent" style="display: none">
|
||||
<!-- 用textarea装html, 防止得到的值失真 -->
|
||||
<textarea>
|
||||
{{.content | raw}}
|
||||
</textarea>
|
||||
</div>
|
||||
<div id="parsedContent">
|
||||
</div>
|
||||
{{else}}
|
||||
{{.content | raw}}
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<div id="footer">
|
||||
<p class="split"></p>
|
||||
<a href="http://leanote.com"><img src="{{.siteUrl}}/images/logo/leanote_icon_blue.png" id="leanote_logo"/></a>
|
||||
<p>
|
||||
<a href="http://leanote.com">Leanote</a>
|
||||
<br />
|
||||
<a href="http://leanote.com/service">Upgrade Account</a>
|
||||
</p>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<script src="{{.siteUrl}}/js/jquery-1.9.0.min.js"></script>
|
||||
|
||||
<link href="{{.siteUrl}}/public/mdeditor/editor/google-code-prettify/prettify.css" type="text/css" rel="stylesheet">
|
||||
<script src="{{.siteUrl}}/public/mdeditor/editor/google-code-prettify/prettify.js"></script>
|
||||
|
||||
<script>
|
||||
function ok() {
|
||||
setTimeout(function() {
|
||||
window.status = 'done';
|
||||
}, 0);
|
||||
}
|
||||
</script>
|
||||
|
||||
{{if not .blog.IsMarkdown }}
|
||||
<script>
|
||||
$("pre").addClass("prettyprint");
|
||||
prettyPrint();
|
||||
ok();
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
{{if .blog.IsMarkdown }}
|
||||
<script src="/public/libs/md2html/md2html_for_export.js"></script>
|
||||
<script>
|
||||
var content = $.trim($("#markdownContent textarea").val());
|
||||
md2Html(content, $("#parsedContent"), function(html) {
|
||||
$("pre").addClass("prettyprint");
|
||||
prettyPrint();
|
||||
ok();
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
</body>
|
||||
</html>
|
||||
@@ -571,7 +571,7 @@ function log(o) {
|
||||
<!-- 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
|
||||
{{leaMsg . "Drop images to here"}}
|
||||
<input type="file" name="file" multiple style="display: none"/>
|
||||
</div>
|
||||
<ul id="uploadMsg">
|
||||
@@ -611,7 +611,7 @@ function log(o) {
|
||||
<!-- 帮助 -->
|
||||
<ul class="nav left-buttons">
|
||||
<li class="wmd-button-group6 btn-group">
|
||||
<li class="wmd-button btn btn-success" id="wmd-help-button" title="Markdown syntax" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li>
|
||||
<li class="wmd-button btn btn-success" id="wmd-help-button" title="{{msg . "Markdown syntax"}}" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -691,32 +691,6 @@ function log(o) {
|
||||
</div>
|
||||
|
||||
<!-- mdEditor -->
|
||||
<!-- v2 -->
|
||||
<div class="modal fade modal-insert-link">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Hyperlink</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Please provide the link URL and an optional title:</p>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-globe"></i></span><input
|
||||
id="input-insert-link" type="text" class="col-sm-5 form-control"
|
||||
placeholder='http://example.com/ "optional title"' />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
|
||||
<a href="#" class="btn btn-primary action-insert-link"
|
||||
data-dismiss="modal">OK</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 插入图片 -->
|
||||
<div class="modal fade modal-insert-image">
|
||||
<div class="modal-dialog" style="width: 840px;max-width:100%;">
|
||||
@@ -724,15 +698,15 @@ function log(o) {
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Image</h4>
|
||||
<h4 class="modal-title">{{msg . "Image"}}</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="padding-top: 0; padding-bottom: 0">
|
||||
<iframe name="mdImageManager" style="width: 100%; height: 350px" scrolling="no" id="leauiIfrForMD" src="" frameborder="0"></iframe>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn btn-default"
|
||||
data-dismiss="modal">Cancel</a> <a href="#"
|
||||
class="btn btn-primary action-insert-image" data-dismiss="modal">Insert Image</a>
|
||||
data-dismiss="modal">{{msg . "Cancel"}}</a> <a href="#"
|
||||
class="btn btn-primary action-insert-image" data-dismiss="modal">{{msg . "Insert Image"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -571,7 +571,7 @@ function log(o) {
|
||||
<!-- 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
|
||||
{{leaMsg . "Drop images to here"}}
|
||||
<input type="file" name="file" multiple style="display: none"/>
|
||||
</div>
|
||||
<ul id="uploadMsg">
|
||||
@@ -611,7 +611,7 @@ function log(o) {
|
||||
<!-- 帮助 -->
|
||||
<ul class="nav left-buttons">
|
||||
<li class="wmd-button-group6 btn-group">
|
||||
<li class="wmd-button btn btn-success" id="wmd-help-button" title="Markdown syntax" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li>
|
||||
<li class="wmd-button btn btn-success" id="wmd-help-button" title="{{msg . "Markdown syntax"}}" style="left: 0px; display: none;"><span style="display: none; background-position: 0px 0px;"></span><i class="fa fa-question-circle"></i></li>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -691,32 +691,6 @@ function log(o) {
|
||||
</div>
|
||||
|
||||
<!-- mdEditor -->
|
||||
<!-- v2 -->
|
||||
<div class="modal fade modal-insert-link">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Hyperlink</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Please provide the link URL and an optional title:</p>
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-globe"></i></span><input
|
||||
id="input-insert-link" type="text" class="col-sm-5 form-control"
|
||||
placeholder='http://example.com/ "optional title"' />
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn btn-default" data-dismiss="modal">Cancel</a>
|
||||
<a href="#" class="btn btn-primary action-insert-link"
|
||||
data-dismiss="modal">OK</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 插入图片 -->
|
||||
<div class="modal fade modal-insert-image">
|
||||
<div class="modal-dialog" style="width: 840px;max-width:100%;">
|
||||
@@ -724,15 +698,15 @@ function log(o) {
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"
|
||||
aria-hidden="true">×</button>
|
||||
<h4 class="modal-title">Image</h4>
|
||||
<h4 class="modal-title">{{msg . "Image"}}</h4>
|
||||
</div>
|
||||
<div class="modal-body" style="padding-top: 0; padding-bottom: 0">
|
||||
<iframe name="mdImageManager" style="width: 100%; height: 350px" scrolling="no" id="leauiIfrForMD" src="" frameborder="0"></iframe>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<a href="#" class="btn btn-default"
|
||||
data-dismiss="modal">Cancel</a> <a href="#"
|
||||
class="btn btn-primary action-insert-image" data-dismiss="modal">Insert Image</a>
|
||||
data-dismiss="modal">{{msg . "Cancel"}}</a> <a href="#"
|
||||
class="btn btn-primary action-insert-image" data-dismiss="modal">{{msg . "Insert Image"}}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ SP=$(cd "$(dirname "$0")"; pwd)
|
||||
tmp="/Users/life/Desktop/leanote_release"
|
||||
|
||||
# version
|
||||
V="v1.0.1"
|
||||
V="v1.1"
|
||||
|
||||
##=================================
|
||||
# 1. 先build 成 3个平台, 2种bit = 6种
|
||||
|
||||
@@ -38,6 +38,8 @@ POST /findPasswordUpdate Auth.FindPasswordUpdate
|
||||
* /note/copySharedNote Note.CopySharedNote
|
||||
* /note/searchNoteByTags Note.SearchNoteByTags
|
||||
* /note/setNote2Blog Note.SetNote2Blog
|
||||
* /note/exportPdf Note.ExportPDF
|
||||
* /note/toPdf Note.ToPdf
|
||||
# pjax
|
||||
GET /note/:noteId Note.Index
|
||||
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ notGoodPassword=Tt's not a good password, the length is at least 6
|
||||
|
||||
# 笔记主页
|
||||
myBlog=Blog
|
||||
history=History
|
||||
history=Histories
|
||||
save=Save
|
||||
editorTips=Tips
|
||||
editorTipsInfo=<h4>1. Short cuts</h4>ctrl+shift+c Toggle code<h4>2. shift+enter Get out of current block</h4> eg. <img src="/images/outofcode.png" style="width: 90px"/> in this situation you can use shift+enter to get out of current code block.
|
||||
|
||||
@@ -141,9 +141,13 @@ Are you sure to delete it ?=确认删除?
|
||||
Insert link into content=将附件链接插入到内容中
|
||||
Download=下载
|
||||
Delete=删除
|
||||
Drop images to here=将图片拖动至此
|
||||
|
||||
update=更新
|
||||
create=创建
|
||||
Update Time=更新时间
|
||||
Create Time=创建时间
|
||||
Post Url=博文链接
|
||||
|
||||
demoRegister=<a href="/register">立即注册</a>
|
||||
|
||||
@@ -395,6 +399,64 @@ sharePwd=查看密码
|
||||
cancelShare=取消分享
|
||||
getShareLinkAndPwd=生成该笔记的分享链接和密码
|
||||
|
||||
# markdown editor
|
||||
|
||||
Hyperlink=超链接
|
||||
Please provide the link URL and an optional title=请填写链接和一个可选的标题
|
||||
optional title=可选标题
|
||||
Ok=确认
|
||||
Cancel=取消
|
||||
Strong=粗体
|
||||
strong text=粗体
|
||||
Emphasis=斜体
|
||||
emphasized text=斜体
|
||||
Blockquote=引用
|
||||
Code Sample=代码
|
||||
enter code here=代码
|
||||
Image=图片
|
||||
Heading=标题
|
||||
Numbered List=有序列表
|
||||
Bulleted List=无序列表
|
||||
List item=项目
|
||||
Horizontal Rule=水平线
|
||||
Markdown syntax=Markdown 语法
|
||||
Undo=撤销
|
||||
Redo=重做
|
||||
enter image description here=图片标题
|
||||
enter link description here=链接标题
|
||||
|
||||
Insert Image=插入
|
||||
|
||||
# album image
|
||||
Images=图片
|
||||
Upload=上传
|
||||
Image URL=图片地址
|
||||
Albums=相册
|
||||
Default=默认
|
||||
File title search=通过标题搜索
|
||||
Go to upload images=去上传图片
|
||||
Rename=重命名
|
||||
Add=添加
|
||||
Add Album=添加相册
|
||||
Add Image=添加图片
|
||||
Can't load this url=不能载入该图片
|
||||
No Images=无图片
|
||||
Click to upload images Or Drop images to here=点击上传图片或将图片拖至此
|
||||
|
||||
Cannot delete default album=不能删除默认相册
|
||||
Cannot rename default album=不能重命名默认相册
|
||||
This album has images, please delete it's images at first.=相册内有图片, 不能删除
|
||||
|
||||
Rename Album=重命名
|
||||
Add Success!=添加成功!
|
||||
Rename Success!=重命名成功!
|
||||
Delete Success!=删除成功
|
||||
Are you sure to delete this image ?=确定删除该图片?
|
||||
click to remove this image=删除图片
|
||||
error=错误
|
||||
Error=错误
|
||||
Prev=上一页
|
||||
Next=下一页
|
||||
|
||||
# 必须要加这个, 奇怪
|
||||
[CN]
|
||||
@@ -907,7 +907,7 @@ body {
|
||||
margin: 0;
|
||||
}
|
||||
a {
|
||||
color: #2e3e4e;
|
||||
color: #346EA9;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover,
|
||||
|
||||
@@ -1088,7 +1088,7 @@ body {
|
||||
}
|
||||
|
||||
a {
|
||||
color: #2e3e4e;
|
||||
color: #346EA9;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
#drop,#imageList li,#upload{position:relative}#imageMask,#upload-msg{position:absolute;top:0}*{font-family:'Open Sans','Helvetica Neue',Arial,'Hiragino Sans GB','Microsoft YaHei','WenQuanYi Micro Hei',sans-serif}#drop{width:99%;min-height:260px;border:1px dotted #000;z-index:2;text-align:center}#drop.in{border:2px solid #000}#drop a{left:33%;top:105px;z-index:15;position:absolute}#drop input{display:none}#upload-msg{list-style-type:none;padding-left:0;margin-left:0;right:10px;width:300px;max-height:240px;overflow:auto;z-index:3}#imageList li,#preview li,.md{overflow:hidden}.tab-pane{padding:10px}#paginationContainer{text-align:right}#imageList{margin:10px 0 0;padding:0;height:196px}#imageList li{display:inline-block;float:left;padding:0;margin:0 3px 3px 0;height:90px;width:122px;border:1px solid #eee}#imageList li .a-img{line-height:80px;display:block;text-align:center}#imageList li:hover{border:1px solid #FF7300}#imageList li.selected{border:2px solid #FF7300}#imageList li img{max-width:100%;vertical-align:middle}#imageList li .tools{position:absolute;bottom:0;left:0;right:0;background-color:#fff;padding-right:2px;text-align:right;opacity:.7}.tools .file-title{width:100px;height:20px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:left}#imageList li:hover .tools{display:block;opacity:.9}.alert{padding:5px;margin-bottom:3px}#preview{margin:3px 0 3px 10px;padding:5px 0 0;border-top:1px solid #eee}#preview li{position:relative;display:inline-block;float:left;border:1px solid #E6E5E3;background-color:#FFF;width:64px;height:64px;margin-right:10px;line-height:64px;text-align:center;color:#E1E1E1;font-size:28px;cursor:pointer}#preview li:hover{border:1px solid #FF7300}#preview li.selected{border:2px solid #FF7300}#preview li .tools{position:absolute;bottom:0;right:0;left:0;height:15px;line-height:15px;font-size:14px;text-align:right}#preview li .tools a{color:red}#imagePage{position:relative}#imageMask{background:#fff;left:0;right:0;bottom:20px;font-size:18px;text-align:center;display:none;z-index:2}#previewAttrs .form-control{width:auto}#previewAttrs label{font-weight:400}@media screen and (max-width:700px){#previewAttrs{display:none}#drop{min-height:initial;padding:10px 0}#drop a{position:initial;margin:auto}#url form{margin:0!important}.form-inline .form-group{display:inline-block;margin-bottom:0;vertical-align:middle}.form-inline .form-control{width:auto;display:inline-block}#preview li:nth-child(10),#preview li:nth-child(3n),#preview li:nth-child(4n),#preview li:nth-child(5),#preview li:nth-child(7){display:none}#imageList li{width:90px}}#imageUrlForm{min-height:260px;text-align:center;padding-top:100px}.md{position:relative;height:350px}.md #previewAttrs{display:none}.md #preview{border:none;position:absolute;bottom:0;left:0;z-index:3}.md #drop{min-height:250px}#albumsForUpload{width:150px}
|
||||
@@ -0,0 +1,243 @@
|
||||
* {
|
||||
font-family: 'Open Sans', 'Helvetica Neue', Arial, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
|
||||
}
|
||||
/* upload */
|
||||
#upload {
|
||||
position: relative;
|
||||
}
|
||||
#drop {
|
||||
position: relative;
|
||||
width: 99%;
|
||||
min-height: 260px;
|
||||
border: 1px dotted #000000;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
}
|
||||
#drop.in {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
#drop a {
|
||||
left: 33%;
|
||||
top: 105px;
|
||||
z-index: 15;
|
||||
position: absolute;
|
||||
}
|
||||
#drop input {
|
||||
display: none;
|
||||
}
|
||||
#upload-msg {
|
||||
list-style-type: none;
|
||||
padding-left: 0px;
|
||||
margin-left: 0px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
width: 300px;
|
||||
max-height: 240px;
|
||||
overflow: auto;
|
||||
z-index: 3;
|
||||
}
|
||||
/**/
|
||||
.tab-pane {
|
||||
padding: 10px;
|
||||
}
|
||||
#paginationContainer {
|
||||
text-align: right;
|
||||
}
|
||||
#imageList {
|
||||
margin: 0;
|
||||
margin-top: 10px;
|
||||
padding: 0;
|
||||
height: 196px;
|
||||
}
|
||||
#imageList li {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
padding: 0;
|
||||
margin: 0 3px 3px 0;
|
||||
position: relative;
|
||||
height: 90px;
|
||||
width: 122px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
#imageList li .a-img {
|
||||
line-height: 80px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
#imageList li:hover {
|
||||
border: 1px solid #FF7300;
|
||||
}
|
||||
#imageList li.selected {
|
||||
border: solid 2px #FF7300;
|
||||
}
|
||||
#imageList li img {
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#imageList li .tools {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #fff;
|
||||
padding-right: 2px;
|
||||
text-align: right;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.tools .file-title {
|
||||
width: 100px;
|
||||
height: 20px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
}
|
||||
#imageList li:hover .tools {
|
||||
display: block;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.alert {
|
||||
padding: 5px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.tabs {
|
||||
/*height: 350px;*/
|
||||
}
|
||||
#preview {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-left: 10px;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
padding-top: 5px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
#preview li {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
border: solid 1px #E6E5E3;
|
||||
background-color: #FFF;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
margin-right: 10px;
|
||||
line-height: 64px;
|
||||
text-align: center;
|
||||
/*font-style: italic;*/
|
||||
color: #E1E1E1;
|
||||
font-size: 28px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#preview li:hover {
|
||||
border: 1px solid #FF7300;
|
||||
}
|
||||
#preview li.selected {
|
||||
border: solid 2px #FF7300;
|
||||
}
|
||||
#preview li .tools {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
font-size: 14px;
|
||||
text-align: right;
|
||||
}
|
||||
#preview li .tools a {
|
||||
color: red;
|
||||
}
|
||||
/**/
|
||||
#imagePage {
|
||||
position: relative;
|
||||
}
|
||||
#imageMask {
|
||||
position: absolute;
|
||||
background: #fff;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 20px;
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
display: none;
|
||||
z-index: 2;
|
||||
}
|
||||
/**/
|
||||
#previewAttrs .form-control {
|
||||
width: auto;
|
||||
}
|
||||
#previewAttrs label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@media screen and (max-width:700px) {
|
||||
#previewAttrs {
|
||||
display: none;
|
||||
}
|
||||
#drop {
|
||||
min-height: initial;
|
||||
padding: 10px 0;
|
||||
}
|
||||
#drop a {
|
||||
position: initial;
|
||||
margin: auto;
|
||||
}
|
||||
#url form {
|
||||
margin: 0 !important;
|
||||
margin: auto;
|
||||
}
|
||||
.form-inline .form-group {
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.form-inline .form-control {
|
||||
width: auto;
|
||||
display: inline-block;
|
||||
}
|
||||
#preview li:nth-child(3n),
|
||||
#preview li:nth-child(4n),
|
||||
#preview li:nth-child(5),
|
||||
#preview li:nth-child(7),
|
||||
#preview li:nth-child(10)
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
#imageList li {
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
#imageUrlForm {
|
||||
min-height: 260px;
|
||||
text-align: center;
|
||||
padding-top: 100px;
|
||||
}
|
||||
|
||||
.md {
|
||||
position: relative;
|
||||
height: 350px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.md #previewAttrs {
|
||||
display: none;
|
||||
|
||||
}
|
||||
.md #preview {
|
||||
border: none;
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
.md #drop {
|
||||
min-height: 250px;
|
||||
}
|
||||
|
||||
#albumsForUpload {
|
||||
width: 150px;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 723 B |
@@ -0,0 +1,7 @@
|
||||
!function(e,t){"use strict";function n(e){var t=e.length,n=se.type(e);return se.isWindow(e)?!1:1===e.nodeType&&t?!0:"array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)}function r(e){var t=Te[e]={};return se.each(e.match(le)||[],function(e,n){t[n]=!0}),t}function i(e,n,r,i){if(se.acceptData(e)){var o,a,s=se.expando,u="string"==typeof n,l=e.nodeType,c=l?se.cache:e,f=l?e[s]:e[s]&&s;if(f&&c[f]&&(i||c[f].data)||!u||r!==t)return f||(l?e[s]=f=K.pop()||se.guid++:f=s),c[f]||(c[f]={},l||(c[f].toJSON=se.noop)),("object"==typeof n||"function"==typeof n)&&(i?c[f]=se.extend(c[f],n):c[f].data=se.extend(c[f].data,n)),o=c[f],i||(o.data||(o.data={}),o=o.data),r!==t&&(o[se.camelCase(n)]=r),u?(a=o[n],null==a&&(a=o[se.camelCase(n)])):a=o,a}}function o(e,t,n){if(se.acceptData(e)){var r,i,o,a=e.nodeType,u=a?se.cache:e,l=a?e[se.expando]:se.expando;if(u[l]){if(t&&(r=n?u[l]:u[l].data)){se.isArray(t)?t=t.concat(se.map(t,se.camelCase)):t in r?t=[t]:(t=se.camelCase(t),t=t in r?[t]:t.split(" "));for(i=0,o=t.length;o>i;i++)delete r[t[i]];if(!(n?s:se.isEmptyObject)(r))return}(n||(delete u[l].data,s(u[l])))&&(a?se.cleanData([e],!0):se.support.deleteExpando||u!=u.window?delete u[l]:u[l]=null)}}}function a(e,n,r){if(r===t&&1===e.nodeType){var i="data-"+n.replace(Ne,"-$1").toLowerCase();if(r=e.getAttribute(i),"string"==typeof r){try{r="true"===r?!0:"false"===r?!1:"null"===r?null:+r+""===r?+r:we.test(r)?se.parseJSON(r):r}catch(o){}se.data(e,n,r)}else r=t}return r}function s(e){var t;for(t in e)if(("data"!==t||!se.isEmptyObject(e[t]))&&"toJSON"!==t)return!1;return!0}function u(){return!0}function l(){return!1}function c(e,t){do e=e[t];while(e&&1!==e.nodeType);return e}function f(e,t,n){if(t=t||0,se.isFunction(t))return se.grep(e,function(e,r){var i=!!t.call(e,r,e);return i===n});if(t.nodeType)return se.grep(e,function(e){return e===t===n});if("string"==typeof t){var r=se.grep(e,function(e){return 1===e.nodeType});if(We.test(t))return se.filter(t,r,!n);t=se.filter(t,r)}return se.grep(e,function(e){return se.inArray(e,t)>=0===n})}function p(e){var t=ze.split("|"),n=e.createDocumentFragment();if(n.createElement)for(;t.length;)n.createElement(t.pop());return n}function d(e,t){return e.getElementsByTagName(t)[0]||e.appendChild(e.ownerDocument.createElement(t))}function h(e){var t=e.getAttributeNode("type");return e.type=(t&&t.specified)+"/"+e.type,e}function g(e){var t=nt.exec(e.type);return t?e.type=t[1]:e.removeAttribute("type"),e}function m(e,t){for(var n,r=0;null!=(n=e[r]);r++)se._data(n,"globalEval",!t||se._data(t[r],"globalEval"))}function y(e,t){if(1===t.nodeType&&se.hasData(e)){var n,r,i,o=se._data(e),a=se._data(t,o),s=o.events;if(s){delete a.handle,a.events={};for(n in s)for(r=0,i=s[n].length;i>r;r++)se.event.add(t,n,s[n][r])}a.data&&(a.data=se.extend({},a.data))}}function v(e,t){var n,r,i;if(1===t.nodeType){if(n=t.nodeName.toLowerCase(),!se.support.noCloneEvent&&t[se.expando]){r=se._data(t);for(i in r.events)se.removeEvent(t,i,r.handle);t.removeAttribute(se.expando)}"script"===n&&t.text!==e.text?(h(t).text=e.text,g(t)):"object"===n?(t.parentNode&&(t.outerHTML=e.outerHTML),se.support.html5Clone&&e.innerHTML&&!se.trim(t.innerHTML)&&(t.innerHTML=e.innerHTML)):"input"===n&&Ze.test(e.type)?(t.defaultChecked=t.checked=e.checked,t.value!==e.value&&(t.value=e.value)):"option"===n?t.defaultSelected=t.selected=e.defaultSelected:("input"===n||"textarea"===n)&&(t.defaultValue=e.defaultValue)}}function b(e,n){var r,i,o=0,a=e.getElementsByTagName!==t?e.getElementsByTagName(n||"*"):e.querySelectorAll!==t?e.querySelectorAll(n||"*"):t;if(!a)for(a=[],r=e.childNodes||e;null!=(i=r[o]);o++)!n||se.nodeName(i,n)?a.push(i):se.merge(a,b(i,n));return n===t||n&&se.nodeName(e,n)?se.merge([e],a):a}function x(e){Ze.test(e.type)&&(e.defaultChecked=e.checked)}function T(e,t){if(t in e)return t;for(var n=t.charAt(0).toUpperCase()+t.slice(1),r=t,i=wt.length;i--;)if(t=wt[i]+n,t in e)return t;return r}function w(e,t){return e=t||e,"none"===se.css(e,"display")||!se.contains(e.ownerDocument,e)}function N(e,t){for(var n,r=[],i=0,o=e.length;o>i;i++)n=e[i],n.style&&(r[i]=se._data(n,"olddisplay"),t?(r[i]||"none"!==n.style.display||(n.style.display=""),""===n.style.display&&w(n)&&(r[i]=se._data(n,"olddisplay",S(n.nodeName)))):r[i]||w(n)||se._data(n,"olddisplay",se.css(n,"display")));for(i=0;o>i;i++)n=e[i],n.style&&(t&&"none"!==n.style.display&&""!==n.style.display||(n.style.display=t?r[i]||"":"none"));return e}function C(e,t,n){var r=gt.exec(t);return r?Math.max(0,r[1]-(n||0))+(r[2]||"px"):t}function k(e,t,n,r,i){for(var o=n===(r?"border":"content")?4:"width"===t?1:0,a=0;4>o;o+=2)"margin"===n&&(a+=se.css(e,n+Tt[o],!0,i)),r?("content"===n&&(a-=se.css(e,"padding"+Tt[o],!0,i)),"margin"!==n&&(a-=se.css(e,"border"+Tt[o]+"Width",!0,i))):(a+=se.css(e,"padding"+Tt[o],!0,i),"padding"!==n&&(a+=se.css(e,"border"+Tt[o]+"Width",!0,i)));return a}function E(e,t,n){var r=!0,i="width"===t?e.offsetWidth:e.offsetHeight,o=ut(e),a=se.support.boxSizing&&"border-box"===se.css(e,"boxSLine truncated
|
||||
},set:function(e,n,r){return se.nodeName(e,"input")?(e.defaultValue=n,t):Ce&&Ce.set(e,n,r)}}),He||(Ce=se.valHooks.button={get:function(e,n){var r=e.getAttributeNode(n);return r&&("id"===n||"name"===n||"coords"===n?""!==r.value:r.specified)?r.value:t},set:function(e,n,r){var i=e.getAttributeNode(r);return i||e.setAttributeNode(i=e.ownerDocument.createAttribute(r)),i.value=n+="","value"===r||n===e.getAttribute(r)?n:t}},se.attrHooks.contenteditable={get:Ce.get,set:function(e,t,n){Ce.set(e,""===t?!1:t,n)}},se.each(["width","height"],function(e,n){se.attrHooks[n]=se.extend(se.attrHooks[n],{set:function(e,r){return""===r?(e.setAttribute(n,"auto"),r):t}})})),se.support.hrefNormalized||(se.each(["href","src","width","height"],function(e,n){se.attrHooks[n]=se.extend(se.attrHooks[n],{get:function(e){var r=e.getAttribute(n,2);return null==r?t:r}})}),se.each(["href","src"],function(e,t){se.propHooks[t]={get:function(e){return e.getAttribute(t,4)}}})),se.support.style||(se.attrHooks.style={get:function(e){return e.style.cssText||t},set:function(e,t){return e.style.cssText=t+""}}),se.support.optSelected||(se.propHooks.selected=se.extend(se.propHooks.selected,{get:function(e){var t=e.parentNode;return t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex),null}})),se.support.enctype||(se.propFix.enctype="encoding"),se.support.checkOn||se.each(["radio","checkbox"],function(){se.valHooks[this]={get:function(e){return null===e.getAttribute("value")?"on":e.value}}}),se.each(["radio","checkbox"],function(){se.valHooks[this]=se.extend(se.valHooks[this],{set:function(e,n){return se.isArray(n)?e.checked=se.inArray(se(e).val(),n)>=0:t}})});var qe=/^(?:input|select|textarea)$/i,_e=/^key/,Fe=/^(?:mouse|contextmenu)|click/,Oe=/^(?:focusinfocus|focusoutblur)$/,Be=/^([^.]*)(?:\.(.+)|)$/;se.event={global:{},add:function(e,n,r,i,o){var a,s,u,l,c,f,p,d,h,g,m,y=3!==e.nodeType&&8!==e.nodeType&&se._data(e);if(y){for(r.handler&&(a=r,r=a.handler,o=a.selector),r.guid||(r.guid=se.guid++),(l=y.events)||(l=y.events={}),(s=y.handle)||(s=y.handle=function(e){return se===t||e&&se.event.triggered===e.type?t:se.event.dispatch.apply(s.elem,arguments)},s.elem=e),n=(n||"").match(le)||[""],c=n.length;c--;)u=Be.exec(n[c])||[],h=m=u[1],g=(u[2]||"").split(".").sort(),p=se.event.special[h]||{},h=(o?p.delegateType:p.bindType)||h,p=se.event.special[h]||{},f=se.extend({type:h,origType:m,data:i,handler:r,guid:r.guid,selector:o,needsContext:o&&se.expr.match.needsContext.test(o),namespace:g.join(".")},a),(d=l[h])||(d=l[h]=[],d.delegateCount=0,p.setup&&p.setup.call(e,i,g,s)!==!1||(e.addEventListener?e.addEventListener(h,s,!1):e.attachEvent&&e.attachEvent("on"+h,s))),p.add&&(p.add.call(e,f),f.handler.guid||(f.handler.guid=r.guid)),o?d.splice(d.delegateCount++,0,f):d.push(f),se.event.global[h]=!0;e=null}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,m=se.hasData(e)&&se._data(e);if(m&&(u=m.events)){for(t=(t||"").match(le)||[""],l=t.length;l--;)if(s=Be.exec(t[l])||[],d=g=s[1],h=(s[2]||"").split(".").sort(),d){for(f=se.event.special[d]||{},d=(r?f.delegateType:f.bindType)||d,p=u[d]||[],s=s[2]&&RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;o--;)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&f.teardown.call(e,h,m.handle)!==!1||se.removeEvent(e,d,m.handle),delete u[d])}else for(d in u)se.event.remove(e,d+t[l],n,r,!0);se.isEmptyObject(u)&&(delete m.handle,se._removeData(e,"events"))}},trigger:function(n,r,i,o){var a,s,u,l,c,f,p,d=[i||V],h=n.type||n,g=n.namespace?n.namespace.split("."):[];if(s=u=i=i||V,3!==i.nodeType&&8!==i.nodeType&&!Oe.test(h+se.event.triggered)&&(h.indexOf(".")>=0&&(g=h.split("."),h=g.shift(),g.sort()),c=0>h.indexOf(":")&&"on"+h,n=n[se.expando]?n:new se.Event(h,"object"==typeof n&&n),n.isTrigger=!0,n.namespace=g.join("."),n.namespace_re=n.namespace?RegExp("(^|\\.)"+g.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,n.result=t,n.target||(n.target=i),r=null==r?[n]:se.makeArray(r,[n]),p=se.event.special[h]||{},o||!p.trigger||p.trigger.apply(i,r)!==!1)){if(!o&&!p.noBubble&&!se.isWindow(i)){for(l=p.delegateType||h,Oe.test(l+h)||(s=s.parentNode);s;s=s.parentNode)d.push(s),u=s;u===(i.ownerDocument||V)&&d.push(u.defaultView||u.parentWindow||e)}for(a=0;(s=d[a++])&&!n.isPropagationStopped();)n.type=a>1?l:p.bindType||h,f=(se._data(s,"events")||{})[n.type]&&se._data(s,"handle"),f&&f.apply(s,r),f=c&&s[c],f&&se.acceptData(s)&&f.apply&&f.apply(s,r)===!1&&n.preventDefault();if(n.type=h,!(o||n.isDefaultPrevented()||p._default&&p._default.apply(i.ownerDocument,r)!==!1||"click"===h&&se.nodeName(i,"a")||!se.acceptData(i)||!c||!i[h]||se.isWindow(i))){u=i[c],u&&(i[c]=null),se.event.triggered=h;try{i[h]()}catch(m){}se.event.triggered=t,u&&(i[c]=u)}return n.result}},dispatch:function(e){e=se.event.fix(e);var n,r,i,o,a,s=[],u=ne.call(arguments),l=(se._data(this,"events")||{})[e.type]||[],c=sLine truncated
|
||||
return c(e,"previousSibling")},nextAll:function(e){return se.dir(e,"nextSibling")},prevAll:function(e){return se.dir(e,"previousSibling")},nextUntil:function(e,t,n){return se.dir(e,"nextSibling",n)},prevUntil:function(e,t,n){return se.dir(e,"previousSibling",n)},siblings:function(e){return se.sibling((e.parentNode||{}).firstChild,e)},children:function(e){return se.sibling(e.firstChild)},contents:function(e){return se.nodeName(e,"iframe")?e.contentDocument||e.contentWindow.document:se.merge([],e.childNodes)}},function(e,t){se.fn[e]=function(n,r){var i=se.map(this,t,n);return Pe.test(e)||(r=n),r&&"string"==typeof r&&(i=se.filter(r,i)),i=this.length>1&&!Ie[e]?se.unique(i):i,this.length>1&&Re.test(e)&&(i=i.reverse()),this.pushStack(i)}}),se.extend({filter:function(e,t,n){return n&&(e=":not("+e+")"),1===t.length?se.find.matchesSelector(t[0],e)?[t[0]]:[]:se.find.matches(e,t)},dir:function(e,n,r){for(var i=[],o=e[n];o&&9!==o.nodeType&&(r===t||1!==o.nodeType||!se(o).is(r));)1===o.nodeType&&i.push(o),o=o[n];return i},sibling:function(e,t){for(var n=[];e;e=e.nextSibling)1===e.nodeType&&e!==t&&n.push(e);return n}});var ze="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Xe=/ jQuery\d+="(?:null|\d+)"/g,Ue=RegExp("<(?:"+ze+")[\\s/>]","i"),Ve=/^\s+/,Ye=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Je=/<([\w:]+)/,Ge=/<tbody/i,Qe=/<|&#?\w+;/,Ke=/<(?:script|style|link)/i,Ze=/^(?:checkbox|radio)$/i,et=/checked\s*(?:[^=]|=\s*.checked.)/i,tt=/^$|\/(?:java|ecma)script/i,nt=/^true\/(.*)/,rt=/^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,it={option:[1,"<select multiple='multiple'>","</select>"],legend:[1,"<fieldset>","</fieldset>"],area:[1,"<map>","</map>"],param:[1,"<object>","</object>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],_default:se.support.htmlSerialize?[0,"",""]:[1,"X<div>","</div>"]},ot=p(V),at=ot.appendChild(V.createElement("div"));it.optgroup=it.option,it.tbody=it.tfoot=it.colgroup=it.caption=it.thead,it.th=it.td,se.fn.extend({text:function(e){return se.access(this,function(e){return e===t?se.text(this):this.empty().append((this[0]&&this[0].ownerDocument||V).createTextNode(e))},null,e,arguments.length)},wrapAll:function(e){if(se.isFunction(e))return this.each(function(t){se(this).wrapAll(e.call(this,t))});if(this[0]){var t=se(e,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstChild&&1===e.firstChild.nodeType;)e=e.firstChild;return e}).append(this)}return this},wrapInner:function(e){return se.isFunction(e)?this.each(function(t){se(this).wrapInner(e.call(this,t))}):this.each(function(){var t=se(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=se.isFunction(e);return this.each(function(n){se(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(){return this.parent().each(function(){se.nodeName(this,"body")||se(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.appendChild(e)})},prepend:function(){return this.domManip(arguments,!0,function(e){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&this.insertBefore(e,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return this.domManip(arguments,!1,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},remove:function(e,t){for(var n,r=0;null!=(n=this[r]);r++)(!e||se.filter(e,[n]).length>0)&&(t||1!==n.nodeType||se.cleanData(b(n)),n.parentNode&&(t&&se.contains(n.ownerDocument,n)&&m(b(n,"script")),n.parentNode.removeChild(n)));return this},empty:function(){for(var e,t=0;null!=(e=this[t]);t++){for(1===e.nodeType&&se.cleanData(b(e,!1));e.firstChild;)e.removeChild(e.firstChild);e.options&&se.nodeName(e,"select")&&(e.options.length=0)}return this},clone:function(e,t){return e=null==e?!1:e,t=null==t?e:t,this.map(function(){return se.clone(this,e,t)})},html:function(e){return se.access(this,function(e){var n=this[0]||{},r=0,i=this.length;if(e===t)return 1===n.nodeType?n.innerHTML.replace(Xe,""):t;if(!("string"!=typeof e||Ke.test(e)||!se.support.htmlSerialize&&Ue.test(e)||!se.support.leadingWhitespace&&Ve.test(e)||it[(Je.exec(e)||["",""])[1].toLowerCase()])){e=e.replace(Ye,"<$1></$2>");try{for(;i>r;r++)n=this[r]||{},1===n.nodeType&&(se.cleanData(b(n,!1)),n.innerHTML=e);n=0}catch(o){}}n&&this.empty().append(e)},null,e,arguments.length)},replaceWith:function(e){var t=se.isFunction(e);return t||"string"==typeof e||(e=se(e).not(this).detach()),this.domManip([e],!0,function(e){var t=this.nextSibling,n=this.parentNode;(n&&1===this.nodeType||11===thiLine truncated
|
||||
if("undefined"==typeof jQuery)throw new Error("Bootstrap requires jQuery");+function(t){"use strict";function e(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(void 0!==t.style[i])return{end:e[i]}}t.fn.emulateTransitionEnd=function(e){var i=!1,o=this;t(this).one(t.support.transition.end,function(){i=!0});var n=function(){i||t(o).trigger(t.support.transition.end)};return setTimeout(n,e),this},t(function(){t.support.transition=e()})}(jQuery),+function(t){"use strict";var e='[data-dismiss="alert"]',i=function(i){t(i).on("click",e,this.close)};i.prototype.close=function(e){function i(){s.trigger("closed.bs.alert").remove()}var o=t(this),n=o.attr("data-target");n||(n=o.attr("href"),n=n&&n.replace(/.*(?=#[^\s]*$)/,""));var s=t(n);e&&e.preventDefault(),s.length||(s=o.hasClass("alert")?o:o.parent()),s.trigger(e=t.Event("close.bs.alert")),e.isDefaultPrevented()||(s.removeClass("in"),t.support.transition&&s.hasClass("fade")?s.one(t.support.transition.end,i).emulateTransitionEnd(150):i())};var o=t.fn.alert;t.fn.alert=function(e){return this.each(function(){var o=t(this),n=o.data("bs.alert");n||o.data("bs.alert",n=new i(this)),"string"==typeof e&&n[e].call(o)})},t.fn.alert.Constructor=i,t.fn.alert.noConflict=function(){return t.fn.alert=o,this},t(document).on("click.bs.alert.data-api",e,i.prototype.close)}(jQuery),+function(t){"use strict";var e=function(i,o){this.$element=t(i),this.options=t.extend({},e.DEFAULTS,o)};e.DEFAULTS={loadingText:"loading..."},e.prototype.setState=function(t){var e="disabled",i=this.$element,o=i.is("input")?"val":"html",n=i.data();t+="Text",n.resetText||i.data("resetText",i[o]()),i[o](n[t]||this.options[t]),setTimeout(function(){"loadingText"==t?i.addClass(e).attr(e,e):i.removeClass(e).removeAttr(e)},0)},e.prototype.toggle=function(){var t=this.$element.closest('[data-toggle="buttons"]');if(t.length){var e=this.$element.find("input").prop("checked",!this.$element.hasClass("active")).trigger("change");"radio"===e.prop("type")&&t.find(".active").removeClass("active")}this.$element.toggleClass("active")};var i=t.fn.button;t.fn.button=function(i){return this.each(function(){var o=t(this),n=o.data("bs.button"),s="object"==typeof i&&i;n||o.data("bs.button",n=new e(this,s)),"toggle"==i?n.toggle():i&&n.setState(i)})},t.fn.button.Constructor=e,t.fn.button.noConflict=function(){return t.fn.button=i,this},t(document).on("click.bs.button.data-api","[data-toggle^=button]",function(e){var i=t(e.target);i.hasClass("btn")||(i=i.closest(".btn")),i.button("toggle"),e.preventDefault()})}(jQuery),+function(t){"use strict";var e=function(e,i){this.$element=t(e),this.$indicators=this.$element.find(".carousel-indicators"),this.options=i,this.paused=this.sliding=this.interval=this.$active=this.$items=null,"hover"==this.options.pause&&this.$element.on("mouseenter",t.proxy(this.pause,this)).on("mouseleave",t.proxy(this.cycle,this))};e.DEFAULTS={interval:5e3,pause:"hover",wrap:!0},e.prototype.cycle=function(e){return e||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(t.proxy(this.next,this),this.options.interval)),this},e.prototype.getActiveIndex=function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},e.prototype.to=function(e){var i=this,o=this.getActiveIndex();return e>this.$items.length-1||0>e?void 0:this.sliding?this.$element.one("slid",function(){i.to(e)}):o==e?this.pause().cycle():this.slide(e>o?"next":"prev",t(this.$items[e]))},e.prototype.pause=function(e){return e||(this.paused=!0),this.$element.find(".next, .prev").length&&t.support.transition.end&&(this.$element.trigger(t.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},e.prototype.next=function(){return this.sliding?void 0:this.slide("next")},e.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},e.prototype.slide=function(e,i){var o=this.$element.find(".item.active"),n=i||o[e](),s=this.interval,a="next"==e?"left":"right",r="next"==e?"first":"last",l=this;if(!n.length){if(!this.options.wrap)return;n=this.$element.find(".item")[r]()}this.sliding=!0,s&&this.pause();var h=t.Event("slide.bs.carousel",{relatedTarget:n[0],direction:a});if(!n.hasClass("active")){if(this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid",function(){var e=t(l.$indicators.children()[l.getActiveIndex()]);e&&e.addClass("active")})),t.support.transition&&this.$element.hasClass("slide")){if(this.$element.trigger(h),h.isDefaultPrevented())return;n.addClass(e),n[0].offsetWidth,o.addClass(a),n.addClass(a),o.one(t.support.transition.end,function(){n.removeClass([e,a].join(" ")).addClass("active"),o.removeClass(["active",a].join(" ")),l.sliding=!1,setTimeout(functioLine truncated
|
||||
!function(e){"use strict";e(window.jQuery)}(function(e){"use strict";var t=0;e.ajaxTransport("iframe",function(i){if(i.async){var n,r,o;return{send:function(s,a){n=e('<form style="display:none;"></form>'),n.attr("accept-charset",i.formAcceptCharset),o=/\?/.test(i.url)?"&":"?","DELETE"===i.type?(i.url=i.url+o+"_method=DELETE",i.type="POST"):"PUT"===i.type?(i.url=i.url+o+"_method=PUT",i.type="POST"):"PATCH"===i.type&&(i.url=i.url+o+"_method=PATCH",i.type="POST"),r=e('<iframe src="javascript:false;" name="iframe-transport-'+(t+=1)+'"></iframe>').bind("load",function(){var t,o=e.isArray(i.paramName)?i.paramName:[i.paramName];r.unbind("load").bind("load",function(){var t;try{if(t=r.contents(),!t.length||!t[0].firstChild)throw new Error}catch(i){t=void 0}a(200,"success",{iframe:t}),e('<iframe src="javascript:false;"></iframe>').appendTo(n),n.remove()}),n.prop("target",r.prop("name")).prop("action",i.url).prop("method",i.type),i.formData&&e.each(i.formData,function(t,i){e('<input type="hidden"/>').prop("name",i.name).val(i.value).appendTo(n)}),i.fileInput&&i.fileInput.length&&"POST"===i.type&&(t=i.fileInput.clone(),i.fileInput.after(function(e){return t[e]}),i.paramName&&i.fileInput.each(function(t){e(this).prop("name",o[t]||i.paramName)}),n.append(i.fileInput).prop("enctype","multipart/form-data").prop("encoding","multipart/form-data")),n.submit(),t&&t.length&&i.fileInput.each(function(i,n){var r=e(t[i]);e(n).prop("name",r.prop("name")),r.replaceWith(n)})}),n.append(r).appendTo(document.body)},abort:function(){r&&r.unbind("load").prop("src","javascript".concat(":false;")),n&&n.remove()}}}}),e.ajaxSetup({converters:{"iframe text":function(t){return t&&e(t[0].body).text()},"iframe json":function(t){return t&&e.parseJSON(e(t[0].body).text())},"iframe html":function(t){return t&&e(t[0].body).html()},"iframe script":function(t){return t&&e.globalEval(e(t[0].body).text())}}})}),!function(e){e(jQuery)}(function(e,t){var i=0,n=Array.prototype.slice,r=e.cleanData;e.cleanData=function(t){for(var i,n=0;null!=(i=t[n]);n++)try{e(i).triggerHandler("remove")}catch(o){}r(t)},e.widget=function(t,i,n){var r,o,s,a,l={},p=t.split(".")[0];t=t.split(".")[1],r=p+"-"+t,n||(n=i,i=e.Widget),e.expr[":"][r.toLowerCase()]=function(t){return!!e.data(t,r)},e[p]=e[p]||{},o=e[p][t],s=e[p][t]=function(e,t){return this._createWidget?void(arguments.length&&this._createWidget(e,t)):new s(e,t)},e.extend(s,o,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),a=new i,a.options=e.widget.extend({},a.options),e.each(n,function(t,n){return e.isFunction(n)?void(l[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},r=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,o=this._superApply;return this._super=e,this._superApply=r,t=n.apply(this,arguments),this._super=i,this._superApply=o,t}}()):void(l[t]=n)}),s.prototype=e.widget.extend(a,{widgetEventPrefix:o?a.widgetEventPrefix:t},l,{constructor:s,namespace:p,widgetName:t,widgetFullName:r}),o?(e.each(o._childConstructors,function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,s,i._proto)}),delete o._childConstructors):i._childConstructors.push(s),e.widget.bridge(t,s)},e.widget.extend=function(i){for(var r,o,s=n.call(arguments,1),a=0,l=s.length;l>a;a++)for(r in s[a])o=s[a][r],s[a].hasOwnProperty(r)&&o!==t&&(e.isPlainObject(o)?i[r]=e.isPlainObject(i[r])?e.widget.extend({},i[r],o):e.widget.extend({},o):i[r]=o);return i},e.widget.bridge=function(i,r){var o=r.prototype.widgetFullName||i;e.fn[i]=function(s){var a="string"==typeof s,l=n.call(arguments,1),p=this;return s=!a&&l.length?e.widget.extend.apply(null,[s].concat(l)):s,a?this.each(function(){var n,r=e.data(this,o);return r?e.isFunction(r[s])&&"_"!==s.charAt(0)?(n=r[s].apply(r,l),n!==r&&n!==t?(p=n&&n.jquery?p.pushStack(n.get()):n,!1):void 0):e.error("no such method '"+s+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+s+"'")}):this.each(function(){var t=e.data(this,o);t?t.option(s||{})._init():e.data(this,o,new r(s,this))}),p}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(t,n){n=e(n||this.defaultElement||this)[0],this.element=e(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),n!==this&&(e.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===n&&this.destroy()}}),this.document=e(n.style?n.ownerDocument:n.document||n),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._deLine truncated
|
||||
jQuery.fn.pagination=function(e,t){return t=jQuery.extend({items_per_page:10,num_display_entries:10,current_page:0,num_edge_entries:2,link_to:"#",prev_text:"Prev",next_text:"Next",ellipse_text:"...",prev_show_always:!0,next_show_always:!0,callback:function(){return!1}},t||{}),this.each(function(){function n(){return Math.ceil(e/t.items_per_page)}function a(){var e=Math.ceil(t.num_display_entries/2),a=n(),r=a-t.num_display_entries,s=i>e?Math.max(Math.min(i-e,r),0):0,_=i>e?Math.min(i+e,a):Math.min(t.num_display_entries,a);return[s,_]}function r(e,n){n.preventDefault(),i=e,s();var a=t.callback(e,_);return a||(n.stopPropagation?n.stopPropagation():n.cancelBubble=!0),a}function s(){_.empty();var e=a(),s=n(),p=function(e){return function(t){return r(e,t)}},l=function(e,n){e=0>e?0:s>e?e:s-1,n=jQuery.extend({text:e+1,classes:""},n||{});var a="";if(e==i){var r=jQuery("<span class='current'>"+n.text+"</span>");n.text!=t.prev_text&&n.text!=t.next_text&&(a='class="active"')}else var r=jQuery("<a>"+n.text+"</a>").bind("click",p(e)).attr("href",t.link_to.replace(/__id__/,e));n.classes&&r.addClass(n.classes);var l=$("<li "+a+"></li>").append(r);_.append(l)};if(t.prev_text&&(i>0||t.prev_show_always)&&l(i-1,{text:t.prev_text,classes:"prev"}),e[0]>0&&t.num_edge_entries>0){for(var u=Math.min(t.num_edge_entries,e[0]),c=0;u>c;c++)l(c);t.num_edge_entries<e[0]&&t.ellipse_text&&jQuery("<li><span>"+t.ellipse_text+"</span></li>").appendTo(_)}for(var c=e[0];c<e[1];c++)l(c);if(e[1]<s&&t.num_edge_entries>0){s-t.num_edge_entries>e[1]&&t.ellipse_text&&jQuery("<li><span>"+t.ellipse_text+"</span></li>").appendTo(_);for(var x=Math.max(s-t.num_edge_entries,e[1]),c=x;s>c;c++)l(c)}t.next_text&&(s-1>i||t.next_show_always)&&l(i+1,{text:t.next_text,classes:"next"})}var i=t.current_page;e=!e||0>e?1:e,t.items_per_page=!t.items_per_page||t.items_per_page<0?1:t.items_per_page;var _=jQuery(this);this.selectPage=function(e){r(e)},this.prevPage=function(){return i>0?(r(i-1),!0):!1},this.nextPage=function(){return i<n()-1?(r(i+1),!0):!1},s()})};
|
||||
function log(e){}function retIsOk(e){return e&&"object"==typeof e&&1==e.Ok?!0:!1}function getImageSize(e,t){function a(e,a){i.parentNode.removeChild(i),t({width:e,height:a})}var i=document.createElement("img");i.onload=function(){a(i.clientWidth,i.clientHeight)},i.onerror=function(){a()},i.src=e;var s=i.style;s.visibility="hidden",s.position="fixed",s.bottom=s.left=0,s.width=s.height="auto",document.body.appendChild(i)}function mdGetImgSrc(){return o.selectedImages&&o.selectedImages.length?o.selectedImages[0]:""}var urlPrefix=UrlPrefix,getMsg=parent.getMsg;getMsg||(getMsg=function(e){return e});var o={maxSelected:G.maxSelected,selectedZoneO:$("#preview"),previewO:$("#preview"),selectedImages:[],imageAttrs:{},pageNum:1,pagination:function(e){var t=this;$(".pagination").pagination(e,{items_per_page:G.perPageItems,prev_text:getMsg("Prev"),next_text:getMsg("Next"),callback:function(e){t.pageNum=e+1,t.renderImages($("#albumsForList").val(),t.pageNum,!1)}})},showMsg:function(e){$("#msg").html(e).css("display","inline"),setTimeout(function(){$("#msg").fadeOut()},2e3)},pageAddAlbum:function(e){var t='<option value="'+e.AlbumId+'">'+e.Name+"</option>";$("#albumsForUpload").append(t).val(e.AlbumId),$("#albumsForList").append(t)},pageUpdateAlbum:function(e,t){$('option[value="'+e+'"]').html(t)},processAlbum:function(){function e(){$("#addOrUpdateAlbumForm").is(":hidden")?($("#addOrUpdateAlbumForm").show(),$("#albumSelect").hide()):($("#addOrUpdateAlbumForm").hide(),$("#albumSelect").show())}var t=this,a=!0,i="";$("#renameAlbumBtn").click(function(){return(i=$("#albumsForUpload").val())?(e(),$("#addOrUpdateAlbumBtn").html(getMsg("Rename Album")),$("#albumName").val($("#albumsForUpload option:selected").html()).focus(),void(a=!1)):void alert(getMsg("Cannot rename default album"))}),$("#addAlbumBtn").click(function(){e(),$("#addOrUpdateAlbumBtn").html(getMsg("Add Album")),$("#albumName").val("").focus(),a=!0}),$("#cancelAlbumBtn").click(function(){e()}),$("#addOrUpdateAlbumBtn").click(function(){var s=$("#albumName").val();return s?void(a?$.get("/album/addAlbum",{name:s},function(a){"object"==typeof a&&""!=a.AlbumId?($("#albumName").val(""),t.showMsg(getMsg("Add Success!")),t.pageAddAlbum(a),setTimeout(function(){e()},200)):alert(getMsg("error"))}):$.get("/album/updateAlbum",{albumId:i,name:s},function(a){"boolean"==typeof a&&a?($("#albumName").val(""),t.showMsg(getMsg("Rename Success!")),t.pageUpdateAlbum(i,s),setTimeout(function(){e()},200)):alert(getMsg("error!"))})):void $("#albumName").focus()}),$("#deleteAlbumBtn").click(function(){var e=$("#albumsForUpload").val();return e?void $.get("/album/deleteAlbum",{albumId:e},function(a){"object"==typeof a&&1==a.Ok?(t.showMsg(getMsg("Delete Success!")),$("#albumsForUpload option[value='"+e+"']").remove(),$("#albumsForList").val()==e&&(t.needRefresh=!0),$("#albumsForList option[value='"+e+"']").remove()):alert(getMsg("This album has images, please delete it's images at first."))}):void alert(getMsg("Cannot delete default album"))})},renderAlbums:function(){var e=this;$.get("/album/getAlbums",function(t){if(t){var a="";for(var i in t){var s=t[i],r='<option value="'+s.AlbumId+'">'+s.Name+"</option>";a+=r}$("#albumsForUpload").append(a),$("#albumsForList").append(a);var l=$("#albumsForList").val();e.renderImages(l,1,!0)}})},imageMaskO:$("#imageMask"),noImagesO:$("#noImages"),loadingO:$("#loading"),loadingStart:function(){this.imageMaskO.is(":hidden")&&this.imageMaskO.css("opacity",.8).show(),this.noImagesO.hide(),this.loadingO.show()},loadingEnd:function(){this.imageMaskO.hide()},noImages:function(){this.imageMaskO.show().css("opacity",1),this.noImagesO.show(),this.loadingO.hide()},search:function(){var e=this,t=1;$("#key").on("keyup",function(){var a=++t,i=$(this).val(),s=$("#albumsForList").val();e.renderImages(s,1,!0,i,function(){return t==a})})},renderImages:function(e,t,a,i,s){var r=this;t||(t=1),r.loadingStart(),$.get("/file/getImages",{albumId:e,page:t,key:i},function(e){if(!e||!e.Count)return void r.noImages();r.loadingEnd();var t=e.List,i={};for(var s in r.selectedImages){var l=r.selectedImages[s];i[l]=!0}var n="";for(var s in t){var o=t[s],d="";if(""!=o.Path&&"/"==o.Path[0]&&(o.Path=o.Path.substr(1)),""!=o.Path&&"upload/"==o.Path.substr(0,7))var l=urlPrefix+"/"+o.Path;else var l=urlPrefix+"/file/outputImage?fileId="+o.FileId;i[l]&&(d='class="selected"'),n+="<li "+d+">",n+='<a title="" href="javascript:;" class="a-img"><img alt="" src="'+l+'" data-original="'+l+'" ></a>',n+='<div class="tools clearfix" data-id="'+o.FileId+'"><div class="file-title pull-left">'+o.Title+'</div><div class="pull-right"><a href="javascript:;" class="del" data-id="'+o.FileId+'"><span class="fa fa-trash"></span></a></div></div>',n+="</li>"}$("#imageList").html(n),a&&r.pagination(e.Count)})},initSelectedZones:function(){var e=this;num=this.maxSelected,e.previewO.html("");for(var t=1;t<=num;++t)e.previewO.append("<li>?</li>")},reRenderSelectedImages:function(e,t){for(var a=this,i=this.selecteLine truncated
|
||||
@@ -0,0 +1,865 @@
|
||||
function log(o) {
|
||||
// console.log(o);
|
||||
}
|
||||
function retIsOk(ret) {
|
||||
if(ret && typeof ret == "object" && ret.Ok == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
var urlPrefix = UrlPrefix;
|
||||
var getMsg = parent.getMsg;
|
||||
if (!getMsg) {
|
||||
getMsg = function(msg) {
|
||||
return msg;
|
||||
};
|
||||
}
|
||||
|
||||
// load image
|
||||
function getImageSize(url, callback) {
|
||||
var img = document.createElement('img');
|
||||
|
||||
function done(width, height) {
|
||||
img.parentNode.removeChild(img);
|
||||
callback({width: width, height: height});
|
||||
}
|
||||
|
||||
img.onload = function() {
|
||||
done(img.clientWidth, img.clientHeight);
|
||||
};
|
||||
|
||||
img.onerror = function() {
|
||||
done();
|
||||
};
|
||||
|
||||
img.src = url;
|
||||
|
||||
var style = img.style;
|
||||
style.visibility = 'hidden';
|
||||
style.position = 'fixed';
|
||||
style.bottom = style.left = 0;
|
||||
style.width = style.height = 'auto';
|
||||
|
||||
document.body.appendChild(img);
|
||||
}
|
||||
|
||||
var o = {
|
||||
maxSelected: G.maxSelected,
|
||||
selectedZoneO:$("#preview"),
|
||||
previewO: $("#preview"),
|
||||
selectedImages:[], // selected urls
|
||||
imageAttrs: {}, // src => {width, height, title}
|
||||
|
||||
pageNum: 1,
|
||||
|
||||
pagination: function(count) {
|
||||
var self = this;
|
||||
$(".pagination").pagination(count, {
|
||||
items_per_page: G.perPageItems,
|
||||
prev_text: getMsg('Prev'),
|
||||
next_text: getMsg('Next'),
|
||||
callback: function(pageNum) {
|
||||
self.pageNum = pageNum+1;
|
||||
self.renderImages($("#albumsForList").val(), self.pageNum, false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showMsg: function(msg) {
|
||||
$("#msg").html(msg).css("display", "inline");
|
||||
setTimeout(function() {
|
||||
$("#msg").fadeOut();
|
||||
}, 2000);
|
||||
},
|
||||
|
||||
pageAddAlbum: function(ret) {
|
||||
var html = '<option value="' + ret.AlbumId + '">' + ret.Name + '</option>';
|
||||
$("#albumsForUpload").append(html).val(ret.AlbumId);
|
||||
$("#albumsForList").append(html);
|
||||
},
|
||||
pageUpdateAlbum: function(albumId, albumName) {
|
||||
$('option[value="' + albumId + '"]').html(albumName);
|
||||
},
|
||||
// add, delete, update album
|
||||
processAlbum: function() {
|
||||
var self = this;
|
||||
var isAddAlbum = true;
|
||||
var curAlbum = "";
|
||||
function toggleAddAlbum() {
|
||||
if($("#addOrUpdateAlbumForm").is(":hidden")) {
|
||||
$("#addOrUpdateAlbumForm").show();
|
||||
$("#albumSelect").hide();
|
||||
} else {
|
||||
$("#addOrUpdateAlbumForm").hide();
|
||||
$("#albumSelect").show();
|
||||
}
|
||||
}
|
||||
// rename
|
||||
$("#renameAlbumBtn").click(function(){
|
||||
curAlbum = $("#albumsForUpload").val();
|
||||
if(!curAlbum) {
|
||||
alert(getMsg("Cannot rename default album"));
|
||||
return;
|
||||
}
|
||||
toggleAddAlbum();
|
||||
$("#addOrUpdateAlbumBtn").html(getMsg("Rename Album"));
|
||||
$("#albumName").val($("#albumsForUpload option:selected").html()).focus();
|
||||
isAddAlbum = false;
|
||||
});
|
||||
// add album
|
||||
$("#addAlbumBtn").click(function() {
|
||||
toggleAddAlbum();
|
||||
$("#addOrUpdateAlbumBtn").html(getMsg("Add Album"));
|
||||
$("#albumName").val("").focus();
|
||||
isAddAlbum = true;
|
||||
});
|
||||
$("#cancelAlbumBtn").click(function() {
|
||||
toggleAddAlbum();
|
||||
});
|
||||
// add or update album
|
||||
$("#addOrUpdateAlbumBtn").click(function() {
|
||||
var albumName = $("#albumName").val();
|
||||
if(!albumName) {
|
||||
$("#albumName").focus();
|
||||
return;
|
||||
}
|
||||
if(isAddAlbum) {
|
||||
$.get("/album/addAlbum", {name: albumName}, function(ret) {
|
||||
if(typeof ret == "object" && ret.AlbumId != "") {
|
||||
$("#albumName").val("");
|
||||
self.showMsg(getMsg("Add Success!"));
|
||||
self.pageAddAlbum(ret);
|
||||
|
||||
setTimeout(function() {
|
||||
toggleAddAlbum();
|
||||
}, 200);
|
||||
} else {
|
||||
alert(getMsg("error"));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.get("/album/updateAlbum", {albumId: curAlbum, name: albumName}, function(ret) {
|
||||
if(typeof ret == "boolean" && ret) {
|
||||
$("#albumName").val("");
|
||||
self.showMsg(getMsg("Rename Success!"));
|
||||
self.pageUpdateAlbum(curAlbum, albumName);
|
||||
|
||||
setTimeout(function() {
|
||||
toggleAddAlbum();
|
||||
}, 200);
|
||||
} else {
|
||||
alert(getMsg("error!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
// delete album
|
||||
$("#deleteAlbumBtn").click(function() {
|
||||
var albumId = $("#albumsForUpload").val();
|
||||
if(!albumId) {
|
||||
alert(getMsg("Cannot delete default album"));
|
||||
return;
|
||||
}
|
||||
$.get("/album/deleteAlbum", {albumId: albumId}, function(ret) {
|
||||
if(typeof ret == "object" && ret.Ok == true) {
|
||||
self.showMsg(getMsg("Delete Success!"));
|
||||
// delete this album from select
|
||||
$("#albumsForUpload option[value='" + albumId + "']").remove();
|
||||
|
||||
// if the albumsForList has select this album, it must refresh list after delete it;
|
||||
if($("#albumsForList").val() == albumId) {
|
||||
self.needRefresh = true;
|
||||
}
|
||||
|
||||
$("#albumsForList option[value='" + albumId + "']").remove();
|
||||
|
||||
} else {
|
||||
alert(getMsg("This album has images, please delete it's images at first."));
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
renderAlbums: function() {
|
||||
var self = this;
|
||||
$.get("/album/getAlbums", function(ret) {
|
||||
if(!ret) return;
|
||||
var html = "";
|
||||
for(var i in ret) {
|
||||
var each = ret[i];
|
||||
var option = '<option value="' + each.AlbumId + '">' + each.Name+ '</option>';
|
||||
html += option;
|
||||
}
|
||||
|
||||
$("#albumsForUpload").append(html);
|
||||
$("#albumsForList").append(html);
|
||||
|
||||
var albumId = $("#albumsForList").val();
|
||||
self.renderImages(albumId, 1, true);
|
||||
});
|
||||
},
|
||||
|
||||
imageMaskO: $("#imageMask"),
|
||||
noImagesO: $("#noImages"),
|
||||
loadingO: $("#loading"),
|
||||
|
||||
loadingStart: function() {
|
||||
if(this.imageMaskO.is(":hidden")) {
|
||||
this.imageMaskO.css("opacity", 0.8).show();
|
||||
}
|
||||
this.noImagesO.hide();
|
||||
this.loadingO.show();
|
||||
},
|
||||
loadingEnd: function() {
|
||||
this.imageMaskO.hide();
|
||||
},
|
||||
|
||||
noImages: function () {
|
||||
this.imageMaskO.show().css("opacity", 1);
|
||||
this.noImagesO.show();
|
||||
this.loadingO.hide();
|
||||
},
|
||||
|
||||
|
||||
search: function() {
|
||||
var self = this;
|
||||
var t1 = 1;
|
||||
$("#key").on("keyup", function() {
|
||||
var t2 = ++t1;
|
||||
var key = $(this).val();
|
||||
var albumId = $("#albumsForList").val();
|
||||
|
||||
self.renderImages(albumId, 1, true, key, function(){
|
||||
return t1 == t2;
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
renderImages: function(albumId, page, needRenderPagination, key, needRender) {
|
||||
var self = this;
|
||||
|
||||
if(!page) {
|
||||
page = 1;
|
||||
}
|
||||
self.loadingStart();
|
||||
$.get("/file/getImages", {albumId: albumId, page: page, key: key}, function(ret) {
|
||||
if(!ret || !ret.Count) {
|
||||
self.noImages();
|
||||
return;
|
||||
}
|
||||
self.loadingEnd();
|
||||
var datas = ret.List;
|
||||
var selectedMap = {};
|
||||
|
||||
for(var i in self.selectedImages) {
|
||||
var src = self.selectedImages[i]; // src include G.imageSrcPrefix
|
||||
selectedMap[src] = true;
|
||||
}
|
||||
// log(self.selectedImages);
|
||||
|
||||
var html = "";
|
||||
for(var i in datas){
|
||||
var each = datas[i];
|
||||
var classes = "";
|
||||
// life edit
|
||||
// 之前的
|
||||
if(each.Path != "" && each.Path[0] == "/") {
|
||||
each.Path = each.Path.substr(1);
|
||||
}
|
||||
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"';
|
||||
}
|
||||
html += '<li ' + classes + '>';
|
||||
html += '<a title="" href="javascript:;" class="a-img"><img alt="" src="' + src + '" data-original="' + src + '" ></a>';
|
||||
// html += '<div class="tools"><a href="javascript:;" class="del" data-id="' + each.FileId + '"><span class="fa fa-trash"></span></a></div>';
|
||||
html += '<div class="tools clearfix" data-id="' + each.FileId + '"><div class="file-title pull-left">' + each.Title + '</div><div class="pull-right"><a href="javascript:;" class="del" data-id="' + each.FileId + '"><span class="fa fa-trash"></span></a></div></div>';
|
||||
html += "</li>";
|
||||
}
|
||||
|
||||
// var html = $("#tImage").render(datas);
|
||||
$("#imageList").html(html);
|
||||
|
||||
if(needRenderPagination) {
|
||||
self.pagination(ret.Count);
|
||||
}
|
||||
|
||||
// $("#imageList img").lazyload({effect : "fadeIn"});
|
||||
// $("#imageList img").lazyload();
|
||||
});
|
||||
},
|
||||
|
||||
// 初始化已选择的图片区域
|
||||
initSelectedZones: function() {
|
||||
var self = this;
|
||||
num = this.maxSelected;
|
||||
self.previewO.html("");
|
||||
for(var i = 1; i <= num; ++i) {
|
||||
// self.previewO.append("<li>" + i + "</li>");
|
||||
self.previewO.append("<li>?</li>");
|
||||
}
|
||||
},
|
||||
|
||||
reRenderSelectedImages: function(isRemove, addSrc) {
|
||||
var self = this;
|
||||
|
||||
var lis = this.selectedZoneO.find("li");
|
||||
var size = this.selectedImages.length-1;
|
||||
for(var i = 0; i < this.maxSelected; ++i) {
|
||||
var target = lis.eq(i);
|
||||
if(i > size) {
|
||||
target.html('?');
|
||||
} else {
|
||||
src = this.selectedImages[i];
|
||||
|
||||
var data = self.imageAttrs[src];
|
||||
var attrs = "";
|
||||
if(data) {
|
||||
if(data.width) attrs += ' data-width="' + data.width + '"';
|
||||
if(data.height) attrs += ' data-height="' + data.height + '"';
|
||||
if(data.title) attrs += ' data-title="' + data.title + '"';
|
||||
}
|
||||
|
||||
target.html('<img ' + attrs + ' src="' + src + '" width="60"/><div class="tools"><a title="' + getMsg('click to remove this image') + '" href="javascript:;" class="del"><span class="fa fa-trash"></span></a></div>');
|
||||
}
|
||||
|
||||
// remove selected
|
||||
if(isRemove) {
|
||||
target.removeClass("selected");
|
||||
} else {
|
||||
// is add
|
||||
// trigger click and set attrs
|
||||
if(addSrc == src) {
|
||||
target.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
removeSelectedImage: function($li) {
|
||||
var self = this;
|
||||
|
||||
var src = $li.find("img").attr('src');
|
||||
for(var i in this.selectedImages) {
|
||||
if(this.selectedImages[i] == src) {
|
||||
this.selectedImages.splice(i, 1)
|
||||
}
|
||||
}
|
||||
this.reRenderSelectedImages(true);
|
||||
|
||||
// clear attrs and disable it
|
||||
self.clearAttrs();
|
||||
},
|
||||
addSelectedImage: function($li) {
|
||||
if(this.maxSelected > 1 && this.maxSelected <= this.selectedImages.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// life 为了图片安全
|
||||
if(typeof $li == "object") {
|
||||
var src = $li.find("img").attr('src');
|
||||
} else {
|
||||
// 也有可能来自url
|
||||
if($li.indexOf("http://") != -1 || $li.indexOf("https://") != -1) {
|
||||
src = $li;
|
||||
} else {
|
||||
// 来自内部
|
||||
src = urlPrefix + "/file/outputImage?fileId=" + $li;
|
||||
}
|
||||
}
|
||||
|
||||
// 如果只允许选1个
|
||||
if(this.maxSelected == 1) {
|
||||
// 先把其它的去掉
|
||||
$("#imageList li").removeClass("selected");
|
||||
this.selectedImages = [src];
|
||||
} else {
|
||||
this.selectedImages.push(src);
|
||||
}
|
||||
|
||||
this.reRenderSelectedImages(false, src);
|
||||
|
||||
return true;
|
||||
},
|
||||
initDataFromTinymce: function() {
|
||||
var self = this;
|
||||
var datas = top.LEAUI_DATAS;
|
||||
var lastSrc = "";
|
||||
if(datas && datas.length > 0) {
|
||||
for(var i in datas) {
|
||||
var data = datas[i];
|
||||
data.constrain = true;
|
||||
lastSrc = data.src;
|
||||
self.selectedImages.push(data.src);
|
||||
self.imageAttrs[data.src] = data;
|
||||
}
|
||||
|
||||
self.reRenderSelectedImages(false, lastSrc);
|
||||
}
|
||||
},
|
||||
|
||||
init: function() {
|
||||
var self = this;
|
||||
|
||||
self.processAlbum();
|
||||
|
||||
$("#albumsForList").change(function() {
|
||||
var albumId = $(this).val();
|
||||
self.renderImages(albumId, 1, true);
|
||||
});
|
||||
|
||||
$("#imageList").on("click", 'li', function() {
|
||||
if($(this).hasClass("selected")) {
|
||||
$(this).removeClass("selected");
|
||||
self.removeSelectedImage($(this));
|
||||
} else {
|
||||
if(self.addSelectedImage($(this))){
|
||||
$(this).addClass("selected");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// delete file
|
||||
$("#imageList").on("click", '.del', function(e) {
|
||||
var t = this;
|
||||
e.stopPropagation();
|
||||
|
||||
if(confirm(getMsg("Are you sure to delete this image ?"))) {
|
||||
var fileId = $(this).data('id');
|
||||
$.get("/file/deleteImage", {fileId: fileId}, function(ret) {
|
||||
if(ret) {
|
||||
var $li = $(t).closest('li');
|
||||
if($li.hasClass("selected")) {
|
||||
self.removeSelectedImage($li);
|
||||
}
|
||||
$(t).closest('li').remove();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
// edit file title
|
||||
$("#imageList").on("click", '.file-title', function(e) {
|
||||
var p = this;
|
||||
var t = this;
|
||||
e.stopPropagation();
|
||||
if($(this).children().eq(0).is("input")){
|
||||
return;
|
||||
}
|
||||
var fileId = $(p).parent().data('id');
|
||||
var fileTitle = $(this).text();
|
||||
$(this).html('<input type="text" value="' + fileTitle + '" />');
|
||||
|
||||
var $input = $(this).find("input");
|
||||
$input.focus();
|
||||
$input.keydown(function(e){
|
||||
if(e.keyCode==13){
|
||||
$(this).trigger("blur");
|
||||
}
|
||||
});
|
||||
$input.blur(function() {
|
||||
var title = $(this).val();
|
||||
if(!title) {
|
||||
title = fileTitle;
|
||||
} else {
|
||||
$.post("/file/updateImageTitle", {fileId: fileId, title: title});
|
||||
}
|
||||
$(p).html(title);
|
||||
});
|
||||
});
|
||||
|
||||
// remove preview
|
||||
$("#preview").on("click", '.del', function(e) {
|
||||
e.stopPropagation();
|
||||
var $li = $(this).closest("li");
|
||||
var src = $li.find("img").attr("src");
|
||||
self.removeSelectedImage($li);
|
||||
|
||||
// 在当前的imagesList下看是否有
|
||||
$("#imageList img").each(function() {
|
||||
var src2 = $(this).attr('src');
|
||||
if(src == src2) {
|
||||
$(this).parent().parent().removeClass("selected");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
$("#goAddImageBtn").click(function() {
|
||||
$("#albumsForUpload").val($("#albumsForList").val());
|
||||
$('#myTab li:eq(1) a').tab('show');
|
||||
});
|
||||
|
||||
// toggle tab
|
||||
// refresh
|
||||
$('#myTab a').on('shown.bs.tab', function(e) {
|
||||
e.preventDefault()
|
||||
$(this).tab('show');
|
||||
var href = $(this).attr("href");
|
||||
|
||||
if(self.needRefresh && href == "#images") {
|
||||
setTimeout(function(){
|
||||
var albumId = $("#albumsForList").val();
|
||||
var key = $("#key").val();
|
||||
self.renderImages(albumId, self.pageNum, true, key);
|
||||
}, 200);
|
||||
self.needRefresh = false;
|
||||
}
|
||||
|
||||
if(href == "#url") {
|
||||
$("#imageUrl").focus();
|
||||
}
|
||||
});
|
||||
$("#refresh").click(function() {
|
||||
var albumId = $("#albumsForList").val();
|
||||
var key = $("#key").val();
|
||||
self.renderImages(albumId, self.pageNum, false, key);
|
||||
});
|
||||
|
||||
// add url
|
||||
$("#addImageUrlBtn").click(function(e) {
|
||||
e.preventDefault();
|
||||
var url = $.trim($("#imageUrl").val());
|
||||
if(!url) {
|
||||
$("#imageUrl").focus();
|
||||
return;
|
||||
}
|
||||
|
||||
getImageSize(url, function(ret) {
|
||||
if(!ret.width || !ret.height){
|
||||
$("#msgForUrl").show();
|
||||
return;
|
||||
}
|
||||
$("#msgForUrl").hide();
|
||||
$("#imageUrl").val("");
|
||||
self.addSelectedImage(url);
|
||||
});
|
||||
});
|
||||
|
||||
// 设置属性
|
||||
$("#preview").on("click", 'li', function() {
|
||||
if($(this).hasClass("selected")) {
|
||||
// $(this).removeClass("selected");
|
||||
} else {
|
||||
if($(this).find("img").length){
|
||||
$("#preview li").removeClass("selected");
|
||||
$(this).addClass("selected");
|
||||
|
||||
self.initAttr($(this));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$("#attrTitle, #attrWidth, #attrHeight").on("keyup", function(){
|
||||
self.modifyAttr($(this));
|
||||
});
|
||||
$("#attrConstrain").on("click", function(){
|
||||
self.modifyAttr($(this));
|
||||
});
|
||||
|
||||
// file search
|
||||
self.search();
|
||||
|
||||
self.initSelectedZones();
|
||||
|
||||
self.initDataFromTinymce();
|
||||
|
||||
self.renderAlbums();
|
||||
//...
|
||||
self.initUploader();
|
||||
},
|
||||
|
||||
// 设置
|
||||
curSrc: "",
|
||||
curLi: null,
|
||||
attrTitleO: $("#attrTitle"),
|
||||
attrWidthO: $("#attrWidth"),
|
||||
attrHeightO: $("#attrHeight"),
|
||||
attrConstrainO: $("#attrConstrain"),
|
||||
// clear attrs and disable it
|
||||
clearAttrs: function() {
|
||||
var self = this;
|
||||
self.attrTitleO.val("").attr("disabled", true);
|
||||
self.attrHeightO.val("").attr("disabled", true);
|
||||
self.attrWidthO.val("").attr("disabled", true);
|
||||
self.attrConstrainO.prop("checked", false).attr("disabled", true);
|
||||
},
|
||||
scale: function(isWidth) {
|
||||
var self = this;
|
||||
var autoScale = self.attrConstrainO.is(":checked");
|
||||
var width = +self.attrWidthO.val();
|
||||
var height = +self.attrHeightO.val();
|
||||
if(isNaN(width) || isNaN(height)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var curAttrs = self.getCurAttrs();
|
||||
var preWidth = curAttrs.preWidth || curAttrs.width;
|
||||
var preHeight = curAttrs.preHeight || curAttrs.height;
|
||||
|
||||
if(autoScale && preWidth && preHeight) {
|
||||
if(isWidth) {
|
||||
height = parseInt((width/preWidth) * preHeight);
|
||||
self.attrHeightO.val(height);
|
||||
} else {
|
||||
width = parseInt((height/preHeight) * preWidth);
|
||||
self.attrWidthO.val(width);
|
||||
}
|
||||
}
|
||||
var ret = {width: width, height: height};
|
||||
return ret;
|
||||
},
|
||||
getCurAttrs: function() {
|
||||
var self = this;
|
||||
return self.imageAttrs[self.curSrc];
|
||||
},
|
||||
setCurDataAttrs: function(attrs) {
|
||||
var self = this;
|
||||
var img = self.curLi.find("img");
|
||||
img.attr("data-width", attrs.width);
|
||||
img.attr("data-height", attrs.height);
|
||||
img.attr("data-title", attrs.title);
|
||||
|
||||
self.imageAttrs[self.curSrc] = attrs;
|
||||
},
|
||||
// 修改属性
|
||||
modifyAttr: function($target){
|
||||
var self = this;
|
||||
var id = $target.attr("id");
|
||||
var val = $target.val();
|
||||
var curAttrs = self.getCurAttrs();
|
||||
if(!curAttrs) {
|
||||
return;
|
||||
}
|
||||
switch(id) {
|
||||
case "attrConstrain":
|
||||
val = 0;
|
||||
if($target.is(":checked")) {
|
||||
val = 1;
|
||||
}
|
||||
curAttrs['constrain'] = val;
|
||||
break;
|
||||
case "attrTitle":
|
||||
curAttrs['title'] = val;
|
||||
break;
|
||||
case "attrWidth":
|
||||
$.extend(curAttrs, self.scale(true));
|
||||
break;
|
||||
case "attrHeight":
|
||||
$.extend(curAttrs, self.scale(false));
|
||||
break;
|
||||
}
|
||||
|
||||
self.setCurDataAttrs(curAttrs);
|
||||
},
|
||||
// when click preview li
|
||||
initAttr: function($li) {
|
||||
var self = this;
|
||||
if(typeof $li != "object") {
|
||||
$li = $("#preview").find('img[src="' + $li + '"]').parent();
|
||||
};
|
||||
|
||||
var src = $li.find("img").attr("src");
|
||||
self.curSrc = src;
|
||||
self.curLi = $li;
|
||||
|
||||
var attrs = self.imageAttrs[src];
|
||||
function setAttr(attrs) {
|
||||
attrs = attrs || {};
|
||||
self.attrTitleO.val(attrs.title).attr("disabled", false);
|
||||
self.attrWidthO.val(attrs.width).attr("disabled", false);
|
||||
self.attrHeightO.val(attrs.height).attr("disabled", false);
|
||||
self.attrConstrainO.attr("disabled", false);
|
||||
|
||||
if(attrs.constrain) {
|
||||
self.attrConstrainO.prop('checked', true);
|
||||
} else {
|
||||
self.attrConstrainO.prop('checked', false);
|
||||
}
|
||||
|
||||
self.setCurDataAttrs(attrs);
|
||||
}
|
||||
attrs = attrs || {};
|
||||
if(!attrs || !attrs.width || !attrs.height) {
|
||||
getImageSize(src, function(ret) {
|
||||
ret.title = attrs.title || "";
|
||||
ret.constrain = 1;
|
||||
ret.preWidth = ret.width;
|
||||
ret.preHeight = ret.height;
|
||||
if(src != self.curSrc) {
|
||||
self.imageAttrs[src] = ret;
|
||||
// in case user click fast
|
||||
self.setCurDataAttrs(attrs);
|
||||
return;
|
||||
}
|
||||
// set attrs
|
||||
setAttr(ret);
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
setAttr(attrs);
|
||||
}
|
||||
},
|
||||
|
||||
needRefresh: false,
|
||||
|
||||
uploadRefreshImageList: function() {
|
||||
var self = this;
|
||||
// check albumId
|
||||
var albumId = $("#albumsForList").val();
|
||||
if(albumId == $("#albumsForUpload").val()){
|
||||
self.needRefresh = true;
|
||||
}
|
||||
},
|
||||
|
||||
initUploader: function() {
|
||||
var self = this;
|
||||
var ul = $('#upload ul');
|
||||
|
||||
$('#drop a').click(function() {
|
||||
// trigger to show file select
|
||||
$(this).parent().find('input').click();
|
||||
});
|
||||
// Initialize the jQuery File Upload plugin
|
||||
$('#upload').fileupload({
|
||||
dataType: 'json',
|
||||
pasteZone: '',
|
||||
acceptFileTypes: /(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,
|
||||
// maxFileSize: 210000,
|
||||
|
||||
// This element will accept file drag/drop uploading
|
||||
dropZone: $('#drop'),
|
||||
formData: function(form) {
|
||||
return [{name: 'albumId', value: $("#albumsForUpload").val()}]
|
||||
},
|
||||
/*
|
||||
urlFunc: function() {
|
||||
return 'server/index.php?action=file:uploadImage&album_id=' + $("#albumsForUpload").val();
|
||||
},
|
||||
*/
|
||||
|
||||
// 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 size = data.files[0].size;
|
||||
var maxFileSize = +parent.GlobalConfigs["uploadImageSize"] || 100;
|
||||
if(typeof size == 'number' && size > 1024 * 1024 * maxFileSize) {
|
||||
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
tpl.find('div').append('<b>Warning:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>] is bigger than ' + maxFileSize + 'M</small> ');
|
||||
tpl.appendTo(ul);
|
||||
return;
|
||||
}
|
||||
|
||||
var tpl = $('<li><div class="alert alert-info"><img class="loader" src="/public/album/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
// Append the file name and file size
|
||||
tpl.find('div').append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
|
||||
|
||||
// Add the HTML to the UL element
|
||||
data.context = tpl.appendTo(ul);
|
||||
|
||||
// data.form[0].action += "&album_id=" + $("#albumsForUpload").val();
|
||||
|
||||
// Automatically upload the file once it is added to the queue
|
||||
var jqXHR = data.submit();
|
||||
},
|
||||
|
||||
|
||||
done: function(e, data) {
|
||||
if (data.result.Ok == true) {
|
||||
data.context.remove();
|
||||
|
||||
// add image to preview
|
||||
self.addSelectedImage(data.result.Id);
|
||||
// reresh image list
|
||||
self.uploadRefreshImageList();
|
||||
} else {
|
||||
data.context.empty();
|
||||
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
tpl.find('div').append('<b>' + getMsg('Error') + ':</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
|
||||
data.context.append(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
}
|
||||
$("#upload-msg").scrollTop(1000);
|
||||
},
|
||||
fail: function(e, data) {
|
||||
data.context.empty();
|
||||
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
tpl.find('div').append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
|
||||
data.context.append(tpl);
|
||||
|
||||
$("#upload-msg").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 = $('#drop'),
|
||||
timeout = window.dropZoneTimeout;
|
||||
if (!timeout) {
|
||||
dropZone.addClass('in');
|
||||
} 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');
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
o.init();
|
||||
});
|
||||
|
||||
// 为md得到图片链接
|
||||
function mdGetImgSrc() {
|
||||
if(o.selectedImages && o.selectedImages.length) {
|
||||
return o.selectedImages[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
@font-face {
|
||||
font-family: Si;
|
||||
src: url("/public/fonts/MSYH.TTF");
|
||||
}
|
||||
@font-face {
|
||||
font-family: 'Open Sans';
|
||||
font-style: normal;
|
||||
@@ -28,14 +24,14 @@
|
||||
}
|
||||
*,
|
||||
body {
|
||||
font-family: Si, 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, 'Hiragino Sans GB';
|
||||
font-family: 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, 'Hiragino Sans GB';
|
||||
font-weight: 300;
|
||||
font-size: 14px;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3 {
|
||||
font-family: Si, 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, 'Hiragino Sans GB';
|
||||
font-family: 'Microsoft YaHei', 'WenQuanYi Micro Hei', 'Helvetica Neue', Arial, 'Hiragino Sans GB';
|
||||
}
|
||||
* {
|
||||
font-size: 16px;
|
||||
@@ -1,8 +1,3 @@
|
||||
@font-face {
|
||||
font-family: Si;
|
||||
src:url("/public/fonts/MSYH.TTF");
|
||||
}
|
||||
|
||||
// font
|
||||
@font-face {
|
||||
font-family: 'Open Sans';
|
||||
@@ -31,7 +26,7 @@
|
||||
|
||||
@bgColor: #fff;
|
||||
@headerBgColor: #fff;
|
||||
@fontFamily: Si, 'Microsoft YaHei','WenQuanYi Micro Hei','Helvetica Neue',Arial,'Hiragino Sans GB';
|
||||
@fontFamily: 'Microsoft YaHei','WenQuanYi Micro Hei','Helvetica Neue',Arial,'Hiragino Sans GB';
|
||||
@green: #65bd77;
|
||||
|
||||
*, body {
|
||||
Vendored
+109
-81
@@ -36974,42 +36974,41 @@ define('editor',[
|
||||
};
|
||||
|
||||
var defaultsStrings = {
|
||||
bold: "Strong <strong> Ctrl/Cmd+B",
|
||||
boldexample: "strong text",
|
||||
bold: getMsg("Strong") + ' <strong> Ctrl/Cmd+B',
|
||||
boldexample: getMsg("strong text"),
|
||||
|
||||
italic: "Emphasis <em> Ctrl/Cmd+I",
|
||||
italicexample: "emphasized text",
|
||||
italic: getMsg("Emphasis") + ' <em> Ctrl/Cmd+I',
|
||||
italicexample: getMsg("emphasized text"),
|
||||
|
||||
link: "Hyperlink <a> Ctrl/Cmd+L",
|
||||
linkdescription: "enter link description here",
|
||||
link: getMsg("Hyperlink") + ' <a> Ctrl/Cmd+L',
|
||||
linkdescription: getMsg("enter link description here"),
|
||||
linkdialog: "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>",
|
||||
|
||||
quote: "Blockquote <blockquote> Ctrl/Cmd+Q",
|
||||
quoteexample: "Blockquote",
|
||||
quote: getMsg("Blockquote") + ' <blockquote> Ctrl/Cmd+Q',
|
||||
quoteexample: getMsg("Blockquote"),
|
||||
|
||||
code: "Code Sample <pre><code> Ctrl/Cmd+K",
|
||||
codeexample: "enter code here",
|
||||
code: getMsg("Code Sample") + ' <pre><code> Ctrl/Cmd+K',
|
||||
codeexample: getMsg("enter code here"),
|
||||
|
||||
image: "Image <img> Ctrl/Cmd+G",
|
||||
imagedescription: "enter image description here",
|
||||
image: getMsg("Image") + '<img> Ctrl/Cmd+G',
|
||||
imagedescription: getMsg("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/Cmd+O",
|
||||
ulist: "Bulleted List <ul> Ctrl/Cmd+U",
|
||||
litem: "List item",
|
||||
olist: getMsg("Numbered List") +' <ol> Ctrl/Cmd+O',
|
||||
ulist: getMsg("Bulleted List") +' <ul> Ctrl/Cmd+U',
|
||||
litem: getMsg("List item"),
|
||||
|
||||
heading: "Heading <h1>/<h2> Ctrl/Cmd+H",
|
||||
headingexample: "Heading",
|
||||
heading: getMsg("Heading") + ' <h1>/<h2> Ctrl/Cmd+H',
|
||||
headingexample: getMsg("Heading"),
|
||||
|
||||
hr: "Horizontal Rule <hr> Ctrl/Cmd+R",
|
||||
hr: getMsg("Horizontal Rule") + ' <hr> Ctrl/Cmd+R',
|
||||
|
||||
undo: "Undo - Ctrl/Cmd+Z",
|
||||
redo: "Redo - Ctrl/Cmd+Y",
|
||||
undo: getMsg("Undo") + ' - Ctrl/Cmd+Z',
|
||||
redo: getMsg("Redo") + ' - Ctrl/Cmd+Y',
|
||||
|
||||
help: "Markdown Editing Help"
|
||||
};
|
||||
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
// YOUR CHANGES GO HERE
|
||||
//
|
||||
@@ -38312,7 +38311,8 @@ define('editor',[
|
||||
|
||||
// life 新添加函数
|
||||
// life
|
||||
function insertLinkLife(link, text) {
|
||||
// isImage 2015/3/1
|
||||
function insertLinkLife(link, text, isImage) {
|
||||
inputBox.focus();
|
||||
if (undoManager) {
|
||||
undoManager.setCommandMode();
|
||||
@@ -38336,7 +38336,7 @@ define('editor',[
|
||||
previewManager.refresh();
|
||||
};
|
||||
|
||||
var a = commandProto.insertLink(chunks, fixupInputArea, link, text);
|
||||
var a = commandProto.insertLink(chunks, fixupInputArea, link, text, isImage);
|
||||
if(!a) fixupInputArea();
|
||||
}
|
||||
|
||||
@@ -38734,9 +38734,8 @@ define('editor',[
|
||||
});
|
||||
}
|
||||
|
||||
// life 添加
|
||||
commandProto.insertLink = function (chunk, postProcessing, link, text) {
|
||||
isImage = false;
|
||||
// life 添加
|
||||
commandProto.insertLink = function (chunk, postProcessing, link, text, isImage) {
|
||||
chunk.trimWhitespace();
|
||||
chunk.findTags(/\s*!?\[/, /\][ ]?(?:\n[ ]*)?(\[.*?\])?/);
|
||||
var background;
|
||||
@@ -38746,7 +38745,6 @@ define('editor',[
|
||||
chunk.startTag = chunk.startTag.replace(/!?\[/, "");
|
||||
chunk.endTag = "";
|
||||
this.addLinkDef(chunk, null);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -38814,8 +38812,7 @@ define('editor',[
|
||||
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) {
|
||||
|
||||
var linkEnteredCallback = function (link, text) {
|
||||
background.parentNode.removeChild(background);
|
||||
|
||||
if (link !== null) {
|
||||
@@ -38845,16 +38842,21 @@ define('editor',[
|
||||
var num = that.addLinkDef(chunk, linkDef);
|
||||
*/
|
||||
chunk.startTag = isImage ? "![" : "[";
|
||||
//chunk.endTag = "][" + num + "]";
|
||||
// chunk.endTag = "][" + num + "]";
|
||||
chunk.endTag = "](" + properlyEncoded(link) + ")";
|
||||
|
||||
if (!chunk.selection) {
|
||||
if (isImage) {
|
||||
chunk.selection = that.getString("imagedescription");
|
||||
var str = '';
|
||||
if (text) {
|
||||
str = text;
|
||||
} else if (isImage) {
|
||||
str = that.getString("imagedescription");
|
||||
}
|
||||
else {
|
||||
chunk.selection = that.getString("linkdescription");
|
||||
str = that.getString("linkdescription");
|
||||
}
|
||||
|
||||
chunk.selection = str;
|
||||
}
|
||||
}
|
||||
postProcessing();
|
||||
@@ -39064,6 +39066,7 @@ define('editor',[
|
||||
}
|
||||
};
|
||||
|
||||
// 这里, 应该用 ``` ```
|
||||
commandProto.doCode = function (chunk, postProcessing) {
|
||||
|
||||
var hasTextBefore = /\S[ ]*$/.test(chunk.before);
|
||||
@@ -39232,8 +39235,9 @@ define('editor',[
|
||||
|
||||
};
|
||||
|
||||
// 要改成 ## ### ####
|
||||
// life 2015/7/12
|
||||
commandProto.doHeading = function (chunk, postProcessing) {
|
||||
|
||||
// Remove leading/trailing whitespace and reduce internal spaces to single spaces.
|
||||
chunk.selection = chunk.selection.replace(/\s+/g, " ");
|
||||
chunk.selection = chunk.selection.replace(/(^\s+|\s+$)/g, "");
|
||||
@@ -39241,63 +39245,58 @@ define('editor',[
|
||||
// If we clicked the button with no selected text, we just
|
||||
// make a level 2 hash header around some default text.
|
||||
if (!chunk.selection) {
|
||||
chunk.startTag = "## ";
|
||||
// 需要skip的时候 life
|
||||
if(chunk.before && (chunk.before[chunk.before.length - 1] != "\n")) {
|
||||
chunk.skipLines(1, 1);
|
||||
}
|
||||
chunk.startTag = "# ";
|
||||
chunk.selection = this.getString("headingexample");
|
||||
chunk.endTag = " ##";
|
||||
chunk.endTag = ""; // ##
|
||||
return;
|
||||
}
|
||||
|
||||
var headerLevel = 0; // The existing header level of the selected text.
|
||||
|
||||
// Remove any existing hash heading markdown and save the header level.
|
||||
chunk.findTags(/#+[ ]*/, /[ ]*#+/);
|
||||
if (/#+/.test(chunk.startTag)) {
|
||||
headerLevel = re.lastMatch.length;
|
||||
}
|
||||
chunk.startTag = chunk.endTag = "";
|
||||
// console.log(chunk);
|
||||
|
||||
// Try to get the current header level by looking for - and = in the line
|
||||
// below the selection.
|
||||
chunk.findTags(null, /\s?(-+|=+)/);
|
||||
if (/=+/.test(chunk.endTag)) {
|
||||
headerLevel = 1;
|
||||
}
|
||||
if (/-+/.test(chunk.endTag)) {
|
||||
headerLevel = 2;
|
||||
if(chunk.before && (chunk.before[chunk.before.length - 1] != "\n")) {
|
||||
chunk.skipLines(1, 1);
|
||||
}
|
||||
|
||||
// Skip to the next line so we can create the header markdown.
|
||||
chunk.startTag = chunk.endTag = "";
|
||||
chunk.skipLines(1, 1);
|
||||
var beforeHLevel = 0;
|
||||
var startTag = chunk.startTag;
|
||||
if (/^#+[ ]*$/.test(startTag)) {
|
||||
startTag = startTag.replace(/ /g, '');
|
||||
beforeHLevel = startTag.length;
|
||||
}
|
||||
|
||||
// We make a level 2 header if there is no current header.
|
||||
// If there is a header level, we substract one from the header level.
|
||||
// If it's already a level 1 header, it's removed.
|
||||
var headerLevelToCreate = headerLevel == 0 ? 2 : headerLevel - 1;
|
||||
// [0, 4]
|
||||
var headerLevelToCreate = 0;
|
||||
if(beforeHLevel >= 0 && beforeHLevel <= 3) {
|
||||
headerLevelToCreate = beforeHLevel + 1;
|
||||
}
|
||||
if(beforeHLevel >= 4) {
|
||||
headerLevelToCreate = 0;
|
||||
chunk.startTag = '';
|
||||
}
|
||||
|
||||
if (headerLevelToCreate > 0) {
|
||||
var header = "";
|
||||
while (headerLevelToCreate--) {
|
||||
header += "#";
|
||||
}
|
||||
header += " ";
|
||||
|
||||
// The button only creates level 1 and 2 underline headers.
|
||||
// Why not have it iterate over hash header levels? Wouldn't that be easier and cleaner?
|
||||
var headerChar = headerLevelToCreate >= 2 ? "-" : "=";
|
||||
var len = chunk.selection.length;
|
||||
if (len > SETTINGS.lineLength) {
|
||||
len = SETTINGS.lineLength;
|
||||
}
|
||||
chunk.endTag = "\n";
|
||||
while (len--) {
|
||||
chunk.endTag += headerChar;
|
||||
}
|
||||
chunk.startTag = header;
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
||||
commandProto.doHorizontalRule = function (chunk, postProcessing) {
|
||||
chunk.startTag = "----------\n";
|
||||
chunk.selection = "";
|
||||
chunk.skipLines(2, 1, true);
|
||||
chunk.skipLines(1, 1, true);
|
||||
}
|
||||
|
||||
|
||||
})();
|
||||
|
||||
define("pagedown", function(){});
|
||||
@@ -39336,12 +39335,21 @@ define('core',[
|
||||
}
|
||||
}
|
||||
|
||||
// Load settings in settings dialog
|
||||
// var $themeInputElt;
|
||||
|
||||
// Create the PageDown editor
|
||||
var pagedownEditor;
|
||||
var fileDesc;
|
||||
var insertLinkO = $('<div class="modal fade modal-insert-link"><div class="modal-dialog"><div class="modal-content">'
|
||||
+ '<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>'
|
||||
+ '<h4 class="modal-title">' + getMsg('Hyperlink') + '</h4></div>'
|
||||
+ '<div class="modal-body"><p>' + getMsg('Please provide the link URL and an optional title') + ':</p>'
|
||||
+ '<div class="input-group"><span class="input-group-addon"><i class="fa fa-link"></i></span><input id="input-insert-link" type="text" class="col-sm-5 form-control" placeholder="http://example.com ' + getMsg('optional title') + '"></div></div><div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal">' + getMsg('Cancel') + '</a> <a href="#" class="btn btn-primary action-insert-link" data-dismiss="modal">' + getMsg('OK') + '</a></div></div></div></div>');
|
||||
|
||||
var actionInsertLinkO = insertLinkO.find('.action-insert-link');
|
||||
|
||||
|
||||
// Load settings in settings dialog
|
||||
// var $themeInputElt;
|
||||
|
||||
core.initEditorFirst = function() {
|
||||
// Create the converter and the editor
|
||||
var converter = new Markdown.Converter();
|
||||
@@ -39370,7 +39378,7 @@ define('core',[
|
||||
pagedownEditor.hooks.set("insertLinkDialog", function(callback) {
|
||||
core.insertLinkCallback = callback;
|
||||
utils.resetModalInputs();
|
||||
$(".modal-insert-link").modal();
|
||||
insertLinkO.modal();
|
||||
return true;
|
||||
});
|
||||
// Custom insert image dialog
|
||||
@@ -39382,7 +39390,7 @@ define('core',[
|
||||
utils.resetModalInputs();
|
||||
var ifr = $("#leauiIfrForMD");
|
||||
if(!ifr.attr('src')) {
|
||||
ifr.attr('src', '/tinymce/plugins/leaui_image/index.html?md=1');
|
||||
ifr.attr('src', '/album/index?md=1');
|
||||
}
|
||||
|
||||
$(".modal-insert-image").modal();
|
||||
@@ -39489,17 +39497,33 @@ define('core',[
|
||||
});
|
||||
|
||||
// Click events on "insert link" and "insert image" dialog buttons
|
||||
$(".action-insert-link").click(function(e) {
|
||||
actionInsertLinkO.click(function(e) {
|
||||
var value = utils.getInputTextValue($("#input-insert-link"), e);
|
||||
if(value !== undefined) {
|
||||
core.insertLinkCallback(value);
|
||||
var arr = value.split(' ');
|
||||
var text = '';
|
||||
var link = arr[0];
|
||||
if (arr.length > 1) {
|
||||
arr.shift();
|
||||
text = $.trim(arr.join(' '));
|
||||
}
|
||||
core.insertLinkCallback(link, text);
|
||||
core.insertLinkCallback = undefined;
|
||||
}
|
||||
});
|
||||
|
||||
// 插入图片
|
||||
$(".action-insert-image").click(function() {
|
||||
// 得到图片链接或图片
|
||||
var value = document.mdImageManager.mdGetImgSrc();
|
||||
/*
|
||||
https://github.com/leanote/leanote/issues/171
|
||||
同遇到了网页编辑markdown时不能添加图片的问题。
|
||||
可以上传图片,但是按下“插入图片”按钮之后,编辑器中没有加入
|
||||
我的控制台有这样的错误: TypeError: document.mdImageManager is undefined
|
||||
*/
|
||||
// mdImageManager是iframe的name, mdGetImgSrc是iframe内的全局方法
|
||||
// var value = document.mdImageManager.mdGetImgSrc();
|
||||
var value = document.getElementById('leauiIfrForMD').contentWindow.mdGetImgSrc();
|
||||
// var value = utils.getInputTextValue($("#input-insert-image"), e);
|
||||
if(value) {
|
||||
core.insertLinkCallback(value);
|
||||
@@ -39508,7 +39532,7 @@ define('core',[
|
||||
});
|
||||
|
||||
// Hide events on "insert link" and "insert image" dialogs
|
||||
$(".modal-insert-link, .modal-insert-image").on('hidden.bs.modal', function() {
|
||||
insertLinkO.on('hidden.bs.modal', function() {
|
||||
if(core.insertLinkCallback !== undefined) {
|
||||
core.insertLinkCallback(null);
|
||||
core.insertLinkCallback = undefined;
|
||||
@@ -39522,7 +39546,7 @@ define('core',[
|
||||
|
||||
// 弹框显示markdown语法
|
||||
$('#wmd-help-button').click(function() {
|
||||
window.open("http://leanote.com/blog/view/531b263bdfeb2c0ea9000002");
|
||||
window.open("http://leanote.com/blog/post/531b263bdfeb2c0ea9000002");
|
||||
});
|
||||
|
||||
// Load images
|
||||
@@ -40608,6 +40632,10 @@ if(window.baseDir.indexOf('-min') !== -1) {
|
||||
}
|
||||
*/
|
||||
|
||||
window.getMsg || (getMsg = function(msg) {
|
||||
return msg;
|
||||
});
|
||||
|
||||
// RequireJS entry point. By requiring synchronizer, publisher, sharing and
|
||||
// media-importer, we are actually loading all the modules
|
||||
require([
|
||||
|
||||
Vendored
+2
-2
@@ -12,5 +12,5 @@ this.trace(t)},parse:function(t){function e(){var t;return t=n.lexer.lex()||f,"n
|
||||
else a=this.leftEnd&&x?r(this.chart,c,[{x:c.x,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e):r(this.chart,c,[{x:c.x,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.bottomStart=!0,t.topEnd=!0,_=c.x+(c.x-d.x)/2;else a=r(this.chart,l,[{x:l.x+S/2,y:l.y},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else a=r(this.chart,l,[{x:l.x+S/2,y:l.y},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else a=r(this.chart,u,p,e),this.leftStart=!0,t.rightEnd=!0,_=p.x;else a=r(this.chart,l,g,e),this.rightStart=!0,t.leftEnd=!0,_=g.x;else a=r(this.chart,c,d,e),this.bottomStart=!0,t.topEnd=!0,_=c.x;if(a){for(var k=0,T=this.chart.lines.length;T>k;k++)for(var I,N=this.chart.lines[k],R=N.attr("path"),A=a.attr("path"),M=0,L=R.length-1;L>M;M++){var O=[];O.push(["M",R[M][1],R[M][2]]),O.push(["L",R[M+1][1],R[M+1][2]]);for(var D=O[0][1],F=O[0][2],P=O[1][1],B=O[1][2],j=0,$=A.length-1;$>j;j++){var H=[];H.push(["M",A[j][1],A[j][2]]),H.push(["L",A[j+1][1],A[j+1][2]]);var U=H[0][1],q=H[0][2],G=H[1][1],z=H[1][2],W=i(D,F,P,B,U,q,G,z);if(W.onLine1&&W.onLine2){var X;q===z?U>G?(X=["L",W.x+2*C,q],A.splice(j+1,0,X),X=["C",W.x+2*C,q,W.x,q-4*C,W.x-2*C,q],A.splice(j+2,0,X),a.attr("path",A)):(X=["L",W.x-2*C,q],A.splice(j+1,0,X),X=["C",W.x-2*C,q,W.x,q-4*C,W.x+2*C,q],A.splice(j+2,0,X),a.attr("path",A)):q>z?(X=["L",U,W.y+2*C],A.splice(j+1,0,X),X=["C",U,W.y+2*C,U+4*C,W.y,U,W.y-2*C],A.splice(j+2,0,X),a.attr("path",A)):(X=["L",U,W.y-2*C],A.splice(j+1,0,X),X=["C",U,W.y-2*C,U+4*C,W.y,U,W.y+2*C],A.splice(j+2,0,X),a.attr("path",A)),j+=2,I+=2}}}this.chart.lines.push(a)}(!this.chart.maxXFromLine||this.chart.maxXFromLine&&_>this.chart.maxXFromLine)&&(this.chart.maxXFromLine=_)},m.inherits(s,o),m.inherits(l,o),m.inherits(c,o),m.inherits(u,o),m.inherits(h,o),h.prototype.getLeft=function(){var t=this.getY()+this.group.getBBox().height/2,e=this.getX()+this.textMargin;return{x:e,y:t}},h.prototype.getRight=function(){var t=this.getY()+this.group.getBBox().height/2,e=this.getX()+this.group.getBBox().width-this.textMargin;return{x:e,y:t}},m.inherits(f,o),f.prototype.render=function(){this.yes_direction&&(this[this.yes_direction+"_symbol"]=this.yes_symbol),this.no_direction&&(this[this.no_direction+"_symbol"]=this.no_symbol);var t=this.getAttr("line-length");if(this.bottom_symbol){var e=this.getBottom();this.bottom_symbol.getTop(),this.bottom_symbol.isPositioned||(this.bottom_symbol.shiftY(this.getY()+this.height+t),this.bottom_symbol.setX(e.x-this.bottom_symbol.width/2),this.bottom_symbol.isPositioned=!0,this.bottom_symbol.render())}if(this.right_symbol){var n=this.getRight();if(this.right_symbol.getLeft(),!this.right_symbol.isPositioned){this.right_symbol.setY(n.y-this.right_symbol.height/2),this.right_symbol.shiftX(this.group.getBBox().x+this.width+t);var r=this;!function i(){for(var e,n=!1,a=0,o=r.chart.symbols.length;o>a;a++){e=r.chart.symbols[a];var s=Math.abs(e.getCenter().x-r.right_symbol.getCenter().x);if(e.getCenter().y>r.right_symbol.getCenter().y&&s<=r.right_symbol.width/2){n=!0;break}}n&&(r.right_symbol.setX(e.getX()+e.width+t),i())}(),this.right_symbol.isPositioned=!0,this.right_symbol.render()}}},f.prototype.renderLines=function(){this.yes_symbol&&this.drawLineTo(this.yes_symbol,this.getAttr("yes-text"),this.yes_direction),this.no_symbol&&this.drawLineTo(this.no_symbol,this.getAttr("no-text"),this.no_direction)},p.parse=d,p}),define("extensions/umlDiagrams",["underscore","utils","logger","classes/Extension","text!html/umlDiagramsSettingsBlock.html","crel","Diagram","flow-chart"],function(t,e,n,r,i,a,o,s){var l=new r("umlDiagrams","UML Diagrams",!0);return l.settingsBlock=i,l.defaultConfig={flowchartOptions:["{",' "line-width": 2,',' "font-family": "sans-serif",',' "font-weight": "normal"',"}"].join("\n")},l.onLoadSettings=function(){e.setInputValue("#textarea-umldiagram-flowchart-options",l.config.flowchartOptions)},l.onSaveSettings=function(t,n){t.flowchartOptions=e.getInputJSONValue("#textarea-umldiagram-flowchart-options",n)},l.onPagedownConfigure=function(e){var n=document.getElementById("preview-contents");e.hooks.chain("onPreviewRefresh",function(){t.each(n.querySelectorAll(".prettyprint > .language-sequence"),function(t){try{var e=o.parse(t.textContent),n=t.parentNode,r=a("div",{"class":"sequence-diagram"});n.parentNode.replaceChild(r,n),e.drawSVG(r,{theme:"simple"})}catch(i){}}),t.each(n.querySelectorAll(".prettyprint > .language-flow"),function(t){try{var e=s.parse(t.textContent),n=t.parentNode,r=a("div",{"class":"flow-chart"});n.parentNode.replaceChild(r,n),e.drawSVG(r,JSON.parse(l.config.flowchartOptions))}catch(i){}})})},l}),define("text!html/tocSettingsBlock.html",[],function(){return'<p>Generates a table of contents when a [TOC] marker is found.</p>\n<div class="form-horizontal">\n <div class="form-group">\n <label class="col-sm-4 control-label" for="input-toc-marker">Marker\nLine truncated
|
||||
},h.postMessage(JSON.stringify({language:u.language,code:u.code}))}else u.highlightedCode=e.highlight(u.code,u.grammar,u.language),e.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,a&&a.call(r),e.hooks.run("after-highlight",u)}}},highlight:function(t,r,i){return n.stringify(e.tokenize(t,r),i)},tokenize:function(t,n){var r=e.Token,i=[t],a=n.rest;if(a){for(var o in a)n[o]=a[o];delete n.rest}t:for(var o in n)if(n.hasOwnProperty(o)&&n[o]){var s=n[o],l=s.inside,c=!!s.lookbehind,u=0;s=s.pattern||s;for(var h=0;h<i.length;h++){var f=i[h];if(i.length>t.length)break t;if(!(f instanceof r)){s.lastIndex=0;var d=s.exec(f);if(d){c&&(u=d[1].length);var p=d.index-1+u,d=d[0].slice(u),g=d.length,m=p+g,v=f.slice(0,p+1),y=f.slice(m+1),x=[h,1];v&&x.push(v);var b=new r(o,l?e.tokenize(d,l):d);x.push(b),y&&x.push(y),Array.prototype.splice.apply(i,x)}}}}return i},hooks:{all:{},add:function(t,n){var r=e.hooks.all;r[t]=r[t]||[],r[t].push(n)},run:function(t,n){var r=e.hooks.all[t];if(r&&r.length)for(var i,a=0;i=r[a++];)i(n)}}},n=e.Token=function(t,e){this.type=t,this.content=e};if(n.stringify=function(t,r,i){if("string"==typeof t)return t;if("[object Array]"==Object.prototype.toString.call(t))return t.map(function(e){return n.stringify(e,r,t)}).join("");var a={type:t.type,content:n.stringify(t.content,r,i),tag:"span",classes:["token",t.type],attributes:{},language:r,parent:i};"comment"==a.type&&(a.attributes.spellcheck="true"),e.hooks.run("wrap",a);var o="";for(var s in a.attributes)o+=s+'="'+(a.attributes[s]||"")+'"';return"<"+a.tag+' class="'+a.classes.join(" ")+'" '+o+">"+a.content+"</"+a.tag+">"},!self.document)return void self.addEventListener("message",function(t){var n=JSON.parse(t.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(e.tokenize(i,e.languages[r]))),self.close()},!1);var r=document.getElementsByTagName("script");r=r[r.length-1],r&&(e.filename=r.src,document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",e.highlightAll))}(),define("prism-core",function(t){return function(){var e;return e||t.Prism}}(this));var DIFF_DELETE=-1,DIFF_INSERT=1,DIFF_EQUAL=0;diff_match_patch.Diff,diff_match_patch.prototype.diff_main=function(t,e,n,r){"undefined"==typeof r&&(r=this.Diff_Timeout<=0?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout);var i=r;if(null==t||null==e)throw new Error("Null input. (diff_main)");if(t==e)return t?[[DIFF_EQUAL,t]]:[];"undefined"==typeof n&&(n=!0);var a=n,o=this.diff_commonPrefix(t,e),s=t.substring(0,o);t=t.substring(o),e=e.substring(o),o=this.diff_commonSuffix(t,e);var l=t.substring(t.length-o);t=t.substring(0,t.length-o),e=e.substring(0,e.length-o);var c=this.diff_compute_(t,e,a,i);return s&&c.unshift([DIFF_EQUAL,s]),l&&c.push([DIFF_EQUAL,l]),this.diff_cleanupMerge(c),c},diff_match_patch.prototype.diff_compute_=function(t,e,n,r){var i;if(!t)return[[DIFF_INSERT,e]];if(!e)return[[DIFF_DELETE,t]];var a=t.length>e.length?t:e,o=t.length>e.length?e:t,s=a.indexOf(o);if(-1!=s)return i=[[DIFF_INSERT,a.substring(0,s)],[DIFF_EQUAL,o],[DIFF_INSERT,a.substring(s+o.length)]],t.length>e.length&&(i[0][0]=i[2][0]=DIFF_DELETE),i;if(1==o.length)return[[DIFF_DELETE,t],[DIFF_INSERT,e]];var l=this.diff_halfMatch_(t,e);if(l){var c=l[0],u=l[1],h=l[2],f=l[3],d=l[4],p=this.diff_main(c,h,n,r),g=this.diff_main(u,f,n,r);return p.concat([[DIFF_EQUAL,d]],g)}return n&&t.length>100&&e.length>100?this.diff_lineMode_(t,e,r):this.diff_bisect_(t,e,r)},diff_match_patch.prototype.diff_lineMode_=function(t,e,n){var r=this.diff_linesToChars_(t,e);t=r.chars1,e=r.chars2;var i=r.lineArray,a=this.diff_main(t,e,!1,n);this.diff_charsToLines_(a,i),this.diff_cleanupSemantic(a),a.push([DIFF_EQUAL,""]);for(var o=0,s=0,l=0,c="",u="";o<a.length;){switch(a[o][0]){case DIFF_INSERT:l++,u+=a[o][1];break;case DIFF_DELETE:s++,c+=a[o][1];break;case DIFF_EQUAL:if(s>=1&&l>=1){a.splice(o-s-l,s+l),o=o-s-l;for(var r=this.diff_main(c,u,!1,n),h=r.length-1;h>=0;h--)a.splice(o,0,r[h]);o+=r.length}l=0,s=0,c="",u=""}o++}return a.pop(),a},diff_match_patch.prototype.diff_bisect_=function(t,e,n){for(var r=t.length,i=e.length,a=Math.ceil((r+i)/2),o=a,s=2*a,l=new Array(s),c=new Array(s),u=0;s>u;u++)l[u]=-1,c[u]=-1;l[o+1]=0,c[o+1]=0;for(var h=r-i,f=h%2!=0,d=0,p=0,g=0,m=0,v=0;a>v&&!((new Date).getTime()>n);v++){for(var y=-v+d;v-p>=y;y+=2){var x,b=o+y;x=y==-v||y!=v&&l[b-1]<l[b+1]?l[b+1]:l[b-1]+1;for(var w=x-y;r>x&&i>w&&t.charAt(x)==e.charAt(w);)x++,w++;if(l[b]=x,x>r)p+=2;else if(w>i)d+=2;else if(f){var _=o+h-y;if(_>=0&&s>_&&-1!=c[_]){var S=r-c[_];if(x>=S)return this.diff_bisectSplit_(t,e,x,w,n)}}}for(var C=-v+g;v-m>=C;C+=2){var S,_=o+C;S=C==-v||C!=v&&c[_-1]<c[_+1]?c[_+1]:c[_-1]+1;for(var E=S-C;r>S&&i>E&&t.charAt(r-S-1)==e.charAt(i-E-1);)S++,E++;if(c[_]=S,S>r)m+=2;else if(E>i)g+=2;else if(!f){var b=o+h-C;if(b>=0&&s>b&&-1!=l[b]){var x=l[b],w=o+x-b;if(S=r-S,x>=S)return this.diff_bisectSplit_(t,e,x,w,n)}}}}return[[DIFF_DELETE,t],[DIFF_INSERT,e]]},diff_match_patch.prototype.diff_bisectSplit_=function(Line truncated
|
||||
};r.filterName="dates",n.diffFilter=r},{}],11:[function(t,e,n){var r=function(t,e,n,r){return t[n]===e[r]},i=function(t,e,n,r){var i,a,o=t.length,s=e.length,l=[o+1];for(i=0;o+1>i;i++)for(l[i]=[s+1],a=0;s+1>a;a++)l[i][a]=0;for(l.match=n,i=1;o+1>i;i++)for(a=1;s+1>a;a++)l[i][a]=n(t,e,i-1,a-1,r)?l[i-1][a-1]+1:Math.max(l[i-1][a],l[i][a-1]);return l},a=function(t,e,n,r,i,o){if(0===r||0===i)return{sequence:[],indices1:[],indices2:[]};if(t.match(e,n,r-1,i-1,o)){var s=a(t,e,n,r-1,i-1,o);return s.sequence.push(e[r-1]),s.indices1.push(r-1),s.indices2.push(i-1),s}return t[r][i-1]>t[r-1][i]?a(t,e,n,r,i-1,o):a(t,e,n,r-1,i,o)},o=function(t,e,n,o){o=o||{};var s=i(t,e,n||r,o),l=a(s,t,e,t.length,e.length,o);return"string"==typeof t&&"string"==typeof e&&(l.sequence=l.sequence.join("")),l};n.get=o},{}],12:[function(t,e,n){var r=t("../contexts/diff").DiffContext,i=t("../contexts/patch").PatchContext,a=t("../contexts/reverse").ReverseContext,o=function(t){if(t&&t.children){for(var e,n=t.children.length,r=t.result,i=0;n>i;i++)e=t.children[i],"undefined"!=typeof e.result&&(r=r||{},r[e.childName]=e.result);r&&t.leftIsArray&&(r._t="a"),t.setResult(r).exit()}};o.filterName="collectChildren";var s=function(t){if(!t.leftIsArray&&"object"===t.leftType){var e,n;for(e in t.left)n=new r(t.left[e],t.right[e]),t.push(n,e);for(e in t.right)"undefined"==typeof t.left[e]&&(n=new r(void 0,t.right[e]),t.push(n,e));return t.children&&0!==t.children.length?void t.exit():void t.setResult(void 0).exit()}};s.filterName="objects";var l=function(t){if(t.nested&&!t.delta._t){var e,n;for(e in t.delta)n=new i(t.left[e],t.delta[e]),t.push(n,e);t.exit()}};l.filterName="objects";var c=function(t){if(t&&t.children&&!t.delta._t){for(var e,n=t.children.length,r=0;n>r;r++)e=t.children[r],t.left[e.childName]!==e.result&&(t.left[e.childName]=e.result);t.setResult(t.left).exit()}};c.filterName="collectChildren";var u=function(t){if(t.nested&&!t.delta._t){var e,n;for(e in t.delta)n=new a(t.delta[e]),t.push(n,e);t.exit()}};u.filterName="objects";var h=function(t){if(t&&t.children&&!t.delta._t){for(var e,n=t.children.length,r={},i=0;n>i;i++)e=t.children[i],r[e.childName]!==e.result&&(r[e.childName]=e.result);t.setResult(r).exit()}};h.filterName="collectChildren",n.collectChildrenDiffFilter=o,n.objectsDiffFilter=s,n.patchFilter=l,n.collectChildrenPatchFilter=c,n.reverseFilter=u,n.collectChildrenReverseFilter=h},{"../contexts/diff":3,"../contexts/patch":4,"../contexts/reverse":5}],13:[function(t,e,n){var r=2,i=60,a=null,o=function(){if(!a){var e;if("undefined"!=typeof diff_match_patch)e=new diff_match_patch;else if("function"==typeof t){var n=t("../../external/diff_match_patch_uncompressed");e=new n.diff_match_patch}if(!e){var r=new Error("text diff_match_patch library not found");throw r.diff_match_patch_not_found=!0,r}a={diff:function(t,n){return e.patch_toText(e.patch_make(t,n))},patch:function(t,n){for(var r=e.patch_apply(e.patch_fromText(n),t),i=0;i<r[1].length;i++)if(!r[1][i]){var a=new Error("text patch failed");a.textPatchFailed=!0}return r[0]}}}return a},s=function(t){if("string"===t.leftType){var e=t.options&&t.options.textDiff&&t.options.textDiff.minLength||i;if(t.left.length<e||t.right.length<e)return void t.setResult([t.left,t.right]).exit();var n=o().diff;t.setResult([n(t.left,t.right),0,r]).exit()}};s.filterName="texts";var l=function(t){if(!t.nested&&t.delta[2]===r){var e=o().patch;t.setResult(e(t.left,t.delta[0])).exit()}};l.filterName="texts";var c=function(t){var e,n,r,i,a,o,s,l,c=null,u=/^@@ +\-(\d+),(\d+) +\+(\d+),(\d+) +@@$/;for(r=t.split("\n"),e=0,n=r.length;n>e;e++){i=r[e];var h=i.slice(0,1);"@"===h?(c=u.exec(i),o=e,s=null,l=null,r[o]="@@ -"+c[3]+","+c[4]+" +"+c[1]+","+c[2]+" @@"):"+"===h?(s=e,r[e]="-"+r[e].slice(1),"+"===r[e-1].slice(0,1)&&(a=r[e],r[e]=r[e-1],r[e-1]=a)):"-"===h&&(l=e,r[e]="+"+r[e].slice(1))}return r.join("\n")},u=function(t){t.nested||t.delta[2]===r&&t.setResult([c(t.delta[0]),0,r]).exit()};u.filterName="texts",n.diffFilter=s,n.patchFilter=l,n.reverseFilter=u},{}],14:[function(t,e,n){var r="function"==typeof Array.isArray?Array.isArray:function(t){return t instanceof Array},i=function(t){if(t.left===t.right)return void t.setResult(void 0).exit();if("undefined"==typeof t.left){if("function"==typeof t.right)throw new Error("functions are not supported");return void t.setResult([t.right]).exit()}if("undefined"==typeof t.right)return void t.setResult([t.left,0,0]).exit();if("function"==typeof t.left||"function"==typeof t.right)throw new Error("functions are not supported");return t.leftType=null===t.left?"null":typeof t.left,t.rightType=null===t.right?"null":typeof t.right,t.leftType!==t.rightType?void t.setResult([t.left,t.right]).exit():"boolean"===t.leftType||"number"===t.leftType?void t.setResult([t.left,t.right]).exit():("object"===t.leftType&&(t.leftIsArray=r(t.left)),"object"===t.rightType&&(t.rightIsArray=r(t.right)),t.leftIsArray!==t.rightIsArray?void t.setResult([t.left,t.right]).exit():void 0)};i.filterName="trivial";var
Line truncated
|
||||
R.blur(function(){e[0].setSelectionRange(0,0),e.blur()})}T.focus=y,T.adjustCursorPosition=h,Object.defineProperty(T,"value",{get:function(){return X},set:f}),Object.defineProperty(T,"selectionStart",{get:function(){return Math.min(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0}),Object.defineProperty(T,"selectionEnd",{get:function(){return Math.max(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(void 0,t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0});var r=!1;R.on("keydown",function(t){if(17!==t.which&&91!==t.which&&18!==t.which&&16!==t.which){W.saveSelectionState(),h();var e=t.metaKey||t.ctrlKey;switch(t.which){case 9:e||(i("indent",{inverse:t.shiftKey}),t.preventDefault());break;case 13:i("newline"),t.preventDefault()}13!==t.which&&(r=!1)}}).on("compositionstart",function(){j++}).on("compositionend",function(){setTimeout(function(){j--},0)}).on("mouseup",t.bind(W.saveSelectionState,W,!0,!1)).on("paste",function(t){Y.currentMode="paste",t.preventDefault();var e,n=(t.originalEvent||t).clipboardData;n?e=n.getData("text/plain"):(n=window.clipboardData,e=n&&n.getData("Text")),e&&(d(W.selectionStart,W.selectionEnd,e),h())}).on("cut",function(){Y.currentMode="cut",h()}).on("focus",function(){W.hasFocus=!0}).on("blur",function(){W.hasFocus=!1});var i=function(t,e){var n=v(),r=Math.min(W.selectionStart,W.selectionEnd),i=Math.max(W.selectionStart,W.selectionEnd),a={selectionStart:r,selectionEnd:i,before:n.slice(0,r),after:n.slice(i),selection:n.slice(r,i)};o[t](a,e||{}),f(a.before+a.selection+a.after),W.setSelectionStartEnd(a.selectionStart,a.selectionEnd),W.updateSelectionRange()},a=/^ {0,3}>[ ]*|^[ \t]*(?:[*+\-]|(\d+)\.)[ \t]|^\s+/,o={indent:function(t,e){function n(t,e,n,r){return n=+n||0,r=r||"",t.slice(0,e)+r+t.slice(e+n)}var r=t.before.lastIndexOf("\n")+1;if(e.inverse)/\s/.test(t.before.charAt(r))&&(t.before=n(t.before,r,1),t.selectionStart--,t.selectionEnd--),t.selection=t.selection.replace(/^[ \t]/gm,"");else{var i=t.before.slice(r);if(!t.selection&&!i.match(a))return t.before+=" ",t.selectionStart++,void t.selectionEnd++;t.before=n(t.before,r,0," "),t.selection=t.selection.replace(/\r?\n(?=[\s\S])/g,"\n "),t.selectionStart++,t.selectionEnd++}t.selectionEnd=t.selectionStart+t.selection.length},newline:function(t){var e=t.before.lastIndexOf("\n")+1;if(r)return t.before=t.before.substring(0,e),t.selection="",t.selectionStart=e,t.selectionEnd=e,void(r=!1);r=!1;var n=t.before.slice(e),i=n.match(a),o=(i||[""])[0];if(i&&i[1]){var s=parseInt(i[1],10);o=o.replace(/\d+/,s+1)}o.length&&(r=!0),Y.currentMode="newlines",t.before+="\n"+o,t.selection="",t.selectionStart+=o.length+1,t.selectionEnd=t.selectionStart}};V!==!1&&F.setContent(V)};var Q,K=[],Z=[],te=[],ee=function(){var t={"&":"&","<":"<"," ":" "};return function(e){return e.replace(/[&<\u00a0]/g,function(e){return t[e]})}}();return r.onEditorCreated(F),F}),function(){function t(){}function e(t){this.buttonBar=h.getElementById("wmd-button-bar"+t),this.preview=h.getElementById("wmd-preview"+t),this.input=h.getElementById("wmd-input"+t)}function n(t,e){var n,i,a,o=this,s=[],c=0,u="none",h=function(t,e){u!=t&&(u=t,e||d()),g.isIE&&"moving"==u?a=null:i=setTimeout(f,1)},f=function(t){a=new r(e,t),i=void 0};this.setCommandMode=function(){u="command",d(),i=setTimeout(f,0)},this.canUndo=function(){return c>1},this.canRedo=function(){return s[c+1]?!0:!1},this.undo=function(){o.canUndo()&&(n?(n.restore(),n=null):(s[c]=new r(e),s[--c].restore(),t&&t())),u="none",e.input.focus(),f()},this.redo=function(){o.canRedo()&&(s[++c].restore(),t&&t()),u="none",e.input.focus(),f()};var d=function(){var i=a||new r(e);return i?"moving"==u?void(n||(n=i)):(n&&(s[c-1].text!=n.text&&(s[c++]=n),n=null),s[c++]=i,s[c+1]=null,void(t&&t())):!1},p=function(t){if(!t.ctrlKey&&!t.metaKey){var e=t.keyCode;e>=33&&40>=e||e>=63232&&63235>=e?h("moving"):8==e||46==e||127==e?h("deleting"):13==e?h("newlines"):27==e?h("escape"):(16>e||e>20)&&91!=e&&h("typing")}},m=function(){l.addEvent(e.input,"keypress",function(t){!t.ctrlKey&&!t.metaKey||t.altKey||89!=t.keyCode&&90!=t.keyCode||t.preventDefault()});var t=function(){(g.isIE||a&&a.text!=e.input.value)&&void 0==i&&(u="paste",d(),f())};l.addEvent(e.input,"keydown",p),l.addEvent(e.input,"mousedown",function(){h("moving")}),e.input.onpaste=t,e.input.ondrop=t},v=function(){m(),f(!0)};this.reinit=function(t,e,r,o){s=[],c=0,u="none",n=void 0,i=void 0,f(),a.text=t,a.start=e,a.end=r,a.scrollTop=o,a.setInputAreaSelection(),d()},this.setMode=h,v()}function r(e){var n=this,r=e.input;this.init=function(){l.isVisible(r)&&(this.setInputAreaSelectionStartEnd(),this.scrollTop=r.scrollTop,(!this.text&&r.selectionStart||0===r.selectionStart)&&(this.text=r.value))},this.setInputAreaSelection=function(){l.isVisible(r)&&(r.focus(),r.selectionStart=n.start,r.selectionEnd=n.end)},this.setInputAreaSelLine truncated
|
||||
for(var n,r,i,a=0,o=t.attributes.length;o>a;++a)if(n=t.attributes[a],i=n.name,"class"!=i){if(r=e.attributes.getNamedItem(i),n.specified!=r.specified)return!1;if(n.specified&&n.nodeValue!==r.nodeValue)return!1}return!0}function f(t,e){for(var n,r=0,i=t.attributes.length;i>r;++r)if(n=t.attributes[r].name,(!e||!k.arrayContains(e,n))&&t.attributes[r].specified&&"class"!=n)return!0;return!1}function d(t,e){for(var n in e)if(e.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}function p(t){var e;return t&&1==t.nodeType&&((e=t.parentNode)&&9==e.nodeType&&"on"==e.designMode||N(t)&&!N(t.parentNode))}function g(t){return(N(t)||1!=t.nodeType&&N(t.parentNode))&&!p(t)}function m(t){return t&&1==t.nodeType&&!R.test(E(t,"display"))}function v(t){if(0==t.data.length)return!0;if(A.test(t.data))return!1;var e=E(t.parentNode,"whiteSpace");switch(e){case"pre":case"pre-wrap":case"-moz-pre-wrap":return!1;case"pre-line":if(/[\r\n]/.test(t.data))return!1}return m(t.previousSibling)||m(t.nextSibling)}function y(t,e){return k.isCharacterDataNode(t)?0==e?!!t.previousSibling:e==t.length?!!t.nextSibling:!0:e>0&&e<t.childNodes.length}function x(t,n,r,i){var a,o=0==r;if(k.isAncestorOf(n,t))return t;if(k.isCharacterDataNode(n))if(0==r)r=k.getNodeIndex(n),n=n.parentNode;else{if(r!=n.length)throw e.createError("splitNodeAt should not be called with offset in the middle of a data node ("+r+" in "+n.data);r=k.getNodeIndex(n)+1,n=n.parentNode}if(y(n,r)){if(!a){a=n.cloneNode(!1),a.id&&a.removeAttribute("id");for(var s;s=n.childNodes[r];)a.appendChild(s);k.insertAfter(a,n)}return n==t?a:x(t,a.parentNode,k.getNodeIndex(a),i)}if(t!=n){a=n.parentNode;var l=k.getNodeIndex(n);return o||l++,x(t,a,l,i)}return t}function b(t,e){return t.tagName==e.tagName&&s(t,e)&&h(t,e)}function w(t){var e=t?"nextSibling":"previousSibling";return function(n,r){var i=n.parentNode,a=n[e];if(a){if(a&&3==a.nodeType)return a}else if(r&&(a=i[e],a&&1==a.nodeType&&b(i,a)))return a[t?"firstChild":"lastChild"];return null}}function _(t){this.isElementMerge=1==t.nodeType,this.firstTextNode=this.isElementMerge?t.lastChild:t,this.textNodes=[this.firstTextNode]}function S(t,e,r){this.cssClass=t;var i,o,s,l,c=null;if("object"==typeof e&&null!==e){for(r=e.tagNames,c=e.elementProperties,o=0;l=O[o++];)e.hasOwnProperty(l)&&(this[l]=e[l]);i=e.normalize}else i=e;this.normalize="undefined"==typeof i?!0:i,this.attrExceptions=[];var u=document.createElement(this.elementTagName);this.elementProperties={};for(var h in c)c.hasOwnProperty(h)&&(D.hasOwnProperty(h)&&(h=D[h]),u[h]=c[h],this.elementProperties[h]=u[h],this.attrExceptions.push(h));this.elementSortedClassName=this.elementProperties.hasOwnProperty("className")?a(this.elementProperties.className+" "+t):t,this.applyToAnyTagName=!1;var f=typeof r;if("string"==f)"*"==r?this.applyToAnyTagName=!0:this.tagNames=n(r.toLowerCase()).split(/\s*,\s*/);else if("object"==f&&"number"==typeof r.length)for(this.tagNames=[],o=0,s=r.length;s>o;++o)"*"==r[o]?this.applyToAnyTagName=!0:this.tagNames.push(r[o].toLowerCase());else this.tagNames=[this.elementTagName]}function C(t,e,n){return new S(t,e,n)}t.requireModules(["WrappedSelection","WrappedRange"]);var E,k=t.dom,T="span",I=function(){function t(t,e,n){return e&&n?" ":""}return function(e,n){e.className&&(e.className=e.className.replace(new RegExp("(?:^|\\s)"+n+"(?:\\s|$)"),t))}}();"undefined"!=typeof window.getComputedStyle?E=function(t,e){return k.getWindow(t).getComputedStyle(t,null)[e]}:"undefined"!=typeof document.documentElement.currentStyle?E=function(t,e){return t.currentStyle[e]}:e.fail("No means of obtaining computed style properties found");var N;!function(){var t=document.createElement("div");N="boolean"==typeof t.isContentEditable?function(t){return t&&1==t.nodeType&&t.isContentEditable}:function(t){return t&&1==t.nodeType&&"false"!=t.contentEditable?"true"==t.contentEditable||N(t.parentNode):!1}}();var R=/^inline(-block|-table)?$/i,A=/[^\r\n\t\f \u200B]/,M=w(!1),L=w(!0);_.prototype={doMerge:function(){for(var t,e,n,r=[],i=0,a=this.textNodes.length;a>i;++i)t=this.textNodes[i],e=t.parentNode,r[i]=t.data,i&&(e.removeChild(t),e.hasChildNodes()||e.parentNode.removeChild(e));return this.firstTextNode.data=n=r.join(""),n},getLength:function(){for(var t=this.textNodes.length,e=0;t--;)e+=this.textNodes[t].length;return e},toString:function(){for(var t=[],e=0,n=this.textNodes.length;n>e;++e)t[e]="'"+this.textNodes[e].data+"'";return"[Merge("+t.join(",")+")]"}};var O=["elementTagName","ignoreWhiteSpace","applyToEditableOnly"],D={"class":"className"};S.prototype={elementTagName:T,elementProperties:{},ignoreWhiteSpace:!0,applyToEditableOnly:!1,hasClass:function(t){return 1==t.nodeType&&k.arrayContains(this.tagNames,t.tagName.toLowerCase())&&r(t,this.cssClass)},getSelfOrAncestorWithClass:function(t){for(;t;){if(this.hasClass(t,this.cssClass))return t;t=t.parentNode}return null},isModifiable:function(t){return!this.applyToEditableOnly||g(t)},isIgnorableWhiteSpaceNode:function(t){return this.ignoreWhiteSpaLine truncated
|
||||
R.blur(function(){e[0].setSelectionRange(0,0),e.blur()})}T.focus=y,T.adjustCursorPosition=h,Object.defineProperty(T,"value",{get:function(){return X},set:f}),Object.defineProperty(T,"selectionStart",{get:function(){return Math.min(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0}),Object.defineProperty(T,"selectionEnd",{get:function(){return Math.max(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(void 0,t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0});var r=!1;R.on("keydown",function(t){if(17!==t.which&&91!==t.which&&18!==t.which&&16!==t.which){W.saveSelectionState(),h();var e=t.metaKey||t.ctrlKey;switch(t.which){case 9:e||(i("indent",{inverse:t.shiftKey}),t.preventDefault());break;case 13:i("newline"),t.preventDefault()}13!==t.which&&(r=!1)}}).on("compositionstart",function(){j++}).on("compositionend",function(){setTimeout(function(){j--},0)}).on("mouseup",t.bind(W.saveSelectionState,W,!0,!1)).on("paste",function(t){Y.currentMode="paste",t.preventDefault();var e,n=(t.originalEvent||t).clipboardData;n?e=n.getData("text/plain"):(n=window.clipboardData,e=n&&n.getData("Text")),e&&(d(W.selectionStart,W.selectionEnd,e),h())}).on("cut",function(){Y.currentMode="cut",h()}).on("focus",function(){W.hasFocus=!0}).on("blur",function(){W.hasFocus=!1});var i=function(t,e){var n=v(),r=Math.min(W.selectionStart,W.selectionEnd),i=Math.max(W.selectionStart,W.selectionEnd),a={selectionStart:r,selectionEnd:i,before:n.slice(0,r),after:n.slice(i),selection:n.slice(r,i)};o[t](a,e||{}),f(a.before+a.selection+a.after),W.setSelectionStartEnd(a.selectionStart,a.selectionEnd),W.updateSelectionRange()},a=/^ {0,3}>[ ]*|^[ \t]*(?:[*+\-]|(\d+)\.)[ \t]|^\s+/,o={indent:function(t,e){function n(t,e,n,r){return n=+n||0,r=r||"",t.slice(0,e)+r+t.slice(e+n)}var r=t.before.lastIndexOf("\n")+1;if(e.inverse)/\s/.test(t.before.charAt(r))&&(t.before=n(t.before,r,1),t.selectionStart--,t.selectionEnd--),t.selection=t.selection.replace(/^[ \t]/gm,"");else{var i=t.before.slice(r);if(!t.selection&&!i.match(a))return t.before+=" ",t.selectionStart++,void t.selectionEnd++;t.before=n(t.before,r,0," "),t.selection=t.selection.replace(/\r?\n(?=[\s\S])/g,"\n "),t.selectionStart++,t.selectionEnd++}t.selectionEnd=t.selectionStart+t.selection.length},newline:function(t){var e=t.before.lastIndexOf("\n")+1;if(r)return t.before=t.before.substring(0,e),t.selection="",t.selectionStart=e,t.selectionEnd=e,void(r=!1);r=!1;var n=t.before.slice(e),i=n.match(a),o=(i||[""])[0];if(i&&i[1]){var s=parseInt(i[1],10);o=o.replace(/\d+/,s+1)}o.length&&(r=!0),Y.currentMode="newlines",t.before+="\n"+o,t.selection="",t.selectionStart+=o.length+1,t.selectionEnd=t.selectionStart}};V!==!1&&F.setContent(V)};var Q,K=[],Z=[],te=[],ee=function(){var t={"&":"&","<":"<"," ":" "};return function(e){return e.replace(/[&<\u00a0]/g,function(e){return t[e]})}}();return r.onEditorCreated(F),F}),function(){function t(){}function e(t){this.buttonBar=h.getElementById("wmd-button-bar"+t),this.preview=h.getElementById("wmd-preview"+t),this.input=h.getElementById("wmd-input"+t)}function n(t,e){var n,i,a,o=this,s=[],c=0,u="none",h=function(t,e){u!=t&&(u=t,e||d()),g.isIE&&"moving"==u?a=null:i=setTimeout(f,1)},f=function(t){a=new r(e,t),i=void 0};this.setCommandMode=function(){u="command",d(),i=setTimeout(f,0)},this.canUndo=function(){return c>1},this.canRedo=function(){return s[c+1]?!0:!1},this.undo=function(){o.canUndo()&&(n?(n.restore(),n=null):(s[c]=new r(e),s[--c].restore(),t&&t())),u="none",e.input.focus(),f()},this.redo=function(){o.canRedo()&&(s[++c].restore(),t&&t()),u="none",e.input.focus(),f()};var d=function(){var i=a||new r(e);return i?"moving"==u?void(n||(n=i)):(n&&(s[c-1].text!=n.text&&(s[c++]=n),n=null),s[c++]=i,s[c+1]=null,void(t&&t())):!1},p=function(t){if(!t.ctrlKey&&!t.metaKey){var e=t.keyCode;e>=33&&40>=e||e>=63232&&63235>=e?h("moving"):8==e||46==e||127==e?h("deleting"):13==e?h("newlines"):27==e?h("escape"):(16>e||e>20)&&91!=e&&h("typing")}},m=function(){l.addEvent(e.input,"keypress",function(t){!t.ctrlKey&&!t.metaKey||t.altKey||89!=t.keyCode&&90!=t.keyCode||t.preventDefault()});var t=function(){(g.isIE||a&&a.text!=e.input.value)&&void 0==i&&(u="paste",d(),f())};l.addEvent(e.input,"keydown",p),l.addEvent(e.input,"mousedown",function(){h("moving")}),e.input.onpaste=t,e.input.ondrop=t},v=function(){m(),f(!0)};this.reinit=function(t,e,r,o){s=[],c=0,u="none",n=void 0,i=void 0,f(),a.text=t,a.start=e,a.end=r,a.scrollTop=o,a.setInputAreaSelection(),d()},this.setMode=h,v()}function r(e){var n=this,r=e.input;this.init=function(){l.isVisible(r)&&(this.setInputAreaSelectionStartEnd(),this.scrollTop=r.scrollTop,(!this.text&&r.selectionStart||0===r.selectionStart)&&(this.text=r.value))},this.setInputAreaSelection=function(){l.isVisible(r)&&(r.focus(),r.selectionStart=n.start,r.selectionEnd=n.end)},this.setInputAreaSelLine truncated
|
||||
if(e.href==i.href)return clearInterval(a),n()}},10);i.href=e,t.appendChild(i)};return i.normalize=function(t,e){return".css"==t.substr(t.length-4,4)&&(t=t.substr(0,t.length-4)),e(t)},i.load=function(t,e,r){(n?d:p)(e.toUrl(t+".css"),r)},i}),define("css",["css/css"],function(t){return t}),rangy.createModule("CssClassApplier",function(t,e){function n(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function r(t,e){return t.className&&new RegExp("(?:^|\\s)"+e+"(?:\\s|$)").test(t.className)}function i(t,e){t.className?r(t,e)||(t.className+=" "+e):t.className=e}function a(t){return t.split(/\s+/).sort().join(" ")}function o(t){return a(t.className)}function s(t,e){return o(t)==o(e)}function l(t){for(var e=t.parentNode;t.hasChildNodes();)e.insertBefore(t.firstChild,t);e.removeChild(t)}function c(t,e){var n=t.cloneRange();n.selectNodeContents(e);var r=n.intersection(t),i=r?r.toString():"";return n.detach(),""!=i}function u(t){return t.getNodes([3],function(e){return c(t,e)})}function h(t,e){if(t.attributes.length!=e.attributes.length)return!1;for(var n,r,i,a=0,o=t.attributes.length;o>a;++a)if(n=t.attributes[a],i=n.name,"class"!=i){if(r=e.attributes.getNamedItem(i),n.specified!=r.specified)return!1;if(n.specified&&n.nodeValue!==r.nodeValue)return!1}return!0}function f(t,e){for(var n,r=0,i=t.attributes.length;i>r;++r)if(n=t.attributes[r].name,(!e||!k.arrayContains(e,n))&&t.attributes[r].specified&&"class"!=n)return!0;return!1}function d(t,e){for(var n in e)if(e.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}function p(t){var e;return t&&1==t.nodeType&&((e=t.parentNode)&&9==e.nodeType&&"on"==e.designMode||N(t)&&!N(t.parentNode))}function g(t){return(N(t)||1!=t.nodeType&&N(t.parentNode))&&!p(t)}function m(t){return t&&1==t.nodeType&&!R.test(E(t,"display"))}function v(t){if(0==t.data.length)return!0;if(A.test(t.data))return!1;var e=E(t.parentNode,"whiteSpace");switch(e){case"pre":case"pre-wrap":case"-moz-pre-wrap":return!1;case"pre-line":if(/[\r\n]/.test(t.data))return!1}return m(t.previousSibling)||m(t.nextSibling)}function y(t,e){return k.isCharacterDataNode(t)?0==e?!!t.previousSibling:e==t.length?!!t.nextSibling:!0:e>0&&e<t.childNodes.length}function x(t,n,r,i){var a,o=0==r;if(k.isAncestorOf(n,t))return t;if(k.isCharacterDataNode(n))if(0==r)r=k.getNodeIndex(n),n=n.parentNode;else{if(r!=n.length)throw e.createError("splitNodeAt should not be called with offset in the middle of a data node ("+r+" in "+n.data);r=k.getNodeIndex(n)+1,n=n.parentNode}if(y(n,r)){if(!a){a=n.cloneNode(!1),a.id&&a.removeAttribute("id");for(var s;s=n.childNodes[r];)a.appendChild(s);k.insertAfter(a,n)}return n==t?a:x(t,a.parentNode,k.getNodeIndex(a),i)}if(t!=n){a=n.parentNode;var l=k.getNodeIndex(n);return o||l++,x(t,a,l,i)}return t}function b(t,e){return t.tagName==e.tagName&&s(t,e)&&h(t,e)}function w(t){var e=t?"nextSibling":"previousSibling";return function(n,r){var i=n.parentNode,a=n[e];if(a){if(a&&3==a.nodeType)return a}else if(r&&(a=i[e],a&&1==a.nodeType&&b(i,a)))return a[t?"firstChild":"lastChild"];return null}}function _(t){this.isElementMerge=1==t.nodeType,this.firstTextNode=this.isElementMerge?t.lastChild:t,this.textNodes=[this.firstTextNode]}function S(t,e,r){this.cssClass=t;var i,o,s,l,c=null;if("object"==typeof e&&null!==e){for(r=e.tagNames,c=e.elementProperties,o=0;l=O[o++];)e.hasOwnProperty(l)&&(this[l]=e[l]);i=e.normalize}else i=e;this.normalize="undefined"==typeof i?!0:i,this.attrExceptions=[];var u=document.createElement(this.elementTagName);this.elementProperties={};for(var h in c)c.hasOwnProperty(h)&&(D.hasOwnProperty(h)&&(h=D[h]),u[h]=c[h],this.elementProperties[h]=u[h],this.attrExceptions.push(h));this.elementSortedClassName=this.elementProperties.hasOwnProperty("className")?a(this.elementProperties.className+" "+t):t,this.applyToAnyTagName=!1;var f=typeof r;if("string"==f)"*"==r?this.applyToAnyTagName=!0:this.tagNames=n(r.toLowerCase()).split(/\s*,\s*/);else if("object"==f&&"number"==typeof r.length)for(this.tagNames=[],o=0,s=r.length;s>o;++o)"*"==r[o]?this.applyToAnyTagName=!0:this.tagNames.push(r[o].toLowerCase());else this.tagNames=[this.elementTagName]}function C(t,e,n){return new S(t,e,n)}t.requireModules(["WrappedSelection","WrappedRange"]);var E,k=t.dom,T="span",I=function(){function t(t,e,n){return e&&n?" ":""}return function(e,n){e.className&&(e.className=e.className.replace(new RegExp("(?:^|\\s)"+n+"(?:\\s|$)"),t))}}();"undefined"!=typeof window.getComputedStyle?E=function(t,e){return k.getWindow(t).getComputedStyle(t,null)[e]}:"undefined"!=typeof document.documentElement.currentStyle?E=function(t,e){return t.currentStyle[e]}:e.fail("No means of obtaining computed style properties found");var N;!function(){var t=document.createElement("div");N="boolean"==typeof t.isContentEditable?function(t){return t&&1==t.nodeType&&t.isContentEditable}:function(t){return t&&1==t.nodeType&&"false"!=t.contentEditable?"true"==t.contentEditable||N(t.parentNode):!1}}();var R=/^inline(-block|-table)?$/i,A=/[^\r\n\t\f \u200B]/,Line truncated
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
.tour-backdrop,div.jGrowl.bottom-right{right:0;bottom:0}#wmd-input>.editor-margin .discussion.active,#wmd-input>.editor-margin .discussion:hover,.btn-link:hover{text-decoration:none}.form-control:focus{border-color:#f0f0f0;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.025),0 0 12px -1px rgba(128,128,128,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.025),0 0 12px -1px rgba(128,128,128,.6)}@media (min-width:768px){.navbar-form .col-sm-1{width:8.33333333%!important}.navbar-form .col-sm-2{width:16.66666667%!important}.navbar-form .col-sm-3{width:25%!important}.navbar-form .col-sm-4{width:33.33333333%!important}.navbar-form .col-sm-5{width:41.66666667%!important}.navbar-form .col-sm-6{width:50%!important}.navbar-form .col-sm-7{width:58.33333333%!important}.navbar-form .col-sm-8{width:66.66666667%!important}.navbar-form .col-sm-9{width:75%!important}.navbar-form .col-sm-10{width:83.33333333%!important}.navbar-form .col-sm-11{width:91.66666667%!important}.navbar-form .col-sm-12{width:100%!important}}.navbar-form *{float:none}pre.prettyprint *{font-family:Monaco,Menlo,Consolas,"Courier New",monospace}pre.prettyprint{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}code.prettyprint,pre.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8;-moz-border-radius:3px;-webkit-border-radius:3px;-o-border-radius:3px;-ms-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;display:block}code.prettyprint ol.linenums,pre.prettyprint ol.linenums{padding:0 0 0 30px;margin:0}code.prettyprint ol.linenums li,pre.prettyprint ol.linenums li{padding-left:0;color:#bebec5;line-height:20px}code.prettyprint .com,pre.prettyprint .com{color:#93a1a1;font-style:italic}code.prettyprint .lit,pre.prettyprint .lit{color:#195f91}code.prettyprint .clo,code.prettyprint .opn,code.prettyprint .pun,pre.prettyprint .clo,pre.prettyprint .opn,pre.prettyprint .pun{color:#93a1a1}code.prettyprint .fun,pre.prettyprint .fun{color:#dc322f}code.prettyprint .atv,code.prettyprint .str,pre.prettyprint .atv,pre.prettyprint .str{color:#d14}code.prettyprint .kwd,code.prettyprint .tag,pre.prettyprint .kwd,pre.prettyprint .tag{color:#1e347b}code.prettyprint .atn,code.prettyprint .dec,code.prettyprint .typ,code.prettyprint .var,pre.prettyprint .atn,pre.prettyprint .dec,pre.prettyprint .typ,pre.prettyprint .var{color:teal}code.prettyprint .pln,pre.prettyprint .pln{color:#48484c}.container{margin-bottom:180px;text-align:justify}blockquote p,ol,ol ol,ol ul,ul,ul ol,ul ul{margin-bottom:.3em}a code{color:inherit}pre{word-break:break-word;border-radius:5px}blockquote,p{margin:0 0 .3em}hr{margin:2em 0}img{max-width:100%}.flow-chart,.sequence-diagram{text-align:center;margin-bottom:.3em}.flow-chart text,.sequence-diagram text{font-size:15px!important;font-family:"Source Sans Pro",sans-serif!important}.flow-chart [fill="#ffffff"],.sequence-diagram [fill="#ffffff"]{fill:#f8f8f8}.flow-chart [stroke="#000000"],.sequence-diagram [stroke="#000000"]{stroke:#3f3f3f}.flow-chart text[stroke="#000000"],.sequence-diagram text[stroke="#000000"]{stroke:none}.flow-chart [fill="#000000"],.flow-chart [fill="#000"],.flow-chart [fill=black],.sequence-diagram [fill="#000000"],.sequence-diagram [fill="#000"],.sequence-diagram [fill=black]{fill:#3f3f3f}code,pre{font-family:"Source Code Pro",monospace;font-size:.9em}code{white-space:normal}pre.prettyprint{text-align:start;border:0;padding:10px 20px}pre.prettyprint code{background-color:transparent!important}dd,dt{margin-top:5px;margin-bottom:5px}dd{margin-left:40px}table{margin-bottom:20px}table td,table th{padding:8px;line-height:20px;vertical-align:top;border-top:1px solid #ddd}table th{font-weight:700}table thead th{vertical-align:bottom}table caption+thead tr:first-child td,table caption+thead tr:first-child th,table colgroup+thead tr:first-child td,table colgroup+thead tr:first-child th,table thead:first-child tr:first-child td,table thead:first-child tr:first-child th{border-top:0}table tbody+tbody{border-top:2px solid #ddd}blockquote{border-left-width:10px;background-color:rgba(128,128,128,.05);border-top-right-radius:5px;border-bottom-right-radius:5px;padding:15px 20px}blockquote p{font-size:1em;line-height:1.45}blockquote ol:last-child,blockquote ul:last-child{margin-bottom:0}kbd{padding:.1em .6em;border:1px solid rgba(63,63,63,.25);-webkit-box-shadow:0 1px 0 rgba(63,63,63,.25);box-shadow:0 1px 0 rgba(63,63,63,.25);font-size:.7em;font-family:sans-serif;background-color:#fff;color:#333;border-radius:3px;display:inline-block;margin:0 .1em;white-space:nowrap}.toc ul{list-style-type:none;margin-bottom:15px}.footnote{vertical-align:top;position:relative;top:-.5em;font-size:.8em}.tour-backdrop{position:fixed;top:0;left:0;z-index:1030;background-color:#000;opacity:.8}.tour-step-backdrop{position:relative;z-index:1031;background:inherit}.tour-step-background{position:absolute;z-index:1030;background:inherit;border-radius:6px}.popover[class*=tour-]{z-iLine truncated
|
||||
.tour-backdrop,div.jGrowl.bottom-right{right:0;bottom:0}#wmd-input>.editor-margin .discussion.active,#wmd-input>.editor-margin .discussion:hover,.btn-link:hover{text-decoration:none}.form-control:focus{border-color:#f0f0f0;outline:0;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.025),0 0 12px -1px rgba(128,128,128,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.025),0 0 12px -1px rgba(128,128,128,.6)}@media (min-width:768px){.navbar-form .col-sm-1{width:8.33333333%!important}.navbar-form .col-sm-2{width:16.66666667%!important}.navbar-form .col-sm-3{width:25%!important}.navbar-form .col-sm-4{width:33.33333333%!important}.navbar-form .col-sm-5{width:41.66666667%!important}.navbar-form .col-sm-6{width:50%!important}.navbar-form .col-sm-7{width:58.33333333%!important}.navbar-form .col-sm-8{width:66.66666667%!important}.navbar-form .col-sm-9{width:75%!important}.navbar-form .col-sm-10{width:83.33333333%!important}.navbar-form .col-sm-11{width:91.66666667%!important}.navbar-form .col-sm-12{width:100%!important}}.navbar-form *{float:none}pre.prettyprint *{font-family:Monaco,Menlo,Consolas,"Courier New",monospace}pre.prettyprint{white-space:pre-wrap;white-space:-moz-pre-wrap;white-space:-pre-wrap;white-space:-o-pre-wrap;word-wrap:break-word}code.prettyprint,pre.prettyprint{padding:8px;background-color:#f7f7f9;border:1px solid #e1e1e8;-moz-border-radius:3px;-webkit-border-radius:3px;-o-border-radius:3px;-ms-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;display:block}code.prettyprint ol.linenums,pre.prettyprint ol.linenums{padding:0 0 0 30px;margin:0}code.prettyprint ol.linenums li,pre.prettyprint ol.linenums li{padding-left:0;color:#bebec5;line-height:20px}code.prettyprint .com,pre.prettyprint .com{color:#93a1a1;font-style:italic}code.prettyprint .lit,pre.prettyprint .lit{color:#195f91}code.prettyprint .clo,code.prettyprint .opn,code.prettyprint .pun,pre.prettyprint .clo,pre.prettyprint .opn,pre.prettyprint .pun{color:#93a1a1}code.prettyprint .fun,pre.prettyprint .fun{color:#dc322f}code.prettyprint .atv,code.prettyprint .str,pre.prettyprint .atv,pre.prettyprint .str{color:#d14}code.prettyprint .kwd,code.prettyprint .tag,pre.prettyprint .kwd,pre.prettyprint .tag{color:#1e347b}code.prettyprint .atn,code.prettyprint .dec,code.prettyprint .typ,code.prettyprint .var,pre.prettyprint .atn,pre.prettyprint .dec,pre.prettyprint .typ,pre.prettyprint .var{color:teal}code.prettyprint .pln,pre.prettyprint .pln{color:#48484c}.container{margin-bottom:180px;text-align:justify}blockquote p,ol,ol ol,ol ul,ul,ul ol,ul ul{margin-bottom:.3em}a code{color:inherit}pre{word-break:break-word;border-radius:5px}blockquote,p{margin:0 0 .3em}hr{margin:2em 0}img{max-width:100%}.flow-chart,.sequence-diagram{text-align:center;margin-bottom:.3em}.flow-chart text,.sequence-diagram text{font-size:15px!important;font-family:"Source Sans Pro",sans-serif!important}.flow-chart [fill="#ffffff"],.sequence-diagram [fill="#ffffff"]{fill:#f8f8f8}.flow-chart [stroke="#000000"],.sequence-diagram [stroke="#000000"]{stroke:#3f3f3f}.flow-chart text[stroke="#000000"],.sequence-diagram text[stroke="#000000"]{stroke:none}.flow-chart [fill="#000000"],.flow-chart [fill="#000"],.flow-chart [fill=black],.sequence-diagram [fill="#000000"],.sequence-diagram [fill="#000"],.sequence-diagram [fill=black]{fill:#3f3f3f}code,pre{font-family:"Source Code Pro",monospace;font-size:.9em}code{white-space:normal}pre.prettyprint{text-align:start;border:0;padding:10px 20px}pre.prettyprint code{background-color:transparent!important}dd,dt{margin-top:5px;margin-bottom:5px}dd{margin-left:40px}table{margin-bottom:20px}table td,table th{padding:8px;line-height:20px;vertical-align:top;border-top:1px solid #ddd}table th{font-weight:700}table thead th{vertical-align:bottom}table caption+thead tr:first-child td,table caption+thead tr:first-child th,table colgroup+thead tr:first-child td,table colgroup+thead tr:first-child th,table thead:first-child tr:first-child td,table thead:first-child tr:first-child th{border-top:0}table tbody+tbody{border-top:2px solid #ddd}blockquote{border-left-width:10px;background-color:rgba(128,128,128,.05);border-top-right-radius:5px;border-bottom-right-radius:5px;padding:15px 20px}blockquote p{font-size:1em;line-height:1.45}blockquote ol:last-child,blockquote ul:last-child{margin-bottom:0}kbd{padding:.1em .6em;border:1px solid rgba(63,63,63,.25);-webkit-box-shadow:0 1px 0 rgba(63,63,63,.25);box-shadow:0 1px 0 rgba(63,63,63,.25);font-size:.7em;font-family:sans-serif;background-color:#fff;color:#333;border-radius:3px;display:inline-block;margin:0 .1em;white-space:nowrap}.toc ul{list-style-type:none;margin-bottom:15px}.footnote{vertical-align:top;position:relative;top:-.5em;font-size:.8em}.tour-backdrop{position:fixed;top:0;left:0;z-index:1030;background-color:#000;opacity:.8}.tour-step-backdrop{position:relative;z-index:1031;background:inherit}.tour-step-background{position:absolute;z-index:1030;background:inherit;border-radius:6px}.popover[class*=tour-]{z-iLine truncated
|
||||
Vendored
-12
@@ -640,11 +640,8 @@ a.list-group-item:focus {
|
||||
-webkit-transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s;
|
||||
transition: background-color ease-in-out .15s, color ease-in-out .15s, border-color ease-in-out .15s;
|
||||
}
|
||||
.btn-default:hover,
|
||||
.alertify-button-cancel:hover,
|
||||
.btn-default:focus,
|
||||
.alertify-button-cancel:focus,
|
||||
.btn-default:active,
|
||||
.alertify-button-cancel:active,
|
||||
.open .btn-default.dropdown-toggle,
|
||||
.open .alertify-button-cancel.dropdown-toggle {
|
||||
@@ -652,29 +649,20 @@ a.list-group-item:focus {
|
||||
border-color: rgba(128, 128, 128, 0.1);
|
||||
background-color: rgba(128, 128, 128, 0.04) !important;
|
||||
}
|
||||
.btn-primary:hover,
|
||||
.alertify-button-ok:hover,
|
||||
.btn-primary:focus,
|
||||
.alertify-button-ok:focus,
|
||||
.btn-primary:active,
|
||||
.alertify-button-ok:active,
|
||||
.open .btn-primary.dropdown-toggle,
|
||||
.open .alertify-button-ok.dropdown-toggle {
|
||||
color: #343434;
|
||||
border-color: rgba(128, 128, 128, 0.1);
|
||||
background-color: #e3e3e3 !important;
|
||||
}
|
||||
.btn-success:hover,
|
||||
.btn-success:focus,
|
||||
.btn-success:active,
|
||||
.open .btn-success.dropdown-toggle {
|
||||
color: #343434 !important;
|
||||
border-color: rgba(128, 128, 128, 0.1);
|
||||
background-color: rgba(128, 128, 128, 0.05) !important;
|
||||
}
|
||||
.btn-info:hover,
|
||||
.btn-info:focus,
|
||||
.btn-info:active,
|
||||
.btn-info.info-tooltip,
|
||||
.info-tooltip .btn-info,
|
||||
.open .btn-info.dropdown-toggle {
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
function trimLeft(t,e){if(!e||" "==e)return $.trim(t);for(;0==t.indexOf(e);)t=t.substring(e.length);return t}function json(str){return eval("("+str+")")}function t(){var t=arguments;if(t.length<=1)return t[0];var e=t[0];if(!e)return e;var n="LEAAEL";e=e.replace(/\?/g,n);for(var o=1;o<=t.length;++o)e=e.replace(n,t[o]);return e}function arrayEqual(t,e){return t=t||[],e=e||[],t.join(",")==e.join(",")}function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function isEmpty(t){return t?isArray(t)&&0==t.length?!0:!1:!0}function getFormJsonData(t){var e=formArrDataToJson($("#"+t).serializeArray());return e}function formArrDataToJson(t){var e={},n={};for(var o in t){var r=t[o].name,i=t[o].value;"[]"!=r.substring(r.length-2,r.length)?e[r]=i:(r=r.substring(0,r.length-2),void 0==n[r]?n[r]=[i]:n[r].push(i))}return $.extend(e,n)}function formSerializeDataToJson(t){for(var e=t.split("&"),n={},o={},r=0;r<e.length;++r){var i=e[r].split("="),a=decodeURI(i[0]),s=decodeURI(i[1]);"[]"!=a.substring(a.length-2,a.length)?n[a]=s:(a=a.substring(0,a.length-2),void 0==o[a]?o[a]=[s]:o[a].push(s))}return $.extend(n,o)}function _ajaxCallback(t,e,n){if(t===!0||"true"==t||"object"==typeof t){if(t&&"object"==typeof t&&"NOTLOGIN"==t.Msg)return void alert("你还没有登录, 请先登录!");"function"==typeof e&&e(t)}else"function"==typeof n?n(t):alert("error!")}function _ajax(t,e,n,o,r,i){return log("-------------------ajax:"),log(e),log(n),i="undefined"==typeof i?!0:!1,$.ajax({type:t,url:e,data:n,async:i,success:function(t){_ajaxCallback(t,o,r)},error:function(t){_ajaxCallback(t,o,r)}})}function ajaxGet(t,e,n,o,r){return _ajax("GET",t,e,n,o,r)}function ajaxPost(t,e,n,o,r){_ajax("POST",t,e,n,o,r)}function ajaxPostJson(t,e,n,o,r){log("-------------------ajaxPostJson:"),log(t),log(e),r="undefined"==typeof r?!0:!1,$.ajax({url:t,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:r,data:JSON.stringify(e),success:function(t,e){_ajaxCallback(t,n,o)},error:function(t){_ajaxCallback(t,n,o)}})}function findParents(t,e){if($(t).is(e))return $(t);for(var n=$(t).parents(),o=0;o<n.length;++o)if(log(n.eq(o)),n.eq(o).is(e))return n.seq(o);return null}function getVendorPrefix(){for(var t=document.body||document.documentElement,e=t.style,n=["webkit","khtml","moz","ms","o"],o=0;o<n.length;){if("string"==typeof e[n[o]+"Transition"])return n[o];o++}}function editorIframeTabindex(t){var e=$("#editorContent");e.attr("tabindex",t),setTimeout(function(){e.attr("tabindex",t)},500),setTimeout(function(){e.attr("tabindex",t)},1e3)}function switchEditor(t){LEA.isM=t,t?($("#mdEditor").css("z-index",3).show(),editorIframeTabindex(3),$("#wmd-input").attr("tabindex",2),$("#leanoteNav").hide()):($("#editor").show(),$("#mdEditor").css("z-index",1).hide(),editorIframeTabindex(2),$("#wmd-input").attr("tabindex",3),$("#leanoteNav").show())}function setEditorContent(t,e,n,o){if(t||(t=""),clearIntervalForSetContent&&clearInterval(clearIntervalForSetContent),e)MD?(MD.setContent(t),o&&o(),LEA.s4=new Date,LEA.s4_1=LEA.s4.getTime()-LEA.s1.getTime()):clearIntervalForSetContent=setTimeout(function(){setEditorContent(t,!0,!1,o)},100);else if($("#editorContent").html(t),"undefined"!=typeof tinymce&&tinymce.activeEditor){var r=tinymce.activeEditor;LEA.s4=new Date,LEA.s4_1=LEA.s4.getTime()-LEA.s1.getTime(),r.setContent(t),o&&o(),r.undoManager.clear()}else clearIntervalForSetContent=setTimeout(function(){setEditorContent(t,!1,!1,o)},100)}function previewIsEmpty(t){return t&&t.substr(0,previewToken.length)!=previewToken?!1:!0}function isAceError(t){return t?-1!=t.indexOf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"):!1}function getEditorContent(t){if(t)return[MD.getContent(),"<div>"+$("#preview-contents").html()+"</div>"];var e=tinymce.activeEditor;if(e){var n=$(e.getBody()).clone();if(n.find(".toggle-raw").remove(),window.LeaAce&&LeaAce.getAce)for(var o=n.find("pre"),r=0;r<o.length;++r){var i=o.eq(r),a=i.attr("id"),s=LeaAce.getAce(a);if(s){var l=s.getValue();isAceError(l)&&(l=i.html()),l=l.replace(/</g,"<").replace(/>/g,">"),i.removeAttr("style","").removeAttr("contenteditable").removeClass("ace_editor"),i.html(l)}}if(n.find("pinit").remove(),n.find(".thunderpin").remove(),n.find(".pin").parent().remove(),n=$(n).html())for(;;){var c=n.lastIndexOf("</script>");if(-1==c)return n;var u=n.length;if(u-9!=c)return n;var f=n.lastIndexOf("<script ");if(-1==f&&(f=n.lastIndexOf("<script>")),-1==f)return n;n=n.substring(0,f)}return n}}function disableEditor(){var t=tinymce.activeEditor;t&&(t.hide(),LEA.editorStatus=!1,$("#mceTollbarMark").show().css("z-index",1e3))}function enableEditor(){if(!LEA.editorStatus){$("#mceTollbarMark").css("z-index",-1).hide();var t=tinymce.activeEditor;t&&t.show()}}function showDialog(t,e){$("#leanoteDialog #modalTitle").html(e.title),$("#leanoteDialog .modal-body").html($("#"+t+" .modal-body").html()),$("#leanoteDialog .modal-footer").html($("#"+t+" .modal-footer").html()),delete e.title,e.show=!0,$("#leanLine 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='<li href="#" class="item ?" noteId="?">',Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>',Note.itemTpl='<li href="#" class="item ? item-image" 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-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>',Note.newItemTpl='<li 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-clock-o"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>',Note.noteItemListO=$("#noteItemList"),Note.cacheByNotebookId={all:{}},Note.notebookIds={},Note.isReadOnly=!1,Note.intervalTime=6e5,Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始..."),changedNote=Note.curChangedSaveIt(!1)},Note.intervalTime)},Note.stopInterval=function(){clearInterval(Note.interval),setTimeout(function(){Note.startInterval()},Note.intervalTime)},Note.addNoteCache=function(t){Note.cache[t.NoteId]=t,Note.clearCacheByNotebookId(t.NotebookId)},Note.setNoteCache=function(t,e){Note.cache[t.NoteId]?$.extend(Note.cache[t.NoteId],t):Note.cache[t.NoteId]=t,void 0==e&&(e=!0),e&&Note.clearCacheByNotebookId(t.NotebookId)},Note.getCurNote=function(){var t=this;return""==t.curNoteId?null:t.cache[t.curNoteId]},Note.getNote=function(t){var e=this;return e.cache[t]},Note.clearCacheByNotebookId=function(t){t&&(Note.cacheByNotebookId[t]={},Note.cacheByNotebookId.all={},Note.notebookIds[t]=!0)},Note.notebookHasNotes=function(t){var e=Note.getNotesByNotebookId(t);return!isEmpty(e)},Note.getNotesByNotebookId=function(t,e,o){if(e||(e="UpdatedTime"),"undefined"==o&&(o=!1),t||(t="all"),!Note.cacheByNotebookId[t])return[];if(Note.cacheByNotebookId[t][e])return Note.cacheByNotebookId[t][e];var a=[];for(var n in Note.cache)if(n){var i=Note.cache[n];i.IsTrash||i.IsShared||("all"==t||i.NotebookId==t)&&a.push(i)}return a.sort(function(t,a){var n=t[e],i=a[e];if(o){if(i>n)return-1;if(n>i)return 1}else{if(i>n)return 1;if(n>i)return-1}return 0}),Note.cacheByNotebookId[t][e]=a,a},Note.curNoteIsDirtied=function(){var t=this,e=t.getCurNote();e&&(e.isDirty=!0)},Note.renderNotesAndFirstOneContent=function(t){isArray(t)&&(Note.renderNotes(t),isEmpty(t[0])||Note.changeNoteForPjax(t[0].NoteId,!0,!1))},Note.curHasChanged=function(t){void 0==t&&(t=!0);var e,o,a,n=Note.cache[Note.curNoteId]||{},i=$("#noteTitle").val(),r=Tag.getTags(),s=getEditorContent(n.IsMarkdown);if(isArray(s))e=s[0],o=s[1],a=e,e&&previewIsEmpty(o)&&Converter&&(o=Converter.makeHtml(e)),e||(o=""),n.Preview=o;else{e=s;try{a=$(e).text()}catch(c){}}var d={hasChanged:!1,IsNew:n.IsNew,IsMarkdown:n.IsMarkdown,FromUserId:n.FromUserId,NoteId:n.NoteId,NotebookId:n.NotebookId,Version:n.Version||0};if(d.IsNew)$.extend(d,n);else if(!t&&!n.isDirty)return log("no dirty"),d.hasChanged=!1,d;if(n.Title!=i&&(d.hasChanged=!0,d.Title=i,!d.Title),arrayEqual(n.Tags,r)||(d.hasChanged=!0,d.Tags=r.join(",")),t&&n.Content!=e||!t&&(!n.IsMarkdown&&$(n.Content).text()!=a||n.IsMarkdown&&n.Content!=a)){d.hasChanged=!0,d.Content=e;var N=o||e;n.HasSelfDefined&&n.IsBlog||(d.Desc=Note.genDesc(N),d.ImgSrc=Note.getImgSrc(N),d.Abstract=Note.genAbstract(N))}else log("text相同"),log(n.Content==e);return d.UserId=n.UserId||"",d},Note.genDesc=function(t){return t?(t=t.replace(/<br \/>/g," <br />"),t=t.replace(/<\/p>/g," </p>"),t=t.replace(/<\/div>/g," </div>"),t=$("<div></div>").html(t).text(),t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),t.length<300?t:t.substring(0,300)):""},Note.genAbstract=function(t,e){if(!t)return"";if(void 0==e&&(e=1e3),t.length<e)return t;for(var o=!1,a=!1,n=0,i="",r=e,s=0;s<t.length;++s){var c=t[s];if("<"==c?o=!0:"&"==c?a=!0:">"==c&&o?(n-=1,o=!1):";"==c&&a&&(a=!1),o||a||(n+=1),i+=c,n>=r)break}var d=document.createElement("div");return d.innerHTML=i,d.innerHTML},Note.getImgSrc=function(t){if(!t)return"";var e=$(t).find("img");for(var o in e){var a=e.eq(o).attr("src");if(a)return a}return""},Note.saveInProcess={},Note.savePool={},Note.curChangedSaveIt=function(t,e){var o=this;if(Note.curNoteId&&!Note.isReadOnly){var a=Note.curHasChanged(t);return a.hasChanged||a.IsNew?(Note.renderChangedNote(a),delete a.hasChanged,showMsg(getMsg("saving")),o.saveILine truncated
|
||||
function trimLeft(t,e){if(!e||" "==e)return $.trim(t);for(;0==t.indexOf(e);)t=t.substring(e.length);return t}function json(str){return eval("("+str+")")}function t(){var t=arguments;if(t.length<=1)return t[0];var e=t[0];if(!e)return e;var n="LEAAEL";e=e.replace(/\?/g,n);for(var o=1;o<=t.length;++o)e=e.replace(n,t[o]);return e}function arrayEqual(t,e){return t=t||[],e=e||[],t.join(",")==e.join(",")}function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function isEmpty(t){return t?isArray(t)&&0==t.length?!0:!1:!0}function getFormJsonData(t){var e=formArrDataToJson($("#"+t).serializeArray());return e}function formArrDataToJson(t){var e={},n={};for(var o in t){var r=t[o].name,i=t[o].value;"[]"!=r.substring(r.length-2,r.length)?e[r]=i:(r=r.substring(0,r.length-2),void 0==n[r]?n[r]=[i]:n[r].push(i))}return $.extend(e,n)}function formSerializeDataToJson(t){for(var e=t.split("&"),n={},o={},r=0;r<e.length;++r){var i=e[r].split("="),a=decodeURI(i[0]),l=decodeURI(i[1]);"[]"!=a.substring(a.length-2,a.length)?n[a]=l:(a=a.substring(0,a.length-2),void 0==o[a]?o[a]=[l]:o[a].push(l))}return $.extend(n,o)}function _ajaxCallback(t,e,n){if(t===!0||"true"==t||"object"==typeof t){if(t&&"object"==typeof t&&"NOTLOGIN"==t.Msg)return void alert("你还没有登录, 请先登录!");"function"==typeof e&&e(t)}else"function"==typeof n?n(t):alert("error!")}function _ajax(t,e,n,o,r,i){return log("-------------------ajax:"),log(e),log(n),i="undefined"==typeof i?!0:!1,$.ajax({type:t,url:e,data:n,async:i,success:function(t){_ajaxCallback(t,o,r)},error:function(t){_ajaxCallback(t,o,r)}})}function ajaxGet(t,e,n,o,r){return _ajax("GET",t,e,n,o,r)}function ajaxPost(t,e,n,o,r){_ajax("POST",t,e,n,o,r)}function ajaxPostJson(t,e,n,o,r){log("-------------------ajaxPostJson:"),log(t),log(e),r="undefined"==typeof r?!0:!1,$.ajax({url:t,type:"POST",contentType:"application/json; charset=utf-8",datatype:"json",async:r,data:JSON.stringify(e),success:function(t,e){_ajaxCallback(t,n,o)},error:function(t){_ajaxCallback(t,n,o)}})}function findParents(t,e){if($(t).is(e))return $(t);for(var n=$(t).parents(),o=0;o<n.length;++o)if(log(n.eq(o)),n.eq(o).is(e))return n.seq(o);return null}function getVendorPrefix(){for(var t=document.body||document.documentElement,e=t.style,n=["webkit","khtml","moz","ms","o"],o=0;o<n.length;){if("string"==typeof e[n[o]+"Transition"])return n[o];o++}}function editorIframeTabindex(t){var e=$("#editorContent");e.attr("tabindex",t),setTimeout(function(){e.attr("tabindex",t)},500),setTimeout(function(){e.attr("tabindex",t)},1e3)}function switchEditor(t){LEA.isM=t,t?($("#mdEditor").css("z-index",3).show(),editorIframeTabindex(3),$("#wmd-input").attr("tabindex",2),$("#leanoteNav").hide()):($("#editor").show(),$("#mdEditor").css("z-index",1).hide(),editorIframeTabindex(2),$("#wmd-input").attr("tabindex",3),$("#leanoteNav").show())}function setEditorContent(t,e,n,o){if(t||(t=""),clearIntervalForSetContent&&clearInterval(clearIntervalForSetContent),e)MD?(MD.setContent(t),o&&o()):clearIntervalForSetContent=setTimeout(function(){setEditorContent(t,!0,!1,o)},100);else if("undefined"!=typeof tinymce&&tinymce.activeEditor){var r=tinymce.activeEditor;r.setContent(t),o&&o(),r.undoManager.clear()}else clearIntervalForSetContent=setTimeout(function(){setEditorContent(t,!1,!1,o)},100)}function previewIsEmpty(t){return t&&t.substr(0,previewToken.length)!=previewToken?!1:!0}function isAceError(t){return t?-1!=t.indexOf("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"):!1}function getEditorContent(t){var e=_getEditorContent(t);return'<p><br data-mce-bogus="1"></p>'===e?"<p><br></p>":e}function _getEditorContent(t){if(t)return[MD.getContent(),"<div>"+$("#preview-contents").html()+"</div>"];var e=tinymce.activeEditor;if(e){var n=$(e.getBody()).clone();if(n.find(".toggle-raw").remove(),window.LeaAce&&LeaAce.getAce)for(var o=n.find("pre"),r=0;r<o.length;++r){var i=o.eq(r),a=i.attr("id"),l=LeaAce.getAce(a);if(l){var s=l.getValue();isAceError(s)&&(s=i.html()),s=s.replace(/</g,"<").replace(/>/g,">"),i.removeAttr("style","").removeAttr("contenteditable").removeClass("ace_editor"),i.html(s)}}if(n.find("pinit").remove(),n.find(".thunderpin").remove(),n.find(".pin").parent().remove(),n=$(n).html())for(;;){var c=n.lastIndexOf("</script>");if(-1==c)return n;var u=n.length;if(u-9!=c)return n;var f=n.lastIndexOf("<script ");if(-1==f&&(f=n.lastIndexOf("<script>")),-1==f)return n;n=n.substring(0,f)}return n}}function disableEditor(){var t=tinymce.activeEditor;t&&(t.hide(),LEA.editorStatus=!1,$("#mceTollbarMark").show().css("z-index",1e3))}function enableEditor(){if(!LEA.editorStatus){$("#mceTollbarMark").css("z-index",-1).hide();var t=tinymce.activeEditor;t&&t.show()}}function showDialog(t,e){$("#leanoteDialog #modalTitle").html(e.title),$("#leanoteDialog .modal-body").html($("#"+t+" .modal-body").html()),$("#leanoteDialog .modal-footer").html($("#"+t+" .modal-footer").html()),delete e.title,e.show=!0,$("#leanoteDialog").modal(e)}function
Line 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='<li href="#" class="item ?" noteId="?">',Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>',Note.itemTpl='<li href="#" class="item ? item-image" 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-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>',Note.newItemTpl='<li 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-clock-o"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>',Note.noteItemListO=$("#noteItemList"),Note.cacheByNotebookId={all:{}},Note.notebookIds={},Note.isReadOnly=!1,Note.intervalTime=6e5,Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始..."),changedNote=Note.curChangedSaveIt(!1)},Note.intervalTime)},Note.stopInterval=function(){clearInterval(Note.interval),setTimeout(function(){Note.startInterval()},Note.intervalTime)},Note.addNoteCache=function(t){Note.cache[t.NoteId]=t,Note.clearCacheByNotebookId(t.NotebookId)},Note.setNoteCache=function(t,e){Note.cache[t.NoteId]?$.extend(Note.cache[t.NoteId],t):Note.cache[t.NoteId]=t,void 0==e&&(e=!0),e&&Note.clearCacheByNotebookId(t.NotebookId)},Note.getCurNote=function(){var t=this;return""==t.curNoteId?null:t.cache[t.curNoteId]},Note.getNote=function(t){var e=this;return e.cache[t]},Note.clearCacheByNotebookId=function(t){t&&(Note.cacheByNotebookId[t]={},Note.cacheByNotebookId.all={},Note.notebookIds[t]=!0)},Note.notebookHasNotes=function(t){var e=Note.getNotesByNotebookId(t);return!isEmpty(e)},Note.getNotesByNotebookId=function(t,e,o){if(e||(e="UpdatedTime"),"undefined"==o&&(o=!1),t||(t="all"),!Note.cacheByNotebookId[t])return[];if(Note.cacheByNotebookId[t][e])return Note.cacheByNotebookId[t][e];var a=[];for(var n in Note.cache)if(n){var i=Note.cache[n];i.IsTrash||i.IsShared||("all"==t||i.NotebookId==t)&&a.push(i)}return a.sort(function(t,a){var n=t[e],i=a[e];if(o){if(i>n)return-1;if(n>i)return 1}else{if(i>n)return 1;if(n>i)return-1}return 0}),Note.cacheByNotebookId[t][e]=a,a},Note.curNoteIsDirtied=function(){var t=this,e=t.getCurNote();e&&(e.isDirty=!0)},Note.renderNotesAndFirstOneContent=function(t){isArray(t)&&(Note.renderNotes(t),isEmpty(t[0])||Note.changeNoteForPjax(t[0].NoteId,!0,!1))},Note.curHasChanged=function(t){void 0==t&&(t=!0);var e,o,a,n=Note.cache[Note.curNoteId]||{},i=$("#noteTitle").val(),r=Tag.getTags(),s=getEditorContent(n.IsMarkdown);if(isArray(s))e=s[0],o=s[1],a=e,e&&previewIsEmpty(o)&&Converter&&(o=Converter.makeHtml(e)),e||(o=""),n.Preview=o;else{e=s;try{a=$(e).text()}catch(d){}}var c={hasChanged:!1,IsNew:n.IsNew,IsMarkdown:n.IsMarkdown,FromUserId:n.FromUserId,NoteId:n.NoteId,NotebookId:n.NotebookId,Version:n.Version||0};if(c.IsNew)$.extend(c,n);else if(!t&&!n.isDirty)return log("no dirty"),c.hasChanged=!1,c;if(n.Title!=i&&(c.hasChanged=!0,c.Title=i,!c.Title),arrayEqual(n.Tags,r)||(c.hasChanged=!0,c.Tags=r.join(",")),t&&n.Content!=e||!t&&(!n.IsMarkdown&&$(n.Content).text()!=a||n.IsMarkdown&&n.Content!=a)){c.hasChanged=!0,c.Content=e;var N=o||e;n.HasSelfDefined&&n.IsBlog||(c.Desc=Note.genDesc(N),c.ImgSrc=Note.getImgSrc(N),c.Abstract=Note.genAbstract(N))}else log("text相同"),log(n.Content==e);return c.UserId=n.UserId||"",c},Note.genDesc=function(t){return t?(t=t.replace(/<br \/>/g," <br />"),t=t.replace(/<\/p>/g," </p>"),t=t.replace(/<\/div>/g," </div>"),t=$("<div></div>").html(t).text(),t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),t.length<300?t:t.substring(0,300)):""},Note.genAbstract=function(t,e){if(!t)return"";if(void 0==e&&(e=1e3),t.length<e)return t;for(var o=!1,a=!1,n=0,i="",r=e,s=0;s<t.length;++s){var d=t[s];if("<"==d?o=!0:"&"==d?a=!0:">"==d&&o?(n-=1,o=!1):";"==d&&a&&(a=!1),o||a||(n+=1),i+=d,n>=r)break}var c=document.createElement("div");return c.innerHTML=i,c.innerHTML},Note.getImgSrc=function(t){if(!t)return"";var e=$(t).find("img");for(var o in e){var a=e.eq(o).attr("src");if(a)return a}return""},Note.saveInProcess={},Note.savePool={},Note.curChangedSaveIt=function(t,e){var o=this;if(Note.curNoteId&&!Note.isReadOnly){var a=Note.curHasChanged(t);return a.hasChanged||a.IsNew?(Note.renderChangedNote(a),delete a.hasChanged,showMsg(getMsg("saving")),o.saveILine truncated
|
||||
function editorMode(){this.writingHash="writing",this.normalHash="normal",this.isWritingMode=location.hash.indexOf(this.writingHash)>=0,this.toggleA=null}function initSlimScroll(){Mobile.isMobile()||($("#notebook").slimScroll({height:"100%"}),$("#noteItemList").slimScroll({height:"100%"}),$("#wmd-panel-preview").slimScroll({height:"100%"}),$("#wmd-panel-preview").css("width","100%"))}function initEditor(){$("#moreBtn").click(function(){saveBookmark();var e=$("#editor");e.hasClass("all-tool")?e.removeClass("all-tool"):e.addClass("all-tool"),restoreBookmark()}),tinymce.init({inline:!0,theme:"leanote",valid_children:"+pre[div|#text|p|span|textarea|i|b|strong]",setup:function(e){e.on("keydown",function(e){var t=e.which?e.which:e.keyCode;return!Note.readOnly||(e.ctrlKey||e.metaKey)&&67==t?void LeaAce.removeCurToggleRaw():void e.preventDefault()}),e.on("click",function(e){})},convert_urls:!0,relative_urls:!1,remove_script_host:!1,selector:"#editorContent",content_css:["/css/editor/editor.css"],skin:"custom",language:LEA.locale,plugins:["autolink link leaui_image lists hr","paste","searchreplace leanote_nav leanote_code tabfocus","table textcolor"],toolbar1:"formatselect | forecolor backcolor | bold italic underline strikethrough | leaui_image | leanote_code leanote_inline_code | bullist numlist | alignleft aligncenter alignright alignjustify",toolbar2:"outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript |searchreplace | pastetext | leanote_ace_pre | fontselect fontsizeselect",menubar:!1,toolbar_items_size:"small",statusbar:!1,url_converter:!1,font_formats:"Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Times New Roman=times new roman,times;Courier New=courier new,courier;Tahoma=tahoma,arial,helvetica,sans-serif;Verdana=verdana,geneva;宋体=SimSun;新宋体=NSimSun;黑体=SimHei;微软雅黑=Microsoft YaHei",block_formats:"Header 1=h1;Header 2=h2;Header 3=h3;Header 4=h4;Paragraph=p",paste_data_images:!0}),window.onbeforeunload=function(e){Note.curChangedSaveIt()},$("body").on("keydown",Note.saveNote)}function scrollTo(e,t,o){var i=$("#editorContent"),n=i.find(t+":contains("+o+")");random++;for(var r=$('#leanoteNavContent [data-a="'+t+"-"+encodeURI(o)+'"]'),s=r.size(),a=0;s>a&&r[a]!=e;++a);if(n.size()>=a+1){n=n.eq(a);var l=i.scrollTop()-i.offset().top+n.offset().top;return void i.animate({scrollTop:l},300)}}function openSetInfoDialog(e){showDialogRemote("/user/account",{tab:e})}function updateLeftIsMin(e){ajaxGet("/user/updateLeftIsMin",{leftIsMin:e})}function minLeft(e){$("#leftNotebook").width(30),$("#notebook").hide(),$("#noteAndEditor").css("left",30),$("#notebookSplitter").hide(),$("#logo").hide(),$("#leftSwitcher").hide(),$("#leftSwitcher2").show(),$("#leftNotebook .slimScrollDiv").hide(),e&&updateLeftIsMin(!0)}function maxLeft(e){$("#noteAndEditor").css("left",UserInfo.NotebookWidth),$("#leftNotebook").width(UserInfo.NotebookWidth),$("#notebook").show(),$("#notebookSplitter").show(),$("#leftSwitcher2").hide(),$("#logo").show(),$("#leftSwitcher").show(),$("#leftNotebook .slimScrollDiv").show(),e&&updateLeftIsMin(!1)}function getMaxDropdownHeight(e){var t=$(e).offset(),o=$(document).height()-t.top;o-=70,0>o&&(o=0);var i=$(e).find("ul").height();return o>i?i:o}function initPage(){if(Notebook.renderNotebooks(notebooks),Share.renderShareNotebooks(sharedUserInfos,shareNotebooks),curSharedNoteNotebookId?Share.firstRenderShareNote(curSharedUserId,curSharedNoteNotebookId,curNoteId):(Note.setNoteCache(noteContentJson),Note.renderNotes(notes),curNoteId&&(setTimeout(function(){Note.changeNoteForPjax(curNoteId,!0,curNotebookId)}),curNotebookId||Notebook.selectNotebook($(tt('#notebook [notebookId="?"]',Notebook.allNotebookId))))),latestNotes.length>0)for(var e=0;e<latestNotes.length;++e)Note.addNoteCache(latestNotes[e]);Tag.renderTagNav(tagsJson),initSlimScroll(),LeaAce.handleEvent()}editorMode.prototype.toggleAText=function(e){var t=this;setTimeout(function(){var o=$(".toggle-editor-mode a"),i=$(".toggle-editor-mode span");e?(o.attr("href","#"+t.normalHash),i.text(getMsg("normalMode"))):(o.attr("href","#"+t.writingHash),i.text(getMsg("writingMode")))},0)},editorMode.prototype.isWriting=function(e){return e||(e=location.hash),e.indexOf(this.writingHash)>=0},editorMode.prototype.init=function(){this.$themeLink=$("#themeLink"),this.changeMode(this.isWritingMode);var e=this;$(".toggle-editor-mode").click(function(t){t.preventDefault(),saveBookmark();var o=$(this).find("a"),i=e.isWriting(o.attr("href"));e.changeMode(i),i?setHash("m",e.writingHash):setHash("m",e.normalHash),restoreBookmark()})},editorMode.prototype.changeMode=function(e){this.toggleAText(e),e?this.writtingMode():this.normalMode()},editorMode.prototype.resizeEditor=function(){setTimeout(function(){resizeEditor()},10),setTimeout(function(){resizeEditor()},20),setTimeout(function(){resizeEditor()},500)},editorMode.prototype.normalMode=function(){$("#noteItemListWrap, #notesAndSort").show(),$("#noteListLine truncated
|
||||
function revertTagStatus(){$("#addTagTrigger").show(),$("#addTagInput").hide()}function hideTagList(a){$("#tagDropdown").removeClass("open"),a&&a.stopPropagation()}function showTagList(a){$("#tagDropdown").addClass("open"),a&&a.stopPropagation()}function reRenderTags(){var a=["label label-default","label label-info"],e=0;$("#tags").children().each(function(){var t=$(this).attr("class");("label label-default"==t||"label label-info"==t)&&($(this).removeClass(t).addClass(a[e%2]),e++)})}Tag.classes={"蓝色":"label label-blue","红色":"label label-red","绿色":"label label-green","黄色":"label label-yellow",blue:"label label-blue",red:"label label-red",green:"label label-green",yellow:"label label-yellow"},Tag.mapCn2En={"蓝色":"blue","红色":"red","绿色":"green","黄色":"yellow"},Tag.mapEn2Cn={blue:"蓝色",red:"红色",green:"绿色",yellow:"黄色"},Tag.t=$("#tags"),Tag.getTags=function(){var a=[];return Tag.t.children().each(function(){var e=$(this).data("tag");e=Tag.mapCn2En[e]||e,a.push(e)}),a},Tag.clearTags=function(){Tag.t.html("")},Tag.renderTags=function(a){if(Tag.t.html(""),!isEmpty(a))for(var e=0;e<a.length;++e){var t=a[e];Tag.appendTag(t)}},Tag.renderReadOnlyTags=function(a){function e(){return t?"label label-default":(t=!0,"label label-info")}$("#noteReadTags").html(""),(isEmpty(a)||1==a.length&&""==a[0])&&$("#noteReadTags").html(getMsg("noTag"));var t=!0;for(var t in a){var l=a[t];l=Tag.mapEn2Cn[l]||l;var n=Tag.classes[l];n||(n=e()),tag=tt('<span class="?">?</span>',n,trimTitle(l)),$("#noteReadTags").append(tag)}},Tag.appendTag=function(a,e){var t,l,n=!1;if("object"==typeof a){if(t=a.classes,l=a.text,!l)return}else{if(a=$.trim(a),l=a,!l)return;var t=Tag.classes[l];t?n=!0:t="label label-default"}var g=l;"zh"==LEA.locale&&(l=Tag.mapEn2Cn[l]||l,g=Tag.mapCn2En[g]||g),a=tt('<span class="?" data-tag="?">?<i title="'+getMsg("delete")+'">X</i></span>',t,l,l);var r=!1;$("#tags").children().each(function(){if(n){var e=$("<div></div>").append($(this).clone()).html();e==a&&($(this).remove(),r=!0)}else l+"X"==$(this).text()&&($(this).remove(),r=!0)}),$("#tags").append(a),hideTagList(),n||reRenderTags(),e&&(Note.curNoteIsDirtied(),r||Note.curChangedSaveIt(!0,function(){ajaxPost("/tag/updateTag",{tag:g},function(a){reIsOk(a)&&Tag.addTagNav(a.Item)})}))},Tag.removeTag=function(a){var e=a.data("tag");a.remove(),reRenderTags(),"zh"==LEA.locale&&(e=Tag.mapCn2En[e]||e),Note.curChangedSaveIt(!0,function(){ajaxPost("/tag/updateTag",{tag:e},function(a){reIsOk(a)&&Tag.addTagNav(a.Item)})})},Tag.tags=[],Tag.renderTagNav=function(a){a=a||[],Tag.tags=a,$("#tagNav").html("");for(var e in a){var t=a[e],l=t.Tag,n=l;if("zh"==LEA.locale)var n=Tag.mapEn2Cn[l]||n;n=trimTitle(n);var g=Tag.classes[l]||"label label-default";$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">?</span> <span class="tag-delete">X</span></li>',l,g,n))}},Tag.addTagNav=function(a){var e=this;for(var t in e.tags){var l=e.tags[t];if(l.Tag==a.Tag){e.tags.splice(t,1);break}}e.tags.unshift(a),e.renderTagNav(e.tags)},$(function(){function a(){$li=$(this).closest("li");var a=$.trim($li.data("tag"));confirm("Are you sure ?")&&ajaxPost("/tag/deleteTag",{tag:a},function(e){if(reIsOk(e)){var t=e.Item;Note.deleteNoteTag(t,a),$li.remove()}})}function e(){var a=$(this).closest("li"),e=$.trim(a.data("tag"));Note.curChangedSaveIt(),Note.clearAll(),$("#tagSearch").html(a.html()).show(),$("#tagSearch .tag-delete").remove(),showLoading(),ajaxGet("/note/searchNoteByTags",{tags:[e]},function(a){hideLoading(),a&&(Note.renderNotes(a),isEmpty(a)||Note.changeNote(a[0].NoteId))})}$("#addTagTrigger").click(function(){$(this).hide(),$("#addTagInput").show().focus().val("")}),$("#addTagInput").click(function(a){showTagList(a)}),$("#addTagInput").blur(function(){var a=$(this).val();a&&Tag.appendTag(a,!0)}),$("#addTagInput").keydown(function(a){13==a.keyCode&&(hideTagList(),$("#addTagInput").val()?($(this).trigger("blur"),$("#addTagTrigger").trigger("click")):$(this).trigger("blur"))}),$("#tagColor li").click(function(a){var e;e=$(this).attr("role")?$(this).find("span"):$(this),Tag.appendTag({classes:e.attr("class"),text:e.text()},!0)}),$("#tags").on("click","i",function(){Tag.removeTag($(this).parent())}),$("#myTag .folderBody").on("click","li .label",e),$("#myTag .folderBody").on("click","li .tag-delete",a)});
|
||||
Notebook.curNotebookId="",Notebook.cache={},Notebook.notebooks=[],Notebook.notebookNavForListNote="",Notebook.notebookNavForNewNote="",Notebook.setCache=function(o){var e=o.NotebookId;e&&(Notebook.cache[e]||(Notebook.cache[e]={}),$.extend(Notebook.cache[e],o))},Notebook.getCurNotebookId=function(){return Notebook.curNotebookId},Notebook.getCurNotebook=function(){return Notebook.cache[Notebook.curNotebookId]},Notebook._updateNotebookNumberNotes=function(o,e){var t=this,N=t.getNotebook(o);N&&(N.NumberNotes+=e,N.NumberNotes<0&&(N.NumberNotes=0),$("#numberNotes_"+o).html(N.NumberNotes))},Notebook.incrNotebookNumberNotes=function(o){var e=this;e._updateNotebookNumberNotes(o,1)},Notebook.minusNotebookNumberNotes=function(o){var e=this;e._updateNotebookNumberNotes(o,-1)},Notebook.getNotebook=function(o){return Notebook.cache[o]},Notebook.getNotebookTitle=function(o){var e=Notebook.cache[o];return e?e.Title:"未知"},Notebook.getTreeSetting=function(o,e){function t(o,t){var N=5,n=$("#"+o+" #"+t.tId+"_switch"),a=$("#"+o+" #"+t.tId+"_ico");if(n.remove(),a.before(n),e?Share.isDefaultNotebookId(t.NotebookId)||a.after($('<span class="fa notebook-setting" title="setting"></span>')):Notebook.isAllNotebookId(t.NotebookId)||Notebook.isTrashNotebookId(t.NotebookId)||(a.after($('<span class="notebook-number-notes" id="numberNotes_'+t.NotebookId+'">'+(t.NumberNotes||0)+"</span>")),a.after($('<span class="fa notebook-setting" title="setting"></span>'))),t.level>1){var r="<span style='display: inline-block;width:"+N*t.level+"px'></span>";n.before(r)}}function N(o,e){for(var t=0,N=e.length;N>t;t++)if(e[t].drag===!1)return!1;return!0}function n(o,e,t,N){return t?t.drop!==!1:!0}function a(o,e,t,N,n){function a(o){return o.level==d}var r=t[0];if(N){var i,k=b.tree,s={curNotebookId:r.NotebookId};if(i="inner"==n?N:N.getParentNode()){s.parentNotebookId=i.NotebookId;var d=i.level+1,l=k.getNodesByFilter(a,!1,i)}else var l=k.getNodes();s.siblings=[];for(var c in l){var h=l[c].NotebookId;Notebook.isAllNotebookId(h)||Notebook.isTrashNotebookId(h)||s.siblings.push(h)}ajaxPost("/notebook/dragNotebooks",{data:JSON.stringify(s)}),setTimeout(function(){Notebook.changeNav()},100)}}var r=!o,b=this;if(e)var i=function(o,e,t){var N=t.NotebookId,n=$(o.target).closest(".friend-notebooks").attr("fromUserId");Share.changeNotebook(n,N)},k=null;else var i=function(o,e,t){var N=t.NotebookId;Notebook.changeNotebook(N)},k=function(o){var e=$(o.target).attr("notebookId");Notebook.isAllNotebookId(e)||Notebook.isTrashNotebookId(e)||b.updateNotebookTitle(o.target)};var s={view:{showLine:!1,showIcon:!1,selectedMulti:!1,dblClickExpand:!1,addDiyDom:t},data:{key:{name:"Title",children:"Subs"}},edit:{enable:!0,showRemoveBtn:!1,showRenameBtn:!1,drag:{isMove:r,prev:r,inner:r,next:r}},callback:{beforeDrag:N,beforeDrop:n,onDrop:a,onClick:i,onDblClick:k,beforeRename:function(o,e,t,N){if(""==t)return e.IsNew?(b.tree.removeNode(e),!0):!1;if(e.Title==t)return!0;if(e.IsNew){var n=e.getParentNode(),a=n?n.NotebookId:"";b.doAddNotebook(e.NotebookId,t,a)}else b.doUpdateNotebookTitle(e.NotebookId,t);return!0}}};return s},Notebook.allNotebookId="0",Notebook.trashNotebookId="-1",Notebook.curNotebookIsTrashOrAll=function(){return Notebook.curNotebookId==Notebook.trashNotebookId||Notebook.curNotebookId==Notebook.allNotebookId},Notebook.renderNotebooks=function(o){var e=this;(!o||"object"!=typeof o||o.length<0)&&(o=[]);for(var t=0,N=o.length;N>t;++t){var n=o[t];n.Title=trimTitle(n.Title)}o=[{NotebookId:Notebook.allNotebookId,Title:getMsg("all"),drop:!1,drag:!1}].concat(o),o.push({NotebookId:Notebook.trashNotebookId,Title:getMsg("trash"),drop:!1,drag:!1}),Notebook.notebooks=o,e.tree=$.fn.zTree.init($("#notebookList"),e.getTreeSetting(),o);var a=$("#notebookList");a.hover(function(){$(this).hasClass("showIcon")||$(this).addClass("showIcon")},function(){$(this).removeClass("showIcon")}),isEmpty(o)||(Notebook.curNotebookId=o[0].NotebookId,e.cacheAllNotebooks(o)),Notebook.renderNav(),Notebook.changeNotebookNavForNewNote(o[0].NotebookId)},Notebook.cacheAllNotebooks=function(o){var e=this;for(var t in o){var N=o[t];Notebook.cache[N.NotebookId]=N,isEmpty(N.Subs)||e.cacheAllNotebooks(N.Subs)}},Notebook.expandNotebookTo=function(o,e){var t=this,N=!1,n=t.tree;if(e&&(n=Share.trees[e]),n){var a=n.getNodeByTId(o);if(a)for(;;){var r=a.getParentNode();if(!r){N||Notebook.changeNotebookNav(o);break}n.expandNode(r,!0),N||(Notebook.changeNotebookNav(o),N=!0),a=r}}},Notebook.renderNav=function(o){var e=this;e.changeNav()},Notebook.searchNotebookForAddNote=function(o){var e=this;if(o){var t=e.tree.getNodesByParamFuzzy("Title",o);t=t||[];var N=[];for(var n in t){var a=t[n].NotebookId;e.isAllNotebookId(a)||e.isTrashNotebookId(a)||N.push(t[n])}isEmpty(N)?$("#notebookNavForNewNote").html(""):$("#notebookNavForNewNote").html(e.getChangedNotebooks(N))}else $("#notebookNavForNewNote").html(e.everNavForNewNote)},Notebook.searchNotebookForList=function(o){var e=this,t=$("#notebookListForSearch"),N=$("#notebookList")Line truncated
|
||||
|
||||
+16
-3
@@ -1096,6 +1096,12 @@ Note.download = function(url, params) {
|
||||
$('<form target="mdImageManager" action="' + url + '" method="GET">' + inputs + '</form>').appendTo('body').submit().remove();
|
||||
};
|
||||
|
||||
// 导出成PDF
|
||||
Note.exportPDF = function(target) {
|
||||
var noteId = $(target).attr("noteId");
|
||||
$('<form target="mdImageManager" action="/note/exportPdf" method="GET"><input name="noteId" value="' + noteId + '"/></form>').appendTo('body').submit().remove();
|
||||
};
|
||||
|
||||
//--------------
|
||||
// read only
|
||||
|
||||
@@ -1357,6 +1363,7 @@ Note.deleteNoteTag = function(item, tag) {
|
||||
|
||||
// readonly
|
||||
Note.readOnly = false; // 默认为false要好?
|
||||
LEA.readOnly = false;
|
||||
// 切换只读模式
|
||||
Note.toggleReadOnly = function() {
|
||||
if(LEA.em && LEA.em.isWriting()) { // 写作模式下
|
||||
@@ -1390,6 +1397,9 @@ Note.toggleReadOnly = function() {
|
||||
$('#infoToolbar .updated-time').html(goNowToDatetime(note.UpdatedTime));
|
||||
}
|
||||
|
||||
Note.readOnly = true;
|
||||
LEA.readOnly = true;
|
||||
|
||||
if(note.readOnly) {
|
||||
return;
|
||||
}
|
||||
@@ -1402,11 +1412,10 @@ Note.toggleReadOnly = function() {
|
||||
}
|
||||
|
||||
note.readOnly = true;
|
||||
Note.readOnly = true;
|
||||
};
|
||||
// 切换到编辑模式
|
||||
Note.toggleWriteable = function() {
|
||||
var me = this;
|
||||
LEA.toggleWriteable = Note.toggleWriteable = function() {
|
||||
var me = Note;
|
||||
|
||||
// $('#infoToolbar').hide();
|
||||
$('#editor').removeClass('read-only');
|
||||
@@ -1438,6 +1447,7 @@ Note.toggleWriteable = function() {
|
||||
|
||||
note.readOnly = false;
|
||||
Note.readOnly = false;
|
||||
LEA.readOnly = false;
|
||||
};
|
||||
|
||||
Note.getPostUrl = function (note) {
|
||||
@@ -1500,6 +1510,9 @@ Note.initContextmenu = function() {
|
||||
{ text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Note.setNote2Blog },
|
||||
{ text: getMsg("cancelPublic"), alias: 'unset2Blog', faIcon: "fa-undo", action: Note.setNote2Blog },
|
||||
{ type: "splitLine" },
|
||||
// { text: "分享到社区", alias: 'html2Image', icon: "", action: Note.html2Image},
|
||||
{ text: getMsg("exportPdf"), alias: 'exportPDF', faIcon: "fa-file-pdf-o", action: Note.exportPDF},
|
||||
{ type: "splitLine" },
|
||||
{ text: getMsg("delete"), icon: "", faIcon: "fa-trash-o", action: Note.deleteNote },
|
||||
{ text: getMsg("move"), alias: "move", faIcon: "fa-arrow-right",
|
||||
type: "group",
|
||||
|
||||
+11
-20
@@ -388,7 +388,6 @@ function switchEditor(isMarkdown) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// editor 设置内容
|
||||
// 可能是tinymce还没有渲染成功
|
||||
var previewToken = "<div style='display: none'>FORTOKEN</div>"
|
||||
@@ -411,27 +410,12 @@ function setEditorContent(content, isMarkdown, preview, callback) {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
$("#editorContent").html(content);
|
||||
// $("#editorContent").html(content);
|
||||
// 不能先setHtml, 因为在tinymce的setContent前要获取之前的content, destory ACE
|
||||
if(typeof tinymce != "undefined" && tinymce.activeEditor) {
|
||||
var editor = tinymce.activeEditor;
|
||||
// console.log('set content');
|
||||
LEA.s4 = new Date();
|
||||
LEA.s4_1 = LEA.s4.getTime()-LEA.s1.getTime();
|
||||
editor.setContent(content);
|
||||
callback && callback();
|
||||
/*
|
||||
if(LeaAce.canAce() && LeaAce.isAce) {
|
||||
try {
|
||||
LeaAce.initAceFromContent(editor);
|
||||
} catch(e) {
|
||||
log(e);
|
||||
}
|
||||
} else {
|
||||
// 为了在firefox下有正常的显示
|
||||
$("#editorContent pre").removeClass("ace-tomorrow ace_editor");
|
||||
}
|
||||
*/
|
||||
editor.undoManager.clear(); // 4-7修复BUG
|
||||
} else {
|
||||
// 等下再设置
|
||||
@@ -464,8 +448,6 @@ function setEditorContent(content, isMarkdown, preview, callback) {
|
||||
if(MD) {
|
||||
MD.setContent(content);
|
||||
callback && callback();
|
||||
LEA.s4 = new Date();
|
||||
LEA.s4_1 = LEA.s4.getTime()-LEA.s1.getTime()
|
||||
} else {
|
||||
clearIntervalForSetContent = setTimeout(function() {
|
||||
setEditorContent(content, true, false, callback);
|
||||
@@ -491,7 +473,16 @@ function isAceError(val) {
|
||||
}
|
||||
|
||||
// 有tinymce得到的content有<html>包围
|
||||
// 总会出现<p> <br></p>, 原因, setContent('<p><br data-mce-bogus="1" /></p>') 会设置成 <p> <br></p>
|
||||
// 所以, 要在getContent时, 当是<p><br data-mce-bogus="1"></p>, 返回 <p><br/></p>
|
||||
function getEditorContent(isMarkdown) {
|
||||
var content = _getEditorContent(isMarkdown);
|
||||
if (content === '<p><br data-mce-bogus="1"></p>') {
|
||||
return '<p><br></p>';
|
||||
}
|
||||
return content;
|
||||
}
|
||||
function _getEditorContent(isMarkdown) {
|
||||
if(!isMarkdown) {
|
||||
var editor = tinymce.activeEditor;
|
||||
if(editor) {
|
||||
|
||||
Vendored
+1
-1
@@ -18,7 +18,7 @@ s=n.offsetHeight,l=r.clientWidth,c=r.clientHeight,"end"==e?(i-=l-a,o-=c-s):"cent
|
||||
if(!u(t)&&t.keyCode==e.BACKSPACE&&(n=Q.getRng(),r=n.startContainer,i=n.startOffset,o=J.getRoot(),a=r,n.collapsed&&0===i)){for(;a&&a.parentNode&&a.parentNode.firstChild==a&&a.parentNode!=o;)a=a.parentNode;"BLOCKQUOTE"===a.tagName&&(s.formatter.toggle("blockquote",null,a),n=J.createRng(),n.setStart(r,0),n.setEnd(r,0),Q.setRng(n))}})}function S(){function e(){s._refreshContentEditable(),l("StyleWithCSS",!1),l("enableInlineTableEditing",!1),Z.object_resizing||l("enableObjectResizing",!1)}Z.readonly||s.on("BeforeExecCommand MouseDown",e)}function T(){function e(){K(J.select("a"),function(e){var t=e.parentNode,n=J.getRoot();if(t.lastChild===e){for(;t&&!J.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}J.add(t,"br",{"data-mce-bogus":1})}})}s.on("SetContent ExecCommand",function(t){("setcontent"==t.type||"mceInsertLink"===t.command)&&e()})}function R(){Z.forced_root_block&&s.on("init",function(){l("DefaultParagraphSeparator",Z.forced_root_block)})}function A(){s.on("Undo Redo SetContent",function(e){e.initial||s.execCommand("mceRepaint")})}function B(){s.on("keydown",function(e){var t;u(e)||e.keyCode!=G||(t=s.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),s.undoManager.beforeChange(),J.remove(t.item(0)),s.undoManager.add()))})}function D(){var e;c()>=10&&(e="",K("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),s.contentStyles.push(e+"{padding-right: 1px !important}"))}function L(){c()<9&&(ee.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),te.addNodeFilter("noscript",function(e){for(var t=e.length,n,o,a;t--;)n=e[t],o=e[t].firstChild,o?o.value=i.decode(o.value):(a=n.attributes.map["data-mce-innertext"],a&&(n.attr("data-mce-innertext",null),o=new r("#text",3),o.value=a,o.raw=!0,n.append(o)))}))}function M(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),J.unbind(r,"mouseup",n),J.unbind(r,"mousemove",t),a=o=0}var r=J.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,J.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(J.bind(r,"mouseup",n),J.bind(r,"mousemove",t),J.getRoot().focus(),a.select())}})}function H(){s.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||Q.normalize()},!0)}function P(){s.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function O(){s.inline||s.on("keydown",function(){document.activeElement==document.body&&s.getWin().focus()})}function I(){s.inline||(s.contentStyles.push("body {min-height: 150px}"),s.on("click",function(e){if("HTML"==e.target.nodeName){var t;t=s.selection.getRng(),s.getBody().focus(),s.selection.setRng(t),s.selection.normalize(),s.nodeChanged()}}))}function F(){o.mac&&s.on("keydown",function(t){!e.metaKeyPressed(t)||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),s.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","word"))})}function z(){l("AutoUrlDetect",!1)}function W(){s.inline||s.on("focus blur beforegetcontent",function(){var e=s.dom.create("br");s.getBody().appendChild(e),e.parentNode.removeChild(e)},!0)}function V(){s.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),s.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function $(){s.on("touchstart",function(e){var t,n,r,i;t=e.target,n=(new Date).getTime(),i=e.changedTouches,!i||i.length>1||(r=i[0],s.once("touchend",function(e){var i=e.changedTouches[0],o;(new Date).getTime()-n>500||Math.abs(r.clientX-i.clientX)>5||Math.abs(r.clientY-i.clientY)>5||(o={target:t},K("pageX pageY clientX clientY screenX screenY".split(" "),function(e){o[e]=i[e]}),o=s.fire("click",o),o.isDefaultPrevented()||(s.selection.placeCaretAt(i.clientX,i.clientY),s.nodeChanged()))}))})}function U(){s.on("init",function(){s.dom.bind(s.getBody(),"submit",function(e){e.preventDefault()})})}function q(){ee.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}function j(){s.on("dragstart",function(e){d(e)}),s.on("drop",function(e){if(!u(e)){var n=f(e);if(n){e.preventDefault();var r=t.getCaretRangeFromPoint(e.x,e.y,s.getDoc());Q.setRng(r),p(n)}}})}var K=a.each,Y=s.$,G=e.BACKSPACE,X=e.DELETE,J=s.dom,Q=s.selection,Z=s.settings,ee=s.parser,te=s.serializer,ne=o.gecko,re=o.ie,ie=o.webkit,oe="data:text/mce-internal,",ae=re?"Text":"URL";k(),m(),H(),ie&&(h(),v(),C(),R(),U(),_(),q(),$(),o.iOS?(O(),I(),V()):g()),re&&o.ie<11&&(y(),w(),E(),N(),B(),D(),L(),MLine truncated
|
||||
var e,s;if(d.unbind(window,"ready",a),i("onpageload"),t.types)return void p(t.types,function(e){p(d.select(e.selector),function(i){r(n(i),h({},t,e),i)})});if(t.selector)return void p(d.select(t.selector),function(e){r(n(e),t,e)});switch(t.target&&r(n(t.target),t),t.mode){case"exact":e=t.elements||"",e.length>0&&p(f(e),function(e){var n;(n=d.get(e))?r(e,t,n):p(document.forms,function(n){p(n.elements,function(n){n.name===e&&(e="mce_editor_"+m++,d.setAttrib(n,"id",e),r(e,t,n))})})});break;case"textareas":case"specific_textareas":p(d.select("textarea"),function(e){t.editor_deselector&&o(e,t.editor_deselector)||(!t.editor_selector||o(e,t.editor_selector))&&r(n(e),t,e)})}t.oninit&&(e=s=0,p(l,function(t){s++,t.initialized?e++:t.on("init",function(){e++,e==s&&i("oninit")}),e==s&&i("oninit")}))}var s=this,l=[];s.settings=t,d.bind(window,"ready",a)},get:function(e){return arguments.length?e in this.editors?this.editors[e]:null:this.editors},add:function(e){var t=this,n=t.editors;return n[e.id]=e,n.push(e),t.activeEditor=e,t.fire("AddEditor",{editor:e}),g||(g=function(){t.fire("BeforeUnload")},d.bind(window,"beforeunload",g)),e},createEditor:function(t,n){return this.add(new e(t,n,this))},remove:function(e){var t=this,n,r=t.editors,i;{if(e)return"string"==typeof e?(e=e.selector||e,void p(d.select(e),function(e){i=r[e.id],i&&t.remove(i)})):(i=e,r[i.id]?(c(i)&&t.fire("RemoveEditor",{editor:i}),r.length||d.unbind(window,"beforeunload",g),i.remove(),i):null);for(n=r.length-1;n>=0;n--)t.remove(r[n])}},execCommand:function(t,n,r){var i=this,o=i.get(r);switch(t){case"mceAddEditor":return i.get(r)||new e(r,i.settings,i).render(),!0;case"mceRemoveEditor":return o&&o.remove(),!0;case"mceToggleEditor":return o?(o.isHidden()?o.show():o.hide(),!0):(i.execCommand("mceAddEditor",0,r),!0)}return i.activeEditor?i.activeEditor.execCommand(t,n,r):!1},triggerSave:function(){p(this.editors,function(e){e.save()})},addI18n:function(e,t){s.add(e,t)},translate:function(e){return s.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!=e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e}},h(v,a),v.setup(),window.tinymce=window.tinyMCE=v,v}),r(ge,[me,d],function(e,t){var n=t.each,r=t.explode;e.on("AddEditor",function(e){var t=e.editor;t.on("preInit",function(){function e(e,t){n(t,function(t,n){t&&s.setStyle(e,n,t)}),s.rename(e,"span")}function i(e){s=t.dom,l.convert_fonts_to_spans&&n(s.select("font,u,strike",e.node),function(e){o[e.nodeName.toLowerCase()](s,e)})}var o,a,s,l=t.settings;l.inline_styles&&(a=r(l.font_size_legacy_values),o={font:function(t,n){e(n,{backgroundColor:n.style.backgroundColor,color:n.color,fontFamily:n.face,fontSize:a[parseInt(n.size,10)-1]})},u:function(n,r){"html4"===t.settings.schema&&e(r,{textDecoration:"underline"})},strike:function(t,n){e(n,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",i))})})}),r(ve,[ce,d],function(e,t){var n={send:function(e){function t(){!e.async||4==r.readyState||i++>1e4?(e.success&&1e4>i&&200==r.status?e.success.call(e.success_scope,""+r.responseText,r,e):e.error&&e.error.call(e.error_scope,i>1e4?"TIMED_OUT":"GENERAL",r,e),r=null):setTimeout(t,10)}var r,i=0;if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=e.async===!1?!1:!0,e.data=e.data||"",r=new XMLHttpRequest){if(r.overrideMimeType&&r.overrideMimeType(e.content_type),r.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(r.withCredentials=!0),e.content_type&&r.setRequestHeader("Content-Type",e.content_type),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r=n.fire("beforeSend",{xhr:r,settings:e}).xhr,r.send(e.data),!e.async)return t();setTimeout(t,10)}}};return t.extend(n,e),n}),r(ye,[],function(){function e(t,n){var r,i,o,a;if(n=n||'"',null===t)return"null";if(o=typeof t,"string"==o)return i="\bb t\nn\ff\rr\"\"''\\\\",n+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=i.indexOf(t),r+1?"\\"+i.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e))})+n;if("object"==o){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(r=0,i="[";r<t.length;r++)i+=(r>0?",":"")+e(t[r],n);return i+"]"}i="{";for(a in t)t.hasOwnProperty(a)&&(i+="function"!=typeof t[a]?(i.length>1?","+n:n)+a+n+":"+e(t[a],n):"");return i+"}"}return""+t}return{serialize:e,parse:function(e){try{return window[String.fromCharCode(101)+"val"]("("+e+")")}catch(t){}}}}),r(be,[ye,ve,d],function(e,t,n){function r(e){this.settings=i({},e),this.count=0}var i=n.extend;return r.sendRPC=function(e){return(new r).send(e)},r.prototype={send:function(n){var r=n.error,o=n.success;n=i(this.settings,n),n.success=function(t,i){t=e.parse(t),"undefined"==typeof t&&(t={error:"JSON Parse error."}),t.error?r.call(n.error_scope||n.scope,t.error,i):o.call(n.success_scope||n.scope,t.result)},n.error=function(e,t){r&&r.call(n.error_scope||n.scope,e,tLine truncated
|
||||
|
||||
})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(je,[Ee],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;fLine truncated
|
||||
})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(je,[Ee],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;fLine truncated
|
||||
(function($){jQuery.fn.extend({slimScroll:function(options){var defaults={width:"auto",height:"250px",size:"7px",color:"#000",position:"right",distance:"1px",start:"top",opacity:.4,alwaysVisible:false,disableFadeOut:false,railVisible:false,railColor:"#333",railOpacity:.2,railDraggable:true,railClass:"slimScrollRail",barClass:"slimScrollBar",wrapperClass:"slimScrollDiv",allowPageScroll:false,wheelStep:20,touchScrollStep:200,borderRadius:"7px",railBorderRadius:"7px"};var o=$.extend(defaults,options);this.each(function(){var isOverPanel,isOverBar,isDragg,queueHide,touchDif,barHeight,percentScroll,lastScroll,divS="<div></div>",minBarHeight=30,releaseScroll=false;var me=$(this);if(me.parent().hasClass(o.wrapperClass)){var offset=me.scrollTop();bar=me.parent().find("."+o.barClass);rail=me.parent().find("."+o.railClass);getBarHeight();if($.isPlainObject(options)){if("height"in options&&options.height=="auto"){me.parent().css("height","auto");me.css("height","auto");var height=me.parent().parent().height();me.parent().css("height",height);me.css("height",height)}if("scrollTo"in options){offset=parseInt(o.scrollTo)}else if("scrollBy"in options){offset+=parseInt(o.scrollBy)}else if("destroy"in options){bar.remove();rail.remove();me.unwrap();return}scrollContent(offset,false,true,options.onlyScrollBar)}return}o.height=o.height=="auto"?me.parent().height():o.height;var wrapper=$(divS).addClass(o.wrapperClass).css({position:"relative",overflow:"hidden",width:o.width,height:o.height});me.css({overflow:"hidden",width:o.width,height:o.height});var rail=$(divS).addClass(o.railClass).css({width:o.size,height:"100%",position:"absolute",top:0,display:o.alwaysVisible&&o.railVisible?"block":"none","border-radius":o.railBorderRadius,background:o.railColor,opacity:o.railOpacity,zIndex:90});var bar=$(divS).addClass(o.barClass).css({background:o.color,width:o.size,position:"absolute",top:0,opacity:o.opacity,display:o.alwaysVisible?"block":"none","border-radius":o.borderRadius,BorderRadius:o.borderRadius,MozBorderRadius:o.borderRadius,WebkitBorderRadius:o.borderRadius,zIndex:99});var posCss=o.position=="right"?{right:o.distance}:{left:o.distance};rail.css(posCss);bar.css(posCss);me.wrap(wrapper);me.parent().append(bar);me.parent().append(rail);if(o.railDraggable){bar.bind("mousedown",function(e){var $doc=$(document);isDragg=true;t=parseFloat(bar.css("top"));pageY=e.pageY;$doc.bind("mousemove.slimscroll",function(e){currTop=t+e.pageY-pageY;bar.css("top",currTop);scrollContent(0,bar.position().top,false)});$doc.bind("mouseup.slimscroll",function(e){isDragg=false;hideBar();$doc.unbind(".slimscroll")});return false}).bind("selectstart.slimscroll",function(e){e.stopPropagation();e.preventDefault();return false})}rail.hover(function(){showBar()},function(){hideBar()});bar.hover(function(){isOverBar=true},function(){isOverBar=false});me.hover(function(){isOverPanel=true;showBar();hideBar()},function(){isOverPanel=false;hideBar()});me.bind("touchstart",function(e,b){if(e.originalEvent.touches.length){touchDif=e.originalEvent.touches[0].pageY}});me.bind("touchmove",function(e){if(!releaseScroll){e.originalEvent.preventDefault()}if(e.originalEvent.touches.length){var diff=(touchDif-e.originalEvent.touches[0].pageY)/o.touchScrollStep;scrollContent(diff,true);touchDif=e.originalEvent.touches[0].pageY}});getBarHeight();if(o.start==="bottom"){bar.css({top:me.outerHeight()-bar.outerHeight()});scrollContent(0,true)}else if(o.start!=="top"){scrollContent($(o.start).position().top,null,true);if(!o.alwaysVisible){bar.hide()}}attachWheel();function _onWheel(e){if(!isOverPanel){return}var e=e||window.event;var delta=0;if(e.wheelDelta){delta=-e.wheelDelta/120}if(e.detail){delta=e.detail/3}var target=e.target||e.srcTarget||e.srcElement;if($(target).closest("."+o.wrapperClass).is(me.parent())){scrollContent(delta,true)}if(e.preventDefault&&!releaseScroll){e.preventDefault()}if(!releaseScroll){e.returnValue=false}}function scrollContent(y,isWheel,isJump,onlyScrollBar){releaseScroll=false;var delta=y;var maxTop=me.outerHeight()-bar.outerHeight();if(isWheel){delta=parseInt(bar.css("top"))+y*parseInt(o.wheelStep)/100*bar.outerHeight();delta=Math.min(Math.max(delta,0),maxTop);delta=y>0?Math.ceil(delta):Math.floor(delta);bar.css({top:delta+"px"})}percentScroll=parseInt(bar.css("top"))/(me.outerHeight()-bar.outerHeight());delta=percentScroll*(me[0].scrollHeight-me.outerHeight());if(isJump){delta=y;var offsetTop=delta/me[0].scrollHeight*me.outerHeight();offsetTop=Math.min(Math.max(offsetTop,0),maxTop);bar.css({top:offsetTop+"px"})}if(!onlyScrollBar){me.scrollTop(delta)}me.trigger("slimscrolling",~~delta);showBar();hideBar()}function attachWheel(){if(window.addEventListener){this.addEventListener("DOMMouseScroll",_onWheel,false);this.addEventListener("mousewheel",_onWheel,false);this.addEventListener("MozMousePixelScroll",_onWheel,false)}else{document.attachEvent("onmousewheel",_onWheel)}}function getBarHeight(){barHeight=Math.max(me.outerHeight()/me[0].scrollHeighLine truncated
|
||||
LEA.cmroot=1;(function($){function returnfalse(){return false}$.fn.contextmenu=function(option){var cmroot="contextmenu"+LEA.cmroot;LEA.cmroot++;option=$.extend({alias:cmroot,width:150},option);var ruleName=null,target=null,groups={},mitems={},actions={},showGroups=[],itemTpl='<div class="b-m-$[type]" unselectable="on"><div class="clearfix cm-item"><div class="b-m-icon pull-left"><i class="fa $[faIcon]"></i>$[imgIcon]</div><div class="pull-left cm-text"><span class="c-text" unselectable="on">$[text]</span></div></div></div>';itemNoIconTpl="<div class='b-m-$[type]' unselectable=on><nobr unselectable=on><span align='absmiddle'></span><span class='c-text' unselectable=on>$[text]</span></nobr></div>";var gTemplet=$("<div/>").addClass("b-m-mpanel").attr("unselectable","on").css("display","none");var iTemplet=$("<div/>").addClass("b-m-item").attr("unselectable","on");var sTemplet=$("<div/>").addClass("b-m-split");var $body=$("body");var itemsCache={};var buildGroup=function(obj){groups[obj.alias]=this;this.gidx=obj.alias;this.id=obj.alias;if(obj.disable){this.disable=obj.disable;this.className="b-m-idisable"}$(this).width(obj.width).click(function(){}).mousedown(returnfalse).appendTo($body);obj=null;return this};var buildItem=function(obj){var T=this;T.title=obj.text;T.idx=obj.alias;T.gidx=obj.gidx;T.data=obj;var imgIcon="";if(obj.icon){imgIcon='<img src="'+obj.icon+'"/>'}obj.imgIcon=imgIcon;if(obj.icon){T.innerHTML=itemTpl.replace(/\$\[([^\]]+)\]/g,function(){return obj[arguments[1]]})}else{T.innerHTML=itemTpl.replace(/\$\[([^\]]+)\]/g,function(){return obj[arguments[1]]})}if(obj.disable){T.disable=obj.disable;T.className="b-m-idisable"}obj.items&&(T.group=true);obj.action&&(actions[obj.alias]=obj.action);mitems[obj.alias]=T;T=obj=null;return this};var addItems=function(gidx,items,parentAlias){var tmp=null;var len=items.length;for(var i=0;i<len;i++){var item=items[i];if(item.type=="splitLine"){tmp=sTemplet.clone()[0]}else{if(!item.alias){if(parentAlias){item.alias=parentAlias+"."+item.text}else{item.alias=item.text}}item.gidx=gidx;if(item.type=="group"&&!item.action){buildGroup.apply(gTemplet.clone()[0],[item]);itemsCache[item.alias]=item.items;item.type="arrow";tmp=buildItem.apply(iTemplet.clone()[0],[item])}else{if(item.type=="group"){buildGroup.apply(gTemplet.clone()[0],[item]);itemsCache[item.alias]=item.items;item.type="arrow";tmp=buildItem.apply(iTemplet.clone()[0],[item])}else{item.type="ibody";tmp=buildItem.apply(iTemplet.clone()[0],[item])}var thisItem=item;(function(thisItem,tmp){$(tmp).click(function(e){if(!this.disable){if($.isFunction(actions[this.idx])){actions[this.idx].call(this,target,thisItem)}hideMenuPane();$(target).removeClass("contextmenu-hover")}return false})})(thisItem,tmp)}$(tmp).bind("contextmenu",returnfalse).hover(overItem,outItem)}groups[gidx].appendChild(tmp);tmp=item=item.items=null}gidx=items=null};var overItem=function(e){if(this.disable)return false;hideMenuPane.call(groups[this.gidx]);if(this.group){var pos=$(this).offset();var width=$(this).outerWidth();showMenuGroup.apply(groups[this.idx],[pos,width,this])}this.className="b-m-ifocus";return false};var outItem=function(e){if(this.disable)return false;if(!this.group){this.className="b-m-item"}return false};var showMenuGroup=function(pos,width,t){var $this=$(this);if($this.html()==""){addItems(t.idx,itemsCache[t.idx],t.idx)}var bwidth=$body.width();var bheight=document.documentElement.clientHeight-10;bheight=bheight<0?100:bheight;var mwidth=$(this).outerWidth();var mheight=$(this).outerHeight()-10;mheight=mheight<0?100:mheight;var mwidth=$(this).outerWidth();pos.left=pos.left+width+mwidth>bwidth?pos.left-mwidth<0?0:pos.left-mwidth:pos.left+width;pos.top=pos.top+mheight>bheight?pos.top-mheight+(width>0?25:0)<0?0:pos.top-mheight+(width>0?25:0):pos.top;$(this).css(pos).show().css("max-height",bheight);showGroups.push(this.gidx)};var hideMenuPane=function(){var alias=null;for(var i=showGroups.length-1;i>=0;i--){if(showGroups[i]==this.gidx)break;alias=showGroups.pop();groups[alias].style.display="none";mitems[alias]&&(mitems[alias].className="b-m-item")}};function applyRule(rule){for(var i in mitems)disable(i,!rule.disable);for(var i=0;i<rule.items.length;i++)disable(rule.items[i],rule.disable);ruleName=rule.name}function disable(alias,disabled){var item=mitems[alias];if(!item||!item.lastChild){return}item.className=(item.disable=item.lastChild.disabled=disabled)?"b-m-idisable":"b-m-item"}function showMenu(e,menutarget){target=menutarget;showMenuGroup.call(groups[cmroot],{left:e.pageX,top:e.pageY},0);if(!$(target).hasClass("item-active")){$(target).addClass("contextmenu-hover")}$(document).one("click",function(){hideMenuPane();$(target).removeClass("contextmenu-hover")})}var $root=$("#"+option.alias);var root=null;if($root.length==0){root=buildGroup.apply(gTemplet.clone()[0],[option]);root.applyrule=applyRule;root.showMenu=showMenu;addItems(option.alias,option.items)}else{root=$root[0]}function onShowMenu(e){var bShowContext=optionLine truncated
|
||||
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=$(e.target);if(!$btn.hasClass("btn"))$btn=$btn.closest(".btn");$btn.button("toggle");e.preventDefault()})}(jQuery);+function($){"use strict";var Carousel=function(element,options){this.$element=$(element);this.$indicators=this.$element.find(".carousel-indicators");this.options=options;this.paused=this.sliding=this.interval=this.$active=this.$items=null;this.options.pause=="hover"&&this.$element.on("mouseenter",$.proxy(this.pause,this)).on("mouseleave",$.proxy(this.cycle,this))};Carousel.DEFAULTS={interval:5e3,pause:"hover",wrap:true};Carousel.prototype.cycle=function(e){e||(this.paused=false);this.interval&&clearInterval(this.interval);this.options.interval&&!this.paused&&(this.interval=setInterval($.proxy(this.next,this),this.options.interval));return this};Carousel.prototype.getActiveIndex=function(){this.$active=this.$element.find(".item.active");this.$items=this.$active.parent().children();return this.$items.index(this.$active)};Carousel.prototype.to=function(pos){var that=this;var activeIndex=this.getActiveIndex();if(pos>this.$items.length-1||pos<0)return;if(this.sliding)return this.$element.one("slid",function(){that.to(pos)});if(activeIndex==pos)return this.pause().cycle();return this.slide(pos>activeIndex?"next":"prev",$(this.$items[pos]))};Carousel.prototype.pause=function(e){e||(this.paused=true);if(this.$element.find(".next, .prev").length&&$.support.transition.end){this.$element.trigger($.support.transition.end);this.cycle(true)}this.interval=clearInterval(this.interval);return this};Carousel.prototype.next=function(){if(this.sliding)return;return this.slide("next")};Carousel.prototype.prev=function(){if(this.sliding)return;return this.slide("prev")};Carousel.prototype.slide=funcLine truncated
|
||||
|
||||
@@ -1 +1 @@
|
||||
var MSG={"app":"Leanote","share":"Share","noTag":"No Tags","inputEmail":"Email is required","history":"History","editorTips":"Tips","editorTipsInfo":"<h4>1. Short cuts</h4>ctrl+shift+c Toggle code<h4>2. shift+enter Get out of current block</h4> eg. <img src=\"/images/outofcode.png\" style=\"width: 90px\"/> in this situation you can use shift+enter to get out of current code block.","all":"Newest","trash":"Trash","delete":"Delete","unTitled":"UnTitled","writingMode":"Writing Mode","normalMode":"Normal Mode","saving":"Saving","saveSuccess":"Save success","update":"Update","close":"Close","cancel":"Cancel","send":"Send","shareToFriends":"Share to friends","publicAsBlog":"Public as blog","cancelPublic":"Cancel public","move":"Move","copy":"Copy","rename":"Rename","exportPdf":"Export PDF","addChildNotebook":"Add child notebook","deleteAllShared":"Delete shared user","deleteSharedNotebook":"Delete shared notebook","copyToMyNotebook":"Copy to my notebook","defaulthhare":"Default","friendEmail":"Friend email","readOnly":"Read only","writable":"Writable","inputFriendEmail":"Friend email is required","clickToChangePermission":"Click to change permission","sendInviteEmailToYourFriend":"Send invite email to your friend","friendNotExits":"Your friend hasn't %s's account, invite register link: %s","emailBodyRequired":"Email body is required","sendSuccess":"success","inviteEmailBody":"Hi,I am %s, %s is awesome, come on!","historiesNum":"We have saved at most <b>10</b> latest histories with each note","noHistories":"No histories","datetime":"Datetime","restoreFromThisVersion":"Restore from this version","confirmBackup":"Are you sure to restore from this version? We will backup the current note.","errorEmail":"Please input the right email"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
|
||||
var MSG={"app":"Leanote","share":"Share","noTag":"No Tags","inputEmail":"Email is required","history":"Histories","editorTips":"Tips","editorTipsInfo":"<h4>1. Short cuts</h4>ctrl+shift+c Toggle code<h4>2. shift+enter Get out of current block</h4> eg. <img src=\"/images/outofcode.png\" style=\"width: 90px\"/> in this situation you can use shift+enter to get out of current code block.","all":"Newest","trash":"Trash","delete":"Delete","unTitled":"UnTitled","writingMode":"Writing Mode","normalMode":"Normal Mode","saving":"Saving","saveSuccess":"Save success","update":"Update","close":"Close","cancel":"Cancel","send":"Send","shareToFriends":"Share to friends","publicAsBlog":"Public as blog","cancelPublic":"Cancel public","move":"Move","copy":"Copy","rename":"Rename","exportPdf":"Export PDF","addChildNotebook":"Add child notebook","deleteAllShared":"Delete shared user","deleteSharedNotebook":"Delete shared notebook","copyToMyNotebook":"Copy to my notebook","defaulthhare":"Default","friendEmail":"Friend email","readOnly":"Read only","writable":"Writable","inputFriendEmail":"Friend email is required","clickToChangePermission":"Click to change permission","sendInviteEmailToYourFriend":"Send invite email to your friend","friendNotExits":"Your friend hasn't %s's account, invite register link: %s","emailBodyRequired":"Email body is required","sendSuccess":"success","inviteEmailBody":"Hi,I am %s, %s is awesome, come on!","historiesNum":"We have saved at most <b>10</b> latest histories with each note","noHistories":"No histories","datetime":"Datetime","restoreFromThisVersion":"Restore from this version","confirmBackup":"Are you sure to restore from this version? We will backup the current note.","errorEmail":"Please input the right email"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
|
||||
@@ -1 +1 @@
|
||||
var MSG={"app":"Leanote","share":"分享","noTag":"无标签","inputEmail":"请输入Email","history":"历史记录","editorTips":"帮助","editorTipsInfo":"<h4>1. 快捷键</h4>ctrl+shift+c 代码块切换 <h4>2. shift+enter 跳出当前区域</h4>比如在代码块中<img src=\"/images/outofcode.png\" style=\"width: 90px\"/>按shift+enter可跳出当前代码块.","all":"最新","trash":"废纸篓","delete":"删除","unTitled":"无标题","writingMode":"写作模式","normalMode":"普通模式","saving":"正在保存","saveSuccess":"保存成功","Are you sure to delete it ?":"确认删除?","Insert link into content":"将附件链接插入到内容中","Download":"下载","Delete":"删除","update":"更新","close":"关闭","cancel":"取消","send":"发送","shareToFriends":"分享给好友","publicAsBlog":"公开为博客","cancelPublic":"取消公开为博客","move":"移动","copy":"复制","rename":"重命名","exportPdf":"导出PDF","addChildNotebook":"添加子笔记本","deleteAllShared":"删除所有共享","deleteSharedNotebook":"删除共享笔记本","copyToMyNotebook":"复制到我的笔记本","sendSuccess":"发送成功","defaulthhare":"默认共享","friendEmail":"好友邮箱","readOnly":"只读","writable":"可写","inputFriendEmail":"请输入好友邮箱","clickToChangePermission":"点击改变权限","sendInviteEmailToYourFriend":"发送邀请email给Ta","friendNotExits":"该用户还没有注册%s, 复制邀请链接发送给Ta, 邀请链接: %s","emailBodyRequired":"邮件内容不能为空","inviteEmailBody":"Hi, 你好, 我是%s, %s非常好用, 快来注册吧!","historiesNum":"leanote会保存笔记的最近<b>10</b>份历史记录","noHistories":"无历史记录","datetime":"日期","restoreFromThisVersion":"从该版本还原","confirmBackup":"确定要从该版还原? 还原前leanote会备份当前版本到历史记录中.","errorEmail":"请输入正确的email"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
|
||||
var MSG={"app":"Leanote","share":"分享","noTag":"无标签","inputEmail":"请输入Email","history":"历史记录","editorTips":"帮助","editorTipsInfo":"<h4>1. 快捷键</h4>ctrl+shift+c 代码块切换 <h4>2. shift+enter 跳出当前区域</h4>比如在代码块中<img src=\"/images/outofcode.png\" style=\"width: 90px\"/>按shift+enter可跳出当前代码块.","all":"最新","trash":"废纸篓","delete":"删除","unTitled":"无标题","writingMode":"写作模式","normalMode":"普通模式","saving":"正在保存","saveSuccess":"保存成功","Are you sure to delete it ?":"确认删除?","Insert link into content":"将附件链接插入到内容中","Download":"下载","Delete":"删除","update":"更新","Update Time":"更新时间","Create Time":"创建时间","Post Url":"博文链接","close":"关闭","cancel":"取消","send":"发送","shareToFriends":"分享给好友","publicAsBlog":"公开为博客","cancelPublic":"取消公开为博客","move":"移动","copy":"复制","rename":"重命名","exportPdf":"导出PDF","addChildNotebook":"添加子笔记本","deleteAllShared":"删除所有共享","deleteSharedNotebook":"删除共享笔记本","copyToMyNotebook":"复制到我的笔记本","sendSuccess":"发送成功","defaulthhare":"默认共享","friendEmail":"好友邮箱","readOnly":"只读","writable":"可写","inputFriendEmail":"请输入好友邮箱","clickToChangePermission":"点击改变权限","sendInviteEmailToYourFriend":"发送邀请email给Ta","friendNotExits":"该用户还没有注册%s, 复制邀请链接发送给Ta, 邀请链接: %s","emailBodyRequired":"邮件内容不能为空","inviteEmailBody":"Hi, 你好, 我是%s, %s非常好用, 快来注册吧!","historiesNum":"leanote会保存笔记的最近<b>10</b>份历史记录","noHistories":"无历史记录","datetime":"日期","restoreFromThisVersion":"从该版本还原","confirmBackup":"确定要从该版还原? 还原前leanote会备份当前版本到历史记录中.","errorEmail":"请输入正确的email","Hyperlink":"超链接","Please provide the link URL and an optional title":"请填写链接和一个可选的标题","optional title":"可选标题","Cancel":"取消","Strong":"粗体","strong text":"粗体","Emphasis":"斜体","emphasized text":"斜体","Blockquote":"引用","Code Sample":"代码","enter code here":"代码","Image":"图片","Heading":"标题","Numbered List":"有序列表","Bulleted List":"无序列表","List item":"项目","Horizontal Rule":"水平线","Undo":"撤销","Redo":"重做","enter image description here":"图片标题","enter link description here":"链接标题","Add Album":"添加相册","Cannot delete default album":"不能删除默认相册","Cannot rename default album":"不能重命名默认相册","Rename Album":"重命名","Add Success!":"添加成功!","Rename Success!":"重命名成功!","Delete Success!":"删除成功","Are you sure to delete this image ?":"确定删除该图片?","click to remove this image":"删除图片","error":"错误","Error":"错误","Prev":"上一页","Next":"下一页"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
|
||||
Vendored
+2
-2
@@ -13,5 +13,5 @@ n[t].apply(n,e)})}}(L))}}(),T.was?k.win.Raphael=n:Raphael=n,n}),function(){funct
|
||||
r=0,i=this.symbols.length;i>r;r++){t=this.symbols[r];var s=t.getX()+t.width,l=t.getY()+t.height;s>a&&(a=s),l>o&&(o=l)}this.paper.setSize(a+this.options["line-width"],o+this.options["line-width"])},a.prototype.clean=function(){if(this.paper){var t=this.paper.canvas;t.parentNode.removeChild(t)}},o.prototype.getAttr=function(t){if(!this.chart)return void 0;var e,n=this.chart.options?this.chart.options[t]:void 0,r=this.chart.options.symbols?this.chart.options.symbols[this.symbolType][t]:void 0;return this.chart.options.flowstate&&this.chart.options.flowstate[this.flowstate]&&(e=this.chart.options.flowstate[this.flowstate][t]),e||r||n},o.prototype.initialize=function(){this.group.transform("t"+this.getAttr("line-width")+","+this.getAttr("line-width")),this.width=this.group.getBBox().width,this.height=this.group.getBBox().height},o.prototype.getCenter=function(){return{x:this.getX()+this.width/2,y:this.getY()+this.height/2}},o.prototype.getX=function(){return this.group.getBBox().x},o.prototype.getY=function(){return this.group.getBBox().y},o.prototype.shiftX=function(t){this.group.transform("t"+(this.getX()+t)+","+this.getY())},o.prototype.setX=function(t){this.group.transform("t"+t+","+this.getY())},o.prototype.shiftY=function(t){this.group.transform("t"+this.getX()+","+(this.getY()+t))},o.prototype.setY=function(t){this.group.transform("t"+this.getX()+","+t)},o.prototype.getTop=function(){var t=this.getY(),e=this.getX()+this.width/2;return{x:e,y:t}},o.prototype.getBottom=function(){var t=this.getY()+this.height,e=this.getX()+this.width/2;return{x:e,y:t}},o.prototype.getLeft=function(){var t=this.getY()+this.group.getBBox().height/2,e=this.getX();return{x:e,y:t}},o.prototype.getRight=function(){var t=this.getY()+this.group.getBBox().height/2,e=this.getX()+this.group.getBBox().width;return{x:e,y:t}},o.prototype.render=function(){if(this.next){var t=this.getAttr("line-length");if("right"===this.next_direction){var e=this.getRight();if(this.next.getLeft(),!this.next.isPositioned){this.next.setY(e.y-this.next.height/2),this.next.shiftX(this.group.getBBox().x+this.width+t);var n=this;!function i(){for(var e,r=!1,a=0,o=n.chart.symbols.length;o>a;a++){e=n.chart.symbols[a];var s=Math.abs(e.getCenter().x-n.next.getCenter().x);if(e.getCenter().y>n.next.getCenter().y&&s<=n.next.width/2){r=!0;break}}r&&(n.next.setX(e.getX()+e.width+t),i())}(),this.next.isPositioned=!0,this.next.render()}}else{var r=this.getBottom();this.next.getTop(),this.next.isPositioned||(this.next.shiftY(this.getY()+this.height+t),this.next.setX(r.x-this.next.width/2),this.next.isPositioned=!0,this.next.render())}}},o.prototype.renderLines=function(){this.next&&(this.next_direction?this.drawLineTo(this.next,"",this.next_direction):this.drawLineTo(this.next))},o.prototype.drawLineTo=function(t,e,n){this.connectedTo.indexOf(t)<0&&this.connectedTo.push(t);var a,o=this.getCenter().x,s=this.getCenter().y,l=(this.getTop(),this.getRight()),c=this.getBottom(),u=this.getLeft(),h=t.getCenter().x,f=t.getCenter().y,d=t.getTop(),p=t.getRight(),g=(t.getBottom(),t.getLeft()),m=o===h,v=s===f,y=f>s,x=s>f,b=o>h,w=h>o,_=0,S=this.getAttr("line-length"),C=this.getAttr("line-width");if(n&&"bottom"!==n||!m||!y)if(n&&"right"!==n||!v||!w)if(n&&"left"!==n||!v||!b)if(n&&"right"!==n||!m||!x)if(n&&"right"!==n||!m||!y)if(n&&"bottom"!==n||!b)if(n&&"bottom"!==n||!w)if(n&&"right"===n&&b)a=r(this.chart,l,[{x:l.x+S/2,y:l.y},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else if(n&&"right"===n&&w)a=r(this.chart,l,[{x:d.x,y:l.y},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else if(n&&"bottom"===n&&m&&x)a=r(this.chart,c,[{x:c.x,y:c.y+S/2},{x:l.x+S/2,y:c.y+S/2},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.bottomStart=!0,t.topEnd=!0,_=c.x+S/2;else if("left"===n&&m&&x){var E=u.x-S/2;g.x<u.x&&(E=g.x-S/2),a=r(this.chart,u,[{x:E,y:u.y},{x:E,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.leftStart=!0,t.topEnd=!0,_=u.x}else"left"===n&&(a=r(this.chart,u,[{x:d.x+(u.x-d.x)/2,y:u.y},{x:d.x+(u.x-d.x)/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.leftStart=!0,t.topEnd=!0,_=u.x);else a=r(this.chart,c,[{x:c.x,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.bottomStart=!0,t.topEnd=!0,_=c.x+(c.x-d.x)/2;else a=this.leftEnd&&x?r(this.chart,c,[{x:c.x,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:c.y+S/2},{x:c.x+(c.x-d.x)/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e):r(this.chart,c,[{x:c.x,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.bottomStart=!0,t.topEnd=!0,_=c.x+(c.x-d.x)/2;else a=r(this.chart,l,[{x:l.x+S/2,y:l.y},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else a=r(this.chart,l,[{x:l.x+S/2,y:l.y},{x:l.x+S/2,y:d.y-S/2},{x:d.x,y:d.y-S/2},{x:d.x,y:d.y}],e),this.rightStart=!0,t.topEnd=!0,_=l.x+S/2;else a=r(this.chart,u,p,e),this.leftStart=!0,t.rightEnd=!0,_=p.x;else a=r(this.chart,l,g,e),this.rightStaLine truncated
|
||||
}catch(n){console.error("No event listener called "+t)}},l("onInit")(),u.onLoadSettings=function(){i.log("onLoadSettings"),t.each(h,function(t){var e=!t.isOptional||void 0===t.config.enabled||t.config.enabled===!0;r.setInputChecked("#input-enable-extension-"+t.extensionId,e),"markdownExtra"==t.extensionId?r.setInputChecked("#input-settings-markdown-extra",e):"mathJax"==t.extensionId&&r.setInputChecked("#input-settings-mathjax",e);var n=t.onLoadSettings;n&&n()})},u.onSaveSettings=function(e,n){i.log("onSaveSettings"),t.each(h,function(i){var a=t.extend({},i.defaultConfig);a.enabled=r.getInputChecked("#input-enable-extension-"+i.extensionId);var o;"markdownExtra"==i.extensionId?(o=r.getInputChecked("#input-settings-markdown-extra"),o!=i.enabled&&(a.enabled=o)):"mathJax"==i.extensionId&&(o=r.getInputChecked("#input-settings-mathjax"),o!=i.enabled&&(a.enabled=o));var s=i.onSaveSettings;s&&s(a,n),e[i.extensionId]=a})},c("onMessage"),c("onError"),c("onOfflineChanged"),c("onUserActive"),c("onAsyncRunning"),c("onPeriodicRun"),c("onEditorCreated"),c("onFileMgrCreated"),c("onSynchronizerCreated"),c("onPublisherCreated"),c("onSharingCreated"),c("onEventMgrCreated"),c("onFileCreated"),c("onFileDeleted"),c("onFileSelected"),c("onFileOpen"),c("onFileClosed"),c("onContentChanged"),c("onTitleChanged"),c("onFoldersChanged"),c("onSyncRunning"),c("onSyncSuccess"),c("onSyncImportSuccess"),c("onSyncExportSuccess"),c("onSyncRemoved"),c("onPublishRunning"),c("onPublishSuccess"),c("onNewPublishSuccess"),c("onPublishRemoved"),c("onLayoutCreated"),c("onLayoutResize"),c("onExtensionButtonResize"),c("onPagedownConfigure"),c("onSectionsCreated"),c("onCursorCoordinates"),c("onEditorPopover"),c("onDiscussionCreated"),c("onDiscussionRemoved"),c("onCommentsChanged"),c("onTweet");var p,g,m=l("onPreviewFinished"),v=s("onAsyncPreview");u.onAsyncPreview=function(){function e(n){var i=n.length?n.shift():function(){setTimeout(function(){var e="";t.each(p.children,function(t){e+=t.innerHTML});var n=r.trim(e),i=n.replace(/ <span class="comment label label-danger">.*?<\/span> /g,"");m(n,i)},10)};i(function(){e(n)})}i.log("onAsyncPreview"),e(v.concat([function(t){g.waitForImages(t)}]))};var y=l("onReady");return u.onReady=function(){p=document.getElementById("preview-contents"),g=$(p);var r=function(n){var r=e("div",{"class":"btn-group"}),i=n();return t.isString(i)?r.innerHTML=i:t.isElement(i)&&r.appendChild(i),r};window.viewerMode===!1,i.log("onCreatePreviewButton");var a=s("onCreatePreviewButton"),o=document.createDocumentFragment();t.each(a,function(t){o.appendChild(r(t))});var l=document.querySelector(".extension-preview-buttons");l&&l.appendChild(o),n.bind("escape",function(){u.onEditorPopover()}),y()},u.onEventMgrCreated(u),u}),function(){var t=/\blang(?:uage)?-(?!\*)(\w+)\b/i,e=self.Prism={util:{type:function(t){return Object.prototype.toString.call(t).match(/\[object (\w+)\]/)[1]},clone:function(t){var n=e.util.type(t);switch(n){case"Object":var r={};for(var i in t)t.hasOwnProperty(i)&&(r[i]=e.util.clone(t[i]));return r;case"Array":return t.slice()}return t}},languages:{extend:function(t,n){var r=e.util.clone(e.languages[t]);for(var i in n)r[i]=n[i];return r},insertBefore:function(t,n,r,i){i=i||e.languages;var a=i[t],o={};for(var s in a)if(a.hasOwnProperty(s)){if(s==n)for(var l in r)r.hasOwnProperty(l)&&(o[l]=r[l]);o[s]=a[s]}return i[t]=o},DFS:function(t,n){for(var r in t)n.call(t,r,t[r]),"Object"===e.util.type(t)&&e.languages.DFS(t[r],n)}},highlightAll:function(t,n){for(var r,i=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),a=0;r=i[a++];)e.highlightElement(r,t===!0,n)},highlightElement:function(r,i,a){for(var o,s,l=r;l&&!t.test(l.className);)l=l.parentNode;if(l&&(o=(l.className.match(t)||[,""])[1],s=e.languages[o]),s){r.className=r.className.replace(t,"").replace(/\s+/g," ")+" language-"+o,l=r.parentNode,/pre/i.test(l.nodeName)&&(l.className=l.className.replace(t,"").replace(/\s+/g," ")+" language-"+o);var c=r.textContent;if(c){c=c.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ");var u={element:r,language:o,grammar:s,code:c};if(e.hooks.run("before-highlight",u),i&&self.Worker){var h=new Worker(e.filename);h.onmessage=function(t){u.highlightedCode=n.stringify(JSON.parse(t.data),o),e.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,a&&a.call(u.element),e.hooks.run("after-highlight",u)},h.postMessage(JSON.stringify({language:u.language,code:u.code}))}else u.highlightedCode=e.highlight(u.code,u.grammar,u.language),e.hooks.run("before-insert",u),u.element.innerHTML=u.highlightedCode,a&&a.call(r),e.hooks.run("after-highlight",u)}}},highlight:function(t,r,i){return n.stringify(e.tokenize(t,r),i)},tokenize:function(t,n){var r=e.Token,i=[t],a=n.rest;if(a){for(var o in a)n[o]=a[o];delete n.rest}t:for(var o in n)if(n.hasOwnProperty(o)&&n[o]){var s=n[o],l=s.inside,c=!!s.lookbehind,u=0;s=s.pattern||s;for(var h=0;h<i.length;h++){var f=i[h];iLine truncated
|
||||
}],9:[function(t,e,n){var r=t("../contexts/diff").DiffContext,i=t("../contexts/patch").PatchContext,a=t("../contexts/reverse").ReverseContext,o=t("./lcs"),s=3,l="function"==typeof Array.isArray?Array.isArray:function(t){return t instanceof Array},c="function"==typeof Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var n=t.length,r=0;n>r;r++)if(t[r]===e)return r;return-1},u=function(t){if(t.leftIsArray){for(var e,n,i,a,l=t.options&&t.options.objectHash,u=function(t,e,n,r,i){var a=t[n],o=e[r];if(a===o)return!0;if("object"!=typeof a||"object"!=typeof o)return!1;if(!l)return!1;var s,c;return"number"==typeof n?(i.hashCache1=i.hashCache1||[],s=i.hashCache1[n],"undefined"==typeof s&&(i.hashCache1[n]=s=l(a,n))):s=l(a),"undefined"==typeof s?!1:("number"==typeof r?(i.hashCache2=i.hashCache2||[],c=i.hashCache2[r],"undefined"==typeof c&&(i.hashCache2[r]=c=l(o,r))):c=l(o),"undefined"==typeof c?!1:s===c)},h={},f=0,d=0,p=t.left,g=t.right,m=p.length,v=g.length;m>f&&v>f&&u(p,g,f,f,h);)e=f,a=new r(t.left[e],t.right[e]),t.push(a,e),f++;for(;m>d+f&&v>d+f&&u(p,g,m-1-d,v-1-d,h);)n=m-1-d,i=v-1-d,a=new r(t.left[n],t.right[i]),t.push(a,i),d++;var y;if(f+d===m){if(m===v)return void t.setResult(void 0).exit();for(y=y||{_t:"a"},e=f;v-d>e;e++)y[e]=[g[e]];return void t.setResult(y).exit()}if(f+d===v){for(y=y||{_t:"a"},e=f;m-d>e;e++)y["_"+e]=[p[e],0,0];return void t.setResult(y).exit()}h={};var x=p.slice(f,m-d),b=g.slice(f,v-d),w=o.get(x,b,u,h),_=[];for(y=y||{_t:"a"},e=f;m-d>e;e++)c(w.indices1,e-f)<0&&(y["_"+e]=[p[e],0,0],_.push(e));var S=!0;t.options&&t.options.arrays&&t.options.arrays.detectMove===!1&&(S=!1);var C=!1;t.options&&t.options.arrays&&t.options.arrays.includeValueOnMove&&(C=!0);var E=_.length;for(e=f;v-d>e;e++){var k=c(w.indices2,e-f);if(0>k){var T=!1;if(S&&E>0)for(n=0;E>n;n++)if(u(x,b,_[n]-f,e-f,h)){y["_"+_[n]].splice(1,2,e,s),C||(y["_"+_[n]][0]=""),n=_[n],i=e,a=new r(t.left[n],t.right[i]),t.push(a,i),_.splice(n,1),T=!0;break}T||(y[e]=[g[e]])}else n=w.indices1[k]+f,i=w.indices2[k]+f,a=new r(t.left[n],t.right[i]),t.push(a,i)}t.setResult(y).exit()}};u.filterName="arrays";var h={numerically:function(t,e){return t-e},numericallyBy:function(t){return function(e,n){return e[t]-n[t]}}},f=function(t){if(t.nested&&"a"===t.delta._t){var e,n,r=t.delta,a=t.left,o=[],l=[],c=[];for(e in r)if("_t"!==e)if("_"===e[0]){if(0!==r[e][2]&&r[e][2]!==s)throw new Error("only removal or move can be applied at original array indices, invalid diff type: "+r[e][2]);o.push(parseInt(e.slice(1),10))}else 1===r[e].length?l.push({index:parseInt(e,10),value:r[e][0]}):c.push({index:parseInt(e,10),delta:r[e]});for(o=o.sort(h.numerically),e=o.length-1;e>=0;e--){n=o[e];var u=r["_"+n],f=a.splice(n,1)[0];u[2]===s&&l.push({index:u[1],value:f})}l=l.sort(h.numericallyBy("index"));var d=l.length;for(e=0;d>e;e++){var p=l[e];a.splice(p.index,0,p.value)}var g,m=c.length;if(m>0)for(e=0;m>e;e++){var v=c[e];g=new i(t.left[v.index],v.delta),t.push(g,v.index)}return t.children?void t.exit():void t.setResult(t.left).exit()}};f.filterName="arrays";var d=function(t){if(t&&t.children&&"a"===t.delta._t){for(var e,n=t.children.length,r=0;n>r;r++)e=t.children[r],t.left[e.childName]=e.result;t.setResult(t.left).exit()}};d.filterName="arraysCollectChildren";var p=function(t){if(!t.nested)return void(t.delta[2]===s&&(t.newName="_"+t.delta[1],t.setResult([t.delta[0],parseInt(t.childName.substr(1),10),s]).exit()));if("a"===t.delta._t){var e,n;for(e in t.delta)"_t"!==e&&(n=new a(t.delta[e]),t.push(n,e));t.exit()}};p.filterName="arrays";var g=function(t,e,n){var r=e;if("string"==typeof e&&"_"===e[0])r=parseInt(e.substr(1),10);else{var i="_"+e;if(l(n)&&0===n[2])r=i;else for(var a in t){var o=t[a];l(o)&&o[2]===s&&o[1].toString()===e&&(r=a.substr(1))}}return r},m=function(t){if(t&&t.children&&"a"===t.delta._t){for(var e,n=t.children.length,r={_t:"a"},i=0;n>i;i++){e=t.children[i];var a=e.newName;"undefined"==typeof a&&(a=g(t.delta,e.childName,e.result)),r[a]!==e.result&&(r[a]=e.result)}t.setResult(r).exit()}};m.filterName="arraysCollectChildren",n.diffFilter=u,n.patchFilter=f,n.collectChildrenPatchFilter=d,n.reverseFilter=p,n.collectChildrenReverseFilter=m},{"../contexts/diff":3,"../contexts/patch":4,"../contexts/reverse":5,"./lcs":11}],10:[function(t,e,n){var r=function(t){t.left instanceof Date?(t.setResult(t.right instanceof Date?t.left.getTime()!==t.right.getTime()?[t.left,t.right]:void 0:[t.left,t.right]),t.exit()):t.right instanceof Date&&t.setResult([t.left,t.right]).exit()};r.filterName="dates",n.diffFilter=r},{}],11:[function(t,e,n){var r=function(t,e,n,r){return t[n]===e[r]},i=function(t,e,n,r){var i,a,o=t.length,s=e.length,l=[o+1];for(i=0;o+1>i;i++)for(l[i]=[s+1],a=0;s+1>a;a++)l[i][a]=0;for(l.match=n,i=1;o+1>i;i++)for(a=1;s+1>a;a++)l[i][a]=n(t,e,i-1,a-1,r)?l[i-1][a-1]+1:Math.max(l[i-1][a],l[i][a-1]);return l},a=function(t,e,n,r,i,o){if(0===r||0===i)return{sequence:[],indices1:[],indices2:[]};if(t.match(e,n,r-1,i-1,o)){var s=a(t,e,n,r-1,i-1,o);return s.sLine truncated
|
||||
var i=_(X,e,n);X=e,i===!0&&(H.discussionList=H.discussionList),H.content=X,W.saveSelectionState(),r.onContentChanged(H,X),i&&r.onCommentsChanged(H),Y.saveState(),J()}else X=e,H.content=X,W.setSelectionStartEnd(H.editorStart,H.editorEnd),W.updateSelectionRange(),W.updateCursorCoordinates(),Y.saveSelectionState(),r.onFileOpen(H,X),L.scrollTop=H.previewScrollTop,P=H.editorScrollTop,T.scrollTop=P,U=!1}function _(t,e,n){if(n.length){var r=G.diff_main(t,e),i=!1,a=0;return r.forEach(function(t){var e=t[0],r=t[1];if(0===e)return void(a+=r.length);var o=a,s=r.length;-1===e&&(o+=s,s=-s),n.forEach(function(t){t.selectionEnd>o?(t.selectionEnd+=s,t.discussionIndex&&(i=!0)):t.selectionEnd>a&&(t.selectionEnd=a,t.discussionIndex&&(i=!0)),t.selectionStart>=o?(t.selectionStart+=s,t.discussionIndex&&(i=!0)):t.selectionStart>a&&(t.selectionStart=a,t.discussionIndex&&(i=!0))}),1===e&&(a+=r.length)}),i}}function S(e){if(tt=[],Z=[],Q=void 0,U===!0)return Z=K,K=e,void(tt=e);var n=K.length;t.some(K,function(t,r){var i=e[r];return r>=e.length||t.textWithFrontMatter!=i.textWithFrontMatter||t.elt.parentNode!==N||t.elt.textContent!=i.textWithFrontMatter?(n=r,!0):void 0});var r=-K.length;t.some(K.slice().reverse(),function(t,n){var i=e[e.length-n-1];return n>=e.length||t.textWithFrontMatter!=i.textWithFrontMatter||t.elt.parentNode!==N||t.elt.textContent!=i.textWithFrontMatter?(r=-n,!0):void 0}),n-r>K.length&&(r=n-K.length);var i=K.slice(0,n);tt=e.slice(n,e.length+r);var a=K.slice(K.length+r,K.length);Q=t.first(a),Z=K.slice(n,K.length+r),K=i.concat(tt).concat(a)}function C(){var t=document.createDocumentFragment();tt.forEach(function(e){k(e),t.appendChild(e.elt)}),q.noWatch(function(){if(U===!0)N.innerHTML="",N.appendChild(t);else{Z.forEach(function(t){t.elt.parentNode===N&&N.removeChild(t.elt),t.elt.generated=!1}),void 0!==Q?N.insertBefore(t,Q.elt):N.appendChild(t);for(var e=N.firstChild;e;){var n=e.nextSibling;e.generated||N.removeChild(e),e=n}}E(),W.updateSelectionRange(),W.updateCursorCoordinates()})}function E(){D=s("span",{"class":"token lf"}),D.textContent="\n",N.appendChild(D)}function k(t){var e=et(t.text);window.viewerMode||(e=i.highlight(e,i.languages.md));var n=t.textWithFrontMatter.substring(0,t.textWithFrontMatter.length-t.text.length);n.length&&(n=et(n),n=n.replace(/\n/g,'<span class="token lf">\n</span>'),e='<span class="token md">'+n+"</span>"+e);var r=s("span",{id:"wmd-input-section-"+t.id,"class":"wmd-input-section"});r.generated=!0,r.innerHTML=e,t.elt=r}var T,I,N,R,A,M,L,O,D,F={},P=0,B=function(){var e,r=0,i=function(){var t=Date.now();O.refreshPreview(),r=Date.now()-t};return n.lazyRendering===!0?t.debounce(i,500):function(){clearTimeout(e),e=setTimeout(i,2e3>r?r:2e3)}}();r.addListener("onPagedownConfigure",function(t){O=t});var j=0;r.addListener("onSectionsCreated",function(t){j||(S(t),C()),U===!0?O.refreshPreview():B()});var H,U=!0;r.addListener("onFileSelected",function(t){U=!0,H=t});var q=new c;F.watcher=q;var G=new a,z=o.create({objectHash:function(t){return JSON.stringify(t)},arrays:{detectMove:!1},textDiff:{minLength:9999999}}),W=new u;F.selectionMgr=W,$(document).on("selectionchange",".editor-content",t.bind(W.saveSelectionState,W,!0,!1)),F.adjustCursorPosition=h;var X;F.setValue=f,F.onResize=function(){r.onLayoutResize()};var V=!1;F.setContent=function(t){H||(H={content:t}),N?(H={content:t},N.textContent=t,r.onFileSelected(H),w(),V=!1):V=t},window.we=F,F.replace=d,F.replaceAll=p,F.replacePreviousText=g,F.setValueNoWatch=m,F.getValue=v,F.getContent=v,F.focus=y;var Y=new x;F.undoMgr=Y,r.addListener("onDiscussionCreated",b),r.addListener("onDiscussionRemoved",b),r.addListener("onCommentsChanged",b);var J=t.debounce(function(){var t=window.getSelection();W.hasFocus&&!j&&W.selectionStart===W.selectionEnd&&t.modify&&(W.selectionStart?(t.modify("move","backward","character"),t.modify("move","forward","character")):(t.modify("move","forward","character"),t.modify("move","backward","character")))},10);F.adjustCommentOffsets=_,F.init=function(){if(T=document.getElementById("wmd-input"),I=$(T),N=T.querySelector(".editor-content"),R=$(N),A=T.querySelector(".editor-margin"),M=$(A),L=document.querySelector(".preview-container"),I.addClass(n.editorFontClass),q.startWatching(),$(T).scroll(function(){P=T.scrollTop,U===!1&&(H.editorScrollTop=P)}),$(L).scroll(function(){U===!1&&(H.previewScrollTop=L.scrollTop)}),/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)){var e=$('<input style="width:1px;height:1px;border:none;margin:0;padding:0;" tabIndex="-1">').appendTo("html");R.blur(function(){e[0].setSelectionRange(0,0),e.blur()})}T.focus=y,T.adjustCursorPosition=h,Object.defineProperty(T,"value",{get:function(){return X},set:f}),Object.defineProperty(T,"selectionStart",{get:function(){return Math.min(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0}),Object.defineProperty(T,"selectionEnd",{get:function(){return Math.maxLine truncated
|
||||
$("#wmd-quote-button").append($('<i class="fa fa-quote-left">')).appendTo(r),$("#wmd-code-button").append($('<i class="fa fa-code">')).appendTo(r),$("#wmd-image-button").append($('<i class="fa fa-picture-o">')).appendTo(r),r=$(".wmd-button-group3"),$("#wmd-olist-button").append($('<i class="fa fa-list-ol">')).appendTo(r),$("#wmd-ulist-button").append($('<i class="fa fa-list-ul">')).appendTo(r),$("#wmd-heading-button").append($('<i class="fa fa-header">')).appendTo(r),$("#wmd-hr-button").append($('<i class="fa fa-ellipsis-h">')).appendTo(r),r=$(".wmd-button-group5"),$("#wmd-undo-button").append($('<i class="fa fa-undo">')).appendTo(r),$("#wmd-redo-button").append($('<i class="fa fa-repeat">')).appendTo(r),$("#wmd-help-button").show()},c.initEditor=function(t){return void 0!==h&&s.onFileClosed(h),h=t,void 0!==u?(n.undoMgr.init(),u.uiManager.setUndoRedoButtonStates()):(c.initEditorFirst(),void n.undoMgr.init())},c.onReady=function(){document.body.className+=" "+o.editMode,i.init(),$(document).mousemove(l).keypress(l),s.onReady(),c.initEditorFirst(),n.init()},s.addListener("onReady",function(){$(document.body).on("shown.bs.modal",".modal",function(){var t=$(this);setTimeout(function(){t.find(".btn:first").focus(),t.find("button:first").focus(),t.find("input:enabled:visible:first").focus()},50)}).on("hidden.bs.modal",".modal",function(){n.focus()}).on("keypress",".modal",function(t){13!=t.which||$(t.target).is("textarea")||$(this).find(".modal-footer a:last").click()}),$(".action-insert-link").click(function(t){var e=i.getInputTextValue($("#input-insert-link"),t);void 0!==e&&(c.insertLinkCallback(e),c.insertLinkCallback=void 0)}),$(".action-insert-image").click(function(){var t=document.mdImageManager.mdGetImgSrc();t&&(c.insertLinkCallback(t),c.insertLinkCallback=void 0)}),$(".modal-insert-link, .modal-insert-image").on("hidden.bs.modal",function(){void 0!==c.insertLinkCallback&&(c.insertLinkCallback(null),c.insertLinkCallback=void 0)}),$("div.dropdown-menu").click(function(t){t.stopPropagation()}),$("#wmd-help-button").click(function(){window.open("http://leanote.com/blog/view/531b263bdfeb2c0ea9000002")}),t.each(document.querySelectorAll("img"),function(t){var e=$(t),n=e.data("stackeditSrc");n&&e.attr("src",window.baseDir+"/img/"+n)})}),c}),define("css/css",[],function(){if("undefined"==typeof window)return{load:function(t,e,n){n()}};var t=document.getElementsByTagName("head")[0],e=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)/)||0,n=!1,r=!0;e[1]||e[7]?n=parseInt(e[1])<6||parseInt(e[7])<=9:e[2]?r=!1:e[4]&&(n=parseInt(e[4])<18);var i={};i.pluginBuilder="./css-builder";var a,o,s,l=function(){a=document.createElement("style"),t.appendChild(a),o=a.styleSheet||a.sheet},c=0,u=[],h=function(t){c++,32==c&&(l(),c=0),o.addImport(t),a.onload=function(){f()}},f=function(){s();var t=u.shift();return t?(s=t[1],void h(t[0])):void(s=null)},d=function(t,e){if(o&&o.addImport||l(),o&&o.addImport)s?u.push([t,e]):(h(t),s=e);else{a.textContent='@import "'+t+'";';var n=setInterval(function(){try{a.sheet.cssRules,clearInterval(n),e()}catch(t){}},10)}},p=function(e,n){var i=document.createElement("link");if(i.type="text/css",i.rel="stylesheet",r)i.onload=function(){i.onload=function(){},setTimeout(n,7)};else var a=setInterval(function(){for(var t=0;t<document.styleSheets.length;t++){var e=document.styleSheets[t];if(e.href==i.href)return clearInterval(a),n()}},10);i.href=e,t.appendChild(i)};return i.normalize=function(t,e){return".css"==t.substr(t.length-4,4)&&(t=t.substr(0,t.length-4)),e(t)},i.load=function(t,e,r){(n?d:p)(e.toUrl(t+".css"),r)},i}),define("css",["css/css"],function(t){return t}),rangy.createModule("CssClassApplier",function(t,e){function n(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function r(t,e){return t.className&&new RegExp("(?:^|\\s)"+e+"(?:\\s|$)").test(t.className)}function i(t,e){t.className?r(t,e)||(t.className+=" "+e):t.className=e}function a(t){return t.split(/\s+/).sort().join(" ")}function o(t){return a(t.className)}function s(t,e){return o(t)==o(e)}function l(t){for(var e=t.parentNode;t.hasChildNodes();)e.insertBefore(t.firstChild,t);e.removeChild(t)}function c(t,e){var n=t.cloneRange();n.selectNodeContents(e);var r=n.intersection(t),i=r?r.toString():"";return n.detach(),""!=i}function u(t){return t.getNodes([3],function(e){return c(t,e)})}function h(t,e){if(t.attributes.length!=e.attributes.length)return!1;for(var n,r,i,a=0,o=t.attributes.length;o>a;++a)if(n=t.attributes[a],i=n.name,"class"!=i){if(r=e.attributes.getNamedItem(i),n.specified!=r.specified)return!1;if(n.specified&&n.nodeValue!==r.nodeValue)return!1}return!0}function f(t,e){for(var n,r=0,i=t.attributes.length;i>r;++r)if(n=t.attributes[r].name,(!e||!k.arrayContains(e,n))&&t.attributes[r].specified&&"class"!=n)return!0;return!1}function d(t,e){for(var n in e)if(e.hasOwnProperty(n)&&t[n]!==e[n])return!1;return!0}function p(t){var e;return t&&1=Line truncated
|
||||
var i=_(X,e,n);X=e,i===!0&&(H.discussionList=H.discussionList),H.content=X,W.saveSelectionState(),r.onContentChanged(H,X),i&&r.onCommentsChanged(H),Y.saveState(),J()}else X=e,H.content=X,W.setSelectionStartEnd(H.editorStart,H.editorEnd),W.updateSelectionRange(),W.updateCursorCoordinates(),Y.saveSelectionState(),r.onFileOpen(H,X),L.scrollTop=H.previewScrollTop,P=H.editorScrollTop,T.scrollTop=P,U=!1}function _(t,e,n){if(n.length){var r=G.diff_main(t,e),i=!1,a=0;return r.forEach(function(t){var e=t[0],r=t[1];if(0===e)return void(a+=r.length);var o=a,s=r.length;-1===e&&(o+=s,s=-s),n.forEach(function(t){t.selectionEnd>o?(t.selectionEnd+=s,t.discussionIndex&&(i=!0)):t.selectionEnd>a&&(t.selectionEnd=a,t.discussionIndex&&(i=!0)),t.selectionStart>=o?(t.selectionStart+=s,t.discussionIndex&&(i=!0)):t.selectionStart>a&&(t.selectionStart=a,t.discussionIndex&&(i=!0))}),1===e&&(a+=r.length)}),i}}function S(e){if(tt=[],Z=[],Q=void 0,U===!0)return Z=K,K=e,void(tt=e);var n=K.length;t.some(K,function(t,r){var i=e[r];return r>=e.length||t.textWithFrontMatter!=i.textWithFrontMatter||t.elt.parentNode!==N||t.elt.textContent!=i.textWithFrontMatter?(n=r,!0):void 0});var r=-K.length;t.some(K.slice().reverse(),function(t,n){var i=e[e.length-n-1];return n>=e.length||t.textWithFrontMatter!=i.textWithFrontMatter||t.elt.parentNode!==N||t.elt.textContent!=i.textWithFrontMatter?(r=-n,!0):void 0}),n-r>K.length&&(r=n-K.length);var i=K.slice(0,n);tt=e.slice(n,e.length+r);var a=K.slice(K.length+r,K.length);Q=t.first(a),Z=K.slice(n,K.length+r),K=i.concat(tt).concat(a)}function C(){var t=document.createDocumentFragment();tt.forEach(function(e){k(e),t.appendChild(e.elt)}),q.noWatch(function(){if(U===!0)N.innerHTML="",N.appendChild(t);else{Z.forEach(function(t){t.elt.parentNode===N&&N.removeChild(t.elt),t.elt.generated=!1}),void 0!==Q?N.insertBefore(t,Q.elt):N.appendChild(t);for(var e=N.firstChild;e;){var n=e.nextSibling;e.generated||N.removeChild(e),e=n}}E(),W.updateSelectionRange(),W.updateCursorCoordinates()})}function E(){D=s("span",{"class":"token lf"}),D.textContent="\n",N.appendChild(D)}function k(t){var e=et(t.text);window.viewerMode||(e=i.highlight(e,i.languages.md));var n=t.textWithFrontMatter.substring(0,t.textWithFrontMatter.length-t.text.length);n.length&&(n=et(n),n=n.replace(/\n/g,'<span class="token lf">\n</span>'),e='<span class="token md">'+n+"</span>"+e);var r=s("span",{id:"wmd-input-section-"+t.id,"class":"wmd-input-section"});r.generated=!0,r.innerHTML=e,t.elt=r}var T,I,N,R,A,M,L,O,D,F={},P=0,B=function(){var e,r=0,i=function(){var t=Date.now();O.refreshPreview(),r=Date.now()-t};return n.lazyRendering===!0?t.debounce(i,500):function(){clearTimeout(e),e=setTimeout(i,2e3>r?r:2e3)}}();r.addListener("onPagedownConfigure",function(t){O=t});var j=0;r.addListener("onSectionsCreated",function(t){j||(S(t),C()),U===!0?O.refreshPreview():B()});var H,U=!0;r.addListener("onFileSelected",function(t){U=!0,H=t});var q=new c;F.watcher=q;var G=new a,z=o.create({objectHash:function(t){return JSON.stringify(t)},arrays:{detectMove:!1},textDiff:{minLength:9999999}}),W=new u;F.selectionMgr=W,$(document).on("selectionchange",".editor-content",t.bind(W.saveSelectionState,W,!0,!1)),F.adjustCursorPosition=h;var X;F.setValue=f,F.onResize=function(){r.onLayoutResize()};var V=!1;F.setContent=function(t){H||(H={content:t}),N?(H={content:t},N.textContent=t,r.onFileSelected(H),w(),V=!1):V=t},window.we=F,F.replace=d,F.replaceAll=p,F.replacePreviousText=g,F.setValueNoWatch=m,F.getValue=v,F.getContent=v,F.focus=y;var Y=new x;F.undoMgr=Y,r.addListener("onDiscussionCreated",b),r.addListener("onDiscussionRemoved",b),r.addListener("onCommentsChanged",b);var J=t.debounce(function(){var t=window.getSelection();W.hasFocus&&!j&&W.selectionStart===W.selectionEnd&&t.modify&&(W.selectionStart?(t.modify("move","backward","character"),t.modify("move","forward","character")):(t.modify("move","forward","character"),t.modify("move","backward","character")))},10);F.adjustCommentOffsets=_,F.init=function(){if(T=document.getElementById("wmd-input"),I=$(T),N=T.querySelector(".editor-content"),R=$(N),A=T.querySelector(".editor-margin"),M=$(A),L=document.querySelector(".preview-container"),I.addClass(n.editorFontClass),q.startWatching(),$(T).scroll(function(){P=T.scrollTop,U===!1&&(H.editorScrollTop=P)}),$(L).scroll(function(){U===!1&&(H.previewScrollTop=L.scrollTop)}),/AppleWebKit\/([\d.]+)/.exec(navigator.userAgent)){var e=$('<input style="width:1px;height:1px;border:none;margin:0;padding:0;" tabIndex="-1">').appendTo("html");R.blur(function(){e[0].setSelectionRange(0,0),e.blur()})}T.focus=y,T.adjustCursorPosition=h,Object.defineProperty(T,"value",{get:function(){return X},set:f}),Object.defineProperty(T,"selectionStart",{get:function(){return Math.min(W.selectionStart,W.selectionEnd)},set:function(t){W.setSelectionStartEnd(t),W.updateSelectionRange(),W.updateCursorCoordinates()},enumerable:!0,configurable:!0}),Object.defineProperty(T,"selectionEnd",{get:function(){return Math.maxLine truncated
|
||||
_DoItalicsAndBold:function(t){return t=t.replace(/(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\1/g,"<strong>$2</strong>"),t=t.replace(/(\*|_)(?=\S)(.+?)(?=\S)\1/g,"<em>$2</em>")}};t.setOptions(e),u=new Markdown.Editor(t,void 0,{undoManager:n.undoMgr}),MD.insertLink2=u.insertLink,u.hooks.set("insertLinkDialog",function(t){return c.insertLinkCallback=t,i.resetModalInputs(),g.modal(),!0}),u.hooks.set("insertImageDialog",function(t){if(c.insertLinkCallback=t,c.catchModal)return!0;i.resetModalInputs();var e=$("#leauiIfrForMD");return e.attr("src")||e.attr("src","/album/index?md=1"),$(".modal-insert-image").modal(),!0}),s.onPagedownConfigure(u),u.hooks.chain("onPreviewRefresh",s.onAsyncPreview),u.run(),$(".wmd-button-row li").addClass("btn btn-success").css("left",0).find("span").hide();var r=$(".wmd-button-group1");$("#wmd-bold-button").append($('<i class="fa fa-bold">')).appendTo(r),$("#wmd-italic-button").append($('<i class="fa fa-italic">')).appendTo(r),r=$(".wmd-button-group2"),$("#wmd-link-button").append($('<i class="fa fa-link">')).appendTo(r),$("#wmd-quote-button").append($('<i class="fa fa-quote-left">')).appendTo(r),$("#wmd-code-button").append($('<i class="fa fa-code">')).appendTo(r),$("#wmd-image-button").append($('<i class="fa fa-picture-o">')).appendTo(r),r=$(".wmd-button-group3"),$("#wmd-olist-button").append($('<i class="fa fa-list-ol">')).appendTo(r),$("#wmd-ulist-button").append($('<i class="fa fa-list-ul">')).appendTo(r),$("#wmd-heading-button").append($('<i class="fa fa-header">')).appendTo(r),$("#wmd-hr-button").append($('<i class="fa fa-ellipsis-h">')).appendTo(r),r=$(".wmd-button-group5"),$("#wmd-undo-button").append($('<i class="fa fa-undo">')).appendTo(r),$("#wmd-redo-button").append($('<i class="fa fa-repeat">')).appendTo(r),$("#wmd-help-button").show()},c.initEditor=function(t){return void 0!==h&&s.onFileClosed(h),h=t,void 0!==u?(n.undoMgr.init(),u.uiManager.setUndoRedoButtonStates()):(c.initEditorFirst(),void n.undoMgr.init())},c.onReady=function(){document.body.className+=" "+o.editMode,i.init(),$(document).mousemove(l).keypress(l),s.onReady(),c.initEditorFirst(),n.init()},s.addListener("onReady",function(){$(document.body).on("shown.bs.modal",".modal",function(){var t=$(this);setTimeout(function(){t.find(".btn:first").focus(),t.find("button:first").focus(),t.find("input:enabled:visible:first").focus()},50)}).on("hidden.bs.modal",".modal",function(){n.focus()}).on("keypress",".modal",function(t){13!=t.which||$(t.target).is("textarea")||$(this).find(".modal-footer a:last").click()}),m.click(function(t){var e=i.getInputTextValue($("#input-insert-link"),t);if(void 0!==e){var n=e.split(" "),r="",a=n[0];n.length>1&&(n.shift(),r=$.trim(n.join(" "))),c.insertLinkCallback(a,r),c.insertLinkCallback=void 0}}),$(".action-insert-image").click(function(){var t=document.getElementById("leauiIfrForMD").contentWindow.mdGetImgSrc();t&&(c.insertLinkCallback(t),c.insertLinkCallback=void 0)}),g.on("hidden.bs.modal",function(){void 0!==c.insertLinkCallback&&(c.insertLinkCallback(null),c.insertLinkCallback=void 0)}),$("div.dropdown-menu").click(function(t){t.stopPropagation()}),$("#wmd-help-button").click(function(){window.open("http://leanote.com/blog/post/531b263bdfeb2c0ea9000002")}),t.each(document.querySelectorAll("img"),function(t){var e=$(t),n=e.data("stackeditSrc");n&&e.attr("src",window.baseDir+"/img/"+n)})}),c}),define("css/css",[],function(){if("undefined"==typeof window)return{load:function(t,e,n){n()}};var t=document.getElementsByTagName("head")[0],e=window.navigator.userAgent.match(/Trident\/([^ ;]*)|AppleWebKit\/([^ ;]*)|Opera\/([^ ;]*)|rv\:([^ ;]*)(.*?)Gecko\/([^ ;]*)|MSIE\s([^ ;]*)/)||0,n=!1,r=!0;e[1]||e[7]?n=parseInt(e[1])<6||parseInt(e[7])<=9:e[2]?r=!1:e[4]&&(n=parseInt(e[4])<18);var i={};i.pluginBuilder="./css-builder";var a,o,s,l=function(){a=document.createElement("style"),t.appendChild(a),o=a.styleSheet||a.sheet},c=0,u=[],h=function(t){c++,32==c&&(l(),c=0),o.addImport(t),a.onload=function(){f()}},f=function(){s();var t=u.shift();return t?(s=t[1],void h(t[0])):void(s=null)},d=function(t,e){if(o&&o.addImport||l(),o&&o.addImport)s?u.push([t,e]):(h(t),s=e);else{a.textContent='@import "'+t+'";';var n=setInterval(function(){try{a.sheet.cssRules,clearInterval(n),e()}catch(t){}},10)}},p=function(e,n){var i=document.createElement("link");if(i.type="text/css",i.rel="stylesheet",r)i.onload=function(){i.onload=function(){},setTimeout(n,7)};else var a=setInterval(function(){for(var t=0;t<document.styleSheets.length;t++){var e=document.styleSheets[t];if(e.href==i.href)return clearInterval(a),n()}},10);i.href=e,t.appendChild(i)};return i.normalize=function(t,e){return".css"==t.substr(t.length-4,4)&&(t=t.substr(0,t.length-4)),e(t)},i.load=function(t,e,r){(n?d:p)(e.toUrl(t+".css"),r)},i}),define("css",["css/css"],function(t){return t}),rangy.createModule("CssClassApplier",function(t,e){function n(t){return t.replace(/^\s\s*/,"").replace(/\s\s*$/,"")}function r(t,e){return t.className&&new RegExp("(?:^|\\s)"+e+"(Line truncated
|
||||
@@ -79,7 +79,7 @@ define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
var imgElm;
|
||||
// 先显示loading...
|
||||
d.id = '__mcenew' + (i++);
|
||||
d.src = "http://leanote.com/images/loading-24.gif";
|
||||
d.src = "/images/loading-24.gif";
|
||||
imgElm = dom.createHTML('img', d);
|
||||
tinymce.activeEditor.insertContent(imgElm);
|
||||
imgElm = dom.get(d.id);
|
||||
@@ -147,7 +147,7 @@ define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
// 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 tpl = $('<li><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></li>');
|
||||
var tpl = $('<li><div class="alert alert-info"><img class="loader" src="/public/album/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
|
||||
// Append the file name and file size
|
||||
tpl.find('div').append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
|
||||
@@ -170,7 +170,7 @@ define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
} else {
|
||||
data.context.empty();
|
||||
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
tpl.find('div').append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
|
||||
tpl.find('div').append('<b>' + getMsg('Error') + ':</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
|
||||
data.context.append(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
@@ -183,7 +183,7 @@ define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
fail: function(e, data) {
|
||||
data.context.empty();
|
||||
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
|
||||
tpl.find('div').append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
|
||||
tpl.find('div').append('<b>' + getMsg('Error') + ':</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
|
||||
data.context.append(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
@@ -247,14 +247,21 @@ define('editor_drop_paste', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
} while (node != null);
|
||||
if (found) {
|
||||
dropZone.addClass('hover');
|
||||
|
||||
// 如果在只读状态, 转换之
|
||||
if (LEA.readOnly) {
|
||||
LEA.toggleWriteable();
|
||||
}
|
||||
|
||||
} else {
|
||||
dropZone.removeClass('hover');
|
||||
}
|
||||
|
||||
window.dropZoneTimeout = setTimeout(function () {
|
||||
window.dropZoneTimeout = null;
|
||||
dropZone.removeClass('in hover');
|
||||
hideUpload();
|
||||
}, 100);
|
||||
}, 500);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,5 +2,5 @@ define("note_info",[],function(){var t=["<table>","<tr><th>"+getMsg("Create Time
|
||||
define("tips",[],function(){var d=['<div class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">','<div class="modal-dialog modal-sm">','<div class="modal-content">','<div class="modal-header">','<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>','<h4 class="modal-title" class="modalTitle">'+getMsg("editorTips")+"</h4>","</div>",'<div class="modal-body">'+getMsg("editorTipsInfo")+"</div>",'<div class="modal-footer">','<button type="button" class="btn btn-default" data-dismiss="modal">'+getMsg("close")+"</button>","</div>","</div>","</div>","</div>"].join(""),a=$(d),i={init:function(){$("#tipsBtn").click(function(){a.modal({show:!0})})}};i.init()});
|
||||
define("history",[],function(){var t=['<div class="modal fade history-modal" tabindex="-1" role="dialog" aria-hidden="true">','<div class="modal-dialog modal-lg ">','<div class="modal-content">','<div class="modal-header">','<h4 class="modal-title" class="modalTitle">NaN',"</div>",'<div class="modal-body clearfix">','<div class="history-list-wrap pull-left">','<div class="history-list-header">'+getMsg("history")+' (<span class="history-num"></span>)</div>','<div class="history-list list-group"></div>',"</div>",'<div class="history-content-wrap pull-left">','<div class="history-content-header">','<a class="btn btn-primary back">'+getMsg("restoreFromThisVersion")+"</a>",'<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>',"</div>",'<div class="history-content"></div>',"</div>","</div>",'<div class="modal-footer hide">','<button type="button" class="btn btn-default" data-dismiss="modal">'+getMsg("close")+"</button>","</div>","</div>","</div>","</div>"].join(""),i=$(t),s=i.find(".history-content"),e=i.find(".history-list"),o=i.find(".history-num"),n={note:null,list:[],curIndex:0,renderContent:function(t){var i=this.list[t].Content;this.curIndex=t;var o="<div>",n="</div>";this.note.IsMarkdown&&(o="<pre>",n="</pre>"),s.html(o+i+n);var a=e.find("a");a.removeClass("active"),a.eq(t).addClass("active")},render:function(t){var s="";if(this.list=t,t)for(var n=0;n<t.length;++n){var a=t[n];s+='<a class="list-group-item" data-index="'+n+'"><span class="badge">#'+(n+1)+"</span>"+goNowToDatetime(a.UpdatedTime)+"</a>"}e.html(s),this.renderContent(0),o.html(t.length),i.modal({show:!0})},bind:function(){var t=this;$("#contentHistory").click(function(){t.getHistories()}),e.on("click","a",function(){var i=$(this).data("index");t.renderContent(i)}),i.find(".back").click(function(){confirm(getMsg("confirmBackup"))&&(Note.curChangedSaveIt(!0),note=Note.cache[Note.curNoteId],setEditorContent(t.list[t.curIndex].Content,note.IsMarkdown),i.modal("hide"),Note.curChangedSaveIt(!0))})},getHistories:function(){var t=this,i=Note.getCurNote();t.note=i,ajaxGet("/noteContentHistory/listHistories",{noteId:Note.curNoteId},function(i){return isArray(i)?void t.render(i):void alert(getMsg("noHistories"))})},init:function(){this.bind()}};n.init()});
|
||||
var urlPrefix=UrlPrefix;define("attachment_upload",["jquery.ui.widget","fileupload"],function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(e,t){var a=$(e);$(t).bind("dragover",function(e){e.preventDefault();var t=window.dropZoneTimeoutAttach;t&&clearTimeout(t);var i=!1,o=e.target;do{if(o===a[0]){i=!0;break}o=o.parentNode}while(null!=o);i?a.addClass("hover"):a.removeClass("hover"),window.dropZoneTimeoutAttach=setTimeout(function(){window.dropZoneTimeoutAttach=null,a.removeClass("in hover")},100)})}t("#dropAttach","#uploadAttach");var a=function(){$(".dropzone .btn-choose-file").click(function(){$(this).parent().find("input").click()});var t=$("#attachUploadMsg");$("#uploadAttach").fileupload({dataType:"json",pasteZone:"",dropZone:$("#dropAttach"),formData:function(e){return[{name:"noteId",value:Note.curNoteId}]},add:function(a,i){var o=Note.getCurNote();if(!o||o.IsNew)return void alert("This note hasn't saved, please save it firstly!");var n=$('<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>');n.append(i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small>"),t.html(n),i.context=t;var r=i.files[0].size,l=+GlobalConfigs.uploadAttachSize||100;if("number"==typeof r&&r>1048576*l)return n.find("img").remove(),n.removeClass("alert-info").addClass("alert-danger"),n.append(" Warning: File size is bigger than "+l+"M"),void setTimeout(function(e){return function(){e.remove()}}(n),3e3);var s;setTimeout(function(){s=i.submit()},10)},done:function(t,a){if(1==a.result.Ok)a.context.html(""),Attach.addAttach(a.result.Item);else{a.result;a.context.html("");var i=$('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');i.append("<b>Error:</b> "+a.files[0].name+" <small>[<i>"+e(a.files[0].size)+"</i>]</small> "+a.result.Msg),a.context.html(i),setTimeout(function(e){return function(){e.remove()}}(i),3e3)}$("#uploadAttachMsg").scrollTop(1e3)},fail:function(t,a){a.context.html("");var i=$('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');i.append("<b>Error:</b> "+a.files[0].name+" <small>[<i>"+e(a.files[0].size)+"</i>]</small> "+a.errorThrown),a.context.html(i),setTimeout(function(e){return function(){e.remove()}}(i),3e3),$("#uploadAttachMsg").scrollTop(1e3)}})};a()});
|
||||
var urlPrefix=UrlPrefix;define("editor_drop_paste",["jquery.ui.widget","fileupload"],function(){function e(e){var i="__mcenew"+(new Date).getTime(),t='<div contenteditable="false" id="'+i+'" class="leanote-image-container"><img class="loader" src="/images/ajax-loader.gif"><div class="progress"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">0%</div></div></div>';this.containerStr=t,e.insertContent(t);var o=$("#"+i);this.container=o,this.id=i,this.processBar=o.find(".progress-bar")}function i(e,i){function t(e,t){o.parentNode.removeChild(o),i({width:e,height:t})}var o=document.createElement("img");o.onload=function(){t(o.clientWidth,o.clientHeight)},o.onerror=function(){t()},o.src=e;var a=o.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left=0,a.width=a.height="auto",document.body.appendChild(o)}function t(e){var t=tinymce.activeEditor,a=t.dom,r=function(t){function r(e){a.setAttrib(n,"src",t.src),t.title&&a.setAttrib(n,"title",t.title),a.setAttrib(n,"id",null)}var n,s={};s.id="__mcenew"+o++,s.src="http://leanote.com/images/loading-24.gif",n=a.createHTML("img",s),tinymce.activeEditor.insertContent(n),n=a.get(s.id),i(e.src,r)},n="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(n=fileIds[1]),n){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:n,toUserId:s.UserId},function(i){if(reIsOk(i)&&i.Id){var t=window.location.protocol+"//"+window.location.host;e.src=t+"/file/outputImage?fileId="+i.Id}r(e)})}(e):r(e)}else r(e)}e.prototype.update=function(e){var i=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+i.id+" .progress-bar").html(e).css("width",e)},e.prototype.replace=function(e){var t=this;i(e,function(){$("#"+t.id).replaceWith('<img src="'+e+'" />')})},e.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var o=1,a=function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function i(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function o(){$("#upload").css("z-index",0).css("top","auto").hide()}var a=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,maxFileSize:21e4,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:""}]},add:function(i,t){var o=$('<li><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></li>');o.find("div").append(t.files[0].name+" <small>[<i>"+e(t.files[0].size)+"</i>]</small>"),t.context=o.appendTo(a);t.submit()},done:function(i,o){if(1==o.result.Ok){o.context.remove();var a={src:urlPrefix+"/file/outputImage?fileId="+o.result.Id};t(a)}else{o.context.empty();var r=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');r.find("div").append("<b>Error:</b> "+o.files[0].name+" <small>[<i>"+e(o.files[0].size)+"</i>]</small> "+o.result.Msg),o.context.append(r),setTimeout(function(e){return function(){e.remove()}}(r),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(i,t){t.context.empty();var o=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');o.find("div").append("<b>Error:</b> "+t.files[0].name+" <small>[<i>"+e(t.files[0].size)+"</i>]</small> "+t.errorThrown),t.context.append(o),setTimeout(function(e){return function(){e.remove()}}(o),2e3),$("#uploadMsg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var t=$("#drop"),a=window.dropZoneTimeout;a?clearTimeout(a):(t.addClass("in"),i());var r=!1,n=e.target;do{if(n===t[0]){r=!0;break}n=n.parentNode}while(null!=n);r?t.addClass("hover"):t.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,t.removeClass("in hover"),o()},100)})},r=0,n=function(){var i,t;$("#editorContent, #wmd-input .editor-content").fileupload({dataType:"json",pasteZone:$("#editorContent, #wmd-input .editor-content"),dropZone:"",maxFileSize:21e4,url:"/file/pasteImage",paramName:"file",formData:function(e){return[{name:"from",value:"pasteImage"},{name:"noteId",value:Note.curNoteId}]},progress:function(e,t){i&&!i.IsMarkdown&&t.process.update(t.loaded/t.total)},add:function(o,a){var n=(new Date).getTime();if(!(500>n-r)){r=n;var s=Note.getCurNote();if(i=s,!s||s.IsNew)return void alert("This note hasn't saved, please save it firstly!");if(t=tinymce.EditorManager.activeEditor,!s.IsMarkdown)var l=new e(t);a.process=l;a.submit()}},done:function(e,t){if(1==t.result.Ok){var o=t.result,a=UrLine truncated
|
||||
var urlPrefix=UrlPrefix;define("editor_drop_paste",["jquery.ui.widget","fileupload"],function(){function e(e){var t="__mcenew"+(new Date).getTime(),i='<div contenteditable="false" id="'+t+'" class="leanote-image-container"><img class="loader" src="/images/ajax-loader.gif"><div class="progress"><div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">0%</div></div></div>';this.containerStr=i,e.insertContent(i);var o=$("#"+t);this.container=o,this.id=t,this.processBar=o.find(".progress-bar")}function t(e,t){function i(e,i){o.parentNode.removeChild(o),t({width:e,height:i})}var o=document.createElement("img");o.onload=function(){i(o.clientWidth,o.clientHeight)},o.onerror=function(){i()},o.src=e;var r=o.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(o)}function i(e){var i=tinymce.activeEditor,r=i.dom,a=function(i){function a(e){r.setAttrib(n,"src",i.src),i.title&&r.setAttrib(n,"title",i.title),r.setAttrib(n,"id",null)}var n,s={};s.id="__mcenew"+o++,s.src="/images/loading-24.gif",n=r.createHTML("img",s),tinymce.activeEditor.insertContent(n),n=r.get(s.id),t(e.src,a)},n="";if(fileIds=e.src.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(n=fileIds[1]),n){var s=Note.getCurNote();s&&s.UserId!=UserInfo.UserId?!function(e){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:n,toUserId:s.UserId},function(t){if(reIsOk(t)&&t.Id){var i=window.location.protocol+"//"+window.location.host;e.src=i+"/file/outputImage?fileId="+t.Id}a(e)})}(e):a(e)}else a(e)}e.prototype.update=function(e){var t=this;e=Math.ceil(100*e),e>=100&&(e=99),e+="%",$("#"+t.id+" .progress-bar").html(e).css("width",e)},e.prototype.replace=function(e){var i=this;t(e,function(){$("#"+i.id).replaceWith('<img src="'+e+'" />')})},e.prototype.remove=function(){var e=this;$("#"+e.id).remove()};var o=1,r=function(){function e(e){return"number"!=typeof e?"":e>=1e9?(e/1e9).toFixed(2)+" GB":e>=1e6?(e/1e6).toFixed(2)+" MB":(e/1e3).toFixed(2)+" KB"}function t(){$("#upload").css("z-index",12);var e=+$("#mceToolbar").css("height").slice(0,-2);$("#upload").css("top",e-8),$("#upload").show()}function o(){$("#upload").css("z-index",0).css("top","auto").hide()}var r=$("#upload ul");$("#drop a").click(function(){$(this).parent().find("input").click()}),$("#upload").fileupload({dataType:"json",pasteZone:"",acceptFileTypes:/(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,maxFileSize:21e4,dropZone:$("#drop"),formData:function(e){return[{name:"albumId",value:""}]},add:function(t,i){var o=$('<li><div class="alert alert-info"><img class="loader" src="/public/album/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div></li>');o.find("div").append(i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small>"),i.context=o.appendTo(r);i.submit()},done:function(t,o){if(1==o.result.Ok){o.context.remove();var r={src:urlPrefix+"/file/outputImage?fileId="+o.result.Id};i(r)}else{o.context.empty();var a=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');a.find("div").append("<b>"+getMsg("Error")+":</b> "+o.files[0].name+" <small>[<i>"+e(o.files[0].size)+"</i>]</small> "+o.result.Msg),o.context.append(a),setTimeout(function(e){return function(){e.remove()}}(a),2e3)}$("#uploadMsg").scrollTop(1e3)},fail:function(t,i){i.context.empty();var o=$('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');o.find("div").append("<b>"+getMsg("Error")+":</b> "+i.files[0].name+" <small>[<i>"+e(i.files[0].size)+"</i>]</small> "+i.errorThrown),i.context.append(o),setTimeout(function(e){return function(){e.remove()}}(o),2e3),$("#uploadMsg").scrollTop(1e3)}}),$(document).on("drop dragover",function(e){e.preventDefault()}),$(document).bind("dragover",function(e){var i=$("#drop"),r=window.dropZoneTimeout;r?clearTimeout(r):(i.addClass("in"),t());var a=!1,n=e.target;do{if(n===i[0]){a=!0;break}n=n.parentNode}while(null!=n);a?(i.addClass("hover"),LEA.readOnly&&LEA.toggleWriteable()):i.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,i.removeClass("in hover"),o()},500)})},a=0,n=function(){var t,i;$("#editorContent, #wmd-input .editor-content").fileupload({dataType:"json",pasteZone:$("#editorContent, #wmd-input .editor-content"),dropZone:"",maxFileSize:21e4,url:"/file/pasteImage",paramName:"file",formData:function(e){return[{name:"from",value:"pasteImage"},{name:"noteId",value:Note.curNoteId}]},progress:function(e,i){t&&!t.IsMarkdown&&i.process.update(i.loaded/i.total)},add:function(o,r){var n=(new Date).getTime();if(!(500>n-a)){a=n;var s=Note.getCurNote();if(t=s,!s||s.IsNew)return void alert("This note hasn't saved, please save it firstly!");if(i=tinymce.EditorManager.activeEditor,!s.IsMarkdown)var l=new e(i);r.process=l;r.submit()}},done:function(e,i){if(1==i.resuLine truncated
|
||||
requirejs.config({paths:{editor_drop_paste:"js/plugins/editor_drop_paste",attachment_upload:"js/plugins/attachment_upload","jquery.ui.widget":"js/plugins/libs-min/jquery.ui.widget",fileupload:"js/plugins/libs-min/jquery.fileupload","iframe-transport":"js/plugins/libs-min/jquery.iframe-transport",note_info:"js/plugins/note_info",tips:"js/plugins/tips",history:"js/plugins/history"},shim:{fileupload:{deps:["jquery.ui.widget","iframe-transport"]}}}),setTimeout(function(){require(["editor_drop_paste","attachment_upload"]),require(["note_info"]),setTimeout(function(){require(["tips"]),require(["history"])},10)});
|
||||
@@ -0,0 +1,632 @@
|
||||
/**
|
||||
* Markdown convert to html
|
||||
*
|
||||
<script src="md2html.js"></script>
|
||||
<script>
|
||||
md2Html(document.getElementById('md').value, $('#content'));
|
||||
md2Html('hello, **leanote**', document.getElementById('content2'), function allRendered(html) {
|
||||
alert(html);
|
||||
});
|
||||
</script>
|
||||
*
|
||||
* @author leanote.com
|
||||
* @date 2015/04/11
|
||||
*/
|
||||
|
||||
// Markdown.Converter.js
|
||||
var Markdown;if(typeof exports==="object"&&typeof require==="function"){Markdown=exports}else{Markdown={}}(function(){function identity(x){return x}function returnFalse(x){return false}function HookCollection(){}HookCollection.prototype={chain:function(hookname,func){var original=this[hookname];if(!original){throw new Error("unknown hook "+hookname)}if(original===identity){this[hookname]=func}else{this[hookname]=function(text){var args=Array.prototype.slice.call(arguments,0);args[0]=original.apply(null,args);return func.apply(null,args)}}},set:function(hookname,func){if(!this[hookname]){throw new Error("unknown hook "+hookname)}this[hookname]=func},addNoop:function(hookname){this[hookname]=identity},addFalse:function(hookname){this[hookname]=returnFalse}};Markdown.HookCollection=HookCollection;function SaveHash(){}SaveHash.prototype={set:function(key,value){this["s_"+key]=value},get:function(key){return this["s_"+key]}};Markdown.Converter=function(){var options={};this.setOptions=function(optionsParam){options=optionsParam};var pluginHooks=this.hooks=new HookCollection();pluginHooks.addNoop("plainLinkText");pluginHooks.addNoop("preConversion");pluginHooks.addNoop("postNormalization");pluginHooks.addNoop("preBlockGamut");pluginHooks.addNoop("postBlockGamut");pluginHooks.addNoop("preSpanGamut");pluginHooks.addNoop("postSpanGamut");pluginHooks.addNoop("postConversion");var g_urls;var g_titles;var g_html_blocks;var g_list_level;this.makeHtml=function(text){if(g_urls){throw new Error("Recursive call to converter.makeHtml")}g_urls=new SaveHash();g_titles=new SaveHash();g_html_blocks=[];g_list_level=0;text=pluginHooks.preConversion(text);text=text.replace(/~/g,"~T");text=text.replace(/\$/g,"~D");text=text.replace(/\r\n/g,"\n");text=text.replace(/\r/g,"\n");text="\n\n"+text+"\n\n";text=_Detab(text);text=text.replace(/^[ \t]+$/mg,"");text=pluginHooks.postNormalization(text);text=_HashHTMLBlocks(text);text=_StripLinkDefinitions(text);text=_RunBlockGamut(text);text=_UnescapeSpecialChars(text);text=text.replace(/~D/g,"$$");text=text.replace(/~T/g,"~");text=pluginHooks.postConversion(text);g_html_blocks=g_titles=g_urls=null;return text};function _StripLinkDefinitions(text){text=text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm,function(wholeMatch,m1,m2,m3,m4,m5){m1=m1.toLowerCase();g_urls.set(m1,_EncodeAmpsAndAngles(m2));if(m4){return m3}else{if(m5){g_titles.set(m1,m5.replace(/"/g,"""))}}return""});return text}function _HashHTMLBlocks(text){var block_tags_a="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del";var block_tags_b="p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math";text=text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement);text=text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement);text=text.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement);text=text.replace(/\n\n[ ]{0,3}(<!(--(?:|(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g,hashElement);text=text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement);return text}function hashElement(wholeMatch,m1){var blockText=m1;blockText=blockText.replace(/^\n+/,"");blockText=blockText.replace(/\n+$/g,"");blockText="\n\n~K"+(g_html_blocks.push(blockText)-1)+"K\n\n";return blockText}var blockGamutHookCallback=function(t){return _RunBlockGamut(t)};function _RunBlockGamut(text,doNotUnhash){text=pluginHooks.preBlockGamut(text,blockGamutHookCallback);text=_DoHeaders(text);var replacement="<hr />\n";text=text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,replacement);text=text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm,replacement);text=text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm,replacement);text=_DoLists(text);text=_DoCodeBlocks(text);text=_DoBlockQuotes(text);text=pluginHooks.postBlockGamut(text,blockGamutHookCallback);text=_HashHTMLBlocks(text);text=_FormParagraphs(text,doNotUnhash);return text}function _RunSpanGamut(text){text=pluginHooks.preSpanGamut(text);text=_DoCodeSpans(text);text=_EscapeSpecialCharsWithinTagAttributes(text);text=_EncodeBackslashEscapes(text);text=_DoImages(text);text=_DoAnchors(text);text=_DoAutoLinks(text);text=text.replace(/~P/g,"://");text=_EncodeAmpsAndAngles(text);text=options._DoItalicsAndBold?options._DoItalicsAndBold(text):_DoItalicsAndBold(text);text=text.replace(/ +\n/g," <br>\n");text=pluginHooks.postSpanGamut(text);return text}function _EscapeSpecialCharsWithinTagAttributes(text){var regex=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--(?:|(?:[^>-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi;text=text.replace(regex,function(wholeMatch){var tag=wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`");tag=escapeCharacters(tag,wholeMatch.charAt(1)=="!"?"\\Line truncated
|
||||
return tag});return text}function _DoAnchors(text){text=text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag);text=text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?((?:\([^)]*\)|[^()\s])*?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag);text=text.replace(/(\[([^\[\]]+)\])()()()()()/g,writeAnchorTag);return text}function writeAnchorTag(wholeMatch,m1,m2,m3,m4,m5,m6,m7){if(m7==undefined){m7=""}var whole_match=m1;var link_text=m2.replace(/:\/\//g,"~P");var link_id=m3.toLowerCase();var url=m4;var title=m7;if(url==""){if(link_id==""){link_id=link_text.toLowerCase().replace(/ ?\n/g," ")}url="#"+link_id;if(g_urls.get(link_id)!=undefined){url=g_urls.get(link_id);if(g_titles.get(link_id)!=undefined){title=g_titles.get(link_id)}}else{if(whole_match.search(/\(\s*\)$/m)>-1){url=""}else{return whole_match}}}url=encodeProblemUrlChars(url);url=escapeCharacters(url,"*_");var result='<a href="'+url+'"';if(title!=""){title=attributeEncode(title);title=escapeCharacters(title,"*_");result+=' title="'+title+'"'}result+=">"+link_text+"</a>";return result}function _DoImages(text){text=text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag);text=text.replace(/(!\[(.*?)\]\s?\([ \t]*()<?(\S+?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag);return text}function attributeEncode(text){return text.replace(/>/g,">").replace(/</g,"<").replace(/"/g,""")}function writeImageTag(wholeMatch,m1,m2,m3,m4,m5,m6,m7){var whole_match=m1;var alt_text=m2;var link_id=m3.toLowerCase();var url=m4;var title=m7;if(!title){title=""}if(url==""){if(link_id==""){link_id=alt_text.toLowerCase().replace(/ ?\n/g," ")}url="#"+link_id;if(g_urls.get(link_id)!=undefined){url=g_urls.get(link_id);if(g_titles.get(link_id)!=undefined){title=g_titles.get(link_id)}}else{return whole_match}}alt_text=escapeCharacters(attributeEncode(alt_text),"*_[]()");url=escapeCharacters(url,"*_");var result='<img src="'+url+'" alt="'+alt_text+'"';title=attributeEncode(title);title=escapeCharacters(title,"*_");result+=' title="'+title+'"';result+=" />";return result}function _DoHeaders(text){text=text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm,function(wholeMatch,m1){return"<h1>"+_RunSpanGamut(m1)+"</h1>\n\n"});text=text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm,function(matchFound,m1){return"<h2>"+_RunSpanGamut(m1)+"</h2>\n\n"});text=text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm,function(wholeMatch,m1,m2){var h_level=m1.length;return"<h"+h_level+">"+_RunSpanGamut(m2)+"</h"+h_level+">\n\n"});return text}function _DoLists(text,isInsideParagraphlessListItem){text+="~0";var whole_list=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;if(g_list_level){text=text.replace(whole_list,function(wholeMatch,m1,m2){var list=m1;var list_type=(m2.search(/[*+-]/g)>-1)?"ul":"ol";var result=_ProcessListItems(list,list_type,isInsideParagraphlessListItem);result=result.replace(/\s+$/,"");result="<"+list_type+">"+result+"</"+list_type+">\n";return result})}else{whole_list=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g;text=text.replace(whole_list,function(wholeMatch,m1,m2,m3){var runup=m1;var list=m2;var list_type=(m3.search(/[*+-]/g)>-1)?"ul":"ol";var result=_ProcessListItems(list,list_type);result=runup+"<"+list_type+">\n"+result+"</"+list_type+">\n";return result})}text=text.replace(/~0/,"");return text}var _listItemMarkers={ol:"\\d+[.]",ul:"[*+-]"};function _ProcessListItems(list_str,list_type,isInsideParagraphlessListItem){g_list_level++;list_str=list_str.replace(/\n{2,}$/,"\n");list_str+="~0";var marker=_listItemMarkers[list_type];var re=new RegExp("(^[ \\t]*)("+marker+")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1("+marker+")[ \\t]+))","gm");var last_item_had_a_double_newline=false;list_str=list_str.replace(re,function(wholeMatch,m1,m2,m3){var item=m3;var leading_space=m1;var ends_with_double_newline=/\n\n$/.test(item);var contains_double_newline=ends_with_double_newline||item.search(/\n{2,}/)>-1;if(contains_double_newline||last_item_had_a_double_newline){item=_RunBlockGamut(_Outdent(item),true)}else{item=_DoLists(_Outdent(item),true);item=item.replace(/\n$/,"");if(!isInsideParagraphlessListItem){item=_RunSpanGamut(item)}}last_item_had_a_double_newline=ends_with_double_newline;return"<li>"+item+"</li>\n"});list_str=list_str.replace(/~0/g,"");g_list_level--;return list_str}function _DoCodeBlocks(text){text+="~0";text=text.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,function(wholeMatch,m1,m2){var codeblock=m1;var nextChar=m2;codeblock=_EncodeCode(_Outdent(codeblock));codeblock=_Detab(codeblock);codeblock=codeblock.replace(/^\n+/g,"");codeblock=codeblock.replace(/\n+$/g,"");codeblock="<pre><code>"+codeblock+"\n</code></pre>";return"\n\n"+codeblock+"\n\n"+nextChar});text=text.replace(/~0/,"");return text}function hashBlock(text){text=text.replace(/(^\n+|\n+$)/g,"");return"\n\n~K"+(g_html_blocks.push(text)-1)Line truncated
|
||||
}function _DoCodeSpans(text){text=text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(wholeMatch,m1,m2,m3,m4){var c=m3;c=c.replace(/^([ \t]*)/g,"");c=c.replace(/[ \t]*$/g,"");c=_EncodeCode(c);c=c.replace(/:\/\//g,"~P");return m1+"<code>"+c+"</code>"});return text}function _EncodeCode(text){text=text.replace(/&/g,"&");text=text.replace(/</g,"<");text=text.replace(/>/g,">");text=escapeCharacters(text,"*_{}[]\\",false);return text}function _DoItalicsAndBold(text){text=text.replace(/([\W_]|^)(\*\*|__)(?=\S)([^\r]*?\S[\*_]*)\2([\W_]|$)/g,"$1<strong>$3</strong>$4");text=text.replace(/([\W_]|^)(\*|_)(?=\S)([^\r\*_]*?\S)\2([\W_]|$)/g,"$1<em>$3</em>$4");return text}function _DoBlockQuotes(text){text=text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(wholeMatch,m1){var bq=m1;bq=bq.replace(/^[ \t]*>[ \t]?/gm,"~0");bq=bq.replace(/~0/g,"");bq=bq.replace(/^[ \t]+$/gm,"");bq=_RunBlockGamut(bq);bq=bq.replace(/(^|\n)/g,"$1 ");bq=bq.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(wholeMatch,m1){var pre=m1;pre=pre.replace(/^ /mg,"~0");pre=pre.replace(/~0/g,"");return pre});return hashBlock("<blockquote>\n"+bq+"\n</blockquote>")});return text}function _FormParagraphs(text,doNotUnhash){text=text.replace(/^\n+/g,"");text=text.replace(/\n+$/g,"");var grafs=text.split(/\n{2,}/g);var grafsOut=[];var markerRe=/~K(\d+)K/;var end=grafs.length;for(var i=0;i<end;i++){var str=grafs[i];if(markerRe.test(str)){grafsOut.push(str)}else{if(/\S/.test(str)){str=_RunSpanGamut(str);str=str.replace(/^([ \t]*)/g,"<p>");str+="</p>";grafsOut.push(str)}}}if(!doNotUnhash){end=grafsOut.length;for(var i=0;i<end;i++){var foundAny=true;while(foundAny){foundAny=false;grafsOut[i]=grafsOut[i].replace(/~K(\d+)K/g,function(wholeMatch,id){foundAny=true;return g_html_blocks[id]})}}}return grafsOut.join("\n\n")}function _EncodeAmpsAndAngles(text){text=text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&");text=text.replace(/<(?![a-z\/?!]|~D)/gi,"<");return text}function _EncodeBackslashEscapes(text){text=text.replace(/\\(\\)/g,escapeCharacters_callback);text=text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback);return text}var charInsideUrl="[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]",charEndingUrl="[-A-Z0-9+&@#/%=~_|[\\])]",autoLinkRegex=new RegExp('(="|<)?\\b(https?|ftp)(://'+charInsideUrl+"*"+charEndingUrl+")(?=$|\\W)","gi"),endCharRegex=new RegExp(charEndingUrl,"i");function handleTrailingParens(wholeMatch,lookbehind,protocol,link){if(lookbehind){return wholeMatch}if(link.charAt(link.length-1)!==")"){return"<"+protocol+link+">"}var parens=link.match(/[()]/g);var level=0;for(var i=0;i<parens.length;i++){if(parens[i]==="("){if(level<=0){level=1}else{level++}}else{level--}}var tail="";if(level<0){var re=new RegExp("\\){1,"+(-level)+"}$");link=link.replace(re,function(trailingParens){tail=trailingParens;return""})}if(tail){var lastChar=link.charAt(link.length-1);if(!endCharRegex.test(lastChar)){tail=lastChar+tail;link=link.substr(0,link.length-1)}}return"<"+protocol+link+">"+tail}function _DoAutoLinks(text){text=text.replace(autoLinkRegex,handleTrailingParens);var replacer=function(wholematch,m1){return'<a href="'+m1+'">'+pluginHooks.plainLinkText(m1)+"</a>"};text=text.replace(/<((https?|ftp):[^'">\s]+)>/gi,replacer);return text}function _UnescapeSpecialChars(text){text=text.replace(/~E(\d+)E/g,function(wholeMatch,m1){var charCodeToReplace=parseInt(m1);return String.fromCharCode(charCodeToReplace)});return text}function _Outdent(text){text=text.replace(/^(\t|[ ]{1,4})/gm,"~0");text=text.replace(/~0/g,"");return text}function _Detab(text){if(!/\t/.test(text)){return text}var spaces=[" "," "," "," "],skew=0,v;return text.replace(/[\n\t]/g,function(match,offset){if(match==="\n"){skew=offset+1;return match}v=(offset-skew)%4;skew=offset+1;return spaces[v]})}var _problemUrlChars=/(?:["'*()[\]:]|~D)/g;function encodeProblemUrlChars(url){if(!url){return""}var len=url.length;return url.replace(_problemUrlChars,function(match,offset){if(match=="~D"){return"%24"}if(match==":"){return":"}return"%"+match.charCodeAt(0).toString(16)})}function escapeCharacters(text,charsToEscape,afterBackslash){var regexString="(["+charsToEscape.replace(/([\[\]\\])/g,"\\$1")+"])";if(afterBackslash){regexString="\\\\"+regexString}var regex=new RegExp(regexString,"g");text=text.replace(regex,escapeCharacters_callback);return text}function escapeCharacters_callback(wholeMatch,m1){var charCodeToEscape=m1.charCodeAt(0);return"~E"+charCodeToEscape+"E"}}})();
|
||||
|
||||
// Markdown.Extra.js
|
||||
(function(){var inlineTags=new RegExp(["^(<\\/?(a|abbr|acronym|applet|area|b|basefont|","bdo|big|button|cite|code|del|dfn|em|figcaption|","font|i|iframe|img|input|ins|kbd|label|map|","mark|meter|object|param|progress|q|ruby|rp|rt|s|","samp|script|select|small|span|strike|strong|","sub|sup|textarea|time|tt|u|var|wbr)[^>]*>|","<(br)\\s?\\/?>)$"].join(""),"i");if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]==obj){return i}}return -1}}function trim(str){return str.replace(/^\s+|\s+$/g,"")}function rtrim(str){return str.replace(/\s+$/g,"")}function outdent(text){return text.replace(new RegExp("^(\\t|[ ]{1,4})","gm"),"")}function contains(str,substr){return str.indexOf(substr)!=-1}function sanitizeHtml(html,whitelist){return html.replace(/<[^>]*>?/gi,function(tag){return tag.match(whitelist)?tag:""})}function union(x,y){var obj={};for(var i=0;i<x.length;i++){obj[x[i]]=x[i]}for(i=0;i<y.length;i++){obj[y[i]]=y[i]}var res=[];for(var k in obj){if(obj.hasOwnProperty(k)){res.push(obj[k])}}return res}function addAnchors(text){if(text.charAt(0)!="\x02"){text="\x02"+text}if(text.charAt(text.length-1)!="\x03"){text=text+"\x03"}return text}function removeAnchors(text){if(text.charAt(0)=="\x02"){text=text.substr(1)}if(text.charAt(text.length-1)=="\x03"){text=text.substr(0,text.length-1)}return text}function convertSpans(text,extra){return sanitizeHtml(convertAll(text,extra),inlineTags)}function convertAll(text,extra){var result=extra.blockGamutHookCallback(text);result=unescapeSpecialChars(result);result=result.replace(/~D/g,"$$").replace(/~T/g,"~");result=extra.previousPostConversion(result);return result}function processEscapesStep1(text){return text.replace(/\\\|/g,"~I").replace(/\\:/g,"~i")}function processEscapesStep2(text){return text.replace(/~I/g,"|").replace(/~i/g,":")}function unescapeSpecialChars(text){text=text.replace(/~E(\d+)E/g,function(wholeMatch,m1){var charCodeToReplace=parseInt(m1);return String.fromCharCode(charCodeToReplace)});return text}function slugify(text){return text.toLowerCase().replace(/\s+/g,"-").replace(/[^\w\-]+/g,"").replace(/\-\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"")}Markdown.Extra=function(){this.converter=null;this.hashBlocks=[];this.footnotes={};this.usedFootnotes=[];this.attributeBlocks=false;this.googleCodePrettify=false;this.highlightJs=false;this.tableClass="";this.tabWidth=4};Markdown.Extra.init=function(converter,options){var extra=new Markdown.Extra();var postNormalizationTransformations=[];var preBlockGamutTransformations=[];var postSpanGamutTransformations=[];var postConversionTransformations=["unHashExtraBlocks"];options=options||{};options.extensions=options.extensions||["all"];if(contains(options.extensions,"all")){options.extensions=["tables","fenced_code_gfm","def_list","attr_list","footnotes","smartypants","strikethrough","newlines"]}preBlockGamutTransformations.push("wrapHeaders");if(contains(options.extensions,"attr_list")){postNormalizationTransformations.push("hashFcbAttributeBlocks");preBlockGamutTransformations.push("hashHeaderAttributeBlocks");postConversionTransformations.push("applyAttributeBlocks");extra.attributeBlocks=true}if(contains(options.extensions,"fenced_code_gfm")){preBlockGamutTransformations.push("fencedCodeBlocks");postNormalizationTransformations.push("fencedCodeBlocks")}if(contains(options.extensions,"tables")){preBlockGamutTransformations.push("tables")}if(contains(options.extensions,"def_list")){preBlockGamutTransformations.push("definitionLists")}if(contains(options.extensions,"footnotes")){postNormalizationTransformations.push("stripFootnoteDefinitions");preBlockGamutTransformations.push("doFootnotes");postConversionTransformations.push("printFootnotes")}if(contains(options.extensions,"smartypants")){postConversionTransformations.push("runSmartyPants")}if(contains(options.extensions,"strikethrough")){postSpanGamutTransformations.push("strikethrough")}if(contains(options.extensions,"newlines")){postSpanGamutTransformations.push("newlines")}converter.hooks.chain("postNormalization",function(text){return extra.doTransform(postNormalizationTransformations,text)+"\n"});converter.hooks.chain("preBlockGamut",function(text,blockGamutHookCallback){extra.blockGamutHookCallback=blockGamutHookCallback;text=processEscapesStep1(text);text=extra.doTransform(preBlockGamutTransformations,text)+"\n";text=processEscapesStep2(text);return text});converter.hooks.chain("postSpanGamut",function(text){return extra.doTransform(postSpanGamutTransformations,text)});extra.previousPostConversion=converter.hooks.postConversion;converter.hooks.chain("postConversion",function(text){text=extra.doTransform(postConversionTransformations,text);extra.hashBlocks=[];extra.footnotes={};extra.usedFootnotes=[];return text});if("highlighter" in options){extra.googleCodePrettify=options.highlighter==="prettify";extra.highlightJs=options.highlighter==="highlight"}if("table_class" in options){extra.tableClass=options.table_class}extLine truncated
|
||||
return extra};Markdown.Extra.prototype.doTransform=function(transformations,text){for(var i=0;i<transformations.length;i++){text=this[transformations[i]](text)}return text};Markdown.Extra.prototype.hashExtraBlock=function(block){return"\n<p>~X"+(this.hashBlocks.push(block)-1)+"X</p>\n"};Markdown.Extra.prototype.hashExtraInline=function(block){return"~X"+(this.hashBlocks.push(block)-1)+"X"};Markdown.Extra.prototype.unHashExtraBlocks=function(text){var self=this;function recursiveUnHash(){var hasHash=false;text=text.replace(/(?:<p>)?~X(\d+)X(?:<\/p>)?/g,function(wholeMatch,m1){hasHash=true;var key=parseInt(m1,10);return self.hashBlocks[key]});if(hasHash===true){recursiveUnHash()}}recursiveUnHash();return text};Markdown.Extra.prototype.wrapHeaders=function(text){function wrap(text){return"\n"+text+"\n"}text=text.replace(/^.+[ \t]*\n=+[ \t]*\n+/gm,wrap);text=text.replace(/^.+[ \t]*\n-+[ \t]*\n+/gm,wrap);text=text.replace(/^\#{1,6}[ \t]*.+?[ \t]*\#*\n+/gm,wrap);return text};var attrBlock="\\{[ \\t]*((?:[#.][-_:a-zA-Z0-9]+[ \\t]*)+)\\}";var hdrAttributesA=new RegExp("^(#{1,6}.*#{0,6})[ \\t]+"+attrBlock+"[ \\t]*(?:\\n|0x03)","gm");var hdrAttributesB=new RegExp("^(.*)[ \\t]+"+attrBlock+"[ \\t]*\\n"+"(?=[\\-|=]+\\s*(?:\\n|0x03))","gm");var fcbAttributes=new RegExp("^(```[^`\\n]*)[ \\t]+"+attrBlock+"[ \\t]*\\n"+"(?=([\\s\\S]*?)\\n```[ \\t]*(\\n|0x03))","gm");Markdown.Extra.prototype.hashHeaderAttributeBlocks=function(text){var self=this;function attributeCallback(wholeMatch,pre,attr){return"<p>~XX"+(self.hashBlocks.push(attr)-1)+"XX</p>\n"+pre+"\n"}text=text.replace(hdrAttributesA,attributeCallback);text=text.replace(hdrAttributesB,attributeCallback);return text};Markdown.Extra.prototype.hashFcbAttributeBlocks=function(text){var self=this;function attributeCallback(wholeMatch,pre,attr){return"<p>~XX"+(self.hashBlocks.push(attr)-1)+"XX</p>\n"+pre+"\n"}return text.replace(fcbAttributes,attributeCallback)};Markdown.Extra.prototype.applyAttributeBlocks=function(text){var self=this;var blockRe=new RegExp("<p>~XX(\\d+)XX</p>[\\s]*"+'(?:<(h[1-6]|pre)(?: +class="(\\S+)")?(>[\\s\\S]*?</\\2>))',"gm");text=text.replace(blockRe,function(wholeMatch,k,tag,cls,rest){if(!tag){return""}var key=parseInt(k,10);var attributes=self.hashBlocks[key];var id=attributes.match(/#[^\s#.]+/g)||[];var idStr=id[0]?' id="'+id[0].substr(1,id[0].length-1)+'"':"";var classes=attributes.match(/\.[^\s#.]+/g)||[];for(var i=0;i<classes.length;i++){classes[i]=classes[i].substr(1,classes[i].length-1)}var classStr="";if(cls){classes=union(classes,[cls])}if(classes.length>0){classStr=' class="'+classes.join(" ")+'"'}return"<"+tag+idStr+classStr+rest});return text};Markdown.Extra.prototype.tables=function(text){var self=this;var leadingPipe=new RegExp(["^","[ ]{0,3}","[|]","(.+)\\n","[ ]{0,3}","[|]([ ]*[-:]+[-| :]*)\\n","(","(?:[ ]*[|].*\\n?)*",")","(?:\\n|$)"].join(""),"gm");var noLeadingPipe=new RegExp(["^","[ ]{0,3}","(\\S.*[|].*)\\n","[ ]{0,3}","([-:]+[ ]*[|][-| :]*)\\n","(","(?:.*[|].*\\n?)*",")","(?:\\n|$)"].join(""),"gm");text=text.replace(leadingPipe,doTable);text=text.replace(noLeadingPipe,doTable);function doTable(match,header,separator,body,offset,string){header=header.replace(/^ *[|]/m,"");separator=separator.replace(/^ *[|]/m,"");body=body.replace(/^ *[|]/gm,"");header=header.replace(/[|] *$/m,"");separator=separator.replace(/[|] *$/m,"");body=body.replace(/[|] *$/gm,"");alignspecs=separator.split(/ *[|] */);align=[];for(var i=0;i<alignspecs.length;i++){var spec=alignspecs[i];if(spec.match(/^ *-+: *$/m)){align[i]=' align="right"'}else{if(spec.match(/^ *:-+: *$/m)){align[i]=' align="center"'}else{if(spec.match(/^ *:-+ *$/m)){align[i]=' align="left"'}else{align[i]=""}}}}var headers=header.split(/ *[|] */);var colCount=headers.length;var cls=self.tableClass?' class="'+self.tableClass+'"':"";var html=["<table",cls,">\n","<thead>\n","<tr>\n"].join("");for(i=0;i<colCount;i++){var headerHtml=convertSpans(trim(headers[i]),self);html+=[" <th",align[i],">",headerHtml,"</th>\n"].join("")}html+="</tr>\n</thead>\n";var rows=body.split("\n");for(i=0;i<rows.length;i++){if(rows[i].match(/^\s*$/)){continue}var rowCells=rows[i].split(/ *[|] */);var lenDiff=colCount-rowCells.length;for(var j=0;j<lenDiff;j++){rowCells.push("")}html+="<tr>\n";for(j=0;j<colCount;j++){var colHtml=convertSpans(trim(rowCells[j]),self);html+=[" <td",align[j],">",colHtml,"</td>\n"].join("")}html+="</tr>\n"}html+="</table>\n";return self.hashExtraBlock(html)}return text};Markdown.Extra.prototype.stripFootnoteDefinitions=function(text){var self=this;text=text.replace(/\n[ ]{0,3}\[\^(.+?)\]\:[ \t]*\n?([\s\S]*?)\n{1,2}((?=\n[ ]{0,3}\S)|$)/g,function(wholeMatch,m1,m2){m1=slugify(m1);m2+="\n";m2=m2.replace(/^[ ]{0,3}/g,"");self.footnotes[m1]=m2;return"\n"});return text};Markdown.Extra.prototype.doFootnotes=function(text){var self=this;if(self.isConvertingFootnote===true){return text}var footnoteCounter=0;text=text.replace(/\[\^(.+?)\]/g,function(wholeMatch,m1){var id=slugify(m1);var footnote=sLine truncated
|
||||
if(footnote===undefined){return wholeMatch}footnoteCounter++;self.usedFootnotes.push(id);var html='<a href="#fn:'+id+'" id="fnref:'+id+'" title="See footnote" class="footnote">'+footnoteCounter+"</a>";return self.hashExtraInline(html)});return text};Markdown.Extra.prototype.printFootnotes=function(text){var self=this;if(self.usedFootnotes.length===0){return text}text+='\n\n<div class="footnotes">\n<hr>\n<ol>\n\n';for(var i=0;i<self.usedFootnotes.length;i++){var id=self.usedFootnotes[i];var footnote=self.footnotes[id];self.isConvertingFootnote=true;var formattedfootnote=convertSpans(footnote,self);delete self.isConvertingFootnote;text+='<li id="fn:'+id+'">'+formattedfootnote+' <a href="#fnref:'+id+'" title="Return to article" class="reversefootnote">↩</a></li>\n\n'}text+="</ol>\n</div>";return text};Markdown.Extra.prototype.fencedCodeBlocks=function(text){function encodeCode(code){code=code.replace(/&/g,"&");code=code.replace(/</g,"<");code=code.replace(/>/g,">");code=code.replace(/~D/g,"$$");code=code.replace(/~T/g,"~");return code}var self=this;text=text.replace(/(?:^|\n)```([^`\n]*)\n([\s\S]*?)\n```[ \t]*(?=\n)/g,function(match,m1,m2){var language=trim(m1),codeblock=m2;var preclass=self.googleCodePrettify?' class="prettyprint"':"";var codeclass="";if(language){if(self.googleCodePrettify||self.highlightJs){codeclass=' class="language-'+language+'"'}else{codeclass=' class="'+language+'"'}}var html=["<pre",preclass,"><code",codeclass,">",encodeCode(codeblock),"</code></pre>"].join("");return self.hashExtraBlock(html)});return text};Markdown.Extra.prototype.educatePants=function(text){var self=this;var result="";var blockOffset=0;text.replace(/(?:<!--[\s\S]*?-->)|(<)([a-zA-Z1-6]+)([^\n]*?>)([\s\S]*?)(<\/\2>)/g,function(wholeMatch,m1,m2,m3,m4,m5,offset){var token=text.substring(blockOffset,offset);result+=self.applyPants(token);self.smartyPantsLastChar=result.substring(result.length-1);blockOffset=offset+wholeMatch.length;if(!m1){result+=wholeMatch;return}if(!/code|kbd|pre|script|noscript|iframe|math|ins|del|pre/i.test(m2)){m4=self.educatePants(m4)}else{self.smartyPantsLastChar=m4.substring(m4.length-1)}result+=m1+m2+m3+m4+m5});var lastToken=text.substring(blockOffset);result+=self.applyPants(lastToken);self.smartyPantsLastChar=result.substring(result.length-1);return result};function revertPants(wholeMatch,m1){var blockText=m1;blockText=blockText.replace(/&\#8220;/g,'"');blockText=blockText.replace(/&\#8221;/g,'"');blockText=blockText.replace(/&\#8216;/g,"'");blockText=blockText.replace(/&\#8217;/g,"'");blockText=blockText.replace(/&\#8212;/g,"---");blockText=blockText.replace(/&\#8211;/g,"--");blockText=blockText.replace(/&\#8230;/g,"...");return blockText}Markdown.Extra.prototype.applyPants=function(text){text=text.replace(/---/g,"—").replace(/--/g,"–");text=text.replace(/\.\.\./g,"…").replace(/\.\s\.\s\./g,"…");text=text.replace(/``/g,"“").replace(/''/g,"”");if(/^'$/.test(text)){if(/\S/.test(this.smartyPantsLastChar)){return"’"}return"‘"}if(/^"$/.test(text)){if(/\S/.test(this.smartyPantsLastChar)){return"”"}return"“"}text=text.replace(/^'(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/,"’");text=text.replace(/^"(?=[!"#\$\%'()*+,\-.\/:;<=>?\@\[\\]\^_`{|}~]\B)/,"”");text=text.replace(/"'(?=\w)/g,"“‘");text=text.replace(/'"(?=\w)/g,"‘“");text=text.replace(/'(?=\d{2}s)/g,"’");text=text.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)'(?=\w)/g,"$1‘");text=text.replace(/([^\s\[\{\(\-])'/g,"$1’");text=text.replace(/'(?=\s|s\b)/g,"’");text=text.replace(/'/g,"‘");text=text.replace(/(\s| |--|&[mn]dash;|&\#8211;|&\#8212;|&\#x201[34];)"(?=\w)/g,"$1“");text=text.replace(/([^\s\[\{\(\-])"/g,"$1”");text=text.replace(/"(?=\s)/g,"”");text=text.replace(/"/ig,"“");return text};Markdown.Extra.prototype.runSmartyPants=function(text){this.smartyPantsLastChar="";text=this.educatePants(text);text=text.replace(/(<([a-zA-Z1-6]+)\b([^\n>]*?)(\/)?>)/g,revertPants);return text};Markdown.Extra.prototype.definitionLists=function(text){var wholeList=new RegExp(["(\\x02\\n?|\\n\\n)","(?:","(","(","[ ]{0,3}","((?:[ \\t]*\\S.*\\n)+)","\\n?","[ ]{0,3}:[ ]+",")","([\\s\\S]+?)","(","(?=\\0x03)","|","(?=","\\n{2,}","(?=\\S)","(?!","[ ]{0,3}","(?:\\S.*\\n)+?","\\n?","[ ]{0,3}:[ ]+",")","(?!","[ ]{0,3}:[ ]+",")",")",")",")",")"].join(""),"gm");var self=this;text=addAnchors(text);text=text.replace(wholeList,function(match,pre,list){var result=trim(self.processDefListItems(list));result="<dl>\n"+result+"\n</dl>";return pre+self.hashExtraBlock(result)+"\n\n"});return removeAnchors(text)};Markdown.Extra.prototype.processDefListItems=function(listStr){var self=this;var dt=new RegExp(["(\\x02\\n?|\\n\\n+)","(","[ ]{0,3}","(?![:][ ]|[ ])","(?:\\S.*\\n)+?",")","(?=\\n?[ ]{0,3}:[ ])"].join(""),"gm");var dd=new RegExp(["\\n(\\n+)?","(","[ ]{0,3}","[:][ ]+",")","([\\s\\S]Line truncated
|
||||
listStr=addAnchors(listStr);listStr=listStr.replace(/\n{2,}(?=\\x03)/,"\n");listStr=listStr.replace(dt,function(match,pre,termsStr){var terms=trim(termsStr).split("\n");var text="";for(var i=0;i<terms.length;i++){var term=terms[i];term=convertSpans(trim(term),self);text+="\n<dt>"+term+"</dt>"}return text+"\n"});listStr=listStr.replace(dd,function(match,leadingLine,markerSpace,def){if(leadingLine||def.match(/\n{2,}/)){def=Array(markerSpace.length+1).join(" ")+def;def=outdent(def)+"\n\n";def="\n"+convertAll(def,self)+"\n"}else{def=rtrim(def);def=convertSpans(outdent(def),self)}return"\n<dd>"+def+"</dd>\n"});return removeAnchors(listStr)};Markdown.Extra.prototype.strikethrough=function(text){return text.replace(/([\W_]|^)~T~T(?=\S)([^\r]*?\S[\*_]*)~T~T([\W_]|$)/g,"$1<del>$2</del>$3")};Markdown.Extra.prototype.newlines=function(text){return text.replace(/(<(?:br|\/li)>)?\n/g,function(wholeMatch,previousTag){return previousTag?wholeMatch:" <br>\n"})}})();
|
||||
|
||||
|
||||
(function() {
|
||||
|
||||
// Create the converter and the editor
|
||||
var converter = new Markdown.Converter();
|
||||
var options = {
|
||||
_DoItalicsAndBold: function(text) {
|
||||
// Restore original markdown implementation
|
||||
text = text.replace(/(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\1/g,
|
||||
"<strong>$2</strong>");
|
||||
text = text.replace(/(\*|_)(?=\S)(.+?)(?=\S)\1/g,
|
||||
"<em>$2</em>");
|
||||
return text;
|
||||
}
|
||||
};
|
||||
converter.setOptions(options);
|
||||
|
||||
function loadJs(src, callback) {
|
||||
var _doc = document.getElementsByTagName('head')[0];
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('type', 'text/javascript');
|
||||
script.setAttribute('src', src);
|
||||
_doc.appendChild(script);
|
||||
script.onload = script.onreadystatechange = function() {
|
||||
if(!this.readyState || this.readyState=='loaded' || this.readyState=='complete'){
|
||||
callback && callback();
|
||||
}
|
||||
script.onload = script.onreadystatechange = null;
|
||||
}
|
||||
}
|
||||
|
||||
function _each(list, callback) {
|
||||
if(list && list.length > 0) {
|
||||
for(var i = 0; i < list.length; i++) {
|
||||
callback(list[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
function _has(obj, key) {
|
||||
return hasOwnProperty.call(obj, key);
|
||||
};
|
||||
|
||||
// markdown extra
|
||||
function initMarkdownExtra() {
|
||||
// Create the converter and the editor
|
||||
// var converter = new Markdown.Converter();
|
||||
var options = {
|
||||
_DoItalicsAndBold: function(text) {
|
||||
// Restore original markdown implementation
|
||||
text = text.replace(/(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\1/g,
|
||||
"<strong>$2</strong>");
|
||||
text = text.replace(/(\*|_)(?=\S)(.+?)(?=\S)\1/g,
|
||||
"<em>$2</em>");
|
||||
return text;
|
||||
}
|
||||
};
|
||||
converter.setOptions(options);
|
||||
|
||||
//================
|
||||
// markdown exstra
|
||||
|
||||
var markdownExtra = {};
|
||||
markdownExtra.config = {
|
||||
extensions: [
|
||||
"fenced_code_gfm",
|
||||
"tables",
|
||||
"def_list",
|
||||
"attr_list",
|
||||
"footnotes",
|
||||
"smartypants",
|
||||
"strikethrough",
|
||||
"newlines"
|
||||
],
|
||||
intraword: true,
|
||||
comments: true,
|
||||
highlighter: "highlight"
|
||||
};
|
||||
var extraOptions = {
|
||||
extensions: markdownExtra.config.extensions,
|
||||
highlighter: "prettify"
|
||||
};
|
||||
|
||||
if(markdownExtra.config.intraword === true) {
|
||||
var converterOptions = {
|
||||
_DoItalicsAndBold: function(text) {
|
||||
text = text.replace(/([^\w*]|^)(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\2(?=[^\w*]|$)/g, "$1<strong>$3</strong>");
|
||||
text = text.replace(/([^\w*]|^)(\*|_)(?=\S)(.+?)(?=\S)\2(?=[^\w*]|$)/g, "$1<em>$3</em>");
|
||||
// Redo bold to handle _**word**_
|
||||
text = text.replace(/([^\w*]|^)(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\2(?=[^\w*]|$)/g, "$1<strong>$3</strong>");
|
||||
return text;
|
||||
}
|
||||
};
|
||||
converter.setOptions(converterOptions);
|
||||
}
|
||||
|
||||
if(markdownExtra.config.comments === true) {
|
||||
converter.hooks.chain("postConversion", function(text) {
|
||||
return text.replace(/<!--.*?-->/g, function(wholeMatch) {
|
||||
return wholeMatch.replace(/^<!---(.+?)-?-->$/, ' <span class="comment label label-danger">$1</span> ');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Markdown.Extra.init(converter, extraOptions);
|
||||
}
|
||||
|
||||
//==============
|
||||
// toc start
|
||||
|
||||
function initToc() {
|
||||
var toc = {};
|
||||
toc.config = {
|
||||
marker: "\\[(TOC|toc)\\]",
|
||||
maxDepth: 6,
|
||||
button: true,
|
||||
};
|
||||
|
||||
// TOC element description
|
||||
function TocElement(tagName, anchor, text) {
|
||||
this.tagName = tagName;
|
||||
this.anchor = anchor;
|
||||
this.text = text;
|
||||
this.children = [];
|
||||
}
|
||||
TocElement.prototype.childrenToString = function() {
|
||||
if(this.children.length === 0) {
|
||||
return "";
|
||||
}
|
||||
var result = "<ul>\n";
|
||||
_each(this.children, function(child) {
|
||||
result += child.toString();
|
||||
});
|
||||
result += "</ul>\n";
|
||||
return result;
|
||||
};
|
||||
TocElement.prototype.toString = function() {
|
||||
var result = "<li>";
|
||||
if(this.anchor && this.text) {
|
||||
result += '<a href="#' + this.anchor + '">' + this.text + '</a>';
|
||||
}
|
||||
result += this.childrenToString() + "</li>\n";
|
||||
return result;
|
||||
};
|
||||
|
||||
// Transform flat list of TocElement into a tree
|
||||
function groupTags(array, level) {
|
||||
level = level || 1;
|
||||
var tagName = "H" + level;
|
||||
var result = [];
|
||||
|
||||
var currentElement;
|
||||
function pushCurrentElement() {
|
||||
if(currentElement !== undefined) {
|
||||
if(currentElement.children.length > 0) {
|
||||
currentElement.children = groupTags(currentElement.children, level + 1);
|
||||
}
|
||||
result.push(currentElement);
|
||||
}
|
||||
}
|
||||
|
||||
_each(array, function(element) {
|
||||
if(element.tagName != tagName) {
|
||||
if(level !== toc.config.maxDepth) {
|
||||
if(currentElement === undefined) {
|
||||
currentElement = new TocElement();
|
||||
}
|
||||
currentElement.children.push(element);
|
||||
}
|
||||
}
|
||||
else {
|
||||
pushCurrentElement();
|
||||
currentElement = element;
|
||||
}
|
||||
});
|
||||
pushCurrentElement();
|
||||
return result;
|
||||
}
|
||||
|
||||
var utils = {};
|
||||
var nonWordChars = new RegExp('[^\\p{L}\\p{N}-]', 'g');
|
||||
utils.slugify = function(text) {
|
||||
return text.toLowerCase().replace(/\s/g, '-') // Replace spaces with -
|
||||
.replace(nonWordChars, '') // Remove all non-word chars
|
||||
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
||||
.replace(/^-+/, '') // Trim - from start of text
|
||||
.replace(/-+$/, ''); // Trim - from end of text
|
||||
};
|
||||
|
||||
// Build the TOC
|
||||
var previewContentsElt;
|
||||
function buildToc(previewContentsElt) {
|
||||
var anchorList = {};
|
||||
function createAnchor(element) {
|
||||
var id = element.id || utils.slugify(element.textContent) || 'title';
|
||||
var anchor = id;
|
||||
var index = 0;
|
||||
while (_has(anchorList, anchor)) {
|
||||
anchor = id + "-" + (++index);
|
||||
}
|
||||
anchorList[anchor] = true;
|
||||
// Update the id of the element
|
||||
element.id = anchor;
|
||||
return anchor;
|
||||
}
|
||||
|
||||
var elementList = [];
|
||||
_each(previewContentsElt.querySelectorAll('h1, h2, h3, h4, h5, h6'), function(elt) {
|
||||
elementList.push(new TocElement(elt.tagName, createAnchor(elt), elt.textContent));
|
||||
});
|
||||
elementList = groupTags(elementList);
|
||||
return '<div class="toc">\n<ul>\n' + elementList.join("") + '</ul>\n</div>\n';
|
||||
}
|
||||
|
||||
toc.convert = function(previewContentsElt) {
|
||||
var tocExp = new RegExp("^\\s*" + toc.config.marker + "\\s*$");
|
||||
var tocEltList = document.querySelectorAll('.table-of-contents, .toc');
|
||||
var htmlToc = buildToc(previewContentsElt);
|
||||
// Replace toc paragraphs
|
||||
_each(previewContentsElt.getElementsByTagName('p'), function(elt) {
|
||||
if(tocExp.test(elt.innerHTML)) {
|
||||
elt.innerHTML = htmlToc;
|
||||
}
|
||||
});
|
||||
// Add toc in the TOC button
|
||||
_each(tocEltList, function(elt) {
|
||||
elt.innerHTML = htmlToc;
|
||||
});
|
||||
}
|
||||
|
||||
return toc;
|
||||
}
|
||||
|
||||
//===========
|
||||
// mathjax
|
||||
function initMathJax() {
|
||||
// 配置
|
||||
MathJax.Hub.Config({
|
||||
skipStartupTypeset: true,
|
||||
"HTML-CSS": {
|
||||
preferredFont: "TeX",
|
||||
availableFonts: [
|
||||
"STIX",
|
||||
"TeX"
|
||||
],
|
||||
linebreaks: {
|
||||
automatic: true
|
||||
},
|
||||
EqnChunk: 10,
|
||||
imageFont: null
|
||||
},
|
||||
tex2jax: { inlineMath: [["$","$"],["\\\\(","\\\\)"]], displayMath: [["$$","$$"],["\\[","\\]"]], processEscapes: true },
|
||||
TeX: {
|
||||
noUndefined: {
|
||||
attributes: {
|
||||
mathcolor: "red",
|
||||
mathbackground: "#FFEEEE",
|
||||
mathsize: "90%"
|
||||
}
|
||||
},
|
||||
Safe: {
|
||||
allow: {
|
||||
URLs: "safe",
|
||||
classes: "safe",
|
||||
cssIDs: "safe",
|
||||
styles: "safe",
|
||||
fontsize: "all"
|
||||
}
|
||||
}
|
||||
},
|
||||
messageStyle: "none"
|
||||
});
|
||||
|
||||
var mathJax = {};
|
||||
mathJax.config = {
|
||||
tex : "{}",
|
||||
tex2jax: '{ inlineMath: [["$","$"],["\\\\\\\\(","\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true }'
|
||||
};
|
||||
|
||||
mathJax.init = function(p) {
|
||||
converter.hooks.chain("preConversion", removeMath);
|
||||
converter.hooks.chain("postConversion", replaceMath);
|
||||
};
|
||||
|
||||
// From math.stackexchange.com...
|
||||
|
||||
//
|
||||
// The math is in blocks i through j, so
|
||||
// collect it into one block and clear the others.
|
||||
// Replace &, <, and > by named entities.
|
||||
// For IE, put <br> at the ends of comments since IE removes \n.
|
||||
// Clear the current math positions and store the index of the
|
||||
// math, then push the math string onto the storage array.
|
||||
//
|
||||
function processMath(i, j, unescape) {
|
||||
var block = blocks.slice(i, j + 1).join("")
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">");
|
||||
for(HUB.Browser.isMSIE && (block = block.replace(/(%[^\n]*)\n/g, "$1<br/>\n")); j > i;)
|
||||
blocks[j] = "", j--;
|
||||
blocks[i] = "@@" + math.length + "@@";
|
||||
unescape && (block = unescape(block));
|
||||
math.push(block);
|
||||
start = end = last = null;
|
||||
}
|
||||
|
||||
function removeMath(text) {
|
||||
if(!text) {
|
||||
return;
|
||||
}
|
||||
start = end = last = null;
|
||||
math = [];
|
||||
var unescape;
|
||||
if(/`/.test(text)) {
|
||||
text = text.replace(/~/g, "~T").replace(/(^|[^\\])(`+)([^\n]*?[^`\n])\2(?!`)/gm, function(text) {
|
||||
return text.replace(/\$/g, "~D")
|
||||
});
|
||||
unescape = function(text) {
|
||||
return text.replace(/~([TD])/g,
|
||||
function(match, n) {
|
||||
return {T: "~", D: "$"}[n]
|
||||
})
|
||||
};
|
||||
} else {
|
||||
unescape = function(text) {
|
||||
return text
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// The pattern for math delimiters and special symbols
|
||||
// needed for searching for math in the page.
|
||||
//
|
||||
var splitDelimiter = /(\$\$?|\\(?:begin|end)\{[a-z]*\*?\}|\\[\\{}$]|[{}]|(?:\n\s*)+|@@\d+@@)/i;
|
||||
var split;
|
||||
|
||||
if(3 === "aba".split(/(b)/).length) {
|
||||
split = function(text, delimiter) {
|
||||
return text.split(delimiter)
|
||||
};
|
||||
} else {
|
||||
split = function(text, delimiter) {
|
||||
var b = [], c;
|
||||
if(!delimiter.global) {
|
||||
c = delimiter.toString();
|
||||
var d = "";
|
||||
c = c.replace(/^\/(.*)\/([im]*)$/, function(a, c, b) {
|
||||
d = b;
|
||||
return c
|
||||
});
|
||||
delimiter = RegExp(c, d + "g")
|
||||
}
|
||||
for(var e = delimiter.lastIndex = 0; c = delimiter.exec(text);) {
|
||||
b.push(text.substring(e, c.index));
|
||||
b.push.apply(b, c.slice(1));
|
||||
e = c.index + c[0].length;
|
||||
}
|
||||
b.push(text.substring(e));
|
||||
return b
|
||||
};
|
||||
}
|
||||
|
||||
blocks = split(text.replace(/\r\n?/g, "\n"), splitDelimiter);
|
||||
for(var i = 1, m = blocks.length; i < m; i += 2) {
|
||||
var block = blocks[i];
|
||||
if("@" === block.charAt(0)) {
|
||||
//
|
||||
// Things that look like our math markers will get
|
||||
// stored and then retrieved along with the math.
|
||||
//
|
||||
blocks[i] = "@@" + math.length + "@@";
|
||||
math.push(block)
|
||||
} else if(start) {
|
||||
// Ignore inline maths that are actually multiline (fixes #136)
|
||||
if(end == inline && block.charAt(0) == '\n') {
|
||||
if(last) {
|
||||
i = last;
|
||||
processMath(start, i, unescape);
|
||||
}
|
||||
start = end = last = null;
|
||||
braces = 0;
|
||||
}
|
||||
//
|
||||
// If we are in math, look for the end delimiter,
|
||||
// but don't go past double line breaks, and
|
||||
// and balance braces within the math.
|
||||
//
|
||||
else if(block === end) {
|
||||
if(braces) {
|
||||
last = i
|
||||
} else {
|
||||
processMath(start, i, unescape)
|
||||
}
|
||||
} else {
|
||||
if(block.match(/\n.*\n/)) {
|
||||
if(last) {
|
||||
i = last;
|
||||
processMath(start, i, unescape);
|
||||
}
|
||||
start = end = last = null;
|
||||
braces = 0;
|
||||
} else {
|
||||
if("{" === block) {
|
||||
braces++
|
||||
} else {
|
||||
"}" === block && braces && braces--
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(block === inline || "$$" === block) {
|
||||
start = i;
|
||||
end = block;
|
||||
braces = 0;
|
||||
} else {
|
||||
if("begin" === block.substr(1, 5)) {
|
||||
start = i;
|
||||
end = "\\end" + block.substr(6);
|
||||
braces = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
last && processMath(start, last, unescape);
|
||||
return unescape(blocks.join(""));
|
||||
}
|
||||
|
||||
//
|
||||
// Put back the math strings that were saved,
|
||||
// and clear the math array (no need to keep it around).
|
||||
//
|
||||
function replaceMath(text) {
|
||||
text = text.replace(/@@(\d+)@@/g, function(match, n) {
|
||||
return math[n]
|
||||
});
|
||||
math = null;
|
||||
return text
|
||||
}
|
||||
|
||||
//
|
||||
// This is run to restart MathJax after it has finished
|
||||
// the previous run (that may have been canceled)
|
||||
//
|
||||
function startMJ(toElem, callback) {
|
||||
var preview = toElem;
|
||||
pending = false;
|
||||
HUB.cancelTypeset = false;
|
||||
HUB.Queue([
|
||||
"Typeset",
|
||||
HUB,
|
||||
preview
|
||||
]);
|
||||
// 执行完后, 再执行
|
||||
HUB.Queue(function() {
|
||||
callback && callback();
|
||||
});
|
||||
}
|
||||
|
||||
var ready = false, pending = false, preview = null, inline = "$", blocks, start, end, last, braces, math, HUB = MathJax.Hub;
|
||||
|
||||
//
|
||||
// Runs after initial typeset
|
||||
//
|
||||
HUB.Queue(function() {
|
||||
ready = true;
|
||||
HUB.processUpdateTime = 50;
|
||||
HUB.Config({"HTML-CSS": {EqnChunk: 10, EqnChunkFactor: 1}, SVG: {EqnChunk: 10, EqnChunkFactor: 1}})
|
||||
});
|
||||
|
||||
mathJax.init();
|
||||
return {
|
||||
convert: startMJ
|
||||
}
|
||||
}
|
||||
|
||||
function initUml() {
|
||||
//===========
|
||||
// uml
|
||||
var umlDiagrams = {};
|
||||
umlDiagrams.config = {
|
||||
flowchartOptions: [
|
||||
'{',
|
||||
' "line-width": 2,',
|
||||
' "font-family": "sans-serif",',
|
||||
' "font-weight": "normal"',
|
||||
'}'
|
||||
].join('\n')
|
||||
};
|
||||
|
||||
var _loadUmlJs = false;
|
||||
|
||||
// callback 执行完后执行
|
||||
umlDiagrams.convert = function(target, callback) {
|
||||
var previewContentsElt = target;
|
||||
|
||||
var sequenceElems = previewContentsElt.querySelectorAll('.prettyprint > .language-sequence');
|
||||
var flowElems = previewContentsElt.querySelectorAll('.prettyprint > .language-flow');
|
||||
|
||||
function convert() {
|
||||
_each(sequenceElems, function(elt) {
|
||||
try {
|
||||
var diagram = Diagram.parse(elt.textContent);
|
||||
var preElt = elt.parentNode;
|
||||
var containerElt = crel('div', {
|
||||
class: 'sequence-diagram'
|
||||
});
|
||||
preElt.parentNode.replaceChild(containerElt, preElt);
|
||||
diagram.drawSVG(containerElt, {
|
||||
theme: 'simple'
|
||||
});
|
||||
}
|
||||
catch(e) {
|
||||
console.trace(e);
|
||||
}
|
||||
});
|
||||
_each(flowElems, function(elt) {
|
||||
try {
|
||||
|
||||
var chart = flowchart.parse(elt.textContent);
|
||||
var preElt = elt.parentNode;
|
||||
var containerElt = crel('div', {
|
||||
class: 'flow-chart'
|
||||
});
|
||||
preElt.parentNode.replaceChild(containerElt, preElt);
|
||||
chart.drawSVG(containerElt, JSON.parse(umlDiagrams.config.flowchartOptions));
|
||||
}
|
||||
catch(e) {
|
||||
console.error(e);
|
||||
}
|
||||
});
|
||||
|
||||
callback && callback();
|
||||
}
|
||||
|
||||
if(sequenceElems.length > 0 || flowElems.length > 0) {
|
||||
if(!_loadUmlJs) {
|
||||
loadJs('/public/libs/md2html/uml.js', function() {
|
||||
_loadUmlJs = true;
|
||||
convert();
|
||||
});
|
||||
} else {
|
||||
convert();
|
||||
}
|
||||
} else {
|
||||
callback && callback();
|
||||
}
|
||||
};
|
||||
|
||||
return umlDiagrams;
|
||||
}
|
||||
|
||||
// extra是实时的, 同步进行
|
||||
initMarkdownExtra();
|
||||
|
||||
var m;
|
||||
window.md2Html = function(mdText, toElem, callback) {
|
||||
var _umlEnd = false;
|
||||
var _mathJaxEnd = false;
|
||||
|
||||
// 如果是jQuery对象
|
||||
if(!toElem['querySelectorAll'] && toElem['get']) {
|
||||
toElem = toElem.get(0);
|
||||
}
|
||||
function _go(mdText, toElem) {
|
||||
var htmlParsed = converter.makeHtml(mdText);
|
||||
toElem.innerHTML = htmlParsed;
|
||||
|
||||
// 同步执行
|
||||
var toc = initToc();
|
||||
toc.convert(toElem);
|
||||
|
||||
// 异步执行
|
||||
var umlDiagrams = initUml();
|
||||
umlDiagrams.convert(toElem, function() {
|
||||
_umlEnd = true;
|
||||
if(_mathJaxEnd) {
|
||||
callback && callback(toElem.innerHTML);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 表示有mathjax?
|
||||
// 加载mathJax
|
||||
if(mdText.indexOf('$') !== -1) {
|
||||
loadJs("/public/libs/MathJax/MathJax.js?config=TeX-AMS_HTML", function() {
|
||||
// loadJs("http://cdn.bootcss.com/mathjax/2.5.3/MathJax.js?config=TeX-AMS_HTML", function() {
|
||||
if(!m) {
|
||||
var m = initMathJax();
|
||||
}
|
||||
// 放到后面, 不然removeMathJax()不运行, bug
|
||||
_go(mdText, toElem);
|
||||
m.convert(toElem, function() {
|
||||
_mathJaxEnd = true;
|
||||
if(_umlEnd) {
|
||||
callback && callback(toElem.innerHTML);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
_mathJaxEnd = true;
|
||||
_go(mdText, toElem);
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
||||
@@ -79,6 +79,8 @@ tinymce.addI18n('zh',{
|
||||
"Insert\/edit mind map": "新建/编辑思维导图",
|
||||
"Insert Mind Map": "插入思维导图",
|
||||
"Mind Map": "思维导图",
|
||||
"Image": "图片",
|
||||
"Insert Image": "插入",
|
||||
"General": "\u666e\u901a",
|
||||
"Advanced": "\u9ad8\u7ea7",
|
||||
"Source": "\u5730\u5740",
|
||||
|
||||
@@ -365,26 +365,27 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
|
||||
var num = e.which ? e.which : e.keyCode;
|
||||
if (num == 9) { // tab pressed
|
||||
if(!e.shiftKey) {
|
||||
// ed.execCommand('Indent');
|
||||
// TODO 如果当前在li, ul, ol下不执行!!
|
||||
// 如果在pre下就加tab
|
||||
// var node = ed.selection.getNode();
|
||||
/*
|
||||
if(node.nodeName == "PRE") {
|
||||
ed.execCommand('mceInsertHTML', false, '\x09'); // inserts tab
|
||||
} else {
|
||||
*/
|
||||
// 如果是在li下的, 就不要控制
|
||||
var node = ed.selection.getNode();
|
||||
if (node && node.nodeName === 'LI') {
|
||||
return true;
|
||||
}
|
||||
ed.insertContent(" ");
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
// ed.execCommand('mceInsertHTML', false, " "); // inserts 空格
|
||||
// }
|
||||
} else {
|
||||
// delete 4 个空格
|
||||
// ed.execCommand('Outdent');
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(a,b){function c(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\<br *\/*\>/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"<br />")):a}function e(a){g=tinymce.activeEditor;var b,e=g.selection.getNode(),f=g.selection.getContent(),h=LeaAce.isInAce(e),i=!1,j=!1;h&&(i=h[0],j=h[1]),$("#editorContent .toggle-raw").remove();var k='class="brush:'+a+'"';if(a&&"convert"!=a){if(i&&i.session.setMode("ace/mode/"+a),j||"PRE"!=e.nodeName||(j=$(e)),j){var l=LeaAce.getPreBrush(j);return void j.removeClass(l).addClass("brush:"+a)}}else if(a&&("BODY"==e.nodeName||"editorContent"==$(e).attr("id")))return;if(LeaAce.canAce()){var m=LeaAce.getAceId();if(LeaAce.disableAddHistory(),i){var n=i.getValue();n=n.replace(/</g,"<"),n=n.replace(/>/g,">"),n=n.replace(/\n/g,"<br />"),j.replaceWith("<p>"+n+"</p>"),i.destroy()}else{if("PRE"==e.nodeName){var j=$(e),n=j.html();return n&&(n=n.replace(/\n/g,"<br />")),void j.replaceWith("<p>"+n+"</p>")}var b=f;if(!b&&("BODY"==e.nodeName||"editorContent"==$(e).attr("id")))return;b?(b=c(b),g.insertContent('<pre id="'+m+'" '+k+">"+b+"</pre>")):(b=c(e),$(e).replaceWith("<pre id='"+m+"'"+k+">"+b+"</pre>"));var i=LeaAce.initAce(m);i&&(i.focus(),a&&"convert"!=a&&i.session.setMode("ace/mode/"+a))}LeaAce.resetAddHistory()}else if("PRE"!=e.nodeName&&(e=$(e).closest("pre").get(0)),e&&"PRE"==e.nodeName){var j=$(e),n=j.html();n&&(n=n.replace(/\n/g,"<br />")),j.replaceWith("<p>"+n+"</p>")}else{try{b=$.trim($(f).text())}catch(o){}b||(b=$.trim(f));var p=null,m=LeaAce.getAceId();b?(b=d(b),p='<pre id="'+m+'" '+k+">"+b+"</pre>",g.insertContent(p)):e?(b=d(e),p='<pre id="'+m+'" '+k+">"+b+"</pre>",$(e).replaceWith(p)):(p='<pre id="'+m+'" '+k+">"+b+"</pre>",g.insertContent(p))}}function f(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var g=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&e(a.control.settings.value)},onPostRender:f(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"code",image:b+"/img/ace-pre2.png",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),g.addCommand("toggleCode",e),g.addShortcut("ctrl+shift+c","","toggleCode"),g.addShortcut("command+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),g.on("keydown",function(a){var b=a.which?a.which:a.keyCode;return 9==b?(a.shiftKey||g.insertContent(" "),a.preventDefault(),a.stopPropagation(),!1):void 0})});
|
||||
tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(a,b){function c(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\<br *\/*\>/gi,"\n").replace(/<\/(p|li|div|ul|ol|hr)>/,"\n").replace(/(<([^>]+)>)/gi,"").replace(/\n\n/g,"\n")):a}function d(a){return a?("object"==typeof a&&(a=$(a).html()),a.replace(/\n/g,"<br />")):a}function e(){var a=$("#editorContent").children(),b=a&&a.length>0?a[a.length-1]:null;b&&"P"==b.tagName||$("#editorContent").append('<p><br data-mce-bogus="1"></p>')}function f(a){h=tinymce.activeEditor;var b,f=h.selection.getNode(),g=h.selection.getContent(),i=LeaAce.isInAce(f),j=!1,k=!1;i&&(j=i[0],k=i[1]),$("#editorContent .toggle-raw").remove();var l='class="brush:'+a+'"';if(a&&"convert"!=a){if(j&&j.session.setMode("ace/mode/"+a),k||"PRE"!=f.nodeName||(k=$(f)),k){var m=LeaAce.getPreBrush(k);return void k.removeClass(m).addClass("brush:"+a)}}else if(a&&("BODY"==f.nodeName||"editorContent"==$(f).attr("id")))return;if(LeaAce.canAce()){var n=LeaAce.getAceId();if(LeaAce.disableAddHistory(),j){var o=j.getValue();o=o.replace(/</g,"<"),o=o.replace(/>/g,">"),o=o.replace(/\n/g,"<br />"),k.replaceWith("<p>"+o+"</p>"),j.destroy()}else{if("PRE"==f.nodeName){var k=$(f),o=k.html();return o&&(o=o.replace(/\n/g,"<br />")),void k.replaceWith("<p>"+o+"</p>")}var b=g;if(!b&&("BODY"==f.nodeName||"editorContent"==$(f).attr("id")))return;b?(b=c(b),h.insertContent('<pre id="'+n+'" '+l+">"+b+"</pre>")):(b=c(f),$(f).replaceWith("<pre id='"+n+"'"+l+">"+b+"</pre>"));var j=LeaAce.initAce(n);j&&(j.focus(),a&&"convert"!=a&&j.session.setMode("ace/mode/"+a),e())}LeaAce.resetAddHistory()}else if("PRE"!=f.nodeName&&(f=$(f).closest("pre").get(0)),f&&"PRE"==f.nodeName){var k=$(f),o=k.html();o&&(o=o.replace(/\n/g,"<br />")),k.replaceWith("<p>"+o+"</p>")}else{try{b=$.trim($(g).text())}catch(p){}b||(b=$.trim(g));var q=null,n=LeaAce.getAceId();b?(b=d(b),q='<pre id="'+n+'" '+l+">"+b+"</pre>",h.insertContent(q)):f?(b=d(f),q='<pre id="'+n+'" '+l+">"+b+"</pre>",$(f).replaceWith(q)):(q='<pre id="'+n+'" '+l+">"+b+"</pre>",h.insertContent(q)),q&&e()}}function g(){return function(){var b=this;a.on("nodeChange",function(){var c=null;try{var d=a.selection.getNode();if("PRE"!=d.nodeName&&(d=$(d).closest("pre").get(0)),d){var e=LeaAce.isInAce(d),f=!1,g=!1;if(e||"PRE"==d.nodeName){e?(f=e[0],g=e[1]):g=$(d);var h=LeaAce.getPreBrush(g);c=$.trim(h.split(":")[1]),b.diableValue("convert",!1)}else b.diableValue("convert",!0)}}catch(i){log(i)}"convert"!=c&&b.value(c)})}}var h=a;a.addButton("leanote_code",function(){var a=["Convert Code:convert","CSS:css","HTML:html","Javascript:javascript","C/C++:c_cpp","C#:csharp","Java:java","Objective-c:objectivec","PHP:php","Python:python","Ruby:ruby","Shell:sh","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","Latex:latex","Xml:xml","ActionScript:actionScript"],b=[];for(var c in a){var d=a[c].split(":");b.push({text:d[0],value:d[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:b,fixedWidth:!0,onselect:function(a){a.control.settings.value&&f(a.control.settings.value)},onPostRender:g(b)}}),a.addButton("leanote_inline_code",{icon:"code",tooltip:"Inline Code",stateSelector:"code",onclick:function(){a.execCommand("mceToggleFormat",!1,"code")}}),LeaAce.canAce()&&a.addButton("leanote_ace_pre",{icon:"ace-pre",tooltip:"Toggle ace with raw html",active:LeaAce.isAce===!1,onclick:function(){LeaAce.isAce===!1?(this.active(!1),LeaAce.isAce=!0,LeaAce.initAceFromContent(a)):(this.active(!0),LeaAce.allToPre(a),LeaAce.isAce=!1)}}),h.addCommand("toggleCode",f),h.addShortcut("ctrl+shift+c","","toggleCode"),h.addShortcut("command+shift+c","","toggleCode"),LeaAce.canAce()&&a.on("keydown",function(a){var b=LeaAce.nowIsInAce();return b?(setTimeout(function(){b[0].focus()}),!0):void 0}),h.on("keydown",function(a){var b=a.which?a.which:a.keyCode;if(9==b&&!a.shiftKey){var c=h.selection.getNode();return c&&"LI"===c.nodeName?!0:(h.insertContent(" "),a.preventDefault(),a.stopPropagation(),!1)}})});
|
||||
@@ -57,7 +57,7 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
LEAUI_DATAS = datas;
|
||||
|
||||
function GetTheHtml(){
|
||||
var html = '<iframe id="leauiIfr" src="'+ url + '/index.html'+ '?' + new Date().getTime() + '" frameborder="0"></iframe>';
|
||||
var html = '<iframe id="leauiIfr" src="/album/index'+ '?' + new Date().getTime() + '" frameborder="0"></iframe>';
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
icon: 'image',
|
||||
tooltip: 'Insert/edit image',
|
||||
onclick: showDialog,
|
||||
stateSelector: 'img:not([data-mce-object])'
|
||||
stateSelector: 'img:not([data-mind-json])'
|
||||
});
|
||||
|
||||
editor.addMenuItem('leaui_image', {
|
||||
@@ -202,16 +202,25 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
|
||||
// 为解决在editor里拖动图片问题
|
||||
// 2014/7/8 21:43 浮躁的一天终有收获
|
||||
// 2015/10/16
|
||||
// TODO 如果把编辑器内的图片拖到外面去, 还是会出现drop images to here
|
||||
var dragStart = false;
|
||||
editor.on("dragstart", function(e) {
|
||||
// readonly时不让drag图片
|
||||
if (LEA.readOnly) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
dragStart = true;
|
||||
});
|
||||
editor.on("dragend", function(e) {
|
||||
dragStart = false;
|
||||
});
|
||||
editor.on("dragover", function(e) {
|
||||
if(!dragStart) {
|
||||
$("body").trigger("dragover");
|
||||
if(dragStart) {
|
||||
// 表示编辑器内在拖动图片, 则停止冒泡
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
});
|
||||
+1
-1
@@ -1 +1 @@
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(a,b){function c(a,b){function c(a,c){d.parentNode.removeChild(d),b({width:a,height:c})}var d=document.createElement("img");d.onload=function(){c(d.clientWidth,d.clientHeight)},d.onerror=function(){c()},d.src=a;var e=d.style;e.visibility="hidden",e.position="fixed",e.bottom=e.left=0,e.width=e.height="auto",document.body.appendChild(d)}function d(){function d(){var a='<iframe id="leauiIfr" src="'+b+"/index.html?"+(new Date).getTime()+'" frameborder="0"></iframe>';return a}var e=a.dom,f=a.selection.getContent(),g=/<img.*?\/>/g,h=f.match(g),i=document.createElement("p"),j=[];for(var k in h){i.innerHTML=h[k];var l=i.firstChild;if(l&&"IMG"==l.nodeName){var m={};m.src=e.getAttrib(l,"data-src")||e.getAttrib(l,"src"),m.width=e.getAttrib(l,"width"),m.height=e.getAttrib(l,"height"),m.title=e.getAttrib(l,"title"),j.push(m)}}LEAUI_DATAS=j;var n=$(document).width()-10;n>805&&(n=805);var o=$(document).height()-100;o>365&&(o=365),win=a.windowManager.open({title:"Image",width:n,height:o,html:d(),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Image",subtype:"primary",onclick:function(d){for(var f=document.getElementById("leauiIfr").contentWindow,g=f.document.getElementById("preview"),h=g.childNodes,i=[],j=0;j<h.length;++j){var d=h[j];if(d.firstChild&&"IMG"==d.firstChild.nodeName){var k=d.firstChild,l={};l.src=k.getAttribute("src"),l.width=k.getAttribute("data-width"),l.height=k.getAttribute("data-height"),l.title=k.getAttribute("data-title"),i.push(l)}}for(var j in i){var m,n=i[j],o=n.src;m=-1!=o.indexOf("http://")||-1!=o.indexOf("https://")?o:b+"/"+o,n.src=m;var p=function(b){var d=function(b,c){var d,f={};return f.id="__mcenew"+c,f.src="http://leanote.com/images/loading-24.gif",d=e.createHTML("img",f),a.insertContent(d),d=e.get(f.id),function(a){a&&a.width&&(a.width>600&&(a.width=600),b.width=a.width),e.setAttrib(d,"src",b.src),e.setAttrib(d,"title",b.title),e.setAttrib(d,"id",null)}}(b,j);c(b.src,d)},q="";if(fileIds=m.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(q=fileIds[1]),q){var r;Note&&Note.getCurNote&&(r=Note.getCurNote()),r&&r.UserId!=UserInfo.UserId?!function(a){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:q,toUserId:r.UserId},function(b){if(reIsOk(b)&&b.Id){var c=UrlPrefix;a.src=c+"/file/outputImage?fileId="+b.Id}p(a)})}(n):p(n)}else p(n)}this.parent().parent().close()}}]})}a.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:d,stateSelector:"img:not([data-mind-json])"}),a.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:d,context:"insert",prependToContext:!0});var e=!1;a.on("dragstart",function(a){e=!0}),a.on("dragend",function(a){e=!1}),a.on("dragover",function(a){e||$("body").trigger("dragover")})});
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(a,b){function c(a,b){function c(a,c){d.parentNode.removeChild(d),b({width:a,height:c})}var d=document.createElement("img");d.onload=function(){c(d.clientWidth,d.clientHeight)},d.onerror=function(){c()},d.src=a;var e=d.style;e.visibility="hidden",e.position="fixed",e.bottom=e.left=0,e.width=e.height="auto",document.body.appendChild(d)}function d(){function d(){var a='<iframe id="leauiIfr" src="/album/index?'+(new Date).getTime()+'" frameborder="0"></iframe>';return a}var e=a.dom,f=a.selection.getContent(),g=/<img.*?\/>/g,h=f.match(g),i=document.createElement("p"),j=[];for(var k in h){i.innerHTML=h[k];var l=i.firstChild;if(l&&"IMG"==l.nodeName){var m={};m.src=e.getAttrib(l,"data-src")||e.getAttrib(l,"src"),m.width=e.getAttrib(l,"width"),m.height=e.getAttrib(l,"height"),m.title=e.getAttrib(l,"title"),j.push(m)}}LEAUI_DATAS=j;var n=$(document).width()-10;n>805&&(n=805);var o=$(document).height()-100;o>365&&(o=365),win=a.windowManager.open({title:"Image",width:n,height:o,html:d(),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Image",subtype:"primary",onclick:function(d){for(var f=document.getElementById("leauiIfr").contentWindow,g=f.document.getElementById("preview"),h=g.childNodes,i=[],j=0;j<h.length;++j){var d=h[j];if(d.firstChild&&"IMG"==d.firstChild.nodeName){var k=d.firstChild,l={};l.src=k.getAttribute("src"),l.width=k.getAttribute("data-width"),l.height=k.getAttribute("data-height"),l.title=k.getAttribute("data-title"),i.push(l)}}for(var j in i){var m,n=i[j],o=n.src;m=-1!=o.indexOf("http://")||-1!=o.indexOf("https://")?o:b+"/"+o,n.src=m;var p=function(b){var d=function(b,c){var d,f={};return f.id="__mcenew"+c,f.src="http://leanote.com/images/loading-24.gif",d=e.createHTML("img",f),a.insertContent(d),d=e.get(f.id),function(a){a&&a.width&&(a.width>600&&(a.width=600),b.width=a.width),e.setAttrib(d,"src",b.src),e.setAttrib(d,"title",b.title),e.setAttrib(d,"id",null)}}(b,j);c(b.src,d)},q="";if(fileIds=m.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(q=fileIds[1]),q){var r;Note&&Note.getCurNote&&(r=Note.getCurNote()),r&&r.UserId!=UserInfo.UserId?!function(a){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:q,toUserId:r.UserId},function(b){if(reIsOk(b)&&b.Id){var c=UrlPrefix;a.src=c+"/file/outputImage?fileId="+b.Id}p(a)})}(n):p(n)}else p(n)}this.parent().parent().close()}}]})}a.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:d,stateSelector:"img:not([data-mind-json])"}),a.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:d,context:"insert",prependToContext:!0});var e=!1;a.on("dragstart",function(a){LEA.readOnly&&(a.preventDefault(),a.stopPropagation()),e=!0}),a.on("dragend",function(a){e=!1}),a.on("dragover",function(a){e&&(a.preventDefault(),a.stopPropagation())})});
|
||||
@@ -0,0 +1,172 @@
|
||||
/**
|
||||
* leaui album image manager plugin
|
||||
* copyright leaui
|
||||
* leaui.com
|
||||
*/
|
||||
var LEAUI_MIND = {};
|
||||
tinymce.PluginManager.add('leaui_mind', function(editor, url) {
|
||||
|
||||
function showDialog() {
|
||||
var dom = editor.dom;
|
||||
|
||||
var content = editor.selection.getContent();
|
||||
// get images and attrs
|
||||
var p = /<img.*?\/>/g;
|
||||
var images = content.match(p);
|
||||
var newNode = document.createElement("p");
|
||||
LEAUI_MIND = {};
|
||||
for(var i in images) {
|
||||
newNode.innerHTML = images[i];
|
||||
var imgElm = newNode.firstChild;
|
||||
if(imgElm && imgElm.nodeName == "IMG") {
|
||||
LEAUI_MIND.json = dom.getAttrib(imgElm, 'data-mind-json');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function GetTheHtml(){
|
||||
var lang = editor.settings.language;
|
||||
var u = '//leanote.com/public/libs/mind/edit.html';
|
||||
// u = 'http://localhost:9000/public/libs/mind/edit.html';
|
||||
var html = '<iframe id="leauiIfr" src="'+ u + '?' + new Date().getTime() + '&lang=' + lang + '" frameborder="0"></iframe>';
|
||||
return html;
|
||||
}
|
||||
|
||||
var w = $(document).width() - 10;
|
||||
var h = $(document).height() - 100;
|
||||
|
||||
win = editor.windowManager.open({
|
||||
title: "Mind Map",
|
||||
width : w,
|
||||
height : h,
|
||||
html: GetTheHtml(),
|
||||
buttons: [
|
||||
{
|
||||
text: 'Cancel',
|
||||
onclick: function() {
|
||||
this.parent().parent().close();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Insert Mind Map',
|
||||
subtype: 'primary',
|
||||
onclick: function(e) {
|
||||
var me = this;
|
||||
var _iframe = document.getElementById('leauiIfr').contentWindow;
|
||||
var km = _iframe.km;
|
||||
km.exportData('png').then(function(data) {
|
||||
var json = JSON.stringify(km.exportJson());
|
||||
// console.log(json);
|
||||
var img = '<img src="' + data + '" data-mce-src="-" data-mind-json=\'' + json + '\'>';
|
||||
editor.insertContent(img);
|
||||
|
||||
me.parent().parent().close();
|
||||
});
|
||||
return;
|
||||
|
||||
var _div =_iframe.document.getElementById('preview');
|
||||
var ii = _div.childNodes;
|
||||
//console.log(ii);
|
||||
var datas = [];
|
||||
for(var i = 0; i < ii.length; ++i) {
|
||||
var e = ii[i];
|
||||
//console.log(e);
|
||||
// 有些没有image
|
||||
if(e.firstChild && e.firstChild.nodeName == "IMG") {
|
||||
var img = e.firstChild;
|
||||
var d = {};
|
||||
d.src = img.getAttribute("src");
|
||||
d.width = img.getAttribute("data-width");
|
||||
d.height = img.getAttribute("data-height");
|
||||
d.title = img.getAttribute("data-title");
|
||||
|
||||
datas.push(d);
|
||||
}
|
||||
};
|
||||
|
||||
for(var i in datas) {
|
||||
var data = datas[i];
|
||||
var src = data.src;
|
||||
// the network image
|
||||
var trueSrc;
|
||||
if(src.indexOf("http://") != -1 || src.indexOf("https://") != -1) {
|
||||
trueSrc = src;
|
||||
} else {
|
||||
trueSrc = url + "/" + src;
|
||||
}
|
||||
data.src = trueSrc;
|
||||
|
||||
var renderImage = function(data) {
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var back = (function(data2, i) {
|
||||
var d = {};
|
||||
var imgElm;
|
||||
// 先显示loading...
|
||||
d.id = '__mcenew' + i;
|
||||
d.src = "http://leanote.com/images/loading-24.gif";
|
||||
imgElm = dom.createHTML('img', d);
|
||||
editor.insertContent(imgElm);
|
||||
imgElm = dom.get(d.id);
|
||||
|
||||
return function(wh) {
|
||||
if(wh && wh.width) {
|
||||
if(wh.width > 600) {
|
||||
wh.width = 600;
|
||||
}
|
||||
data2.width = wh.width;
|
||||
}
|
||||
dom.setAttrib(imgElm, 'src', data2.src);
|
||||
// dom.setAttrib(imgElm, 'width', data2.width);
|
||||
dom.setAttrib(imgElm, 'title', data2.title);
|
||||
|
||||
dom.setAttrib(imgElm, 'id', null);
|
||||
}
|
||||
})(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
|
||||
// 博客设置中不用没有Note
|
||||
var curNote;
|
||||
if(Note && Note.getCurNote) {
|
||||
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 = 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();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
|
||||
editor.addButton('leaui_mind', {
|
||||
icon: 'mind',
|
||||
tooltip: 'Insert/edit mind map',
|
||||
onclick: showDialog,
|
||||
stateSelector: 'img[data-mind-json]'
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
var LEAUI_MIND={};tinymce.PluginManager.add("leaui_mind",function(a,b){function c(){function b(){var b=a.settings.language,c="//leanote.com/public/libs/mind/edit.html",d='<iframe id="leauiIfr" src="'+c+"?"+(new Date).getTime()+"&lang="+b+'" frameborder="0"></iframe>';return d}var c=a.dom,d=a.selection.getContent(),e=/<img.*?\/>/g,f=d.match(e),g=document.createElement("p");LEAUI_MIND={};for(var h in f){g.innerHTML=f[h];var i=g.firstChild;if(i&&"IMG"==i.nodeName){LEAUI_MIND.json=c.getAttrib(i,"data-mind-json");break}}var j=$(document).width()-10,k=$(document).height()-100;win=a.windowManager.open({title:"Mind Map",width:j,height:k,html:b(),buttons:[{text:"Cancel",onclick:function(){this.parent().parent().close()}},{text:"Insert Mind Map",subtype:"primary",onclick:function(b){var c=this,d=document.getElementById("leauiIfr").contentWindow,e=d.km;return void e.exportData("png").then(function(b){var d=JSON.stringify(e.exportJson()),f='<img src="'+b+'" data-mce-src="-" data-mind-json=\''+d+"'>";a.insertContent(f),c.parent().parent().close()})}}]})}a.addButton("leaui_mind",{icon:"mind",tooltip:"Insert/edit mind map",onclick:c,stateSelector:"img[data-mind-json]"})});
|
||||
+611
@@ -0,0 +1,611 @@
|
||||
/**
|
||||
* Clipboard.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains logic for getting HTML contents out of the clipboard.
|
||||
*
|
||||
* We need to make a lot of ugly hacks to get the contents out of the clipboard since
|
||||
* the W3C Clipboard API is broken in all browsers that have it: Gecko/WebKit/Blink.
|
||||
* We might rewrite this the way those API:s stabilize. Browsers doesn't handle pasting
|
||||
* from applications like Word the same way as it does when pasting into a contentEditable area
|
||||
* so we need to do lots of extra work to try to get to this clipboard data.
|
||||
*
|
||||
* Current implementation steps:
|
||||
* 1. On keydown with paste keys Ctrl+V or Shift+Insert create
|
||||
* a paste bin element and move focus to that element.
|
||||
* 2. Wait for the browser to fire a "paste" event and get the contents out of the paste bin.
|
||||
* 3. Check if the paste was successful if true, process the HTML.
|
||||
* (4). If the paste was unsuccessful use IE execCommand, Clipboard API, document.dataTransfer old WebKit API etc.
|
||||
*
|
||||
* @class tinymce.pasteplugin.Clipboard
|
||||
* @private
|
||||
*/
|
||||
define("tinymce/pasteplugin/Clipboard", [
|
||||
"tinymce/Env",
|
||||
"tinymce/dom/RangeUtils",
|
||||
"tinymce/util/VK",
|
||||
"tinymce/pasteplugin/Utils"
|
||||
], function(Env, RangeUtils, VK, Utils) {
|
||||
return function(editor) {
|
||||
var self = this, pasteBinElm, lastRng, keyboardPasteTimeStamp = 0, draggingInternally = false;
|
||||
var pasteBinDefaultContent = '%MCEPASTEBIN%', keyboardPastePlainTextState;
|
||||
var mceInternalUrlPrefix = 'data:text/mce-internal,';
|
||||
|
||||
/**
|
||||
* Pastes the specified HTML. This means that the HTML is filtered and then
|
||||
* inserted at the current selection in the editor. It will also fire paste events
|
||||
* for custom user filtering.
|
||||
*
|
||||
* @param {String} html HTML code to paste into the current selection.
|
||||
*/
|
||||
function pasteHtml(html) {
|
||||
var args, dom = editor.dom;
|
||||
|
||||
args = editor.fire('BeforePastePreProcess', {content: html}); // Internal event used by Quirks
|
||||
args = editor.fire('PastePreProcess', args);
|
||||
html = args.content;
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
// User has bound PastePostProcess events then we need to pass it through a DOM node
|
||||
// This is not ideal but we don't want to let the browser mess up the HTML for example
|
||||
// some browsers add to P tags etc
|
||||
if (editor.hasEventListeners('PastePostProcess') && !args.isDefaultPrevented()) {
|
||||
// We need to attach the element to the DOM so Sizzle selectors work on the contents
|
||||
var tempBody = dom.add(editor.getBody(), 'div', {style: 'display:none'}, html);
|
||||
args = editor.fire('PastePostProcess', {node: tempBody});
|
||||
dom.remove(tempBody);
|
||||
html = args.node.innerHTML;
|
||||
}
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
editor.insertContent(html, {merge: editor.settings.paste_merge_formats !== false});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pastes the specified text. This means that the plain text is processed
|
||||
* and converted into BR and P elements. It will fire paste events for custom filtering.
|
||||
*
|
||||
* @param {String} text Text to paste as the current selection location.
|
||||
*/
|
||||
function pasteText(text) {
|
||||
text = editor.dom.encode(text).replace(/\r\n/g, '\n');
|
||||
|
||||
var startBlock = editor.dom.getParent(editor.selection.getStart(), editor.dom.isBlock);
|
||||
|
||||
// Create start block html for example <p attr="value">
|
||||
var forcedRootBlockName = editor.settings.forced_root_block;
|
||||
var forcedRootBlockStartHtml;
|
||||
if (forcedRootBlockName) {
|
||||
forcedRootBlockStartHtml = editor.dom.createHTML(forcedRootBlockName, editor.settings.forced_root_block_attrs);
|
||||
forcedRootBlockStartHtml = forcedRootBlockStartHtml.substr(0, forcedRootBlockStartHtml.length - 3) + '>';
|
||||
}
|
||||
|
||||
if ((startBlock && /^(PRE|DIV)$/.test(startBlock.nodeName)) || !forcedRootBlockName) {
|
||||
text = Utils.filter(text, [
|
||||
[/\n/g, "<br>"]
|
||||
]);
|
||||
} else {
|
||||
text = Utils.filter(text, [
|
||||
[/\n\n/g, "</p>" + forcedRootBlockStartHtml],
|
||||
[/^(.*<\/p>)(<p>)$/, forcedRootBlockStartHtml + '$1'],
|
||||
[/\n/g, "<br />"]
|
||||
]);
|
||||
|
||||
if (text.indexOf('<p>') != -1) {
|
||||
text = forcedRootBlockStartHtml + text;
|
||||
}
|
||||
}
|
||||
|
||||
pasteHtml(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a paste bin element as close as possible to the current caret location and places the focus inside that element
|
||||
* so that when the real paste event occurs the contents gets inserted into this element
|
||||
* instead of the current editor selection element.
|
||||
*/
|
||||
function createPasteBin() {
|
||||
var dom = editor.dom, body = editor.getBody();
|
||||
var viewport = editor.dom.getViewPort(editor.getWin()), scrollTop = viewport.y, top = 20;
|
||||
var scrollContainer;
|
||||
|
||||
lastRng = editor.selection.getRng();
|
||||
|
||||
if (editor.inline) {
|
||||
scrollContainer = editor.selection.getScrollContainer();
|
||||
|
||||
// Can't always rely on scrollTop returning a useful value.
|
||||
// It returns 0 if the browser doesn't support scrollTop for the element or is non-scrollable
|
||||
if (scrollContainer && scrollContainer.scrollTop > 0) {
|
||||
scrollTop = scrollContainer.scrollTop;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the rect of the current caret if the caret is in an empty block before a
|
||||
* BR we insert a temporary invisible character that we get the rect this way we always get a proper rect.
|
||||
*
|
||||
* TODO: This might be useful in core.
|
||||
*/
|
||||
function getCaretRect(rng) {
|
||||
var rects, textNode, node, container = rng.startContainer;
|
||||
|
||||
rects = rng.getClientRects();
|
||||
if (rects.length) {
|
||||
return rects[0];
|
||||
}
|
||||
|
||||
if (!rng.collapsed || container.nodeType != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = container.childNodes[lastRng.startOffset];
|
||||
|
||||
// Skip empty whitespace nodes
|
||||
while (node && node.nodeType == 3 && !node.data.length) {
|
||||
node = node.nextSibling;
|
||||
}
|
||||
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if the location is |<br>
|
||||
// TODO: Might need to expand this to say |<table>
|
||||
if (node.tagName == 'BR') {
|
||||
textNode = dom.doc.createTextNode('\uFEFF');
|
||||
node.parentNode.insertBefore(textNode, node);
|
||||
|
||||
rng = dom.createRng();
|
||||
rng.setStartBefore(textNode);
|
||||
rng.setEndAfter(textNode);
|
||||
|
||||
rects = rng.getClientRects();
|
||||
dom.remove(textNode);
|
||||
}
|
||||
|
||||
if (rects.length) {
|
||||
return rects[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate top cordinate this is needed to avoid scrolling to top of document
|
||||
// We want the paste bin to be as close to the caret as possible to avoid scrolling
|
||||
if (lastRng.getClientRects) {
|
||||
var rect = getCaretRect(lastRng);
|
||||
|
||||
if (rect) {
|
||||
// Client rects gets us closes to the actual
|
||||
// caret location in for example a wrapped paragraph block
|
||||
top = scrollTop + (rect.top - dom.getPos(body).y);
|
||||
} else {
|
||||
top = scrollTop;
|
||||
|
||||
// Check if we can find a closer location by checking the range element
|
||||
var container = lastRng.startContainer;
|
||||
if (container) {
|
||||
if (container.nodeType == 3 && container.parentNode != body) {
|
||||
container = container.parentNode;
|
||||
}
|
||||
|
||||
if (container.nodeType == 1) {
|
||||
top = dom.getPos(container, scrollContainer || body).y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create a pastebin
|
||||
pasteBinElm = dom.add(editor.getBody(), 'div', {
|
||||
id: "mcepastebin",
|
||||
contentEditable: true,
|
||||
"data-mce-bogus": "all",
|
||||
style: 'position: absolute; top: ' + top + 'px;' +
|
||||
'width: 10px; height: 10px; overflow: hidden; opacity: 0'
|
||||
}, pasteBinDefaultContent);
|
||||
|
||||
// Move paste bin out of sight since the controlSelection rect gets displayed otherwise on IE and Gecko
|
||||
if (Env.ie || Env.gecko) {
|
||||
dom.setStyle(pasteBinElm, 'left', dom.getStyle(body, 'direction', true) == 'rtl' ? 0xFFFF : -0xFFFF);
|
||||
}
|
||||
|
||||
// Prevent focus events from bubbeling fixed FocusManager issues
|
||||
dom.bind(pasteBinElm, 'beforedeactivate focusin focusout', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
pasteBinElm.focus();
|
||||
editor.selection.select(pasteBinElm, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the paste bin if it exists.
|
||||
*/
|
||||
function removePasteBin() {
|
||||
if (pasteBinElm) {
|
||||
var pasteBinClone;
|
||||
|
||||
// WebKit/Blink might clone the div so
|
||||
// lets make sure we remove all clones
|
||||
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
|
||||
while ((pasteBinClone = editor.dom.get('mcepastebin'))) {
|
||||
editor.dom.remove(pasteBinClone);
|
||||
editor.dom.unbind(pasteBinClone);
|
||||
}
|
||||
|
||||
if (lastRng) {
|
||||
editor.selection.setRng(lastRng);
|
||||
}
|
||||
}
|
||||
|
||||
pasteBinElm = lastRng = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the contents of the paste bin as a HTML string.
|
||||
*
|
||||
* @return {String} Get the contents of the paste bin.
|
||||
*/
|
||||
function getPasteBinHtml() {
|
||||
var html = '', pasteBinClones, i, clone, cloneHtml;
|
||||
|
||||
// Since WebKit/Chrome might clone the paste bin when pasting
|
||||
// for example: <img style="float: right"> we need to check if any of them contains some useful html.
|
||||
// TODO: Man o man is this ugly. WebKit is the new IE! Remove this if they ever fix it!
|
||||
pasteBinClones = editor.dom.select('div[id=mcepastebin]');
|
||||
for (i = 0; i < pasteBinClones.length; i++) {
|
||||
clone = pasteBinClones[i];
|
||||
|
||||
// Pasting plain text produces pastebins in pastebinds makes sence right!?
|
||||
if (clone.firstChild && clone.firstChild.id == 'mcepastebin') {
|
||||
clone = clone.firstChild;
|
||||
}
|
||||
|
||||
cloneHtml = clone.innerHTML;
|
||||
if (html != pasteBinDefaultContent) {
|
||||
html += cloneHtml;
|
||||
}
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets various content types out of a datatransfer object.
|
||||
*
|
||||
* @param {DataTransfer} dataTransfer Event fired on paste.
|
||||
* @return {Object} Object with mime types and data for those mime types.
|
||||
*/
|
||||
function getDataTransferItems(dataTransfer) {
|
||||
var data = {};
|
||||
|
||||
if (dataTransfer) {
|
||||
// Use old WebKit/IE API
|
||||
if (dataTransfer.getData) {
|
||||
var legacyText = dataTransfer.getData('Text');
|
||||
if (legacyText && legacyText.length > 0) {
|
||||
if (legacyText.indexOf(mceInternalUrlPrefix) == -1) {
|
||||
data['text/plain'] = legacyText;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTransfer.types) {
|
||||
for (var i = 0; i < dataTransfer.types.length; i++) {
|
||||
var contentType = dataTransfer.types[i];
|
||||
data[contentType] = dataTransfer.getData(contentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets various content types out of the Clipboard API. It will also get the
|
||||
* plain text using older IE and WebKit API:s.
|
||||
*
|
||||
* @param {ClipboardEvent} clipboardEvent Event fired on paste.
|
||||
* @return {Object} Object with mime types and data for those mime types.
|
||||
*/
|
||||
function getClipboardContent(clipboardEvent) {
|
||||
return getDataTransferItems(clipboardEvent.clipboardData || editor.getDoc().dataTransfer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the clipboard contains image data if it does it will take that data
|
||||
* and convert it into a data url image and paste that image at the caret location.
|
||||
*
|
||||
* @param {ClipboardEvent} e Paste/drop event object.
|
||||
* @param {DOMRange} rng Optional rng object to move selection to.
|
||||
* @return {Boolean} true/false if the image data was found or not.
|
||||
*/
|
||||
function pasteImageData(e, rng) {
|
||||
var dataTransfer = e.clipboardData || e.dataTransfer;
|
||||
|
||||
function processItems(items) {
|
||||
var i, item, reader, hadImage = false;
|
||||
|
||||
function pasteImage(reader) {
|
||||
if (rng) {
|
||||
editor.selection.setRng(rng);
|
||||
rng = null;
|
||||
}
|
||||
|
||||
pasteHtml('<img src="' + reader.result + '">');
|
||||
}
|
||||
|
||||
if (items) {
|
||||
for (i = 0; i < items.length; i++) {
|
||||
item = items[i];
|
||||
|
||||
if (/^image\/(jpeg|png|gif|bmp)$/.test(item.type)) {
|
||||
reader = new FileReader();
|
||||
reader.onload = pasteImage.bind(null, reader);
|
||||
reader.readAsDataURL(item.getAsFile ? item.getAsFile() : item);
|
||||
|
||||
e.preventDefault();
|
||||
hadImage = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return hadImage;
|
||||
}
|
||||
|
||||
if (editor.settings.paste_data_images && dataTransfer) {
|
||||
return processItems(dataTransfer.items) || processItems(dataTransfer.files);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Chrome on Android doesn't support proper clipboard access so we have no choice but to allow the browser default behavior.
|
||||
*
|
||||
* @param {Event} e Paste event object to check if it contains any data.
|
||||
* @return {Boolean} true/false if the clipboard is empty or not.
|
||||
*/
|
||||
function isBrokenAndroidClipboardEvent(e) {
|
||||
var clipboardData = e.clipboardData;
|
||||
|
||||
return navigator.userAgent.indexOf('Android') != -1 && clipboardData && clipboardData.items && clipboardData.items.length === 0;
|
||||
}
|
||||
|
||||
function getCaretRangeFromEvent(e) {
|
||||
return RangeUtils.getCaretRangeFromPoint(e.clientX, e.clientY, editor.getDoc());
|
||||
}
|
||||
|
||||
function hasContentType(clipboardContent, mimeType) {
|
||||
return mimeType in clipboardContent && clipboardContent[mimeType].length > 0;
|
||||
}
|
||||
|
||||
function isKeyboardPasteEvent(e) {
|
||||
return (VK.metaKeyPressed(e) && e.keyCode == 86) || (e.shiftKey && e.keyCode == 45);
|
||||
}
|
||||
|
||||
function registerEventHandlers() {
|
||||
editor.on('keydown', function(e) {
|
||||
function removePasteBinOnKeyUp(e) {
|
||||
// Ctrl+V or Shift+Insert
|
||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||
removePasteBin();
|
||||
}
|
||||
}
|
||||
|
||||
// Ctrl+V or Shift+Insert
|
||||
if (isKeyboardPasteEvent(e) && !e.isDefaultPrevented()) {
|
||||
keyboardPastePlainTextState = e.shiftKey && e.keyCode == 86;
|
||||
|
||||
// Edge case on Safari on Mac where it doesn't handle Cmd+Shift+V correctly
|
||||
// it fires the keydown but no paste or keyup so we are left with a paste bin
|
||||
if (keyboardPastePlainTextState && Env.webkit && navigator.userAgent.indexOf('Version/') != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Prevent undoManager keydown handler from making an undo level with the pastebin in it
|
||||
e.stopImmediatePropagation();
|
||||
|
||||
keyboardPasteTimeStamp = new Date().getTime();
|
||||
|
||||
// IE doesn't support Ctrl+Shift+V and it doesn't even produce a paste event
|
||||
// so lets fake a paste event and let IE use the execCommand/dataTransfer methods
|
||||
if (Env.ie && keyboardPastePlainTextState) {
|
||||
e.preventDefault();
|
||||
editor.fire('paste', {ieFake: true});
|
||||
return;
|
||||
}
|
||||
|
||||
removePasteBin();
|
||||
createPasteBin();
|
||||
|
||||
// Remove pastebin if we get a keyup and no paste event
|
||||
// For example pasting a file in IE 11 will not produce a paste event
|
||||
editor.once('keyup', removePasteBinOnKeyUp);
|
||||
editor.once('paste', function() {
|
||||
editor.off('keyup', removePasteBinOnKeyUp);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('paste', function(e) {
|
||||
// Getting content from the Clipboard can take some time
|
||||
var clipboardTimer = new Date().getTime();
|
||||
var clipboardContent = getClipboardContent(e);
|
||||
var clipboardDelay = new Date().getTime() - clipboardTimer;
|
||||
|
||||
var isKeyBoardPaste = (new Date().getTime() - keyboardPasteTimeStamp - clipboardDelay) < 1000;
|
||||
var plainTextMode = self.pasteFormat == "text" || keyboardPastePlainTextState;
|
||||
|
||||
keyboardPastePlainTextState = false;
|
||||
|
||||
if (e.isDefaultPrevented() || isBrokenAndroidClipboardEvent(e)) {
|
||||
removePasteBin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (pasteImageData(e)) {
|
||||
removePasteBin();
|
||||
return;
|
||||
}
|
||||
|
||||
// Not a keyboard paste prevent default paste and try to grab the clipboard contents using different APIs
|
||||
if (!isKeyBoardPaste) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// Try IE only method if paste isn't a keyboard paste
|
||||
if (Env.ie && (!isKeyBoardPaste || e.ieFake)) {
|
||||
createPasteBin();
|
||||
|
||||
editor.dom.bind(pasteBinElm, 'paste', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
editor.getDoc().execCommand('Paste', false, null);
|
||||
clipboardContent["text/html"] = getPasteBinHtml();
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
var content;
|
||||
|
||||
// Grab HTML from Clipboard API or paste bin as a fallback
|
||||
if (hasContentType(clipboardContent, 'text/html')) {
|
||||
content = clipboardContent['text/html'];
|
||||
} else {
|
||||
content = getPasteBinHtml();
|
||||
|
||||
// If paste bin is empty try using plain text mode
|
||||
// since that is better than nothing right
|
||||
if (content == pasteBinDefaultContent) {
|
||||
plainTextMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
content = Utils.trimHtml(content);
|
||||
|
||||
// WebKit has a nice bug where it clones the paste bin if you paste from for example notepad
|
||||
// so we need to force plain text mode in this case
|
||||
if (pasteBinElm && pasteBinElm.firstChild && pasteBinElm.firstChild.id === 'mcepastebin') {
|
||||
plainTextMode = true;
|
||||
}
|
||||
|
||||
removePasteBin();
|
||||
|
||||
// If we got nothing from clipboard API and pastebin then we could try the last resort: plain/text
|
||||
if (!content.length) {
|
||||
plainTextMode = true;
|
||||
}
|
||||
|
||||
// Grab plain text from Clipboard API or convert existing HTML to plain text
|
||||
if (plainTextMode) {
|
||||
// Use plain text contents from Clipboard API unless the HTML contains paragraphs then
|
||||
// we should convert the HTML to plain text since works better when pasting HTML/Word contents as plain text
|
||||
if (hasContentType(clipboardContent, 'text/plain') && content.indexOf('</p>') == -1) {
|
||||
content = clipboardContent['text/plain'];
|
||||
} else {
|
||||
content = Utils.innerText(content);
|
||||
}
|
||||
}
|
||||
|
||||
// If the content is the paste bin default HTML then it was
|
||||
// impossible to get the cliboard data out.
|
||||
if (content == pasteBinDefaultContent) {
|
||||
if (!isKeyBoardPaste) {
|
||||
editor.windowManager.alert('Please use Ctrl+V/Cmd+V keyboard shortcuts to paste contents.');
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (plainTextMode) {
|
||||
pasteText(content);
|
||||
} else {
|
||||
pasteHtml(content);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
|
||||
editor.on('dragstart dragend', function(e) {
|
||||
draggingInternally = e.type == 'dragstart';
|
||||
});
|
||||
|
||||
editor.on('drop', function(e) {
|
||||
var rng = getCaretRangeFromEvent(e);
|
||||
|
||||
if (e.isDefaultPrevented() || draggingInternally) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pasteImageData(e, rng)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rng && editor.settings.paste_filter_drop !== false) {
|
||||
var dropContent = getDataTransferItems(e.dataTransfer);
|
||||
var content = dropContent['mce-internal'] || dropContent['text/html'] || dropContent['text/plain'];
|
||||
|
||||
if (content) {
|
||||
e.preventDefault();
|
||||
|
||||
editor.undoManager.transact(function() {
|
||||
if (dropContent['mce-internal']) {
|
||||
editor.execCommand('Delete');
|
||||
}
|
||||
|
||||
editor.selection.setRng(rng);
|
||||
|
||||
content = Utils.trimHtml(content);
|
||||
|
||||
if (!dropContent['text/html']) {
|
||||
pasteText(content);
|
||||
} else {
|
||||
pasteHtml(content);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on('dragover dragend', function(e) {
|
||||
if (editor.settings.paste_data_images) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.pasteHtml = pasteHtml;
|
||||
self.pasteText = pasteText;
|
||||
|
||||
editor.on('preInit', function() {
|
||||
registerEventHandlers();
|
||||
|
||||
// Remove all data images from paste for example from Gecko
|
||||
// except internal images like video elements
|
||||
editor.parser.addNodeFilter('img', function(nodes) {
|
||||
if (!editor.settings.paste_data_images) {
|
||||
var i = nodes.length;
|
||||
|
||||
while (i--) {
|
||||
var src = nodes[i].attributes.map.src;
|
||||
|
||||
// Some browsers automatically produce data uris on paste
|
||||
// Safari on Mac produces webkit-fake-url see: https://bugs.webkit.org/show_bug.cgi?id=49141
|
||||
if (src && /^(data:image|webkit\-fake\-url)/.test(src)) {
|
||||
if (!nodes[i].attr('data-mce-object') && src !== Env.transparentSrc) {
|
||||
nodes[i].remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
/**
|
||||
* Plugin.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains the tinymce plugin logic for the paste plugin.
|
||||
*
|
||||
* @class tinymce.pasteplugin.Plugin
|
||||
* @private
|
||||
*/
|
||||
define("tinymce/pasteplugin/Plugin", [
|
||||
"tinymce/PluginManager",
|
||||
"tinymce/pasteplugin/Clipboard",
|
||||
"tinymce/pasteplugin/WordFilter",
|
||||
"tinymce/pasteplugin/Quirks"
|
||||
], function(PluginManager, Clipboard, WordFilter, Quirks) {
|
||||
var userIsInformed;
|
||||
|
||||
PluginManager.add('paste', function(editor) {
|
||||
var self = this, clipboard, settings = editor.settings;
|
||||
|
||||
function togglePlainTextPaste() {
|
||||
if (clipboard.pasteFormat == "text") {
|
||||
this.active(false);
|
||||
clipboard.pasteFormat = "html";
|
||||
} else {
|
||||
clipboard.pasteFormat = "text";
|
||||
this.active(true);
|
||||
|
||||
if (!userIsInformed) {
|
||||
editor.windowManager.alert(
|
||||
'Paste is now in plain text mode. Contents will now ' +
|
||||
'be pasted as plain text until you toggle this option off.'
|
||||
);
|
||||
|
||||
userIsInformed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.clipboard = clipboard = new Clipboard(editor);
|
||||
self.quirks = new Quirks(editor);
|
||||
self.wordFilter = new WordFilter(editor);
|
||||
|
||||
if (editor.settings.paste_as_text) {
|
||||
self.clipboard.pasteFormat = "text";
|
||||
}
|
||||
|
||||
if (settings.paste_preprocess) {
|
||||
editor.on('PastePreProcess', function(e) {
|
||||
settings.paste_preprocess.call(self, self, e);
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.paste_postprocess) {
|
||||
editor.on('PastePostProcess', function(e) {
|
||||
settings.paste_postprocess.call(self, self, e);
|
||||
});
|
||||
}
|
||||
|
||||
editor.addCommand('mceInsertClipboardContent', function(ui, value) {
|
||||
if (value.content) {
|
||||
self.clipboard.pasteHtml(value.content);
|
||||
}
|
||||
|
||||
if (value.text) {
|
||||
self.clipboard.pasteText(value.text);
|
||||
}
|
||||
});
|
||||
|
||||
// Block all drag/drop events
|
||||
if (editor.paste_block_drop) {
|
||||
editor.on('dragend dragover draggesture dragdrop drop drag', function(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
// Prevent users from dropping data images on Gecko
|
||||
if (!editor.settings.paste_data_images) {
|
||||
editor.on('drop', function(e) {
|
||||
var dataTransfer = e.dataTransfer;
|
||||
|
||||
if (dataTransfer && dataTransfer.files && dataTransfer.files.length > 0) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.addButton('pastetext', {
|
||||
icon: 'pastetext',
|
||||
tooltip: 'Paste as text',
|
||||
onclick: togglePlainTextPaste,
|
||||
active: self.clipboard.pasteFormat == "text"
|
||||
});
|
||||
|
||||
editor.addMenuItem('pastetext', {
|
||||
text: 'Paste as text',
|
||||
selectable: true,
|
||||
active: clipboard.pasteFormat,
|
||||
onclick: togglePlainTextPaste
|
||||
});
|
||||
});
|
||||
});
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
/**
|
||||
* Quirks.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contains various fixes for browsers. These issues can not be feature
|
||||
* detected since we have no direct control over the clipboard. However we might be able
|
||||
* to remove some of these fixes once the browsers gets updated/fixed.
|
||||
*
|
||||
* @class tinymce.pasteplugin.Quirks
|
||||
* @private
|
||||
*/
|
||||
define("tinymce/pasteplugin/Quirks", [
|
||||
"tinymce/Env",
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/pasteplugin/WordFilter",
|
||||
"tinymce/pasteplugin/Utils"
|
||||
], function(Env, Tools, WordFilter, Utils) {
|
||||
"use strict";
|
||||
|
||||
return function(editor) {
|
||||
function addPreProcessFilter(filterFunc) {
|
||||
editor.on('BeforePastePreProcess', function(e) {
|
||||
e.content = filterFunc(e.content);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes BR elements after block elements. IE9 has a nasty bug where it puts a BR element after each
|
||||
* block element when pasting from word. This removes those elements.
|
||||
*
|
||||
* This:
|
||||
* <p>a</p><br><p>b</p>
|
||||
*
|
||||
* Becomes:
|
||||
* <p>a</p><p>b</p>
|
||||
*/
|
||||
function removeExplorerBrElementsAfterBlocks(html) {
|
||||
// Only filter word specific content
|
||||
if (!WordFilter.isWordContent(html)) {
|
||||
return html;
|
||||
}
|
||||
|
||||
// Produce block regexp based on the block elements in schema
|
||||
var blockElements = [];
|
||||
|
||||
Tools.each(editor.schema.getBlockElements(), function(block, blockName) {
|
||||
blockElements.push(blockName);
|
||||
});
|
||||
|
||||
var explorerBlocksRegExp = new RegExp(
|
||||
'(?:<br> [\\s\\r\\n]+|<br>)*(<\\/?(' + blockElements.join('|') + ')[^>]*>)(?:<br> [\\s\\r\\n]+|<br>)*',
|
||||
'g'
|
||||
);
|
||||
|
||||
// Remove BR:s from: <BLOCK>X</BLOCK><BR>
|
||||
html = Utils.filter(html, [
|
||||
[explorerBlocksRegExp, '$1']
|
||||
]);
|
||||
|
||||
// IE9 also adds an extra BR element for each soft-linefeed and it also adds a BR for each word wrap break
|
||||
html = Utils.filter(html, [
|
||||
[/<br><br>/g, '<BR><BR>'], // Replace multiple BR elements with uppercase BR to keep them intact
|
||||
[/<br>/g, ' '], // Replace single br elements with space since they are word wrap BR:s
|
||||
[/<BR><BR>/g, '<br>'] // Replace back the double brs but into a single BR
|
||||
]);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebKit has a nasty bug where the all computed styles gets added to style attributes when copy/pasting contents.
|
||||
* This fix solves that by simply removing the whole style attribute.
|
||||
*
|
||||
* The paste_webkit_styles option can be set to specify what to keep:
|
||||
* paste_webkit_styles: "none" // Keep no styles
|
||||
* paste_webkit_styles: "all", // Keep all of them
|
||||
* paste_webkit_styles: "font-weight color" // Keep specific ones
|
||||
*
|
||||
* @param {String} content Content that needs to be processed.
|
||||
* @return {String} Processed contents.
|
||||
*/
|
||||
function removeWebKitStyles(content) {
|
||||
// Passthrough all styles from Word and let the WordFilter handle that junk
|
||||
if (WordFilter.isWordContent(content)) {
|
||||
return content;
|
||||
}
|
||||
|
||||
// Filter away styles that isn't matching the target node
|
||||
var webKitStyles = editor.settings.paste_webkit_styles;
|
||||
|
||||
if (editor.settings.paste_remove_styles_if_webkit === false || webKitStyles == "all") {
|
||||
return content;
|
||||
}
|
||||
|
||||
if (webKitStyles) {
|
||||
webKitStyles = webKitStyles.split(/[, ]/);
|
||||
}
|
||||
|
||||
// Keep specific styles that doesn't match the current node computed style
|
||||
if (webKitStyles) {
|
||||
var dom = editor.dom, node = editor.selection.getNode();
|
||||
|
||||
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, function(all, before, value, after) {
|
||||
var inputStyles = dom.parseStyle(value, 'span'), outputStyles = {};
|
||||
|
||||
if (webKitStyles === "none") {
|
||||
return before + after;
|
||||
}
|
||||
|
||||
for (var i = 0; i < webKitStyles.length; i++) {
|
||||
var inputValue = inputStyles[webKitStyles[i]], currentValue = dom.getStyle(node, webKitStyles[i], true);
|
||||
|
||||
if (/color/.test(webKitStyles[i])) {
|
||||
inputValue = dom.toHex(inputValue);
|
||||
currentValue = dom.toHex(currentValue);
|
||||
}
|
||||
|
||||
if (currentValue != inputValue) {
|
||||
outputStyles[webKitStyles[i]] = inputValue;
|
||||
}
|
||||
}
|
||||
|
||||
outputStyles = dom.serializeStyle(outputStyles, 'span');
|
||||
if (outputStyles) {
|
||||
return before + ' style="' + outputStyles + '"' + after;
|
||||
}
|
||||
|
||||
return before + after;
|
||||
});
|
||||
} else {
|
||||
// Remove all external styles
|
||||
content = content.replace(/(<[^>]+) style="([^"]*)"([^>]*>)/gi, '$1$3');
|
||||
}
|
||||
|
||||
// Keep internal styles
|
||||
content = content.replace(/(<[^>]+) data-mce-style="([^"]+)"([^>]*>)/gi, function(all, before, value, after) {
|
||||
return before + ' style="' + value + '"' + after;
|
||||
});
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
// Sniff browsers and apply fixes since we can't feature detect
|
||||
if (Env.webkit) {
|
||||
addPreProcessFilter(removeWebKitStyles);
|
||||
}
|
||||
|
||||
if (Env.ie) {
|
||||
addPreProcessFilter(removeExplorerBrElementsAfterBlocks);
|
||||
}
|
||||
};
|
||||
});
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
/**
|
||||
* Utils.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class contails various utility functions for the paste plugin.
|
||||
*
|
||||
* @class tinymce.pasteplugin.Utils
|
||||
*/
|
||||
define("tinymce/pasteplugin/Utils", [
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/html/DomParser",
|
||||
"tinymce/html/Schema"
|
||||
], function(Tools, DomParser, Schema) {
|
||||
function filter(content, items) {
|
||||
Tools.each(items, function(v) {
|
||||
if (v.constructor == RegExp) {
|
||||
content = content.replace(v, '');
|
||||
} else {
|
||||
content = content.replace(v[0], v[1]);
|
||||
}
|
||||
});
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the innerText of the specified element. It will handle edge cases
|
||||
* and works better than textContent on Gecko.
|
||||
*
|
||||
* @param {String} html HTML string to get text from.
|
||||
* @return {String} String of text with line feeds.
|
||||
*/
|
||||
function innerText(html) {
|
||||
var schema = new Schema(), domParser = new DomParser({}, schema), text = '';
|
||||
var shortEndedElements = schema.getShortEndedElements();
|
||||
var ignoreElements = Tools.makeMap('script noscript style textarea video audio iframe object', ' ');
|
||||
var blockElements = schema.getBlockElements();
|
||||
|
||||
function walk(node) {
|
||||
var name = node.name, currentNode = node;
|
||||
|
||||
if (name === 'br') {
|
||||
text += '\n';
|
||||
return;
|
||||
}
|
||||
|
||||
// img/input/hr
|
||||
if (shortEndedElements[name]) {
|
||||
text += ' ';
|
||||
}
|
||||
|
||||
// Ingore script, video contents
|
||||
if (ignoreElements[name]) {
|
||||
text += ' ';
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.type == 3) {
|
||||
text += node.value;
|
||||
}
|
||||
|
||||
// Walk all children
|
||||
if (!node.shortEnded) {
|
||||
if ((node = node.firstChild)) {
|
||||
do {
|
||||
walk(node);
|
||||
} while ((node = node.next));
|
||||
}
|
||||
}
|
||||
|
||||
// Add \n or \n\n for blocks or P
|
||||
if (blockElements[name] && currentNode.next) {
|
||||
text += '\n';
|
||||
|
||||
if (name == 'p') {
|
||||
text += '\n';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
html = filter(html, [
|
||||
/<!\[[^\]]+\]>/g // Conditional comments
|
||||
]);
|
||||
|
||||
walk(domParser.parse(html));
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trims the specified HTML by removing all WebKit fragments, all elements wrapping the body trailing BR elements etc.
|
||||
*
|
||||
* @param {String} html Html string to trim contents on.
|
||||
* @return {String} Html contents that got trimmed.
|
||||
*/
|
||||
function trimHtml(html) {
|
||||
function trimSpaces(all, s1, s2) {
|
||||
// WebKit meant to preserve multiple spaces but instead inserted around all inline tags,
|
||||
// including the spans with inline styles created on paste
|
||||
if (!s1 && !s2) {
|
||||
return ' ';
|
||||
}
|
||||
|
||||
return '\u00a0';
|
||||
}
|
||||
|
||||
html = filter(html, [
|
||||
/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g, // Remove anything but the contents within the BODY element
|
||||
/<!--StartFragment-->|<!--EndFragment-->/g, // Inner fragments (tables from excel on mac)
|
||||
[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g, trimSpaces],
|
||||
/<br>$/i // Trailing BR elements
|
||||
]);
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
return {
|
||||
filter: filter,
|
||||
innerText: innerText,
|
||||
trimHtml: trimHtml
|
||||
};
|
||||
});
|
||||
+498
@@ -0,0 +1,498 @@
|
||||
/**
|
||||
* WordFilter.js
|
||||
*
|
||||
* Copyright, Moxiecode Systems AB
|
||||
* Released under LGPL License.
|
||||
*
|
||||
* License: http://www.tinymce.com/license
|
||||
* Contributing: http://www.tinymce.com/contributing
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class parses word HTML into proper TinyMCE markup.
|
||||
*
|
||||
* @class tinymce.pasteplugin.WordFilter
|
||||
* @private
|
||||
*/
|
||||
define("tinymce/pasteplugin/WordFilter", [
|
||||
"tinymce/util/Tools",
|
||||
"tinymce/html/DomParser",
|
||||
"tinymce/html/Schema",
|
||||
"tinymce/html/Serializer",
|
||||
"tinymce/html/Node",
|
||||
"tinymce/pasteplugin/Utils"
|
||||
], function(Tools, DomParser, Schema, Serializer, Node, Utils) {
|
||||
/**
|
||||
* Checks if the specified content is from any of the following sources: MS Word/Office 365/Google docs.
|
||||
*/
|
||||
function isWordContent(content) {
|
||||
return (
|
||||
(/<font face="Times New Roman"|class="?Mso|style="[^"]*\bmso-|style='[^'']*\bmso-|w:WordDocument/i).test(content) ||
|
||||
(/class="OutlineElement/).test(content) ||
|
||||
(/id="?docs\-internal\-guid\-/.test(content))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the specified text starts with "1. " or "a. " etc.
|
||||
*/
|
||||
function isNumericList(text) {
|
||||
var found, patterns;
|
||||
|
||||
patterns = [
|
||||
/^[IVXLMCD]{1,2}\.[ \u00a0]/, // Roman upper case
|
||||
/^[ivxlmcd]{1,2}\.[ \u00a0]/, // Roman lower case
|
||||
/^[a-z]{1,2}[\.\)][ \u00a0]/, // Alphabetical a-z
|
||||
/^[A-Z]{1,2}[\.\)][ \u00a0]/, // Alphabetical A-Z
|
||||
/^[0-9]+\.[ \u00a0]/, // Numeric lists
|
||||
/^[\u3007\u4e00\u4e8c\u4e09\u56db\u4e94\u516d\u4e03\u516b\u4e5d]+\.[ \u00a0]/, // Japanese
|
||||
/^[\u58f1\u5f10\u53c2\u56db\u4f0d\u516d\u4e03\u516b\u4e5d\u62fe]+\.[ \u00a0]/ // Chinese
|
||||
];
|
||||
|
||||
text = text.replace(/^[\u00a0 ]+/, '');
|
||||
|
||||
Tools.each(patterns, function(pattern) {
|
||||
if (pattern.test(text)) {
|
||||
found = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
function isBulletList(text) {
|
||||
return /^[\s\u00a0]*[\u2022\u00b7\u00a7\u25CF]\s*/.test(text);
|
||||
}
|
||||
|
||||
function WordFilter(editor) {
|
||||
var settings = editor.settings;
|
||||
|
||||
editor.on('BeforePastePreProcess', function(e) {
|
||||
var content = e.content, retainStyleProperties, validStyles;
|
||||
|
||||
// Remove google docs internal guid markers
|
||||
content = content.replace(/<b[^>]+id="?docs-internal-[^>]*>/gi, '');
|
||||
content = content.replace(/<br class="?Apple-interchange-newline"?>/gi, '');
|
||||
|
||||
retainStyleProperties = settings.paste_retain_style_properties;
|
||||
if (retainStyleProperties) {
|
||||
validStyles = Tools.makeMap(retainStyleProperties.split(/[, ]/));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts fake bullet and numbered lists to real semantic OL/UL.
|
||||
*
|
||||
* @param {tinymce.html.Node} node Root node to convert children of.
|
||||
*/
|
||||
function convertFakeListsToProperLists(node) {
|
||||
var currentListNode, prevListNode, lastLevel = 1;
|
||||
|
||||
function getText(node) {
|
||||
var txt = '';
|
||||
|
||||
if (node.type === 3) {
|
||||
return node.value;
|
||||
}
|
||||
|
||||
if ((node = node.firstChild)) {
|
||||
do {
|
||||
txt += getText(node);
|
||||
} while ((node = node.next));
|
||||
}
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
||||
function trimListStart(node, regExp) {
|
||||
if (node.type === 3) {
|
||||
if (regExp.test(node.value)) {
|
||||
node.value = node.value.replace(regExp, '');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ((node = node.firstChild)) {
|
||||
do {
|
||||
if (!trimListStart(node, regExp)) {
|
||||
return false;
|
||||
}
|
||||
} while ((node = node.next));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function removeIgnoredNodes(node) {
|
||||
if (node._listIgnore) {
|
||||
node.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if ((node = node.firstChild)) {
|
||||
do {
|
||||
removeIgnoredNodes(node);
|
||||
} while ((node = node.next));
|
||||
}
|
||||
}
|
||||
|
||||
function convertParagraphToLi(paragraphNode, listName, start) {
|
||||
var level = paragraphNode._listLevel || lastLevel;
|
||||
|
||||
// Handle list nesting
|
||||
if (level != lastLevel) {
|
||||
if (level < lastLevel) {
|
||||
// Move to parent list
|
||||
if (currentListNode) {
|
||||
currentListNode = currentListNode.parent.parent;
|
||||
}
|
||||
} else {
|
||||
// Create new list
|
||||
prevListNode = currentListNode;
|
||||
currentListNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentListNode || currentListNode.name != listName) {
|
||||
prevListNode = prevListNode || currentListNode;
|
||||
currentListNode = new Node(listName, 1);
|
||||
|
||||
if (start > 1) {
|
||||
currentListNode.attr('start', '' + start);
|
||||
}
|
||||
|
||||
paragraphNode.wrap(currentListNode);
|
||||
} else {
|
||||
currentListNode.append(paragraphNode);
|
||||
}
|
||||
|
||||
paragraphNode.name = 'li';
|
||||
|
||||
// Append list to previous list if it exists
|
||||
if (level > lastLevel && prevListNode) {
|
||||
prevListNode.lastChild.append(currentListNode);
|
||||
}
|
||||
|
||||
lastLevel = level;
|
||||
|
||||
// Remove start of list item "1. " or "· " etc
|
||||
removeIgnoredNodes(paragraphNode);
|
||||
trimListStart(paragraphNode, /^\u00a0+/);
|
||||
trimListStart(paragraphNode, /^\s*([\u2022\u00b7\u00a7\u25CF]|\w+\.)/);
|
||||
trimListStart(paragraphNode, /^\u00a0+/);
|
||||
}
|
||||
|
||||
// Build a list of all root level elements before we start
|
||||
// altering them in the loop below.
|
||||
var elements = [], child = node.firstChild;
|
||||
while (typeof child !== 'undefined' && child !== null) {
|
||||
elements.push(child);
|
||||
|
||||
child = child.walk();
|
||||
if (child !== null) {
|
||||
while (typeof child !== 'undefined' && child.parent !== node) {
|
||||
child = child.walk();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < elements.length; i++) {
|
||||
node = elements[i];
|
||||
|
||||
if (node.name == 'p' && node.firstChild) {
|
||||
// Find first text node in paragraph
|
||||
var nodeText = getText(node);
|
||||
|
||||
// Detect unordered lists look for bullets
|
||||
if (isBulletList(nodeText)) {
|
||||
convertParagraphToLi(node, 'ul');
|
||||
continue;
|
||||
}
|
||||
|
||||
// Detect ordered lists 1., a. or ixv.
|
||||
if (isNumericList(nodeText)) {
|
||||
// Parse OL start number
|
||||
var matches = /([0-9]+)\./.exec(nodeText);
|
||||
var start = 1;
|
||||
if (matches) {
|
||||
start = parseInt(matches[1], 10);
|
||||
}
|
||||
|
||||
convertParagraphToLi(node, 'ol', start);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Convert paragraphs marked as lists but doesn't look like anything
|
||||
if (node._listLevel) {
|
||||
convertParagraphToLi(node, 'ul', 1);
|
||||
continue;
|
||||
}
|
||||
|
||||
currentListNode = null;
|
||||
} else {
|
||||
// If the root level element isn't a p tag which can be
|
||||
// processed by convertParagraphToLi, it interrupts the
|
||||
// lists, causing a new list to start instead of having
|
||||
// elements from the next list inserted above this tag.
|
||||
prevListNode = currentListNode;
|
||||
currentListNode = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filterStyles(node, styleValue) {
|
||||
var outputStyles = {}, matches, styles = editor.dom.parseStyle(styleValue);
|
||||
|
||||
Tools.each(styles, function(value, name) {
|
||||
// Convert various MS styles to W3C styles
|
||||
switch (name) {
|
||||
case 'mso-list':
|
||||
// Parse out list indent level for lists
|
||||
matches = /\w+ \w+([0-9]+)/i.exec(styleValue);
|
||||
if (matches) {
|
||||
node._listLevel = parseInt(matches[1], 10);
|
||||
}
|
||||
|
||||
// Remove these nodes <span style="mso-list:Ignore">o</span>
|
||||
// Since the span gets removed we mark the text node and the span
|
||||
if (/Ignore/i.test(value) && node.firstChild) {
|
||||
node._listIgnore = true;
|
||||
node.firstChild._listIgnore = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "horiz-align":
|
||||
name = "text-align";
|
||||
break;
|
||||
|
||||
case "vert-align":
|
||||
name = "vertical-align";
|
||||
break;
|
||||
|
||||
case "font-color":
|
||||
case "mso-foreground":
|
||||
name = "color";
|
||||
break;
|
||||
|
||||
case "mso-background":
|
||||
case "mso-highlight":
|
||||
name = "background";
|
||||
break;
|
||||
|
||||
case "font-weight":
|
||||
case "font-style":
|
||||
if (value != "normal") {
|
||||
outputStyles[name] = value;
|
||||
}
|
||||
return;
|
||||
|
||||
case "mso-element":
|
||||
// Remove track changes code
|
||||
if (/^(comment|comment-list)$/i.test(value)) {
|
||||
node.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (name.indexOf('mso-comment') === 0) {
|
||||
node.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
// Never allow mso- prefixed names
|
||||
if (name.indexOf('mso-') === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Output only valid styles
|
||||
if (retainStyleProperties == "all" || (validStyles && validStyles[name])) {
|
||||
outputStyles[name] = value;
|
||||
}
|
||||
});
|
||||
|
||||
// Convert bold style to "b" element
|
||||
if (/(bold)/i.test(outputStyles["font-weight"])) {
|
||||
delete outputStyles["font-weight"];
|
||||
node.wrap(new Node("b", 1));
|
||||
}
|
||||
|
||||
// Convert italic style to "i" element
|
||||
if (/(italic)/i.test(outputStyles["font-style"])) {
|
||||
delete outputStyles["font-style"];
|
||||
node.wrap(new Node("i", 1));
|
||||
}
|
||||
|
||||
// Serialize the styles and see if there is something left to keep
|
||||
outputStyles = editor.dom.serializeStyle(outputStyles, node.name);
|
||||
if (outputStyles) {
|
||||
return outputStyles;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
if (settings.paste_enable_default_filters === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Detect is the contents is Word junk HTML
|
||||
if (isWordContent(e.content)) {
|
||||
e.wordContent = true; // Mark it for other processors
|
||||
|
||||
// Remove basic Word junk
|
||||
content = Utils.filter(content, [
|
||||
// Word comments like conditional comments etc
|
||||
/<!--[\s\S]+?-->/gi,
|
||||
|
||||
// Remove comments, scripts (e.g., msoShowComment), XML tag, VML content,
|
||||
// MS Office namespaced tags, and a few other tags
|
||||
/<(!|script[^>]*>.*?<\/script(?=[>\s])|\/?(\?xml(:\w+)?|img|meta|link|style|\w:\w+)(?=[\s\/>]))[^>]*>/gi,
|
||||
|
||||
// Convert <s> into <strike> for line-though
|
||||
[/<(\/?)s>/gi, "<$1strike>"],
|
||||
|
||||
// Replace nsbp entites to char since it's easier to handle
|
||||
[/ /gi, "\u00a0"],
|
||||
|
||||
// Convert <span style="mso-spacerun:yes">___</span> to string of alternating
|
||||
// breaking/non-breaking spaces of same length
|
||||
[/<span\s+style\s*=\s*"\s*mso-spacerun\s*:\s*yes\s*;?\s*"\s*>([\s\u00a0]*)<\/span>/gi,
|
||||
function(str, spaces) {
|
||||
return (spaces.length > 0) ?
|
||||
spaces.replace(/./, " ").slice(Math.floor(spaces.length / 2)).split("").join("\u00a0") : "";
|
||||
}
|
||||
]
|
||||
]);
|
||||
|
||||
var validElements = settings.paste_word_valid_elements;
|
||||
if (!validElements) {
|
||||
validElements = (
|
||||
'-strong/b,-em/i,-u,-span,-p,-ol,-ul,-li,-h1,-h2,-h3,-h4,-h5,-h6,' +
|
||||
'-p/div,-a[href|name],sub,sup,strike,br,del,table[width],tr,' +
|
||||
'td[colspan|rowspan|width],th[colspan|rowspan|width],thead,tfoot,tbody'
|
||||
);
|
||||
}
|
||||
|
||||
// Setup strict schema
|
||||
var schema = new Schema({
|
||||
valid_elements: validElements,
|
||||
valid_children: '-li[p]'
|
||||
});
|
||||
|
||||
// Add style/class attribute to all element rules since the user might have removed them from
|
||||
// paste_word_valid_elements config option and we need to check them for properties
|
||||
Tools.each(schema.elements, function(rule) {
|
||||
/*eslint dot-notation:0*/
|
||||
if (!rule.attributes["class"]) {
|
||||
rule.attributes["class"] = {};
|
||||
rule.attributesOrder.push("class");
|
||||
}
|
||||
|
||||
if (!rule.attributes.style) {
|
||||
rule.attributes.style = {};
|
||||
rule.attributesOrder.push("style");
|
||||
}
|
||||
});
|
||||
|
||||
// Parse HTML into DOM structure
|
||||
var domParser = new DomParser({}, schema);
|
||||
|
||||
// Filter styles to remove "mso" specific styles and convert some of them
|
||||
domParser.addAttributeFilter('style', function(nodes) {
|
||||
var i = nodes.length, node;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
node.attr('style', filterStyles(node, node.attr('style')));
|
||||
|
||||
// Remove pointess spans
|
||||
if (node.name == 'span' && node.parent && !node.attributes.length) {
|
||||
node.unwrap();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Check the class attribute for comments or del items and remove those
|
||||
domParser.addAttributeFilter('class', function(nodes) {
|
||||
var i = nodes.length, node, className;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
|
||||
className = node.attr('class');
|
||||
if (/^(MsoCommentReference|MsoCommentText|msoDel)$/i.test(className)) {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
node.attr('class', null);
|
||||
}
|
||||
});
|
||||
|
||||
// Remove all del elements since we don't want the track changes code in the editor
|
||||
domParser.addNodeFilter('del', function(nodes) {
|
||||
var i = nodes.length;
|
||||
|
||||
while (i--) {
|
||||
nodes[i].remove();
|
||||
}
|
||||
});
|
||||
|
||||
// Keep some of the links and anchors
|
||||
domParser.addNodeFilter('a', function(nodes) {
|
||||
var i = nodes.length, node, href, name;
|
||||
|
||||
while (i--) {
|
||||
node = nodes[i];
|
||||
href = node.attr('href');
|
||||
name = node.attr('name');
|
||||
|
||||
if (href && href.indexOf('#_msocom_') != -1) {
|
||||
node.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (href && href.indexOf('file://') === 0) {
|
||||
href = href.split('#')[1];
|
||||
if (href) {
|
||||
href = '#' + href;
|
||||
}
|
||||
}
|
||||
|
||||
if (!href && !name) {
|
||||
node.unwrap();
|
||||
} else {
|
||||
// Remove all named anchors that aren't specific to TOC, Footnotes or Endnotes
|
||||
if (name && !/^_?(?:toc|edn|ftn)/i.test(name)) {
|
||||
node.unwrap();
|
||||
continue;
|
||||
}
|
||||
|
||||
node.attr({
|
||||
href: href,
|
||||
name: name
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Parse into DOM structure
|
||||
var rootNode = domParser.parse(content);
|
||||
|
||||
// Process DOM
|
||||
if (settings.paste_convert_word_fake_lists !== false) {
|
||||
convertFakeListsToProperLists(rootNode);
|
||||
}
|
||||
|
||||
// Serialize DOM back to HTML
|
||||
e.content = new Serializer({}, schema).serialize(rootNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
WordFilter.isWordContent = isWordContent;
|
||||
|
||||
return WordFilter;
|
||||
});
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Inline development version. Only to be used while developing since it uses document.write to load scripts.
|
||||
*/
|
||||
|
||||
/*jshint smarttabs:true, undef:true, latedef:true, curly:true, bitwise:true, camelcase:true */
|
||||
/*globals $code */
|
||||
|
||||
(function(exports) {
|
||||
"use strict";
|
||||
|
||||
var html = "", baseDir;
|
||||
var modules = {}, exposedModules = [], moduleCount = 0;
|
||||
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
for (var i = 0; i < scripts.length; i++) {
|
||||
var src = scripts[i].src;
|
||||
|
||||
if (src.indexOf('/plugin.dev.js') != -1) {
|
||||
baseDir = src.substring(0, src.lastIndexOf('/'));
|
||||
}
|
||||
}
|
||||
|
||||
function require(ids, callback) {
|
||||
var module, defs = [];
|
||||
|
||||
for (var i = 0; i < ids.length; ++i) {
|
||||
module = modules[ids[i]] || resolve(ids[i]);
|
||||
if (!module) {
|
||||
throw 'module definition dependecy not found: ' + ids[i];
|
||||
}
|
||||
|
||||
defs.push(module);
|
||||
}
|
||||
|
||||
callback.apply(null, defs);
|
||||
}
|
||||
|
||||
function resolve(id) {
|
||||
var target = exports;
|
||||
var fragments = id.split(/[.\/]/);
|
||||
|
||||
for (var fi = 0; fi < fragments.length; ++fi) {
|
||||
if (!target[fragments[fi]]) {
|
||||
return;
|
||||
}
|
||||
|
||||
target = target[fragments[fi]];
|
||||
}
|
||||
|
||||
return target;
|
||||
}
|
||||
|
||||
function register(id) {
|
||||
var target = exports;
|
||||
var fragments = id.split(/[.\/]/);
|
||||
|
||||
for (var fi = 0; fi < fragments.length - 1; ++fi) {
|
||||
if (target[fragments[fi]] === undefined) {
|
||||
target[fragments[fi]] = {};
|
||||
}
|
||||
|
||||
target = target[fragments[fi]];
|
||||
}
|
||||
|
||||
target[fragments[fragments.length - 1]] = modules[id];
|
||||
}
|
||||
|
||||
function define(id, dependencies, definition) {
|
||||
if (typeof id !== 'string') {
|
||||
throw 'invalid module definition, module id must be defined and be a string';
|
||||
}
|
||||
|
||||
if (dependencies === undefined) {
|
||||
throw 'invalid module definition, dependencies must be specified';
|
||||
}
|
||||
|
||||
if (definition === undefined) {
|
||||
throw 'invalid module definition, definition function must be specified';
|
||||
}
|
||||
|
||||
require(dependencies, function() {
|
||||
modules[id] = definition.apply(null, arguments);
|
||||
});
|
||||
|
||||
if (--moduleCount === 0) {
|
||||
for (var i = 0; i < exposedModules.length; i++) {
|
||||
register(exposedModules[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function expose(ids) {
|
||||
exposedModules = ids;
|
||||
}
|
||||
|
||||
function writeScripts() {
|
||||
document.write(html);
|
||||
}
|
||||
|
||||
function load(path) {
|
||||
html += '<script type="text/javascript" src="' + baseDir + '/' + path + '"></script>\n';
|
||||
moduleCount++;
|
||||
}
|
||||
|
||||
// Expose globally
|
||||
exports.define = define;
|
||||
exports.require = require;
|
||||
|
||||
expose(["tinymce/pasteplugin/Utils"]);
|
||||
|
||||
load('classes/Utils.js');
|
||||
load('classes/Clipboard.js');
|
||||
load('classes/WordFilter.js');
|
||||
load('classes/Quirks.js');
|
||||
load('classes/Plugin.js');
|
||||
|
||||
writeScripts();
|
||||
})(this);
|
||||
|
||||
// $hash: 81d4a05c04adf0776e1e2ca9a3e818bd
|
||||
Executable
+1606
File diff suppressed because it is too large.
Load diff
+1
@@ -0,0 +1 @@
|
||||
!function(a,b){"use strict";function c(a,b){for(var c,d=[],f=0;f<a.length;++f){if(c=g[a[f]]||e(a[f]),!c)throw"module definition dependecy not found: "+a[f];d.push(c)}b.apply(null,d)}function d(a,d,e){if("string"!=typeof a)throw"invalid module definition, module id must be defined and be a string";if(d===b)throw"invalid module definition, dependencies must be specified";if(e===b)throw"invalid module definition, definition function must be specified";c(d,function(){g[a]=e.apply(null,arguments)})}function e(b){for(var c=a,d=b.split(/[.\/]/),e=0;e<d.length;++e){if(!c[d[e]])return;c=c[d[e]]}return c}function f(c){for(var d=0;d<c.length;d++){for(var e=a,f=c[d],h=f.split(/[.\/]/),i=0;i<h.length-1;++i)e[h[i]]===b&&(e[h[i]]={}),e=e[h[i]];e[h[h.length-1]]=g[f]}}var g={};d("tinymce/pasteplugin/Utils",["tinymce/util/Tools","tinymce/html/DomParser","tinymce/html/Schema"],function(a,b,c){function d(b,c){return a.each(c,function(a){b=a.constructor==RegExp?b.replace(a,""):b.replace(a[0],a[1])}),b}function e(e){function f(a){var b=a.name,c=a;if("br"===b)return void(i+="\n");if(j[b]&&(i+=" "),k[b])return void(i+=" ");if(3==a.type&&(i+=a.value),!a.shortEnded&&(a=a.firstChild))do f(a);while(a=a.next);l[b]&&c.next&&(i+="\n","p"==b&&(i+="\n"))}var g=new c,h=new b({},g),i="",j=g.getShortEndedElements(),k=a.makeMap("script noscript style textarea video audio iframe object"," "),l=g.getBlockElements();return e=d(e,[/<!\[[^\]]+\]>/g]),f(h.parse(e)),i}function f(a){function b(a,b,c){return b||c?"\xa0":" "}return a=d(a,[/^[\s\S]*<body[^>]*>\s*|\s*<\/body[^>]*>[\s\S]*$/g,/<!--StartFragment-->|<!--EndFragment-->/g,[/( ?)<span class="Apple-converted-space">\u00a0<\/span>( ?)/g,b],/<br>$/i])}return{filter:d,innerText:e,trimHtml:f}}),d("tinymce/pasteplugin/Clipboard",["tinymce/Env","tinymce/dom/RangeUtils","tinymce/util/VK","tinymce/pasteplugin/Utils"],function(a,b,c,d){return function(e){function f(a){var b,c=e.dom;if(b=e.fire("BeforePastePreProcess",{content:a}),b=e.fire("PastePreProcess",b),a=b.content,!b.isDefaultPrevented()){if(e.hasEventListeners("PastePostProcess")&&!b.isDefaultPrevented()){var d=c.add(e.getBody(),"div",{style:"display:none"},a);b=e.fire("PastePostProcess",{node:d}),c.remove(d),a=b.node.innerHTML}b.isDefaultPrevented()||e.insertContent(a,{merge:e.settings.paste_merge_formats!==!1})}}function g(a){a=e.dom.encode(a).replace(/\r\n/g,"\n");var b,c=e.dom.getParent(e.selection.getStart(),e.dom.isBlock),g=e.settings.forced_root_block;g&&(b=e.dom.createHTML(g,e.settings.forced_root_block_attrs),b=b.substr(0,b.length-3)+">"),c&&/^(PRE|DIV)$/.test(c.nodeName)||!g?a=d.filter(a,[[/\n/g,"<br>"]]):(a=d.filter(a,[[/\n\n/g,"</p>"+b],[/^(.*<\/p>)(<p>)$/,b+"$1"],[/\n/g,"<br />"]]),-1!=a.indexOf("<p>")&&(a=b+a)),f(a)}function h(){function b(a){var b,c,e,f=a.startContainer;if(b=a.getClientRects(),b.length)return b[0];if(a.collapsed&&1==f.nodeType){for(e=f.childNodes[t.startOffset];e&&3==e.nodeType&&!e.data.length;)e=e.nextSibling;if(e)return"BR"==e.tagName&&(c=d.doc.createTextNode("\ufeff"),e.parentNode.insertBefore(c,e),a=d.createRng(),a.setStartBefore(c),a.setEndAfter(c),b=a.getClientRects(),d.remove(c)),b.length?b[0]:void 0}}var c,d=e.dom,f=e.getBody(),g=e.dom.getViewPort(e.getWin()),h=g.y,i=20;if(t=e.selection.getRng(),e.inline&&(c=e.selection.getScrollContainer(),c&&c.scrollTop>0&&(h=c.scrollTop)),t.getClientRects){var j=b(t);if(j)i=h+(j.top-d.getPos(f).y);else{i=h;var k=t.startContainer;k&&(3==k.nodeType&&k.parentNode!=f&&(k=k.parentNode),1==k.nodeType&&(i=d.getPos(k,c||f).y))}}s=d.add(e.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"all",style:"position: absolute; top: "+i+"px;width: 10px; height: 10px; overflow: hidden; opacity: 0"},y),(a.ie||a.gecko)&&d.setStyle(s,"left","rtl"==d.getStyle(f,"direction",!0)?65535:-65535),d.bind(s,"beforedeactivate focusin focusout",function(a){a.stopPropagation()}),s.focus(),e.selection.select(s,!0)}function i(){if(s){for(var a;a=e.dom.get("mcepastebin");)e.dom.remove(a),e.dom.unbind(a);t&&e.selection.setRng(t)}s=t=null}function j(){var a,b,c,d,f="";for(a=e.dom.select("div[id=mcepastebin]"),b=0;b<a.length;b++)c=a[b],c.firstChild&&"mcepastebin"==c.firstChild.id&&(c=c.firstChild),d=c.innerHTML,f!=y&&(f+=d);return f}function k(a){var b={};if(a){if(a.getData){var c=a.getData("Text");c&&c.length>0&&-1==c.indexOf(z)&&(b["text/plain"]=c)}if(a.types)for(var d=0;d<a.types.length;d++){var e=a.types[d];b[e]=a.getData(e)}}return b}function l(a){return k(a.clipboardData||e.getDoc().dataTransfer)}function m(a,b){function c(c){function d(a){b&&(e.selection.setRng(b),b=null),f('<img src="'+a.result+'">')}var g,h,i,j=!1;if(c)for(g=0;g<c.length;g++)h=c[g],/^image\/(jpeg|png|gif|bmp)$/.test(h.type)&&(i=new FileReader,i.onload=d.bind(null,i),i.readAsDataURL(h.getAsFile?h.getAsFile():h),a.preventDefault(),j=!0);return j}var d=a.clipboardData||a.dataTransfer;return e.settings.paste_data_images&&d?c(d.items)||c(d.files):void 0}function n(a){var b=a.clipboardData;return-1!=navigator.userAgent.Line truncated
|
||||
@@ -39846,7 +39846,7 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
LEAUI_DATAS = datas;
|
||||
|
||||
function GetTheHtml(){
|
||||
var html = '<iframe id="leauiIfr" src="'+ url + '/index.html'+ '?' + new Date().getTime() + '" frameborder="0"></iframe>';
|
||||
var html = '<iframe id="leauiIfr" src="/album/index'+ '?' + new Date().getTime() + '" frameborder="0"></iframe>';
|
||||
return html;
|
||||
}
|
||||
|
||||
@@ -39991,16 +39991,24 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
|
||||
// 为解决在editor里拖动图片问题
|
||||
// 2014/7/8 21:43 浮躁的一天终有收获
|
||||
// 2015/10/16
|
||||
var dragStart = false;
|
||||
editor.on("dragstart", function(e) {
|
||||
// readonly时不让drag图片
|
||||
if (LEA.readOnly) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
dragStart = true;
|
||||
});
|
||||
editor.on("dragend", function(e) {
|
||||
dragStart = false;
|
||||
});
|
||||
editor.on("dragover", function(e) {
|
||||
if(!dragStart) {
|
||||
$("body").trigger("dragover");
|
||||
if(dragStart) {
|
||||
// 表示编辑器内在拖动图片, 则停止冒泡
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -43215,26 +43223,27 @@ tinymce.PluginManager.add('leanote_code', function(editor, url) {
|
||||
var num = e.which ? e.which : e.keyCode;
|
||||
if (num == 9) { // tab pressed
|
||||
if(!e.shiftKey) {
|
||||
// ed.execCommand('Indent');
|
||||
// TODO 如果当前在li, ul, ol下不执行!!
|
||||
// 如果在pre下就加tab
|
||||
// var node = ed.selection.getNode();
|
||||
/*
|
||||
if(node.nodeName == "PRE") {
|
||||
ed.execCommand('mceInsertHTML', false, '\x09'); // inserts tab
|
||||
} else {
|
||||
*/
|
||||
// 如果是在li下的, 就不要控制
|
||||
var node = ed.selection.getNode();
|
||||
if (node && node.nodeName === 'LI') {
|
||||
return true;
|
||||
}
|
||||
ed.insertContent(" ");
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
// ed.execCommand('mceInsertHTML', false, " "); // inserts 空格
|
||||
// }
|
||||
} else {
|
||||
// delete 4 个空格
|
||||
// ed.execCommand('Outdent');
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
});/**
|
||||
|
||||
Vendored
+1
-1
@@ -12,4 +12,4 @@ s=n.offsetHeight,l=r.clientWidth,c=r.clientHeight,"end"==e?(i-=l-a,o-=c-s):"cent
|
||||
if(!u(t)&&t.keyCode==e.BACKSPACE&&(n=Q.getRng(),r=n.startContainer,i=n.startOffset,o=J.getRoot(),a=r,n.collapsed&&0===i)){for(;a&&a.parentNode&&a.parentNode.firstChild==a&&a.parentNode!=o;)a=a.parentNode;"BLOCKQUOTE"===a.tagName&&(s.formatter.toggle("blockquote",null,a),n=J.createRng(),n.setStart(r,0),n.setEnd(r,0),Q.setRng(n))}})}function S(){function e(){s._refreshContentEditable(),l("StyleWithCSS",!1),l("enableInlineTableEditing",!1),Z.object_resizing||l("enableObjectResizing",!1)}Z.readonly||s.on("BeforeExecCommand MouseDown",e)}function T(){function e(){K(J.select("a"),function(e){var t=e.parentNode,n=J.getRoot();if(t.lastChild===e){for(;t&&!J.isBlock(t);){if(t.parentNode.lastChild!==t||t===n)return;t=t.parentNode}J.add(t,"br",{"data-mce-bogus":1})}})}s.on("SetContent ExecCommand",function(t){("setcontent"==t.type||"mceInsertLink"===t.command)&&e()})}function R(){Z.forced_root_block&&s.on("init",function(){l("DefaultParagraphSeparator",Z.forced_root_block)})}function A(){s.on("Undo Redo SetContent",function(e){e.initial||s.execCommand("mceRepaint")})}function B(){s.on("keydown",function(e){var t;u(e)||e.keyCode!=G||(t=s.getDoc().selection.createRange(),t&&t.item&&(e.preventDefault(),s.undoManager.beforeChange(),J.remove(t.item(0)),s.undoManager.add()))})}function D(){var e;c()>=10&&(e="",K("p div h1 h2 h3 h4 h5 h6".split(" "),function(t,n){e+=(n>0?",":"")+t+":empty"}),s.contentStyles.push(e+"{padding-right: 1px !important}"))}function L(){c()<9&&(ee.addNodeFilter("noscript",function(e){for(var t=e.length,n,r;t--;)n=e[t],r=n.firstChild,r&&n.attr("data-mce-innertext",r.value)}),te.addNodeFilter("noscript",function(e){for(var t=e.length,n,o,a;t--;)n=e[t],o=e[t].firstChild,o?o.value=i.decode(o.value):(a=n.attributes.map["data-mce-innertext"],a&&(n.attr("data-mce-innertext",null),o=new r("#text",3),o.value=a,o.raw=!0,n.append(o)))}))}function M(){function e(e,t){var n=i.createTextRange();try{n.moveToPoint(e,t)}catch(r){n=null}return n}function t(t){var r;t.button?(r=e(t.x,t.y),r&&(r.compareEndPoints("StartToStart",a)>0?r.setEndPoint("StartToStart",a):r.setEndPoint("EndToEnd",a),r.select())):n()}function n(){var e=r.selection.createRange();a&&!e.item&&0===e.compareEndPoints("StartToEnd",e)&&a.select(),J.unbind(r,"mouseup",n),J.unbind(r,"mousemove",t),a=o=0}var r=J.doc,i=r.body,o,a,s;r.documentElement.unselectable=!0,J.bind(r,"mousedown contextmenu",function(i){if("HTML"===i.target.nodeName){if(o&&n(),s=r.documentElement,s.scrollHeight>s.clientHeight)return;o=1,a=e(i.x,i.y),a&&(J.bind(r,"mouseup",n),J.bind(r,"mousemove",t),J.getRoot().focus(),a.select())}})}function H(){s.on("keyup focusin mouseup",function(t){65==t.keyCode&&e.metaKeyPressed(t)||Q.normalize()},!0)}function P(){s.contentStyles.push("img:-moz-broken {-moz-force-broken-image-icon:1;min-width:24px;min-height:24px}")}function O(){s.inline||s.on("keydown",function(){document.activeElement==document.body&&s.getWin().focus()})}function I(){s.inline||(s.contentStyles.push("body {min-height: 150px}"),s.on("click",function(e){if("HTML"==e.target.nodeName){var t;t=s.selection.getRng(),s.getBody().focus(),s.selection.setRng(t),s.selection.normalize(),s.nodeChanged()}}))}function F(){o.mac&&s.on("keydown",function(t){!e.metaKeyPressed(t)||37!=t.keyCode&&39!=t.keyCode||(t.preventDefault(),s.selection.getSel().modify("move",37==t.keyCode?"backward":"forward","word"))})}function z(){l("AutoUrlDetect",!1)}function W(){s.inline||s.on("focus blur beforegetcontent",function(){var e=s.dom.create("br");s.getBody().appendChild(e),e.parentNode.removeChild(e)},!0)}function V(){s.on("click",function(e){var t=e.target;do if("A"===t.tagName)return void e.preventDefault();while(t=t.parentNode)}),s.contentStyles.push(".mce-content-body {-webkit-touch-callout: none}")}function $(){s.on("touchstart",function(e){var t,n,r,i;t=e.target,n=(new Date).getTime(),i=e.changedTouches,!i||i.length>1||(r=i[0],s.once("touchend",function(e){var i=e.changedTouches[0],o;(new Date).getTime()-n>500||Math.abs(r.clientX-i.clientX)>5||Math.abs(r.clientY-i.clientY)>5||(o={target:t},K("pageX pageY clientX clientY screenX screenY".split(" "),function(e){o[e]=i[e]}),o=s.fire("click",o),o.isDefaultPrevented()||(s.selection.placeCaretAt(i.clientX,i.clientY),s.nodeChanged()))}))})}function U(){s.on("init",function(){s.dom.bind(s.getBody(),"submit",function(e){e.preventDefault()})})}function q(){ee.addNodeFilter("br",function(e){for(var t=e.length;t--;)"Apple-interchange-newline"==e[t].attr("class")&&e[t].remove()})}function j(){s.on("dragstart",function(e){d(e)}),s.on("drop",function(e){if(!u(e)){var n=f(e);if(n){e.preventDefault();var r=t.getCaretRangeFromPoint(e.x,e.y,s.getDoc());Q.setRng(r),p(n)}}})}var K=a.each,Y=s.$,G=e.BACKSPACE,X=e.DELETE,J=s.dom,Q=s.selection,Z=s.settings,ee=s.parser,te=s.serializer,ne=o.gecko,re=o.ie,ie=o.webkit,oe="data:text/mce-internal,",ae=re?"Text":"URL";k(),m(),H(),ie&&(h(),v(),C(),R(),U(),_(),q(),$(),o.iOS?(O(),I(),V()):g()),re&&o.ie<11&&(y(),w(),E(),N(),B(),D(),L(),MLine truncated
|
||||
var e,s;if(d.unbind(window,"ready",a),i("onpageload"),t.types)return void p(t.types,function(e){p(d.select(e.selector),function(i){r(n(i),h({},t,e),i)})});if(t.selector)return void p(d.select(t.selector),function(e){r(n(e),t,e)});switch(t.target&&r(n(t.target),t),t.mode){case"exact":e=t.elements||"",e.length>0&&p(f(e),function(e){var n;(n=d.get(e))?r(e,t,n):p(document.forms,function(n){p(n.elements,function(n){n.name===e&&(e="mce_editor_"+m++,d.setAttrib(n,"id",e),r(e,t,n))})})});break;case"textareas":case"specific_textareas":p(d.select("textarea"),function(e){t.editor_deselector&&o(e,t.editor_deselector)||(!t.editor_selector||o(e,t.editor_selector))&&r(n(e),t,e)})}t.oninit&&(e=s=0,p(l,function(t){s++,t.initialized?e++:t.on("init",function(){e++,e==s&&i("oninit")}),e==s&&i("oninit")}))}var s=this,l=[];s.settings=t,d.bind(window,"ready",a)},get:function(e){return arguments.length?e in this.editors?this.editors[e]:null:this.editors},add:function(e){var t=this,n=t.editors;return n[e.id]=e,n.push(e),t.activeEditor=e,t.fire("AddEditor",{editor:e}),g||(g=function(){t.fire("BeforeUnload")},d.bind(window,"beforeunload",g)),e},createEditor:function(t,n){return this.add(new e(t,n,this))},remove:function(e){var t=this,n,r=t.editors,i;{if(e)return"string"==typeof e?(e=e.selector||e,void p(d.select(e),function(e){i=r[e.id],i&&t.remove(i)})):(i=e,r[i.id]?(c(i)&&t.fire("RemoveEditor",{editor:i}),r.length||d.unbind(window,"beforeunload",g),i.remove(),i):null);for(n=r.length-1;n>=0;n--)t.remove(r[n])}},execCommand:function(t,n,r){var i=this,o=i.get(r);switch(t){case"mceAddEditor":return i.get(r)||new e(r,i.settings,i).render(),!0;case"mceRemoveEditor":return o&&o.remove(),!0;case"mceToggleEditor":return o?(o.isHidden()?o.show():o.hide(),!0):(i.execCommand("mceAddEditor",0,r),!0)}return i.activeEditor?i.activeEditor.execCommand(t,n,r):!1},triggerSave:function(){p(this.editors,function(e){e.save()})},addI18n:function(e,t){s.add(e,t)},translate:function(e){return s.translate(e)},setActive:function(e){var t=this.activeEditor;this.activeEditor!=e&&(t&&t.fire("deactivate",{relatedTarget:e}),e.fire("activate",{relatedTarget:t})),this.activeEditor=e}},h(v,a),v.setup(),window.tinymce=window.tinyMCE=v,v}),r(ge,[me,d],function(e,t){var n=t.each,r=t.explode;e.on("AddEditor",function(e){var t=e.editor;t.on("preInit",function(){function e(e,t){n(t,function(t,n){t&&s.setStyle(e,n,t)}),s.rename(e,"span")}function i(e){s=t.dom,l.convert_fonts_to_spans&&n(s.select("font,u,strike",e.node),function(e){o[e.nodeName.toLowerCase()](s,e)})}var o,a,s,l=t.settings;l.inline_styles&&(a=r(l.font_size_legacy_values),o={font:function(t,n){e(n,{backgroundColor:n.style.backgroundColor,color:n.color,fontFamily:n.face,fontSize:a[parseInt(n.size,10)-1]})},u:function(n,r){"html4"===t.settings.schema&&e(r,{textDecoration:"underline"})},strike:function(t,n){e(n,{textDecoration:"line-through"})}},t.on("PreProcess SetContent",i))})})}),r(ve,[ce,d],function(e,t){var n={send:function(e){function t(){!e.async||4==r.readyState||i++>1e4?(e.success&&1e4>i&&200==r.status?e.success.call(e.success_scope,""+r.responseText,r,e):e.error&&e.error.call(e.error_scope,i>1e4?"TIMED_OUT":"GENERAL",r,e),r=null):setTimeout(t,10)}var r,i=0;if(e.scope=e.scope||this,e.success_scope=e.success_scope||e.scope,e.error_scope=e.error_scope||e.scope,e.async=e.async===!1?!1:!0,e.data=e.data||"",r=new XMLHttpRequest){if(r.overrideMimeType&&r.overrideMimeType(e.content_type),r.open(e.type||(e.data?"POST":"GET"),e.url,e.async),e.crossDomain&&(r.withCredentials=!0),e.content_type&&r.setRequestHeader("Content-Type",e.content_type),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r=n.fire("beforeSend",{xhr:r,settings:e}).xhr,r.send(e.data),!e.async)return t();setTimeout(t,10)}}};return t.extend(n,e),n}),r(ye,[],function(){function e(t,n){var r,i,o,a;if(n=n||'"',null===t)return"null";if(o=typeof t,"string"==o)return i="\bb t\nn\ff\rr\"\"''\\\\",n+t.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(e,t){return'"'===n&&"'"===e?e:(r=i.indexOf(t),r+1?"\\"+i.charAt(r+1):(e=t.charCodeAt().toString(16),"\\u"+"0000".substring(e.length)+e))})+n;if("object"==o){if(t.hasOwnProperty&&"[object Array]"===Object.prototype.toString.call(t)){for(r=0,i="[";r<t.length;r++)i+=(r>0?",":"")+e(t[r],n);return i+"]"}i="{";for(a in t)t.hasOwnProperty(a)&&(i+="function"!=typeof t[a]?(i.length>1?","+n:n)+a+n+":"+e(t[a],n):"");return i+"}"}return""+t}return{serialize:e,parse:function(e){try{return window[String.fromCharCode(101)+"val"]("("+e+")")}catch(t){}}}}),r(be,[ye,ve,d],function(e,t,n){function r(e){this.settings=i({},e),this.count=0}var i=n.extend;return r.sendRPC=function(e){return(new r).send(e)},r.prototype={send:function(n){var r=n.error,o=n.success;n=i(this.settings,n),n.success=function(t,i){t=e.parse(t),"undefined"==typeof t&&(t={error:"JSON Parse error."}),t.error?r.call(n.error_scope||n.scope,t.error,i):o.call(n.success_scope||n.scope,t.result)},n.error=function(e,t){r&&r.call(n.error_scope||n.scope,e,tLine truncated
|
||||
|
||||
})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(je,[Ee],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;fLine truncated
|
||||
})})},onclick:function(){l(n)}})}),s({outdent:["Decrease indent","Outdent"],indent:["Increase indent","Indent"],cut:["Cut","Cut"],copy:["Copy","Copy"],paste:["Paste","Paste"],help:["Help","mceHelp"],selectall:["Select all","SelectAll"],removeformat:["Clear formatting","RemoveFormat"],visualaid:["Visual aids","mceToggleVisualAid"],newdocument:["New document","mceNewDocument"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1]})}),s({blockquote:["Blockquote","mceBlockQuote"],numlist:["Numbered list","InsertOrderedList"],bullist:["Bullet list","InsertUnorderedList"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],alignleft:["Align left","JustifyLeft"],aligncenter:["Align center","JustifyCenter"],alignright:["Align right","JustifyRight"],alignjustify:["Justify","JustifyFull"]},function(t,n){e.addButton(n,{tooltip:t[0],cmd:t[1],onPostRender:function(){var t=this;e.formatter?e.formatter.formatChanged(n,function(e){t.active(e)}):e.on("init",function(){e.formatter.formatChanged(n,function(e){t.active(e)})})}})}),e.addButton("undo",{tooltip:"Undo",onPostRender:o("undo"),cmd:"undo"}),e.addButton("redo",{tooltip:"Redo",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("newdocument",{text:"New document",icon:"newdocument",cmd:"mceNewDocument"}),e.addMenuItem("undo",{text:"Undo",icon:"undo",shortcut:"Meta+Z",onPostRender:o("undo"),cmd:"undo"}),e.addMenuItem("redo",{text:"Redo",icon:"redo",shortcut:"Meta+Y",onPostRender:o("redo"),cmd:"redo"}),e.addMenuItem("visualaid",{text:"Visual aids",selectable:!0,onPostRender:a,cmd:"mceToggleVisualAid"}),s({cut:["Cut","Cut","Meta+X"],copy:["Copy","Copy","Meta+C"],paste:["Paste","Paste","Meta+V"],selectall:["Select all","SelectAll","Meta+A"],bold:["Bold","Bold","Meta+B"],italic:["Italic","Italic","Meta+I"],underline:["Underline","Underline"],strikethrough:["Strikethrough","Strikethrough"],subscript:["Subscript","Subscript"],superscript:["Superscript","Superscript"],removeformat:["Clear formatting","RemoveFormat"]},function(t,n){e.addMenuItem(n,{text:t[0],icon:n,shortcut:t[2],cmd:t[1]})}),e.on("mousedown",function(){n.hideAll()}),e.addButton("styleselect",{type:"menubutton",text:"Formats",menu:c}),e.addButton("formatselect",function(){var n=[],i=r(e.settings.block_formats||"Paragraph=p;Heading 1=h1;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Preformatted=pre");return s(i,function(t){n.push({text:t[0],value:t[1],textStyle:function(){return e.formatter.getCssText(t[1])}})}),{type:"listbox",text:i[0][0],values:n,fixedWidth:!0,onselect:l,onPostRender:t(n)}}),e.addButton("fontselect",function(){var n="Andale Mono=andale mono,monospace;Arial=arial,helvetica,sans-serif;Arial Black=arial black,sans-serif;Book Antiqua=book antiqua,palatino,serif;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,palatino,serif;Helvetica=helvetica,arial,sans-serif;Impact=impact,sans-serif;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco,monospace;Times New Roman=times new roman,times,serif;Trebuchet MS=trebuchet ms,geneva,sans-serif;Verdana=verdana,geneva,sans-serif;Webdings=webdings;Wingdings=wingdings,zapf dingbats",i=[],o=r(e.settings.font_formats||n);return s(o,function(e){i.push({text:{raw:e[0]},value:e[1],textStyle:-1==e[1].indexOf("dings")?"font-family:"+e[1]:""})}),{type:"listbox",text:"Font Family",tooltip:"Font Family",values:i,fixedWidth:!0,onPostRender:t(i,"fontname"),onselect:function(t){t.control.settings.value&&e.execCommand("FontName",!1,t.control.settings.value)}}}),e.addButton("fontsizeselect",function(){var n=[],r="8pt 10pt 12pt 14pt 18pt 24pt 36pt",i=e.settings.fontsize_formats||r;return s(i.split(" "),function(e){var t=e,r=e,i=e.split("=");i.length>1&&(t=i[0],r=i[1]),n.push({text:t,value:r})}),{type:"listbox",text:"Font Sizes",tooltip:"Font Sizes",values:n,fixedWidth:!0,onPostRender:t(n,"fontsize"),onclick:function(t){t.control.settings.value&&e.execCommand("FontSize",!1,t.control.settings.value)}}}),e.addMenuItem("formats",{text:"Formats",menu:c})}var s=r.each;i.on("AddEditor",function(t){t.editor.rtl&&(e.rtl=!0),a(t.editor)}),e.translate=function(e){return i.translate(e)},t.tooltips=!o.iOS}),r(je,[Ee],function(e){return e.extend({recalc:function(e){var t=e.settings,n,r,i,o,a,s,l,c,u,d,f,p,h,m,g,v,y,b,C,x,w,_,E=[],N=[],k,S,T,R,A,B;t=e.settings,i=e.items().filter(":visible"),o=e.layoutRect(),r=t.columns||Math.ceil(Math.sqrt(i.length)),n=Math.ceil(i.length/r),y=t.spacingH||t.spacing||0,b=t.spacingV||t.spacing||0,C=t.alignH||t.align,x=t.alignV||t.align,g=e._paddingBox,A="reverseRows"in t?t.reverseRows:e.isRtl(),C&&"string"==typeof C&&(C=[C]),x&&"string"==typeof x&&(x=[x]);for(d=0;r>d;d++)E.push(0);for(f=0;n>f;f++)N.push(0);for(f=0;n>f;f++)for(d=0;r>d&&(u=i[f*r+d],u);d++)c=u.layoutRect(),k=c.minW,S=c.minH,E[d]=k>E[d]?k:E[d],N[f]=S>N[f]?S:N[f];for(T=o.innerW-g.left-g.right,w=0,d=0;r>d;d++)w+=E[d]+(d>0?y:0),T-=(d>0?y:0)+E[d];for(R=o.innerH-g.top-g.bottom,_=0,f=0;n>f;fLine truncated
|
||||
Reference in new issue
Block a user