Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitabb7029

Browse files
author
minjk-bl
committed
CHROME: add lib files(codemirror, jquery, require)
1 parent9fea57b commitabb7029

File tree

13 files changed

+13593
-0
lines changed

13 files changed

+13593
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
3+
4+
(function(mod){
5+
if(typeofexports=="object"&&typeofmodule=="object")// CommonJS
6+
mod(require("../../lib/codemirror"))
7+
elseif(typeofdefine=="function"&&define.amd)// AMD
8+
define(["../../lib/codemirror"],mod)
9+
else// Plain browser env
10+
mod(CodeMirror)
11+
})(function(CodeMirror){
12+
"use strict"
13+
14+
CodeMirror.defineOption("autoRefresh",false,function(cm,val){
15+
if(cm.state.autoRefresh){
16+
stopListening(cm,cm.state.autoRefresh)
17+
cm.state.autoRefresh=null
18+
}
19+
if(val&&cm.display.wrapper.offsetHeight==0)
20+
startListening(cm,cm.state.autoRefresh={delay:val.delay||250})
21+
})
22+
23+
functionstartListening(cm,state){
24+
functioncheck(){
25+
if(cm.display.wrapper.offsetHeight){
26+
stopListening(cm,state)
27+
if(cm.display.lastWrapHeight!=cm.display.wrapper.clientHeight)
28+
cm.refresh()
29+
}else{
30+
state.timeout=setTimeout(check,state.delay)
31+
}
32+
}
33+
state.timeout=setTimeout(check,state.delay)
34+
state.hurry=function(){
35+
clearTimeout(state.timeout)
36+
state.timeout=setTimeout(check,50)
37+
}
38+
CodeMirror.on(window,"mouseup",state.hurry)
39+
CodeMirror.on(window,"keyup",state.hurry)
40+
}
41+
42+
functionstopListening(_cm,state){
43+
clearTimeout(state.timeout)
44+
CodeMirror.off(window,"mouseup",state.hurry)
45+
CodeMirror.off(window,"keyup",state.hurry)
46+
}
47+
});
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
2+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
3+
4+
(function(mod){
5+
if(typeofexports=="object"&&typeofmodule=="object")// CommonJS
6+
mod(require("../../lib/codemirror"));
7+
elseif(typeofdefine=="function"&&define.amd)// AMD
8+
define(["../../lib/codemirror"],mod);
9+
else// Plain browser env
10+
mod(CodeMirror);
11+
})(function(CodeMirror){
12+
CodeMirror.defineOption("placeholder","",function(cm,val,old){
13+
varprev=old&&old!=CodeMirror.Init;
14+
if(val&&!prev){
15+
cm.on("blur",onBlur);
16+
cm.on("change",onChange);
17+
cm.on("swapDoc",onChange);
18+
CodeMirror.on(cm.getInputField(),"compositionupdate",cm.state.placeholderCompose=function(){onComposition(cm)})
19+
onChange(cm);
20+
}elseif(!val&&prev){
21+
cm.off("blur",onBlur);
22+
cm.off("change",onChange);
23+
cm.off("swapDoc",onChange);
24+
CodeMirror.off(cm.getInputField(),"compositionupdate",cm.state.placeholderCompose)
25+
clearPlaceholder(cm);
26+
varwrapper=cm.getWrapperElement();
27+
wrapper.className=wrapper.className.replace(" CodeMirror-empty","");
28+
}
29+
30+
if(val&&!cm.hasFocus())onBlur(cm);
31+
});
32+
33+
functionclearPlaceholder(cm){
34+
if(cm.state.placeholder){
35+
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
36+
cm.state.placeholder=null;
37+
}
38+
}
39+
functionsetPlaceholder(cm){
40+
clearPlaceholder(cm);
41+
varelt=cm.state.placeholder=document.createElement("pre");
42+
elt.style.cssText="height: 0; overflow: visible";
43+
elt.style.direction=cm.getOption("direction");
44+
elt.className="CodeMirror-placeholder CodeMirror-line-like";
45+
varplaceHolder=cm.getOption("placeholder")
46+
if(typeofplaceHolder=="string")placeHolder=document.createTextNode(placeHolder)
47+
elt.appendChild(placeHolder)
48+
cm.display.lineSpace.insertBefore(elt,cm.display.lineSpace.firstChild);
49+
}
50+
51+
functiononComposition(cm){
52+
setTimeout(function(){
53+
varempty=false
54+
if(cm.lineCount()==1){
55+
varinput=cm.getInputField()
56+
empty=input.nodeName=="TEXTAREA" ?!cm.getLine(0).length
57+
:!/[^\u200b]/.test(input.querySelector(".CodeMirror-line").textContent)
58+
}
59+
if(empty)setPlaceholder(cm)
60+
elseclearPlaceholder(cm)
61+
},20)
62+
}
63+
64+
functiononBlur(cm){
65+
if(isEmpty(cm))setPlaceholder(cm);
66+
}
67+
functiononChange(cm){
68+
varwrapper=cm.getWrapperElement(),empty=isEmpty(cm);
69+
wrapper.className=wrapper.className.replace(" CodeMirror-empty","")+(empty ?" CodeMirror-empty" :"");
70+
71+
if(empty)setPlaceholder(cm);
72+
elseclearPlaceholder(cm);
73+
}
74+
75+
functionisEmpty(cm){
76+
return(cm.lineCount()===1)&&(cm.getLine(0)==="");
77+
}
78+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp